Class Geometry
Implements
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
new Geometry(
id: string,
scene?: Scene,
vertexData?: VertexData,
updatable?: boolean,
mesh?: Nullable<Mesh>,
totalVertices?: Nullable<number>,
): GeometryCreates a new geometry
Parameters
- id: string
defines the unique ID
Optionalscene: Scenedefines the hosting scene
OptionalvertexData: VertexDatadefines the VertexData used to get geometry data
- updatable: boolean = false
defines if geometry must be updatable (false by default)
- mesh: Nullable<Mesh> = null
defines the mesh that will be associated with the geometry
- totalVertices: Nullable<number> = null
defines the total number of vertices (optional)
Returns Geometry
- id: string
Properties
delay Loading File
Gets the file containing the data to load when running in delay load state
delay Load State
Gets the delay loading state of the geometry (none by default which means not delayed)
id
Gets or sets the ID of the geometry
on Geometry Updated
Callback called when the geometry is updated
unique Id
Gets or sets the unique ID of the geometry
use Bounding Info From Geometry
If set to true (false by default), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
Accessors
bounding Bias
-
Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
Returns Vector2
-
Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
Parameters
- value: Vector2
Returns void
do Not Serialize
-
get doNotSerialize(): boolean
Gets a value indicating that the geometry should not be serialized
Returns boolean
extend
meshes
-
Get the list of meshes using this geometry
Returns Mesh[]
Methods
apply To Mesh
-
Apply current geometry to a given mesh
Parameters
- mesh: Mesh
defines the mesh to apply geometry to
Returns void
- mesh: Mesh
clear Cached Data
-
Release any memory retained by the cached data on the Geometry.
Call this function to reduce memory footprint of the mesh. Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
Returns void
copy
-
Clone the current geometry into a new geometry
Parameters
- id: string
defines the unique ID of the new geometry
Returns Geometry
a new geometry object
- id: string
copy Vertices Data
-
copyVerticesData(
kind: string,
vertexData: { [kind: string]: Float32Array<ArrayBufferLike> },
): voidCopies the requested vertex data kind into the given vertex data map. Float data is constructed if the map doesn't have the data.
Parameters
- kind: string
defines the data kind (Position, normal, etc...)
- vertexData: { [kind: string]: Float32Array<ArrayBufferLike> }
defines the map that stores the resulting data
Returns void
- kind: string
dispose
-
Free all associated resources
Returns void
get Engine
get Index Buffer
get Indices
-
Gets the index buffer array
Parameters
OptionalcopyWhenShared: booleandefines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
OptionalforceCopy: booleandefines a boolean indicating that the returned array must be cloned upon returning it
Returns Nullable<IndicesArray>
the index buffer array
get Scene
get Total Indices
-
Return the total number of indices
Returns number
the total number of indices
get Total Vertices
-
Gets total number of vertices
Returns number
the total number of vertices
get Vertex Buffer
-
Gets a specific vertex buffer
Parameters
- kind: string
defines the data kind (Position, normal, etc...)
Returns Nullable<VertexBuffer>
a VertexBuffer
- kind: string
get Vertex Buffers
-
Returns all vertex buffers
Returns Nullable<{ [key: string]: VertexBuffer }>
an object holding all vertex buffers indexed by kind
get Vertices Data
-
getVerticesData(
kind: string,
copyWhenShared?: boolean,
forceCopy?: boolean,
): Nullable<FloatArray>Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
Parameters
- kind: string
defines the data kind (Position, normal, etc...)
OptionalcopyWhenShared: booleandefines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
OptionalforceCopy: booleandefines a boolean indicating that the returned array must be cloned upon returning it
Returns Nullable<FloatArray>
a float array containing vertex data
- kind: string
get Vertices Data Kinds
-
Gets a list of all attached data kinds (Position, normal, etc...)
Returns string[]
a list of string containing all kinds
is Disposed
-
Gets a value indicating if the geometry is disposed
Returns boolean
true if the geometry was disposed
is Ready
-
Defines if the geometry is ready to use
Returns boolean
true if the geometry is ready to be used
is Vertex Buffer Updatable
-
Returns a boolean defining if the vertex data for the requested
kindis updatableParameters
- kind: string
defines the data kind (Position, normal, etc...)
Returns boolean
true if the vertex buffer with the specified kind is updatable
- kind: string
is Vertices Data Present
-
Gets a boolean indicating if specific vertex buffer is present
Parameters
- kind: string
defines the data kind (Position, normal, etc...)
Returns boolean
true if data is present
- kind: string
load
-
Load the geometry if it was flagged as delay loaded
Parameters
- scene: Scene
defines the hosting scene
OptionalonLoaded: () => voiddefines a callback called when the geometry is loaded
Returns void
- scene: Scene
release For Mesh
-
Release the associated resources for a specific mesh
Parameters
- mesh: Mesh
defines the source mesh
OptionalshouldDispose: booleandefines if the geometry must be disposed if there is no more mesh pointing to it
Returns void
- mesh: Mesh
remove Vertices Data
-
Removes a specific vertex data
Parameters
- kind: string
defines the data kind (Position, normal, etc...)
Returns void
- kind: string
serialize
-
Serialize the current geometry info (and not the vertices data) into a JSON object
Returns any
a JSON representation of the current geometry data (without the vertices data)
serialize Vertice Data
-
Serialize all vertices data into a JSON object
Returns any
a JSON representation of the current geometry data
set All Vertices Data
-
Affects all geometry data in one call
Parameters
- vertexData: VertexData
defines the geometry data
Optionalupdatable: booleandefines if the geometry must be flagged as updatable (false as default)
Returns void
- vertexData: VertexData
set Index Buffer
-
setIndexBuffer(
indexBuffer: DataBuffer,
totalVertices: number,
totalIndices: number,
is32Bits?: Nullable<boolean>,
): voidSets the index buffer for this geometry.
Parameters
- indexBuffer: DataBuffer
Defines the index buffer to use for this geometry
- totalVertices: number
Defines the total number of vertices used by the buffer
- totalIndices: number
Defines the total number of indices in the index buffer
- is32Bits: Nullable<boolean> = null
Defines if the indices are 32 bits. If null (default), the value is guessed from the number of vertices
Returns void
- indexBuffer: DataBuffer
set Indices
-
setIndices(
indices: IndicesArray,
totalVertices?: Nullable<number>,
updatable?: boolean,
dontForceSubMeshRecreation?: boolean,
): voidCreates a new index buffer
Parameters
- indices: IndicesArray
defines the indices to store in the index buffer
- totalVertices: Nullable<number> = null
defines the total number of vertices (could be null)
- updatable: boolean = false
defines if the index buffer must be flagged as updatable (false by default)
- dontForceSubMeshRecreation: boolean = false
defines a boolean indicating that we don't want to force the recreation of sub-meshes if we don't have to (false by default)
Returns void
- indices: IndicesArray
set Vertices Buffer
-
setVerticesBuffer(
buffer: VertexBuffer,
totalVertices?: Nullable<number>,
disposeExistingBuffer?: boolean,
): voidAffect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
Parameters
- buffer: VertexBuffer
defines the vertex buffer to use
- totalVertices: Nullable<number> = null
defines the total number of vertices for position kind (could be null)
- disposeExistingBuffer: boolean = true
disposes the existing buffer, if any (default: true)
Returns void
- buffer: VertexBuffer
set Vertices Data
-
Set specific vertex data
Parameters
- kind: string
defines the data kind (Position, normal, etc...)
- data: FloatArray
defines the vertex data to use
- updatable: boolean = false
defines if the vertex must be flagged as updatable (false as default)
Optionalstride: numberdefines the stride to use (0 by default). This value is deduced from the kind value if not specified
Returns void
- kind: string
to Left Handed
-
Invert the geometry to move from a right handed system to a left handed one.
Returns void
update Indices
-
Update index buffer
Parameters
- indices: IndicesArray
defines the indices to store in the index buffer
Optionaloffset: numberdefines the offset in the target buffer where to store the data
- gpuMemoryOnly: boolean = false
defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
Returns void
- indices: IndicesArray
update Vertices Data
-
Update a specific vertex buffer This function will create a new buffer if the current one is not updatable
Parameters
- kind: string
defines the data kind (Position, normal, etc...)
- data: FloatArray
defines the data to use
- updateExtends: boolean = false
defines if the geometry extends must be recomputed (false by default)
Returns void
- kind: string
update Vertices Data Directly
-
updateVerticesDataDirectly(
kind: string,
data: DataArray,
offset: number,
useBytes?: boolean,
): voidUpdate a specific vertex buffer This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array It will do nothing if the buffer is not updatable
Parameters
- kind: string
defines the data kind (Position, normal, etc...)
- data: DataArray
defines the data to use
- offset: number
defines the offset in the target buffer where to store the data
- useBytes: boolean = false
set to true if the offset is in bytes
Returns void
- kind: string
StaticCreate Geometry For Mesh
StaticExtract From Mesh
StaticParse
StaticRandom Id
-
You should now use Tools.RandomId(), this method is still here for legacy reasons. Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523 Be aware Math.random() could cause collisions, but: "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
Returns string
a string containing a new GUID
Class used to store geometry data (vertex buffers + index buffer)