Class: GeometryBase
Defined in: src/core/geometry/GeometryBase.ts:40
Base class for all geometries, holding vertex/index attribute data, GPU buffers, bounds and the logic to generate them for rendering.
Extended by
ExtrudeGeometryBoxGeometryCylinderGeometryPlaneGeometrySphereGeometryStripeGeometryTorusGeometryTrailGeometryTriGeometry
Constructors
Constructor
new GeometryBase():
GeometryBase
Defined in: src/core/geometry/GeometryBase.ts:71
Returns
GeometryBase
Properties
instanceID
instanceID:
string
Defined in: src/core/geometry/GeometryBase.ts:43
Unique identifier of this geometry instance.
name
name:
string
Defined in: src/core/geometry/GeometryBase.ts:45
Human-readable name of this geometry.
subGeometries
subGeometries:
SubGeometry[] =[]
Defined in: src/core/geometry/GeometryBase.ts:47
Sub-geometries with their per-LOD draw descriptors.
morphTargetsRelative
morphTargetsRelative:
boolean
Defined in: src/core/geometry/GeometryBase.ts:49
Whether morph targets are stored as relative offsets.
morphTargetDictionary
morphTargetDictionary:
object
Defined in: src/core/geometry/GeometryBase.ts:51
Maps morph-target names to their attribute indices.
Index Signature
[blenderName: string]: number
skinNames
skinNames:
string[]
Defined in: src/core/geometry/GeometryBase.ts:53
Names of the skin joints used by this geometry.
bindPose
bindPose:
Matrix4[]
Defined in: src/core/geometry/GeometryBase.ts:55
Inverse bind-pose matrices for skinning.
blendShapeData
blendShapeData:
BlendShapeData
Defined in: src/core/geometry/GeometryBase.ts:57
Blend-shape (morph target) data for this geometry.
vertexDim
vertexDim:
number
Defined in: src/core/geometry/GeometryBase.ts:59
Number of floats per vertex for interleaved buffers.
vertexCount
vertexCount:
number=0
Defined in: src/core/geometry/GeometryBase.ts:61
Number of vertices in this geometry.
Accessors
indicesBuffer
Get Signature
get indicesBuffer():
GeometryIndicesBuffer
Defined in: src/core/geometry/GeometryBase.ts:79
Get the GPU index buffer of this geometry.
Returns
vertexBuffer
Get Signature
get vertexBuffer():
GeometryVertexBuffer
Defined in: src/core/geometry/GeometryBase.ts:84
Get the GPU vertex buffer of this geometry.
Returns
vertexAttributes
Get Signature
get vertexAttributes():
string[]
Defined in: src/core/geometry/GeometryBase.ts:89
Get the list of vertex attribute names present on this geometry.
Returns
string[]
vertexAttributeMap
Get Signature
get vertexAttributeMap():
Map<string,VertexAttributeData>
Defined in: src/core/geometry/GeometryBase.ts:94
Get the map from attribute name to its vertex attribute data.
Returns
Map<string, VertexAttributeData>
geometryType
Get Signature
get geometryType():
GeometryVertexType
Defined in: src/core/geometry/GeometryBase.ts:99
Get the vertex layout type of this geometry.
Returns
Set Signature
set geometryType(
value):void
Defined in: src/core/geometry/GeometryBase.ts:103
Set the vertex layout type of this geometry.
Parameters
value
Returns
void
bounds
Get Signature
get bounds():
BoundingBox
Defined in: src/core/geometry/GeometryBase.ts:108
Get the bounding box of this geometry, computing it from positions on first access.
Returns
BoundingBox
Set Signature
set bounds(
value):void
Defined in: src/core/geometry/GeometryBase.ts:152
Set the bounding box of this geometry.
Parameters
value
BoundingBox
Returns
void
Methods
addSubGeometry()
addSubGeometry(...
lodLevels):SubGeometry
Defined in: src/core/geometry/GeometryBase.ts:161
add subGeometry from lod level
Parameters
lodLevels
...LODDescriptor[]
Returns
See
LODDescriptor
generate()
generate(
shaderReflection):void
Defined in: src/core/geometry/GeometryBase.ts:194
Build the GPU vertex buffer + buffer-layout array from this geometry's attribute data, driven by the consuming pass's ShaderReflection. The layout array is indexed by shader slot (attribute.location), so the LAYOUT contents depend on which attributes the shader actually declares.
Originally this was gated purely on _onChange — i.e. ran once after the geometry's attribute data was set. That broke multi-pass materials: when a single geometry is consumed by a color pass that declares N attributes (say position / normal / uv) AND a depth pass that declares N+1 (adding TEXCOORD_1 at slot 3 via VertexAttributes #include), the color pass ran first, populated slots 0..N-1, and cleared _onChange. The depth pass's generate call was then a no-op, so the pipeline built with vertexBufferLayouts was missing slot N — WebGPU rejects it with "Vertex attribute slot X used in shader is not present in VertexState".
The fix: rebuild also when the incoming reflection requires a slot the current layout array doesn't yet have. The data is already in _attributeMap; createVertexBuffer will pick up the missing slot. We keep the _onChange short-circuit for the normal "shader requirements unchanged" case so dynamic geometry updates don't pay a per-frame createVertexBuffer cost.
Parameters
shaderReflection
ShaderReflection
Returns
void
setIndices()
setIndices(
data):void
Defined in: src/core/geometry/GeometryBase.ts:214
Set the index data of this geometry, creating its index buffer.
Parameters
data
the index buffer data
Returns
void
setVertexs()
setVertexs(
data):void
Defined in: src/core/geometry/GeometryBase.ts:230
Set the position (vertex) data of this geometry.
Parameters
data
the position buffer data
Returns
void
setAttribute()
setAttribute(
attribute,data):void
Defined in: src/core/geometry/GeometryBase.ts:244
Set the data of a named vertex attribute (or indices/position).
Parameters
attribute
string
the attribute name
data
the attribute buffer data
Returns
void
getAttribute()
getAttribute(
attribute):VertexAttributeData
Defined in: src/core/geometry/GeometryBase.ts:263
Get the data of a named vertex attribute.
Parameters
attribute
string
the attribute name
Returns
hasAttribute()
hasAttribute(
attribute):boolean
Defined in: src/core/geometry/GeometryBase.ts:271
Whether this geometry has the given named attribute.
Parameters
attribute
string
the attribute name
Returns
boolean
genWireframe()
genWireframe():
Vector3[]
Defined in: src/core/geometry/GeometryBase.ts:279
Generate (and cache) the line list describing this geometry's wireframe.
Returns
Vector3[]
the wireframe line vertices, or null if not available
compute()
compute():
void
Defined in: src/core/geometry/GeometryBase.ts:335
Run the compute step on this geometry's index and vertex buffers.
Returns
void
computeNormals()
computeNormals():
this
Defined in: src/core/geometry/GeometryBase.ts:357
Compute per-vertex normals from the position and index data and upload them.
Returns
this
this geometry for chaining
isPrimitive()
isPrimitive():
boolean
Defined in: src/core/geometry/GeometryBase.ts:403
Whether this geometry is a built-in primitive.
Returns
boolean
destroy()
destroy(
force?):void
Defined in: src/core/geometry/GeometryBase.ts:411
Release the buffers and data held by this geometry.
Parameters
force?
boolean
whether to force-destroy
Returns
void

