Taos API Reference
    Preparing search index...

    Class Scene

    Top-level container for the GameObject hierarchy.

    Holds the root-level GameObjects for a frame. Scene.update recursively ticks every component in the hierarchy; the renderer then queries the scene (via Scene.findCamera, Scene.findSunLight, Scene.collectMeshRenderers, Scene.getComponents) to build its per-pass draw lists.

    The scene maintains typed caches of Camera, DirectionalLight, and MeshRenderer components so those lookups are O(matches) rather than walking the hierarchy every frame. Caches are kept in sync via GameObject add/remove and GameObject.addComponent / GameObject.removeComponent; descendants are tracked too.

    Index

    Constructors

    Properties

    gameObjects: GameObject[] = []

    Root-level GameObjects in this scene.

    engine: Engine | null = null

    The Engine driving this scene, or null when the scene is used standalone (e.g. in tests). Assigned by the Engine that owns the scene. Gives behaviors a path to engine-level resources — most usefully scene.engine.ctx.device to build meshes / textures at runtime — without a global singleton.

    time: Time = ...

    Simulation clock for this scene. Advanced by the Engine each frame before Scene.update. Components read it via Component.time for absolute time, frame count, FPS, and timeScale-aware delta.

    Methods

    • Removes a root GameObject from the scene if present. Unregisters every component in the subtree from the scene's typed caches.

      Parameters

      Returns void

    • Recursively updates every root GameObject and its children.

      Parameters

      • dt: number

        Frame delta time in seconds.

      Returns void

    • Recursively refreshes per-frame render state on every root GameObject and its children. Call after update and any input/controller mutations so cached state (e.g. camera matrices) reflects the final transforms.

      Parameters

      Returns void

    • Returns the first Camera in the hierarchy whose GameObject (and every ancestor) is enabled, or null. O(matches) via the camera cache.

      Returns Camera | null

    • Returns every MeshRenderer in the hierarchy whose GameObject and every ancestor is enabled. Used by the world geometry pass and shadow passes to build draw lists. O(matches) via the mesh-renderer cache.

      Returns MeshRenderer[]

    • Returns one component of the given type per root GameObject (the first match via GameObject.getComponent). Does not recurse into children.

      Type Parameters

      Parameters

      • ctor: new (...args: never[]) => T

        Component subclass constructor used as a type filter.

      Returns T[]

    • Depth-first search for the first GameObject named name anywhere in the hierarchy (roots and all descendants), or null if none matches. Names are not unique, so this returns the first match in traversal order. Convenience for behaviors that need to reference another object by name; for hot paths cache the result rather than calling every frame.

      Parameters

      Returns GameObject | null