TriMesh

TriMesh class

A TriMesh contains raw data that can be used by GPU directly. This class is a utility to help to construct a mesh that only contains per-vertex data.

Methods

constructor

NameDescription
constructor(name, declaration)Initialize an instance of TriMesh

Parameters:

NameTypeDescription
nameStringThe name of this TriMesh
declarationVertexDeclarationThe vertex’s declaration

Result:


getVertexDeclaration

NameDescription
getVertexDeclaration()The vertex layout of the TriMesh.

Result:


getVerticesCount

NameDescription
getVerticesCount()The count of vertices in this TriMesh

Result:


getIndicesCount

NameDescription
getIndicesCount()The count of indices in this TriMesh

Result:


getUnmergedVerticesCount

NameDescription
getUnmergedVerticesCount()The count of unmerged vertices that passed in by beginVertex() and endVertex().

Result:


getCapacity

NameDescription
getCapacity()The capacity of pre-allocated vertices.

Result:


getVerticesSizeInBytes

NameDescription
getVerticesSizeInBytes()The total size of all vertices in bytes

Result:


getParentNodes

NameDescription
getParentNodes()Gets all parent nodes, an entity can be attached to multiple parent nodes for geometry instancing The nodes.

Result:


getExcluded

NameDescription
getExcluded()Gets or sets whether to exclude this entity during exporting.

Result:


setExcluded

NameDescription
setExcluded(value)Gets or sets whether to exclude this entity during exporting.

Result:


getParentNode

NameDescription
getParentNode()Gets or sets the first parent node, if set the first parent node, this entity will be detached from other parent nodes. The parent node.

Result:


setParentNode

NameDescription
setParentNode(value)Gets or sets the first parent node, if set the first parent node, this entity will be detached from other parent nodes. The parent node.

Result:


getScene

NameDescription
getScene()Gets the scene that this object belongs to

Result:


getName

NameDescription
getName()Gets or sets the name. The name.

Result:


setName

NameDescription
setName(value)Gets or sets the name. The name.

Result:


getProperties

NameDescription
getProperties()Gets the collection of all properties.

Result:


fromMesh

NameDescription
fromMesh(declaration, mesh)Create a TriMesh from given mesh object with given vertex layout.

Parameters:

NameTypeDescription
declaratioVertexDeclarationnull
mesMeshnull

Result: TriMesh


copyFrom

NameDescription
copyFrom(input, vd)Copy the TriMesh from input with new vertex layout

Parameters:

NameTypeDescription
inputTriMeshThe input TriMesh for copying
vdVertexDeclarationThe new vertex declaration of the output TriMesh

Result: TriMesh


fromMesh

NameDescription
fromMesh(mesh, useFloat)Create a TriMesh from given mesh object, the vertex declaration are based on the input mesh’s structure.

Parameters:

NameTypeDescription
mesMeshnull
useFloatbooleanUse float type instead of double type for each vertex element component.

Result: TriMesh


beginVertex

NameDescription
beginVertex()Begin adding vertex

Result: Vertex


endVertex

NameDescription
endVertex()End adding vertex

Result: Vertex


verticesToArray

NameDescription
verticesToArray()Convert the vertices data to byte array

Result: byte[]


toString

NameDescription
toString()

Result: String


fromRawData

NameDescription
fromRawData(vd, vertices, indices, generateVertexMapping)Create TriMesh from raw data The returned TriMesh will not copy the input byte array for performance, external changes on the array will be reflected to this instance.

Parameters:

NameTypeDescription
vdVertexDeclarationVertex declaration, must contains at least one field.
verticesbyte[]The input vertex data, the minimum length of the vertices must be greater or equal to vertex declaration’s size
indicesNumber[]The triangle indices
generateVertexMappingbooleanGenerate

Result: TriMesh


loadVerticesFromBytes

NameDescription
loadVerticesFromBytes(verticesInBytes)Load vertices from bytes, the length of bytes must be an integer multiple of vertex size.

Parameters:

NameTypeDescription
verticesInBytebyte[]null

Result: TriMesh


readVector4

NameDescription
readVector4(idx, field)Read the vector4 field

Parameters:

NameTypeDescription
idxNumberThe index of vertex to read
fieldVertexFieldThe field with a Vector4/FVector4 data type

Result: Vector4


readFVector4

NameDescription
readFVector4(idx, field)Read the vector4 field

Parameters:

NameTypeDescription
idxNumberThe index of vertex to read
fieldVertexFieldThe field with a Vector4/FVector4 data type

Result: FVector4


readVector3

NameDescription
readVector3(idx, field)Read the vector3 field

Parameters:

NameTypeDescription
idxNumberThe index of vertex to read
fieldVertexFieldThe field with a Vector3/FVector3 data type

Result: Vector3


readFVector3

NameDescription
readFVector3(idx, field)Read the vector3 field

Parameters:

NameTypeDescription
idxNumberThe index of vertex to read
fieldVertexFieldThe field with a Vector3/FVector3 data type

Result: FVector3


readVector2

NameDescription
readVector2(idx, field)Read the vector2 field

Parameters:

NameTypeDescription
idxNumberThe index of vertex to read
fieldVertexFieldThe field with a Vector2/FVector2 data type

Result: Vector2


readFVector2

NameDescription
readFVector2(idx, field)Read the vector2 field

Parameters:

NameTypeDescription
idxNumberThe index of vertex to read
fieldVertexFieldThe field with a Vector2/FVector2 data type

Result: FVector2


readDouble

NameDescription
readDouble(idx, field)Read the double field

Parameters:

NameTypeDescription
idxNumberThe index of vertex to read
fieldVertexFieldThe field with a float/double compatible data type

Result: Number


readFloat

NameDescription
readFloat(idx, field)Read the float field

Parameters:

NameTypeDescription
idxNumberThe index of vertex to read
fieldVertexFieldThe field with a float/double compatible data type

Result: Number


getBoundingBox

NameDescription
getBoundingBox()Gets the bounding box of current entity in its object space coordinate system.

Result: Number


getEntityRendererKey

NameDescription
getEntityRendererKey()Gets the key of the entity renderer registered in the renderer

Result: EntityRendererKey


removeProperty

NameDescription
removeProperty(property)Removes a dynamic property.

Parameters:

NameTypeDescription
propertyPropertyWhich property to remove

Result: boolean


removeProperty

NameDescription
removeProperty(property)Remove the specified property identified by name

Parameters:

NameTypeDescription
propertStringnull

Result: boolean


getProperty

NameDescription
getProperty(property)Get the value of specified property

Parameters:

NameTypeDescription
propertyStringProperty name

Result: Object


setProperty

NameDescription
setProperty(property, value)Sets the value of specified property

Parameters:

NameTypeDescription
propertyStringProperty name
valueObjectThe value of the property

Result: Object


findProperty

NameDescription
findProperty(propertyName)Finds the property. It can be a dynamic property (Created by CreateDynamicProperty/SetProperty) or native property(Identified by its name)

Parameters:

NameTypeDescription
propertyNameStringProperty name.

Result: Property


iterator

NameDescription
iterator()Reserved for internal use.

Result: Property