Open Asterune
CFrame

CFrame

Represents a position and rotation in three-dimensional space.

Behavior

CFrame stores a position and rotation. Multiplication composes transforms: a * b applies b relative to a. Multiplication order affects the result. Transform operations return new values.

Summary

Constructors11
Constants1
  • CFrame.identity: CFrame

    The transform with zero translation and no rotation.

Functions10
  • CFrame.Angles(rx: number, ry: number, rz: number): CFrame

    Creates a rotation from X, Y, and Z angles in radians.

  • CFrame.fromAxisAngle(axis: Vector3, angle: number): CFrame

    Creates a rotation about the specified axis.

  • CFrame.fromEulerAngles(rx: number, ry: number, rz: number, order: EnumItem?): CFrame

    Creates a rotation from Euler angles in radians using the selected rotation order.

  • CFrame.fromEulerAnglesXYZ(rx: number, ry: number, rz: number): CFrame

    Creates a rotation from X, Y, and Z Euler angles in radians.

  • CFrame.fromEulerAnglesYXZ(rx: number, ry: number, rz: number): CFrame

    Creates a rotation from Euler angles in radians, applied in Y-X-Z order.

  • CFrame.fromMatrix(position: Vector3, vX: Vector3, vY: Vector3, vZ: Vector3?): CFrame

    Creates a transform from a position and basis vectors.

  • CFrame.fromOrientation(rx: number, ry: number, rz: number): CFrame

    Creates a rotation from orientation angles in radians.

  • CFrame.lookAlong(at: Vector3, direction: Vector3, up: Vector3?): CFrame

    Creates a transform at at facing the supplied direction.

  • CFrame.lookAt(at: Vector3, target: Vector3, up: Vector3?): CFrame

    Creates a transform at at facing target.

  • CFrame.new(…)

    Creates a transform.

Members26
Properties11
Methods15

Constructors

Angles

CFrame.Angles(rx: number, ry: number, rz: number): CFrame

Creates a rotation from X, Y, and Z angles in radians. Use math.rad to convert degrees.

fromAxisAngle

CFrame.fromAxisAngle(axis: Vector3, angle: number): CFrame

Creates a rotation about the specified axis. The angle is in radians.

fromEulerAngles

CFrame.fromEulerAngles(rx: number, ry: number, rz: number, order: EnumItem?): CFrame

Creates a rotation from Euler angles in radians using the selected rotation order.

fromEulerAnglesXYZ

CFrame.fromEulerAnglesXYZ(rx: number, ry: number, rz: number): CFrame

Creates a rotation from X, Y, and Z Euler angles in radians. Equivalent to Angles.

fromEulerAnglesYXZ

CFrame.fromEulerAnglesYXZ(rx: number, ry: number, rz: number): CFrame

Creates a rotation from Euler angles in radians, applied in Y-X-Z order.

fromMatrix

CFrame.fromMatrix(position: Vector3, vX: Vector3, vY: Vector3, vZ: Vector3?): CFrame

Creates a transform from a position and basis vectors. The optional third basis vector completes the rotation matrix.

fromOrientation

CFrame.fromOrientation(rx: number, ry: number, rz: number): CFrame

Creates a rotation from orientation angles in radians.

identity

CFrame.identity: CFrame

The transform with zero translation and no rotation.

lookAlong

CFrame.lookAlong(at: Vector3, direction: Vector3, up: Vector3?): CFrame

Creates a transform at at facing the supplied direction. The optional up vector controls the roll reference.

lookAt

CFrame.lookAt(at: Vector3, target: Vector3, up: Vector3?): CFrame

Creates a transform at at facing target. The optional up vector controls the roll reference.

new

CFrame.new(…)

Creates a transform. Three numbers specify a position with no rotation. Two positions specify a transform at the first position facing the second.

Properties

LookVector

CFrame.LookVector: Vector3

The forward unit vector.

Position

CFrame.Position: Vector3

The position component as a Vector3.

RightVector

CFrame.RightVector: Vector3

The right-facing unit vector.

Rotation

CFrame.Rotation: CFrame

The rotation of this transform with its translation set to zero.

UpVector

CFrame.UpVector: Vector3

The up-facing unit vector in the transformed coordinate frame.

X

CFrame.X: number

The X component of the translation.

XVector

CFrame.XVector: Vector3

The transform's local X basis vector in world space.

Y

CFrame.Y: number

The Y component of the translation.

YVector

CFrame.YVector: Vector3

The transform's local Y basis vector in world space.

Z

CFrame.Z: number

The Z component of the translation.

ZVector

CFrame.ZVector: Vector3

The transform's local Z basis vector in world space.

Methods

FuzzyEq

CFrame:FuzzyEq(other: CFrame, epsilon: number?): boolean

Returns whether the transforms differ by no more than the supplied tolerance.

GetComponents

CFrame:GetComponents(): (number, number, number, number, number, number, number, number, number, number, number, number)

Returns the three translation components followed by the nine rotation-matrix components.

Inverse

CFrame:Inverse(): CFrame

Returns the inverse transform. Multiplying a transform by its inverse produces the identity transform.

Lerp

CFrame:Lerp(other: CFrame, alpha: number): CFrame

Interpolates position and rotation toward another frame. Rotation follows the shortest path.

Orthonormalize

CFrame:Orthonormalize(): CFrame

Returns a transform whose rotation basis is orthonormal.

PointToObjectSpace

CFrame:PointToObjectSpace(args: ...Vector3): ...Vector3

Converts world-space points into this transform's local space. Translation is included.

PointToWorldSpace

CFrame:PointToWorldSpace(args: ...Vector3): ...Vector3

Converts local-space points into world space. Translation is included.

ToAxisAngle

CFrame:ToAxisAngle(): (Vector3, number)

Returns the rotation axis and angle in radians.

ToEulerAnglesXYZ

CFrame:ToEulerAnglesXYZ(): number, number, number

Returns the rotation as X, Y, and Z Euler angles in radians. Multiple angle triples can represent the same orientation.

ToEulerAnglesYXZ

CFrame:ToEulerAnglesYXZ(): number, number, number

Returns Euler angles in radians using Y-X-Z rotation order.

ToObjectSpace

CFrame:ToObjectSpace(other: CFrame): CFrame

Transforms a world-space frame into coordinates relative to this frame.

ToOrientation

CFrame:ToOrientation(): number, number, number

Returns orientation angles in radians.

ToWorldSpace

CFrame:ToWorldSpace(other: CFrame): CFrame

Transforms a local frame into world space relative to this frame.

VectorToObjectSpace

CFrame:VectorToObjectSpace(args: ...Vector3): ...Vector3

Rotates world-space vectors into local space without applying translation.

VectorToWorldSpace

CFrame:VectorToWorldSpace(args: ...Vector3): ...Vector3

Rotates local-space vectors into world space without applying translation.

Operators

__add · __eq · __mul · __sub · __tostring · __type

Example

Luau
local transform = CFrame.new(0, 5, 0) * CFrame.Angles(0, math.rad(45), 0)

Used by

Accessory · AlignOrientation · Attachment · BasePart · Camera · CFrameValue · CharacterController · Collider · DecalProjector · FogVolume · GeometryPart · IntersectOperation · LightProbeVolume · Model · Motor6D · NegateOperation · Part · PlayerMouse · Pose · ReflectionProbe · SceneFrame · Seat · SpawnLocation · Terrain · Tool · UnionOperation · VehicleSeat · VRService · Workspace

Vector3 · BasePart · Camera