几何实例化允许一个
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
