Class Node

A Node with position, rotation, scale, all Instances extend this class. But Nodes also be created to group instances and simplify transformations.

Hierarchy (view full)

Constructors

  • Create a default node, at origin with scale of [1,1,1] and no rotation

    Returns Node

Properties

_castShadow: boolean
_children: Node[] = []
_enabled: boolean
_parent?: Node
_physicsBody?: Body
_receiveShadow: boolean
eventHandlers: Map<string, ((event) => void)[]>
id: string

Unique ID for this node

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)

scale: XYZ

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

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

  • Convenience method to make another Node a child of this one

    Parameters

    Returns void

  • 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

  • Convenience method to remove all child Nodes

    Returns void

  • Convenience method to remove a child Node

    Parameters

    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