Library

CFrame

table

Constructor and helpers for the CFrame datatype (a coordinate frame in 3D space).

Properties

1
NameTypeAccessDescription
identityCFrameread

The identity CFrame (position 0,0,0, no rotation).

since 1.2.0-alpha

Functions

8

#CFrame.new() → CFrame

since 0.6.0-dev

Creates a new CFrame. Accepts no arguments (identity), three numbers (x, y, z), a Vector3 position, two Vector3 values (position, lookAt), seven numbers (x, y, z, qX, qY, qZ, qW -- position + unit quaternion), or twelve numbers (x, y, z, R00..R22 -- position + 3x3 rotation matrix).

Errors

  • LuaError invalid arguments -- Argument combination does not match any CFrame.new overload.

#CFrame.lookAt(at: Vector3, lookAt: Vector3, up: Vector3?) → CFrame

since 0.6.0-dev

Creates a CFrame positioned at at looking toward lookAt, with optional up vector.

Parameters

atVector3

Position.

lookAtVector3

Target to look at.

upVector3?

Up direction (default 0, 1, 0).

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

since 1.2.0-alpha

Creates a CFrame positioned at at looking along direction (a unit-length direction vector), with optional up. Equivalent to lookAt(at, at + direction, up).

Parameters

atVector3

Position.

directionVector3

Forward direction.

upVector3?

Up direction (default 0, 1, 0).

#CFrame.fromMatrix(pos: Vector3, vX: Vector3, vY: Vector3, vZ: Vector3?) → CFrame

since 1.2.0-alpha

Builds a CFrame from a position and orthonormal basis vectors. If vZ is omitted it is derived as cross(vX, vY). The basis vectors are interpreted as columns of the rotation matrix (XVector, YVector, ZVector).

Parameters

posVector3

Position.

vXVector3

Right axis (XVector).

vYVector3

Up axis (YVector).

vZVector3?

Back axis (ZVector). Defaults to vX cross vY.

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

since 1.2.0-alpha

Creates a rotation-only CFrame from Euler angles (rx, ry, rz) applied in XYZ order.

AliasesAngles

Parameters

rxnumber

Rotation around X in radians.

rynumber

Rotation around Y in radians.

rznumber

Rotation around Z in radians.

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

since 1.2.0-alpha

Creates a rotation-only CFrame from Euler angles (rx, ry, rz) applied in YXZ order.

AliasesfromOrientation

Parameters

rxnumber

Rotation around X in radians.

rynumber

Rotation around Y in radians.

rznumber

Rotation around Z in radians.

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

since 1.2.0-alpha

Creates a rotation-only CFrame from Euler angles. Optional fourth argument is an Enum.RotationOrder integer (0=XYZ, 1=XZY, 2=YZX, 3=YXZ, 4=ZXY, 5=ZYX); defaults to XYZ.

Parameters

rxnumber
rynumber
rznumber
ordernumber?

RotationOrder (defaults to XYZ)

#CFrame.fromAxisAngle(axis: Vector3, rotation: number) → CFrame

since 1.2.0-alpha

Creates a rotation-only CFrame from an axis-angle pair (Rodrigues).

Parameters

axisVector3

Rotation axis (need not be unit-length).

rotationnumber

Rotation magnitude in radians.