几何实例允许一 Geometry instancing allows one
Geometry 对象位于几个不同的位置并具有独特的颜色。例如,一个 object to be positions in several different locations and colored uniquely. For example, one BoxGeometry 可以多次实例化,每次都有不同的 can be instanced several times, each with a different modelMatrix 更改其位置、旋转和比例。 to change its position, rotation, and scale.
| 名称 Name | 类型 Type | 说明 Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下属性的对象: Object with the following properties:
|
示例: 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
每个实例的属性,例如 Per-instance attributes like
ColorGeometryInstanceAttribute or ShowGeometryInstanceAttribute.
Geometry 每个顶点的属性各不相同;这些属性对于整个实例来说是不变的。 attributes varying per vertex; these attributes are constant for the entire instance.
-
默认值: Default Value:
{}
正在实例化的几何体。 The geometry being instanced.
选择实例时返回的用户定义对象或用于获取/设置每个实例的属性。 User-defined object returned when the instance is picked or used to get/set per-instance attributes.
-
默认值: Default Value:
undefined
另见: See:
modelMatrix : Matrix4
将几何体从模型转换为世界坐标的 4x4 转换矩阵。当这是单位矩阵时,几何图形是在世界坐标(即地球的 WGS84 坐标)中绘制的。可以通过提供不同的变换矩阵来使用局部参考系,例如返回的矩阵 The 4x4 transformation matrix that transforms the geometry from model to world coordinates. When this is the identity matrix, the geometry is drawn in world coordinates, i.e., Earth's WGS84 coordinates. Local reference frames can be used by providing a different transformation matrix, like that returned by
Transforms.eastNorthUpToFixedFrame.
-
默认值: Default Value:
Matrix4.IDENTITY
