diff --git a/build/three.js b/build/three.js index b5770035cf533c07c248fa3ccca7860c0355f919..3f9c02aade8dcaa124381127ffc4362422441497 100644 --- a/build/three.js +++ b/build/three.js @@ -1,6 +1,7 @@ /** * @author mrdoob / http://mrdoob.com/ * @author Larry Battle / http://bateru.com/news + * @author bhouston / http://exocortex.com */ var THREE = THREE || { REVISION: '59dev' }; @@ -64,25 +65,25 @@ THREE.extend = function ( obj, source ) { // requestAnimationFrame polyfill by Erik Möller // fixes from Paul Irish and Tino Zijdel - +// using 'self' instead of 'window' for compatibility with both NodeJS and IE10. ( function () { var lastTime = 0; var vendors = [ 'ms', 'moz', 'webkit', 'o' ]; - for ( var x = 0; x < vendors.length && !window.requestAnimationFrame; ++ x ) { + for ( var x = 0; x < vendors.length && !self.requestAnimationFrame; ++ x ) { - window.requestAnimationFrame = window[ vendors[ x ] + 'RequestAnimationFrame' ]; - window.cancelAnimationFrame = window[ vendors[ x ] + 'CancelAnimationFrame' ] || window[ vendors[ x ] + 'CancelRequestAnimationFrame' ]; + self.requestAnimationFrame = self[ vendors[ x ] + 'RequestAnimationFrame' ]; + self.cancelAnimationFrame = self[ vendors[ x ] + 'CancelAnimationFrame' ] || self[ vendors[ x ] + 'CancelRequestAnimationFrame' ]; } - if ( window.requestAnimationFrame === undefined ) { + if ( self.requestAnimationFrame === undefined && self['setTimeout'] !== undefined ) { - window.requestAnimationFrame = function ( callback ) { + self.requestAnimationFrame = function ( callback ) { var currTime = Date.now(), timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) ); - var id = window.setTimeout( function() { callback( currTime + timeToCall ); }, timeToCall ); + var id = self.setTimeout( function() { callback( currTime + timeToCall ); }, timeToCall ); lastTime = currTime + timeToCall; return id; @@ -90,7 +91,11 @@ THREE.extend = function ( obj, source ) { } - window.cancelAnimationFrame = window.cancelAnimationFrame || function ( id ) { window.clearTimeout( id ) }; + if( self.cancelAnimationFrame === undefined && self['clearTimeout'] !== undefined ) { + + self.cancelAnimationFrame = function ( id ) { self.clearTimeout( id ) }; + + } }() ); @@ -5855,8 +5860,8 @@ THREE.Clock.prototype = { start: function () { - this.startTime = window.performance !== undefined && window.performance.now !== undefined - ? window.performance.now() + this.startTime = self.performance !== undefined && self.performance.now !== undefined + ? self.performance.now() : Date.now(); this.oldTime = this.startTime; @@ -5889,8 +5894,8 @@ THREE.Clock.prototype = { if ( this.running ) { - var newTime = window.performance !== undefined && window.performance.now !== undefined - ? window.performance.now() + var newTime = self.performance !== undefined && self.performance.now !== undefined + ? self.performance.now() : Date.now(); diff = 0.001 * ( newTime - this.oldTime ); diff --git a/build/three.min.js b/build/three.min.js index ce2b15174613dedf8fea65c574a56d129ce3cebc..ac245ce4633d2781231a8273f5d85af0ef983818 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -1,12 +1,12 @@ // three.js - http://github.com/mrdoob/three.js 'use strict';var THREE=THREE||{REVISION:"59dev"};self.console=self.console||{info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}};self.Int32Array=self.Int32Array||Array;self.Float32Array=self.Float32Array||Array;String.prototype.trim=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")}; THREE.extend=function(a,b){if(Object.keys)for(var c=Object.keys(b),d=0,e=c.length;d>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(a,b,c){if(0===b)this.r=this.g=this.b=c;else{var d=function(a,b,c){0>c&&(c+=1);1c?b:c<2/3?a+6*(b-a)*(2/3-c):a},b=0.5>=c?c*(1+b):c+b-c*b,c=2*c-b;this.r=d(c,b,a+1/3);this.g=d(c,b,a);this.b=d(c,b,a-1/3)}return this},setStyle:function(a){if(/^rgb\((\d+),(\d+),(\d+)\)$/i.test(a))return a=/^rgb\((\d+),(\d+),(\d+)\)$/i.exec(a),this.r=Math.min(255,parseInt(a[1],10))/255,this.g=Math.min(255,parseInt(a[2],10))/255,this.b=Math.min(255,parseInt(a[3],10))/255,this;if(/^rgb\((\d+)\%,(\d+)\%,(\d+)\%\)$/i.test(a))return a=/^rgb\((\d+)\%,(\d+)\%,(\d+)\%\)$/i.exec(a),this.r=Math.min(100, parseInt(a[1],10))/100,this.g=Math.min(100,parseInt(a[2],10))/100,this.b=Math.min(100,parseInt(a[3],10))/100,this;if(/^\#([0-9a-f]{6})$/i.test(a))return a=/^\#([0-9a-f]{6})$/i.exec(a),this.setHex(parseInt(a[1],16)),this;if(/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.test(a))return a=/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(a),this.setHex(parseInt(a[1]+a[1]+a[2]+a[2]+a[3]+a[3],16)),this;if(/^(\w+)$/i.test(a))return this.setHex(THREE.ColorKeywords[a]),this},copy:function(a){this.r=a.r;this.g=a.g;this.b= @@ -123,8 +123,8 @@ THREE.Triangle.containsPoint=function(){var a=new THREE.Vector3;return function( THREE.Triangle.prototype={constructor:THREE.Triangle,set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},area:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return 0.5*a.cross(b).length()}}(),midpoint:function(a){return(a|| new THREE.Vector3).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return THREE.Triangle.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new THREE.Plane).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return THREE.Triangle.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return THREE.Triangle.containsPoint(a,this.a,this.b,this.c)},equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}, clone:function(){return(new THREE.Triangle).copy(this)}};THREE.Vertex=function(a){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.");return a};THREE.UV=function(a,b){console.warn("THREE.UV has been DEPRECATED. Use THREE.Vector2 instead.");return new THREE.Vector2(a,b)};THREE.Clock=function(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}; -THREE.Clock.prototype={constructor:THREE.Clock,start:function(){this.oldTime=this.startTime=void 0!==window.performance&&void 0!==window.performance.now?window.performance.now():Date.now();this.running=!0},stop:function(){this.getElapsedTime();this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=void 0!==window.performance&&void 0!==window.performance.now?window.performance.now(): -Date.now(),a=0.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a}};THREE.EventDispatcher=function(){}; +THREE.Clock.prototype={constructor:THREE.Clock,start:function(){this.oldTime=this.startTime=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now();this.running=!0},stop:function(){this.getElapsedTime();this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now(), +a=0.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a}};THREE.EventDispatcher=function(){}; THREE.EventDispatcher.prototype={constructor:THREE.EventDispatcher,addEventListener:function(a,b){void 0===this._listeners&&(this._listeners={});var c=this._listeners;void 0===c[a]&&(c[a]=[]);-1===c[a].indexOf(b)&&c[a].push(b)},hasEventListener:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;return void 0!==c[a]&&-1!==c[a].indexOf(b)?!0:!1},removeEventListener:function(a,b){if(void 0!==this._listeners){var c=this._listeners,d=c[a].indexOf(b);-1!==d&&c[a].splice(d,1)}},dispatchEvent:function(a){if(void 0!== this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;for(var c=0,d=b.length;cg.scale.x)return l;l.push({distance:r,point:g.position,face:null,object:g})}else if(g instanceof a.LOD)f.getPositionFromMatrix(g.matrixWorld),r=j.ray.origin.distanceTo(f),i(g.getObjectForDistance(r),j,l);else if(g instanceof a.Mesh){f.getPositionFromMatrix(g.matrixWorld);b.set(f,g.geometry.boundingSphere.radius*g.matrixWorld.getMaxScaleOnAxis());if(!j.ray.isIntersectionSphere(b))return l;var r=g.geometry,t=r.vertices,n=g.material instanceof a.MeshFaceMaterial,s=!0===n?g.material.materials:null,q=g.material.side,v,y,D,F=j.precision;h.getInverse(g.matrixWorld);c.copy(j.ray).applyMatrix4(h);for(var H=