Class Instance

An instance of thing in the world to be rendered, with position, rotation, scale etc

Hierarchy (view full)

Constructors

Properties

customProgramName?: string

Very advanced feature, set this to plugin a custom shader program Use ProgramCache.compileShader to create a named program

flipTextureX: boolean = false

Flip all textures on this instance on the X axis

flipTextureY: boolean = false

Flip all textures on this instance on the Y axis

id: string

Unique ID for this node

material?: Material

Material override. This will override the renderable's material. This is only useful on simple models that probably consist of one surface

metadata: Record<string, string | number | boolean>

Metadata is a key/value store for any extra data you want to store on a node

position: XYZ

Position of this Node in world space, relative to any parent nodes (if any)

quaternion: quat

Rotation quaternion of this Node in world space, relative to any parent nodes (if any)

renderable: undefined | Renderable

Main renderable thing this instance represents

scale: XYZ

Scale of this Node in world space, relative to any parent nodes (if any)

uniformOverrides?: UniformSet

Inject additional uniforms to the shader for this instance. Prefix with u_mat. e.g. u_mat.diffuse to change material properties for a single instance. Warning an advanced feature!

Accessors

  • get castShadow(): boolean
  • Does this Node cast shadows, default true

    Returns boolean

  • set castShadow(value): void
  • Set will this Node cast shadows, this will also set all child nodes

    Parameters

    • value: boolean

    Returns void

  • get enabled(): boolean
  • Is this Node enabled. Disabled nodes will not be rendered

    Returns boolean

  • set enabled(enabled): void
  • Set enabled state of this Node, this will also set all child nodes

    Parameters

    • enabled: boolean

    Returns void

  • get modelMatrix(): mat4
  • Return the world or model matrix for this node, this is the matrix that places this node in the world. This will be in relation to the parent node, if there is one.

    Returns mat4

  • get parent(): undefined | Node
  • Get current parent of this Node

    Returns undefined | Node

  • set parent(node): void
  • Sets the parent this Node, to the provided Node

    Parameters

    • node: undefined | Node

    Returns void

  • get physicsBody(): undefined | Body
  • Get the physics body for this Node, if there is one

    Returns undefined | Body

  • set physicsBody(body): void
  • Set the physics body for this Node

    Parameters

    • body: undefined | Body

    Returns void

  • get receiveShadow(): boolean
  • Does this Node receive shadows, default true

    Returns boolean

  • set receiveShadow(value): void
  • Set will this Node receive shadows, this will also set all child nodes

    Parameters

    • value: boolean

    Returns void

Methods

  • Add an event handler to listen for node changes

    Parameters

    • event: string

      NodeEvent type, one of 'position', 'rotation', 'scale'

    • handler: ((event) => void)

      Function to call when event is triggered

        • (event): void
        • Parameters

          Returns void

    Returns void

  • Render this instance in the world, called internally by the context when rendering

    Parameters

    • gl: WebGL2RenderingContext

      WebGL context to render into

    • uniforms: UniformSet

      Map of uniforms to pass to shader

    • Optional programOverride: ProgramInfo

    Returns void

  • Rotate this instance around the X, Y and Z axis in radians

    Parameters

    • ax: number
    • ay: number
    • az: number

    Returns void

  • Rotate this instance around the X axis

    Parameters

    • angle: number

    Returns void

  • Rotate this instance around the Z axis by a given angle in degrees

    Parameters

    • angle: number

    Returns void

  • Rotate this instance around the Y axis

    Parameters

    • angle: number

    Returns void

  • Rotate this instance around the Y axis by a given angle in degrees

    Parameters

    • angle: number

    Returns void

  • Rotate this instance around the Z axis, in radians

    Parameters

    • angle: number

    Returns void

  • Rotate this instance around the X axis by a given angle in degrees

    Parameters

    • angle: number

    Returns void

  • Set the rotation quaternion directly, normally users should use the rotate methods. This method is for advanced uses, like integration with an external physics system

    Parameters

    Returns void

  • Updates the position & rotation of this node to match it's linked physics Body This is called automatically by the engine, but can be called manually if needed

    Returns void

Generated using TypeDoc