vanilladocs
vanillapunch.com
API / base/vector3

base/vector3

3차원 벡터.

3D vector.

Vector3extends Object

짝Counterpart: vanilla-engine Vector3

3차원 벡터.

3D vector.

예제Example만들고 외적, 정규화하기Create, cross and normalize
import { Vector3 } from "./build/vanilla.js";

const right = Vector3.create(1, 0, 0);
const up = Vector3.up();
const forward = right.cross(up);
const offset = Vector3.create(3, 0, 4);
const direction = offset.normalize();
console.log(forward.x, forward.y, forward.z);
console.log(direction.x, direction.z, direction.length());
생성자constructorconstructor()#0.3.0 부터since 0.3.0소스source

생성.

Constructor.

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

생성. (정적)

Creates. (static)

xnumber
X 좌표.X coordinate.
ynumber
Y 좌표.Y coordinate.
znumber
Z 좌표.Z coordinate.

반환ReturnsVector3 새 벡터.A new vector.

짝Counterpart: vanilla-engine Vector3.create

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

영벡터 생성. (정적)

Creates a zero vector. (static)

반환ReturnsVector3 (0, 0, 0) 벡터.A (0, 0, 0) vector.

짝Counterpart: vanilla-engine Vector3.zero

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

일벡터 생성. (정적)

Creates a one vector. (static)

반환ReturnsVector3 (1, 1, 1) 벡터.A (1, 1, 1) vector.

짝Counterpart: vanilla-engine Vector3.one

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

위쪽 단위벡터 생성. (정적)

Creates an up unit vector. (static)

반환ReturnsVector3 (0, 1, 0) 벡터.A (0, 1, 0) vector.

짝Counterpart: vanilla-engine Vector3.up

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

선형 보간. (정적)

Linear interpolation. (static)

fromVector3
시작 벡터.Start vector.
toVector3
끝 벡터.End vector.
normalizedTimenumber
0 이면 from, 1 이면 to. (0 ~ 1 밖이어도 자르지 않고 늘여 보간한다)0 gives from, 1 gives to. (values outside 0 ~ 1 are not clamped and extrapolate)

반환ReturnsVector3 보간한 새 벡터.A new interpolated vector.

짝Counterpart: vanilla-engine Vector3.lerp

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

X 좌표 반환 프로퍼티. X 좌표 설정 프로퍼티.

X coordinate getter property. X coordinate setter property.

반환Returnsnumber X 좌표.X coordinate.

짝Counterpart: vanilla-engine Vector3.x

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

Y 좌표 반환 프로퍼티. Y 좌표 설정 프로퍼티.

Y coordinate getter property. Y coordinate setter property.

반환Returnsnumber Y 좌표.Y coordinate.

짝Counterpart: vanilla-engine Vector3.y

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

Z 좌표 반환 프로퍼티. Z 좌표 설정 프로퍼티.

Z coordinate getter property. Z coordinate setter property.

반환Returnsnumber Z 좌표.Z coordinate.

짝Counterpart: vanilla-engine Vector3.z

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

비교.

Comparison.

otherany
비교할 값.Value to compare.

반환Returnsboolean 같은 객체이거나 x, y, z 가 모두 같은 Vector3 면 참.True if it is the same object or a Vector3 with the same x, y and z.

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

복제.

Clone.

반환Returnsthis x, y, z 가 같은 새 벡터.A new vector with the same x, y and z.

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

대입.

Assignment.

xnumber
X 좌표.X coordinate.
ynumber
Y 좌표.Y coordinate.
znumber
Z 좌표.Z coordinate.

짝Counterpart: vanilla-engine Vector3.set

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

가로축 반환.

Returns the horizontal axis.

반환Returnsnumber X 좌표.X coordinate.

짝Counterpart: vanilla-engine Vector3.get_x

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

세로축 반환.

Returns the vertical axis.

반환Returnsnumber Y 좌표.Y coordinate.

짝Counterpart: vanilla-engine Vector3.get_y

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

깊이축 반환.

Returns the depth axis.

반환Returnsnumber Z 좌표.Z coordinate.

짝Counterpart: vanilla-engine Vector3.get_z

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

길이.

Length.

반환Returnsnumber 벡터의 길이.Length of the vector.

짝Counterpart: vanilla-engine Vector3.length

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

길이 제곱.

Squared length.

반환Returnsnumber 길이의 제곱.Squared length.

짝Counterpart: vanilla-engine Vector3.length_squared

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

정규화.

Normalize.

반환ReturnsVector3 길이를 1 로 맞춘 새 벡터. (길이가 0 이면 그대로 복사한다)A new vector scaled to length 1. (copied as is if the length is 0)

짝Counterpart: vanilla-engine Vector3.normalize

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

더하기.

Add.

otherVector3 | number
더할 벡터나 수. (수면 세 성분에 같은 수를 더한다, 그 밖의 꼴이면 오류를 던진다)Vector or number to add. (a number is added to all three components, other types throw an error)

반환ReturnsVector3 계산한 새 벡터. (자신은 바뀌지 않는다)A new computed vector. (this vector is not changed)

짝Counterpart: vanilla-engine Vector3.add

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

빼기.

Subtract.

otherVector3 | number
뺄 벡터나 수. (수면 세 성분에 같은 수를 뺀다, 그 밖의 꼴이면 오류를 던진다)Vector or number to subtract. (a number is subtracted from all three components, other types throw an error)

반환ReturnsVector3 계산한 새 벡터. (자신은 바뀌지 않는다)A new computed vector. (this vector is not changed)

짝Counterpart: vanilla-engine Vector3.subtract

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

곱하기.

Multiply.

otherVector3 | number
곱할 벡터나 수. (수면 세 성분에 같은 수를 곱한다, 그 밖의 꼴이면 오류를 던진다)Vector or number to multiply by. (all three components are multiplied by a number, other types throw an error)

반환ReturnsVector3 계산한 새 벡터. (자신은 바뀌지 않는다)A new computed vector. (this vector is not changed)

짝Counterpart: vanilla-engine Vector3.multiply

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

나누기.

Divide.

otherVector3 | number
나눌 벡터나 수. (수면 세 성분을 같은 수로 나눈다, 그 밖의 꼴이면 오류를 던진다)Vector or number to divide by. (all three components are divided by a number, other types throw an error)

반환ReturnsVector3 계산한 새 벡터. (자신은 바뀌지 않는다)A new computed vector. (this vector is not changed)

짝Counterpart: vanilla-engine Vector3.divide

메서드methodaddScalar(scalar)#0.4.0 부터since 0.4.0소스source

수 더하기. (모든 성분에 같은 수, add(number) 와 같다)

Adds a number. (Same number to every component, same as add(number))

scalarnumber
더할 수.Number to add.

반환ReturnsVector3 계산한 새 벡터.A new computed vector.

짝Counterpart: vanilla-engine Vector3.add_scalar

메서드methodsubtractScalar(scalar)#0.4.0 부터since 0.4.0소스source

수 빼기. (모든 성분에 같은 수, subtract(number) 와 같다)

Subtracts a number. (Same number from every component, same as subtract(number))

scalarnumber
뺄 수.Number to subtract.

반환ReturnsVector3 계산한 새 벡터.A new computed vector.

짝Counterpart: vanilla-engine Vector3.subtract_scalar

메서드methodmultiplyScalar(scalar)#0.4.0 부터since 0.4.0소스source

수 곱하기. (모든 성분에 같은 수, multiply(number) 와 같다)

Multiplies by a number. (Same number for every component, same as multiply(number))

scalarnumber
곱할 수.Number to multiply by.

반환ReturnsVector3 계산한 새 벡터.A new computed vector.

짝Counterpart: vanilla-engine Vector3.multiply_scalar

메서드methoddivideScalar(scalar)#0.4.0 부터since 0.4.0소스source

수 나누기. (모든 성분에 같은 수, divide(number) 와 같다)

Divides by a number. (Same number for every component, same as divide(number))

scalarnumber
나눌 수.Number to divide by.

반환ReturnsVector3 계산한 새 벡터.A new computed vector.

짝Counterpart: vanilla-engine Vector3.divide_scalar

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

내적.

Dot product.

otherVector3
내적할 벡터.Vector for the dot product.

반환Returnsnumber 내적 값.Dot product.

짝Counterpart: vanilla-engine Vector3.dot

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

외적.

Cross product.

otherVector3
외적할 벡터.Vector for the cross product.

반환ReturnsVector3 this 와 other 에 수직인 새 벡터. (this × other)A new vector perpendicular to this and other. (this × other)

짝Counterpart: vanilla-engine Vector3.cross

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

거리.

Distance.

otherVector3
거리를 잴 벡터.Vector to measure the distance to.

반환Returnsnumber 두 점 사이의 거리.Distance between the two points.

짝Counterpart: vanilla-engine Vector3.distance