/*! * Original code from three.js project. https://github.com/mrdoob/three.js * Original code published with the following license: * * The MIT License * * Copyright © 2010-2014 three.js authors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ var Zia;!function(a){var b=function(){function a(a,b,c,d){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),this._x=a,this._y=b,this._z=c,this._w=d}return Object.defineProperty(a.prototype,"x",{get:function(){return this._x},set:function(a){this._x=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"y",{get:function(){return this._y},set:function(a){this._y=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"z",{get:function(){return this._z},set:function(a){this._z=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"w",{get:function(){return this._w},set:function(a){this._w=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),a.prototype.set=function(a,b,c,d){return this._x=a,this._y=b,this._z=c,this._w=d,this._onChangeCallback(),this},a.prototype.copy=function(a){return this._x=a._x,this._y=a._y,this._z=a._z,this._w=a._w,this._onChangeCallback(),this},a.createFromEuler=function(a,b){var c=Math.cos(a.x/2),d=Math.cos(a.y/2),e=Math.cos(a.z/2),f=Math.sin(a.x/2),g=Math.sin(a.y/2),h=Math.sin(a.z/2);return"XYZ"===a.order?(b._x=f*d*e+c*g*h,b._y=c*g*e-f*d*h,b._z=c*d*h+f*g*e,b._w=c*d*e-f*g*h):"YXZ"===a.order?(b._x=f*d*e+c*g*h,b._y=c*g*e-f*d*h,b._z=c*d*h-f*g*e,b._w=c*d*e+f*g*h):"ZXY"===a.order?(b._x=f*d*e-c*g*h,b._y=c*g*e+f*d*h,b._z=c*d*h+f*g*e,b._w=c*d*e-f*g*h):"ZYX"===a.order?(b._x=f*d*e-c*g*h,b._y=c*g*e+f*d*h,b._z=c*d*h-f*g*e,b._w=c*d*e+f*g*h):"YZX"===a.order?(b._x=f*d*e+c*g*h,b._y=c*g*e+f*d*h,b._z=c*d*h-f*g*e,b._w=c*d*e-f*g*h):"XZY"===a.order&&(b._x=f*d*e-c*g*h,b._y=c*g*e-f*d*h,b._z=c*d*h+f*g*e,b._w=c*d*e+f*g*h),b._onChangeCallback(),b},a.createFromAxisAngle=function(a,b,c){var d=b/2,e=Math.sin(d);return c._x=a.x*e,c._y=a.y*e,c._z=a.z*e,c._w=Math.cos(d),c._onChangeCallback(),c},a.createFromRotationMatrix=function(a,b){var c,d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],i=d[5],j=d[9],k=d[2],l=d[6],m=d[10],n=e+i+m;return n>0?(c=.5/Math.sqrt(n+1),b._w=.25/c,b._x=(l-j)*c,b._y=(g-k)*c,b._z=(h-f)*c):e>i&&e>m?(c=2*Math.sqrt(1+e-i-m),b._w=(l-j)/c,b._x=.25*c,b._y=(f+h)/c,b._z=(g+k)/c):i>m?(c=2*Math.sqrt(1+i-e-m),b._w=(g-k)/c,b._x=(f+h)/c,b._y=.25*c,b._z=(j+l)/c):(c=2*Math.sqrt(1+m-e-i),b._w=(h-f)/c,b._x=(g+k)/c,b._y=(j+l)/c,b._z=.25*c),b._onChangeCallback(),b},a.inverse=function(a,b){return b.copy(a),b.conjugate(),b.normalize(),b},a.prototype.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},a.prototype.lengthSquared=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},a.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},a.prototype.normalize=function(){var a=this.length();0===a?(this._x=0,this._y=0,this._z=0,this._w=1):(a=1/a,this._x=this._x*a,this._y=this._y*a,this._z=this._z*a,this._w=this._w*a),this._onChangeCallback()},a.multiply=function(a,b,c){var d=a._x,e=a._y,f=a._z,g=a._w,h=b._x,i=b._y,j=b._z,k=b._w;return c._x=d*k+g*h+e*j-f*i,c._y=e*k+g*i+f*h-d*j,c._z=f*k+g*j+d*i-e*h,c._w=g*k-d*h-e*i-f*j,c._onChangeCallback(),c},a.prototype.multiply=function(b){return a.multiply(this,b,this)},a.prototype.equals=function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},a.prototype.onChange=function(a){return this._onChangeCallback=a,this},a.prototype._onChangeCallback=function(){},a.prototype.suppressChangeCallback=function(a){var b=this._onChangeCallback;this._onChangeCallback=function(){},a(),this._onChangeCallback=b},a.prototype.clone=function(){return new a(this._x,this._y,this._z,this._w)},a.prototype.toJS=function(){return[this._x,this._y,this._z,this._w]},a.slerp=function(a,b,c,d){var e=a._x,f=a._y,g=a._z,h=a._w,i=h*b._w+e*b._x+f*b._y+g*b._z;if(0>i?(d._w=-b._w,d._x=-b._x,d._y=-b._y,d._z=-b._z,i=-i):d.copy(b),i>=1)return d._w=a.w,d._x=a.x,d._y=a.y,void(d._z=a.z);var j=Math.acos(i),k=Math.sqrt(1-i*i);if(Math.abs(k)<.001)return d._w=.5*(h+d._w),d._x=.5*(e+d._x),d._y=.5*(f+d._y),void(d._z=.5*(g+d._z));var l=Math.sin((1-c)*j)/k,m=Math.sin(c*j)/k;d._w=h*l+d._w*m,d._x=e*l+d._x*m,d._y=f*l+d._y*m,d._z=g*l+d._z*m,d._onChangeCallback()},a}();a.Quaternion=b}(Zia||(Zia={}));/*! * Original code from three.js project. https://github.com/mrdoob/three.js * Original code published with the following license: * * The MIT License * * Copyright © 2010-2014 three.js authors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ var Zia;!function(a){var b=function(){function b(a,b,c){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),this._x=a,this._y=b,this._z=c}return Object.defineProperty(b.prototype,"x",{get:function(){return this._x},set:function(a){this._x=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(a){this._y=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"z",{get:function(){return this._z},set:function(a){this._z=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),b.prototype.set=function(a,b,c){return this._x=a,this._y=b,this._z=c,this._onChangeCallback(),this},b.prototype.copy=function(a){return this._x=a._x,this._y=a._y,this._z=a._z,this._onChangeCallback(),this},b.prototype.add=function(a){return this._x+=a._x,this._y+=a._y,this._z+=a._z,this._onChangeCallback(),this},b.prototype.addScalar=function(a){return this._x+=a,this._y+=a,this._z+=a,this._onChangeCallback(),this},b.prototype.addVectors=function(a,b){return this._x=a._x+b._x,this._y=a._y+b._y,this._z=a._z+b._z,this._onChangeCallback(),this},b.prototype.sub=function(a){return this._x-=a._x,this._y-=a._y,this._z-=a._z,this._onChangeCallback(),this},b.prototype.subVectors=function(a,b){return this._x=a._x-b._x,this._y=a._y-b._y,this._z=a._z-b._z,this._onChangeCallback(),this},b.prototype.multiply=function(a){return this._x*=a._x,this._y*=a._y,this._z*=a._z,this._onChangeCallback(),this},b.prototype.multiplyScalar=function(a){return this._x*=a,this._y*=a,this._z*=a,this._onChangeCallback(),this},b.prototype.multiplyVectors=function(a,b){return this._x=a._x*b._x,this._y=a._y*b._y,this._z=a._z*b._z,this._onChangeCallback(),this},b.prototype.applyEuler=function(c){return a.Quaternion.createFromEuler(c,b._quaternionTemp),this.applyQuaternion(b._quaternionTemp),this},b.prototype.applyAxisAngle=function(c,d){return a.Quaternion.createFromAxisAngle(c,d,b._quaternionTemp),this.applyQuaternion(b._quaternionTemp),this},b.prototype.applyMatrix3=function(a){var b=this._x,c=this._y,d=this._z,e=a.elements;return this._x=e[0]*b+e[3]*c+e[6]*d,this._y=e[1]*b+e[4]*c+e[7]*d,this._z=e[2]*b+e[5]*c+e[8]*d,this._onChangeCallback(),this},b.prototype.applyMatrix4=function(a){var b=this._x,c=this._y,d=this._z,e=a.elements;return this._x=e[0]*b+e[4]*c+e[8]*d+e[12],this._y=e[1]*b+e[5]*c+e[9]*d+e[13],this._z=e[2]*b+e[6]*c+e[10]*d+e[14],this._onChangeCallback(),this},b.prototype.applyProjection=function(a){var b=this._x,c=this._y,d=this._z,e=a.elements,f=1/(e[3]*b+e[7]*c+e[11]*d+e[15]);return this._x=(e[0]*b+e[4]*c+e[8]*d+e[12])*f,this._y=(e[1]*b+e[5]*c+e[9]*d+e[13])*f,this._z=(e[2]*b+e[6]*c+e[10]*d+e[14])*f,this._onChangeCallback(),this},b.prototype.applyQuaternion=function(a){var b=this._x,c=this._y,d=this._z,e=a.x,f=a.y,g=a.z,h=a.w,i=h*b+f*d-g*c,j=h*c+g*b-e*d,k=h*d+e*c-f*b,l=-e*b-f*c-g*d;return this._x=i*h+l*-e+j*-g-k*-f,this._y=j*h+l*-f+k*-e-i*-g,this._z=k*h+l*-g+i*-f-j*-e,this._onChangeCallback(),this},b.prototype.transformDirection=function(a){var b=this._x,c=this._y,d=this._z,e=a.elements;return this._x=e[0]*b+e[4]*c+e[8]*d,this._y=e[1]*b+e[5]*c+e[9]*d,this._z=e[2]*b+e[6]*c+e[10]*d,this._onChangeCallback(),this.normalize(),this},b.prototype.divide=function(a){return this._x/=a._x,this._y/=a._y,this._z/=a._z,this._onChangeCallback(),this},b.prototype.divideScalar=function(a){if(0!==a){var b=1/a;this._x*=b,this._y*=b,this._z*=b}else this._x=0,this._y=0,this._z=0;return this._onChangeCallback(),this},b.prototype.min=function(a){return this._x>a._x&&(this._x=a._x),this._y>a._y&&(this._y=a._y),this._z>a._z&&(this._z=a._z),this._onChangeCallback(),this},b.prototype.max=function(a){return this._xb._x&&(this._x=b._x),this._yb._y&&(this._y=b._y),this._zb._z&&(this._z=b._z),this._onChangeCallback(),this},b.prototype.clampScalar=function(a,c){return b._clampScalarMinTemp.set(a,a,a),b._clampScalarMaxTemp.set(c,c,c),this.clamp(b._clampScalarMinTemp,b._clampScalarMaxTemp)},b.prototype.floor=function(){return this._x=Math.floor(this._x),this._y=Math.floor(this._y),this._z=Math.floor(this._z),this._onChangeCallback(),this},b.prototype.ceil=function(){return this._x=Math.ceil(this._x),this._y=Math.ceil(this._y),this._z=Math.ceil(this._z),this._onChangeCallback(),this},b.prototype.round=function(){return this._x=Math.round(this._x),this._y=Math.round(this._y),this._z=Math.round(this._z),this._onChangeCallback(),this},b.prototype.roundToZero=function(){return 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),this._onChangeCallback(),this},b.prototype.negate=function(){return this.multiplyScalar(-1)},b.prototype.nearEqual=function(b,c){return a.MathUtil.withinEpsilon(this._x,b._x,c._x)&&a.MathUtil.withinEpsilon(this._y,b._y,c._y)&&a.MathUtil.withinEpsilon(this._z,b._z,c._z)},b.prototype.dot=function(a){return this._x*a._x+this._y*a._y+this._z*a._z},b.prototype.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z},b.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)},b.prototype.normalize=function(){return this.divideScalar(this.length())},b.prototype.lerp=function(a,b){return this._x+=(a._x-this._x)*b,this._y+=(a._y-this._y)*b,this._z+=(a._z-this._z)*b,this._onChangeCallback(),this},b.prototype.cross=function(a){var b=this._x,c=this._y,d=this._z;return this._x=c*a._z-d*a._y,this._y=d*a._x-b*a._z,this._z=b*a._y-c*a._x,this._onChangeCallback(),this},b.prototype.crossVectors=function(a,b){var c=a._x,d=a._y,e=a._z,f=b._x,g=b._y,h=b._z;return this._x=d*h-e*g,this._y=e*f-c*h,this._z=c*g-d*f,this._onChangeCallback(),this},b.prototype.projectOnVector=function(a){b._projectOnVectorTemp.copy(a).normalize();var c=this.dot(b._projectOnVectorTemp);return this.copy(b._projectOnVectorTemp).multiplyScalar(c)},b.prototype.projectOnPlane=function(a){return b._projectOnPlaneTemp.copy(this).projectOnVector(a),this.sub(b._projectOnPlaneTemp)},b.prototype.reflect=function(a){return this.sub(b._reflectTemp.copy(a).multiplyScalar(2*this.dot(a)))},b.prototype.angleTo=function(b){var c=this.dot(b)/(this.length()*b.length());return Math.acos(a.MathUtil.clamp(c,-1,1))},b.prototype.distanceTo=function(a){return Math.sqrt(this.distanceToSquared(a))},b.prototype.distanceToSquared=function(a){var b=this._x-a._x,c=this._y-a._y,d=this._z-a._z;return b*b+c*c+d*d},b.prototype.setFromMatrixPosition=function(a){return this._x=a.elements[12],this._y=a.elements[13],this._z=a.elements[14],this._onChangeCallback(),this},b.prototype.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(),d=this.set(a.elements[8],a.elements[9],a.elements[10]).length();return this._x=b,this._y=c,this._z=d,this._onChangeCallback(),this},b.prototype.setFromMatrixColumn=function(a,b){var c=4*a,d=b.elements;return this._x=d[c],this._y=d[c+1],this._z=d[c+2],this._onChangeCallback(),this},b.prototype.equals=function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z},b.prototype.onChange=function(a){return this._onChangeCallback=a,this},b.prototype._onChangeCallback=function(){},b.prototype.suppressChangeCallback=function(a){var b=this._onChangeCallback;this._onChangeCallback=function(){},a(),this._onChangeCallback=b},b.prototype.clone=function(a){return a.set(this._x,this._y,this._z),a},b.prototype.toJS=function(){return[this._x,this._y,this._z]},b.prototype.toArray=function(){return this.toJS()},b.distance=function(c,d){return a.Vector3.subtract(c,d,b._distanceTemp),b._distanceTemp.length()},b.add=function(a,b,c){return c._x=a._x+b._x,c._y=a._y+b._y,c._z=a._z+b._z,c._onChangeCallback(),c},b.subtract=function(a,b,c){return c._x=a._x-b._x,c._y=a._y-b._y,c._z=a._z-b._z,c._onChangeCallback(),c},b.multiplyScalar=function(a,b,c){return c._x=a._x*b,c._y=a._y*b,c._z=a._z*b,c._onChangeCallback(),c},b.divideScalar=function(a,b,c){return c._x=a._x/b,c._y=a._y/b,c._z=a._z/b,c._onChangeCallback(),c},b.cross=function(a,b,c){var d=a._x,e=a._y,f=a._z;return c._x=e*b._z-f*b._y,c._y=f*b._x-d*b._z,c._z=d*b._y-e*b._x,c._onChangeCallback(),c},b._quaternionTemp=new a.Quaternion,b._clampScalarMinTemp=new b,b._clampScalarMaxTemp=new b,b._projectOnVectorTemp=new b,b._projectOnPlaneTemp=new b,b._reflectTemp=new b,b._distanceTemp=new b,b}();a.Vector3=b}(Zia||(Zia={}));var Zia;!function(a){var b=function(){function a(a,b,c,d){this.r=a,this.g=b,this.b=c,this.a=d}return a.prototype.copy=function(a){return this.r=a.r,this.g=a.g,this.b=a.b,this.a=a.a,this},a.prototype.multiplyScalar=function(a){return this.r*=a,this.g*=a,this.b*=a,this},a.prototype.toJS=function(){return[this.r,this.g,this.b,this.a]},a}();a.Color4=b}(Zia||(Zia={}));var Zia;!function(a){var b=function(){function b(a,c,d,e){void 0===a&&(a=0),void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=b.DefaultOrder),this._x=a,this._y=c,this._z=d,this._order=e}return Object.defineProperty(b.prototype,"x",{get:function(){return this._x},set:function(a){this._x=a,this.onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(a){this._y=a,this.onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"z",{get:function(){return this._z},set:function(a){this._z=a,this.onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"order",{get:function(){return this._order},set:function(a){this._order=a,this.onChangeCallback()},enumerable:!0,configurable:!0}),b.prototype.set=function(a,b,c,d){return this._x=a,this._y=b,this._z=c,this._order=d||this._order,this.onChangeCallback(),this},b.prototype.copy=function(a){return this._x=a._x,this._y=a._y,this._z=a._z,this._order=a._order,this.onChangeCallback(),this},b.prototype.setFromRotationMatrix=function(b,c){var d=a.MathUtil.clamp,e=b.elements,f=e[0],g=e[4],h=e[8],i=e[1],j=e[5],k=e[9],l=e[2],m=e[6],n=e[10];return c=c||this._order,"XYZ"===c?(this._y=Math.asin(d(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(-k,n),this._z=Math.atan2(-g,f)):(this._x=Math.atan2(m,j),this._z=0)):"YXZ"===c?(this._x=Math.asin(-d(k,-1,1)),Math.abs(k)<.99999?(this._y=Math.atan2(h,n),this._z=Math.atan2(i,j)):(this._y=Math.atan2(-l,f),this._z=0)):"ZXY"===c?(this._x=Math.asin(d(m,-1,1)),Math.abs(m)<.99999?(this._y=Math.atan2(-l,n),this._z=Math.atan2(-g,j)):(this._y=0,this._z=Math.atan2(i,f))):"ZYX"===c?(this._y=Math.asin(-d(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(m,n),this._z=Math.atan2(i,f)):(this._x=0,this._z=Math.atan2(-g,j))):"YZX"===c?(this._z=Math.asin(d(i,-1,1)),Math.abs(i)<.99999?(this._x=Math.atan2(-k,j),this._y=Math.atan2(-l,f)):(this._x=0,this._y=Math.atan2(h,n))):"XZY"===c?(this._z=Math.asin(-d(g,-1,1)),Math.abs(g)<.99999?(this._x=Math.atan2(m,j),this._y=Math.atan2(h,f)):(this._x=Math.atan2(-k,n),this._y=0)):console.warn("Zia.Euler: .setFromRotationMatrix() given unsupported order: "+c),this._order=c,this.onChangeCallback(),this},b.prototype.setFromQuaternion=function(b,c){var d=a.MathUtil.clamp,e=b.x*b.x,f=b.y*b.y,g=b.z*b.z,h=b.w*b.w;return c=c||this._order,"XYZ"===c?(this._x=Math.atan2(2*(b.x*b.w-b.y*b.z),h-e-f+g),this._y=Math.asin(d(2*(b.x*b.z+b.y*b.w),-1,1)),this._z=Math.atan2(2*(b.z*b.w-b.x*b.y),h+e-f-g)):"YXZ"===c?(this._x=Math.asin(d(2*(b.x*b.w-b.y*b.z),-1,1)),this._y=Math.atan2(2*(b.x*b.z+b.y*b.w),h-e-f+g),this._z=Math.atan2(2*(b.x*b.y+b.z*b.w),h-e+f-g)):"ZXY"===c?(this._x=Math.asin(d(2*(b.x*b.w+b.y*b.z),-1,1)),this._y=Math.atan2(2*(b.y*b.w-b.z*b.x),h-e-f+g),this._z=Math.atan2(2*(b.z*b.w-b.x*b.y),h-e+f-g)):"ZYX"===c?(this._x=Math.atan2(2*(b.x*b.w+b.z*b.y),h-e-f+g),this._y=Math.asin(d(2*(b.y*b.w-b.x*b.z),-1,1)),this._z=Math.atan2(2*(b.x*b.y+b.z*b.w),h+e-f-g)):"YZX"===c?(this._x=Math.atan2(2*(b.x*b.w-b.z*b.y),h-e+f-g),this._y=Math.atan2(2*(b.y*b.w-b.x*b.z),h+e-f-g),this._z=Math.asin(d(2*(b.x*b.y+b.z*b.w),-1,1))):"XZY"===c?(this._x=Math.atan2(2*(b.x*b.w+b.y*b.z),h-e+f-g),this._y=Math.atan2(2*(b.x*b.z+b.y*b.w),h+e-f-g),this._z=Math.asin(d(2*(b.z*b.w-b.x*b.y),-1,1))):console.warn("Zia.Euler: .setFromQuaternion() given unsupported order: "+c),this._order=c,this},b.prototype.reorder=function(c){a.Quaternion.createFromEuler(this,b._reorderTemp),this.setFromQuaternion(b._reorderTemp,c)},b.prototype.equals=function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},b.prototype.onChange=function(a){return this.onChangeCallback=a,this},b.prototype.onChangeCallback=function(){},b.prototype.clone=function(){return new b(this._x,this._y,this._z,this._order)},b.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],b.DefaultOrder="XYZ",b._reorderTemp=new a.Quaternion,b}();a.Euler=b}(Zia||(Zia={}));var Zia;!function(a){a.MathUtil={TWO_PI:2*Math.PI,PI_OVER_TWO:Math.PI/2,PI_OVER_FOUR:Math.PI/4,withinEpsilon:function(a,b,c){var d=a-b;return d>=-c&&c>=d},/*! Math.uuid.js (v1.4) http://www.broofa.com mailto:robert@broofa.com Copyright (c) 2010 Robert Kieffer Dual licensed under the MIT and GPL licenses. */ generateUUID:function(){var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");return function(b,c){var d,e=a,f=[];if(c=c||e.length,b)for(d=0;b>d;d++)f[d]=e[0|Math.random()*c];else{var g;for(f[8]=f[13]=f[18]=f[23]="-",f[14]="4",d=0;36>d;d++)f[d]||(g=0|16*Math.random(),f[d]=e[19==d?3&g|8:g])}return f.join("")}}(),clamp:function(a,b,c){return b>a?b:a>c?c:a},degToRad:function(){var a=Math.PI/180;return function(b){return b*a}}()}}(Zia||(Zia={}));/*! * Original code from three.js project. https://github.com/mrdoob/three.js * Original code published with the following license: * * The MIT License * * Copyright © 2010-2014 three.js authors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ var Zia;!function(a){var b=function(){function b(a,b,c,d,e,f,g,h,i){void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=1),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=0),void 0===i&&(i=1);var j=[a,d,g,b,e,h,c,f,i];this.elements=new Float32Array(j)}return b.prototype.set=function(a,b,c,d,e,f,g,h,i){var j=this.elements;return j[0]=a,j[3]=b,j[6]=c,j[1]=d,j[4]=e,j[7]=f,j[2]=g,j[5]=h,j[8]=i,this},b.createIdentity=function(a){return a.set(1,0,0,0,1,0,0,0,1),a},b.prototype.copy=function(a){var b=a.elements;return this.set(b[0],b[3],b[6],b[1],b[4],b[7],b[2],b[5],b[8]),this},b.prototype.multiplyScalar=function(a){var b=this.elements;return b[0]*=a,b[3]*=a,b[6]*=a,b[1]*=a,b[4]*=a,b[7]*=a,b[2]*=a,b[5]*=a,b[8]*=a,this},b.prototype.determinant=function(){var a=this.elements,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8];return b*f*j-b*g*i-c*e*j+c*g*h+d*e*i-d*f*h},b.prototype.getInverse=function(a,c){void 0===c&&(c=!1);var d=a.elements,e=this.elements;e[0]=d[10]*d[5]-d[6]*d[9],e[1]=-d[10]*d[1]+d[2]*d[9],e[2]=d[6]*d[1]-d[2]*d[5],e[3]=-d[10]*d[4]+d[6]*d[8],e[4]=d[10]*d[0]-d[2]*d[8],e[5]=-d[6]*d[0]+d[2]*d[4],e[6]=d[9]*d[4]-d[5]*d[8],e[7]=-d[9]*d[0]+d[1]*d[8],e[8]=d[5]*d[0]-d[1]*d[4];var f=d[0]*e[0]+d[1]*e[3]+d[2]*e[6];if(0===f){var g="Matrix3.getInverse(): can't invert matrix, determinant is 0";if(c)throw new Error(g);return console.warn(g),b.createIdentity(this),this}return this.multiplyScalar(1/f),this},b.prototype.transpose=function(){var a,b=this.elements;return a=b[1],b[1]=b[3],b[3]=a,a=b[2],b[2]=b[6],b[6]=a,a=b[5],b[5]=b[7],b[7]=a,this},b.prototype.getNormalMatrix=function(a){return this.getInverse(a).transpose(),this},b.prototype.clone=function(){var b=this.elements;return new a.Matrix3(b[0],b[3],b[6],b[1],b[4],b[7],b[2],b[5],b[8])},b}();a.Matrix3=b}(Zia||(Zia={}));/*! * Original code from three.js project. https://github.com/mrdoob/three.js * Original code published with the following license: * * The MIT License * * Copyright © 2010-2014 three.js authors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ var Zia;!function(a){var b=function(){function b(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=0),void 0===i&&(i=0),void 0===j&&(j=0),void 0===k&&(k=0),void 0===l&&(l=0),void 0===m&&(m=0),void 0===n&&(n=0),void 0===o&&(o=0),void 0===p&&(p=0);var q=[a,e,i,m,b,f,j,n,c,g,k,o,d,h,l,p];this.elements=new Float32Array(q)}return b.compose=function(a,c,d,e){return b.createFromQuaternion(c,e),e.multiply(b.createScale(a,b._composeTemp)),e.setTranslation(d),e},b.createTranslation=function(a,b){return b.set(1,0,0,a.x,0,1,0,a.y,0,0,1,a.z,0,0,0,1)},b.createRotationX=function(a,b){var c=Math.cos(a),d=Math.sin(a);return b.set(1,0,0,0,0,c,-d,0,0,d,c,0,0,0,0,1)},b.createRotationY=function(a,b){var c=Math.cos(a),d=Math.sin(a);return b.set(c,0,d,0,0,1,0,0,-d,0,c,0,0,0,0,1)},b.createRotationZ=function(a,b){var c=Math.cos(a),d=Math.sin(a);return b.set(c,-d,0,0,d,c,0,0,0,0,1,0,0,0,0,1)},b.createFromAxisAngle=function(a,b,c){var d=Math.cos(b),e=Math.sin(b),f=1-d,g=a.x,h=a.y,i=a.z,j=f*g,k=f*h;return c.set(j*g+d,j*h-e*i,j*i+e*h,0,j*h+e*i,k*h+d,k*i-e*g,0,j*i-e*h,k*i+e*g,f*i*i+d,0,0,0,0,1)},b.createFromQuaternion=function(a,b){var c=b.elements,d=a.x,e=a.y,f=a.z,g=a.w,h=d+d,i=e+e,j=f+f,k=d*h,l=d*i,m=d*j,n=e*i,o=e*j,p=f*j,q=g*h,r=g*i,s=g*j;return c[0]=1-(n+p),c[4]=l-s,c[8]=m+r,c[1]=l+s,c[5]=1-(k+p),c[9]=o-q,c[2]=m-r,c[6]=o+q,c[10]=1-(k+n),c[3]=0,c[7]=0,c[11]=0,c[12]=0,c[13]=0,c[14]=0,c[15]=1,b},b.createOrthographicOffCenter=function(a,b,c,d,e,f,g){var h=g.elements,i=b-a,j=d-c,k=f-e,l=(b+a)/i,m=(d+c)/j,n=(f+e)/k;return h[0]=2/i,h[4]=0,h[8]=0,h[12]=-l,h[1]=0,h[5]=2/j,h[9]=0,h[13]=-m,h[2]=0,h[6]=0,h[10]=-2/k,h[14]=-n,h[3]=0,h[7]=0,h[11]=0,h[15]=1,g},b.createPerspectiveOffCenter=function(a,b,c,d,e,f,g){var h=g.elements,i=2*e/(b-a),j=2*e/(d-c),k=(b+a)/(b-a),l=(d+c)/(d-c),m=-(f+e)/(f-e),n=-2*f*e/(f-e);return h[0]=i,h[4]=0,h[8]=k,h[12]=0,h[1]=0,h[5]=j,h[9]=l,h[13]=0,h[2]=0,h[6]=0,h[10]=m,h[14]=n,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,g},b.createPerspectiveFieldOfView=function(b,c,d,e,f){var g=d*Math.tan(.5*b),h=-g,i=h*c,j=g*c;return a.Matrix4.createPerspectiveOffCenter(i,j,h,g,d,e,f)},b.createScale=function(a,b){return b.set(a.x,0,0,0,0,a.y,0,0,0,0,a.z,0,0,0,0,1)},b.createUniformScale=function(a,b){return b.set(a,0,0,0,0,a,0,0,0,0,a,0,0,0,0,1)},b.createIdentity=function(a){return a.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},b.multiply=function(a,b,c){var d=a.elements,e=b.elements,f=c.elements,g=d[0],h=d[4],i=d[8],j=d[12],k=d[1],l=d[5],m=d[9],n=d[13],o=d[2],p=d[6],q=d[10],r=d[14],s=d[3],t=d[7],u=d[11],v=d[15],w=e[0],x=e[4],y=e[8],z=e[12],A=e[1],B=e[5],C=e[9],D=e[13],E=e[2],F=e[6],G=e[10],H=e[14],I=e[3],J=e[7],K=e[11],L=e[15];return f[0]=g*w+h*A+i*E+j*I,f[4]=g*x+h*B+i*F+j*J,f[8]=g*y+h*C+i*G+j*K,f[12]=g*z+h*D+i*H+j*L,f[1]=k*w+l*A+m*E+n*I,f[5]=k*x+l*B+m*F+n*J,f[9]=k*y+l*C+m*G+n*K,f[13]=k*z+l*D+m*H+n*L,f[2]=o*w+p*A+q*E+r*I,f[6]=o*x+p*B+q*F+r*J,f[10]=o*y+p*C+q*G+r*K,f[14]=o*z+p*D+q*H+r*L,f[3]=s*w+t*A+u*E+v*I,f[7]=s*x+t*B+u*F+v*J,f[11]=s*y+t*C+u*G+v*K,f[15]=s*z+t*D+u*H+v*L,c},b.multiplyByScalar=function(a,b,c){var d=a.elements,e=c.elements;return e[0]=d[0]*b,e[1]=d[1]*b,e[2]=d[2]*b,e[3]=d[3]*b,e[4]=d[4]*b,e[5]=d[5]*b,e[6]=d[6]*b,e[7]=d[7]*b,e[8]=d[8]*b,e[9]=d[9]*b,e[10]=d[10]*b,e[11]=d[11]*b,e[12]=d[12]*b,e[13]=d[13]*b,e[14]=d[14]*b,e[15]=d[15]*b,c},b.invert=function(b,c){var d=b.elements,e=c.elements,f=e[0],g=e[4],h=e[8],i=e[12],j=e[1],k=e[5],l=e[9],m=e[13],n=e[2],o=e[6],p=e[10],q=e[14],r=e[3],s=e[7],t=e[11],u=e[15];d[0]=l*q*s-m*p*s+m*o*t-k*q*t-l*o*u+k*p*u,d[4]=i*p*s-h*q*s-i*o*t+g*q*t+h*o*u-g*p*u,d[8]=h*m*s-i*l*s+i*k*t-g*m*t-h*k*u+g*l*u,d[12]=i*l*o-h*m*o-i*k*p+g*m*p+h*k*q-g*l*q,d[1]=m*p*r-l*q*r-m*n*t+j*q*t+l*n*u-j*p*u,d[5]=h*q*r-i*p*r+i*n*t-f*q*t-h*n*u+f*p*u,d[9]=i*l*r-h*m*r-i*j*t+f*m*t+h*j*u-f*l*u,d[13]=h*m*n-i*l*n+i*j*p-f*m*p-h*j*q+f*l*q,d[2]=k*q*r-m*o*r+m*n*s-j*q*s-k*n*u+j*o*u,d[6]=i*o*r-g*q*r-i*n*s+f*q*s+g*n*u-f*o*u,d[10]=g*m*r-i*k*r+i*j*s-f*m*s-g*j*u+f*k*u,d[14]=i*k*n-g*m*n-i*j*o+f*m*o+g*j*q-f*k*q,d[3]=l*o*r-k*p*r-l*n*s+j*p*s+k*n*t-j*o*t,d[7]=g*p*r-h*o*r+h*n*s-f*p*s-g*n*t+f*o*t,d[11]=h*k*r-g*l*r-h*j*s+f*l*s+g*j*t-f*k*t,d[15]=g*l*n-h*k*n+h*j*o-f*l*o-g*j*p+f*k*p;var v=f*d[0]+j*d[4]+n*d[8]+r*d[12];if(0===v)throw new Error("Can't invert matrix, determinant is 0");return a.Matrix4.multiplyByScalar(c,1/v,c),c},b.transpose=function(a,b){var c,d=a.elements,e=b.elements;return c=d[1],e[1]=d[4],e[4]=c,c=d[2],e[2]=d[8],e[8]=c,c=d[6],e[6]=d[9],e[9]=c,c=d[3],e[3]=d[12],e[12]=c,c=d[7],e[7]=d[13],e[13]=c,c=d[11],e[11]=d[14],e[14]=c,b},b.prototype.getTranslation=function(a){var b=this.elements;return a.x=b[12],a.y=b[13],a.z=b[14],a},b.prototype.setTranslation=function(a){var b=this.elements;b[12]=a.x,b[13]=a.y,b[14]=a.z},b.prototype.set=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){var q=this.elements;return q[0]=a,q[4]=b,q[8]=c,q[12]=d,q[1]=e,q[5]=f,q[9]=g,q[13]=h,q[2]=i,q[6]=j,q[10]=k,q[14]=l,q[3]=m,q[7]=n,q[11]=o,q[15]=p,this},b.prototype.makeRotationFromEuler=function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c),g=Math.sin(c),h=Math.cos(d),i=Math.sin(d),j=Math.cos(e),k=Math.sin(e);if("XYZ"===a.order){var l=f*j,m=f*k,n=g*j,o=g*k;b[0]=h*j,b[4]=-h*k,b[8]=i,b[1]=m+n*i,b[5]=l-o*i,b[9]=-g*h,b[2]=o-l*i,b[6]=n+m*i,b[10]=f*h}else if("YXZ"===a.order){var p=h*j,q=h*k,r=i*j,s=i*k;b[0]=p+s*g,b[4]=r*g-q,b[8]=f*i,b[1]=f*k,b[5]=f*j,b[9]=-g,b[2]=q*g-r,b[6]=s+p*g,b[10]=f*h}else if("ZXY"===a.order){var p=h*j,q=h*k,r=i*j,s=i*k;b[0]=p-s*g,b[4]=-f*k,b[8]=r+q*g,b[1]=q+r*g,b[5]=f*j,b[9]=s-p*g,b[2]=-f*i,b[6]=g,b[10]=f*h}else if("ZYX"===a.order){var l=f*j,m=f*k,n=g*j,o=g*k;b[0]=h*j,b[4]=n*i-m,b[8]=l*i+o,b[1]=h*k,b[5]=o*i+l,b[9]=m*i-n,b[2]=-i,b[6]=g*h,b[10]=f*h}else if("YZX"===a.order){var t=f*h,u=f*i,v=g*h,w=g*i;b[0]=h*j,b[4]=w-t*k,b[8]=v*k+u,b[1]=k,b[5]=f*j,b[9]=-g*j,b[2]=-i*j,b[6]=u*k+v,b[10]=t-w*k}else if("XZY"===a.order){var t=f*h,u=f*i,v=g*h,w=g*i;b[0]=h*j,b[4]=-k,b[8]=i*j,b[1]=t*k+w,b[5]=f*j,b[9]=u*k-v,b[2]=v*k-u,b[6]=g*j,b[10]=w*k+t}return b[3]=0,b[7]=0,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,this},b.prototype.multiply=function(b){return a.Matrix4.multiply(this,b,this)},b.prototype.determinant=function(){var a=this.elements,b=a[0],c=a[4],d=a[8],e=a[12],f=a[1],g=a[5],h=a[9],i=a[13],j=a[2],k=a[6],l=a[10],m=a[14],n=a[3],o=a[7],p=a[11],q=a[15];return n*(+e*h*k-d*i*k-e*g*l+c*i*l+d*g*m-c*h*m)+o*(+b*h*m-b*i*l+e*f*l-d*f*m+d*i*j-e*h*j)+p*(+b*i*k-b*g*m-e*f*k+c*f*m+e*g*j-c*i*j)+q*(-d*g*j-b*h*k+b*g*l+d*f*k-c*f*l+c*h*j)},b.prototype.clone=function(a){return a.elements.set(this.elements),a},b.prototype.decompose=function(c,d,e){var f=this.elements,g=b._decomposeVectorTemp,h=b._decomposeMatrixTemp,i=g.set(f[0],f[1],f[2]).length(),j=g.set(f[4],f[5],f[6]).length(),k=g.set(f[8],f[9],f[10]).length(),l=this.determinant();0>l&&(i=-i),e.x=f[12],e.y=f[13],e.z=f[14],h.elements.set(this.elements);var m=1/i,n=1/j,o=1/k;return h.elements[0]*=m,h.elements[1]*=m,h.elements[2]*=m,h.elements[4]*=n,h.elements[5]*=n,h.elements[6]*=n,h.elements[8]*=o,h.elements[9]*=o,h.elements[10]*=o,a.Quaternion.createFromRotationMatrix(h,d),c.x=i,c.y=j,c.z=k,!0},b._composeTemp=new b,b.createLookAt=function(){var b=new a.Vector3,c=new a.Vector3,d=new a.Vector3;return function(a,e,f,g){var h=g.elements;d.subVectors(a,e).normalize(),b.crossVectors(f,d).normalize(),c.crossVectors(d,b);var i=b.dot(a),j=c.dot(a),k=d.dot(a);return h[0]=b.x,h[4]=b.y,h[8]=b.z,h[12]=-i,h[1]=c.x,h[5]=c.y,h[9]=c.z,h[13]=-j,h[2]=d.x,h[6]=d.y,h[10]=d.z,h[14]=-k,h[3]=0,h[7]=0,h[11]=0,h[15]=1,g}}(),b._decomposeVectorTemp=new a.Vector3,b._decomposeMatrixTemp=new b,b}();a.Matrix4=b}(Zia||(Zia={}));/*! * Original code from three.js project. https://github.com/mrdoob/three.js * Original code published with the following license: * * The MIT License * * Copyright © 2010-2014 three.js authors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ var Zia;!function(a){var b=function(){function b(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this._x=a,this._y=b}return Object.defineProperty(b.prototype,"x",{get:function(){return this._x},set:function(a){this._x=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(a){this._y=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),b.prototype.set=function(a,b){return this._x=a,this._y=b,this._onChangeCallback(),this},b.prototype.copy=function(a){return this._x=a._x,this._y=a._y,this._onChangeCallback(),this},b.prototype.add=function(a){return this._x+=a._x,this._y+=a._y,this._onChangeCallback(),this},b.prototype.addVectors=function(a,b){return this._x=a._x+b._x,this._y=a._y+b._y,this._onChangeCallback(),this},b.prototype.addScalar=function(a){return this._x+=a,this._y+=a,this._onChangeCallback(),this},b.prototype.sub=function(a){return this._x-=a._x,this._y-=a._y,this._onChangeCallback(),this},b.prototype.subVectors=function(a,b){return this._x=a._x-b._x,this._y=a._y-b._y,this._onChangeCallback(),this},b.prototype.multiply=function(a){return this._x*=a._x,this._y*=a._y,this._onChangeCallback(),this},b.prototype.multiplyScalar=function(a){return this._x*=a,this._y*=a,this._onChangeCallback(),this},b.prototype.divide=function(a){return this._x/=a._x,this._y/=a._y,this._onChangeCallback(),this},b.prototype.divideScalar=function(a){if(0!==a){var b=1/a;this._x*=b,this._y*=b}else this._x=0,this._y=0;return this._onChangeCallback(),this},b.prototype.min=function(a){return this._x>a._x&&(this._x=a._x),this._y>a._y&&(this._y=a._y),this._onChangeCallback(),this},b.prototype.max=function(a){return this._xb._x&&(this._x=b._x),this._yb._y&&(this._y=b._y),this._onChangeCallback(),this},b.prototype.clampScalar=function(a,c){return b._clampScalarMinTemp.set(a,a),b._clampScalarMaxTemp.set(c,c),this.clamp(b._clampScalarMinTemp,b._clampScalarMaxTemp)},b.prototype.floor=function(){return this._x=Math.floor(this._x),this._y=Math.floor(this._y),this._onChangeCallback(),this},b.prototype.ceil=function(){return this._x=Math.ceil(this._x),this._y=Math.ceil(this._y),this._onChangeCallback(),this},b.prototype.round=function(){return this._x=Math.round(this._x),this._y=Math.round(this._y),this._onChangeCallback(),this},b.prototype.roundToZero=function(){return 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._onChangeCallback(),this},b.prototype.negate=function(){return this.multiplyScalar(-1)},b.prototype.dot=function(a){return this._x*a._x+this._y*a._y},b.prototype.lengthSq=function(){return this._x*this._x+this._y*this._y},b.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y)},b.prototype.normalize=function(){return this.divideScalar(this.length())},b.prototype.distanceTo=function(a){return Math.sqrt(this.distanceToSquared(a))},b.prototype.distanceToSquared=function(a){var b=this._x-a._x,c=this._y-a._y;return b*b+c*c},b.prototype.setLength=function(a){var b=this.length();return 0!==b&&a!==b&&this.multiplyScalar(a/b),this},b.prototype.lerp=function(a,b){return this._x+=(a._x-this._x)*b,this._y+=(a._y-this._y)*b,this._onChangeCallback(),this},b.prototype.equals=function(a){return a._x===this._x&&a._y===this._y},b.prototype.onChange=function(a){return this._onChangeCallback=a,this},b.prototype._onChangeCallback=function(){},b.prototype.clone=function(){return new a.Vector2(this._x,this._y)},b.prototype.toJS=function(){return[this._x,this._y]},b.prototype.toArray=function(){return this.toJS()},b._clampScalarMinTemp=new b,b._clampScalarMaxTemp=new b,b}();a.Vector2=b}(Zia||(Zia={}));/*! * Original code from three.js project. https://github.com/mrdoob/three.js * Original code published with the following license: * * The MIT License * * Copyright © 2010-2014 three.js authors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ var Zia;!function(a){var b=function(){function b(a,b,c,d){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),this._x=a,this._y=b,this._z=c,this._w=d}return Object.defineProperty(b.prototype,"x",{get:function(){return this._x},set:function(a){this._x=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(a){this._y=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"z",{get:function(){return this._z},set:function(a){this._z=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"w",{get:function(){return this._w},set:function(a){this._w=a,this._onChangeCallback()},enumerable:!0,configurable:!0}),b.prototype.set=function(a,b,c,d){return this._x=a,this._y=b,this._z=c,this._w=d,this._onChangeCallback(),this},b.prototype.copy=function(a){return this._x=a._x,this._y=a._y,this._z=a._z,this._w=void 0!==a._w?a._w:1,this._onChangeCallback(),this},b.prototype.add=function(a){return this._x+=a._x,this._y+=a._y,this._z+=a._z,this._w+=a._w,this._onChangeCallback(),this},b.prototype.addScalar=function(a){return this._x+=a,this._y+=a,this._z+=a,this._w+=a,this._onChangeCallback(),this},b.prototype.addVectors=function(a,b){return this._x=a._x+b._x,this._y=a._y+b._y,this._z=a._z+b._z,this._w=a._w+b._w,this._onChangeCallback(),this},b.prototype.sub=function(a){return this._x-=a._x,this._y-=a._y,this._z-=a._z,this._w-=a._w,this._onChangeCallback(),this},b.prototype.subVectors=function(a,b){return this._x=a._x-b._x,this._y=a._y-b._y,this._z=a._z-b._z,this._w=a._w-b._w,this._onChangeCallback(),this},b.prototype.multiplyScalar=function(a){return this._x*=a,this._y*=a,this._z*=a,this._w*=a,this._onChangeCallback(),this},b.prototype.applyMatrix4=function(a){var b=this._x,c=this._y,d=this._z,e=this._w,f=a.elements;return this._x=f[0]*b+f[4]*c+f[8]*d+f[12]*e,this._y=f[1]*b+f[5]*c+f[9]*d+f[13]*e,this._z=f[2]*b+f[6]*c+f[10]*d+f[14]*e,this._w=f[3]*b+f[7]*c+f[11]*d+f[15]*e,this._onChangeCallback(),this},b.prototype.divideScalar=function(a){if(0!==a){var b=1/a;this._x*=b,this._y*=b,this._z*=b,this._w*=b}else this._x=0,this._y=0,this._z=0,this._w=1;return this._onChangeCallback(),this},b.prototype.setAxisAngleFromQuaternion=function(a){this._w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);return 1e-4>b?(this._x=1,this._y=0,this._z=0):(this._x=a.x/b,this._y=a.y/b,this._z=a.z/b),this._onChangeCallback(),this},b.prototype.setAxisAngleFromRotationMatrix=function(a){var b,c,d,e,f=.01,g=.1,h=a.elements,i=h[0],j=h[4],k=h[8],l=h[1],m=h[5],n=h[9],o=h[2],p=h[6],q=h[10];if(Math.abs(j-l)s&&r>t?f>r?(c=0,d=.707106781,e=.707106781):(c=Math.sqrt(r),d=u/c,e=v/c):s>t?f>s?(c=.707106781,d=0,e=.707106781):(d=Math.sqrt(s),c=u/d,e=w/d):f>t?(c=.707106781,d=.707106781,e=0):(e=Math.sqrt(t),c=v/e,d=w/e),this.set(c,d,e,b),this}var x=Math.sqrt((p-n)*(p-n)+(k-o)*(k-o)+(l-j)*(l-j));return Math.abs(x)<.001&&(x=1),this._x=(p-n)/x,this._y=(k-o)/x,this._z=(l-j)/x,this._w=Math.acos((i+m+q-1)/2),this._onChangeCallback(),this},b.prototype.min=function(a){return this._x>a._x&&(this._x=a._x),this._y>a._y&&(this._y=a._y),this._z>a._z&&(this._z=a._z),this._w>a._w&&(this._w=a._w),this._onChangeCallback(),this},b.prototype.max=function(a){return this._xb._x&&(this._x=b._x),this._yb._y&&(this._y=b._y),this._zb._z&&(this._z=b._z),this._wb._w&&(this._w=b._w),this._onChangeCallback(),this},b.prototype.clampScalar=function(c,d){return void 0===b._min&&(b._min=new a.Vector4,b._max=new a.Vector4),b._min.set(c,c,c,c),b._max.set(d,d,d,d),this.clamp(b._min,b._max)},b.prototype.floor=function(){return this._x=Math.floor(this._x),this._y=Math.floor(this._y),this._z=Math.floor(this._z),this._w=Math.floor(this._w),this._onChangeCallback(),this},b.prototype.ceil=function(){return this._x=Math.ceil(this._x),this._y=Math.ceil(this._y),this._z=Math.ceil(this._z),this._w=Math.ceil(this._w),this._onChangeCallback(),this},b.prototype.round=function(){return this._x=Math.round(this._x),this._y=Math.round(this._y),this._z=Math.round(this._z),this._w=Math.round(this._w),this._onChangeCallback(),this},b.prototype.roundToZero=function(){return 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),this._w=this._w<0?Math.ceil(this._w):Math.floor(this._w),this._onChangeCallback(),this},b.prototype.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onChangeCallback(),this},b.prototype.dot=function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},b.prototype.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},b.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},b.prototype.lengthManhattan=function(){return Math.abs(this._x)+Math.abs(this._y)+Math.abs(this._z)+Math.abs(this._w)},b.prototype.normalize=function(){return this.divideScalar(this.length())},b.prototype.lerp=function(a,b){return this._x+=(a._x-this._x)*b,this._y+=(a._y-this._y)*b,this._z+=(a._z-this._z)*b,this._w+=(a._w-this._w)*b,this._onChangeCallback(),this},b.prototype.equals=function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},b.prototype.clone=function(){return new a.Vector4(this._x,this._y,this._z,this._w)},b.prototype.onChange=function(a){return this._onChangeCallback=a,this},b.prototype._onChangeCallback=function(){},b.prototype.suppressChangeCallback=function(a){var b=this._onChangeCallback;this._onChangeCallback=function(){},a(),this._onChangeCallback=b},b}();a.Vector4=b}(Zia||(Zia={}));var Zia;!function(a){var b;!function(b){function c(){for(var a=[],b=0;be;e++)for(var f=0;fg;g++){var h=a.getActiveUniform(b,g);d.uniforms.push(c(h,a.getUniformLocation(b,h.name)))}for(var g=0;f>g;g++){var i=a.getActiveAttrib(b,g);d.attributes.push(c(i,a.getAttribLocation(b,i.name)))}for(var j=0,g=0;g0&&(this.graphicsDevice.setVertexBuffer(c.vertexBuffer),this.graphicsDevice.setIndexBuffer(c.indexBuffer),d.apply(),this.graphicsDevice.drawIndexedPrimitives(4,c.startIndex,c.indexCount))}},a}();a.ModelMesh=b}(Zia||(Zia={}));var Zia;!function(a){var b=function(){function b(b){b=a.ObjectUtil.reverseMerge(b||{},{indexBuffer:null,startIndex:0,indexCount:0,vertexBuffer:null}),this.indexBuffer=b.indexBuffer,this.startIndex=b.startIndex,this.indexCount=b.indexCount,this.vertexBuffer=b.vertexBuffer,this._program=null,this._parent=null}return Object.defineProperty(b.prototype,"program",{get:function(){return this._program},set:function(a){if(a!==this._program){if(this._program){for(var b=!0,c=0;c=0&&this._parent.programs.splice(e,1)}}this._program=a,this._parent.programs.push(a)}},enumerable:!0,configurable:!0}),b}();a.ModelMeshPart=b}(Zia||(Zia={}));var Zia;!function(a){!function(a){a[a.Back=0]="Back",a[a.Front=1]="Front",a[a.FrontAndBack=2]="FrontAndBack",a[a.None=3]="None"}(a.CullMode||(a.CullMode={}));var b=a.CullMode,c=function(){function c(b){b=a.ObjectUtil.reverseMerge(b||{},{cullMode:a.CullMode.Back,isFrontClockwise:!1,isPolygonOffsetEnabled:!1,polygonOffsetFactor:0,polygonOffsetUnits:0}),this.cullMode=b.cullMode,this.isFrontClockwise=b.isFrontClockwise,this.isPolygonOffsetEnabled=b.isPolygonOffsetEnabled,this.polygonOffsetFactor=b.polygonOffsetFactor,this.polygonOffsetUnits=b.polygonOffsetUnits}return c.prototype._apply=function(a){switch(this.cullMode){case b.Back:a.enable(a.CULL_FACE),a.cullFace(a.BACK);break;case b.Front:a.enable(a.CULL_FACE),a.cullFace(a.FRONT);break;case b.FrontAndBack:a.enable(a.CULL_FACE),a.cullFace(a.FRONT_AND_BACK);break;case b.None:a.disable(a.CULL_FACE)}a.frontFace(this.isFrontClockwise?a.CW:a.CCW),this.isPolygonOffsetEnabled?(a.enable(a.POLYGON_OFFSET_FILL),a.polygonOffset(this.polygonOffsetFactor,this.polygonOffsetUnits)):a.disable(a.POLYGON_OFFSET_FILL)},c}();a.RasterizerState=c}(Zia||(Zia={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Zia;!function(a){var b=function(){function a(a,b,c){var d=this._gl=a.gl,e=d.createShader(b);if(d.shaderSource(e,c),d.compileShader(e),!d.getShaderParameter(e,d.COMPILE_STATUS)){var f=d.getShaderInfoLog(e);throw d.deleteShader(e),new Error("Failed to compile shader: "+f)}this.shader=e}return a.prototype.destroy=function(){this._gl.deleteShader(this.shader)},a}();a.Shader=b;var c=function(a){function b(b,c){a.call(this,b,b.gl.FRAGMENT_SHADER,c)}return __extends(b,a),b}(b);a.FragmentShader=c;var d=function(a){function b(b,c){a.call(this,b,b.gl.VERTEX_SHADER,c)}return __extends(b,a),b}(b);a.VertexShader=d}(Zia||(Zia={}));var Zia;!function(a){var b=function(){function b(b,c,d){var e=this._gl=b.gl;this._texture=this._gl.createTexture(),this._textureType=d,this._options=a.ObjectUtil.reverseMerge(c||{},{filter:3,wrapS:0,wrapT:0}),e.bindTexture(d,this._texture),e.texParameteri(d,e.TEXTURE_WRAP_S,a.TextureWrapUtil._map(e,this._options.wrapS)),e.texParameteri(d,e.TEXTURE_WRAP_T,a.TextureWrapUtil._map(e,this._options.wrapT));var f=a.TextureFilterUtil._map(e,this._options.filter);e.texParameteri(d,e.TEXTURE_MIN_FILTER,f[0]),e.texParameteri(d,e.TEXTURE_MAG_FILTER,f[1]),e.bindTexture(d,null)}return b.prototype._setData=function(a,b){var c=this._gl,d=this._textureType;c.activeTexture(c.TEXTURE0),c.bindTexture(d,this._texture),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,b),a(c),c.bindTexture(d,null)},b.prototype._generateMipmap=function(){var a=this._gl,b=this._textureType;a.activeTexture(a.TEXTURE0),a.bindTexture(b,this._texture),a.generateMipmap(b),a.bindTexture(b,null)},b.prototype.destroy=function(){this._gl.deleteTexture(this._texture)},b}();a.Texture=b}(Zia||(Zia={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Zia;!function(a){var b=function(b){function c(a,c){b.call(this,a,c,a.gl.TEXTURE_2D)}return __extends(c,b),c.prototype.setData=function(a){var b=this.width,c=this.height;this._setData(function(d){d.texImage2D(d.TEXTURE_2D,0,d.RGBA,b,c,0,d.RGBA,d.UNSIGNED_BYTE,a)},!0),this._generateMipmap()},c.createFromImagePath=function(b,c,d){var e=new a.Texture2D(b,d),f=b.gl;e.width=1,e.height=1,e.setData(new Uint8Array([255,255,255,255]));var g=new Image;return g.onload=function(){e._setData(function(){f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,g)},!0),e._generateMipmap(),e.width=g.naturalWidth,e.height=g.naturalHeight},g.src=c,e},c.createFromImageData=function(b,c,d,e,f){var g=new a.Texture2D(b,f);g.width=d,g.height=e;b.gl;return g.setData(c),g},c.createWhiteTexture=function(a){var b=new Uint8Array([255,255,255,255]);return c.createFromImageData(a,b,1,1)},c}(a.Texture);a.Texture2D=b}(Zia||(Zia={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Zia;!function(a){a.CubeMapFaceUtil={_map:function(a,b){switch(b){case 1:return a.TEXTURE_CUBE_MAP_NEGATIVE_X;case 3:return a.TEXTURE_CUBE_MAP_NEGATIVE_Y;case 5:return a.TEXTURE_CUBE_MAP_NEGATIVE_Z;case 0:return a.TEXTURE_CUBE_MAP_POSITIVE_X;case 2:return a.TEXTURE_CUBE_MAP_POSITIVE_Y;case 4:return a.TEXTURE_CUBE_MAP_POSITIVE_Z;default:throw"Invalid face: "+b}}};var b=function(b){function c(a,c){b.call(this,a,c,a.gl.TEXTURE_CUBE_MAP)}return __extends(c,b),c.prototype.setData=function(b,c){var d=this.size;this._setData(function(e){e.texImage2D(a.CubeMapFaceUtil._map(e,b),0,e.RGBA,d,d,0,e.RGBA,e.UNSIGNED_BYTE,c)},!1)},c.createFromImagePaths=function(b,c,d){if(6!==c.length)throw"Must pass an array of 6 URLs";var e=new a.TextureCube(b,d);e.size=1;for(var f=new Uint8Array([255,255,255,255]),g=0;6>g;g++)e.setData(g,f);for(var h=b.gl,i=0,g=0;gl;l++){var m=e[l],n=l>=4?new a.Vector3(0,0,1):new a.Vector3(0,1,0);g.set(m.x,m.y,m.z),a.Vector3.cross(g,n,g),h.set(m.x,m.y,m.z),a.Vector3.cross(h,g,h);var o=4*l;k.push(o+0),k.push(o+2),k.push(o+1),k.push(o+0),k.push(o+3),k.push(o+2),c.push(m.clone(new a.Vector3).sub(g).sub(h).multiplyScalar(b)),c.push(m.clone(new a.Vector3).sub(g).add(h).multiplyScalar(b)),c.push(m.clone(new a.Vector3).add(g).add(h).multiplyScalar(b)),c.push(m.clone(new a.Vector3).add(g).sub(h).multiplyScalar(b)),i.push(m),i.push(m),i.push(m),i.push(m),j.push(f[0]),j.push(f[1]),j.push(f[2]),j.push(f[3])}return{positions:c,normals:i,textureCoordinates:j,indices:k}}var d=6,e=[new a.Vector3(0,0,1),new a.Vector3(0,0,-1),new a.Vector3(1,0,0),new a.Vector3(-1,0,0),new a.Vector3(0,1,0),new a.Vector3(0,-1,0)],f=[new a.Vector2(1,1),new a.Vector2(1,0),new a.Vector2(0,0),new a.Vector2(0,1)],g=new a.Vector3,h=new a.Vector3;b.createCube=c}(b=a.GeometricPrimitive||(a.GeometricPrimitive={}))}(Zia||(Zia={}));var Zia;!function(a){var b;!function(b){function c(b,c){var d=2*b*Math.PI/c,e=Math.sin(d),f=Math.cos(d);return new a.Vector3(e,0,f)}function d(b,d,e,g,h,i,j,k){for(var l=0;h-2>l;l++){var m=(l+1)%h,n=(l+2)%h;k&&(n=[m,m=n][0]);var o=b.length;g.push(o),g.push(o+n),g.push(o+m)}var p=new a.Vector3(0,1,0),q=new a.Vector2(-.5,-.5);k||(p.negate(),q.x=-q.x);for(var l=0;h>l;l++){var r=c(l,h),s=r.clone(new a.Vector3).multiplyScalar(j);f.set(p.x,p.y,p.z),f.multiplyScalar(i),s.add(f),b.push(s),d.push(p),e.push(new a.Vector2(r.x*q.x+.5,1-r.z*q.y+.5))}}function e(b,e,f){if(void 0===b&&(b=1),void 0===e&&(e=1),void 0===f&&(f=32),3>f)throw"tessellation must be >= 3";var h=[],i=[],j=[],k=[];b/=2;for(var l=new a.Vector3(0,1,0).multiplyScalar(b),m=e/2,n=f+1,o=0;f>=o;o++){var p=c(o,f),q=p.clone(new a.Vector3).multiplyScalar(m),r=new a.Vector2(o/f,1);h.push(q.clone(new a.Vector3).add(l)),i.push(p),j.push(r),h.push(q.clone(new a.Vector3).sub(l)),i.push(p),j.push(r.clone().sub(g)),k.push(2*o),k.push(2*o+1),k.push((2*o+2)%(2*n)),k.push(2*o+1),k.push((2*o+3)%(2*n)),k.push((2*o+2)%(2*n))}return d(h,i,j,k,f,b,m,!0),d(h,i,j,k,f,b,m,!1),{positions:h,normals:i,textureCoordinates:j,indices:k}}var f=new a.Vector3,g=new a.Vector2(0,1);b.createCylinder=e}(b=a.GeometricPrimitive||(a.GeometricPrimitive={}))}(Zia||(Zia={}));var Zia;!function(a){var b;!function(b){function c(b,c,d,e){if(void 0===b&&(b=1),void 0===c&&(c=1),void 0===d&&(d=1),void 0===e&&(e=new a.Vector2(1,1)),1>d)throw"tessellation must be > 0";var f=d+1,g=new Array(f*f),h=new Array(f*f),i=new Array(f*f),j=new Array(d*d*6),k=b/d,l=c/d;b/=2,c/=2;for(var m=new a.Vector3(0,1,0),n=0,o=0;d+1>o;o++)for(var p=0;d+1>p;p++)g[n]=new a.Vector3(-b+k*p,0,c-l*o),h[n]=m,i[n]=new a.Vector2(1-1*p/d*e.x,1-1*o/d*e.y),n++;for(var q=0,o=0;d>o;o++)for(var p=0;d>p;p++){var r=f*o+p;j[q++]=r+1,j[q++]=r+1+f,j[q++]=r+f,j[q++]=r+1,j[q++]=r+f,j[q++]=r}return{positions:g,normals:h,textureCoordinates:i,indices:j}}b.createPlane=c}(b=a.GeometricPrimitive||(a.GeometricPrimitive={}))}(Zia||(Zia={}));var Zia;!function(a){var b;!function(b){function c(b,c){if(void 0===b&&(b=1),void 0===c&&(c=16),3>c)throw"tessellation must be >= 3";for(var d=c,e=2*c,f=new Array((d+1)*(e+1)),g=new Array((d+1)*(e+1)),h=new Array((d+1)*(e+1)),i=new Array(d*(e+1)*6),j=b/2,k=0,l=0;d>=l;l++)for(var m=1-l/d,n=l*Math.PI/d-Math.PI/2,o=Math.sin(n),p=Math.cos(n),q=0;e>=q;q++){var r=q/e,s=2*q*Math.PI/e,t=Math.sin(s),u=Math.cos(s);t*=p,u*=p;var v=new a.Vector3(t,o,u),w=new a.Vector2(r,1-m);f[k]=v.clone(new a.Vector3).multiplyScalar(j),g[k]=v,h[k]=w,k++}for(var x=e+1,y=0,l=0;d>l;l++)for(var q=0;e>=q;q++){var z=l+1,A=(q+1)%x; i[y++]=l*x+q,i[y++]=l*x+A,i[y++]=z*x+q,i[y++]=l*x+A,i[y++]=z*x+A,i[y++]=z*x+q}return{positions:f,normals:g,textureCoordinates:h,indices:i}}b.createSphere=c}(b=a.GeometricPrimitive||(a.GeometricPrimitive={}))}(Zia||(Zia={}));var Zia;!function(a){var b;!function(b){function c(a,b,c){for(var d=a+1,e=new Array(6),f=[],g=0;a>g;g++)for(var h=0;a>h;h++){e[0]=c+g*d+h,e[2]=c+(g+1)*d+h,e[1]=c+(g+1)*d+h+1,e[3]=c+g*d+h,e[5]=c+(g+1)*d+h+1,e[4]=c+g*d+h+1,b&&e.reverse();for(var i=0;i=j;j++)for(var k=j/c,l=0;c>=l;l++){var m=l/c,n=d(b[0],b[1],b[2],b[3],k),o=d(b[4],b[5],b[6],b[7],k),p=d(b[8],b[9],b[10],b[11],k),q=d(b[12],b[13],b[14],b[15],k),r=d(n,o,p,q,m),s=d(b[0],b[4],b[8],b[12],m),t=d(b[1],b[5],b[9],b[13],m),u=d(b[2],b[6],b[10],b[14],m),v=d(b[3],b[7],b[11],b[15],m),w=e(n,o,p,q,m),x=e(s,t,u,v,k),y=(new a.Vector3).crossVectors(w,x);y.nearEqual(new a.Vector3,new a.Vector3(1e-7))?(y.x=0,y.y=r.y<0?-1:1,y.z=0):(y.normalize(),f&&y.negate());var z=f?1-k:k,A=new a.Vector2(z,1-m);g.push(r),h.push(y),i.push(A)}}function g(b,d,e,g,h,i,j,l){for(var m=new Array(16),n=0;16>n;n++)m[n]=k[h.indices[n]].clone(new a.Vector3).multiply(j);var o=b.length;Array.prototype.push.apply(g,c(i,l,o)),f(m,i,l,b,d,e)}function h(b,c){if(void 0===b&&(b=1),void 0===c&&(c=8),1>c)throw"tessellation must be > 0";var d=[],e=[],f=[],h=[],i=new a.Vector3(b,b,b),k=i.clone(new a.Vector3);k.x=-k.x;var l=i.clone(new a.Vector3);l.z=-l.z;for(var m=new a.Vector3(-b,b,-b),n=0;nd)throw"tessellation parameter out of range";for(var e=[],f=[],g=[],h=[],i=d+1,j=a.Matrix4.createTranslation(new a.Vector3(b/2,0,0),new a.Matrix4),k=new a.Matrix4,l=0;d>=l;l++){var m=l/d,n=l*a.MathUtil.TWO_PI/d-a.MathUtil.PI_OVER_TWO;a.Matrix4.createRotationY(n,k).multiply(j);for(var o=0;d>=o;o++){var p=1-o/d,q=o*a.MathUtil.TWO_PI/d+Math.PI,r=Math.cos(q),s=Math.sin(q),t=new a.Vector3(r,s,0),u=t.clone(new a.Vector3).multiplyScalar(c/2),v=new a.Vector2(m,1-p);u.applyMatrix4(k),t.transformDirection(k),e.push(u),f.push(t),g.push(v);var w=(l+1)%i,x=(o+1)%i;h.push(l*i+o),h.push(w*i+o),h.push(l*i+x),h.push(l*i+x),h.push(w*i+o),h.push(w*i+x)}}return{positions:e,normals:f,textureCoordinates:g,indices:h}}b.createTorus=c}(b=a.GeometricPrimitive||(a.GeometricPrimitive={}))}(Zia||(Zia={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Zia;!function(a){function b(b){b.push("uniform vec3 uDirLight0Direction;"),b.push("uniform vec3 uDirLight0DiffuseColor;"),b.push("uniform vec3 uDirLight0SpecularColor;"),b.push("uniform vec3 uDirLight1Direction;"),b.push("uniform vec3 uDirLight1DiffuseColor;"),b.push("uniform vec3 uDirLight1SpecularColor;"),b.push("uniform vec3 uDirLight2Direction;"),b.push("uniform vec3 uDirLight2DiffuseColor;"),b.push("uniform vec3 uDirLight2SpecularColor;"),b.push("uniform vec3 uEyePosition;"),b.push("uniform vec3 uEmissiveColor;"),b.push("uniform vec3 uSpecularColor;"),b.push("uniform float uSpecularPower;"),b.push(a.SharedProgramCode.lighting)}function c(c){var d=[];return d.push("precision mediump float;"),d.push("attribute vec3 aVertexPosition;"),c.lightingEnabled&&d.push("attribute vec3 aVertexNormal;"),c.vertexColorEnabled&&d.push("attribute vec4 aVertexColor;"),c.textureEnabled&&d.push("attribute vec2 aTextureCoord;"),d.push("uniform mat4 uMVPMatrix;"),c.lightingEnabled&&(d.push("uniform mat4 uMMatrix;"),d.push("uniform mat3 uMMatrixInverseTranspose;")),d.push("uniform vec4 uDiffuseColor;"),d.push("varying vec4 vDiffuseColor;"),c.lightingEnabled&&(c.perPixelLightingEnabled?(d.push("varying vec3 vPositionWS;"),d.push("varying vec3 vNormalWS;")):(d.push("varying vec3 vSpecularColor;"),b(d),d.push(a.SharedProgramCode.lightingVertex))),c.textureEnabled&&d.push("varying vec2 vTextureCoord;"),d.push("void main(void) {"),d.push(" gl_Position = uMVPMatrix * vec4(aVertexPosition, 1.0);"),c.lightingEnabled?c.perPixelLightingEnabled?(d.push(" vDiffuseColor = vec4(1, 1, 1, uDiffuseColor.a);"),d.push(" vPositionWS = (uMMatrix * vec4(aVertexPosition, 1.0)).xyz;"),d.push(" vNormalWS = normalize(uMMatrixInverseTranspose * aVertexNormal);")):d.push(" ComputeCommonVSOutputWithLighting(vec4(aVertexPosition, 1.0), aVertexNormal);"):d.push(" vDiffuseColor = uDiffuseColor;"),c.vertexColorEnabled&&d.push(" vDiffuseColor *= aVertexColor;"),c.textureEnabled&&d.push(" vTextureCoord = aTextureCoord;"),d.push("}"),d.join("\n")}function d(c){var d=[];return d.push("precision mediump float;"),d.push("varying vec4 vDiffuseColor;"),c.textureEnabled&&(d.push("varying vec2 vTextureCoord;"),d.push("uniform sampler2D uSampler;")),c.lightingEnabled&&(c.perPixelLightingEnabled?(d.push("uniform vec4 uDiffuseColor;"),d.push("varying vec3 vPositionWS;"),d.push("varying vec3 vNormalWS;"),b(d)):d.push("varying vec3 vSpecularColor;")),d.push(a.SharedProgramCode.common),d.push("void main(void) {"),d.push(" vec4 color = vDiffuseColor;"),c.textureEnabled&&d.push(" color *= texture2D(uSampler, vTextureCoord);"),c.lightingEnabled&&(c.perPixelLightingEnabled?(d.push(" vec3 eyeVector = normalize(uEyePosition - vPositionWS);"),d.push(" vec3 worldNormal = normalize(vNormalWS);"),d.push(" ColorPair lightResult = ComputeLights(eyeVector, worldNormal);"),d.push(" color.rgb *= lightResult.Diffuse;"),d.push(" AddSpecular(color, lightResult.Specular);")):d.push(" AddSpecular(color, vSpecularColor.rgb);")),d.push(" gl_FragColor = color;"),d.push("}"),d.join("\n")}var e=function(b){function e(e,f){this._dirtyFlags=-1,this.modelMatrix=new a.Matrix4,this.viewMatrix=new a.Matrix4,this.projectionMatrix=new a.Matrix4,this._modelView=new a.Matrix4,this.diffuseColor=new a.Vector3(1,1,1),this.emissiveColor=new a.Vector3,this.specularColor=new a.Vector3(1,1,1),this.specularPower=16,this.alpha=1,this.texture=null,this.ambientLightColor=new a.Vector3,this._directionalLight0=new a.DirectionalLight(this,0),this._directionalLight1=new a.DirectionalLight(this,1),this._directionalLight2=new a.DirectionalLight(this,2),this._directionalLight0.enabled=!0,f=a.ObjectUtil.reverseMerge(f||{},{lightingEnabled:!1,perPixelLightingEnabled:!0,textureEnabled:!1,vertexColorEnabled:!1}),this._options=f;var g=new a.VertexShader(e,c(f)),h=new a.FragmentShader(e,d(f));b.call(this,e,g,h)}return __extends(e,b),Object.defineProperty(e.prototype,"modelMatrix",{get:function(){return this._modelMatrix},set:function(a){this._modelMatrix=a,this._dirtyFlags|=3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewMatrix",{get:function(){return this._viewMatrix},set:function(a){this._viewMatrix=a,this._dirtyFlags|=5},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"projectionMatrix",{get:function(){return this._projectionMatrix},set:function(a){this._projectionMatrix=a,this._dirtyFlags|=1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"diffuseColor",{get:function(){return this._diffuseColor},set:function(a){this._diffuseColor=a,this._dirtyFlags|=8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"emissiveColor",{get:function(){return this._emissiveColor},set:function(a){this._emissiveColor=a,this._dirtyFlags|=8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"specularColor",{get:function(){return this._specularColor},set:function(a){this._specularColor=a,this._dirtyFlags|=16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"specularPower",{get:function(){return this._specularPower},set:function(a){this._specularPower=a,this._dirtyFlags|=32},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(a){this._alpha=a,this._dirtyFlags|=8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"texture",{get:function(){return this._texture},set:function(a){this._texture=a},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ambientLightColor",{get:function(){return this._ambientLightColor},set:function(a){this._ambientLightColor=a,this._dirtyFlags|=8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"directionalLight0",{get:function(){return this._directionalLight0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"directionalLight1",{get:function(){return this._directionalLight1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"directionalLight2",{get:function(){return this._directionalLight2},enumerable:!0,configurable:!0}),e.prototype.enableDefaultLighting=function(){if(!this._options.lightingEnabled)throw"Lighting must be enabled when creating this program.";this.ambientLightColor=a.ProgramUtil.enableDefaultLighting(this._directionalLight0,this._directionalLight1,this._directionalLight2)},e.prototype._onApply=function(){this._dirtyFlags=a.ProgramUtil.setModelViewProj(this,this._dirtyFlags,this._modelMatrix,this._viewMatrix,this._projectionMatrix,this._modelView),0!=(8&this._dirtyFlags)&&(a.ProgramUtil.setMaterialColor(this,this._options.lightingEnabled,this._alpha,this._diffuseColor,this._emissiveColor,this._ambientLightColor),this._dirtyFlags&=-9),0!=(16&this._dirtyFlags)&&(this.setUniform("uSpecularColor",this._specularColor),this._dirtyFlags&=-17),0!=(32&this._dirtyFlags)&&(this.setUniform("uSpecularPower",this._specularPower),this._dirtyFlags&=-33),this._options.lightingEnabled&&(this._dirtyFlags=a.ProgramUtil.setLightingMatrices(this,this._dirtyFlags,this._modelMatrix,this._viewMatrix)),this.setUniform("uSampler",this._texture),this._directionalLight0._apply(),this._directionalLight1._apply(),this._directionalLight2._apply()},e}(a.Program);a.BasicProgram=e}(Zia||(Zia={}));var Zia;!function(a){var b=function(){function b(b,c){this._program=b,this._index=c,this.direction=new a.Vector3,this.diffuseColor=new a.Vector3,this.specularColor=new a.Vector3,this.enabled=!1}return Object.defineProperty(b.prototype,"direction",{get:function(){return this._direction},set:function(a){this._direction=a,this._directionChanged=!0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"diffuseColor",{get:function(){return this._diffuseColor},set:function(a){this._diffuseColor=a,this._diffuseColorChanged=!0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"specularColor",{get:function(){return this._specularColor},set:function(a){this._specularColor=a,this._specularColorChanged=!0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"enabled",{get:function(){return this._enabled},set:function(a){this._enabled=a,this._enabledChanged=!0},enumerable:!0,configurable:!0}),b.prototype._apply=function(){this._directionChanged&&(this._setUniform("Direction",this._direction),this._directionChanged=!1),this._diffuseColorChanged&&this._enabled&&(this._setUniform("DiffuseColor",this._diffuseColor),this._diffuseColorChanged=!1),this._specularColorChanged&&this._enabled&&(this._setUniform("SpecularColor",this._specularColor),this._specularColorChanged=!1),this._enabledChanged&&(this._enabled||(this._setUniform("DiffuseColor",b._zero),this._setUniform("SpecularColor",b._zero)),this._enabledChanged=!1)},b.prototype._setUniform=function(a,b){this._program.setUniform("uDirLight"+this._index+a,b)},b._zero=new a.Vector3,b}();a.DirectionalLight=b}(Zia||(Zia={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Zia;!function(a){function b(b){var c=[];return c.push("precision mediump float;"),c.push("attribute vec3 aVertexPosition;"),c.push("attribute vec3 aVertexNormal;"),c.push("attribute vec2 aTextureCoord;"),c.push("uniform mat4 uMVPMatrix;"),c.push("uniform mat4 uMMatrix;"),c.push("uniform mat3 uMMatrixInverseTranspose;"),c.push("uniform vec4 uDiffuseColor;"),c.push("uniform float uEnvironmentMapAmount;"),c.push("uniform float uFresnelFactor;"),c.push("uniform vec3 uDirLight0Direction;"),c.push("uniform vec3 uDirLight0DiffuseColor;"),c.push("#define uDirLight0SpecularColor vec3(0,0,0)"),c.push("uniform vec3 uDirLight1Direction;"),c.push("uniform vec3 uDirLight1DiffuseColor;"),c.push("#define uDirLight1SpecularColor vec3(0,0,0)"),c.push("uniform vec3 uDirLight2Direction;"),c.push("uniform vec3 uDirLight2DiffuseColor;"),c.push("#define uDirLight2SpecularColor vec3(0,0,0)"),c.push("uniform vec3 uEyePosition;"),c.push("uniform vec3 uEmissiveColor;"),c.push("#define uSpecularColor vec3(0,0,0)"),c.push("#define uSpecularPower 0"),c.push(a.SharedProgramCode.lighting),c.push("varying vec4 vDiffuseColor;"),c.push("varying vec3 vSpecularColor;"),c.push("varying vec2 vTextureCoord;"),c.push("varying vec3 vEnvCoord;"),c.push("float ComputeFresnelFactor(vec3 eyeVector, vec3 worldNormal) {"),c.push(" float viewAngle = dot(eyeVector, worldNormal);"),c.push(" return pow(max(1.0 - abs(viewAngle), 0.0), uFresnelFactor) * uEnvironmentMapAmount;"),c.push("}"),c.push("void main(void) {"),c.push(" gl_Position = uMVPMatrix * vec4(aVertexPosition, 1.0);"),c.push(" vec4 positionWS = uMMatrix * vec4(aVertexPosition, 1.0);"),c.push(" vec3 eyeVector = normalize(uEyePosition - positionWS.xyz);"),c.push(" vec3 worldNormal = normalize(uMMatrixInverseTranspose * aVertexNormal);"),c.push(" ColorPair lightResult = ComputeLights(eyeVector, worldNormal);"),c.push(" vDiffuseColor = vec4(lightResult.Diffuse, uDiffuseColor.a);"),c.push(b.fresnelEnabled?" vSpecularColor.rgb = vec3(ComputeFresnelFactor(eyeVector, worldNormal));":" vSpecularColor.rgb = vec3(uEnvironmentMapAmount);"),c.push(" vTextureCoord = aTextureCoord;"),c.push(" vEnvCoord = reflect(-eyeVector, worldNormal);"),c.push("}"),c.join("\n")}function c(a){var b=[];return b.push("precision mediump float;"),b.push("varying vec4 vDiffuseColor;"),b.push("varying vec3 vSpecularColor;"),b.push("varying vec2 vTextureCoord;"),b.push("uniform sampler2D uSampler;"),b.push("varying vec3 vEnvCoord;"),b.push("uniform samplerCube uEnvironmentMapSampler;"),b.push("uniform vec3 uEnvironmentMapSpecular;"),b.push("void main(void) {"),b.push(" vec4 color = vDiffuseColor;"),b.push(" color *= texture2D(uSampler, vTextureCoord);"),b.push(" vec4 envmap = textureCube(uEnvironmentMapSampler, vEnvCoord) * color.a;"),b.push(" color.rgb = mix(color.rgb, envmap.rgb, vSpecularColor.rgb);"),a.environmentMapSpecularEnabled&&b.push(" color.rgb += uEnvironmentMapSpecular * envmap.a;"),b.push(" gl_FragColor = color;"),b.push("}"),b.join("\n")}var d=function(d){function e(e,f){this._dirtyFlags=-1,this.modelMatrix=new a.Matrix4,this.viewMatrix=new a.Matrix4,this.projectionMatrix=new a.Matrix4,this._modelView=new a.Matrix4,this.diffuseColor=new a.Vector3(1,1,1),this.emissiveColor=new a.Vector3,this.alpha=1,this.texture=null,this.ambientLightColor=new a.Vector3,this._environmentMap=null,this.environmentMapAmount=1,this.environmentMapSpecular=new a.Vector3,this.fresnelFactor=1,this._directionalLight0=new a.DirectionalLight(this,0),this._directionalLight1=new a.DirectionalLight(this,1),this._directionalLight2=new a.DirectionalLight(this,2),this._directionalLight0.enabled=!0,f=a.ObjectUtil.reverseMerge(f||{},{environmentMapSpecularEnabled:!1,fresnelEnabled:!0}),this._options=f;var g=new a.VertexShader(e,b(f)),h=new a.FragmentShader(e,c(f));d.call(this,e,g,h)}return __extends(e,d),Object.defineProperty(e.prototype,"modelMatrix",{get:function(){return this._modelMatrix},set:function(a){this._modelMatrix=a,this._dirtyFlags|=3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewMatrix",{get:function(){return this._viewMatrix},set:function(a){this._viewMatrix=a,this._dirtyFlags|=5},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"projectionMatrix",{get:function(){return this._projectionMatrix},set:function(a){this._projectionMatrix=a,this._dirtyFlags|=1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"diffuseColor",{get:function(){return this._diffuseColor},set:function(a){this._diffuseColor=a,this._dirtyFlags|=8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"emissiveColor",{get:function(){return this._emissiveColor},set:function(a){this._emissiveColor=a,this._dirtyFlags|=8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(a){this._alpha=a,this._dirtyFlags|=8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ambientLightColor",{get:function(){return this._ambientLightColor},set:function(a){this._ambientLightColor=a,this._dirtyFlags|=8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"directionalLight0",{get:function(){return this._directionalLight0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"directionalLight1",{get:function(){return this._directionalLight1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"directionalLight2",{get:function(){return this._directionalLight2},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"texture",{get:function(){return this._texture},set:function(a){this._texture=a},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"environmentMap",{get:function(){return this._environmentMap},set:function(a){this._environmentMap=a},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"environmentMapAmount",{get:function(){return this._environmentMapAmount},set:function(a){this._environmentMapAmount=a,this._dirtyFlags|=64},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"environmentMapSpecular",{get:function(){return this._environmentMapSpecular},set:function(a){this._environmentMapSpecular=a,this._dirtyFlags|=128},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fresnelFactor",{get:function(){return this._fresnelFactor},set:function(a){this._fresnelFactor=a,this._dirtyFlags|=256},enumerable:!0,configurable:!0}),e.prototype.enableDefaultLighting=function(){this.ambientLightColor=a.ProgramUtil.enableDefaultLighting(this._directionalLight0,this._directionalLight1,this._directionalLight2)},e.prototype._onApply=function(){this._dirtyFlags=a.ProgramUtil.setModelViewProj(this,this._dirtyFlags,this._modelMatrix,this._viewMatrix,this._projectionMatrix,this._modelView),0!=(8&this._dirtyFlags)&&(a.ProgramUtil.setMaterialColor(this,this._options.lightingEnabled,this._alpha,this._diffuseColor,this._emissiveColor,this._ambientLightColor),this._dirtyFlags&=-9),this.setUniform("uSampler",this._texture),this.setUniform("uEnvironmentMapSampler",this._environmentMap),0!=(64&this._dirtyFlags)&&(this.setUniform("uEnvironmentMapAmount",this._environmentMapAmount),this._dirtyFlags&=-65),0!=(128&this._dirtyFlags)&&(this.setUniform("uEnvironmentMapSpecular",this._environmentMapSpecular),this._dirtyFlags&=-129),0!=(256&this._dirtyFlags)&&(this.setUniform("uFresnelFactor",this._fresnelFactor),this._dirtyFlags&=-257),this._dirtyFlags=a.ProgramUtil.setLightingMatrices(this,this._dirtyFlags,this._modelMatrix,this._viewMatrix),this._directionalLight0._apply(),this._directionalLight1._apply(),this._directionalLight2._apply()},e}(a.Program);a.EnvironmentMapProgram=d}(Zia||(Zia={}));var Zia;!function(a){a.SharedProgramCode={common:["void AddSpecular(inout vec4 color, vec3 specular) {"," color.rgb += specular * color.a;","}"].join("\n"),lighting:["struct ColorPair {"," vec3 Diffuse;"," vec3 Specular;","};","ColorPair ComputeLights(vec3 eyeVector, vec3 worldNormal) {"," mat3 lightDirections;"," mat3 lightDiffuse;"," mat3 lightSpecular;"," mat3 halfVectors;"," for (int i = 0; i < 3; i++) {"," lightDirections[i] = mat3(uDirLight0Direction, uDirLight1Direction, uDirLight2Direction) [i];"," lightDiffuse[i] = mat3(uDirLight0DiffuseColor, uDirLight1DiffuseColor, uDirLight2DiffuseColor) [i];"," lightSpecular[i] = mat3(uDirLight0SpecularColor, uDirLight1SpecularColor, uDirLight2SpecularColor)[i];"," halfVectors[i] = normalize(eyeVector - lightDirections[i]);"," }"," vec3 dotL = worldNormal * -lightDirections;"," vec3 dotH = worldNormal * halfVectors;"," vec3 zeroL = step(vec3(0.0), dotL);"," vec3 diffuse = zeroL * dotL;"," vec3 specular = pow(max(dotH, vec3(0.0)) * zeroL, vec3(uSpecularPower));"," ColorPair result;"," result.Diffuse = (lightDiffuse * diffuse) * uDiffuseColor.rgb + uEmissiveColor;"," result.Specular = (lightSpecular * specular) * uSpecularColor;"," return result;","}"].join("\n"),lightingVertex:["void ComputeCommonVSOutputWithLighting(vec4 position, vec3 normal) {"," vec4 positionWS = uMMatrix * position;"," vec3 eyeVector = normalize(uEyePosition - positionWS.xyz);"," vec3 worldNormal = normalize(uMMatrixInverseTranspose * normal);"," ColorPair lightResult = ComputeLights(eyeVector, worldNormal);"," vDiffuseColor = vec4(lightResult.Diffuse, uDiffuseColor.a);"," vSpecularColor = lightResult.Specular;","}"].join("\n")}}(Zia||(Zia={}));var Zia;!function(a){var b=function(){function b(){this._pressedKeys=[];var a=this;this._onKeyDown=function(b){var c=a._pressedKeys.indexOf(b.keyCode);-1===c&&a._pressedKeys.push(b.keyCode)},this._onKeyUp=function(b){var c=a._pressedKeys.indexOf(b.keyCode);c>=0&&a._pressedKeys.splice(c,1)},window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp)}return b.prototype.getState=function(b){return void 0===b&&(b=new a.KeyboardState),b._setPressedKeys(this._pressedKeys),b},b.prototype.destroy=function(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp)},b}();a.Keyboard=b}(Zia||(Zia={}));var Zia;!function(a){var b=function(){function a(){}return a.prototype._setPressedKeys=function(a){this._pressedKeys=a.slice(0)},a.prototype.getPressedKeys=function(){return this._pressedKeys},a.prototype.isKeyDown=function(a){for(var b=0;b