Skip to main content
Version: 0.12.0 (latest)

UeScene

The UeScene class represents the root node of a 3D scene in Unique Engine. It inherits from UeObject3D and manages fog settings, material overrides, and the hierarchy of objects to be rendered.

Constructor​

new UeScene(data = {})

Inherits from UeObject3D

Data parameters​

KeyTypeDefaultDescription
fogstruct(see below)Fog configuration struct
overrideMaterialUeMaterialundefinedForces all objects in the scene to use this material

Properties​

PropertyTypeDefaultDescription
isScenebooleantrueIndicates that this is a scene
typestring"Scene"Object type identifier
fogstruct{...}Fog settings for the scene
overrideMaterialUeMaterialundefinedIf set, overrides materials of all children

Fog Configuration Struct​

The fog property is a struct with the following fields:

FieldTypeDefaultDescription
enabledbooleanfalseWhether fog is active
colorarray[0.5, 0.5, 0.5]RGB fog color
densitynumber0Exponential fog density
nearnumber1Linear fog start distance
farnumber1000Linear fog end distance

🧩 Methods​

toJSON()

Returns a JSON-compatible representation of the scene, including recursive serialization of model instances.

fromJSON(data, objectsByUUID)

Loads scene data from a JSON object. objectsByUUID is an optional lookup table to link existing objects.

clone(recursive = true)

Returns a clone of the scene. If recursive is true, it also clones all children.

🧠 Notes​

  • You can build your scene tree using .add() to nest meshes, lights, or other objects.
  • overrideMaterial is useful for effects like depth-prepass or selecting all objects with a single material.

Example​

const scene = new UeScene();

// Setup Fog
scene.fog.enabled = true;
scene.fog.color = [0.1, 0.1, 0.1];
scene.fog.near = 100;
scene.fog.far = 2000;

const light = new UeDirectionalLight(c_white, { x: 100 });
const material = new UeMeshStandardMaterial();
const mesh = new UeMesh(new UeBoxGeometry(), material);

scene.add(light, mesh);