Bitbybit Docs
    Preparing search index...

    Class BabylonNode

    Transform nodes: invisible points with a position and an orientation that meshes and other nodes can be parented to, so a whole group moves as one. Building a hierarchy of nodes is how complex arrangements are placed: turn the parent and every child turns with it. The methods here create nodes, read their axes and positions in world or local space, and move, rotate and reparent them; angles are in degrees.

    Index

    Constructors

    Methods

    • Draws the three axes of a node as colored lines of the given length, parented to it, so its position and orientation can be seen; the default colors are red for X, green for Y and blue for Z.

      Parameters

      • inputs: DrawNodeDto

        The node, the axis colors and the axis length

      Returns void

      bitbybit.babylon.node.drawNode({ node, colorX: "#ff0000", colorY: "#00ff00", colorZ: "#0000ff", size: 2 });
      
    • Draws the three axes of several nodes as colored lines of the given length, each set parented to its node, as drawNode does for one.

      Parameters

      • inputs: DrawNodesDto

        The nodes, the axis colors and the axis length

      Returns void

      bitbybit.babylon.node.drawNodes({ nodes: [nodeA, nodeB], colorX: "#ff0000", colorY: "#00ff00", colorZ: "#0000ff", size: 2 });
      
    • Creates a node at origin turned by the three rotation angles in degrees around X, Y and Z, inside the coordinate system of parent when one is given.

      Parameters

      Returns TransformNode

      The new node

      const node = bitbybit.babylon.node.createNodeFromRotation({ parent: null, origin: [0, 5, 0], rotation: [0, 45, 0] });
      
    • Creates a node parented to the root node of the scene, a fresh starting point for building a hierarchy at the world origin.

      Returns TransformNode

      The new node, whose parent is the scene's root node

      const world = bitbybit.babylon.node.createWorldNode();
      const arm = bitbybit.babylon.node.createNodeFromRotation({ parent: world, origin: [0, 5, 0], rotation: [0, 0, 30] });
    • Reads the direction a node's local Z axis points in world space, with every parent's rotation applied.

      Parameters

      Returns number[]

      The forward direction as a vector

    • Reads the direction a node's local X axis points in world space, with every parent's rotation applied.

      Parameters

      Returns number[]

      The right direction as a vector

    • Reads the direction a node's local Y axis points in world space, with every parent's rotation applied.

      Parameters

      Returns number[]

      The up direction as a vector

    • Reads where a node's origin is in world space, with every parent's transform applied.

      Parameters

      Returns number[]

      The world position as a point

    • Reads the rotation of a node in world space, with every parent's rotation applied, as a 4x4 matrix of 16 numbers.

      Parameters

      Returns number[]

      The rotation as a matrix of 16 numbers

    • Reads the rotation of a node relative to its parent as a 4x4 matrix of 16 numbers; the node must carry a rotation quaternion, which rotate and setDirection give it.

      Parameters

      Returns number[]

      The rotation as a matrix of 16 numbers

    • Lists the nodes and meshes parented directly under a node, the ones that move with it.

      Parameters

      Returns Node[]

      The direct children

    • Reads the node a node is parented to, the one it moves with; a top-level node has none.

      Parameters

      Returns Node

      The parent node

    • Reads a node's position measured in its own local axes rather than its parent's, which differs once the node is rotated.

      Parameters

      Returns number[]

      The position as a point in the node's local space

    • Gives the root node of the scene, the top of the hierarchy that createWorldNode parents to.

      Returns TransformNode

      The root node

    • Reads a node's rotation relative to its parent as three angles in degrees around X, Y and Z.

      Parameters

      Returns number[]

      The rotation angles in degrees

    • Turns a node by angle degrees around an axis that passes through position, so the node orbits that point rather than spinning in place; its children follow.

      Parameters

      Returns void

      bitbybit.babylon.node.rotateAroundAxisWithPosition({ node, position: [0, 0, 0], axis: [0, 1, 0], angle: 90 });
      
    • Turns a node by angle degrees around an axis through its own origin, on top of its current rotation; its children follow.

      Parameters

      • inputs: RotateNodeDto

        The node, the axis direction and the angle in degrees

      Returns void

      bitbybit.babylon.node.rotate({ node, axis: [0, 1, 0], angle: 45 });
      
    • Moves a node to a point in world space, whatever its parents are; its children follow.

      Parameters

      Returns void

      bitbybit.babylon.node.setAbsolutePosition({ node, position: [10, 0, 0] });
      
    • Turns a node so its local Z axis points along direction; its children follow.

      Parameters

      Returns void

      bitbybit.babylon.node.setDirection({ node, direction: [1, 0, 0] });
      
    • Parents a node to another so it moves with it from then on, keeping its current place in the world; a null parent detaches it.

      Parameters

      Returns void

      bitbybit.babylon.node.setParent({ node: wheel, parentNode: car });
      
    • Moves a node by distance scene units along direction, given in the node's own local axes; its children follow.

      Parameters

      Returns void

      bitbybit.babylon.node.translate({ node, direction: [0, 1, 0], distance: 5 });