base/vector3
3차원 벡터.
3D vector.
Vector3extends Object
3차원 벡터.
3D vector.
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());생성.
Constructor.
생성. (정적)
Creates. (static)
- xnumber
- X 좌표.X coordinate.
- ynumber
- Y 좌표.Y coordinate.
- znumber
- Z 좌표.Z coordinate.
반환ReturnsVector3 새 벡터.A new vector.
짝Counterpart: vanilla-engine Vector3.create
영벡터 생성. (정적)
Creates a zero vector. (static)
반환ReturnsVector3 (0, 0, 0) 벡터.A (0, 0, 0) vector.
짝Counterpart: vanilla-engine Vector3.zero
일벡터 생성. (정적)
Creates a one vector. (static)
반환ReturnsVector3 (1, 1, 1) 벡터.A (1, 1, 1) vector.
짝Counterpart: vanilla-engine Vector3.one
위쪽 단위벡터 생성. (정적)
Creates an up unit vector. (static)
반환ReturnsVector3 (0, 1, 0) 벡터.A (0, 1, 0) vector.
짝Counterpart: vanilla-engine Vector3.up
선형 보간. (정적)
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
X 좌표 반환 프로퍼티. X 좌표 설정 프로퍼티.
X coordinate getter property. X coordinate setter property.
반환Returnsnumber X 좌표.X coordinate.
짝Counterpart: vanilla-engine Vector3.x
Y 좌표 반환 프로퍼티. Y 좌표 설정 프로퍼티.
Y coordinate getter property. Y coordinate setter property.
반환Returnsnumber Y 좌표.Y coordinate.
짝Counterpart: vanilla-engine Vector3.y
Z 좌표 반환 프로퍼티. Z 좌표 설정 프로퍼티.
Z coordinate getter property. Z coordinate setter property.
반환Returnsnumber Z 좌표.Z coordinate.
짝Counterpart: vanilla-engine Vector3.z
비교.
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.
대입.
Assignment.
- xnumber
- X 좌표.X coordinate.
- ynumber
- Y 좌표.Y coordinate.
- znumber
- Z 좌표.Z coordinate.
짝Counterpart: vanilla-engine Vector3.set
가로축 반환.
Returns the horizontal axis.
반환Returnsnumber X 좌표.X coordinate.
짝Counterpart: vanilla-engine Vector3.get_x
세로축 반환.
Returns the vertical axis.
반환Returnsnumber Y 좌표.Y coordinate.
짝Counterpart: vanilla-engine Vector3.get_y
깊이축 반환.
Returns the depth axis.
반환Returnsnumber Z 좌표.Z coordinate.
짝Counterpart: vanilla-engine Vector3.get_z
길이 제곱.
Squared length.
반환Returnsnumber 길이의 제곱.Squared length.
짝Counterpart: vanilla-engine Vector3.length_squared
정규화.
Normalize.
반환ReturnsVector3 길이를 1 로 맞춘 새 벡터. (길이가 0 이면 그대로 복사한다)A new vector scaled to length 1. (copied as is if the length is 0)
짝Counterpart: vanilla-engine Vector3.normalize
더하기.
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
빼기.
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
곱하기.
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
나누기.
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
수 더하기. (모든 성분에 같은 수, 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
수 빼기. (모든 성분에 같은 수, 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
수 곱하기. (모든 성분에 같은 수, 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
수 나누기. (모든 성분에 같은 수, 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
내적.
Dot product.
- otherVector3
- 내적할 벡터.Vector for the dot product.
반환Returnsnumber 내적 값.Dot product.
짝Counterpart: vanilla-engine Vector3.dot
외적.
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
거리.
Distance.
- otherVector3
- 거리를 잴 벡터.Vector to measure the distance to.
반환Returnsnumber 두 점 사이의 거리.Distance between the two points.
짝Counterpart: vanilla-engine Vector3.distance