GeometryInstance

new Cesium.GeometryInstance(options)

Geometry实例允许一个几何体对象位于多个位置 位置不同,颜色独特。例如,一个BoxGeometry可以 被实例化几次,每次都用不同的modelMatrix来改变 它的位置、旋转和比例。
Name Type Description
options Object 具有以下属性的对象:
Name Type Default Description
geometry Geometry | GeometryFactory 要引用的几何体。
modelMatrix Matrix4 Matrix4.IDENTITY optional 将几何体从模型转换为世界坐标的模型矩阵。
id Object optional 使用Scene#pick选择实例或使用Primitive#getGeometryInstanceAttributes获取/设置每个实例属性时要返回的用户定义对象。
attributes Object optional 每实例属性,如下面示例中显示的show或color属性。
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.
var geometry = Cesium.BoxGeometry.fromDimensions({
  vertexFormat : Cesium.VertexFormat.POSITION_AND_NORMAL,
  dimensions : new Cesium.Cartesian3(1000000.0, 1000000.0, 500000.0)
});
var 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'
});
var 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

attributes : Object

每实例属性,如ColorGeometryInstanceAttributeShowGeometryInstanceAttributeGeometry每个顶点都有不同的属性;这些属性对于整个实例都是常量。
Default Value: undefined
正在实例化的几何体。
Default Value: undefined
拾取实例或用于获取/设置每个实例属性时返回的用户定义对象。
Default Value: undefined
See:
将几何体从模型转换为世界坐标的4x4变换矩阵。 当这是单位矩阵时,几何图形是在世界坐标系中绘制的,即地球的WGS84坐标系。 局部参考帧可以通过提供不同的转换矩阵来使用,就像返回的那样 通过Transforms.eastNorthUpToFixedFrame
Default Value: Matrix4.IDENTITY