SCENE

3D scene object creation and management.

Availability: Client-only

Methods


SCENE.addAsset

client

Add a custom asset model to the 3D scene

Signature: obj action(str, num, num, num, num, str, obj, action)

Parameters:

NameTypeDescription
aidstrAsset 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)
xnumX position
ynumY position
znumZ position
sclnumScale factor (0.01-100)
colrstrColor tint (hex)
dataobjAdditional configuration
onLoadCallBackactionCallback 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:

NameTypeDescription
aidstrAsset ID for identification
colrstrColor (hex)
xnumX position
ynumY position
znumZ position
wnumWidth
hnumHeight
lnumLength/depth
dataobjAdditional 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:

NameTypeDescription
aidstrAsset ID for identification
colrstrColor (hex)
vertsnum[]Array of vertex positions (x,y,z triplets)
xnumX position
ynumY position
znumZ position
wnumWidth scale
hnumHeight scale
lnumLength scale
dataobjAdditional 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:

NameTypeDescription
colrstrLight color (hex)
xnumLight X position
ynumLight Y position
znumLight Z position
txnumTarget X position
tynumTarget Y position
tznumTarget Z position
intensitynumLight intensity (0-15)
castShadowboolWhether 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:

NameTypeDescription
colrstrBar color (hex)
xnumX position
ynumY position
znumZ position
wnumBar width
lnumBar length
dataobjAdditional 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:

NameTypeDescription
colrstrCone color (hex)
xnumX position
ynumY position
znumZ position
wnumCone base width
lnumCone base length
hnumCone height
dataobjConfiguration 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:

NameTypeDescription
aidstrAsset ID for identification
colrstrColor (hex)
xnumX position
ynumY position
znumZ position
wnumWidth
lnumLength
dataobjAdditional 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:

NameTypeDescription
colrstrLight color (hex)
xnumX position
ynumY position
znumZ position
distancenumMaximum light distance (0-1000)
decaynumLight decay factor (0.1-2)
intensitynumLight intensity (0-15)
castShadowboolWhether 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:

NameTypeDescription
colrstrLight color (hex)
xnumX position
ynumY position
znumZ position
wnumLight width
lnumLight length
intensitynumLight 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:

NameTypeDescription
xnumX position
ynumY position
znumZ position
wnumSign width
lnumSign length
textstrText content to display
dataobjAdditional 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:

NameTypeDescription
aidstrAsset ID for identification
colrstrColor (hex)
xnumX position
ynumY position
znumZ position
wnumWidth
hnumHeight
lnumLength/depth
dataobjAdditional 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:

NameTypeDescription
colrstrLight color (hex)
xnumLight X position
ynumLight Y position
znumLight Z position
txnumTarget X position
tynumTarget Y position
tznumTarget Z position
distancenumMaximum light distance (0-1000)
decaynumLight decay factor (0.1-2)
intensitynumLight intensity (0-15)
anglenumCone angle in degrees (1-90)
penumbranumSoft edge falloff (0-1)
castShadowboolWhether 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:

NameTypeDescription
aidstrAsset ID for the texture
colrstrColor tint (hex)
xnumX position
ynumY position
znumZ position
wnumWidth
hnumHeight
lnumDepth (unused for sprites)
dataobjAdditional 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:

NameTypeDescription
objobjThe 3D object to move
xnumX offset to add
ynumY offset to add
znumZ 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:

NameTypeDescription
xnumWorld X position
ynumWorld Y position
znumWorld 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:

NameTypeDescription
objobjThe 3D object to rotate
xnumX rotation in radians
ynumY rotation in radians
znumZ 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:

NameTypeDescription
objobjThe 3D object to scale
xnumX scale factor
ynumY scale factor
znumZ scale factor
GAME.SCENE.scaleObj(obj, 0, 10, 0);

SCENE.setAmbientLight

client

Set the ambient light color and intensity

Signature: action(str, num)

Parameters:

NameTypeDescription
colorstrLight color (hex)
intensitynumLight 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:

NameTypeDescription
colrstrFog color (hex)
distancenumFog end distance (10-15000)
GAME.SCENE.setFog("#FF0000", 0);

SCENE.setSkyColor

client

Set the sky background color

Signature: action(str)

Parameters:

NameTypeDescription
colorstrSky 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:

NameTypeDescription
color1strTop color (hex)
color2strMiddle color (hex)
color3strBottom color (hex)
dataobjConfiguration 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:

NameTypeDescription
colorstrLight color (hex)
intensitynumLight intensity (0.1-3)
sunAngXnumSun angle X in degrees (0-360)
sunAngYnumSun angle Y in degrees (0-360)
distancenumLight distance (10-15000)
GAME.SCENE.setSkyLight("#FF0000", 1.0, 0, 0, 0);