Class Node2

This is the base class for all objects that can be added to a GopherGfx 2D scene. It is named "Node" because the scene is stored in a graph data structure, so we think of every element in that graph as a "node" in the graph. There is also a "Node3" base class for all objects that can be added to the 3D scene.

Every object that can be added to a 2D scene (e.g., Mesh2s, Line2s) will inherit from this base object. So, every object in the scene will have a position, rotation, scale, boundingBox, boundingSphere, visibility, and all of the other properties listed in this class.

For more detail on how the scene graph works, see the documentation for the Scene class.

Hierarchy

Constructors

Properties

_localBoundingBox: BoundingBox2

Bounding box in this transform's local coordinate space

_localBoundingCircle: BoundingCircle

Bounding circle in this transform's local coordinate space

_position: Vector2

Vector2 representing the position

_rotation: number

Rotation of the transform in radians

_scale: Vector2

Vector2 representing the scale

_shear: null | Vector2
_worldBoundingBox: BoundingBox2

Bounding box in the world coordinate space

_worldBoundingCircle: BoundingCircle

Bounding box in the world coordinate space

boundingBox: BoundingBox2

Bounding box in vertex coordinate space

boundingCircle: BoundingCircle

Bounding circle in vertex coordinate space

children: Node2[]

Array of children for this transform

layer: number

Integer representing the layer of this transform

localBoundsDirty: boolean
localMatrixDirty: boolean
localMatrixUpdated: boolean
localToParentMatrix: Matrix3

Matrix3 representing the transformation matrix in local space

localToWorldMatrix: Matrix3

Matrix3 representing the transformation matrix in world space

parent: null | Node2

Parent transform for this transform

visible: boolean

Boolean indicating whether this transform should be rendered

worldBoundsDirty: boolean
worldMatrixDirty: boolean

Accessors

Methods

  • Adds a child Node2 to the current Node2

    Parameters

    • child: Node2

      The child Node2 to add

    Returns void

  • Recursively draws the Node2 object and its children

    Returns void

  • Checks if this Node2 intersects another Node2, using either a BoundingCircle or AxisAlignedBoundingBox

    Returns

    A boolean indicating whether the two objects intersect

    Parameters

    • other: Node2

      The Node2 to check for intersection with

    • mode: IntersectionMode2 = IntersectionMode2.BOUNDING_CIRCLE

      The IntersectionMode2 to use for the comparison (default: BOUNDING_CIRCLE)

    • space: CoordinateSpace2 = CoordinateSpace2.LOCAL_SPACE

      The CoordinateSpace2 to use for the comparison (default: LOCAL_SPACE)

    Returns boolean

  • Looks at a target vector with the given look vector

    Parameters

    • target: Vector2

      The vector to look at

    • lookVector: Vector2 = Vector2.UP

      The vector used to determine the look direction (defaults to Vector2.UP)

    • coordinateSpace: CoordinateSpace2 = CoordinateSpace2.LOCAL_SPACE

    Returns void

  • Removes the current Node2 from its parent

    Returns

    True if the Node2 was successfully removed, false otherwise

    Returns boolean

  • Removes the specified child Node2 from the current Node2

    Returns

    The removed Node2, or null if it was not found

    Parameters

    • child: Node2

      The child Node2 to remove

    Returns null | Node2

  • Traverses the scene graph starting from the current Node2 object

    Parameters

    • parentMatrixDirty: boolean = false

    Returns void

  • Updates the world matrix of the current Node2 object and its parent

    Returns void

Generated using TypeDoc