Skip to content

KBE3D / KBCore / Cesium / GeometryInstance

类: GeometryInstance

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 <code>modelMatrix</code> to change its position, rotation, and scale.

示例

ts
// 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'
});

参数

Object with the following properties:

参数

The geometry to instance.

参数

The model matrix that transforms to transform the geometry from model to world coordinates.

参数

A user-defined object to return when the instance is picked with Scene#pick or get/set per-instance attributes with Primitive#getGeometryInstanceAttributes.

参数

Per-instance attributes like a show or color attribute shown in the example below.

属性

geometry

geometry: Geometry

The geometry being instanced.


modelMatrix

modelMatrix: Matrix4

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.


id

id: any

User-defined object returned when the instance is picked or used to get/set per-instance attributes.


attributes

attributes: any

Per-instance attributes like ColorGeometryInstanceAttribute or ShowGeometryInstanceAttribute. Geometry attributes varying per vertex; these attributes are constant for the entire instance.

构造函数

构造函数

new GeometryInstance(options: { geometry: Geometry | GeometryFactory; modelMatrix?: Matrix4; id?: any; attributes?: any; }): GeometryInstance

参数

options
geometry

Geometry | GeometryFactory

modelMatrix?

Matrix4

id?

any

attributes?

any

返回

GeometryInstance

KBE3D @3.0.0 Copyright © 2024-present KBE3D