|
@@ -10,35 +10,64 @@
|
|
|
<body>
|
|
|
<h1>[name]</h1>
|
|
|
|
|
|
- <div class="desc">3D vector.</div>
|
|
|
+ <div class="desc">Class representing a 3D [link:https://en.wikipedia.org/wiki/Vector_space vector].
|
|
|
+
|
|
|
+ A 3D vector is an ordered triplet of numbers (labeled x, y, and z), which can be used to
|
|
|
+ represent a number of things, such as:
|
|
|
+
|
|
|
+ <ul>
|
|
|
+ <li>
|
|
|
+ A point in 3D space.
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ A direction and length in 3D space. In Three the length will always be the
|
|
|
+ [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean distance]
|
|
|
+ (straight-line distance) from (0, 0, 0) to (x, y, z) and the direction is also
|
|
|
+ measured from (0, 0, 0) towards (x, y, z).
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ Any arbitrary ordered triplet of numbers.
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+
|
|
|
+ There are other things a 3D vector can be used to represent, such as momentum
|
|
|
+ vectors and so on, however these are the most common uses in Three.
|
|
|
+ </div>
|
|
|
|
|
|
|
|
|
<h2>Example</h2>
|
|
|
|
|
|
- <code>var a = new THREE.Vector3( 1, 0, 0 );
|
|
|
- var b = new THREE.Vector3( 0, 1, 0 );
|
|
|
+ <code>
|
|
|
+var a = new THREE.Vector3( 0, 1, 0 );
|
|
|
+
|
|
|
+//no arguments; will be initialised to (0, 0, 0)
|
|
|
+var b = new THREE.Vector3( );
|
|
|
|
|
|
- var c = new THREE.Vector3();
|
|
|
- c.crossVectors( a, b );
|
|
|
+var d = a.distanceTo( b );
|
|
|
</code>
|
|
|
|
|
|
|
|
|
<h2>Constructor</h2>
|
|
|
|
|
|
-
|
|
|
<h3>[name]( [page:Float x], [page:Float y], [page:Float z] )</h3>
|
|
|
<div>
|
|
|
- x -- [page:Float] the vector's x value <br />
|
|
|
- y -- [page:Float] the vector's y value <br />
|
|
|
- z -- [page:Float] the vector's z value
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- A 3 dimensional vector
|
|
|
+ [page:Float x] - the x value of the vector. Default is *0*.<br />
|
|
|
+ [page:Float y] - the y value of the vector. Default is *0*.<br />
|
|
|
+ [page:Float z] - the z value of the vector. Default is *0*.<br /><br />
|
|
|
+
|
|
|
+ Creates a new [name].
|
|
|
</div>
|
|
|
|
|
|
|
|
|
<h2>Properties</h2>
|
|
|
|
|
|
+ <h3>[property:Boolean isVector3]</h3>
|
|
|
+ <div>
|
|
|
+ Used to check whether this or derived classes are Vector3s. Default is *true*.<br /><br />
|
|
|
+
|
|
|
+ You should not change this, as it used internally for optimisation.
|
|
|
+ </div>
|
|
|
+
|
|
|
<h3>[property:Float x]</h3>
|
|
|
|
|
|
<h3>[property:Float y]</h3>
|
|
@@ -48,443 +77,381 @@
|
|
|
|
|
|
<h2>Methods</h2>
|
|
|
|
|
|
- <h3>[method:Vector3 set]( [page:Float x], [page:Float y], [page:Float z] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- Sets value of this vector.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 add]( [page:Vector3 v] )</h3>
|
|
|
+ <div>Adds [page:Vector3 v] to this vector.</div>
|
|
|
|
|
|
- <h3>[method:Vector3 setX]( [page:Float x] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- Sets x value of this vector.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 addScalar]( [page:Float s] )</h3>
|
|
|
+ <div>Add the scalar value s to this vector's [page:.x x], [page:.y y] and [page:.z z] values.</div>
|
|
|
|
|
|
- <h3>[method:Vector3 setY]( [page:Float y] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- Sets y value of this vector.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 addScaledVector]( [page:Vector3 v], [page:Float s] )</h3>
|
|
|
+ <div>Adds the multiple of [page:Vector3 v] and [page:Float s] to this vector.</div>
|
|
|
|
|
|
- <h3>[method:Vector3 setZ]( [page:Float z] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- Sets z value of this vector.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 addVectors]( [page:Vector3 a], [page:Vector3 b] )</h3>
|
|
|
+ <div>Sets this vector to [page:Vector3 a] + [page:Vector3 b].</div>
|
|
|
|
|
|
- <h3>[method:Vector3 setScalar]( [page:Float scalar] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- scalar -- [page:Float]
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 applyAxisAngle]( [page:Vector3 axis], [page:Float angle] )</h3>
|
|
|
<div>
|
|
|
- set all component values of this vector to *scalar*.
|
|
|
- </div>
|
|
|
+ [page:Vector3 axis] - A normalized [page:Vector3].<br />
|
|
|
+ [page:Float angle] - An angle in radians.<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector3 copy]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- Copies value of *v* to this vector.
|
|
|
+ Applies a rotation specified by an axis and an angle to this vector.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 fromArray]( [page:Array array], [page:Integer offset] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- array -- The source array in the form [x, y, z].<br />
|
|
|
- offset -- An optional offset into the array.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 applyEuler]( [page:Euler euler] )</h3>
|
|
|
<div>
|
|
|
- Sets the vector's components based on an array formatted like [x, y, z]
|
|
|
+ Applies euler transform to this vector by converting the [page:Euler] object to a
|
|
|
+ [page:Quaternion] and applying.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 add]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- Adds *v* to this vector.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 applyMatrix3]( [page:Matrix3 m] )</h3>
|
|
|
+ <div>Multiply this vector by [page:Matrix3 m]</div>
|
|
|
|
|
|
- <h3>[method:Vector3 addVectors]( [page:Vector3 a], [page:Vector3 b] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 applyMatrix4]( [page:Matrix4 m] )</h3>
|
|
|
<div>
|
|
|
- Sets this vector to *a + b*.
|
|
|
+ Multiply this vector by 4 x 3 subset of a [page:Matrix4 m]. If [page:Matrix4 m] is:
|
|
|
+ <code>
|
|
|
+a, b, c, d,
|
|
|
+e, f, g, h,
|
|
|
+i, j, k, l,
|
|
|
+m, n, o, p
|
|
|
+ </code>
|
|
|
+ Then the 4 x 3 matrix will be:
|
|
|
+ <code>
|
|
|
+a, b, c,
|
|
|
+e, f, g,
|
|
|
+i, j, k,
|
|
|
+m, n, o
|
|
|
+ </code>
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 addScaledVector]( [page:Vector3 v], [page:Float s] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 applyProjection]( [page:Matrix4 m] )</h3>
|
|
|
<div>
|
|
|
- Adds the multiple of v and s to this vector.
|
|
|
+ [page:Matrix4 m] - [page:Matrix4] projection matrix.<br /><br />
|
|
|
+
|
|
|
+ Multiplies this vector and m, and divides by perspective.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 sub]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 applyQuaternion]( [page:Quaternion quaternion] )</h3>
|
|
|
<div>
|
|
|
- Subtracts *v* from this vector.
|
|
|
+ Applies a [page:Quaternion] transform to this vector.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 subVectors]( [page:Vector3 a], [page:Vector3 b] ) [page:Vector3 this]</h3>
|
|
|
+
|
|
|
+ <h3>[method:Float angleTo]( [page:Vector3 v] )</h3>
|
|
|
<div>
|
|
|
- Sets this vector to *a - b*.
|
|
|
+ Returns the angle between this vector and vector [page:Vector3 v] in radians.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 multiplyScalar]( [page:Float s] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 ceil]()</h3>
|
|
|
<div>
|
|
|
- Multiplies this vector by scalar *s*.
|
|
|
+ The [page:.x x], [page:.y y] and [page:.z z] components of the vector are rounded up to the nearest integer value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 divideScalar]( [page:Float s] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 clamp]( [page:Vector3 min], [page:Vector3 max] )</h3>
|
|
|
<div>
|
|
|
- Divides this vector by scalar *s*.<br />
|
|
|
- Set vector to *( 0, 0, 0 )* if *s == 0*.
|
|
|
+ [page:Vector3 min] - the minimum [page:.x x], [page:.y y] and [page:.z z] values.<br />
|
|
|
+ [page:Vector3 max] - the maximum [page:.x x], [page:.y y] and [page:.z z] values in the desired range<br /><br />
|
|
|
+
|
|
|
+ If this vector's x, y or z value is greater than the max vector's x, y or z value, it is replaced by the corresponding value. <br /><br />
|
|
|
+ If this vector's x, y or z value is less than the min vector's x, y or z value, it is replaced by the corresponding value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 negate]() [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 clampLength]( [page:Float min], [page:Float max] )</h3>
|
|
|
<div>
|
|
|
- Inverts this vector.
|
|
|
+ [page:Float min] - the minimum value the length will be clamped to <br />
|
|
|
+ [page:Float max] - the maximum value the length will be clamped to<br /><br />
|
|
|
+
|
|
|
+ If this vector's length is greater than the max value, it is replaced by the max value. <br /><br />
|
|
|
+ If this vector's length is less than the min value, it is replaced by the min value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float dot]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 clampScalar]( [page:Float min], [page:Float max] )</h3>
|
|
|
<div>
|
|
|
- Computes dot product of this vector and *v*.
|
|
|
+ [page:Float min] - the minimum value the components will be clamped to <br />
|
|
|
+ [page:Float max] - the maximum value the components will be clamped to<br /><br />
|
|
|
+
|
|
|
+ If this vector's x, y or z values are greater than the max value, they are replaced by the max value. <br /><br />
|
|
|
+ If this vector's x, y or z values are less than the min value, they are replaced by the min value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float lengthSq]() [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 clone]()</h3>
|
|
|
<div>
|
|
|
- Computes the squared length of this vector.
|
|
|
+ Returns a new vector3 with the same [page:.x x], [page:.y y] and [page:.z z] values as this one.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float length]() [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 copy]( [page:Vector3 v] )</h3>
|
|
|
<div>
|
|
|
- Computes the length of this vector.
|
|
|
+ Copies the values of the passed vector3's [page:.x x], [page:.y y] and [page:.z z]
|
|
|
+ properties to this vector3.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float lengthManhattan]() [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 cross]( [page:Vector3 v] )</h3>
|
|
|
<div>
|
|
|
- Computes the Manhattan length of this vector.<br />
|
|
|
- [link:http://en.wikipedia.org/wiki/Taxicab_geometry]
|
|
|
+ Sets this vector to [link:https://en.wikipedia.org/wiki/Cross_product cross product] of itself and [page:Vector3 v].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 normalize]() [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 crossVectors]( [page:Vector3 a], [page:Vector3 b] )</h3>
|
|
|
<div>
|
|
|
- Normalizes this vector. Transforms this Vector into a Unit vector by dividing the vector by its length.
|
|
|
+ Sets this vector to [link:https://en.wikipedia.org/wiki/Cross_product cross product] of [page:Vector3 a] and [page:Vector3 b].
|
|
|
</div>
|
|
|
|
|
|
<h3>[method:Float distanceTo]( [page:Vector3 v] )</h3>
|
|
|
+ <div>Computes the distance from this vector to [page:Vector3 v].</div>
|
|
|
+
|
|
|
+ <h3>[method:Float distanceToManhattan]( [page:Vector3 v] )</h3>
|
|
|
<div>
|
|
|
- Computes the distance from this vector to *v*.
|
|
|
+ Computes the [link:https://en.wikipedia.org/wiki/Taxicab_geometry Manhattan distance] from this vector to [page:Vector3 v].
|
|
|
</div>
|
|
|
|
|
|
<h3>[method:Float distanceToSquared]( [page:Vector3 v] )</h3>
|
|
|
<div>
|
|
|
- Computes the squared distance from this vector to *v*.
|
|
|
+ Computes the squared distance from this vector to [page:Vector3 v]. If you are just
|
|
|
+ comparing the distance with another distance, you should compare the distance squared instead
|
|
|
+ as it is slightly more efficient to calculate.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float distanceToManhattan]( [page:Vector3 v] )</h3>
|
|
|
- <div>
|
|
|
- Computes the Manhattan distance from this vector to *v*.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 divide]( [page:Vector3 v] )</h3>
|
|
|
+ <div>Divides this vector by [page:Vector3 v].</div>
|
|
|
|
|
|
- <h3>[method:Vector3 setLength]( [page:Float l] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 divideScalar]( [page:Float s] )</h3>
|
|
|
<div>
|
|
|
- Normalizes this vector and multiplies it by *l*.
|
|
|
+ Divides this vector by scalar [page:Float s].<br />
|
|
|
+ Sets vector to *( 0, 0 )* if *[page:Float s] = 0*.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 cross]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Float dot]( [page:Vector3 v] )</h3>
|
|
|
<div>
|
|
|
- Sets this vector to cross product of itself and *v*.
|
|
|
+ Calculate the [link:https://en.wikipedia.org/wiki/Dot_product dot product] of this
|
|
|
+ vector and [page:Vector3 v].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 crossVectors]( [page:Vector3 a], [page:Vector3 b] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- Sets this vector to cross product of *a* and *b*.
|
|
|
- </div>
|
|
|
+ <h3>[method:Boolean equals]( [page:Vector3 v] )</h3>
|
|
|
+ <div>Checks for strict equality of this vector and [page:Vector3 v].</div>
|
|
|
|
|
|
- <h3>[method:Vector3 setFromMatrixPosition]( [page:Matrix4 m] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- Sets this vector extracting position from matrix transform.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 floor]()</h3>
|
|
|
+ <div>The components of the vector are rounded down to the nearest integer value.</div>
|
|
|
|
|
|
- <h3>[method:Vector3 setFromMatrixScale]( [page:Matrix4 m] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 fromArray]( [page:Array array], [page:Integer offset] )</h3>
|
|
|
<div>
|
|
|
- Sets this vector extracting scale from matrix transform.
|
|
|
- </div>
|
|
|
+ [page:Array array] - the source array.<br />
|
|
|
+ [page:Integer offset] - ( optional) offset into the array. Default is 0.<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector3 setFromSpherical]( [page:Spherical s] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- Sets this vector from the spherical coordinates *s*.
|
|
|
+ Sets this vector's [page:.x x] value to be array[ offset + 0 ], [page:.y y] value to be array[ offset + 1 ]
|
|
|
+ and [page:.z z] value to be array[ offset + 2 ].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 setFromCylindrical]( [page:Cylindrical c] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 fromAttribute]( [page:BufferAttribute attribute], [page:Integer index], [page:Integer offset] )</h3>
|
|
|
<div>
|
|
|
- Sets this vector from the cylindrical coordinates *c*.
|
|
|
- </div>
|
|
|
+ [page:BufferAttribute attribute] - the source attribute.<br />
|
|
|
+ [page:Integer index] - index in the attribute.<br /><br />
|
|
|
+ [page:Integer offset] - (optional) offset into the attribute. Default is 0.<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector3 clamp]( [page:Vector3 min], [page:Vector3 max] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- min -- [page:Vector3] <br />
|
|
|
- max -- [page:Vector3]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- If this vector's x, y or z value is greater than the max vector's x, y or z value, it is replaced by the corresponding value. <br /><br />
|
|
|
- If this vector's x, y or z value is less than the min vector's x, y or z value, it is replaced by the corresponding value.
|
|
|
+ Sets this vector's [page:.x x], [page:.y y] and [page:.z z] values from the [page:BufferAttribute attribute].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 clampScalar]( [page:Float min], [page:Float max] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Float getComponent]( [page:Integer index] )</h3>
|
|
|
<div>
|
|
|
- min -- [page:Float] the minimum value the components will be clamped to <br />
|
|
|
- max -- [page:Float] the maximum value the components will be clamped to
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- If this vector's x, y or z values are greater than the max value, they are replaced by the max value. <br /><br />
|
|
|
- If this vector's x, y or z values are less than the min value, they are replaced by the min value.
|
|
|
- </div>
|
|
|
+ [page:Integer index] - 0, 1 or 2.<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector3 clampLength]( [page:Float min], [page:Float max] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- min -- [page:Float] the minimum value the length will be clamped to <br />
|
|
|
- max -- [page:Float] the maximum value the length will be clamped to
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- If this vector's length is greater than the max value, it is replaced by the max value. <br /><br />
|
|
|
- If this vector's length is less than the min value, it is replaced by the min value.
|
|
|
+ If index equals 0 returns the [page:.x x] value. <br />
|
|
|
+ If index equals 1 returns the [page:.y y] value. <br />
|
|
|
+ If index equals 2 returns the [page:.z z] value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 floor]() [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- The components of the vector are rounded downwards (towards negative infinity) to an integer value.
|
|
|
- </div>
|
|
|
+ <h3>[method:Float length]()</h3>
|
|
|
+ <div>Computes the [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean length]
|
|
|
+ (straight-line length) from (0, 0, 0) to (x, y, z).</div>
|
|
|
|
|
|
- <h3>[method:Vector3 ceil]() [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Float lengthManhattan]()</h3>
|
|
|
<div>
|
|
|
- The components of the vector are rounded upwards (towards positive infinity) to an integer value.
|
|
|
+ Computes the [link:http://en.wikipedia.org/wiki/Taxicab_geometry Manhattan length] of this vector.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 round]() [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Float lengthSq]()</h3>
|
|
|
<div>
|
|
|
- The components of the vector are rounded towards the nearest integer value.
|
|
|
+ Computes the square of the [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean length]
|
|
|
+ (straight-line length) from (0, 0, 0) to (x, y, z). If you are comparing the lengths of
|
|
|
+ vectors, you should compare the length squared instead as it is slightly more efficient to calculate.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 roundToZero]() [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 lerp]( [page:Vector3 v], [page:Float alpha] )</h3>
|
|
|
<div>
|
|
|
- The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.
|
|
|
- </div>
|
|
|
+ [page:Vector3 v] - [page:Vector3] to interpolate towards.<br />
|
|
|
+ alpha - interpolation factor in the closed interval [0, 1].<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector3 applyMatrix3]( [page:Matrix3 m] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- m -- [page:Matrix3]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Multiplies this vector times a 3 x 3 matrix.
|
|
|
+ Linearly interpolate between this vector and [page:Vector3 v], where alpha is the
|
|
|
+ distance along the line - alpha = 0 will be this vector, and alpha = 1 will be [page:Vector3 v].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 applyMatrix4]( [page:Matrix3 m] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 lerpVectors]( [page:Vector3 v1], [page:Vector3 v2], [page:Float alpha] )</h3>
|
|
|
<div>
|
|
|
- m -- [page:Matrix4]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Multiplies this vector by 4 x 3 subset of a Matrix4.
|
|
|
- </div>
|
|
|
+ [page:Vector3 v1] - the starting [page:Vector3].<br />
|
|
|
+ [page:Vector3 v2] - [page:Vector3] to interpolate towards.<br />
|
|
|
+ [page:Float alpha] - interpolation factor in the closed interval [0, 1].<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector3 projectOnPlane]( [page:Vector3 planeNormal] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- planeNormal -- [page:Vector3 planeNormal] A vector representing a plane normal.
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Projects this vector onto a plane by subtracting this vector projected onto the plane's normal from this vector.
|
|
|
+ Sets this vector to be the vector linearly interpolated between [page:Vector3 v1] and
|
|
|
+ [page:Vector3 v2] where alpha is the distance along the line connecting the two vectors
|
|
|
+ - alpha = 0 will be [page:Vector3 v1], and alpha = 1 will be [page:Vector3 v2].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 projectOnVector]( [page:Vector3] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- vector -- [page:Vector3]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Projects this vector onto another vector.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 negate]()</h3>
|
|
|
+ <div>Inverts this vector - i.e. sets x = -x, y = -y and z = -z.</div>
|
|
|
|
|
|
- <h3>[method:Vector3 addScalar]( [page:Float] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- s -- [page:Float]
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 normalize]()</h3>
|
|
|
<div>
|
|
|
- Adds a s to this vector.
|
|
|
+ Convert this vector to a [link:https://en.wikipedia.org/wiki/Unit_vector unit vector] - that is, sets it equal to the vector with the same direction
|
|
|
+ as this one, but [page:.length length] 1.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 divide]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- v -- [page:Vector3]
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 max]( [page:Vector3 v] )</h3>
|
|
|
<div>
|
|
|
- Divides this vector by vector v.
|
|
|
+ If this vector's x, y or z value is less than [page:Vector3 v's] x, y or z value, replace
|
|
|
+ that value with the corresponding max value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 min]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- v -- [page:Vector3]
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 min]( [page:Vector3 v] )</h3>
|
|
|
<div>
|
|
|
- If this vector's x, y, or z value is greater than vector v's x, y, or z value, that value is replaced by the corresponding vector v value.
|
|
|
+ If this vector's x, y or z value is greater than [page:Vector3 v's] x, y or z value, replace
|
|
|
+ that value with the corresponding min value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 max]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- v -- [page:Vector3]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- If this vector's x, y, or z value is less than vector v's x, y, or z value, that value is replaced by the corresponding vector v value.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 multiply]( [page:Vector3 v] )</h3>
|
|
|
+ <div>Multiplies this vector by [page:Vector3 v].</div>
|
|
|
|
|
|
- <h3>[method:null setComponent]( [page:Integer index], [page:Float value] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- index -- 0, 1, or 2 <br />
|
|
|
- value -- [page:Float]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- If index equals 0 the method sets this vector's x value to value <br />
|
|
|
- If index equals 1 the method sets this vector's y value to value <br />
|
|
|
- If index equals 2 the method sets this vector's z value to value
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 multiplyScalar]( [page:Float s] )</h3>
|
|
|
+ <div>Multiplies this vector by scalar [page:Float s].</div>
|
|
|
|
|
|
- <h3>[method:Vector3 transformDirection]( [page:Matrix4 m] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- m -- [page:Matrix4]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Transforms the direction of this vector by a matrix (a 3 x 3 subset of a Matrix4) and then normalizes the result.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 multiplyVectors]( [page:Vector3 a], [page:Vector3 b] )</h3>
|
|
|
+ <div>Sets this vector equal to [page:Vector3 a] x [page:Vector3 b].</div>
|
|
|
|
|
|
- <h3>[method:Vector3 multiplyVectors]( [page:Vector3 a], [page:Vector3 b] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 project]( [page:Camera camera] )</h3>
|
|
|
<div>
|
|
|
- a -- [page:Vector3] <br />
|
|
|
- b -- [page:Vector3]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Sets this vector equal to the result of multiplying vector a by vector b.
|
|
|
- </div>
|
|
|
+ [page:Camera camera] — camera to use in the projection.<br /><br />
|
|
|
|
|
|
- <h3>[method:Float getComponent]( [page:Integer index] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- index -- [page:Integer] 0, 1, or 2
|
|
|
+ [link:https://en.wikipedia.org/wiki/Vector_projection Projects] the vector with the camera.
|
|
|
</div>
|
|
|
- <div>
|
|
|
|
|
|
- Returns the value of the vector component x, y, or z by an index. <br /><br />
|
|
|
+ <h3>[method:Vector3 projectOnPlane]( [page:Vector3 planeNormal] )</h3>
|
|
|
+ <div>
|
|
|
+ [page:Vector3 planeNormal] - A vector representing a plane normal.<br /><br />
|
|
|
|
|
|
- Index 0: x <br />
|
|
|
- Index 1: y <br />
|
|
|
- Index 2: z <br />
|
|
|
+ [link:https://en.wikipedia.org/wiki/Vector_projection Projects] this vector onto a plane by subtracting this vector projected onto the plane's
|
|
|
+ normal from this vector.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 applyAxisAngle]( [page:Vector3 axis], [page:Float angle] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- axis -- A normalized [page:Vector3] <br />
|
|
|
- angle -- An angle in radians
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Applies a rotation specified by an axis and an angle to this vector.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 projectOnVector]( [page:Vector3] )</h3>
|
|
|
+ <div>[link:https://en.wikipedia.org/wiki/Vector_projection Projects] this vector onto another vector.</div>
|
|
|
|
|
|
- <h3>[method:Vector3 lerp]( [page:Vector3 v], [page:Float alpha] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- v -- [page:Vector3] <br />
|
|
|
- alpha -- [page:Float] between 0 and 1.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 reflect]( [page:Vector3 normal] )</h3>
|
|
|
<div>
|
|
|
- Linear Interpolation between this vector and vector v, where alpha is the percent along the line.
|
|
|
- </div>
|
|
|
+ [page:Vector3 normal] - the normal to the reflecting plane<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector3 lerpVectors]( [page:Vector3 v1], [page:Vector3 v2], [page:Float alpha] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- v1 -- [page:Vector3] <br />
|
|
|
- v2 -- [page:Vector3] <br />
|
|
|
- alpha -- [page:Float] between 0 and 1.
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Sets this vector to be the vector linearly interpolated between *v1* and *v2* with *alpha* factor.
|
|
|
+ Reflect the vector off of plane orthogonal to [page:Vector3 normal]. Normal is assumed to
|
|
|
+ have unit length.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float angleTo]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- v -- [page:Vector3]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Returns the angle between this vector and vector v in radians.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 round]()</h3>
|
|
|
+ <div>The components of the vector are rounded to the nearest integer value.</div>
|
|
|
|
|
|
- <h3>[method:Vector3 setFromMatrixColumn]( [page:Matrix4 matrix], [page:Integer index] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- matrix -- [page:Matrix4]<br />
|
|
|
- index -- 0, 1, 2, or 3
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 roundToZero]()</h3>
|
|
|
<div>
|
|
|
- Sets this vector's x, y, and z equal to the column of the matrix specified by the index.
|
|
|
+ The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 reflect]( [page:Vector3 normal] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- normal -- [page:Vector3] the normal to the reflecting plane
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Reflect incident vector off of plane orthogonal to normal. Normal is assumed to have unit length.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 set]( [page:Float x], [page:Float y], [page:Float z] )</h3>
|
|
|
+ <div>Sets the [page:.x x], [page:.y y] and [page:.z z] components of this vector.</div>
|
|
|
|
|
|
- <h3>[method:Vector3 multiply]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:null setComponent]( [page:Integer index], [page:Float value] )</h3>
|
|
|
<div>
|
|
|
- v -- [page:Vector3] <br />
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Multiplies this vector by vector v.
|
|
|
- </div>
|
|
|
+ [page:Integer index] - 0, 1 or 2.<br />
|
|
|
+ [page:Float value] - [page:Float]<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector3 applyProjection]( [page:Matrix4 m] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- m -- [page:Matrix4] projection matrix.
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Multiplies this vector and m, and divides by perspective.
|
|
|
+ If index equals 0 set [page:.x x] to [page:Float value].<br />
|
|
|
+ If index equals 1 set [page:.y y] to [page:Float value].<br />
|
|
|
+ If index equals 2 set [page:.z z] to [page:Float value]
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 applyEuler]( [page:Euler euler] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 setFromCylindrical]( [page:Cylindrical c] )</h3>
|
|
|
<div>
|
|
|
- euler -- [page:Euler]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Applies euler transform to this vector by converting the [page:Euler] object to a [page:Quaternion] and applying.
|
|
|
+ Sets this vector from the cylindrical coordinates [page:Cylindrical c].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 applyQuaternion]( [page:Quaternion quaternion] ) [page:Vector3 this]</h3>
|
|
|
- <div>
|
|
|
- quaternion -- [page:Quaternion]
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector3 setFromMatrixColumn]( [page:Matrix4 matrix], [page:Integer index] )</h3>
|
|
|
<div>
|
|
|
- Applies a [page:Quaternion] transform to this vector.
|
|
|
+ Sets this vector's [page:.x x], [page:.y y] and [page:.z z] equal to the column of
|
|
|
+ the [page:Matrix4 matrix] specified by the [page:Integer index].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 project]( [page:Camera camera] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 setFromMatrixPosition]( [page:Matrix4 m] )</h3>
|
|
|
<div>
|
|
|
- [page:Camera camera] — camera to use in the projection.<br />
|
|
|
+ Sets this vector to the position elements of the
|
|
|
+ [link:https://en.wikipedia.org/wiki/Transformation_matrix transformation matrix] [page:Matrix4 m].
|
|
|
</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector3 setFromMatrixScale]( [page:Matrix4 m] )</h3>
|
|
|
<div>
|
|
|
- Projects the vector with the camera.
|
|
|
+ Sets this vector to the scale elements of the
|
|
|
+ [link:https://en.wikipedia.org/wiki/Transformation_matrix transformation matrix] [page:Matrix4 m].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 unproject]( [page:Camera camera] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 setFromSpherical]( [page:Spherical s] )</h3>
|
|
|
<div>
|
|
|
- [page:Camera camera] — camera to use in the projection.<br />
|
|
|
+ Sets this vector from the spherical coordinates [page:Spherical s].
|
|
|
</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector3 setLength]( [page:Float l] )</h3>
|
|
|
<div>
|
|
|
- Unprojects the vector with the camera.
|
|
|
+ Set this vector to the vector with the same direction as this one, but [page:.length length]
|
|
|
+ [page:Float l].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Boolean equals]( [page:Vector3 v] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 setScalar]( [page:Float scalar] )</h3>
|
|
|
<div>
|
|
|
- Checks for strict equality of this vector and *v*.
|
|
|
+ Set the [page:.x x], [page:.y y] and [page:.z z] values of this vector both equal to [page:Float scalar].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector3 clone]() [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 setX]( [page:Float x] )</h3>
|
|
|
+ <div>Replace this vector's [page:.x x] value with [page:Float x].</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector3 setY]( [page:Float y] )</h3>
|
|
|
+ <div>Replace this vector's [page:.y y] value with [page:Float y].</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector3 setZ]( [page:Float z] )</h3>
|
|
|
+ <div>Replace this vector's [page:.z z] value with [page:Float z].</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector3 sub]( [page:Vector3 v] )</h3>
|
|
|
+ <div>Subtracts [page:Vector3 v] from this vector.</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector3 subScalar]( [page:Float s] )</h3>
|
|
|
+ <div>Subtracts [page:Float s] from this vector's [page:.x x], [page:.y y] and [page:.z z] compnents.</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector3 subVectors]( [page:Vector3 a], [page:Vector3 b] )</h3>
|
|
|
+ <div>Sets this vector to [page:Vector3 a] - [page:Vector3 b].</div>
|
|
|
+
|
|
|
+ <h3>[method:Array toArray]( [page:Array array], [page:Integer offset] )</h3>
|
|
|
<div>
|
|
|
- Clones this vector.
|
|
|
+ [page:Array array] - (optional) array to store the vector to. If this is not provided
|
|
|
+ a new array will be created.<br />
|
|
|
+ [page:Integer offset] - (optional) optional offset into the array.<br /><br />
|
|
|
+
|
|
|
+ Returns an array [x, y, z], or copies x, y and z into the provided [page:Array array].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Array toArray]( [page:Array array], [page:Integer offset] ) [page:Vector3 this]</h3>
|
|
|
+ <h3>[method:Vector3 transformDirection]( [page:Matrix4 m] )</h3>
|
|
|
<div>
|
|
|
- array -- An optional array to store the vector to. <br />
|
|
|
- offset -- An optional offset into the array.
|
|
|
+ Transforms the direction of this vector by a matrix (the upper left 3 x 3 subset of a [page:Matrix4 m])
|
|
|
+ and then [page:.normalize normalizes] the result.
|
|
|
</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector3 unproject]( [page:Camera camera] )</h3>
|
|
|
<div>
|
|
|
- Assigns this vector's x value to array[0]. <br />
|
|
|
- Assigns this vector's y value to array[1]. <br />
|
|
|
- Assigns this vector's z value to array[2]. <br />
|
|
|
- Returns the created array.
|
|
|
+ [page:Camera camera] — camera to use in the projection.<br /><br />
|
|
|
+
|
|
|
+ [link:https://en.wikipedia.org/wiki/Vector_projection Unprojects] the vector with the
|
|
|
+ camera's projection matrix.
|
|
|
</div>
|
|
|
|
|
|
+
|
|
|
<h2>Source</h2>
|
|
|
|
|
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|