Explorar o código

Docs: Vector4.

Mr.doob %!s(int64=13) %!d(string=hai) anos
pai
achega
8e13516ebd
Modificáronse 4 ficheiros con 105 adicións e 203 borrados
  1. 2 2
      docs/api/core/Vector3.html
  2. 87 5
      docs/api/core/Vector4.html
  3. 0 179
      docs/api/core/Vector4.rst
  4. 16 17
      src/core/Vector4.js

+ 2 - 2
docs/api/core/Vector3.html

@@ -126,9 +126,9 @@ Computes distance of this vector to *v*.
 Computes squared distance of this vector to *v*.
 </div>
 
-<h3>.setLength( [page:Float l] ) [page:Vector3]</h3>
+<h3>.normalize() [page:Vector3]</h3>
 <div>
-Normalizes this vector and multiplies it by *l*.
+Normalizes this vector.
 </div>
 
 <h3>.setLength( [page:Float l] ) [page:Vector3]</h3>

+ 87 - 5
docs/api/core/Vector4.html

@@ -1,23 +1,105 @@
 <h1>[name]</h1>
 
-<div class="desc">todo</div>
+<div class="desc">4D vector.</div>
 
 
 <h2>Constructor</h2>
 
-<h3>[name]()</h3>
+<h3>[name]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )</h3>
 
 
 <h2>Properties</h2>
 
-<h3>.[page:Vector3 todo]</h3>
+<h3>.[page:Float x]</h3>
+
+<h3>.[page:Float y]</h3>
+
+<h3>.[page:Float z]</h3>
+
+<h3>.[page:Float w]</h3>
 
 
 <h2>Methods</h2>
 
-<h3>.todo( [page:Vector3 todo] )</h3>
+<h3>.set( [page:Float x], [page:Float y], [page:Float z], [page:Float w] ) [page:Vector4]</h3>
+<div>
+Sets value of this vector.
+</div>
+
+<h3>.copy( [page:Vector4 v] ) [page:Vector4]</h3>
+<div>
+Copies value of *v* to this vector.
+</div>
+
+<h3>.add( [page:Vector4 a], [page:Vector4 b] ) [page:Vector4]</h3>
+<div>
+Sets this vector to *a + b*.
+</div>
+
+<h3>.addSelf( [page:Vector4 v] ) [page:Vector4s]</h3>
+<div>
+Adds *v* to this vector.
+</div>
+
+<h3>.sub( [page:Vector4 a], [page:Vector4 b] ) [page:Vector4]</h3>
+<div>
+Sets this vector to *a - b*.
+</div>
+
+<h3>.subSelf( [page:Vector4 v] ) [page:Vector4]</h3>
+<div>
+Subtracts *v* from this vector.
+</div>
+
+<h3>.multiplyScalar( [page:Float s] ) [page:Vector4]</h3>
+<div>
+Multiplies this vector by scalar *s*.
+</div>
+
+<h3>.divideScalar( [page:Float s] ) [page:Vector4]</h3>
+<div>
+Divides this vector by scalar *s*.<br />
+Set vector to *( 0, 0, 0 )* if *s == 0*.
+</div>
+
+<h3>.negate() [page:Vector4]</h3>
+<div>
+Inverts this vector.
+</div>
+
+<h3>.dot( [page:Vector4 v] ) [page:Float]</h3>
+<div>
+Computes dot product of this vector and *v*.
+</div>
+
+<h3>.lengthSq() [page:Float]</h3>
+<div>
+Computes squared length of this vector.
+</div>
+
+<h3>.length() [page:Float]</h3>
+<div>
+Computes length of this vector.
+</div>
+
+<h3>.normalize() [page:Vector4]</h3>
+<div>
+Normalizes this vector.
+</div>
+
+<h3>.setLength( [page:Float l] ) [page:Vector3]</h3>
+<div>
+Normalizes this vector and multiplies it by *l*.
+</div>
+
+<h3>.lerpSelf( [page:Vector4 v], [page:Float alpha] ) [page:Vector4]</h3>
+<div>
+Linearly interpolate between this vector and *v* with *alpha* factor.
+</div>
+
+<h3>.clone() [page:Vector3]</h3>
 <div>
-todo — todo<br />
+Clones this vector.
 </div>
 
 

+ 0 - 179
docs/api/core/Vector4.rst

@@ -1,179 +0,0 @@
-Vector4 - 4D vector
--------------------
-
-.. ...............................................................................
-.. rubric:: Constructor
-.. ...............................................................................
-
-.. class:: Vector4( x, y, z, w )
-
-    4D vector
-
-    :param float x: x-coordinate
-    :param float y: y-coordinate
-    :param float z: z-coordinate
-    :param float w: w-coordinate
-
-.. ...............................................................................
-.. rubric:: Attributes
-.. ...............................................................................
-
-.. attribute:: Vector4.x
-
-    float - default ``0``
-
-.. attribute:: Vector4.y
-
-    float - default ``0``
-
-.. attribute:: Vector4.z
-
-    float - default ``0``
-
-.. attribute:: Vector4.w
-
-    float - default ``1``
-
-
-.. ...............................................................................
-.. rubric:: Methods
-.. ...............................................................................
-
-.. function:: Vector4.clone( )
-
-    Clones this vector
-
-    :returns: New instance identical to this vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.set( x, y, z, w )
-
-    Sets value of this vector
-
-    :param float x: x-coordinate
-    :param float y: y-coordinate
-    :param float z: z-coordinate
-    :param float w: w-coordinate
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.copy( v )
-
-    Copies value of ``v`` to this vector
-
-    Sets ``w`` to 1 if ``v.w`` is undefined
-
-    :param Vector4 v: source vector
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.add( v1, v2 )
-
-    Sets this vector to ``v1 + v2``
-
-    :param Vector4 v1: source vector 1
-    :param Vector4 v2: source vector 2
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.addSelf( v )
-
-    Adds ``v`` to this vector
-
-    :param Vector4 v: source vector
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.sub( v1, v2 )
-
-    Sets this vector to ``v1 - v2``
-
-    :param Vector4 v1: source vector 1
-    :param Vector4 v2: source vector 2
-
-.. function:: Vector4.subSelf( v )
-
-    Subtracts ``v`` from this vector
-
-    :param Vector4 v: source vector
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.multiplyScalar( s )
-
-    Multiplies this vector by scalar ``s``
-
-    :param float s: scalar
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.divideScalar( s )
-
-    Divides this vector by scalar ``s``
-
-    Set vector to ``( 0, 0, 0, 1 )`` if ``s == 0``
-
-    :param float s: scalar
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.negate( )
-
-    Inverts this vector
-
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.dot( v )
-
-    Computes dot product of this vector and ``v``
-
-    :param Vector4 v: vector
-    :returns: dot product
-    :rtype: float
-
-.. function:: Vector4.lengthSq( )
-
-    Computes squared length of this vector
-
-    :returns: squared length
-    :rtype: float
-
-.. function:: Vector4.length( )
-
-    Computes length of this vector
-
-    :returns: length
-    :rtype: float
-
-.. function:: Vector4.normalize( )
-
-    Normalizes this vector
-
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.setLength( l )
-
-    Normalizes this vector and multiplies it by ``l``
-
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-.. function:: Vector4.lerpSelf( v, alpha )
-
-    Linearly interpolate between this vector and ``v`` with ``alpha`` factor
-
-    :param Vector4 v: vector
-    :param float alpha: interpolation factor
-    :returns: This vector
-    :rtype: :class:`Vector4`
-
-
-.. ...............................................................................
-.. rubric:: Example
-.. ...............................................................................
-
-::
-
-    var a = new THREE.Vector4( 1, 0, 0, 0 );

+ 16 - 17
src/core/Vector4.js

@@ -40,19 +40,12 @@ THREE.Vector4.prototype = {
 
 	},
 
-	clone: function () {
-
-		return new THREE.Vector4( this.x, this.y, this.z, this.w );
-
-	},
-
-
-	add: function ( v1, v2 ) {
+	add: function ( a, b ) {
 
-		this.x = v1.x + v2.x;
-		this.y = v1.y + v2.y;
-		this.z = v1.z + v2.z;
-		this.w = v1.w + v2.w;
+		this.x = a.x + b.x;
+		this.y = a.y + b.y;
+		this.z = a.z + b.z;
+		this.w = a.w + b.w;
 
 		return this;
 
@@ -69,12 +62,12 @@ THREE.Vector4.prototype = {
 
 	},
 
-	sub: function ( v1, v2 ) {
+	sub: function ( a, b ) {
 
-		this.x = v1.x - v2.x;
-		this.y = v1.y - v2.y;
-		this.z = v1.z - v2.z;
-		this.w = v1.w - v2.w;
+		this.x = a.x - b.x;
+		this.y = a.y - b.y;
+		this.z = a.z - b.z;
+		this.w = a.w - b.w;
 
 		return this;
 
@@ -170,6 +163,12 @@ THREE.Vector4.prototype = {
 
 		return this;
 
+	},
+
+	clone: function () {
+
+		return new THREE.Vector4( this.x, this.y, this.z, this.w );
+
 	}
 
 };