-
new Vector3(x, y, z)
-
三维向量
Name Type Default Description x
Number 0 optional X component
y
Number 0 optional Y component
z
Number 0 optional Z component
Members Show Inherited
Name | Type | Default | Description |
---|---|---|---|
className
|
String | Vector3 |
类名 |
isVector3
|
Boolean | true | |
elements
|
Float32Array |
数据 |
|
x
|
Number |
X component |
|
y
|
Number |
Y component |
|
z
|
Number |
Z component |
Methods Show Inherited
-
copy(m){Vector3}
-
Copy the values from one vec3 to this
Name Type Description m
Vector3 the source vector
Returns:
Type Description Vector3 this -
clone(){Vector3}
-
Creates a new vec3 initialized with values from this vec3
Returns:
Type Description Vector3 a new Vector3 -
toArray(array, offset){Array}
-
转换到数组
Name Type Default Description array
Array.<number> | TypedArray [] optional 数组
offset
Number 0 optional 数组偏移值
Returns:
Type Description Array -
fromArray(array, offset){Vector3}
-
从数组赋值
Name Type Default Description array
Array.<number> | TypedArray 数组
offset
Number 0 optional 数组偏移值
Returns:
Type Description Vector3 this -
set(x, y, z){Vector3}
-
Set the components of a vec3 to the given values
Name Type Description x
Number X component
y
Number Y component
z
Number Z component
Returns:
Type Description Vector3 this -
add(a, b){Vector3}
-
Adds two vec3's
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的和
Returns:
Type Description Vector3 this -
subtract(a, b){Vector3}
-
Subtracts vector b from vector a
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的差
Returns:
Type Description Vector3 this -
multiply(a, b){Vector3}
-
Multiplies two vec3's
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的积
Returns:
Type Description Vector3 this -
divide(a, b){Vector3}
-
Divides two vec3's
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的商
Returns:
Type Description Vector3 this -
min(a, b){Vector3}
-
Returns the minimum of two vec3's
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Vector3 this -
max(a, b){Vector3}
-
Returns the maximum of two vec3's
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Vector3 this -
scale(scale){Vector3}
-
Scales this by a scalar number
Name Type Description scale
Number amount to scale the vector by
Returns:
Type Description Vector3 this -
scaleAndAdd(scale, a, b){Vector3}
-
Adds two vec3's after scaling the second vector by a scalar value
Name Type Description scale
Number the amount to scale the second vector by before adding
a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Vector3 this -
distance(a, b){Number}
-
Calculates the euclidian distance between two vec3's
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Number distance between a and b -
squaredDistance(a, b){Number}
-
Calculates the squared euclidian distance between two vec3's
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Number squared distance between a and b -
length(){Number}
-
Calculates the length of this
Returns:
Type Description Number length of this -
squaredLength(){Number}
-
Calculates the squared length of this
Returns:
Type Description Number squared length of this -
inverse(a){Vector3}
-
Returns the inverse of the components of a vec3
Name Type Default Description a
Vector3 this optional Returns:
Type Description Vector3 this -
dot(a, b){Number}
-
Calculates the dot product of two vec3's
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Number product of a and b -
cross(a, b){Number}
-
Computes the cross product of two vec3's
Name Type Description a
Vector2 b
Vector2 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Number cross product of a and b -
lerp(v, t){Vector3}
-
Performs a linear interpolation between two vec3's
Name Type Description v
Vector3 t
Number interpolation amount between the two vectors
Returns:
Type Description Vector3 this -
hermite(a, b, c, d, t){Vector3}
-
Performs a hermite interpolation with two control points
Name Type Description a
Vector3 b
Vector3 c
Vector3 d
Vector3 t
Number interpolation amount between the two inputs
Returns:
Type Description Vector3 this -
bezier(a, b, c, d, t){Vector3}
-
Performs a bezier interpolation with two control points
Name Type Description a
Vector3 b
Vector3 c
Vector3 d
Vector3 t
Number interpolation amount between the two inputs
Returns:
Type Description Vector3 this -
random(scale){Vector3}
-
Generates a random vector with the given scale
Name Type Default Description scale
Number 1 optional Length of the resulting vector. If ommitted, a unit vector will be returned
Returns:
Type Description Vector3 this -
transformMat3(m){Vector3}
-
Transforms the vec3 with a mat3
Name Type Description m
Matrix3 matrix to transform with
Returns:
Type Description Vector3 this -
transformMat4(m){Vector3}
-
Transforms the vec3 with a mat4
Name Type Description m
Matrix4 matrix to transform with
Returns:
Type Description Vector3 this -
transformDirection(m){Vector3}
-
Transforms the vec3 direction with a mat4
Name Type Description m
Matrix4 matrix to transform with
Returns:
Type Description Vector3 this -
transformQuat(q){Vector3}
-
Transforms the vec3 with a quat
Name Type Description q
Quaternion quaternion to transform with
Returns:
Type Description Vector3 this -
rotateX(origin, rotation){Vector3}
-
Rotate this 3D vector around the x-axis
Name Type Description origin
Vector3 The origin of the rotation
rotation
Number The angle of rotation
Returns:
Type Description Vector3 this -
rotateY(origin, rotation){Vector3}
-
Rotate this 3D vector around the y-axis
Name Type Description origin
Vector3 The origin of the rotation
rotation
Number The angle of rotation
Returns:
Type Description Vector3 this -
rotateZ(origin, rotation){Vector3}
-
Rotate this 3D vector around the z-axis
Name Type Description origin
Vector3 The origin of the rotation
rotation
Number The angle of rotation
Returns:
Type Description Vector3 this -
exactEquals(a, b){Boolean}
-
Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Boolean True if the vectors are equal, false otherwise. -
equals(a, b){Boolean}
-
Returns whether or not the vectors have approximately the same elements in the same position.
Name Type Description a
Vector3 b
Vector3 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Boolean True if the vectors are equal, false otherwise. -
sub()
-
Alias for
Vector3#subtract
-
mul()
-
Alias for
Vector3#multiply
-
div()
-
Alias for
Vector3#divide
-
dist()
-
Alias for
Vector3#distance
-
sqrDist()
-
Alias for
Vector3#squaredDistance
-
len()
-
Alias for
Vector3#length
-
sqrLen()
-
Alias for
Vector3#squaredLength