几何体实例化允许一个
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.
var geometry = SuperMap3D.BoxGeometry.fromDimensions({
vertexFormat : SuperMap3D.VertexFormat.POSITION_AND_NORMAL,
dimensions : new SuperMap3D.Cartesian3(1000000.0, 1000000.0, 500000.0)
});
var instanceBottom = new SuperMap3D.GeometryInstance({
geometry : geometry,
modelMatrix : SuperMap3D.Matrix4.multiplyByTranslation(SuperMap3D.Transforms.eastNorthUpToFixedFrame(
SuperMap3D.Cartesian3.fromDegrees(-75.59777, 40.03883)), new SuperMap3D.Cartesian3(0.0, 0.0, 1000000.0), new SuperMap3D.Matrix4()),
attributes : {
color : SuperMap3D.ColorGeometryInstanceAttribute.fromColor(SuperMap3D.Color.AQUA)
},
id : 'bottom'
});
var instanceTop = new SuperMap3D.GeometryInstance({
geometry : geometry,
modelMatrix : SuperMap3D.Matrix4.multiplyByTranslation(SuperMap3D.Transforms.eastNorthUpToFixedFrame(
SuperMap3D.Cartesian3.fromDegrees(-75.59777, 40.03883)), new SuperMap3D.Cartesian3(0.0, 0.0, 3000000.0), new SuperMap3D.Matrix4()),
attributes : {
color : SuperMap3D.ColorGeometryInstanceAttribute.fromColor(SuperMap3D.Color.AQUA)
},
id : 'top'
});
See:
Members
-
每个顶点的属性(如
ColorGeometryInstanceAttribute
或ShowGeometryInstanceAttribute
.Geometry
属性)各不相同;这些属性在整个实例中是恒定的。-
Default Value:
undefined
-
geometry : Geometry
-
被实例化的几何体。
-
Default Value:
undefined
-
用户自定义对象,在选中实例时返回,或用于获取/设置每个实例的属性。
-
Default Value:
undefined
See:
-
modelMatrix : Matrix4
-
将几何体从模型坐标转换为地理坐标的 4x4 变换矩阵。 当变换矩阵为同一矩阵时,几何体将以地理坐标绘制,即地球的 WGS84 坐标。 本地参照系可以通过提供不同的变换矩阵来使用,如
Transforms.eastNorthUpToFixedFrame
返回的矩阵。-
Default Value:
Matrix4.IDENTITY