vanilladocs
vanillapunch.com
API / base/quaternion

base/quaternion

쿼터니언. (3차원 회전, 골격 애니메이션 보간의 기본 단위)

Quaternion. (3D rotation, the basic unit of skeletal animation interpolation)

Quaternionextends Object

짝Counterpart: vanilla-engine Quaternion

쿼터니언. (3차원 회전, 골격 애니메이션 보간의 기본 단위)

Quaternion. (3D rotation, the basic unit of skeletal animation interpolation)

예제Example두 회전 사이를 보간해 방향 돌리기Interpolate between two rotations and rotate a direction
import { Quaternion, Matrix4 } from "./build/vanilla.js";

const start = Quaternion.identity();
const end = Quaternion.createFromEuler(0, Math.PI / 2, 0);
const halfway = Quaternion.slerp(start, end, 0.5);
console.log(halfway.x, halfway.y, halfway.z, halfway.w);
const rotation = Matrix4.createRotationFromQuaternion(halfway);
const direction = rotation.transformDirection(0, 0, 1);
console.log(direction.x, direction.y, direction.z);
생성자constructorconstructor()#0.3.0 부터since 0.3.0소스source

생성.

Constructor.

정적staticstatic create(x, y, z, w)#0.3.0 부터since 0.3.0소스source

생성. (정적)

Creates. (static)

xnumber
X 성분.X component.
ynumber
Y 성분.Y component.
znumber
Z 성분.Z component.
wnumber
W 성분.W component.

반환ReturnsQuaternion 새 쿼터니언.A new quaternion.

짝Counterpart: vanilla-engine Quaternion.create

정적staticstatic identity()#0.3.0 부터since 0.3.0소스source

단위 쿼터니언 생성. (정적)

Creates an identity quaternion. (static)

반환ReturnsQuaternion 회전이 없는 (0, 0, 0, 1) 쿼터니언.A (0, 0, 0, 1) quaternion with no rotation.

짝Counterpart: vanilla-engine Quaternion.identity

정적staticstatic createFromEuler(xRadian, yRadian, zRadian)#0.3.0 부터since 0.3.0소스source

오일러 각으로 생성. (정적, XYZ 순서 라디안)

Creates from Euler angles. (static, XYZ order, radians)

xRadiannumber
X 축 회전. (라디안)Rotation around the X axis. (radians)
yRadiannumber
Y 축 회전. (라디안)Rotation around the Y axis. (radians)
zRadiannumber
Z 축 회전. (라디안)Rotation around the Z axis. (radians)

반환ReturnsQuaternion 회전 쿼터니언.Rotation quaternion.

짝Counterpart: vanilla-engine Quaternion.create_from_euler

정적staticstatic slerp(from, to, normalizedTime)#0.3.0 부터since 0.3.0소스source

구면 선형 보간. (정적, 최단 경로)

Spherical linear interpolation. (static, shortest path)

fromQuaternion
시작 회전.Start rotation.
toQuaternion
끝 회전.End rotation.
normalizedTimenumber
0 이면 from, 1 이면 to.0 gives from, 1 gives to.

반환ReturnsQuaternion 보간해 정규화한 새 쿼터니언. (짧은 쪽으로 돈다)A new interpolated and normalized quaternion. (takes the shorter path)

짝Counterpart: vanilla-engine Quaternion.slerp

속성propertyget/set x#0.3.0 부터since 0.3.0소스source

X 성분 반환 프로퍼티. X 성분 설정 프로퍼티.

X component getter property. X component setter property.

반환Returnsnumber X 성분.X component.

짝Counterpart: vanilla-engine Quaternion.x

속성propertyget/set y#0.3.0 부터since 0.3.0소스source

Y 성분 반환 프로퍼티. Y 성분 설정 프로퍼티.

Y component getter property. Y component setter property.

반환Returnsnumber Y 성분.Y component.

짝Counterpart: vanilla-engine Quaternion.y

속성propertyget/set z#0.3.0 부터since 0.3.0소스source

Z 성분 반환 프로퍼티. Z 성분 설정 프로퍼티.

Z component getter property. Z component setter property.

반환Returnsnumber Z 성분.Z component.

짝Counterpart: vanilla-engine Quaternion.z

속성propertyget/set w#0.3.0 부터since 0.3.0소스source

W 성분 반환 프로퍼티. W 성분 설정 프로퍼티.

W component getter property. W component setter property.

반환Returnsnumber W 성분.W component.

짝Counterpart: vanilla-engine Quaternion.w

메서드methodclone()#0.3.0 부터since 0.3.0소스source

복제.

Clone.

반환Returnsthis 성분이 같은 새 쿼터니언.A new quaternion with the same components.

메서드methodset(x, y, z, w)#0.3.0 부터since 0.3.0소스source

대입.

Assignment.

xnumber
X 성분.X component.
ynumber
Y 성분.Y component.
znumber
Z 성분.Z component.
wnumber
W 성분.W component.

짝Counterpart: vanilla-engine Quaternion.set

메서드methodnormalize()#0.3.0 부터since 0.3.0소스source

정규화.

Normalize.

반환ReturnsQuaternion 길이를 1 로 맞춘 새 쿼터니언. (길이가 0 이면 단위 쿼터니언)A new quaternion scaled to length 1. (identity if the length is 0)

짝Counterpart: vanilla-engine Quaternion.normalize

메서드methodmultiply(other)#0.3.0 부터since 0.3.0소스source

곱하기. (this 회전 뒤에 other 회전을 로컬로 누적)

Multiply. (Accumulates the other rotation locally after this rotation)

otherQuaternion
뒤에 이을 회전.Rotation to apply after.

반환ReturnsQuaternion 두 회전을 합친 새 쿼터니언. (this × other)A new quaternion combining both rotations. (this × other)

짝Counterpart: vanilla-engine Quaternion.multiply