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.
  • FORWARD Vec3 return a Vec3 object with x = 0, y = 0, z = 1.
  • x Number
  • y Number
  • z Number
Methods
  • mag Returns the length of this vector.
  • magSqr Returns the squared length of this vector.
  • subSelf Subtracts one vector from this.
  • sub Subtracts one vector from this, and returns the new result.
  • mulSelf Multiplies this by a number.
  • mul Multiplies by a number, and returns the new result.
  • divSelf Divides by a number.
  • div Divides by a number, and returns the new result.
  • scaleSelf Multiplies two vectors.
  • scale Multiplies two vectors, and returns the new result.
  • negSelf Negates the components.
  • neg Negates the components, and returns the new result.
  • 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:174
ZERO

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

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

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

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

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

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

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

meta description
Type Vec3
Defined in cocos2d/core/value-types/vec3.ts:214
x
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.ts:1019
y
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.ts:1023
z
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.ts:1027

Methods

mag

Returns the length of this vector.

meta description
Returns number
Defined in cocos2d/core/value-types/vec3.ts:58
Examples
var v = cc.v3(10, 10, 10);
v.mag(); // return 17.320508075688775;
magSqr

Returns the squared length of this vector.

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

Subtracts one vector from this. If you want to save result to another vector, use sub() instead.

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

Subtracts one vector from this, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:84
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
mulSelf

Multiplies this by a number. If you want to save result to another vector, use mul() instead.

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

Multiplies by a number, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:104
Parameters
  • num number
  • 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
divSelf

Divides by a number. If you want to save result to another vector, use div() instead.

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

Divides by a number, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:124
Parameters
  • num number
  • 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
scaleSelf

Multiplies two vectors.

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

Multiplies two vectors, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:144
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
negSelf

Negates the components. If you want to save result to another vector, use neg() instead.

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

Negates the components, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:163
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
zero

The target of an assignment zero vector

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

Obtaining copy vectors designated

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

Copy the target vector

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

Set to value

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

Element-wise vector addition

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

Element-wise vector subtraction

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

Element-wise vector multiplication (product component)

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

Element-wise vector division

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

Rounding up by elements of the vector

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

Element vector by rounding down

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

The minimum by-element vector

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

The maximum value of the element-wise vector

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

Element-wise vector of rounding to whole

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

Vector scalar multiplication

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

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

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

Seeking two vectors Euclidean distance

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

Euclidean distance squared seeking two vectors

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

Seeking vector length

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

Seeking squared vector length

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

By taking the negative elements of the vector

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

Element vector by taking the inverse, return near 0 Infinity

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

Element vector by taking the inverse, return near 0 0

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

Normalized vector

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

Vector dot product (scalar product)

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

Vector cross product (vector product)

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

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

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

Generates a uniformly distributed random vectors on the unit sphere

meta description
Defined in cocos2d/core/value-types/vec3.ts:638
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:660
transformMat4Normal

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

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

Dimensional vector matrix multiplication

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

Vector quaternion multiplication

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

Rotation vector specified angle about the X axis

meta description
Defined in cocos2d/core/value-types/vec3.ts:802
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:834
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:866
Parameters
  • v Unknown 待旋转向量
  • o Unknown 旋转中心
  • a Unknown 旋转弧度
strictEquals

Equivalent vectors Analyzing

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

Negative error vector floating point approximately equivalent Analyzing

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

Radian angle between two vectors seek

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

Calculating a projection vector in the specified plane

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

Projection vector calculated in the vector designated

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

Vector transfer array

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

Array steering amount

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

Constructor see Cc/vec3:method

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

clone a Vec3 value

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

Set the current vector value with the given vector.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1068
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:1083
Parameters
fuzzyEquals

Check whether two vector equal with some degree of variance.

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

Transform to string with vector informations

meta description
Returns string
Defined in cocos2d/core/value-types/vec3.ts:1115
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:1129
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:1144
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:1163
Parameters
add

Adds two vectors, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1178
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:1194
Parameters
multiplyScalar

Multiplies this by a number.

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

Multiplies two vectors.

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

Divides by a number.

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

Negates the components.

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

Dot product

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

Cross product

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

Returns the length of this vector.

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

Returns the squared length of this vector.

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

Make the length of this vector to 1.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.ts:1316
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:1328
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:1347
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:1360
angle

Get angle in radian between this and vector.

meta description
Returns number
Defined in cocos2d/core/value-types/vec3.ts:1369
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:1377
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:1391
Parameters
rotate

rotate. In order to compatible with the vec2 API.

meta description
Returns Vec2 | Vec3
Defined in cocos2d/core/value-types/vec3.ts:1407
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:1421
Parameters

results matching ""

    No results matching ""