ReferenceProperty

new Cesium.ReferenceProperty(targetCollection, targetId, targetPropertyNames)

一个 Property,透明地链接到提供的对象上的另一个属性。
Name Type Description
targetCollection EntityCollection 将用于解析引用的实体集合。
targetId string 被引用实体的id。
targetPropertyNames Array.<string> 我们将使用的目标实体上的属性名称。
Example:
const collection = new Cesium.EntityCollection();

//创建一个新实体并分配广告牌缩放比例。
const object1 = new Cesium.Entity({id:'object1'});
object1.billboard = new Cesium.BillboardGraphics();
object1.billboard.scale = new Cesium.ConstantProperty(2.0);
collection.add(object1);

//创建第二个实体并引用第一个实体的缩放比例。
const object2 = new Cesium.Entity({id:'object2'});
object2.model = new Cesium.ModelGraphics();
object2.model.scale = new Cesium.ReferenceProperty(collection, 'object1', ['billboard', 'scale']);
collection.add(object2);

//创建第三个对象,但使用fromString辅助函数。
const object3 = new Cesium.Entity({id:'object3'});
object3.billboard = new Cesium.BillboardGraphics();
object3.billboard.scale = Cesium.ReferenceProperty.fromString(collection, 'object1#billboard.scale');
collection.add(object3);

//你可以通过转义来引用id和属性名称中包含#或.的实体。
const object4 = new Cesium.Entity({id:'#object.4'});
object4.billboard = new Cesium.BillboardGraphics();
object4.billboard.scale = new Cesium.ConstantProperty(2.0);
collection.add(object4);

const object5 = new Cesium.Entity({id:'object5'});
object5.billboard = new Cesium.BillboardGraphics();
object5.billboard.scale = Cesium.ReferenceProperty.fromString(collection, '\\#object\\.4#billboard.scale');
collection.add(object5);

Members

获取当此属性的定义更改时引发的事件。 只要被引用属性的定义发生更改,定义就会更改。
获取一个值,指示此属性是否为常量。
获取定义位置的参考系。 仅当被引用的属性是 PositionProperty 时,此属性才有效。

readonly resolvedProperty : Property|undefined

获取底层被引用属性的已解析实例。
获取包含被引用实体的集合。
获取被引用实体的id。

readonly targetPropertyNames : Object

获取用于检索被引用属性的属性名称数组。

Methods

static Cesium.ReferenceProperty.fromString(targetCollection, referenceString)ReferenceProperty

创建新实例,给定将用于解析它的实体集合和指示目标实体id及属性的字符串。 字符串格式为 "objectId#foo.bar",其中 # 分隔id和属性路径,. 分隔子属性。如果引用标识符或任何子属性包含 # . 或 \,则必须对其进行转义。
Name Type Description
targetCollection EntityCollection
referenceString string
Returns:
ReferenceProperty的新实例。
Throws:
将此属性与提供的属性进行比较,如果相等则返回 true,否则返回 false
Name Type Description
other Property optional 另一个属性。
Returns:
如果左右相等则返回 true,否则返回 false
获取指定时间的 Material 类型。 仅当被引用的属性是 MaterialProperty 时,此方法才有效。
Name Type Description
time JulianDate 用于检索类型的时间。
Returns:
材质类型。

getValue(time, result)object

获取属性在指定时间的值。
Name Type Default Description
time JulianDate JulianDate.now() optional 用于检索值的时间。如果省略,则使用当前系统时间。
result object optional 用于存储值的对象,如果省略,则创建并返回新实例。
Returns:
修改后的结果参数,如果未提供结果参数,则返回新实例。

getValueInReferenceFrame(time, referenceFrame, result)Cartesian3

获取属性在指定时间和指定参考系中的值。 仅当被引用的属性是 PositionProperty 时,此方法才有效。
Name Type Description
time JulianDate 用于检索值的时间。
referenceFrame ReferenceFrame 结果的所需参考系。
result Cartesian3 optional 用于存储值的对象,如果省略,则创建并返回新实例。
Returns:
修改后的结果参数,如果未提供结果参数,则返回新实例。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.