@galacean/engine-math 0.9.0-beta.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self)["@galacean/engineMath"]={})}(this,function(t){"use strict";function n(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function e(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}t.ContainmentType=void 0,(i=t.ContainmentType||(t.ContainmentType={}))[i.Disjoint=0]="Disjoint",i[i.Contains=1]="Contains",i[i.Intersects=2]="Intersects",t.PlaneIntersectionType=void 0,(a=t.PlaneIntersectionType||(t.PlaneIntersectionType={}))[a.Back=0]="Back",a[a.Front=1]="Front",a[a.Intersecting=2]="Intersecting",t.FrustumFace=void 0,(r=t.FrustumFace||(t.FrustumFace={}))[r.Near=0]="Near",r[r.Far=1]="Far",r[r.Left=2]="Left",r[r.Right=3]="Right",r[r.Bottom=4]="Bottom",r[r.Top=5]="Top";var i,a,r,_=function(){function t(){}return t.clamp=function(t,n,e){return Math.max(n,Math.min(e,t))},t.equals=function(n,e){return Math.abs(n-e)<=t.zeroTolerance},t.isPowerOf2=function(t){return(t&t-1)==0},t.radianToDegree=function(n){return n*t.radToDegreeFactor},t.degreeToRadian=function(n){return n*t.degreeToRadFactor},t}();_.zeroTolerance=1e-6,_.radToDegreeFactor=180/Math.PI,_.degreeToRadFactor=Math.PI/180;var o=function(){function t(t,n,e){void 0===t&&(t=0),void 0===n&&(n=0),void 0===e&&(e=0),this._onValueChanged=null,this._x=t,this._y=n,this._z=e}var n=t.prototype;return n.set=function(t,n,e){return this._x=t,this._y=n,this._z=e,this._onValueChanged&&this._onValueChanged(),this},n.add=function(t){return this._x+=t._x,this._y+=t._y,this._z+=t._z,this._onValueChanged&&this._onValueChanged(),this},n.subtract=function(t){return this._x-=t._x,this._y-=t._y,this._z-=t._z,this._onValueChanged&&this._onValueChanged(),this},n.multiply=function(t){return this._x*=t._x,this._y*=t._y,this._z*=t._z,this._onValueChanged&&this._onValueChanged(),this},n.divide=function(t){return this._x/=t._x,this._y/=t._y,this._z/=t._z,this._onValueChanged&&this._onValueChanged(),this},n.length=function(){var t=this._x,n=this._y,e=this._z;return Math.sqrt(t*t+n*n+e*e)},n.lengthSquared=function(){var t=this._x,n=this._y,e=this._z;return t*t+n*n+e*e},n.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},n.normalize=function(){return t.normalize(this,this),this},n.scale=function(t){return this._x*=t,this._y*=t,this._z*=t,this._onValueChanged&&this._onValueChanged(),this},n.transformNormal=function(n){return t.transformNormal(this,n,this),this},n.transformToVec3=function(n){return t.transformToVec3(this,n,this),this},n.transformCoordinate=function(n){return t.transformCoordinate(this,n,this),this},n.transformByQuat=function(n){return t.transformByQuat(this,n,this),this},n.clone=function(){return new t(this._x,this._y,this._z)},n.copyFrom=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._onValueChanged&&this._onValueChanged(),this},n.copyFromArray=function(t,n){return void 0===n&&(n=0),this._x=t[n],this._y=t[n+1],this._z=t[n+2],this._onValueChanged&&this._onValueChanged(),this},n.copyToArray=function(t,n){void 0===n&&(n=0),t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z},n.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},t.add=function(t,n,e){e._x=t._x+n._x,e._y=t._y+n._y,e._z=t._z+n._z,e._onValueChanged&&e._onValueChanged()},t.subtract=function(t,n,e){e._x=t._x-n._x,e._y=t._y-n._y,e._z=t._z-n._z,e._onValueChanged&&e._onValueChanged()},t.multiply=function(t,n,e){e._x=t._x*n._x,e._y=t._y*n._y,e._z=t._z*n._z,e._onValueChanged&&e._onValueChanged()},t.divide=function(t,n,e){e._x=t._x/n._x,e._y=t._y/n._y,e._z=t._z/n._z,e._onValueChanged&&e._onValueChanged()},t.dot=function(t,n){return t._x*n._x+t._y*n._y+t._z*n._z},t.cross=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=n._x,o=n._y,s=n._z;e.set(a*s-r*o,r*_-i*s,i*o-a*_)},t.distance=function(t,n){var e=n._x-t._x,i=n._y-t._y,a=n._z-t._z;return Math.sqrt(e*e+i*i+a*a)},t.distanceSquared=function(t,n){var e=n._x-t._x,i=n._y-t._y,a=n._z-t._z;return e*e+i*i+a*a},t.equals=function(t,n){return _.equals(t._x,n._x)&&_.equals(t._y,n._y)&&_.equals(t._z,n._z)},t.lerp=function(t,n,e,i){var a=t._x,r=t._y,_=t._z;i._x=a+(n._x-a)*e,i._y=r+(n._y-r)*e,i._z=_+(n._z-_)*e,i._onValueChanged&&i._onValueChanged()},t.max=function(t,n,e){e._x=Math.max(t._x,n._x),e._y=Math.max(t._y,n._y),e._z=Math.max(t._z,n._z),e._onValueChanged&&e._onValueChanged()},t.min=function(t,n,e){e._x=Math.min(t._x,n._x),e._y=Math.min(t._y,n._y),e._z=Math.min(t._z,n._z),e._onValueChanged&&e._onValueChanged()},t.negate=function(t,n){n._x=-t._x,n._y=-t._y,n._z=-t._z,n._onValueChanged&&n._onValueChanged()},t.normalize=function(t,n){var e=t._x,i=t._y,a=t._z,r=Math.sqrt(e*e+i*i+a*a);r>_.zeroTolerance&&(r=1/r,n.set(e*r,i*r,a*r))},t.scale=function(t,n,e){e._x=t._x*n,e._y=t._y*n,e._z=t._z*n,e._onValueChanged&&e._onValueChanged()},t.transformNormal=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=n.elements;e._x=i*_[0]+a*_[4]+r*_[8],e._y=i*_[1]+a*_[5]+r*_[9],e._z=i*_[2]+a*_[6]+r*_[10],e._onValueChanged&&e._onValueChanged()},t.transformToVec3=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=n.elements;e._x=i*_[0]+a*_[4]+r*_[8]+_[12],e._y=i*_[1]+a*_[5]+r*_[9]+_[13],e._z=i*_[2]+a*_[6]+r*_[10]+_[14],e._onValueChanged&&e._onValueChanged()},t.transformToVec4=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=n.elements;e._x=i*_[0]+a*_[4]+r*_[8]+_[12],e._y=i*_[1]+a*_[5]+r*_[9]+_[13],e._z=i*_[2]+a*_[6]+r*_[10]+_[14],e._w=i*_[3]+a*_[7]+r*_[11]+_[15],e._onValueChanged&&e._onValueChanged()},t.transformCoordinate=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=n.elements,o=i*_[3]+a*_[7]+r*_[11]+_[15];o=1/o,e._x=(i*_[0]+a*_[4]+r*_[8]+_[12])*o,e._y=(i*_[1]+a*_[5]+r*_[9]+_[13])*o,e._z=(i*_[2]+a*_[6]+r*_[10]+_[14])*o,e._onValueChanged&&e._onValueChanged()},t.transformByQuat=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=n._x,o=n._y,s=n._z,h=n._w,u=h*i+o*r-s*a,c=h*a+s*i-_*r,l=h*r+_*a-o*i,y=-_*i-o*a-s*r;e._x=u*h-y*_-c*s+l*o,e._y=c*h-y*o-l*_+u*s,e._z=l*h-y*s-u*o+c*_,e._onValueChanged&&e._onValueChanged()},e(t,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onValueChanged&&this._onValueChanged()}}]),t}();o._zero=new o(0,0,0),o._one=new o(1,1,1);var s=function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n=0),this.center=new o,this.radius=0,t&&this.center.copyFrom(t),this.radius=n}var n=t.prototype;return n.clone=function(){return new t(this.center,this.radius)},n.copyFrom=function(t){return this.center.copyFrom(t.center),this.radius=t.radius,this},t.fromPoints=function(n,e){if(!n||0===n.length)throw Error("points must be array and length must > 0");var i=n.length,a=t._tempVec30;a.x=a.y=a.z=0;for(var r=0;r<i;++r)o.add(n[r],a,a);o.scale(a,1/i,e.center);for(var _=0,s=0;s<i;++s){var h=o.distanceSquared(a,n[s]);h>_&&(_=h)}e.radius=Math.sqrt(_)},t.fromBox=function(t,n){var e=n.center,i=t.min,a=t.max;e.x=(i.x+a.x)*.5,e.y=(i.y+a.y)*.5,e.z=(i.z+a.z)*.5,n.radius=o.distance(e,a)},t}();s._tempVec30=new o;var h=function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n=null),this.min=new o,this.max=new o,t&&this.min.copyFrom(t),n&&this.max.copyFrom(n)}var n=t.prototype;return n.getCenter=function(t){return o.add(this.min,this.max,t),o.scale(t,.5,t),t},n.getExtent=function(t){return o.subtract(this.max,this.min,t),o.scale(t,.5,t),t},n.getCorners=function(t){void 0===t&&(t=[]);var n=this.min,e=this.max,i=n.x,a=n.y,r=n.z,_=e.x,s=e.y,h=e.z,u=t.length;if(u<8)for(var c=0,l=8-u;c<l;++c)t[u+c]=new o;return t[0].set(i,s,h),t[1].set(_,s,h),t[2].set(_,a,h),t[3].set(i,a,h),t[4].set(i,s,r),t[5].set(_,s,r),t[6].set(_,a,r),t[7].set(i,a,r),t},n.transform=function(n){return t.transform(this,n,this),this},n.clone=function(){return new t(this.min,this.max)},n.copyFrom=function(t){return this.min.copyFrom(t.min),this.max.copyFrom(t.max),this},t.fromCenterAndExtent=function(t,n,e){o.subtract(t,n,e.min),o.add(t,n,e.max)},t.fromPoints=function(t,n){if(!t||0===t.length)throw Error("points must be array and length must > 0");var e=n.min,i=n.max;e.x=e.y=e.z=Number.MAX_VALUE,i.x=i.y=i.z=-Number.MAX_VALUE;for(var a=0,r=t.length;a<r;++a){var _=t[a];o.min(e,_,e),o.max(i,_,i)}},t.fromSphere=function(t,n){var e=t.center,i=t.radius,a=n.min,r=n.max;a.x=e.x-i,a.y=e.y-i,a.z=e.z-i,r.x=e.x+i,r.y=e.y+i,r.z=e.z+i},t.transform=function(n,e,i){var a=t._tempVec30,r=t._tempVec31;n.getCenter(a),n.getExtent(r),o.transformCoordinate(a,e,a);var _=r.x,s=r.y,h=r.z,u=e.elements;r.x=Math.abs(_*u[0])+Math.abs(s*u[4])+Math.abs(h*u[8]),r.y=Math.abs(_*u[1])+Math.abs(s*u[5])+Math.abs(h*u[9]),r.z=Math.abs(_*u[2])+Math.abs(s*u[6])+Math.abs(h*u[10]),o.subtract(a,r,i.min),o.add(a,r,i.max)},t.merge=function(t,n,e){return o.min(t.min,n.min,e.min),o.max(t.max,n.max,e.max),e},t}();h._tempVec30=new o,h._tempVec31=new o;var u=function(){function n(){}return n.intersectionPointThreePlanes=function(t,e,i,a){var r=t.normal,_=e.normal,s=i.normal;o.cross(_,s,n._tempVec30),o.cross(s,r,n._tempVec31),o.cross(r,_,n._tempVec32);var h=-o.dot(r,n._tempVec30),u=-o.dot(_,n._tempVec31),c=-o.dot(s,n._tempVec32);o.scale(n._tempVec30,t.distance/h,n._tempVec30),o.scale(n._tempVec31,e.distance/u,n._tempVec31),o.scale(n._tempVec32,i.distance/c,n._tempVec32),o.add(n._tempVec30,n._tempVec31,a),o.add(a,n._tempVec32,a)},n.distancePlaneAndPoint=function(t,n){return o.dot(t.normal,n)+t.distance},n.intersectsPlaneAndPoint=function(e,i){var a=n.distancePlaneAndPoint(e,i);return a>0?t.PlaneIntersectionType.Front:a<0?t.PlaneIntersectionType.Back:t.PlaneIntersectionType.Intersecting},n.intersectsPlaneAndBox=function(e,i){var a=i.min,r=i.max,_=e.normal,o=n._tempVec30,s=n._tempVec31;return(_.x>=0?(o.x=r.x,s.x=a.x):(o.x=a.x,s.x=r.x),_.y>=0?(o.y=r.y,s.y=a.y):(o.y=a.y,s.y=r.y),_.z>=0?(o.z=r.z,s.z=a.z):(o.z=a.z,s.z=r.z),0>n.distancePlaneAndPoint(e,o))?t.PlaneIntersectionType.Back:n.distancePlaneAndPoint(e,s)>0?t.PlaneIntersectionType.Front:t.PlaneIntersectionType.Intersecting},n.intersectsPlaneAndSphere=function(e,i){var a=i.center,r=i.radius,_=n.distancePlaneAndPoint(e,a);return _>r?t.PlaneIntersectionType.Front:_<-r?t.PlaneIntersectionType.Back:t.PlaneIntersectionType.Intersecting},n.intersectsRayAndPlane=function(t,n){var e=n.normal,i=_.zeroTolerance,a=o.dot(e,t.direction);if(Math.abs(a)<i)return -1;var r=o.dot(e,t.origin),s=(-n.distance-r)/a;if(s<0){if(s<-i)return -1;s=0}return s},n.intersectsRayAndBox=function(t,n){var e=_.zeroTolerance,i=t.origin,a=t.direction,r=n.min,o=n.max,s=a.x,h=a.y,u=a.z,c=i.x,l=i.y,y=i.z,d=0,f=Number.MAX_VALUE;if(Math.abs(s)<e){if(c<r.x||c>o.x)return -1}else{var m=1/s,x=(r.x-c)*m,g=(o.x-c)*m;if(x>g){var z=x;x=g,g=z}if((d=Math.max(x,d))>(f=Math.min(g,f)))return -1}if(Math.abs(h)<e){if(l<r.y||l>o.y)return -1}else{var v=1/h,V=(r.y-l)*v,C=(o.y-l)*v;if(V>C){var p=V;V=C,C=p}if((d=Math.max(V,d))>(f=Math.min(C,f)))return -1}if(Math.abs(u)<e){if(y<r.z||y>o.z)return -1}else{var w=1/u,M=(r.z-y)*w,b=(o.z-y)*w;if(M>b){var q=M;M=b,b=q}if((d=Math.max(M,d))>(f=Math.min(b,f)))return -1}return d},n.intersectsRayAndSphere=function(t,e){var i=t.origin,a=t.direction,r=e.center,_=e.radius,s=n._tempVec30;o.subtract(i,r,s);var h=o.dot(s,a),u=o.dot(s,s)-_*_;if(h>0&&u>0)return -1;var c=h*h-u;if(c<0)return -1;var l=-h-Math.sqrt(c);return l<0&&(l=0),l},n.intersectsBoxAndBox=function(t,n){return!(t.min.x>n.max.x)&&!(n.min.x>t.max.x)&&!(t.min.y>n.max.y)&&!(n.min.y>t.max.y)&&!(t.min.z>n.max.z||n.min.z>t.max.z)},n.intersectsSphereAndSphere=function(t,n){var e=t.radius+n.radius;return o.distanceSquared(t.center,n.center)<e*e},n.intersectsSphereAndBox=function(t,e){var i=t.center,a=e.max,r=e.min,_=n._tempVec30;return _.set(Math.max(r.x,Math.min(i.x,a.x)),Math.max(r.y,Math.min(i.y,a.y)),Math.max(r.z,Math.min(i.z,a.z))),o.distanceSquared(i,_)<=t.radius*t.radius},n.intersectsFrustumAndBox=function(t,e){for(var i=e.min,a=e.max,r=n._tempVec30,_=0;_<6;++_){var s=t.getPlane(_),h=s.normal;if(r.set(h.x>=0?a.x:i.x,h.y>=0?a.y:i.y,h.z>=0?a.z:i.z),o.dot(h,r)<-s.distance)return!1}return!0},n.frustumContainsBox=function(e,i){for(var a=i.min,r=i.max,_=n._tempVec30,o=n._tempVec31,s=t.ContainmentType.Contains,h=0;h<6;++h){var u=e.getPlane(h),c=u.normal;if(c.x>=0?(_.x=r.x,o.x=a.x):(_.x=a.x,o.x=r.x),c.y>=0?(_.y=r.y,o.y=a.y):(_.y=a.y,o.y=r.y),c.z>=0?(_.z=r.z,o.z=a.z):(_.z=a.z,o.z=r.z),n.intersectsPlaneAndPoint(u,_)===t.PlaneIntersectionType.Back)return t.ContainmentType.Disjoint;n.intersectsPlaneAndPoint(u,o)===t.PlaneIntersectionType.Back&&(s=t.ContainmentType.Intersects)}return s},n.frustumContainsSphere=function(e,i){for(var a=t.ContainmentType.Contains,r=0;r<6;++r){var _=e.getPlane(r),o=n.intersectsPlaneAndSphere(_,i);if(o===t.PlaneIntersectionType.Back)return t.ContainmentType.Disjoint;if(o===t.PlaneIntersectionType.Intersecting){a=t.ContainmentType.Intersects;break}}return a},n}();u._tempVec30=new o,u._tempVec31=new o,u._tempVec32=new o;var c=function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n=0),this.normal=new o,this.distance=0,t&&this.normal.copyFrom(t),this.distance=n}var n=t.prototype;return n.normalize=function(){return t.normalize(this,this),this},n.clone=function(){var n=new t;return n.copyFrom(this),n},n.copyFrom=function(t){return this.normal.copyFrom(t.normal),this.distance=t.distance,this},t.normalize=function(t,n){var e=t.normal,i=1/e.length();o.scale(e,i,n.normal),n.distance=t.distance*i},t.fromPoints=function(t,n,e,i){var a=t.x,r=t.y,_=t.z,o=n.x-a,s=n.y-r,h=n.z-_,u=e.x-a,c=e.y-r,l=e.z-_,y=s*l-h*c,d=h*u-o*l,f=o*c-s*u,m=1/Math.sqrt(y*y+d*d+f*f),x=y*m,g=d*m,z=f*m,v=i.normal;v.x=x,v.y=g,v.z=z,i.distance=-(x*a+g*r+z*_)},t}(),l=function(){function n(t){void 0===t&&(t=null),this.near=new c,this.far=new c,this.left=new c,this.right=new c,this.top=new c,this.bottom=new c,t&&this.calculateFromMatrix(t)}var e=n.prototype;return e.getPlane=function(n){switch(n){case t.FrustumFace.Near:return this.near;case t.FrustumFace.Far:return this.far;case t.FrustumFace.Left:return this.left;case t.FrustumFace.Right:return this.right;case t.FrustumFace.Bottom:return this.bottom;case t.FrustumFace.Top:return this.top;default:return null}},e.calculateFromMatrix=function(t){var n=t.elements,e=n[0],i=n[1],a=n[2],r=n[3],_=n[4],o=n[5],s=n[6],h=n[7],u=n[8],c=n[9],l=n[10],y=n[11],d=n[12],f=n[13],m=n[14],x=n[15];this.near.normal.set(r+a,h+s,y+l),this.near.distance=x+m,this.near.normalize(),this.far.normal.set(r-a,h-s,y-l),this.far.distance=x-m,this.far.normalize(),this.left.normal.set(r+e,h+_,y+u),this.left.distance=x+d,this.left.normalize(),this.right.normal.set(r-e,h-_,y-u),this.right.distance=x-d,this.right.normalize(),this.bottom.normal.set(r+i,h+o,y+c),this.bottom.distance=x+f,this.bottom.normalize(),this.top.normal.set(r-i,h-o,y-c),this.top.distance=x-f,this.top.normalize()},e.intersectsBox=function(t){return u.intersectsFrustumAndBox(this,t)},e.intersectsSphere=function(n){return u.frustumContainsSphere(this,n)!==t.ContainmentType.Disjoint},e.clone=function(){var t=new n;return t.copyFrom(this),t},e.copyFrom=function(t){return this.near.copyFrom(t.near),this.far.copyFrom(t.far),this.left.copyFrom(t.left),this.right.copyFrom(t.right),this.bottom.copyFrom(t.bottom),this.top.copyFrom(t.top),this},n}(),y=function(){function t(t,n,e,i,a,r,_,o,s){void 0===t&&(t=1),void 0===n&&(n=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===a&&(a=1),void 0===r&&(r=0),void 0===_&&(_=0),void 0===o&&(o=0),void 0===s&&(s=1),this.elements=new Float32Array(9);var h=this.elements;h[0]=t,h[1]=n,h[2]=e,h[3]=i,h[4]=a,h[5]=r,h[6]=_,h[7]=o,h[8]=s}var n=t.prototype;return n.set=function(t,n,e,i,a,r,_,o,s){var h=this.elements;return h[0]=t,h[1]=n,h[2]=e,h[3]=i,h[4]=a,h[5]=r,h[6]=_,h[7]=o,h[8]=s,this},n.add=function(n){return t.add(this,n,this),this},n.subtract=function(n){return t.subtract(this,n,this),this},n.multiply=function(n){return t.multiply(this,n,this),this},n.determinant=function(){var t=this.elements,n=t[0],e=t[1],i=t[2],a=t[3],r=t[4],_=t[5],o=t[6],s=t[7],h=t[8];return n*(h*r-_*s)+e*(-h*a+_*o)+i*(s*a-r*o)},n.identity=function(){var t=this.elements;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},n.invert=function(){return t.invert(this,this),this},n.rotate=function(n){return t.rotate(this,n,this),this},n.scale=function(n){return t.scale(this,n,this),this},n.translate=function(n){return t.translate(this,n,this),this},n.transpose=function(){return t.transpose(this,this),this},n.clone=function(){var n=this.elements;return new t(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8])},n.copyFrom=function(t){var n=this.elements,e=t.elements;return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],this},n.copyFromArray=function(t,n){void 0===n&&(n=0);for(var e=this.elements,i=0;i<12;i++)e[i]=t[i+n];return this},n.copyToArray=function(t,n){void 0===n&&(n=0);var e=this.elements;t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8]},n.copyFromMatrix=function(t){var n=t.elements,e=this.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[4],e[4]=n[5],e[5]=n[6],e[6]=n[8],e[7]=n[9],e[8]=n[10],this},t.add=function(t,n,e){var i=t.elements,a=n.elements,r=e.elements;r[0]=i[0]+a[0],r[1]=i[1]+a[1],r[2]=i[2]+a[2],r[3]=i[3]+a[3],r[4]=i[4]+a[4],r[5]=i[5]+a[5],r[6]=i[6]+a[6],r[7]=i[7]+a[7],r[8]=i[8]+a[8]},t.subtract=function(t,n,e){var i=t.elements,a=n.elements,r=e.elements;r[0]=i[0]-a[0],r[1]=i[1]-a[1],r[2]=i[2]-a[2],r[3]=i[3]-a[3],r[4]=i[4]-a[4],r[5]=i[5]-a[5],r[6]=i[6]-a[6],r[7]=i[7]-a[7],r[8]=i[8]-a[8]},t.multiply=function(t,n,e){var i=t.elements,a=n.elements,r=e.elements,_=i[0],o=i[1],s=i[2],h=i[3],u=i[4],c=i[5],l=i[6],y=i[7],d=i[8],f=a[0],m=a[1],x=a[2],g=a[3],z=a[4],v=a[5],V=a[6],C=a[7],p=a[8];r[0]=_*f+h*m+l*x,r[1]=o*f+u*m+y*x,r[2]=s*f+c*m+d*x,r[3]=_*g+h*z+l*v,r[4]=o*g+u*z+y*v,r[5]=s*g+c*z+d*v,r[6]=_*V+h*C+l*p,r[7]=o*V+u*C+y*p,r[8]=s*V+c*C+d*p},t.equals=function(t,n){var e=t.elements,i=n.elements;return _.equals(e[0],i[0])&&_.equals(e[1],i[1])&&_.equals(e[2],i[2])&&_.equals(e[3],i[3])&&_.equals(e[4],i[4])&&_.equals(e[5],i[5])&&_.equals(e[6],i[6])&&_.equals(e[7],i[7])&&_.equals(e[8],i[8])},t.lerp=function(t,n,e,i){var a=t.elements,r=n.elements,_=i.elements,o=1-e;_[0]=a[0]*o+r[0]*e,_[1]=a[1]*o+r[1]*e,_[2]=a[2]*o+r[2]*e,_[3]=a[3]*o+r[3]*e,_[4]=a[4]*o+r[4]*e,_[5]=a[5]*o+r[5]*e,_[6]=a[6]*o+r[6]*e,_[7]=a[7]*o+r[7]*e,_[8]=a[8]*o+r[8]*e},t.rotationQuaternion=function(t,n){var e=n.elements,i=t._x,a=t._y,r=t._z,_=t._w,o=i+i,s=a+a,h=r+r,u=i*o,c=a*o,l=a*s,y=r*o,d=r*s,f=r*h,m=_*o,x=_*s,g=_*h;e[0]=1-l-f,e[3]=c-g,e[6]=y+x,e[1]=c+g,e[4]=1-u-f,e[7]=d-m,e[2]=y-x,e[5]=d+m,e[8]=1-u-l},t.scaling=function(t,n){var e=n.elements;e[0]=t._x,e[1]=0,e[2]=0,e[3]=0,e[4]=t._y,e[5]=0,e[6]=0,e[7]=0,e[8]=1},t.translation=function(t,n){var e=n.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t._x,e[7]=t._y,e[8]=1},t.invert=function(t,n){var e=t.elements,i=n.elements,a=e[0],r=e[1],_=e[2],o=e[3],s=e[4],h=e[5],u=e[6],c=e[7],l=e[8],y=l*s-h*c,d=-l*o+h*u,f=c*o-s*u,m=a*y+r*d+_*f;m&&(m=1/m,i[0]=y*m,i[1]=(-l*r+_*c)*m,i[2]=(h*r-_*s)*m,i[3]=d*m,i[4]=(l*a-_*u)*m,i[5]=(-h*a+_*o)*m,i[6]=f*m,i[7]=(-c*a+r*u)*m,i[8]=(s*a-r*o)*m)},t.normalMatrix=function(t,n){var e=t.elements,i=n.elements,a=e[0],r=e[1],_=e[2],o=e[3],s=e[4],h=e[5],u=e[6],c=e[7],l=e[8],y=e[9],d=e[10],f=e[11],m=e[12],x=e[13],g=e[14],z=e[15],v=a*h-r*s,V=a*u-_*s,C=a*c-o*s,p=r*u-_*h,w=r*c-o*h,M=_*c-o*u,b=l*x-y*m,q=l*g-d*m,T=l*z-f*m,F=y*g-d*x,A=y*z-f*x,P=d*z-f*g,S=v*P-V*A+C*F+p*T-w*q+M*b;if(!S)return null;S=1/S,i[0]=(h*P-u*A+c*F)*S,i[1]=(u*T-s*P-c*q)*S,i[2]=(s*A-h*T+c*b)*S,i[3]=(_*A-r*P-o*F)*S,i[4]=(a*P-_*T+o*q)*S,i[5]=(r*T-a*A-o*b)*S,i[6]=(x*M-g*w+z*p)*S,i[7]=(g*C-m*M-z*V)*S,i[8]=(m*w-x*C+z*v)*S},t.rotate=function(t,n,e){var i=t.elements,a=e.elements,r=Math.sin(n),_=Math.cos(n),o=i[0],s=i[1],h=i[2],u=i[3],c=i[4],l=i[5],y=i[6],d=i[7],f=i[8];a[0]=_*o+r*u,a[1]=_*s+r*c,a[2]=_*h+r*l,a[3]=_*u-r*o,a[4]=_*c-r*s,a[5]=_*l-r*h,a[6]=y,a[7]=d,a[8]=f},t.scale=function(t,n,e){var i=n._x,a=n._y,r=t.elements,_=e.elements;_[0]=i*r[0],_[1]=i*r[1],_[2]=i*r[2],_[3]=a*r[3],_[4]=a*r[4],_[5]=a*r[5],_[6]=r[6],_[7]=r[7],_[8]=r[8]},t.translate=function(t,n,e){var i=n._x,a=n._y,r=t.elements,_=e.elements,o=r[0],s=r[1],h=r[2],u=r[3],c=r[4],l=r[5],y=r[6],d=r[7],f=r[8];_[0]=o,_[1]=s,_[2]=h,_[3]=u,_[4]=c,_[5]=l,_[6]=i*o+a*u+y,_[7]=i*s+a*c+d,_[8]=i*h+a*l+f},t.transpose=function(t,n){var e=t.elements,i=n.elements;if(n===t){var a=e[1],r=e[2],_=e[5];i[1]=e[3],i[2]=e[6],i[3]=a,i[5]=e[7],i[6]=r,i[7]=_}else i[0]=e[0],i[1]=e[3],i[2]=e[6],i[3]=e[1],i[4]=e[4],i[5]=e[7],i[6]=e[2],i[7]=e[5],i[8]=e[8]},t}(),d=function(){function t(t,n,e,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===e&&(e=0),void 0===i&&(i=1),this._onValueChanged=null,this._x=t,this._y=n,this._z=e,this._w=i}var n=t.prototype;return n.set=function(t,n,e,i){return this._x=t,this._y=n,this._z=e,this._w=i,this._onValueChanged&&this._onValueChanged(),this},n.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onValueChanged&&this._onValueChanged(),this},n.getAxisAngle=function(t){var n=this._x,e=this._y,i=this._z,a=n*n+e*e+i*i;if(a<_.zeroTolerance)return t._x=1,t._y=0,t._z=0,0;var r=1/a;return t._x=this._x*r,t._y=this._y*r,t._z=this._z*r,2*Math.acos(this._w)},n.identity=function(){return this._x=0,this._y=0,this._z=0,this._w=1,this._onValueChanged&&this._onValueChanged(),this},n.length=function(){var t=this._x,n=this._y,e=this._z,i=this._w;return Math.sqrt(t*t+n*n+e*e+i*i)},n.lengthSquared=function(){var t=this._x,n=this._y,e=this._z,i=this._w;return t*t+n*n+e*e+i*i},n.normalize=function(){return t.normalize(this,this),this},n.toEuler=function(t){this._toYawPitchRoll(t);var n=t._x;return t._x=t._y,t._y=n,t._onValueChanged&&t._onValueChanged(),t},n.toYawPitchRoll=function(t){return this._toYawPitchRoll(t),t._onValueChanged&&t._onValueChanged(),t},n.rotateX=function(n){return t.rotateX(this,n,this),this},n.rotateY=function(n){return t.rotateY(this,n,this),this},n.rotateZ=function(n){return t.rotateZ(this,n,this),this},n.rotationAxisAngle=function(n,e){return t.rotationAxisAngle(n,e,this),this},n.multiply=function(n){return t.multiply(this,n,this),this},n.invert=function(){return t.invert(this,this),this},n.dot=function(n){return t.dot(this,n)},n.lerp=function(n,e){return t.lerp(this,n,e,this),this},n.rotateAxisAngle=function(n,e){return t._tempQuat1.rotationAxisAngle(n,e),this.multiply(t._tempQuat1),this},n.clone=function(){return new t(this._x,this._y,this._z,this._w)},n.copyFrom=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onValueChanged&&this._onValueChanged(),this},n.copyFromArray=function(t,n){return void 0===n&&(n=0),this._x=t[n],this._y=t[n+1],this._z=t[n+2],this._w=t[n+3],this._onValueChanged&&this._onValueChanged(),this},n.copyToArray=function(t,n){void 0===n&&(n=0),t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._w},n.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},n._toYawPitchRoll=function(t){var n=this._x,e=this._y,i=this._z,a=this._w,r=n*n,_=2*(n*a-e*i);t._y=Math.abs(_)>=1?Math.sign(_)*(Math.PI/2):Math.asin(_),t._x=Math.atan2(2*(i*n+e*a),1-2*(e*e+r)),t._z=Math.atan2(2*(n*e+i*a),1-2*(i*i+r))},t.add=function(t,n,e){e._x=t._x+n._x,e._y=t._y+n._y,e._z=t._z+n._z,e._w=t._w+n._w,e._onValueChanged&&e._onValueChanged()},t.multiply=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=t._w,o=n._x,s=n._y,h=n._z,u=n._w;e._x=i*u+_*o+a*h-r*s,e._y=a*u+_*s+r*o-i*h,e._z=r*u+_*h+i*s-a*o,e._w=_*u-i*o-a*s-r*h,e._onValueChanged&&e._onValueChanged()},t.conjugate=function(t,n){n._x=-t._x,n._y=-t._y,n._z=-t._z,n._w=t._w,n._onValueChanged&&n._onValueChanged()},t.dot=function(t,n){return t._x*n._x+t._y*n._y+t._z*n._z+t._w*n._w},t.equals=function(t,n){return _.equals(t._x,n._x)&&_.equals(t._y,n._y)&&_.equals(t._z,n._z)&&_.equals(t._w,n._w)},t.rotationAxisAngle=function(n,e,i){var a=t._tempVector3;o.normalize(n,a);var r=Math.sin(e*=.5);i._x=a._x*r,i._y=a._y*r,i._z=a._z*r,i._w=Math.cos(e),i._onValueChanged&&i._onValueChanged()},t.rotationEuler=function(n,e,i,a){t.rotationYawPitchRoll(e,n,i,a)},t.rotationYawPitchRoll=function(t,n,e,i){var a=.5*e,r=.5*n,_=.5*t,o=Math.sin(a),s=Math.cos(a),h=Math.sin(r),u=Math.cos(r),c=Math.sin(_),l=Math.cos(_),y=l*u,d=c*h;i._x=l*h*s+c*u*o,i._y=c*u*s-l*h*o,i._z=y*o-d*s,i._w=y*s+d*o,i._onValueChanged&&i._onValueChanged()},t.rotationMatrix3x3=function(t,n){var e,i,a=t.elements,r=a[0],_=a[1],o=a[2],s=a[3],h=a[4],u=a[5],c=a[6],l=a[7],y=a[8],d=r+h+y;d>0?(e=Math.sqrt(d+1),n._w=.5*e,e=.5/e,n._x=(u-l)*e,n._y=(c-o)*e,n._z=(_-s)*e):r>=h&&r>=y?(i=.5/(e=Math.sqrt(1+r-h-y)),n._x=.5*e,n._y=(_+s)*i,n._z=(o+c)*i,n._w=(u-l)*i):h>y?(i=.5/(e=Math.sqrt(1+h-r-y)),n._x=(s+_)*i,n._y=.5*e,n._z=(l+u)*i,n._w=(c-o)*i):(i=.5/(e=Math.sqrt(1+y-r-h)),n._x=(o+c)*i,n._y=(u+l)*i,n._z=.5*e,n._w=(_-s)*i),n._onValueChanged&&n._onValueChanged()},t.invert=function(t,n){var e=t._x,i=t._y,a=t._z,r=t._w,o=e*e+i*i+a*a+r*r;if(o>_.zeroTolerance){var s=1/o;n._x=-e*s,n._y=-i*s,n._z=-a*s,n._w=r*s,n._onValueChanged&&n._onValueChanged()}},t.lerp=function(n,e,i,a){var r=1-i;t.dot(n,e)>=0?(a._x=n._x*r+e._x*i,a._y=n._y*r+e._y*i,a._z=n._z*r+e._z*i,a._w=n._w*r+e._w*i):(a._x=n._x*r-e._x*i,a._y=n._y*r-e._y*i,a._z=n._z*r-e._z*i,a._w=n._w*r-e._w*i),a.normalize()},t.slerp=function(n,e,i,a){var r,o,s=t.dot(n,e);if(Math.abs(s)>1-_.zeroTolerance)o=1-i,r=i*Math.sign(s);else{var h=Math.acos(Math.abs(s)),u=1/Math.sin(h);o=Math.sin((1-i)*h)*u,r=Math.sin(i*h)*u*Math.sign(s)}a.x=o*n.x+r*e.x,a.y=o*n.y+r*e.y,a.z=o*n.z+r*e.z,a.w=o*n.w+r*e.w,a._onValueChanged&&a._onValueChanged()},t.normalize=function(t,n){var e=t._x,i=t._y,a=t._z,r=t._w,o=Math.sqrt(e*e+i*i+a*a+r*r);o>_.zeroTolerance&&(o=1/o,n._x=e*o,n._y=i*o,n._z=a*o,n._w=r*o,n._onValueChanged&&n._onValueChanged())},t.rotationX=function(t,n){var e=Math.sin(t*=.5),i=Math.cos(t);n._x=e,n._y=0,n._z=0,n._w=i,n._onValueChanged&&n._onValueChanged()},t.rotationY=function(t,n){var e=Math.sin(t*=.5),i=Math.cos(t);n._x=0,n._y=e,n._z=0,n._w=i,n._onValueChanged&&n._onValueChanged()},t.rotationZ=function(t,n){var e=Math.sin(t*=.5),i=Math.cos(t);n._x=0,n._y=0,n._z=e,n._w=i,n._onValueChanged&&n._onValueChanged()},t.rotateX=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=t._w,o=Math.sin(n*=.5),s=Math.cos(n);e._x=i*s+_*o,e._y=a*s+r*o,e._z=r*s-a*o,e._w=_*s-i*o,e._onValueChanged&&e._onValueChanged()},t.rotateY=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=t._w,o=Math.sin(n*=.5),s=Math.cos(n);e._x=i*s-r*o,e._y=a*s+_*o,e._z=r*s+i*o,e._w=_*s-a*o,e._onValueChanged&&e._onValueChanged()},t.rotateZ=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=t._w,o=Math.sin(n*=.5),s=Math.cos(n);e._x=i*s+a*o,e._y=a*s-i*o,e._z=r*s+_*o,e._w=_*s-r*o,e._onValueChanged&&e._onValueChanged()},t.scale=function(t,n,e){e._x=t._x*n,e._y=t._y*n,e._z=t._z*n,e._w=t._w*n,e._onValueChanged&&e._onValueChanged()},e(t,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onValueChanged&&this._onValueChanged()}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)<_.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(t){this._w=t,this._onValueChanged&&this._onValueChanged()}}]),t}();d._tempVector3=new o,d._tempQuat1=new d;var f=function(){function t(t,n,e,i,a,r,_,o,s,h,u,c,l,y,d,f){void 0===t&&(t=1),void 0===n&&(n=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===a&&(a=0),void 0===r&&(r=1),void 0===_&&(_=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===h&&(h=0),void 0===u&&(u=1),void 0===c&&(c=0),void 0===l&&(l=0),void 0===y&&(y=0),void 0===d&&(d=0),void 0===f&&(f=1),this.elements=new Float32Array(16);var m=this.elements;m[0]=t,m[1]=n,m[2]=e,m[3]=i,m[4]=a,m[5]=r,m[6]=_,m[7]=o,m[8]=s,m[9]=h,m[10]=u,m[11]=c,m[12]=l,m[13]=y,m[14]=d,m[15]=f}var n=t.prototype;return n.set=function(t,n,e,i,a,r,_,o,s,h,u,c,l,y,d,f){var m=this.elements;return m[0]=t,m[1]=n,m[2]=e,m[3]=i,m[4]=a,m[5]=r,m[6]=_,m[7]=o,m[8]=s,m[9]=h,m[10]=u,m[11]=c,m[12]=l,m[13]=y,m[14]=d,m[15]=f,this},n.multiply=function(n){return t.multiply(this,n,this),this},n.determinant=function(){var t=this.elements,n=t[0],e=t[1],i=t[2],a=t[3],r=t[4],_=t[5],o=t[6],s=t[7],h=t[8],u=t[9],c=t[10],l=t[11],y=t[12],d=t[13],f=t[14],m=t[15];return(n*_-e*r)*(c*m-l*f)-(n*o-i*r)*(u*m-l*d)+(n*s-a*r)*(u*f-c*d)+(e*o-i*_)*(h*m-l*y)-(e*s-a*_)*(h*f-c*y)+(i*s-a*o)*(h*d-u*y)},n.decompose=function(n,e,i){var a=t._tempMat30,r=this.elements,o=a.elements,s=r[0],h=r[1],u=r[2],c=r[3],l=r[4],y=r[5],f=r[6],m=r[7],x=r[8],g=r[9],z=r[10],v=r[11];n.set(r[12],r[13],r[14]);var V=(0>Math.sign(s*h*u*c)?-1:1)*Math.sqrt(s*s+h*h+u*u),C=(0>Math.sign(l*y*f*m)?-1:1)*Math.sqrt(l*l+y*y+f*f),p=(0>Math.sign(x*g*z*v)?-1:1)*Math.sqrt(x*x+g*g+z*z);if(i.set(V,C,p),Math.abs(V)<_.zeroTolerance||Math.abs(C)<_.zeroTolerance||Math.abs(p)<_.zeroTolerance)return e.identity(),!1;var w=1/V,M=1/C,b=1/p;return o[0]=s*w,o[1]=h*w,o[2]=u*w,o[3]=l*M,o[4]=y*M,o[5]=f*M,o[6]=x*b,o[7]=g*b,o[8]=z*b,d.rotationMatrix3x3(a,e),!0},n.getRotation=function(t){var n=this.elements,e=n[0]+n[5]+n[10];if(e>_.zeroTolerance){var i=2*Math.sqrt(e+1);t._w=.25*i,t._x=(n[6]-n[9])/i,t._y=(n[8]-n[2])/i,t._z=(n[1]-n[4])/i}else if(n[0]>n[5]&&n[0]>n[10]){var a=2*Math.sqrt(1+n[0]-n[5]-n[10]);t._w=(n[6]-n[9])/a,t._x=.25*a,t._y=(n[1]+n[4])/a,t._z=(n[8]+n[2])/a}else if(n[5]>n[10]){var r=2*Math.sqrt(1+n[5]-n[0]-n[10]);t._w=(n[8]-n[2])/r,t._x=(n[1]+n[4])/r,t._y=.25*r,t._z=(n[6]+n[9])/r}else{var o=2*Math.sqrt(1+n[10]-n[0]-n[5]);t._w=(n[1]-n[4])/o,t._x=(n[8]+n[2])/o,t._y=(n[6]+n[9])/o,t._z=.25*o}return t._onValueChanged&&t._onValueChanged(),t},n.getScaling=function(t){var n=this.elements,e=n[0],i=n[1],a=n[2],r=n[4],_=n[5],o=n[6],s=n[8],h=n[9],u=n[10];return t.set(Math.sqrt(e*e+i*i+a*a),Math.sqrt(r*r+_*_+o*o),Math.sqrt(s*s+h*h+u*u)),t},n.getTranslation=function(t){var n=this.elements;return t.set(n[12],n[13],n[14]),t},n.identity=function(){var t=this.elements;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},n.invert=function(){return t.invert(this,this),this},n.rotateAxisAngle=function(n,e){return t.rotateAxisAngle(this,n,e,this),this},n.scale=function(n){return t.scale(this,n,this),this},n.translate=function(n){return t.translate(this,n,this),this},n.transpose=function(){return t.transpose(this,this),this},n.clone=function(){var n=this.elements;return new t(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])},n.copyFrom=function(t){var n=this.elements,e=t.elements;return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],this},n.copyFromArray=function(t,n){void 0===n&&(n=0);for(var e=this.elements,i=0;i<16;i++)e[i]=t[i+n];return this},n.copyToArray=function(t,n){void 0===n&&(n=0);var e=this.elements;t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t[n+9]=e[9],t[n+10]=e[10],t[n+11]=e[11],t[n+12]=e[12],t[n+13]=e[13],t[n+14]=e[14],t[n+15]=e[15]},t.multiply=function(t,n,e){var i=t.elements,a=n.elements,r=e.elements,_=i[0],o=i[1],s=i[2],h=i[3],u=i[4],c=i[5],l=i[6],y=i[7],d=i[8],f=i[9],m=i[10],x=i[11],g=i[12],z=i[13],v=i[14],V=i[15],C=a[0],p=a[1],w=a[2],M=a[3],b=a[4],q=a[5],T=a[6],F=a[7],A=a[8],P=a[9],S=a[10],B=a[11],k=a[12],I=a[13],R=a[14],N=a[15];r[0]=_*C+u*p+d*w+g*M,r[1]=o*C+c*p+f*w+z*M,r[2]=s*C+l*p+m*w+v*M,r[3]=h*C+y*p+x*w+V*M,r[4]=_*b+u*q+d*T+g*F,r[5]=o*b+c*q+f*T+z*F,r[6]=s*b+l*q+m*T+v*F,r[7]=h*b+y*q+x*T+V*F,r[8]=_*A+u*P+d*S+g*B,r[9]=o*A+c*P+f*S+z*B,r[10]=s*A+l*P+m*S+v*B,r[11]=h*A+y*P+x*S+V*B,r[12]=_*k+u*I+d*R+g*N,r[13]=o*k+c*I+f*R+z*N,r[14]=s*k+l*I+m*R+v*N,r[15]=h*k+y*I+x*R+V*N},t.equals=function(t,n){var e=t.elements,i=n.elements;return _.equals(e[0],i[0])&&_.equals(e[1],i[1])&&_.equals(e[2],i[2])&&_.equals(e[3],i[3])&&_.equals(e[4],i[4])&&_.equals(e[5],i[5])&&_.equals(e[6],i[6])&&_.equals(e[7],i[7])&&_.equals(e[8],i[8])&&_.equals(e[9],i[9])&&_.equals(e[10],i[10])&&_.equals(e[11],i[11])&&_.equals(e[12],i[12])&&_.equals(e[13],i[13])&&_.equals(e[14],i[14])&&_.equals(e[15],i[15])},t.lerp=function(t,n,e,i){var a=t.elements,r=n.elements,_=i.elements,o=1-e;_[0]=a[0]*o+r[0]*e,_[1]=a[1]*o+r[1]*e,_[2]=a[2]*o+r[2]*e,_[3]=a[3]*o+r[3]*e,_[4]=a[4]*o+r[4]*e,_[5]=a[5]*o+r[5]*e,_[6]=a[6]*o+r[6]*e,_[7]=a[7]*o+r[7]*e,_[8]=a[8]*o+r[8]*e,_[9]=a[9]*o+r[9]*e,_[10]=a[10]*o+r[10]*e,_[11]=a[11]*o+r[11]*e,_[12]=a[12]*o+r[12]*e,_[13]=a[13]*o+r[13]*e,_[14]=a[14]*o+r[14]*e,_[15]=a[15]*o+r[15]*e},t.add=function(t,n,e){var i=t.elements,a=n.elements,r=e.elements;r[0]=i[0]+a[0],r[1]=i[1]+a[1],r[2]=i[2]+a[2],r[3]=i[3]+a[3],r[4]=i[4]+a[4],r[5]=i[5]+a[5],r[6]=i[6]+a[6],r[7]=i[7]+a[7],r[8]=i[8]+a[8],r[9]=i[9]+a[9],r[10]=i[10]+a[10],r[11]=i[11]+a[11],r[12]=i[12]+a[12],r[13]=i[13]+a[13],r[14]=i[14]+a[14],r[15]=i[15]+a[15]},t.multiplyScalar=function(t,n,e){var i=t.elements,a=e.elements;a[0]=i[0]*n,a[1]=i[1]*n,a[2]=i[2]*n,a[3]=i[3]*n,a[4]=i[4]*n,a[5]=i[5]*n,a[6]=i[6]*n,a[7]=i[7]*n,a[8]=i[8]*n,a[9]=i[9]*n,a[10]=i[10]*n,a[11]=i[11]*n,a[12]=i[12]*n,a[13]=i[13]*n,a[14]=i[14]*n,a[15]=i[15]*n},t.rotationQuaternion=function(t,n){var e=n.elements,i=t._x,a=t._y,r=t._z,_=t._w,o=i+i,s=a+a,h=r+r,u=i*o,c=a*o,l=a*s,y=r*o,d=r*s,f=r*h,m=_*o,x=_*s,g=_*h;e[0]=1-l-f,e[1]=c+g,e[2]=y-x,e[3]=0,e[4]=c-g,e[5]=1-u-f,e[6]=d+m,e[7]=0,e[8]=y+x,e[9]=d-m,e[10]=1-u-l,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1},t.rotationAxisAngle=function(t,n,e){var i,a,r,o=e.elements,s=t._x,h=t._y,u=t._z,c=Math.sqrt(s*s+h*h+u*u);Math.abs(c)<_.zeroTolerance||(s*=c=1/c,h*=c,u*=c,i=Math.sin(n),r=1-(a=Math.cos(n)),o[0]=s*s*r+a,o[1]=h*s*r+u*i,o[2]=u*s*r-h*i,o[3]=0,o[4]=s*h*r-u*i,o[5]=h*h*r+a,o[6]=u*h*r+s*i,o[7]=0,o[8]=s*u*r+h*i,o[9]=h*u*r-s*i,o[10]=u*u*r+a,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1)},t.rotationTranslation=function(n,e,i){t.rotationQuaternion(n,i);var a=i.elements;a[12]=e._x,a[13]=e._y,a[14]=e._z},t.affineTransformation=function(t,n,e,i){var a=i.elements,r=n._x,_=n._y,o=n._z,s=n._w,h=r+r,u=_+_,c=o+o,l=r*h,y=r*u,d=r*c,f=_*u,m=_*c,x=o*c,g=s*h,z=s*u,v=s*c,V=t._x,C=t._y,p=t._z;a[0]=(1-(f+x))*V,a[1]=(y+v)*V,a[2]=(d-z)*V,a[3]=0,a[4]=(y-v)*C,a[5]=(1-(l+x))*C,a[6]=(m+g)*C,a[7]=0,a[8]=(d+z)*p,a[9]=(m-g)*p,a[10]=(1-(l+f))*p,a[11]=0,a[12]=e._x,a[13]=e._y,a[14]=e._z,a[15]=1},t.scaling=function(t,n){var e=n.elements;e[0]=t._x,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t._y,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t._z,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1},t.translation=function(t,n){var e=n.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t._x,e[13]=t._y,e[14]=t._z,e[15]=1},t.invert=function(t,n){var e=t.elements,i=n.elements,a=e[0],r=e[1],_=e[2],o=e[3],s=e[4],h=e[5],u=e[6],c=e[7],l=e[8],y=e[9],d=e[10],f=e[11],m=e[12],x=e[13],g=e[14],z=e[15],v=a*h-r*s,V=a*u-_*s,C=a*c-o*s,p=r*u-_*h,w=r*c-o*h,M=_*c-o*u,b=l*x-y*m,q=l*g-d*m,T=l*z-f*m,F=y*g-d*x,A=y*z-f*x,P=d*z-f*g,S=v*P-V*A+C*F+p*T-w*q+M*b;if(!S)return null;S=1/S,i[0]=(h*P-u*A+c*F)*S,i[1]=(_*A-r*P-o*F)*S,i[2]=(x*M-g*w+z*p)*S,i[3]=(d*w-y*M-f*p)*S,i[4]=(u*T-s*P-c*q)*S,i[5]=(a*P-_*T+o*q)*S,i[6]=(g*C-m*M-z*V)*S,i[7]=(l*M-d*C+f*V)*S,i[8]=(s*A-h*T+c*b)*S,i[9]=(r*T-a*A-o*b)*S,i[10]=(m*w-x*C+z*v)*S,i[11]=(y*C-l*w-f*v)*S,i[12]=(h*q-s*F-u*b)*S,i[13]=(a*F-r*q+_*b)*S,i[14]=(x*V-m*p-g*v)*S,i[15]=(l*p-y*V+d*v)*S},t.lookAt=function(n,e,i,a){var r=a.elements,_=t._tempVec30,s=t._tempVec31,h=t._tempVec32;o.subtract(n,e,h),h.normalize(),o.cross(i,h,_),_.normalize(),o.cross(h,_,s),r[0]=_._x,r[1]=s._x,r[2]=h._x,r[3]=0,r[4]=_._y,r[5]=s._y,r[6]=h._y,r[7]=0,r[8]=_._z,r[9]=s._z,r[10]=h._z,r[11]=0,r[12]=-o.dot(_,n),r[13]=-o.dot(s,n),r[14]=-o.dot(h,n),r[15]=1},t.ortho=function(t,n,e,i,a,r,_){var o=_.elements,s=1/(t-n),h=1/(e-i),u=1/(a-r);o[0]=-2*s,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*h,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*u,o[11]=0,o[12]=(t+n)*s,o[13]=(i+e)*h,o[14]=(r+a)*u,o[15]=1},t.perspective=function(t,n,e,i,a){var r=a.elements,_=1/Math.tan(t/2),o=1/(e-i);r[0]=_/n,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=_,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=(i+e)*o,r[11]=-1,r[12]=0,r[13]=0,r[14]=2*i*e*o,r[15]=0},t.rotateAxisAngle=function(t,n,e,i){var a,r,o,s=n._x,h=n._y,u=n._z,c=Math.sqrt(s*s+h*h+u*u);if(!(Math.abs(c)<_.zeroTolerance)){var l=t.elements,y=i.elements;s*=c=1/c,h*=c,u*=c,a=Math.sin(e),o=1-(r=Math.cos(e));var d=l[0],f=l[1],m=l[2],x=l[3],g=l[4],z=l[5],v=l[6],V=l[7],C=l[8],p=l[9],w=l[10],M=l[11],b=s*s*o+r,q=h*s*o+u*a,T=u*s*o-h*a,F=s*h*o-u*a,A=h*h*o+r,P=u*h*o+s*a,S=s*u*o+h*a,B=h*u*o-s*a,k=u*u*o+r;y[0]=d*b+g*q+C*T,y[1]=f*b+z*q+p*T,y[2]=m*b+v*q+w*T,y[3]=x*b+V*q+M*T,y[4]=d*F+g*A+C*P,y[5]=f*F+z*A+p*P,y[6]=m*F+v*A+w*P,y[7]=x*F+V*A+M*P,y[8]=d*S+g*B+C*k,y[9]=f*S+z*B+p*k,y[10]=m*S+v*B+w*k,y[11]=x*S+V*B+M*k,t!==i&&(y[12]=l[12],y[13]=l[13],y[14]=l[14],y[15]=l[15])}},t.scale=function(t,n,e){var i=t.elements,a=e.elements,r=n._x,_=n._y,o=n._z;a[0]=i[0]*r,a[1]=i[1]*r,a[2]=i[2]*r,a[3]=i[3]*r,a[4]=i[4]*_,a[5]=i[5]*_,a[6]=i[6]*_,a[7]=i[7]*_,a[8]=i[8]*o,a[9]=i[9]*o,a[10]=i[10]*o,a[11]=i[11]*o,a[12]=i[12],a[13]=i[13],a[14]=i[14],a[15]=i[15]},t.translate=function(t,n,e){var i=t.elements,a=e.elements,r=n._x,_=n._y,o=n._z;if(t===e)a[12]=i[0]*r+i[4]*_+i[8]*o+i[12],a[13]=i[1]*r+i[5]*_+i[9]*o+i[13],a[14]=i[2]*r+i[6]*_+i[10]*o+i[14],a[15]=i[3]*r+i[7]*_+i[11]*o+i[15];else{var s=i[0],h=i[1],u=i[2],c=i[3],l=i[4],y=i[5],d=i[6],f=i[7],m=i[8],x=i[9],g=i[10],z=i[11];a[0]=s,a[1]=h,a[2]=u,a[3]=c,a[4]=l,a[5]=y,a[6]=d,a[7]=f,a[8]=m,a[9]=x,a[10]=g,a[11]=z,a[12]=s*r+l*_+m*o+i[12],a[13]=h*r+y*_+x*o+i[13],a[14]=u*r+d*_+g*o+i[14],a[15]=c*r+f*_+z*o+i[15]}},t.transpose=function(t,n){var e=t.elements,i=n.elements;if(n===t){var a=e[1],r=e[2],_=e[3],o=e[6],s=e[7],h=e[11];i[1]=e[4],i[2]=e[8],i[3]=e[12],i[4]=a,i[6]=e[9],i[7]=e[13],i[8]=r,i[9]=o,i[11]=e[14],i[12]=_,i[13]=s,i[14]=h}else i[0]=e[0],i[1]=e[4],i[2]=e[8],i[3]=e[12],i[4]=e[1],i[5]=e[5],i[6]=e[9],i[7]=e[13],i[8]=e[2],i[9]=e[6],i[10]=e[10],i[11]=e[14],i[12]=e[3],i[13]=e[7],i[14]=e[11],i[15]=e[15]},t}();f._tempVec30=new o,f._tempVec31=new o,f._tempVec32=new o,f._tempMat30=new y,f._identity=new f(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var m=function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n=null),this.origin=new o,this.direction=new o,t&&this.origin.copyFrom(t),n&&this.direction.copyFrom(n)}var n=t.prototype;return n.intersectPlane=function(t){return u.intersectsRayAndPlane(this,t)},n.intersectSphere=function(t){return u.intersectsRayAndSphere(this,t)},n.intersectBox=function(t){return u.intersectsRayAndBox(this,t)},n.getPoint=function(t,n){return o.scale(this.direction,t,n),n.add(this.origin)},t}(),x=function(){function t(t,n){void 0===t&&(t=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=t,this._y=n}var n=t.prototype;return n.set=function(t,n){return this._x=t,this._y=n,this._onValueChanged&&this._onValueChanged(),this},n.add=function(t){return this._x+=t._x,this._y+=t._y,this._onValueChanged&&this._onValueChanged(),this},n.subtract=function(t){return this._x-=t._x,this._y-=t._y,this._onValueChanged&&this._onValueChanged(),this},n.multiply=function(t){return this._x*=t._x,this._y*=t._y,this._onValueChanged&&this._onValueChanged(),this},n.divide=function(t){return this._x/=t._x,this._y/=t._y,this._onValueChanged&&this._onValueChanged(),this},n.length=function(){var t=this._x,n=this._y;return Math.sqrt(t*t+n*n)},n.lengthSquared=function(){var t=this._x,n=this._y;return t*t+n*n},n.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},n.normalize=function(){return t.normalize(this,this),this},n.scale=function(t){return this._x*=t,this._y*=t,this._onValueChanged&&this._onValueChanged(),this},n.clone=function(){return new t(this._x,this._y)},n.copyFrom=function(t){return this._x=t.x,this._y=t.y,this._onValueChanged&&this._onValueChanged(),this},n.copyFromArray=function(t,n){return void 0===n&&(n=0),this._x=t[n],this._y=t[n+1],this._onValueChanged&&this._onValueChanged(),this},n.copyToArray=function(t,n){void 0===n&&(n=0),t[n]=this._x,t[n+1]=this._y},n.toJSON=function(){return{x:this._x,y:this._y}},t.add=function(t,n,e){e._x=t._x+n._x,e._y=t._y+n._y,e._onValueChanged&&e._onValueChanged()},t.subtract=function(t,n,e){e._x=t._x-n._x,e._y=t._y-n._y,e._onValueChanged&&e._onValueChanged()},t.multiply=function(t,n,e){e._x=t._x*n._x,e._y=t._y*n._y,e._onValueChanged&&e._onValueChanged()},t.divide=function(t,n,e){e._x=t._x/n._x,e._y=t._y/n._y,e._onValueChanged&&e._onValueChanged()},t.dot=function(t,n){return t._x*n._x+t._y*n._y},t.distance=function(t,n){var e=n._x-t._x,i=n._y-t._y;return Math.sqrt(e*e+i*i)},t.distanceSquared=function(t,n){var e=n._x-t._x,i=n._y-t._y;return e*e+i*i},t.equals=function(t,n){return _.equals(t._x,n._x)&&_.equals(t._y,n._y)},t.lerp=function(t,n,e,i){var a=t._x,r=t._y;i._x=a+(n._x-a)*e,i._y=r+(n._y-r)*e,i._onValueChanged&&i._onValueChanged()},t.max=function(t,n,e){e._x=Math.max(t._x,n._x),e._y=Math.max(t._y,n._y),e._onValueChanged&&e._onValueChanged()},t.min=function(t,n,e){e._x=Math.min(t._x,n._x),e._y=Math.min(t._y,n._y),e._onValueChanged&&e._onValueChanged()},t.negate=function(t,n){n._x=-t._x,n._y=-t._y,n._onValueChanged&&n._onValueChanged()},t.normalize=function(t,n){var e=t._x,i=t._y,a=Math.sqrt(e*e+i*i);a>_.zeroTolerance&&(a=1/a,n._x=e*a,n._y=i*a,n._onValueChanged&&n._onValueChanged())},t.scale=function(t,n,e){e._x=t._x*n,e._y=t._y*n,e._onValueChanged&&e._onValueChanged()},e(t,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}}]),t}();x._zero=new x(0,0),x._one=new x(1,1);var g=function(){function t(t,n,e,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===e&&(e=0),void 0===i&&(i=0),this._onValueChanged=null,this._x=t,this._y=n,this._z=e,this._w=i}var n=t.prototype;return n.set=function(t,n,e,i){return this._x=t,this._y=n,this._z=e,this._w=i,this._onValueChanged&&this._onValueChanged(),this},n.add=function(t){return this._x+=t._x,this._y+=t._y,this._z+=t._z,this._w+=t._w,this._onValueChanged&&this._onValueChanged(),this},n.subtract=function(t){return this._x-=t._x,this._y-=t._y,this._z-=t._z,this._w-=t._w,this._onValueChanged&&this._onValueChanged(),this},n.multiply=function(t){return this._x*=t._x,this._y*=t._y,this._z*=t._z,this._w*=t._w,this._onValueChanged&&this._onValueChanged(),this},n.divide=function(t){return this._x/=t._x,this._y/=t._y,this._z/=t._z,this._w/=t._w,this._onValueChanged&&this._onValueChanged(),this},n.length=function(){var t=this._x,n=this._y,e=this._z,i=this._w;return Math.sqrt(t*t+n*n+e*e+i*i)},n.lengthSquared=function(){var t=this._x,n=this._y,e=this._z,i=this._w;return t*t+n*n+e*e+i*i},n.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},n.normalize=function(){return t.normalize(this,this),this},n.scale=function(t){return this._x*=t,this._y*=t,this._z*=t,this._w*=t,this._onValueChanged&&this._onValueChanged(),this},n.clone=function(){return new t(this._x,this._y,this._z,this._w)},n.copyFrom=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onValueChanged&&this._onValueChanged(),this},n.copyFromArray=function(t,n){return void 0===n&&(n=0),this._x=t[n],this._y=t[n+1],this._z=t[n+2],this._w=t[n+3],this._onValueChanged&&this._onValueChanged(),this},n.copyToArray=function(t,n){void 0===n&&(n=0),t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._w},n.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},t.add=function(t,n,e){e._x=t._x+n._x,e._y=t._y+n._y,e._z=t._z+n._z,e._w=t._w+n._w,e._onValueChanged&&e._onValueChanged()},t.subtract=function(t,n,e){e._x=t._x-n._x,e._y=t._y-n._y,e._z=t._z-n._z,e._w=t._w-n._w,e._onValueChanged&&e._onValueChanged()},t.multiply=function(t,n,e){e._x=t._x*n._x,e._y=t._y*n._y,e._z=t._z*n._z,e._w=t._w*n._w,e._onValueChanged&&e._onValueChanged()},t.divide=function(t,n,e){e._x=t._x/n._x,e._y=t._y/n._y,e._z=t._z/n._z,e._w=t._w/n._w,e._onValueChanged&&e._onValueChanged()},t.dot=function(t,n){return t._x*n._x+t._y*n._y+t._z*n._z+t._w*n._w},t.distance=function(t,n){var e=n._x-t._x,i=n._y-t._y,a=n._z-t._z,r=n._w-t._w;return Math.sqrt(e*e+i*i+a*a+r*r)},t.distanceSquared=function(t,n){var e=n._x-t._x,i=n._y-t._y,a=n._z-t._z,r=n._w-t._w;return e*e+i*i+a*a+r*r},t.equals=function(t,n){return _.equals(t._x,n._x)&&_.equals(t._y,n._y)&&_.equals(t._z,n._z)&&_.equals(t._w,n._w)},t.lerp=function(t,n,e,i){var a=t._x,r=t._y,_=t._z,o=t._w;i._x=a+(n._x-a)*e,i._y=r+(n._y-r)*e,i._z=_+(n._z-_)*e,i._w=o+(n._w-o)*e,i._onValueChanged&&i._onValueChanged()},t.max=function(t,n,e){e._x=Math.max(t._x,n._x),e._y=Math.max(t._y,n._y),e._z=Math.max(t._z,n._z),e._w=Math.max(t._w,n._w),e._onValueChanged&&e._onValueChanged()},t.min=function(t,n,e){e._x=Math.min(t._x,n._x),e._y=Math.min(t._y,n._y),e._z=Math.min(t._z,n._z),e._w=Math.min(t._w,n._w),e._onValueChanged&&e._onValueChanged()},t.negate=function(t,n){n._x=-t._x,n._y=-t._y,n._z=-t._z,n._w=-t._w,n._onValueChanged&&n._onValueChanged()},t.normalize=function(t,n){var e=t._x,i=t._y,a=t._z,r=t._w,o=Math.sqrt(e*e+i*i+a*a+r*r);o>_.zeroTolerance&&(o=1/o,n._x=e*o,n._y=i*o,n._z=a*o,n._w=r*o,n._onValueChanged&&n._onValueChanged())},t.scale=function(t,n,e){e._x=t._x*n,e._y=t._y*n,e._z=t._z*n,e._w=t._w*n,e._onValueChanged&&e._onValueChanged()},t.transform=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=t._w,o=n.elements;e._x=i*o[0]+a*o[4]+r*o[8]+_*o[12],e._y=i*o[1]+a*o[5]+r*o[9]+_*o[13],e._z=i*o[2]+a*o[6]+r*o[10]+_*o[14],e._w=i*o[3]+a*o[7]+r*o[11]+_*o[15],e._onValueChanged&&e._onValueChanged()},t.transformByQuat=function(t,n,e){var i=t._x,a=t._y,r=t._z,_=t._w,o=n._x,s=n._y,h=n._z,u=n._w,c=u*i+s*r-h*a,l=u*a+h*i-o*r,y=u*r+o*a-s*i,d=-o*i-s*a-h*r;e._x=c*u-d*o-l*h+y*s,e._y=l*u-d*s-y*o+c*h,e._z=y*u-d*h-c*s+l*o,e._w=_,e._onValueChanged&&e._onValueChanged()},e(t,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(t){this._w=t,this._onValueChanged&&this._onValueChanged()}}]),t}();g._zero=new g(0,0,0,0),g._one=new g(1,1,1,1);var z=function(){function t(t,n,e,i){void 0===t&&(t=1),void 0===n&&(n=1),void 0===e&&(e=1),void 0===i&&(i=1),this._onValueChanged=null,this._r=t,this._g=n,this._b=e,this._a=i}var n=t.prototype;return n.set=function(t,n,e,i){return this._r=t,this._g=n,this._b=e,this._a=i,this._onValueChanged&&this._onValueChanged(),this},n.add=function(t){return this._r+=t._r,this._g+=t._g,this._b+=t._b,this._a+=t._a,this._onValueChanged&&this._onValueChanged(),this},n.scale=function(t){return this._r*=t,this._g*=t,this._b*=t,this._a*=t,this._onValueChanged&&this._onValueChanged(),this},n.clone=function(){return new t(this._r,this._g,this._b,this._a)},n.copyFrom=function(t){return this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._onValueChanged&&this._onValueChanged(),this},n.toLinear=function(n){return n._r=t.gammaToLinearSpace(this._r),n._g=t.gammaToLinearSpace(this._g),n._b=t.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),n},n.toGamma=function(n){return n._r=t.linearToGammaSpace(this._r),n._g=t.linearToGammaSpace(this._g),n._b=t.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),n},n.getBrightness=function(){var t=this.r,n=this.g,e=this.b,i=t,a=t;return n>i&&(i=n),e>i&&(i=e),n<a&&(a=n),e<a&&(a=e),(i+a)/2},n.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},t.gammaToLinearSpace=function(t){return t<=0?0:t<=.04045?t/12.92:t<1?Math.pow((t+.055)/1.055,2.4):Math.pow(t,2.4)},t.linearToGammaSpace=function(t){return t<=0?0:t<.0031308?12.92*t:t<1?1.055*Math.pow(t,.41666)-.055:Math.pow(t,.41666)},t.equals=function(t,n){return _.equals(t._r,n._r)&&_.equals(t._g,n._g)&&_.equals(t._b,n._b)&&_.equals(t._a,n._a)},t.add=function(t,n,e){return e._r=t._r+n._r,e._g=t._g+n._g,e._b=t._b+n._b,e._a=t._a+n._a,e._onValueChanged&&e._onValueChanged(),e},t.subtract=function(t,n,e){e._r=t._r-n._r,e._g=t._g-n._g,e._b=t._b-n._b,e._a=t._a-n._a,e._onValueChanged&&e._onValueChanged()},t.scale=function(t,n,e){return e._r=t._r*n,e._g=t._g*n,e._b=t._b*n,e._a=t._a*n,e._onValueChanged&&e._onValueChanged(),e},t.lerp=function(t,n,e,i){var a=t._r,r=t._g,_=t._b,o=t._a;return i._r=a+(n._r-a)*e,i._g=r+(n._g-r)*e,i._b=_+(n._b-_)*e,i._a=o+(n._a-o)*e,i._onValueChanged&&i._onValueChanged(),i},e(t,[{key:"r",get:function(){return this._r},set:function(t){this._r=t,this._onValueChanged&&this._onValueChanged()}},{key:"g",get:function(){return this._g},set:function(t){this._g=t,this._onValueChanged&&this._onValueChanged()}},{key:"b",get:function(){return this._b},set:function(t){this._b=t,this._onValueChanged&&this._onValueChanged()}},{key:"a",get:function(){return this._a},set:function(t){this._a=t,this._onValueChanged&&this._onValueChanged()}}]),t}(),v=function(){function t(t,n,e,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=n,this.width=e,this.height=i}var n=t.prototype;return n.set=function(t,n,e,i){return this.x=t,this.y=n,this.width=e,this.height=i,this},n.clone=function(){return new t(this.x,this.y,this.width,this.height)},n.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this},t}(),V=function(){function t(){this.coefficients=new Float32Array(27)}var n=t.prototype;return n.addLight=function(t,n,e){n.scale(e);var i=this.coefficients,a=t._x,r=t._y,_=t._z,o=n.r,s=n.g,h=n.b,u=-.488603*r,c=.488603*_,l=-.488603*a,y=1.092548*(a*r),d=-1.092548*(r*_),f=.315392*(3*_*_-1),m=-1.092548*(a*_),x=.546274*(a*a-r*r);i[0]+=.282095*o,i[1]+=.282095*s,i[2]+=.282095*h,i[3]+=o*u,i[4]+=s*u,i[5]+=h*u,i[6]+=o*c,i[7]+=s*c,i[8]+=h*c,i[9]+=o*l,i[10]+=s*l,i[11]+=h*l,i[12]+=o*y,i[13]+=s*y,i[14]+=h*y,i[15]+=o*d,i[16]+=s*d,i[17]+=h*d,i[18]+=o*f,i[19]+=s*f,i[20]+=h*f,i[21]+=o*m,i[22]+=s*m,i[23]+=h*m,i[24]+=o*x,i[25]+=s*x,i[26]+=h*x},n.evaluate=function(t,n){var e=this.coefficients,i=t._x,a=t._y,r=t._z,_=-1.023327*a,o=1.023327*r,s=-1.023327*i,h=.858086*a*i,u=-.858086*a*r,c=.247708*(3*r*r-1),l=-.858086*r*i,y=.429042*(i*i-a*a),d=.886227*e[0],f=.886227*e[1],m=.886227*e[2];return d+=e[3]*_+e[6]*o+e[9]*s,f+=e[4]*_+e[7]*o+e[10]*s,m+=e[5]*_+e[8]*o+e[11]*s,d+=e[12]*h+e[15]*u+e[18]*c+e[21]*l+e[24]*y,f+=e[13]*h+e[16]*u+e[19]*c+e[22]*l+e[25]*y,m+=e[14]*h+e[17]*u+e[20]*c+e[23]*l+e[26]*y,n.set(d,f,m,1),n},n.scale=function(t){var n=this.coefficients;n[0]*=t,n[1]*=t,n[2]*=t,n[3]*=t,n[4]*=t,n[5]*=t,n[6]*=t,n[7]*=t,n[8]*=t,n[9]*=t,n[10]*=t,n[11]*=t,n[12]*=t,n[13]*=t,n[14]*=t,n[15]*=t,n[16]*=t,n[17]*=t,n[18]*=t,n[19]*=t,n[20]*=t,n[21]*=t,n[22]*=t,n[23]*=t,n[24]*=t,n[25]*=t,n[26]*=t},n.clone=function(){var n=new t;return n.copyFrom(this),n},n.copyFrom=function(t){return t.copyToArray(this.coefficients),this},n.copyFromArray=function(t,n){void 0===n&&(n=0);var e=this.coefficients;e[0]=t[n],e[1]=t[1+n],e[2]=t[2+n],e[3]=t[3+n],e[4]=t[4+n],e[5]=t[5+n],e[6]=t[6+n],e[7]=t[7+n],e[8]=t[8+n],e[9]=t[9+n],e[10]=t[10+n],e[11]=t[11+n],e[12]=t[12+n],e[13]=t[13+n],e[14]=t[14+n],e[15]=t[15+n],e[16]=t[16+n],e[17]=t[17+n],e[18]=t[18+n],e[19]=t[19+n],e[20]=t[20+n],e[21]=t[21+n],e[22]=t[22+n],e[23]=t[23+n],e[24]=t[24+n],e[25]=t[25+n],e[26]=t[26+n]},n.copyToArray=function(t,n){void 0===n&&(n=0);var e=this.coefficients;t[0+n]=e[0],t[1+n]=e[1],t[2+n]=e[2],t[3+n]=e[3],t[4+n]=e[4],t[5+n]=e[5],t[6+n]=e[6],t[7+n]=e[7],t[8+n]=e[8],t[9+n]=e[9],t[10+n]=e[10],t[11+n]=e[11],t[12+n]=e[12],t[13+n]=e[13],t[14+n]=e[14],t[15+n]=e[15],t[16+n]=e[16],t[17+n]=e[17],t[18+n]=e[18],t[19+n]=e[19],t[20+n]=e[20],t[21+n]=e[21],t[22+n]=e[22],t[23+n]=e[23],t[24+n]=e[24],t[25+n]=e[25],t[26+n]=e[26]},t}();t.BoundingBox=h,t.BoundingFrustum=l,t.BoundingSphere=s,t.CollisionUtil=u,t.Color=z,t.MathUtil=_,t.Matrix=f,t.Matrix3x3=y,t.Plane=c,t.Quaternion=d,t.Ray=m,t.Rect=v,t.SphericalHarmonics3=V,t.Vector2=x,t.Vector3=o,t.Vector4=g,Object.defineProperty(t,"__esModule",{value:!0})});