Taos API Reference
    Preparing search index...

    Class MeshRenderer

    Component that draws a Mesh with a Material.

    Discovered each frame by Scene.collectMeshRenderers and submitted by the world geometry pass (and the cascade/spot/point shadow passes when castShadow is true).

    The fields prefixed _ are populated by Engine._bucketScene each frame. They're public-readonly so the engine can read them across the package boundary; outside code should treat them as opaque.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    id: string = ...

    Stable identity for this component, unique within a session. Auto-generated for runtime-created components; the editor overwrites it with a persistent id when projecting a saved document so references survive save / load / undo.

    enabled: boolean = true

    Whether this component participates in simulation and rendering. When false, the GameObject skips its update/updateRender and the scene's render collectors (mesh renderers, camera, lights, …) ignore it — the component stays attached and keeps its state, like Unity's Behaviour.enabled / Renderer.enabled. Defaults to true.

    gameObject: GameObject

    The owning GameObject; assigned by addComponent before onAttach runs.

    _sceneAttached: boolean = false

    True between onAttach and onDetach — i.e. while this component sits on a GameObject that is part of a live Scene. Managed by GameObject. Internal — do not set directly.

    mesh: Mesh
    material: Material
    castShadow: boolean = true

    Whether this mesh contributes to shadow map rendering.

    reflectionProbeVisible: boolean = true

    Whether this mesh is rendered into ReflectionProbe 'scene' captures. Set false to keep an object out of probe reflections — e.g. the subject standing inside a probe that should reflect only its surroundings, avoiding the object reflecting a copy of itself.

    previousWorldMatrix: Mat4 | null = null

    The engine bucketing no longer writes here — it uses an internal persistent buffer (_previousWorld) for the velocity pass. Field is preserved so external draw-list builders (e.g. samples that build their own DrawItems) keep compiling, but engine-driven code should rely on the per-frame bucketing instead.

    _currentWorld: Mat4 = ...

    Current frame's world matrix. Filled in by Engine._bucketScene.

    _previousWorld: Mat4 = ...

    Previous frame's world matrix, for velocity-pass motion blur. Equals _currentWorld on the first frame (zero velocity).

    _normalMatrix: Mat4 = ...

    Inverse-transpose of _currentWorld. Filled in by _bucketScene.

    _seenFirstFrame: boolean = false

    False until Engine._bucketScene has processed this renderer once.

    _drawItem: DrawItem

    Pre-allocated DrawItem reused each frame. The Mat4 references are stable (always point at the buffers above); only mesh/material are reassigned on a swap.

    _shadowItem: ShadowMeshDraw

    Pre-allocated shadow-caster item reused each frame.

    Accessors

    • get time(): Time

      The simulation clock of the scene this component belongs to. Read inside update (or any time after the GameObject is added to a scene) for absolute time, frame count, FPS, and timeScale-aware delta — e.g. this.time.elapsed, this.time.delta, this.time.frameCount.

      this.time.delta equals the dt argument passed to update, so components can ignore that argument entirely and pull everything from here.

      Returns Time

      if the owning GameObject is not currently part of a scene.

    • get lightExcludeMask(): number

      8-bit light-exclusion mask (deferred path). A deferred point / spot / area light whose own excludeMask shares a bit with this is skipped for this mesh — (mesh & light) != 0 → not lit by that light. 0 (default) = lit by everything. Written into the G-buffer by the deferred GeometryPass; forward paths ignore it. Lets a light illuminate the scene while sparing a chosen object (e.g. a window "sun" that shouldn't blow out the window frame).

      Returns number

    • set lightExcludeMask(mask: number): void

      Parameters

      • mask: number

      Returns void

    Methods

    • Connect to a Signal with automatic disconnect when this component is removed from its GameObject — the safe default for cross-object listening, so a destroyed component never leaks into (or gets called by) a signal it once observed. Typically called from onAttach:

      onAttach(): void {
      const health = this.gameObject.getComponent(Health)!;
      this.listen(health.died, () => this.playDeathEffect());
      }

      Type Parameters

      • A extends unknown[]

      Parameters

      Returns () => void

      The unsubscribe function, for listeners that also want to disconnect early; calling it is optional and idempotent.

    • Called when the component joins a live scene — from addComponent when the GameObject is already in a scene, otherwise when the GameObject is added to one. this.gameObject.scene (and scene.engine) is always set here. Override to acquire references to siblings/children or initialize resources.

      Returns void

    • Called every frame by the GameObject's update traversal.

      Parameters

      • _dt: number

        Frame delta time in seconds.

      Returns void

    • Called when this component's GameObject begins touching another body, with the GameObject it collided with. Dispatched by the physics system after each world step (only while playing), so handlers may freely mutate the scene. Requires a physics body (RigidBody / CharacterBody) on the object.

      Parameters

      • _other: GameObject

        The other GameObject involved in the contact.

      Returns void

    • Called every frame by the GameObject's render traversal, after update and any input/controller mutations to the transform. Override to refresh per-frame state that render passes consume (e.g. Camera recomputes its cached view/projection matrices here).

      Parameters

      • _ctx: RenderContext

        Active render context (provides canvas width/height etc.).

      Returns void