English中文

GeometryInstance

new Cesium.GeometryInstance(options)

几何实例允许一 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:
名称 Name 类型 Type 默认值 Default 说明 Description
geometry Geometry | GeometryFactory 要实例化的几何图形。 The geometry to instance.
modelMatrix Matrix4 Matrix4.IDENTITY 可选 optional 模型矩阵,用于将几何体从模型变换到世界坐标。 The model matrix that transforms to transform the geometry from model to world coordinates.
id object 可选 optional 选取实例时要返回的用户定义对象 A user-defined object to return when the instance is picked with Scene#pick 或获取/设置每个实例的属性 or get/set per-instance attributes with Primitive#getGeometryInstanceAttributes.
attributes object 可选 optional 每个实例的属性,如下面示例中所示的显示或颜色属性。 Per-instance attributes like a show or color attribute shown in the example below.
示例: 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:
将几何体从模型转换为世界坐标的 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
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.