cleanup of files for MrDoob's code style
@@ -118,7 +118,7 @@ THREE.AudioObject = function ( url, volume, playbackRate, loop ) {
cameraUp.copy( camera.up );
- cameraFront.set( 0, 0, -1 );
+ cameraFront.set( 0, 0, - 1 );
cameraFront.transformDirection( camera.matrixWorld );
this.listener.setPosition( cameraPosition.x, cameraPosition.y, cameraPosition.z );
@@ -130,7 +130,7 @@ THREE.AudioObject = function ( url, volume, playbackRate, loop ) {
if ( this.directionalSource ) {
- soundFront.set( 0, 0, -1 );
+ soundFront.set( 0, 0, - 1 );
soundFront.transformDirection( this.matrixWorld );
soundUp.copy( this.up );
@@ -62,7 +62,7 @@ THREE.BlendCharacter = function () {
// interpolate the weight for the current time
- data.anim.weight = data.startWeight + (data.endWeight - data.startWeight) * data.timeElapsed / data.duration;
+ data.anim.weight = data.startWeight + ( data.endWeight - data.startWeight ) * data.timeElapsed / data.duration;
}
@@ -117,7 +117,7 @@ THREE.BlendCharacter = function () {
};
- this.play = function(animName, weight) {
+ this.play = function( animName, weight ) {
this.animations[ animName ].play( 0, weight );
@@ -172,7 +172,7 @@ THREE.BlendCharacter = function () {
- this.applyWeight = function(animName, weight) {
+ this.applyWeight = function( animName, weight ) {
this.animations[ animName ].weight = weight;
@@ -212,7 +212,9 @@ THREE.BlendCharacter = function () {
for ( a in this.animations ) {
if ( this.animations[ a ].isPlaying ) {
- this.animations[ a ].stop(0);
+
+ this.animations[ a ].stop( 0 );
this.animations[ a ].weight = 0;
@@ -244,12 +246,14 @@ THREE.BlendCharacter.prototype.getForward = function() {
// pull the character's forward basis vector out of the matrix
forward.set(
- -this.matrix.elements[ 8 ],
- -this.matrix.elements[ 9 ],
- -this.matrix.elements[ 10 ]
+ - this.matrix.elements[ 8 ],
+ - this.matrix.elements[ 9 ],
+ - this.matrix.elements[ 10 ]
);
return forward;
@@ -2,7 +2,7 @@
* @author Michael Guerrero / http://realitymeltdown.com
*/
-function BlendCharacterGui(animations) {
+function BlendCharacterGui( animations ) {
var controls = {
@@ -22,27 +22,27 @@ function BlendCharacterGui(animations) {
this.showModel = function() {
- return controls['Show Model'];
+ return controls[ 'Show Model' ];
this.showSkeleton = function() {
- return controls['Show Skeleton'];
+ return controls[ 'Show Skeleton' ];
this.getTimeScale = function() {
- return controls['Time Scale'];
+ return controls[ 'Time Scale' ];
this.update = function() {
- controls[ 'idle'] = animations[ 'idle' ].weight;
- controls[ 'walk'] = animations[ 'walk' ].weight;
- controls[ 'run'] = animations[ 'run' ].weight;
+ controls[ 'idle' ] = animations[ 'idle' ].weight;
+ controls[ 'walk' ] = animations[ 'walk' ].weight;
+ controls[ 'run' ] = animations[ 'run' ].weight;
@@ -68,9 +68,9 @@ function BlendCharacterGui(animations) {
playback.add( controls, "walk to run" );
playback.add( controls, "warp walk to run" );
- blending.add( controls, "idle", 0, 1, 0.01).listen().onChange( controls.weight );
- blending.add( controls, "walk", 0, 1, 0.01).listen().onChange( controls.weight );
- blending.add( controls, "run", 0, 1, 0.01).listen().onChange( controls.weight );
+ blending.add( controls, "idle", 0, 1, 0.01 ).listen().onChange( controls.weight );
+ blending.add( controls, "walk", 0, 1, 0.01 ).listen().onChange( controls.weight );
+ blending.add( controls, "run", 0, 1, 0.01 ).listen().onChange( controls.weight );
settings.open();
playback.open();
@@ -86,18 +86,19 @@ function BlendCharacterGui(animations) {
anims: [ "idle", "walk", "run" ],
- weights: [ controls['idle'],
- controls['walk'],
- controls['run'] ]
+ weights: [ controls[ 'idle' ],
+ controls[ 'walk' ],
+ controls[ 'run' ] ]
controls.start = function() {
var startEvent = new CustomEvent( 'start-animation', getAnimationData() );
- window.dispatchEvent(startEvent);
+ window.dispatchEvent( startEvent );
@@ -117,21 +118,22 @@ function BlendCharacterGui(animations) {
controls.step = function() {
- var stepData = { detail: { stepSize: controls['Step Size'] } };
- window.dispatchEvent( new CustomEvent('step-animation', stepData ));
+ var stepData = { detail: { stepSize: controls[ 'Step Size' ] } };
+ window.dispatchEvent( new CustomEvent( 'step-animation', stepData ) );
controls.weight = function() {
// renormalize
- var sum = controls['idle'] + controls['walk'] + controls['run'];
- controls['idle'] /= sum;
- controls['walk'] /= sum;
- controls['run'] /= sum;
+ var sum = controls[ 'idle' ] + controls[ 'walk' ] + controls[ 'run' ];
+ controls[ 'idle' ] /= sum;
+ controls[ 'walk' ] /= sum;
+ controls[ 'run' ] /= sum;
var weightEvent = new CustomEvent( 'weight-animation', getAnimationData() );
- window.dispatchEvent(weightEvent);
+ window.dispatchEvent( weightEvent );
controls.crossfade = function( from, to ) {
@@ -142,6 +144,7 @@ function BlendCharacterGui(animations) {
fadeData.detail.time = controls[ "Crossfade Time" ];
window.dispatchEvent( new CustomEvent( 'crossfade', fadeData ) );
controls.warp = function( from, to ) {
@@ -152,21 +155,22 @@ function BlendCharacterGui(animations) {
warpData.detail.time = controls[ "Crossfade Time" ];
window.dispatchEvent( new CustomEvent( 'warp', warpData ) );
- controls['idle to walk'] = function() {
+ controls[ 'idle to walk' ] = function() {
controls.crossfade( 'idle', 'walk' );
- controls['walk to run'] = function() {
+ controls[ 'walk to run' ] = function() {
controls.crossfade( 'walk', 'run' );
- controls['warp walk to run'] = function() {
+ controls[ 'warp walk to run' ] = function() {
controls.warp( 'walk', 'run' );
@@ -176,11 +180,12 @@ function BlendCharacterGui(animations) {
var data = {
detail: {
- shouldShow: controls['Show Skeleton']
+ shouldShow: controls[ 'Show Skeleton' ]
window.dispatchEvent( new CustomEvent( 'toggle-show-skeleton', data ) );
@@ -188,14 +193,15 @@ function BlendCharacterGui(animations) {
- shouldShow: controls['Show Model']
+ shouldShow: controls[ 'Show Model' ]
window.dispatchEvent( new CustomEvent( 'toggle-show-model', data ) );
- init.call(this);
+ init.call( this );
@@ -27,7 +27,7 @@ THREE.Car = function () {
// car "feel" parameters
this.MAX_SPEED = 2200;
- this.MAX_REVERSE_SPEED = -1500;
+ this.MAX_REVERSE_SPEED = - 1500;
this.MAX_WHEEL_ROTATION = 0.6;
@@ -107,8 +107,16 @@ THREE.Car = function () {
var loader = new THREE.JSONLoader();
- loader.load( bodyURL, function( geometry, materials ) { createBody( geometry, materials ) } );
- loader.load( wheelURL, function( geometry, materials ) { createWheels( geometry, materials ) } );
+ loader.load( bodyURL, function( geometry, materials ) {
+ createBody( geometry, materials )
+ } );
+ loader.load( wheelURL, function( geometry, materials ) {
+ createWheels( geometry, materials )
@@ -116,8 +124,16 @@ THREE.Car = function () {
var loader = new THREE.BinaryLoader();
@@ -128,7 +144,7 @@ THREE.Car = function () {
if ( controls.moveForward ) {
this.speed = THREE.Math.clamp( this.speed + delta * this.FRONT_ACCELERATION, this.MAX_REVERSE_SPEED, this.MAX_SPEED );
- this.acceleration = THREE.Math.clamp( this.acceleration + delta, -1, 1 );
+ this.acceleration = THREE.Math.clamp( this.acceleration + delta, - 1, 1 );
@@ -136,7 +152,7 @@ THREE.Car = function () {
this.speed = THREE.Math.clamp( this.speed - delta * this.BACK_ACCELERATION, this.MAX_REVERSE_SPEED, this.MAX_SPEED );
- this.acceleration = THREE.Math.clamp( this.acceleration - delta, -1, 1 );
+ this.acceleration = THREE.Math.clamp( this.acceleration - delta, - 1, 1 );
@@ -168,7 +184,7 @@ THREE.Car = function () {
var k = exponentialEaseOut( this.speed / this.MAX_REVERSE_SPEED );
this.speed = THREE.Math.clamp( this.speed + k * delta * this.BACK_ACCELERATION, this.MAX_REVERSE_SPEED, 0 );
- this.acceleration = THREE.Math.clamp( this.acceleration + k * delta, -1, 0 );
+ this.acceleration = THREE.Math.clamp( this.acceleration + k * delta, - 1, 0 );
@@ -307,7 +323,7 @@ THREE.Car = function () {
// front right wheel
- delta.multiplyVectors( scope.wheelOffset, new THREE.Vector3( -s, s, s ) );
+ delta.multiplyVectors( scope.wheelOffset, new THREE.Vector3( - s, s, s ) );
scope.frontRightWheelRoot.position.add( delta );
@@ -321,7 +337,7 @@ THREE.Car = function () {
// back left wheel
- delta.multiplyVectors( scope.wheelOffset, new THREE.Vector3( s, s, -s ) );
+ delta.multiplyVectors( scope.wheelOffset, new THREE.Vector3( s, s, - s ) );
delta.z -= scope.backWheelOffset;
scope.backLeftWheelMesh = new THREE.Mesh( scope.wheelGeometry, wheelFaceMaterial );
@@ -333,7 +349,7 @@ THREE.Car = function () {
// back right wheel
- delta.multiplyVectors( scope.wheelOffset, new THREE.Vector3( -s, s, -s ) );
+ delta.multiplyVectors( scope.wheelOffset, new THREE.Vector3( - s, s, - s ) );
scope.backRightWheelMesh = new THREE.Mesh( scope.wheelGeometry, wheelFaceMaterial );
@@ -362,10 +378,30 @@ THREE.Car = function () {
- function quadraticEaseOut( k ) { return - k * ( k - 2 ); }
- function cubicEaseOut( k ) { return -- k * k * k + 1; }
- function circularEaseOut( k ) { return Math.sqrt( 1 - -- k * k ); }
- function sinusoidalEaseOut( k ) { return Math.sin( k * Math.PI / 2 ); }
- function exponentialEaseOut( k ) { return k === 1 ? 1 : - Math.pow( 2, - 10 * k ) + 1; }
+ function quadraticEaseOut( k ) {
+ return - k * ( k - 2 );
+ }
+ function cubicEaseOut( k ) {
+ return -- k * k * k + 1;
+ function circularEaseOut( k ) {
+ return Math.sqrt( 1 - -- k * k );
+ function sinusoidalEaseOut( k ) {
+ return Math.sin( k * Math.PI / 2 );
+ function exponentialEaseOut( k ) {
+ return k === 1 ? 1 : - Math.pow( 2, - 10 * k ) + 1;
@@ -19,12 +19,12 @@ var restDistance = 25;
var xSegs = 10; //
var ySegs = 10; //
-var clothFunction = plane(restDistance * xSegs, restDistance * ySegs);
+var clothFunction = plane( restDistance * xSegs, restDistance * ySegs );
-var cloth = new Cloth(xSegs, ySegs);
+var cloth = new Cloth( xSegs, ySegs );
var GRAVITY = 981 * 1.4; //
-var gravity = new THREE.Vector3( 0, -GRAVITY, 0 ).multiplyScalar(MASS);
+var gravity = new THREE.Vector3( 0, - GRAVITY, 0 ).multiplyScalar( MASS );
var TIMESTEP = 18 / 1000;
@@ -35,9 +35,9 @@ var pins = [];
var wind = true;
var windStrength = 2;
-var windForce = new THREE.Vector3(0,0,0);
+var windForce = new THREE.Vector3( 0, 0, 0 );
-var ballPosition = new THREE.Vector3(0, -45, 0);
+var ballPosition = new THREE.Vector3( 0, - 45, 0 );
var ballSize = 60; //40
var tmpForce = new THREE.Vector3();
@@ -45,64 +45,76 @@ var tmpForce = new THREE.Vector3();
var lastTime;
-function plane(width, height) {
+function plane( width, height ) {
- return function(u, v) {
- var x = (u - 0.5) * width;
- var y = (v + 0.5) * height;
+ return function( u, v ) {
+ var x = ( u - 0.5 ) * width;
+ var y = ( v + 0.5 ) * height;
var z = 0;
- return new THREE.Vector3(x, y, z);
+ return new THREE.Vector3( x, y, z );
-function Particle(x, y, z, mass) {
- this.position = clothFunction(x, y); // position
- this.previous = clothFunction(x, y); // previous
- this.original = clothFunction(x, y);
- this.a = new THREE.Vector3(0, 0, 0); // acceleration
+function Particle( x, y, z, mass ) {
+ this.position = clothFunction( x, y ); // position
+ this.previous = clothFunction( x, y ); // previous
+ this.original = clothFunction( x, y );
+ this.a = new THREE.Vector3( 0, 0, 0 ); // acceleration
this.mass = mass;
this.invMass = 1 / mass;
this.tmp = new THREE.Vector3();
this.tmp2 = new THREE.Vector3();
// Force -> Acceleration
-Particle.prototype.addForce = function(force) {
+Particle.prototype.addForce = function( force ) {
this.a.add(
- this.tmp2.copy(force).multiplyScalar(this.invMass)
+ this.tmp2.copy( force ).multiplyScalar( this.invMass )
// Performs verlet integration
-Particle.prototype.integrate = function(timesq) {
- var newPos = this.tmp.subVectors(this.position, this.previous);
- newPos.multiplyScalar(DRAG).add(this.position);
- newPos.add(this.a.multiplyScalar(timesq));
+Particle.prototype.integrate = function( timesq ) {
+ var newPos = this.tmp.subVectors( this.position, this.previous );
+ newPos.multiplyScalar( DRAG ).add( this.position );
+ newPos.add( this.a.multiplyScalar( timesq ) );
this.tmp = this.previous;
this.previous = this.position;
this.position = newPos;
- this.a.set(0, 0, 0);
+ this.a.set( 0, 0, 0 );
var diff = new THREE.Vector3();
-function satisifyConstrains(p1, p2, distance) {
- diff.subVectors(p2.position, p1.position);
+function satisifyConstrains( p1, p2, distance ) {
+ diff.subVectors( p2.position, p1.position );
var currentDist = diff.length();
- if (currentDist == 0) return; // prevents division by 0
- var correction = diff.multiplyScalar(1 - distance / currentDist);
- var correctionHalf = correction.multiplyScalar(0.5);
- p1.position.add(correctionHalf);
- p2.position.sub(correctionHalf);
+ if ( currentDist == 0 ) return; // prevents division by 0
+ var correction = diff.multiplyScalar( 1 - distance / currentDist );
+ var correctionHalf = correction.multiplyScalar( 0.5 );
+ p1.position.add( correctionHalf );
+ p2.position.sub( correctionHalf );
-function Cloth(w, h) {
+function Cloth( w, h ) {
w = w || 10;
h = h || 10;
this.w = w;
@@ -114,49 +126,59 @@ function Cloth(w, h) {
var u, v;
// Create particles
- for (v = 0; v <= h; v ++) {
- for (u = 0; u <= w; u ++) {
+ for ( v = 0; v <= h; v ++ ) {
+ for ( u = 0; u <= w; u ++ ) {
particles.push(
- new Particle(u / w, v / h, 0, MASS)
+ new Particle( u / w, v / h, 0, MASS )
// Structural
- for (v = 0; v < h; v ++) {
- for (u = 0; u < w; u ++) {
+ for ( v = 0; v < h; v ++ ) {
+ for ( u = 0; u < w; u ++ ) {
- constrains.push([
- particles[index(u, v)],
- particles[index(u, v + 1)],
+ constrains.push( [
+ particles[ index( u, v ) ],
+ particles[ index( u, v + 1 ) ],
restDistance
- ]);
+ ] );
- particles[index(u + 1, v)],
+ particles[ index( u + 1, v ) ],
- for (u = w, v = 0; v < h; v ++) {
+ for ( u = w, v = 0; v < h; v ++ ) {
- for (v = h, u = 0; u < w; u ++) {
+ for ( v = h, u = 0; u < w; u ++ ) {
@@ -189,91 +211,114 @@ function Cloth(w, h) {
this.particles = particles;
this.constrains = constrains;
- function index(u, v) {
- return u + v * (w + 1);
+ function index( u, v ) {
+ return u + v * ( w + 1 );
this.index = index;
-function simulate(time) {
- if (!lastTime) {
+function simulate( time ) {
+ if ( ! lastTime ) {
lastTime = time;
return;
var i, il, particles, particle, pt, constrains, constrain;
// Aerodynamics forces
- if (wind) {
+ if ( wind ) {
var face, faces = clothGeometry.faces, normal;
particles = cloth.particles;
- for (i = 0,il = faces.length; i < il; i ++) {
- face = faces[i];
+ for ( i = 0, il = faces.length; i < il; i ++ ) {
+ face = faces[ i ];
normal = face.normal;
- tmpForce.copy(normal).normalize().multiplyScalar(normal.dot(windForce));
- particles[face.a].addForce(tmpForce);
- particles[face.b].addForce(tmpForce);
- particles[face.c].addForce(tmpForce);
+ tmpForce.copy( normal ).normalize().multiplyScalar( normal.dot( windForce ) );
+ particles[ face.a ].addForce( tmpForce );
+ particles[ face.b ].addForce( tmpForce );
+ particles[ face.c ].addForce( tmpForce );
- for (particles = cloth.particles, i = 0, il = particles.length
- ; i < il; i ++) {
- particle = particles[i];
- particle.addForce(gravity);
+ for ( particles = cloth.particles, i = 0, il = particles.length
+ ; i < il; i ++ ) {
+ particle = particles[ i ];
+ particle.addForce( gravity );
+ particle.integrate( TIMESTEP_SQ );
- particle.integrate(TIMESTEP_SQ);
// Start Constrains
constrains = cloth.constrains,
il = constrains.length;
- for (i = 0; i < il; i ++) {
- constrain = constrains[i];
- satisifyConstrains(constrain[0], constrain[1], constrain[2]);
+ for ( i = 0; i < il; i ++ ) {
+ constrain = constrains[ i ];
+ satisifyConstrains( constrain[ 0 ], constrain[ 1 ], constrain[ 2 ] );
// Ball Constrains
- ballPosition.z = -Math.sin(Date.now() / 600) * 90 ; //+ 40;
- ballPosition.x = Math.cos(Date.now() / 400) * 70;
+ ballPosition.z = - Math.sin( Date.now() / 600 ) * 90 ; //+ 40;
+ ballPosition.x = Math.cos( Date.now() / 400 ) * 70;
+ if ( sphere.visible )
- if (sphere.visible)
pos = particle.position;
- diff.subVectors(pos, ballPosition);
- if (diff.length() < ballSize) {
+ diff.subVectors( pos, ballPosition );
+ if ( diff.length() < ballSize ) {
// collided
- diff.normalize().multiplyScalar(ballSize);
- pos.copy(ballPosition).add(diff);
+ diff.normalize().multiplyScalar( ballSize );
+ pos.copy( ballPosition ).add( diff );
// Floor Constains
- if (pos.y < -250) {
- pos.y = -250;
+ if ( pos.y < - 250 ) {
+ pos.y = - 250;
// Pin Constrains
- for (i = 0, il = pins.length; i < il; i ++) {
- var xy = pins[i];
- var p = particles[xy];
- p.position.copy(p.original);
- p.previous.copy(p.original);
+ for ( i = 0, il = pins.length; i < il; i ++ ) {
+ var xy = pins[ i ];
+ var p = particles[ xy ];
+ p.position.copy( p.original );
+ p.previous.copy( p.original );
@@ -17,32 +17,34 @@ THREE.Curves = {};
THREE.Curves.GrannyKnot = THREE.Curve.create( function() {},
- function(t) {
+ function( t ) {
t = 2 * Math.PI * t;
- var x = -0.22 * Math.cos(t) - 1.28 * Math.sin(t) - 0.44 * Math.cos(3 * t) - 0.78 * Math.sin(3 * t);
- var y = -0.1 * Math.cos(2 * t) - 0.27 * Math.sin(2 * t) + 0.38 * Math.cos(4 * t) + 0.46 * Math.sin(4 * t);
- var z = 0.7 * Math.cos(3 * t) - 0.4 * Math.sin(3 * t);
- return new THREE.Vector3(x, y, z).multiplyScalar(20);
+ var x = - 0.22 * Math.cos( t ) - 1.28 * Math.sin( t ) - 0.44 * Math.cos( 3 * t ) - 0.78 * Math.sin( 3 * t );
+ var y = - 0.1 * Math.cos( 2 * t ) - 0.27 * Math.sin( 2 * t ) + 0.38 * Math.cos( 4 * t ) + 0.46 * Math.sin( 4 * t );
+ var z = 0.7 * Math.cos( 3 * t ) - 0.4 * Math.sin( 3 * t );
+ return new THREE.Vector3( x, y, z ).multiplyScalar( 20 );
THREE.Curves.HeartCurve = THREE.Curve.create(
-function(s) {
+function( s ) {
- this.scale = (s === undefined) ? 5 : s;
+ this.scale = ( s === undefined ) ? 5 : s;
},
-function(t) {
+function( t ) {
t *= 2 * Math.PI;
- var tx = 16 * Math.pow(Math.sin(t), 3);
- var ty = 13 * Math.cos(t) - 5 * Math.cos(2 * t) - 2 * Math.cos(3 * t) - Math.cos(4 * t), tz = 0;
+ var tx = 16 * Math.pow( Math.sin( t ), 3 );
+ var ty = 13 * Math.cos( t ) - 5 * Math.cos( 2 * t ) - 2 * Math.cos( 3 * t ) - Math.cos( 4 * t ), tz = 0;
- return new THREE.Vector3(tx, ty, tz).multiplyScalar(this.scale);
+ return new THREE.Vector3( tx, ty, tz ).multiplyScalar( this.scale );
@@ -53,20 +55,21 @@ function(t) {
// Viviani's Curve
THREE.Curves.VivianiCurve = THREE.Curve.create(
- function(radius) {
+ function( radius ) {
this.radius = radius;
t = t * 4 * Math.PI; // Normalized to 0..1
var a = this.radius / 2;
- var tx = a * (1 + Math.cos(t)),
- ty = a * Math.sin(t),
- tz = 2 * a * Math.sin(t / 2);
+ var tx = a * ( 1 + Math.cos( t ) ),
+ ty = a * Math.sin( t ),
+ tz = 2 * a * Math.sin( t / 2 );
- return new THREE.Vector3(tx, ty, tz);
+ return new THREE.Vector3( tx, ty, tz );
@@ -79,17 +82,17 @@ THREE.Curves.KnotCurve = THREE.Curve.create(
var R = 10;
var s = 50;
- var tx = s * Math.sin(t),
- ty = Math.cos(t) * (R + s * Math.cos(t)),
- tz = Math.sin(t) * (R + s * Math.cos(t));
+ var tx = s * Math.sin( t ),
+ ty = Math.cos( t ) * ( R + s * Math.cos( t ) ),
+ tz = Math.sin( t ) * ( R + s * Math.cos( t ) );
@@ -101,16 +104,16 @@ THREE.Curves.HelixCurve = THREE.Curve.create(
var a = 30; // radius
var b = 150; //height
var t2 = 2 * Math.PI * t * b / 30;
- var tx = Math.cos(t2) * a,
- ty = Math.sin(t2) * a,
+ var tx = Math.cos( t2 ) * a,
+ ty = Math.sin( t2 ) * a,
tz = b * t;
@@ -118,20 +121,20 @@ THREE.Curves.HelixCurve = THREE.Curve.create(
THREE.Curves.TrefoilKnot = THREE.Curve.create(
- function(s) {
+ function( s ) {
- this.scale = (s === undefined) ? 10 : s;
+ this.scale = ( s === undefined ) ? 10 : s;
t *= Math.PI * 2;
- var tx = (2 + Math.cos(3 * t)) * Math.cos(2 * t),
- ty = (2 + Math.cos(3 * t)) * Math.sin(2 * t),
- tz = Math.sin(3 * t);
+ var tx = ( 2 + Math.cos( 3 * t ) ) * Math.cos( 2 * t ),
+ ty = ( 2 + Math.cos( 3 * t ) ) * Math.sin( 2 * t ),
+ tz = Math.sin( 3 * t );
@@ -139,22 +142,22 @@ THREE.Curves.TrefoilKnot = THREE.Curve.create(
THREE.Curves.TorusKnot = THREE.Curve.create(
var p = 3,
q = 4;
- var tx = (2 + Math.cos(q * t)) * Math.cos(p * t),
- ty = (2 + Math.cos(q * t)) * Math.sin(p * t),
- tz = Math.sin(q * t);
+ var tx = ( 2 + Math.cos( q * t ) ) * Math.cos( p * t ),
+ ty = ( 2 + Math.cos( q * t ) ) * Math.sin( p * t ),
+ tz = Math.sin( q * t );
@@ -163,22 +166,22 @@ THREE.Curves.TorusKnot = THREE.Curve.create(
THREE.Curves.CinquefoilKnot = THREE.Curve.create(
var p = 2,
q = 5;
@@ -187,20 +190,20 @@ THREE.Curves.CinquefoilKnot = THREE.Curve.create(
THREE.Curves.TrefoilPolynomialKnot = THREE.Curve.create(
t = t * 4 - 2;
- var tx = Math.pow(t, 3) - 3 * t,
- ty = Math.pow(t, 4) - 4 * t * t,
- tz = 1 / 5 * Math.pow(t, 5) - 2 * t;
+ var tx = Math.pow( t, 3 ) - 3 * t,
+ ty = Math.pow( t, 4 ) - 4 * t * t,
+ tz = 1 / 5 * Math.pow( t, 5 ) - 2 * t;
@@ -212,7 +215,7 @@ THREE.Curves.TrefoilPolynomialKnot = THREE.Curve.create(
// t * r + x;
// };
// }
-var scaleTo = function(x, y, t) {
+var scaleTo = function( x, y, t ) {
var r = y - x;
return t * r + x;
@@ -221,20 +224,20 @@ var scaleTo = function(x, y, t) {
THREE.Curves.FigureEightPolynomialKnot = THREE.Curve.create(
- this.scale = (s === undefined) ? 1 : s;
+ this.scale = ( s === undefined ) ? 1 : s;
- t = scaleTo(-4, 4, t);
- var tx = 2 / 5 * t * (t * t - 7) * (t * t - 10),
- ty = Math.pow(t, 4) - 13 * t * t,
- tz = 1 / 10 * t * (t * t - 4) * (t * t - 9) * (t * t - 12);
+ t = scaleTo( - 4, 4, t );
+ var tx = 2 / 5 * t * ( t * t - 7 ) * ( t * t - 10 ),
+ ty = Math.pow( t, 4 ) - 13 * t * t,
+ tz = 1 / 10 * t * ( t * t - 4 ) * ( t * t - 9 ) * ( t * t - 12 );
@@ -242,21 +245,21 @@ THREE.Curves.FigureEightPolynomialKnot = THREE.Curve.create(
THREE.Curves.DecoratedTorusKnot4a = THREE.Curve.create(
- this.scale = (s === undefined) ? 40 : s;
+ this.scale = ( s === undefined ) ? 40 : s;
var
- x = Math.cos(2 * t) * (1 + 0.6 * (Math.cos(5 * t) + 0.75 * Math.cos(10 * t))),
- y = Math.sin(2 * t) * (1 + 0.6 * (Math.cos(5 * t) + 0.75 * Math.cos(10 * t))),
- z = 0.35 * Math.sin(5 * t);
+ x = Math.cos( 2 * t ) * ( 1 + 0.6 * ( Math.cos( 5 * t ) + 0.75 * Math.cos( 10 * t ) ) ),
+ y = Math.sin( 2 * t ) * ( 1 + 0.6 * ( Math.cos( 5 * t ) + 0.75 * Math.cos( 10 * t ) ) ),
+ z = 0.35 * Math.sin( 5 * t );
- return new THREE.Vector3(x, y, z).multiplyScalar(this.scale);
+ return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
@@ -265,19 +268,20 @@ THREE.Curves.DecoratedTorusKnot4a = THREE.Curve.create(
THREE.Curves.DecoratedTorusKnot4b = THREE.Curve.create(
var fi = t * Math.PI * 2;
- var x = Math.cos(2 * fi) * (1 + 0.45 * Math.cos(3 * fi) + 0.4 * Math.cos(9 * fi)),
- y = Math.sin(2 * fi) * (1 + 0.45 * Math.cos(3 * fi) + 0.4 * Math.cos(9 * fi)),
- z = 0.2 * Math.sin(9 * fi);
+ var x = Math.cos( 2 * fi ) * ( 1 + 0.45 * Math.cos( 3 * fi ) + 0.4 * Math.cos( 9 * fi ) ),
+ y = Math.sin( 2 * fi ) * ( 1 + 0.45 * Math.cos( 3 * fi ) + 0.4 * Math.cos( 9 * fi ) ),
+ z = 0.2 * Math.sin( 9 * fi );
@@ -286,20 +290,20 @@ THREE.Curves.DecoratedTorusKnot4b = THREE.Curve.create(
THREE.Curves.DecoratedTorusKnot5a = THREE.Curve.create(
- var x = Math.cos(3 * fi) * (1 + 0.3 * Math.cos(5 * fi) + 0.5 * Math.cos(10 * fi)),
- y = Math.sin(3 * fi) * (1 + 0.3 * Math.cos(5 * fi) + 0.5 * Math.cos(10 * fi)),
- z = 0.2 * Math.sin(20 * fi);
+ var x = Math.cos( 3 * fi ) * ( 1 + 0.3 * Math.cos( 5 * fi ) + 0.5 * Math.cos( 10 * fi ) ),
+ y = Math.sin( 3 * fi ) * ( 1 + 0.3 * Math.cos( 5 * fi ) + 0.5 * Math.cos( 10 * fi ) ),
+ z = 0.2 * Math.sin( 20 * fi );
@@ -307,21 +311,21 @@ THREE.Curves.DecoratedTorusKnot5a = THREE.Curve.create(
THREE.Curves.DecoratedTorusKnot5c = THREE.Curve.create(
- var x = Math.cos(4 * fi) * (1 + 0.5 * (Math.cos(5 * fi) + 0.4 * Math.cos(20 * fi))),
- y = Math.sin(4 * fi) * (1 + 0.5 * (Math.cos(5 * fi) + 0.4 * Math.cos(20 * fi))),
- z = 0.35 * Math.sin(15 * fi);
+ var x = Math.cos( 4 * fi ) * ( 1 + 0.5 * ( Math.cos( 5 * fi ) + 0.4 * Math.cos( 20 * fi ) ) ),
+ y = Math.sin( 4 * fi ) * ( 1 + 0.5 * ( Math.cos( 5 * fi ) + 0.4 * Math.cos( 20 * fi ) ) ),
+ z = 0.35 * Math.sin( 15 * fi );
-);
+);
@@ -6,7 +6,19 @@
var Detector = {
canvas: !! window.CanvasRenderingContext2D,
- webgl: ( function () { try { var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) ); } catch ( e ) { return false; } } )(),
+ webgl: ( function () {
+ try {
+ var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
+ } catch ( e ) {
+ return false;
+ } )(),
workers: !! window.Worker,
fileapi: window.File && window.FileReader && window.FileList && window.Blob,
@@ -209,7 +209,7 @@ THREE.MD2Character = function () {
//
var mesh = new THREE.MorphAnimMesh( geometry, materialTexture );
- mesh.rotation.y = -Math.PI / 2;
+ mesh.rotation.y = - Math.PI / 2;
mesh.castShadow = true;
mesh.receiveShadow = true;
@@ -16,7 +16,7 @@ THREE.MD2CharacterComplex = function () {
// movement model parameters
this.maxSpeed = 275;
- this.maxReverseSpeed = -275;
+ this.maxReverseSpeed = - 275;
this.frontAcceleration = 600;
this.backAcceleration = 600;
@@ -261,7 +261,7 @@ THREE.MD2CharacterComplex = function () {
this.setAnimation = function ( animationName ) {
- if ( animationName === this.activeAnimation || !animationName ) return;
+ if ( animationName === this.activeAnimation || ! animationName ) return;
if ( this.meshBody ) {
@@ -388,7 +388,7 @@ THREE.MD2CharacterComplex = function () {
- if ( Math.abs( this.speed ) < 0.2 * this.maxSpeed && !( controls.moveLeft || controls.moveRight || controls.moveForward || controls.moveBackward ) ) {
+ if ( Math.abs( this.speed ) < 0.2 * this.maxSpeed && ! ( controls.moveLeft || controls.moveRight || controls.moveForward || controls.moveBackward ) ) {
if ( this.activeAnimation !== idleAnimation ) {
@@ -447,7 +447,7 @@ THREE.MD2CharacterComplex = function () {
if ( controls.crouch ) this.maxSpeed = this.crouchSpeed;
else this.maxSpeed = this.walkSpeed;
- this.maxReverseSpeed = -this.maxSpeed;
+ this.maxReverseSpeed = - this.maxSpeed;
if ( controls.moveForward ) this.speed = THREE.Math.clamp( this.speed + delta * this.frontAcceleration, this.maxReverseSpeed, this.maxSpeed );
if ( controls.moveBackward ) this.speed = THREE.Math.clamp( this.speed - delta * this.backAcceleration, this.maxReverseSpeed, this.maxSpeed );
@@ -532,7 +532,7 @@ THREE.MD2CharacterComplex = function () {
var mesh = new THREE.MorphBlendMesh( geometry, materialTexture );
@@ -554,6 +554,10 @@ THREE.MD2CharacterComplex = function () {
@@ -80,7 +80,11 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )
// Polygonization
///////////////////////
- this.lerp = function( a, b, t ) { return a + ( b - a ) * t; };
+ this.lerp = function( a, b, t ) {
+ return a + ( b - a ) * t;
+ };
this.VIntX = function( q, pout, nout, offset, isol, x, y, z, valp1, valp2 ) {
@@ -137,7 +141,7 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )
if ( this.normal_cache[ q3 ] === 0.0 ) {
- this.normal_cache[ q3 ] = this.field[ q - 1 ] - this.field[ q + 1 ];
+ this.normal_cache[ q3 ] = this.field[ q - 1 ] - this.field[ q + 1 ];
this.normal_cache[ q3 + 1 ] = this.field[ q - this.yd ] - this.field[ q + this.yd ];
this.normal_cache[ q3 + 2 ] = this.field[ q - this.zd ] - this.field[ q + this.zd ];
@@ -296,7 +300,7 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors )
// here is where triangles are created
- while ( THREE.triTable[ cubeindex + i ] != -1 ) {
+ while ( THREE.triTable[ cubeindex + i ] != - 1 ) {
o1 = cubeindex + i;
o2 = o1 + 1;
@@ -762,7 +766,7 @@ THREE.MarchingCubes.prototype.constructor = THREE.MarchingCubes;
// http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/
// who in turn got them from Cory Gene Bloyd.
-THREE.edgeTable = new Int32Array([
+THREE.edgeTable = new Int32Array( [
0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
@@ -794,262 +798,262 @@ THREE.edgeTable = new Int32Array([
0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,
0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
-0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 ]);
-
-THREE.triTable = new Int32Array([
--1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,
-3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,
-3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,
-3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,
-9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,
-1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,
-9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,
-2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,
-8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,
-9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,
-4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,
-3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,
-1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,
-4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,
-4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,
-9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,
-1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,
-5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,
-2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,
-9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,
-0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,
-2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,
-10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,
-4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,
-5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,
-5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,
-9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,
-0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,
-1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,
-10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,
-8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,
-2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,
-7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,
-9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,
-2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,
-11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,
-9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,
-5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,
-11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,
-11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,
-1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,
-9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,
-5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,
-2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,
-0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,
-5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,
-6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,
-0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,
-3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,
-6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,
-5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,
-1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,
-10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,
-6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,
-1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,
-8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,
-7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,
-3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,
-5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,
-0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,
-9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,
-8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,
-5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,
-0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,
-6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,
-10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,
-10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,
-8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,
-1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,
-3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,
-0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,
-10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,
-0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,
-3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,
-6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,
-9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,
-8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,
-3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,
-6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,
-0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,
-10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,
-10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,
-1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,
-2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,
-7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,
-7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,
-2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,
-1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,
-11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,
-8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,
-0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,
-7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,
-10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,
-2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,
-6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,
-7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,
-2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,
-1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,
-10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,
-10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,
-0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,
-7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,
-6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,
-8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,
-9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,
-6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,
-1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,
-4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,
-10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,
-8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,
-0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,
-1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,
-8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,
-10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,
-4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,
-10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,
-5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,
-11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,
-9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,
-6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,
-7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,
-3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,
-7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,
-9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,
-3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,
-6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,
-9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,
-1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,
-4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,
-7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,
-6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,
-3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,
-0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,
-6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,
-1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,
-0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,
-11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,
-6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,
-5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,
-9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,
-1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,
-1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,
-10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,
-0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,
-5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,
-10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,
-11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,
-0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,
-9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,
-7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,
-2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,
-8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,
-9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,
-9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,
-1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,
-9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,
-9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,
-5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,
-0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,
-10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,
-2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,
-0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,
-0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,
-9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,
-5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,
-3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,
-5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,
-8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,
-0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,
-9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,
-0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,
-1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,
-3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,
-4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,
-9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,
-11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,
-11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,
-2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,
-9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,
-3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,
-1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,
-4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,
-4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,
-0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,
-3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,
-3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,
-0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,
-9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,
-1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
--1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ]);
+0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 ] );
+THREE.triTable = new Int32Array( [
+- 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 8, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 1, 9, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 8, 3, 9, 8, 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 2, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 8, 3, 1, 2, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 2, 10, 0, 2, 9, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+2, 8, 3, 2, 10, 8, 10, 9, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 11, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 11, 2, 8, 11, 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 9, 0, 2, 3, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 11, 2, 1, 9, 11, 9, 8, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 10, 1, 11, 10, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 10, 1, 0, 8, 10, 8, 11, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 9, 0, 3, 11, 9, 11, 10, 9, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 8, 10, 10, 8, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 7, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 3, 0, 7, 3, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 1, 9, 8, 4, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 1, 9, 4, 7, 1, 7, 3, 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 2, 10, 8, 4, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 4, 7, 3, 0, 4, 1, 2, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 2, 10, 9, 0, 2, 8, 4, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, - 1, - 1, - 1, - 1,
+8, 4, 7, 3, 11, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+11, 4, 7, 11, 2, 4, 2, 0, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 0, 1, 8, 4, 7, 2, 3, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, - 1, - 1, - 1, - 1,
+3, 10, 1, 3, 11, 10, 7, 8, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, - 1, - 1, - 1, - 1,
+4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, - 1, - 1, - 1, - 1,
+4, 7, 11, 4, 11, 9, 9, 11, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 5, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 5, 4, 0, 8, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 5, 4, 1, 5, 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+8, 5, 4, 8, 3, 5, 3, 1, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 2, 10, 9, 5, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 0, 8, 1, 2, 10, 4, 9, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+5, 2, 10, 5, 4, 2, 4, 0, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, - 1, - 1, - 1, - 1,
+9, 5, 4, 2, 3, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 11, 2, 0, 8, 11, 4, 9, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 5, 4, 0, 1, 5, 2, 3, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, - 1, - 1, - 1, - 1,
+10, 3, 11, 10, 1, 3, 9, 5, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, - 1, - 1, - 1, - 1,
+5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, - 1, - 1, - 1, - 1,
+5, 4, 8, 5, 8, 10, 10, 8, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 7, 8, 5, 7, 9, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 3, 0, 9, 5, 3, 5, 7, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 7, 8, 0, 1, 7, 1, 5, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 5, 3, 3, 5, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 7, 8, 9, 5, 7, 10, 1, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, - 1, - 1, - 1, - 1,
+8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, - 1, - 1, - 1, - 1,
+2, 10, 5, 2, 5, 3, 3, 5, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+7, 9, 5, 7, 8, 9, 3, 11, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, - 1, - 1, - 1, - 1,
+2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, - 1, - 1, - 1, - 1,
+11, 2, 1, 11, 1, 7, 7, 1, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, - 1, - 1, - 1, - 1,
+5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, - 1,
+11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, - 1,
+11, 10, 5, 7, 11, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+10, 6, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 8, 3, 5, 10, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 0, 1, 5, 10, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 8, 3, 1, 9, 8, 5, 10, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 6, 5, 2, 6, 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 6, 5, 1, 2, 6, 3, 0, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 6, 5, 9, 0, 6, 0, 2, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, - 1, - 1, - 1, - 1,
+2, 3, 11, 10, 6, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+11, 0, 8, 11, 2, 0, 10, 6, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 1, 9, 2, 3, 11, 5, 10, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, - 1, - 1, - 1, - 1,
+6, 3, 11, 6, 5, 3, 5, 1, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, - 1, - 1, - 1, - 1,
+3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, - 1, - 1, - 1, - 1,
+6, 5, 9, 6, 9, 11, 11, 9, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+5, 10, 6, 4, 7, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 3, 0, 4, 7, 3, 6, 5, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 9, 0, 5, 10, 6, 8, 4, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, - 1, - 1, - 1, - 1,
+6, 1, 2, 6, 5, 1, 4, 7, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, - 1, - 1, - 1, - 1,
+8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, - 1, - 1, - 1, - 1,
+7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, - 1,
+3, 11, 2, 7, 8, 4, 10, 6, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, - 1, - 1, - 1, - 1,
+0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, - 1, - 1, - 1, - 1,
+9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, - 1,
+8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, - 1, - 1, - 1, - 1,
+5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, - 1,
+0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, - 1,
+6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, - 1, - 1, - 1, - 1,
+10, 4, 9, 6, 4, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 10, 6, 4, 9, 10, 0, 8, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+10, 0, 1, 10, 6, 0, 6, 4, 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, - 1, - 1, - 1, - 1,
+1, 4, 9, 1, 2, 4, 2, 6, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, - 1, - 1, - 1, - 1,
+0, 2, 4, 4, 2, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+8, 3, 2, 8, 2, 4, 4, 2, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+10, 4, 9, 10, 6, 4, 11, 2, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, - 1, - 1, - 1, - 1,
+3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, - 1, - 1, - 1, - 1,
+6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, - 1,
+9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, - 1, - 1, - 1, - 1,
+8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, - 1,
+3, 11, 6, 3, 6, 0, 0, 6, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+6, 4, 8, 11, 6, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+7, 10, 6, 7, 8, 10, 8, 9, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, - 1, - 1, - 1, - 1,
+10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, - 1, - 1, - 1, - 1,
+10, 6, 7, 10, 7, 1, 1, 7, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, - 1, - 1, - 1, - 1,
+2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, - 1,
+7, 8, 0, 7, 0, 6, 6, 0, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+7, 3, 2, 6, 7, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, - 1, - 1, - 1, - 1,
+2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, - 1,
+1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, - 1,
+11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, - 1, - 1, - 1, - 1,
+8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, - 1,
+0, 9, 1, 11, 6, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, - 1, - 1, - 1, - 1,
+7, 11, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+7, 6, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 0, 8, 11, 7, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 1, 9, 11, 7, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+8, 1, 9, 8, 3, 1, 11, 7, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+10, 1, 2, 6, 11, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 2, 10, 3, 0, 8, 6, 11, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+2, 9, 0, 2, 10, 9, 6, 11, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, - 1, - 1, - 1, - 1,
+7, 2, 3, 6, 2, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+7, 0, 8, 7, 6, 0, 6, 2, 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+2, 7, 6, 2, 3, 7, 0, 1, 9, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, - 1, - 1, - 1, - 1,
+10, 7, 6, 10, 1, 7, 1, 3, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, - 1, - 1, - 1, - 1,
+0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, - 1, - 1, - 1, - 1,
+7, 6, 10, 7, 10, 8, 8, 10, 9, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+6, 8, 4, 11, 8, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 6, 11, 3, 0, 6, 0, 4, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+8, 6, 11, 8, 4, 6, 9, 0, 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, - 1, - 1, - 1, - 1,
+6, 8, 4, 6, 11, 8, 2, 10, 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, - 1, - 1, - 1, - 1,
+4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, - 1, - 1, - 1, - 1,
+10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, - 1,
+8, 2, 3, 8, 4, 2, 4, 6, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 4, 2, 4, 6, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, - 1, - 1, - 1, - 1,
+1, 9, 4, 1, 4, 2, 2, 4, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, - 1, - 1, - 1, - 1,
+10, 1, 0, 10, 0, 6, 6, 0, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, - 1,
+10, 9, 4, 6, 10, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 9, 5, 7, 6, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 8, 3, 4, 9, 5, 11, 7, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+5, 0, 1, 5, 4, 0, 7, 6, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, - 1, - 1, - 1, - 1,
+9, 5, 4, 10, 1, 2, 7, 6, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, - 1, - 1, - 1, - 1,
+7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, - 1, - 1, - 1, - 1,
+3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, - 1,
+7, 2, 3, 7, 6, 2, 5, 4, 9, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, - 1, - 1, - 1, - 1,
+3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, - 1, - 1, - 1, - 1,
+6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, - 1,
+9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, - 1, - 1, - 1, - 1,
+1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, - 1,
+4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, - 1,
+7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, - 1, - 1, - 1, - 1,
+6, 9, 5, 6, 11, 9, 11, 8, 9, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, - 1, - 1, - 1, - 1,
+0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, - 1, - 1, - 1, - 1,
+6, 11, 3, 6, 3, 5, 5, 3, 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, - 1, - 1, - 1, - 1,
+0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, - 1,
+11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, - 1,
+6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, - 1, - 1, - 1, - 1,
+5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, - 1, - 1, - 1, - 1,
+9, 5, 6, 9, 6, 0, 0, 6, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, - 1,
+1, 5, 6, 2, 1, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, - 1,
+10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, - 1, - 1, - 1, - 1,
+0, 3, 8, 5, 6, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+10, 5, 6, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+11, 5, 10, 7, 5, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+11, 5, 10, 11, 7, 5, 8, 3, 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+5, 11, 7, 5, 10, 11, 1, 9, 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, - 1, - 1, - 1, - 1,
+11, 1, 2, 11, 7, 1, 7, 5, 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, - 1, - 1, - 1, - 1,
+9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, - 1, - 1, - 1, - 1,
+7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, - 1,
+2, 5, 10, 2, 3, 5, 3, 7, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, - 1, - 1, - 1, - 1,
+9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, - 1, - 1, - 1, - 1,
+9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, - 1,
+1, 3, 5, 3, 7, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 8, 7, 0, 7, 1, 1, 7, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 0, 3, 9, 3, 5, 5, 3, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 8, 7, 5, 9, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+5, 8, 4, 5, 10, 8, 10, 11, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, - 1, - 1, - 1, - 1,
+0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, - 1, - 1, - 1, - 1,
+10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, - 1,
+2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, - 1, - 1, - 1, - 1,
+0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, - 1,
+0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, - 1,
+9, 4, 5, 2, 11, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, - 1, - 1, - 1, - 1,
+5, 10, 2, 5, 2, 4, 4, 2, 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, - 1,
+5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, - 1, - 1, - 1, - 1,
+8, 4, 5, 8, 5, 3, 3, 5, 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 4, 5, 1, 0, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, - 1, - 1, - 1, - 1,
+9, 4, 5, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 11, 7, 4, 9, 11, 9, 10, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, - 1, - 1, - 1, - 1,
+1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, - 1, - 1, - 1, - 1,
+3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, - 1,
+4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, - 1, - 1, - 1, - 1,
+9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, - 1,
+11, 7, 4, 11, 4, 2, 2, 4, 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, - 1, - 1, - 1, - 1,
+2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, - 1, - 1, - 1, - 1,
+9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, - 1,
+3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, - 1,
+1, 10, 2, 8, 7, 4, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 9, 1, 4, 1, 7, 7, 1, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, - 1, - 1, - 1, - 1,
+4, 0, 3, 7, 4, 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+4, 8, 7, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 10, 8, 10, 11, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 0, 9, 3, 9, 11, 11, 9, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 1, 10, 0, 10, 8, 8, 10, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 1, 10, 11, 3, 10, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 2, 11, 1, 11, 9, 9, 11, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, - 1, - 1, - 1, - 1,
+0, 2, 11, 8, 0, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+3, 2, 11, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+2, 3, 8, 2, 8, 10, 10, 8, 9, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+9, 10, 2, 0, 9, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, - 1, - 1, - 1, - 1,
+1, 10, 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+1, 3, 8, 9, 1, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 9, 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+0, 3, 8, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1,
+- 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1 ] );
@@ -2,9 +2,9 @@
* @author Slayvin / http://slayvin.net
-THREE.ShaderLib['mirror'] = {
+THREE.ShaderLib[ 'mirror' ] = {
- uniforms: { "mirrorColor": { type: "c", value: new THREE.Color(0x7F7F7F) },
+ uniforms: { "mirrorColor": { type: "c", value: new THREE.Color( 0x7F7F7F ) },
"mirrorSampler": { type: "t", value: null },
"textureMatrix" : { type: "m4", value: new THREE.Matrix4() }
@@ -25,7 +25,7 @@ THREE.ShaderLib['mirror'] = {
"}"
- ].join("\n"),
+ ].join( "\n" ),
fragmentShader: [
@@ -47,7 +47,7 @@ THREE.ShaderLib['mirror'] = {
- ].join("\n")
+ ].join( "\n" )
@@ -66,7 +66,7 @@ THREE.Mirror = function ( renderer, camera, options ) {
this.clipBias = options.clipBias !== undefined ? options.clipBias : 0.0;
- var mirrorColor = options.color !== undefined ? new THREE.Color(options.color) : new THREE.Color(0x7F7F7F);
+ var mirrorColor = options.color !== undefined ? new THREE.Color( options.color ) : new THREE.Color( 0x7F7F7F );
this.renderer = renderer;
this.mirrorPlane = new THREE.Plane();
@@ -74,7 +74,7 @@ THREE.Mirror = function ( renderer, camera, options ) {
this.mirrorWorldPosition = new THREE.Vector3();
this.cameraWorldPosition = new THREE.Vector3();
this.rotationMatrix = new THREE.Matrix4();
- this.lookAtPosition = new THREE.Vector3(0, 0, -1);
+ this.lookAtPosition = new THREE.Vector3( 0, 0, - 1 );
this.clipPlane = new THREE.Vector4();
// For debug only, show the normal and plane of the mirror
@@ -82,17 +82,17 @@ THREE.Mirror = function ( renderer, camera, options ) {
if ( debugMode ) {
- var arrow = new THREE.ArrowHelper(new THREE.Vector3( 0, 0, 1 ), new THREE.Vector3( 0, 0, 0 ), 10, 0xffff80 );
+ var arrow = new THREE.ArrowHelper( new THREE.Vector3( 0, 0, 1 ), new THREE.Vector3( 0, 0, 0 ), 10, 0xffff80 );
var planeGeometry = new THREE.Geometry();
- planeGeometry.vertices.push( new THREE.Vector3( -10, -10, 0 ) );
- planeGeometry.vertices.push( new THREE.Vector3( 10, -10, 0 ) );
+ planeGeometry.vertices.push( new THREE.Vector3( - 10, - 10, 0 ) );
+ planeGeometry.vertices.push( new THREE.Vector3( 10, - 10, 0 ) );
planeGeometry.vertices.push( new THREE.Vector3( 10, 10, 0 ) );
- planeGeometry.vertices.push( new THREE.Vector3( -10, 10, 0 ) );
- planeGeometry.vertices.push( planeGeometry.vertices[0] );
+ planeGeometry.vertices.push( new THREE.Vector3( - 10, 10, 0 ) );
+ planeGeometry.vertices.push( planeGeometry.vertices[ 0 ] );
var plane = new THREE.Line( planeGeometry, new THREE.LineBasicMaterial( { color: 0xffff80 } ) );
- this.add(arrow);
- this.add(plane);
+ this.add( arrow );
+ this.add( plane );
@@ -132,7 +132,7 @@ THREE.Mirror = function ( renderer, camera, options ) {
this.material.uniforms.mirrorColor.value = mirrorColor;
this.material.uniforms.textureMatrix.value = this.textureMatrix;
- if ( !THREE.Math.isPowerOfTwo(width) || !THREE.Math.isPowerOfTwo( height ) ) {
+ if ( ! THREE.Math.isPowerOfTwo( width ) || ! THREE.Math.isPowerOfTwo( height ) ) {
this.texture.generateMipmaps = false;
this.tempTexture.generateMipmaps = false;
@@ -171,6 +171,7 @@ THREE.Mirror.prototype.renderWithMirror = function ( otherMirror ) {
// restore texture matrix of other mirror
otherMirror.updateTextureMatrix();
THREE.Mirror.prototype.updateTextureMatrix = function () {
@@ -192,7 +193,7 @@ THREE.Mirror.prototype.updateTextureMatrix = function () {
this.rotationMatrix.extractRotation( this.camera.matrixWorld );
- this.lookAtPosition.set(0, 0, -1);
+ this.lookAtPosition.set( 0, 0, - 1 );
this.lookAtPosition.applyMatrix4( this.rotationMatrix );
this.lookAtPosition.add( this.cameraWorldPosition );
@@ -200,7 +201,7 @@ THREE.Mirror.prototype.updateTextureMatrix = function () {
target.reflect( this.normal ).negate();
target.add( this.mirrorWorldPosition );
- this.up.set( 0, -1, 0 );
+ this.up.set( 0, - 1, 0 );
this.up.applyMatrix4( this.rotationMatrix );
this.up.reflect( this.normal ).negate();
@@ -230,20 +231,20 @@ THREE.Mirror.prototype.updateTextureMatrix = function () {
var q = new THREE.Vector4();
var projectionMatrix = this.mirrorCamera.projectionMatrix;
- q.x = ( Math.sign(this.clipPlane.x) + projectionMatrix.elements[8] ) / projectionMatrix.elements[0];
- q.y = ( Math.sign(this.clipPlane.y) + projectionMatrix.elements[9] ) / projectionMatrix.elements[5];
+ q.x = ( Math.sign( this.clipPlane.x ) + projectionMatrix.elements[ 8 ] ) / projectionMatrix.elements[ 0 ];
+ q.y = ( Math.sign( this.clipPlane.y ) + projectionMatrix.elements[ 9 ] ) / projectionMatrix.elements[ 5 ];
q.z = - 1.0;
- q.w = ( 1.0 + projectionMatrix.elements[10] ) / projectionMatrix.elements[14];
+ q.w = ( 1.0 + projectionMatrix.elements[ 10 ] ) / projectionMatrix.elements[ 14 ];
// Calculate the scaled plane vector
var c = new THREE.Vector4();
- c = this.clipPlane.multiplyScalar( 2.0 / this.clipPlane.dot(q) );
+ c = this.clipPlane.multiplyScalar( 2.0 / this.clipPlane.dot( q ) );
// Replacing the third row of the projection matrix
- projectionMatrix.elements[2] = c.x;
- projectionMatrix.elements[6] = c.y;
- projectionMatrix.elements[10] = c.z + 1.0 - this.clipBias;
- projectionMatrix.elements[14] = c.w;
+ projectionMatrix.elements[ 2 ] = c.x;
+ projectionMatrix.elements[ 6 ] = c.y;
+ projectionMatrix.elements[ 10 ] = c.z + 1.0 - this.clipBias;
+ projectionMatrix.elements[ 14 ] = c.w;
@@ -262,7 +263,7 @@ THREE.Mirror.prototype.render = function () {
- if ( scene !== undefined && scene instanceof THREE.Scene) {
+ if ( scene !== undefined && scene instanceof THREE.Scene ) {
// We can't render ourself to ourself
var visible = this.material.visible;
@@ -291,7 +292,7 @@ THREE.Mirror.prototype.renderTemp = function () {
this.renderer.render( scene, this.mirrorCamera, this.tempTexture, true );
@@ -1,4 +1,5 @@
-THREE.Ocean = function (renderer, camera, scene, options) {
+THREE.Ocean = function ( renderer, camera, scene, options ) {
// flag used to trigger parameter changes
this.changed = true;
this.initial = true;
@@ -12,36 +13,38 @@
this.scene = new THREE.Scene();
// Enable necessary extensions
- this.renderer.context.getExtension('OES_texture_float');
- this.renderer.context.getExtension('OES_texture_float_linear');
+ this.renderer.context.getExtension( 'OES_texture_float' );
+ this.renderer.context.getExtension( 'OES_texture_float_linear' );
// Assign optional parameters as variables and object properties
- function optionalParameter(value, defaultValue) {
+ function optionalParameter( value, defaultValue ) {
return value !== undefined ? value : defaultValue;
options = options || {};
- this.clearColor = optionalParameter(options.CLEAR_COLOR, [ 1.0, 1.0, 1.0, 0.0 ]);
- this.geometryOrigin = optionalParameter(options.GEOMETRY_ORIGIN, [ -1000.0, -1000.0 ]);
- this.sunDirectionX = optionalParameter(options.SUN_DIRECTION[0], -1.0);
- this.sunDirectionY = optionalParameter(options.SUN_DIRECTION[1], 1.0);
- this.sunDirectionZ = optionalParameter(options.SUN_DIRECTION[2], 1.0);
- this.oceanColor = optionalParameter(options.OCEAN_COLOR, new THREE.Vector3(0.004, 0.016, 0.047));
- this.skyColor = optionalParameter(options.SKY_COLOR, new THREE.Vector3(3.2, 9.6, 12.8));
- this.exposure = optionalParameter(options.EXPOSURE, 0.35);
- this.geometryResolution = optionalParameter(options.GEOMETRY_RESOLUTION, 32);
- this.geometrySize = optionalParameter(options.GEOMETRY_SIZE, 2000);
- this.resolution = optionalParameter(options.RESOLUTION, 64);
- this.floatSize = optionalParameter(options.SIZE_OF_FLOAT, 4);
- this.windX = optionalParameter(options.INITIAL_WIND[0], 10.0),
- this.windY = optionalParameter(options.INITIAL_WIND[1], 10.0),
- this.size = optionalParameter(options.INITIAL_SIZE, 250.0),
- this.choppiness = optionalParameter(options.INITIAL_CHOPPINESS, 1.5);
+ this.clearColor = optionalParameter( options.CLEAR_COLOR, [ 1.0, 1.0, 1.0, 0.0 ] );
+ this.geometryOrigin = optionalParameter( options.GEOMETRY_ORIGIN, [ - 1000.0, - 1000.0 ] );
+ this.sunDirectionX = optionalParameter( options.SUN_DIRECTION[ 0 ], - 1.0 );
+ this.sunDirectionY = optionalParameter( options.SUN_DIRECTION[ 1 ], 1.0 );
+ this.sunDirectionZ = optionalParameter( options.SUN_DIRECTION[ 2 ], 1.0 );
+ this.oceanColor = optionalParameter( options.OCEAN_COLOR, new THREE.Vector3( 0.004, 0.016, 0.047 ) );
+ this.skyColor = optionalParameter( options.SKY_COLOR, new THREE.Vector3( 3.2, 9.6, 12.8 ) );
+ this.exposure = optionalParameter( options.EXPOSURE, 0.35 );
+ this.geometryResolution = optionalParameter( options.GEOMETRY_RESOLUTION, 32 );
+ this.geometrySize = optionalParameter( options.GEOMETRY_SIZE, 2000 );
+ this.resolution = optionalParameter( options.RESOLUTION, 64 );
+ this.floatSize = optionalParameter( options.SIZE_OF_FLOAT, 4 );
+ this.windX = optionalParameter( options.INITIAL_WIND[ 0 ], 10.0 ),
+ this.windY = optionalParameter( options.INITIAL_WIND[ 1 ], 10.0 ),
+ this.size = optionalParameter( options.INITIAL_SIZE, 250.0 ),
+ this.choppiness = optionalParameter( options.INITIAL_CHOPPINESS, 1.5 );
this.matrixNeedsUpdate = false;
// Setup framebuffer pipeline
- var renderTargetType = optionalParameter(options.USE_HALF_FLOAT, false) ? THREE.HalfFloatType : THREE.FloatType;
+ var renderTargetType = optionalParameter( options.USE_HALF_FLOAT, false ) ? THREE.HalfFloatType : THREE.FloatType;
var LinearClampParams = {
minFilter: THREE.LinearFilter,
magFilter: THREE.LinearFilter,
@@ -61,7 +64,7 @@
format: THREE.RGBAFormat,
stencilBuffer: false,
depthBuffer: false,
- premultiplyAlpha:false,
+ premultiplyAlpha: false,
type: renderTargetType
var NearestRepeatParams = {
@@ -75,104 +78,104 @@
premultiplyAlpha: false,
- this.initialSpectrumFramebuffer = new THREE.WebGLRenderTarget(this.resolution, this.resolution, NearestRepeatParams);
- this.spectrumFramebuffer = new THREE.WebGLRenderTarget(this.resolution, this.resolution, NearestClampParams);
- this.pingPhaseFramebuffer = new THREE.WebGLRenderTarget(this.resolution, this.resolution, NearestClampParams);
- this.pongPhaseFramebuffer = new THREE.WebGLRenderTarget(this.resolution, this.resolution, NearestClampParams);
- this.pingTransformFramebuffer = new THREE.WebGLRenderTarget(this.resolution, this.resolution, NearestClampParams);
- this.pongTransformFramebuffer = new THREE.WebGLRenderTarget(this.resolution, this.resolution, NearestClampParams);
- this.displacementMapFramebuffer = new THREE.WebGLRenderTarget(this.resolution, this.resolution, LinearClampParams);
- this.normalMapFramebuffer = new THREE.WebGLRenderTarget(this.resolution, this.resolution, LinearClampParams);
+ this.initialSpectrumFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestRepeatParams );
+ this.spectrumFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
+ this.pingPhaseFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
+ this.pongPhaseFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
+ this.pingTransformFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
+ this.pongTransformFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
+ this.displacementMapFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, LinearClampParams );
+ this.normalMapFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, LinearClampParams );
// Define shaders and constant uniforms
////////////////////////////////////////
// 0 - The vertex shader used in all of the simulation steps
- var fullscreeenVertexShader = THREE.ShaderLib["ocean_sim_vertex"];
+ var fullscreeenVertexShader = THREE.ShaderLib[ "ocean_sim_vertex" ];
// 1 - Horizontal wave vertices used for FFT
- var oceanHorizontalShader = THREE.ShaderLib["ocean_subtransform"];
- var oceanHorizontalUniforms = THREE.UniformsUtils.clone(oceanHorizontalShader.uniforms);
- this.materialOceanHorizontal = new THREE.ShaderMaterial({
+ var oceanHorizontalShader = THREE.ShaderLib[ "ocean_subtransform" ];
+ var oceanHorizontalUniforms = THREE.UniformsUtils.clone( oceanHorizontalShader.uniforms );
+ this.materialOceanHorizontal = new THREE.ShaderMaterial( {
uniforms: oceanHorizontalUniforms,
vertexShader: fullscreeenVertexShader.vertexShader,
fragmentShader: "#define HORIZONTAL \n" + oceanHorizontalShader.fragmentShader
- });
this.materialOceanHorizontal.uniforms.u_transformSize = { type: "f", value: this.resolution };
this.materialOceanHorizontal.uniforms.u_subtransformSize = { type: "f", value: null };
this.materialOceanHorizontal.uniforms.u_input = { type: "t", value: null };
this.materialOceanHorizontal.depthTest = false;
// 2 - Vertical wave vertices used for FFT
- var oceanVerticalShader = THREE.ShaderLib["ocean_subtransform"];
- var oceanVerticalUniforms = THREE.UniformsUtils.clone(oceanVerticalShader.uniforms);
- this.materialOceanVertical = new THREE.ShaderMaterial({
+ var oceanVerticalShader = THREE.ShaderLib[ "ocean_subtransform" ];
+ var oceanVerticalUniforms = THREE.UniformsUtils.clone( oceanVerticalShader.uniforms );
+ this.materialOceanVertical = new THREE.ShaderMaterial( {
uniforms: oceanVerticalUniforms,
fragmentShader: oceanVerticalShader.fragmentShader
this.materialOceanVertical.uniforms.u_transformSize = { type: "f", value: this.resolution };
this.materialOceanVertical.uniforms.u_subtransformSize = { type: "f", value: null };
this.materialOceanVertical.uniforms.u_input = { type: "t", value: null };
this.materialOceanVertical.depthTest = false;
// 3 - Initial spectrum used to generate height map
- var initialSpectrumShader = THREE.ShaderLib["ocean_initial_spectrum"];
- var initialSpectrumUniforms = THREE.UniformsUtils.clone(initialSpectrumShader.uniforms);
- this.materialInitialSpectrum = new THREE.ShaderMaterial({
+ var initialSpectrumShader = THREE.ShaderLib[ "ocean_initial_spectrum" ];
+ var initialSpectrumUniforms = THREE.UniformsUtils.clone( initialSpectrumShader.uniforms );
+ this.materialInitialSpectrum = new THREE.ShaderMaterial( {
uniforms: initialSpectrumUniforms,
- fragmentShader:initialSpectrumShader.fragmentShader
+ fragmentShader: initialSpectrumShader.fragmentShader
this.materialInitialSpectrum.uniforms.u_wind = { type: "v2", value: new THREE.Vector2() };
this.materialInitialSpectrum.uniforms.u_resolution = { type: "f", value: this.resolution };
this.materialInitialSpectrum.depthTest = false;
// 4 - Phases used to animate heightmap
- var phaseShader = THREE.ShaderLib["ocean_phase"];
- var phaseUniforms = THREE.UniformsUtils.clone(phaseShader.uniforms);
- this.materialPhase = new THREE.ShaderMaterial({
+ var phaseShader = THREE.ShaderLib[ "ocean_phase" ];
+ var phaseUniforms = THREE.UniformsUtils.clone( phaseShader.uniforms );
+ this.materialPhase = new THREE.ShaderMaterial( {
uniforms: phaseUniforms,
fragmentShader: phaseShader.fragmentShader
this.materialPhase.uniforms.u_resolution = { type: "f", value: this.resolution };
this.materialPhase.depthTest = false;
// 5 - Shader used to update spectrum
- var spectrumShader = THREE.ShaderLib["ocean_spectrum"];
- var spectrumUniforms = THREE.UniformsUtils.clone(spectrumShader.uniforms);
- this.materialSpectrum = new THREE.ShaderMaterial({
+ var spectrumShader = THREE.ShaderLib[ "ocean_spectrum" ];
+ var spectrumUniforms = THREE.UniformsUtils.clone( spectrumShader.uniforms );
+ this.materialSpectrum = new THREE.ShaderMaterial( {
uniforms: spectrumUniforms,
fragmentShader: spectrumShader.fragmentShader
this.materialSpectrum.uniforms.u_initialSpectrum = { type: "t", value: null };
this.materialSpectrum.uniforms.u_resolution = { type: "f", value: this.resolution };
this.materialSpectrum.depthTest = false;
// 6 - Shader used to update spectrum normals
- var normalShader = THREE.ShaderLib["ocean_normals"];
- var normalUniforms = THREE.UniformsUtils.clone(normalShader.uniforms);
- this.materialNormal = new THREE.ShaderMaterial({
+ var normalShader = THREE.ShaderLib[ "ocean_normals" ];
+ var normalUniforms = THREE.UniformsUtils.clone( normalShader.uniforms );
+ this.materialNormal = new THREE.ShaderMaterial( {
uniforms: normalUniforms,
fragmentShader: normalShader.fragmentShader
this.materialNormal.uniforms.u_displacementMap = { type: "t", value: null };
this.materialNormal.uniforms.u_resolution = { type: "f", value: this.resolution };
this.materialNormal.depthTest = false;
// 7 - Shader used to update normals
- var oceanShader = THREE.ShaderLib["ocean_main"];
- var oceanUniforms = THREE.UniformsUtils.clone(oceanShader.uniforms);
- var oceanAttributes = THREE.UniformsUtils.clone(oceanShader.attributes);
- this.materialOcean = new THREE.ShaderMaterial({
+ var oceanShader = THREE.ShaderLib[ "ocean_main" ];
+ var oceanUniforms = THREE.UniformsUtils.clone( oceanShader.uniforms );
+ var oceanAttributes = THREE.UniformsUtils.clone( oceanShader.attributes );
+ this.materialOcean = new THREE.ShaderMaterial( {
attributes: oceanAttributes,
uniforms: oceanUniforms,
vertexShader: oceanShader.vertexShader,
fragmentShader: oceanShader.fragmentShader
// this.materialOcean.wireframe = true;
this.materialOcean.uniforms.u_geometrySize = { type: "f", value: this.resolution };
this.materialOcean.uniforms.u_displacementMap = { type: "t", value: this.displacementMapFramebuffer };
@@ -193,13 +196,14 @@
// Create the simulation plane
this.screenQuad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ) );
- this.scene.add(this.screenQuad);
+ this.scene.add( this.screenQuad );
// Initialise spectrum data
this.generateSeedPhaseTexture();
// Generate the ocean mesh
this.generateMesh();
THREE.Ocean.prototype.generateMesh = function () {
@@ -209,12 +213,14 @@ THREE.Ocean.prototype.generateMesh = function () {
geometry.applyMatrix( new THREE.Matrix4().makeRotationX( - Math.PI / 2 ) );
this.oceanMesh = new THREE.Mesh( geometry, this.materialOcean );
THREE.Ocean.prototype.render = function () {
this.scene.overrideMaterial = null;
- if (this.changed)
+ if ( this.changed )
this.renderInitialSpectrum();
this.renderWavePhase();
@@ -222,107 +228,140 @@ THREE.Ocean.prototype.render = function () {
this.renderSpectrumFFT();
this.renderNormalMap();
THREE.Ocean.prototype.generateSeedPhaseTexture = function() {
// Setup the seed texture
this.pingPhase = true;
- var phaseArray = new window.Float32Array(this.resolution * this.resolution * 4);
- for (var i = 0; i < this.resolution; i ++) {
- for (var j = 0; j < this.resolution; j ++) {
- phaseArray[i * this.resolution * 4 + j * 4] = Math.random() * 2.0 * Math.PI;
- phaseArray[i * this.resolution * 4 + j * 4 + 1] = 0.0;
- phaseArray[i * this.resolution * 4 + j * 4 + 2] = 0.0;
- phaseArray[i * this.resolution * 4 + j * 4 + 3] = 0.0;
+ var phaseArray = new window.Float32Array( this.resolution * this.resolution * 4 );
+ for ( var i = 0; i < this.resolution; i ++ ) {
+ for ( var j = 0; j < this.resolution; j ++ ) {
+ phaseArray[ i * this.resolution * 4 + j * 4 ] = Math.random() * 2.0 * Math.PI;
+ phaseArray[ i * this.resolution * 4 + j * 4 + 1 ] = 0.0;
+ phaseArray[ i * this.resolution * 4 + j * 4 + 2 ] = 0.0;
+ phaseArray[ i * this.resolution * 4 + j * 4 + 3 ] = 0.0;
- this.pingPhaseTexture = new THREE.DataTexture(phaseArray, this.resolution, this.resolution, THREE.RGBAFormat);
+ this.pingPhaseTexture = new THREE.DataTexture( phaseArray, this.resolution, this.resolution, THREE.RGBAFormat );
this.pingPhaseTexture.minFilter = THREE.NearestFilter;
this.pingPhaseTexture.magFilter = THREE.NearestFilter;
this.pingPhaseTexture.wrapS = THREE.ClampToEdgeWrapping;
this.pingPhaseTexture.wrapT = THREE.ClampToEdgeWrapping;
this.pingPhaseTexture.type = THREE.FloatType;
this.pingPhaseTexture.needsUpdate = true;
THREE.Ocean.prototype.renderInitialSpectrum = function () {
this.scene.overrideMaterial = this.materialInitialSpectrum;
this.materialInitialSpectrum.uniforms.u_wind.value.set( this.windX, this.windY );
this.materialInitialSpectrum.uniforms.u_size.value = this.size;
- this.renderer.render(this.scene, this.oceanCamera, this.initialSpectrumFramebuffer, true);
+ this.renderer.render( this.scene, this.oceanCamera, this.initialSpectrumFramebuffer, true );
THREE.Ocean.prototype.renderWavePhase = function () {
this.scene.overrideMaterial = this.materialPhase;
this.screenQuad.material = this.materialPhase;
- if (this.initial) {
+ if ( this.initial ) {
this.materialPhase.uniforms.u_phases.value = this.pingPhaseTexture;
this.initial = false;
}else {
this.materialPhase.uniforms.u_phases.value = this.pingPhase ? this.pingPhaseFramebuffer : this.pongPhaseFramebuffer;
this.materialPhase.uniforms.u_deltaTime.value = this.deltaTime;
this.materialPhase.uniforms.u_size.value = this.size;
- this.renderer.render(this.scene, this.oceanCamera, this.pingPhase ? this.pongPhaseFramebuffer : this.pingPhaseFramebuffer);
- this.pingPhase = !this.pingPhase;
+ this.renderer.render( this.scene, this.oceanCamera, this.pingPhase ? this.pongPhaseFramebuffer : this.pingPhaseFramebuffer );
+ this.pingPhase = ! this.pingPhase;
THREE.Ocean.prototype.renderSpectrum = function () {
this.scene.overrideMaterial = this.materialSpectrum;
this.materialSpectrum.uniforms.u_initialSpectrum.value = this.initialSpectrumFramebuffer;
this.materialSpectrum.uniforms.u_phases.value = this.pingPhase ? this.pingPhaseFramebuffer : this.pongPhaseFramebuffer;
this.materialSpectrum.uniforms.u_choppiness.value = this.choppiness ;
this.materialSpectrum.uniforms.u_size.value = this.size ;
- this.renderer.render(this.scene, this.oceanCamera, this.spectrumFramebuffer);
+ this.renderer.render( this.scene, this.oceanCamera, this.spectrumFramebuffer );
THREE.Ocean.prototype.renderSpectrumFFT = function() {
// GPU FFT using Stockham formulation
- var iterations = Math.log( this.resolution ) / Math.log(2); // log2
+ var iterations = Math.log( this.resolution ) / Math.log( 2 ); // log2
this.scene.overrideMaterial = this.materialOceanHorizontal;
- for (var i = 0; i < iterations; i ++) {
- if (i === 0) {
+ for ( var i = 0; i < iterations; i ++ ) {
+ if ( i === 0 ) {
this.materialOceanHorizontal.uniforms.u_input.value = this.spectrumFramebuffer;
- this.materialOceanHorizontal.uniforms.u_subtransformSize.value = Math.pow(2, (i % (iterations)) + 1);
- this.renderer.render(this.scene, this.oceanCamera, this.pingTransformFramebuffer);
- }
- else if (i % 2 === 1) {
+ this.materialOceanHorizontal.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
+ this.renderer.render( this.scene, this.oceanCamera, this.pingTransformFramebuffer );
+ } else if ( i % 2 === 1 ) {
this.materialOceanHorizontal.uniforms.u_input.value = this.pingTransformFramebuffer;
- this.renderer.render(this.scene, this.oceanCamera, this.pongTransformFramebuffer);
- else {
+ this.renderer.render( this.scene, this.oceanCamera, this.pongTransformFramebuffer );
+ } else {
this.materialOceanHorizontal.uniforms.u_input.value = this.pongTransformFramebuffer;
this.scene.overrideMaterial = this.materialOceanVertical;
- for (var i = iterations; i < iterations * 2; i ++) {
- if (i === iterations * 2 - 1) {
- this.materialOceanVertical.uniforms.u_input.value = (iterations % 2 === 0) ? this.pingTransformFramebuffer : this.pongTransformFramebuffer;
- this.materialOceanVertical.uniforms.u_subtransformSize.value = Math.pow(2, (i % (iterations)) + 1);
- this.renderer.render(this.scene, this.oceanCamera, this.displacementMapFramebuffer);
+ for ( var i = iterations; i < iterations * 2; i ++ ) {
+ if ( i === iterations * 2 - 1 ) {
+ this.materialOceanVertical.uniforms.u_input.value = ( iterations % 2 === 0 ) ? this.pingTransformFramebuffer : this.pongTransformFramebuffer;
+ this.materialOceanVertical.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
+ this.renderer.render( this.scene, this.oceanCamera, this.displacementMapFramebuffer );
this.materialOceanVertical.uniforms.u_input.value = this.pingTransformFramebuffer;
this.materialOceanVertical.uniforms.u_input.value = this.pongTransformFramebuffer;
THREE.Ocean.prototype.renderNormalMap = function () {
this.scene.overrideMaterial = this.materialNormal;
- if (this.changed) this.materialNormal.uniforms.u_size.value = this.size;
+ if ( this.changed ) this.materialNormal.uniforms.u_size.value = this.size;
this.materialNormal.uniforms.u_displacementMap.value = this.displacementMapFramebuffer;
- this.renderer.render(this.scene, this.oceanCamera, this.normalMapFramebuffer, true);
+ this.renderer.render( this.scene, this.oceanCamera, this.normalMapFramebuffer, true );
@@ -7,7 +7,9 @@
* based on Dynamic Octree by Piko3D @ http://www.piko3d.com/ and Octree by Marek Pawlowski @ pawlowski.it
*
- ( function ( THREE ) { "use strict";
+ ( function ( THREE ) {
+ "use strict";
/*===================================================
@@ -16,15 +18,21 @@
=====================================================*/
function isNumber ( n ) {
- return !isNaN( n ) && isFinite( n );
+ return ! isNaN( n ) && isFinite( n );
function isArray ( target ) {
return Object.prototype.toString.call( target ) === '[object Array]';
function toArray ( target ) {
return target ? ( isArray ( target ) !== true ? [ target ] : target ) : [];
function indexOfValue( array, value ) {
@@ -39,7 +47,7 @@
- return -1;
+ return - 1;
@@ -55,7 +63,7 @@
@@ -77,7 +85,7 @@
this.nodeCount = 0;
- this.INDEX_INSIDE_CROSS = -1;
+ this.INDEX_INSIDE_CROSS = - 1;
this.INDEX_OUTSIDE_OFFSET = 2;
this.INDEX_OUTSIDE_POS_X = isNumber( parameters.INDEX_OUTSIDE_POS_X ) ? parameters.INDEX_OUTSIDE_POS_X : 0;
@@ -89,11 +97,11 @@
this.INDEX_OUTSIDE_MAP = [];
this.INDEX_OUTSIDE_MAP[ this.INDEX_OUTSIDE_POS_X ] = { index: this.INDEX_OUTSIDE_POS_X, count: 0, x: 1, y: 0, z: 0 };
- this.INDEX_OUTSIDE_MAP[ this.INDEX_OUTSIDE_NEG_X ] = { index: this.INDEX_OUTSIDE_NEG_X, count: 0, x: -1, y: 0, z: 0 };
+ this.INDEX_OUTSIDE_MAP[ this.INDEX_OUTSIDE_NEG_X ] = { index: this.INDEX_OUTSIDE_NEG_X, count: 0, x: - 1, y: 0, z: 0 };
this.INDEX_OUTSIDE_MAP[ this.INDEX_OUTSIDE_POS_Y ] = { index: this.INDEX_OUTSIDE_POS_Y, count: 0, x: 0, y: 1, z: 0 };
- this.INDEX_OUTSIDE_MAP[ this.INDEX_OUTSIDE_NEG_Y ] = { index: this.INDEX_OUTSIDE_NEG_Y, count: 0, x: 0, y: -1, z: 0 };
+ this.INDEX_OUTSIDE_MAP[ this.INDEX_OUTSIDE_NEG_Y ] = { index: this.INDEX_OUTSIDE_NEG_Y, count: 0, x: 0, y: - 1, z: 0 };
this.INDEX_OUTSIDE_MAP[ this.INDEX_OUTSIDE_POS_Z ] = { index: this.INDEX_OUTSIDE_POS_Z, count: 0, x: 0, y: 0, z: 1 };
- this.INDEX_OUTSIDE_MAP[ this.INDEX_OUTSIDE_NEG_Z ] = { index: this.INDEX_OUTSIDE_NEG_Z, count: 0, x: 0, y: 0, z: -1 };
+ this.INDEX_OUTSIDE_MAP[ this.INDEX_OUTSIDE_NEG_Z ] = { index: this.INDEX_OUTSIDE_NEG_Z, count: 0, x: 0, y: 0, z: - 1 };
this.FLAG_POS_X = 1 << ( this.INDEX_OUTSIDE_POS_X + 1 );
this.FLAG_NEG_X = 1 << ( this.INDEX_OUTSIDE_NEG_X + 1 );
@@ -194,13 +202,13 @@
// check uuid to avoid duplicates
- if ( !object.uuid ) {
+ if ( ! object.uuid ) {
object.uuid = THREE.Math.generateUUID();
- if ( !this.objectsMap[ object.uuid ] ) {
+ if ( ! this.objectsMap[ object.uuid ] ) {
// store
@@ -287,7 +295,7 @@
index = indexOfValue( this.objects, object );
- if ( index !== -1 ) {
+ if ( index !== - 1 ) {
this.objects.splice( index, 1 );
@@ -303,7 +311,7 @@
index = indexOfValue( this.objectsData, objectData );
this.objectsData.splice( index, 1 );
@@ -319,7 +327,7 @@
index = indexOfPropertyWithValue( this.objectsDeferred, 'object', object );
this.objectsDeferred.splice( index, 1 );
@@ -378,7 +386,7 @@
// if position has changed since last organization of object in tree
- if ( node instanceof THREE.OctreeNode && !objectData.positionLast.equals( objectData.position ) ) {
+ if ( node instanceof THREE.OctreeNode && ! objectData.positionLast.equals( objectData.position ) ) {
// get octant index of object within current node
@@ -477,7 +485,7 @@
// ensure radius (i.e. distance of ray) is a number
- if ( !( radius > 0 ) ) {
+ if ( ! ( radius > 0 ) ) {
radius = Number.MAX_VALUE;
@@ -520,7 +528,7 @@
// if needed, create new result data
- if ( resultObjectIndex === -1 ) {
+ if ( resultObjectIndex === - 1 ) {
resultData = {
object: object,
@@ -860,7 +868,7 @@
node.indexOctant = indexOctant;
- if ( indexOfValue( this.nodesIndices, indexOctant ) === -1 ) {
+ if ( indexOfValue( this.nodesIndices, indexOctant ) === - 1 ) {
this.nodesIndices.push( indexOctant );
@@ -908,13 +916,13 @@
indexOctant = this.getOctantIndex( object );
// if object fully contained by an octant, add to subtree
- if ( indexOctant > -1 && this.nodesIndices.length > 0 ) {
+ if ( indexOctant > - 1 && this.nodesIndices.length > 0 ) {
node = this.branch( indexOctant );
node.addObject( object );
- } else if ( indexOctant < -1 && this.parent instanceof THREE.OctreeNode ) {
+ } else if ( indexOctant < - 1 && this.parent instanceof THREE.OctreeNode ) {
// if object lies outside bounds, add to parent node
@@ -926,7 +934,7 @@
- if ( index === -1 ) {
+ if ( index === - 1 ) {
this.objects.push( object );
@@ -992,7 +1000,7 @@
removeObjectRecursive: function ( object, removeData ) {
var i, l,
- index = -1,
+ index = - 1,
objectData,
node,
objectRemoved;
@@ -1006,7 +1014,7 @@
object.node = undefined;
@@ -1034,7 +1042,7 @@
objectRemoved = true;
- if ( !objectData.faces && !objectData.vertices ) {
+ if ( ! objectData.faces && ! objectData.vertices ) {
removeData.searchComplete = true;
break;
@@ -1115,12 +1123,12 @@
// if lies within octant
- if ( indexOctant > -1 ) {
+ if ( indexOctant > - 1 ) {
objectsSplit.push( object );
objectsSplitOctants.push( indexOctant );
- } else if ( indexOctant < -1 ) {
+ } else if ( indexOctant < - 1 ) {
// lies outside radius
@@ -1139,7 +1147,7 @@
// if has objects to split
- if ( objectsSplit.length > 0) {
+ if ( objectsSplit.length > 0 ) {
objectsRemaining = objectsRemaining.concat( this.split( objectsSplit, objectsSplitOctants ) );
@@ -1147,7 +1155,7 @@
// if has objects to expand
- if ( objectsExpand.length > 0) {
+ if ( objectsExpand.length > 0 ) {
objectsRemaining = objectsRemaining.concat( this.expand( objectsExpand, objectsExpandOctants ) );
@@ -1193,7 +1201,7 @@
// if object contained by octant, branch this tree
@@ -1247,7 +1255,7 @@
radius = ( this.radiusOverlap ) * 0.5;
overlap = radius * this.tree.overlapPct;
radiusOffset = radius - overlap;
- offset = this.utilVec31Branch.set( indexOctant & 1 ? radiusOffset : -radiusOffset, indexOctant & 2 ? radiusOffset : -radiusOffset, indexOctant & 4 ? radiusOffset : -radiusOffset );
+ offset = this.utilVec31Branch.set( indexOctant & 1 ? radiusOffset : - radiusOffset, indexOctant & 2 ? radiusOffset : - radiusOffset, indexOctant & 4 ? radiusOffset : - radiusOffset );
position = new THREE.Vector3().addVectors( this.position, offset );
// node
@@ -1332,11 +1340,11 @@
// if object outside this, include in calculations
- if ( indexOctant < -1 ) {
+ if ( indexOctant < - 1 ) {
// convert octant index to outside flags
- flagsOutside = -indexOctant - this.tree.INDEX_OUTSIDE_OFFSET;
+ flagsOutside = - indexOctant - this.tree.INDEX_OUTSIDE_OFFSET;
// check against bitwise flags
@@ -1438,7 +1446,7 @@
// get this octant indices based on octant normal
indexOctant = this.getOctantIndexFromPosition( octantX, octantY, octantZ );
- indexOctantInverse = this.getOctantIndexFromPosition( -octantX, -octantY, -octantZ );
+ indexOctantInverse = this.getOctantIndexFromPosition( - octantX, - octantY, - octantZ );
// properties
@@ -1453,7 +1461,7 @@
// parent offset is difference between radius + overlap of parent and child
radiusOffset = ( radiusParent + overlapParent ) - ( radius + overlap );
- offset.set( indexOctant & 1 ? radiusOffset : -radiusOffset, indexOctant & 2 ? radiusOffset : -radiusOffset, indexOctant & 4 ? radiusOffset : -radiusOffset );
+ offset.set( indexOctant & 1 ? radiusOffset : - radiusOffset, indexOctant & 2 ? radiusOffset : - radiusOffset, indexOctant & 4 ? radiusOffset : - radiusOffset );
// parent
@@ -1735,7 +1743,7 @@
- objectData.indexOctant = -indexOctant - this.tree.INDEX_OUTSIDE_OFFSET;
+ objectData.indexOctant = - indexOctant - this.tree.INDEX_OUTSIDE_OFFSET;
return objectData.indexOctant;
@@ -1743,13 +1751,13 @@
// return octant index from delta xyz
- if ( deltaX - radiusObj > -overlap ) {
+ if ( deltaX - radiusObj > - overlap ) {
// x right
indexOctant = indexOctant | 1;
- } else if ( !( deltaX + radiusObj < overlap ) ) {
+ } else if ( ! ( deltaX + radiusObj < overlap ) ) {
// x left
@@ -1758,13 +1766,13 @@
- if ( deltaY - radiusObj > -overlap ) {
+ if ( deltaY - radiusObj > - overlap ) {
// y right
indexOctant = indexOctant | 2;
- } else if ( !( deltaY + radiusObj < overlap ) ) {
+ } else if ( ! ( deltaY + radiusObj < overlap ) ) {
// y left
@@ -1774,13 +1782,13 @@
- if ( deltaZ - radiusObj > -overlap ) {
+ if ( deltaZ - radiusObj > - overlap ) {
// z right
indexOctant = indexOctant | 4;
- } else if ( !( deltaZ + radiusObj < overlap ) ) {
+ } else if ( ! ( deltaZ + radiusObj < overlap ) ) {
// z left
@@ -1870,21 +1878,33 @@
pz = position.z;
if ( px < this.left ) {
distance -= Math.pow( px - this.left, 2 );
} else if ( px > this.right ) {
distance -= Math.pow( px - this.right, 2 );
if ( py < this.bottom ) {
distance -= Math.pow( py - this.bottom, 2 );
} else if ( py > this.top ) {
distance -= Math.pow( py - this.top, 2 );
if ( pz < this.back ) {
distance -= Math.pow( pz - this.back, 2 );
} else if ( pz > this.front ) {
distance -= Math.pow( pz - this.front, 2 );
return distance >= 0;
@@ -1905,20 +1925,23 @@
t4 = ( this.top - origin.y ) * directionPct.y,
t5 = ( this.back - origin.z ) * directionPct.z,
t6 = ( this.front - origin.z ) * directionPct.z,
- tmax = Math.min( Math.min( Math.max( t1, t2), Math.max( t3, t4) ), Math.max( t5, t6) ),
+ tmax = Math.min( Math.min( Math.max( t1, t2 ), Math.max( t3, t4 ) ), Math.max( t5, t6 ) ),
tmin;
// ray would intersect in reverse direction, i.e. this is behind ray
- if (tmax < 0)
- {
+ if ( tmax < 0 ) {
return false;
- tmin = Math.max( Math.max( Math.min( t1, t2), Math.min( t3, t4)), Math.min( t5, t6));
+ tmin = Math.max( Math.max( Math.min( t1, t2 ), Math.min( t3, t4 ) ), Math.min( t5, t6 ) );
// if tmin > tmax or tmin > ray distance, ray doesn't intersect AABB
if ( tmin > tmax || tmin > distance ) {
return true;
@@ -1942,7 +1965,7 @@
} else {
- depth = !depth || this.depth > depth ? this.depth : depth;
+ depth = ! depth || this.depth > depth ? this.depth : depth;
@@ -2111,4 +2134,4 @@
-}( THREE ) );
+}( THREE ) );
@@ -4,8 +4,20 @@
var PRNG = function () {
this.seed = 1;
- this.next = function() { return (this.gen() / 2147483647); };
- this.nextRange = function(min, max) { return min + ((max - min) * this.next()) };
- this.gen = function() { return this.seed = (this.seed * 16807) % 2147483647; };
+ this.next = function() {
+ return ( this.gen() / 2147483647 );
+ this.nextRange = function( min, max ) {
+ return min + ( ( max - min ) * this.next() )
+ this.gen = function() {
+ return this.seed = ( this.seed * 16807 ) % 2147483647;
@@ -8,37 +8,46 @@
THREE.ParametricGeometries = {
- klein: function (v, u) {
+ klein: function ( v, u ) {
u *= Math.PI;
v *= 2 * Math.PI;
u = u * 2;
var x, y, z;
- if (u < Math.PI) {
- x = 3 * Math.cos(u) * (1 + Math.sin(u)) + (2 * (1 - Math.cos(u) / 2)) * Math.cos(u) * Math.cos(v);
- z = -8 * Math.sin(u) - 2 * (1 - Math.cos(u) / 2) * Math.sin(u) * Math.cos(v);
+ if ( u < Math.PI ) {
+ x = 3 * Math.cos( u ) * ( 1 + Math.sin( u ) ) + ( 2 * ( 1 - Math.cos( u ) / 2 ) ) * Math.cos( u ) * Math.cos( v );
+ z = - 8 * Math.sin( u ) - 2 * ( 1 - Math.cos( u ) / 2 ) * Math.sin( u ) * Math.cos( v );
- x = 3 * Math.cos(u) * (1 + Math.sin(u)) + (2 * (1 - Math.cos(u) / 2)) * Math.cos(v + Math.PI);
- z = -8 * Math.sin(u);
+ x = 3 * Math.cos( u ) * ( 1 + Math.sin( u ) ) + ( 2 * ( 1 - Math.cos( u ) / 2 ) ) * Math.cos( v + Math.PI );
+ z = - 8 * Math.sin( u );
- y = -2 * (1 - Math.cos(u) / 2) * Math.sin(v);
+ y = - 2 * ( 1 - Math.cos( u ) / 2 ) * Math.sin( v );
- plane: function (width, height) {
+ plane: function ( width, height ) {
var x = u * width;
var y = 0;
var z = v * height;
- mobius: function(u, t) {
+ mobius: function( u, t ) {
// flat mobius strip
// http://www.wolframalpha.com/input/?i=M%C3%B6bius+strip+parametric+equations&lk=1&a=ClashPrefs_*Surface.MoebiusStrip.SurfaceProperty.ParametricEquations-
@@ -48,14 +57,14 @@ THREE.ParametricGeometries = {
var a = 2;
- x = Math.cos(v) * (a + u * Math.cos(v / 2));
- y = Math.sin(v) * (a + u * Math.cos(v / 2));
- z = u * Math.sin(v / 2);
+ x = Math.cos( v ) * ( a + u * Math.cos( v / 2 ) );
+ y = Math.sin( v ) * ( a + u * Math.cos( v / 2 ) );
+ z = u * Math.sin( v / 2 );
- mobius3d: function(u, t) {
+ mobius3d: function( u, t ) {
// volumetric mobius strip
@@ -65,11 +74,12 @@ THREE.ParametricGeometries = {
var phi = u / 2;
var major = 2.25, a = 0.125, b = 0.65;
- x = a * Math.cos(t) * Math.cos(phi) - b * Math.sin(t) * Math.sin(phi);
- z = a * Math.cos(t) * Math.sin(phi) + b * Math.sin(t) * Math.cos(phi);
- y = (major + x) * Math.sin(u);
- x = (major + x) * Math.cos(u);
+ x = a * Math.cos( t ) * Math.cos( phi ) - b * Math.sin( t ) * Math.sin( phi );
+ z = a * Math.cos( t ) * Math.sin( phi ) + b * Math.sin( t ) * Math.cos( phi );
+ y = ( major + x ) * Math.sin( u );
+ x = ( major + x ) * Math.cos( u );
@@ -81,14 +91,14 @@ THREE.ParametricGeometries = {
*********************************************/
-THREE.ParametricGeometries.TubeGeometry = function(path, segments, radius, segmentsRadius, closed, debug) {
+THREE.ParametricGeometries.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, debug ) {
this.path = path;
this.segments = segments || 64;
this.radius = radius || 1;
this.segmentsRadius = segmentsRadius || 8;
this.closed = closed || false;
- if (debug) this.debug = new THREE.Object3D();
+ if ( debug ) this.debug = new THREE.Object3D();
var scope = this,
@@ -102,50 +112,52 @@ THREE.ParametricGeometries.TubeGeometry = function(path, segments, radius, segme
cx, cy, pos, pos2 = new THREE.Vector3(),
i, j, ip, jp, a, b, c, d, uva, uvb, uvc, uvd;
- var frames = new THREE.TubeGeometry.FrenetFrames(path, segments, closed),
+ var frames = new THREE.TubeGeometry.FrenetFrames( path, segments, closed ),
tangents = frames.tangents,
normals = frames.normals,
binormals = frames.binormals;
- // proxy internals
+ // proxy internals
this.tangents = tangents;
this.normals = normals;
this.binormals = binormals;
- var ParametricTube = function(u, v) {
+ var ParametricTube = function( u, v ) {
- i = u * (numpoints - 1);
- i = Math.floor(i);
+ i = u * ( numpoints - 1 );
+ i = Math.floor( i );
- pos = path.getPointAt(u);
+ pos = path.getPointAt( u );
- tangent = tangents[i];
- normal = normals[i];
- binormal = binormals[i];
+ tangent = tangents[ i ];
+ normal = normals[ i ];
+ binormal = binormals[ i ];
- if (scope.debug) {
+ if ( scope.debug ) {
- scope.debug.add(new THREE.ArrowHelper(tangent, pos, radius, 0x0000ff));
- scope.debug.add(new THREE.ArrowHelper(normal, pos, radius, 0xff0000));
- scope.debug.add(new THREE.ArrowHelper(binormal, pos, radius, 0x00ff00));
+ scope.debug.add( new THREE.ArrowHelper( tangent, pos, radius, 0x0000ff ) );
+ scope.debug.add( new THREE.ArrowHelper( normal, pos, radius, 0xff0000 ) );
+ scope.debug.add( new THREE.ArrowHelper( binormal, pos, radius, 0x00ff00 ) );
- cx = -scope.radius * Math.cos(v); // TODO: Hack: Negating it so it faces outside.
- cy = scope.radius * Math.sin(v);
+ cx = - scope.radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
+ cy = scope.radius * Math.sin( v );
- pos2.copy(pos);
+ pos2.copy( pos );
pos2.x += cx * normal.x + cy * binormal.x;
pos2.y += cx * normal.y + cy * binormal.y;
pos2.z += cx * normal.z + cy * binormal.z;
return pos2.clone();
- THREE.ParametricGeometry.call(this, ParametricTube, segments, segmentsRadius);
+ THREE.ParametricGeometry.call( this, ParametricTube, segments, segmentsRadius );
@@ -176,17 +188,17 @@ THREE.ParametricGeometries.TorusKnotGeometry = function ( radius, tube, segments
function() {
var r = 0.5;
- var tx = (1 + r * Math.cos(q * t)) * Math.cos(p * t),
- ty = (1 + r * Math.cos(q * t)) * Math.sin(p * t),
- tz = r * Math.sin(q * t);
+ var tx = ( 1 + r * Math.cos( q * t ) ) * Math.cos( p * t ),
+ ty = ( 1 + r * Math.cos( q * t ) ) * Math.sin( p * t ),
+ tz = r * Math.sin( q * t );
- return new THREE.Vector3(tx, ty * heightScale, tz).multiplyScalar(radius);
+ return new THREE.Vector3( tx, ty * heightScale, tz ).multiplyScalar( radius );
@@ -209,21 +221,23 @@ THREE.ParametricGeometries.TorusKnotGeometry.prototype.constructor = THREE.Param
* Parametric Replacement for SphereGeometry
-THREE.ParametricGeometries.SphereGeometry = function(size, u, v) {
+THREE.ParametricGeometries.SphereGeometry = function( size, u, v ) {
+ function sphere( u, v ) {
- function sphere(u, v) {
- var x = size * Math.sin(u) * Math.cos(v);
- var y = size * Math.sin(u) * Math.sin(v);
- var z = size * Math.cos(u);
+ var x = size * Math.sin( u ) * Math.cos( v );
+ var y = size * Math.sin( u ) * Math.sin( v );
+ var z = size * Math.cos( u );
- THREE.ParametricGeometry.call(this, sphere, u, v, !true);
+ THREE.ParametricGeometry.call( this, sphere, u, v, ! true );
@@ -237,18 +251,19 @@ THREE.ParametricGeometries.SphereGeometry.prototype.constructor = THREE.Parametr
-THREE.ParametricGeometries.PlaneGeometry = function(width, depth, segmentsWidth, segmentsDepth) {
+THREE.ParametricGeometries.PlaneGeometry = function( width, depth, segmentsWidth, segmentsDepth ) {
- function plane(u, v) {
+ function plane( u, v ) {
var z = v * depth;
- THREE.ParametricGeometry.call(this, plane, segmentsWidth, segmentsDepth);
+ THREE.ParametricGeometry.call( this, plane, segmentsWidth, segmentsDepth );
@@ -23,7 +23,7 @@ THREE.DeferredShaderChunk = {
computeVertexPositionVS: [
@@ -41,13 +41,13 @@ THREE.DeferredShaderChunk = {
"vertexPositionVS.xyz /= vertexPositionVS.w;",
"vertexPositionVS.w = 1.0;"
computeNormal: [
"vec3 normal = normalDepth.xyz * 2.0 - 1.0;"
unpackColorMap: [
@@ -59,7 +59,7 @@ THREE.DeferredShaderChunk = {
"float wrapAround = sign( colorMap.z );",
"float additiveSpecular = sign( colorMap.y );"
computeDiffuse: [
@@ -85,7 +85,7 @@ THREE.DeferredShaderChunk = {
computeSpecular: [
@@ -103,14 +103,14 @@ THREE.DeferredShaderChunk = {
"vec3 schlick = specularColor + vec3( 1.0 - specularColor ) * pow( 1.0 - dot( lightVector, halfVector ), 5.0 );",
"vec3 specular = schlick * max( pow( dotNormalHalf, shininess ), 0.0 ) * diffuse * specularNormalization;"
combine: [
"vec3 light = lightIntensity * lightColor;",
"gl_FragColor = vec4( light * ( albedo * diffuse + specular ), attenuation );"
@@ -305,7 +305,7 @@ THREE.ShaderDeferred = {
vertexShader : [
@@ -346,7 +346,7 @@ THREE.ShaderDeferred = {
@@ -391,7 +391,7 @@ THREE.ShaderDeferred = {
@@ -434,7 +434,7 @@ THREE.ShaderDeferred = {
@@ -528,7 +528,7 @@ THREE.ShaderDeferred = {
@@ -542,7 +542,7 @@ THREE.ShaderDeferred = {
@@ -556,7 +556,7 @@ THREE.ShaderDeferred = {
viewWidth: { type: "f", value: 800 },
viewHeight: { type: "f", value: 600 },
- lightPositionVS:{ type: "v3", value: new THREE.Vector3( 0, 0, 0 ) },
+ lightPositionVS: { type: "v3", value: new THREE.Vector3( 0, 0, 0 ) },
lightColor: { type: "c", value: new THREE.Color( 0x000000 ) },
lightIntensity: { type: "f", value: 1.0 },
lightRadius: { type: "f", value: 1.0 }
@@ -614,7 +614,7 @@ THREE.ShaderDeferred = {
@@ -627,7 +627,7 @@ THREE.ShaderDeferred = {
@@ -641,8 +641,8 @@ THREE.ShaderDeferred = {
- lightPositionVS :{ type: "v3", value: new THREE.Vector3( 0, 1, 0 ) },
- lightDirectionVS:{ type: "v3", value: new THREE.Vector3( 0, 1, 0 ) },
+ lightPositionVS : { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) },
+ lightDirectionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) },
lightDistance: { type: "f", value: 1.0 },
@@ -718,7 +718,7 @@ THREE.ShaderDeferred = {
@@ -730,7 +730,7 @@ THREE.ShaderDeferred = {
@@ -788,7 +788,7 @@ THREE.ShaderDeferred = {
@@ -800,7 +800,7 @@ THREE.ShaderDeferred = {
@@ -886,7 +886,7 @@ THREE.ShaderDeferred = {
@@ -898,7 +898,7 @@ THREE.ShaderDeferred = {
@@ -913,7 +913,7 @@ THREE.ShaderDeferred = {
lightPositionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) },
- lightNormalVS: { type: "v3", value: new THREE.Vector3( 0, -1, 0 ) },
+ lightNormalVS: { type: "v3", value: new THREE.Vector3( 0, - 1, 0 ) },
lightRightVS: { type: "v3", value: new THREE.Vector3( 1, 0, 0 ) },
lightUpVS: { type: "v3", value: new THREE.Vector3( 1, 0, 0 ) },
@@ -1041,7 +1041,7 @@ THREE.ShaderDeferred = {
@@ -1053,7 +1053,7 @@ THREE.ShaderDeferred = {
@@ -1087,7 +1087,7 @@ THREE.ShaderDeferred = {
@@ -1099,7 +1099,7 @@ THREE.ShaderDeferred = {
@@ -71,7 +71,7 @@ THREE.ShaderGodRays = {
@@ -157,7 +157,7 @@ THREE.ShaderGodRays = {
@@ -203,7 +203,7 @@ THREE.ShaderGodRays = {
@@ -226,7 +226,7 @@ THREE.ShaderGodRays = {
@@ -273,7 +273,7 @@ THREE.ShaderGodRays = {
@@ -301,7 +301,7 @@ THREE.ShaderGodRays = {
@@ -30,27 +30,27 @@ THREE.ShaderSkin = {
{
- "enableBump" : { type: "i", value: 0 },
- "enableSpecular": { type: "i", value: 0 },
+ "enableBump" : { type: "i", value: 0 },
+ "enableSpecular": { type: "i", value: 0 },
- "tDiffuse" : { type: "t", value: null },
- "tBeckmann" : { type: "t", value: null },
+ "tDiffuse" : { type: "t", value: null },
+ "tBeckmann" : { type: "t", value: null },
- "diffuse": { type: "c", value: new THREE.Color( 0xeeeeee ) },
- "specular": { type: "c", value: new THREE.Color( 0x111111 ) },
- "opacity": { type: "f", value: 1 },
+ "diffuse": { type: "c", value: new THREE.Color( 0xeeeeee ) },
+ "specular": { type: "c", value: new THREE.Color( 0x111111 ) },
+ "opacity": { type: "f", value: 1 },
- "uRoughness": { type: "f", value: 0.15 },
- "uSpecularBrightness": { type: "f", value: 0.75 },
+ "uRoughness": { type: "f", value: 0.15 },
+ "uSpecularBrightness": { type: "f", value: 0.75 },
- "bumpMap" : { type: "t", value: null },
- "bumpScale" : { type: "f", value: 1 },
+ "bumpMap" : { type: "t", value: null },
+ "bumpScale" : { type: "f", value: 1 },
- "specularMap" : { type: "t", value: null },
+ "specularMap" : { type: "t", value: null },
- "offsetRepeat" : { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) },
+ "offsetRepeat" : { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) },
- "uWrapRGB": { type: "v3", value: new THREE.Vector3( 0.75, 0.375, 0.1875 ) }
+ "uWrapRGB": { type: "v3", value: new THREE.Vector3( 0.75, 0.375, 0.1875 ) }
@@ -279,7 +279,7 @@ THREE.ShaderSkin = {
vertexShader: [
@@ -338,26 +338,26 @@ THREE.ShaderSkin = {
- "passID": { type: "i", value: 0 },
+ "passID": { type: "i", value: 0 },
- "tNormal" : { type: "t", value: null },
+ "tNormal" : { type: "t", value: null },
- "tBlur1" : { type: "t", value: null },
- "tBlur2" : { type: "t", value: null },
- "tBlur3" : { type: "t", value: null },
- "tBlur4" : { type: "t", value: null },
+ "tBlur1" : { type: "t", value: null },
+ "tBlur2" : { type: "t", value: null },
+ "tBlur3" : { type: "t", value: null },
+ "tBlur4" : { type: "t", value: null },
- "uNormalScale": { type: "f", value: 1.0 },
+ "uNormalScale": { type: "f", value: 1.0 },
- "uSpecularBrightness": { type: "f", value: 0.75 }
+ "uSpecularBrightness": { type: "f", value: 0.75 }
@@ -570,7 +570,7 @@ THREE.ShaderSkin = {
@@ -659,7 +659,7 @@ THREE.ShaderSkin = {
vertexShaderUV: [
@@ -735,7 +735,7 @@ THREE.ShaderSkin = {
@@ -762,7 +762,7 @@ THREE.ShaderSkin = {
@@ -794,7 +794,7 @@ THREE.ShaderSkin = {
@@ -23,32 +23,32 @@ THREE.ShaderTerrain = {
- "enableDiffuse1" : { type: "i", value: 0 },
- "enableDiffuse2" : { type: "i", value: 0 },
- "enableSpecular" : { type: "i", value: 0 },
- "enableReflection": { type: "i", value: 0 },
+ "enableDiffuse1" : { type: "i", value: 0 },
+ "enableDiffuse2" : { type: "i", value: 0 },
+ "enableSpecular" : { type: "i", value: 0 },
+ "enableReflection": { type: "i", value: 0 },
- "tDiffuse1" : { type: "t", value: null },
- "tDiffuse2" : { type: "t", value: null },
- "tDetail" : { type: "t", value: null },
- "tSpecular" : { type: "t", value: null },
- "tDisplacement": { type: "t", value: null },
+ "tDiffuse1" : { type: "t", value: null },
+ "tDiffuse2" : { type: "t", value: null },
+ "tDetail" : { type: "t", value: null },
+ "tSpecular" : { type: "t", value: null },
+ "tDisplacement": { type: "t", value: null },
- "uDisplacementBias": { type: "f", value: 0.0 },
- "uDisplacementScale": { type: "f", value: 1.0 },
+ "uDisplacementBias": { type: "f", value: 0.0 },
+ "uDisplacementScale": { type: "f", value: 1.0 },
- "shininess": { type: "f", value: 30 },
+ "shininess": { type: "f", value: 30 },
- "uRepeatBase" : { type: "v2", value: new THREE.Vector2( 1, 1 ) },
- "uRepeatOverlay" : { type: "v2", value: new THREE.Vector2( 1, 1 ) },
+ "uRepeatBase" : { type: "v2", value: new THREE.Vector2( 1, 1 ) },
+ "uRepeatOverlay" : { type: "v2", value: new THREE.Vector2( 1, 1 ) },
- "uOffset" : { type: "v2", value: new THREE.Vector2( 0, 0 ) }
+ "uOffset" : { type: "v2", value: new THREE.Vector2( 0, 0 ) }
@@ -263,7 +263,7 @@ THREE.ShaderTerrain = {
@@ -336,7 +336,7 @@ THREE.ShaderTerrain = {
@@ -12,320 +12,320 @@
THREE.ShaderToon = {
-'toon1' : {
+ 'toon1' : {
- uniforms: {
+ uniforms: {
- "uDirLightPos": { type: "v3", value: new THREE.Vector3() },
- "uDirLightColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
+ "uDirLightPos": { type: "v3", value: new THREE.Vector3() },
+ "uDirLightColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
- "uAmbientLightColor": { type: "c", value: new THREE.Color( 0x050505 ) },
+ "uAmbientLightColor": { type: "c", value: new THREE.Color( 0x050505 ) },
- "uBaseColor": { type: "c", value: new THREE.Color( 0xffffff ) }
+ "uBaseColor": { type: "c", value: new THREE.Color( 0xffffff ) }
- },
+ },
- vertexShader: [
+ vertexShader: [
- "varying vec3 vNormal;",
- "varying vec3 vRefract;",
+ "varying vec3 vNormal;",
+ "varying vec3 vRefract;",
- "void main() {",
+ "void main() {",
- "vec4 worldPosition = modelMatrix * vec4( position, 1.0 );",
- "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
- "vec3 worldNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );",
+ "vec4 worldPosition = modelMatrix * vec4( position, 1.0 );",
+ "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+ "vec3 worldNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );",
- "vNormal = normalize( normalMatrix * normal );",
+ "vNormal = normalize( normalMatrix * normal );",
- "vec3 I = worldPosition.xyz - cameraPosition;",
- "vRefract = refract( normalize( I ), worldNormal, 1.02 );",
+ "vec3 I = worldPosition.xyz - cameraPosition;",
+ "vRefract = refract( normalize( I ), worldNormal, 1.02 );",
- "gl_Position = projectionMatrix * mvPosition;",
+ "gl_Position = projectionMatrix * mvPosition;",
- "}"
+ "}"
- fragmentShader: [
+ fragmentShader: [
- "uniform vec3 uBaseColor;",
+ "uniform vec3 uBaseColor;",
- "uniform vec3 uDirLightPos;",
- "uniform vec3 uDirLightColor;",
+ "uniform vec3 uDirLightPos;",
+ "uniform vec3 uDirLightColor;",
- "uniform vec3 uAmbientLightColor;",
+ "uniform vec3 uAmbientLightColor;",
- "float directionalLightWeighting = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);",
- "vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;",
+ "float directionalLightWeighting = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);",
+ "vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;",
- "float intensity = smoothstep( - 0.5, 1.0, pow( length(lightWeighting), 20.0 ) );",
- "intensity += length(lightWeighting) * 0.2;",
+ "float intensity = smoothstep( - 0.5, 1.0, pow( length(lightWeighting), 20.0 ) );",
+ "intensity += length(lightWeighting) * 0.2;",
- "float cameraWeighting = dot( normalize( vNormal ), vRefract );",
- "intensity += pow( 1.0 - length( cameraWeighting ), 6.0 );",
- "intensity = intensity * 0.2 + 0.3;",
+ "float cameraWeighting = dot( normalize( vNormal ), vRefract );",
+ "intensity += pow( 1.0 - length( cameraWeighting ), 6.0 );",
+ "intensity = intensity * 0.2 + 0.3;",
- "if ( intensity < 0.50 ) {",
+ "if ( intensity < 0.50 ) {",
- "gl_FragColor = vec4( 2.0 * intensity * uBaseColor, 1.0 );",
+ "gl_FragColor = vec4( 2.0 * intensity * uBaseColor, 1.0 );",
- "} else {",
+ "} else {",
- "gl_FragColor = vec4( 1.0 - 2.0 * ( 1.0 - intensity ) * ( 1.0 - uBaseColor ), 1.0 );",
+ "gl_FragColor = vec4( 1.0 - 2.0 * ( 1.0 - intensity ) * ( 1.0 - uBaseColor ), 1.0 );",
- "}",
+ "}",
-},
-'toon2' : {
+ 'toon2' : {
- "uBaseColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
- "uLineColor1": { type: "c", value: new THREE.Color( 0x808080 ) },
- "uLineColor2": { type: "c", value: new THREE.Color( 0x000000 ) },
- "uLineColor3": { type: "c", value: new THREE.Color( 0x000000 ) },
- "uLineColor4": { type: "c", value: new THREE.Color( 0x000000 ) }
+ "uBaseColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
+ "uLineColor1": { type: "c", value: new THREE.Color( 0x808080 ) },
+ "uLineColor2": { type: "c", value: new THREE.Color( 0x000000 ) },
+ "uLineColor3": { type: "c", value: new THREE.Color( 0x000000 ) },
+ "uLineColor4": { type: "c", value: new THREE.Color( 0x000000 ) }
- "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
- "uniform vec3 uLineColor1;",
- "uniform vec3 uLineColor2;",
- "uniform vec3 uLineColor3;",
- "uniform vec3 uLineColor4;",
+ "uniform vec3 uLineColor1;",
+ "uniform vec3 uLineColor2;",
+ "uniform vec3 uLineColor3;",
+ "uniform vec3 uLineColor4;",
- "float camera = max( dot( normalize( vNormal ), vec3( 0.0, 0.0, 1.0 ) ), 0.4);",
- "float light = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);",
+ "float camera = max( dot( normalize( vNormal ), vec3( 0.0, 0.0, 1.0 ) ), 0.4);",
+ "float light = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);",
- "gl_FragColor = vec4( uBaseColor, 1.0 );",
+ "gl_FragColor = vec4( uBaseColor, 1.0 );",
- "if ( length(uAmbientLightColor + uDirLightColor * light) < 1.00 ) {",
+ "if ( length(uAmbientLightColor + uDirLightColor * light) < 1.00 ) {",
- "gl_FragColor *= vec4( uLineColor1, 1.0 );",
+ "gl_FragColor *= vec4( uLineColor1, 1.0 );",
+ "if ( length(uAmbientLightColor + uDirLightColor * camera) < 0.50 ) {",
- "if ( length(uAmbientLightColor + uDirLightColor * camera) < 0.50 ) {",
+ "gl_FragColor *= vec4( uLineColor2, 1.0 );",
- "gl_FragColor *= vec4( uLineColor2, 1.0 );",
+ 'hatching' : {
-'hatching' : {
+ "uBaseColor": { type: "c", value: new THREE.Color( 0xffffff ) },
+ "uLineColor1": { type: "c", value: new THREE.Color( 0x000000 ) },
- "uBaseColor": { type: "c", value: new THREE.Color( 0xffffff ) },
- "uLineColor1": { type: "c", value: new THREE.Color( 0x000000 ) },
+ "float directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);",
- "float directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);",
+ "if ( length(lightWeighting) < 1.00 ) {",
- "if ( length(lightWeighting) < 1.00 ) {",
+ "if ( mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {",
- "if ( mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {",
+ "gl_FragColor = vec4( uLineColor1, 1.0 );",
- "gl_FragColor = vec4( uLineColor1, 1.0 );",
"}",
+ "if ( length(lightWeighting) < 0.75 ) {",
- "if ( length(lightWeighting) < 0.75 ) {",
+ "if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {",
- "if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {",
- "gl_FragColor = vec4( uLineColor2, 1.0 );",
+ "gl_FragColor = vec4( uLineColor2, 1.0 );",
- "if ( length(lightWeighting) < 0.50 ) {",
+ "if ( length(lightWeighting) < 0.50 ) {",
- "if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {",
+ "if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {",
- "gl_FragColor = vec4( uLineColor3, 1.0 );",
+ "gl_FragColor = vec4( uLineColor3, 1.0 );",
- "if ( length(lightWeighting) < 0.3465 ) {",
+ "if ( length(lightWeighting) < 0.3465 ) {",
- "if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {",
+ "if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {",
- "gl_FragColor = vec4( uLineColor4, 1.0 );",
+ "gl_FragColor = vec4( uLineColor4, 1.0 );",
-'dotted' : {
+ 'dotted' : {
- "uLineColor1": { type: "c", value: new THREE.Color( 0x000000 ) }
+ "uLineColor1": { type: "c", value: new THREE.Color( 0x000000 ) }
+ "if ( ( mod(gl_FragCoord.x, 4.001) + mod(gl_FragCoord.y, 4.0) ) > 6.00 ) {",
- "if ( ( mod(gl_FragCoord.x, 4.001) + mod(gl_FragCoord.y, 4.0) ) > 6.00 ) {",
+ "if ( ( mod(gl_FragCoord.x + 2.0, 4.001) + mod(gl_FragCoord.y + 2.0, 4.0) ) > 6.00 ) {",
- "if ( ( mod(gl_FragCoord.x + 2.0, 4.001) + mod(gl_FragCoord.y + 2.0, 4.0) ) > 6.00 ) {",
-}
@@ -10,7 +10,7 @@
-function SimulationRenderer(WIDTH, renderer) {
+function SimulationRenderer( WIDTH, renderer ) {
WIDTH = WIDTH || 4;
var camera = new THREE.Camera();
@@ -19,14 +19,18 @@ function SimulationRenderer(WIDTH, renderer) {
// Init RTT stuff
gl = renderer.getContext();
- if ( !gl.getExtension( "OES_texture_float" )) {
+ if ( ! gl.getExtension( "OES_texture_float" ) ) {
alert( "No OES_texture_float support for float textures!" );
- if ( gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS) == 0) {
+ if ( gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS ) == 0 ) {
alert( "No support for vertex shader textures!" );
var scene = new THREE.Scene();
@@ -77,7 +81,7 @@ function SimulationRenderer(WIDTH, renderer) {
predator: { type: "v3", value: new THREE.Vector3() }
defines: {
- WIDTH: WIDTH.toFixed(2)
+ WIDTH: WIDTH.toFixed( 2 )
vertexShader: document.getElementById( 'vertexShader' ).textContent,
fragmentShader: document.getElementById( 'fragmentShaderVelocity' ).textContent
@@ -92,6 +96,7 @@ function SimulationRenderer(WIDTH, renderer) {
var rtPosition1, rtPosition2, rtVelocity1, rtVelocity2;
function init() {
var dtPosition = generatePositionTexture();
var dtVelocity = generateVelocityTexture();
@@ -100,19 +105,21 @@ function SimulationRenderer(WIDTH, renderer) {
rtVelocity1 = getRenderTarget( THREE.RGBFormat );
rtVelocity2 = rtVelocity1.clone();
- simulator.renderTexture(dtPosition, rtPosition1);
- simulator.renderTexture(rtPosition1, rtPosition2);
+ simulator.renderTexture( dtPosition, rtPosition1 );
+ simulator.renderTexture( rtPosition1, rtPosition2 );
- simulator.renderTexture(dtVelocity, rtVelocity1);
- simulator.renderTexture(rtVelocity1, rtVelocity2);
+ simulator.renderTexture( dtVelocity, rtVelocity1 );
+ simulator.renderTexture( rtVelocity1, rtVelocity2 );
simulator.velocityUniforms.testing.value = 10;
this.init = init;
function getRenderTarget( type ) {
- var renderTarget = new THREE.WebGLRenderTarget(WIDTH, WIDTH, {
+ var renderTarget = new THREE.WebGLRenderTarget( WIDTH, WIDTH, {
wrapS: THREE.RepeatWrapping,
wrapT: THREE.RepeatWrapping,
minFilter: THREE.NearestFilter,
@@ -120,20 +127,24 @@ function SimulationRenderer(WIDTH, renderer) {
format: type,
type: THREE.FloatType,
stencilBuffer: false
return renderTarget;
// Takes a texture, and render out as another texture
this.renderTexture = function ( input, output ) {
mesh.material = passThruShader;
uniforms.texture.value = input;
renderer.render( scene, camera, output );
- this.renderPosition = function(position, velocity, output, delta) {
+ this.renderPosition = function( position, velocity, output, delta ) {
mesh.material = positionShader;
positionShader.uniforms.texturePosition.value = position;
positionShader.uniforms.textureVelocity.value = velocity;
@@ -141,9 +152,11 @@ function SimulationRenderer(WIDTH, renderer) {
positionShader.uniforms.delta.value = delta;
this.currentPosition = output;
- this.renderVelocity = function(position, velocity, output, delta) {
+ this.renderVelocity = function( position, velocity, output, delta ) {
mesh.material = velocityShader;
velocityShader.uniforms.texturePosition.value = position;
velocityShader.uniforms.textureVelocity.value = velocity;
@@ -151,11 +164,12 @@ function SimulationRenderer(WIDTH, renderer) {
velocityShader.uniforms.delta.value = delta;
this.currentVelocity = output;
this.simulate = function( delta ) {
- if (flipflop) {
+ if ( flipflop ) {
simulator.renderVelocity( rtPosition1, rtVelocity1, rtVelocity2, delta );
simulator.renderPosition( rtPosition1, rtVelocity2, rtPosition2, delta );
@@ -167,7 +181,7 @@ function SimulationRenderer(WIDTH, renderer) {
- flipflop = !flipflop;
+ flipflop = ! flipflop;
@@ -14,15 +14,15 @@
* Three.js integration by zz85 http://twitter.com/blurspline
-THREE.ShaderLib['sky'] = {
+THREE.ShaderLib[ 'sky' ] = {
uniforms: {
- luminance: { type: "f", value:1 },
- turbidity: { type: "f", value:2 },
- reileigh: { type: "f", value:1 },
- mieCoefficient: { type: "f", value:0.005 },
- mieDirectionalG: { type: "f", value:0.8 },
+ luminance: { type: "f", value: 1 },
+ turbidity: { type: "f", value: 2 },
+ reileigh: { type: "f", value: 1 },
+ mieCoefficient: { type: "f", value: 0.005 },
+ mieDirectionalG: { type: "f", value: 0.8 },
sunPosition: { type: "v3", value: new THREE.Vector3() }
@@ -40,7 +40,7 @@ THREE.ShaderLib['sky'] = {
@@ -235,7 +235,7 @@ THREE.ShaderLib['sky'] = {
"gl_FragColor.a = 1.0;",
@@ -17,9 +17,9 @@ var SPARKS = {};
* Creates and Manages Particles
*********************************/
-SPARKS.Emitter = function (counter) {
+SPARKS.Emitter = function ( counter ) {
- this._counter = counter ? counter : new SPARKS.SteadyCounter(10); // provides number of particles to produce
+ this._counter = counter ? counter : new SPARKS.SteadyCounter( 10 ); // provides number of particles to produce
this._particles = [];
@@ -31,6 +31,7 @@ SPARKS.Emitter = function (counter) {
this._handlers = [];
this.callbacks = {};
@@ -44,165 +45,207 @@ SPARKS.Emitter.prototype = {
// run its built in timer / stepping
start: function() {
this._lastTime = Date.now();
- this._timer = setTimeout(this.step, this._timerStep, this);
+ this._timer = setTimeout( this.step, this._timerStep, this );
this._isRunning = true;
stop: function() {
this._isRunning = false;
- clearTimeout(this._timer);
+ clearTimeout( this._timer );
isRunning: function() {
return this._isRunning & true;
// Step gets called upon by the engine
// but attempts to call update() on a regular basics
// This method is also described in http://gameclosure.com/2011/04/11/deterministic-delta-tee-in-js-games/
- step: function(emitter) {
+ step: function( emitter ) {
var time = Date.now();
var elapsed = time - emitter._lastTime;
- if (!this._velocityVerlet) {
+ if ( ! this._velocityVerlet ) {
// if elapsed is way higher than time step, (usually after switching tabs, or excution cached in ff)
// we will drop cycles. perhaps set to a limit of 10 or something?
var maxBlock = emitter._TIMESTEP * 20;
- if (elapsed >= maxBlock) {
+ if ( elapsed >= maxBlock ) {
//console.log('warning: sparks.js is fast fowarding engine, skipping steps', elapsed / emitter._TIMESTEP);
//emitter.update( (elapsed - maxBlock) / 1000);
elapsed = maxBlock;
- while (elapsed >= emitter._TIMESTEP) {
- emitter.update(emitter._TIMESTEP / 1000);
+ while ( elapsed >= emitter._TIMESTEP ) {
+ emitter.update( emitter._TIMESTEP / 1000 );
elapsed -= emitter._TIMESTEP;
emitter._lastTime = time - elapsed;
- emitter.update(elapsed / 1000);
+ emitter.update( elapsed / 1000 );
emitter._lastTime = time;
- if (emitter._isRunning)
- setTimeout(emitter.step, emitter._timerStep, emitter);
+ if ( emitter._isRunning )
+ setTimeout( emitter.step, emitter._timerStep, emitter );
// Update particle engine in seconds, not milliseconds
- update: function(time) {
+ update: function( time ) {
- var i, j;
- var len = this._counter.updateEmitter( this, time );
+ var i, j;
+ var len = this._counter.updateEmitter( this, time );
- // Create particles
- for ( i = 0; i < len; i ++ ) {
- this.createParticle();
+ // Create particles
+ for ( i = 0; i < len; i ++ ) {
- // Update activities
- len = this._activities.length;
- for ( i = 0; i < len; i ++ )
- this._activities[i].update( this, time );
+ this.createParticle();
- len = this._actions.length;
+ // Update activities
+ len = this._activities.length;
- var particle;
- var action;
- var len2 = this._particles.length;
+ this._activities[ i ].update( this, time );
- for ( j = 0; j < len; j ++ )
- action = this._actions[j];
- for ( i = 0; i < len2; ++ i )
- particle = this._particles[i];
- action.update( this, particle, time );
- // remove dead particles
- for ( i = len2; i --; )
- if ( particle.isDead )
- //particle =
- this._particles.splice( i, 1 );
- this.dispatchEvent("dead", particle);
- SPARKS.VectorPool.release(particle.position); //
- SPARKS.VectorPool.release(particle.velocity);
+ len = this._actions.length;
+ var particle;
+ var action;
+ var len2 = this._particles.length;
+ for ( j = 0; j < len; j ++ ) {
+ action = this._actions[ j ];
+ for ( i = 0; i < len2; ++ i ) {
+ particle = this._particles[ i ];
+ action.update( this, particle, time );
- } else {
- this.dispatchEvent("updated", particle);
- this.dispatchEvent("loopUpdated");
+ // remove dead particles
+ for ( i = len2; i --; ) {
- createParticle: function() {
- var particle = new SPARKS.Particle();
- // In future, use a Particle Factory
- var len = this._initializers.length, i;
+ if ( particle.isDead ) {
- this._initializers[i].initialize( this, particle );
+ //particle =
+ this._particles.splice( i, 1 );
+ this.dispatchEvent( "dead", particle );
+ SPARKS.VectorPool.release( particle.position ); //
+ SPARKS.VectorPool.release( particle.velocity );
- this._particles.push( particle );
- this.dispatchEvent("created", particle); // ParticleCreated
+ this.dispatchEvent( "updated", particle );
- return particle;
- addInitializer: function (initializer) {
- this._initializers.push(initializer);
- addAction: function (action) {
- this._actions.push(action);
+ this.dispatchEvent( "loopUpdated" );
- removeInitializer: function (initializer) {
- var index = this._initializers.indexOf(initializer);
- if (index > -1) {
- this._initializers.splice( index, 1 );
- removeAction: function (action) {
- var index = this._actions.indexOf(action);
- this._actions.splice( index, 1 );
+ createParticle: function() {
+ var particle = new SPARKS.Particle();
+ // In future, use a Particle Factory
+ var len = this._initializers.length, i;
+ this._initializers[ i ].initialize( this, particle );
+ this._particles.push( particle );
+ this.dispatchEvent( "created", particle ); // ParticleCreated
+ return particle;
+ addInitializer: function ( initializer ) {
+ this._initializers.push( initializer );
+ addAction: function ( action ) {
+ this._actions.push( action );
+ removeInitializer: function ( initializer ) {
+ var index = this._initializers.indexOf( initializer );
+ if ( index > - 1 ) {
+ this._initializers.splice( index, 1 );
+ removeAction: function ( action ) {
+ var index = this._actions.indexOf( action );
+ this._actions.splice( index, 1 );
//console.log('removeAction', index, this._actions);
- addCallback: function(name, callback) {
- this.callbacks[name] = callback;
+ addCallback: function( name, callback ) {
- dispatchEvent: function(name, args) {
- var callback = this.callbacks[name];
- if (callback) {
- callback(args);
+ this.callbacks[ name ] = callback;
+ dispatchEvent: function( name, args ) {
+ var callback = this.callbacks[ name ];
+ if ( callback ) {
+ callback( args );
@@ -226,7 +269,8 @@ SPARKS.EVENT_LOOP_UPDATED = "loopUpdated";
// Number of particles per seconds
-SPARKS.SteadyCounter = function(rate) {
+SPARKS.SteadyCounter = function( rate ) {
this.rate = rate;
// we use a shortfall counter to make up for slow emitters
@@ -234,14 +278,15 @@ SPARKS.SteadyCounter = function(rate) {
-SPARKS.SteadyCounter.prototype.updateEmitter = function(emitter, time) {
+SPARKS.SteadyCounter.prototype.updateEmitter = function( emitter, time ) {
var targetRelease = time * this.rate + this.leftover;
- var actualRelease = Math.floor(targetRelease);
+ var actualRelease = Math.floor( targetRelease );
this.leftover = targetRelease - actualRelease;
return actualRelease;
@@ -250,20 +295,27 @@ SPARKS.SteadyCounter.prototype.updateEmitter = function(emitter, time) {
* on a single impluse or burst
-SPARKS.ShotCounter = function(particles) {
+SPARKS.ShotCounter = function( particles ) {
this.used = false;
-SPARKS.ShotCounter.prototype.updateEmitter = function(emitter, time) {
+SPARKS.ShotCounter.prototype.updateEmitter = function( emitter, time ) {
+ if ( this.used ) {
- if (this.used) {
return 0;
this.used = true;
return this.particles;
@@ -274,38 +326,38 @@ SPARKS.ShotCounter.prototype.updateEmitter = function(emitter, time) {
SPARKS.Particle = function() {
- /**
- * The lifetime of the particle, in seconds.
- */
+ /**
+ * The lifetime of the particle, in seconds.
+ */
this.lifetime = 0;
- * The age of the particle, in seconds.
+ * The age of the particle, in seconds.
this.age = 0;
- * The energy of the particle.
+ * The energy of the particle.
this.energy = 1;
- * Whether the particle is dead and should be removed from the stage.
+ * Whether the particle is dead and should be removed from the stage.
this.isDead = false;
this.target = null; // tag
- * For 3D
- this.position = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
- this.velocity = SPARKS.VectorPool.get().set(0, 0, 0); //new THREE.Vector3( 0, 0, 0 );
- this._oldvelocity = SPARKS.VectorPool.get().set(0, 0, 0);
- // rotation vec3
- // angVelocity vec3
- // faceAxis vec3
+ * For 3D
+ this.position = SPARKS.VectorPool.get().set( 0, 0, 0 ); //new THREE.Vector3( 0, 0, 0 );
+ this.velocity = SPARKS.VectorPool.get().set( 0, 0, 0 ); //new THREE.Vector3( 0, 0, 0 );
+ this._oldvelocity = SPARKS.VectorPool.get().set( 0, 0, 0 );
+ // rotation vec3
+ // angVelocity vec3
+ // faceAxis vec3
@@ -317,26 +369,33 @@ SPARKS.Particle = function() {
* update function
SPARKS.Action = function() {
this._priority = 0;
-SPARKS.Age = function(easing) {
- this._easing = (easing == null) ? TWEEN.Easing.Linear.None : easing;
+SPARKS.Age = function( easing ) {
+ this._easing = ( easing == null ) ? TWEEN.Easing.Linear.None : easing;
-SPARKS.Age.prototype.update = function (emitter, particle, time) {
+SPARKS.Age.prototype.update = function ( emitter, particle, time ) {
particle.age += time;
- if ( particle.age >= particle.lifetime )
+ if ( particle.age >= particle.lifetime ) {
particle.energy = 0;
particle.isDead = true;
+ var t = this._easing( particle.age / particle.lifetime );
+ particle.energy = - 1 * t + 1;
- else
- var t = this._easing(particle.age / particle.lifetime);
- particle.energy = -1 * t + 1;
/*
@@ -358,39 +417,48 @@ SPARKS.Move = function() {
-SPARKS.Move.prototype.update = function(emitter, particle, time) {
- // attempt verlet velocity updating.
+SPARKS.Move.prototype.update = function( emitter, particle, time ) {
+ // attempt verlet velocity updating.
var p = particle.position;
var v = particle.velocity;
var old = particle._oldvelocity;
- if (this._velocityVerlet) {
- p.x += (v.x + old.x) * 0.5 * time;
- p.y += (v.y + old.y) * 0.5 * time;
- p.z += (v.z + old.z) * 0.5 * time;
+ if ( this._velocityVerlet ) {
+ p.x += ( v.x + old.x ) * 0.5 * time;
+ p.y += ( v.y + old.y ) * 0.5 * time;
+ p.z += ( v.z + old.z ) * 0.5 * time;
p.x += v.x * time;
p.y += v.y * time;
p.z += v.z * time;
- // OldVel = Vel;
- // Vel = Vel + Accel * dt;
- // Pos = Pos + (vel + Vel + Accel * dt) * 0.5 * dt;
+ // OldVel = Vel;
+ // Vel = Vel + Accel * dt;
+ // Pos = Pos + (vel + Vel + Accel * dt) * 0.5 * dt;
/* Marks particles found in specified zone dead */
-SPARKS.DeathZone = function(zone) {
+SPARKS.DeathZone = function( zone ) {
this.zone = zone;
-SPARKS.DeathZone.prototype.update = function(emitter, particle, time) {
+SPARKS.DeathZone.prototype.update = function( emitter, particle, time ) {
+ if ( this.zone.contains( particle.position ) ) {
- if (this.zone.contains(particle.position)) {
@@ -398,15 +466,19 @@ SPARKS.DeathZone.prototype.update = function(emitter, particle, time) {
* SPARKS.ActionZone applies an action when particle is found in zone
-SPARKS.ActionZone = function(action, zone) {
+SPARKS.ActionZone = function( action, zone ) {
this.action = action;
-SPARKS.ActionZone.prototype.update = function(emitter, particle, time) {
+SPARKS.ActionZone.prototype.update = function( emitter, particle, time ) {
this.action.update( emitter, particle, time );
@@ -414,23 +486,26 @@ SPARKS.ActionZone.prototype.update = function(emitter, particle, time) {
* Accelerate action affects velocity in specified 3d direction
-SPARKS.Accelerate = function(x,y,z) {
+SPARKS.Accelerate = function( x, y, z ) {
+ if ( x instanceof THREE.Vector3 ) {
- if (x instanceof THREE.Vector3) {
this.acceleration = x;
- this.acceleration = new THREE.Vector3(x,y,z);
+ this.acceleration = new THREE.Vector3( x, y, z );
-SPARKS.Accelerate.prototype.update = function(emitter, particle, time) {
+SPARKS.Accelerate.prototype.update = function( emitter, particle, time ) {
var acc = this.acceleration;
- particle._oldvelocity.set(v.x, v.y, v.z);
+ particle._oldvelocity.set( v.x, v.y, v.z );
v.x += acc.x * time;
v.y += acc.y * time;
@@ -441,25 +516,29 @@ SPARKS.Accelerate.prototype.update = function(emitter, particle, time) {
* Accelerate Factor accelerate based on a factor of particle's velocity.
-SPARKS.AccelerateFactor = function(factor) {
+SPARKS.AccelerateFactor = function( factor ) {
this.factor = factor;
-SPARKS.AccelerateFactor.prototype.update = function(emitter, particle, time) {
+SPARKS.AccelerateFactor.prototype.update = function( emitter, particle, time ) {
var factor = this.factor;
var len = v.length();
var adjFactor;
- if (len > 0) {
+ if ( len > 0 ) {
adjFactor = factor * time / len;
adjFactor += 1;
- v.multiplyScalar(adjFactor);
+ v.multiplyScalar( adjFactor );
// v.x *= adjFactor;
// v.y *= adjFactor;
// v.z *= adjFactor;
@@ -468,13 +547,14 @@ SPARKS.AccelerateFactor.prototype.update = function(emitter, particle, time) {
AccelerateNormal
* AccelerateVelocity affects velocity based on its velocity direction
-SPARKS.AccelerateVelocity = function(factor) {
+SPARKS.AccelerateVelocity = function( factor ) {
-SPARKS.AccelerateVelocity.prototype.update = function(emitter, particle, time) {
+SPARKS.AccelerateVelocity.prototype.update = function( emitter, particle, time ) {
@@ -488,17 +568,22 @@ SPARKS.AccelerateVelocity.prototype.update = function(emitter, particle, time) {
/* Set the max ammount of x,y,z drift movements in a second */
-SPARKS.RandomDrift = function(x,y,z) {
+SPARKS.RandomDrift = function( x, y, z ) {
this.drift = x;
- this.drift = new THREE.Vector3(x,y,z);
+ this.drift = new THREE.Vector3( x, y, z );
-SPARKS.RandomDrift.prototype.update = function(emitter, particle, time) {
+SPARKS.RandomDrift.prototype.update = function( emitter, particle, time ) {
var drift = this.drift;
@@ -520,29 +605,40 @@ SPARKS.Zone = function() {
// TODO, contains() for Zone
-SPARKS.PointZone = function(pos) {
+SPARKS.PointZone = function( pos ) {
this.pos = pos;
SPARKS.PointZone.prototype.getLocation = function() {
return this.pos;
-SPARKS.LineZone = function(start, end) {
+SPARKS.LineZone = function( start, end ) {
this.start = start;
this.end = end;
this._length = end.clone().sub( start );
SPARKS.LineZone.prototype.getLocation = function() {
var len = this._length.clone();
len.multiplyScalar( Math.random() );
@@ -551,30 +647,35 @@ SPARKS.LineZone.prototype.getLocation = function() {
// Basically a RectangleZone
-SPARKS.ParallelogramZone = function(corner, side1, side2) {
+SPARKS.ParallelogramZone = function( corner, side1, side2 ) {
this.corner = corner;
this.side1 = side1;
this.side2 = side2;
SPARKS.ParallelogramZone.prototype.getLocation = function() {
var d1 = this.side1.clone().multiplyScalar( Math.random() );
var d2 = this.side2.clone().multiplyScalar( Math.random() );
- d1.add(d2);
+ d1.add( d2 );
return d1.add( this.corner );
-SPARKS.CubeZone = function(position, x, y, z) {
+SPARKS.CubeZone = function( position, x, y, z ) {
this.position = position;
this.x = x;
this.y = y;
this.z = z;
SPARKS.CubeZone.prototype.getLocation = function() {
- //TODO use pool?
+ //TODO use pool?
var location = this.position.clone();
location.x += Math.random() * this.x;
@@ -586,7 +687,7 @@ SPARKS.CubeZone.prototype.getLocation = function() {
-SPARKS.CubeZone.prototype.contains = function(position) {
+SPARKS.CubeZone.prototype.contains = function( position ) {
var startX = this.position.x;
var startY = this.position.y;
@@ -595,29 +696,37 @@ SPARKS.CubeZone.prototype.contains = function(position) {
var y = this.y; // depth
var z = this.z; // height
- if (x < 0) {
+ if ( x < 0 ) {
startX += x;
- x = Math.abs(x);
+ x = Math.abs( x );
- if (y < 0) {
+ if ( y < 0 ) {
startY += y;
- y = Math.abs(y);
+ y = Math.abs( y );
- if (z < 0) {
+ if ( z < 0 ) {
startZ += z;
- z = Math.abs(z);
+ z = Math.abs( z );
var diffX = position.x - startX;
var diffY = position.y - startY;
var diffZ = position.z - startZ;
- if ( (diffX > 0) && (diffX < x) &&
- (diffY > 0) && (diffY < y) &&
- (diffZ > 0) && (diffZ < z) ) {
+ if ( ( diffX > 0 ) && ( diffX < x ) &&
+ ( diffY > 0 ) && ( diffY < y ) &&
+ ( diffZ > 0 ) && ( diffZ < z ) ) {
@@ -673,30 +782,34 @@ SPARKS.DiscZone.prototype.getLocation = function() {
-SPARKS.SphereCapZone = function(x, y, z, minr, maxr, angle) {
+SPARKS.SphereCapZone = function( x, y, z, minr, maxr, angle ) {
this.minr = minr;
this.maxr = maxr;
this.angle = angle;
SPARKS.SphereCapZone.prototype.getLocation = function() {
var theta = Math.PI * 2 * SPARKS.Utils.random();
var r = SPARKS.Utils.random();
- //new THREE.Vector3
- var v = SPARKS.VectorPool.get().set(r * Math.cos(theta), -1 / Math.tan(this.angle * SPARKS.Utils.DEGREE_TO_RADIAN), r * Math.sin(theta));
+ //new THREE.Vector3
+ var v = SPARKS.VectorPool.get().set( r * Math.cos( theta ), - 1 / Math.tan( this.angle * SPARKS.Utils.DEGREE_TO_RADIAN ), r * Math.sin( theta ) );
- //v.length = StardustMath.interpolate(0, _minRadius, 1, _maxRadius, Math.random());
+ //v.length = StardustMath.interpolate(0, _minRadius, 1, _maxRadius, Math.random());
- var i = this.minr - ((this.minr - this.maxr) * Math.random() );
- v.multiplyScalar(i);
+ var i = this.minr - ( ( this.minr - this.maxr ) * Math.random() );
+ v.multiplyScalar( i );
v.__markedForReleased = true;
return v;
@@ -708,7 +821,8 @@ SPARKS.SphereCapZone.prototype.getLocation = function() {
// Specifies random life between max and min
-SPARKS.Lifetime = function(min, max) {
+SPARKS.Lifetime = function( min, max ) {
this._min = min;
this._max = max ? max : min;
@@ -716,44 +830,62 @@ SPARKS.Lifetime = function(min, max) {
SPARKS.Lifetime.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
particle.lifetime = this._min + SPARKS.Utils.random() * ( this._max - this._min );
-SPARKS.Position = function(zone) {
+SPARKS.Position = function( zone ) {
SPARKS.Position.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
var pos = this.zone.getLocation();
- particle.position.set(pos.x, pos.y, pos.z);
+ particle.position.set( pos.x, pos.y, pos.z );
-SPARKS.Velocity = function(zone) {
+SPARKS.Velocity = function( zone ) {
SPARKS.Velocity.prototype.initialize = function( emitter/*Emitter*/, particle/*Particle*/ ) {
- particle.velocity.set(pos.x, pos.y, pos.z);
- if (pos.__markedForReleased) {
+ particle.velocity.set( pos.x, pos.y, pos.z );
+ if ( pos.__markedForReleased ) {
//console.log("release");
- SPARKS.VectorPool.release(pos);
+ SPARKS.VectorPool.release( pos );
pos.__markedForReleased = false;
-SPARKS.Target = function(target, callback) {
+SPARKS.Target = function( target, callback ) {
this.target = target;
this.callback = callback;
SPARKS.Target.prototype.initialize = function( emitter, particle ) {
- if (this.callback) {
+ if ( this.callback ) {
particle.target = this.callback();
particle.target = this.target;
@@ -769,8 +901,11 @@ SPARKS.VectorPool = {
// Get a new Vector
get: function() {
- if (this.__pools.length > 0) {
+ if ( this.__pools.length > 0 ) {
return this.__pools.pop();
return this._addToPool();
@@ -778,16 +913,21 @@ SPARKS.VectorPool = {
// Release a vector back into the pool
- release: function(v) {
- this.__pools.push(v);
+ release: function( v ) {
+ this.__pools.push( v );
// Create a bunch of vectors and add to the pool
_addToPool: function() {
//console.log("creating some pools");
- for (var i = 0, size = 100; i < size; i ++) {
- this.__pools.push(new THREE.Vector3());
+ for ( var i = 0, size = 100; i < size; i ++ ) {
+ this.__pools.push( new THREE.Vector3() );
return new THREE.Vector3();
@@ -806,30 +946,36 @@ SPARKS.VectorPool = {
* particles. Implements initialize( emitter:Emitter, particle:Particle )
SPARKS.Utils = {
- random: function() {
- return Math.random();
- DEGREE_TO_RADIAN: Math.PI / 180,
+ random: function() {
+ return Math.random();
+ DEGREE_TO_RADIAN: Math.PI / 180,
TWOPI: Math.PI * 2,
- getPerpendiculars: function(normal) {
+ getPerpendiculars: function( normal ) {
var p1 = this.getPerpendicular( normal );
var p2 = normal.cross( p1 );
p2.normalize();
return [ p1, p2 ];
- getPerpendicular: function( v )
- if ( v.x == 0 )
+ getPerpendicular: function( v ) {
+ if ( v.x == 0 ) {
return new THREE.Vector3D( 1, 0, 0 );
- var temp = new THREE.Vector3( v.y, -v.x, 0 );
+ var temp = new THREE.Vector3( v.y, - v.x, 0 );
return temp.normalize();
@@ -21,7 +21,7 @@ THREE.TypedArrayUtils = {};
THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
var stack = [];
- var sp = -1;
+ var sp = - 1;
var left = 0;
var right = arr.length / eleSize - 1;
var tmp = 0.0, x = 0, y = 0;
@@ -56,7 +56,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
i = j - 1;
- while ( i >= left && arr[ i * eleSize + orderElement ] > swap[orderElement ] ) {
+ while ( i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ] ) {
for ( x = 0; x < eleSize; x ++ ) {
@@ -76,7 +76,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
- if ( sp == -1 ) break;
+ if ( sp == - 1 ) break;
right = stack[ sp -- ]; //?
left = stack[ sp -- ];
@@ -215,7 +215,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
median = Math.floor( plength / 2 );
node = new self.Node( getPointSet( points, median ), depth, parent, median + pos );
- node.left = buildTree( points.subarray( 0, median * eleSize), depth + 1, node, pos );
+ node.left = buildTree( points.subarray( 0, median * eleSize ), depth + 1, node, pos );
node.right = buildTree( points.subarray( ( median + 1 ) * eleSize, points.length ), depth + 1, node, pos + median + 1 );
return node;
@@ -224,7 +224,11 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
this.root = buildTree( points, 0, null, 0 );
- this.getMaxDepth = function () { return maxDepth; };
+ this.getMaxDepth = function () {
+ return maxDepth;
this.nearest = function ( point, maxNodes, maxDistance ) {
@@ -240,15 +244,19 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
bestNodes = new THREE.TypedArrayUtils.Kdtree.BinaryHeap(
- function ( e ) { return -e[ 1 ]; }
+ function ( e ) {
- );
+ return - e[ 1 ];
+ );
function nearestSearch( node ) {
var bestChild,
dimension = node.depth % eleSize,
- ownDistance = metric(point, node.obj),
+ ownDistance = metric( point, node.obj ),
linearDistance = 0,
otherChild,
i,
@@ -330,7 +338,7 @@ THREE.TypedArrayUtils.quicksortIP = function ( arr, eleSize, orderElement ) {
// if there's still room or the current distance is nearer than the best distance
- if ( bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ] ) {
+ if ( bestNodes.size() < maxNodes || Math.abs( linearDistance ) < bestNodes.peek()[ 1 ] ) {
if ( bestChild === node.left ) {
@@ -591,4 +599,4 @@ THREE.TypedArrayUtils.Kdtree.BinaryHeap.prototype = {
-};
+};
@@ -38,6 +38,7 @@ THREE.UCSCharacter = function() {
console.log( config.baseUrl + config.character );
loader.load( config.baseUrl + config.character, function( geometry ) {
geometry.computeBoundingBox();
geometry.computeVertexNormals();
@@ -56,28 +57,40 @@ THREE.UCSCharacter = function() {
animation = new THREE.Animation( mesh, geometry.animation );
animation.play();
- scope.setSkin(0);
+ scope.setSkin( 0 );
scope.checkLoadComplete();
} );
this.setSkin = function( index ) {
if ( mesh && scope.materials ) {
mesh.material = scope.materials[ index ];
this.updateMorphs = function( influences ) {
if ( mesh ) {
for ( var i = 0; i < scope.numMorphs; i ++ ) {
mesh.morphTargetInfluences[ i ] = influences[ scope.morphs[ i ] ] / 100;
function loadTextures( baseUrl, textureUrls ) {
var mapping = THREE.UVMapping;
var textures = [];
@@ -89,9 +102,11 @@ THREE.UCSCharacter = function() {
return textures;
function createMaterials( skins ) {
var materials = [];
for ( var i = 0; i < skins.length; i ++ ) {
@@ -107,6 +122,7 @@ THREE.UCSCharacter = function() {
return materials;
this.checkLoadComplete = function () {
@@ -7,7 +7,7 @@
* @author Jonas Wagner / http://29a.ch/ && http://29a.ch/slides/2012/webglwater/ : Water shader explanations in WebGL
-THREE.ShaderLib['water'] = {
+THREE.ShaderLib[ 'water' ] = {
uniforms: { "normalSampler": { type: "t", value: null },
@@ -35,7 +35,7 @@ THREE.ShaderLib['water'] = {
' mirrorCoord = textureMatrix * mirrorCoord;',
' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
'}'
- ].join('\n'),
+ ].join( '\n' ),
'precision highp float;',
@@ -98,7 +98,7 @@ THREE.ShaderLib['water'] = {
' vec3 albedo = mix( sunColor * diffuseLight * 0.3 + scatter, ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance );',
' gl_FragColor = vec4( albedo, alpha );',
- ].join('\n')
+ ].join( '\n' )
@@ -108,7 +108,9 @@ THREE.Water = function ( renderer, camera, scene, options ) {
this.name = 'water_' + this.id;
function optionalParameter ( value, defaultValue ) {
@@ -134,15 +136,16 @@ THREE.Water = function ( renderer, camera, scene, options ) {
- this.lookAtPosition = new THREE.Vector3( 0, 0, -1 );
if ( camera instanceof THREE.PerspectiveCamera )
this.camera = camera;
+ else {
this.camera = new THREE.PerspectiveCamera();
- console.log(this.name + ': camera is not a Perspective Camera!')
+ console.log( this.name + ': camera is not a Perspective Camera!' )
this.textureMatrix = new THREE.Matrix4();
@@ -174,16 +177,18 @@ THREE.Water = function ( renderer, camera, scene, options ) {
this.material.uniforms.eye.value = this.eye;
- if ( !THREE.Math.isPowerOfTwo(width) || !THREE.Math.isPowerOfTwo(height) )
this.texture.minFilter = THREE.LinearFilter;
this.tempTexture.minFilter = THREE.LinearFilter;
this.updateTextureMatrix();
this.render();
THREE.Water.prototype = Object.create( THREE.Mirror.prototype );
@@ -192,7 +197,11 @@ THREE.Water.prototype.constructor = THREE.Water;
THREE.Water.prototype.updateTextureMatrix = function () {
- function sign(x) { return x ? x < 0 ? -1 : 1 : 0; }
+ function sign( x ) {
+ return x ? x < 0 ? - 1 : 1 : 0;
this.updateMatrixWorld();
this.camera.updateMatrixWorld();
@@ -211,7 +220,7 @@ THREE.Water.prototype.updateTextureMatrix = function () {
@@ -219,7 +228,7 @@ THREE.Water.prototype.updateTextureMatrix = function () {
- this.up.set(0, -1, 0);
@@ -230,43 +239,44 @@ THREE.Water.prototype.updateTextureMatrix = function () {
this.mirrorCamera.updateProjectionMatrix();
this.mirrorCamera.updateMatrixWorld();
- this.mirrorCamera.matrixWorldInverse.getInverse(this.mirrorCamera.matrixWorld);
+ this.mirrorCamera.matrixWorldInverse.getInverse( this.mirrorCamera.matrixWorld );
// Update the texture matrix
this.textureMatrix.set( 0.5, 0.0, 0.0, 0.5,
0.0, 0.5, 0.0, 0.5,
0.0, 0.0, 0.5, 0.5,
0.0, 0.0, 0.0, 1.0 );
- this.textureMatrix.multiply(this.mirrorCamera.projectionMatrix);
- this.textureMatrix.multiply(this.mirrorCamera.matrixWorldInverse);
+ this.textureMatrix.multiply( this.mirrorCamera.projectionMatrix );
+ this.textureMatrix.multiply( this.mirrorCamera.matrixWorldInverse );
// Now update projection matrix with new clip plane, implementing code from: http://www.terathon.com/code/oblique.html
// Paper explaining this technique: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf
this.mirrorPlane.setFromNormalAndCoplanarPoint( this.normal, this.mirrorWorldPosition );
- this.mirrorPlane.applyMatrix4(this.mirrorCamera.matrixWorldInverse);
+ this.mirrorPlane.applyMatrix4( this.mirrorCamera.matrixWorldInverse );
- this.clipPlane.set(this.mirrorPlane.normal.x, this.mirrorPlane.normal.y, this.mirrorPlane.normal.z, this.mirrorPlane.constant );
+ this.clipPlane.set( this.mirrorPlane.normal.x, this.mirrorPlane.normal.y, this.mirrorPlane.normal.z, this.mirrorPlane.constant );
- q.x = (sign(this.clipPlane.x) + projectionMatrix.elements[8]) / projectionMatrix.elements[0];
- q.y = (sign(this.clipPlane.y) + projectionMatrix.elements[9]) / projectionMatrix.elements[5];
- q.z = -1.0;
- q.w = (1.0 + projectionMatrix.elements[10]) / projectionMatrix.elements[14];
+ q.x = ( sign( this.clipPlane.x ) + projectionMatrix.elements[ 8 ] ) / projectionMatrix.elements[ 0 ];
+ q.y = ( sign( this.clipPlane.y ) + projectionMatrix.elements[ 9 ] ) / projectionMatrix.elements[ 5 ];
+ q.z = - 1.0;
var worldCoordinates = new THREE.Vector3();
worldCoordinates.setFromMatrixPosition( this.camera.matrixWorld );
this.eye = worldCoordinates;
@@ -15,10 +15,10 @@ THREE.CombinedCamera = function ( width, height, fov, near, far, orthoNear, orth
this.fov = fov;
- this.left = -width / 2;
+ this.left = - width / 2;
this.right = width / 2;
this.top = height / 2;
- this.bottom = -height / 2;
+ this.bottom = - height / 2;
// We could also handle the projectionMatrix internally, but just wanted to test nested camera objects
@@ -73,10 +73,10 @@ THREE.CombinedCamera.prototype.toOrthographic = function () {
halfHeight /= this.zoom;
halfWidth /= this.zoom;
- this.cameraO.left = -halfWidth;
+ this.cameraO.left = - halfWidth;
this.cameraO.right = halfWidth;
this.cameraO.top = halfHeight;
- this.cameraO.bottom = -halfHeight;
+ this.cameraO.bottom = - halfHeight;
// this.cameraO.left = -farHalfWidth;
// this.cameraO.right = farHalfWidth;
@@ -103,10 +103,10 @@ THREE.CombinedCamera.prototype.toOrthographic = function () {
THREE.CombinedCamera.prototype.setSize = function( width, height ) {
this.cameraP.aspect = width / height;
@@ -158,6 +158,7 @@ THREE.CombinedCamera.prototype.setLens = function ( focalLength, frameHeight ) {
this.setFov( fov );
return fov;
@@ -25,7 +25,7 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
var me = this;
this.on = function( event, handler ) {
- if ( !_listeners[ event ] ) _listeners[ event ] = [];
+ if ( ! _listeners[ event ] ) _listeners[ event ] = [];
_listeners[ event ].push( handler );
return me;
@@ -35,9 +35,9 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
this.off = function( event, handler ) {
var l = _listeners[ event ];
- if ( !l ) return me;
+ if ( ! l ) return me;
- if ( l.indexOf( handler ) > -1 ) {
+ if ( l.indexOf( handler ) > - 1 ) {
l.splice( handler, 1 );
@@ -50,9 +50,9 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
var notify = function( event, data, member ) {
- if ( !l ) return;
+ if ( ! l ) return;
- if ( !member ) {
+ if ( ! member ) {
for ( var i = 0; i < l.length; i ++ ) {
@@ -103,7 +103,7 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
event.preventDefault();
_mouse.x = ( event.clientX / _domElement.width ) * 2 - 1;
- _mouse.y = -( event.clientY / _domElement.height ) * 2 + 1;
+ _mouse.y = - ( event.clientY / _domElement.height ) * 2 + 1;
_raycaster.setFromCamera( _mouse, _camera );
var ray = _raycaster.ray;
@@ -118,6 +118,7 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
var denom = normal.dot( ray.direction );
if ( denom == 0 ) {
// bail
console.log( 'no or infinite solutions' );
@@ -188,7 +189,7 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
var intersects = _raycaster.intersectObjects( _objects );
@@ -19,7 +19,7 @@ THREE.EditorControls = function ( object, domElement ) {
var scope = this;
var vector = new THREE.Vector3();
- var STATE = { NONE: -1, ROTATE: 0, ZOOM: 1, PAN: 2 };
+ var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2 };
var state = STATE.NONE;
var center = this.center;
@@ -39,7 +39,7 @@ THREE.EditorControls = function ( object, domElement ) {
if ( frame && target.geometry ) {
scale = ( scale.x + scale.y + scale.z ) / 3;
- center.add(target.geometry.boundingSphere.center.clone().multiplyScalar( scale ));
+ center.add( target.geometry.boundingSphere.center.clone().multiplyScalar( scale ) );
var radius = target.geometry.boundingSphere.radius * ( scale );
var pos = object.position.clone().sub( center ).normalize().multiplyScalar( radius * 2 );
object.position.copy( center ).add( pos );
@@ -185,11 +185,15 @@ THREE.EditorControls = function ( object, domElement ) {
var delta = 0;
- if ( event.wheelDelta ) { // WebKit / Opera / Explorer 9
+ if ( event.wheelDelta ) {
+ // WebKit / Opera / Explorer 9
delta = - event.wheelDelta;
- } else if ( event.detail ) { // Firefox
+ } else if ( event.detail ) {
+ // Firefox
delta = event.detail * 10;
@@ -199,7 +203,11 @@ THREE.EditorControls = function ( object, domElement ) {
- domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
+ domElement.addEventListener( 'contextmenu', function ( event ) {
+ event.preventDefault();
+ }, false );
domElement.addEventListener( 'mousedown', onMouseDown, false );
domElement.addEventListener( 'mousewheel', onMouseWheel, false );
domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox
@@ -250,7 +258,9 @@ THREE.EditorControls = function ( object, domElement ) {
var closest = touches[ 0 ];
for ( var i in touches ) {
- if ( closest.distanceTo(touch) > touches[ i ].distanceTo(touch) ) closest = touches[ i ];
+ if ( closest.distanceTo( touch ) > touches[ i ].distanceTo( touch ) ) closest = touches[ i ];
return closest;
@@ -275,8 +285,8 @@ THREE.EditorControls = function ( object, domElement ) {
var offset0 = touches[ 0 ].clone().sub( getClosest( touches[ 0 ], prevTouches ) );
var offset1 = touches[ 1 ].clone().sub( getClosest( touches[ 1 ], prevTouches ) );
- offset0.x = -offset0.x;
- offset1.x = -offset1.x;
+ offset0.x = - offset0.x;
+ offset1.x = - offset1.x;
scope.pan( offset0.add( offset1 ).multiplyScalar( 0.5 ) );
@@ -52,7 +52,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
if ( this.domElement !== document ) {
- this.domElement.setAttribute( 'tabindex', -1 );
+ this.domElement.setAttribute( 'tabindex', - 1 );
@@ -203,7 +203,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
var actualMoveSpeed = delta * this.movementSpeed;
- if ( this.moveForward || ( this.autoForward && !this.moveBackward ) ) this.object.translateZ( - ( actualMoveSpeed + this.autoSpeedFactor ) );
+ if ( this.moveForward || ( this.autoForward && ! this.moveBackward ) ) this.object.translateZ( - ( actualMoveSpeed + this.autoSpeedFactor ) );
if ( this.moveBackward ) this.object.translateZ( actualMoveSpeed );
if ( this.moveLeft ) this.object.translateX( - actualMoveSpeed );
@@ -214,7 +214,7 @@ THREE.FirstPersonControls = function ( object, domElement ) {
var actualLookSpeed = delta * this.lookSpeed;
- if ( !this.activeLook ) {
+ if ( ! this.activeLook ) {
actualLookSpeed = 0;
@@ -254,7 +254,11 @@ THREE.FirstPersonControls = function ( object, domElement ) {
- this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
+ this.domElement.addEventListener( 'contextmenu', function ( event ) {
this.domElement.addEventListener( 'mousemove', bind( this, this.onMouseMove ), false );
this.domElement.addEventListener( 'mousedown', bind( this, this.onMouseDown ), false );
@@ -7,7 +7,7 @@ THREE.FlyControls = function ( object, domElement ) {
this.object = object;
this.domElement = ( domElement !== undefined ) ? domElement : document;
- if ( domElement ) this.domElement.setAttribute( 'tabindex', -1 );
+ if ( domElement ) this.domElement.setAttribute( 'tabindex', - 1 );
// API
@@ -141,7 +141,7 @@ THREE.FlyControls = function ( object, domElement ) {
this.mousemove = function( event ) {
- if ( !this.dragToLook || this.mouseStatus > 0 ) {
+ if ( ! this.dragToLook || this.mouseStatus > 0 ) {
var container = this.getContainerDimensions();
var halfWidth = container.size[ 0 ] / 2;
@@ -204,11 +204,11 @@ THREE.FlyControls = function ( object, domElement ) {
this.updateMovementVector = function() {
- var forward = ( this.moveState.forward || ( this.autoForward && !this.moveState.back ) ) ? 1 : 0;
+ var forward = ( this.moveState.forward || ( this.autoForward && ! this.moveState.back ) ) ? 1 : 0;
- this.moveVector.x = ( -this.moveState.left + this.moveState.right );
- this.moveVector.y = ( -this.moveState.down + this.moveState.up );
- this.moveVector.z = ( -forward + this.moveState.back );
+ this.moveVector.x = ( - this.moveState.left + this.moveState.right );
+ this.moveVector.y = ( - this.moveState.down + this.moveState.up );
+ this.moveVector.z = ( - forward + this.moveState.back );
//console.log( 'move:', [ this.moveVector.x, this.moveVector.y, this.moveVector.z ] );
@@ -216,9 +216,9 @@ THREE.FlyControls = function ( object, domElement ) {
this.updateRotationVector = function() {
- this.rotationVector.x = ( -this.moveState.pitchDown + this.moveState.pitchUp );
- this.rotationVector.y = ( -this.moveState.yawRight + this.moveState.yawLeft );
- this.rotationVector.z = ( -this.moveState.rollRight + this.moveState.rollLeft );
+ this.rotationVector.x = ( - this.moveState.pitchDown + this.moveState.pitchUp );
+ this.rotationVector.y = ( - this.moveState.yawRight + this.moveState.yawLeft );
+ this.rotationVector.z = ( - this.moveState.rollRight + this.moveState.rollLeft );
//console.log( 'rotate:', [ this.rotationVector.x, this.rotationVector.y, this.rotationVector.z ] );
@@ -254,7 +254,11 @@ THREE.FlyControls = function ( object, domElement ) {
this.domElement.addEventListener( 'mousemove', bind( this, this.mousemove ), false );
this.domElement.addEventListener( 'mousedown', bind( this, this.mousedown ), false );
@@ -9,9 +9,9 @@ THREE.MouseControls = function ( object ) {
var PI_2 = Math.PI / 2;
var mouseQuat = {
- x: new THREE.Quaternion(),
- y: new THREE.Quaternion()
- };
+ x: new THREE.Quaternion(),
+ y: new THREE.Quaternion()
var object = object;
var xVector = new THREE.Vector3( 1, 0, 0 );
var yVector = new THREE.Vector3( 0, 1, 0 );
@@ -35,9 +35,9 @@ THREE.MouseControls = function ( object ) {
this.enabled = true;
this.orientation = {
- x: 0,
- y: 0,
+ x: 0,
+ y: 0,
@@ -45,7 +45,7 @@ THREE.MouseControls = function ( object ) {
mouseQuat.x.setFromAxisAngle( xVector, this.orientation.x );
mouseQuat.y.setFromAxisAngle( yVector, this.orientation.y );
- object.quaternion.copy(mouseQuat.y).multiply(mouseQuat.x);
+ object.quaternion.copy( mouseQuat.y ).multiply( mouseQuat.x );
/*global THREE, console */
-(function () {
+( function () {
function OrbitConstraint ( object ) {
@@ -260,7 +260,7 @@
if ( zoomChanged ||
lastPosition.distanceToSquared( this.object.position ) > EPS ||
- 8 * ( 1 - lastQuaternion.dot( this.object.quaternion) ) > EPS ) {
+ 8 * ( 1 - lastQuaternion.dot( this.object.quaternion ) ) > EPS ) {
lastPosition.copy( this.object.position );
lastQuaternion.copy( this.object.quaternion );
@@ -295,15 +295,15 @@
- Object.defineProperty(this, 'constraint', {
+ Object.defineProperty( this, 'constraint', {
- get: function() {
+ get: function() {
- return constraint;
+ return constraint;
this.getPolarAngle = function () {
@@ -366,7 +366,7 @@
var dollyEnd = new THREE.Vector2();
var dollyDelta = new THREE.Vector2();
- var STATE = { NONE : -1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 };
+ var STATE = { NONE : - 1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 };
@@ -556,11 +556,15 @@
- if ( event.wheelDelta !== undefined ) { // WebKit / Opera / Explorer 9
+ if ( event.wheelDelta !== undefined ) {
delta = event.wheelDelta;
- } else if ( event.detail !== undefined ) { // Firefox
+ } else if ( event.detail !== undefined ) {
delta = - event.detail;
@@ -746,7 +750,11 @@
this.domElement.addEventListener( 'mousedown', onMouseDown, false );
this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox
@@ -772,6 +780,7 @@
get: function () {
return this.constraint.object;
@@ -921,6 +930,6 @@
-}());
+}() );
@@ -8,7 +8,7 @@
THREE.OrthographicTrackballControls = function ( object, domElement ) {
var _this = this;
- var STATE = { NONE: -1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
+ var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
@@ -186,7 +186,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
}() );
- this.rotateCamera = (function() {
+ this.rotateCamera = ( function() {
var axis = new THREE.Vector3(),
quaternion = new THREE.Quaternion();
@@ -202,7 +202,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
angle *= _this.rotateSpeed;
- quaternion.setFromAxisAngle( axis, -angle );
+ quaternion.setFromAxisAngle( axis, - angle );
_eye.applyQuaternion( quaternion );
_this.object.up.applyQuaternion( quaternion );
@@ -223,9 +223,10 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
_changed = true;
- }());
+ }() );
this.zoomCamera = function () {
@@ -264,7 +265,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
- this.panCamera = (function() {
+ this.panCamera = ( function() {
var mouseChange = new THREE.Vector2(),
objectUp = new THREE.Vector3(),
@@ -301,21 +302,22 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
this.update = function () {
_eye.subVectors( _this.object.position, _this.target );
- if ( !_this.noRotate ) {
+ if ( ! _this.noRotate ) {
_this.rotateCamera();
- if ( !_this.noZoom ) {
+ if ( ! _this.noZoom ) {
_this.zoomCamera();
@@ -327,7 +329,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
- if ( !_this.noPan ) {
+ if ( ! _this.noPan ) {
_this.panCamera();
@@ -385,15 +387,15 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
- } else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && !_this.noRotate ) {
+ } else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noRotate ) {
_state = STATE.ROTATE;
- } else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && !_this.noZoom ) {
+ } else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && ! _this.noZoom ) {
_state = STATE.ZOOM;
- } else if ( event.keyCode === _this.keys[ STATE.PAN ] && !_this.noPan ) {
+ } else if ( event.keyCode === _this.keys[ STATE.PAN ] && ! _this.noPan ) {
_state = STATE.PAN;
@@ -424,20 +426,20 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
- if ( _state === STATE.ROTATE && !_this.noRotate ) {
+ if ( _state === STATE.ROTATE && ! _this.noRotate ) {
_rotateStart.copy( getMouseProjectionOnBall( event.pageX, event.pageY ) );
_rotateEnd.copy( _rotateStart );
- } else if ( _state === STATE.ZOOM && !_this.noZoom ) {
+ } else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
_zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
- _zoomEnd.copy(_zoomStart);
+ _zoomEnd.copy( _zoomStart );
- } else if ( _state === STATE.PAN && !_this.noPan ) {
+ } else if ( _state === STATE.PAN && ! _this.noPan ) {
_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
- _panEnd.copy(_panStart)
+ _panEnd.copy( _panStart )
@@ -455,15 +457,15 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
event.stopPropagation();
_rotateEnd.copy( getMouseProjectionOnBall( event.pageX, event.pageY ) );
_zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
_panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
@@ -495,11 +497,15 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
delta = event.wheelDelta / 40;
delta = - event.detail / 3;
@@ -600,7 +606,11 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
this.domElement.addEventListener( 'mousedown', mousedown, false );
@@ -45,7 +45,7 @@ THREE.PointerLockControls = function ( camera ) {
// assumes the camera itself is not rotated
- var direction = new THREE.Vector3( 0, 0, -1 );
+ var direction = new THREE.Vector3( 0, 0, - 1 );
var rotation = new THREE.Euler( 0, 0, 0, "YXZ" );
return function( v ) {
THREE.TrackballControls = function ( object, domElement ) {
@@ -140,11 +140,12 @@ THREE.TrackballControls = function ( object, domElement ) {
return vector;
quaternion = new THREE.Quaternion(),
@@ -183,7 +184,7 @@ THREE.TrackballControls = function ( object, domElement ) {
_lastAxis.copy( axis );
_lastAngle = angle;
- } else if ( !_this.staticMoving && _lastAngle ) {
+ } else if ( ! _this.staticMoving && _lastAngle ) {
_lastAngle *= Math.sqrt( 1.0 - _this.dynamicDampingFactor );
_eye.copy( _this.object.position ).sub( _this.target );
@@ -197,7 +198,7 @@ THREE.TrackballControls = function ( object, domElement ) {
@@ -234,7 +235,7 @@ THREE.TrackballControls = function ( object, domElement ) {
@@ -265,13 +266,14 @@ THREE.TrackballControls = function ( object, domElement ) {
this.checkDistances = function () {
- if ( !_this.noZoom || !_this.noPan ) {
+ if ( ! _this.noZoom || ! _this.noPan ) {
if ( _eye.lengthSq() > _this.maxDistance * _this.maxDistance ) {
@@ -295,19 +297,19 @@ THREE.TrackballControls = function ( object, domElement ) {
@@ -362,15 +364,15 @@ THREE.TrackballControls = function ( object, domElement ) {
@@ -401,20 +403,20 @@ THREE.TrackballControls = function ( object, domElement ) {
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
- _movePrev.copy(_moveCurr);
+ _movePrev.copy( _moveCurr );
- _panEnd.copy(_panStart);
+ _panEnd.copy( _panStart );
@@ -432,16 +434,16 @@ THREE.TrackballControls = function ( object, domElement ) {
@@ -473,11 +475,15 @@ THREE.TrackballControls = function ( object, domElement ) {
@@ -498,7 +504,7 @@ THREE.TrackballControls = function ( object, domElement ) {
case 1:
_state = STATE.TOUCH_ROTATE;
_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
case 2:
@@ -532,7 +538,7 @@ THREE.TrackballControls = function ( object, domElement ) {
switch ( event.touches.length ) {
@@ -560,7 +566,7 @@ THREE.TrackballControls = function ( object, domElement ) {
@@ -580,7 +586,11 @@ THREE.TrackballControls = function ( object, domElement ) {
@@ -3,7 +3,7 @@
/*jshint sub:true*/
'use strict';
@@ -95,9 +95,9 @@
this.pickers = new THREE.Object3D();
this.planes = new THREE.Object3D();
- this.add(this.handles);
- this.add(this.pickers);
- this.add(this.planes);
+ this.add( this.handles );
+ this.add( this.pickers );
+ this.add( this.planes );
//// PLANES
@@ -111,15 +111,17 @@
"XYZE": new THREE.Mesh( planeGeometry, planeMaterial )
- this.activePlane = planes["XYZE"];
+ this.activePlane = planes[ "XYZE" ];
- planes["YZ"].rotation.set( 0, Math.PI / 2, 0 );
- planes["XZ"].rotation.set( -Math.PI / 2, 0, 0 );
+ planes[ "YZ" ].rotation.set( 0, Math.PI / 2, 0 );
+ planes[ "XZ" ].rotation.set( - Math.PI / 2, 0, 0 );
+ for ( var i in planes ) {
+ planes[ i ].name = i;
+ this.planes.add( planes[ i ] );
+ this.planes[ i ] = planes[ i ];
- for (var i in planes) {
- planes[i].name = i;
- this.planes.add(planes[i]);
- this.planes[i] = planes[i];
//// HANDLES AND PICKERS
@@ -128,16 +130,16 @@
for ( var name in gizmoMap ) {
- for ( i = gizmoMap[name].length; i --;) {
+ for ( i = gizmoMap[ name ].length; i --; ) {
- var object = gizmoMap[name][i][0];
- var position = gizmoMap[name][i][1];
- var rotation = gizmoMap[name][i][2];
+ var object = gizmoMap[ name ][ i ][ 0 ];
+ var position = gizmoMap[ name ][ i ][ 1 ];
+ var rotation = gizmoMap[ name ][ i ][ 2 ];
object.name = name;
- if ( position ) object.position.set( position[0], position[1], position[2] );
- if ( rotation ) object.rotation.set( rotation[0], rotation[1], rotation[2] );
+ if ( position ) object.position.set( position[ 0 ], position[ 1 ], position[ 2 ] );
+ if ( rotation ) object.rotation.set( rotation[ 0 ], rotation[ 1 ], rotation[ 2 ] );
parent.add( object );
@@ -147,14 +149,14 @@
- setupGizmos(this.handleGizmos, this.handles);
- setupGizmos(this.pickerGizmos, this.pickers);
+ setupGizmos( this.handleGizmos, this.handles );
+ setupGizmos( this.pickerGizmos, this.pickers );
// reset Transformations
- this.traverse(function ( child ) {
+ this.traverse( function ( child ) {
- if (child instanceof THREE.Mesh) {
+ if ( child instanceof THREE.Mesh ) {
child.updateMatrix();
@@ -168,7 +170,7 @@
@@ -205,13 +207,13 @@
var vec2 = new THREE.Vector3( 0, 1, 0 );
var lookAtMatrix = new THREE.Matrix4();
- this.traverse( function(child) {
+ this.traverse( function( child ) {
- if ( child.name.search("E") !== -1 ) {
+ if ( child.name.search( "E" ) !== - 1 ) {
child.quaternion.setFromRotationMatrix( lookAtMatrix.lookAt( eye, vec1, vec2 ) );
- } else if ( child.name.search("X") !== -1 || child.name.search("Y") !== -1 || child.name.search("Z") !== -1 ) {
+ } else if ( child.name.search( "X" ) !== - 1 || child.name.search( "Y" ) !== - 1 || child.name.search( "Z" ) !== - 1 ) {
child.quaternion.setFromEuler( rotation );
@@ -244,7 +246,7 @@
this.handleGizmos = {
X: [
- [ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0xff0000 } ) ), [ 0.5, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ],
+ [ new THREE.Mesh( arrowGeometry, new GizmoMaterial( { color: 0xff0000 } ) ), [ 0.5, 0, 0 ], [ 0, 0, - Math.PI / 2 ] ],
[ new THREE.Line( lineXGeometry, new GizmoLineMaterial( { color: 0xff0000 } ) ) ]
],
@@ -271,7 +273,7 @@
XZ: [
- [ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0xff00ff, opacity: 0.25 } ) ), [ 0.15, 0, 0.15 ], [ -Math.PI / 2, 0, 0 ] ]
+ [ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.29, 0.29 ), new GizmoMaterial( { color: 0xff00ff, opacity: 0.25 } ) ), [ 0.15, 0, 0.15 ], [ - Math.PI / 2, 0, 0 ] ]
]
@@ -279,7 +281,7 @@
this.pickerGizmos = {
- [ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), pickerMaterial ), [ 0.6, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ]
+ [ new THREE.Mesh( new THREE.CylinderGeometry( 0.2, 0, 1, 4, 1, false ), pickerMaterial ), [ 0.6, 0, 0 ], [ 0, 0, - Math.PI / 2 ] ]
Y: [
@@ -303,7 +305,7 @@
- [ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), pickerMaterial ), [ 0.2, 0, 0.2 ], [ -Math.PI / 2, 0, 0 ] ]
+ [ new THREE.Mesh( new THREE.PlaneBufferGeometry( 0.4, 0.4 ), pickerMaterial ), [ 0.2, 0, 0.2 ], [ - Math.PI / 2, 0, 0 ] ]
@@ -317,7 +319,7 @@
this.activePlane = this.planes[ "XY" ];
- if ( Math.abs(eye.y) > Math.abs(eye.z) ) this.activePlane = this.planes[ "XZ" ];
+ if ( Math.abs( eye.y ) > Math.abs( eye.z ) ) this.activePlane = this.planes[ "XZ" ];
@@ -325,7 +327,7 @@
- if ( Math.abs(eye.x) > Math.abs(eye.z) ) this.activePlane = this.planes[ "YZ" ];
+ if ( Math.abs( eye.x ) > Math.abs( eye.z ) ) this.activePlane = this.planes[ "YZ" ];
@@ -333,7 +335,7 @@
this.activePlane = this.planes[ "XZ" ];
- if ( Math.abs(eye.x) > Math.abs(eye.y) ) this.activePlane = this.planes[ "YZ" ];
+ if ( Math.abs( eye.x ) > Math.abs( eye.y ) ) this.activePlane = this.planes[ "YZ" ];
@@ -380,23 +382,23 @@
- [ new THREE.Line( new CircleGeometry(1,'x',0.5), new GizmoLineMaterial( { color: 0xff0000 } ) ) ]
+ [ new THREE.Line( new CircleGeometry( 1, 'x', 0.5 ), new GizmoLineMaterial( { color: 0xff0000 } ) ) ]
- [ new THREE.Line( new CircleGeometry(1,'y',0.5), new GizmoLineMaterial( { color: 0x00ff00 } ) ) ]
+ [ new THREE.Line( new CircleGeometry( 1, 'y', 0.5 ), new GizmoLineMaterial( { color: 0x00ff00 } ) ) ]
Z: [
- [ new THREE.Line( new CircleGeometry(1,'z',0.5), new GizmoLineMaterial( { color: 0x0000ff } ) ) ]
+ [ new THREE.Line( new CircleGeometry( 1, 'z', 0.5 ), new GizmoLineMaterial( { color: 0x0000ff } ) ) ]
E: [
- [ new THREE.Line( new CircleGeometry(1.25,'z',1), new GizmoLineMaterial( { color: 0xcccc00 } ) ) ]
+ [ new THREE.Line( new CircleGeometry( 1.25, 'z', 1 ), new GizmoLineMaterial( { color: 0xcccc00 } ) ) ]
XYZE: [
- [ new THREE.Line( new CircleGeometry(1,'z',1), new GizmoLineMaterial( { color: 0x787878 } ) ) ]
+ [ new THREE.Line( new CircleGeometry( 1, 'z', 1 ), new GizmoLineMaterial( { color: 0x787878 } ) ) ]
@@ -404,7 +406,7 @@
- [ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), pickerMaterial ), [ 0, 0, 0 ], [ 0, -Math.PI / 2, -Math.PI / 2 ] ]
+ [ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), pickerMaterial ), [ 0, 0, 0 ], [ 0, - Math.PI / 2, - Math.PI / 2 ] ]
@@ -412,7 +414,7 @@
- [ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), pickerMaterial ), [ 0, 0, 0 ], [ 0, 0, -Math.PI / 2 ] ]
+ [ new THREE.Mesh( new THREE.TorusGeometry( 1, 0.12, 4, 12, Math.PI ), pickerMaterial ), [ 0, 0, 0 ], [ 0, 0, - Math.PI / 2 ] ]
@@ -443,8 +445,8 @@
var group = {
- handles: this["handles"],
- pickers: this["pickers"],
+ handles: this[ "handles" ],
+ pickers: this[ "pickers" ],
@@ -459,19 +461,19 @@
var quaternionZ = new THREE.Quaternion();
var eye = eye2.clone();
- worldRotation.copy( this.planes["XY"].rotation );
+ worldRotation.copy( this.planes[ "XY" ].rotation );
tempQuaternion.setFromEuler( worldRotation );
tempMatrix.makeRotationFromQuaternion( tempQuaternion ).getInverse( tempMatrix );
eye.applyMatrix4( tempMatrix );
- this.traverse(function(child) {
if ( child.name === "X" ) {
- quaternionX.setFromAxisAngle( unitX, Math.atan2( -eye.y, eye.z ) );
+ quaternionX.setFromAxisAngle( unitX, Math.atan2( - eye.y, eye.z ) );
tempQuaternion.multiplyQuaternions( tempQuaternion, quaternionX );
child.quaternion.copy( tempQuaternion );
@@ -493,7 +495,7 @@
@@ -527,7 +529,7 @@
@@ -550,7 +552,7 @@
@@ -573,18 +575,24 @@
eye.applyMatrix4( tempMatrix.getInverse( tempMatrix.extractRotation( this.planes[ "XY" ].matrixWorld ) ) );
if ( axis === "X" ) {
if ( axis === "Y" ) {
if ( axis === "Z" ) {
if ( axis === "XYZ" ) this.activePlane = this.planes[ "XYZE" ];
@@ -626,9 +634,9 @@
"scale": new THREE.TransformGizmoScale()
- for (var type in _gizmo) {
+ for ( var type in _gizmo ) {
- var gizmoObj = _gizmo[type];
+ var gizmoObj = _gizmo[ type ];
gizmoObj.visible = ( type === _mode );
this.add( gizmoObj );
@@ -735,7 +743,7 @@
if ( _mode === "scale" ) scope.space = "local";
- for (var type in _gizmo) _gizmo[type].visible = ( type === _mode );
+ for ( var type in _gizmo ) _gizmo[ type ].visible = ( type === _mode );
this.update();
scope.dispatchEvent( changeEvent );
@@ -784,15 +792,15 @@
if ( scope.space === "local" ) {
- _gizmo[_mode].update( worldRotation, eye );
+ _gizmo[ _mode ].update( worldRotation, eye );
} else if ( scope.space === "world" ) {
- _gizmo[_mode].update( new THREE.Euler(), eye );
+ _gizmo[ _mode ].update( new THREE.Euler(), eye );
- _gizmo[_mode].highlight( scope.axis );
+ _gizmo[ _mode ].highlight( scope.axis );
@@ -802,7 +810,7 @@
var pointer = event.changedTouches ? event.changedTouches[ 0 ] : event;
- var intersect = intersectObjects( pointer, _gizmo[_mode].pickers.children );
+ var intersect = intersectObjects( pointer, _gizmo[ _mode ].pickers.children );
var axis = null;
@@ -832,7 +840,7 @@
if ( pointer.button === 0 || pointer.button === undefined ) {
if ( intersect ) {
@@ -847,9 +855,9 @@
eye.copy( camPosition ).sub( worldPosition ).normalize();
- _gizmo[_mode].setActivePlane( scope.axis, eye );
+ _gizmo[ _mode ].setActivePlane( scope.axis, eye );
- var planeIntersect = intersectObjects( pointer, [ _gizmo[_mode].activePlane ] );
+ var planeIntersect = intersectObjects( pointer, [ _gizmo[ _mode ].activePlane ] );
if ( planeIntersect ) {
@@ -878,9 +886,9 @@
if ( scope.object === undefined || scope.axis === null || _dragging === false ) return;
- var pointer = event.changedTouches ? event.changedTouches[0] : event;
+ var pointer = event.changedTouches ? event.changedTouches[ 0 ] : event;
if ( planeIntersect === false ) return;
@@ -892,15 +900,15 @@
if ( _mode === "translate" ) {
point.sub( offset );
- point.multiply(parentScale);
+ point.multiply( parentScale );
point.applyMatrix4( tempMatrix.getInverse( worldRotationMatrix ) );
- if ( scope.axis.search("X") === -1 ) point.x = 0;
- if ( scope.axis.search("Y") === -1 ) point.y = 0;
- if ( scope.axis.search("Z") === -1 ) point.z = 0;
+ if ( scope.axis.search( "X" ) === - 1 ) point.x = 0;
+ if ( scope.axis.search( "Y" ) === - 1 ) point.y = 0;
+ if ( scope.axis.search( "Z" ) === - 1 ) point.z = 0;
point.applyMatrix4( oldRotationMatrix );
@@ -909,11 +917,11 @@
- if ( scope.space === "world" || scope.axis.search("XYZ") !== -1 ) {
+ if ( scope.space === "world" || scope.axis.search( "XYZ" ) !== - 1 ) {
point.applyMatrix4( tempMatrix.getInverse( parentRotationMatrix ) );
@@ -924,20 +932,20 @@
if ( scope.snap !== null ) {
- if ( scope.axis.search("X") !== -1 ) scope.object.position.x = Math.round( scope.object.position.x / scope.snap ) * scope.snap;
- if ( scope.axis.search("Y") !== -1 ) scope.object.position.y = Math.round( scope.object.position.y / scope.snap ) * scope.snap;
- if ( scope.axis.search("Z") !== -1 ) scope.object.position.z = Math.round( scope.object.position.z / scope.snap ) * scope.snap;
+ if ( scope.axis.search( "X" ) !== - 1 ) scope.object.position.x = Math.round( scope.object.position.x / scope.snap ) * scope.snap;
+ if ( scope.axis.search( "Y" ) !== - 1 ) scope.object.position.y = Math.round( scope.object.position.y / scope.snap ) * scope.snap;
+ if ( scope.axis.search( "Z" ) !== - 1 ) scope.object.position.z = Math.round( scope.object.position.z / scope.snap ) * scope.snap;
} else if ( _mode === "scale" ) {
- if ( scope.axis === "XYZ") {
+ if ( scope.axis === "XYZ" ) {
scale = 1 + ( ( point.y ) / 50 );
@@ -984,10 +992,10 @@
} else if ( scope.axis === "XYZE" ) {
- quaternionE.setFromEuler( point.clone().cross(tempVector).normalize() ); // rotation axis
+ quaternionE.setFromEuler( point.clone().cross( tempVector ).normalize() ); // rotation axis
tempQuaternion.setFromRotationMatrix( tempMatrix.getInverse( parentRotationMatrix ) );
- quaternionX.setFromAxisAngle( quaternionE, - point.clone().angleTo(tempVector) );
+ quaternionX.setFromAxisAngle( quaternionE, - point.clone().angleTo( tempVector ) );
quaternionXYZ.setFromRotationMatrix( worldRotationMatrix );
@@ -1069,7 +1077,7 @@
ray.setFromCamera( pointerVector, camera );
var intersections = ray.intersectObjects( objects, true );
- return intersections[0] ? intersections[0] : false;
+ return intersections[ 0 ] ? intersections[ 0 ] : false;
@@ -1078,4 +1086,4 @@
THREE.TransformControls.prototype = Object.create( THREE.Object3D.prototype );
THREE.TransformControls.prototype.constructor = THREE.TransformControls;
@@ -15,7 +15,7 @@ THREE.VRControls = function ( object, onError ) {
var oculusDevices = devices.filter( function ( device ) {
- return device.deviceName.toLowerCase().indexOf('oculus') !== -1;
+ return device.deviceName.toLowerCase().indexOf( 'oculus' ) !== - 1;
@@ -23,7 +23,7 @@ THREE.VRControls = function ( object, onError ) {
return devices.filter( function ( device ) {
- return device.deviceName.toLowerCase().indexOf('cardboard') === -1;
+ return device.deviceName.toLowerCase().indexOf( 'cardboard' ) === - 1;
@@ -12,28 +12,28 @@ function initGUI() {
var gui = new dat.GUI();
- gui.add(transitionParams, "useTexture").onChange(function(value) {
+ gui.add( transitionParams, "useTexture" ).onChange( function( value ) {
- transition.useTexture(value);
+ transition.useTexture( value );
- gui.add(transitionParams, 'loopTexture');
+ gui.add( transitionParams, 'loopTexture' );
- gui.add(transitionParams, 'texture', { Perlin: 0, Squares: 1, Cells: 2, Distort: 3, Gradient: 4, Radial: 5 } ).onChange(function(value) {
+ gui.add( transitionParams, 'texture', { Perlin: 0, Squares: 1, Cells: 2, Distort: 3, Gradient: 4, Radial: 5 } ).onChange( function( value ) {
- transition.setTexture(value);
+ transition.setTexture( value );
- }).listen();
+ } ).listen();
- gui.add(transitionParams, "textureThreshold", 0, 1, 0.01).onChange(function(value) {
+ gui.add( transitionParams, "textureThreshold", 0, 1, 0.01 ).onChange( function( value ) {
- transition.setTextureThreshold(value);
+ transition.setTextureThreshold( value );
- gui.add(transitionParams, "animateTransition");
- gui.add(transitionParams, "transition", 0, 1, 0.01).listen();
- gui.add(transitionParams, "transitionSpeed", 0.5, 5, 0.01);
+ gui.add( transitionParams, "animateTransition" );
+ gui.add( transitionParams, "transition", 0, 1, 0.01 ).listen();
+ gui.add( transitionParams, "transitionSpeed", 0.5, 5, 0.01 );
+}
@@ -1,4 +1,4 @@
-function generateGeometry(objectType, numObjects) {
+function generateGeometry( objectType, numObjects ) {
var geometry = new THREE.Geometry();
@@ -38,18 +38,19 @@ function generateGeometry(objectType, numObjects) {
scale.x = Math.random() * 200 + 100;
- if ( objectType == "cube" )
+ if ( objectType == "cube" ) {
geom = new THREE.BoxGeometry( 1, 1, 1 );
scale.y = Math.random() * 200 + 100;
scale.z = Math.random() * 200 + 100;
color.setRGB( 0, 0, Math.random() + 0.1 );
- else if ( objectType == "sphere" )
+ } else if ( objectType == "sphere" ) {
geom = new THREE.IcosahedronGeometry( 1, 1 );
scale.y = scale.z = scale.x;
color.setRGB( Math.random() + 0.1, 0, 0 );
// give the geom's vertices a random color, to be displayed
@@ -85,7 +86,7 @@ function Scene ( type, numObjects, cameraZ, fov, rotationSpeed, clearColor ) {
this.scene.add( light );
this.rotationSpeed = rotationSpeed;
- defaultMaterial = new THREE.MeshLambertMaterial({ color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } );
+ defaultMaterial = new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } );
this.mesh = new THREE.Mesh( generateGeometry( type, numObjects ), defaultMaterial );
this.scene.add( this.mesh );
@@ -100,10 +101,11 @@ function Scene ( type, numObjects, cameraZ, fov, rotationSpeed, clearColor ) {
renderer.setClearColor( this.clearColor );
- if (rtt)
+ if ( rtt )
renderer.render( this.scene, this.camera, this.fbo, true );
else
renderer.render( this.scene, this.camera );
@@ -2,13 +2,13 @@ function Transition ( sceneA, sceneB ) {
- this.cameraOrtho = new THREE.OrthographicCamera(window.innerWidth / -2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / -2, -10, 10);
+ this.cameraOrtho = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 10, 10 );
this.textures = [];
- for (var i = 0; i < 6; i ++)
- this.textures[i] = new THREE.ImageUtils.loadTexture('textures/transition/transition' + (i + 1) + '.png');
+ for ( var i = 0; i < 6; i ++ )
+ this.textures[ i ] = new THREE.ImageUtils.loadTexture( 'textures/transition/transition' + ( i + 1 ) + '.png' );
- this.quadmaterial = new THREE.ShaderMaterial({
+ this.quadmaterial = new THREE.ShaderMaterial( {
@@ -34,7 +34,7 @@ function Transition ( sceneA, sceneB ) {
tMixTexture: {
type: "t",
- value: this.textures[0]
+ value: this.textures[ 0 ]
@@ -48,7 +48,7 @@ function Transition ( sceneA, sceneB ) {
"uniform float mixRatio;",
@@ -81,14 +81,14 @@ function Transition ( sceneA, sceneB ) {
- quadgeometry = new THREE.PlaneBufferGeometry(window.innerWidth, window.innerHeight);
+ quadgeometry = new THREE.PlaneBufferGeometry( window.innerWidth, window.innerHeight );
- this.quad = new THREE.Mesh(quadgeometry, this.quadmaterial);
- this.scene.add(this.quad);
+ this.quad = new THREE.Mesh( quadgeometry, this.quadmaterial );
+ this.scene.add( this.quad );
// Link both scenes and their FBOs
this.sceneA = sceneA;
@@ -113,29 +113,30 @@ function Transition ( sceneA, sceneB ) {
this.setTexture = function ( i ) {
- this.quadmaterial.uniforms.tMixTexture.value = this.textures[i];
+ this.quadmaterial.uniforms.tMixTexture.value = this.textures[ i ];
this.render = function( delta ) {
// Transition animation
- if (transitionParams.animateTransition)
- var t = (1 + Math.sin(transitionParams.transitionSpeed * clock.getElapsedTime() / Math.PI)) / 2;
- transitionParams.transition = THREE.Math.smoothstep(t, 0.3, 0.7);
+ if ( transitionParams.animateTransition ) {
+ var t = ( 1 + Math.sin( transitionParams.transitionSpeed * clock.getElapsedTime() / Math.PI ) ) / 2;
+ transitionParams.transition = THREE.Math.smoothstep( t, 0.3, 0.7 );
// Change the current alpha texture after each transition
- if (transitionParams.loopTexture && (transitionParams.transition == 0 || transitionParams.transition == 1))
- if (this.needChange)
- transitionParams.texture = (transitionParams.texture + 1)%this.textures.length;
- this.quadmaterial.uniforms.tMixTexture.value = this.textures[transitionParams.texture];
+ if ( transitionParams.loopTexture && ( transitionParams.transition == 0 || transitionParams.transition == 1 ) ) {
+ if ( this.needChange ) {
+ transitionParams.texture = ( transitionParams.texture + 1 ) % this.textures.length;
+ this.quadmaterial.uniforms.tMixTexture.value = this.textures[ transitionParams.texture ];
this.needChange = false;
+ } else
this.needChange = true;
@@ -143,11 +144,11 @@ function Transition ( sceneA, sceneB ) {
this.quadmaterial.uniforms.mixRatio.value = transitionParams.transition;
// Prevent render both scenes when it's not necessary
- if (transitionParams.transition == 0) {
+ if ( transitionParams.transition == 0 ) {
this.sceneB.render( delta, false );
- } else if (transitionParams.transition == 1) {
+ } else if ( transitionParams.transition == 1 ) {
this.sceneA.render( delta, false );
@@ -162,4 +163,5 @@ function Transition ( sceneA, sceneB ) {
@@ -13,14 +13,17 @@
* NURBS curve
**************************************************************/
-THREE.NURBSCurve = function ( degree, knots /* array of reals */, controlPoints /* array of Vector(2|3|4) */) {
+THREE.NURBSCurve = function ( degree, knots /* array of reals */, controlPoints /* array of Vector(2|3|4) */ ) {
this.degree = degree;
this.knots = knots;
this.controlPoints = [];
- for (var i = 0; i < controlPoints.length; ++ i) { // ensure Vector4 for control points
- var point = controlPoints[i];
- this.controlPoints[i] = new THREE.Vector4(point.x, point.y, point.z, point.w);
+ for ( var i = 0; i < controlPoints.length; ++ i ) {
+ // ensure Vector4 for control points
+ var point = controlPoints[ i ];
+ this.controlPoints[ i ] = new THREE.Vector4( point.x, point.y, point.z, point.w );
@@ -32,26 +35,31 @@ THREE.NURBSCurve.prototype.constructor = THREE.NURBSCurve;
THREE.NURBSCurve.prototype.getPoint = function ( t ) {
- var u = this.knots[0] + t * (this.knots[this.knots.length - 1] - this.knots[0]); // linear mapping t->u
+ var u = this.knots[ 0 ] + t * ( this.knots[ this.knots.length - 1 ] - this.knots[ 0 ] ); // linear mapping t->u
// following results in (wx, wy, wz, w) homogeneous point
- var hpoint = THREE.NURBSUtils.calcBSplinePoint(this.degree, this.knots, this.controlPoints, u);
+ var hpoint = THREE.NURBSUtils.calcBSplinePoint( this.degree, this.knots, this.controlPoints, u );
+ if ( hpoint.w != 1.0 ) {
+ // project to 3D space: (wx, wy, wz, w) -> (x, y, z, 1)
+ hpoint.divideScalar( hpoint.w );
- if (hpoint.w != 1.0) { // project to 3D space: (wx, wy, wz, w) -> (x, y, z, 1)
- hpoint.divideScalar(hpoint.w);
- return new THREE.Vector3(hpoint.x, hpoint.y, hpoint.z);
+ return new THREE.Vector3( hpoint.x, hpoint.y, hpoint.z );
THREE.NURBSCurve.prototype.getTangent = function ( t ) {
- var u = this.knots[0] + t * (this.knots[this.knots.length - 1] - this.knots[0]);
- var ders = THREE.NURBSUtils.calcNURBSDerivatives(this.degree, this.knots, this.controlPoints, u, 1);
- var tangent = ders[1].clone();
+ var u = this.knots[ 0 ] + t * ( this.knots[ this.knots.length - 1 ] - this.knots[ 0 ] );
+ var ders = THREE.NURBSUtils.calcNURBSDerivatives( this.degree, this.knots, this.controlPoints, u, 1 );
+ var tangent = ders[ 1 ].clone();
tangent.normalize();
return tangent;
@@ -11,7 +11,7 @@
* NURBS surface
-THREE.NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of reals */, controlPoints /* array^2 of Vector(2|3|4) */) {
+THREE.NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of reals */, controlPoints /* array^2 of Vector(2|3|4) */ ) {
this.degree1 = degree1;
this.degree2 = degree2;
@@ -23,13 +23,18 @@ THREE.NURBSSurface = function ( degree1, degree2, knots1, knots2 /* arrays of re
var len2 = knots2.length - degree2 - 1;
// ensure Vector4 for control points
- for (var i = 0; i < len1; ++ i) {
- this.controlPoints[i] = [];
- for (var j = 0; j < len2; ++ j) {
- var point = controlPoints[i][j];
- this.controlPoints[i][j] = new THREE.Vector4(point.x, point.y, point.z, point.w);
+ for ( var i = 0; i < len1; ++ i ) {
+ this.controlPoints[ i ] = [];
+ for ( var j = 0; j < len2; ++ j ) {
+ var point = controlPoints[ i ][ j ];
+ this.controlPoints[ i ][ j ] = new THREE.Vector4( point.x, point.y, point.z, point.w );
@@ -39,10 +44,11 @@ THREE.NURBSSurface.prototype = {
getPoint: function ( t1, t2 ) {
- var u = this.knots1[0] + t1 * (this.knots1[this.knots1.length - 1] - this.knots1[0]); // linear mapping t1->u
- var v = this.knots2[0] + t2 * (this.knots2[this.knots2.length - 1] - this.knots2[0]); // linear mapping t2->u
+ var u = this.knots1[ 0 ] + t1 * ( this.knots1[ this.knots1.length - 1 ] - this.knots1[ 0 ] ); // linear mapping t1->u
+ var v = this.knots2[ 0 ] + t2 * ( this.knots2[ this.knots2.length - 1 ] - this.knots2[ 0 ] ); // linear mapping t2->u
+ return THREE.NURBSUtils.calcSurfacePoint( this.degree1, this.degree2, this.knots1, this.knots2, this.controlPoints, u, v );
- return THREE.NURBSUtils.calcSurfacePoint(this.degree1, this.degree2, this.knots1, this.knots2, this.controlPoints, u, v);
@@ -23,32 +23,43 @@ THREE.NURBSUtils = {
returns the span
findSpan: function( p, u, U ) {
var n = U.length - p - 1;
- if (u >= U[n]) {
+ if ( u >= U[ n ] ) {
return n - 1;
- if (u <= U[p]) {
+ if ( u <= U[ p ] ) {
return p;
var low = p;
var high = n;
- var mid = Math.floor((low + high) / 2);
+ var mid = Math.floor( ( low + high ) / 2 );
- while (u < U[mid] || u >= U[mid + 1]) {
+ while ( u < U[ mid ] || u >= U[ mid + 1 ] ) {
- if (u < U[mid]) {
+ if ( u < U[ mid ] ) {
high = mid;
low = mid;
- mid = Math.floor((low + high) / 2);
+ mid = Math.floor( ( low + high ) / 2 );
return mid;
@@ -63,31 +74,35 @@ THREE.NURBSUtils = {
returns array[p+1] with basis functions values.
calcBasisFunctions: function( span, u, p, U ) {
var N = [];
var left = [];
var right = [];
- N[0] = 1.0;
+ N[ 0 ] = 1.0;
- for (var j = 1; j <= p; ++ j) {
+ for ( var j = 1; j <= p; ++ j ) {
- left[j] = u - U[span + 1 - j];
- right[j] = U[span + j] - u;
+ left[ j ] = u - U[ span + 1 - j ];
+ right[ j ] = U[ span + j ] - u;
var saved = 0.0;
- for (var r = 0; r < j; ++ r) {
+ for ( var r = 0; r < j; ++ r ) {
- var rv = right[r + 1];
- var lv = left[j - r];
- var temp = N[r] / (rv + lv);
- N[r] = saved + rv * temp;
+ var rv = right[ r + 1 ];
+ var lv = left[ j - r ];
+ var temp = N[ r ] / ( rv + lv );
+ N[ r ] = saved + rv * temp;
saved = lv * temp;
- N[j] = saved;
+ N[ j ] = saved;
return N;
@@ -102,21 +117,25 @@ THREE.NURBSUtils = {
returns point for given u
calcBSplinePoint: function( p, U, P, u ) {
- var span = this.findSpan(p, u, U);
- var N = this.calcBasisFunctions(span, u, p, U);
- var C = new THREE.Vector4(0, 0, 0, 0);
- for (var j = 0; j <= p; ++ j) {
- var point = P[span - p + j];
- var Nj = N[j];
+ var span = this.findSpan( p, u, U );
+ var N = this.calcBasisFunctions( span, u, p, U );
+ var C = new THREE.Vector4( 0, 0, 0, 0 );
+ for ( var j = 0; j <= p; ++ j ) {
+ var point = P[ span - p + j ];
+ var Nj = N[ j ];
var wNj = point.w * Nj;
C.x += point.x * wNj;
C.y += point.y * wNj;
C.z += point.z * wNj;
C.w += point.w * Nj;
return C;
@@ -134,142 +153,175 @@ THREE.NURBSUtils = {
calcBasisFunctionDerivatives: function( span, u, p, n, U ) {
var zeroArr = [];
- for (var i = 0; i <= p; ++ i)
- zeroArr[i] = 0.0;
+ for ( var i = 0; i <= p; ++ i )
+ zeroArr[ i ] = 0.0;
var ders = [];
- for (var i = 0; i <= n; ++ i)
- ders[i] = zeroArr.slice(0);
+ for ( var i = 0; i <= n; ++ i )
+ ders[ i ] = zeroArr.slice( 0 );
var ndu = [];
- ndu[i] = zeroArr.slice(0);
+ ndu[ i ] = zeroArr.slice( 0 );
- ndu[0][0] = 1.0;
+ ndu[ 0 ][ 0 ] = 1.0;
- var left = zeroArr.slice(0);
- var right = zeroArr.slice(0);
+ var left = zeroArr.slice( 0 );
+ var right = zeroArr.slice( 0 );
- ndu[j][r] = rv + lv;
+ ndu[ j ][ r ] = rv + lv;
- var temp = ndu[r][j - 1] / ndu[j][r];
- ndu[r][j] = saved + rv * temp;
+ var temp = ndu[ r ][ j - 1 ] / ndu[ j ][ r ];
+ ndu[ r ][ j ] = saved + rv * temp;
- ndu[j][j] = saved;
+ ndu[ j ][ j ] = saved;
- ders[0][j] = ndu[j][p];
+ ders[ 0 ][ j ] = ndu[ j ][ p ];
- for (var r = 0; r <= p; ++ r) {
+ for ( var r = 0; r <= p; ++ r ) {
var s1 = 0;
var s2 = 1;
var a = [];
- for (var i = 0; i <= p; ++ i) {
- a[i] = zeroArr.slice(0);
+ for ( var i = 0; i <= p; ++ i ) {
+ a[ i ] = zeroArr.slice( 0 );
- a[0][0] = 1.0;
+ a[ 0 ][ 0 ] = 1.0;
+ for ( var k = 1; k <= n; ++ k ) {
- for (var k = 1; k <= n; ++ k) {
var d = 0.0;
var rk = r - k;
var pk = p - k;
- if (r >= k) {
- a[s2][0] = a[s1][0] / ndu[pk + 1][rk];
- d = a[s2][0] * ndu[rk][pk];
+ if ( r >= k ) {
+ a[ s2 ][ 0 ] = a[ s1 ][ 0 ] / ndu[ pk + 1 ][ rk ];
+ d = a[ s2 ][ 0 ] * ndu[ rk ][ pk ];
- var j1 = (rk >= -1) ? 1 : -rk;
- var j2 = (r - 1 <= pk) ? k - 1 : p - r;
+ var j1 = ( rk >= - 1 ) ? 1 : - rk;
+ var j2 = ( r - 1 <= pk ) ? k - 1 : p - r;
+ for ( var j = j1; j <= j2; ++ j ) {
+ a[ s2 ][ j ] = ( a[ s1 ][ j ] - a[ s1 ][ j - 1 ] ) / ndu[ pk + 1 ][ rk + j ];
+ d += a[ s2 ][ j ] * ndu[ rk + j ][ pk ];
- for (var j = j1; j <= j2; ++ j) {
- a[s2][j] = (a[s1][j] - a[s1][j - 1]) / ndu[pk + 1][rk + j];
- d += a[s2][j] * ndu[rk + j][pk];
- if (r <= pk) {
- a[s2][k] = -a[s1][k - 1] / ndu[pk + 1][r];
- d += a[s2][k] * ndu[r][pk];
+ if ( r <= pk ) {
+ a[ s2 ][ k ] = - a[ s1 ][ k - 1 ] / ndu[ pk + 1 ][ r ];
+ d += a[ s2 ][ k ] * ndu[ r ][ pk ];
- ders[k][r] = d;
+ ders[ k ][ r ] = d;
var j = s1;
s1 = s2;
s2 = j;
var r = p;
- ders[k][j] *= r;
+ ders[ k ][ j ] *= r;
r *= p - k;
return ders;
- /*
- Calculate derivatives of a B-Spline. See The NURBS Book, page 93, algorithm A3.2.
+ /*
+ Calculate derivatives of a B-Spline. See The NURBS Book, page 93, algorithm A3.2.
- p : degree
- U : knot vector
- P : control points
- u : Parametric points
- nd : number of derivatives
+ p : degree
+ U : knot vector
+ P : control points
+ u : Parametric points
+ nd : number of derivatives
- returns array[d+1] with derivatives
+ returns array[d+1] with derivatives
calcBSplineDerivatives: function( p, U, P, u, nd ) {
var du = nd < p ? nd : p;
var CK = [];
- var nders = this.calcBasisFunctionDerivatives(span, u, p, du, U);
+ var nders = this.calcBasisFunctionDerivatives( span, u, p, du, U );
var Pw = [];
- for (var i = 0; i < P.length; ++ i) {
- var point = P[i].clone();
+ for ( var i = 0; i < P.length; ++ i ) {
+ var point = P[ i ].clone();
var w = point.w;
point.x *= w;
point.y *= w;
point.z *= w;
- Pw[i] = point;
+ Pw[ i ] = point;
- for (var k = 0; k <= du; ++ k) {
- var point = Pw[span - p].clone().multiplyScalar(nders[k][0]);
+ for ( var k = 0; k <= du; ++ k ) {
+ var point = Pw[ span - p ].clone().multiplyScalar( nders[ k ][ 0 ] );
+ point.add( Pw[ span - p + j ].clone().multiplyScalar( nders[ k ][ j ] ) );
- point.add(Pw[span - p + j].clone().multiplyScalar(nders[k][j]));
- CK[k] = point;
+ CK[ k ] = point;
- for (var k = du + 1; k <= nd + 1; ++ k) {
- CK[k] = new THREE.Vector4(0, 0, 0);
+ for ( var k = du + 1; k <= nd + 1; ++ k ) {
+ CK[ k ] = new THREE.Vector4( 0, 0, 0 );
return CK;
@@ -279,23 +331,31 @@ THREE.NURBSUtils = {
returns k!/(i!(k-i)!)
calcKoverI: function( k, i ) {
var nom = 1;
- for (var j = 2; j <= k; ++ j) {
+ for ( var j = 2; j <= k; ++ j ) {
nom *= j;
var denom = 1;
- for (var j = 2; j <= i; ++ j) {
+ for ( var j = 2; j <= i; ++ j ) {
denom *= j;
- for (var j = 2; j <= k - i; ++ j) {
+ for ( var j = 2; j <= k - i; ++ j ) {
return nom / denom;
@@ -307,29 +367,37 @@ THREE.NURBSUtils = {
returns array with derivatives for rational curve.
calcRationalCurveDerivatives: function ( Pders ) {
var nd = Pders.length;
var Aders = [];
var wders = [];
- for (var i = 0; i < nd; ++ i) {
- var point = Pders[i];
- Aders[i] = new THREE.Vector3(point.x, point.y, point.z);
- wders[i] = point.w;
+ for ( var i = 0; i < nd; ++ i ) {
+ var point = Pders[ i ];
+ Aders[ i ] = new THREE.Vector3( point.x, point.y, point.z );
+ wders[ i ] = point.w;
- for (var k = 0; k < nd; ++ k) {
- var v = Aders[k].clone();
+ for ( var k = 0; k < nd; ++ k ) {
+ var v = Aders[ k ].clone();
+ for ( var i = 1; i <= k; ++ i ) {
+ v.sub( CK[ k - i ].clone().multiplyScalar( this.calcKoverI( k, i ) * wders[ i ] ) );
- for (var i = 1; i <= k; ++ i) {
- v.sub(CK[k - i].clone().multiplyScalar(this.calcKoverI(k, i) * wders[i]));
- CK[k] = v.divideScalar(wders[0]);
+ CK[ k ] = v.divideScalar( wders[ 0 ] );
@@ -345,8 +413,10 @@ THREE.NURBSUtils = {
returns array with derivatives.
calcNURBSDerivatives: function( p, U, P, u, nd ) {
- var Pders = this.calcBSplineDerivatives(p, U, P, u, nd);
- return this.calcRationalCurveDerivatives(Pders);
+ var Pders = this.calcBSplineDerivatives( p, U, P, u, nd );
+ return this.calcRationalCurveDerivatives( Pders );
@@ -361,31 +431,39 @@ THREE.NURBSUtils = {
returns point for given (u, v)
calcSurfacePoint: function( p, q, U, V, P, u, v ) {
- var uspan = this.findSpan(p, u, U);
- var vspan = this.findSpan(q, v, V);
- var Nu = this.calcBasisFunctions(uspan, u, p, U);
- var Nv = this.calcBasisFunctions(vspan, v, q, V);
+ var uspan = this.findSpan( p, u, U );
+ var vspan = this.findSpan( q, v, V );
+ var Nu = this.calcBasisFunctions( uspan, u, p, U );
+ var Nv = this.calcBasisFunctions( vspan, v, q, V );
var temp = [];
- for (var l = 0; l <= q; ++ l) {
- temp[l] = new THREE.Vector4(0, 0, 0, 0);
- for (var k = 0; k <= p; ++ k) {
- var point = P[uspan - p + k][vspan - q + l].clone();
+ for ( var l = 0; l <= q; ++ l ) {
+ temp[ l ] = new THREE.Vector4( 0, 0, 0, 0 );
+ for ( var k = 0; k <= p; ++ k ) {
+ var point = P[ uspan - p + k ][ vspan - q + l ].clone();
- temp[l].add(point.multiplyScalar(Nu[k]));
+ temp[ l ].add( point.multiplyScalar( Nu[ k ] ) );
- var Sw = new THREE.Vector4(0, 0, 0, 0);
- Sw.add(temp[l].multiplyScalar(Nv[l]));
+ var Sw = new THREE.Vector4( 0, 0, 0, 0 );
+ Sw.add( temp[ l ].multiplyScalar( Nv[ l ] ) );
- Sw.divideScalar(Sw.w);
- return new THREE.Vector3(Sw.x, Sw.y, Sw.z);
+ Sw.divideScalar( Sw.w );
+ return new THREE.Vector3( Sw.x, Sw.y, Sw.z );
@@ -17,7 +17,7 @@ THREE.AnaglyphEffect = function ( renderer, width, height ) {
var _cameraR = new THREE.PerspectiveCamera();
_cameraR.matrixAutoUpdate = false;
- var _camera = new THREE.OrthographicCamera( -1, 1, 1, - 1, 0, 1 );
+ var _camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
var _scene = new THREE.Scene();
@@ -49,7 +49,7 @@ THREE.AnaglyphEffect = function ( renderer, width, height ) {
@@ -71,7 +71,7 @@ THREE.AnaglyphEffect = function ( renderer, width, height ) {
@@ -124,26 +124,26 @@ THREE.AnaglyphEffect = function ( renderer, width, height ) {
// translate xOffset
- eyeRight.elements[12] = eyeSep;
- eyeLeft.elements[12] = -eyeSep;
+ eyeRight.elements[ 12 ] = eyeSep;
+ eyeLeft.elements[ 12 ] = - eyeSep;
// for left eye
- xmin = -ymax * _aspect + eyeSepOnProjection;
+ xmin = - ymax * _aspect + eyeSepOnProjection;
xmax = ymax * _aspect + eyeSepOnProjection;
- projectionMatrix.elements[0] = 2 * _near / ( xmax - xmin );
- projectionMatrix.elements[8] = ( xmax + xmin ) / ( xmax - xmin );
+ projectionMatrix.elements[ 0 ] = 2 * _near / ( xmax - xmin );
+ projectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );
_cameraL.projectionMatrix.copy( projectionMatrix );
// for right eye
- xmin = -ymax * _aspect - eyeSepOnProjection;
+ xmin = - ymax * _aspect - eyeSepOnProjection;
xmax = ymax * _aspect - eyeSepOnProjection;
_cameraR.projectionMatrix.copy( projectionMatrix );
@@ -168,8 +168,10 @@ THREE.AnaglyphEffect = function ( renderer, width, height ) {
this.dispose = function() {
if ( _renderTargetL ) _renderTargetL.dispose();
if ( _renderTargetR ) _renderTargetR.dispose();
@@ -17,25 +17,25 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
// darker bolder character set from https://github.com/saw/Canvas-ASCII-Art/
// ' .\'`^",:;Il!i~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$'.split('');
- if ( !options ) options = {};
+ if ( ! options ) options = {};
// Some ASCII settings
- var bResolution = !options['resolution'] ? 0.15 : options['resolution']; // Higher for more details
- var iScale = !options['scale'] ? 1 : options['scale'];
- var bColor = !options['color'] ? false : options['color']; // nice but slows down rendering!
- var bAlpha = !options['alpha'] ? false : options['alpha']; // Transparency
- var bBlock = !options['block'] ? false : options['block']; // blocked characters. like good O dos
- var bInvert = !options['invert'] ? false : options['invert']; // black is white, white is black
+ var bResolution = ! options[ 'resolution' ] ? 0.15 : options[ 'resolution' ]; // Higher for more details
+ var iScale = ! options[ 'scale' ] ? 1 : options[ 'scale' ];
+ var bColor = ! options[ 'color' ] ? false : options[ 'color' ]; // nice but slows down rendering!
+ var bAlpha = ! options[ 'alpha' ] ? false : options[ 'alpha' ]; // Transparency
+ var bBlock = ! options[ 'block' ] ? false : options[ 'block' ]; // blocked characters. like good O dos
+ var bInvert = ! options[ 'invert' ] ? false : options[ 'invert' ]; // black is white, white is black
var strResolution = 'low';
var width, height;
- var domElement = document.createElement('div');
+ var domElement = document.createElement( 'div' );
domElement.style.cursor = 'default';
- var oAscii = document.createElement("table");
+ var oAscii = document.createElement( "table" );
domElement.appendChild( oAscii );
var iWidth, iHeight;
@@ -86,8 +86,8 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
if ( oImg.style.backgroundColor ) {
- oAscii.rows[0].cells[0].style.backgroundColor = oImg.style.backgroundColor;
- oAscii.rows[0].cells[0].style.color = oImg.style.color;
+ oAscii.rows[ 0 ].cells[ 0 ].style.backgroundColor = oImg.style.backgroundColor;
+ oAscii.rows[ 0 ].cells[ 0 ].style.color = oImg.style.color;
@@ -96,8 +96,8 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
var oStyle = oAscii.style;
oStyle.display = "inline";
- oStyle.width = Math.round(iWidth / fResolution * iScale) + "px";
- oStyle.height = Math.round(iHeight / fResolution * iScale) + "px";
+ oStyle.width = Math.round( iWidth / fResolution * iScale ) + "px";
+ oStyle.height = Math.round( iHeight / fResolution * iScale ) + "px";
oStyle.whiteSpace = "pre";
oStyle.margin = "0px";
oStyle.padding = "0px";
@@ -107,28 +107,33 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
oStyle.lineHeight = fLineHeight + "px";
oStyle.textAlign = "left";
oStyle.textDecoration = "none";
- var aDefaultCharList = (" .,:;i1tfLCG08@").split("");
- var aDefaultColorCharList = (" CGO08@").split("");
+ var aDefaultCharList = ( " .,:;i1tfLCG08@" ).split( "" );
+ var aDefaultColorCharList = ( " CGO08@" ).split( "" );
var strFont = "courier new, monospace";
var oCanvasImg = renderer.domElement;
- var oCanvas = document.createElement("canvas");
- if (!oCanvas.getContext) {
+ var oCanvas = document.createElement( "canvas" );
+ if ( ! oCanvas.getContext ) {
- var oCtx = oCanvas.getContext("2d");
- if (!oCtx.getImageData) {
+ var oCtx = oCanvas.getContext( "2d" );
+ if ( ! oCtx.getImageData ) {
- var aCharList = (bColor ? aDefaultColorCharList : aDefaultCharList);
+ var aCharList = ( bColor ? aDefaultColorCharList : aDefaultCharList );
- if (charSet) aCharList = charSet;
+ if ( charSet ) aCharList = charSet;
var fResolution = 0.5;
@@ -144,8 +149,8 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
// Setup dom
- var fFontSize = (2 / fResolution) * iScale;
- var fLineHeight = (2 / fResolution) * iScale;
+ var fFontSize = ( 2 / fResolution ) * iScale;
+ var fLineHeight = ( 2 / fResolution ) * iScale;
// adjust letter-spacing for all combinations of scale and resolution to get it to fit the image width.
@@ -153,36 +158,36 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
if ( strResolution == "low" ) {
- switch (iScale) {
- case 1 : fLetterSpacing = -1; break;
+ switch ( iScale ) {
+ case 1 : fLetterSpacing = - 1; break;
case 2 :
- case 3 : fLetterSpacing = -2.1; break;
- case 4 : fLetterSpacing = -3.1; break;
- case 5 : fLetterSpacing = -4.15; break;
+ case 3 : fLetterSpacing = - 2.1; break;
+ case 4 : fLetterSpacing = - 3.1; break;
+ case 5 : fLetterSpacing = - 4.15; break;
if ( strResolution == "medium" ) {
case 1 : fLetterSpacing = 0; break;
- case 2 : fLetterSpacing = -1; break;
- case 3 : fLetterSpacing = -1.04; break;
+ case 2 : fLetterSpacing = - 1; break;
+ case 3 : fLetterSpacing = - 1.04; break;
case 4 :
- case 5 : fLetterSpacing = -2.1; break;
+ case 5 : fLetterSpacing = - 2.1; break;
if ( strResolution == "high" ) {
case 1 :
case 2 : fLetterSpacing = 0; break;
case 3 :
- case 5 : fLetterSpacing = -1; break;
+ case 5 : fLetterSpacing = - 1; break;
@@ -197,61 +202,72 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
oCtx.clearRect( 0, 0, iWidth, iHeight );
oCtx.drawImage( oCanvasImg, 0, 0, iWidth, iHeight );
- var oImgData = oCtx.getImageData(0, 0, iWidth, iHeight).data;
+ var oImgData = oCtx.getImageData( 0, 0, iWidth, iHeight ).data;
// Coloring loop starts now
var strChars = "";
// console.time('rendering');
- for (var y = 0; y < iHeight; y+=2) {
- for (var x = 0; x < iWidth; x ++) {
- var iOffset = (y * iWidth + x) * 4;
+ for ( var y = 0; y < iHeight; y += 2 ) {
- var iRed = oImgData[iOffset];
- var iGreen = oImgData[iOffset + 1];
- var iBlue = oImgData[iOffset + 2];
- var iAlpha = oImgData[iOffset + 3];
+ for ( var x = 0; x < iWidth; x ++ ) {
+ var iOffset = ( y * iWidth + x ) * 4;
+ var iRed = oImgData[ iOffset ];
+ var iGreen = oImgData[ iOffset + 1 ];
+ var iBlue = oImgData[ iOffset + 2 ];
+ var iAlpha = oImgData[ iOffset + 3 ];
var iCharIdx;
var fBrightness;
- fBrightness = (0.3 * iRed + 0.59 * iGreen + 0.11 * iBlue) / 255;
+ fBrightness = ( 0.3 * iRed + 0.59 * iGreen + 0.11 * iBlue ) / 255;
// fBrightness = (0.3*iRed + 0.5*iGreen + 0.3*iBlue) / 255;
- if (iAlpha == 0) {
+ if ( iAlpha == 0 ) {
// should calculate alpha instead, but quick hack :)
//fBrightness *= (iAlpha / 255);
fBrightness = 1;
- iCharIdx = Math.floor((1 - fBrightness) * (aCharList.length - 1));
+ iCharIdx = Math.floor( ( 1 - fBrightness ) * ( aCharList.length - 1 ) );
+ if ( bInvert ) {
- if (bInvert) {
iCharIdx = aCharList.length - iCharIdx - 1;
// good for debugging
//fBrightness = Math.floor(fBrightness * 10);
//strThisChar = fBrightness;
- var strThisChar = aCharList[iCharIdx];
+ var strThisChar = aCharList[ iCharIdx ];
- if (strThisChar === undefined || strThisChar == " ")
+ if ( strThisChar === undefined || strThisChar == " " )
strThisChar = " ";
- if (bColor) {
+ if ( bColor ) {
strChars += "<span style='"
+ "color:rgb(" + iRed + "," + iGreen + "," + iBlue + ");"
- + (bBlock ? "background-color:rgb(" + iRed + "," + iGreen + "," + iBlue + ");" : "")
- + (bAlpha ? "opacity:" + (iAlpha / 255) + ";" : "")
+ + ( bBlock ? "background-color:rgb(" + iRed + "," + iGreen + "," + iBlue + ");" : "" )
+ + ( bAlpha ? "opacity:" + ( iAlpha / 255 ) + ";" : "" )
+ "'>" + strThisChar + "</span>";
strChars += strThisChar;
strChars += "<br/>";
oAscii.innerHTML = "<tr><td>" + strChars + "</td></tr>";
@@ -259,6 +275,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
// console.timeEnd('rendering');
// return oAscii;
// end modified asciifyImage block
@@ -48,7 +48,7 @@ THREE.ParallaxBarrierEffect = function ( renderer ) {
@@ -72,7 +72,7 @@ THREE.ParallaxBarrierEffect = function ( renderer ) {
@@ -123,26 +123,26 @@ THREE.ParallaxBarrierEffect = function ( renderer ) {
@@ -19,20 +19,28 @@ THREE.StereoEffect = function ( renderer ) {
Object.defineProperties( this, {
separation: {
return scope.eyeSeparation;
set: function ( value ) {
console.warn( 'THREE.StereoEffect: .separation is now .eyeSeparation.' );
scope.eyeSeparation = value;
targetDistance: {
return scope.focalLength;
console.warn( 'THREE.StereoEffect: .targetDistance is now .focalLength.' );
scope.focalLength = value;
@@ -83,7 +91,7 @@ THREE.StereoEffect = function ( renderer ) {
_halfFocalWidth = _halfFocalHeight * 0.5 * camera.aspect;
_top = _halfFocalHeight * _ndfl;
- _bottom = -_top;
+ _bottom = - _top;
_innerFactor = ( _halfFocalWidth + this.eyeSeparation / 2.0 ) / ( _halfFocalWidth * 2.0 );
_outerFactor = 1.0 - _innerFactor;
@@ -93,7 +101,7 @@ THREE.StereoEffect = function ( renderer ) {
// left
_cameraL.projectionMatrix.makeFrustum(
- -_outer,
+ - _outer,
_inner,
_bottom,
_top,
@@ -108,7 +116,7 @@ THREE.StereoEffect = function ( renderer ) {
// right
_cameraR.projectionMatrix.makeFrustum(
- -_inner,
+ - _inner,
_outer,
@@ -172,10 +172,10 @@ THREE.VREffect = function ( renderer, onError ) {
function fovToNDCScaleOffset( fov ) {
- var pxscale = 2.0 / (fov.leftTan + fov.rightTan);
- var pxoffset = (fov.leftTan - fov.rightTan) * pxscale * 0.5;
- var pyscale = 2.0 / (fov.upTan + fov.downTan);
- var pyoffset = (fov.upTan - fov.downTan) * pyscale * 0.5;
+ var pxscale = 2.0 / ( fov.leftTan + fov.rightTan );
+ var pxoffset = ( fov.leftTan - fov.rightTan ) * pxscale * 0.5;
+ var pyscale = 2.0 / ( fov.upTan + fov.downTan );
+ var pyoffset = ( fov.upTan - fov.downTan ) * pyscale * 0.5;
return { scale: [ pxscale, pyscale ], offset: [ pxoffset, pyoffset ] };
@@ -186,44 +186,45 @@ THREE.VREffect = function ( renderer, onError ) {
zNear = zNear === undefined ? 0.01 : zNear;
zFar = zFar === undefined ? 10000.0 : zFar;
- var handednessScale = rightHanded ? -1.0 : 1.0;
+ var handednessScale = rightHanded ? - 1.0 : 1.0;
// start with an identity matrix
var mobj = new THREE.Matrix4();
var m = mobj.elements;
// and with scale/offset info for normalized device coords
- var scaleAndOffset = fovToNDCScaleOffset(fov);
+ var scaleAndOffset = fovToNDCScaleOffset( fov );
// X result, map clip edges to [-w,+w]
- m[0 * 4 + 0] = scaleAndOffset.scale[0];
- m[0 * 4 + 1] = 0.0;
- m[0 * 4 + 2] = scaleAndOffset.offset[0] * handednessScale;
- m[0 * 4 + 3] = 0.0;
+ m[ 0 * 4 + 0 ] = scaleAndOffset.scale[ 0 ];
+ m[ 0 * 4 + 1 ] = 0.0;
+ m[ 0 * 4 + 2 ] = scaleAndOffset.offset[ 0 ] * handednessScale;
+ m[ 0 * 4 + 3 ] = 0.0;
// Y result, map clip edges to [-w,+w]
// Y offset is negated because this proj matrix transforms from world coords with Y=up,
// but the NDC scaling has Y=down (thanks D3D?)
- m[1 * 4 + 0] = 0.0;
- m[1 * 4 + 1] = scaleAndOffset.scale[1];
- m[1 * 4 + 2] = -scaleAndOffset.offset[1] * handednessScale;
- m[1 * 4 + 3] = 0.0;
+ m[ 1 * 4 + 0 ] = 0.0;
+ m[ 1 * 4 + 1 ] = scaleAndOffset.scale[ 1 ];
+ m[ 1 * 4 + 2 ] = - scaleAndOffset.offset[ 1 ] * handednessScale;
+ m[ 1 * 4 + 3 ] = 0.0;
// Z result (up to the app)
- m[2 * 4 + 0] = 0.0;
- m[2 * 4 + 1] = 0.0;
- m[2 * 4 + 2] = zFar / (zNear - zFar) * -handednessScale;
- m[2 * 4 + 3] = (zFar * zNear) / (zNear - zFar);
+ m[ 2 * 4 + 0 ] = 0.0;
+ m[ 2 * 4 + 1 ] = 0.0;
+ m[ 2 * 4 + 2 ] = zFar / ( zNear - zFar ) * - handednessScale;
+ m[ 2 * 4 + 3 ] = ( zFar * zNear ) / ( zNear - zFar );
// W result (= Z in)
- m[3 * 4 + 0] = 0.0;
- m[3 * 4 + 1] = 0.0;
- m[3 * 4 + 2] = handednessScale;
- m[3 * 4 + 3] = 0.0;
+ m[ 3 * 4 + 0 ] = 0.0;
+ m[ 3 * 4 + 1 ] = 0.0;
+ m[ 3 * 4 + 2 ] = handednessScale;
+ m[ 3 * 4 + 3 ] = 0.0;
mobj.transpose();
return mobj;
function fovToProjection( fov, rightHanded, zNear, zFar ) {
@@ -19,20 +19,22 @@ THREE.STLBinaryExporter.prototype = {
var triangles = 0;
scene.traverse( function ( object ) {
- if ( !(object instanceof THREE.Mesh) ) return;
+ if ( ! ( object instanceof THREE.Mesh ) ) return;
triangles += object.geometry.faces.length;
var offset = 80; // skip header
var bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4;
- var arrayBuffer = new ArrayBuffer(bufferLength);
- var output = new DataView(arrayBuffer);
- output.setUint32(offset, triangles, true); offset += 4;
+ var arrayBuffer = new ArrayBuffer( bufferLength );
+ var output = new DataView( arrayBuffer );
+ output.setUint32( offset, triangles, true ); offset += 4;
- if ( !(object.geometry instanceof THREE.Geometry )) return;
+ if ( ! ( object.geometry instanceof THREE.Geometry ) ) return;
var geometry = object.geometry;
var matrixWorld = object.matrixWorld;
@@ -48,9 +50,9 @@ THREE.STLBinaryExporter.prototype = {
vector.copy( face.normal ).applyMatrix3( normalMatrixWorld ).normalize();
- output.setFloat32(offset, vector.x, true); offset += 4; // normal
- output.setFloat32(offset, vector.y, true); offset += 4;
- output.setFloat32(offset, vector.z, true); offset += 4;
+ output.setFloat32( offset, vector.x, true ); offset += 4; // normal
+ output.setFloat32( offset, vector.y, true ); offset += 4;
+ output.setFloat32( offset, vector.z, true ); offset += 4;
var indices = [ face.a, face.b, face.c ];
@@ -58,13 +60,13 @@ THREE.STLBinaryExporter.prototype = {
vector.copy( vertices[ indices[ j ] ] ).applyMatrix4( matrixWorld );
- output.setFloat32(offset, vector.x, true); offset += 4; // vertices
+ output.setFloat32( offset, vector.x, true ); offset += 4; // vertices
- output.setUint16(offset, 0, true); offset += 2; // attribute byte count
+ output.setUint16( offset, 0, true ); offset += 2; // attribute byte count
@@ -80,11 +80,14 @@ THREE.ConvexGeometry = function( vertices ) {
faces[ f ] = faces[ faces.length - 1 ];
faces.pop();
- } else { // not visible
+ // not visible
f ++;
// construct the new faces formed by the edges of the hole and the vertex
@@ -97,6 +100,7 @@ THREE.ConvexGeometry = function( vertices ) {
] );
/**
@@ -208,7 +212,7 @@ THREE.ConvexGeometry = function( vertices ) {
this.faceVertexUvs[ 0 ].push( [
vertexUv( this.vertices[ face.a ] ),
vertexUv( this.vertices[ face.b ] ),
- vertexUv( this.vertices[ face.c ])
+ vertexUv( this.vertices[ face.c ] )
@@ -79,20 +79,26 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
switch ( total ) {
case 0: {
outVertices.push( inVertices[ j ] );
outVertices.push( inVertices[ j + 1 ] );
outVertices.push( inVertices[ j + 2 ] );
case 1: {
var nV1, nV2, nV3;
if ( v1Out ) {
nV1 = inVertices[ j + 1 ];
nV2 = inVertices[ j + 2 ];
nV3 = clip( inVertices[ j ], nV1, plane );
nV4 = clip( inVertices[ j ], nV2, plane );
if ( v2Out ) {
nV1 = inVertices[ j ];
nV3 = clip( inVertices[ j + 1 ], nV1, plane );
@@ -106,12 +112,15 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
outVertices.push( nV3.clone() );
outVertices.push( nV4 );
if ( v3Out ) {
nV2 = inVertices[ j + 1 ];
nV3 = clip( inVertices[ j + 2 ], nV1, plane );
nV4 = clip( inVertices[ j + 2 ], nV2, plane );
outVertices.push( nV1.clone() );
@@ -123,38 +132,49 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
outVertices.push( nV2.clone() );
case 2: {
- if ( !v1Out ) {
+ if ( ! v1Out ) {
nV1 = inVertices[ j ].clone();
nV2 = clip( nV1, inVertices[ j + 1 ], plane );
nV3 = clip( nV1, inVertices[ j + 2 ], plane );
outVertices.push( nV1 );
outVertices.push( nV2 );
outVertices.push( nV3 );
- if ( !v2Out ) {
+ if ( ! v2Out ) {
nV1 = inVertices[ j + 1 ].clone();
nV2 = clip( nV1, inVertices[ j + 2 ], plane );
nV3 = clip( nV1, inVertices[ j ], plane );
- if ( !v3Out ) {
+ if ( ! v3Out ) {
nV1 = inVertices[ j + 2 ].clone();
nV2 = clip( nV1, inVertices[ j ], plane );
nV3 = clip( nV1, inVertices[ j + 1 ], plane );
case 3: {
@@ -187,16 +207,22 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) {
this.pushVertex( vertices, f[ this.faceIndices[ 2 ] ], f.vertexNormals[ 2 ] );
if ( check.x ) {
vertices = this.clipFace( vertices, new THREE.Vector3( 1, 0, 0 ) );
- vertices = this.clipFace( vertices, new THREE.Vector3( -1, 0, 0 ) );
+ vertices = this.clipFace( vertices, new THREE.Vector3( - 1, 0, 0 ) );
if ( check.y ) {
vertices = this.clipFace( vertices, new THREE.Vector3( 0, 1, 0 ) );
- vertices = this.clipFace( vertices, new THREE.Vector3( 0, -1, 0 ) );
+ vertices = this.clipFace( vertices, new THREE.Vector3( 0, - 1, 0 ) );
if ( check.z ) {
vertices = this.clipFace( vertices, new THREE.Vector3( 0, 0, 1 ) );
- vertices = this.clipFace( vertices, new THREE.Vector3( 0, 0, -1 ) );
+ vertices = this.clipFace( vertices, new THREE.Vector3( 0, 0, - 1 ) );
for ( var j = 0; j < vertices.length; j ++ ) {
@@ -15,9 +15,10 @@
* @param v2 Corner index +X, +Z.
* @param v3 Corner index +X, -Z.
-function hilbert2D (center, size, iterations, v0, v1, v2, v3) {
+function hilbert2D ( center, size, iterations, v0, v1, v2, v3 ) {
// Default Vars
- var center = undefined !== center ? center : new THREE.Vector3(0, 0, 0),
+ var center = undefined !== center ? center : new THREE.Vector3( 0, 0, 0 ),
size = undefined !== size ? size : 10,
half = size / 2,
iterations = undefined !== iterations ? iterations : 1,
@@ -42,7 +43,8 @@ function hilbert2D (center, size, iterations, v0, v1, v2, v3) {
];
// Recurse iterations
- if (0 <= -- iterations) {
+ if ( 0 <= -- iterations ) {
var tmp = [];
Array.prototype.push.apply( tmp, hilbert2D ( vec[ 0 ], half, iterations, v0, v3, v2, v1 ) );
@@ -52,8 +54,10 @@ function hilbert2D (center, size, iterations, v0, v1, v2, v3) {
// Return recursive call
return tmp;
// Return complete Hilbert Curve.
return vec;
@@ -24,9 +24,10 @@
* @param v6 Corner index +X, +Y, +Z.
* @param v7 Corner index +X, +Y, -Z.
-function hilbert3D(center, size, iterations, v0, v1, v2, v3, v4, v5, v6, v7) {
+function hilbert3D( center, size, iterations, v0, v1, v2, v3, v4, v5, v6, v7 ) {
@@ -64,6 +65,7 @@ function hilbert3D(center, size, iterations, v0, v1, v2, v3, v4, v5, v6, v7) {
if ( -- iterations >= 0 ) {
Array.prototype.push.apply( tmp, hilbert3D ( vec[ 0 ], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1 ) );
@@ -77,8 +79,10 @@ function hilbert3D(center, size, iterations, v0, v1, v2, v3, v4, v5, v6, v7) {
@@ -14,6 +14,7 @@
THREE.AssimpJSONLoader = function ( manager ) {
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
THREE.AssimpJSONLoader.prototype = {
@@ -29,109 +30,142 @@ THREE.AssimpJSONLoader.prototype = {
var loader = new THREE.XHRLoader( this.manager );
loader.setCrossOrigin( this.crossOrigin );
loader.load( url, function ( text ) {
var json = JSON.parse( text ), scene, metadata;
// Check __metadata__ meta header if present
// This header is used to disambiguate between
// different JSON-based file formats.
metadata = json.__metadata__;
- if ( typeof metadata !== 'undefined' )
+ if ( typeof metadata !== 'undefined' ) {
// Check if assimp2json at all
if ( metadata.format !== 'assimp2json' ) {
- onError('Not an assimp2json scene');
+ onError( 'Not an assimp2json scene' );
// Check major format version
else if ( metadata.version < 100 && metadata.version >= 200 ) {
- onError('Unsupported assimp2json file format version');
+ onError( 'Unsupported assimp2json file format version' );
scene = scope.parse( json );
onLoad( scene );
}, onProgress, onError );
setCrossOrigin: function ( value ) {
this.crossOrigin = value;
setTexturePath: function ( value ) {
this.texturePath = value;
- extractUrlBase: function ( url ) { // from three/src/loaders/Loader.js
+ extractUrlBase: function ( url ) {
+ // from three/src/loaders/Loader.js
var parts = url.split( '/' );
parts.pop();
return ( parts.length < 1 ? '.' : parts.join( '/' ) ) + '/';
parse: function ( json ) {
var meshes = this.parseList ( json.meshes, this.parseMesh );
var materials = this.parseList ( json.materials, this.parseMaterial );
return this.parseObject( json, json.rootnode, meshes, materials );
- parseList : function(json, handler) {
- var meshes = new Array(json.length);
- for (var i = 0; i < json.length; ++ i) {
- meshes[i] = handler.call(this, json[i]);
+ parseList : function( json, handler ) {
+ var meshes = new Array( json.length );
+ for ( var i = 0; i < json.length; ++ i ) {
+ meshes[ i ] = handler.call( this, json[ i ] );
return meshes;
- parseMesh : function(json) {
+ parseMesh : function( json ) {
var vertex, geometry, i, e, in_data, src;
geometry = new THREE.Geometry();
// read vertex positions
- for (in_data = json.vertices, i = 0, e = in_data.length; i < e; ) {
+ for ( in_data = json.vertices, i = 0, e = in_data.length; i < e; ) {
geometry.vertices.push( new THREE.Vector3( in_data[ i ++ ], in_data[ i ++ ], in_data[ i ++ ] ) );
// read faces
var cnt = 0;
- for (in_data = json.faces, i = 0, e = in_data.length; i < e; ++ i) {
- src = in_data[i];
- face = new THREE.Face3(src[0],src[1],src[2]);
- geometry.faces.push(face);
+ for ( in_data = json.faces, i = 0, e = in_data.length; i < e; ++ i ) {
+ src = in_data[ i ];
+ face = new THREE.Face3( src[ 0 ], src[ 1 ], src[ 2 ] );
+ geometry.faces.push( face );
// read texture coordinates - three.js attaches them to its faces
json.texturecoords = json.texturecoords || [];
- for (i = 0, e = json.texturecoords.length; i < e; ++ i) {
+ for ( i = 0, e = json.texturecoords.length; i < e; ++ i ) {
+ function convertTextureCoords( in_uv, out_faces, out_vertex_uvs ) {
- function convertTextureCoords(in_uv, out_faces, out_vertex_uvs) {
var i, e, face, a, b, c;
- for (i = 0, e = out_faces.length; i < e; ++ i) {
- face = out_faces[i];
+ for ( i = 0, e = out_faces.length; i < e; ++ i ) {
+ face = out_faces[ i ];
a = face.a * 2;
b = face.b * 2;
c = face.c * 2;
- out_vertex_uvs.push([
+ out_vertex_uvs.push( [
new THREE.Vector2( in_uv[ a ], in_uv[ a + 1 ] ),
new THREE.Vector2( in_uv[ b ], in_uv[ b + 1 ] ),
new THREE.Vector2( in_uv[ c ], in_uv[ c + 1 ] )
- convertTextureCoords(json.texturecoords[i], geometry.faces, geometry.faceVertexUvs[i]);
+ convertTextureCoords( json.texturecoords[ i ], geometry.faces, geometry.faceVertexUvs[ i ] );
// read normals - three.js also attaches them to its faces
- if (json.normals) {
+ if ( json.normals ) {
+ function convertNormals( in_nor, out_faces ) {
- function convertNormals(in_nor, out_faces) {
a = face.a * 3;
b = face.b * 3;
c = face.c * 3;
@@ -140,27 +174,34 @@ THREE.AssimpJSONLoader.prototype = {
new THREE.Vector3( in_nor[ b ], in_nor[ b + 1 ], in_nor[ b + 2 ] ),
new THREE.Vector3( in_nor[ c ], in_nor[ c + 1 ], in_nor[ c + 2 ] )
- convertNormals(json.normals, geometry.faces);
+ convertNormals( json.normals, geometry.faces );
// read vertex colors - three.js also attaches them to its faces
- if (json.colors && json.colors[0]) {
+ if ( json.colors && json.colors[ 0 ] ) {
+ function convertColors( in_color, out_faces ) {
- function convertColors(in_color, out_faces) {
- function makeColor(start) {
+ function makeColor( start ) {
var col = new THREE.Color( );
- col.setRGB( arr[0], arr[1], arr[2] );
+ col.setRGB( arr[ 0 ], arr[ 1 ], arr[ 2 ] );
// TODO: what about alpha?
return col;
a = face.a * 4;
b = face.b * 4;
c = face.c * 4;
@@ -169,10 +210,13 @@ THREE.AssimpJSONLoader.prototype = {
makeColor( b ),
makeColor( c )
- convertColors(json.colors[0], geometry.faces);
+ convertColors( json.colors[ 0 ], geometry.faces );
@@ -183,9 +227,11 @@ THREE.AssimpJSONLoader.prototype = {
// TODO: tangents
return geometry;
- parseMaterial : function(json) {
+ parseMaterial : function( json ) {
var mat = null,
scope = this, i, prop, has_textures = [],
@@ -193,120 +239,160 @@ THREE.AssimpJSONLoader.prototype = {
shading : THREE.SmoothShading
- function toColor(value_arr) {
+ function toColor( value_arr ) {
var col = new THREE.Color();
- col.setRGB(value_arr[0], value_arr[1], value_arr[2]);
+ col.setRGB( value_arr[ 0 ], value_arr[ 1 ], value_arr[ 2 ] );
function defaultTexture() {
var im = new Image();
im.width = 1;
im.height = 1;
- return new THREE.Texture(im);
+ return new THREE.Texture( im );
- for (var i in json.properties) {
- prop = json.properties[i];
+ for ( var i in json.properties ) {
+ prop = json.properties[ i ];
+ if ( prop.key === '$tex.file' ) {
- if (prop.key === '$tex.file') {
// prop.semantic gives the type of the texture
// 1: diffuse
// 2: specular mao
// 5: height map (bumps)
// 6: normal map
// more values (i.e. emissive, environment) are known by assimp and may be relevant
- if (prop.semantic === 1 || prop.semantic === 5 || prop.semantic === 6 || prop.semantic === 2) {
- (function(semantic) {
- var loader = new THREE.TextureLoader(scope.manager),
+ if ( prop.semantic === 1 || prop.semantic === 5 || prop.semantic === 6 || prop.semantic === 2 ) {
+ ( function( semantic ) {
+ var loader = new THREE.TextureLoader( scope.manager ),
keyname;
- if (semantic === 1) {
+ if ( semantic === 1 ) {
keyname = 'map';
- else if (semantic === 5) {
+ } else if ( semantic === 5 ) {
keyname = 'bumpMap';
- else if (semantic === 6) {
+ } else if ( semantic === 6 ) {
keyname = 'normalMap';
- else if (semantic === 2) {
+ } else if ( semantic === 2 ) {
keyname = 'specularMap';
- has_textures.push(keyname);
+ has_textures.push( keyname );
- loader.setCrossOrigin(this.crossOrigin);
+ loader.setCrossOrigin( this.crossOrigin );
var material_url = scope.texturePath + '/' + prop.value;
- material_url = material_url.replace(/\\/g, '/');
- loader.load(material_url, function(tex) {
- if (tex) {
+ material_url = material_url.replace( /\\/g, '/' );
+ loader.load( material_url, function( tex ) {
+ if ( tex ) {
// TODO: read texture settings from assimp.
// Wrapping is the default, though.
tex.wrapS = tex.wrapT = THREE.RepeatWrapping;
- mat[keyname] = tex;
+ mat[ keyname ] = tex;
mat.needsUpdate = true;
- })(prop.semantic);
+ } )( prop.semantic );
- else if (prop.key === '?mat.name') {
+ } else if ( prop.key === '?mat.name' ) {
init_props.name = prop.value;
- else if (prop.key === '$clr.diffuse') {
- init_props.color = toColor(prop.value);
- else if (prop.key === '$clr.specular') {
- init_props.specular = toColor(prop.value);
- else if (prop.key === '$clr.emissive') {
- init_props.emissive = toColor(prop.value);
- else if (prop.key === '$mat.shadingm') {
+ } else if ( prop.key === '$clr.diffuse' ) {
+ init_props.color = toColor( prop.value );
+ } else if ( prop.key === '$clr.specular' ) {
+ init_props.specular = toColor( prop.value );
+ } else if ( prop.key === '$clr.emissive' ) {
+ init_props.emissive = toColor( prop.value );
+ } else if ( prop.key === '$mat.shadingm' ) {
// aiShadingMode_Flat
- if (prop.value === 1) {
+ if ( prop.value === 1 ) {
init_props.shading = THREE.FlatShading;
- else if (prop.key === '$mat.shininess') {
+ } else if ( prop.key === '$mat.shininess' ) {
init_props.shininess = prop.value;
// note: three.js does not like it when a texture is added after the geometry
// has been rendered once, see http://stackoverflow.com/questions/16531759/.
// for this reason we fill all slots upfront with default textures
- if (has_textures.length) {
- for (i = has_textures.length - 1; i >= 0; -- i) {
- init_props[has_textures[i]] = defaultTexture();
+ if ( has_textures.length ) {
+ for ( i = has_textures.length - 1; i >= 0; -- i ) {
+ init_props[ has_textures[ i ]] = defaultTexture();
mat = new THREE.MeshPhongMaterial( init_props );
return mat;
- parseObject : function(json, node, meshes, materials) {
+ parseObject : function( json, node, meshes, materials ) {
var obj = new THREE.Object3D()
, i
, idx
;
obj.name = node.name || "";
- obj.matrix = new THREE.Matrix4().fromArray(node.transformation).transpose();
+ obj.matrix = new THREE.Matrix4().fromArray( node.transformation ).transpose();
obj.matrix.decompose( obj.position, obj.quaternion, obj.scale );
- for (i = 0; node.meshes && i < node.meshes.length; ++ i) {
- idx = node.meshes[i];
- obj.add(new THREE.Mesh( meshes[idx], materials[json.meshes[idx].materialindex] ));
+ for ( i = 0; node.meshes && i < node.meshes.length; ++ i ) {
+ idx = node.meshes[ i ];
+ obj.add( new THREE.Mesh( meshes[ idx ], materials[ json.meshes[ idx ].materialindex ] ) );
- for (i = 0; node.children && i < node.children.length; ++ i) {
- obj.add(this.parseObject(json, node.children[i], meshes, materials));
+ for ( i = 0; node.children && i < node.children.length; ++ i ) {
+ obj.add( this.parseObject( json, node.children[ i ], meshes, materials ) );
return obj;
@@ -50,7 +50,7 @@ THREE.BinaryLoader.prototype = {
scope.parse( bufData, onLoad, texturePath, json.materials );
- }, onProgress, onError);
+ }, onProgress, onError );
@@ -95,12 +95,12 @@ THREE.BinaryLoader.prototype = {
md = parseMetaData( data, currentOffset );
currentOffset += md.header_bytes;
- md.vertex_index_bytes = Uint32Array.BYTES_PER_ELEMENT;
- md.material_index_bytes = Uint16Array.BYTES_PER_ELEMENT;
- md.normal_index_bytes = Uint32Array.BYTES_PER_ELEMENT;
- md.uv_index_bytes = Uint32Array.BYTES_PER_ELEMENT;
+ md.vertex_index_bytes = Uint32Array.BYTES_PER_ELEMENT;
+ md.material_index_bytes = Uint16Array.BYTES_PER_ELEMENT;
+ md.normal_index_bytes = Uint32Array.BYTES_PER_ELEMENT;
+ md.uv_index_bytes = Uint32Array.BYTES_PER_ELEMENT;
// buffers sizes
tri_size = md.vertex_index_bytes * 3 + md.material_index_bytes;
@@ -133,7 +133,7 @@ THREE.BinaryLoader.prototype = {
start_quad_flat = start_tri_smooth_uv + len_tri_smooth_uv + handlePadding( md.ntri_smooth_uv * 2 );
start_quad_smooth = start_quad_flat + len_quad_flat + handlePadding( md.nquad_flat * 2 );
start_quad_flat_uv = start_quad_smooth + len_quad_smooth + handlePadding( md.nquad_smooth * 2 );
- start_quad_smooth_uv= start_quad_flat_uv + len_quad_flat_uv + handlePadding( md.nquad_flat_uv * 2 );
+ start_quad_smooth_uv = start_quad_flat_uv + len_quad_flat_uv + handlePadding( md.nquad_flat_uv * 2 );
// have to first process faces with uvs
// so that face and uv indices match
@@ -164,75 +164,75 @@ THREE.BinaryLoader.prototype = {
var metaData = {
- 'signature' :parseString( data, offset, 12 ),
- 'header_bytes' :parseUChar8( data, offset + 12 ),
+ 'signature' : parseString( data, offset, 12 ),
+ 'header_bytes' : parseUChar8( data, offset + 12 ),
- 'vertex_coordinate_bytes' :parseUChar8( data, offset + 13 ),
- 'normal_coordinate_bytes' :parseUChar8( data, offset + 14 ),
- 'uv_coordinate_bytes' :parseUChar8( data, offset + 15 ),
+ 'vertex_coordinate_bytes' : parseUChar8( data, offset + 13 ),
+ 'normal_coordinate_bytes' : parseUChar8( data, offset + 14 ),
+ 'uv_coordinate_bytes' : parseUChar8( data, offset + 15 ),
- 'vertex_index_bytes' :parseUChar8( data, offset + 16 ),
- 'normal_index_bytes' :parseUChar8( data, offset + 17 ),
- 'uv_index_bytes' :parseUChar8( data, offset + 18 ),
- 'material_index_bytes' :parseUChar8( data, offset + 19 ),
+ 'vertex_index_bytes' : parseUChar8( data, offset + 16 ),
+ 'normal_index_bytes' : parseUChar8( data, offset + 17 ),
+ 'uv_index_bytes' : parseUChar8( data, offset + 18 ),
+ 'material_index_bytes' : parseUChar8( data, offset + 19 ),
- 'nvertices' :parseUInt32( data, offset + 20 ),
- 'nnormals' :parseUInt32( data, offset + 20 + 4*1 ),
- 'nuvs' :parseUInt32( data, offset + 20 + 4*2 ),
+ 'nvertices' : parseUInt32( data, offset + 20 ),
+ 'nnormals' : parseUInt32( data, offset + 20 + 4 * 1 ),
+ 'nuvs' : parseUInt32( data, offset + 20 + 4 * 2 ),
- 'ntri_flat' :parseUInt32( data, offset + 20 + 4*3 ),
- 'ntri_smooth' :parseUInt32( data, offset + 20 + 4*4 ),
- 'ntri_flat_uv' :parseUInt32( data, offset + 20 + 4*5 ),
- 'ntri_smooth_uv' :parseUInt32( data, offset + 20 + 4*6 ),
+ 'ntri_flat' : parseUInt32( data, offset + 20 + 4 * 3 ),
+ 'ntri_smooth' : parseUInt32( data, offset + 20 + 4 * 4 ),
+ 'ntri_flat_uv' : parseUInt32( data, offset + 20 + 4 * 5 ),
+ 'ntri_smooth_uv' : parseUInt32( data, offset + 20 + 4 * 6 ),
- 'nquad_flat' :parseUInt32( data, offset + 20 + 4*7 ),
- 'nquad_smooth' :parseUInt32( data, offset + 20 + 4*8 ),
- 'nquad_flat_uv' :parseUInt32( data, offset + 20 + 4*9 ),
- 'nquad_smooth_uv' :parseUInt32( data, offset + 20 + 4*10 )
+ 'nquad_flat' : parseUInt32( data, offset + 20 + 4 * 7 ),
+ 'nquad_smooth' : parseUInt32( data, offset + 20 + 4 * 8 ),
+ 'nquad_flat_uv' : parseUInt32( data, offset + 20 + 4 * 9 ),
+ 'nquad_smooth_uv' : parseUInt32( data, offset + 20 + 4 * 10 )
- console.log( "signature: " + metaData.signature );
- console.log( "header_bytes: " + metaData.header_bytes );
- console.log( "vertex_coordinate_bytes: " + metaData.vertex_coordinate_bytes );
- console.log( "normal_coordinate_bytes: " + metaData.normal_coordinate_bytes );
- console.log( "uv_coordinate_bytes: " + metaData.uv_coordinate_bytes );
- console.log( "vertex_index_bytes: " + metaData.vertex_index_bytes );
- console.log( "normal_index_bytes: " + metaData.normal_index_bytes );
- console.log( "uv_index_bytes: " + metaData.uv_index_bytes );
- console.log( "material_index_bytes: " + metaData.material_index_bytes );
- console.log( "nvertices: " + metaData.nvertices );
- console.log( "nnormals: " + metaData.nnormals );
- console.log( "nuvs: " + metaData.nuvs );
- console.log( "ntri_flat: " + metaData.ntri_flat );
- console.log( "ntri_smooth: " + metaData.ntri_smooth );
- console.log( "ntri_flat_uv: " + metaData.ntri_flat_uv );
- console.log( "ntri_smooth_uv: " + metaData.ntri_smooth_uv );
- console.log( "nquad_flat: " + metaData.nquad_flat );
- console.log( "nquad_smooth: " + metaData.nquad_smooth );
- console.log( "nquad_flat_uv: " + metaData.nquad_flat_uv );
- console.log( "nquad_smooth_uv: " + metaData.nquad_smooth_uv );
- var total = metaData.header_bytes
- + metaData.nvertices * metaData.vertex_coordinate_bytes * 3
- + metaData.nnormals * metaData.normal_coordinate_bytes * 3
- + metaData.nuvs * metaData.uv_coordinate_bytes * 2
- + metaData.ntri_flat * ( metaData.vertex_index_bytes*3 + metaData.material_index_bytes )
- + metaData.ntri_smooth * ( metaData.vertex_index_bytes*3 + metaData.material_index_bytes + metaData.normal_index_bytes*3 )
- + metaData.ntri_flat_uv * ( metaData.vertex_index_bytes*3 + metaData.material_index_bytes + metaData.uv_index_bytes*3 )
- + metaData.ntri_smooth_uv * ( metaData.vertex_index_bytes*3 + metaData.material_index_bytes + metaData.normal_index_bytes*3 + metaData.uv_index_bytes*3 )
- + metaData.nquad_flat * ( metaData.vertex_index_bytes*4 + metaData.material_index_bytes )
- + metaData.nquad_smooth * ( metaData.vertex_index_bytes*4 + metaData.material_index_bytes + metaData.normal_index_bytes*4 )
- + metaData.nquad_flat_uv * ( metaData.vertex_index_bytes*4 + metaData.material_index_bytes + metaData.uv_index_bytes*4 )
- + metaData.nquad_smooth_uv * ( metaData.vertex_index_bytes*4 + metaData.material_index_bytes + metaData.normal_index_bytes*4 + metaData.uv_index_bytes*4 );
- console.log( "total bytes: " + total );
+ console.log( "signature: " + metaData.signature );
+ console.log( "header_bytes: " + metaData.header_bytes );
+ console.log( "vertex_coordinate_bytes: " + metaData.vertex_coordinate_bytes );
+ console.log( "normal_coordinate_bytes: " + metaData.normal_coordinate_bytes );
+ console.log( "uv_coordinate_bytes: " + metaData.uv_coordinate_bytes );
+ console.log( "vertex_index_bytes: " + metaData.vertex_index_bytes );
+ console.log( "normal_index_bytes: " + metaData.normal_index_bytes );
+ console.log( "uv_index_bytes: " + metaData.uv_index_bytes );
+ console.log( "material_index_bytes: " + metaData.material_index_bytes );
+ console.log( "nvertices: " + metaData.nvertices );
+ console.log( "nnormals: " + metaData.nnormals );
+ console.log( "nuvs: " + metaData.nuvs );
+ console.log( "ntri_flat: " + metaData.ntri_flat );
+ console.log( "ntri_smooth: " + metaData.ntri_smooth );
+ console.log( "ntri_flat_uv: " + metaData.ntri_flat_uv );
+ console.log( "ntri_smooth_uv: " + metaData.ntri_smooth_uv );
+ console.log( "nquad_flat: " + metaData.nquad_flat );
+ console.log( "nquad_smooth: " + metaData.nquad_smooth );
+ console.log( "nquad_flat_uv: " + metaData.nquad_flat_uv );
+ console.log( "nquad_smooth_uv: " + metaData.nquad_smooth_uv );
+ var total = metaData.header_bytes
+ + metaData.nvertices * metaData.vertex_coordinate_bytes * 3
+ + metaData.nnormals * metaData.normal_coordinate_bytes * 3
+ + metaData.nuvs * metaData.uv_coordinate_bytes * 2
+ + metaData.ntri_flat * ( metaData.vertex_index_bytes*3 + metaData.material_index_bytes )
+ + metaData.ntri_smooth * ( metaData.vertex_index_bytes*3 + metaData.material_index_bytes + metaData.normal_index_bytes*3 )
+ + metaData.ntri_flat_uv * ( metaData.vertex_index_bytes*3 + metaData.material_index_bytes + metaData.uv_index_bytes*3 )
+ + metaData.ntri_smooth_uv * ( metaData.vertex_index_bytes*3 + metaData.material_index_bytes + metaData.normal_index_bytes*3 + metaData.uv_index_bytes*3 )
+ + metaData.nquad_flat * ( metaData.vertex_index_bytes*4 + metaData.material_index_bytes )
+ + metaData.nquad_smooth * ( metaData.vertex_index_bytes*4 + metaData.material_index_bytes + metaData.normal_index_bytes*4 )
+ + metaData.nquad_flat_uv * ( metaData.vertex_index_bytes*4 + metaData.material_index_bytes + metaData.uv_index_bytes*4 )
+ + metaData.nquad_smooth_uv * ( metaData.vertex_index_bytes*4 + metaData.material_index_bytes + metaData.normal_index_bytes*4 + metaData.uv_index_bytes*4 );
+ console.log( "total bytes: " + total );
return metaData;
@@ -277,7 +277,7 @@ THREE.BinaryLoader.prototype = {
var i, x, y, z;
- for( i = 0; i < nElements; i ++ ) {
+ for ( i = 0; i < nElements; i ++ ) {
x = coordArray[ i * 3 ];
y = coordArray[ i * 3 + 1 ];
@@ -301,13 +301,13 @@ THREE.BinaryLoader.prototype = {
x = normalArray[ i * 3 ];
y = normalArray[ i * 3 + 1 ];
z = normalArray[ i * 3 + 2 ];
- normals.push( x/127, y/127, z/127 );
+ normals.push( x / 127, y / 127, z / 127 );
@@ -327,7 +327,7 @@ THREE.BinaryLoader.prototype = {
var i, u, v;
u = uvArray[ i * 2 ];
v = uvArray[ i * 2 + 1 ];
@@ -348,20 +348,20 @@ THREE.BinaryLoader.prototype = {
var uvIndexBuffer = new Uint32Array( data, offset, 3 * nElements );
uva = uvIndexBuffer[ i * 3 ];
uvb = uvIndexBuffer[ i * 3 + 1 ];
uvc = uvIndexBuffer[ i * 3 + 2 ];
- u1 = uvs[ uva*2 ];
- v1 = uvs[ uva*2 + 1 ];
+ u1 = uvs[ uva * 2 ];
+ v1 = uvs[ uva * 2 + 1 ];
- u2 = uvs[ uvb*2 ];
- v2 = uvs[ uvb*2 + 1 ];
+ u2 = uvs[ uvb * 2 ];
+ v2 = uvs[ uvb * 2 + 1 ];
- u3 = uvs[ uvc*2 ];
- v3 = uvs[ uvc*2 + 1 ];
+ u3 = uvs[ uvc * 2 ];
+ v3 = uvs[ uvc * 2 + 1 ];
scope.faceVertexUvs[ 0 ].push( [
new THREE.Vector2( u1, v1 ),
@@ -379,24 +379,24 @@ THREE.BinaryLoader.prototype = {
var uvIndexBuffer = new Uint32Array( data, offset, 4 * nElements );
uva = uvIndexBuffer[ i * 4 ];
uvb = uvIndexBuffer[ i * 4 + 1 ];
uvc = uvIndexBuffer[ i * 4 + 2 ];
uvd = uvIndexBuffer[ i * 4 + 3 ];
- u4 = uvs[ uvd*2 ];
- v4 = uvs[ uvd*2 + 1 ];
+ u4 = uvs[ uvd * 2 ];
+ v4 = uvs[ uvd * 2 + 1 ];
@@ -421,7 +421,7 @@ THREE.BinaryLoader.prototype = {
var vertexIndexBuffer = new Uint32Array( data, offsetVertices, 3 * nElements );
var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements );
a = vertexIndexBuffer[ i * 3 ];
b = vertexIndexBuffer[ i * 3 + 1 ];
@@ -442,7 +442,7 @@ THREE.BinaryLoader.prototype = {
var vertexIndexBuffer = new Uint32Array( data, offsetVertices, 4 * nElements );
a = vertexIndexBuffer[ i * 4 ];
b = vertexIndexBuffer[ i * 4 + 1 ];
@@ -467,7 +467,7 @@ THREE.BinaryLoader.prototype = {
var normalIndexBuffer = new Uint32Array( data, offsetNormals, 3 * nElements );
@@ -479,17 +479,17 @@ THREE.BinaryLoader.prototype = {
m = materialIndexBuffer[ i ];
- var nax = normals[ na*3 ],
- nay = normals[ na*3 + 1 ],
- naz = normals[ na*3 + 2 ],
+ var nax = normals[ na * 3 ],
+ nay = normals[ na * 3 + 1 ],
+ naz = normals[ na * 3 + 2 ],
- nbx = normals[ nb*3 ],
- nby = normals[ nb*3 + 1 ],
- nbz = normals[ nb*3 + 2 ],
+ nbx = normals[ nb * 3 ],
+ nby = normals[ nb * 3 + 1 ],
+ nbz = normals[ nb * 3 + 2 ],
- ncx = normals[ nc*3 ],
- ncy = normals[ nc*3 + 1 ],
- ncz = normals[ nc*3 + 2 ];
+ ncx = normals[ nc * 3 ],
+ ncy = normals[ nc * 3 + 1 ],
+ ncz = normals[ nc * 3 + 2 ];
scope.faces.push( new THREE.Face3( a, b, c, [
new THREE.Vector3( nax, nay, naz ),
@@ -510,7 +510,7 @@ THREE.BinaryLoader.prototype = {
var normalIndexBuffer = new Uint32Array( data, offsetNormals, 4 * nElements );
@@ -524,21 +524,21 @@ THREE.BinaryLoader.prototype = {
- ncz = normals[ nc*3 + 2 ],
+ ncz = normals[ nc * 3 + 2 ],
- ndx = normals[ nd*3 ],
- ndy = normals[ nd*3 + 1 ],
- ndz = normals[ nd*3 + 2 ];
+ ndx = normals[ nd * 3 ],
+ ndy = normals[ nd * 3 + 1 ],
+ ndz = normals[ nd * 3 + 2 ];
scope.faces.push( new THREE.Face3( a, b, d, [
@@ -3,7 +3,9 @@
THREE.DDSLoader = function () {
this._parser = THREE.DDSLoader.parse;
THREE.DDSLoader.prototype = Object.create( THREE.CompressedTextureLoader.prototype );
@@ -52,10 +54,10 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
function fourCCToInt32( value ) {
- return value.charCodeAt(0) +
- (value.charCodeAt(1) << 8) +
- (value.charCodeAt(2) << 16) +
- (value.charCodeAt(3) << 24);
+ return value.charCodeAt( 0 ) +
+ ( value.charCodeAt( 1 ) << 8 ) +
+ ( value.charCodeAt( 2 ) << 16 ) +
+ ( value.charCodeAt( 3 ) << 24 );
@@ -63,36 +65,43 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
return String.fromCharCode(
value & 0xff,
- (value >> 8) & 0xff,
- (value >> 16) & 0xff,
- (value >> 24) & 0xff
+ ( value >> 8 ) & 0xff,
+ ( value >> 16 ) & 0xff,
+ ( value >> 24 ) & 0xff
function loadARGBMip( buffer, dataOffset, width, height ) {
var dataLength = width * height * 4;
var srcBuffer = new Uint8Array( buffer, dataOffset, dataLength );
var byteArray = new Uint8Array( dataLength );
var dst = 0;
var src = 0;
for ( var y = 0; y < height; y ++ ) {
for ( var x = 0; x < width; x ++ ) {
- var b = srcBuffer[src]; src ++;
- var g = srcBuffer[src]; src ++;
- var r = srcBuffer[src]; src ++;
- var a = srcBuffer[src]; src ++;
- byteArray[dst] = r; dst ++; //r
- byteArray[dst] = g; dst ++; //g
- byteArray[dst] = b; dst ++; //b
- byteArray[dst] = a; dst ++; //a
+ var b = srcBuffer[ src ]; src ++;
+ var g = srcBuffer[ src ]; src ++;
+ var r = srcBuffer[ src ]; src ++;
+ var a = srcBuffer[ src ]; src ++;
+ byteArray[ dst ] = r; dst ++; //r
+ byteArray[ dst ] = g; dst ++; //g
+ byteArray[ dst ] = b; dst ++; //b
+ byteArray[ dst ] = a; dst ++; //a
return byteArray;
- var FOURCC_DXT1 = fourCCToInt32("DXT1");
- var FOURCC_DXT3 = fourCCToInt32("DXT3");
- var FOURCC_DXT5 = fourCCToInt32("DXT5");
+ var FOURCC_DXT1 = fourCCToInt32( "DXT1" );
+ var FOURCC_DXT3 = fourCCToInt32( "DXT3" );
+ var FOURCC_DXT5 = fourCCToInt32( "DXT5" );
var headerLengthInt = 31; // The header length in 32 bit ints
@@ -166,17 +175,21 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
default:
- if ( header[off_RGBBitCount] == 32
- && header[off_RBitMask]&0xff0000
- && header[off_GBitMask]&0xff00
- && header[off_BBitMask]&0xff
- && header[off_ABitMask]&0xff000000 ) {
+ if ( header[ off_RGBBitCount ] == 32
+ && header[ off_RBitMask ] & 0xff0000
+ && header[ off_GBitMask ] & 0xff00
+ && header[ off_BBitMask ] & 0xff
+ && header[ off_ABitMask ] & 0xff000000 ) {
isRGBAUncompressed = true;
blockBytes = 64;
dds.format = THREE.RGBAFormat;
console.error( 'THREE.DDSLoader.parse: Unsupported FourCC code ', int32ToFourCC( fourCC ) );
return dds;
@@ -209,11 +222,15 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) {
for ( var i = 0; i < dds.mipmapCount; i ++ ) {
if ( isRGBAUncompressed ) {
var byteArray = loadARGBMip( buffer, dataOffset, width, height );
var dataLength = byteArray.length;
var dataLength = Math.max( 4, width ) / 4 * Math.max( 4, height ) / 4 * blockBytes;
var byteArray = new Uint8Array( buffer, dataOffset, dataLength );
var mipmap = { "data": byteArray, "width": width, "height": height };
@@ -90,7 +90,7 @@ THREE.MTLLoader.prototype = {
if ( key === "ka" || key === "kd" || key === "ks" ) {
var ss = value.split( delimiter_pattern, 3 );
- info[ key ] = [ parseFloat( ss[0] ), parseFloat( ss[1] ), parseFloat( ss[2] ) ];
+ info[ key ] = [ parseFloat( ss[ 0 ] ), parseFloat( ss[ 1 ] ), parseFloat( ss[ 2 ] ) ];
@@ -170,7 +170,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
convert: function( materialsInfo ) {
- if ( !this.options ) return materialsInfo;
+ if ( ! this.options ) return materialsInfo;
var converted = {};
@@ -213,6 +213,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
save = false;
@@ -350,7 +351,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
// The specular exponent (defines the focus of the specular highlight)
// A high exponent results in a tight, concentrated highlight. Ns values normally range from 0 to 1000.
- params['shininess'] = value;
+ params[ 'shininess' ] = value;
@@ -362,8 +363,8 @@ THREE.MTLLoader.MaterialCreator.prototype = {
if ( value < 1 ) {
- params['transparent'] = true;
- params['opacity'] = value;
+ params[ 'transparent' ] = true;
+ params[ 'opacity' ] = value;
@@ -444,7 +445,7 @@ THREE.MTLLoader.ensurePowerOfTwo_ = function ( image ) {
canvas.width = THREE.MTLLoader.nextHighestPowerOfTwo_( image.width );
canvas.height = THREE.MTLLoader.nextHighestPowerOfTwo_( image.height );
- var ctx = canvas.getContext("2d");
+ var ctx = canvas.getContext( "2d" );
ctx.drawImage( image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height );
return canvas;
@@ -352,11 +352,15 @@ THREE.OBJLoader.prototype = {
buffergeometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( geometry.vertices ), 3 ) );
if ( geometry.normals.length > 0 ) {
buffergeometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( geometry.normals ), 3 ) );
if ( geometry.uvs.length > 0 ) {
buffergeometry.addAttribute( 'uv', new THREE.BufferAttribute( new Float32Array( geometry.uvs ), 2 ) );
material = new THREE.MeshLambertMaterial();
@@ -138,17 +138,17 @@ THREE.OBJMTLLoader.prototype = {
if ( normals_inds === undefined ) {
geometry.faces.push( face3(
- parseInt( a ) - (face_offset + 1),
- parseInt( b ) - (face_offset + 1),
- parseInt( c ) - (face_offset + 1)
+ parseInt( a ) - ( face_offset + 1 ),
+ parseInt( b ) - ( face_offset + 1 ),
+ parseInt( c ) - ( face_offset + 1 )
) );
- parseInt( c ) - (face_offset + 1),
+ parseInt( c ) - ( face_offset + 1 ),
[
normals[ parseInt( normals_inds[ 0 ] ) - 1 ].clone(),
normals[ parseInt( normals_inds[ 1 ] ) - 1 ].clone(),
@@ -170,31 +170,33 @@ THREE.OBJMTLLoader.prototype = {
- function handle_face_line(faces, uvs, normals_inds) {
+ function handle_face_line( faces, uvs, normals_inds ) {
if ( faces[ 3 ] === undefined ) {
add_face( faces[ 0 ], faces[ 1 ], faces[ 2 ], normals_inds );
- if (!(uvs === undefined) && uvs.length > 0) {
+ if ( ! ( uvs === undefined ) && uvs.length > 0 ) {
add_uvs( uvs[ 0 ], uvs[ 1 ], uvs[ 2 ] );
- if (!(normals_inds === undefined) && normals_inds.length > 0) {
+ if ( ! ( normals_inds === undefined ) && normals_inds.length > 0 ) {
- add_face( faces[ 0 ], faces[ 1 ], faces[ 3 ], [ normals_inds[ 0 ], normals_inds[ 1 ], normals_inds[ 3 ] ]);
- add_face( faces[ 1 ], faces[ 2 ], faces[ 3 ], [ normals_inds[ 1 ], normals_inds[ 2 ], normals_inds[ 3 ] ]);
+ add_face( faces[ 0 ], faces[ 1 ], faces[ 3 ], [ normals_inds[ 0 ], normals_inds[ 1 ], normals_inds[ 3 ] ] );
+ add_face( faces[ 1 ], faces[ 2 ], faces[ 3 ], [ normals_inds[ 1 ], normals_inds[ 2 ], normals_inds[ 3 ] ] );
- add_face( faces[ 0 ], faces[ 1 ], faces[ 3 ]);
- add_face( faces[ 1 ], faces[ 2 ], faces[ 3 ]);
+ add_face( faces[ 0 ], faces[ 1 ], faces[ 3 ] );
+ add_face( faces[ 1 ], faces[ 2 ], faces[ 3 ] );
add_uvs( uvs[ 0 ], uvs[ 1 ], uvs[ 3 ] );
add_uvs( uvs[ 1 ], uvs[ 2 ], uvs[ 3 ] );
@@ -282,7 +284,7 @@ THREE.OBJMTLLoader.prototype = {
// ["f 1 2 3", "1", "2", "3", undefined]
- handle_face_line([ result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ] ]);
+ handle_face_line( [ result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ] ] );
} else if ( ( result = face_pattern2.exec( line ) ) !== null ) {
@@ -361,7 +363,7 @@ THREE.OBJMTLLoader.prototype = {
//Add last object
- meshN(undefined, undefined);
+ meshN( undefined, undefined );
return group;
@@ -66,12 +66,14 @@ THREE.PLYLoader.prototype = {
- bin2str: function (buf) {
+ bin2str: function ( buf ) {
- var array_buffer = new Uint8Array(buf);
+ var array_buffer = new Uint8Array( buf );
var str = '';
- for (var i = 0; i < buf.byteLength; i ++) {
- str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
+ for ( var i = 0; i < buf.byteLength; i ++ ) {
+ str += String.fromCharCode( array_buffer[ i ] ); // implicitly assumes little-endian
return str;
@@ -109,8 +111,10 @@ THREE.PLYLoader.prototype = {
var headerLength = 0;
var result = patternHeader.exec( data );
if ( result !== null ) {
headerText = result [ 1 ];
headerLength = result[ 0 ].length;
var header = {
@@ -155,37 +159,41 @@ THREE.PLYLoader.prototype = {
var line = lines[ i ];
line = line.trim();
- if ( line === "" ) { continue; }
+ if ( line === "" ) {
+ continue;
lineValues = line.split( /\s+/ );
lineType = lineValues.shift();
- line = lineValues.join(" ");
+ line = lineValues.join( " " );
switch ( lineType ) {
case "format":
- header.format = lineValues[0];
- header.version = lineValues[1];
+ header.format = lineValues[ 0 ];
+ header.version = lineValues[ 1 ];
case "comment":
- header.comments.push(line);
+ header.comments.push( line );
case "element":
- if ( !(currentElement === undefined) ) {
+ if ( ! ( currentElement === undefined ) ) {
- header.elements.push(currentElement);
+ header.elements.push( currentElement );
currentElement = Object();
- currentElement.name = lineValues[0];
- currentElement.count = parseInt( lineValues[1] );
+ currentElement.name = lineValues[ 0 ];
+ currentElement.count = parseInt( lineValues[ 1 ] );
currentElement.properties = [];
@@ -199,15 +207,15 @@ THREE.PLYLoader.prototype = {
- console.log("unhandled", lineType, lineValues);
+ console.log( "unhandled", lineType, lineValues );
@@ -240,22 +248,22 @@ THREE.PLYLoader.prototype = {
for ( var i = 0; i < properties.length; i ++ ) {
- if ( properties[i].type === "list" ) {
+ if ( properties[ i ].type === "list" ) {
var list = [];
- var n = this.parseASCIINumber( values.shift(), properties[i].countType );
+ var n = this.parseASCIINumber( values.shift(), properties[ i ].countType );
for ( var j = 0; j < n; j ++ ) {
- list.push( this.parseASCIINumber( values.shift(), properties[i].itemType ) );
+ list.push( this.parseASCIINumber( values.shift(), properties[ i ].itemType ) );
- element[ properties[i].name ] = list;
+ element[ properties[ i ].name ] = list;
- element[ properties[i].name ] = this.parseASCIINumber( values.shift(), properties[i].type );
+ element[ properties[ i ].name ] = this.parseASCIINumber( values.shift(), properties[ i ].type );
@@ -278,7 +286,9 @@ THREE.PLYLoader.prototype = {
var patternBody = /end_header\s([\s\S]*)$/;
var body = "";
if ( ( result = patternBody.exec( data ) ) !== null ) {
body = result [ 1 ];
var lines = body.split( '\n' );
@@ -290,18 +300,22 @@ THREE.PLYLoader.prototype = {
- if ( currentElementCount >= header.elements[currentElement].count ) {
+ if ( currentElementCount >= header.elements[ currentElement ].count ) {
currentElement ++;
currentElementCount = 0;
- var element = this.parseASCIIElement( header.elements[currentElement].properties, line );
+ var element = this.parseASCIIElement( header.elements[ currentElement ].properties, line );
- this.handleElement( geometry, header.elements[currentElement].name, element );
+ this.handleElement( geometry, header.elements[ currentElement ].name, element );
currentElementCount ++;
@@ -317,10 +331,10 @@ THREE.PLYLoader.prototype = {
for ( var i = 0; i < geometry.faces.length; i ++ ) {
- geometry.faces[i].vertexColors = [
- geometry.colors[geometry.faces[i].a],
- geometry.colors[geometry.faces[i].b],
- geometry.colors[geometry.faces[i].c]
+ geometry.faces[ i ].vertexColors = [
+ geometry.colors[ geometry.faces[ i ].a ],
+ geometry.colors[ geometry.faces[ i ].b ],
+ geometry.colors[ geometry.faces[ i ].c ]
@@ -408,29 +422,29 @@ THREE.PLYLoader.prototype = {
- result = this.binaryRead( dataview, at + read, properties[i].countType, little_endian );
- var n = result[0];
- read += result[1];
+ result = this.binaryRead( dataview, at + read, properties[ i ].countType, little_endian );
+ var n = result[ 0 ];
+ read += result[ 1 ];
- result = this.binaryRead( dataview, at + read, properties[i].itemType, little_endian );
- list.push( result[0] );
+ result = this.binaryRead( dataview, at + read, properties[ i ].itemType, little_endian );
+ list.push( result[ 0 ] );
- result = this.binaryRead( dataview, at + read, properties[i].type, little_endian );
- element[ properties[i].name ] = result[0];
+ result = this.binaryRead( dataview, at + read, properties[ i ].type, little_endian );
+ element[ properties[ i ].name ] = result[ 0 ];
@@ -445,19 +459,19 @@ THREE.PLYLoader.prototype = {
var header = this.parseHeader( this.bin2str( data ) );
- var little_endian = (header.format === "binary_little_endian");
+ var little_endian = ( header.format === "binary_little_endian" );
var body = new DataView( data, header.headerLength );
var result, loc = 0;
for ( var currentElement = 0; currentElement < header.elements.length; currentElement ++ ) {
- for ( var currentElementCount = 0; currentElementCount < header.elements[currentElement].count; currentElementCount ++ ) {
+ for ( var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount ++ ) {
- result = this.binaryReadElement( body, loc, header.elements[currentElement].properties, little_endian );
- loc += result[1];
- var element = result[0];
+ result = this.binaryReadElement( body, loc, header.elements[ currentElement ].properties, little_endian );
+ loc += result[ 1 ];
+ var element = result[ 0 ];
@@ -467,4 +481,4 @@ THREE.PLYLoader.prototype = {
@@ -13,6 +13,7 @@ THREE.PVRLoader = function ( manager ) {
this._parser = THREE.PVRLoader.parse;
THREE.PVRLoader.prototype = Object.create( THREE.CompressedTextureLoader.prototype );
@@ -20,6 +21,7 @@ THREE.PVRLoader.prototype.constructor = THREE.PVRLoader;
THREE.PVRLoader.parse = function ( buffer, loadMipmaps ) {
var headerLengthInt = 13;
var header = new Uint32Array( buffer, 0, headerLengthInt );
@@ -30,15 +32,20 @@ THREE.PVRLoader.parse = function ( buffer, loadMipmaps ) {
// PVR v3
- if ( header[0] === 0x03525650 ) {
+ if ( header[ 0 ] === 0x03525650 ) {
return THREE.PVRLoader._parseV3( pvrDatas );
// PVR v2
- else if ( header[11] === 0x21525650) {
+ else if ( header[ 11 ] === 0x21525650 ) {
return THREE.PVRLoader._parseV2( pvrDatas );
throw new Error( "[THREE.PVRLoader] Unknown PVR format" );
@@ -49,13 +56,13 @@ THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
var bpp, format;
- var metaLen = header[12],
- pixelFormat = header[2],
- height = header[6],
- width = header[7],
- numSurfs = header[9],
- numFaces = header[10],
- numMipmaps = header[11];
+ var metaLen = header[ 12 ],
+ pixelFormat = header[ 2 ],
+ height = header[ 6 ],
+ width = header[ 7 ],
+ numSurfs = header[ 9 ],
+ numFaces = header[ 10 ],
+ numMipmaps = header[ 11 ];
switch ( pixelFormat ) {
case 0 : // PVRTC 2bpp RGB
@@ -75,7 +82,7 @@ THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
format = THREE.RGBA_PVRTC_4BPPV1_Format;
default :
- throw new Error( "pvrtc - unsupported PVR format " + pixelFormat);
+ throw new Error( "pvrtc - unsupported PVR format " + pixelFormat );
pvrDatas.dataPtr = 52 + metaLen;
@@ -86,28 +93,29 @@ THREE.PVRLoader._parseV3 = function ( pvrDatas ) {
pvrDatas.numSurfaces = numFaces;
pvrDatas.numMipmaps = numMipmaps;
- pvrDatas.isCubemap = (numFaces === 6);
+ pvrDatas.isCubemap = ( numFaces === 6 );
return THREE.PVRLoader._extract( pvrDatas );
THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
var header = pvrDatas.header;
- var headerLength = header[0],
- height = header[1],
- width = header[2],
- numMipmaps = header[3],
- flags = header[4],
- dataLength = header[5],
- bpp = header[6],
- bitmaskRed = header[7],
- bitmaskGreen = header[8],
- bitmaskBlue = header[9],
- bitmaskAlpha = header[10],
- pvrTag = header[11],
- numSurfs = header[12];
+ var headerLength = header[ 0 ],
+ height = header[ 1 ],
+ width = header[ 2 ],
+ numMipmaps = header[ 3 ],
+ flags = header[ 4 ],
+ dataLength = header[ 5 ],
+ bpp = header[ 6 ],
+ bitmaskRed = header[ 7 ],
+ bitmaskGreen = header[ 8 ],
+ bitmaskBlue = header[ 9 ],
+ bitmaskAlpha = header[ 10 ],
+ pvrTag = header[ 11 ],
+ numSurfs = header[ 12 ];
var TYPE_MASK = 0xff;
@@ -121,16 +129,18 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
var _hasAlpha = bitmaskAlpha > 0;
- if (formatFlags === PVRTC_4 ) {
+ if ( formatFlags === PVRTC_4 ) {
format = _hasAlpha ? THREE.RGBA_PVRTC_4BPPV1_Format : THREE.RGB_PVRTC_4BPPV1_Format;
bpp = 4;
- else if ( formatFlags === PVRTC_2) {
+ } else if ( formatFlags === PVRTC_2 ) {
format = _hasAlpha ? THREE.RGBA_PVRTC_2BPPV1_Format : THREE.RGB_PVRTC_2BPPV1_Format;
bpp = 2;
- throw new Error( "pvrtc - unknown format " + formatFlags);
+ throw new Error( "pvrtc - unknown format " + formatFlags );
@@ -142,9 +152,9 @@ THREE.PVRLoader._parseV2 = function ( pvrDatas ) {
pvrDatas.numSurfaces = numSurfs;
pvrDatas.numMipmaps = numMipmaps + 1;
- // guess cubemap type seems tricky in v2
- // it juste a pvr containing 6 surface (no explicit cubemap type)
- pvrDatas.isCubemap = (numSurfs === 6);
+ // guess cubemap type seems tricky in v2
+ // it juste a pvr containing 6 surface (no explicit cubemap type)
+ pvrDatas.isCubemap = ( numSurfs === 6 );
@@ -198,20 +208,24 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
if ( bpp === 2 ) {
blockWidth = 8;
blockHeight = 4;
blockWidth = 4;
- blockSize = (blockWidth * blockHeight) * bpp / 8;
+ blockSize = ( blockWidth * blockHeight ) * bpp / 8;
pvr.mipmaps.length = pvrDatas.numMipmaps * numSurfs;
var mipLevel = 0;
- while (mipLevel < pvrDatas.numMipmaps) {
+ while ( mipLevel < pvrDatas.numMipmaps ) {
var sWidth = pvrDatas.width >> mipLevel,
sHeight = pvrDatas.height >> mipLevel;
@@ -220,9 +234,9 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
heightBlocks = sHeight / blockHeight;
// Clamp to minimum number of blocks
- if (widthBlocks < 2)
+ if ( widthBlocks < 2 )
widthBlocks = 2;
- if (heightBlocks < 2)
+ if ( heightBlocks < 2 )
heightBlocks = 2;
dataSize = widthBlocks * heightBlocks * blockSize;
@@ -238,7 +252,7 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
height: sHeight
- pvr.mipmaps[ surfIndex * pvrDatas.numMipmaps + mipLevel] = mipmap;
+ pvr.mipmaps[ surfIndex * pvrDatas.numMipmaps + mipLevel ] = mipmap;
dataOffset += dataSize;
@@ -251,4 +265,5 @@ THREE.PVRLoader._extract = function ( pvrDatas ) {
return pvr;
@@ -20,25 +20,27 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
/* return codes for rgbe routines */
RGBE_RETURN_SUCCESS = 0,
- RGBE_RETURN_FAILURE = -1,
+ RGBE_RETURN_FAILURE = - 1,
/* default error routine. change this to change error handling */
rgbe_read_error = 1,
rgbe_write_error = 2,
rgbe_format_error = 3,
rgbe_memory_error = 4,
- rgbe_error = function(rgbe_error_code, msg) {
- switch (rgbe_error_code) {
- case rgbe_read_error: console.error("THREE.RGBELoader Read Error: " + (msg||''));
+ rgbe_error = function( rgbe_error_code, msg ) {
+ switch ( rgbe_error_code ) {
+ case rgbe_read_error: console.error( "THREE.RGBELoader Read Error: " + ( msg || '' ) );
- case rgbe_write_error: console.error("THREE.RGBELoader Write Error: " + (msg||''));
+ case rgbe_write_error: console.error( "THREE.RGBELoader Write Error: " + ( msg || '' ) );
- case rgbe_format_error: console.error("THREE.RGBELoader Bad File Format: " + (msg||''));
+ case rgbe_format_error: console.error( "THREE.RGBELoader Bad File Format: " + ( msg || '' ) );
- case rgbe_memory_error: console.error("THREE.RGBELoader: Error: " + (msg||''));
+ case rgbe_memory_error: console.error( "THREE.RGBELoader: Error: " + ( msg || '' ) );
return RGBE_RETURN_FAILURE;
/* offsets to red, green, and blue components in a data (float) pixel */
@@ -57,20 +59,21 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
NEWLINE = "\n",
fgets = function( buffer, lineLimit, consume ) {
- lineLimit = !lineLimit ? 1024 : lineLimit;
+ lineLimit = ! lineLimit ? 1024 : lineLimit;
var p = buffer.pos,
- i = -1, len = 0, s = '', chunkSize = 128,
- chunk = String.fromCharCode.apply(null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) )
+ i = - 1, len = 0, s = '', chunkSize = 128,
+ chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) )
- while ( (0 > (i = chunk.indexOf( NEWLINE ))) && (len < lineLimit) && (p < buffer.byteLength) ) {
+ while ( ( 0 > ( i = chunk.indexOf( NEWLINE ) ) ) && ( len < lineLimit ) && ( p < buffer.byteLength ) ) {
s += chunk; len += chunk.length;
p += chunkSize;
- chunk += String.fromCharCode.apply(null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
+ chunk += String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
- if ( -1 < i ) {
+ if ( - 1 < i ) {
/*for (i=l-1; i>=0; i--) {
byteCode = m.charCodeAt(i);
@@ -79,14 +82,16 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
if (byteCode >= 0xDC00 && byteCode <= 0xDFFF) i--; //trail surrogate
}*/
if ( false !== consume ) buffer.pos += len + i + 1;
- return s + chunk.slice(0, i);
+ return s + chunk.slice( 0, i );
/* minimal header reading. modify if you want to parse more information */
RGBE_ReadHeader = function( buffer ) {
var line, match,
// regexes to parse header info fields
@@ -99,38 +104,42 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
// RGBE format header struct
header = {
- valid: 0, /* indicate which fields are valid */
+ valid: 0, /* indicate which fields are valid */
- string: '', /* the actual header string */
+ string: '', /* the actual header string */
- comments: '', /* comments found in header */
+ comments: '', /* comments found in header */
- programtype: 'RGBE', /* listed at beginning of file to identify it
+ programtype: 'RGBE', /* listed at beginning of file to identify it
* after "#?". defaults to "RGBE" */
+ format: '', /* RGBE format, default 32-bit_rle_rgbe */
- format: '', /* RGBE format, default 32-bit_rle_rgbe */
- gamma: 1.0, /* image has already been gamma corrected with
+ 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: 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 */
+ width: 0, height: 0 /* image dimensions, width/height */
- if ( buffer.pos >= buffer.byteLength || !( line = fgets( buffer ) ) ) {
+ if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) {
return rgbe_error( rgbe_read_error, "no header found" );
/* if you want to require the magic token then uncomment the next line */
- if ( !(match = line.match(magic_token_re)) ) {
+ if ( ! ( match = line.match( magic_token_re ) ) ) {
return rgbe_error( rgbe_format_error, "bad initial token" );
header.valid |= RGBE_VALID_PROGRAMTYPE;
- header.programtype = match[1];
+ header.programtype = match[ 1 ];
header.string += line + "\n";
while ( true ) {
@@ -139,41 +148,58 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
if ( false === line ) break;
- if ( '#' === line.charAt(0) ) {
+ if ( '#' === line.charAt( 0 ) ) {
header.comments += line + "\n";
continue; // comment line
- if ( match = line.match(gamma_re) ) {
- header.gamma = parseFloat(match[1], 10);
+ if ( match = line.match( gamma_re ) ) {
+ header.gamma = parseFloat( match[ 1 ], 10 );
- if ( match = line.match(exposure_re) ) {
- header.exposure = parseFloat(match[1], 10);
+ if ( match = line.match( exposure_re ) ) {
+ header.exposure = parseFloat( match[ 1 ], 10 );
- if ( match = line.match(format_re) ) {
+ if ( match = line.match( format_re ) ) {
header.valid |= RGBE_VALID_FORMAT;
- header.format = match[1];//'32-bit_rle_rgbe';
+ header.format = match[ 1 ];//'32-bit_rle_rgbe';
- if ( match = line.match(dimensions_re) ) {
+ if ( match = line.match( dimensions_re ) ) {
header.valid |= RGBE_VALID_DIMENSIONS;
- header.height = parseInt(match[1], 10);
- header.width = parseInt(match[2], 10);
+ header.height = parseInt( match[ 1 ], 10 );
+ header.width = parseInt( match[ 2 ], 10 );
- if ( (header.valid&RGBE_VALID_FORMAT) && (header.valid&RGBE_VALID_DIMENSIONS) ) break;
+ if ( ( header.valid & RGBE_VALID_FORMAT ) && ( header.valid & RGBE_VALID_DIMENSIONS ) ) break;
- if ( !(header.valid&RGBE_VALID_FORMAT) ) {
+ if ( ! ( header.valid & RGBE_VALID_FORMAT ) ) {
return rgbe_error( rgbe_format_error, "missing format specifier" );
- if ( !(header.valid&RGBE_VALID_DIMENSIONS) ) {
+ if ( ! ( header.valid & RGBE_VALID_DIMENSIONS ) ) {
return rgbe_error( rgbe_format_error, "missing image size specifier" );
return header;
RGBE_ReadPixels_RLE = function( buffer, w, h ) {
var data_rgba, offset, pos, count, byteValue,
scanline_buffer, ptr, ptr_end, i, l, off, isEncodedRun,
scanline_width = w, num_scanlines = h, rgbeStart
@@ -181,22 +207,28 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
if (
// run length encoding is not allowed so read flat
- ((scanline_width < 8) || (scanline_width > 0x7fff)) ||
+ ( ( scanline_width < 8 ) || ( scanline_width > 0x7fff ) ) ||
// this file is not run length encoded
- ((2 !== buffer[0]) || (2 !== buffer[1]) || (buffer[2] & 0x80))
+ ( ( 2 !== buffer[ 0 ] ) || ( 2 !== buffer[ 1 ] ) || ( buffer[ 2 ] & 0x80 ) )
) {
// return the flat buffer
return new Uint8Array( buffer );
- if ( scanline_width !== ((buffer[2]<<8) | buffer[3]) ) {
- return rgbe_error(rgbe_format_error, "wrong scanline width");
+ if ( scanline_width !== ( ( buffer[ 2 ] << 8 ) | buffer[ 3 ] ) ) {
+ return rgbe_error( rgbe_format_error, "wrong scanline width" );
data_rgba = new Uint8Array( 4 * w * h );
- if ( !data_rgba || !data_rgba.length ) {
- return rgbe_error(rgbe_memory_error, "unable to allocate buffer space");
+ if ( ! data_rgba || ! data_rgba.length ) {
+ return rgbe_error( rgbe_memory_error, "unable to allocate buffer space" );
offset = 0; pos = 0; ptr_end = 4 * scanline_width;
@@ -204,7 +236,7 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
scanline_buffer = new Uint8Array( ptr_end );
// read in each successive scanline
- while ( (num_scanlines > 0) && (pos < buffer.byteLength) ) {
+ while ( ( num_scanlines > 0 ) && ( pos < buffer.byteLength ) ) {
if ( pos + 4 > buffer.byteLength ) {
@@ -212,67 +244,77 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
- rgbeStart[0] = buffer[pos ++];
- rgbeStart[1] = buffer[pos ++];
- rgbeStart[2] = buffer[pos ++];
- rgbeStart[3] = buffer[pos ++];
+ rgbeStart[ 0 ] = buffer[ pos ++ ];
+ rgbeStart[ 1 ] = buffer[ pos ++ ];
+ rgbeStart[ 2 ] = buffer[ pos ++ ];
+ rgbeStart[ 3 ] = buffer[ pos ++ ];
- if ( (2 != rgbeStart[0]) || (2 != rgbeStart[1]) || (((rgbeStart[2]<<8) | rgbeStart[3]) != scanline_width) ) {
+ if ( ( 2 != rgbeStart[ 0 ] ) || ( 2 != rgbeStart[ 1 ] ) || ( ( ( rgbeStart[ 2 ] << 8 ) | rgbeStart[ 3 ] ) != scanline_width ) ) {
- return rgbe_error(rgbe_format_error, "bad rgbe scanline format");
+ return rgbe_error( rgbe_format_error, "bad rgbe scanline format" );
// read each of the four channels for the scanline into the buffer
// first red, then green, then blue, then exponent
ptr = 0;
- while ( (ptr < ptr_end) && (pos < buffer.byteLength) ) {
+ while ( ( ptr < ptr_end ) && ( pos < buffer.byteLength ) ) {
count = buffer[ pos ++ ];
isEncodedRun = count > 128;
if ( isEncodedRun ) count -= 128;
- if ( (0 === count) || (ptr + count > ptr_end) ) {
+ if ( ( 0 === count ) || ( ptr + count > ptr_end ) ) {
- return rgbe_error(rgbe_format_error, "bad scanline data");
+ return rgbe_error( rgbe_format_error, "bad scanline data" );
if ( isEncodedRun ) {
// a (encoded) run of the same value
byteValue = buffer[ pos ++ ];
- for (i = 0; i < count; i ++) {
+ for ( i = 0; i < count; i ++ ) {
scanline_buffer[ ptr ++ ] = byteValue;
//ptr += count;
// a literal-run
- scanline_buffer.set( buffer.subarray(pos, pos + count), ptr );
+ scanline_buffer.set( buffer.subarray( pos, pos + count ), ptr );
ptr += count; pos += count;
// now convert data from buffer into rgba
// first red, then green, then blue, then exponent (alpha)
l = scanline_width; //scanline_buffer.byteLength;
- for (i = 0; i < l; i ++) {
+ for ( i = 0; i < l; i ++ ) {
off = 0;
- data_rgba[offset] = scanline_buffer[i + off];
+ data_rgba[ offset ] = scanline_buffer[ i + off ];
off += scanline_width; //1;
- data_rgba[offset + 1] = scanline_buffer[i + off];
+ data_rgba[ offset + 1 ] = scanline_buffer[ i + off ];
- data_rgba[offset + 2] = scanline_buffer[i + off];
+ data_rgba[ offset + 2 ] = scanline_buffer[ i + off ];
- data_rgba[offset + 3] = scanline_buffer[i + off];
+ data_rgba[ offset + 3 ] = scanline_buffer[ i + off ];
offset += 4;
num_scanlines --;
return data_rgba;
@@ -285,9 +327,10 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
var w = rgbe_header_info.width,
h = rgbe_header_info.height
- ,image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray(byteArray.pos), w, h )
+ , image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h )
if ( RGBE_RETURN_FAILURE !== image_rgba_data ) {
return {
width: w, height: h,
data: image_rgba_data,
@@ -297,7 +340,10 @@ THREE.RGBELoader.prototype._parser = function( buffer ) {
format: THREE.RGBEFormat, // handled as THREE.RGBAFormat in shaders
type: THREE.UnsignedByteType
return null;
@@ -64,9 +64,9 @@ THREE.STLLoader.prototype = {
var expect, face_size, n_faces, reader;
reader = new DataView( binData );
- face_size = (32 / 8 * 3) + ((32 / 8 * 3) * 3) + (16 / 8);
- n_faces = reader.getUint32(80, true);
- expect = 80 + (32 / 8) + (n_faces * face_size);
+ face_size = ( 32 / 8 * 3 ) + ( ( 32 / 8 * 3 ) * 3 ) + ( 16 / 8 );
+ n_faces = reader.getUint32( 80, true );
+ expect = 80 + ( 32 / 8 ) + ( n_faces * face_size );
if ( expect === reader.byteLength ) {
@@ -79,7 +79,7 @@ THREE.STLLoader.prototype = {
var fileLength = reader.byteLength;
for ( var index = 0; index < fileLength; index ++ ) {
- if ( reader.getUint8(index, false) > 127 ) {
+ if ( reader.getUint8( index, false ) > 127 ) {
@@ -112,18 +112,20 @@ THREE.STLLoader.prototype = {
for ( var index = 0; index < 80 - 10; index ++ ) {
- if ((reader.getUint32(index, false) == 0x434F4C4F /*COLO*/) &&
- (reader.getUint8(index + 4) == 0x52 /*'R'*/) &&
- (reader.getUint8(index + 5) == 0x3D /*'='*/)) {
+ if ( ( reader.getUint32( index, false ) == 0x434F4C4F /*COLO*/ ) &&
+ ( reader.getUint8( index + 4 ) == 0x52 /*'R'*/ ) &&
+ ( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) {
hasColors = true;
- colors = new Float32Array( faces * 3 * 3);
+ colors = new Float32Array( faces * 3 * 3 );
+ defaultR = reader.getUint8( index + 6 ) / 255;
+ defaultG = reader.getUint8( index + 7 ) / 255;
+ defaultB = reader.getUint8( index + 8 ) / 255;
+ alpha = reader.getUint8( index + 9 ) / 255;
- defaultR = reader.getUint8(index + 6) / 255;
- defaultG = reader.getUint8(index + 7) / 255;
- defaultB = reader.getUint8(index + 8) / 255;
- alpha = reader.getUint8(index + 9) / 255;
var dataOffset = 84;
@@ -139,43 +141,50 @@ THREE.STLLoader.prototype = {
for ( var face = 0; face < faces; face ++ ) {
var start = dataOffset + face * faceLength;
- var normalX = reader.getFloat32(start, true);
- var normalY = reader.getFloat32(start + 4, true);
- var normalZ = reader.getFloat32(start + 8, true);
+ var normalX = reader.getFloat32( start, true );
+ var normalY = reader.getFloat32( start + 4, true );
+ var normalZ = reader.getFloat32( start + 8, true );
+ if ( hasColors ) {
+ var packedColor = reader.getUint16( start + 48, true );
- if (hasColors) {
+ if ( ( packedColor & 0x8000 ) === 0 ) {
- var packedColor = reader.getUint16(start + 48, true);
+ // facet has its own unique color
- if ((packedColor & 0x8000) === 0) { // facet has its own unique color
+ r = ( packedColor & 0x1F ) / 31;
+ g = ( ( packedColor >> 5 ) & 0x1F ) / 31;
+ b = ( ( packedColor >> 10 ) & 0x1F ) / 31;
- r = (packedColor & 0x1F) / 31;
- g = ((packedColor >> 5) & 0x1F) / 31;
- b = ((packedColor >> 10) & 0x1F) / 31;
r = defaultR;
g = defaultG;
b = defaultB;
for ( var i = 1; i <= 3; i ++ ) {
var vertexstart = start + i * 12;
- vertices[ offset ] = reader.getFloat32( vertexstart, true );
+ vertices[ offset ] = reader.getFloat32( vertexstart, true );
vertices[ offset + 1 ] = reader.getFloat32( vertexstart + 4, true );
vertices[ offset + 2 ] = reader.getFloat32( vertexstart + 8, true );
- normals[ offset ] = normalX;
+ normals[ offset ] = normalX;
normals[ offset + 1 ] = normalY;
normals[ offset + 2 ] = normalZ;
- colors[ offset ] = r;
+ colors[ offset ] = r;
colors[ offset + 1 ] = g;
colors[ offset + 2 ] = b;
offset += 3;
@@ -187,10 +196,12 @@ THREE.STLLoader.prototype = {
geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) );
geometry.hasColors = true;
geometry.alpha = alpha;
@@ -205,7 +216,7 @@ THREE.STLLoader.prototype = {
while ( ( result = patternFace.exec( data ) ) !== null ) {
- text = result[0];
+ text = result[ 0 ];
patternNormal = /normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g;
while ( ( result = patternNormal.exec( text ) ) !== null ) {
@@ -237,38 +248,50 @@ THREE.STLLoader.prototype = {
ensureString: function ( buf ) {
- if (typeof buf !== "string") {
+ if ( typeof buf !== "string" ) {
return buf;
ensureBinary: function ( buf ) {
- if (typeof buf === "string") {
- var array_buffer = new Uint8Array(buf.length);
- for (var i = 0; i < buf.length; i ++) {
- array_buffer[i] = buf.charCodeAt(i) & 0xff; // implicitly assumes little-endian
+ if ( typeof buf === "string" ) {
+ var array_buffer = new Uint8Array( buf.length );
+ for ( var i = 0; i < buf.length; i ++ ) {
+ array_buffer[ i ] = buf.charCodeAt( i ) & 0xff; // implicitly assumes little-endian
return array_buffer.buffer || array_buffer;
-if ( typeof DataView === 'undefined') {
+if ( typeof DataView === 'undefined' ) {
- DataView = function(buffer, byteOffset, byteLength) {
+ DataView = function( buffer, byteOffset, byteLength ) {
this.buffer = buffer;
this.byteOffset = byteOffset || 0;
@@ -279,30 +302,34 @@ if ( typeof DataView === 'undefined') {
DataView.prototype = {
- _getCharCodes:function(buffer,start,length) {
+ _getCharCodes: function( buffer, start, length ) {
start = start || 0;
length = length || buffer.length;
var end = start + length;
var codes = [];
- for (var i = start; i < end; i ++) {
- codes.push(buffer.charCodeAt(i) & 0xff);
+ for ( var i = start; i < end; i ++ ) {
+ codes.push( buffer.charCodeAt( i ) & 0xff );
return codes;
- _getBytes: function (length, byteOffset, littleEndian) {
+ _getBytes: function ( length, byteOffset, littleEndian ) {
var result;
// Handle the lack of endianness
- if (littleEndian === undefined) {
+ if ( littleEndian === undefined ) {
littleEndian = this._littleEndian;
// Handle the lack of byteOffset
- if (byteOffset === undefined) {
+ if ( byteOffset === undefined ) {
byteOffset = this.byteOffset;
@@ -312,44 +339,45 @@ if ( typeof DataView === 'undefined') {
- if (length === undefined) {
+ if ( length === undefined ) {
length = this.byteLength - byteOffset;
// Error Checking
- if (typeof byteOffset !== 'number') {
+ if ( typeof byteOffset !== 'number' ) {
- throw new TypeError('DataView byteOffset is not a number');
+ throw new TypeError( 'DataView byteOffset is not a number' );
- if (length < 0 || byteOffset + length > this.byteLength) {
+ if ( length < 0 || byteOffset + length > this.byteLength ) {
- throw new Error('DataView length or (byteOffset+length) value is out of bounds');
+ throw new Error( 'DataView length or (byteOffset+length) value is out of bounds' );
- if (this.isString) {
+ if ( this.isString ) {
- result = this._getCharCodes(this.buffer, byteOffset, byteOffset + length);
+ result = this._getCharCodes( this.buffer, byteOffset, byteOffset + length );
- result = this.buffer.slice(byteOffset, byteOffset + length);
+ result = this.buffer.slice( byteOffset, byteOffset + length );
- if (!littleEndian && length > 1) {
+ if ( ! littleEndian && length > 1 ) {
if ( Array.isArray( result ) === false ) {
- result = Array.prototype.slice.call(result);
+ result = Array.prototype.slice.call( result );
result.reverse();
return result;
@@ -358,80 +386,111 @@ if ( typeof DataView === 'undefined') {
// Compatibility functions on a String Buffer
- getFloat64: function (byteOffset, littleEndian) {
+ getFloat64: function ( byteOffset, littleEndian ) {
- var b = this._getBytes(8, byteOffset, littleEndian),
+ var b = this._getBytes( 8, byteOffset, littleEndian ),
- sign = 1 - (2 * (b[7] >> 7)),
- exponent = ((((b[7] << 1) & 0xff) << 3) | (b[6] >> 4)) - ((1 << 10) - 1),
+ sign = 1 - ( 2 * ( b[ 7 ] >> 7 ) ),
+ exponent = ( ( ( ( b[ 7 ] << 1 ) & 0xff ) << 3 ) | ( b[ 6 ] >> 4 ) ) - ( ( 1 << 10 ) - 1 ),
// Binary operators such as | and << operate on 32 bit values, using + and Math.pow(2) instead
- mantissa = ((b[6] & 0x0f) * Math.pow(2, 48)) + (b[5] * Math.pow(2, 40)) + (b[4] * Math.pow(2, 32)) +
- (b[3] * Math.pow(2, 24)) + (b[2] * Math.pow(2, 16)) + (b[1] * Math.pow(2, 8)) + b[0];
+ mantissa = ( ( b[ 6 ] & 0x0f ) * Math.pow( 2, 48 ) ) + ( b[ 5 ] * Math.pow( 2, 40 ) ) + ( b[ 4 ] * Math.pow( 2, 32 ) ) +
+ ( b[ 3 ] * Math.pow( 2, 24 ) ) + ( b[ 2 ] * Math.pow( 2, 16 ) ) + ( b[ 1 ] * Math.pow( 2, 8 ) ) + b[ 0 ];
+ if ( exponent === 1024 ) {
+ if ( mantissa !== 0 ) {
- if (exponent === 1024) {
- if (mantissa !== 0) {
return NaN;
return sign * Infinity;
- if (exponent === -1023) { // Denormalized
- return sign * mantissa * Math.pow(2, -1022 - 52);
+ if ( exponent === - 1023 ) {
+ // Denormalized
+ return sign * mantissa * Math.pow( 2, - 1022 - 52 );
- return sign * (1 + mantissa * Math.pow(2, -52)) * Math.pow(2, exponent);
+ return sign * ( 1 + mantissa * Math.pow( 2, - 52 ) ) * Math.pow( 2, exponent );
- getFloat32: function (byteOffset, littleEndian) {
+ getFloat32: function ( byteOffset, littleEndian ) {
- var b = this._getBytes(4, byteOffset, littleEndian),
+ var b = this._getBytes( 4, byteOffset, littleEndian ),
- sign = 1 - (2 * (b[3] >> 7)),
- exponent = (((b[3] << 1) & 0xff) | (b[2] >> 7)) - 127,
- mantissa = ((b[2] & 0x7f) << 16) | (b[1] << 8) | b[0];
+ sign = 1 - ( 2 * ( b[ 3 ] >> 7 ) ),
+ exponent = ( ( ( b[ 3 ] << 1 ) & 0xff ) | ( b[ 2 ] >> 7 ) ) - 127,
+ mantissa = ( ( b[ 2 ] & 0x7f ) << 16 ) | ( b[ 1 ] << 8 ) | b[ 0 ];
+ if ( exponent === 128 ) {
- if (exponent === 128) {
- if (exponent === -127) { // Denormalized
- return sign * mantissa * Math.pow(2, -126 - 23);
+ if ( exponent === - 127 ) {
+ return sign * mantissa * Math.pow( 2, - 126 - 23 );
- return sign * (1 + mantissa * Math.pow(2, -23)) * Math.pow(2, exponent);
+ return sign * ( 1 + mantissa * Math.pow( 2, - 23 ) ) * Math.pow( 2, exponent );
- getInt32: function (byteOffset, littleEndian) {
- var b = this._getBytes(4, byteOffset, littleEndian);
- return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0];
+ getInt32: function ( byteOffset, littleEndian ) {
+ var b = this._getBytes( 4, byteOffset, littleEndian );
+ return ( b[ 3 ] << 24 ) | ( b[ 2 ] << 16 ) | ( b[ 1 ] << 8 ) | b[ 0 ];
- getUint32: function (byteOffset, littleEndian) {
- return this.getInt32(byteOffset, littleEndian) >>> 0;
+ getUint32: function ( byteOffset, littleEndian ) {
+ return this.getInt32( byteOffset, littleEndian ) >>> 0;
- getInt16: function (byteOffset, littleEndian) {
- return (this.getUint16(byteOffset, littleEndian) << 16) >> 16;
+ getInt16: function ( byteOffset, littleEndian ) {
+ return ( this.getUint16( byteOffset, littleEndian ) << 16 ) >> 16;
- getUint16: function (byteOffset, littleEndian) {
- var b = this._getBytes(2, byteOffset, littleEndian);
- return (b[1] << 8) | b[0];
+ getUint16: function ( byteOffset, littleEndian ) {
+ var b = this._getBytes( 2, byteOffset, littleEndian );
+ return ( b[ 1 ] << 8 ) | b[ 0 ];
- getInt8: function (byteOffset) {
- return (this.getUint8(byteOffset) << 24) >> 24;
+ getInt8: function ( byteOffset ) {
+ return ( this.getUint8( byteOffset ) << 24 ) >> 24;
- getUint8: function (byteOffset) {
- return this._getBytes(1, byteOffset)[0];
+ getUint8: function ( byteOffset ) {
+ return this._getBytes( 1, byteOffset )[ 0 ];
@@ -62,8 +62,10 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
// Check indexed type
case TGA_TYPE_INDEXED:
case TGA_TYPE_RLE_INDEXED:
- if ( header.colormap_length > 256 || header.colormap_size !== 24 || header.colormap_type !== 1) {
- console.error('THREE.TGALoader.parse.tgaCheckHeader: Invalid type colormap data for indexed type');
+ if ( header.colormap_length > 256 || header.colormap_size !== 24 || header.colormap_type !== 1 ) {
+ console.error( 'THREE.TGALoader.parse.tgaCheckHeader: Invalid type colormap data for indexed type' );
@@ -72,32 +74,38 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
case TGA_TYPE_GREY:
case TGA_TYPE_RLE_RGB:
case TGA_TYPE_RLE_GREY:
- if (header.colormap_type) {
- console.error('THREE.TGALoader.parse.tgaCheckHeader: Invalid type colormap data for colormap type');
+ if ( header.colormap_type ) {
+ console.error( 'THREE.TGALoader.parse.tgaCheckHeader: Invalid type colormap data for colormap type' );
// What the need of a file without data ?
case TGA_TYPE_NO_DATA:
- console.error('THREE.TGALoader.parse.tgaCheckHeader: No data');
+ console.error( 'THREE.TGALoader.parse.tgaCheckHeader: No data' );
// Invalid type ?
- console.error('THREE.TGALoader.parse.tgaCheckHeader: Invalid type " ' + header.image_type + '"');
+ console.error( 'THREE.TGALoader.parse.tgaCheckHeader: Invalid type " ' + header.image_type + '"' );
// Check image width and height
if ( header.width <= 0 || header.height <= 0 ) {
console.error( 'THREE.TGALoader.parse.tgaCheckHeader: Invalid image size' );
// Check image pixel size
- if (header.pixel_size !== 8 &&
+ if ( header.pixel_size !== 8 &&
header.pixel_size !== 16 &&
header.pixel_size !== 24 &&
- header.pixel_size !== 32) {
- console.error('THREE.TGALoader.parse.tgaCheckHeader: Invalid pixel size "' + header.pixel_size + '"');
+ header.pixel_size !== 32 ) {
+ console.error( 'THREE.TGALoader.parse.tgaCheckHeader: Invalid pixel size "' + header.pixel_size + '"' );
@@ -106,7 +114,9 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
tgaCheckHeader( header );
if ( header.id_length + offset > buffer.length ) {
- console.error('THREE.TGALoader.parse: No data');
+ console.error( 'THREE.TGALoader.parse: No data' );
// Skip the needn't data
@@ -159,126 +169,160 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
// Read palettes
if ( use_pal ) {
palettes = data.subarray( offset, offset += header.colormap_length * ( header.colormap_size >> 3 ) );
// Read RLE
if ( use_rle ) {
- pixel_data = new Uint8Array(pixel_total);
+ pixel_data = new Uint8Array( pixel_total );
var c, count, i;
var shift = 0;
- var pixels = new Uint8Array(pixel_size);
+ var pixels = new Uint8Array( pixel_size );
- while (shift < pixel_total) {
- c = data[offset ++];
- count = (c & 0x7f) + 1;
+ while ( shift < pixel_total ) {
+ c = data[ offset ++ ];
+ count = ( c & 0x7f ) + 1;
// RLE pixels.
- if (c & 0x80) {
+ if ( c & 0x80 ) {
// Bind pixel tmp array
- for (i = 0; i < pixel_size; ++ i) {
- pixels[i] = data[offset ++];
+ for ( i = 0; i < pixel_size; ++ i ) {
+ pixels[ i ] = data[ offset ++ ];
// Copy pixel array
- for (i = 0; i < count; ++ i) {
- pixel_data.set(pixels, shift + i * pixel_size);
+ for ( i = 0; i < count; ++ i ) {
+ pixel_data.set( pixels, shift + i * pixel_size );
shift += pixel_size * count;
// Raw pixels.
count *= pixel_size;
- pixel_data[shift + i] = data[offset ++];
+ pixel_data[ shift + i ] = data[ offset ++ ];
shift += count;
// RAW Pixels
pixel_data = data.subarray(
- offset, offset += (use_pal ? header.width * header.height : pixel_total)
+ offset, offset += ( use_pal ? header.width * header.height : pixel_total )
pixel_data: pixel_data,
palettes: palettes
- function tgaGetImageData8bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end, image, palettes) {
+ function tgaGetImageData8bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image, palettes ) {
var colormap = palettes;
var color, i = 0, x, y;
var width = header.width;
- for (y = y_start; y !== y_end; y += y_step) {
- for (x = x_start; x !== x_end; x += x_step, i ++) {
- color = image[i];
- imageData[(x + width * y) * 4 + 3] = 255;
- imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
- imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
- imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
+ for ( y = y_start; y !== y_end; y += y_step ) {
+ for ( x = x_start; x !== x_end; x += x_step, i ++ ) {
+ color = image[ i ];
+ imageData[ ( x + width * y ) * 4 + 3 ] = 255;
+ imageData[ ( x + width * y ) * 4 + 2 ] = colormap[ ( color * 3 ) + 0 ];
+ imageData[ ( x + width * y ) * 4 + 1 ] = colormap[ ( color * 3 ) + 1 ];
+ imageData[ ( x + width * y ) * 4 + 0 ] = colormap[ ( color * 3 ) + 2 ];
return imageData;
- function tgaGetImageData16bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end, image) {
+ function tgaGetImageData16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
- for (x = x_start; x !== x_end; x += x_step, i += 2) {
- color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
- imageData[(x + width * y) * 4 + 0] = (color & 0x7C00) >> 7;
- imageData[(x + width * y) * 4 + 1] = (color & 0x03E0) >> 2;
- imageData[(x + width * y) * 4 + 2] = (color & 0x001F) >> 3;
- imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
+ for ( x = x_start; x !== x_end; x += x_step, i += 2 ) {
+ color = image[ i + 0 ] + ( image[ i + 1 ] << 8 ); // Inversed ?
+ imageData[ ( x + width * y ) * 4 + 0 ] = ( color & 0x7C00 ) >> 7;
+ imageData[ ( x + width * y ) * 4 + 1 ] = ( color & 0x03E0 ) >> 2;
+ imageData[ ( x + width * y ) * 4 + 2 ] = ( color & 0x001F ) >> 3;
+ imageData[ ( x + width * y ) * 4 + 3 ] = ( color & 0x8000 ) ? 0 : 255;
- function tgaGetImageData24bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end, image) {
+ function tgaGetImageData24bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
var i = 0, x, y;
- for (x = x_start; x !== x_end; x += x_step, i += 3) {
- imageData[(x + width * y) * 4 + 2] = image[i + 0];
- imageData[(x + width * y) * 4 + 1] = image[i + 1];
- imageData[(x + width * y) * 4 + 0] = image[i + 2];
+ for ( x = x_start; x !== x_end; x += x_step, i += 3 ) {
+ imageData[ ( x + width * y ) * 4 + 2 ] = image[ i + 0 ];
+ imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 1 ];
+ imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 2 ];
- function tgaGetImageData32bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end, image) {
+ function tgaGetImageData32bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
- for (x = x_start; x !== x_end; x += x_step, i += 4) {
- imageData[(x + width * y) * 4 + 3] = image[i + 3];
+ for ( x = x_start; x !== x_end; x += x_step, i += 4 ) {
+ imageData[ ( x + width * y ) * 4 + 3 ] = image[ i + 3 ];
@@ -290,32 +334,40 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
- imageData[(x + width * y) * 4 + 0] = color;
- imageData[(x + width * y) * 4 + 1] = color;
- imageData[(x + width * y) * 4 + 2] = color;
+ imageData[ ( x + width * y ) * 4 + 0 ] = color;
+ imageData[ ( x + width * y ) * 4 + 1 ] = color;
+ imageData[ ( x + width * y ) * 4 + 2 ] = color;
- function tgaGetImageDataGrey16bits(imageData, y_start, y_step, y_end, x_start, x_step, x_end, image) {
+ function tgaGetImageDataGrey16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
- imageData[(x + width * y) * 4 + 0] = image[i + 0];
- imageData[(x + width * y) * 4 + 1] = image[i + 0];
- imageData[(x + width * y) * 4 + 3] = image[i + 1];
+ imageData[ ( x + width * y ) * 4 + 0 ] = image[ i + 0 ];
+ imageData[ ( x + width * y ) * 4 + 1 ] = image[ i + 0 ];
+ imageData[ ( x + width * y ) * 4 + 3 ] = image[ i + 1 ];
@@ -330,9 +382,9 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
y_step,
x_end,
y_end,
- data = new Uint8Array(width * height * 4);
+ data = new Uint8Array( width * height * 4 );
- switch ( (header.flags & TGA_ORIGIN_MASK) >> TGA_ORIGIN_SHIFT ) {
+ switch ( ( header.flags & TGA_ORIGIN_MASK ) >> TGA_ORIGIN_SHIFT ) {
case TGA_ORIGIN_UL:
x_start = 0;
@@ -348,14 +400,14 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
x_step = 1;
x_end = width;
y_start = height - 1;
- y_step = -1;
- y_end = -1;
+ y_step = - 1;
+ y_end = - 1;
case TGA_ORIGIN_UR:
x_start = width - 1;
- x_step = -1;
- x_end = -1;
+ x_step = - 1;
+ x_end = - 1;
y_start = 0;
y_step = 1;
y_end = height;
@@ -363,11 +415,11 @@ THREE.TGALoader.prototype._parser = function ( buffer ) {
case TGA_ORIGIN_BR:
@@ -69,7 +69,8 @@ THREE.VRMLLoader.prototype = {
* @param float t
* @returns {Color}
- var interpolateColors = function(a, b, t) {
+ var interpolateColors = function( a, b, t ) {
var deltaR = a.r - b.r;
var deltaG = a.g - b.g;
var deltaB = a.b - b.b;
@@ -81,6 +82,7 @@ THREE.VRMLLoader.prototype = {
c.b = a.b - t * deltaB;
return c;
@@ -105,11 +107,11 @@ THREE.VRMLLoader.prototype = {
* @param colors
* @param boolean directionIsDown Whether to work bottom up or top down.
- var paintFaces = function (geometry, radius, angles, colors, directionIsDown) {
+ var paintFaces = function ( geometry, radius, angles, colors, directionIsDown ) {
var f, n, p, vertexIndex, color;
- var direction = directionIsDown ? 1 : -1;
+ var direction = directionIsDown ? 1 : - 1;
var faceIndices = [ 'a', 'b', 'c', 'd' ];
@@ -120,9 +122,9 @@ THREE.VRMLLoader.prototype = {
var vec = { };
// push the vector at which the color changes
- vec.y = direction * ( Math.cos( angles[k] ) * radius);
+ vec.y = direction * ( Math.cos( angles[ k ] ) * radius );
- vec.x = direction * ( Math.sin( angles[k] ) * radius);
+ vec.x = direction * ( Math.sin( angles[ k ] ) * radius );
coord.push( vec );
@@ -148,7 +150,7 @@ THREE.VRMLLoader.prototype = {
if ( index === 0 ) {
A.x = 0;
- A.y = directionIsDown ? radius : -1 * radius;
+ A.y = directionIsDown ? radius : - 1 * radius;
@@ -158,13 +160,14 @@ THREE.VRMLLoader.prototype = {
// B is current point (angle)
- B = coord[index];
+ B = coord[ index ];
if ( undefined !== B ) {
// p has to be between the points A and B which we interpolate
applyColor = directionIsDown ? p.y <= A.y && p.y > B.y : p.y >= A.y && p.y < B.y;
- if (applyColor) {
+ if ( applyColor ) {
bColor = colors[ index + 1 ];
@@ -177,21 +180,25 @@ THREE.VRMLLoader.prototype = {
color = interpolateColors( aColor, bColor, t );
f.vertexColors[ j ] = color;
} else if ( undefined === f.vertexColors[ j ] ) {
colorIndex = directionIsDown ? colors.length - 1 : 0;
f.vertexColors[ j ] = colors[ colorIndex ];
- var parseProperty = function (node, line) {
+ var parseProperty = function ( node, line ) {
var parts = [], part, property = {}, fieldName;
@@ -203,15 +210,17 @@ THREE.VRMLLoader.prototype = {
var point, index, angles, colors;
- while (null != ( part = regex.exec(line) ) ) {
- parts.push(part[0]);
+ while ( null != ( part = regex.exec( line ) ) ) {
+ parts.push( part[ 0 ] );
- fieldName = parts[0];
+ fieldName = parts[ 0 ];
// trigger several recorders
- switch (fieldName) {
+ switch ( fieldName ) {
case 'skyAngle':
case 'groundAngle':
this.recordingFieldname = fieldName;
@@ -236,56 +245,72 @@ THREE.VRMLLoader.prototype = {
- if (this.isRecordingFaces) {
+ if ( this.isRecordingFaces ) {
// the parts hold the indexes as strings
- if (parts.length > 0) {
+ if ( parts.length > 0 ) {
index = [];
- for (var ind = 0; ind < parts.length; ind ++) {
+ for ( var ind = 0; ind < parts.length; ind ++ ) {
// the part should either be positive integer or -1
- if (!/(-?\d+)/.test( parts[ind]) ) {
+ if ( ! /(-?\d+)/.test( parts[ ind ] ) ) {
continue;
// end of current face
- if (parts[ind] === "-1") {
- if (index.length > 0) {
- this.indexes.push(index);
+ if ( parts[ ind ] === "-1" ) {
+ if ( index.length > 0 ) {
+ this.indexes.push( index );
// start new one
- index.push(parseInt( parts[ind]) );
+ index.push( parseInt( parts[ ind ] ) );
// end
- if (/]/.exec(line)) {
+ if ( /]/.exec( line ) ) {
this.isRecordingFaces = false;
node.coordIndex = this.indexes;
- } else if (this.isRecordingPoints) {
+ } else if ( this.isRecordingPoints ) {
+ while ( null !== ( parts = float3_pattern.exec( line ) ) ) {
- while ( null !== ( parts = float3_pattern.exec(line) ) ) {
point = {
- x: parseFloat(parts[1]),
- y: parseFloat(parts[2]),
- z: parseFloat(parts[3])
+ x: parseFloat( parts[ 1 ] ),
+ y: parseFloat( parts[ 2 ] ),
+ z: parseFloat( parts[ 3 ] )
- this.points.push(point);
+ this.points.push( point );
- if ( /]/.exec(line) ) {
this.isRecordingPoints = false;
node.points = this.points;
} else if ( this.isRecordingAngles ) {
@@ -296,59 +321,68 @@ THREE.VRMLLoader.prototype = {
for ( var ind = 0; ind < parts.length; ind ++ ) {
// the part should be a float
- if ( ! float_pattern.test( parts[ind] ) ) {
+ if ( ! float_pattern.test( parts[ ind ] ) ) {
- this.angles.push( parseFloat( parts[ind] ) );
+ this.angles.push( parseFloat( parts[ ind ] ) );
this.isRecordingAngles = false;
- node[this.recordingFieldname] = this.angles;
+ node[ this.recordingFieldname ] = this.angles;
- } else if (this.isRecordingColors) {
+ } else if ( this.isRecordingColors ) {
color = {
- r: parseFloat(parts[1]),
- g: parseFloat(parts[2]),
- b: parseFloat(parts[3])
+ r: parseFloat( parts[ 1 ] ),
+ g: parseFloat( parts[ 2 ] ),
+ b: parseFloat( parts[ 3 ] )
- this.colors.push(color);
+ this.colors.push( color );
this.isRecordingColors = false;
- node[this.recordingFieldname] = this.colors;
+ node[ this.recordingFieldname ] = this.colors;
- } else if ( parts[parts.length - 1] !== 'NULL' && fieldName !== 'children') {
+ } else if ( parts[ parts.length - 1 ] !== 'NULL' && fieldName !== 'children' ) {
case 'diffuseColor':
case 'emissiveColor':
case 'specularColor':
case 'color':
- if (parts.length != 4) {
- console.warn('Invalid color format detected for ' + fieldName );
+ if ( parts.length != 4 ) {
+ console.warn( 'Invalid color format detected for ' + fieldName );
property = {
@@ -356,15 +390,17 @@ THREE.VRMLLoader.prototype = {
case 'translation':
case 'scale':
case 'size':
- console.warn('Invalid vector format detected for ' + fieldName);
+ console.warn( 'Invalid vector format detected for ' + fieldName );
@@ -376,26 +412,30 @@ THREE.VRMLLoader.prototype = {
case 'transparency':
case 'shininess':
case 'ambientIntensity':
- if (parts.length != 2) {
- console.warn('Invalid single float value specification detected for ' + fieldName);
+ if ( parts.length != 2 ) {
+ console.warn( 'Invalid single float value specification detected for ' + fieldName );
- property = parseFloat(parts[1]);
+ property = parseFloat( parts[ 1 ] );
case 'rotation':
- if (parts.length != 5) {
- console.warn('Invalid quaternion format detected for ' + fieldName);
+ if ( parts.length != 5 ) {
+ console.warn( 'Invalid quaternion format detected for ' + fieldName );
- z: parseFloat(parts[3]),
- w: parseFloat(parts[4])
+ z: parseFloat( parts[ 3 ] ),
+ w: parseFloat( parts[ 4 ] )
@@ -404,20 +444,24 @@ THREE.VRMLLoader.prototype = {
case 'solid':
case 'colorPerVertex':
case 'convex':
- console.warn('Invalid format detected for ' + fieldName);
+ console.warn( 'Invalid format detected for ' + fieldName );
- property = parts[1] === 'TRUE' ? true : false;
+ property = parts[ 1 ] === 'TRUE' ? true : false;
- node[fieldName] = property;
+ node[ fieldName ] = property;
return property;
var getTree = function ( lines ) {
@@ -435,41 +479,49 @@ THREE.VRMLLoader.prototype = {
// omit whitespace only lines
if ( null !== ( result = /^\s+?$/g.exec( line ) ) ) {
// skip empty lines
- if (line === '') {
+ if ( line === '' ) {
if ( /#/.exec( line ) ) {
- var parts = line.split('#');
+ var parts = line.split( '#' );
// discard everything after the #, it is a comment
- line = parts[0];
+ line = parts[ 0 ];
// well, let's also keep the comment
- comment = parts[1];
+ comment = parts[ 1 ];
- if ( matches = /([^\s]*){1}\s?{/.exec( line ) ) { // first subpattern should match the Node name
+ if ( matches = /([^\s]*){1}\s?{/.exec( line ) ) {
+ // first subpattern should match the Node name
- var block = { 'nodeType' : matches[1], 'string': line, 'parent': current, 'children': [],'comment' : comment };
+ var block = { 'nodeType' : matches[ 1 ], 'string': line, 'parent': current, 'children': [], 'comment' : comment };
current.children.push( block );
current = block;
if ( /}/.exec( line ) ) {
// example: geometry Box { size 1 1 1 } # all on the same line
specification = /{(.*)}/.exec( line )[ 1 ];
// todo: remove once new parsing is complete?
block.children.push( specification );
- parseProperty(current, specification);
+ parseProperty( current, specification );
current = current.parent;
@@ -481,7 +533,7 @@ THREE.VRMLLoader.prototype = {
} else if ( line !== '' ) {
- parseProperty(current, line);
+ parseProperty( current, line );
// todo: remove once new parsing is complete? we still do not parse geometry and appearance the new way
current.children.push( line );
@@ -490,6 +542,7 @@ THREE.VRMLLoader.prototype = {
return tree;
var parseNode = function ( data, parent ) {
@@ -502,8 +555,10 @@ THREE.VRMLLoader.prototype = {
var defineKey = /USE\s+?(\w+)/.exec( data )[ 1 ];
- if (undefined == defines[defineKey]) {
- console.warn(defineKey + ' is not defined.');
+ if ( undefined == defines[ defineKey ] ) {
+ console.warn( defineKey + ' is not defined.' );
if ( /appearance/.exec( data ) && defineKey ) {
@@ -515,12 +570,14 @@ THREE.VRMLLoader.prototype = {
parent.geometry = defines[ defineKey ].clone();
// the solid property is not cloned with clone(), is only needed for VRML loading, so we need to transfer it
- if (undefined !== defines[ defineKey ].solid && defines[ defineKey ].solid === false) {
+ if ( undefined !== defines[ defineKey ].solid && defines[ defineKey ].solid === false ) {
parent.geometry.solid = false;
parent.material.side = THREE.DoubleSide;
- } else if (defineKey) {
+ } else if ( defineKey ) {
var object = defines[ defineKey ].clone();
@@ -542,15 +599,17 @@ THREE.VRMLLoader.prototype = {
object = new THREE.Object3D();
if ( /DEF/.exec( data.string ) ) {
object.name = /DEF\s+(\w+)/.exec( data.string )[ 1 ];
defines[ object.name ] = object;
- if ( undefined !== data['translation'] ) {
+ if ( undefined !== data[ 'translation' ] ) {
var t = data.translation;
- object.position.set(t.x, t.y, t.z);
+ object.position.set( t.x, t.y, t.z );
@@ -581,6 +640,7 @@ THREE.VRMLLoader.prototype = {
object.name = /DEF (\w+)/.exec( data.string )[ 1 ];
@@ -667,10 +727,13 @@ THREE.VRMLLoader.prototype = {
vec = new THREE.Vector3( point.x, point.y, point.z );
geometry.vertices.push( vec );
var skip = 0;
@@ -678,7 +741,7 @@ THREE.VRMLLoader.prototype = {
// read this: http://math.hws.edu/eck/cs424/notes2013/16_Threejs_Advanced.html
for ( var i = 0, j = data.coordIndex.length; i < j; i ++ ) {
- indexes = data.coordIndex[i];
+ indexes = data.coordIndex[ i ];
// vrml support multipoint indexed face sets (more then 3 vertices). You must calculate the composing triangles here
skip = 0;
@@ -689,9 +752,9 @@ THREE.VRMLLoader.prototype = {
while ( indexes.length >= 3 && skip < ( indexes.length - 2 ) ) {
var face = new THREE.Face3(
- indexes[0],
- indexes[skip + 1],
- indexes[skip + 2],
+ indexes[ 0 ],
+ indexes[ skip + 1 ],
+ indexes[ skip + 2 ],
null // normal, will be added later
// todo: pass in the color, if a color index is present
@@ -706,7 +769,9 @@ THREE.VRMLLoader.prototype = {
if ( false === data.solid ) {
// we need to store it on the geometry for use with defines
@@ -718,11 +783,14 @@ THREE.VRMLLoader.prototype = {
// see if it's a define
geometry.name = /DEF (\w+)/.exec( data.string )[ 1 ];
defines[ geometry.name ] = geometry;
parent.geometry = geometry;
@@ -734,6 +802,7 @@ THREE.VRMLLoader.prototype = {
var child = data.children[ i ];
if ( 'Material' === child.nodeType ) {
var material = new THREE.MeshPhongMaterial();
if ( undefined !== child.diffuseColor ) {
@@ -783,6 +852,7 @@ THREE.VRMLLoader.prototype = {
// material found, stop looping
@@ -825,4 +895,4 @@ THREE.VRMLLoader.prototype = {
@@ -308,10 +308,10 @@ THREE.SceneLoader.prototype = {
object.matrixAutoUpdate = false;
object.matrix.set(
- mat[0], mat[1], mat[2], mat[3],
- mat[4], mat[5], mat[6], mat[7],
- mat[8], mat[9], mat[10], mat[11],
- mat[12], mat[13], mat[14], mat[15]
+ mat[ 0 ], mat[ 1 ], mat[ 2 ], mat[ 3 ],
+ mat[ 4 ], mat[ 5 ], mat[ 6 ], mat[ 7 ],
+ mat[ 8 ], mat[ 9 ], mat[ 10 ], mat[ 11 ],
+ mat[ 12 ], mat[ 13 ], mat[ 14 ], mat[ 15 ]
@@ -385,7 +385,7 @@ THREE.SceneLoader.prototype = {
case 'AreaLight':
- light = new THREE.AreaLight(color, intensity);
+ light = new THREE.AreaLight( color, intensity );
light.position.fromArray( position );
light.width = objJSON.size;
light.height = objJSON.size_y;
@@ -763,7 +763,7 @@ THREE.SceneLoader.prototype = {
color = fogJSON.color;
- fog.color.setRGB( color[0], color[1], color[2] );
+ fog.color.setRGB( color[ 0 ], color[ 1 ], color[ 2 ] );
result.fogs[ fogID ] = fog;
@@ -805,7 +805,7 @@ THREE.SceneLoader.prototype = {
@@ -29,6 +29,7 @@ THREE.ColorConverter = {
s: 2 * hsl.s / ( hsl.l + hsl.s ),
v: hsl.l + hsl.s
// where c, m, y, k is between 0 and 1
@@ -48,7 +49,7 @@ THREE.ColorConverter = {
var r = color.r;
var g = color.g;
var b = color.b;
- var k = 1 - Math.max(r, g, b);
+ var k = 1 - Math.max( r, g, b );
var c = ( 1 - r - k ) / ( 1 - k );
var m = ( 1 - g - k ) / ( 1 - k );
var y = ( 1 - b - k ) / ( 1 - k );
@@ -60,4 +61,4 @@ THREE.ColorConverter = {
@@ -26,7 +26,7 @@ THREE.Lut = function ( colormap, numberofcolors ) {
color = minColor.lerp( maxColor, ( i - min ) / ( max - min ) );
- this.lut.push(color);
+ this.lut.push( color );
@@ -130,7 +130,11 @@ THREE.Lut.prototype = {
setLegendOn: function ( parameters ) {
- if ( parameters === undefined ) { parameters = {}; }
+ if ( parameters === undefined ) {
+ parameters = {};
this.legend = {};
@@ -165,7 +169,7 @@ THREE.Lut.prototype = {
var step = 1.0 / this.n;
- for ( var i = 1; i >= 0; i-=step ) {
+ for ( var i = 1; i >= 0; i -= step ) {
for ( var j = this.map.length - 1; j >= 0; j -- ) {
@@ -174,16 +178,16 @@ THREE.Lut.prototype = {
var min = this.map[ j - 1 ][ 0 ];
var max = this.map[ j ][ 0 ];
var color = new THREE.Color( 0xffffff );
- var minColor = new THREE.Color( 0xffffff ).setHex( this.map[ j - 1][ 1 ] );
+ var minColor = new THREE.Color( 0xffffff ).setHex( this.map[ j - 1 ][ 1 ] );
var maxColor = new THREE.Color( 0xffffff ).setHex( this.map[ j ][ 1 ] );
- data[ k * 4 ] = Math.round( color.r * 255 );
+ data[ k * 4 ] = Math.round( color.r * 255 );
data[ k * 4 + 1 ] = Math.round( color.g * 255 );
data[ k * 4 + 2 ] = Math.round( color.b * 255 );
data[ k * 4 + 3 ] = 255;
- k+=1;
+ k += 1;
@@ -199,7 +203,7 @@ THREE.Lut.prototype = {
this.legend.mesh = new THREE.Mesh( this.legend.legendGeometry, this.legend.legendMaterial );
- if ( this.legend.layout == 'horizontal') {
+ if ( this.legend.layout == 'horizontal' ) {
this.legend.mesh.rotation.z = - 90 * ( Math.PI / 180 );
@@ -221,11 +225,23 @@ THREE.Lut.prototype = {
setLegendLayout: function ( layout ) {
- if ( ! this.legend ) { return false; }
+ if ( ! this.legend ) {
- if ( this.legend.layout == layout ) { return false; }
- if ( layout != 'horizontal' && layout != 'vertical' ) { return false; }
+ if ( this.legend.layout == layout ) {
+ if ( layout != 'horizontal' && layout != 'vertical' ) {
this.layout = layout;
@@ -237,7 +253,7 @@ THREE.Lut.prototype = {
if ( layout == 'vertical' ) {
- this.legend.mesh.rotation.z = -90 * ( Math.PI / 180 );
+ this.legend.mesh.rotation.z = - 90 * ( Math.PI / 180 );
@@ -255,11 +271,23 @@ THREE.Lut.prototype = {
setLegendLabels: function ( parameters, callback ) {
- if ( typeof parameters === 'function') { callback = parameters; }
+ if ( typeof parameters === 'function' ) {
+ callback = parameters;
this.legend.labels = {};
@@ -348,17 +376,13 @@ THREE.Lut.prototype = {
value = callback ( value );
if ( this.legend.labels.notation == 'scientific' ) {
value = value.toExponential( this.legend.labels.decimal );
value = value.toFixed( this.legend.labels.decimal );
@@ -408,13 +432,21 @@ THREE.Lut.prototype = {
if ( this.legend.labels.ticks > 5 ) {
- if ( i % 2 === 0 ) { var offset = 1.7; }
+ if ( i % 2 === 0 ) {
- else { var offset = 2.1; }
+ var offset = 1.7;
+ var offset = 2.1;
- else { var offset = 1.7; }
spriteTick.position.set( position, this.legend.position.y - this.legend.dimensions.width * offset, this.legend.position.z );
@@ -463,9 +495,9 @@ THREE.Lut.prototype = {
THREE.ColorMapKeywords = {
- "rainbow": [ [ 0.0, '0x0000FF' ], [ 0.2, '0x00FFFF' ], [ 0.5, '0x00FF00' ], [ 0.8, '0xFFFF00' ], [ 1.0, '0xFF0000' ] ],
- "cooltowarm": [ [ 0.0, '0x3C4EC2' ], [ 0.2, '0x9BBCFF' ], [ 0.5, '0xDCDCDC' ], [ 0.8, '0xF6A385' ], [ 1.0, '0xB40426' ] ],
- "blackbody" : [ [ 0.0, '0x000000' ], [ 0.2, '0x780000' ], [ 0.5, '0xE63200' ], [ 0.8, '0xFFFF00' ], [ 1.0, '0xFFFFFF' ] ],
- "grayscale" : [ [ 0.0, '0x000000' ], [ 0.2, '0x404040' ], [ 0.5, '0x7F7F80' ], [ 0.8, '0xBFBFBF' ], [ 1.0, '0xFFFFFF' ] ]
+ "rainbow": [ [ 0.0, '0x0000FF' ], [ 0.2, '0x00FFFF' ], [ 0.5, '0x00FF00' ], [ 0.8, '0xFFFF00' ], [ 1.0, '0xFF0000' ] ],
+ "cooltowarm": [ [ 0.0, '0x3C4EC2' ], [ 0.2, '0x9BBCFF' ], [ 0.5, '0xDCDCDC' ], [ 0.8, '0xF6A385' ], [ 1.0, '0xB40426' ] ],
+ "blackbody" : [ [ 0.0, '0x000000' ], [ 0.2, '0x780000' ], [ 0.5, '0xE63200' ], [ 0.8, '0xFFFF00' ], [ 1.0, '0xFFFFFF' ] ],
+ "grayscale" : [ [ 0.0, '0x000000' ], [ 0.2, '0x404040' ], [ 0.5, '0x7F7F80' ], [ 0.8, '0xBFBFBF' ], [ 1.0, '0xFFFFFF' ] ]
@@ -17,7 +17,7 @@
THREE.SubdivisionModifier = function ( subdivisions ) {
- this.subdivisions = (subdivisions === undefined ) ? 1 : subdivisions;
+ this.subdivisions = ( subdivisions === undefined ) ? 1 : subdivisions;
@@ -27,7 +27,9 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
var repeats = this.subdivisions;
while ( repeats -- > 0 ) {
this.smooth( geometry );
delete geometry.__tmpVertices;
@@ -37,10 +39,10 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
-(function() {
+( function() {
// Some constants
- var WARNINGS = !true; // Set to true for development
+ var WARNINGS = ! true; // Set to true for development
var ABC = [ 'a', 'b', 'c' ];
@@ -102,10 +104,13 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
var i, il, face, edge;
for ( i = 0, il = vertices.length; i < il; i ++ ) {
metaVertices[ i ] = { edges: [] };
for ( i = 0, il = faces.length; i < il; i ++ ) {
face = faces[ i ];
processEdge( face.a, face.b, vertices, edges, face, metaVertices );
@@ -113,6 +118,7 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
processEdge( face.c, face.a, vertices, edges, face, metaVertices );
function newFace( newFaces, a, b, c ) {
@@ -150,7 +156,7 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
metaVertices = new Array( oldVertices.length );
sourceEdges = {}; // Edge => { oldVertex1, oldVertex2, faces[] }
- generateLookups(oldVertices, oldFaces, metaVertices, sourceEdges);
+ generateLookups( oldVertices, oldFaces, metaVertices, sourceEdges );
/******************************************************
@@ -184,7 +190,7 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
if ( connectedFaces != 1 ) {
- if (WARNINGS) console.warn('Subdivision Modifier: Number of connected faces != 2, is: ', connectedFaces, currentEdge);
+ if ( WARNINGS ) console.warn( 'Subdivision Modifier: Number of connected faces != 2, is: ', connectedFaces, currentEdge );
@@ -200,8 +206,8 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
for ( k = 0; k < 3; k ++ ) {
- other = oldVertices[ face[ ABC[k] ] ];
- if (other !== currentEdge.a && other !== currentEdge.b ) break;
+ other = oldVertices[ face[ ABC[ k ] ] ];
+ if ( other !== currentEdge.a && other !== currentEdge.b ) break;
@@ -213,9 +219,10 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
newEdge.add( tmp );
currentEdge.newEdge = newEdgeVertices.length;
- newEdgeVertices.push(newEdge);
+ newEdgeVertices.push( newEdge );
// console.log(currentEdge, newEdge);
@@ -261,7 +268,7 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
if ( n == 2 ) {
- if (WARNINGS) console.warn('2 connecting edges', connectingEdges);
+ if ( WARNINGS ) console.warn( '2 connecting edges', connectingEdges );
sourceVertexWeight = 3 / 4;
connectingVertexWeight = 1 / 8;
@@ -270,11 +277,11 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
} else if ( n == 1 ) {
- if (WARNINGS) console.warn('only 1 connecting edge');
+ if ( WARNINGS ) console.warn( 'only 1 connecting edge' );
} else if ( n == 0 ) {
- if (WARNINGS) console.warn('0 connecting edges');
+ if ( WARNINGS ) console.warn( '0 connecting edges' );
@@ -340,4 +347,4 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
-})();
+} )();
@@ -38,29 +38,29 @@ THREE.ShadowMesh.prototype.update = function () {
var dot = plane.normal.x * lightPosition4D.x +
plane.normal.y * lightPosition4D.y +
plane.normal.z * lightPosition4D.z +
- -plane.constant * lightPosition4D.w;
+ - plane.constant * lightPosition4D.w;
var sme = shadowMatrix.elements;
sme[ 0 ] = dot - lightPosition4D.x * plane.normal.x;
sme[ 4 ] = - lightPosition4D.x * plane.normal.y;
sme[ 8 ] = - lightPosition4D.x * plane.normal.z;
- sme[ 12 ] = - lightPosition4D.x * -plane.constant;
+ sme[ 12 ] = - lightPosition4D.x * - plane.constant;
sme[ 1 ] = - lightPosition4D.y * plane.normal.x;
sme[ 5 ] = dot - lightPosition4D.y * plane.normal.y;
sme[ 9 ] = - lightPosition4D.y * plane.normal.z;
- sme[ 13 ] = - lightPosition4D.y * -plane.constant;
+ sme[ 13 ] = - lightPosition4D.y * - plane.constant;
sme[ 2 ] = - lightPosition4D.z * plane.normal.x;
sme[ 6 ] = - lightPosition4D.z * plane.normal.y;
sme[ 10 ] = dot - lightPosition4D.z * plane.normal.z;
- sme[ 14 ] = - lightPosition4D.z * -plane.constant;
+ sme[ 14 ] = - lightPosition4D.z * - plane.constant;
sme[ 3 ] = - lightPosition4D.w * plane.normal.x;
sme[ 7 ] = - lightPosition4D.w * plane.normal.y;
sme[ 11 ] = - lightPosition4D.w * plane.normal.z;
- sme[ 15 ] = dot - lightPosition4D.w * -plane.constant;
+ sme[ 15 ] = dot - lightPosition4D.w * - plane.constant;
this.matrix.multiplyMatrices( shadowMatrix, this.meshMatrix );
@@ -11,7 +11,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
this.resolution = ( resolution !== undefined ) ? resolution : 256;
this.needsInit = true;
- this.adaptive = adaptive !== undefined ? !!adaptive : true;
+ this.adaptive = adaptive !== undefined ? !! adaptive : true;
this.luminanceRT = null;
this.previousLuminanceRT = null;
@@ -47,7 +47,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
this.adaptLuminanceShader = {
- "MIP_LEVEL_1X1" : ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed(1),
+ "MIP_LEVEL_1X1" : ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 ),
"lastLum": { type: "t", value: null },
@@ -64,7 +64,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
"varying vec2 vUv;",
@@ -90,7 +90,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
// "fAdaptedLum = sqrt(fAdaptedLum);",
"gl_FragColor = vec4( vec3( fAdaptedLum ), 1.0 );",
this.materialAdaptiveLum = new THREE.ShaderMaterial( {
@@ -117,7 +117,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
this.needsSwap = true;
this.clear = false;
- this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
+ this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
@@ -130,14 +130,17 @@ THREE.AdaptiveToneMappingPass.prototype = {
render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
if ( this.needsInit ) {
this.reset( renderer );
this.luminanceRT.type = readBuffer.type;
this.previousLuminanceRT.type = readBuffer.type;
this.currentLuminanceRT.type = readBuffer.type;
this.needsInit = false;
if ( this.adaptive ) {
//Render the luminance of the current scene into a render target with mipmapping enabled
this.quad.material = this.materialLuminance;
this.materialLuminance.uniforms.tDiffuse.value = readBuffer;
@@ -155,6 +158,7 @@ THREE.AdaptiveToneMappingPass.prototype = {
this.quad.material = this.materialCopy;
this.copyUniforms.tDiffuse.value = this.luminanceRT;
renderer.render( this.scene, this.camera, this.previousLuminanceRT );
this.quad.material = this.materialToneMap;
@@ -164,15 +168,22 @@ THREE.AdaptiveToneMappingPass.prototype = {
reset: function( renderer ) {
// render targets
if ( this.luminanceRT ) {
this.luminanceRT.dispose();
if ( this.currentLuminanceRT ) {
this.currentLuminanceRT.dispose();
if ( this.previousLuminanceRT ) {
this.previousLuminanceRT.dispose();
var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat };
@@ -186,79 +197,119 @@ THREE.AdaptiveToneMappingPass.prototype = {
this.currentLuminanceRT = new THREE.WebGLRenderTarget( this.resolution, this.resolution, pars );
- this.materialToneMap.defines["ADAPTED_LUMINANCE"] = "";
+ this.materialToneMap.defines[ "ADAPTED_LUMINANCE" ] = "";
this.materialToneMap.uniforms.luminanceMap.value = this.luminanceRT;
//Put something in the adaptive luminance texture so that the scene can render initially
- this.quad.material = new THREE.MeshBasicMaterial( { color: 0x777777 });
+ this.quad.material = new THREE.MeshBasicMaterial( { color: 0x777777 } );
this.materialLuminance.needsUpdate = true;
this.materialAdaptiveLum.needsUpdate = true;
this.materialToneMap.needsUpdate = true;
// renderer.render( this.scene, this.camera, this.luminanceRT );
// renderer.render( this.scene, this.camera, this.previousLuminanceRT );
// renderer.render( this.scene, this.camera, this.currentLuminanceRT );
setAdaptive: function( adaptive ) {
if ( adaptive ) {
this.adaptive = true;
this.adaptive = false;
- delete this.materialToneMap.defines["ADAPTED_LUMINANCE"];
+ delete this.materialToneMap.defines[ "ADAPTED_LUMINANCE" ];
this.materialToneMap.uniforms.luminanceMap.value = undefined;
setAdaptionRate: function( rate ) {
if ( rate ) {
this.materialAdaptiveLum.uniforms.tau.value = Math.abs( rate );
setMaxLuminance: function( maxLum ) {
if ( maxLum ) {
this.materialToneMap.uniforms.maxLuminance.value = maxLum;
setAverageLuminance: function( avgLum ) {
if ( avgLum ) {
this.materialToneMap.uniforms.averageLuminance.value = avgLum;
setMiddleGrey: function( middleGrey ) {
if ( middleGrey ) {
this.materialToneMap.uniforms.middleGrey.value = middleGrey;
dispose: function() {
if ( this.materialLuminance ) {
this.materialLuminance.dispose();
if ( this.materialAdaptiveLum ) {
this.materialAdaptiveLum.dispose();
if ( this.materialCopy ) {
this.materialCopy.dispose();
if ( this.materialToneMap ) {
this.materialToneMap.dispose();
@@ -66,7 +66,7 @@ THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) {
@@ -33,7 +33,9 @@ THREE.BokehPass = function ( scene, camera, params ) {
// bokeh material
if ( THREE.BokehShader === undefined ) {
console.error( "THREE.BokehPass relies on THREE.BokehShader" );
var bokehShader = THREE.BokehShader;
@@ -46,11 +48,11 @@ THREE.BokehPass = function ( scene, camera, params ) {
bokehUniforms[ "aperture" ].value = aperture;
bokehUniforms[ "maxblur" ].value = maxblur;
- this.materialBokeh = new THREE.ShaderMaterial({
+ this.materialBokeh = new THREE.ShaderMaterial( {
uniforms: bokehUniforms,
vertexShader: bokehShader.vertexShader,
fragmentShader: bokehShader.fragmentShader
this.uniforms = bokehUniforms;
@@ -58,7 +60,7 @@ THREE.BokehPass = function ( scene, camera, params ) {
this.renderToScreen = false;
- this.camera2 = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
+ this.camera2 = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene2 = new THREE.Scene();
this.quad2 = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
@@ -12,8 +12,8 @@ THREE.DotScreenPass = function ( center, angle, scale ) {
this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
if ( center !== undefined ) this.uniforms[ "center" ].value.copy( center );
- if ( angle !== undefined ) this.uniforms[ "angle"].value = angle;
- if ( scale !== undefined ) this.uniforms[ "scale"].value = scale;
+ if ( angle !== undefined ) this.uniforms[ "angle" ].value = angle;
+ if ( scale !== undefined ) this.uniforms[ "scale" ].value = scale;
this.material = new THREE.ShaderMaterial( {
@@ -28,7 +28,7 @@ THREE.DotScreenPass = function ( center, angle, scale ) {
@@ -68,7 +68,7 @@ THREE.EffectComposer.prototype = {
pass = this.passes[ i ];
- if ( !pass.enabled ) continue;
+ if ( ! pass.enabled ) continue;
pass.render( this.renderer, this.writeBuffer, this.readBuffer, delta, maskActive );
@@ -29,7 +29,7 @@ THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount,
@@ -9,26 +9,26 @@ THREE.GlitchPass = function ( dt_size ) {
var shader = THREE.DigitalGlitch;
- if (dt_size == undefined) dt_size = 64;
+ if ( dt_size == undefined ) dt_size = 64;
- this.uniforms[ "tDisp"].value = this.generateHeightmap(dt_size);
+ this.uniforms[ "tDisp" ].value = this.generateHeightmap( dt_size );
- this.material = new THREE.ShaderMaterial({
+ this.material = new THREE.ShaderMaterial( {
uniforms: this.uniforms,
vertexShader: shader.vertexShader,
fragmentShader: shader.fragmentShader
- console.log(this.material);
+ console.log( this.material );
@@ -42,73 +42,79 @@ THREE.GlitchPass = function ( dt_size ) {
THREE.GlitchPass.prototype = {
- render: function ( renderer, writeBuffer, readBuffer, delta )
+ render: function ( renderer, writeBuffer, readBuffer, delta ) {
this.uniforms[ "tDiffuse" ].value = readBuffer;
this.uniforms[ 'seed' ].value = Math.random();//default seeding
this.uniforms[ 'byp' ].value = 0;
- if (this.curF % this.randX == 0 || this.goWild == true)
+ if ( this.curF % this.randX == 0 || this.goWild == true ) {
this.uniforms[ 'amount' ].value = Math.random() / 30;
- this.uniforms[ 'angle' ].value = THREE.Math.randFloat(-Math.PI, Math.PI);
- this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat(-1, 1);
- this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat(-1, 1);
- this.uniforms[ 'distortion_x' ].value = THREE.Math.randFloat(0, 1);
- this.uniforms[ 'distortion_y' ].value = THREE.Math.randFloat(0, 1);
+ this.uniforms[ 'angle' ].value = THREE.Math.randFloat( - Math.PI, Math.PI );
+ this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat( - 1, 1 );
+ this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat( - 1, 1 );
+ this.uniforms[ 'distortion_x' ].value = THREE.Math.randFloat( 0, 1 );
+ this.uniforms[ 'distortion_y' ].value = THREE.Math.randFloat( 0, 1 );
this.curF = 0;
this.generateTrigger();
- else if (this.curF % this.randX < this.randX / 5)
+ } else if ( this.curF % this.randX < this.randX / 5 ) {
this.uniforms[ 'amount' ].value = Math.random() / 90;
- this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat(-0.3, 0.3);
- this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat(-0.3, 0.3);
- else if (this.goWild == false)
+ this.uniforms[ 'seed_x' ].value = THREE.Math.randFloat( - 0.3, 0.3 );
+ this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat( - 0.3, 0.3 );
+ } else if ( this.goWild == false ) {
this.uniforms[ 'byp' ].value = 1;
this.curF ++;
this.quad.material = this.material;
- if ( this.renderToScreen )
+ if ( this.renderToScreen ) {
renderer.render( this.scene, this.camera, writeBuffer, false );
- generateTrigger:function()
- this.randX = THREE.Math.randInt(120, 240);
+ generateTrigger: function() {
+ this.randX = THREE.Math.randInt( 120, 240 );
- generateHeightmap:function(dt_size)
+ generateHeightmap: function( dt_size ) {
var data_arr = new Float32Array( dt_size * dt_size * 3 );
- console.log(dt_size);
+ console.log( dt_size );
var length = dt_size * dt_size;
- for ( var i = 0; i < length; i ++)
- var val = THREE.Math.randFloat(0, 1);
+ for ( var i = 0; i < length; i ++ ) {
+ var val = THREE.Math.randFloat( 0, 1 );
data_arr[ i * 3 + 0 ] = val;
data_arr[ i * 3 + 1 ] = val;
data_arr[ i * 3 + 2 ] = val;
var texture = new THREE.DataTexture( data_arr, dt_size, dt_size, THREE.RGBFormat, THREE.FloatType );
- console.log(texture);
+ console.log( texture );
texture.minFilter = THREE.NearestFilter;
texture.magFilter = THREE.NearestFilter;
texture.needsUpdate = true;
texture.flipY = false;
return texture;
@@ -35,7 +35,7 @@ THREE.SavePass = function ( renderTarget ) {
@@ -10,7 +10,7 @@ THREE.ShaderPass = function ( shader, textureID ) {
- defines: shader.defines || {},
+ defines: shader.defines || {},
@@ -24,7 +24,7 @@ THREE.ShaderPass = function ( shader, textureID ) {
@@ -26,7 +26,7 @@ THREE.TexturePass = function ( texture, opacity ) {
this.needsSwap = false;
@@ -188,7 +188,7 @@ THREE.CanvasRenderer = function ( parameters ) {
- _clipBox.min.set( -_canvasWidthHalf, -_canvasHeightHalf );
+ _clipBox.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
_clipBox.max.set( _canvasWidthHalf, _canvasHeightHalf );
_clearBox.min.set( - _canvasWidthHalf, - _canvasHeightHalf );
@@ -828,7 +828,7 @@ THREE.CanvasRenderer = function ( parameters ) {
texture instanceof THREE.CompressedTexture ||
texture instanceof THREE.DataTexture ) {
- return {
+ return {
canvas: undefined,
version: texture.version
@@ -533,8 +533,10 @@ THREE.Projector = function () {
var visible = renderList.checkBackfaceCulling( v1, v2, v3 );
if ( side !== THREE.DoubleSide ) {
if ( side === THREE.FrontSide && visible === false ) continue;
if ( side === THREE.BackSide && visible === true ) continue;
_face = getNextFaceInPool();
@@ -825,7 +827,7 @@ THREE.Projector = function () {
function painterSort( a, b ) {
- if ( a.renderOrder !== b.renderOrder) {
+ if ( a.renderOrder !== b.renderOrder ) {
return a.renderOrder - b.renderOrder;
@@ -543,4 +543,4 @@ THREE.RaytracingRenderer = function ( parameters ) {
-THREE.EventDispatcher.prototype.apply(THREE.RaytracingRenderer.prototype);
+THREE.EventDispatcher.prototype.apply( THREE.RaytracingRenderer.prototype );
@@ -20,7 +20,7 @@ THREE.SVGRenderer = function () {
var _this = this,
_renderData, _elements, _lights,
_projector = new THREE.Projector(),
- _svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
+ _svg = document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' ),
_svgWidth, _svgHeight, _svgWidthHalf, _svgHeightHalf,
_v1, _v2, _v3, _v4,
@@ -68,7 +68,7 @@ THREE.SVGRenderer = function () {
this.setQuality = function( quality ) {
- switch (quality) {
+ switch ( quality ) {
case "high": _quality = 1; break;
case "low": _quality = 0; break;
@@ -181,9 +181,9 @@ THREE.SVGRenderer = function () {
_v1 = element.v1; _v2 = element.v2; _v3 = element.v3;
- if ( _v1.positionScreen.z < -1 || _v1.positionScreen.z > 1 ) continue;
- if ( _v2.positionScreen.z < -1 || _v2.positionScreen.z > 1 ) continue;
- if ( _v3.positionScreen.z < -1 || _v3.positionScreen.z > 1 ) continue;
+ if ( _v1.positionScreen.z < - 1 || _v1.positionScreen.z > 1 ) continue;
+ if ( _v2.positionScreen.z < - 1 || _v2.positionScreen.z > 1 ) continue;
+ if ( _v3.positionScreen.z < - 1 || _v3.positionScreen.z > 1 ) continue;
_v1.positionScreen.x *= _svgWidthHalf; _v1.positionScreen.y *= - _svgHeightHalf;
_v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= - _svgHeightHalf;
@@ -385,7 +385,7 @@ THREE.SVGRenderer = function () {
} else if ( material instanceof THREE.MeshDepthMaterial ) {
- _w = 1 - ( material.__2near / (material.__farPlusNear - element.z * material.__farMinusNear) );
+ _w = 1 - ( material.__2near / ( material.__farPlusNear - element.z * material.__farMinusNear ) );
_color.setRGB( _w, _w, _w );
} else if ( material instanceof THREE.MeshNormalMaterial ) {
@@ -32,14 +32,14 @@ THREE.SoftwareRenderer = function ( parameters ) {
var imagedata, data, zbuffer;
var numBlocks, blockMaxZ, blockFlags;
- var BLOCK_ISCLEAR = (1 << 0);
- var BLOCK_NEEDCLEAR = (1 << 1);
+ var BLOCK_ISCLEAR = ( 1 << 0 );
+ var BLOCK_NEEDCLEAR = ( 1 << 1 );
var subpixelBits = 4;
- var subpixelBias = (1 << subpixelBits) - 1;
+ var subpixelBias = ( 1 << subpixelBits ) - 1;
var blockShift = 3;
var blockSize = 1 << blockShift;
- var maxZVal = (1 << 24); // Note: You want to size this so you don't get overflows.
+ var maxZVal = ( 1 << 24 ); // Note: You want to size this so you don't get overflows.
var rectx1 = Infinity, recty1 = Infinity;
var rectx2 = 0, recty2 = 0;
@@ -70,6 +70,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
clearColor.set( color );
cleanColorBuffer();
this.setPixelRatio = function () {};
@@ -84,7 +85,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
var fixScale = 1 << subpixelBits;
viewportXScale = fixScale * canvasWidth / 2;
- viewportYScale = -fixScale * canvasHeight / 2;
+ viewportYScale = - fixScale * canvasHeight / 2;
viewportZScale = maxZVal / 2;
viewportXOffs = fixScale * canvasWidth / 2 + 0.5;
@@ -134,7 +135,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
for ( var i = 0; i < numBlocks; i ++ ) {
blockMaxZ[ i ] = maxZVal;
- blockFlags[ i ] = (blockFlags[ i ] & BLOCK_ISCLEAR) ? BLOCK_ISCLEAR : BLOCK_NEEDCLEAR;
+ blockFlags[ i ] = ( blockFlags[ i ] & BLOCK_ISCLEAR ) ? BLOCK_ISCLEAR : BLOCK_NEEDCLEAR;
@@ -155,7 +156,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
if ( element instanceof THREE.RenderableFace ) {
- if ( !element.uvs ) {
+ if ( ! element.uvs ) {
drawTriangle(
element.v1.positionScreen,
@@ -164,15 +165,17 @@ THREE.SoftwareRenderer = function ( parameters ) {
null, null, null,
shader, element, material
element.v2.positionScreen,
element.v3.positionScreen,
- element.uvs[0], element.uvs[1], element.uvs[2],
+ element.uvs[ 0 ], element.uvs[ 1 ], element.uvs[ 2 ],
@@ -289,53 +292,64 @@ THREE.SoftwareRenderer = function ( parameters ) {
var size = canvasWidth * canvasHeight * 4;
- for ( var i = 0; i < size; i+=4 ) {
+ for ( var i = 0; i < size; i += 4 ) {
data[ i ] = clearColor.r * 255 | 0;
data[ i + 1 ] = clearColor.g * 255 | 0;
data[ i + 2 ] = clearColor.b * 255 | 0;
data[ i + 3 ] = 255;
context.fillStyle = clearColor.getStyle();
context.fillRect( 0, 0, canvasWidth, canvasHeight );
function getPalette( material, bSimulateSpecular ) {
var i = 0, j = 0;
var diffuseR = material.color.r * 255;
var diffuseG = material.color.g * 255;
var diffuseB = material.color.b * 255;
- var palette = new Uint8Array(256 * 3);
+ var palette = new Uint8Array( 256 * 3 );
if ( bSimulateSpecular ) {
- while (i < 204) {
- palette[j ++] = Math.min( i * diffuseR / 204, 255 );
- palette[j ++] = Math.min( i * diffuseG / 204, 255 );
- palette[j ++] = Math.min( i * diffuseB / 204, 255 );
+ while ( i < 204 ) {
+ palette[ j ++ ] = Math.min( i * diffuseR / 204, 255 );
+ palette[ j ++ ] = Math.min( i * diffuseG / 204, 255 );
+ palette[ j ++ ] = Math.min( i * diffuseB / 204, 255 );
++ i;
- while (i < 256) { // plus specular highlight
- palette[j ++] = Math.min( diffuseR + (i - 204) * (255 - diffuseR) / 82, 255 );
- palette[j ++] = Math.min( diffuseG + (i - 204) * (255 - diffuseG) / 82, 255 );
- palette[j ++] = Math.min( diffuseB + (i - 204) * (255 - diffuseB) / 82, 255 );
+ while ( i < 256 ) {
+ // plus specular highlight
+ palette[ j ++ ] = Math.min( diffuseR + ( i - 204 ) * ( 255 - diffuseR ) / 82, 255 );
+ palette[ j ++ ] = Math.min( diffuseG + ( i - 204 ) * ( 255 - diffuseG ) / 82, 255 );
+ palette[ j ++ ] = Math.min( diffuseB + ( i - 204 ) * ( 255 - diffuseB ) / 82, 255 );
- while (i < 256) {
- palette[j ++] = Math.min( i * diffuseR / 255, 255 );
- palette[j ++] = Math.min( i * diffuseG / 255, 255 );
- palette[j ++] = Math.min( i * diffuseB / 255, 255 );
+ palette[ j ++ ] = Math.min( i * diffuseR / 255, 255 );
+ palette[ j ++ ] = Math.min( i * diffuseG / 255, 255 );
+ palette[ j ++ ] = Math.min( i * diffuseB / 255, 255 );
return palette;
function basicMaterialShader( buffer, depthBuf, offset, depth, u, v, n, face, material ) {
@@ -344,35 +358,41 @@ THREE.SoftwareRenderer = function ( parameters ) {
var texture = textures[ material.map.id ];
- if ( !texture.data )
+ if ( ! texture.data )
var tdim = texture.width;
var isTransparent = material.transparent;
var tbound = tdim - 1;
var tdata = texture.data;
- var tIndex = (((v * tdim) & tbound) * tdim + ((u * tdim) & tbound)) * 4;
+ var tIndex = ( ( ( v * tdim ) & tbound ) * tdim + ( ( u * tdim ) & tbound ) ) * 4;
+ if ( ! isTransparent ) {
- if ( !isTransparent ) {
- buffer[ colorOffset ] = tdata[tIndex];
- buffer[ colorOffset + 1 ] = tdata[tIndex + 1];
- buffer[ colorOffset + 2 ] = tdata[tIndex + 2];
+ buffer[ colorOffset ] = tdata[ tIndex ];
+ buffer[ colorOffset + 1 ] = tdata[ tIndex + 1 ];
+ buffer[ colorOffset + 2 ] = tdata[ tIndex + 2 ];
buffer[ colorOffset + 3 ] = material.opacity * 255;
depthBuf[ offset ] = depth;
- var opaci = tdata[tIndex + 3] * material.opacity;
- var texel = (tdata[tIndex] << 16) + (tdata[tIndex + 1] << 8) + tdata[tIndex + 2];
- if (opaci < 250) {
- var backColor = (buffer[colorOffset] << 16) + (buffer[colorOffset + 1] << 8) + buffer[colorOffset + 2];
- texel = texel * opaci + backColor * (1 - opaci);
+ var opaci = tdata[ tIndex + 3 ] * material.opacity;
+ var texel = ( tdata[ tIndex ] << 16 ) + ( tdata[ tIndex + 1 ] << 8 ) + tdata[ tIndex + 2 ];
+ if ( opaci < 250 ) {
+ var backColor = ( buffer[ colorOffset ] << 16 ) + ( buffer[ colorOffset + 1 ] << 8 ) + buffer[ colorOffset + 2 ];
+ texel = texel * opaci + backColor * ( 1 - opaci );
- buffer[ colorOffset ] = (texel & 0xff0000) >> 16;
- buffer[ colorOffset + 1 ] = (texel & 0xff00) >> 8;
+ buffer[ colorOffset ] = ( texel & 0xff0000 ) >> 16;
+ buffer[ colorOffset + 1 ] = ( texel & 0xff00 ) >> 8;
buffer[ colorOffset + 2 ] = texel & 0xff;
function lightingMaterialShader( buffer, depthBuf, offset, depth, u, v, n, face, material ) {
@@ -381,37 +401,43 @@ THREE.SoftwareRenderer = function ( parameters ) {
- var cIndex = (n > 0 ? (~~n) : 0) * 3;
+ var cIndex = ( n > 0 ? ( ~~ n ) : 0 ) * 3;
- buffer[ colorOffset ] = (material.palette[cIndex] * tdata[tIndex]) >> 8;
- buffer[ colorOffset + 1 ] = (material.palette[cIndex + 1] * tdata[tIndex + 1]) >> 8;
- buffer[ colorOffset + 2 ] = (material.palette[cIndex + 2] * tdata[tIndex + 2]) >> 8;
+ buffer[ colorOffset ] = ( material.palette[ cIndex ] * tdata[ tIndex ] ) >> 8;
+ buffer[ colorOffset + 1 ] = ( material.palette[ cIndex + 1 ] * tdata[ tIndex + 1 ] ) >> 8;
+ buffer[ colorOffset + 2 ] = ( material.palette[ cIndex + 2 ] * tdata[ tIndex + 2 ] ) >> 8;
- var foreColor = ((material.palette[cIndex] * tdata[tIndex]) << 16)
- + ((material.palette[cIndex + 1] * tdata[tIndex + 1]) << 8 )
- + (material.palette[cIndex + 2] * tdata[tIndex + 2]);
+ var foreColor = ( ( material.palette[ cIndex ] * tdata[ tIndex ] ) << 16 )
+ + ( ( material.palette[ cIndex + 1 ] * tdata[ tIndex + 1 ] ) << 8 )
+ + ( material.palette[ cIndex + 2 ] * tdata[ tIndex + 2 ] );
var backColor = buffer[ colorOffset ] << 24 + buffer[ colorOffset + 1 ] << 16 + buffer[ colorOffset + 2 ] << 8;
- foreColor = foreColor * opaci + backColor * (1 - opaci);
+ foreColor = foreColor * opaci + backColor * ( 1 - opaci );
- buffer[ colorOffset ] = (foreColor & 0xff0000) >> 16;
- buffer[ colorOffset + 1 ] = (foreColor & 0xff00) >> 8;
- buffer[ colorOffset + 2 ] = (foreColor & 0xff);
+ buffer[ colorOffset ] = ( foreColor & 0xff0000 ) >> 16;
+ buffer[ colorOffset + 1 ] = ( foreColor & 0xff00 ) >> 8;
+ buffer[ colorOffset + 2 ] = ( foreColor & 0xff );
@@ -441,16 +467,23 @@ THREE.SoftwareRenderer = function ( parameters ) {
material instanceof THREE.SpriteMaterial ) {
if ( material instanceof THREE.MeshLambertMaterial ) {
// Generate color palette
- if ( !material.palette ) {
+ if ( ! material.palette ) {
material.palette = getPalette( material, false );
} else if ( material instanceof THREE.MeshPhongMaterial ) {
material.palette = getPalette( material, true );
var string;
@@ -472,9 +505,11 @@ THREE.SoftwareRenderer = function ( parameters ) {
|| material instanceof THREE.SpriteMaterial ) {
shader = basicMaterialShader;
shader = lightingMaterialShader;
@@ -489,7 +524,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
'buffer[ colorOffset + 2 ] = face.color.b * 255;',
'buffer[ colorOffset + 3 ] = material.opacity * 255;',
'depthBuf[ offset ] = depth;'
- ].join('\n');
+ ].join( '\n' );
@@ -500,11 +535,12 @@ THREE.SoftwareRenderer = function ( parameters ) {
'buffer[ colorOffset + 2 ] = material.color.b * 255;',
shader = new Function( 'buffer, depthBuf, offset, depth, u, v, n, face, material', string );
@@ -516,7 +552,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
'buffer[ colorOffset + 2 ] = 0;',
'buffer[ colorOffset + 3 ] = 255;',
shader = new Function( 'buffer, depthBuf, offset, depth, u, v', string );
@@ -558,32 +594,33 @@ THREE.SoftwareRenderer = function ( parameters ) {
// TODO: Implement per-pixel z-clipping
- if ( v1.z < -1 || v1.z > 1 || v2.z < -1 || v2.z > 1 || v3.z < -1 || v3.z > 1 ) return;
+ if ( v1.z < - 1 || v1.z > 1 || v2.z < - 1 || v2.z > 1 || v3.z < - 1 || v3.z > 1 ) return;
// https://gist.github.com/2486101
// explanation: http://pouet.net/topic.php?which=8760&page=1
// 28.4 fixed-point coordinates
- var x1 = (v1.x * viewportXScale + viewportXOffs) | 0;
- var x2 = (v2.x * viewportXScale + viewportXOffs) | 0;
- var x3 = (v3.x * viewportXScale + viewportXOffs) | 0;
+ var x1 = ( v1.x * viewportXScale + viewportXOffs ) | 0;
+ var x2 = ( v2.x * viewportXScale + viewportXOffs ) | 0;
+ var x3 = ( v3.x * viewportXScale + viewportXOffs ) | 0;
- var y1 = (v1.y * viewportYScale + viewportYOffs) | 0;
- var y2 = (v2.y * viewportYScale + viewportYOffs) | 0;
- var y3 = (v3.y * viewportYScale + viewportYOffs) | 0;
+ var y1 = ( v1.y * viewportYScale + viewportYOffs ) | 0;
+ var y2 = ( v2.y * viewportYScale + viewportYOffs ) | 0;
+ var y3 = ( v3.y * viewportYScale + viewportYOffs ) | 0;
// Z values (.28 fixed-point)
- var z1 = (v1.z * viewportZScale + viewportZOffs) | 0;
- var z2 = (v2.z * viewportZScale + viewportZOffs) | 0;
- var z3 = (v3.z * viewportZScale + viewportZOffs) | 0;
+ var z1 = ( v1.z * viewportZScale + viewportZOffs ) | 0;
+ var z2 = ( v2.z * viewportZScale + viewportZOffs ) | 0;
+ var z3 = ( v3.z * viewportZScale + viewportZOffs ) | 0;
// UV values
var bHasUV = false;
var tu1, tv1, tu2, tv2, tu3, tv3;
if ( uv1 && uv2 && uv3 ) {
bHasUV = true;
tu1 = uv1.x;
@@ -592,6 +629,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
tv2 = 1 - uv2.y;
tu3 = uv3.x;
tv3 = 1 - uv3.y;
// Normal values
@@ -599,14 +637,16 @@ THREE.SoftwareRenderer = function ( parameters ) {
var n1, n2, n3, nz1, nz2, nz3;
if ( face.vertexNormalsModel ) {
bHasNormal = true;
- n1 = face.vertexNormalsModel[0];
- n2 = face.vertexNormalsModel[1];
- n3 = face.vertexNormalsModel[2];
+ n1 = face.vertexNormalsModel[ 0 ];
+ n2 = face.vertexNormalsModel[ 1 ];
+ n3 = face.vertexNormalsModel[ 2 ];
nz1 = n1.z * 255;
nz2 = n2.z * 255;
nz3 = n3.z * 255;
// Deltas
@@ -633,17 +673,17 @@ THREE.SoftwareRenderer = function ( parameters ) {
// Start in corner of 8x8 block
- minx &= ~(q - 1);
- miny &= ~(q - 1);
+ minx &= ~ ( q - 1 );
+ miny &= ~ ( q - 1 );
// Constant part of half-edge functions
- var minXfixscale = (minx << subpixelBits);
- var minYfixscale = (miny << subpixelBits);
+ var minXfixscale = ( minx << subpixelBits );
+ var minYfixscale = ( miny << subpixelBits );
- var c1 = dy12 * ((minXfixscale) - x1) + dx12 * ((minYfixscale) - y1);
- var c2 = dy23 * ((minXfixscale) - x2) + dx23 * ((minYfixscale) - y2);
- var c3 = dy31 * ((minXfixscale) - x3) + dx31 * ((minYfixscale) - y3);
+ var c1 = dy12 * ( ( minXfixscale ) - x1 ) + dx12 * ( ( minYfixscale ) - y1 );
+ var c2 = dy23 * ( ( minXfixscale ) - x2 ) + dx23 * ( ( minYfixscale ) - y2 );
+ var c3 = dy31 * ( ( minXfixscale ) - x3 ) + dx31 * ( ( minYfixscale ) - y3 );
// Correct for fill convention
@@ -653,61 +693,65 @@ THREE.SoftwareRenderer = function ( parameters ) {
// Note this doesn't kill subpixel precision, but only because we test for >=0 (not >0).
// It's a bit subtle. :)
- c1 = (c1 - 1) >> subpixelBits;
- c2 = (c2 - 1) >> subpixelBits;
- c3 = (c3 - 1) >> subpixelBits;
+ c1 = ( c1 - 1 ) >> subpixelBits;
+ c2 = ( c2 - 1 ) >> subpixelBits;
+ c3 = ( c3 - 1 ) >> subpixelBits;
// Z interpolation setup
var dz12 = z1 - z2, dz31 = z3 - z1;
- var invDet = 1.0 / (dx12 * dy31 - dx31 * dy12);
- var dzdx = (invDet * (dz12 * dy31 - dz31 * dy12)); // dz per one subpixel step in x
- var dzdy = (invDet * (dz12 * dx31 - dx12 * dz31)); // dz per one subpixel step in y
+ var invDet = 1.0 / ( dx12 * dy31 - dx31 * dy12 );
+ var dzdx = ( invDet * ( dz12 * dy31 - dz31 * dy12 ) ); // dz per one subpixel step in x
+ var dzdy = ( invDet * ( dz12 * dx31 - dx12 * dz31 ) ); // dz per one subpixel step in y
// Z at top/left corner of rast area
- var cz = ( z1 + ((minXfixscale) - x1) * dzdx + ((minYfixscale) - y1) * dzdy ) | 0;
+ var cz = ( z1 + ( ( minXfixscale ) - x1 ) * dzdx + ( ( minYfixscale ) - y1 ) * dzdy ) | 0;
// Z pixel steps
- var fixscale = (1 << subpixelBits);
- dzdx = (dzdx * fixscale) | 0;
- dzdy = (dzdy * fixscale) | 0;
+ var fixscale = ( 1 << subpixelBits );
+ dzdx = ( dzdx * fixscale ) | 0;
+ dzdy = ( dzdy * fixscale ) | 0;
var dtvdx, dtvdy, cbtu, cbtv;
if ( bHasUV ) {
// UV interpolation setup
var dtu12 = tu1 - tu2, dtu31 = tu3 - tu1;
- var dtudx = (invDet * (dtu12 * dy31 - dtu31 * dy12)); // dtu per one subpixel step in x
- var dtudy = (invDet * (dtu12 * dx31 - dx12 * dtu31)); // dtu per one subpixel step in y
+ var dtudx = ( invDet * ( dtu12 * dy31 - dtu31 * dy12 ) ); // dtu per one subpixel step in x
+ var dtudy = ( invDet * ( dtu12 * dx31 - dx12 * dtu31 ) ); // dtu per one subpixel step in y
var dtv12 = tv1 - tv2, dtv31 = tv3 - tv1;
- dtvdx = (invDet * (dtv12 * dy31 - dtv31 * dy12)); // dtv per one subpixel step in x
- dtvdy = (invDet * (dtv12 * dx31 - dx12 * dtv31)); // dtv per one subpixel step in y
+ dtvdx = ( invDet * ( dtv12 * dy31 - dtv31 * dy12 ) ); // dtv per one subpixel step in x
+ dtvdy = ( invDet * ( dtv12 * dx31 - dx12 * dtv31 ) ); // dtv per one subpixel step in y
// UV at top/left corner of rast area
- cbtu = ( tu1 + (minXfixscale - x1) * dtudx + (minYfixscale - y1) * dtudy );
- cbtv = ( tv1 + (minXfixscale - x1) * dtvdx + (minYfixscale - y1) * dtvdy );
+ cbtu = ( tu1 + ( minXfixscale - x1 ) * dtudx + ( minYfixscale - y1 ) * dtudy );
+ cbtv = ( tv1 + ( minXfixscale - x1 ) * dtvdx + ( minYfixscale - y1 ) * dtvdy );
// UV pixel steps
dtudx = dtudx * fixscale;
dtudy = dtudy * fixscale;
dtvdx = dtvdx * fixscale;
dtvdy = dtvdy * fixscale;
var dnxdx, dnzdy, cbnz;
if ( bHasNormal ) {
// Normal interpolation setup
var dnz12 = nz1 - nz2, dnz31 = nz3 - nz1;
- var dnzdx = (invDet * (dnz12 * dy31 - dnz31 * dy12)); // dnz per one subpixel step in x
- var dnzdy = (invDet * (dnz12 * dx31 - dx12 * dnz31)); // dnz per one subpixel step in y
+ var dnzdx = ( invDet * ( dnz12 * dy31 - dnz31 * dy12 ) ); // dnz per one subpixel step in x
+ var dnzdy = ( invDet * ( dnz12 * dx31 - dx12 * dnz31 ) ); // dnz per one subpixel step in y
// Normal at top/left corner of rast area
- cbnz = ( nz1 + (minXfixscale - x1) * dnzdx + (minYfixscale - y1) * dnzdy );
+ cbnz = ( nz1 + ( minXfixscale - x1 ) * dnzdx + ( minYfixscale - y1 ) * dnzdy );
// Normal pixel steps
- dnzdx = (dnzdx * fixscale);
- dnzdy = (dnzdy * fixscale);
+ dnzdx = ( dnzdx * fixscale );
+ dnzdy = ( dnzdy * fixscale );
// Set up min/max corners
@@ -716,24 +760,24 @@ THREE.SoftwareRenderer = function ( parameters ) {
var nmin2 = 0, nmax2 = 0;
var nmin3 = 0, nmax3 = 0;
var nminz = 0, nmaxz = 0;
- if (dx12 >= 0) nmax1 -= qm1 * dx12; else nmin1 -= qm1 * dx12;
- if (dy12 >= 0) nmax1 -= qm1 * dy12; else nmin1 -= qm1 * dy12;
- if (dx23 >= 0) nmax2 -= qm1 * dx23; else nmin2 -= qm1 * dx23;
- if (dy23 >= 0) nmax2 -= qm1 * dy23; else nmin2 -= qm1 * dy23;
- if (dx31 >= 0) nmax3 -= qm1 * dx31; else nmin3 -= qm1 * dx31;
- if (dy31 >= 0) nmax3 -= qm1 * dy31; else nmin3 -= qm1 * dy31;
- if (dzdx >= 0) nmaxz += qm1 * dzdx; else nminz += qm1 * dzdx;
- if (dzdy >= 0) nmaxz += qm1 * dzdy; else nminz += qm1 * dzdy;
+ if ( dx12 >= 0 ) nmax1 -= qm1 * dx12; else nmin1 -= qm1 * dx12;
+ if ( dy12 >= 0 ) nmax1 -= qm1 * dy12; else nmin1 -= qm1 * dy12;
+ if ( dx23 >= 0 ) nmax2 -= qm1 * dx23; else nmin2 -= qm1 * dx23;
+ if ( dy23 >= 0 ) nmax2 -= qm1 * dy23; else nmin2 -= qm1 * dy23;
+ if ( dx31 >= 0 ) nmax3 -= qm1 * dx31; else nmin3 -= qm1 * dx31;
+ if ( dy31 >= 0 ) nmax3 -= qm1 * dy31; else nmin3 -= qm1 * dy31;
+ if ( dzdx >= 0 ) nmaxz += qm1 * dzdx; else nminz += qm1 * dzdx;
+ if ( dzdy >= 0 ) nmaxz += qm1 * dzdy; else nminz += qm1 * dzdy;
// Loop through blocks
var linestep = canvasWidth - q;
- var scale = 1.0 / (c1 + c2 + c3);
+ var scale = 1.0 / ( c1 + c2 + c3 );
var cb1 = c1;
var cb2 = c2;
var cb3 = c3;
var cbz = cz;
- var qstep = -q;
+ var qstep = - q;
var e1x = qstep * dy12;
var e2x = qstep * dy23;
var e3x = qstep * dy31;
@@ -741,13 +785,17 @@ THREE.SoftwareRenderer = function ( parameters ) {
var etux, etvx;
etux = qstep * dtudx;
etvx = qstep * dtvdx;
var enzx;
enzx = qstep * dnzdx;
var x0 = minx;
@@ -764,30 +812,38 @@ THREE.SoftwareRenderer = function ( parameters ) {
cbz += ezx;
cbtu += etux;
cbtv += etvx;
cbnz += enzx;
// Okay, we're now in a block we know is outside. Reverse direction and go into main loop.
- qstep = -qstep;
- e1x = -e1x;
- e2x = -e2x;
- e3x = -e3x;
- ezx = -ezx;
+ qstep = - qstep;
+ e1x = - e1x;
+ e2x = - e2x;
+ e3x = - e3x;
+ ezx = - ezx;
- etux = -etux;
- etvx = -etvx;
+ etux = - etux;
+ etvx = - etvx;
- enzx = -enzx;
+ enzx = - enzx;
while ( 1 ) {
@@ -800,21 +856,25 @@ THREE.SoftwareRenderer = function ( parameters ) {
// We're done with this block line when at least one edge completely out
// If an edge function is too small and decreasing in the current traversal
// dir, we're done with this line.
- if (x0 < minx || x0 >= maxx) break;
- if (cb1 < nmax1) if (e1x < 0) break; else continue;
- if (cb2 < nmax2) if (e2x < 0) break; else continue;
- if (cb3 < nmax3) if (e3x < 0) break; else continue;
+ if ( x0 < minx || x0 >= maxx ) break;
+ if ( cb1 < nmax1 ) if ( e1x < 0 ) break; else continue;
+ if ( cb2 < nmax2 ) if ( e2x < 0 ) break; else continue;
+ if ( cb3 < nmax3 ) if ( e3x < 0 ) break; else continue;
// We can skip this block if it's already fully covered
var blockX = x0 >> blockShift;
@@ -827,8 +887,8 @@ THREE.SoftwareRenderer = function ( parameters ) {
// Need to do a deferred clear?
var bflags = blockFlags[ blockId ];
- if ( bflags & BLOCK_NEEDCLEAR) clearBlock( blockX, blockY );
- blockFlags[ blockId ] = bflags & ~( BLOCK_ISCLEAR | BLOCK_NEEDCLEAR );
+ if ( bflags & BLOCK_NEEDCLEAR ) clearBlock( blockX, blockY );
+ blockFlags[ blockId ] = bflags & ~ ( BLOCK_ISCLEAR | BLOCK_NEEDCLEAR );
// Offset at top-left corner
var offset = x0 + y0 * canvasWidth;
@@ -845,13 +905,17 @@ THREE.SoftwareRenderer = function ( parameters ) {
var cytu, cytv;
cytu = cbtu;
cytv = cbtv;
var cynz;
cynz = cbnz;
@@ -864,13 +928,17 @@ THREE.SoftwareRenderer = function ( parameters ) {
var cxtu;
var cxtv;
cxtu = cytu;
cxtv = cytv;
var cxnz;
cxnz = cynz;
for ( var ix = 0; ix < q; ix ++ ) {
@@ -878,7 +946,9 @@ THREE.SoftwareRenderer = function ( parameters ) {
var z = cxz;
if ( z < zbuffer[ offset ] ) {
shader( data, zbuffer, offset, z, cxtu, cxtv, cxnz, face, material );
cx1 += dy12;
@@ -886,12 +956,16 @@ THREE.SoftwareRenderer = function ( parameters ) {
cxz += dzdx;
cxtu += dtudx;
cxtv += dtvdx;
cxnz += dnzdx;
offset ++;
@@ -903,19 +977,25 @@ THREE.SoftwareRenderer = function ( parameters ) {
cyz += dzdy;
cytu += dtudy;
cytv += dtvdy;
cynz += dnzdy;
offset += linestep;
- } else { // Partially covered block
+ // Partially covered block
var cy1 = cb1;
var cy2 = cb2;
@@ -924,13 +1004,17 @@ THREE.SoftwareRenderer = function ( parameters ) {
for ( var iy = 0; iy < q; iy ++ ) {
@@ -943,13 +1027,17 @@ THREE.SoftwareRenderer = function ( parameters ) {
@@ -959,7 +1047,9 @@ THREE.SoftwareRenderer = function ( parameters ) {
@@ -970,12 +1060,16 @@ THREE.SoftwareRenderer = function ( parameters ) {
@@ -988,12 +1082,16 @@ THREE.SoftwareRenderer = function ( parameters ) {
@@ -1011,12 +1109,16 @@ THREE.SoftwareRenderer = function ( parameters ) {
cbz += q * dzdy;
cbtu += q * dtudy;
cbtv += q * dtvdy;
cbnz += q * dnzdy;
@@ -1067,6 +1169,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
block ++;
@@ -1081,7 +1184,7 @@ THREE.SoftwareRenderer.Texture = function() {
this.fromImage = function( image ) {
- if ( !image || image.width <= 0 || image.height <= 0 )
+ if ( ! image || image.width <= 0 || image.height <= 0 )
if ( canvas === undefined ) {
@@ -1093,12 +1196,14 @@ THREE.SoftwareRenderer.Texture = function() {
var size = image.width > image.height ? image.width : image.height;
size = THREE.Math.nextPowerOfTwo( size );
- if ( canvas.width != size || canvas.height != size) {
+ if ( canvas.width != size || canvas.height != size ) {
canvas.width = size;
canvas.height = size;
- var ctx = canvas.getContext('2d');
+ var ctx = canvas.getContext( '2d' );
ctx.clearRect( 0, 0, size, size );
ctx.drawImage( image, 0, 0, size, size );
@@ -1108,5 +1213,7 @@ THREE.SoftwareRenderer.Texture = function() {
this.width = size;
this.height = size;
this.srcUrl = image.src;
@@ -185,8 +185,8 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
var specular = originalMaterial.specular !== undefined ? originalMaterial.specular : black;
var shininess = originalMaterial.shininess !== undefined ? originalMaterial.shininess : 1;
- var wrapAround = originalMaterial.wrapAround !== undefined ? ( originalMaterial.wrapAround ? -1 : 1 ) : 1;
- var additiveSpecular = originalMaterial.metal !== undefined ? ( originalMaterial.metal ? 1 : -1 ) : -1;
+ var wrapAround = originalMaterial.wrapAround !== undefined ? ( originalMaterial.wrapAround ? - 1 : 1 ) : 1;
+ var additiveSpecular = originalMaterial.metal !== undefined ? ( originalMaterial.metal ? 1 : - 1 ) : - 1;
uniforms.emissive.value.copyGammaToLinear( emissive );
uniforms.diffuse.value.copyGammaToLinear( diffuse );
@@ -204,7 +204,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
uniforms.refractionRatio.value = originalMaterial.refractionRatio;
uniforms.combine.value = originalMaterial.combine;
uniforms.reflectivity.value = originalMaterial.reflectivity;
- uniforms.flipEnvMap.value = ( originalMaterial.envMap instanceof THREE.WebGLRenderTargetCube ) ? 1 : -1;
+ uniforms.flipEnvMap.value = ( originalMaterial.envMap instanceof THREE.WebGLRenderTargetCube ) ? 1 : - 1;
uniforms.samplerNormalDepth.value = compNormalDepth.renderTarget2;
uniforms.viewWidth.value = scaledWidth;
@@ -270,7 +270,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
if ( originalMaterial.morphTargets || originalMaterial.skinning || originalMaterial.bumpMap ) {
var uniforms = THREE.UniformsUtils.clone( normalDepthShader.uniforms );
- var defines = { "USE_BUMPMAP": !!originalMaterial.bumpMap };
+ var defines = { "USE_BUMPMAP": !! originalMaterial.bumpMap };
var normalDepthMaterial = new THREE.ShaderMaterial( {
@@ -848,6 +848,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
effectFXAA.enabled = false;
compositePass.renderToScreen = true;
@@ -873,7 +874,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
- compFinal.insertPass( effect, -1 );
+ compFinal.insertPass( effect, - 1 );
@@ -990,7 +991,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
passColor.camera = currentCamera;
passNormalDepth.camera = currentCamera;
passLightProxy.camera = currentCamera;
- passLightFullscreen.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
+ passLightFullscreen.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
passColor.scene = scene;
passNormalDepth.scene = scene;
@@ -16,7 +16,7 @@ THREE.BasicShader = {
@@ -26,6 +26,6 @@ THREE.BasicShader = {
@@ -26,7 +26,7 @@ THREE.BleachBypassShader = {
@@ -59,6 +59,6 @@ THREE.BleachBypassShader = {
@@ -26,7 +26,7 @@ THREE.BlendShader = {
@@ -46,6 +46,6 @@ THREE.BlendShader = {
@@ -30,7 +30,7 @@ THREE.BokehShader = {
@@ -111,6 +111,6 @@ THREE.BokehShader = {
@@ -60,7 +60,7 @@ THREE.BokehShader = {
@@ -373,6 +373,6 @@ THREE.BokehShader = {
"} "
@@ -29,7 +29,7 @@ THREE.BrightnessContrastShader = {
@@ -53,6 +53,6 @@ THREE.BrightnessContrastShader = {
@@ -27,7 +27,7 @@ THREE.ColorCorrectionShader = {
@@ -45,6 +45,6 @@ THREE.ColorCorrectionShader = {
@@ -24,7 +24,7 @@ THREE.ColorifyShader = {
@@ -44,6 +44,6 @@ THREE.ColorifyShader = {
@@ -36,7 +36,7 @@ THREE.ConvolutionShader = {
@@ -64,7 +64,7 @@ THREE.ConvolutionShader = {
buildKernel: function ( sigma ) {
@@ -24,7 +24,7 @@ THREE.CopyShader = {
@@ -41,6 +41,6 @@ THREE.CopyShader = {