Vec3 Class

Extends ValueType

Module: cc Parent Module: cc

Representation of 3D vectors and points.

Index

Properties
  • x Number
  • y Number
  • z Number
  • 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.
Methods
  • 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.
  • 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.
  • scaleSelf Multiplies two vectors.
  • scale Multiplies two vectors, and returns the new result.
  • divSelf Divides by a number.
  • div Divides by a number, and returns the new result.
  • negSelf Negates the components.
  • neg Negates the components, and returns the new result.
  • dot Dot product
  • cross Cross product
  • mag Returns the length of this vector.
  • magSqr 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.
  • 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.
  • v3 The convenience method to create a new cc.Vec3.

Details

Properties

x
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.js:70
y
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.js:73
z
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.js:76
ONE

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

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

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

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

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

meta description
Type Vec3
Defined in cocos2d/core/value-types/vec3.js:550

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

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

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

meta description
Type Vec3
Defined in cocos2d/core/value-types/vec3.js:572

Methods

constructor

Constructor see Cc/vec3:method

meta description
Defined in cocos2d/core/value-types/vec3.js:46
Parameters
clone

clone a Vec3 value

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

Set the current vector value with the given vector.

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

Check whether two vector equal with some degree of variance.

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

Transform to string with vector informations

meta description
Returns string
Defined in cocos2d/core/value-types/vec3.js:140
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.js:154
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.js:169
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.js:188
Parameters
add

Adds two vectors, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:203
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
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.js:219
Parameters
sub

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

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:234
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.js:250
Parameters
mul

Multiplies by a number, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:265
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.js:281
Parameters
scale

Multiplies two vectors, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:296
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
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.js:312
Parameters
div

Divides by a number, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:327
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.js:343
neg

Negates the components, and returns the new result.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:357
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
dot

Dot product

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

Cross product

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:383
Parameters
mag

Returns the length of this vector.

meta description
Returns number
Defined in cocos2d/core/value-types/vec3.js:397
Examples
var v = cc.v2(10, 10);
v.mag(); // return 14.142135623730951;
magSqr

Returns the squared length of this vector.

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

Make the length of this vector to 1.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:420
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.js:432
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.js:451
Parameters
  • m Mat4 matrix to transform with
    • m00 Number Component in column 0, row 0 position (index 0)
    • m01 Number Component in column 0, row 1 position (index 1)
    • m02 Number Component in column 0, row 2 position (index 2)
    • m03 Number Component in column 0, row 3 position (index 3)
    • m10 Number Component in column 1, row 0 position (index 4)
    • m11 Number Component in column 1, row 1 position (index 5)
    • m12 Number Component in column 1, row 2 position (index 6)
    • m13 Number Component in column 1, row 3 position (index 7)
    • m20 Number Component in column 2, row 0 position (index 8)
    • m21 Number Component in column 2, row 1 position (index 9)
    • m22 Number Component in column 2, row 2 position (index 10)
    • m23 Number Component in column 2, row 3 position (index 11)
    • m30 Number Component in column 3, row 0 position (index 12)
    • m31 Number Component in column 3, row 1 position (index 13)
    • m32 Number Component in column 3, row 2 position (index 14)
    • m33 Number Component in column 3, row 3 position (index 15)
  • 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
angle

Get angle in radian between this and vector.

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

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

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:472
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.js:487
Parameters
rotate

rotate. In order to compatible with the vec2 API.

meta description
Returns Vec2 | Vec3
Defined in cocos2d/core/value-types/vec3.js:502
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.js:515
Parameters
v3

The convenience method to create a new cc.Vec3.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:583
Parameters
Examples
var v1 = cc.v3();
var v2 = cc.v3(0, 0, 0);
var v3 = cc.v3(v2);
var v4 = cc.v3({x: 100, y: 100, z: 0});

results matching ""

    No results matching ""