浏览代码

Added docs for Vector2. Some fixes for other docs.

alteredq 13 年之前
父节点
当前提交
9d436f073b

+ 1 - 1
docs/api/cameras/OrthographicCamera.rst

@@ -56,7 +56,7 @@ OrthographicCamera - Camera with orthographic projection
 
 
 .. function:: OrthographicCamera.updateProjectionMatrix()
 .. function:: OrthographicCamera.updateProjectionMatrix()
 
 
-    Updated camera's projection matrix. Must be called after change of parameters.
+    Updates camera's projection matrix. Must be called after change of parameters.
 
 
 
 
 .. ...............................................................................
 .. ...............................................................................

+ 1 - 1
docs/api/cameras/PerspectiveCamera.rst

@@ -57,7 +57,7 @@ PerspectiveCamera - Camera with perspective projection
 
 
 .. function:: PerspectiveCamera.updateProjectionMatrix()
 .. function:: PerspectiveCamera.updateProjectionMatrix()
 
 
-    Updated camera's projection matrix. Must be called after change of parameters.
+    Updates camera's projection matrix. Must be called after change of parameters.
 
 
 .. function:: PerspectiveCamera.setLens ( focalLength, frameSize )
 .. function:: PerspectiveCamera.setLens ( focalLength, frameSize )
 
 

+ 56 - 36
docs/api/core/Color.rst

@@ -9,6 +9,8 @@ Color - Represents a color
 
 
     Represents a color
     Represents a color
 
 
+    See also :class:`ColorUtils`
+
     :param integer hex: Hex value to intialize the color
     :param integer hex: Hex value to intialize the color
 
 
 
 
@@ -18,97 +20,112 @@ Color - Represents a color
 
 
 .. attribute:: Color.r
 .. attribute:: Color.r
 
 
-    Red channel (float between 0 and 1)
+    Red channel (float between 0 and 1) (default ``1``)
 
 
 .. attribute:: Color.g
 .. attribute:: Color.g
 
 
-    Green channel (float between 0 and 1)
+    Green channel (float between 0 and 1) (default ``1``)
 
 
 .. attribute:: Color.b
 .. attribute:: Color.b
 
 
-    Blue channel (float between 0 and 1)
+    Blue channel (float between 0 and 1) (default ``1``)
 
 
 
 
 .. ...............................................................................
 .. ...............................................................................
 .. rubric:: Methods
 .. rubric:: Methods
 .. ...............................................................................
 .. ...............................................................................
 
 
-.. function:: Color.convertGammaToLinear()
-
-    Converts this color from gamma color to linear color
+.. function:: Color.clone()
 
 
-.. function:: Color.convertLinearToGamma()
+    Clones this color
 
 
-    Converts this color from linear color to gamma color
+    :returns: New instance identical to this color
+    :rtype: :class:`Color`
 
 
-.. function:: Color.copy(color)
+.. function:: Color.copy( color )
 
 
-    Copies the given color into this color
+    Copies given ``color`` into this color
 
 
     :param Color color: Color to copy
     :param Color color: Color to copy
+    :returns: This color
+    :rtype: :class:`Color`
 
 
-.. function:: Color.copyGammaToLinear(color)
+.. function:: Color.copyGammaToLinear( color )
 
 
-    Creates a gamma color from a linear color
+    Copies given ``color`` into this color, making conversion from gamma to linear color space
 
 
     :param Color color: Color to copy
     :param Color color: Color to copy
-    :returns: Linear color
-    :rtype: Color
+    :returns: This color
+    :rtype: :class:`Color`
 
 
 .. function:: Color.copyLinearToGamma(color)
 .. function:: Color.copyLinearToGamma(color)
 
 
-    Creates a linear color from a gamma color
+    Copies given ``color`` into this color, making conversion from linear to gamma color space
 
 
     :param Color color: Color to copy
     :param Color color: Color to copy
-    :returns: Gamma color
-    :rtype: Color
+    :returns: This color
+    :rtype: :class:`Color`
+
+.. function:: Color.convertGammaToLinear()
+
+    Converts this color from gamma to linear color space
+
+    :returns: This color
+    :rtype: :class:`Color`
+
+.. function:: Color.convertLinearToGamma()
 
 
-.. function:: Color.setRGB(r, g, b)
+    Converts this color from linear to gamma color space
 
 
-    Sets the RGB value of this color
+    :returns: This color
+    :rtype: :class:`Color`
+
+.. function:: Color.setRGB( r, g, b )
+
+    Sets this color from RGB values
 
 
     :param float r: Red channel value (between 0 and 1)
     :param float r: Red channel value (between 0 and 1)
     :param float g: Green channel value (between 0 and 1)
     :param float g: Green channel value (between 0 and 1)
     :param float b: Blue channel value (between 0 and 1)
     :param float b: Blue channel value (between 0 and 1)
+    :returns: This color
+    :rtype: :class:`Color`
+
+.. function:: Color.setHSV( h, s, v )
 
 
-.. function:: Color.setHSV(h, s, v)
+    Sets this color from HSV values.
 
 
-    Sets the HSV value of this color. Based on MochiKit implementation by
-    Bob Ippolito.
+    Based on MochiKit implementation by Bob Ippolito.
 
 
     :param float h: Hue channel (between 0 and 1)
     :param float h: Hue channel (between 0 and 1)
     :param float s: Saturation channel (between 0 and 1)
     :param float s: Saturation channel (between 0 and 1)
     :param float v: Value channel (between 0 and 1)
     :param float v: Value channel (between 0 and 1)
+    :returns: This color
+    :rtype: :class:`Color`
 
 
-.. function:: Color.setHex(hex)
+.. function:: Color.setHex( hex )
 
 
-    Sets the value of this color from a hex value
+    Sets this color from a hex value
 
 
-    :param integer hex: Value of the color in hex
+    :param integer hex: Value of the color in hex (between ``0x000000`` and ``0xffffff``)
+    :returns: This color
+    :rtype: :class:`Color`
 
 
 .. function:: Color.getHex()
 .. function:: Color.getHex()
 
 
     Gets the value of this color in hex
     Gets the value of this color in hex
 
 
-    :returns: The color value in hex
+    :returns: Color value in hex
     :rtype: integer
     :rtype: integer
 
 
 .. function:: Color.getContextStyle()
 .. function:: Color.getContextStyle()
 
 
     Returns the value of this color in CSS context style.
     Returns the value of this color in CSS context style.
 
 
-    Example: ``rgb(r,g,b)``
+    Example: ``rgb( r, g, b )``
 
 
-    :returns: A CSS-formatted color value
+    :returns: CSS-formatted color value
     :rtype: string
     :rtype: string
 
 
-.. function:: Color.clone()
-
-    Clones this color
-
-    :returns: New instance identical to this color
-    :rtype: Color
-
 
 
 .. ...............................................................................
 .. ...............................................................................
 .. rubric:: Example
 .. rubric:: Example
@@ -117,8 +134,11 @@ Color - Represents a color
 ::
 ::
 
 
     var colors = [];
     var colors = [];
+
     for ( i = 0; i < 5000; i ++ ) {
     for ( i = 0; i < 5000; i ++ ) {
+
         x = 2000 * Math.random() - 1000;
         x = 2000 * Math.random() - 1000;
         colors[ i ] = new THREE.Color( 0xffffff );
         colors[ i ] = new THREE.Color( 0xffffff );
-        colors[ i ].setHSV( (x+1000)/2000, 1.0, 1.0 );
+        colors[ i ].setHSV( ( x + 1000 ) / 2000, 1.0, 1.0 );
+
     }
     }

+ 7 - 7
docs/api/core/Geometry.rst

@@ -133,27 +133,27 @@ Geometry - Base class for geometries
 
 
 .. function:: Geometry.applyMatrix( matrix )
 .. function:: Geometry.applyMatrix( matrix )
 
 
-    Bake matrix transform directly into vertex coordinates
+    Bakes matrix transform directly into vertex coordinates
 
 
     :param Matrix4 matrix: matrix transform
     :param Matrix4 matrix: matrix transform
 
 
 .. function:: Geometry.computeCentroids()
 .. function:: Geometry.computeCentroids()
 
 
-    Compute centroids for all faces
+    Computes centroids for all faces
 
 
 .. function:: Geometry.computeFaceNormals()
 .. function:: Geometry.computeFaceNormals()
 
 
-    Compute face normals
+    Computes face normals
 
 
 .. function:: Geometry.computeVertexNormals()
 .. function:: Geometry.computeVertexNormals()
 
 
-    Compute vertex normals by averaging face normals.
+    Computes vertex normals by averaging face normals.
 
 
     Face normals must be existing / computed beforehand.
     Face normals must be existing / computed beforehand.
 
 
 .. function:: Geometry.computeTangents()
 .. function:: Geometry.computeTangents()
 
 
-    Compute vertex tangents
+    Computes vertex tangents
 
 
     Based on http://www.terathon.com/code/tangent.html
     Based on http://www.terathon.com/code/tangent.html
 
 
@@ -161,11 +161,11 @@ Geometry - Base class for geometries
 
 
 .. function:: Geometry.computeBoundingBox()
 .. function:: Geometry.computeBoundingBox()
 
 
-    Compute bounding box of the geometry, updating :attr:`Geometry.boundingBox` attribute.
+    Computes bounding box of the geometry, updating :attr:`Geometry.boundingBox` attribute.
 
 
 .. function:: Geometry.computeBoundingSphere()
 .. function:: Geometry.computeBoundingSphere()
 
 
-    Compute bounding sphere of the geometry, updating :attr:`Geometry.boundingSphere` attribute.
+    Computes bounding sphere of the geometry, updating :attr:`Geometry.boundingSphere` attribute.
 
 
 .. function:: Geometry.mergeVertices()
 .. function:: Geometry.mergeVertices()
 
 

+ 3 - 3
docs/api/core/Math.rst

@@ -44,17 +44,17 @@ Math - Math utility functions
     :returns: Random float from <0, 1> with 16 bits of randomness
     :returns: Random float from <0, 1> with 16 bits of randomness
     :rtype: float
     :rtype: float
 
 
-.. function:: Math.randInt(low, high)
+.. function:: Math.randInt( low, high )
 
 
     :returns: Random integer from *low* to *high* interval
     :returns: Random integer from *low* to *high* interval
     :rtype: integer
     :rtype: integer
 
 
-.. function:: Math.randFloat(low, high)
+.. function:: Math.randFloat( low, high )
 
 
     :returns: Random float from *low* to *high* interval
     :returns: Random float from *low* to *high* interval
     :rtype: float
     :rtype: float
 
 
-.. function:: Math.randFloatSpread(range)
+.. function:: Math.randFloatSpread( range )
 
 
     :returns: Random float from -range/2 to range/2 interval
     :returns: Random float from -range/2 to range/2 interval
     :rtype: float
     :rtype: float

+ 10 - 10
docs/api/core/Object3D.rst

@@ -175,50 +175,50 @@ Object3D - Base class for scene graph objects
 
 
 .. function:: Object3D.translate ( distance, axis )
 .. function:: Object3D.translate ( distance, axis )
 
 
-    Translate object along arbitrary axis by distance
+    Translates object along arbitrary axis by distance
 
 
     :param float distance: distance
     :param float distance: distance
     :param Vector3 axis: translation direction
     :param Vector3 axis: translation direction
 
 
 .. function:: Object3D.translateX ( distance )
 .. function:: Object3D.translateX ( distance )
 
 
-    Translate object along X-axis by distance
+    Translates object along X-axis by distance
 
 
     :param float distance: distance
     :param float distance: distance
 
 
 .. function:: Object3D.translateY ( distance )
 .. function:: Object3D.translateY ( distance )
 
 
-    Translate object along Y-axis by distance
+    Translates object along Y-axis by distance
 
 
     :param float distance: distance
     :param float distance: distance
 
 
 .. function:: Object3D.translateZ ( distance )
 .. function:: Object3D.translateZ ( distance )
 
 
-    Translate object along Z-axis by distance
+    Translates object along Z-axis by distance
 
 
     :param float distance: distance
     :param float distance: distance
 
 
 .. function:: Object3D.lookAt ( vector )
 .. function:: Object3D.lookAt ( vector )
 
 
-    Rotate object to face point in space
+    Rotates object to face point in space
 
 
     :param Vector3 vector: vector
     :param Vector3 vector: vector
 
 
 .. function:: Object3D.add ( object )
 .. function:: Object3D.add ( object )
 
 
-    Add child object to this object
+    Adds child object to this object
 
 
     :param Object3D object: child
     :param Object3D object: child
 
 
 .. function:: Object3D.remove ( object )
 .. function:: Object3D.remove ( object )
 
 
-    Remove child object from this object
+    Removes child object from this object
 
 
     :param Object3D object: child
     :param Object3D object: child
 
 
 .. function:: Object3D.getChildByName ( name, doRecurse )
 .. function:: Object3D.getChildByName ( name, doRecurse )
 
 
-    Get first child with name matching the argument, search whole subgraph recursively if flag is set.
+    Gets first child with name matching the argument (searches whole subgraph recursively if flag is set).
 
 
     :param string name: child name
     :param string name: child name
     :param boolean doRecurse: recurse flag
     :param boolean doRecurse: recurse flag
@@ -227,11 +227,11 @@ Object3D - Base class for scene graph objects
 
 
 .. function:: Object3D.updateMatrix ( )
 .. function:: Object3D.updateMatrix ( )
 
 
-    Update local transform
+    Updates local transform
 
 
 .. function:: Object3D.updateMatrixWorld ( force )
 .. function:: Object3D.updateMatrixWorld ( force )
 
 
-    Update global transform of the object and its children
+    Updates global transform of the object and its children
 
 
 
 
 .. ...............................................................................
 .. ...............................................................................

+ 162 - 4
docs/api/core/Vector2.rst

@@ -1,14 +1,172 @@
 Vector2 - 2D vector
 Vector2 - 2D vector
 -------------------
 -------------------
 
 
+.. ...............................................................................
 .. rubric:: Constructor
 .. rubric:: Constructor
+.. ...............................................................................
 
 
-.. class:: Vector2()
+.. class:: Vector2( x, y )
 
 
     2D vector
     2D vector
-    
+
+    :param float x: x-coordinate
+    :param float y: y-coordinate
+
+.. ...............................................................................
 .. rubric:: Attributes
 .. rubric:: Attributes
+.. ...............................................................................
+
+.. attribute:: Vector2.x
+.. attribute:: Vector2.y
+
+.. ...............................................................................
+.. rubric:: Methods
+.. ...............................................................................
+
+.. function:: Vector2.clone( )
+
+    Clones this vector
+
+    :returns: New instance identical to this vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.set( x, y )
+
+    Sets value of this vector
+
+    :param float x: x-coordinate
+    :param float y: y-coordinate
+    :returns: This vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.copy( v )
+
+    Copies value of ``v`` to this vector
+
+    :param Vector2 v: source vector
+    :returns: This vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.add( v1, v2 )
+
+    Sets this vector to ``v1 + v2``
+
+    :param Vector2 v1: source vector 1
+    :param Vector2 v2: source vector 2
+    :returns: This vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.addSelf( v )
+
+    Adds ``v`` to this vector
+
+    :param Vector2 v: source vector
+    :returns: This vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.sub( v1, v2 )
+
+    Sets this vector to ``v1 - v2``
+
+    :param Vector2 v1: source vector 1
+    :param Vector2 v2: source vector 2
+
+.. function:: Vector2.subSelf( v )
+
+    Subtracts ``v`` from this vector
+
+    :param Vector2 v: source vector
+    :returns: This vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.multiplyScalar( s )
+
+    Multiplies this vector by scalar ``s``
+
+    :param float s: scalar
+    :returns: This vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.divideScalar( s )
+
+    Divides this vector by scalar ``s``
+
+    Set vector to ``( 0, 0 )`` if ``s == 0``
+
+    :param float s: scalar
+    :returns: This vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.negate( )
+
+    Inverts this vector
+
+    :returns: This vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.dot( v )
+
+    Computes dot product of this vector and ``v``
+
+    :returns: dot product
+    :rtype: float
+
+.. function:: Vector2.lengthSq( )
+
+    Computes squared length of this vector
+
+    :returns: squared length
+    :rtype: float
+
+.. function:: Vector2.length( )
+
+    Computes length of this vector
+
+    :returns: length
+    :rtype: float
+
+.. function:: Vector2.normalize( )
+
+    Normalizes this vector
+
+    :returns: This vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.distanceTo( v )
+
+    Computes distance of this vector to ``v``
+
+    :returns: squared distance
+    :rtype: float
+
+.. function:: Vector2.distanceToSquared( v )
+
+    Computes squared distance of this vector to ``v``
+
+    :returns: squared distance
+    :rtype: float
+
+.. function:: Vector2.setLength( l )
+
+    Normalizes this vector and multiplies it by ``l``
+
+    :returns: This vector
+    :rtype: :class:`Vector2`
+
+.. function:: Vector2.equals( v )
+
+    Checks for strict equality of this vector and ``v``
+
+    :returns: true if this vector equals ``v``
+    :rtype: boolean
+
+.. ...............................................................................
+.. rubric:: Example
+.. ...............................................................................
+
+::
 
 
-.. rubric:: Method
+    var a = new THREE.Vector2( 0, 1 );
+    var b = new THREE.Vector2( 1, 0 );
 
 
-.. rubric:: Example(s)
+    var d = a.distanceTo( b );