new Geometry()
3D geometry class.
| Name | Type | Default | Description |
|---|---|---|---|
options.attributes |
GeometryAttributes |
optional
Attributes that constitute the vertices of the geometry. |
|
options.primitiveType |
PrimitiveType | PrimitiveType.TRIANGLES |
optional
The type of primitive of the geometry. |
options.indices |
Uint16Array | Uint32Array |
optional
Optional index data used to determine primitives in the geometry. |
|
options.boundingSphere |
BoundingSphere |
optional
Optional bounding sphere that fully encloses the geometry. |
- See:
-
- PolygonGeometry
- RectangleGeometry
- EllipseGeometry
- CircleGeometry
- WallGeometry
- SimplePolylineGeometry
- BoxGeometry
- EllipsoidGeometry
Example
// Create geometry with a position attribute and indexed lines.
var positions = new Float64Array([
0.0, 0.0, 0.0,
7500000.0, 0.0, 0.0,
0.0, 7500000.0, 0.0
]);
var geometry = new SuperMap3D.Geometry({
attributes : {
position : new SuperMap3D.GeometryAttribute({
componentDatatype : SuperMap3D.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
})
},
indices : new Uint16Array([0, 1, 1, 2, 2, 0]),
primitiveType : SuperMap3D.PrimitiveType.LINES,
boundingSphere : SuperMap3D.BoundingSphere.fromVertices(positions)
});
Members
-
attributesGeometryAttributes
-
Attributes that constitute the vertices of the geometry. Each attribute in this object corresponds to a GeometryAttribute containing the attribute data. Attributes are always stored non-interleaved in the geometry. Reserved attribute names have well-known semantics. The following attributes are created by Geometry (depending on the VertexFormat provided).
- position - 3D vertex position. 64-bit floating point (for precision). Three components per attribute. See VertexFormat#position.
- normal - (normalized), commonly used for lighting. 32-bit floating point. Three components per attribute. See VertexFormat#normal.
- st - 2D texture coordinates. 32-bit floating point. Two components per attribute. See VertexFormat#st.
- bitangent - (normalized), used for tangent space effects such as bump mapping. 32-bit floating point. Three components per attribute. See VertexFormat#bitangent.
- tangent - (normalized), used for tangent space effects such as bump mapping. 32-bit floating point. Three components per attribute. See VertexFormat#tangent.
PrimitiveorGeometryPipelinefunctions to prepare the geometry for rendering.- position3DHigh - The high 32 bits of the encoded 64-bit position computed by GeometryPipeline.encodeAttribute. 32-bit floating point. Four components per attribute.
- position3DLow - The low 32 bits of the encoded 64-bit position computed by GeometryPipeline.encodeAttribute. 32-bit floating point. Four components per attribute.
- position3DHigh - The high 32 bits of the encoded 64-bit 2D (Columbus view) position computed by GeometryPipeline.encodeAttribute. 32-bit floating point. Four components per attribute.
- position2DLow - The low 32 bits of the encoded 64-bit 2D (Columbus view) position computed by GeometryPipeline.encodeAttribute. 32-bit floating point. Four components per attribute.
- color - RGBA color (normalized) typically from GeometryInstance#color. 32-bit floating point. Four components per attribute.
- pickColor - RGBA color used for picking. 32-bit floating point. Four components per attribute.
- Default Value: undefined
- See:
-
- GeometryAttribute
- VertexFormat
Example
geometry.attributes.position = new SuperMap3D.GeometryAttribute({
componentDatatype : SuperMap3D.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : new Float32Array(0)
});
boundingSphereBoundingSphere
Optional bounding sphere that fully encloses the geometry. Typically used for culling.
- Default Value: undefined
indicesArray
Optional index data - together with Geometry#primitiveType - determines the primitives in the geometry.
- Default Value: undefined
primitiveTypePrimitiveType
The type of primitive in the geometry. This is usually PrimitiveType.TRIANGLES, but can vary depending on the specific geometry.
- Default Value: undefined
Methods
-
static computeNumberOfVertices(geometry){Number}
-
Computes the number of vertices in a geometry. The runtime is linear with respect to the number of attributes, not the number of vertices.
Name Type Description geometryGeometry Geometry.
Returns:
Type Description Number The number of vertices in the geometry. Example
var numVertices = SuperMap3D.Geometry.computeNumberOfVertices(geometry);