Skip to main content

Scene

TypeNameInterface Description
Functions

createSceneObject(name: string) : SceneObject

Function: Creates a new SceneObject object and assigns it a specified name.

Return Value: Returns the created SceneObject object.

Default Behavior: By default, newly created objects are mounted in the 3D scene if no parent object is set.

Example

let newObject = scene.createSceneObject("MyObject");
newObject.parent = this.getSceneObject();

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
onStart() {
const scene = this.getSceneObject().scene;
const newObj = scene.createSceneObject("test");
newObj.parent = this.getSceneObject();
const obj = scene.findSceneObject("test");
console.log('test name:', obj?.name);
}
onUpdate(deltaTime: number) {

}
}

TypeNameInterface Description
FunctionsremoveSceneObject(obj: SceneObject): booleanFunction: Remove the specified SceneObject object from the scene.

Return value: If the removal is successful, returns true; otherwise, returns false.

FunctionsgetRootSceneObjects(): SceneObject[]Function: Get all root-level SceneObject objects in the scene.

Return Value: Returns an array containing all root-level SceneObject objects.

FunctionsfindSceneObject(objName: string, root?: SceneObject):SceneObject | undefinedFunction: Find a SceneObject with the specified name in the scene.

Parameter:

◦ objName: The name of the object to be searched for.

◦ root: The starting node for the search. If it is null, the search starts from the root node of the scene.

Return Value: Returns the found SceneObject object; if not found, returns undefined.

FunctionsgetAllSceneObjects(): SceneObject[]Function: Get all SceneObject objects in the scene.

Return Value: Returns an array containing all SceneObject objects.

Examples

removeSceneObject(obj: SceneObject): boolean

let result = scene.removeSceneObject(myObject);

getRootSceneObjects(): SceneObject[]

let rootObjects = scene.getRootSceneObjects();

findSceneObject(objName: string, root?: SceneObject):SceneObject | undefined

let foundObject = scene.findSceneObject("MyObject", null);

getAllSceneObjects(): SceneObject[]

let allObjects = scene.getAllSceneObjects();

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
onStart() {
const scene = this.getSceneObject().scene;
let toBeRemovedSO = scene.findSceneObject("ToBeRemoved");
console.log("ToBeRemoved SceneObject Existed: ", toBeRemovedSO !== null);
toBeRemovedSO && scene.removeSceneObject(toBeRemovedSO);
console.log("Remove SceneObject");
toBeRemovedSO = scene.findSceneObject("ToBeRemoved");
console.log("ToBeRemoved SceneObject Existed: ", toBeRemovedSO !== null);

const rootObjects = scene.getRootSceneObjects();
for (const obj of rootObjects) {
console.log("Root SceneObject Name:", obj.name);
}

const allObjects = scene.getAllSceneObjects();
for (const obj of allObjects) {
console.log("All SceneObject Name:", obj.name);
}
}
onUpdate(deltaTime: number) {

}
}
Copyright © 2026 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalTerms of ServicePrivacy PolicyCookies