提交 290502de 编写于 作者: M Mr.doob

Docs: Geometry, Math and Vertex.

上级 3abd17c0
<h1>[name]</h1>
<div class="desc">todo</div>
<div class="desc">Base class for geometries</div>
<h2>Example</h2>
<code>// geometry with random points
var geometry = new THREE.Geometry()
for ( var i = 0; i < 10000; i ++ ) {
var vertex = new THREE.Vertex();
vertex.position.x = Math.random() * 1000 - 500;
vertex.position.y = Math.random() * 1000 - 500;
vertex.position.z = Math.random() * 1000 - 500;
geometry.vertices.push( vertex );
}
geometry.computeBoundingSphere();
</code>
<h2>Constructor</h2>
<h3>[name]()</h3>
......@@ -10,14 +30,137 @@
<h2>Properties</h2>
<h3>.[page:Vector3 todo]</h3>
<h3>.[page:Integer id]</h3>
<div>
Unique number of this geometry instance
</div>
<h3>.[page:Array vertices]</h3>
<div>
Array of [page:Vertex vertices].
</div>
<h3>.[page:Array colors]</h3>
<div>
Array of vertex [page:Color colors], matching number and order of vertices.<br />
Used in [page:ParticleSystem], [page:Line] and [page:Ribbon].<br />
[page:Mesh Meshes] use per-face-use-of-vertex colors embedded directly in faces.
</div>
<h3>.[page:Array materials]</h3>
<div>
Array of [page:Material materials].
</div>
<h3>.[page:Array faces]</h3>
<div>
Array of [page:Face3 triangles] or/and [page:Face4 quads].
</div>
<h3>.[page:Array faceUvs]</h3>
<div>
Array of face [page:UV] layers.<br />
Each UV layer is an array of [page:UV] matching order and number of faces.
</div>
<h3>.[page:Array faceVertexUvs]</h3>
<div>
Array of face [page:UV] layers.<br />
Each UV layer is an array of [page:UV] matching order and number of vertices in faces.
</div>
<h3>.[page:Array morphTargets]</h3>
<div>
Array of morph targets. Each morph target is JS object:
<code>{ name: "targetName", vertices: [ new THREE.Vertex(), ... ] }</code>
Morph vertices match number and order of primary vertices.
</div>
<h3>.[page:Array morphColors]</h3>
<div>
Array of morph colors. Morph colors have similar structure as morph targets, each color set is JS object:
<code>morphColor = { name: "colorName", colors: [ new THREE.Color(), ... ] }</code>
Morph colors can match either number and order of faces (face colors) or number of vertices (vertex colors).
</div>
<h3>.[page:Array skinWeights]</h3>
<div>
Array of skinning weights, matching number and order of vertices.
</div>
<h3>.[page:Array skinIndices]</h3>
<div>
Array of skinning indices, matching number and order of vertices.
</div>
<h3>.[page:Object boundingBox]</h3>
<div>
Bounding box.
<code>{ min: new THREE.Vector3(), max: new THREE.Vector3() }</code>
</div>
<h3>.[page:Object boundingSphere]</h3>
<div>
Bounding sphere.
<code>{ radius: float }</code>
</div>
<h3>.[page:Boolean hasTangents]</h3>
<div>
True if geometry has tangents. Set in [page:Geometry Geometry.computeTangents].
</div>
<h3>.[page:Boolean dynamic]</h3>
<div>
Set to <strong>true</strong> if attribute buffers will need to change in runtime (using "dirty" flags).<br/>
Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU.
</div>
<h2>Methods</h2>
<h3>.todo( [page:Vector3 todo] )</h3>
<h3>.applyMatrix( [page:Matrix4 matrix] )</h3>
<div>
Bakes matrix transform directly into vertex coordinates.
</div>
<h3>.computeCentroids()</h3>
<div>
Computes centroids for all faces.
</div>
<h3>.computeFaceNormals()</h3>
<div>
Computes face normals.
</div>
<h3>.computeVertexNormals()</h3>
<div>
Computes vertex normals by averaging face normals.<br />
Face normals must be existing / computed beforehand.
</div>
<h3>.computeTangents()</h3>
<div>
Computes vertex tangents.<br />
Based on <a href="http://www.terathon.com/code/tangent.html" target="_blank">http://www.terathon.com/code/tangent.html</a><br />
Geometry must have vertex [page:UV UVs] (layer 0 will be used).
</div>
<h3>.computeBoundingBox()</h3>
<div>
Computes bounding box of the geometry, updating [page:Geometry Geometry.boundingBox] attribute.
</div>
<h3>.computeBoundingSphere()</h3>
<div>
Computes bounding sphere of the geometry, updating [page:Geometry Geometry.boundingSphere] attribute.
</div>
<h3>.mergeVertices()</h3>
<div>
todo — todo<br />
Checks for duplicate vertices using hashmap.<br />
Duplicated vertices are removed and faces' vertices are updated.
</div>
......
Geometry - Base class for geometries
----------------------------------------
.. ...............................................................................
.. rubric:: Constructor
.. ...............................................................................
.. class:: Geometry()
Base class for geometries
Encapsulates unique instances of vertex buffer objects in :class:`WebGLRenderer`
.. ...............................................................................
.. rubric:: Attributes
.. ...............................................................................
.. attribute:: Geometry.id
Unique number of this geometry instance
.. attribute:: Geometry.boundingBox
Bounding box
::
boundingBox = { min: new THREE.Vector3(), max: new THREE.Vector3() }
.. attribute:: Geometry.boundingSphere
Bounding sphere
::
boundingSphere = { radius: float }
.. attribute:: Geometry.materials
Array of :class:`materials <Material>`
Used with models containing multiple materials in a single geometry (with pass-through :class:`MeshFaceMaterial`)
Face indices index into this array.
.. ...............................................................................
.. rubric:: Attribute buffers
.. ...............................................................................
.. attribute:: Geometry.faces
Array of faces (:class:`Face3`, :class:`Face4`)
.. attribute:: Geometry.vertices
Array of :class:`vertices <Vertex>`
Face indices index into this array.
.. attribute:: Geometry.colors
Array of vertex :class:`colors <Color>`, matching number and order of vertices.
Used in :class:`ParticleSystem`, :class:`Line` and :class:`Ribbon`.
:class:`Meshes <Mesh>` use per-face-use-of-vertex colors embedded directly in faces.
.. attribute:: Geometry.faceUvs
Array of face UV layers.
Each UV layer is an array of :class:`UV` matching order and number of faces.
.. attribute:: Geometry.faceVertexUvs
Array of vertex UV layers.
Each UV layer is an array of :class:`UV` matching order and number of vertices in faces.
.. attribute:: Geometry.morphTargets
Array of morph targets.
Each morph target is JS object:
::
morphTarget = { name: "targetName", vertices: [ new THREE.Vertex(), ... ] }
Morph vertices match number and order of primary vertices.
.. attribute:: Geometry.morphColors
Array of morph colors.
Morph colors have similar structure as morph targets, each color set is JS object:
::
morphColor = { name: "colorName", colors: [ new THREE.Color(), ... ] }
Morph colors can match either number and order of faces (face colors) or number of vertices (vertex colors).
.. attribute:: Geometry.skinWeights
Array of skinning weights (:class:`Vector4`), matching number and order of vertices.
.. attribute:: Geometry.skinIndices
Array of skinning indices (:class:`Vector4`), matching number and order of vertices.
.. ...............................................................................
.. rubric:: Flags
.. ...............................................................................
.. attribute:: Geometry.hasTangents
True if geometry has tangents. Set in :func:`Geometry.computeTangents`
``default false``
.. attribute:: Geometry.dynamic
Set to `true` if attribute buffers will need to change in runtime (using ``dirty`` flags).
Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU.
``default false``
.. ...............................................................................
.. rubric:: Methods
.. ...............................................................................
.. function:: Geometry.applyMatrix( matrix )
Bakes matrix transform directly into vertex coordinates
:param Matrix4 matrix: matrix transform
.. function:: Geometry.computeCentroids()
Computes centroids for all faces
.. function:: Geometry.computeFaceNormals()
Computes face normals
.. function:: Geometry.computeVertexNormals()
Computes vertex normals by averaging face normals.
Face normals must be existing / computed beforehand.
.. function:: Geometry.computeTangents()
Computes vertex tangents
Based on http://www.terathon.com/code/tangent.html
Geometry must have vertex UVs (layer 0 will be used).
.. function:: Geometry.computeBoundingBox()
Computes bounding box of the geometry, updating :attr:`Geometry.boundingBox` attribute.
.. function:: Geometry.computeBoundingSphere()
Computes bounding sphere of the geometry, updating :attr:`Geometry.boundingSphere` attribute.
.. function:: Geometry.mergeVertices()
Checks for duplicate vertices using hashmap.
Duplicated vertices are removed and faces' vertices are updated.
.. ...............................................................................
.. rubric:: Example
.. ...............................................................................
::
// geometry with random points
// (useful for example with ParticleSystem)
var n = 10000;
var geometry = new THREE.Geometry()
for ( var i = 0; i < n; i ++ ) {
var x = THREE.MathUtils.randFloatSpread( 1000 );
var y = THREE.MathUtils.randFloatSpread( 1000 );
var z = THREE.MathUtils.randFloatSpread( 1000 );
var position = new THREE.Vector3( x, y, z );
var vertex = new THREE.Vertex( position );
geometry.vertices.push( vertex );
}
geometry.computeBoundingSphere();
<h1>[name]</h1>
<div class="desc">todo</div>
<div class="desc">Math utility functions</div>
<h2>Constructor</h2>
<h2>Methods</h2>
<h3>[name]()</h3>
<h3>.clamp( [page:Float x], [page:Float a], [page:Float b] ) [page:Float]</h3>
<div>
x — Value to be clamped.<br />
a — Minimum value<br />
b — Maximum value.
</div>
<div>
Clamps the <strong>x</strong> to be between <strong>a</strong> and <strong>b</strong>.
</div>
<h3>.clampBottom( [page:Float x], [page:Float a] ) [page:Float]</h3>
<div>
x — Value to be clamped.<br />
a — Minimum value
</div>
<div>
Clamps the <strong>x</strong> to be larger than <strong>a</strong>.
</div>
<h2>Properties</h2>
<h3>.mapLinear( [page:Float x], [page:Float a] ) [page:Float]</h3>
<div>
x — Value to be mapped.<br />
a1 — Minimum value for range A.<br />
a2 — Maximum value for range A.<br />
b1 — Minimum value for range B.<br />
b2 — Maximum value for range B.
</div>
<div>
Linear mapping of <strong>x</strong> from range [<strong>a1</strong>, <strong>a2</strong>] to range [<strong>b1</strong>, <strong>b2</strong>].
</div>
<h3>.[page:Vector3 todo]</h3>
<h3>.random16() [page:Float]</h3>
<div>
Random float from 0 to 1 with 16 bits of randomness.<br />
Standard Math.random() creates repetitive patterns when applied over larger space.
</div>
<h3>.randInt( [page:Integer low], [page:Integer high] ) [page:Integer]</h3>
<div>
Random integer from <strong>low</strong> to <strong>high</strong> interval.
</div>
<h2>Methods</h2>
<h3>.randFloat( [page:Float low], [page:Float high] ) [page:Float]</h3>
<div>
Random float from <strong>low</strong> to <strong>high</strong> interval.
</div>
<h3>.todo( [page:Vector3 todo] )</h3>
<h3>.randFloatSpread( [page:Float range] ) [page:Float]</h3>
<div>
todo — todo<br />
Random float from <strong>- range / 2</strong> to <strong>range / 2</strong> interval.
</div>
......
Math - Math utility functions
-----------------------------
.. ...............................................................................
.. rubric:: Methods
.. ...............................................................................
.. function:: Math.clamp( x, a, b )
Clamps the x to be between a and b
:param float x: value to be clamped
:param float a: minimum value
:param float b: maximum value
:returns: Clamped value
:rtype: float
.. function:: Math.clampBottom( x, a )
Clamps the x to be larger than a
:param float x: value to be clamped
:param float a: minimum value
:returns: Clamped value
:rtype: float
.. function:: Math.mapLinear( x, a1, a2, b1, b2 )
Linear mapping of x from range <a1, a2> to range <b1, b2>
:param float x: value to be mapped
:param float a1: minimum value for range A
:param float a2: maximum value for range A
:param float b1: minimum value for range B
:param float b2: maximum value for range B
:returns: mapped value
:rtype: float
.. function:: Math.random16()
Random float from <0, 1> with 16 bits of randomness
(standard Math.random() creates repetitive patterns when applied over larger space)
:returns: Random float from <0, 1> with 16 bits of randomness
:rtype: float
.. function:: Math.randInt( low, high )
:returns: Random integer from *low* to *high* interval
:rtype: integer
.. function:: Math.randFloat( low, high )
:returns: Random float from *low* to *high* interval
:rtype: float
.. function:: Math.randFloatSpread( range )
:returns: Random float from -range/2 to range/2 interval
:rtype: float
<h1>[name]</h1>
<div class="desc">todo</div>
<div class="desc"></div>
<h2>Constructor</h2>
......@@ -10,15 +10,7 @@
<h2>Properties</h2>
<h3>.[page:Vector3 todo]</h3>
<h2>Methods</h2>
<h3>.todo( [page:Vector3 todo] )</h3>
<div>
todo — todo<br />
</div>
<h3>.[page:Vector3 position]</h3>
<h2>Source</h2>
......
Vertex - Represents a vertex in space
-------------------------------------
.. rubric:: Constructor
.. class:: Vertex()
Represents a vertex in space
.. rubric:: Attributes
.. rubric:: Method
.. rubric:: Example(s)
\ No newline at end of file
......@@ -351,7 +351,7 @@
text = text.replace(/\[name\]/gi, name);
text = text.replace(/\[path\]/gi, path);
text = text.replace(/\[page:(\w+)\]/gi, "<a href=\"javascript:goTo('$1')\" title=\"$1\">$1</a>" );
text = text.replace(/\[page:(\w+) (\w+)\]/gi, "<a href=\"javascript:goTo('$1')\" title=\"$1\">$2</a>" );
text = text.replace(/\[page:(\w+) ([\w|\.]+)\]/gi, "<a href=\"javascript:goTo('$1')\" title=\"$1\">$2</a>" );
viewer.innerHTML = '<br>' + text + '<br><br>';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册