@@ -19,14 +19,14 @@ The aim of the project is to create an easy to use, lightweight, 3D library. The
### Usage ###
### Usage ###
-Download the [minified library](http://threejs.org/build/three.min.js) and include it in your html, or install and import it as a [module](http://threejs.org/docs/#manual/introduction/Import-via-modules),
+Download the [minified library](http://threejs.org/build/three.min.js) and include it in your HTML, or install and import it as a [module](http://threejs.org/docs/#manual/introduction/Import-via-modules),
Alternatively see [how to build the library yourself](https://github.com/mrdoob/three.js/wiki/Build-instructions).
Alternatively see [how to build the library yourself](https://github.com/mrdoob/three.js/wiki/Build-instructions).
```html
```html
<script src="js/three.min.js"></script>
<script src="js/three.min.js"></script>
```
```
-This code creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a `WebGL` renderer for the scene and camera, and it adds that viewport to the document.body element. Finally it animates the cube within the scene for the camera.
+This code creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a `WebGL` renderer for the scene and camera, and it adds that viewport to the document.body element. Finally, it animates the cube within the scene for the camera.
+ [page:Camera object]: (required) The camera to be controlled.<br><br>
+
+ [page:HTMLDOMElement domElement]: (optional) The HTML element used for event listeners. By default this is the whole document,
+ however if you only want to the controls to work over a specific element (e.g. the canvas) you can specify that here.
+ </div>
+
+
+ <h2>Properties</h2>
+
+ <h3>[property:Boolean autoRotate]</h3>
+ <div>
+ Set to true to automatically rotate around the target.<br> Note that if this is enabled, you must call [page:.update]
+ () in your animation loop.
+ </div>
+
+ <h3>[property:Float autoRotateSpeed]</h3>
+ <div>
+ How fast to rotate around the target if [property:Boolean autoRotate] is true. Default is 2.0, which equates to 30 seconds
+ per rotation at 60fps.<br> Note that if [property:Boolean autoRotate] is enabled, you must call [page:.update]
+ () in your animation loop.
+ </div>
+
+ <h3>
+ [property:Float dampingFactor]</h3>
+ <div>
+ The damping inertia used if [property:Boolean enableDamping] is set to true.<br> Note that for this to work, you must
+ call [page:.update] () in your animation loop.
+ </div>
+
+ <h3>[property:HTMLDOMElement domElement]</h3>
+ <div>
+ The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will
+ not set up new event listeners. Default is the whole document.
+ </div>
+
+ <h3>[property:Boolean enabled]</h3>
+ <div>
+ Whether or not the controls are enabled.
+ </div>
+
+ <h3>[property:Boolean enableDamping]</h3>
+ <div>
+ Set to true to enable damping (inertia), which can be used to give a sense of weight to the controls. Default is false.<br> Note that if this is enabled, you must call [page:.update] () in your animation loop.
+ </div>
+
+ <h3>[property:Boolean enableKeys]</h3>
+ <div>
+ Enable or disable the use of keyboard controls.
+ </div>
+
+ <h3>[property:Boolean enablePan]</h3>
+ <div>
+ Enable or disable camera panning. Default is true.
+ </div>
+
+ <h3>[property:Boolean enableRotate]</h3>
+ <div>
+ Enable or disable horizontal and vertical rotation of the camera. Default is true.<br>
+ Note that it is possible to disable a single axis by setting the min and max of the
+ [page:.minPolarAngle polar angle] or [page:.minAzimuthAngle azimuth angle] to the same value,
+ which will cause the vertical or horizontal rotation to be fixed at that value.
+ </div>
+
+ <h3>[property:Boolean enableZoom]</h3>
+ <div>
+ Enable or disable zooming (dollying) of the camera.
+ </div>
+
+ <h3>[property:Float keyPanSpeed]</h3>
+ <div>
+ How fast to pan the camera when the keyboard is used. Default is 7.0 pixels per keypress.
+ </div>
+
+ <h3>[property:Object keys]</h3>
+ <div>
+ This object contains references to the keycodes for controlling camera panning. Default is the 4 arrow keys.
+ <code>
+controls.keys = {
+ LEFT: 37, //left arrow
+ UP: 38, // up arrow
+ RIGHT: 39, // right arrow
+ BOTTOM: 40 // down arrow
+}
+ </code> See [link:https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode this page] for a full
+ list of keycodes.
+ </div>
+
+ <h3>[property:Float maxAzimuthAngle]</h3>
+ <div>
+ How far you can orbit horizontally, upper limit. Range is - Math.PI to Math.PI ( or Infinity for no limit ) and default is
+ Infinity;
+ </div>
+
+ <h3>[property:Float maxDistance]</h3>
+ <div>
+ How far you can dolly out ( [page:PerspectiveCamera] only ). Default is Infinity.
+ </div>
+
+ <h3>[property:Float maxPolarAngle]</h3>
+ <div>
+ How far you can orbit vertically, upper limit. Range is 0 to Math.PI radians, and default is Math.PI.
+ </div>
+
+ <h3>[property:Float maxZoom]</h3>
+ <div>
+ How far you can zoom out ( [page:OrthographicCamera] only ). Default is Infinity.
+ </div>
+
+ <h3>[property:Float minAzimuthAngle]</h3>
+ <div>
+ How far you can orbit horizontally, lower limit. Range is - Math.PI to Math.PI ( or - Infinity for no limit ) and default
+ is - Infinity;
+ </div>
+
+ <h3>[property:Float minDistance]</h3>
+ <div>
+ How far you can dolly in ( [page:PerspectiveCamera] only ). Default is 0.
+ </div>
+
+ <h3>[property:Float minPolarAngle]</h3>
+ <div>
+ How far you can orbit vertically, lower limit. Range is 0 to Math.PI radians, and default is 0.
+ </div>
+
+ <h3>[property:Float minZoom]</h3>
+ <div>
+ How far you can zoom in ( [page:OrthographicCamera] only ). Default is 0.
+ </div>
+
+ <h3>
+ [property:Object mouseButtons]</h3>
+ <div>
+ This object contains references to the mouse buttons used for the controls.
+ <code>
+controls.mouseButtons = {
+ ORBIT: THREE.MOUSE.LEFT,
+ ZOOM: THREE.MOUSE.MIDDLE,
+ PAN: THREE.MOUSE.RIGHT
+}
+ </code>
+ </div>
+
+ <h3>[property:Camera object]</h3>
+ <div>
+ The camera ( or other object ) that is being controlled.
+ </div>
+
+ <h3>[property:Vector3 position0]</h3>
+ <div>
+ Used internally by the [method:saveState] and [method:reset] methods.
+ </div>
+
+ <h3>[property:Float rotateSpeed]</h3>
+ <div>
+ Speed of rotation. Default is 1.
+ </div>
+
+ <h3>[property:Vector3 target0]</h3>
+ <div>
+ Used internally by the [method:saveState] and [method:reset] methods.
+ </div>
+
+ <h3>[property:Vector3 target]</h3>
+ <div>
+ The focus point of the controls, the [page:.object] orbits around this. It can be updated manually at any point to change
+ the focus of the controls.
+ </div>
+
+ <h3>[property:Float zoom0]</h3>
+ <div>
+ Used internally by the [method:saveState] and [method:reset] methods.
+ </div>
+
+ <h3>[property:Float zoomSpeed]</h3>
+ <div>
+ Speed of zooming / dollying. Default is 1.
+ </div>
+
+
+
+ <h2>Methods</h2>
+
+ <h3>[method:null dispose] ()</h3>
+ <div>
+ Remove all the event listeners.
+ </div>
+
+ <h3>[method:radians getAzimuthalAngle] ()</h3>
+ <div>
+ Get the current horizontal rotation, in radians.
+ </div>
+
+ <h3>[method:radians getPolarAngle] ()</h3>
+ <div>
+ Get the current vertical rotation, in radians.
+ </div>
+
+ <h3>[method:null reset] ()</h3>
+ <div>
+ Reset the controls to their state from either the last time the [page:.saveState] was called, or the initial state.
+ </div>
+
+ <h3>[method:null saveState] ()</h3>
+ <div>
+ Save the current state of the controls. This can later be recovered with [page:.reset].
+ </div>
+
+ <h3>[method:false update] ()</h3>
+ <div>
+ Update the controls. Must be called after any manual changes to the camera's transform,
+ or in the update loop if [page:.autoRotate] or [page:.enableDamping] are set.
+ [page:Function onCompleted] — Will be called when the export completes. The argument will be the generated glTF JSON.<br />
+ [page:Options options] - Export options<br />
+ <ul>
+ <li>trs - bool. Export position, rotation and scale instead of matrix per node. Default is false</li>
+ <li>onlyVisible - bool. Export only visible objects. Default is true.</li>
+ <li>truncateDrawRange - bool. Export just the attributes within the drawRange, if defined, instead of exporting the whole array. Default is true.</li>
+ </ul>
+ </div>
+ <div>
+ Generates a glTF output (JSON) with from the input (Scene or Objects)
- <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: scene, camera and renderer, so that we can render the scene with camera.</div>
<code>
<code>
var scene = new THREE.Scene();
var scene = new THREE.Scene();
@@ -51,7 +51,11 @@
document.body.appendChild( renderer.domElement );
document.body.appendChild( renderer.domElement );
</code>
</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.</div>
+
+ <div>There are a few different cameras in three.js. For now, let's use a <strong>PerspectiveCamera</strong>.</div>
+
+ <div>The first attribute is the <strong>field of view</strong>. FOV is the extent of the scene that is seen on the display at any given moment. The value is in degrees.</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 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>
@@ -96,7 +100,7 @@
animate();
animate();
</code>
</code>
- <div>This will create a loop that causes the renderer to draw the scene 60 times per second. If you're new to writing games in the browser, you might say "why don't we just create a <strong>setInterval</strong>? The thing is - we could, but <strong>requestAnimationFrame</strong> has a number of advantages. Perhaps the most important one is that it pauses when the user navigates to another browser tab, hence not wasting their precious processing power and battery life.</div>
+ <div>This will create a loop that causes the renderer to draw the scene 60 times per second. If you're new to writing games in the browser, you might say <em>"why don't we just create a setInterval ?"</em> The thing is - we could, but <strong>requestAnimationFrame</strong> has a number of advantages. Perhaps the most important one is that it pauses when the user navigates to another browser tab, hence not wasting their precious processing power and battery life.</div>
- <div>Using a dependency manager like npm avoids these caveats by allowing you to simply download and import your desired version of the libarary onto your machine.</div>
+ <div>Using a dependency manager like npm avoids these caveats by allowing you to simply download and import your desired version of the library onto your machine.</div>
<h2>Installation via npm</h2>
<h2>Installation via npm</h2>
@@ -65,7 +65,7 @@
<h2>Caveats</h2>
<h2>Caveats</h2>
<div>
<div>
- Currently it's not possible to import the files within the "examples/js" directroy in this way.
+ Currently it's not possible to import the files within the "examples/js" directory in this way.
This is due to some of the files relying on global namespace pollution of THREE. For more information see <a href="https://github.com/mrdoob/three.js/issues/9562" target="_blank">Transform `examples/js` to support modules #9562</a>.
This is due to some of the files relying on global namespace pollution of THREE. For more information see <a href="https://github.com/mrdoob/three.js/issues/9562" target="_blank">Transform `examples/js` to support modules #9562</a>.
+ // Each token is an integer value whose type is specified by "header_type" at the top of the file (UInt32 if no type specified). The token meanings are:
+ // [#blocks] = Number of blocks
+ // [#u-size] = Block size before compression
+ // [#p-size] = Size of last partial block (zero if it not needed)
+ // [#c-size-i] = Size in bytes of block i after compression
+ //
+ // The [DATA] portion stores contiguously every block appended together. The offset from the beginning of the data section to the beginning of a block is
+ // computed by summing the compressed block sizes from preceding blocks according to the header.
+
+ rawData = ele[ '#text' ];
+
+ byteData = Base64toByteArray( rawData );
+
+ blocks = byteData[ 0 ];
+ for ( var i = 1; i < numBytes - 1; i ++ ) {
+
+ blocks = blocks | ( byteData[ i ] << ( i * numBytes ) );
- // Each token is an integer value whose type is specified by "header_type" at the top of the file (UInt32 if no type specified). The token meanings are:
- // [#blocks] = Number of blocks
- // [#u-size] = Block size before compression
- // [#p-size] = Size of last partial block (zero if it not needed)
- // [#c-size-i] = Size in bytes of block i after compression
- //
- // The [DATA] portion stores contiguously every block appended together. The offset from the beginning of the data section to the beginning of a block is
- // computed by summing the compressed block sizes from preceding blocks according to the header.
- callbacks: new THREE.OBJLoader2.WWOBJLoader2.PrepDataCallbacks()
- };
-};
-
-/**
- * Callbacks utilized by functions working with {@link THREE.OBJLoader2.WWOBJLoader2.PrepDataArrayBuffer} or {@link THREE.OBJLoader2.WWOBJLoader2.PrepDataFile}
- * @param {callback} callbackErrorWhileLoading Callback function for described functionality
- */
- registerCallbackErrorWhileLoading: function ( callbackErrorWhileLoading ) {
- if ( Validator.isValid( callbackErrorWhileLoading ) ) this.errorWhileLoading = callbackErrorWhileLoading;
- },
-
- progress: null,
- completedLoading: null,
- errorWhileLoading: null,
- materialsLoaded: null,
- meshLoaded: null
- };
-};
-
-
-/**
- * Object to return by {@link THREE.OBJLoader2.WWOBJLoader2}.callbacks.meshLoaded. Used to adjust bufferGeometry or material or prevent complete loading of mesh
- *
- * @param {boolean} disregardMesh=false Tell WWOBJLoader2 to completely disregard this mesh
- * @param {THREE.BufferGeometry} bufferGeometry The {@link THREE.BufferGeometry} to be used
- * @param {THREE.Material} material The {@link THREE.Material} to be used
+ d = 200.0 + cos( f * g / 2.0 ) * 18.0 + cos( e * g ) * 7.0;
+ r = sqrt( pow( abs( i - e ), 2.0 ) + pow( abs( d - f ), 2.0 ) );
+ q = f / r;
+ e = ( r * cos( q ) ) - a / 2.0;
+ f = ( r * sin( q ) ) - a / 2.0;
+ d = sin( e * g ) * 176.0 + sin( e * g ) * 164.0 + r;
+ h = ( ( f + d ) + a / 2.0 ) * g;
+ i = cos( h + r * p.x / 1.3 ) * ( e + e + a ) + cos( q * g * 6.0 ) * ( r + h / 3.0 );
+ h = sin( f * g ) * 144.0 - sin( e * g ) * 212.0 * p.x;
+ h = ( h + ( f - e ) * q + sin( r - ( a + h ) / 7.0 ) * 10.0 + i / 4.0 ) * g;
+ i += cos( h * 2.3 * sin( a / 350.0 - q ) ) * 184.0 * sin( q - ( r * 4.3 + a / 12.0 ) * g ) + tan( r * g + h ) * 184.0 * cos( r * g + h );
+ i = mod( i / 5.6, 256.0 ) / 64.0;
+ if ( i < 0.0 ) i += 4.0;
+ if ( i >= 2.0 ) i = 4.0 - i;
+ d = r / 350.0;
+ d += sin( d * d * 8.0 ) * 0.52;
+ f = ( sin( a * g ) + 1.0 ) / 2.0;
+ gl_FragColor = vec4( vec3( f * i / 1.6, i / 2.0 + d / 13.0, i ) * d * p.x + vec3( i / 1.3 + d / 8.0, i / 2.0 + d / 18.0, i ) * d * ( 1.0 - p.x ), 1.0 );
}
}
@@ -90,7 +95,7 @@
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();