几何体实例化允许一个
Geometry 对象在多个
不同位置上实例化并具有独特颜色。例如,一个 BoxGeometry 可以
被实例化多次,每次使用不同的 modelMatrix 来改变
其位置、旋转和缩放。
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下属性的对象:
|
Example:
// Create geometry for a box, and two instances that refer to it.
// One instance positions the box on the bottom and colored aqua.
// The other instance positions the box on the top and color white.
const geometry = Cesium.BoxGeometry.fromDimensions({
vertexFormat : Cesium.VertexFormat.POSITION_AND_NORMAL,
dimensions : new Cesium.Cartesian3(1000000.0, 1000000.0, 500000.0)
});
const instanceBottom = new Cesium.GeometryInstance({
geometry : geometry,
modelMatrix : Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883)), new Cesium.Cartesian3(0.0, 0.0, 1000000.0), new Cesium.Matrix4()),
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.AQUA)
},
id : 'bottom'
});
const instanceTop = new Cesium.GeometryInstance({
geometry : geometry,
modelMatrix : Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883)), new Cesium.Cartesian3(0.0, 0.0, 3000000.0), new Cesium.Matrix4()),
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.AQUA)
},
id : 'top'
});
See:
Members
每个实例的属性,例如
ColorGeometryInstanceAttribute 或 ShowGeometryInstanceAttribute。
Geometry 总是每个顶点变化的属性;这些属性对整个实例是常量。
-
Default Value:
{}
正在实例化的几何体。
用户定义的对象,在实例被选择时返回或用于获取/设置每个实例的属性。
-
Default Value:
undefined
See:
modelMatrix : Matrix4
将几何体从模型坐标转换到世界坐标的 4x4 变换矩阵。
当这是单位矩阵时,几何体在世界坐标中绘制,即地球的 WGS84 坐标。
通过提供不同的变换矩阵,例如
Transforms.eastNorthUpToFixedFrame 返回的矩阵,可以使用局部参考坐标系。
-
Default Value:
Matrix4.IDENTITY
