Creates a new Geometry3D
See Geometry3DOptions for available options
The geometry's local bounding box, used for picking and for a mesh's local bounds
Culling tests Geometry3D#boundsSphere instead.
The sphere around Geometry3D#bounds3D, which frustum culling tests
Computed once, at construction, so later edits to the positions or to bounds3D don't reach
culling.
Readonly AdvanceddynamicWhether the geometry stays out of the shared buffers; see Geometry3DOptions#dynamic
Readonly AdvancedhasWhether the morph targets bend the normals as well as the positions; see Geometry3DOptions#morphTargets
ReadonlymorphCount of morph targets; a mesh drawing the geometry takes one weight per target
StaticdefaultDefaults for every new Geometry3D
Each primitive, such as SphereGeometry, copies these into its own defaultOptions when
its module loads, so changing one of them here later doesn't reach the primitives; set theirs
instead.
Advanced
The attribute names and formats, ignoring strides, offsets and buffers
Geometries with the same key are packed into the same shared buffers. A geometry with
positions, normals and UVs has the key aNormal:snorm16x4|aPosition:float32x3|aUV:float32x2|.
The index data
Sets the index data
New indices, three per triangle for triangle-list
The normal data as stored, or undefined when the geometry has no normals
With Geometry3DOptions#quantizeNormals (the default) it's an Int16Array with four
values per vertex; on an interleaved geometry, the whole interleaved buffer as a Uint8Array.
To read normals as floats, three per vertex, use getAttributeData.
Sets the normal data; ignored when the geometry has no normals
New data, in the format the normals are stored in
The position data as stored
A Float32Array, unless the geometry was built from quantized positions; on an interleaved
geometry, the whole interleaved buffer as a Uint8Array. On a
dynamic geometry that isn't interleaved, write through it
and update its buffer. To read positions as floats, three per vertex, use
getAttributeData.
Sets the position data
New data, covering at least as many vertices as before
The tangent data as stored, or undefined when the geometry has no tangents
With Geometry3DOptions#quantizeTangents (the default) it is an Int16Array with four
values per vertex. Read tangents as floats, four per vertex, with getAttributeData.
Sets the tangent data; ignored when the geometry has no tangents
New data, in the format the tangents are stored in
The UV data as stored, or undefined when the geometry has no UVs
Read them as floats, two per vertex, with getAttributeData.
Sets the UV data; ignored when the geometry has no UVs
New data, covering every vertex
StaticEMPTYAdvanced
A shared geometry with no vertices, which a Mesh3D holds until it's given a geometry
A mesh on it draws nothing and compiles no shader. Assign it to a mesh's geometry to stop the
mesh drawing; to hide a mesh for a while, visible = false is cheaper to toggle. Only Mesh3D
takes it: a BatchedMesh3D slot in a pass needs a real geometry.
Its destroy does nothing, as with pixi's Texture.EMPTY, so destroying a mesh with
geometry: true can't free it from under other meshes.
Frees the geometry for good
Its own buffers are destroyed only with destroyBuffers, since other geometries may share
them. Calling it again does nothing.
OptionaldestroyBuffers: boolean
Whether to destroy the geometry's own buffers as well
Geometry3D.unload To hand back the GPU memory but keep the geometry usable.
Unloads this geometry from the GPU, keeping its CPU data so it can be rebuilt
A dynamic geometry frees its own GPU buffers; any other leaves its place in the shared buffers, which never shrink, for later geometries. The next render that draws it uploads it again, and the image comes out the same: a geometry out of the scene comes back when its mesh does, one still drawn on the next frame. A BatchedMesh3D slot that draws it also needs invalidate. Safe to call more than once, and does nothing after Geometry3D.destroy.
view.root.removeChild(mesh);
mesh.geometry.unload(); // adding the mesh again uploads it again
Geometry3D.destroy To free the geometry for good.
A mesh's vertex and index data: positions plus optional normals, UVs, tangents, colours and skinning data, in separate buffers or interleaved in one
Only positions are required. Inputs can be raw
Float32Arraydata or pixiAttributes, including the quantized integer formats glTF files use (KHR_mesh_quantization). getAttributeData reads any attribute back as floats, however it is stored.The first time a geometry is drawn it's copied into buffers shared with other geometries, so later edits to its data don't show. Build a new geometry for a new shape, call unload after an occasional edit, or make it Geometry3DOptions#dynamic if you rewrite it every frame.
Example
See
Geometry3DOptions For the constructor options