Vec4 Class

Extends ValueType

Module: cc

Representation of 3D vectors and points.

Index

Properties
  • x Number
  • y Number
  • z Number
  • w Number
Methods
  • constructor Constructor
  • clone clone a Vec4 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 vec4 with a mat4.

Details

Properties

x
meta description
Type Number
Defined in cocos2d/core/value-types/vec4.js:63
y
meta description
Type Number
Defined in cocos2d/core/value-types/vec4.js:67
z
meta description
Type Number
Defined in cocos2d/core/value-types/vec4.js:71
w
meta description
Type Number
Defined in cocos2d/core/value-types/vec4.js:75

Methods

constructor

Constructor see Cc/vec4:method

meta description
Defined in cocos2d/core/value-types/vec4.js:43
Parameters
clone

clone a Vec4 value

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

Set the current vector value with the given vector.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:91
Parameters
  • newValue Vec4 !#en new value to set. !#zh 要设置的新值
equals

Check whether the vector equals another one

meta description
Returns Boolean
Defined in cocos2d/core/value-types/vec4.js:107
Parameters
fuzzyEquals

Check whether two vector equal with some degree of variance.

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

Transform to string with vector informations

meta description
Returns string
Defined in cocos2d/core/value-types/vec4.js:141
lerp

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

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:155
Parameters
  • 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

Clamp the vector between from float and to float.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:170
Parameters
addSelf

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

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:190
Parameters
add

Adds two vectors, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:206
Parameters
  • 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

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

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:223
Parameters
sub

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

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:239
Parameters
  • 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

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

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:256
Parameters
mul

Multiplies by a number, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:272
Parameters
  • 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

Multiplies two vectors.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:289
Parameters
scale

Multiplies two vectors, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:305
Parameters
  • 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

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

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:322
Parameters
div

Divides by a number, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:338
Parameters
  • 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

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

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:355
neg

Negates the components, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:370
Parameters
  • 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

Dot product

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

Cross product

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:397
Parameters
mag

Returns the length of this vector.

meta description
Returns number
Defined in cocos2d/core/value-types/vec4.js:411
Examples
var v = cc.v4(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/vec4.js:428
normalizeSelf

Make the length of this vector to 1.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:442
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 Vec4
Defined in cocos2d/core/value-types/vec4.js:454
Parameters
  • 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
transformMat4

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

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.js:473
Parameters
  • 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

results matching ""

    No results matching ""