Vec3 Class

Extends ValueType

Module: cc

Representation of 3D vectors and points.

Index

Properties
  • x Number
  • y Number
  • z Number
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.
  • 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:68
y
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.js:71
z
meta description
Type Number
Defined in cocos2d/core/value-types/vec3.js:74

Methods

constructor

Constructor see Cc/vec3:method

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

clone a Vec3 value

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

Set the current vector value with the given vector.

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

Check whether two vector equal with some degree of variance.

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

Transform to string with vector informations

meta description
Returns string
Defined in cocos2d/core/value-types/vec3.js:138
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:152
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:167
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:186
Parameters
add

Adds two vectors, and returns the new result.

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

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

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

Multiplies by a number, and returns the new result.

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

Multiplies two vectors, and returns the new result.

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

Divides by a number, and returns the new result.

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

Negates the components, and returns the new result.

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

Cross product

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

Returns the length of this vector.

meta description
Returns number
Defined in cocos2d/core/value-types/vec3.js:395
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:408
normalizeSelf

Make the length of this vector to 1.

meta description
Returns Vec3
Defined in cocos2d/core/value-types/vec3.js:418
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:430
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:449
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
v3

The convenience method to create a new cc.Vec3.

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