SCENE
3D scene object creation and management.
Availability: Client-only
Methods
- addAsset
- addCube
- addCustom
- addDirLight
- addLightBar
- addLightCone
- addPlane
- addPointLight
- addRectLight
- addSign
- addSphere
- addSpotLight
- addSprite
- clear
- movObj
- posToScreen
- removeSkyDome
- rotObj
- scaleObj
- setAmbientLight
- setFog
- setSkyColor
- setSkyDome
- setSkyLight
SCENE.addAsset
client
Add a custom asset model to the 3D scene
Signature: obj action(str, num, num, num, num, str, obj, action)
Parameters:
| Name | Type | Description |
|---|---|---|
aid | str | Asset ID with optional flags (e=emissive, n=normal, s=specular, a=alpha, m=metalness, r=roughness, l=lightmap, p=displacement, b=bump, g=gltf, q=glb, f=fbx) |
x | num | X position |
y | num | Y position |
z | num | Z position |
scl | num | Scale factor (0.01-100) |
colr | str | Color tint (hex) |
data | obj | Additional configuration |
onLoadCallBack | action | Callback when model finishes loading |
Returns: obj - The created 3D object
obj result = GAME.SCENE.addAsset("asset_id", 0, 10, 0, 1, "#FF0000", {}, callback);
SCENE.addCube
client
Add a cube primitive to the 3D scene
Signature: obj action(str, str, num, num, num, num, num, num, obj)
Parameters:
| Name | Type | Description |
|---|---|---|
aid | str | Asset ID for identification |
colr | str | Color (hex) |
x | num | X position |
y | num | Y position |
z | num | Z position |
w | num | Width |
h | num | Height |
l | num | Length/depth |
data | obj | Additional configuration |
Returns: obj - The created 3D object
obj result = GAME.SCENE.addCube("asset_id", "#FF0000", 0, 10, 0, 5, 5, 5, {});
SCENE.addCustom
client
Add a custom geometry from vertex data to the 3D scene
Signature: obj action(str, str, num[], num, num, num, num, num, num, obj)
Parameters:
| Name | Type | Description |
|---|---|---|
aid | str | Asset ID for identification |
colr | str | Color (hex) |
verts | num[] | Array of vertex positions (x,y,z triplets) |
x | num | X position |
y | num | Y position |
z | num | Z position |
w | num | Width scale |
h | num | Height scale |
l | num | Length scale |
data | obj | Additional configuration |
Returns: obj - The created 3D object
obj result = GAME.SCENE.addCustom("asset_id", "#FF0000", num [], 0, 10, 0, 5, 5, 5, {});
SCENE.addDirLight
client
Add a directional light (like sunlight)
Signature: obj action(str, num, num, num, num, num, num, num, bool)
Parameters:
| Name | Type | Description |
|---|---|---|
colr | str | Light color (hex) |
x | num | Light X position |
y | num | Light Y position |
z | num | Light Z position |
tx | num | Target X position |
ty | num | Target Y position |
tz | num | Target Z position |
intensity | num | Light intensity (0-15) |
castShadow | bool | Whether light casts shadows |
Returns: obj - The created light object
obj result = GAME.SCENE.addDirLight("#FF0000", 0, 10, 0, 0, 0, 0, 1.0, true);
SCENE.addLightBar
client
Add a glowing light bar visual effect
Signature: obj action(str, num, num, num, num, num, obj)
Parameters:
| Name | Type | Description |
|---|---|---|
colr | str | Bar color (hex) |
x | num | X position |
y | num | Y position |
z | num | Z position |
w | num | Bar width |
l | num | Bar length |
data | obj | Additional configuration |
Returns: obj - The created bar object
obj result = GAME.SCENE.addLightBar("#FF0000", 0, 10, 0, 5, 5, {});
SCENE.addLightCone
client
Add a light cone visual effect (not a real light source)
Signature: obj action(str, num, num, num, num, num, num, obj)
Parameters:
| Name | Type | Description |
|---|---|---|
colr | str | Cone color (hex) |
x | num | X position |
y | num | Y position |
z | num | Z position |
w | num | Cone base width |
l | num | Cone base length |
h | num | Cone height |
data | obj | Configuration with optional fullCone property |
Returns: obj - The created cone object
obj result = GAME.SCENE.addLightCone("#FF0000", 0, 10, 0, 5, 5, 5, {});
SCENE.addPlane
client
Add a plane primitive to the 3D scene
Signature: obj action(str, str, num, num, num, num, num, obj)
Parameters:
| Name | Type | Description |
|---|---|---|
aid | str | Asset ID for identification |
colr | str | Color (hex) |
x | num | X position |
y | num | Y position |
z | num | Z position |
w | num | Width |
l | num | Length |
data | obj | Additional configuration |
Returns: obj - The created 3D object
obj result = GAME.SCENE.addPlane("asset_id", "#FF0000", 0, 10, 0, 5, 5, {});
SCENE.addPointLight
client
Add a point light that emits in all directions
Signature: obj action(str, num, num, num, num, num, num, bool)
Parameters:
| Name | Type | Description |
|---|---|---|
colr | str | Light color (hex) |
x | num | X position |
y | num | Y position |
z | num | Z position |
distance | num | Maximum light distance (0-1000) |
decay | num | Light decay factor (0.1-2) |
intensity | num | Light intensity (0-15) |
castShadow | bool | Whether light casts shadows |
Returns: obj - The created light object
obj result = GAME.SCENE.addPointLight("#FF0000", 0, 10, 0, 0, 1.0, 1.0, true);
SCENE.addRectLight
client
Add a rectangular area light
Signature: obj action(str, num, num, num, num, num, num)
Parameters:
| Name | Type | Description |
|---|---|---|
colr | str | Light color (hex) |
x | num | X position |
y | num | Y position |
z | num | Z position |
w | num | Light width |
l | num | Light length |
intensity | num | Light intensity (0-15) |
Returns: obj - The created light object
obj result = GAME.SCENE.addRectLight("#FF0000", 0, 10, 0, 5, 5, 1.0);
SCENE.addSign
client
Add a text sign to the 3D scene
Signature: obj action(num, num, num, num, num, str, obj)
Parameters:
| Name | Type | Description |
|---|---|---|
x | num | X position |
y | num | Y position |
z | num | Z position |
w | num | Sign width |
l | num | Sign length |
text | str | Text content to display |
data | obj | Additional configuration |
Returns: obj - The created sign object
obj result = GAME.SCENE.addSign(0, 10, 0, 5, 5, "Hello", {});
SCENE.addSphere
client
Add a sphere primitive to the 3D scene
Signature: obj action(str, str, num, num, num, num, num, num, obj)
Parameters:
| Name | Type | Description |
|---|---|---|
aid | str | Asset ID for identification |
colr | str | Color (hex) |
x | num | X position |
y | num | Y position |
z | num | Z position |
w | num | Width |
h | num | Height |
l | num | Length/depth |
data | obj | Additional configuration |
Returns: obj - The created 3D object
obj result = GAME.SCENE.addSphere("asset_id", "#FF0000", 0, 10, 0, 5, 5, 5, {});
SCENE.addSpotLight
client
Add a spotlight with cone-shaped illumination
Signature: obj action(str, num, num, num, num, num, num, num, num, num, num, num, bool)
Parameters:
| Name | Type | Description |
|---|---|---|
colr | str | Light color (hex) |
x | num | Light X position |
y | num | Light Y position |
z | num | Light Z position |
tx | num | Target X position |
ty | num | Target Y position |
tz | num | Target Z position |
distance | num | Maximum light distance (0-1000) |
decay | num | Light decay factor (0.1-2) |
intensity | num | Light intensity (0-15) |
angle | num | Cone angle in degrees (1-90) |
penumbra | num | Soft edge falloff (0-1) |
castShadow | bool | Whether light casts shadows |
Returns: obj - The created light object
obj result = GAME.SCENE.addSpotLight("#FF0000", 0, 10, 0, 0, 0, 0, 0, 1.0, 1.0, 0, 0.5, true);
SCENE.addSprite
client
Add a 2D sprite that always faces the camera
Signature: obj action(str, str, num, num, num, num, num, num, obj)
Parameters:
| Name | Type | Description |
|---|---|---|
aid | str | Asset ID for the texture |
colr | str | Color tint (hex) |
x | num | X position |
y | num | Y position |
z | num | Z position |
w | num | Width |
h | num | Height |
l | num | Depth (unused for sprites) |
data | obj | Additional configuration |
Returns: obj - The created sprite object
obj result = GAME.SCENE.addSprite("asset_id", "#FF0000", 0, 10, 0, 5, 5, 5, {});
SCENE.clear
client
Remove all custom objects from the 3D scene
Signature: action()
GAME.SCENE.clear();
SCENE.movObj
client
Move a 3D object by adding to its current position
Signature: action(obj, num, num, num)
Parameters:
| Name | Type | Description |
|---|---|---|
obj | obj | The 3D object to move |
x | num | X offset to add |
y | num | Y offset to add |
z | num | Z offset to add |
GAME.SCENE.movObj(obj, 0, 10, 0);
SCENE.posToScreen
client
Convert a 3D world position to 2D screen coordinates
Signature: obj action(num, num, num)
Parameters:
| Name | Type | Description |
|---|---|---|
x | num | World X position |
y | num | World Y position |
z | num | World Z position |
Returns: obj - Object with x, y screen coordinates and onScreen boolean
obj result = GAME.SCENE.posToScreen(0, 10, 0);
SCENE.removeSkyDome
client
Remove the sky dome and revert to default sky
Signature: action()
GAME.SCENE.removeSkyDome();
SCENE.rotObj
client
Set the rotation of a 3D object
Signature: action(obj, num, num, num)
Parameters:
| Name | Type | Description |
|---|---|---|
obj | obj | The 3D object to rotate |
x | num | X rotation in radians |
y | num | Y rotation in radians |
z | num | Z rotation in radians |
GAME.SCENE.rotObj(obj, 0, 10, 0);
SCENE.scaleObj
client
Set the scale of a 3D object
Signature: action(obj, num, num, num)
Parameters:
| Name | Type | Description |
|---|---|---|
obj | obj | The 3D object to scale |
x | num | X scale factor |
y | num | Y scale factor |
z | num | Z scale factor |
GAME.SCENE.scaleObj(obj, 0, 10, 0);
SCENE.setAmbientLight
client
Set the ambient light color and intensity
Signature: action(str, num)
Parameters:
| Name | Type | Description |
|---|---|---|
color | str | Light color (hex) |
intensity | num | Light intensity (0.1-3) |
GAME.SCENE.setAmbientLight("#FF0000", 1.0);
SCENE.setFog
client
Set the scene fog color and distance
Signature: action(str, num)
Parameters:
| Name | Type | Description |
|---|---|---|
colr | str | Fog color (hex) |
distance | num | Fog end distance (10-15000) |
GAME.SCENE.setFog("#FF0000", 0);
SCENE.setSkyColor
client
Set the sky background color
Signature: action(str)
Parameters:
| Name | Type | Description |
|---|---|---|
color | str | Sky color (hex) |
GAME.SCENE.setSkyColor("#FF0000");
SCENE.setSkyDome
client
Create a gradient sky dome with up to 3 colors
Signature: action(str, str, str, obj)
Parameters:
| Name | Type | Description |
|---|---|---|
color1 | str | Top color (hex) |
color2 | str | Middle color (hex) |
color3 | str | Bottom color (hex) |
data | obj | Configuration with texture, emissive, textureMoveSpeed, textureMoveAxis |
GAME.SCENE.setSkyDome("value", "value", "value", {});
SCENE.setSkyLight
client
Set the directional sky light properties
Signature: action(str, num, num, num, num)
Parameters:
| Name | Type | Description |
|---|---|---|
color | str | Light color (hex) |
intensity | num | Light intensity (0.1-3) |
sunAngX | num | Sun angle X in degrees (0-360) |
sunAngY | num | Sun angle Y in degrees (0-360) |
distance | num | Light distance (10-15000) |
GAME.SCENE.setSkyLight("#FF0000", 1.0, 0, 0, 0);