diff --git a/js/cube/cuber.js b/js/cube/cuber.js index ece7526..7479b2a 100644 --- a/js/cube/cuber.js +++ b/js/cube/cuber.js @@ -11523,7 +11523,9 @@ ERNO.Cube = function( parameters ){ var key = String.fromCharCode( event.which ); if( 'XxRrMmLlYyUuEeDdZzFfSsBb'.indexOf( key ) >= 0 ) this.twist( key ); - + if( key == 'q') this.undo(); + if( key == 'Q') this.redo(); + } }.bind( this )); @@ -12075,4 +12077,4 @@ ERNO.Solver.prototype.explain = function( text ){ window._ = _; window.TWEEN = window.TWEEN || TWEEN; window.THREE = window.THREE || THREE; -}()) \ No newline at end of file +}()) diff --git a/js/cube/cuber.min.js b/js/cube/cuber.min.js index 8aa616b..2e5d067 100644 --- a/js/cube/cuber.min.js +++ b/js/cube/cuber.min.js @@ -1,288 +1 @@ -(function(){ -/* - - - CUBER - ----- - - - Cuber is a programmable Rubiks cube of sorts. - - - Made with love by: - @author Mark Lundin - http://mark-lundin.com / @mark_lundin - @author Stewart Smith - stewd.io - @author Google Creative Lab - - - - NOTATION - - UPPERCASE = Clockwise to next 90 degree peg - lowercase = Anticlockwise to next 90 degree peg - - - - FACE & SLICE ROTATION COMMANDS - - F Front - S Standing (rotate according to Front Face's orientation) - B Back - - L Left - M Middle (rotate according to Left Face's orientation) - R Right - - U Up - E Equator (rotate according to Up Face's orientation) - D Down - - - - ENTIRE CUBE ROTATION COMMANDS - - X Rotate entire cube according to Right Face's orientation - Y Rotate entire cube according to Up Face's orientation - Z Rotate entire cube according to Front Face's orientation - - - - NOTATION REFERENCES - - http://en.wikipedia.org/wiki/Rubik's_Cube#Move_notation - http://en.wikibooks.org/wiki/Template:Rubik's_cube_notation - - -*/ -var ERNO={};(function(){function a(a,c){c=c||{bubbles:!1,cancelable:!1,detail:void 0};var d=document.createEvent("CustomEvent");d.initCustomEvent(a,c.bubbles,c.cancelable,c.detail);return d}a.prototype=window.Event.prototype;window.CustomEvent=a})();ERNO.extend=function(a,b){if(Object.keys)for(var c=Object.keys(b),d=0,e=c.length;d(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*a:0.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return 1>(a*=2)?0.5*a*a*a*a:-0.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a* -a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*a*a*a:0.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return 0.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:1>(a*=2)?0.5*Math.pow(1024,a-1):0.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1- -Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return 1>(a*=2)?-0.5*(Math.sqrt(1-a*a)-1):0.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=0.1;if(0===a)return 0;if(1===a)return 1;!c||1>c?(c=1,b=0.1):b=0.4*Math.asin(1/c)/(2*Math.PI);return-(c*Math.pow(2,10*(a-=1))*Math.sin(2*(a-b)*Math.PI/0.4))},Out:function(a){var b,c=0.1;if(0===a)return 0;if(1===a)return 1;!c||1>c?(c=1,b=0.1):b=0.4*Math.asin(1/c)/(2*Math.PI);return c*Math.pow(2,-10*a)*Math.sin(2*(a- -b)*Math.PI/0.4)+1},InOut:function(a){var b,c=0.1;if(0===a)return 0;if(1===a)return 1;!c||1>c?(c=1,b=0.1):b=0.4*Math.asin(1/c)/(2*Math.PI);return 1>(a*=2)?-0.5*c*Math.pow(2,10*(a-=1))*Math.sin(2*(a-b)*Math.PI/0.4):c*Math.pow(2,-10*(a-=1))*Math.sin(2*(a-b)*Math.PI/0.4)*0.5+1}},Back:{In:function(a){return a*a*(2.70158*a-1.70158)},Out:function(a){return--a*a*(2.70158*a+1.70158)+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*(3.5949095*a-2.5949095):0.5*((a-=2)*a*(3.5949095*a+2.5949095)+2)}},Bounce:{In:function(a){return 1- -TWEEN.Easing.Bounce.Out(1-a)},Out:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+0.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+0.9375:7.5625*(a-=2.625/2.75)*a+0.984375},InOut:function(a){return 0.5>a?0.5*TWEEN.Easing.Bounce.In(2*a):0.5*TWEEN.Easing.Bounce.Out(2*a-1)+0.5}}}; -TWEEN.Interpolation={Linear:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d),f=TWEEN.Interpolation.Utils.Linear;return 0>b?f(a[0],a[1],d):1c?c:e+1],d-e)},Bezier:function(a,b){var c=0,d=a.length-1,e=Math.pow,f=TWEEN.Interpolation.Utils.Bernstein,g;for(g=0;g<=d;g++)c+=e(1-b,d-g)*e(b,g)*a[g]*f(d,g);return c},CatmullRom:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d),f=TWEEN.Interpolation.Utils.CatmullRom;return a[0]===a[c]?(0>b&&(e=Math.floor(d=c*(1+b))),f(a[(e- -1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):0>b?a[0]-(f(a[0],a[0],a[1],a[1],-d)-a[0]):1e;e++)8==e||13==e||18==e||23==e?b[e]="-":14==e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19==e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())},sign:function(a){return 0>a?-1:0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x= -0.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=0.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=0.25*c);this._updateEuler();return this},inverse:function(){this.conjugate().normalize();return this},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this._updateEuler();return this},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x* -this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);return this},multiply:function(a,b){return void 0!==b?(console.warn("DEPRECATED: Quaternion's .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f= -a._w,g=b._x,h=b._y,k=b._z,l=b._w;this._x=c*l+f*g+d*k-e*h;this._y=d*l+f*h+e*g-c*k;this._z=e*l+f*k+c*h-d*g;this._w=f*l-c*g-d*h-e*k;this._updateEuler();return this},multiplyVector3:function(a){console.warn("DEPRECATED: Quaternion's .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return a.applyQuaternion(this)},slerp:function(a,b){var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z= --a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=Math.acos(g),k=Math.sqrt(1-g*g);if(0.001>Math.abs(k))return this._w=0.5*(f+this._w),this._x=0.5*(c+this._x),this._y=0.5*(d+this._y),this._z=0.5*(e+this._z),this;g=Math.sin((1-b)*h)/k;h=Math.sin(b*h)/k;this._w=f*g+this._w*h;this._x=c*g+this._x*h;this._y=d*g+this._y*h;this._z=e*g+this._z*h;this._updateEuler();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w}, -fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];this._w=a[3];this._updateEuler();return this},toArray:function(){return[this._x,this._y,this._z,this._w]},clone:function(){return new THREE.Quaternion(this._x,this._y,this._z,this._w)}};THREE.Quaternion.slerp=function(a,b,c,d){return c.copy(a).slerp(b,d)};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; -THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a, -b){if(void 0!==b)return console.warn("DEPRECATED: Vector2's .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},sub:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector2's .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-= -a.y;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divideScalar:function(a){0!==a?(a=1/a,this.x*=a,this.y*=a):this.y=this.x=0;return this},min:function(a){this.x>a.x&&(this.x=a.x);this.y>a.y&&(this.y=a.y);return this},max:function(a){this.xb.x&&(this.x=b.x);this.yb.y&&(this.y=b.y); -return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector2,b=new THREE.Vector2);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y? -Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},setLength:function(a){var b= -this.length();0!==b&&a!==b&&this.multiplyScalar(a/b);return this},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a){this.x=a[0];this.y=a[1];return this},toArray:function(){return[this.x,this.y]},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}; -THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+ -a);}},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector3's .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},sub:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector3's .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), -this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector3's .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},multiplyVectors:function(a,b){this.x=a.x* -b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a;return function(b){!1===b instanceof THREE.Euler&&console.error("ERROR: Vector3's .applyEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.");void 0===a&&(a=new THREE.Quaternion);this.applyQuaternion(a.setFromEuler(b));return this}}(),applyAxisAngle:function(){var a;return function(b,c){void 0===a&&(a=new THREE.Quaternion);this.applyQuaternion(a.setFromAxisAngle(b,c));return this}}(), -applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this},applyProjection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y= -(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,l=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-l*-f;this.y=k*a+b*-f+l*-e-h*-g;this.z=l*a+b*-g+h*-f-k*-e;return this},transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;this.normalize();return this}, -divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){0!==a?(a=1/a,this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;return this},min:function(a){this.x>a.x&&(this.x=a.x);this.y>a.y&&(this.y=a.y);this.z>a.z&&(this.z=a.z);return this},max:function(a){this.xb.x&&(this.x=b.x);this.yb.y&&(this.y=b.y);this.z< -a.z?this.z=a.z:this.z>b.z&&(this.z=b.z);return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3,b=new THREE.Vector3);a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z); -return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+ -Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){var b=this.length();0!==b&&a!==b&&this.multiplyScalar(a/b);return this},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},cross:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector3's .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b);var c=this.x,d=this.y,e=this.z;this.x= -d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;this.y=e*f-c*h;this.z=c*g-d*f;return this},projectOnVector:function(){var a,b;return function(c){void 0===a&&(a=new THREE.Vector3);a.copy(c).normalize();b=this.dot(a);return this.copy(a).multiplyScalar(b)}}(),projectOnPlane:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a; -return function(b){void 0===a&&(a=new THREE.Vector3);return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/(this.length()*a.length());return Math.acos(THREE.Math.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},setEulerFromRotationMatrix:function(a,b){console.error("REMOVED: Vector3's setEulerFromRotationMatrix has been removed in favor of Euler.setFromRotationMatrix(), please update your code.")}, -setEulerFromQuaternion:function(a,b){console.error("REMOVED: Vector3's setEulerFromQuaternion: has been removed in favor of Euler.setFromQuaternion(), please update your code.")},getPositionFromMatrix:function(a){console.warn("DEPRECATED: Vector3's .getPositionFromMatrix() has been renamed to .setFromMatrixPosition(). Please update your code.");return this.setFromMatrixPosition(a)},getScaleFromMatrix:function(a){console.warn("DEPRECATED: Vector3's .getScaleFromMatrix() has been renamed to .setFromMatrixScale(). Please update your code."); -return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("DEPRECATED: Vector3's .getColumnFromMatrix() has been renamed to .setFromMatrixColumn(). Please update your code.");return this.setFromMatrixColumn(a,b)},setFromMatrixPosition:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setFromMatrixScale:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(); -a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){var c=4*a,d=b.elements;this.x=d[c];this.y=d[c+1];this.z=d[c+2];return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a){this.x=a[0];this.y=a[1];this.z=a[2];return this},toArray:function(){return[this.x,this.y,this.z]},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Box3=function(a,b){this.min=void 0!==a?a:new THREE.Vector3(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new THREE.Vector3(-Infinity,-Infinity,-Infinity)}; -THREE.Box3.prototype={constructor:THREE.Box3,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},addPoint:function(a){a.xthis.max.x&&(this.max.x=a.x);a.ythis.max.y&&(this.max.y=a.y);a.zthis.max.z&&(this.max.z=a.z)},setFromPoints:function(a){if(0this.max.x||a.ythis.max.y||a.zthis.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z?!0:!1},getParameter:function(a,b){return(b||new THREE.Vector3).set((a.x-this.min.x)/(this.max.x- -this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},isIntersectionBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y||a.max.zthis.max.z?!1:!0},clampPoint:function(a,b){return(b||new THREE.Vector3).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new THREE.Vector3;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a= -new THREE.Vector3;return function(b){b=b||new THREE.Sphere;b.center=this.center();b.radius=0.5*this.size(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];return function(b){a[0].set(this.min.x,this.min.y, -this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.makeEmpty();this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a); -this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)},clone:function(){return(new THREE.Box3).copy(this)}};THREE.Sphere=function(a,b){this.center=void 0!==a?a:new THREE.Vector3;this.radius=void 0!==b?b:0}; -THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new THREE.Box3;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).center(d);for(var e=0,f=0,g=b.length;f=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<= -this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},clampPoint:function(a,b){var c=this.center.distanceToSquared(a),d=b||new THREE.Vector3;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a=a||new THREE.Box3;a.set(this.center,this.center);a.expandByScalar(this.radius); -return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius},clone:function(){return(new THREE.Sphere).copy(this)}};THREE.Euler=function(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||THREE.Euler.DefaultOrder};THREE.Euler.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");THREE.Euler.DefaultOrder="XYZ"; -THREE.Euler.prototype={constructor:THREE.Euler,_x:0,_y:0,_z:0,_order:THREE.Euler.DefaultOrder,_quaternion:void 0,_updateQuaternion:function(){void 0!==this._quaternion&&this._quaternion.setFromEuler(this,!1)},get x(){return this._x},set x(a){this._x=a;this._updateQuaternion()},get y(){return this._y},set y(a){this._y=a;this._updateQuaternion()},get z(){return this._z},set z(a){this._z=a;this._updateQuaternion()},get order(){return this._order},set order(a){this._order=a;this._updateQuaternion()}, -set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this._updateQuaternion();return this},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this._updateQuaternion();return this},setFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],k=d[5],l=d[9],n=d[2],m=d[6],d=d[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(c(g)),0.99999>Math.abs(g)?(this._x=Math.atan2(-l,d),this._z= -Math.atan2(-f,e)):(this._x=Math.atan2(m,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-c(l)),0.99999>Math.abs(l)?(this._y=Math.atan2(g,d),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-n,e),this._z=0)):"ZXY"===b?(this._x=Math.asin(c(m)),0.99999>Math.abs(m)?(this._y=Math.atan2(-n,d),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,e))):"ZYX"===b?(this._y=Math.asin(-c(n)),0.99999>Math.abs(n)?(this._x=Math.atan2(m,d),this._z=Math.atan2(h,e)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z= -Math.asin(c(h)),0.99999>Math.abs(h)?(this._x=Math.atan2(-l,k),this._y=Math.atan2(-n,e)):(this._x=0,this._y=Math.atan2(g,d))):"XZY"===b?(this._z=Math.asin(-c(f)),0.99999>Math.abs(f)?(this._x=Math.atan2(m,k),this._y=Math.atan2(g,e)):(this._x=Math.atan2(-l,d),this._y=0)):console.warn("WARNING: Euler.setFromRotationMatrix() given unsupported order: "+b);this._order=b;this._updateQuaternion();return this},setFromQuaternion:function(a,b,c){function d(a){return Math.min(Math.max(a,-1),1)}var e=a.x*a.x,f= -a.y*a.y,g=a.z*a.z,h=a.w*a.w;b=b||this._order;"XYZ"===b?(this._x=Math.atan2(2*(a.x*a.w-a.y*a.z),h-e-f+g),this._y=Math.asin(d(2*(a.x*a.z+a.y*a.w))),this._z=Math.atan2(2*(a.z*a.w-a.x*a.y),h+e-f-g)):"YXZ"===b?(this._x=Math.asin(d(2*(a.x*a.w-a.y*a.z))),this._y=Math.atan2(2*(a.x*a.z+a.y*a.w),h-e-f+g),this._z=Math.atan2(2*(a.x*a.y+a.z*a.w),h-e+f-g)):"ZXY"===b?(this._x=Math.asin(d(2*(a.x*a.w+a.y*a.z))),this._y=Math.atan2(2*(a.y*a.w-a.z*a.x),h-e-f+g),this._z=Math.atan2(2*(a.z*a.w-a.x*a.y),h-e+f-g)):"ZYX"=== -b?(this._x=Math.atan2(2*(a.x*a.w+a.z*a.y),h-e-f+g),this._y=Math.asin(d(2*(a.y*a.w-a.x*a.z))),this._z=Math.atan2(2*(a.x*a.y+a.z*a.w),h+e-f-g)):"YZX"===b?(this._x=Math.atan2(2*(a.x*a.w-a.z*a.y),h-e+f-g),this._y=Math.atan2(2*(a.y*a.w-a.x*a.z),h+e-f-g),this._z=Math.asin(d(2*(a.x*a.y+a.z*a.w)))):"XZY"===b?(this._x=Math.atan2(2*(a.x*a.w+a.y*a.z),h-e+f-g),this._y=Math.atan2(2*(a.x*a.z+a.y*a.w),h+e-f-g),this._z=Math.asin(d(2*(a.z*a.w-a.x*a.y)))):console.warn("WARNING: Euler.setFromQuaternion() given unsupported order: "+ -b);this._order=b;!1!==c&&this._updateQuaternion();return this},reorder:function(){var a=new THREE.Quaternion;return function(b){a.setFromEuler(this);this.setFromQuaternion(a,b)}}(),fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this._updateQuaternion();return this},toArray:function(){return[this._x,this._y,this._z,this._order]},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},clone:function(){return new THREE.Euler(this._x, -this._y,this._z,this._order)}};THREE.Matrix3=function(a,b,c,d,e,f,g,h,k){this.elements=new Float32Array(9);this.set(void 0!==a?a:1,b||0,c||0,d||0,void 0!==e?e:1,f||0,g||0,h||0,void 0!==k?k:1)}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,set:function(a,b,c,d,e,f,g,h,k){var l=this.elements;l[0]=a;l[3]=b;l[6]=c;l[1]=d;l[4]=e;l[7]=f;l[2]=g;l[5]=h;l[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]);return this},multiplyVector3:function(a){console.warn("DEPRECATED: Matrix3's .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)}, -multiplyVector3Array:function(){var a=new THREE.Vector3;return function(b){for(var c=0,d=b.length;cthis.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.elements.set(this.elements);c=1/g;var f=1/h,l=1/k;b.elements[0]*=c;b.elements[1]*= -c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=l;b.elements[9]*=l;b.elements[10]*=l;d.setFromRotationMatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makeFrustum:function(a,b,c,d,e,f){var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a,b,c,d){a=c*Math.tan(THREE.Math.degToRad(0.5*a)); -var e=-a;return this.makeFrustum(e*b,a*b,e,a,c,d)},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=b-a,k=c-d,l=f-e;g[0]=2/h;g[4]=0;g[8]=0;g[12]=-((b+a)/h);g[1]=0;g[5]=2/k;g[9]=0;g[13]=-((c+d)/k);g[2]=0;g[6]=0;g[10]=-2/l;g[14]=-((f+e)/l);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},fromArray:function(a){this.elements.set(a);return this},toArray:function(){var a=this.elements;return[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]]},clone:function(){var a= -this.elements;return new THREE.Matrix4(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15])}};THREE.Object3D=function(){this.id=THREE.Object3DIdCount++;this.uuid=THREE.Math.generateUUID();this.name="";this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this._rotation=new THREE.Euler;this._quaternion=new THREE.Quaternion;this.scale=new THREE.Vector3(1,1,1);this._rotation._quaternion=this.quaternion;this._quaternion._euler=this.rotation;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4; -this.visible=this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.userData={}}; -THREE.Object3D.prototype={constructor:THREE.Object3D,get rotation(){return this._rotation},set rotation(a){this._rotation=a;this._rotation._quaternion=this._quaternion;this._quaternion._euler=this._rotation;this._rotation._updateQuaternion()},get quaternion(){return this._quaternion},set quaternion(a){this._quaternion=a;this._quaternion._euler=this._rotation;this._rotation._quaternion=this._quaternion;this._quaternion._updateEuler()},get eulerOrder(){console.warn("DEPRECATED: Object3D's .eulerOrder has been moved to Object3D's .rotation.order."); -return this.rotation.order},set eulerOrder(a){console.warn("DEPRECATED: Object3D's .eulerOrder has been moved to Object3D's .rotation.order.");this.rotation.order=a},get useQuaternion(){console.warn("DEPRECATED: Object3D's .useQuaternion has been removed. The library now uses quaternions by default.")},set useQuaternion(a){console.warn("DEPRECATED: Object3D's .useQuaternion has been removed. The library now uses quaternions by default.")},applyMatrix:function(a){this.matrix.multiplyMatrices(a,this.matrix); -this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(a,b){this.quaternion.setFromAxisAngle(a,b)},setRotationFromEuler:function(a){this.quaternion.setFromEuler(a,!0)},setRotationFromMatrix:function(a){this.quaternion.setFromRotationMatrix(a)},setRotationFromQuaternion:function(a){this.quaternion.copy(a)},rotateOnAxis:function(){var a=new THREE.Quaternion;return function(b,c){a.setFromAxisAngle(b,c);this.quaternion.multiply(a);return this}}(),rotateX:function(){var a= -new THREE.Vector3(1,0,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateY:function(){var a=new THREE.Vector3(0,1,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateZ:function(){var a=new THREE.Vector3(0,0,1);return function(b){return this.rotateOnAxis(a,b)}}(),translateOnAxis:function(){var a=new THREE.Vector3;return function(b,c){a.copy(b);a.applyQuaternion(this.quaternion);this.position.add(a.multiplyScalar(c));return this}}(),translate:function(a,b){console.warn("DEPRECATED: Object3D's .translate() has been removed. Use .translateOnAxis( axis, distance ) instead. Note args have been changed."); -return this.translateOnAxis(b,a)},translateX:function(){var a=new THREE.Vector3(1,0,0);return function(b){return this.translateOnAxis(a,b)}}(),translateY:function(){var a=new THREE.Vector3(0,1,0);return function(b){return this.translateOnAxis(a,b)}}(),translateZ:function(){var a=new THREE.Vector3(0,0,1);return function(b){return this.translateOnAxis(a,b)}}(),localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var a=new THREE.Matrix4;return function(b){return b.applyMatrix4(a.getInverse(this.matrixWorld))}}(), -lookAt:function(){var a=new THREE.Matrix4;return function(b){a.lookAt(b,this.position,this.up);this.quaternion.setFromRotationMatrix(a)}}(),add:function(a){if(a===this)console.warn("THREE.Object3D.add: An object can't be added as a child of itself.");else if(a instanceof THREE.Object3D){void 0!==a.parent&&a.parent.remove(a);a.parent=this;a.dispatchEvent({type:"added"});this.children.push(a);for(var b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.__addObject(a)}},remove:function(a){var b= -this.children.indexOf(a);if(-1!==b){a.parent=void 0;a.dispatchEvent({type:"removed"});this.children.splice(b,1);for(b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.__removeObject(a)}},traverse:function(a){a(this);for(var b=0,c=this.children.length;bd?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},distanceToPoint:function(){var a=new THREE.Vector3;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceTo(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceTo(b)}}(),distanceSqToSegment:function(a,b,c,d){var e=a.clone().add(b).multiplyScalar(0.5),f=b.clone().sub(a).normalize(),g=0.5*a.distanceTo(b), -h=this.origin.clone().sub(e);a=-this.direction.dot(f);b=h.dot(this.direction);var k=-h.dot(f),l=h.lengthSq(),n=Math.abs(1-a*a),m,r;0<=n?(h=a*k-b,m=a*b-k,r=g*n,0<=h?m>=-r?m<=r?(g=1/n,h*=g,m*=g,a=h*(h+a*m+2*b)+m*(a*h+m+2*k)+l):(m=g,h=Math.max(0,-(a*m+b)),a=-h*h+m*(m+2*k)+l):(m=-g,h=Math.max(0,-(a*m+b)),a=-h*h+m*(m+2*k)+l):m<=-r?(h=Math.max(0,-(-a*g+b)),m=0a.normal.dot(this.direction)*b?!0:!1},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0==b)return 0==a.distanceToPoint(this.origin)? -0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){var c=this.distanceToPlane(a);return null===c?null:this.at(c,b)},isIntersectionBox:function(){var a=new THREE.Vector3;return function(b){return null!==this.intersectBox(b,a)}}(),intersectBox:function(a,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z;var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*= -a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e;if(fg||e>d)return null;if(e>c||c!==c)c=e;if(gd?null:this.at(0<=c?c:d,b)},intersectTriangle:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3,d=new THREE.Vector3;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0< -f){if(h)return null;h=1}else if(0>f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a);this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}, -clone:function(){return(new THREE.Ray).copy(this)}};THREE.Plane=function(a,b){this.normal=void 0!==a?a:new THREE.Vector3(1,0,0);this.constant=void 0!==b?b:0}; -THREE.Plane.prototype={constructor:THREE.Plane,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d, -c);return this}}(),copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a, -b){var c=this.distanceToPoint(a);return(b||new THREE.Vector3).copy(this.normal).multiplyScalar(c)},isIntersectionLine:function(a){var b=this.distanceToPoint(a.start);a=this.distanceToPoint(a.end);return 0>b&&0a&&0f||1Math.abs(a)?0:a},k=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Euler,d=new THREE.Quaternion;c._quaternion=d;d._euler=c;return function(e){e.decompose(a,d,b);return"translate3d(-50%,-50%,0) translate3d("+h(a.x)+"px, "+h(a.y)+"px, "+h(a.z)+"px) rotateX("+h(c.x)+"rad) rotateY("+h(c.y)+ -"rad) rotateZ("+h(c.z)+"rad) scale3d("+h(b.x)+", "+h(-b.y)+", "+h(b.z)+")"}}(),l=function(a,b){if(a instanceof THREE.CSS3DObject){var c;a instanceof THREE.CSS3DSprite?(e.copy(b.matrixWorldInverse),e.transpose(),e.copyPosition(a.matrixWorld),e.scale(a.scale),e.elements[3]=0,e.elements[7]=0,e.elements[11]=0,e.elements[15]=1,c=k(e)):c=k(a.matrixWorld);var d=a.element;d.style.WebkitTransformStyle="preserve-3d";d.style.MozTransformStyle="preserve-3d";d.style.oTransformStyle="preserve-3d";d.style.transformStyle= -"preserve-3d";d.style.WebkitTransform=c;d.style.MozTransform=c;d.style.oTransform=c;d.style.transform=c;d.parentNode!==g&&g.appendChild(d)}c=0;for(d=a.children.length;cb&&(c=c.substr(-1*b));if(0a&&(c=c.substr(0,c.length+ -a));return c},justifyLeft:function(a){for(var b=this;b.lengthb.length;)b="0"+b;c+="\\u"+b}return c}});ERNO.extend(Array.prototype,{distanceTo:function(a){var b,c=0;0"+this[a]+"");return b+""},toText:function(a){var b,c,d;a=_.cascade(a,0);c="\n"+"\t".multiply(a);d="";for(b= -0;bd&&this.neighbors[d]!==b;d++);return this.neighbors[d.add(c*a).modulo(4)]};ERNO.Direction.prototype.getClockwise=function(a,b){return this.getRotation(1,a,b)};ERNO.Direction.prototype.getAnticlockwise=function(a,b){return this.getRotation(-1,a,b)}; -ERNO.Direction.prototype.getDirection=function(a,b){return this.getRotation(1,b,a.id-1)};ERNO.Direction.prototype.getUp=function(a){return this.getDirection(ERNO.Direction.UP,a)};ERNO.Direction.prototype.getRight=function(a){return this.getDirection(ERNO.Direction.RIGHT,a)};ERNO.Direction.prototype.getDown=function(a){return this.getDirection(ERNO.Direction.DOWN,a)};ERNO.Direction.prototype.getLeft=function(a){return this.getDirection(ERNO.Direction.LEFT,a)};ERNO.Direction.prototype.getOpposite=function(){return this.opposite}; -ERNO.Direction.FRONT=new ERNO.Direction(0,"front",new THREE.Vector3(0,0,1));ERNO.Direction.UP=new ERNO.Direction(1,"up",new THREE.Vector3(0,1,0));ERNO.Direction.RIGHT=new ERNO.Direction(2,"right",new THREE.Vector3(1,0,0));ERNO.Direction.DOWN=new ERNO.Direction(3,"down",new THREE.Vector3(0,-1,0));ERNO.Direction.LEFT=new ERNO.Direction(4,"left",new THREE.Vector3(-1,0,0));ERNO.Direction.BACK=new ERNO.Direction(5,"back",new THREE.Vector3(0,0,-1)); -ERNO.Direction.FRONT.setRelationships(ERNO.Direction.UP,ERNO.Direction.RIGHT,ERNO.Direction.DOWN,ERNO.Direction.LEFT,ERNO.Direction.BACK);ERNO.Direction.UP.setRelationships(ERNO.Direction.BACK,ERNO.Direction.RIGHT,ERNO.Direction.FRONT,ERNO.Direction.LEFT,ERNO.Direction.DOWN);ERNO.Direction.RIGHT.setRelationships(ERNO.Direction.UP,ERNO.Direction.BACK,ERNO.Direction.DOWN,ERNO.Direction.FRONT,ERNO.Direction.LEFT); -ERNO.Direction.DOWN.setRelationships(ERNO.Direction.FRONT,ERNO.Direction.RIGHT,ERNO.Direction.BACK,ERNO.Direction.LEFT,ERNO.Direction.UP);ERNO.Direction.LEFT.setRelationships(ERNO.Direction.UP,ERNO.Direction.FRONT,ERNO.Direction.DOWN,ERNO.Direction.BACK,ERNO.Direction.RIGHT);ERNO.Direction.BACK.setRelationships(ERNO.Direction.UP,ERNO.Direction.LEFT,ERNO.Direction.DOWN,ERNO.Direction.RIGHT,ERNO.Direction.FRONT);ERNO.Queue=function(a){void 0!==a&&a instanceof Function&&(this.validate=a);this.history=[];this.useHistory=!0;this.future=[];this.isReady=!0;this.isLooping=!1};ERNO.Queue.prototype.add=function(){var a=Array.prototype.slice.call(arguments);void 0!==this.validate&&this.validate instanceof Function&&(a=this.validate(a));a instanceof Array&&a.forEach(function(a){this.future.push(a)}.bind(this));return this.future}; -ERNO.Queue.prototype.remove=function(){var a=Array.prototype.slice.call(arguments);a instanceof Array&&a.forEach(function(a){this.future=this.future.filter(function(c){return c!=a})}.bind(this));return this.future};ERNO.Queue.prototype.purge=function(){var a=Array.prototype.slice.call(arguments);a instanceof Array&&a.forEach(function(a){this.history=this.history.filter(function(c){return c!=a})}.bind(this));return this.history}; -ERNO.Queue.prototype.empty=function(a){this.future=[];a&&(this.history=[])};ERNO.Queue.prototype.do=function(){if(this.future.length){var a=this.future.shift();this.useHistory&&this.history.push(a);return a}this.isLooping&&(this.future=this.history.slice(),this.history=[])};ERNO.Queue.prototype.undo=function(){if(this.history.length){var a=this.history.pop();this.future.unshift(a);return a}};ERNO.Queue.prototype.redo=function(){return this.do()};ERNO.Twist=function(a,b){a&&this.set(a,b)}; -ERNO.Twist.prototype.set=function(a,b){var c={X:"Cube on X",L:"Left face",M:"Middle slice",R:"Right face",Y:"Cube on Y",U:"Up face",E:"Equator slice",D:"Down face",Z:"Cube on Z",F:"Front face",S:"Standing slice",B:"Back face"}[a.toUpperCase()];if(void 0!==c){void 0!=b&&0>b&&(a=a.invert(),b=b.absolute());var d=0,e="unwise";a===a.toUpperCase()?(d=1,e="clockwise"):a===a.toLowerCase()&&(d=-1,e="anticlockwise");this.command=a;this.group=c;this.degrees=b;this.vector=d;this.wise=e;this.isShuffle=!1;this.getInverse= -function(){return new ERNO.Twist(a.invert(),b)}}else return!1};ERNO.Twist.prototype.equals=function(a){return this.command===a.command&&this.degrees===a.degrees};ERNO.Twist.prototype.copy=function(a){this.command=a.command;this.group=a.group;this.degrees=a.degrees;this.vector=a.vector;this.wise=a.wise;this.isShuffle=a.isShuffle;return this}; -ERNO.Twist.validate=function(){var a=Array.prototype.slice.call(arguments),b,c,d,e,f,g;for(c=0;cb;b++)d=c[b]||ERNO.COLORLESS,this.faces[b]={},this.faces[b].id=b,this.faces[b].color= -d,this.faces[b].normal=ERNO.Direction.getNameById(b),this.faces[b].isIntrovert=d===ERNO.COLORLESS,d!==ERNO.COLORLESS&&a++;this.type=["core","center","edge","corner"][a];this.front=this.faces[0];this.up=this.faces[1];this.right=this.faces[2];this.down=this.faces[3];this.left=this.faces[4];this.back=this.faces[5];this.colors=(this.faces[0].color?this.faces[0].color.initial:"-")+(this.faces[1].color?this.faces[1].color.initial:"-")+(this.faces[2].color?this.faces[2].color.initial:"-")+(this.faces[3].color? -this.faces[3].color.initial:"-")+(this.faces[4].color?this.faces[4].color.initial:"-")+(this.faces[5].color?this.faces[5].color.initial:"-");this.isStickerCubelet=this.front.color&&"white"===this.front.color.name&&"center"===this.type;this.isTweening=!0;this.isTweening=this.isEngagedZ=this.isEngagedY=this.isEngagedX=!1;this.opacity=1;this.radius=0};ERNO.Cubelet.prototype=Object.create(THREE.Object3D.prototype); -ERNO.extend(ERNO.Cubelet.prototype,{setAddress:function(a){this.address=a||0;this.addressX=a.modulo(3).subtract(1);this.addressY=-1*a.modulo(9).divide(3).roundDown().subtract(1);this.addressZ=-1*a.divide(9).roundDown().subtract(1)},hasColor:function(a){var b,c,d=_.hexToRgb(a.hex);for(a=0;6>a;a++)if(c=_.hexToRgb(this.faces[a].color.hex),c.r===d.r&&c.g===d.g&&c.b===d.b){b=a;break}return void 0!==b?"front up right down left back".split(" ")[b]:!1},hasColors:function(){var a=this,b=!0;Array.prototype.slice.call(arguments).forEach(function(c){b= -b&&!!a.hasColor(c)});return b},getRadius:function(){return this.radius},setRadius:function(a,b){if(!1===this.isTweening&&(a=a||0,void 0===this.radius&&(this.radius=0),this.radius!==a)){this.isTweening=!0;var c=(this.radius-a).absolute(),d={radius:this.radius};(new TWEEN.Tween(d)).to({radius:a},c).easing(TWEEN.Easing.Quartic.Out).onUpdate(function(){this.position.set(this.addressX.multiply(this.size+d.radius)+0.2,this.addressY.multiply(this.size+d.radius)+0.2,this.addressZ.multiply(this.size+d.radius)+ -0.2);this.updateMatrix();this.matrixSlice.copy(this.matrix);this.radius=d.radius}.bind(this)).onComplete(function(){this.isTweening=!1;this.position.set(this.addressX.multiply(this.size+d.radius)+0.2,this.addressY.multiply(this.size+d.radius)+0.2,this.addressZ.multiply(this.size+d.radius)+0.2);this.updateMatrix();this.matrixSlice.copy(this.matrix);this.radius=d.radius;b instanceof Function&&b()}.bind(this)).start(this.cube.time)}}});ERNO.Group=function(){this.cubelets=[];this.add(Array.prototype.slice.call(arguments))};ERNO.extend(ERNO.Group.prototype,THREE.EventDispatcher.prototype); -ERNO.extend(ERNO.Group.prototype,{add:function(){var a=this;Array.prototype.slice.call(arguments).forEach(function(b){b instanceof ERNO.Group&&(b=b.cubelets);b instanceof Array?a.add.apply(a,b):a.cubelets.push(b)});return this},remove:function(a){a instanceof ERNO.Group&&(a=a.cubelets);if(a instanceof Array){var b=this;a.forEach(function(a){b.remove(a)})}for(var c=this.cubelets.length;0c;c++)if(this.origin.faces[c].color&&this.origin.faces[c].color!==ERNO.COLORLESS){this.color=this.origin.faces[c].color;this.face=ERNO.Direction.getNameById(c);break}if(void 0===this.axis||0===this.axis.lengthSq()){var c=this.northEast.position.clone(),d=this.southWest.position.clone(),e=this.northWest.position.clone();this.axis=(new THREE.Vector3).crossVectors(d.sub(c),e.sub(c)).normalize();this.axis.rotation=0}this.up=new ERNO.Group(this.northWest,this.north,this.northEast);this.equator= -new ERNO.Group(this.west,this.origin,this.east);this.down=new ERNO.Group(this.southWest,this.south,this.southEast);this.left=new ERNO.Group(this.northWest,this.west,this.southWest);this.middle=new ERNO.Group(this.north,this.origin,this.south);this.right=new ERNO.Group(this.northEast,this.east,this.southEast);(c=this.hasType("center"))&&1===c.cubelets.length?(this.center=this.hasType("center"),this.corners=new ERNO.Group(this.hasType("corner")),this.cross=new ERNO.Group(this.center,this.hasType("edge")), -this.ex=new ERNO.Group(this.center,this.hasType("corner"))):this.centers=new ERNO.Group(this.hasType("center"));this.edges=new ERNO.Group(this.hasType("edge"));this.ring=new ERNO.Group(this.northWest,this.north,this.northEast,this.west,this.east,this.southWest,this.south,this.southEast);this.dexter=new ERNO.Group(this.northWest,this.origin,this.southEast);this.sinister=new ERNO.Group(this.northEast,this.origin,this.southWest);return this},set rotation(a){if(this.ableToHideInternalFaces&&0!==this.cube.isFlagged("showingIntroverts")&& -this.cube.hideInvisibleFaces){var b=0!==a%(0.5*Math.PI);this.invertedAxis.copy(this.axis).negate();b?this.neighbour?(this.showIntroverts(this.axis,!0),this.neighbour.showIntroverts(this.invertedAxis,!0)):(this.cube.showIntroverts(this.axis,!0),this.cube.showIntroverts(this.invertedAxis,!0)):this.neighbour?(this.hideIntroverts(null,!0),this.neighbour.hideIntroverts(null,!0)):this.cube.hideIntroverts(null,!0)}this.matrix.makeRotationAxis(this.axis,a);this.axis.rotation=a;a=this.indices.length;for(var c= -new THREE.Matrix4;a--;)b=this.getCubelet(a),b.matrix.multiplyMatrices(this.matrix,b.matrixSlice),b.position.setFromMatrixPosition(b.matrix),b.scale.setFromMatrixScale(b.matrix),c.extractRotation(b.matrix),b.quaternion.setFromRotationMatrix(c)},get rotation(){return this.axis.rotation},getLocation:function(a){return a===this.origin?"origin":a===this.north?"north":a===this.northEast?"northEast":a===this.east?"east":a===this.southEast?"southEast":a===this.south?"south":a===this.southWest?"southWest": -a===this.west?"west":a===this.northWest?"northWest":!1},isSolved:function(a){if(a){var b={},c,d=this.indices.length,e=0;a instanceof ERNO.Direction&&(a=a.name);for(;0b;b++)this.map[b].innerHTML=a.substr(b,1)};ERNO.Projector=function(){return function(a,b){function c(a,b){q.getInverse(b.projectionMatrix);f.multiplyMatrices(b.matrixWorld,q);return a.applyProjection(f)}function d(d,f,l){var m=b,q=m!==document?m.getBoundingClientRect():{left:0,top:0,width:window.innerWidth,height:window.innerHeight};m!==document&&(m=m.ownerDocument.documentElement,q.left+=window.pageXOffset-m.clientLeft,q.top+=window.pageYOffset-m.clientTop);e=q;h.x=(f-e.left)/e.width*2-1;h.y=(l-e.top)/e.height*-2+1;h.z=-1;k.set(h.x,h.y,1); -c(h,d);c(k,d);k.sub(h).normalize();n.set(h,k);g.getInverse(a.matrixWorld);n.applyMatrix4(g);return n}var e,f=new THREE.Matrix4,g=new THREE.Matrix4,h=new THREE.Vector3,k=new THREE.Vector3(1,1,1),l=new THREE.Vector3,n=new THREE.Ray,m=new THREE.Box3,r=new THREE.Sphere,q=new THREE.Matrix4,t=h.distanceTo(k);m.min.set(0.5*-a.size,0.5*-a.size,0.5*-a.size);m.max.set(0.5*a.size,0.5*a.size,0.5*a.size);r.radius=t*a.size*0.5;return{getIntersection:function(b,c,e,f,g){f=f||new THREE.Vector3;if(null===c||null=== -e)return null;d(b,c,e);return n.isIntersectionSphere(r)&&null!==n.intersectBox(m,f)?(g&&(b=l||new THREE.Vector3,b.copy(f).set(Math.round(b.x),Math.round(b.y),Math.round(b.z)).multiplyScalar(2/a.size).set(b.x|0,b.y|0,b.z|0),g.setFromNormalAndCoplanarPoint(l,f)),f):null},getIntersectionOnPlane:function(a,b,c,e,f){if(null===b||null===c)return null;d(a,b,c);return n.intersectPlane(e,f)},getCubeletAtIntersection:function(){var b=new THREE.Vector3;return function(c){b.copy(c).add(m.max).multiplyScalar(3/ -a.size).set(Math.min(b.x|0,2),Math.min(3-b.y|0,2),Math.min(3-b.z|0,2));return a.cubelets[9*b.z+3*b.y+b.x]}}()}}}();ERNO.Interaction=function(){return function(a,b,c,d,e){function f(c){null!=c.touches&&c.preventDefault();y.enabled&&2!==c.button&&(q=(c.touches&&c.touches[0]||c).clientX,t=(c.touches&&c.touches[0]||c).clientY,k.getIntersection(b,q,t,l,s)&&0===a.isTweening()&&(z="undefined"!==typeof window&&void 0!==window.performance&&void 0!==window.performance.now?window.performance.now():Date.now(),y.active=!0,n=k.getCubeletAtIntersection(l),m=[a.slices[n.addressX+1],a.slices[n.addressY+4],a.slices[n.addressZ+ -7]],document.addEventListener("mousemove",g),document.addEventListener("touchmove",g),document.addEventListener("mouseup",h),document.addEventListener("touchcancel",h),document.addEventListener("touchend",h),document.removeEventListener("mousedown",f),document.removeEventListener("touchstart",f)))}function g(a){y.active&&(A.x=(a.touches&&a.touches[0]||a).clientX,A.y=(a.touches&&a.touches[0]||a).clientY);y.enabled&&(a.preventDefault(),a.stopImmediatePropagation())}function h(b){var c=(b.touches&&b.touches[0]|| -b).clientX;b=(b.touches&&b.touches[0]||b).clientY;y.active=!1;y.enabled&&(c!==t||b!==t)&&p&&(c=r.name[0].toUpperCase(),b=Math.round(C/Math.PI*2)*Math.PI*0.5,0.3=a)return this.folds[a].getText()},setText:function(a,b){void 0===b?(this.folds[0].setText(a),this.folds[1].setText(a),this.folds[2].setText(a)):_.isNumeric(b)&&0<=b&&2>=b&&this.folds[b].setText(a)},setSize:function(a,b){this.camera.aspect=a/b;this.camera.updateProjectionMatrix();this.renderer.setSize(a,b)},PRESERVE_LOGO:"RrLlUuDdSsBb",ALL_SLICES:"RrMmLlUuEeDdFfSsBb",EVERYTHING:"XxRrMmLlYyUuEeDdZzFfSsBb", -loop:function(){var a=0;return function(){requestAnimationFrame(this.loop);var b="undefined"!==typeof window&&void 0!==window.performance&&void 0!==window.performance.now?window.performance.now():Date.now(),c=b-(a||b);a=b;this.paused||(this.time+=c,TWEEN.update(this.time),this.autoRotate&&(this.rotation.x+=this.rotationDelta.x,this.rotation.y+=this.rotationDelta.y,this.rotation.z+=this.rotationDelta.z),this.isReady&&0===this.isTweening()&&(b=this.undoing?this.historyQueue:this.twistQueue,0===b.future.length? -this.isSolving&&window.solver?this.isSolving=window.solver.consider(this):!0===this.taskQueue.isReady&&(b=this.taskQueue.do(),b instanceof Function&&b()):(c=b.do(),"x"!==c.command.toLowerCase()&&"y"!==c.command.toLowerCase()&&"z"!==c.command.toLowerCase()&&0!==c.degrees&&(this.moveCounter+=this.undoing?-1:1),(0===c.degrees||c.isShuffle)&&b.purge(c),this.immediateTwist(c))),this.mouseInteraction.enabled=this.mouseControlsEnabled&&!this.finalShuffle,this.mouseInteraction.update(),this.controls.enabled= -this.mouseControlsEnabled&&!this.mouseInteraction.active,this.controls.update())}}()});ERNO.Solver=function(){this.logic=function(a){return!1}};ERNO.Solver.prototype.consider=function(a){if(void 0===a)return console.warn("A cube [Cube] argument must be specified for Solver.consider()."),!1;if(!1===a instanceof ERNO.Cube)return console.warn("The cube argument provided is not a valid Cube."),!1;a.isShuffling=!1;return a.isSolved()?(ERNO.Solver.prototype.explain("I\u2019ve found that the cube is already solved."),!1):this.logic(a)}; -ERNO.Solver.prototype.hint=function(a){console.log("%c"+a+"%c\n","background-color: #EEE; color: #333","")};ERNO.Solver.prototype.explain=function(a){console.log("Solver says: %c "+a+" %c\n","color: #080","")}; - - window.ERNO = ERNO; - window._ = _; - window.TWEEN = window.TWEEN || TWEEN; - window.THREE = window.THREE || THREE; -}()) \ No newline at end of file +(function(){var ERNO={};(function(){function CustomEvent(event,params){params=params||{bubbles:false,cancelable:false,detail:undefined};var evt=document.createEvent("CustomEvent");evt.initCustomEvent(event,params.bubbles,params.cancelable,params.detail);return evt}CustomEvent.prototype=window.Event.prototype;window.CustomEvent=CustomEvent})();ERNO.extend=function(obj,source){if(Object.keys){var keys=Object.keys(source);for(var i=0,il=keys.length;i1?1:elapsed;var value=_easingFunction(elapsed);for(property in _valuesEnd){var start=_valuesStart[property]||0;var end=_valuesEnd[property];if(end instanceof Array){_object[property]=_interpolationFunction(end,value)}else{if(typeof end==="string"){end=start+parseFloat(end,10)}if(typeof end==="number"){_object[property]=start+(end-start)*value}}}if(_onUpdateCallback!==null){_onUpdateCallback.call(_object,value)}if(elapsed==1){if(_repeat>0){if(isFinite(_repeat)){_repeat--}for(property in _valuesStartRepeat){if(typeof _valuesEnd[property]==="string"){_valuesStartRepeat[property]=_valuesStartRepeat[property]+parseFloat(_valuesEnd[property],10)}if(_yoyo){var tmp=_valuesStartRepeat[property];_valuesStartRepeat[property]=_valuesEnd[property];_valuesEnd[property]=tmp;_reversed=!_reversed}_valuesStart[property]=_valuesStartRepeat[property]}_startTime=time+_delayTime;return true}else{if(_onCompleteCallback!==null){_onCompleteCallback.call(_object)}for(var i=0,numChainedTweens=_chainedTweens.length;i1)return fn(v[m],v[m-1],m-f);return fn(v[i],v[i+1>m?m:i+1],f-i)},Bezier:function(v,k){var b=0,n=v.length-1,pw=Math.pow,bn=TWEEN.Interpolation.Utils.Bernstein,i;for(i=0;i<=n;i++){b+=pw(1-k,n-i)*pw(k,i)*v[i]*bn(n,i)}return b},CatmullRom:function(v,k){var m=v.length-1,f=m*k,i=Math.floor(f),fn=TWEEN.Interpolation.Utils.CatmullRom;if(v[0]===v[m]){if(k<0)i=Math.floor(f=m*(1+k));return fn(v[(i-1+m)%m],v[i],v[(i+1)%m],v[(i+2)%m],f-i)}else{if(k<0)return v[0]-(fn(v[0],v[0],v[1],v[1],-f)-v[0]);if(k>1)return v[m]-(fn(v[m],v[m],v[m-1],v[m-1],f-m)-v[m]);return fn(v[i?i-1:0],v[i],v[m1;i--)s*=i;return a[n]=s}}(),CatmullRom:function(p0,p1,p2,p3,t){var v0=(p2-p0)*.5,v1=(p3-p1)*.5,t2=t*t,t3=t*t2;return(2*p1-2*p2+v0+v1)*t3+(-3*p1+3*p2-2*v0-v1)*t2+v0*t+p1}}};var THREE={REVISION:"66"};self.console=self.console||{info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}};(function(){var lastTime=0;var vendors=["ms","moz","webkit","o"];for(var x=0;x>4;uuid[i]=chars[i==19?r&3|8:r]}}return uuid.join("")}}(),clamp:function(x,a,b){return xb?b:x},clampBottom:function(x,a){return x=max)return 1;x=(x-min)/(max-min);return x*x*(3-2*x)},smootherstep:function(x,min,max){if(x<=min)return 0;if(x>=max)return 1;x=(x-min)/(max-min);return x*x*x*(x*(x*6-15)+10)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(low,high){return low+Math.floor(Math.random()*(high-low+1))},randFloat:function(low,high){return low+Math.random()*(high-low)},randFloatSpread:function(range){return range*(.5-Math.random())},sign:function(x){return x<0?-1:x>0?1:0},degToRad:function(){var degreeToRadiansFactor=Math.PI/180;return function(degrees){return degrees*degreeToRadiansFactor}}(),radToDeg:function(){var radianToDegreesFactor=180/Math.PI;return function(radians){return radians*radianToDegreesFactor}}(),isPowerOfTwo:function(value){return(value&value-1)===0&&value!==0}};THREE.Quaternion=function(x,y,z,w){this._x=x||0;this._y=y||0;this._z=z||0;this._w=w!==undefined?w:1};THREE.Quaternion.prototype={constructor:THREE.Quaternion,_x:0,_y:0,_z:0,_w:0,_euler:undefined,_updateEuler:function(callback){if(this._euler!==undefined){this._euler.setFromQuaternion(this,undefined,false)}},get x(){return this._x},set x(value){this._x=value;this._updateEuler()},get y(){return this._y},set y(value){this._y=value;this._updateEuler()},get z(){return this._z},set z(value){this._z=value;this._updateEuler()},get w(){return this._w},set w(value){this._w=value;this._updateEuler()},set:function(x,y,z,w){this._x=x;this._y=y;this._z=z;this._w=w;this._updateEuler();return this},copy:function(quaternion){this._x=quaternion._x;this._y=quaternion._y;this._z=quaternion._z;this._w=quaternion._w;this._updateEuler();return this},setFromEuler:function(euler,update){if(euler instanceof THREE.Euler===false){throw new Error("ERROR: Quaternion's .setFromEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.")}var c1=Math.cos(euler._x/2);var c2=Math.cos(euler._y/2);var c3=Math.cos(euler._z/2);var s1=Math.sin(euler._x/2);var s2=Math.sin(euler._y/2);var s3=Math.sin(euler._z/2);if(euler.order==="XYZ"){this._x=s1*c2*c3+c1*s2*s3;this._y=c1*s2*c3-s1*c2*s3;this._z=c1*c2*s3+s1*s2*c3;this._w=c1*c2*c3-s1*s2*s3}else if(euler.order==="YXZ"){this._x=s1*c2*c3+c1*s2*s3;this._y=c1*s2*c3-s1*c2*s3;this._z=c1*c2*s3-s1*s2*c3;this._w=c1*c2*c3+s1*s2*s3}else if(euler.order==="ZXY"){this._x=s1*c2*c3-c1*s2*s3;this._y=c1*s2*c3+s1*c2*s3;this._z=c1*c2*s3+s1*s2*c3;this._w=c1*c2*c3-s1*s2*s3}else if(euler.order==="ZYX"){this._x=s1*c2*c3-c1*s2*s3;this._y=c1*s2*c3+s1*c2*s3;this._z=c1*c2*s3-s1*s2*c3;this._w=c1*c2*c3+s1*s2*s3}else if(euler.order==="YZX"){this._x=s1*c2*c3+c1*s2*s3;this._y=c1*s2*c3+s1*c2*s3;this._z=c1*c2*s3-s1*s2*c3;this._w=c1*c2*c3-s1*s2*s3}else if(euler.order==="XZY"){this._x=s1*c2*c3-c1*s2*s3;this._y=c1*s2*c3-s1*c2*s3;this._z=c1*c2*s3+s1*s2*c3;this._w=c1*c2*c3+s1*s2*s3}if(update!==false)this._updateEuler();return this},setFromAxisAngle:function(axis,angle){var halfAngle=angle/2,s=Math.sin(halfAngle);this._x=axis.x*s;this._y=axis.y*s;this._z=axis.z*s;this._w=Math.cos(halfAngle);this._updateEuler();return this},setFromRotationMatrix:function(m){var te=m.elements,m11=te[0],m12=te[4],m13=te[8],m21=te[1],m22=te[5],m23=te[9],m31=te[2],m32=te[6],m33=te[10],trace=m11+m22+m33,s;if(trace>0){s=.5/Math.sqrt(trace+1);this._w=.25/s;this._x=(m32-m23)*s;this._y=(m13-m31)*s;this._z=(m21-m12)*s}else if(m11>m22&&m11>m33){s=2*Math.sqrt(1+m11-m22-m33);this._w=(m32-m23)/s;this._x=.25*s;this._y=(m12+m21)/s;this._z=(m13+m31)/s}else if(m22>m33){s=2*Math.sqrt(1+m22-m11-m33);this._w=(m13-m31)/s;this._x=(m12+m21)/s;this._y=.25*s;this._z=(m23+m32)/s}else{s=2*Math.sqrt(1+m33-m11-m22);this._w=(m21-m12)/s;this._x=(m13+m31)/s;this._y=(m23+m32)/s;this._z=.25*s}this._updateEuler();return this},inverse:function(){this.conjugate().normalize();return this},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this._updateEuler();return this},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var l=this.length();if(l===0){this._x=0;this._y=0;this._z=0;this._w=1}else{l=1/l;this._x=this._x*l;this._y=this._y*l;this._z=this._z*l;this._w=this._w*l}return this},multiply:function(q,p){if(p!==undefined){console.warn("DEPRECATED: Quaternion's .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.");return this.multiplyQuaternions(q,p)}return this.multiplyQuaternions(this,q)},multiplyQuaternions:function(a,b){var qax=a._x,qay=a._y,qaz=a._z,qaw=a._w;var qbx=b._x,qby=b._y,qbz=b._z,qbw=b._w;this._x=qax*qbw+qaw*qbx+qay*qbz-qaz*qby;this._y=qay*qbw+qaw*qby+qaz*qbx-qax*qbz;this._z=qaz*qbw+qaw*qbz+qax*qby-qay*qbx;this._w=qaw*qbw-qax*qbx-qay*qby-qaz*qbz;this._updateEuler();return this},multiplyVector3:function(vector){console.warn("DEPRECATED: Quaternion's .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return vector.applyQuaternion(this)},slerp:function(qb,t){var x=this._x,y=this._y,z=this._z,w=this._w;var cosHalfTheta=w*qb._w+x*qb._x+y*qb._y+z*qb._z;if(cosHalfTheta<0){this._w=-qb._w;this._x=-qb._x;this._y=-qb._y;this._z=-qb._z;cosHalfTheta=-cosHalfTheta}else{this.copy(qb)}if(cosHalfTheta>=1){this._w=w;this._x=x;this._y=y;this._z=z;return this}var halfTheta=Math.acos(cosHalfTheta);var sinHalfTheta=Math.sqrt(1-cosHalfTheta*cosHalfTheta);if(Math.abs(sinHalfTheta)<.001){this._w=.5*(w+this._w);this._x=.5*(x+this._x);this._y=.5*(y+this._y);this._z=.5*(z+this._z);return this}var ratioA=Math.sin((1-t)*halfTheta)/sinHalfTheta,ratioB=Math.sin(t*halfTheta)/sinHalfTheta;this._w=w*ratioA+this._w*ratioB;this._x=x*ratioA+this._x*ratioB;this._y=y*ratioA+this._y*ratioB;this._z=z*ratioA+this._z*ratioB;this._updateEuler();return this},equals:function(quaternion){return quaternion._x===this._x&&quaternion._y===this._y&&quaternion._z===this._z&&quaternion._w===this._w},fromArray:function(array){this._x=array[0];this._y=array[1];this._z=array[2];this._w=array[3];this._updateEuler();return this},toArray:function(){return[this._x,this._y,this._z,this._w]},clone:function(){return new THREE.Quaternion(this._x,this._y,this._z,this._w)}};THREE.Quaternion.slerp=function(qa,qb,qm,t){return qm.copy(qa).slerp(qb,t)};THREE.Vector2=function(x,y){this.x=x||0;this.y=y||0};THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(x,y){this.x=x;this.y=y;return this},setX:function(x){this.x=x;return this},setY:function(y){this.y=y;return this},setComponent:function(index,value){switch(index){case 0:this.x=value;break;case 1:this.y=value;break;default:throw new Error("index is out of range: "+index)}},getComponent:function(index){switch(index){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+index)}},copy:function(v){this.x=v.x;this.y=v.y;return this},add:function(v,w){if(w!==undefined){console.warn("DEPRECATED: Vector2's .add() now only accepts one argument. Use .addVectors( a, b ) instead.");return this.addVectors(v,w)}this.x+=v.x;this.y+=v.y;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScalar:function(s){this.x+=s;this.y+=s;return this},sub:function(v,w){if(w!==undefined){console.warn("DEPRECATED: Vector2's .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");return this.subVectors(v,w)}this.x-=v.x;this.y-=v.y;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(s){this.x*=s;this.y*=s;return this},divideScalar:function(scalar){if(scalar!==0){var invScalar=1/scalar;this.x*=invScalar;this.y*=invScalar}else{this.x=0;this.y=0}return this},min:function(v){if(this.x>v.x){this.x=v.x}if(this.y>v.y){this.y=v.y}return this},max:function(v){if(this.xmax.x){this.x=max.x}if(this.ymax.y){this.y=max.y}return this},clampScalar:function(){var min,max;return function(minVal,maxVal){if(min===undefined){min=new THREE.Vector2;max=new THREE.Vector2}min.set(minVal,minVal);max.set(maxVal,maxVal);return this.clamp(min,max)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x);this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(v){return this.x*v.x+this.y*v.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(v){return Math.sqrt(this.distanceToSquared(v))},distanceToSquared:function(v){var dx=this.x-v.x,dy=this.y-v.y;return dx*dx+dy*dy},setLength:function(l){var oldLength=this.length();if(oldLength!==0&&l!==oldLength){this.multiplyScalar(l/oldLength)}return this},lerp:function(v,alpha){this.x+=(v.x-this.x)*alpha;this.y+=(v.y-this.y)*alpha;return this},equals:function(v){return v.x===this.x&&v.y===this.y},fromArray:function(array){this.x=array[0];this.y=array[1];return this},toArray:function(){return[this.x,this.y]},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(x,y,z){this.x=x||0;this.y=y||0;this.z=z||0};THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(x,y,z){this.x=x;this.y=y;this.z=z;return this},setX:function(x){this.x=x;return this},setY:function(y){this.y=y;return this},setZ:function(z){this.z=z;return this},setComponent:function(index,value){switch(index){case 0:this.x=value;break;case 1:this.y=value;break;case 2:this.z=value;break;default:throw new Error("index is out of range: "+index)}},getComponent:function(index){switch(index){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+index)}},copy:function(v){this.x=v.x;this.y=v.y;this.z=v.z;return this},add:function(v,w){if(w!==undefined){console.warn("DEPRECATED: Vector3's .add() now only accepts one argument. Use .addVectors( a, b ) instead.");return this.addVectors(v,w)}this.x+=v.x;this.y+=v.y;this.z+=v.z;return this},addScalar:function(s){this.x+=s;this.y+=s;this.z+=s;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},sub:function(v,w){if(w!==undefined){console.warn("DEPRECATED: Vector3's .sub() now only accepts one argument. Use .subVectors( a, b ) instead.");return this.subVectors(v,w)}this.x-=v.x;this.y-=v.y;this.z-=v.z;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(v,w){if(w!==undefined){console.warn("DEPRECATED: Vector3's .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.");return this.multiplyVectors(v,w)}this.x*=v.x;this.y*=v.y;this.z*=v.z;return this},multiplyScalar:function(scalar){this.x*=scalar;this.y*=scalar;this.z*=scalar;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var quaternion;return function(euler){if(euler instanceof THREE.Euler===false){console.error("ERROR: Vector3's .applyEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.")}if(quaternion===undefined)quaternion=new THREE.Quaternion;this.applyQuaternion(quaternion.setFromEuler(euler));return this}}(),applyAxisAngle:function(){var quaternion;return function(axis,angle){if(quaternion===undefined)quaternion=new THREE.Quaternion;this.applyQuaternion(quaternion.setFromAxisAngle(axis,angle));return this}}(),applyMatrix3:function(m){var x=this.x;var y=this.y;var z=this.z;var e=m.elements;this.x=e[0]*x+e[3]*y+e[6]*z;this.y=e[1]*x+e[4]*y+e[7]*z;this.z=e[2]*x+e[5]*y+e[8]*z;return this},applyMatrix4:function(m){var x=this.x,y=this.y,z=this.z;var e=m.elements;this.x=e[0]*x+e[4]*y+e[8]*z+e[12];this.y=e[1]*x+e[5]*y+e[9]*z+e[13];this.z=e[2]*x+e[6]*y+e[10]*z+e[14];return this},applyProjection:function(m){var x=this.x,y=this.y,z=this.z;var e=m.elements;var d=1/(e[3]*x+e[7]*y+e[11]*z+e[15]);this.x=(e[0]*x+e[4]*y+e[8]*z+e[12])*d;this.y=(e[1]*x+e[5]*y+e[9]*z+e[13])*d;this.z=(e[2]*x+e[6]*y+e[10]*z+e[14])*d;return this},applyQuaternion:function(q){var x=this.x;var y=this.y;var z=this.z;var qx=q.x;var qy=q.y;var qz=q.z;var qw=q.w;var ix=qw*x+qy*z-qz*y;var iy=qw*y+qz*x-qx*z;var iz=qw*z+qx*y-qy*x;var iw=-qx*x-qy*y-qz*z;this.x=ix*qw+iw*-qx+iy*-qz-iz*-qy;this.y=iy*qw+iw*-qy+iz*-qx-ix*-qz;this.z=iz*qw+iw*-qz+ix*-qy-iy*-qx;return this},transformDirection:function(m){var x=this.x,y=this.y,z=this.z;var e=m.elements;this.x=e[0]*x+e[4]*y+e[8]*z;this.y=e[1]*x+e[5]*y+e[9]*z;this.z=e[2]*x+e[6]*y+e[10]*z;this.normalize();return this},divide:function(v){this.x/=v.x;this.y/=v.y;this.z/=v.z;return this},divideScalar:function(scalar){if(scalar!==0){var invScalar=1/scalar;this.x*=invScalar;this.y*=invScalar;this.z*=invScalar}else{this.x=0;this.y=0;this.z=0}return this},min:function(v){if(this.x>v.x){this.x=v.x}if(this.y>v.y){this.y=v.y}if(this.z>v.z){this.z=v.z}return this},max:function(v){if(this.xmax.x){this.x=max.x}if(this.ymax.y){this.y=max.y}if(this.zmax.z){this.z=max.z}return this},clampScalar:function(){var min,max;return function(minVal,maxVal){if(min===undefined){min=new THREE.Vector3;max=new THREE.Vector3}min.set(minVal,minVal,minVal);max.set(maxVal,maxVal,maxVal);return this.clamp(min,max)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x);this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y);this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(v){return this.x*v.x+this.y*v.y+this.z*v.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(l){var oldLength=this.length();if(oldLength!==0&&l!==oldLength){this.multiplyScalar(l/oldLength)}return this},lerp:function(v,alpha){this.x+=(v.x-this.x)*alpha;this.y+=(v.y-this.y)*alpha;this.z+=(v.z-this.z)*alpha;return this},cross:function(v,w){if(w!==undefined){console.warn("DEPRECATED: Vector3's .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.");return this.crossVectors(v,w)}var x=this.x,y=this.y,z=this.z;this.x=y*v.z-z*v.y;this.y=z*v.x-x*v.z;this.z=x*v.y-y*v.x;return this},crossVectors:function(a,b){var ax=a.x,ay=a.y,az=a.z;var bx=b.x,by=b.y,bz=b.z;this.x=ay*bz-az*by;this.y=az*bx-ax*bz;this.z=ax*by-ay*bx;return this},projectOnVector:function(){var v1,dot;return function(vector){if(v1===undefined)v1=new THREE.Vector3;v1.copy(vector).normalize();dot=this.dot(v1);return this.copy(v1).multiplyScalar(dot)}}(),projectOnPlane:function(){var v1;return function(planeNormal){if(v1===undefined)v1=new THREE.Vector3;v1.copy(this).projectOnVector(planeNormal);return this.sub(v1)}}(),reflect:function(){var v1;return function(normal){if(v1===undefined)v1=new THREE.Vector3;return this.sub(v1.copy(normal).multiplyScalar(2*this.dot(normal)))}}(),angleTo:function(v){var theta=this.dot(v)/(this.length()*v.length());return Math.acos(THREE.Math.clamp(theta,-1,1))},distanceTo:function(v){return Math.sqrt(this.distanceToSquared(v))},distanceToSquared:function(v){var dx=this.x-v.x;var dy=this.y-v.y;var dz=this.z-v.z;return dx*dx+dy*dy+dz*dz},setEulerFromRotationMatrix:function(m,order){console.error("REMOVED: Vector3's setEulerFromRotationMatrix has been removed in favor of Euler.setFromRotationMatrix(), please update your code.")},setEulerFromQuaternion:function(q,order){console.error("REMOVED: Vector3's setEulerFromQuaternion: has been removed in favor of Euler.setFromQuaternion(), please update your code.")},getPositionFromMatrix:function(m){console.warn("DEPRECATED: Vector3's .getPositionFromMatrix() has been renamed to .setFromMatrixPosition(). Please update your code.");return this.setFromMatrixPosition(m)},getScaleFromMatrix:function(m){console.warn("DEPRECATED: Vector3's .getScaleFromMatrix() has been renamed to .setFromMatrixScale(). Please update your code.");return this.setFromMatrixScale(m)},getColumnFromMatrix:function(index,matrix){console.warn("DEPRECATED: Vector3's .getColumnFromMatrix() has been renamed to .setFromMatrixColumn(). Please update your code.");return this.setFromMatrixColumn(index,matrix)},setFromMatrixPosition:function(m){this.x=m.elements[12];this.y=m.elements[13];this.z=m.elements[14];return this},setFromMatrixScale:function(m){var sx=this.set(m.elements[0],m.elements[1],m.elements[2]).length();var sy=this.set(m.elements[4],m.elements[5],m.elements[6]).length();var sz=this.set(m.elements[8],m.elements[9],m.elements[10]).length();this.x=sx;this.y=sy;this.z=sz;return this},setFromMatrixColumn:function(index,matrix){var offset=index*4;var me=matrix.elements;this.x=me[offset];this.y=me[offset+1];this.z=me[offset+2];return this},equals:function(v){return v.x===this.x&&v.y===this.y&&v.z===this.z},fromArray:function(array){this.x=array[0];this.y=array[1];this.z=array[2];return this},toArray:function(){return[this.x,this.y,this.z]},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Box3=function(min,max){this.min=min!==undefined?min:new THREE.Vector3(Infinity,Infinity,Infinity);this.max=max!==undefined?max:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};THREE.Box3.prototype={constructor:THREE.Box3,set:function(min,max){this.min.copy(min);this.max.copy(max);return this},addPoint:function(point){if(point.xthis.max.x){this.max.x=point.x}if(point.ythis.max.y){this.max.y=point.y}if(point.zthis.max.z){this.max.z=point.z}},setFromPoints:function(points){if(points.length>0){var point=points[0];this.min.copy(point);this.max.copy(point);for(var i=1,il=points.length;ithis.max.x||point.ythis.max.y||point.zthis.max.z){return false}return true},containsBox:function(box){if(this.min.x<=box.min.x&&box.max.x<=this.max.x&&this.min.y<=box.min.y&&box.max.y<=this.max.y&&this.min.z<=box.min.z&&box.max.z<=this.max.z){return true}return false},getParameter:function(point,optionalTarget){var result=optionalTarget||new THREE.Vector3;return result.set((point.x-this.min.x)/(this.max.x-this.min.x),(point.y-this.min.y)/(this.max.y-this.min.y),(point.z-this.min.z)/(this.max.z-this.min.z))},isIntersectionBox:function(box){if(box.max.xthis.max.x||box.max.ythis.max.y||box.max.zthis.max.z){return false}return true},clampPoint:function(point,optionalTarget){var result=optionalTarget||new THREE.Vector3;return result.copy(point).clamp(this.min,this.max)},distanceToPoint:function(){var v1=new THREE.Vector3;return function(point){var clampedPoint=v1.copy(point).clamp(this.min,this.max);return clampedPoint.sub(point).length()}}(),getBoundingSphere:function(){var v1=new THREE.Vector3;return function(optionalTarget){var result=optionalTarget||new THREE.Sphere;result.center=this.center();result.radius=this.size(v1).length()*.5;return result}}(),intersect:function(box){this.min.max(box.min);this.max.min(box.max);return this},union:function(box){this.min.min(box.min);this.max.max(box.max);return this},applyMatrix4:function(){var points=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];return function(matrix){points[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(matrix);points[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(matrix);points[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(matrix);points[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(matrix);points[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(matrix);points[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(matrix);points[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(matrix);points[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(matrix);this.makeEmpty();this.setFromPoints(points);return this}}(),translate:function(offset){this.min.add(offset);this.max.add(offset);return this},equals:function(box){return box.min.equals(this.min)&&box.max.equals(this.max)},clone:function(){return(new THREE.Box3).copy(this)}};THREE.Sphere=function(center,radius){this.center=center!==undefined?center:new THREE.Vector3;this.radius=radius!==undefined?radius:0};THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(center,radius){this.center.copy(center);this.radius=radius;return this},setFromPoints:function(){var box=new THREE.Box3;return function(points,optionalCenter){var center=this.center;if(optionalCenter!==undefined){center.copy(optionalCenter)}else{box.setFromPoints(points).center(center)}var maxRadiusSq=0;for(var i=0,il=points.length;ithis.radius*this.radius){result.sub(this.center).normalize();result.multiplyScalar(this.radius).add(this.center)}return result},getBoundingBox:function(optionalTarget){var box=optionalTarget||new THREE.Box3;box.set(this.center,this.center);box.expandByScalar(this.radius);return box},applyMatrix4:function(matrix){this.center.applyMatrix4(matrix);this.radius=this.radius*matrix.getMaxScaleOnAxis();return this},translate:function(offset){this.center.add(offset);return this},equals:function(sphere){return sphere.center.equals(this.center)&&sphere.radius===this.radius},clone:function(){return(new THREE.Sphere).copy(this)}};THREE.Euler=function(x,y,z,order){this._x=x||0;this._y=y||0;this._z=z||0;this._order=order||THREE.Euler.DefaultOrder};THREE.Euler.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];THREE.Euler.DefaultOrder="XYZ";THREE.Euler.prototype={constructor:THREE.Euler,_x:0,_y:0,_z:0,_order:THREE.Euler.DefaultOrder,_quaternion:undefined,_updateQuaternion:function(){if(this._quaternion!==undefined){this._quaternion.setFromEuler(this,false)}},get x(){return this._x},set x(value){this._x=value;this._updateQuaternion()},get y(){return this._y},set y(value){this._y=value;this._updateQuaternion()},get z(){return this._z},set z(value){this._z=value;this._updateQuaternion()},get order(){return this._order},set order(value){this._order=value;this._updateQuaternion()},set:function(x,y,z,order){this._x=x;this._y=y;this._z=z;this._order=order||this._order;this._updateQuaternion();return this},copy:function(euler){this._x=euler._x;this._y=euler._y;this._z=euler._z;this._order=euler._order;this._updateQuaternion();return this},setFromRotationMatrix:function(m,order){function clamp(x){return Math.min(Math.max(x,-1),1)}var te=m.elements;var m11=te[0],m12=te[4],m13=te[8];var m21=te[1],m22=te[5],m23=te[9];var m31=te[2],m32=te[6],m33=te[10];order=order||this._order;if(order==="XYZ"){this._y=Math.asin(clamp(m13));if(Math.abs(m13)<.99999){this._x=Math.atan2(-m23,m33);this._z=Math.atan2(-m12,m11)}else{this._x=Math.atan2(m32,m22);this._z=0}}else if(order==="YXZ"){this._x=Math.asin(-clamp(m23));if(Math.abs(m23)<.99999){this._y=Math.atan2(m13,m33);this._z=Math.atan2(m21,m22)}else{this._y=Math.atan2(-m31,m11);this._z=0}}else if(order==="ZXY"){this._x=Math.asin(clamp(m32));if(Math.abs(m32)<.99999){this._y=Math.atan2(-m31,m33);this._z=Math.atan2(-m12,m22)}else{this._y=0;this._z=Math.atan2(m21,m11)}}else if(order==="ZYX"){this._y=Math.asin(-clamp(m31));if(Math.abs(m31)<.99999){this._x=Math.atan2(m32,m33);this._z=Math.atan2(m21,m11)}else{this._x=0;this._z=Math.atan2(-m12,m22)}}else if(order==="YZX"){this._z=Math.asin(clamp(m21));if(Math.abs(m21)<.99999){this._x=Math.atan2(-m23,m22);this._y=Math.atan2(-m31,m11)}else{this._x=0;this._y=Math.atan2(m13,m33)}}else if(order==="XZY"){this._z=Math.asin(-clamp(m12));if(Math.abs(m12)<.99999){this._x=Math.atan2(m32,m22);this._y=Math.atan2(m13,m11)}else{this._x=Math.atan2(-m23,m33);this._y=0}}else{console.warn("WARNING: Euler.setFromRotationMatrix() given unsupported order: "+order)}this._order=order;this._updateQuaternion();return this},setFromQuaternion:function(q,order,update){function clamp(x){return Math.min(Math.max(x,-1),1)}var sqx=q.x*q.x;var sqy=q.y*q.y;var sqz=q.z*q.z;var sqw=q.w*q.w;order=order||this._order;if(order==="XYZ"){this._x=Math.atan2(2*(q.x*q.w-q.y*q.z),sqw-sqx-sqy+sqz);this._y=Math.asin(clamp(2*(q.x*q.z+q.y*q.w)));this._z=Math.atan2(2*(q.z*q.w-q.x*q.y),sqw+sqx-sqy-sqz)}else if(order==="YXZ"){this._x=Math.asin(clamp(2*(q.x*q.w-q.y*q.z)));this._y=Math.atan2(2*(q.x*q.z+q.y*q.w),sqw-sqx-sqy+sqz);this._z=Math.atan2(2*(q.x*q.y+q.z*q.w),sqw-sqx+sqy-sqz)}else if(order==="ZXY"){this._x=Math.asin(clamp(2*(q.x*q.w+q.y*q.z)));this._y=Math.atan2(2*(q.y*q.w-q.z*q.x),sqw-sqx-sqy+sqz);this._z=Math.atan2(2*(q.z*q.w-q.x*q.y),sqw-sqx+sqy-sqz)}else if(order==="ZYX"){this._x=Math.atan2(2*(q.x*q.w+q.z*q.y),sqw-sqx-sqy+sqz);this._y=Math.asin(clamp(2*(q.y*q.w-q.x*q.z)));this._z=Math.atan2(2*(q.x*q.y+q.z*q.w),sqw+sqx-sqy-sqz)}else if(order==="YZX"){this._x=Math.atan2(2*(q.x*q.w-q.z*q.y),sqw-sqx+sqy-sqz);this._y=Math.atan2(2*(q.y*q.w-q.x*q.z),sqw+sqx-sqy-sqz);this._z=Math.asin(clamp(2*(q.x*q.y+q.z*q.w)))}else if(order==="XZY"){this._x=Math.atan2(2*(q.x*q.w+q.y*q.z),sqw-sqx+sqy-sqz);this._y=Math.atan2(2*(q.x*q.z+q.y*q.w),sqw+sqx-sqy-sqz);this._z=Math.asin(clamp(2*(q.z*q.w-q.x*q.y)))}else{console.warn("WARNING: Euler.setFromQuaternion() given unsupported order: "+order)}this._order=order;if(update!==false)this._updateQuaternion();return this},reorder:function(){var q=new THREE.Quaternion;return function(newOrder){q.setFromEuler(this);this.setFromQuaternion(q,newOrder)}}(),fromArray:function(array){this._x=array[0];this._y=array[1];this._z=array[2];if(array[3]!==undefined)this._order=array[3];this._updateQuaternion();return this},toArray:function(){return[this._x,this._y,this._z,this._order]},equals:function(euler){return euler._x===this._x&&euler._y===this._y&&euler._z===this._z&&euler._order===this._order},clone:function(){return new THREE.Euler(this._x,this._y,this._z,this._order)}};THREE.Matrix3=function(n11,n12,n13,n21,n22,n23,n31,n32,n33){this.elements=new Float32Array(9);this.set(n11!==undefined?n11:1,n12||0,n13||0,n21||0,n22!==undefined?n22:1,n23||0,n31||0,n32||0,n33!==undefined?n33:1)};THREE.Matrix3.prototype={constructor:THREE.Matrix3,set:function(n11,n12,n13,n21,n22,n23,n31,n32,n33){var te=this.elements;te[0]=n11;te[3]=n12;te[6]=n13;te[1]=n21;te[4]=n22;te[7]=n23;te[2]=n31;te[5]=n32;te[8]=n33;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},copy:function(m){var me=m.elements;this.set(me[0],me[3],me[6],me[1],me[4],me[7],me[2],me[5],me[8]);return this},multiplyVector3:function(vector){console.warn("DEPRECATED: Matrix3's .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return vector.applyMatrix3(this)},multiplyVector3Array:function(){var v1=new THREE.Vector3;return function(a){for(var i=0,il=a.length;i=0){s0=a01*b1-b0;s1=a01*b0-b1;extDet=segExtent*det;if(s0>=0){if(s1>=-extDet){if(s1<=extDet){var invDet=1/det;s0*=invDet;s1*=invDet;sqrDist=s0*(s0+a01*s1+2*b0)+s1*(a01*s0+s1+2*b1)+c}else{s1=segExtent;s0=Math.max(0,-(a01*s1+b0));sqrDist=-s0*s0+s1*(s1+2*b1)+c}}else{s1=-segExtent;s0=Math.max(0,-(a01*s1+b0));sqrDist=-s0*s0+s1*(s1+2*b1)+c}}else{if(s1<=-extDet){s0=Math.max(0,-(-a01*segExtent+b0));s1=s0>0?-segExtent:Math.min(Math.max(-segExtent,-b1),segExtent);sqrDist=-s0*s0+s1*(s1+2*b1)+c}else if(s1<=extDet){s0=0;s1=Math.min(Math.max(-segExtent,-b1),segExtent);sqrDist=s1*(s1+2*b1)+c}else{s0=Math.max(0,-(a01*segExtent+b0));s1=s0>0?segExtent:Math.min(Math.max(-segExtent,-b1),segExtent);sqrDist=-s0*s0+s1*(s1+2*b1)+c}}}else{s1=a01>0?-segExtent:segExtent;s0=Math.max(0,-(a01*s1+b0));sqrDist=-s0*s0+s1*(s1+2*b1)+c}if(optionalPointOnRay){optionalPointOnRay.copy(this.direction.clone().multiplyScalar(s0).add(this.origin))}if(optionalPointOnSegment){optionalPointOnSegment.copy(segDir.clone().multiplyScalar(s1).add(segCenter))}return sqrDist},isIntersectionSphere:function(sphere){return this.distanceToPoint(sphere.center)<=sphere.radius},isIntersectionPlane:function(plane){var distToPoint=plane.distanceToPoint(this.origin);if(distToPoint===0){return true}var denominator=plane.normal.dot(this.direction);if(denominator*distToPoint<0){return true}return false},distanceToPlane:function(plane){var denominator=plane.normal.dot(this.direction);if(denominator==0){if(plane.distanceToPoint(this.origin)==0){return 0}return null}var t=-(this.origin.dot(plane.normal)+plane.constant)/denominator;return t>=0?t:null},intersectPlane:function(plane,optionalTarget){var t=this.distanceToPlane(plane);if(t===null){return null}return this.at(t,optionalTarget)},isIntersectionBox:function(){var v=new THREE.Vector3;return function(box){return this.intersectBox(box,v)!==null}}(),intersectBox:function(box,optionalTarget){var tmin,tmax,tymin,tymax,tzmin,tzmax;var invdirx=1/this.direction.x,invdiry=1/this.direction.y,invdirz=1/this.direction.z;var origin=this.origin;if(invdirx>=0){tmin=(box.min.x-origin.x)*invdirx;tmax=(box.max.x-origin.x)*invdirx}else{tmin=(box.max.x-origin.x)*invdirx;tmax=(box.min.x-origin.x)*invdirx}if(invdiry>=0){tymin=(box.min.y-origin.y)*invdiry;tymax=(box.max.y-origin.y)*invdiry}else{tymin=(box.max.y-origin.y)*invdiry;tymax=(box.min.y-origin.y)*invdiry}if(tmin>tymax||tymin>tmax)return null;if(tymin>tmin||tmin!==tmin)tmin=tymin;if(tymax=0){tzmin=(box.min.z-origin.z)*invdirz;tzmax=(box.max.z-origin.z)*invdirz}else{tzmin=(box.max.z-origin.z)*invdirz;tzmax=(box.min.z-origin.z)*invdirz}if(tmin>tzmax||tzmin>tmax)return null;if(tzmin>tmin||tmin!==tmin)tmin=tzmin;if(tzmax=0?tmin:tmax,optionalTarget)},intersectTriangle:function(){var diff=new THREE.Vector3;var edge1=new THREE.Vector3;var edge2=new THREE.Vector3;var normal=new THREE.Vector3;return function(a,b,c,backfaceCulling,optionalTarget){edge1.subVectors(b,a);edge2.subVectors(c,a);normal.crossVectors(edge1,edge2);var DdN=this.direction.dot(normal);var sign;if(DdN>0){if(backfaceCulling)return null;sign=1}else if(DdN<0){sign=-1;DdN=-DdN}else{return null}diff.subVectors(this.origin,a);var DdQxE2=sign*this.direction.dot(edge2.crossVectors(diff,edge2));if(DdQxE2<0){return null}var DdE1xQ=sign*this.direction.dot(edge1.cross(diff));if(DdE1xQ<0){return null}if(DdQxE2+DdE1xQ>DdN){return null}var QdN=-sign*diff.dot(normal);if(QdN<0){return null}return this.at(QdN/DdN,optionalTarget)}}(),applyMatrix4:function(matrix4){this.direction.add(this.origin).applyMatrix4(matrix4);this.origin.applyMatrix4(matrix4);this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(ray){return ray.origin.equals(this.origin)&&ray.direction.equals(this.direction)},clone:function(){return(new THREE.Ray).copy(this)}};THREE.Plane=function(normal,constant){this.normal=normal!==undefined?normal:new THREE.Vector3(1,0,0);this.constant=constant!==undefined?constant:0};THREE.Plane.prototype={constructor:THREE.Plane,set:function(normal,constant){this.normal.copy(normal);this.constant=constant;return this},setComponents:function(x,y,z,w){this.normal.set(x,y,z);this.constant=w;return this},setFromNormalAndCoplanarPoint:function(normal,point){this.normal.copy(normal);this.constant=-point.dot(this.normal);return this},setFromCoplanarPoints:function(){var v1=new THREE.Vector3;var v2=new THREE.Vector3;return function(a,b,c){var normal=v1.subVectors(c,b).cross(v2.subVectors(a,b)).normalize();this.setFromNormalAndCoplanarPoint(normal,a);return this}}(),copy:function(plane){this.normal.copy(plane.normal);this.constant=plane.constant;return this},normalize:function(){var inverseNormalLength=1/this.normal.length();this.normal.multiplyScalar(inverseNormalLength);this.constant*=inverseNormalLength;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(point){return this.normal.dot(point)+this.constant},distanceToSphere:function(sphere){return this.distanceToPoint(sphere.center)-sphere.radius},projectPoint:function(point,optionalTarget){return this.orthoPoint(point,optionalTarget).sub(point).negate()},orthoPoint:function(point,optionalTarget){var perpendicularMagnitude=this.distanceToPoint(point);var result=optionalTarget||new THREE.Vector3;return result.copy(this.normal).multiplyScalar(perpendicularMagnitude)},isIntersectionLine:function(line){var startSign=this.distanceToPoint(line.start);var endSign=this.distanceToPoint(line.end);return startSign<0&&endSign>0||endSign<0&&startSign>0},intersectLine:function(){var v1=new THREE.Vector3;return function(line,optionalTarget){var result=optionalTarget||new THREE.Vector3;var direction=line.delta(v1);var denominator=this.normal.dot(direction);if(denominator==0){if(this.distanceToPoint(line.start)==0){return result.copy(line.start)}return undefined}var t=-(line.start.dot(this.normal)+this.constant)/denominator;if(t<0||t>1){return undefined}return result.copy(direction).multiplyScalar(t).add(line.start)}}(),coplanarPoint:function(optionalTarget){var result=optionalTarget||new THREE.Vector3;return result.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var v1=new THREE.Vector3;var v2=new THREE.Vector3;var m1=new THREE.Matrix3;return function(matrix,optionalNormalMatrix){var normalMatrix=optionalNormalMatrix||m1.getNormalMatrix(matrix);var newNormal=v1.copy(this.normal).applyMatrix3(normalMatrix);var newCoplanarPoint=this.coplanarPoint(v2);newCoplanarPoint.applyMatrix4(matrix);this.setFromNormalAndCoplanarPoint(newNormal,newCoplanarPoint);return this}}(),translate:function(offset){this.constant=this.constant-offset.dot(this.normal);return this},equals:function(plane){return plane.normal.equals(this.normal)&&plane.constant==this.constant},clone:function(){return(new THREE.Plane).copy(this)}};THREE.CSS3DObject=function(element){THREE.Object3D.call(this);this.element=element;this.done=false;this.element.style.position="absolute";this.addEventListener("removed",function(event){if(this.element.parentNode!==null){this.element.parentNode.removeChild(this.element);for(var i=0,l=this.children.length;i=0)stringed="+"+stringed;return stringed},toString:function(){return""+this}});ERNO.extend(String.prototype,{capitalize:function(){return this.charAt(0).toUpperCase()+this.slice(1)},invert:function(){var s="",i;for(i=0;i0){while(padLeftLength--)centered=" "+centered}else if(padLeftLength<0){centered=centered.substr(padLeftLength*-1)}if(padRightLength>0){while(padRightLength--)centered+=" "}else if(padRightLength<0){centered=centered.substr(0,centered.length+padRightLength)}return centered},justifyLeft:function(n){var justified=this;while(justified.length=0?i.scale(0,directions.length-1,0,360):Number.NaN},toArray:function(){return[this]},toNumber:function(){return parseFloat(this)},toString:function(){return this},toUnderscoreCase:function(){var underscored=this.replace(/[A-Z]+/g,function($0){return"_"+$0});if(underscored.charAt(0)==="_")underscored=underscored.substr(1);return underscored.toLowerCase()},toUnicode:function(){var i,u,unicode="";for(i=0;i0)target=Array.prototype.slice.call(arguments);if(this.length===target.length){for(i=0;i"}html+="";return html},toText:function(depth){var i,indent,text;depth=_.cascade(depth,0);indent="\n"+"\t".multiply(depth);text="";for(i=0;i1){pattern=/(-?\d+|[XLMRYUEDZFSB])/gi;matches=element.match(pattern);for(m=0;m0){if(this.cubelets[i]===cubeletToRemove)this.cubelets.splice(i,1)}return this},isFlagged:function(property){var count=0;this.cubelets.forEach(function(cubelet){count+=cubelet[property]?1:0});return count},isTweening:function(){return this.isFlagged("isTweening")},isEngagedX:function(){return this.isFlagged("isEngagedX")},isEngagedY:function(){return this.isFlagged("isEngagedY")},isEngagedZ:function(){return this.isFlagged("isEngagedZ")},isEngaged:function(){return this.isEngagedX()+this.isEngagedY()+this.isEngagedZ()},hasProperty:function(property,value){var results=new ERNO.Group;this.cubelets.forEach(function(cubelet){if(cubelet[property]===value)results.add(cubelet)});return results},hasId:function(id){return this.hasProperty("id",id)},hasAddress:function(address){return this.hasProperty("address",address)},hasType:function(type){return this.hasProperty("type",type)},hasColor:function(color){var results=new ERNO.Group;this.cubelets.forEach(function(cubelet){if(cubelet.hasColor(color))results.add(cubelet)});return results},hasColors:function(){var results=new ERNO.Group,colors=Array.prototype.slice.call(arguments);this.cubelets.forEach(function(cubelet){if(cubelet.hasColors.apply(cubelet,colors))results.add(cubelet)});return results},isSolved:function(face){if(face){var faceColors={},numberOfColors=0;if(face instanceof ERNO.Direction)face=face.name;this.cubelets.forEach(function(cubelet){var color=cubelet[face].color.name;if(faceColors[color]===undefined){faceColors[color]=1;numberOfColors++}else faceColors[color]++});return numberOfColors===1?true:false}else{console.warn("A face [String or ERNO.Controls] argument must be specified when using ERNO.Group.isSolved().");return false}},show:function(){this.cubelets.forEach(function(cubelet){cubelet.show()});return this},hide:function(){this.cubelets.forEach(function(cubelet){cubelet.hide()});return this},showPlastics:function(){this.cubelets.forEach(function(cubelet){cubelet.showPlastics()});return this},hidePlastics:function(){this.cubelets.forEach(function(cubelet){cubelet.hidePlastics()});return this},showExtroverts:function(){this.cubelets.forEach(function(cubelet){cubelet.showExtroverts()});return this},hideExtroverts:function(){this.cubelets.forEach(function(cubelet){cubelet.hideExtroverts()});return this},showIntroverts:function(only,soft){this.cubelets.forEach(function(cubelet){cubelet.showIntroverts(only,soft)});return this},hideIntroverts:function(only,soft){this.cubelets.forEach(function(cubelet){cubelet.hideIntroverts(only,soft)});return this},showStickers:function(){this.cubelets.forEach(function(cubelet){cubelet.showStickers()});return this},hideStickers:function(){this.cubelets.forEach(function(cubelet){cubelet.hideStickers()});return this},showWireframes:function(){this.cubelets.forEach(function(cubelet){cubelet.showWireframes()});return this},hideWireframes:function(){this.cubelets.forEach(function(cubelet){cubelet.hideWireframes()});return this},showIds:function(){this.cubelets.forEach(function(cubelet){cubelet.showIds()});return this},hideIds:function(){this.cubelets.forEach(function(cubelet){cubelet.hideIds()});return this},showTexts:function(){this.cubelets.forEach(function(cubelet){cubelet.showTexts()});return this},hideTexts:function(){this.cubelets.forEach(function(cubelet){cubelet.hideTexts()});return this},getOpacity:function(){var avg=0;this.cubelets.forEach(function(cubelet){avg+=cubelet.getOpacity()});return avg/this.cubelets.length},setOpacity:function(opacity,onComplete){this.cubelets.forEach(function(cubelet){cubelet.setOpacity(opacity,onComplete)});return this},getRadius:function(){var avg=0;this.cubelets.forEach(function(cubelet){avg+=cubelet.getRadius()});return avg/this.cubelets.length},setRadius:function(radius,onComplete){this.cubelets.forEach(function(cubelet){cubelet.setRadius(radius,onComplete)});return this}});ERNO.Slice=function(indices,cube){this.axis=new THREE.Vector3;this.invertedAxis=new THREE.Vector3;this.matrix=new THREE.Matrix4;this.axis.rotation=0;this.indices=indices;this.neighbour=null;this.ableToHideInternalFaces=true;this.cube=cube;var self=this;this.getCubelet=function(index){return cube.cubelets[indices[index]]};this.rotateGroupMappingOnAxis=function(){var absAxis=new THREE.Vector3,max=new THREE.Vector3(1,1,1),point=new THREE.Vector3,origin=new THREE.Vector3,rotation=new THREE.Matrix4,faceArray;return function(angle){angle=Math.round(angle/(Math.PI*.25))*Math.PI*.25;absAxis.copy(max);absAxis.sub(this.axis);var cubletsCopy=cube.cubelets.slice();rotation.makeRotationAxis(this.axis,angle*-1);var i=indices.length,cubelet;while(i-- >0){cubelet=cube.cubelets[indices[i]];point.set(cubelet.addressX,cubelet.addressY,cubelet.addressZ);origin.copy(point);point.multiply(absAxis).applyMatrix4(rotation);point.x=Math.round(point.x);point.y=Math.round(point.y);point.z=Math.round(point.z);point.add(origin.multiply(this.axis));point.add(max);point.y=2-point.y;point.z=2-point.z;var address=point.z*9+point.y*3+point.x;cube.cubelets[cubelet.address]=cubletsCopy[address]}for(i=0;i0){array.push(this.getCubelet(l))}return array},map:function(indices,cubelets){for(var i=0;i<6;i++){if(this.origin.faces[i].color&&this.origin.faces[i].color!==ERNO.COLORLESS){this.color=this.origin.faces[i].color;this.face=ERNO.Direction.getNameById(i);break}}if(this.axis===undefined||this.axis.lengthSq()===0){var pointA=this.northEast.position.clone(),pointB=this.southWest.position.clone(),pointC=this.northWest.position.clone();this.axis=(new THREE.Vector3).crossVectors(pointB.sub(pointA),pointC.sub(pointA)).normalize();this.axis.rotation=0}this.up=new ERNO.Group(this.northWest,this.north,this.northEast);this.equator=new ERNO.Group(this.west,this.origin,this.east);this.down=new ERNO.Group(this.southWest,this.south,this.southEast);this.left=new ERNO.Group(this.northWest,this.west,this.southWest);this.middle=new ERNO.Group(this.north,this.origin,this.south);this.right=new ERNO.Group(this.northEast,this.east,this.southEast);var hasCenter=this.hasType("center");if(hasCenter&&hasCenter.cubelets.length===1){this.center=this.hasType("center");this.corners=new ERNO.Group(this.hasType("corner"));this.cross=new ERNO.Group(this.center,this.hasType("edge"));this.ex=new ERNO.Group(this.center,this.hasType("corner"))}else{this.centers=new ERNO.Group(this.hasType("center"))}this.edges=new ERNO.Group(this.hasType("edge"));this.ring=new ERNO.Group(this.northWest,this.north,this.northEast,this.west,this.east,this.southWest,this.south,this.southEast);this.dexter=new ERNO.Group(this.northWest,this.origin,this.southEast);this.sinister=new ERNO.Group(this.northEast,this.origin,this.southWest);return this},set rotation(radians){if(this.ableToHideInternalFaces&&this.cube.isFlagged("showingIntroverts")!==0&&this.cube.hideInvisibleFaces){var partialRotation=radians%(Math.PI*.5)!==0;this.invertedAxis.copy(this.axis).negate();if(partialRotation){if(this.neighbour){this.showIntroverts(this.axis,true);this.neighbour.showIntroverts(this.invertedAxis,true)}else{this.cube.showIntroverts(this.axis,true);this.cube.showIntroverts(this.invertedAxis,true)}}else{if(this.neighbour){this.hideIntroverts(null,true);this.neighbour.hideIntroverts(null,true)}else{this.cube.hideIntroverts(null,true)}}}this.matrix.makeRotationAxis(this.axis,radians);this.axis.rotation=radians;var l=this.indices.length,cubelet,m1=new THREE.Matrix4;while(l--){cubelet=this.getCubelet(l);cubelet.matrix.multiplyMatrices(this.matrix,cubelet.matrixSlice);cubelet.position.setFromMatrixPosition(cubelet.matrix);cubelet.scale.setFromMatrixScale(cubelet.matrix);m1.extractRotation(cubelet.matrix);cubelet.quaternion.setFromRotationMatrix(m1)}},get rotation(){return this.axis.rotation},getLocation:function(cubelet){if(cubelet===this.origin)return"origin";if(cubelet===this.north)return"north";if(cubelet===this.northEast)return"northEast";if(cubelet===this.east)return"east";if(cubelet===this.southEast)return"southEast";if(cubelet===this.south)return"south";if(cubelet===this.southWest)return"southWest";if(cubelet===this.west)return"west";if(cubelet===this.northWest)return"northWest";return false},isSolved:function(face){if(face){var faceColors={},cubelet,color,l=this.indices.length,numberOfColors=0;if(face instanceof ERNO.Direction)face=face.name;while(l-- >0){cubelet=this.getCubelet(l);color=cubelet[face].color.name;if(faceColors[color]===undefined){faceColors[color]=1;numberOfColors++}else faceColors[color]++}return numberOfColors===1?true:false}else{console.warn("A face [String or ERNO.Controls] argument must be specified when using ERNO.Group.isSolved().");return false}}});ERNO.Fold=function(left,right){this.map=[left.northWest[left.face].text,left.north[left.face].text,left.northEast[left.face].text,right.northWest[right.face].text,right.north[right.face].text,right.northEast[right.face].text,left.west[left.face].text,left.origin[left.face].text,left.east[left.face].text,right.west[right.face].text,right.origin[right.face].text,right.east[right.face].text,left.southWest[left.face].text,left.south[left.face].text,left.southEast[left.face].text,right.southWest[right.face].text,right.south[right.face].text,right.southEast[right.face].text]};ERNO.Fold.prototype.getText=function(){var text="";this.map.forEach(function(element){text+=element.innerHTML});return text};ERNO.Fold.prototype.setText=function(text){var i;text=text.justifyLeft(18);for(i=0;i<18;i++){this.map[i].innerHTML=text.substr(i,1)}};ERNO.Projector=function(){return function(cube,domElement){var api,screen,viewProjectionMatrix=new THREE.Matrix4,inverseMatrix=new THREE.Matrix4,mouse=new THREE.Vector3,end=new THREE.Vector3(1,1,1),normal=new THREE.Vector3,ray=new THREE.Ray,box=new THREE.Box3,sphere=new THREE.Sphere,projectionMatrixInverse=new THREE.Matrix4,unitCubeBoundingRadius=mouse.distanceTo(end);box.min.set(-cube.size*.5,-cube.size*.5,-cube.size*.5);box.max.set(cube.size*.5,cube.size*.5,cube.size*.5);sphere.radius=unitCubeBoundingRadius*cube.size*.5;function unprojectVector(vector,camera){projectionMatrixInverse.getInverse(camera.projectionMatrix);viewProjectionMatrix.multiplyMatrices(camera.matrixWorld,projectionMatrixInverse);return vector.applyProjection(viewProjectionMatrix)}function getBoundingClientRect(element){var bounds=element!==document?element.getBoundingClientRect():{left:0,top:0,width:window.innerWidth,height:window.innerHeight};if(element!==document){var d=element.ownerDocument.documentElement;bounds.left+=window.pageXOffset-d.clientLeft;bounds.top+=window.pageYOffset-d.clientTop}return bounds}function setRay(camera,mouseX,mouseY){screen=getBoundingClientRect(domElement);mouse.x=(mouseX-screen.left)/screen.width*2-1;mouse.y=(mouseY-screen.top)/screen.height*-2+1;mouse.z=-1;end.set(mouse.x,mouse.y,1);unprojectVector(mouse,camera);unprojectVector(end,camera);end.sub(mouse).normalize();ray.set(mouse,end);inverseMatrix.getInverse(cube.matrixWorld);ray.applyMatrix4(inverseMatrix);return ray}function getFaceNormalForIntersection(intersection,optionalTarget){var target=optionalTarget||new THREE.Vector3;target.copy(intersection).set(Math.round(target.x),Math.round(target.y),Math.round(target.z)).multiplyScalar(2/cube.size).set(target.x|0,target.y|0,target.z|0);return normal}api={getIntersection:function(camera,mouseX,mouseY,optionalIntersectionTarget,optionalPlaneTarget){var intersection=optionalIntersectionTarget||new THREE.Vector3;if(mouseX===null||mouseY===null)return null;setRay(camera,mouseX,mouseY);if(ray.isIntersectionSphere(sphere)&&ray.intersectBox(box,intersection)!==null){if(optionalPlaneTarget){getFaceNormalForIntersection(intersection,normal);optionalPlaneTarget.setFromNormalAndCoplanarPoint(normal,intersection)}return intersection}return null},getIntersectionOnPlane:function(camera,mouseX,mouseY,plane,optionalTarget){if(mouseX===null||mouseY===null)return null;setRay(camera,mouseX,mouseY);return ray.intersectPlane(plane,optionalTarget)},getCubeletAtIntersection:function(){var tmp=new THREE.Vector3;return function(intersection){tmp.copy(intersection).add(box.max).multiplyScalar(3/cube.size).set(Math.min(tmp.x|0,2),Math.min(3-tmp.y|0,2),Math.min(3-tmp.z|0,2));return cube.cubelets[tmp.z*9+tmp.y*3+tmp.x]}}()};return api}}();ERNO.Interaction=function(){return function(cube,camera,domElement,dragSpeed,multiDrag){var projector=new ERNO.Projector(cube,domElement);var intersected,points=[],intersection=new THREE.Vector3,cubelet,possibleSlices,slice,mouseX,mouseY,pointOnPlane=new THREE.Vector3,axisDefined=false,plane=new THREE.Plane,direction=new THREE.Vector3,cross=new THREE.Vector3,current=new THREE.Vector2,basis=new THREE.Vector3,axis=new THREE.Vector3,angle=0,time=0;current.x=undefined;current.y=undefined;var api={active:false,enabled:true,multiDrag:multiDrag||false,multiDragSnapArea:100,dragSpeed:dragSpeed||1.3};THREE.EventDispatcher.prototype.apply(api);api.getIntersectionAt=function(){var intersection3D=new THREE.Vector3,plane3D=new THREE.Plane;return function(x,y){if(projector.getIntersection(camera,x,y,intersection3D,plane3D)===null)return null;return{cubelet:projector.getCubeletAtIntersection(intersection3D),face:plane3D.normal.x===1?"RIGHT":plane3D.normal.x===-1?"LEFT":plane3D.normal.y===1?"UP":plane3D.normal.y===-1?"DOWN":plane3D.normal.z===1?"FRONT":"BACK"}}}();var projectVector=function(){var viewProjectionMatrix=new THREE.Matrix4;return function(vector,camera){camera.matrixWorldInverse.getInverse(camera.matrixWorld);viewProjectionMatrix.multiplyMatrices(camera.projectionMatrix,camera.matrixWorldInverse);return vector.applyProjection(viewProjectionMatrix)}};function snapVectorToBasis(vector){var max=Math.max(Math.abs(vector.x),Math.abs(vector.y),Math.abs(vector.z));vector.x=vector.x/max|0;vector.y=vector.x===1?0:vector.y/max|0;vector.z=vector.x===1||vector.y===1?0:vector.z/max|0;return vector}api.update=function(){var x=current.x,y=current.y;if(api.enabled&&api.active&&x!==undefined&&y!=undefined&&(mouseX!==x||mouseY!==y)){projector.getIntersectionOnPlane(camera,x,y,plane,pointOnPlane);direction.subVectors(pointOnPlane,intersection);if(!axisDefined&&direction.length()>5){if(slice)slice.rotation=0;axisDefined=true;axis.crossVectors(plane.normal,direction);snapVectorToBasis(axis);slice=possibleSlices[Math.abs(axis.z*3+axis.y*2+axis.x)-1];cross.crossVectors(slice.axis,plane.normal).normalize()}if(axisDefined){direction.subVectors(pointOnPlane,intersection);var dot=cross.dot(direction);angle=dot/cube.size*api.dragSpeed}if(slice)slice.rotation=angle}};function onInteractStart(event){if(event.touches!=null)event.preventDefault();if(api.enabled&&event.button!==2){mouseX=(event.touches&&event.touches[0]||event).clientX;mouseY=(event.touches&&event.touches[0]||event).clientY;if(intersected=projector.getIntersection(camera,mouseX,mouseY,intersection,plane)){if(cube.isTweening()===0){time=typeof window!=="undefined"&&window.performance!==undefined&&window.performance.now!==undefined?window.performance.now():Date.now();api.active=true;cubelet=projector.getCubeletAtIntersection(intersection);possibleSlices=[cube.slices[cubelet.addressX+1],cube.slices[cubelet.addressY+4],cube.slices[cubelet.addressZ+7]];document.addEventListener("mousemove",onInteractUpdate);document.addEventListener("touchmove",onInteractUpdate);document.addEventListener("mouseup",onInteractEnd);document.addEventListener("touchcancel",onInteractEnd);document.addEventListener("touchend",onInteractEnd);document.removeEventListener("mousedown",onInteractStart);document.removeEventListener("touchstart",onInteractStart)}}}}function onInteractUpdate(event){if(api.active){current.x=(event.touches&&event.touches[0]||event).clientX,current.y=(event.touches&&event.touches[0]||event).clientY}if(api.enabled){event.preventDefault();event.stopImmediatePropagation()}}function onInteractEnd(event){var x=(event.touches&&event.touches[0]||event).clientX,y=(event.touches&&event.touches[0]||event).clientY;api.active=false;if(api.enabled&&(x!==mouseY||y!==mouseY)&&axisDefined){var command=slice.name[0].toUpperCase();var targetAngle=Math.round(angle/Math.PI*.5*4)*Math.PI*.5;var velocityOfInteraction=direction.length()/((typeof window!=="undefined"&&window.performance!==undefined&&window.performance.now!==undefined?window.performance.now():Date.now())-time);if(velocityOfInteraction>.3){targetAngle=Math.floor(angle/Math.PI*.5*4)*Math.PI*.5;targetAngle+=cross.dot(direction.normalize())>0?Math.PI*.5:0}cube.twist(new ERNO.Twist(command,targetAngle.radiansToDegrees()))}time=0;current.x=undefined;current.y=undefined;axisDefined=false;slice=null;document.removeEventListener("mousemove",onInteractUpdate);document.removeEventListener("touchmove",onInteractUpdate);document.removeEventListener("mouseup",onInteractEnd);document.removeEventListener("touchend",onInteractEnd);document.removeEventListener("touchcancel",onInteractEnd);document.addEventListener("mousedown",onInteractStart);document.addEventListener("touchstart",onInteractStart)}document.addEventListener("mousedown",onInteractStart);document.addEventListener("touchstart",onInteractStart);var detectInteraction=function(x,y){var intersection=this.getIntersectionAt(x,y);if(intersection){this.dispatchEvent(new CustomEvent("click",{detail:intersection}))}}.bind(api);var ax,ay;domElement.addEventListener("mousedown",function(event){ax=event.clientX;ay=event.clientY});domElement.addEventListener("mouseup",function(event){var bx=event.clientX,by=event.clientY;if(Math.abs(Math.sqrt((bx-ax)*(bx-ax)+(by-ay)*(by-ay)))<10*(window.devicePixelratio||1)){detectInteraction(ax,ay)}});domElement.addEventListener("touchstart",function(event){event.preventDefault();ax=event.touches[0].clientX,ay=event.touches[0].clientY});domElement.addEventListener("touchend",function(event){var bx=event.changedTouches[0].clientX,by=event.changedTouches[0].clientY;if(Math.abs(Math.sqrt((bx-ax)*(bx-ax)+(by-ay)*(by-ay)))<10*(window.devicePixelratio||1)){detectInteraction(ax,ay)}});return api}}();ERNO.Controls=function(){var STATE={NONE:-1,ROTATE:0,INERTIA:1};function getBoundingClientRect(element){var bounds=element!==document?element.getBoundingClientRect():{left:0,top:0,width:window.innerWidth,height:window.innerHeight};return bounds}return function(object,camera,domElement){var state=STATE.NONE,direction=new THREE.Vector2,mouse=new THREE.Vector2,mouseEnd=new THREE.Vector2,lastPosition=new THREE.Vector2,projector=new ERNO.Projector(object,domElement),api={enabled:true,domElement:domElement,rotationSpeed:4,damping:.25};var getMouseProjectionOnBall=function(x,y,vector){var view=getBoundingClientRect(api.domElement),aspect=view.height/view.width;var dpr=window.devicePixelRatio||1;x*=dpr;y*=dpr;return vector.set((x-view.width-view.left)*.001,(view.height+view.top-y)*.001)};api.update=function(){var axis=new THREE.Vector3,length=0,modelViewInverse=new THREE.Matrix4;return function updateClosure(){if(api.enabled===false||state===STATE.NONE)return;axis.set(direction.y,direction.x*-1,0).normalize();modelViewInverse.getInverse(object.matrixWorld);modelViewInverse.multiply(camera.matrixWorld);axis.transformDirection(modelViewInverse);direction.multiplyScalar(1-Math.max(0,Math.min(1,api.damping)));length=direction.length();object.object3D.rotateOnAxis(axis,-length*api.rotationSpeed);if(state===STATE.ROTATE)state=STATE.NONE;else if(state===STATE.INERTIA&&length>=1e-4){mouse.add(direction)}else{state=STATE.NONE}}}();function mousedown(event){if(!api.enabled||event.which!==1)return;if(projector.getIntersection(camera,event.pageX,event.pageY)===null){state=STATE.ROTATE;direction.multiplyScalar(0);getMouseProjectionOnBall(event.pageX,event.pageY,mouse);lastPosition.copy(mouse);api.domElement.removeEventListener("mousedown",mousedown);document.addEventListener("mousemove",mousemove);document.addEventListener("mouseup",mouseup)}}function mousemove(event){if(api.enabled){event.preventDefault();state=STATE.ROTATE;getMouseProjectionOnBall(event.pageX,event.pageY,mouse);direction.subVectors(mouse,lastPosition);lastPosition.copy(mouse)}}function mouseup(event){document.removeEventListener("mousemove",mousemove);document.removeEventListener("mouseup",mouseup);api.domElement.addEventListener("mousedown",mousedown);if(api.enabled){state=STATE.INERTIA}}function touchstart(event){if(api.enabled&&projector.getIntersection(camera,event.touches[0].pageX,event.touches[0].pageY)===null){state=STATE.ROTATE;direction.multiplyScalar(0);getMouseProjectionOnBall(event.touches[0].pageX,event.touches[0].pageY,mouse);lastPosition.copy(mouse);api.domElement.removeEventListener("touchstart",touchstart);document.addEventListener("touchend",touchend);document.addEventListener("touchmove",touchmove)}}function touchmove(event){if(api.enabled){state=STATE.ROTATE;getMouseProjectionOnBall(event.changedTouches[0].pageX,event.changedTouches[0].pageY,mouse);direction.subVectors(mouse,lastPosition);lastPosition.copy(mouse)}}function touchend(event){document.removeEventListener("touchend",touchend);document.removeEventListener("touchmove",touchmove);api.domElement.addEventListener("touchstart",touchstart);if(api.enabled){state=STATE.INERTIA}}api.domElement.addEventListener("mousedown",mousedown);api.domElement.addEventListener("touchstart",touchstart);return api}}();var SceneType=THREE.Scene;THREE.Scene=SceneType||function(){};ERNO.renderers=ERNO.renderers||{};ERNO.renderers.CSS3D=function(cubelets,cube){var renderer=new THREE.CSS3DRenderer,scene=new THREE.Object3D;renderer.scene=scene;scene.add(cube.autoRotateObj3D);scene.add(cube.camera);var faceLabel,axis=new THREE.Vector3;cube.faces.forEach(function(face,i){faceLabel=cube[face.face].label=new THREE.CSS3DObject(document.createElement("div"));faceLabel.element.classList.add("faceLabel");faceLabel.position.copy(face.axis).multiplyScalar(cube.size);faceLabel.position.negate();faceLabel.element.innerHTML=face.face.toUpperCase();cube.object3D.add(faceLabel)});cube.right.label.rotation.y=Math.PI*.5;cube.left.label.rotation.y=Math.PI*-.5;cube.back.label.rotation.y=Math.PI;cube.up.label.rotation.x=Math.PI*-.5;cube.down.label.rotation.x=Math.PI*.5;function showItem(item){item.style.display="block"}function hideItem(item){item.style.display="none"}function getFaceLabelElements(){return Array.prototype.slice.call(renderer.domElement.querySelectorAll(".faceLabel"))}cube.showFaceLabels=function(){getFaceLabelElements().forEach(showItem);this.showingFaceLabels=true;return this};cube.hideFaceLabels=function(){getFaceLabelElements().forEach(hideItem);this.showingFaceLabels=false;return this};ERNO.extend(ERNO.Cubelet.prototype,ERNO.renderers.CSS3DCubelet.methods);cubelets.forEach(ERNO.renderers.CSS3DCubelet);function render(){if(cube.domElement.parentNode){var parentWidth=cube.domElement.parentNode.clientWidth,parentHeight=cube.domElement.parentNode.clientHeight;if(cube.domElement.parentNode&&(cube.domElement.clientWidth!==parentWidth||cube.domElement.clientHeight!==parentHeight)){cube.setSize(parentWidth,parentHeight)}renderer.render(scene,cube.camera)}requestAnimationFrame(render)}requestAnimationFrame(render);if(SceneType)THREE.Scene=SceneType;return renderer};ERNO.renderers.CSS3DCubelet=function(){return function(cubelet){var domElement=document.createElement("div");domElement.classList.add("cubelet");domElement.classList.add("cubeletId-"+cubelet.id);cubelet.css3DObject=new THREE.CSS3DObject(domElement);cubelet.css3DObject.name="css3DObject-"+cubelet.id;cubelet.add(cubelet.css3DObject);var faceSpacing=cubelet.size/2;var transformMap=["rotateX( 0deg ) translateZ( "+faceSpacing+"px ) rotateZ( 0deg )","rotateX( 90deg ) translateZ( "+faceSpacing+"px ) rotateZ( 0deg )","rotateY( 90deg ) translateZ( "+faceSpacing+"px ) rotateZ( 0deg )","rotateX( -90deg ) translateZ( "+faceSpacing+"px ) rotateZ( 90deg )","rotateY( -90deg ) translateZ( "+faceSpacing+"px ) rotateZ( -90deg )","rotateY( 180deg ) translateZ( "+faceSpacing+"px ) rotateZ( -90deg )"];var axisMap=["axisZ","axisY","axisX","axisY","axisX","axisZ"];cubelet.faces.forEach(function(face){face.element=document.createElement("div");face.element.classList.add("face");face.element.classList.add(axisMap[face.id]);face.element.classList.add("face"+ERNO.Direction.getNameById(face.id).capitalize());cubelet.css3DObject.element.appendChild(face.element);var wireframeElement=document.createElement("div");wireframeElement.classList.add("wireframe");face.element.appendChild(wireframeElement);var idElement=document.createElement("div");idElement.classList.add("id");face.element.appendChild(idElement);var underlineElement=document.createElement("span");underlineElement.classList.add("underline");underlineElement.innerText=cubelet.id;idElement.appendChild(underlineElement);var cssTransform=transformMap[face.id],style=face.element.style;style.OTransform=style.MozTransform=style.WebkitTransform=style.transform=cssTransform;if(face.isIntrovert){face.element.classList.add("faceIntroverted");face.element.appendChild(document.createElement("div"))}else{face.element.classList.add("faceExtroverted");var stickerElement=document.createElement("div");stickerElement.classList.add("sticker");stickerElement.classList.add(face.color.name);face.element.appendChild(stickerElement);if(cubelet.isStickerCubelet){stickerElement.classList.add("stickerLogo")}var textElement=document.createElement("div");textElement.classList.add("text");textElement.innerText=face.id;face.text=textElement;face.element.appendChild(textElement)}});cubelet.show();cubelet.showIntroverts();cubelet.showPlastics();cubelet.showStickers();cubelet.hideIds();cubelet.hideTexts();cubelet.hideWireframes()}}();ERNO.renderers.CSS3DCubelet.methods=function(){function showItem(item){item.style.display="block"}function hideItem(item){item.style.display="none"}return{getFaceElements:function(selector){var selectorString=selector||"";return Array.prototype.slice.call(this.css3DObject.element.querySelectorAll(".face"+selectorString))},show:function(){showItem(this.css3DObject.element);this.showing=true},hide:function(){hideItem(this.css3DObject.element);this.showing=false},showExtroverts:function(){this.getFaceElements(".faceExtroverted").forEach(showItem);this.showingExtroverts=true},hideExtroverts:function(){this.getFaceElements(".faceExtroverted").forEach(hideItem);this.showingExtroverts=false},showIntroverts:function(){var axis=new THREE.Vector3,inv=new THREE.Matrix4,only;return function(onlyAxis,soft){only="";if(onlyAxis){inv.getInverse(this.matrix);axis.copy(onlyAxis).transformDirection(inv);only=Math.abs(Math.round(axis.x))===1?".axisX":Math.round(Math.abs(axis.y))===1?".axisY":".axisZ"}this.getFaceElements(".faceIntroverted"+(onlyAxis!==undefined?only:"")).forEach(showItem);if(!soft)this.showingIntroverts=true}}(),hideIntroverts:function(){var axis=new THREE.Vector3,inv=new THREE.Matrix4,only;return function(onlyAxis,soft){only="";if(onlyAxis){inv.getInverse(this.matrix);axis.copy(onlyAxis).transformDirection(inv);only=Math.abs(Math.round(axis.x))===1?".axisX":Math.round(Math.abs(axis.y))===1?".axisY":".axisZ"}this.getFaceElements(".faceIntroverted"+(onlyAxis!==undefined?only:"")).forEach(hideItem);if(!soft)this.showingIntroverts=false}}(),showPlastics:function(){this.getFaceElements().forEach(function(item){item.classList.remove("faceTransparent")});this.showingPlastics=true},hidePlastics:function(){this.getFaceElements().forEach(function(item){item.classList.add("faceTransparent")});this.showingPlastics=false},hideStickers:function(){this.getFaceElements(" .sticker").forEach(hideItem);this.showingStickers=false},showStickers:function(){this.getFaceElements(" .sticker").forEach(showItem);this.showingStickers=true},showWireframes:function(){this.getFaceElements(" .wireframe").forEach(showItem);this.showingWireframes=true},hideWireframes:function(){this.getFaceElements(" .wireframe").forEach(hideItem);this.showingWireframes=false},showIds:function(){this.getFaceElements(" .id").forEach(showItem);this.showingIds=true},hideIds:function(){this.getFaceElements(" .id").forEach(hideItem);this.showingIds=false},showTexts:function(){this.getFaceElements(" .text").forEach(showItem);this.showingTexts=true},hideTexts:function(){this.getFaceElements(" .text").forEach(hideItem);this.showingTexts=false},getOpacity:function(){return this.opacity},setOpacity:function(opacityTarget,onComplete){if(this.opacityTween)this.opacityTween.stop();if(opacityTarget===undefined)opacityTarget=1;if(opacityTarget!==this.opacity){var that=this,tweenDuration=(opacityTarget-this.opacity).absolute().scale(0,1,0,1e3*.2);this.opacityTween=new TWEEN.Tween({opacity:this.opacity}).to({opacity:opacityTarget},tweenDuration).easing(TWEEN.Easing.Quadratic.InOut).onUpdate(function(){that.css3DObject.element.style.opacity=this.opacity;that.opacity=this.opacity}).onComplete(function(){if(onComplete instanceof Function)onComplete()}).start()}},getStickersOpacity:function(value){return parseFloat(this.getFaceElements(" .sticker")[0].style.opacity)},setStickersOpacity:function(value){if(value===undefined)value=.2;var valueStr=value;this.getFaceElements(" .sticker").forEach(function(sticker){sticker.style.opacity=valueStr.toString()})}}}();ERNO.Cube=function(parameters){ERNO.Group.call(this);parameters=parameters||{};this.paused=parameters.paused===undefined?false:parameters.paused;this.autoRotate=parameters.autoRotate===undefined?false:parameters.autoRotate;this.keyboardControlsEnabled=parameters.keyboardControlsEnabled===undefined?true:parameters.keyboardControlsEnabled;this.mouseControlsEnabled=parameters.mouseControlsEnabled===undefined?true:parameters.mouseControlsEnabled;var renderFactory=parameters.renderer||ERNO.renderers.CSS3D;parameters.textureSize=parameters.textureSize===undefined?120:parameters.textureSize;this.isShuffling=false;this.isReady=true;this.isSolving=false;this.undoing=false;this.render=true;this.finalShuffle=null;this.hideInvisibleFaces=parameters.hideInvisibleFaces===undefined?false:parameters.hideInvisibleFaces;this.time=0;this.moveCounter=0;this.taskQueue=new ERNO.Queue;this.twistQueue=new ERNO.Queue(ERNO.Twist.validate);this.historyQueue=new ERNO.Queue(ERNO.Twist.validate);this.twistDuration=parameters.twistDuration!==undefined?parameters.twistDuration:500;this.shuffleMethod=this.PRESERVE_LOGO;this.size=parameters.textureSize*3;this.cubeletSize=this.size/3;var FIELD_OF_VIEW=35,WIDTH=window.innerWidth,HEIGHT=window.innerHeight,ASPECT_RATIO=WIDTH/HEIGHT,NEAR=1,FAR=6e3;this.camera=new THREE.PerspectiveCamera(FIELD_OF_VIEW,ASPECT_RATIO,NEAR,FAR);this.camera.position.z=this.size*4;this.object3D=new THREE.Object3D;this.autoRotateObj3D=new THREE.Object3D;this.rotation=this.object3D.rotation;this.quaternion=this.object3D.quaternion;this.position=this.object3D.position;this.matrix=this.object3D.matrix;this.matrixWorld=this.object3D.matrixWorld;this.rotation.set(25*Math.PI/180,-30*Math.PI/180,0);this.rotationDelta=new THREE.Euler(.1*Math.PI/180,.15*Math.PI/180,0);this.cubelets=[];[[W,O,,,G],[W,O,,,,],[W,O,B,,,],[W,,,,G],[W,,,,,],[W,,B,,,],[W,,,R,G],[W,,,R,,],[W,,B,R,,],[,O,,,G],[,O,,,,],[,O,B,,,],[,,,,G],[,,,,,],[,,B,,,],[,,,R,G],[,,,R,,],[,,B,R,,],[,O,,,G,Y],[,O,,,,Y],[,O,B,,,Y],[,,,,G,Y],[,,,,,Y],[,,B,,,Y],[,,,R,G,Y],[,,,R,,Y],[,,B,R,,Y]].forEach(function(cubeletColorMap,cubeletId){this.cubelets.push(new ERNO.Cubelet(this,cubeletId,cubeletColorMap))}.bind(this));var i;this.core=new ERNO.Group;this.centers=new ERNO.Group;this.edges=new ERNO.Group;this.corners=new ERNO.Group;this.crosses=new ERNO.Group;this.cubelets.forEach(function(cubelet,index){if(cubelet.type==="core")this.core.add(cubelet);if(cubelet.type==="center")this.centers.add(cubelet);if(cubelet.type==="edge")this.edges.add(cubelet);if(cubelet.type==="corner")this.corners.add(cubelet);if(cubelet.type==="center"||cubelet.type==="edge")this.crosses.add(cubelet)}.bind(this));this.left=new ERNO.Slice([24,21,18,15,12,9,6,3,0],this);this.left.name="left";this.middle=new ERNO.Slice([25,22,19,16,13,10,7,4,1],this);this.middle.name="middle";this.right=new ERNO.Slice([2,11,20,5,14,23,8,17,26],this);this.right.name="right";this.right.neighbour=this.middle;this.left.neighbour=this.middle;this.up=new ERNO.Slice([18,19,20,9,10,11,0,1,2],this);this.up.name="up";this.equator=new ERNO.Slice([21,22,23,12,13,14,3,4,5],this);this.equator.name="equator";this.down=new ERNO.Slice([8,17,26,7,16,25,6,15,24],this);this.down.name="down";this.down.neighbour=this.equator;this.up.neighbour=this.equator;this.front=new ERNO.Slice([0,1,2,3,4,5,6,7,8],this);this.front.name="front";this.standing=new ERNO.Slice([9,10,11,12,13,14,15,16,17],this);this.standing.name="standing";this.back=new ERNO.Slice([26,23,20,25,22,19,24,21,18],this);this.back.name="back";this.back.neighbour=this.standing;this.front.neighbour=this.standing;this.faces=[this.front,this.up,this.right,this.down,this.left,this.back];this.slices=[this.left,this.middle,this.right,this.down,this.equator,this.up,this.back,this.standing,this.front];var onSliceRotated=function(evt){this.dispatchEvent(new CustomEvent("onTwistComplete",{detail:{slice:evt.target}}))}.bind(this);this.slices.forEach(function(slice){slice.addEventListener("change",onSliceRotated)});var allIndices=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26];this.slicesDictionary={f:this.front,s:this.standing,b:this.back,u:this.up,e:this.equator,d:this.down,r:this.right,m:this.middle,l:this.left,x:new ERNO.Slice(allIndices,this),y:new ERNO.Slice(allIndices,this),z:new ERNO.Slice(allIndices,this)};this.slicesDictionary.x.ableToHideInternalFaces=false;this.slicesDictionary.y.ableToHideInternalFaces=false;this.slicesDictionary.z.ableToHideInternalFaces=false;this.slicesDictionary.x.axis.set(-1,0,0);this.slicesDictionary.y.axis.set(0,-1,0);this.slicesDictionary.z.axis.set(0,0,-1);this.cubelets.forEach(function(cubelet,i){cubelet.setAddress(i)});this.renderer=renderFactory(this.cubelets,this);this.domElement=this.renderer.domElement;this.domElement.classList.add("cube");this.domElement.style.fontSize=this.cubeletSize+"px";this.autoRotateObj3D.add(this.object3D);if(this.hideInvisibleFaces)this.hideIntroverts(null,true);this.mouseInteraction=new ERNO.Interaction(this,this.camera,this.domElement);this.mouseInteraction.addEventListener("click",function(evt){this.dispatchEvent(new CustomEvent("click",{detail:evt.detail}))}.bind(this));this.controls=new(parameters.controls||ERNO.Controls)(this,this.camera,this.domElement);this.folds=[new ERNO.Fold(this.front,this.right),new ERNO.Fold(this.left,this.up),new ERNO.Fold(this.down,this.back)];this.setSize(400,200);this.loop=this.loop.bind(this);requestAnimationFrame(this.loop);document.addEventListener("keypress",function(event){if(event.target.tagName.toLowerCase()!=="input"&&event.target.tagName.toLowerCase()!=="textarea"&&!this.mouseInteraction.active&&this.keyboardControlsEnabled){var key=String.fromCharCode(event.which);if("XxRrMmLlYyUuEeDdZzFfSsBb".indexOf(key)>=0)this.twist(key);if(key=="q")this.undo();if(key=="Q")this.redo()}}.bind(this))};ERNO.Cube.prototype=Object.create(ERNO.Group.prototype);ERNO.Cube.prototype.constructor=ERNO.Cube;ERNO.extend(ERNO.Cube.prototype,{shuffle:function(amount,sequence){amount=amount||30;sequence=sequence||"";var moves=this.shuffleMethod.slice(),move,inverseOfLastMove=new ERNO.Twist,allowedMoves,sequenceLength=sequence.length,sequenceIndex=0;this.twistQueue.empty(true);this.historyQueue.empty(true);while(amount-- >0){if(sequence){move.set(sequence[sequenceIndex]);sequenceIndex=(sequenceIndex+1)%sequenceLength}else{allowedMoves=moves.split("");move=(new ERNO.Twist).copy(inverseOfLastMove);while(move.equals(inverseOfLastMove)){move.set(allowedMoves.splice(Math.floor(Math.random()*allowedMoves.length),1)[0])}}move.isShuffle=true;this.twist(move);inverseOfLastMove=move.getInverse()}this.finalShuffle=move},solve:function(){this.isSolving=true},isSolved:function(){return this.front.isSolved(ERNO.Direction.FRONT)&&this.up.isSolved(ERNO.Direction.UP)&&this.right.isSolved(ERNO.Direction.RIGHT)&&this.down.isSolved(ERNO.Direction.DOWN)&&this.left.isSolved(ERNO.Direction.LEFT)&&this.back.isSolved(ERNO.Direction.BACK)},undo:function(){if(this.twistQueue.history.length>0){this.historyQueue.add(this.twistQueue.undo().getInverse());this.undoing=true}},redo:function(){if(this.twistQueue.future.length>0){this.undoing=true;this.historyQueue.empty();this.historyQueue.add(this.twistQueue.redo())}},twist:function(command){if(this.undoing)this.twistQueue.empty();this.historyQueue.empty();this.undoing=false;this.twistQueue.add(command)},immediateTwist:function(twist){if(this.verbosity>=.8){console.log("Executing a twist command to rotate the "+twist.group+" "+twist.wise+" by",twist.degrees,"degrees.")}var slice=this.slicesDictionary[twist.command.toLowerCase()],rotation=(twist.degrees===undefined?90:twist.degrees)*twist.vector,radians=rotation.degreesToRadians(),duration=Math.abs(radians-slice.rotation)/(Math.PI*.5)*this.twistDuration;var l=slice.indices.length,cubelet;while(l-- >0){slice.getCubelet(l).isTweening=true}new TWEEN.Tween(slice).to({rotation:radians},duration).easing(TWEEN.Easing.Quartic.Out).onComplete(function(){slice.rotation=radians;slice.axis.rotation=0;l=slice.indices.length;while(l-- >0){cubelet=slice.getCubelet(l);cubelet.isTweening=false;cubelet.updateMatrix();cubelet.matrixSlice.copy(cubelet.matrix)}if(rotation!==0){slice.rotateGroupMappingOnAxis(radians);this.dispatchEvent(new CustomEvent("onTwistComplete",{detail:{slice:slice,twist:twist}}))}if(twist===this.finalShuffle){this.finalShuffle=null;this.dispatchEvent(new CustomEvent("onShuffleComplete",{detail:{slice:slice,twist:twist}}))}}.bind(this)).start(this.time)},getText:function(fold){if(fold===undefined){return[this.folds[0].getText(),this.folds[1].getText(),this.folds[2].getText()]}else if(_.isNumeric(fold)&&fold>=0&&fold<=2){return this.folds[fold].getText()}},setText:function(text,fold){if(fold===undefined){this.folds[0].setText(text);this.folds[1].setText(text);this.folds[2].setText(text)}else if(_.isNumeric(fold)&&fold>=0&&fold<=2){this.folds[fold].setText(text)}},setSize:function(width,height){this.camera.aspect=width/height;this.camera.updateProjectionMatrix();this.renderer.setSize(width,height)},PRESERVE_LOGO:"RrLlUuDdSsBb",ALL_SLICES:"RrMmLlUuEeDdFfSsBb",EVERYTHING:"XxRrMmLlYyUuEeDdZzFfSsBb",loop:function(){var time=0;return function(){requestAnimationFrame(this.loop);var localTime=typeof window!=="undefined"&&window.performance!==undefined&&window.performance.now!==undefined?window.performance.now():Date.now();var frameDelta=localTime-(time||localTime);time=localTime;if(!this.paused){this.time+=frameDelta;TWEEN.update(this.time);if(this.autoRotate){this.rotation.x+=this.rotationDelta.x;this.rotation.y+=this.rotationDelta.y;this.rotation.z+=this.rotationDelta.z}if(this.isReady&&this.isTweening()===0){var queue=this.undoing?this.historyQueue:this.twistQueue;if(queue.future.length===0){if(this.isSolving&&window.solver){this.isSolving=window.solver.consider(this)}else if(this.taskQueue.isReady===true){var task=this.taskQueue.do();if(task instanceof Function)task()}}else{var twist=queue.do();if(twist.command.toLowerCase()!=="x"&&twist.command.toLowerCase()!=="y"&&twist.command.toLowerCase()!=="z"&&twist.degrees!==0)this.moveCounter+=this.undoing?-1:1;if(twist.degrees===0||twist.isShuffle)queue.purge(twist);this.immediateTwist(twist)}}this.mouseInteraction.enabled=this.mouseControlsEnabled&&!this.finalShuffle;this.mouseInteraction.update();this.controls.enabled=this.mouseControlsEnabled&&!this.mouseInteraction.active;this.controls.update()}}}()});ERNO.Solver=function(){this.logic=function(cube){return false}};ERNO.Solver.prototype.consider=function(cube){if(cube===undefined){console.warn("A cube [Cube] argument must be specified for Solver.consider().");return false}else if(cube instanceof ERNO.Cube===false){console.warn("The cube argument provided is not a valid Cube.");return false}cube.isShuffling=false;if(cube.isSolved()){ERNO.Solver.prototype.explain("I’ve found that the cube is already solved.");return false}else return this.logic(cube)};ERNO.Solver.prototype.hint=function(text){console.log("%c"+text+"%c\n","background-color: #EEE; color: #333","")};ERNO.Solver.prototype.explain=function(text){console.log("Solver says: %c "+text+" %c\n","color: #080","")};window.ERNO=ERNO;window._=_;window.TWEEN=window.TWEEN||TWEEN;window.THREE=window.THREE||THREE})(); \ No newline at end of file