-
new Vector4(x, y, z, w)
-
四维向量
Name Type Default Description x
Number 0 optional X component
y
Number 0 optional Y component
z
Number 0 optional Z component
w
Number 0 optional W component
Members Show Inherited
Name | Type | Default | Description |
---|---|---|---|
className
|
String | Vector4 |
类名 |
isVector4
|
Boolean | true | |
elements
|
Float32Array |
数据 |
|
x
|
Number |
X component |
|
y
|
Number |
Y component |
|
z
|
Number |
Z component |
|
w
|
Number |
W component |
Methods Show Inherited
-
copy(m){Vector4}
-
Copy the values from one vec4 to this
Name Type Description m
Vector4 the source vector
Returns:
Type Description Vector4 this -
clone(){Vector4}
-
Creates a new vec4 initialized with values from this vector
Returns:
Type Description Vector4 a new Vector4 -
toArray(array, offset){Array}
-
转换到数组
Name Type Default Description array
Array.<number> | TypedArray [] optional 数组
offset
Number 0 optional 数组偏移值
Returns:
Type Description Array -
fromArray(array, offset){this}
-
从数组赋值
Name Type Default Description array
Array.<number> | TypedArray 数组
offset
Number 0 optional 数组偏移值
Returns:
Type Description this -
set(x, y, z, w){Vector4}
-
Set the components of a vec4 to the given values
Name Type Description x
Number X component
y
Number Y component
z
Number Z component
w
Number W component
Returns:
Type Description Vector4 this -
add(a, b){Vector4}
-
Adds two vec4's
Name Type Description a
Vector4 b
Vector4 optional 如果不传,计算 this 和 a 的和
Returns:
Type Description Vector4 this -
subtract(a, b){Vector4}
-
Subtracts vector b from vector a
Name Type Description a
Vector4 b
Vector4 optional 如果不传,计算 this 和 a 的差
Returns:
Type Description Vector4 this -
multiply(a, b){Vector4}
-
Multiplies two vec4's
Name Type Description a
Vector4 b
Vector4 optional 如果不传,计算 this 和 a 的积
Returns:
Type Description Vector4 this -
divide(a, b){Vector4}
-
Divides two vec4's
Name Type Description a
Vector4 b
Vector4 optional 如果不传,计算 this 和 a 的商
Returns:
Type Description Vector4 this -
min(a, b){Vector4}
-
Returns the minimum of two vec4's
Name Type Description a
Vector4 b
Vector4 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Vector4 this -
max(a, b){Vector4}
-
Returns the maximum of two vec4's
Name Type Description a
Vector4 b
Vector4 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Vector4 this -
scale(scale){Vector4}
-
Scales this by a scalar number
Name Type Description scale
Number amount to scale the vector by
Returns:
Type Description Vector4 this -
scaleAndAdd(scale, a, b){Vector4}
-
Adds two vec4'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
Vector4 b
Vector4 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Vector4 this -
distance(a, b){Number}
-
Calculates the euclidian distance between two vec4's
Name Type Description a
Vector4 b
Vector4 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Number distance between a and b -
squaredDistance(a, b){Number}
-
Calculates the squared euclidian distance between two vec4's
Name Type Description a
Vector4 b
Vector4 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){Vector4}
-
Returns the inverse of the components of a vec4
Name Type Default Description a
Vector4 this optional Returns:
Type Description Vector4 this -
dot(a, b){Number}
-
Calculates the dot product of two vec4's
Name Type Description a
Vector4 b
Vector4 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Number product of a and b -
lerp(v, t){Vector4}
-
Performs a linear interpolation between two vec4's
Name Type Description v
Vector4 t
Number interpolation amount between the two vectors
Returns:
Type Description Vector4 this -
random(scale){Vector4}
-
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 Vector4 this -
transformMat4(m){Vector4}
-
Transforms the vec4 with a mat4
Name Type Description m
Matrix4 matrix to transform with
Returns:
Type Description Vector4 this -
transformQuat(q){Vector4}
-
Transforms the vec4 with a quat
Name Type Description q
Quaternion quaternion to transform with
Returns:
Type Description Vector4 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
Vector4 b
Vector4 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
Vector4 b
Vector4 optional 如果不传,计算 this 和 a 的结果
Returns:
Type Description Boolean True if the vectors are equal, false otherwise. -
sub()
-
Alias for
Vector4#subtract
-
mul()
-
Alias for
Vector4#multiply
-
div()
-
Alias for
Vector4#divide
-
dist()
-
Alias for
Vector4#distance
-
sqrDist()
-
Alias for
Vector4#squaredDistance
-
len()
-
Alias for
Vector4#length
-
sqrLen()
-
Alias for
Vector4#squaredLength