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();

//Create a new entity and assign a billboard scale.
const object1 = new Cesium.Entity({id:'object1'});
object1.billboard = new Cesium.BillboardGraphics();
object1.billboard.scale = new Cesium.ConstantProperty(2.0);
collection.add(object1);

//Create a second entity and reference the scale from the first one.
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);

//Create a third object, but use the fromString helper function.
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);

//You can refer to an entity with a # or . in id and property names by escaping them.
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

获取此属性的定义发生更改时引发的事件。 每当引用属性的定义发生更改时,定义都会更改。
获取一个值,该值指示此属性是否为 constant。
获取定义位置的参考帧。 仅当引用的属性是 PositionProperty 时,此属性才有效。

readonly resolvedProperty : Property|undefined

获取基础引用属性的已解析实例。
获取包含被引用实体的集合。
获取被引用的实体的 ID。

readonly targetPropertyNames : Object

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

Methods

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

在给定实体集合的情况下创建一个新实例,该实例将 用于解析它,以及指示目标实体 ID 和属性的字符串。 字符串的格式为 “objectId#foo.bar”,其中 # 将 id 与 属性路径和 .分隔子属性。 如果引用标识符或 或任何子属性包含 # . or \ 他们必须逃脱。
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:
修改后的结果参数或者,如果未提供 result 参数,则为新实例。

getValueInReferenceFrame(time, referenceFrame, result)Cartesian3

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