Vec3 Class

Extends ValueType

Module: cc Parent Module: cc

Representation of 3D vectors and points.

Index

Properties
  • ONE Vec3 return a Vec3 object with x = 1, y = 1, z = 1.
  • ZERO Vec3 return a Vec3 object with x = 0, y = 0, z = 0.
  • UP Vec3 return a Vec3 object with x = 0, y = 1, z = 0.
  • RIGHT Vec3 return a Vec3 object with x = 1, y = 0, z = 0.
  • FRONT Vec3 return a Vec3 object with x = 0, y = 0, z = 1.
  • x Number
  • y Number
  • z Number
Methods
  • zero The target of an assignment zero vector
  • clone Obtaining copy vectors designated
  • copy Copy the target vector
  • set Set to value
  • add Element-wise vector addition
  • subtract Element-wise vector subtraction
  • multiply Element-wise vector multiplication (product component)
  • divide Element-wise vector division
  • ceil Rounding up by elements of the vector
  • floor Element vector by rounding down
  • min The minimum by-element vector
  • max The maximum value of the element-wise vector
  • round Element-wise vector of rounding to whole
  • multiplyScalar Vector scalar multiplication
  • scaleAndAdd Element-wise vector multiply add: A + B * scale
  • distance Seeking two vectors Euclidean distance
  • squaredDistance Euclidean distance squared seeking two vectors
  • len Seeking vector length
  • lengthSqr Seeking squared vector length
  • negate By taking the negative elements of the vector
  • inverse Element vector by taking the inverse, return near 0 Infinity
  • inverseSafe Element vector by taking the inverse, return near 0 0
  • normalize Normalized vector
  • dot Vector dot product (scalar product)
  • cross Vector cross product (vector product)
  • lerp Vector element by element linear interpolation: A + t * (B - A)
  • random Generates a uniformly distributed random vectors on the unit sphere
  • transformMat4 Four-dimensional vector and matrix multiplication, the default vectors fourth one.
  • transformMat4Normal Four-dimensional vector and matrix multiplication, vector fourth default is 0.
  • transformMat3 Dimensional vector matrix multiplication
  • transformQuat Vector quaternion multiplication
  • rotateX Rotation vector specified angle about the X axis
  • rotateY Rotation vector specified angle around the Y axis
  • rotateZ Around the Z axis specified angle vector
  • strictEquals Equivalent vectors Analyzing
  • equals Negative error vector floating point approximately equivalent Analyzing
  • angle Radian angle between two vectors seek
  • projectOnPlane Calculating a projection vector in the specified plane
  • project Projection vector calculated in the vector designated
  • toArray Vector transfer array
  • fromArray Array steering amount
  • constructor Constructor
  • clone clone a Vec3 value
  • set Set the current vector value with the given vector.
  • equals Check whether the vector equals another one
  • fuzzyEquals Check whether two vector equal with some degree of variance.
  • toString Transform to string with vector informations
  • lerp Calculate linear interpolation result between this vector and another one with given ratio
  • clampf Clamp the vector between from float and to float.
  • addSelf Adds this vector.
  • add Adds two vectors, and returns the new result.
  • subtract Subtracts one vector from this.
  • multiplyScalar Multiplies this by a number.
  • multiply Multiplies two vectors.
  • divide Divides by a number.
  • negate Negates the components.
  • dot Dot product
  • cross Cross product
  • len Returns the length of this vector.
  • lengthSqr Returns the squared length of this vector.
  • normalizeSelf Make the length of this vector to 1.
  • normalize Note that the current vector is unchanged and a new normalized vector is returned.
  • transformMat4 Transforms the vec3 with a mat4.
  • maxAxis Returns the maximum value in x, y, and z
  • angle Get angle in radian between this and vector.
  • project Calculates the projection of the current vector over the given vector.
  • signAngle Get angle in radian between this and vector with direction.
  • rotate rotate.
  • rotateSelf rotate self.

Details

Properties

ONE

return a Vec3 object with x = 1, y = 1, z = 1.

meta description
Type Vec3
Defined in cocos2d/core/value-types/vec3.ts:81
ZERO

return a Vec3 object with x = 0, y = 0, z = 0.

meta description
Type Vec3
Defined in cocos2d/core/value-types/vec3.ts:91
UP

return a Vec3 object with x = 0, y = 1, z = 0.

meta description
Type Vec3
Defined in cocos2d/core/value-types/vec3.ts:101

return a Vec3 object with x = 1, y = 0, z = 0.

meta description
Type Vec3
Defined in cocos2d/core/value-types/vec3.ts:111
FRONT

return a Vec3 object with x = 0, y = 0, z = 1.

meta description
Type Vec3
Defined in cocos2d/core/value-types/vec3.ts:121
x
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.ts:926
y
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.ts:930
z
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.ts:934

Methods

zero

The target of an assignment zero vector

meta description
Defined in cocos2d/core/value-types/vec3.ts:132
clone

Obtaining copy vectors designated

meta description
Defined in cocos2d/core/value-types/vec3.ts:147
copy

Copy the target vector

meta description
Defined in cocos2d/core/value-types/vec3.ts:159
set

Set to value

meta description
Defined in cocos2d/core/value-types/vec3.ts:174
add

Element-wise vector addition

meta description
Defined in cocos2d/core/value-types/vec3.ts:189
subtract

Element-wise vector subtraction

meta description
Defined in cocos2d/core/value-types/vec3.ts:204
multiply

Element-wise vector multiplication (product component)

meta description
Defined in cocos2d/core/value-types/vec3.ts:219
divide

Element-wise vector division

meta description
Defined in cocos2d/core/value-types/vec3.ts:234
ceil

Rounding up by elements of the vector

meta description
Defined in cocos2d/core/value-types/vec3.ts:249
floor

Element vector by rounding down

meta description
Defined in cocos2d/core/value-types/vec3.ts:264
min

The minimum by-element vector

meta description
Defined in cocos2d/core/value-types/vec3.ts:279
max

The maximum value of the element-wise vector

meta description
Defined in cocos2d/core/value-types/vec3.ts:294
round

Element-wise vector of rounding to whole

meta description
Defined in cocos2d/core/value-types/vec3.ts:309
multiplyScalar

Vector scalar multiplication

meta description
Defined in cocos2d/core/value-types/vec3.ts:324
scaleAndAdd

Element-wise vector multiply add: A + B * scale

meta description
Defined in cocos2d/core/value-types/vec3.ts:339
distance

Seeking two vectors Euclidean distance

meta description
Defined in cocos2d/core/value-types/vec3.ts:354
squaredDistance

Euclidean distance squared seeking two vectors

meta description
Defined in cocos2d/core/value-types/vec3.ts:369
len

Seeking vector length

meta description
Defined in cocos2d/core/value-types/vec3.ts:384
lengthSqr

Seeking squared vector length

meta description
Defined in cocos2d/core/value-types/vec3.ts:399
negate

By taking the negative elements of the vector

meta description
Defined in cocos2d/core/value-types/vec3.ts:414
inverse

Element vector by taking the inverse, return near 0 Infinity

meta description
Defined in cocos2d/core/value-types/vec3.ts:429
inverseSafe

Element vector by taking the inverse, return near 0 0

meta description
Defined in cocos2d/core/value-types/vec3.ts:444
normalize

Normalized vector

meta description
Defined in cocos2d/core/value-types/vec3.ts:478
dot

Vector dot product (scalar product)

meta description
Defined in cocos2d/core/value-types/vec3.ts:501
cross

Vector cross product (vector product)

meta description
Defined in cocos2d/core/value-types/vec3.ts:513
lerp

Vector element by element linear interpolation: A + t * (B - A)

meta description
Defined in cocos2d/core/value-types/vec3.ts:530
random

Generates a uniformly distributed random vectors on the unit sphere

meta description
Defined in cocos2d/core/value-types/vec3.ts:545
Parameters
  • scale Unknown 生成的向量长度
transformMat4

Four-dimensional vector and matrix multiplication, the default vectors fourth one.

meta description
Defined in cocos2d/core/value-types/vec3.ts:567
transformMat4Normal

Four-dimensional vector and matrix multiplication, vector fourth default is 0.

meta description
Defined in cocos2d/core/value-types/vec3.ts:588
transformMat3

Dimensional vector matrix multiplication

meta description
Defined in cocos2d/core/value-types/vec3.ts:609
transformQuat

Vector quaternion multiplication

meta description
Defined in cocos2d/core/value-types/vec3.ts:645
rotateX

Rotation vector specified angle about the X axis

meta description
Defined in cocos2d/core/value-types/vec3.ts:709
Parameters
  • v Unknown 待旋转向量
  • o Unknown 旋转中心
  • a Unknown 旋转弧度
rotateY

Rotation vector specified angle around the Y axis

meta description
Defined in cocos2d/core/value-types/vec3.ts:741
Parameters
  • v Unknown 待旋转向量
  • o Unknown 旋转中心
  • a Unknown 旋转弧度
rotateZ

Around the Z axis specified angle vector

meta description
Defined in cocos2d/core/value-types/vec3.ts:773
Parameters
  • v Unknown 待旋转向量
  • o Unknown 旋转中心
  • a Unknown 旋转弧度
strictEquals

Equivalent vectors Analyzing

meta description
Defined in cocos2d/core/value-types/vec3.ts:805
equals

Negative error vector floating point approximately equivalent Analyzing

meta description
Defined in cocos2d/core/value-types/vec3.ts:817
angle

Radian angle between two vectors seek

meta description
Defined in cocos2d/core/value-types/vec3.ts:838
projectOnPlane

Calculating a projection vector in the specified plane

meta description
Defined in cocos2d/core/value-types/vec3.ts:859
Parameters
  • a Unknown 待投影向量
  • n Unknown 指定平面的法线
project

Projection vector calculated in the vector designated

meta description
Defined in cocos2d/core/value-types/vec3.ts:873
Parameters
  • a Unknown 待投影向量
  • n Unknown 目标向量
toArray

Vector transfer array

meta description
Defined in cocos2d/core/value-types/vec3.ts:892
Parameters
  • ofs Unknown 数组起始偏移量
fromArray

Array steering amount

meta description
Defined in cocos2d/core/value-types/vec3.ts:909
Parameters
  • ofs Unknown 数组起始偏移量
constructor

Constructor see Cc/vec3:method

meta description
Defined in cocos2d/core/value-types/vec3.ts:940
Parameters
clone

clone a Vec3 value

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:965
set

Set the current vector value with the given vector.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:975
Parameters
  • newValue Vec3 !#en new value to set. !#zh 要设置的新值
equals

Check whether the vector equals another one

meta description
Returns Boolean
Defined in cocos2d/core/value-types/vec3.ts:990
Parameters
fuzzyEquals

Check whether two vector equal with some degree of variance.

meta description
Returns Boolean
Defined in cocos2d/core/value-types/vec3.ts:1002
Parameters
toString

Transform to string with vector informations

meta description
Returns string
Defined in cocos2d/core/value-types/vec3.ts:1022
lerp

Calculate linear interpolation result between this vector and another one with given ratio

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1036
Parameters
  • to Vec3
  • ratio number the interpolation coefficient
  • out Vec3 optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
clampf

Clamp the vector between from float and to float.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1051
Parameters
addSelf

Adds this vector. If you want to save result to another vector, use add() instead.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1070
Parameters
add

Adds two vectors, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1085
Parameters
  • vector Vec3
  • out Vec3 optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
subtract

Subtracts one vector from this.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1101
Parameters
multiplyScalar

Multiplies this by a number.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1116
Parameters
multiply

Multiplies two vectors.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1131
Parameters
divide

Divides by a number.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1146
Parameters
negate

Negates the components.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1161
dot

Dot product

meta description
Returns number
Defined in cocos2d/core/value-types/vec3.ts:1175
Parameters
cross

Cross product

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1186
Parameters
len

Returns the length of this vector.

meta description
Returns number
Defined in cocos2d/core/value-types/vec3.ts:1200
Examples
var v = cc.v2(10, 10);
v.len(); // return 14.142135623730951;
lengthSqr

Returns the squared length of this vector.

meta description
Returns number
Defined in cocos2d/core/value-types/vec3.ts:1213
normalizeSelf

Make the length of this vector to 1.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1223
normalize

Returns this vector with a magnitude of 1.

Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1235
Parameters
  • out Vec3 optional, the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
transformMat4

Transforms the vec3 with a mat4. 4th vector component is implicitly '1'

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1254
Parameters
  • m Mat4 matrix to transform with
  • out Vec3 the receiving vector, you can pass the same vec3 to save result to itself, if not provided, a new vec3 will be created
maxAxis

Returns the maximum value in x, y, and z

meta description
Returns number
Defined in cocos2d/core/value-types/vec3.ts:1267
angle

Get angle in radian between this and vector.

meta description
Returns number
Defined in cocos2d/core/value-types/vec3.ts:1276
Parameters
project

Calculates the projection of the current vector over the given vector.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1284
Parameters
Examples
var v1 = cc.v3(20, 20, 20);
var v2 = cc.v3(5, 5, 5);
v1.project(v2); // Vec3 {x: 20, y: 20, z: 20};
signAngle

Get angle in radian between this and vector with direction.
In order to compatible with the vec2 API.

meta description
Returns number
Defined in cocos2d/core/value-types/vec3.ts:1298
Parameters
rotate

rotate. In order to compatible with the vec2 API.

meta description
Returns Vec2 | Vec3
Defined in cocos2d/core/value-types/vec3.ts:1314
Parameters
  • radians number
  • out Vec3 optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
rotateSelf

rotate self. In order to compatible with the vec2 API.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1328
Parameters

results matching ""

    No results matching ""