Record Class Transform

java.lang.Object
java.lang.Record
dev.engine.core.scene.component.Transform
All Implemented Interfaces:
Component

public record Transform(Vec3 position, Quat rotation, Vec3 scale) extends Record implements Component
Spatial transform: position, rotation, scale. Not every entity needs one — a timer or audio source might not.
  • Field Details

    • IDENTITY

      public static final Transform IDENTITY
  • Constructor Details

    • Transform

      public Transform(Vec3 position, Quat rotation, Vec3 scale)
      Creates an instance of a Transform record class.
      Parameters:
      position - the value for the position record component
      rotation - the value for the rotation record component
      scale - the value for the scale record component
  • Method Details

    • at

      public static Transform at(Vec3 position)
    • at

      public static Transform at(float x, float y, float z)
    • withPosition

      public Transform withPosition(Vec3 position)
    • withPosition

      public Transform withPosition(float x, float y, float z)
    • withRotation

      public Transform withRotation(Quat rotation)
    • withScale

      public Transform withScale(Vec3 scale)
    • withScale

      public Transform withScale(float uniform)
    • moved

      public Transform moved(Vec3 offset)
      Translates by offset (adds to current position).
    • moved

      public Transform moved(float dx, float dy, float dz)
    • rotated

      public Transform rotated(Vec3 axis, float radians)
      Rotates incrementally around an axis.
    • rotatedX

      public Transform rotatedX(float radians)
    • rotatedY

      public Transform rotatedY(float radians)
    • rotatedZ

      public Transform rotatedZ(float radians)
    • scaledBy

      public Transform scaledBy(float factor)
      Multiplies current scale.
    • lookingAt

      public Transform lookingAt(Vec3 target, Vec3 up)
      Orients to look at a target from current position.
    • toMatrix

      public Mat4 toMatrix()
      Computes the 4x4 local transform matrix.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • position

      public Vec3 position()
      Returns the value of the position record component.
      Returns:
      the value of the position record component
    • rotation

      public Quat rotation()
      Returns the value of the rotation record component.
      Returns:
      the value of the rotation record component
    • scale

      public Vec3 scale()
      Returns the value of the scale record component.
      Returns:
      the value of the scale record component