Vec4 类型
继承于 ValueType
模块: cc
父模块: cc
表示 3D 向量和坐标
索引
属性(properties)
x Number
y Number
z Number
w Number
方法
Details
属性(properties)
x
y
z
w
方法
constructor
构造函数,可查看 Cc/vec4:method
参数列表
clone
克隆一个 Vec4 值
set
用另一个向量设置当前的向量对象值。
参数列表
newValue Vec4 !#en new value to set. !#zh 要设置的新值
equals
当前的向量是否与指定的向量相等。
参数列表
fuzzyEquals
近似判断两个点是否相等。
判断 2 个向量是否在指定数值的范围之内,如果在则返回 true,反之则返回 false。
参数列表
toString
转换为方便阅读的字符串。
lerp
线性插值。
参数列表
to Vec4
ratio number the interpolation coefficient
out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
clampf
返回指定限制区域后的向量。
向量大于 max_inclusive 则返回 max_inclusive。
向量小于 min_inclusive 则返回 min_inclusive。
否则返回自身。
参数列表
addSelf
向量加法。如果你想保存结果到另一个向量,使用 add() 代替。
参数列表
add
向量加法,并返回新结果。
参数列表
vector Vec4
out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
subSelf
向量减法。如果你想保存结果到另一个向量,可使用 sub() 代替。
参数列表
sub
向量减法,并返回新结果。
参数列表
vector Vec4
out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
mulSelf
缩放当前向量。如果你想结果保存到另一个向量,可使用 mul() 代替。
参数列表
mul
缩放向量,并返回新结果。
参数列表
num number
out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
scaleSelf
分量相乘。
参数列表
scale
分量相乘,并返回新的结果。
参数列表
vector Vec4
out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
divSelf
向量除法。如果你想结果保存到另一个向量,可使用 div() 代替。
参数列表
div
向量除法,并返回新的结果。
参数列表
num number
out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
negSelf
向量取反。如果你想结果保存到另一个向量,可使用 neg() 代替。
neg
返回取反后的新向量。
参数列表
out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
dot
当前向量与指定向量进行点乘。
参数列表
cross
当前向量与指定向量进行叉乘。
参数列表
mag
返回该向量的长度。
示例
var v = cc.v4(10, 10);
v.mag();
magSqr
返回该向量的长度平方。
normalizeSelf
向量归一化,让这个向量的长度为 1。
normalize
返回归一化后的向量。
注意,当前向量不变,并返回一个新的归一化向量。如果你想来归一化当前向量,可使用 normalizeSelf 函数。
参数列表
out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
Transforms the vec4 with a mat4. 4th vector component is implicitly '1'
参数列表
m Mat4 matrix to transform with
out Vec4 the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created