Mesh
Represents a 3D mesh, containing vertices, indices, and other geometric data.
| Type | Name | Interface Description |
|---|---|---|
| Variables | boundingBox: AABB | • Function: Gets the axis-aligned bounding box (AABB) of the mesh. |
| Functions | constructor() | |
| Functions | getTopology(): MeshTopology | • Function: Gets the topology of the mesh. Returns The mesh topology. |
| Functions | getTriangles(): Uint16Array | • Function: Gets the triangle indices of the mesh as a 16-bit array. Returns A Uint16Array of vertex indices forming the triangles. |
| Functions | getVertexAttributes(): VertexAttributeDesc[] | • Function: Gets the vertex attributes of the mesh. Returns An array of vertex attribute descriptors. |
| Functions | getVertexCount(): number | • Function: Gets the number of vertices in the mesh. Returns The vertex count. |
| Functions | getVertices(): Float32Array | • Function: Gets the vertex data of the mesh. Returns A Float32Array containing the vertex positions. |
Examples
constructor()
let obj = new APJS.Mesh();
Use Case
Change a 3D object's material color at runtime via MeshRenderer.mainMaterial
@component()
export class MaterialColorChange extends APJS.BasicScriptComponent {
@serializeProperty
private targetColor: APJS.Color = new APJS.Color(1, 0, 0, 1);
onStart(): void {
this.applyColor(this.targetColor);
}
private applyColor(color: APJS.Color): void {
const renderer = this.getSceneObject().getComponent("MeshRenderer") as APJS.MeshRenderer;
// Use mainMaterial for single material access
// Use setVector (NOT setVector4 — it doesn't exist)
if (renderer && renderer.mainMaterial) {
renderer.mainMaterial.setVector("_AlbedoColor", new APJS.Vector4f(color.r, color.g, color.b, color.a));
}
}
onDestroy(): void {}
}