Skip to main content

Renderer

APJS Script API reference for the Renderer class.

TypeNameInterface Description
VariablesautoSortingOrder: boolean

Function: Indicates whether the sorting order is automatically managed.

Variablesmaterials: Material[]

Function: Retrieves the shared materials used by the Renderer.

VariablesshadowMode: ShadowMode

Function: Gets the shadow mode of the renderer.

VariablessortingOrder: number

Function: Gets the sorting order of the Renderer.

Returns The current sorting order.

Functionsconstructor()

Examples

constructor()

let obj = new APJS.Renderer();

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