提交 7c1edc33 编写于 作者: L Lewy Blue

merged dev

......@@ -11,7 +11,7 @@
<h1>Polyfills</h1>
<div class="desc">Three includes polyfills for the following functions and constants.</div>
<div class="desc">Three.js includes polyfills for the following functions and constants.</div>
<h3>[page:Number.EPSILON Number.EPSILON]</h3>
<div>
......
......@@ -67,8 +67,7 @@ scene.add( camera );</code>
<div>
Camera frustum far plane. Default is *2000*.<br /><br />
Note that Three does not currently give warnings for incorrect values here, however the expected
range is between the current value of the [page:.far far] plane and infinity.
The valid range is between the current value of the [page:.near near] plane and infinity.
</div>
<h3>[property:Boolean isOrthographicCamera]</h3>
......@@ -83,10 +82,11 @@ scene.add( camera );</code>
<h3>[property:Float near]</h3>
<div>
Camera fustum near plane. Default is *0.1*.<br /><br />
Camera frustum near plane. Default is *0.1*.<br /><br />
Note that Three does not currently give warnings for incorrect values here, however the expected
range is between 0 and the current value of the [page:.far far] plane.
The valid range is between 0 and the current value of the [page:.far far] plane.
Note that, unlike for the [page:PerspectiveCamera], *0* is a valid value for an
OrthographicCamera's near plane.
</div>
<h3>[property:Float right]</h3>
......
......@@ -57,8 +57,7 @@ scene.add( camera );</code>
<div>
Camera frustum far plane. Default is *2000*.<br /><br />
Note that Three does not currently give warnings for incorrect values here, however the expected
range is between the current value of the [page:.far far] plane and infinity.
The valid range is between the current value of the [page:.near near] plane and infinity.
</div>
<h3>[property:Float filmGauge]</h3>
......@@ -86,10 +85,11 @@ scene.add( camera );</code>
<h3>[property:Float near]</h3>
<div>
Camera fustum near plane. Default is *0.1*.<br /><br />
Camera frustum near plane. Default is *0.1*.<br /><br />
Note that Three does not currently give warnings for incorrect values here, however the expected
range is between 0 and the current value of the [page:.far far] plane.
The valid range is greater than 0 and less than the current value of the [page:.far far] plane.
Note that, unlike for the [page:OrthographicCamera], *0* is <em>not</em> a valid value
for a PerspectiveCamera's near plane.
</div>
<h3>[property:Object view]</h3>
......
......@@ -17,7 +17,7 @@
</code>
<div id="rev">
The current Three.js [link:https://github.com/mrdoob/three.js/releases revision number].
The current three.js [link:https://github.com/mrdoob/three.js/releases revision number].
</div>
<h2>Mouse Buttons</h2>
......
......@@ -11,7 +11,7 @@
<h1>[name]</h1>
<div class="desc">
This is the base class for most objects in Three and provides a set of properties and methods
This is the base class for most objects in three.js and provides a set of properties and methods
for manipulating objects in 3D space.<br /><br />
Note that this can be used for grouping objects via the [page:.add]( object ) method
......@@ -64,7 +64,7 @@
<h3>[property:Boolean matrixAutoUpdate]</h3>
<div>
When this is set, it calculates the matrix of position, (rotation or quaternion) and
scale every frame and also recalculates the matrixWorld property. Default is *true*.
scale every frame and also recalculates the matrixWorld property. Default is [page:Object3D.DefaultMatrixAutoUpdate] (true).
</div>
<h3>[property:Matrix4 matrixWorld]</h3>
......@@ -132,7 +132,10 @@
</div>
<h3>[property:Vector3 up]</h3>
<div>Up direction. Default is [page:Vector3]( 0, 1, 0 ).</div>
<div>
This is used by the [page:.lookAt lookAt] method, for example, to determine the orientation of the result.<br />
Default is [page:Object3D.DefaultUp] - that is, ( 0, 1, 0 ).
</div>
<h3>[property:object userData]</h3>
<div>
......@@ -152,7 +155,27 @@
<h2>Static Properties</h2>
<div>
Static properties and methods are defined per class rather than per instance of that class.
This means that changing [page:Object3D.DefaultUp] or [page:Object3D.DefaultMatrixAutoUpdate]
will change the values of [page:.up up] and [page:.matrixAutoUpdate matrixAutoUpdate] for
<em>every</em> instance of Object3D (or derived classes) created after the change has
been made (already created Object3Ds will not be affected).
</div>
<h3>[property:Vector3 DefaultUp]</h3>
<div>
The default [page:.up up] direction for objects, also used as the default position for [page:DirectionalLight],
[page:HemisphereLight] and [page:Spotlight] (which creates lights shining from the top down).<br />
Set to (0, 1, 0) by default.
</div>
<h3>[property:Vector3 DefaultMatrixAutoUpdate]</h3>
<div>
The default setting for [page.matrixAutoUpdate matrixAutoUpdate] for newly created Object3Ds.<br />
</div>
<h2>Methods</h2>
......
......@@ -13,7 +13,7 @@
<h1>BufferAttribute Types</h1>
<div class="desc">
There are nine types of [page:BufferAttribute] available in Three. These correspond to the JavaScript
There are nine types of [page:BufferAttribute] available in three.js. These correspond to the JavaScript
[link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Syntax Typed Arrays].
</div>
......
......@@ -11,7 +11,7 @@
<h1>Deprecated API List</h1>
<div>
As Three.js has a rapidly evolving interface, you may come across examples that
As three.js has a rapidly evolving interface, you may come across examples that
suggest the use of API elements that are no longer part of the core.<br /><br />
Below is a list of such elements, along with info regarding their replacements.
......@@ -34,6 +34,8 @@
<h3>[page:AudioAnalyser]</h3>
<div>AudioAnalyser.getData() has been renamed to [page:AudioAnalyser.getFrequencyData]().</div>
<h3>[page:BinaryTextureLoader]</h3>
<div>BinaryTextureLoader has been renamed to [page:DataTextureLoader].</div>
......@@ -117,7 +119,7 @@
<h2>Core</h2>
<h3>[page:EventDispatcher]</h3>
<div>EventDispatcher.apply has been has been removed. Inherit or Object.assign the prototype to mix-in instead.</div>
<div>EventDispatcher.apply has been removed. Inherit or Object.assign the prototype to mix-in instead.</div>
<h3>[page:Raycaster]</h3>
<div>Raycaster.params.PointCloud has been renamed to [page:Raycaster.params.Points].</div>
......@@ -125,9 +127,9 @@
<h3>[page:Uniform]</h3>
<div>
Uniform.dynamic has been has been removed. Use object.onBeforeRender() instead.<br /><br />
Uniform.dynamic has been removed. Use object.onBeforeRender() instead.<br /><br />
Uniform.onUpdate has been has been removed. Use object.onBeforeRender() instead.
Uniform.onUpdate has been removed. Use object.onBeforeRender() instead.
</div>
......@@ -316,8 +318,7 @@
Matrix4.setRotationFromQuaternion() has been renamed to [page:Matrix4.makeRotationFromQuaternion]( quaternion ).<br /><br />
Matrix4.multiplyVector3() has been has been removed. Use vector.applyMatrix4( matrix )
or vector.applyProjection( matrix ) instead.<br /><br />
Matrix4.multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.<br /><br />
Matrix4.multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.<br /><br />
......@@ -355,6 +356,10 @@
Ray.isIntersectionSphere has been renamed to [page:Ray.intersectsSphere].
</div>
<h3>[page:Vector2]</h3>
<div>
Vector2.fromAttribute() has been renamed to [page:Vector2.fromBufferAttribute]().
</div>
<h3>[page:Vector3]</h3>
<div>
......@@ -366,12 +371,24 @@
Vector3.getScaleFromMatrix() has been renamed to [page:Vector3.setFromMatrixScale]().<br /><br />
Vector3.getColumnFromMatrix() has been renamed to [page:Vector3.setFromMatrixColumn]().
Vector3.getColumnFromMatrix() has been renamed to [page:Vector3.setFromMatrixColumn]().<br /><br />
Vector3.applyProjection() has been removed. Use [page:Vector3.applyMatrix4]() instead.<br /><br />
Vector3.fromAttribute() has been renamed to [page:Vector3.fromBufferAttribute]().
</div>
<h3>[page:Vector4]</h3>
<div>
Vector4.fromAttribute() has been renamed to [page:Vector4.fromBufferAttribute]().
</div>
<h3>[page:Vertex]</h3>
<div>Vertex has been removed. Use [page:Vector3] instead.</div>
<h3>[page:Spline]</h3>
<div>Spline has been removed. Use [page:CatmullRomCurve3] instead.</div>
......
......@@ -24,7 +24,7 @@
<h2>A Note about Position, Target and rotation</h2>
<div>
A common point of confusion for directional lights is that setting the rotation has no effect.
This is because Three's DirectionalLight is the equivalent to what is often called a 'Target
This is because three.js's DirectionalLight is the equivalent to what is often called a 'Target
Direct Light' in other applications.<br /><br />
This means that its direction is calculated as pointing
......@@ -54,7 +54,6 @@
<code>
// White directional light at half intensity shining from the top.
var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
directionalLight.position.set( 0, 1, 0 );
scene.add( directionalLight );
</code>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<div class="desc">
Abstract base class to load generic binary textures formats (rgbe, hdr, ...).
This uses the [page:FileLoader] internally for loading files.
</div>
<h2>Examples</h2>
<div>
See the [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/RGBELoader.js RGBELoader]
for an example of a derived class.
</div>
<h2>Constructor</h2>
<h3>[name]( [page:LoadingManager manager] )</h3>
<div>
[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use.
Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
Creates a new [name].
</div>
<h2>Properties</h2>
<h3>[property:LoadingManager manager]</h3>
<div>
The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
</div>
<h2>Methods</h2>
<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
<div>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded texture.<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.<br />
[page:Function onError] — Will be called when load errors.<br />
</div>
<div>
Begin loading from url and pass the loaded texture to onLoad.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
......@@ -10,9 +10,54 @@
<body>
<h1>[name]</h1>
<div class="desc">This is an alias for the [page:BinaryTextureLoader BinaryTextureLoader].
See that page for details.
<div class="desc">
Abstract base class to load generic binary textures formats (rgbe, hdr, ...).
This uses the [page:FileLoader] internally for loading files, and creates a new
[page:DataTexture].
</div>
<h2>Examples</h2>
<div>
See the [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/RGBELoader.js RGBELoader]
for an example of a derived class.
</div>
<h2>Constructor</h2>
<h3>[name]( [page:LoadingManager manager] )</h3>
<div>
[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use.
Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
Creates a new [name].
</div>
<h2>Properties</h2>
<h3>[property:LoadingManager manager]</h3>
<div>
The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
</div>
<h2>Methods</h2>
<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
<div>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded texture.<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.<br />
[page:Function onError] — Will be called when load errors.<br />
</div>
<div>
Begin loading from url and pass the loaded texture to onLoad.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
......@@ -256,7 +256,7 @@
<h3>[method:null toJSON]( [page:object meta] )</h3>
<div>
meta -- object containing metadata such as textures or images for the material.<br />
Convert the material to Three JSON format.
Convert the material to three.js JSON format.
</div>
<h3>[method:null update]()</h3>
......
......@@ -48,7 +48,7 @@
</li>
</ul>
Technical details of the approach used in Three (and most other PBR systems) can be found is this
Technical details of the approach used in three.js (and most other PBR systems) can be found is this
[link:https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf paper from Disney] (pdf),
by Brent Burley.
</div>
......
......@@ -100,7 +100,7 @@ scene.add( cubeMesh );
<h3>[method:null toJSON]( [page:object meta] )</h3>
<div>
meta -- object containing metadata such as textures or images for the material.<br />
Convert the material to Three JSON format.
Convert the material to three.js JSON format.
</div>
<h2>Source</h2>
......
......@@ -51,7 +51,7 @@ var color = new THREE.Color( 1, 0, 0 );
[page:Float g] - (optional) The green component of the color if it is defined.<br />
[page:Float b] - (optional) The blue component of the color if it is defined.<br /><br />
Note that standard method of specifying color in Three is with a [link:https://en.wikipedia.org/wiki/Web_colors#Hex_triplet hexadecimal triplet], and that method is used
Note that standard method of specifying color in three.js is with a [link:https://en.wikipedia.org/wiki/Web_colors#Hex_triplet hexadecimal triplet], and that method is used
throughout the rest of the documentation.<br /><br />
When all arguments are defined then r is the red component, g is the green component and b is the blue component of the color.<br />
......
......@@ -38,7 +38,7 @@ m.elements = [ 11, 21, 31,
</code>
and internally all calculations are performed using column-major ordering. However, as the actual ordering
makes no difference mathematically and most people are used to thinking about matrices in row-major order,
the Three.js documentation shows matrices in row-major order. Just bear in mind that if you are reading the source
the three.js documentation shows matrices in row-major order. Just bear in mind that if you are reading the source
code, you'll have to take the transpose of any matrices outlined here to make sense of the calculations.
</div>
......@@ -78,7 +78,7 @@ m.elements = [ 11, 21, 31,
Multiplies (applies) this matrix to every 3D vector in the [page:BufferAttribute attribute].
</div>
<h3>[method:Matrix3 clone]()</h3>
<div>Creates a new Matrix3 and with identical elements to this one.</div>
......
......@@ -75,7 +75,7 @@ m.elements = [ 11, 21, 31, 41,
</code>
and internally all calculations are performed using column-major ordering. However, as the actual ordering
makes no difference mathematically and most people are used to thinking about matrices in row-major order,
the Three.js documentation shows matrices in row-major order. Just bear in mind that if you are reading the source
the three.js documentation shows matrices in row-major order. Just bear in mind that if you are reading the source
code, you'll have to take the transpose of any matrices outlined here to make sense of the calculations.
</div>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<div class="desc">
Class representing a [link:https://en.wikipedia.org/wiki/Spline_(mathematics) spline].<br /><br />
</div>
<h2>Examples</h2>
<div>
[example:webgl_lines_splines WebGL / lines / splines]<br />
[example:webgl_lines_dashed WebGL / lines / dashed]<br />
[example:software_sandbox Software / sandbox]<br />
[example:canvas_lines_dashed Canvas / lines / dashed]
</div>
<h2>Constructor</h2>
<h3>[name]( [page:Array points] )</h3>
<div>
Initialises the spline with [page:Array points], which are the [page:Vector3 Vector3s]
through which the spline will pass.
</div>
<h2>Properties</h2>
<h3>[property:Array points]</h3>
<h2>Methods</h2>
<h3>[method:Array getControlPointsArray]( )</h3>
<div>
Returns an array with triplets of [ x, y, z ] coordinates that correspond to the
current control points.
</div>
<h3>[method:Vector3 getPoint]( [page:Integer k] )</h3>
<div>
[page:Integer k] — point index<br /><br />
Return the interpolated point at [page:Integer k].
</div>
<h3>[method:Object getLength]( [page:Integer nSubDivisions] )</h3>
<div>
[page:Integer nSubDivisions] — number of subdivisions between control points. Default is *100*.<br /><br />
Returns an object with the two properties. The property <strong>[page:Number total]</strong> contains
the length of the spline when using [page:Integer nSubDivisions]. The property [page:Array chunkLength]
contains an array with the total length from the beginning of the spline to the end of that chunk.
</div>
<h3>[method:null initFromArray]( [page:Array a] )</h3>
<div>
[page:Array a] — array of the form
<code>
var a = [ [x1, y1, z1], [x2, y2, z2], ... ];
</code>
from which to initialise the points array.<br /><br />
Initialises using the data in the array as a series of points. Each value in *a* must
be another array with three values, where a[n] is v, the value for the *nth* point,
and v[0], v[1] and v[2] are the x, y and z coordinates of that point n, respectively.
</div>
<h3>[method:Vector3 interpolate]( p0, p1, p2, p3, t, t2, t3 )</h3>
<div>
</div>
<h3>[method:null reparametrizeByArcLength]( [page:Float samplingCoef] )</h3>
<div>
[page:Float samplingCoef] — how many intermediate values to use between spline points<br /><br />
Modifies the spline so that it looks similar to the original but has its points distributed
in such way that moving along the spline it's done at a more or less constant speed.
The points should also appear more uniformly spread along the curve.
This is done by resampling the original spline, with the density of sampling controlled by [page:Float samplingCoef].
Here it's interesting to note that denser sampling is not necessarily better:
if sampling is too high, you may get weird kinks in curvature.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
......@@ -21,7 +21,7 @@
A point in 2D space (i.e. a position on a plane).
</li>
<li>
A direction and length across a plane. In Three the length will always be the
A direction and length across a plane. In three.js the length will always be the
[link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean distance]
(straight-line distance) from (0, 0) to (x, y) and the direction is also
measured from (0, 0) towards (x, y).
......@@ -32,7 +32,7 @@
</ul>
There are other things a 2D vector can be used to represent, such as momentum
vectors, complex numbers and so on, however these are the most common uses in Three.
vectors, complex numbers and so on, however these are the most common uses in three.js.
</div>
<h2>Example</h2>
......@@ -184,11 +184,10 @@
Sets this vector's [page:.x x] value to be array[0] and [page:.y y] value to be array[1].
</div>
<h3>[method:Vector2 fromAttribute]( [page:BufferAttribute attribute], [page:Integer index], [page:Integer offset] )</h3>
<h3>[method:Vector2 fromBufferAttribute]( [page:BufferAttribute attribute], [page:Integer index] )</h3>
<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 />
Sets this vector's [page:.x x] and [page:.y y] values from the [page:BufferAttribute attribute].
</div>
......
......@@ -20,7 +20,7 @@
A point in 3D space.
</li>
<li>
A direction and length in 3D space. In Three the length will always be the
A direction and length in 3D space. In three.js 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).
......@@ -31,7 +31,7 @@
</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.
vectors and so on, however these are the most common uses in three.js.
</div>
......@@ -108,29 +108,7 @@ var d = a.distanceTo( b );
<h3>[method:Vector3 applyMatrix4]( [page:Matrix4 m] )</h3>
<div>
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>
Note that the input matrix [page:Matrix4 m] is assumed to be
[link:https://en.wikipedia.org/wiki/Affine_transformation affine].
</div>
<h3>[method:Vector3 applyProjection]( [page:Matrix4 m] )</h3>
<div>
[page:Matrix4 m] - [page:Matrix4] projection matrix.<br /><br />
Multiplies this vector and m, and divides by perspective.
Multiplies this vector (with an implicit 1 in the 4th dimension) and m, and divides by perspective.
</div>
<h3>[method:Vector3 applyQuaternion]( [page:Quaternion quaternion] )</h3>
......@@ -242,11 +220,10 @@ m, n, o
and [page:.z z] value to be array[ offset + 2 ].
</div>
<h3>[method:Vector3 fromAttribute]( [page:BufferAttribute attribute], [page:Integer index], [page:Integer offset] )</h3>
<h3>[method:Vector3 fromBufferAttribute]( [page:BufferAttribute attribute], [page:Integer index] )</h3>
<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 />
Sets this vector's [page:.x x], [page:.y y] and [page:.z z] values from the [page:BufferAttribute attribute].
</div>
......
......@@ -20,7 +20,7 @@
A point in 4D space.
</li>
<li>
A direction and length in 4D space. In Three the length will always be the
A direction and length in 4D space. In three.js the length will always be the
[link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean distance]
(straight-line distance) from (0, 0, 0, 0, 0) to (x, y, z, w) and the direction is also
measured from (0, 0, 0, 0) towards (x, y, z, w).
......@@ -30,7 +30,7 @@
</li>
</ul>
There are other things a 4D vector can be used to represent, however these are the most common uses in Three.
There are other things a 4D vector can be used to represent, however these are the most common uses in three.js.
</div>
......@@ -157,11 +157,10 @@ var d = a.distanceTo( b );
[page:.z z] value to be array[ offset + 2 ] and [page:.w w ] value to be array[ offset + 3 ].
</div>
<h3>[method:Vector4 fromAttribute]( [page:BufferAttribute attribute], [page:Integer index], [page:Integer offset] )</h3>
<h3>[method:Vector4 fromBufferAttribute]( [page:BufferAttribute attribute], [page:Integer index] )</h3>
<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 />
Sets this vector's [page:.x x], [page:.y y], [page:.z z] and [page:.w w] values from the [page:BufferAttribute attribute].
</div>
......
......@@ -48,7 +48,7 @@
<h3>[property:Image image]</h3>
<div>
An image object, typically created using the [page:TextureLoader.load] method.
This can be any image (e.g., PNG, JPG, GIF, DDS) or video (e.g., MP4, OGG/OGV) type supported by Three.<br /><br />
This can be any image (e.g., PNG, JPG, GIF, DDS) or video (e.g., MP4, OGG/OGV) type supported by three.js.<br /><br />
To use video as a texture you need to have a playing HTML5
video element as a source for your texture image and continuously update this texture
......@@ -84,7 +84,7 @@
NOTE: tiling of images in textures only functions if image dimensions are powers of two
(2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, ...) in terms of pixels.
Individual dimensions need not be equal, but each must be a power of two.
This is a limitation of WebGL, not Three.js.
This is a limitation of WebGL, not three.js.
</div>
<h3>[property:number magFilter]</h3>
......@@ -202,7 +202,7 @@
<h3>[method:Texture toJSON]( meta )</h3>
<div>
meta -- optional object containing metadata.<br />
Convert the material to Three JSON format.
Convert the material to three.js JSON format.
</div>
<h3>[method:null dispose]()</h3>
......
......@@ -133,7 +133,7 @@
value -- the data value to be displayed as a color.
</div>
<div>
Returns a Three.Color.
Returns a [page:Color].
</div>
<h2>Source</h2>
......
......@@ -16,7 +16,7 @@
API.<br /><br />
<b>
NOTE: The Canvas renderer has been deprecated and is no longer part of the Three.js core.
NOTE: The Canvas renderer has been deprecated and is no longer part of the three.js core.
</b>
If you still need to use it you can find it here: [link:https://github.com/mrdoob/three.js/blob/master/examples/js/[path].js examples/js/[path].js].<br /><br />
......
......@@ -3,8 +3,20 @@ var list = {
"Manual": {
"Introduction": [
[ "Creating a scene", "manual/introduction/Creating-a-scene" ],
<<<<<<< HEAD
[ "Matrix transformations", "manual/introduction/Matrix-transformations" ],
[ "Useful links", "manual/introduction/Useful-links" ]
=======
[ "Drawing Lines", "manual/introduction/Drawing-lines" ],
[ "Creating Text", "manual/introduction/Creating-text" ],
[ "Code Style Guide", "manual/introduction/Code-style-guide" ],
[ "Migration Guide", "manual/introduction/Migration-guide" ],
[ "Matrix transformations", "manual/introduction/Matrix-transformations" ]
],
"Build Tools": [
[ "Testing with NPM", "manual/buildTools/Testing-with-NPM" ]
>>>>>>> 56ec5ce2e269d9fdf08ce6b385813c6ce0dc10ed
]
},
......@@ -196,7 +208,6 @@ var list = {
"Loaders": [
[ "AnimationLoader", "api/loaders/AnimationLoader" ],
[ "AudioLoader", "api/loaders/AudioLoader" ],
[ "BinaryTextureLoader", "api/loaders/BinaryTextureLoader" ],
[ "BufferGeometryLoader", "api/loaders/BufferGeometryLoader" ],
[ "Cache", "api/loaders/Cache" ],
[ "CompressedTextureLoader", "api/loaders/CompressedTextureLoader" ],
......@@ -254,7 +265,6 @@ var list = {
[ "Ray", "api/math/Ray" ],
[ "Sphere", "api/math/Sphere" ],
[ "Spherical", "api/math/Spherical" ],
[ "Spline", "api/math/Spline" ],
[ "Triangle", "api/math/Triangle" ],
[ "Vector2", "api/math/Vector2" ],
[ "Vector3", "api/math/Vector3" ],
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<div class="desc">
This article shows how to get three.js into a [link:https://nodejs.org/en/ node.js] environment so that you
can execute automated tests. Tests can be run on the command line, or by automated
CI tools like [link:https://travis-ci.org/ Travis].
</div>
<h2>The short version</h2>
<div>
If you're comfortable with node and npm,
<code>
$ npm install three --save-dev
</code>
and add
<code>
var THREE = require('three');
</code>
to your test.
</div>
<h2>Create a testable project from scratch</h2>
<div>
If you're not familiar with these tools, here's a quick guide (for linux, the installation process
will be slightly different using windows, but the NPM commands are identical).
</div>
<h3>Basic setup</h3>
<div>
<ol>
<li>
Install [link:https://www.npmjs.org/ npm] and nodejs. The shortest path typically looks something like
<code>
$ sudo apt-get install -y npm nodejs-legacy
# fix any problems with SSL in the default registry URL
$ npm config set registry http://registry.npmjs.org/
</code>
</li>
<li>
Make a new project directory
<code>
$ mkdir test-example; cd test-example
</code>
</li>
<li>
Ask npm to create a new project file for you:
<code>
$ npm init
</code>
and accept all defaults by hitting Enter on all the prompts.
This will create package.json.
</li><br />
<li>
Try and start the test feature with
<code>
$ npm test
</code>
This will fail, which is expected.
If you look in the package.json, the definition of the test script is
<code>
"test": "echo \"Error: no test specified\" && exit 1"
</code>
</li>
</ol>
</div>
<h2>Add mocha</h2>
<div>
We're going to use [link:https://mochajs.org/ mocha].
<ol>
<li>
Install mocha with
<code>
$ npm install mocha --save-dev
</code>
Notice that node_modules/ is created and your dependencies appear in there.
Also notice that your package.json has been updated: the property devDependencies
is added and updated by the use of --save-dev.
</li><br />
<li>
Edit package.json to use mocha for testing. When test is invoked, we just want to run
mocha and specify a verbose reporter. By default this will run anything in test/
(not having directory test/ can run into npm ERR!, create it by mkdir test)
<code>
"test": "mocha --reporter list"
</code>
</li>
<li>
Rerun the test with
<code>
$ npm test.
</code>
This should now succeed, reporting 0 passing (1ms)
or similar.
</li>
</ol>
</div>
<h2>Add three.js</h2>
<div>
<ol>
<li>
Let's pull in our three.js dependency with
<code>
$ npm install three --save-dev
</code>
<ul>
<li>
If you need a different three version, use
<code>
$ npm show three versions
</code>
to see
what's available. To tell npm the right one, use
<code>
$ npm install three@0.84.0 --save
</code>
(0.84.0 in this example). --save makes this a dependency of this project, rather than
dev dependency. See the docs [link:https://www.npmjs.org/doc/json.html here] for more info.
</li>
</ul>
</li>
<li>
Mocha will look for tests in test/, so let's
<code>
$ mkdir test.
</code>
</li>
<li>
Finally we actually need a JS test to run. Let's add a simple test that will verify that
the three.js object is available and working. Create test/verify-three.js containing:
<code>
var THREE = require('three');
var assert = require("assert");
describe('The THREE object', function() {
it('should have a defined BasicShadowMap constant', function() {
assert.notEqual('undefined', THREE.BasicShadowMap);
}),
it('should be able to construct a Vector3 with default of x=0', function() {
var vec3 = new THREE.Vector3();
assert.equal(0, vec3.x);
})
})
</code>
</li>
<li>
Finally let's test again with $ npm test. This should run the tests above and succeed,
showing something like:
<code>
The THREE object should have a defined BasicShadowMap constant: 0ms
The THREE object should be able to construct a Vector3 with default of x=0: 0ms
2 passing (8ms)
</code>
</li>
</ol>
</div>
<h2>Add your own code</h2>
<div>
You need to do three things:
<ol>
<li>
Write a test for the expected behaviour of your code, and place it under test/.
[linkk:https://github.com/air/encounter/blob/master/test/Physics-test.js Here] is an example from a real project.
</li>
<li>
Export your functional code in such a way that nodejs can see it, for use in conjunction with require.
See it [link:https://github.com/air/encounter/blob/master/js/Physics.js here].
</li>
<li>
Require your code into the test file, in the same way we did a require('three') in the example above.
</li>
</ol>
Items 2 and 3 will vary depending on how you manage your code. In the example of Physics.js
given above, the export part is right at the end. We assign an object to module.exports:
<code>
//=============================================================================
// make available in nodejs
//=============================================================================
if (typeof exports !== 'undefined')
{
module.exports = Physics;
}
</code>
</div>
<h2>Dealing with dependencies</h2>
<div>
<p>
If you're already using something clever like require.js or browserify, skip this part.
</p>
<p>
Typically a three.js project is going to run in the browser. Module loading is hence done by
the browser executing a bunch of script tags. Your individual files don't have to worry
about dependencies. In a nodejs context however, there is no index.html binding everything
together, so you have to be explicit.
</p>
<p>
If you're exporting a module that depends on other files, you're going to have to tell node to load them.
Here is one approach:
</p>
<ol>
<li>
At the start of your module, check to see if you're in a nodejs environment.
</li>
<li>
If so, explicitly declare your dependencies.
</li>
<li>
If not, you're probably in a browser so you don't need to do anything else.
</li>
</ol>
Example code from Physics.js:
<code>
//=============================================================================
// setup for server-side testing
//=============================================================================
if (typeof require === 'function') // test for nodejs environment
{
var THREE = require('three');
var MY3 = require('./MY3.js');
}
</code>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</a></h1>
<div class="desc">
All code and examples in three.js are written using Mr.doob's Code Style.
Of course you are free to use whatever style you prefer for your own work, but
if you are adding code to the library or examples then you must follow this guide.<br /><br />
You can find details
<a href="https://github.com/mrdoob/three.js/wiki/Mr.doob%27s-Code-Style%E2%84%A2">here</a>.
</div>
</body>
</html>
......@@ -10,18 +10,18 @@
<body>
<h1>[name]</h1><br />
<div>The goal of this section is to give a brief introduction to Three.js. We will start by setting up a scene, with a spinning cube. A working example is provided at the bottom of the page in case you get stuck and need help.</div>
<div>The goal of this section is to give a brief introduction to three.js. We will start by setting up a scene, with a spinning cube. A working example is provided at the bottom of the page in case you get stuck and need help.</div>
<h2>Before we start</h2>
<div>Before you can use Three.js, you need somewhere to display it. Save the following HTML to a file on your computer, along with a copy of <a href="http://threejs.org/build/three.js">three.js</a> in the js/ directory, and open it in your browser.</div>
<div>Before you can use three.js, you need somewhere to display it. Save the following HTML to a file on your computer, along with a copy of <a href="http://threejs.org/build/three.js">three.js</a> in the js/ directory, and open it in your browser.</div>
<code>
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset=utf-8&gt;
&lt;title&gt;My first Three.js app&lt;/title&gt;
&lt;title&gt;My first three.js app&lt;/title&gt;
&lt;style&gt;
body { margin: 0; }
canvas { width: 100%; height: 100% }
......@@ -40,7 +40,7 @@
<h2>Creating the scene</h2>
<div>To actually be able to display anything with Three.js, we need three things: A scene, a camera, and a renderer so we can render the scene with the camera.</div>
<div>To actually be able to display anything with three.js, we need three things: A scene, a camera, and a renderer so we can render the scene with the camera.</div>
<code>
var scene = new THREE.Scene();
......@@ -51,13 +51,13 @@
document.body.appendChild( renderer.domElement );
</code>
<div>Let's take a moment to explain what's going on here. We have now set up the scene, our camera and the renderer. There are a few different cameras in Three.js. For now, let's use a PerspectiveCamera. The first attribute is the <strong>field of view</strong>.</div>
<div>Let's take a moment to explain what's going on here. We have now set up the scene, our camera and the renderer. There are a few different cameras in three.js. For now, let's use a PerspectiveCamera. The first attribute is the <strong>field of view</strong>.</div>
<div>The second one is the <strong>aspect ratio</strong>. You almost always want to use the width of the element divided by the height, or you'll get the same result as when you play old movies on a widescreen TV - the image looks squished.</div>
<div>The next two attributes are the <strong>near</strong> and <strong>far</strong> clipping plane. What that means, is that objects further away from the camera than the value of <strong>far</strong> or closer than <strong>near</strong> won't be rendered. You don't have to worry about this now, but you may want to use other values in your apps to get better performance.</div>
<div>Next up is the renderer. This is where the magic happens. In addition to the WebGLRenderer we use here, Three.js comes with a few others, often used as fallbacks for users with older browsers or for those who don't have WebGL support for some reason.</div>
<div>Next up is the renderer. This is where the magic happens. In addition to the WebGLRenderer we use here, three.js comes with a few others, often used as fallbacks for users with older browsers or for those who don't have WebGL support for some reason.</div>
<div>In addition to creating the renderer instance, we also need to set the size at which we want it to render our app. It's a good idea to use the width and height of the area we want to fill with our app - in this case, the width and height of the browser window. For performance intensive apps, you can also give <strong>setSize</strong> smaller values, like <strong>window.innerWidth/2</strong> and <strong>window.innerHeight/2</strong>, which will make the app render at half size.</div>
......@@ -113,14 +113,14 @@
</div>
<h2>The result</h2>
<div>Congratulations! You have now completed your first Three.js application. It's simple, you have to start somewhere.</div>
<div>Congratulations! You have now completed your first three.js application. It's simple, you have to start somewhere.</div>
<div>The full code is available below. Play around with it to get a better understanding of how it works.</div>
<code>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My first Three.js app&lt;/title&gt;
&lt;title&gt;My first three.js app&lt;/title&gt;
&lt;style&gt;
body { margin: 0; }
canvas { width: 100%; height: 100% }
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<p>There are often times when you might need to use text in your Three.js application. Here's are some options you may consider when you wish to add Text.</p>
<h2>1. DOM + CSS</h2>
<p>Using HTML could simply be the easiest and fastest manner to add text. This is commonly used for descriptive overlays in three.js examples.</p>
<p>You can add content to a
<code>&lt;div id="info"&gt;Description&lt;/div&gt;</code></p>
<p>and use css markup to position absolutely at a position above all others with a z-index especially if you are running three.js full screen.</p>
<p><code>#info {
position: absolute;
top: 10px;
width: 100%;
text-align: center;
z-index: 100;
display:block;
}</code></p>
<h2>2. Draw text to canvas and use as Texture</h2>
<p>Use this method if you wish to draw text easily on a plane in your three.js scene. This technique can be seen utilized in the <a href="http://plumegraph.org/">Civilian Casualties in Afghanistan</a> visualization.</p>
<h2>3. Create a 3d model in your 3d application and export to three.js</h2>
<p>Use this method if you prefer working with your 3d applications and importing the models to three.js</p>
<h2>4. Procedural Text Geometry</h2>
<p>Use this method if you prefer to work purely in three.js or create procedural and dynamic 3d text geometries. However, font data files <a href="http://typeface.neocracy.org/fonts.html">http://typeface.neocracy.org/fonts.html</a> in the typeface.js format needs to be loaded.</p>
<p>A Text Geometry can then be created with <code>new THREE.TextGeometry( text, parameters );</code></p>
<p>For examples, see <a href="https://github.com/mrdoob/three.js/blob/master/examples/webgl_geometry_text.html">https://github.com/mrdoob/three.js/blob/master/examples/webgl_geometry_text.html</a>, <a href="https://github.com/mrdoob/three.js/blob/master/examples/canvas_geometry_text.html">https://github.com/mrdoob/three.js/blob/master/examples/canvas_geometry_text.html</a> and <a href="https://github.com/mrdoob/three.js/blob/master/examples/webgl_shadowmap.html">https://github.com/mrdoob/three.js/blob/master/examples/webgl_shadowmap.html</a></p>
<p>If Typeface is down, or you want to use a font that is not there, there's a tutorial with a python script for blender that allows you to export text to Three.js's JSON format: <a href="http://www.jaanga.com/2012/03/blender-to-threejs-create-3d-text-with.html">http://www.jaanga.com/2012/03/blender-to-threejs-create-3d-text-with.html</a></p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<p>Let's say you want to draw a line or a circle, not a wireframe geometry.
First we need to setup Renderer, Scene and camera (<a href="Getting%20Started">see Getting Started</a>).</p>
<p>Here is the code that we will use:</p>
<div class="highlight highlight-source-js"><pre> <span class="pl-k">var</span> renderer <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">THREE.WebGLRenderer</span>();
<span class="pl-smi">renderer</span>.<span class="pl-en">setSize</span>(<span class="pl-c1">window</span>.<span class="pl-c1">innerWidth</span>, <span class="pl-c1">window</span>.<span class="pl-c1">innerHeight</span>);
<span class="pl-c1">document</span>.<span class="pl-c1">body</span>.<span class="pl-c1">appendChild</span>(<span class="pl-smi">renderer</span>.<span class="pl-smi">domElement</span>);
<span class="pl-k">var</span> camera <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">THREE.PerspectiveCamera</span>(<span class="pl-c1">45</span>, <span class="pl-c1">window</span>.<span class="pl-c1">innerWidth</span> <span class="pl-k">/</span> <span class="pl-c1">window</span>.<span class="pl-c1">innerHeight</span>, <span class="pl-c1">1</span>, <span class="pl-c1">500</span>);
<span class="pl-smi">camera</span>.<span class="pl-smi">position</span>.<span class="pl-c1">set</span>(<span class="pl-c1">0</span>, <span class="pl-c1">0</span>, <span class="pl-c1">100</span>);
<span class="pl-smi">camera</span>.<span class="pl-en">lookAt</span>(<span class="pl-k">new</span> <span class="pl-en">THREE.Vector3</span>(<span class="pl-c1">0</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>));
<span class="pl-k">var</span> scene <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">THREE.Scene</span>();</pre></div>
<p>Next thing we will do is define a material. For lines we have to use <code>LineBasicMaterial</code>.</p>
<div class="highlight highlight-source-js"><pre> <span class="pl-k">var</span> material <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">THREE.LineBasicMaterial</span>({
color<span class="pl-k">:</span> <span class="pl-c1">0x0000ff</span>
});
</pre></div>
<p>After material we will need a <code>Geometry</code> with some vertices:</p>
<div class="highlight highlight-source-js"><pre> <span class="pl-k">var</span> geometry <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">THREE.Geometry</span>();
<span class="pl-smi">geometry</span>.<span class="pl-smi">vertices</span>.<span class="pl-c1">push</span>(<span class="pl-k">new</span> <span class="pl-en">THREE.Vector3</span>(<span class="pl-k">-</span><span class="pl-c1">10</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>));
<span class="pl-smi">geometry</span>.<span class="pl-smi">vertices</span>.<span class="pl-c1">push</span>(<span class="pl-k">new</span> <span class="pl-en">THREE.Vector3</span>(<span class="pl-c1">0</span>, <span class="pl-c1">10</span>, <span class="pl-c1">0</span>));
<span class="pl-smi">geometry</span>.<span class="pl-smi">vertices</span>.<span class="pl-c1">push</span>(<span class="pl-k">new</span> <span class="pl-en">THREE.Vector3</span>(<span class="pl-c1">10</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>));</pre></div>
<p>Note that lines are drawn between each consecutive pair of vertices, but not between the first and last (the line is not closed.)</p>
<p>Now that we have points for two lines and a material, we can put them together to form a line.</p>
<div class="highlight highlight-source-js"><pre>
<span class="pl-k">var</span> line <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">THREE.Line</span>(geometry, material);
</pre></div>
<p>All that's left is to add it to the scene and call <code>render</code>.</p>
<div class="highlight highlight-source-js"><pre>
<span class="pl-smi">scene</span>.<span class="pl-c1">add</span>(line);
<span class="pl-smi">renderer</span>.<span class="pl-en">render</span>(scene, camera);
</pre></div>
<p>You should now be seeing a arrow pointing upwards, made from two blue lines.</p>
</body>
</html>
......@@ -19,7 +19,7 @@
There are two ways to update an object's transformation:
<ol>
<li>
Modify the object's *position*, *quaternion*, and *scale* properties, and let Three.js recompute
Modify the object's *position*, *quaternion*, and *scale* properties, and let three.js recompute
the object's matrix from these properties:
<code>
object.position.copy(start_position);
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</a></h1>
<div class="desc">
The migration guide is maintained on the [link:https://github.com/mrdoob/three.js/wiki wiki].
It contains a list of changes for each version of three.js going back to r45.<br /><br />
You can find it [link:https://github.com/mrdoob/three.js/wiki/Migration here].
</div>
</body>
</html>
......@@ -43,7 +43,7 @@ var onDocumentLoad = function ( event ) {
text = text.replace( /\[example:([\w\_]+)\]/gi, "[example:$1 $1]" ); // [example:name] to [example:name title]
text = text.replace( /\[example:([\w\_]+) ([\w\:\/\.\-\_ \s]+)\]/gi, "<a href=\"../examples/#$1\" target=\"_blank\">$2</a>" ); // [example:name title]
document.body.innerHTML = text;
// handle code snippets formatting
......
......@@ -4215,34 +4215,6 @@
"!doc": "A geometric sphere defined by a center position and radius.",
"!type": "fn(center: +THREE.Vector3, radius: number)"
},
"Spline": {
"!url": "http://threejs.org/docs/#Reference/math/Spline",
"prototype": {
"points": "[]",
"initFromArray": {
"!type": "fn(a: [])",
"!doc": "Initialises using the data in the array as a series of points. Each value in *a* must be another array with three values, where a[n] is v, the value for the *nth* point, and v[0], v[1] and v[2] are the x, y and z coordinates of that point n, respectively."
},
"getPoint": {
"!type": "fn(k: number) -> +THREE.Vector3",
"!doc": "Return the interpolated point at *k*."
},
"getControlPointsArray": {
"!type": "fn() -> []",
"!doc": "Returns an array with triplets of x, y, z coordinates that correspond to the current control points."
},
"getLength": {
"!type": "fn(nSubDivisions: number) -> object",
"!doc": "Returns an object with the two properties. The property .[page:Number total] contains\n\t\t\tthe length of the spline when using nSubDivisions. The property .[page:Array chunkLength]\n\t\t\tcontains an array with the total length from the beginning of the spline to the end of that chunk."
},
"reparametrizeByArcLength": {
"!type": "fn(samplingCoef: number)",
"!doc": "This is done by resampling the original spline, with the density of sampling controlled by *samplingCoef*. Here it's interesting to note that denser sampling is not necessarily better: if sampling is too high, you may get weird kinks in curvature."
}
},
"!doc": "Represents a spline.",
"!type": "fn(points: [])"
},
"Triangle": {
"!url": "http://threejs.org/docs/#Reference/math/Triangle",
"prototype": {
......
......@@ -71,7 +71,7 @@
var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 25.0, recursion, 0, 1, 2, 3, 4, 5, 6, 7 );
var spline = new THREE.Spline( points );
var spline = new THREE.CatmullRomCurve3( points );
var geometrySpline = new THREE.Geometry();
for ( var i = 0; i < points.length * subdivisions; i ++ ) {
......
......@@ -11,8 +11,8 @@ THREE.HDRLoader = THREE.RGBELoader = function ( manager ) {
};
// extend THREE.BinaryTextureLoader
THREE.RGBELoader.prototype = Object.create( THREE.BinaryTextureLoader.prototype );
// extend THREE.DataTextureLoader
THREE.RGBELoader.prototype = Object.create( THREE.DataTextureLoader.prototype );
// adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
THREE.RGBELoader.prototype._parser = function( buffer ) {
......@@ -112,16 +112,16 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
programtype: 'RGBE', /* listed at beginning of file to identify it
* after "#?". defaults to "RGBE" */
format: '', /* RGBE format, default 32-bit_rle_rgbe */
gamma: 1.0, /* image has already been gamma corrected with
* given gamma. defaults to 1.0 (no correction) */
exposure: 1.0, /* a value of 1.0 in an image corresponds to
* <exposure> watts/steradian/m^2.
* defaults to 1.0 */
width: 0, height: 0 /* image dimensions, width/height */
}
......
......@@ -60,7 +60,7 @@ THREE.CSS2DRenderer = function () {
if ( object instanceof THREE.CSS2DObject ) {
vector.setFromMatrixPosition( object.matrixWorld );
vector.applyProjection( viewProjectionMatrix );
vector.applyMatrix4( viewProjectionMatrix );
var element = object.element;
var style = 'translate(-50%,-50%) translate(' + ( vector.x * _widthHalf + _widthHalf ) + 'px,' + ( - vector.y * _heightHalf + _heightHalf ) + 'px)';
......
......@@ -346,7 +346,7 @@ THREE.Projector = function () {
_object.object = object;
_vector3.setFromMatrixPosition( object.matrixWorld );
_vector3.applyProjection( _viewProjectionMatrix );
_vector3.applyMatrix4( _viewProjectionMatrix );
_object.z = _vector3.z;
_object.renderOrder = object.renderOrder;
......@@ -444,9 +444,9 @@ THREE.Projector = function () {
if ( groups.length > 0 ) {
for ( var o = 0; o < groups.length; o ++ ) {
for ( var g = 0; g < groups.length; g ++ ) {
var group = groups[ o ];
var group = groups[ g ];
for ( var i = group.start, l = group.start + group.count; i < l; i += 3 ) {
......
......@@ -225,7 +225,7 @@ THREE.SVGRenderer = function () {
if ( object instanceof THREE.SVGObject ) {
_vector3.setFromMatrixPosition( object.matrixWorld );
_vector3.applyProjection( _viewProjectionMatrix );
_vector3.applyMatrix4( _viewProjectionMatrix );
var x = _vector3.x * _svgWidthHalf;
var y = - _vector3.y * _svgHeightHalf;
......
......@@ -94,7 +94,7 @@
var position, index;
var spline = new THREE.Spline( points );
var spline = new THREE.CatmullRomCurve3( points );
for ( i = 0; i < points.length * n_sub; i ++ ) {
......
......@@ -102,7 +102,7 @@
// Line
var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 200.0, 1, 0, 1, 2, 3, 4, 5, 6, 7 );
var spline = new THREE.Spline( points );
var spline = new THREE.CatmullRomCurve3( points );
var n_sub = 6, colors = [], line;
var lineGeometry = new THREE.Geometry();
......
......@@ -226,7 +226,7 @@
for ( var i = 0; i < length; i ++ ) {
vector.fromArray( positions, i * 3 );
vector.applyProjection( matrix );
vector.applyMatrix4( matrix );
sortArray.push( [ vector.z, i ] );
......
......@@ -68,7 +68,7 @@
var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 25.0, recursion, 0, 1, 2, 3, 4, 5, 6, 7 );
var spline = new THREE.Spline( points );
var spline = new THREE.CatmullRomCurve3( points );
var geometrySpline = new THREE.Geometry();
for ( var i = 0; i < points.length * subdivisions; i ++ ) {
......
......@@ -92,7 +92,7 @@
var position, index;
var spline = new THREE.Spline( points );
var spline = new THREE.CatmullRomCurve3( points );
for ( i = 0; i < points.length * n_sub; i ++ ) {
......
......@@ -35,6 +35,7 @@ import { Light } from './lights/Light.js';
import { FileLoader } from './loaders/FileLoader.js';
import { AudioLoader } from './loaders/AudioLoader.js';
import { CubeTextureLoader } from './loaders/CubeTextureLoader.js';
import { DataTextureLoader } from './loaders/DataTextureLoader.js';
import { TextureLoader } from './loaders/TextureLoader.js';
import { Material } from './materials/Material.js';
import { LineBasicMaterial } from './materials/LineBasicMaterial.js';
......@@ -52,7 +53,9 @@ import { Matrix4 } from './math/Matrix4.js';
import { Plane } from './math/Plane.js';
import { Quaternion } from './math/Quaternion.js';
import { Ray } from './math/Ray.js';
import { Vector2 } from './math/Vector2.js';
import { Vector3 } from './math/Vector3.js';
import { Vector4 } from './math/Vector4.js';
import { LineSegments } from './objects/LineSegments.js';
import { LOD } from './objects/LOD.js';
import { Points } from './objects/Points.js';
......@@ -230,6 +233,39 @@ export function SplineCurve3( points ) {
SplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype );
//
export function Spline( points ) {
console.warn( 'THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.' );
CatmullRomCurve3.call( this, points );
this.type = 'catmullrom';
}
Spline.prototype = Object.create( CatmullRomCurve3.prototype );
Object.assign( Spline.prototype, {
initFromArray: function ( a ) {
console.error( 'THREE.Spline: .initFromArray() has been removed.' );
},
getControlPointsArray: function ( optionalTarget ) {
console.error( 'THREE.Spline: .getControlPointsArray() has been removed.' );
},
reparametrizeByArcLength: function ( samplingCoef ) {
console.error( 'THREE.Spline: .reparametrizeByArcLength() has been removed.' );
}
} );
//
export function BoundingBoxHelper( object, color ) {
......@@ -267,6 +303,13 @@ export function XHRLoader( manager ) {
}
export function BinaryTextureLoader( manager ) {
console.warn( 'THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader.' );
return new DataTextureLoader( manager );
}
//
Object.assign( Box2.prototype, {
......@@ -414,8 +457,8 @@ Object.assign( Matrix4.prototype, {
},
multiplyVector3: function ( vector ) {
console.warn( 'THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead.' );
return vector.applyProjection( this );
console.warn( 'THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.' );
return vector.applyMatrix4( this );
},
multiplyVector4: function ( vector ) {
......@@ -541,6 +584,17 @@ Object.assign( Shape.prototype, {
} );
Object.assign( Vector2.prototype, {
fromAttribute: function ( attribute, index, offset ) {
console.error( 'THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().' );
return this.fromBufferAttribute( attribute, index, offset );
}
} );
Object.assign( Vector3.prototype, {
setEulerFromRotationMatrix: function () {
......@@ -570,6 +624,29 @@ Object.assign( Vector3.prototype, {
console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' );
return this.setFromMatrixColumn( matrix, index );
},
applyProjection: function ( m ) {
console.warn( 'THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.' );
return this.applyMatrix4( m );
},
fromAttribute: function ( attribute, index, offset ) {
console.error( 'THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().' );
return this.fromBufferAttribute( attribute, index, offset );
}
} );
Object.assign( Vector4.prototype, {
fromAttribute: function ( attribute, index, offset ) {
console.error( 'THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().' );
return this.fromBufferAttribute( attribute, index, offset );
}
} );
......
......@@ -32,7 +32,7 @@ export { Texture } from './textures/Texture.js';
export * from './geometries/Geometries.js';
export * from './materials/Materials.js';
export { CompressedTextureLoader } from './loaders/CompressedTextureLoader.js';
export { BinaryTextureLoader, DataTextureLoader } from './loaders/BinaryTextureLoader.js';
export { DataTextureLoader } from './loaders/DataTextureLoader.js';
export { CubeTextureLoader } from './loaders/CubeTextureLoader.js';
export { TextureLoader } from './loaders/TextureLoader.js';
export { ObjectLoader } from './loaders/ObjectLoader.js';
......@@ -100,7 +100,6 @@ export { DiscreteInterpolant } from './math/interpolants/DiscreteInterpolant.js'
export { CubicInterpolant } from './math/interpolants/CubicInterpolant.js';
export { Interpolant } from './math/Interpolant.js';
export { Triangle } from './math/Triangle.js';
export { Spline } from './math/Spline.js';
export { _Math as Math } from './math/Math.js';
export { Spherical } from './math/Spherical.js';
export { Cylindrical } from './math/Cylindrical.js';
......
......@@ -9,8 +9,7 @@ import { DefaultLoadingManager } from './LoadingManager';
* Abstract Base class to load generic binary textures formats (rgbe, hdr, ...)
*/
var DataTextureLoader = BinaryTextureLoader;
function BinaryTextureLoader( manager ) {
function DataTextureLoader( manager ) {
this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
......@@ -19,7 +18,7 @@ function BinaryTextureLoader( manager ) {
}
Object.assign( BinaryTextureLoader.prototype, {
Object.assign( DataTextureLoader.prototype, {
load: function ( url, onLoad, onProgress, onError ) {
......@@ -93,4 +92,4 @@ Object.assign( BinaryTextureLoader.prototype, {
} );
export { BinaryTextureLoader, DataTextureLoader };
export { DataTextureLoader };
......@@ -165,7 +165,7 @@ Box3.prototype = {
for ( i = 0, l = attribute.count; i < l; i ++ ) {
v1.fromAttribute( attribute, i ).applyMatrix4( node.matrixWorld );
v1.fromBufferAttribute( attribute, i ).applyMatrix4( node.matrixWorld );
scope.expandByPoint( v1 );
......
import { Vector3 } from './Vector3';
/**
* Spline from Tween.js, slightly optimized (and trashed)
* http://sole.github.com/tween.js/examples/05_spline.html
*
* @author mrdoob / http://mrdoob.com/
* @author alteredq / http://alteredqualia.com/
*/
function Spline( points ) {
this.points = points;
var c = [], v3 = { x: 0, y: 0, z: 0 },
point, intPoint, weight, w2, w3,
pa, pb, pc, pd;
this.initFromArray = function ( a ) {
this.points = [];
for ( var i = 0; i < a.length; i ++ ) {
this.points[ i ] = { x: a[ i ][ 0 ], y: a[ i ][ 1 ], z: a[ i ][ 2 ] };
}
};
this.getPoint = function ( k ) {
point = ( this.points.length - 1 ) * k;
intPoint = Math.floor( point );
weight = point - intPoint;
c[ 0 ] = intPoint === 0 ? intPoint : intPoint - 1;
c[ 1 ] = intPoint;
c[ 2 ] = intPoint > this.points.length - 2 ? this.points.length - 1 : intPoint + 1;
c[ 3 ] = intPoint > this.points.length - 3 ? this.points.length - 1 : intPoint + 2;
pa = this.points[ c[ 0 ] ];
pb = this.points[ c[ 1 ] ];
pc = this.points[ c[ 2 ] ];
pd = this.points[ c[ 3 ] ];
w2 = weight * weight;
w3 = weight * w2;
v3.x = interpolate( pa.x, pb.x, pc.x, pd.x, weight, w2, w3 );
v3.y = interpolate( pa.y, pb.y, pc.y, pd.y, weight, w2, w3 );
v3.z = interpolate( pa.z, pb.z, pc.z, pd.z, weight, w2, w3 );
return v3;
};
this.getControlPointsArray = function () {
var i, p, l = this.points.length,
coords = [];
for ( i = 0; i < l; i ++ ) {
p = this.points[ i ];
coords[ i ] = [ p.x, p.y, p.z ];
}
return coords;
};
// approximate length by summing linear segments
this.getLength = function ( nSubDivisions ) {
var i, index, nSamples, position,
point = 0, intPoint = 0, oldIntPoint = 0,
oldPosition = new Vector3(),
tmpVec = new Vector3(),
chunkLengths = [],
totalLength = 0;
// first point has 0 length
chunkLengths[ 0 ] = 0;
if ( ! nSubDivisions ) nSubDivisions = 100;
nSamples = this.points.length * nSubDivisions;
oldPosition.copy( this.points[ 0 ] );
for ( i = 1; i < nSamples; i ++ ) {
index = i / nSamples;
position = this.getPoint( index );
tmpVec.copy( position );
totalLength += tmpVec.distanceTo( oldPosition );
oldPosition.copy( position );
point = ( this.points.length - 1 ) * index;
intPoint = Math.floor( point );
if ( intPoint !== oldIntPoint ) {
chunkLengths[ intPoint ] = totalLength;
oldIntPoint = intPoint;
}
}
// last point ends with total length
chunkLengths[ chunkLengths.length ] = totalLength;
return { chunks: chunkLengths, total: totalLength };
};
this.reparametrizeByArcLength = function ( samplingCoef ) {
var i, j,
index, indexCurrent, indexNext,
realDistance,
sampling, position,
newpoints = [],
tmpVec = new Vector3(),
sl = this.getLength();
newpoints.push( tmpVec.copy( this.points[ 0 ] ).clone() );
for ( i = 1; i < this.points.length; i ++ ) {
//tmpVec.copy( this.points[ i - 1 ] );
//linearDistance = tmpVec.distanceTo( this.points[ i ] );
realDistance = sl.chunks[ i ] - sl.chunks[ i - 1 ];
sampling = Math.ceil( samplingCoef * realDistance / sl.total );
indexCurrent = ( i - 1 ) / ( this.points.length - 1 );
indexNext = i / ( this.points.length - 1 );
for ( j = 1; j < sampling - 1; j ++ ) {
index = indexCurrent + j * ( 1 / sampling ) * ( indexNext - indexCurrent );
position = this.getPoint( index );
newpoints.push( tmpVec.copy( position ).clone() );
}
newpoints.push( tmpVec.copy( this.points[ i ] ).clone() );
}
this.points = newpoints;
};
// Catmull-Rom
function interpolate( p0, p1, p2, p3, t, t2, t3 ) {
var v0 = ( p2 - p0 ) * 0.5,
v1 = ( p3 - p1 ) * 0.5;
return ( 2 * ( p1 - p2 ) + v0 + v1 ) * t3 + ( - 3 * ( p1 - p2 ) - 2 * v0 - v1 ) * t2 + v0 * t + p1;
}
}
export { Spline };
......@@ -453,11 +453,11 @@ Vector2.prototype = {
},
fromAttribute: function ( attribute, index, offset ) {
fromBufferAttribute: function ( attribute, index, offset ) {
if ( offset !== undefined ) {
console.warn( 'THREE.Vector2: offset has been removed from .fromAttribute().' );
console.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' );
}
......
......@@ -293,32 +293,15 @@ Vector3.prototype = {
applyMatrix4: function ( m ) {
// input: THREE.Matrix4 affine matrix
var x = this.x, y = this.y, z = this.z;
var e = m.elements;
this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ];
this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ];
this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ];
var w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ];
return this;
},
applyProjection: function ( m ) {
// input: THREE.Matrix4 projection matrix
var x = this.x, y = this.y, z = this.z;
var e = m.elements;
var d = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] ); // perspective divide
this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * d;
this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * d;
this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * d;
return this;
return this.divideScalar( w );
},
......@@ -353,7 +336,7 @@ Vector3.prototype = {
if ( matrix === undefined ) matrix = new Matrix4();
matrix.multiplyMatrices( camera.projectionMatrix, matrix.getInverse( camera.matrixWorld ) );
return this.applyProjection( matrix );
return this.applyMatrix4( matrix );
};
......@@ -368,7 +351,7 @@ Vector3.prototype = {
if ( matrix === undefined ) matrix = new Matrix4();
matrix.multiplyMatrices( camera.matrixWorld, matrix.getInverse( camera.projectionMatrix ) );
return this.applyProjection( matrix );
return this.applyMatrix4( matrix );
};
......@@ -761,11 +744,11 @@ Vector3.prototype = {
},
fromAttribute: function ( attribute, index, offset ) {
fromBufferAttribute: function ( attribute, index, offset ) {
if ( offset !== undefined ) {
console.warn( 'THREE.Vector3: offset has been removed from .fromAttribute().' );
console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );
}
......
......@@ -611,11 +611,11 @@ Vector4.prototype = {
},
fromAttribute: function ( attribute, index, offset ) {
fromBufferAttribute: function ( attribute, index, offset ) {
if ( offset !== undefined ) {
console.warn( 'THREE.Vector4: offset has been removed from .fromAttribute().' );
console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );
}
......
......@@ -145,9 +145,9 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
function checkBufferGeometryIntersection( object, raycaster, ray, position, uv, a, b, c ) {
vA.fromAttribute( position, a );
vB.fromAttribute( position, b );
vC.fromAttribute( position, c );
vA.fromBufferAttribute( position, a );
vB.fromBufferAttribute( position, b );
vC.fromBufferAttribute( position, c );
var intersection = checkIntersection( object, raycaster, ray, vA, vB, vC, intersectionPoint );
......@@ -155,9 +155,9 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
if ( uv ) {
uvA.fromAttribute( uv, a );
uvB.fromAttribute( uv, b );
uvC.fromAttribute( uv, c );
uvA.fromBufferAttribute( uv, a );
uvB.fromBufferAttribute( uv, b );
uvC.fromBufferAttribute( uv, c );
intersection.uv = uvIntersection( intersectionPoint, vA, vB, vC, uvA, uvB, uvC );
......
......@@ -1382,7 +1382,7 @@ function WebGLRenderer( parameters ) {
if ( _this.sortObjects === true ) {
_vector3.setFromMatrixPosition( object.matrixWorld );
_vector3.applyProjection( _projScreenMatrix );
_vector3.applyMatrix4( _projScreenMatrix );
}
......@@ -1405,7 +1405,7 @@ function WebGLRenderer( parameters ) {
if ( _this.sortObjects === true ) {
_vector3.setFromMatrixPosition( object.matrixWorld );
_vector3.applyProjection( _projScreenMatrix );
_vector3.applyMatrix4( _projScreenMatrix );
}
......
......@@ -242,7 +242,7 @@ function LensFlarePlugin( renderer, flares ) {
tempPosition.set( flare.matrixWorld.elements[ 12 ], flare.matrixWorld.elements[ 13 ], flare.matrixWorld.elements[ 14 ] );
tempPosition.applyMatrix4( camera.matrixWorldInverse );
tempPosition.applyProjection( camera.projectionMatrix );
tempPosition.applyMatrix4( camera.projectionMatrix );
// setup arrays for gl programs
......
......@@ -344,3 +344,36 @@ test( "equals", function() {
ok( a.equals( b ), "Passed!" );
ok( b.equals( a ), "Passed!" );
});
test( "applyMatrix4", function() {
var a = new THREE.Vector3( x, y, z );
var b = new THREE.Vector4( x, y, z, 1 );
var m = new THREE.Matrix4().makeRotationX( Math.PI );
a.applyMatrix4( m );
b.applyMatrix4( m );
ok( a.x == b.x / b.w, "Passed!" );
ok( a.y == b.y / b.w, "Passed!" );
ok( a.z == b.z / b.w, "Passed!" );
m = new THREE.Matrix4().makeTranslation( 3, 2, 1 );
a.applyMatrix4( m );
b.applyMatrix4( m );
ok( a.x == b.x / b.w, "Passed!" );
ok( a.y == b.y / b.w, "Passed!" );
ok( a.z == b.z / b.w, "Passed!" );
m = new THREE.Matrix4().set(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 1, 0
);
a.applyMatrix4( m );
b.applyMatrix4( m );
ok( a.x == b.x / b.w, "Passed!" );
ok( a.y == b.y / b.w, "Passed!" );
ok( a.z == b.z / b.w, "Passed!" );
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册