Theme:

World

world is a global singleton.

Objects


// Use these at runtime to add/remove objects

// Registers world-managed behavior on an object and its descendants.
// An unparented object is also attached to world.scene by default.
world.add(object: U.Object3D, addToScene: boolean = true)

// Remove an object and its descendants from runtime systems and the hierarchy
world.remove(object)


// list of objects that .update() each frame
world.objects -> Array of Objects

// list of objects which are raycasted each frame
world.raycastables -> Array of Objects

// make an object grabbable at runtime
world.addGrabbable(object)

// Register one mesh or text object for interaction raycasting
world.addRaycastable(mesh)

// Register a planar mesh for realtime planar reflections.
// Returns its stable reflection slot (0-7), or -1 if the geometry is not
// planar or all slots are occupied.
world.addPlanarReflection(mesh)

// Release a previously registered planar-reflection slot.
world.removePlanarReflection(mesh)

Up to eight planes may be registered. With one registered plane, its full-raster cadence is controlled by SINGLE_REFLECTION_RASTER_INTERVAL in Backend/PlanarReflection.js, and intervening eligible frames use reprojection. With two or more registered planes, one eligible plane receives a full raster capture per frame in round-robin order while the other eligible captures are reprojected. Planes outside the camera frustum, hidden planes, and planes whose front normal faces away from the camera are skipped. Both ordinary BufferGeometry data and the packed geometry used by BatchedMesh are supported. All vertex normals must point in roughly the same direction, and all triangle faces must be roughly coplanar. The shared local normal is transformed with the object, and the reflection plane passes through the transformed center of the geometry bounding box. Removing a registered mesh with world.remove() also releases its reflection slot.

Adding runtime objects

Use world.add(object) for a top-level runtime object. It discovers descendant update/preUpdate callbacks and point/spot lights, then attaches an unparented object to world.scene.

const model = await Model('prop.glb')
world.add(model)

For an ordinary visual child, parent.add(child) is enough: Unia synchronizes the child and queues its descendants for rendering.

parent.add(model)

If a late-added subtree defines update/preUpdate callbacks or contains point/spot lights, register that behavior after parenting it:

parent.add(child)
world.add(child)

Because child already has a parent, world.add() does not reparent it. addToScene = false only suppresses automatic scene attachment for an unparented object. Configure collider before adding a mesh. Raycasting is separate and world.addRaycastable() accepts individual meshes or text, not a Group.

Registered ordinary meshes and custom-shader meshes raycast their full CPU triangle geometry by default. Set mesh.raycastBoundsOnly = true to use only the mesh's world-space axis-aligned bounding box. The property is undefined by default, and only strict true enables the bounds-only path. This can be useful for vertex shaders that visually deform a mesh, provided the local geometry.boundingBox contains the full deformation.

Avatars

world.avatars -> Map of avatar UUIDs to Objects
world.avatar -> Your avatar

Other


// Exclude object from all raycasting
world.setRaycastable(Object3D, boolean)
// or use object.raycastable = false before adding to the scene

world.username -> 'yourUserName' | null
world.scene -> U.Scene
world.renderer -> WebGPU renderer interface
world.physics -> Physics global, see physics docs
world.storage -> Storage global, see storage docs
world.camera - > U.PerspectiveCamera, the player camera
world.animationMixer -> U.AnimationMixer, the main animation mixer

world.XR -> Boolean, whether we are in XR or not
world.startXR()

world.stats ->
{
    triangles: number,
    calls: number,
    FPS: number,
}