Bitbybit Docs
    Preparing search index...

    Class BabylonTransforms

    Builds transformation matrices for moving, rotating and scaling geometry, using the BabylonJS math. A transformation is a 4x4 matrix as 16 numbers in column-major order; most methods return a short list of them that is applied in order, so a rotation about a point is a move to the origin, the rotation, and the move back. Angles are in degrees. The transforms service on the base package builds the same matrices without the engine.

    Index

    Constructors

    rotation

    • Builds a rotation about an axis that passes through a center point, as three matrices applied in order: move the center to the origin, rotate, move back. The angle is in degrees.

      Parameters

      Returns TransformMatrixes

      The list of matrices to apply in order

      const turn = bitbybit.babylon.transforms.rotationCenterAxis({ angle: 90, axis: [0, 1, 0], center: [5, 0, 0] });
      
    • Builds a rotation about a line parallel to the X axis through a center point, as three matrices applied in order: move the center to the origin, rotate, move back. The angle is in degrees.

      Parameters

      Returns TransformMatrixes

      The list of matrices to apply in order

      const turn = bitbybit.babylon.transforms.rotationCenterX({ angle: 90, center: [0, 0, 0] });
      
    • Builds a rotation about a line parallel to the Y axis through a center point, as three matrices applied in order: move the center to the origin, rotate, move back. The angle is in degrees.

      Parameters

      Returns TransformMatrixes

      The list of matrices to apply in order

      const turn = bitbybit.babylon.transforms.rotationCenterY({ angle: 90, center: [0, 0, 0] });
      
    • Builds a rotation about a line parallel to the Z axis through a center point, as three matrices applied in order: move the center to the origin, rotate, move back. The angle is in degrees.

      Parameters

      Returns TransformMatrixes

      The list of matrices to apply in order

      const turn = bitbybit.babylon.transforms.rotationCenterZ({ angle: 90, center: [0, 0, 0] });
      
    • Builds a rotation from three angles about a center point: yaw turns about Y, pitch about X and roll about Z, in degrees. The result is three matrices applied in order: move the center to the origin, rotate, move back.

      Parameters

      Returns TransformMatrixes

      The list of matrices to apply in order

      const turn = bitbybit.babylon.transforms.rotationCenterYawPitchRoll({ yaw: 90, pitch: 0, roll: 0, center: [0, 0, 0] });
      
    • Builds a scale with its own factor per axis, measured from a center point that stays in place, as three matrices applied in order: move the center to the origin, scale, move back.

      Parameters

      Returns TransformMatrixes

      The list of matrices to apply in order

      const stretch = bitbybit.babylon.transforms.scaleCenterXYZ({ center: [5, 5, 5], scaleXyz: [2, 1, 0.5] });
      

    scale

    • Builds a scale with its own factor per axis, measured from the origin; [2, 3, 1] doubles X, triples Y and keeps Z.

      Parameters

      Returns TransformMatrixes

      A list with the one scale matrix

      const stretch = bitbybit.babylon.transforms.scaleXYZ({ scaleXyz: [2, 3, 1] });
      
    • Builds a scale by the same factor on every axis, measured from the origin, so 2 makes everything twice as big and twice as far from the origin.

      Parameters

      Returns TransformMatrixes

      A list with the one scale matrix

      const double = bitbybit.babylon.transforms.uniformScale({ scale: 2 });
      
    • Builds a scale by the same factor on every axis, measured from a center point that stays in place, as three matrices applied in order: move the center to the origin, scale, move back.

      Parameters

      Returns TransformMatrixes

      The list of matrices to apply in order

      const half = bitbybit.babylon.transforms.uniformScaleFromCenter({ scale: 0.5, center: [5, 5, 5] });
      

    translation

    • Builds a move by a vector; [10, 5, 0] moves 10 along X, 5 along Y and nothing along Z.

      Parameters

      Returns TransformMatrixes

      A list with the one translation matrix

      const move = bitbybit.babylon.transforms.translationXYZ({ translation: [10, 5, 0] });
      

    translations

    • Builds one move per vector, for transforming many objects each by its own vector, in the same order.

      Parameters

      Returns TransformMatrixes[]

      One transformation per vector, in the same order

      const moves = bitbybit.babylon.transforms.translationsXYZ({ translations: [[1, 0, 0], [0, 2, 0]] });