Skip to main content

Mesh

Represents a 3D mesh, containing vertices, indices, and other geometric data.

TypeNameInterface Description
VariablesboundingBox: AABB

Function: Gets the axis-aligned bounding box (AABB) of the mesh.

Functionsconstructor()

FunctionsgetTopology(): MeshTopology

Function: Gets the topology of the mesh.

Returns The mesh topology.

FunctionsgetTriangles(): Uint16Array

Function: Gets the triangle indices of the mesh as a 16-bit array.

Returns A Uint16Array of vertex indices forming the triangles.

FunctionsgetVertexAttributes(): VertexAttributeDesc[]

Function: Gets the vertex attributes of the mesh.

Returns An array of vertex attribute descriptors.

FunctionsgetVertexCount(): number

Function: Gets the number of vertices in the mesh.

Returns The vertex count.

FunctionsgetVertices(): 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 {}
}
Copyright © 2026 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalTerms of ServicePrivacy PolicyCookies