Skip to main content
Version: 0.11.0

UeGeometry

A geometry class representing a 3D geometry, optimized for GPU rendering.
Manages vertex data, index buffers, and provides methods to build, freeze, and dispose the vertex buffer.
Includes support for bounding volumes (bounding box and bounding sphere).

Constructor​

new UeGeometry(data = {})

Data parameters​

KeyTypeDefaultDescription
positionarrayundefinedArray of vertex positions [x,y,z, x,y,z, ...]
normalarrayundefinedArray of vertex normals [nx,ny,nz, ...]
uvarrayundefinedArray of texture coordinates [u,v, ...]
tangentarrayundefinedArray of vertex tangents [tx,ty,tz,tw, ...] (float4)
colorarrayundefinedArray of vertex colors [col, alpha, col, alpha, ...]
indexarrayundefinedOptional index buffer for reusing verts
formatVertexFormatglobal.UE_VFORMAT_PNUTCVertex layout format
canFreezebooleantrueWhether to freeze the vertex buffer after the build
boundingBoxUeBox3Axis-aligned bounding box
boundingSphereUeSphereBounding sphere

Properties​

PropertyTypeDescription
isGeometrybooleanFlag indicating this is a geometry
typestringType identifier "Geometry"
uuidstringUnique identifier
namestringOptional name
positionArrayVertex position data array
normalArrayVertex normal data array
uvArrayVertex UV data array
tangentArrayVertex tangent data array (float4)
colorArrayVertex color data array
indexArray or undefinedOptional index array
formatObjectVertex format descriptor
vbobjectVertex buffer handle
canFreezebooleanIf true, allows freezing the vertex buffer for optimization
boundingBoxUeBox3Axis-aligned bounding box
boundingSphereUeSphereBounding sphere

Methods​

MethodReturnsDescription
build()selfBuilds the vertex buffer from the current attributes and vertex format
freeze()selfFreezes the vertex buffer to optimize usage
dispose()selfDeletes the vertex buffer and releases GPU resources
computeBoundingBox()selfComputes the bounding box from the current vertex positions
computeBoundingSphere()selfComputes the bounding sphere from the current vertex positions
applyMatrix(matrix)selfApplies the matrix transform to the geometry vertices
merge(geometries)UeGeometryReturns a new geometry by merging an array of geometries. They must share the same format.
toJSON()structReturns an object representing this entity's properties.
fromJSON(data)selfLoads geometry properties from a JSON object.
export(fname)selfExports only the vertex buffer to a file.
import(fname)selfLoads the vertex buffer data from a previously exported file.

Notes​

The geometric data is stored in separate flat arrays (e.g., position, normal, uv).

If index is provided, it must be an array of indices pointing into these attribute arrays.

You can define custom vertex attributes using .format.custom(name, type) and provide the data as an array directly on the geometry instance using the custom attribute name.