Appearance
KBE3D / KBCore / Cesium / Geometry
类: Geometry
A geometry representation with attributes forming vertices and optional index data defining primitives. Geometries and an Appearance, which describes the shading, can be assigned to a Primitive for visualization. A <code>Primitive</code> can be created from many heterogeneous - in many cases - geometries for performance. <p> Geometries can be transformed and optimized using functions in GeometryPipeline. </p>
示例
ts
// Create geometry with a position attribute and indexed lines.
const positions = new Float64Array([
0.0, 0.0, 0.0,
7500000.0, 0.0, 0.0,
0.0, 7500000.0, 0.0
]);
const geometry = new Cesium.Geometry({
attributes : {
position : new Cesium.GeometryAttribute({
componentDatatype : Cesium.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
})
},
indices : new Uint16Array([0, 1, 1, 2, 2, 0]),
primitiveType : Cesium.PrimitiveType.LINES,
boundingSphere : Cesium.BoundingSphere.fromVertices(positions)
});参数
Object with the following properties:
参数
Attributes, which make up the geometry's vertices.
参数
The type of primitives in the geometry.
参数
Optional index data that determines the primitives in the geometry.
参数
An optional bounding sphere that fully enclosed the geometry.
属性
attributes
attributes:
GeometryAttributes
Attributes, which make up the geometry's vertices. Each property in this object corresponds to a GeometryAttribute containing the attribute's data. <p> Attributes are always stored non-interleaved in a Geometry. </p> <p> There are reserved attribute names with well-known semantics. The following attributes are created by a Geometry (depending on the provided VertexFormat. <ul> <li><code>position</code> - 3D vertex position. 64-bit floating-point (for precision). 3 components per attribute. See VertexFormat#position.</li> <li><code>normal</code> - Normal (normalized), commonly used for lighting. 32-bit floating-point. 3 components per attribute. See VertexFormat#normal.</li> <li><code>st</code> - 2D texture coordinate. 32-bit floating-point. 2 components per attribute. See VertexFormat#st.</li> <li><code>bitangent</code> - Bitangent (normalized), used for tangent-space effects like bump mapping. 32-bit floating-point. 3 components per attribute. See VertexFormat#bitangent.</li> <li><code>tangent</code> - Tangent (normalized), used for tangent-space effects like bump mapping. 32-bit floating-point. 3 components per attribute. See VertexFormat#tangent.</li> </ul> </p> <p> The following attribute names are generally not created by a Geometry, but are added to a Geometry by a Primitive or GeometryPipeline functions to prepare the geometry for rendering. <ul> <li><code>position3DHigh</code> - High 32 bits for encoded 64-bit position computed with GeometryPipeline.encodeAttribute. 32-bit floating-point. 4 components per attribute.</li> <li><code>position3DLow</code> - Low 32 bits for encoded 64-bit position computed with GeometryPipeline.encodeAttribute. 32-bit floating-point. 4 components per attribute.</li> <li><code>position2DHigh</code> - High 32 bits for encoded 64-bit 2D (Columbus view) position computed with GeometryPipeline.encodeAttribute. 32-bit floating-point. 4 components per attribute.</li> <li><code>position2DLow</code> - Low 32 bits for encoded 64-bit 2D (Columbus view) position computed with GeometryPipeline.encodeAttribute. 32-bit floating-point. 4 components per attribute.</li> <li><code>color</code> - RGBA color (normalized) usually from GeometryInstance#color. 32-bit floating-point. 4 components per attribute.</li> <li><code>pickColor</code> - RGBA color used for picking. 32-bit floating-point. 4 components per attribute.</li> </ul> </p>
示例
ts
geometry.attributes.position = new Cesium.GeometryAttribute({
componentDatatype : Cesium.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : new Float32Array(0)
});indices
indices:
any[] |undefined
Optional index data that - along with Geometry#primitiveType - determines the primitives in the geometry.
primitiveType
primitiveType:
PrimitiveType|undefined
The type of primitives in the geometry. This is most often PrimitiveType.TRIANGLES, but can varying based on the specific geometry.
boundingSphere
boundingSphere:
BoundingSphere|undefined
An optional bounding sphere that fully encloses the geometry. This is commonly used for culling.
方法
computeNumberOfVertices()
staticcomputeNumberOfVertices(geometry:Geometry):number
Computes the number of vertices in a geometry. The runtime is linear with respect to the number of attributes in a vertex, not the number of vertices.
参数
geometry
Geometry
The geometry.
返回
number
The number of vertices in the geometry.
示例
ts
const numVertices = Cesium.Geometry.computeNumberOfVertices(geometry);构造函数
构造函数
new Geometry(
options: {attributes:GeometryAttributes;primitiveType?:PrimitiveType;indices?:Uint16Array<ArrayBufferLike> |Uint32Array<ArrayBufferLike>;boundingSphere?:BoundingSphere; }):Geometry
参数
options
attributes
primitiveType?
indices?
Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>
boundingSphere?
返回
Geometry
