@galacean/engine-math 1.0.0-alpha.6 → 1.0.0

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.
@@ -1 +0,0 @@
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,o=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}();o.zeroTolerance=1e-6,o.radToDegreeFactor=180/Math.PI,o.degreeToRadFactor=Math.PI/180;var s=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,o=n._x,s=n._y,_=n._z;e.set(a*_-r*s,r*o-i*_,i*s-a*o)},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 o.equals(t._x,n._x)&&o.equals(t._y,n._y)&&o.equals(t._z,n._z)},t.lerp=function(t,n,e,i){var a=t._x,r=t._y,o=t._z;i._x=a+(n._x-a)*e,i._y=r+(n._y-r)*e,i._z=o+(n._z-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._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>o.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,o=n.elements;e._x=i*o[0]+a*o[4]+r*o[8],e._y=i*o[1]+a*o[5]+r*o[9],e._z=i*o[2]+a*o[6]+r*o[10],e._onValueChanged&&e._onValueChanged()},t.transformToVec3=function(t,n,e){var i=t._x,a=t._y,r=t._z,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._onValueChanged&&e._onValueChanged()},t.transformToVec4=function(t,n,e){var i=t._x,a=t._y,r=t._z,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.transformCoordinate=function(t,n,e){var i=t._x,a=t._y,r=t._z,o=n.elements,s=i*o[3]+a*o[7]+r*o[11]+o[15];s=1/s,e._x=(i*o[0]+a*o[4]+r*o[8]+o[12])*s,e._y=(i*o[1]+a*o[5]+r*o[9]+o[13])*s,e._z=(i*o[2]+a*o[6]+r*o[10]+o[14])*s,e._onValueChanged&&e._onValueChanged()},t.transformByQuat=function(t,n,e){var i=t._x,a=t._y,r=t._z,o=n._x,s=n._y,_=n._z,h=n._w,u=h*i+s*r-_*a,c=h*a+_*i-o*r,l=h*r+o*a-s*i,y=-o*i-s*a-_*r;e._x=u*h-y*o-c*_+l*s,e._y=c*h-y*s-l*o+u*_,e._z=l*h-y*_-u*s+c*o,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}();s._zero=new s(0,0,0),s._one=new s(1,1,1);var _=function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n=0),this.center=new s,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)s.add(n[r],a,a);s.scale(a,1/i,e.center);for(var o=0,_=0;_<i;++_){var h=s.distanceSquared(a,n[_]);h>o&&(o=h)}e.radius=Math.sqrt(o)},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=s.distance(e,a)},t}();_._tempVec30=new s;var h=function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n=null),this.min=new s,this.max=new s,t&&this.min.copyFrom(t),n&&this.max.copyFrom(n)}var n=t.prototype;return n.getCenter=function(t){return s.add(this.min,this.max,t),s.scale(t,.5,t),t},n.getExtent=function(t){return s.subtract(this.max,this.min,t),s.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,o=e.x,_=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 s;return t[0].set(i,_,h),t[1].set(o,_,h),t[2].set(o,a,h),t[3].set(i,a,h),t[4].set(i,_,r),t[5].set(o,_,r),t[6].set(o,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){s.subtract(t,n,e.min),s.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 o=t[a];s.min(e,o,e),s.max(i,o,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),s.transformCoordinate(a,e,a);var o=r.x,_=r.y,h=r.z,u=e.elements;r.x=Math.abs(o*u[0])+Math.abs(_*u[4])+Math.abs(h*u[8]),r.y=Math.abs(o*u[1])+Math.abs(_*u[5])+Math.abs(h*u[9]),r.z=Math.abs(o*u[2])+Math.abs(_*u[6])+Math.abs(h*u[10]),s.subtract(a,r,i.min),s.add(a,r,i.max)},t.merge=function(t,n,e){return s.min(t.min,n.min,e.min),s.max(t.max,n.max,e.max),e},t}();h._tempVec30=new s,h._tempVec31=new s;var u=function(){function n(){}return n.intersectionPointThreePlanes=function(t,e,i,a){var r=t.normal,o=e.normal,_=i.normal;s.cross(o,_,n._tempVec30),s.cross(_,r,n._tempVec31),s.cross(r,o,n._tempVec32);var h=-s.dot(r,n._tempVec30),u=-s.dot(o,n._tempVec31),c=-s.dot(_,n._tempVec32);s.scale(n._tempVec30,t.distance/h,n._tempVec30),s.scale(n._tempVec31,e.distance/u,n._tempVec31),s.scale(n._tempVec32,i.distance/c,n._tempVec32),s.add(n._tempVec30,n._tempVec31,a),s.add(a,n._tempVec32,a)},n.distancePlaneAndPoint=function(t,n){return s.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,o=e.normal,s=n._tempVec30,_=n._tempVec31;return(o.x>=0?(s.x=r.x,_.x=a.x):(s.x=a.x,_.x=r.x),o.y>=0?(s.y=r.y,_.y=a.y):(s.y=a.y,_.y=r.y),o.z>=0?(s.z=r.z,_.z=a.z):(s.z=a.z,_.z=r.z),0>n.distancePlaneAndPoint(e,s))?t.PlaneIntersectionType.Back:n.distancePlaneAndPoint(e,_)>0?t.PlaneIntersectionType.Front:t.PlaneIntersectionType.Intersecting},n.intersectsPlaneAndSphere=function(e,i){var a=i.center,r=i.radius,o=n.distancePlaneAndPoint(e,a);return o>r?t.PlaneIntersectionType.Front:o<-r?t.PlaneIntersectionType.Back:t.PlaneIntersectionType.Intersecting},n.intersectsRayAndPlane=function(t,n){var e=n.normal,i=o.zeroTolerance,a=s.dot(e,t.direction);if(Math.abs(a)<i)return -1;var r=s.dot(e,t.origin),_=(-n.distance-r)/a;if(_<0){if(_<-i)return -1;_=0}return _},n.intersectsRayAndBox=function(t,n){var e=o.zeroTolerance,i=t.origin,a=t.direction,r=n.min,s=n.max,_=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(_)<e){if(c<r.x||c>s.x)return -1}else{var m=1/_,x=(r.x-c)*m,g=(s.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>s.y)return -1}else{var v=1/h,V=(r.y-l)*v,C=(s.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>s.z)return -1}else{var w=1/u,M=(r.z-y)*w,b=(s.z-y)*w;if(M>b){var T=M;M=b,b=T}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,o=e.radius,_=n._tempVec30;s.subtract(i,r,_);var h=s.dot(_,a),u=s.dot(_,_)-o*o;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 s.distanceSquared(t.center,n.center)<e*e},n.intersectsSphereAndBox=function(t,e){var i=t.center,a=e.max,r=e.min,o=n._tempVec30;return o.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))),s.distanceSquared(i,o)<=t.radius*t.radius},n.intersectsFrustumAndBox=function(t,e){for(var i=e.min,a=e.max,r=n._tempVec30,o=0;o<6;++o){var _=t.getPlane(o),h=_.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),s.dot(h,r)<-_.distance)return!1}return!0},n.frustumContainsPoint=function(e,i){var a=n.distancePlaneAndPoint(e.near,i);return Math.abs(a)<o.zeroTolerance?t.ContainmentType.Intersects:a<0?t.ContainmentType.Disjoint:Math.abs(a=n.distancePlaneAndPoint(e.far,i))<o.zeroTolerance?t.ContainmentType.Intersects:a<0?t.ContainmentType.Disjoint:Math.abs(a=n.distancePlaneAndPoint(e.left,i))<o.zeroTolerance?t.ContainmentType.Intersects:a<0?t.ContainmentType.Disjoint:Math.abs(a=n.distancePlaneAndPoint(e.right,i))<o.zeroTolerance?t.ContainmentType.Intersects:a<0?t.ContainmentType.Disjoint:Math.abs(a=n.distancePlaneAndPoint(e.top,i))<o.zeroTolerance?t.ContainmentType.Intersects:a<0?t.ContainmentType.Disjoint:Math.abs(a=n.distancePlaneAndPoint(e.bottom,i))<o.zeroTolerance?t.ContainmentType.Intersects:a<0?t.ContainmentType.Disjoint:t.ContainmentType.Contains},n.frustumContainsBox=function(e,i){for(var a=i.min,r=i.max,o=n._tempVec30,s=n._tempVec31,_=t.ContainmentType.Contains,h=0;h<6;++h){var u=e.getPlane(h),c=u.normal;if(c.x>=0?(o.x=r.x,s.x=a.x):(o.x=a.x,s.x=r.x),c.y>=0?(o.y=r.y,s.y=a.y):(o.y=a.y,s.y=r.y),c.z>=0?(o.z=r.z,s.z=a.z):(o.z=a.z,s.z=r.z),n.intersectsPlaneAndPoint(u,o)===t.PlaneIntersectionType.Back)return t.ContainmentType.Disjoint;n.intersectsPlaneAndPoint(u,s)===t.PlaneIntersectionType.Back&&(_=t.ContainmentType.Intersects)}return _},n.frustumContainsSphere=function(e,i){for(var a=t.ContainmentType.Contains,r=0;r<6;++r){var o=e.getPlane(r),s=n.intersectsPlaneAndSphere(o,i);if(s===t.PlaneIntersectionType.Back)return t.ContainmentType.Disjoint;if(s===t.PlaneIntersectionType.Intersecting){a=t.ContainmentType.Intersects;break}}return a},n}();u._tempVec30=new s,u._tempVec31=new s,u._tempVec32=new s;var c=function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n=0),this.normal=new s,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();s.scale(e,i,n.normal),n.distance=t.distance*i},t.fromPoints=function(t,n,e,i){var a=t.x,r=t.y,o=t.z,s=n.x-a,_=n.y-r,h=n.z-o,u=e.x-a,c=e.y-r,l=e.z-o,y=_*l-h*c,d=h*u-s*l,f=s*c-_*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*o)},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],o=n[4],s=n[5],_=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+_,y+l),this.near.distance=x+m,this.near.normalize(),this.far.normal.set(r-a,h-_,y-l),this.far.distance=x-m,this.far.normalize(),this.left.normal.set(r+e,h+o,y+u),this.left.distance=x+d,this.left.normalize(),this.right.normal.set(r-e,h-o,y-u),this.right.distance=x-d,this.right.normalize(),this.bottom.normal.set(r+i,h+s,y+c),this.bottom.distance=x+f,this.bottom.normalize(),this.top.normal.set(r-i,h-s,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===o&&(o=0),void 0===s&&(s=0),void 0===_&&(_=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]=o,h[7]=s,h[8]=_}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]=o,h[7]=s,h[8]=_,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],o=t[5],s=t[6],_=t[7],h=t[8];return n*(h*r-o*_)+e*(-h*a+o*s)+i*(_*a-r*s)},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,o=i[0],s=i[1],_=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]=o*f+h*m+l*x,r[1]=s*f+u*m+y*x,r[2]=_*f+c*m+d*x,r[3]=o*g+h*z+l*v,r[4]=s*g+u*z+y*v,r[5]=_*g+c*z+d*v,r[6]=o*V+h*C+l*p,r[7]=s*V+u*C+y*p,r[8]=_*V+c*C+d*p},t.equals=function(t,n){var e=t.elements,i=n.elements;return o.equals(e[0],i[0])&&o.equals(e[1],i[1])&&o.equals(e[2],i[2])&&o.equals(e[3],i[3])&&o.equals(e[4],i[4])&&o.equals(e[5],i[5])&&o.equals(e[6],i[6])&&o.equals(e[7],i[7])&&o.equals(e[8],i[8])},t.lerp=function(t,n,e,i){var a=t.elements,r=n.elements,o=i.elements,s=1-e;o[0]=a[0]*s+r[0]*e,o[1]=a[1]*s+r[1]*e,o[2]=a[2]*s+r[2]*e,o[3]=a[3]*s+r[3]*e,o[4]=a[4]*s+r[4]*e,o[5]=a[5]*s+r[5]*e,o[6]=a[6]*s+r[6]*e,o[7]=a[7]*s+r[7]*e,o[8]=a[8]*s+r[8]*e},t.rotationQuaternion=function(t,n){var e=n.elements,i=t._x,a=t._y,r=t._z,o=t._w,s=i+i,_=a+a,h=r+r,u=i*s,c=a*s,l=a*_,y=r*s,d=r*_,f=r*h,m=o*s,x=o*_,g=o*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],o=e[2],s=e[3],_=e[4],h=e[5],u=e[6],c=e[7],l=e[8],y=l*_-h*c,d=-l*s+h*u,f=c*s-_*u,m=a*y+r*d+o*f;m&&(m=1/m,i[0]=y*m,i[1]=(-l*r+o*c)*m,i[2]=(h*r-o*_)*m,i[3]=d*m,i[4]=(l*a-o*u)*m,i[5]=(-h*a+o*s)*m,i[6]=f*m,i[7]=(-c*a+r*u)*m,i[8]=(_*a-r*s)*m)},t.normalMatrix=function(t,n){var e=t.elements,i=n.elements,a=e[0],r=e[1],o=e[2],s=e[3],_=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*_,V=a*u-o*_,C=a*c-s*_,p=r*u-o*h,w=r*c-s*h,M=o*c-s*u,b=l*x-y*m,T=l*g-d*m,q=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*q-w*T+M*b;if(!S)return null;S=1/S,i[0]=(h*P-u*A+c*F)*S,i[1]=(u*q-_*P-c*T)*S,i[2]=(_*A-h*q+c*b)*S,i[3]=(o*A-r*P-s*F)*S,i[4]=(a*P-o*q+s*T)*S,i[5]=(r*q-a*A-s*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),o=Math.cos(n),s=i[0],_=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*s+r*u,a[1]=o*_+r*c,a[2]=o*h+r*l,a[3]=o*u-r*s,a[4]=o*c-r*_,a[5]=o*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,o=e.elements;o[0]=i*r[0],o[1]=i*r[1],o[2]=i*r[2],o[3]=a*r[3],o[4]=a*r[4],o[5]=a*r[5],o[6]=r[6],o[7]=r[7],o[8]=r[8]},t.translate=function(t,n,e){var i=n._x,a=n._y,r=t.elements,o=e.elements,s=r[0],_=r[1],h=r[2],u=r[3],c=r[4],l=r[5],y=r[6],d=r[7],f=r[8];o[0]=s,o[1]=_,o[2]=h,o[3]=u,o[4]=c,o[5]=l,o[6]=i*s+a*u+y,o[7]=i*_+a*c+d,o[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],o=e[5];i[1]=e[3],i[2]=e[6],i[3]=a,i[5]=e[7],i[6]=r,i[7]=o}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<o.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,o=2*(n*a-e*i);t._y=Math.abs(o)>=1?Math.sign(o)*(Math.PI/2):Math.asin(o),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,o=t._w,s=n._x,_=n._y,h=n._z,u=n._w;e._x=i*u+o*s+a*h-r*_,e._y=a*u+o*_+r*s-i*h,e._z=r*u+o*h+i*_-a*s,e._w=o*u-i*s-a*_-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 o.equals(t._x,n._x)&&o.equals(t._y,n._y)&&o.equals(t._z,n._z)&&o.equals(t._w,n._w)},t.rotationAxisAngle=function(n,e,i){var a=t._tempVector3;s.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,o=.5*t,s=Math.sin(a),_=Math.cos(a),h=Math.sin(r),u=Math.cos(r),c=Math.sin(o),l=Math.cos(o),y=l*u,d=c*h;i._x=l*h*_+c*u*s,i._y=c*u*_-l*h*s,i._z=y*s-d*_,i._w=y*_+d*s,i._onValueChanged&&i._onValueChanged()},t.rotationMatrix3x3=function(t,n){var e,i,a=t.elements,r=a[0],o=a[1],s=a[2],_=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-s)*e,n._z=(o-_)*e):r>=h&&r>=y?(i=.5/(e=Math.sqrt(1+r-h-y)),n._x=.5*e,n._y=(o+_)*i,n._z=(s+c)*i,n._w=(u-l)*i):h>y?(i=.5/(e=Math.sqrt(1+h-r-y)),n._x=(_+o)*i,n._y=.5*e,n._z=(l+u)*i,n._w=(c-s)*i):(i=.5/(e=Math.sqrt(1+y-r-h)),n._x=(s+c)*i,n._y=(u+l)*i,n._z=.5*e,n._w=(o-_)*i),n._onValueChanged&&n._onValueChanged()},t.invert=function(t,n){var e=t._x,i=t._y,a=t._z,r=t._w,s=e*e+i*i+a*a+r*r;if(s>o.zeroTolerance){var _=1/s;n._x=-e*_,n._y=-i*_,n._z=-a*_,n._w=r*_,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,s,_=t.dot(n,e);if(Math.abs(_)>1-o.zeroTolerance)s=1-i,r=i*Math.sign(_);else{var h=Math.acos(Math.abs(_)),u=1/Math.sin(h);s=Math.sin((1-i)*h)*u,r=Math.sin(i*h)*u*Math.sign(_)}a.x=s*n.x+r*e.x,a.y=s*n.y+r*e.y,a.z=s*n.z+r*e.z,a.w=s*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,s=Math.sqrt(e*e+i*i+a*a+r*r);s>o.zeroTolerance&&(s=1/s,n._x=e*s,n._y=i*s,n._z=a*s,n._w=r*s,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,o=t._w,s=Math.sin(n*=.5),_=Math.cos(n);e._x=i*_+o*s,e._y=a*_+r*s,e._z=r*_-a*s,e._w=o*_-i*s,e._onValueChanged&&e._onValueChanged()},t.rotateY=function(t,n,e){var i=t._x,a=t._y,r=t._z,o=t._w,s=Math.sin(n*=.5),_=Math.cos(n);e._x=i*_-r*s,e._y=a*_+o*s,e._z=r*_+i*s,e._w=o*_-a*s,e._onValueChanged&&e._onValueChanged()},t.rotateZ=function(t,n,e){var i=t._x,a=t._y,r=t._z,o=t._w,s=Math.sin(n*=.5),_=Math.cos(n);e._x=i*_+a*s,e._y=a*_-i*s,e._z=r*_+o*s,e._w=o*_-r*s,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)<o.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(t){this._w=t,this._onValueChanged&&this._onValueChanged()}}]),t}();d._tempVector3=new s,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===o&&(o=0),void 0===s&&(s=0),void 0===_&&(_=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]=o,m[7]=s,m[8]=_,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]=o,m[7]=s,m[8]=_,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],o=t[5],s=t[6],_=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*o-e*r)*(c*m-l*f)-(n*s-i*r)*(u*m-l*d)+(n*_-a*r)*(u*f-c*d)+(e*s-i*o)*(h*m-l*y)-(e*_-a*o)*(h*f-c*y)+(i*_-a*s)*(h*d-u*y)},n.decompose=function(n,e,i){var a=t._tempMat30,r=this.elements,s=a.elements,_=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(_*h*u*c)?-1:1)*Math.sqrt(_*_+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)<o.zeroTolerance||Math.abs(C)<o.zeroTolerance||Math.abs(p)<o.zeroTolerance)return e.identity(),!1;var w=1/V,M=1/C,b=1/p;return s[0]=_*w,s[1]=h*w,s[2]=u*w,s[3]=l*M,s[4]=y*M,s[5]=f*M,s[6]=x*b,s[7]=g*b,s[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>o.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 s=2*Math.sqrt(1+n[10]-n[0]-n[5]);t._w=(n[1]-n[4])/s,t._x=(n[8]+n[2])/s,t._y=(n[6]+n[9])/s,t._z=.25*s}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],o=n[5],s=n[6],_=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+s*s),Math.sqrt(_*_+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,o=i[0],s=i[1],_=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],T=a[5],q=a[6],F=a[7],A=a[8],P=a[9],S=a[10],I=a[11],B=a[12],k=a[13],R=a[14],j=a[15];r[0]=o*C+u*p+d*w+g*M,r[1]=s*C+c*p+f*w+z*M,r[2]=_*C+l*p+m*w+v*M,r[3]=h*C+y*p+x*w+V*M,r[4]=o*b+u*T+d*q+g*F,r[5]=s*b+c*T+f*q+z*F,r[6]=_*b+l*T+m*q+v*F,r[7]=h*b+y*T+x*q+V*F,r[8]=o*A+u*P+d*S+g*I,r[9]=s*A+c*P+f*S+z*I,r[10]=_*A+l*P+m*S+v*I,r[11]=h*A+y*P+x*S+V*I,r[12]=o*B+u*k+d*R+g*j,r[13]=s*B+c*k+f*R+z*j,r[14]=_*B+l*k+m*R+v*j,r[15]=h*B+y*k+x*R+V*j},t.equals=function(t,n){var e=t.elements,i=n.elements;return o.equals(e[0],i[0])&&o.equals(e[1],i[1])&&o.equals(e[2],i[2])&&o.equals(e[3],i[3])&&o.equals(e[4],i[4])&&o.equals(e[5],i[5])&&o.equals(e[6],i[6])&&o.equals(e[7],i[7])&&o.equals(e[8],i[8])&&o.equals(e[9],i[9])&&o.equals(e[10],i[10])&&o.equals(e[11],i[11])&&o.equals(e[12],i[12])&&o.equals(e[13],i[13])&&o.equals(e[14],i[14])&&o.equals(e[15],i[15])},t.lerp=function(t,n,e,i){var a=t.elements,r=n.elements,o=i.elements,s=1-e;o[0]=a[0]*s+r[0]*e,o[1]=a[1]*s+r[1]*e,o[2]=a[2]*s+r[2]*e,o[3]=a[3]*s+r[3]*e,o[4]=a[4]*s+r[4]*e,o[5]=a[5]*s+r[5]*e,o[6]=a[6]*s+r[6]*e,o[7]=a[7]*s+r[7]*e,o[8]=a[8]*s+r[8]*e,o[9]=a[9]*s+r[9]*e,o[10]=a[10]*s+r[10]*e,o[11]=a[11]*s+r[11]*e,o[12]=a[12]*s+r[12]*e,o[13]=a[13]*s+r[13]*e,o[14]=a[14]*s+r[14]*e,o[15]=a[15]*s+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,o=t._w,s=i+i,_=a+a,h=r+r,u=i*s,c=a*s,l=a*_,y=r*s,d=r*_,f=r*h,m=o*s,x=o*_,g=o*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,s=e.elements,_=t._x,h=t._y,u=t._z,c=Math.sqrt(_*_+h*h+u*u);Math.abs(c)<o.zeroTolerance||(_*=c=1/c,h*=c,u*=c,i=Math.sin(n),r=1-(a=Math.cos(n)),s[0]=_*_*r+a,s[1]=h*_*r+u*i,s[2]=u*_*r-h*i,s[3]=0,s[4]=_*h*r-u*i,s[5]=h*h*r+a,s[6]=u*h*r+_*i,s[7]=0,s[8]=_*u*r+h*i,s[9]=h*u*r-_*i,s[10]=u*u*r+a,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[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,o=n._y,s=n._z,_=n._w,h=r+r,u=o+o,c=s+s,l=r*h,y=r*u,d=r*c,f=o*u,m=o*c,x=s*c,g=_*h,z=_*u,v=_*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],o=e[2],s=e[3],_=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*_,V=a*u-o*_,C=a*c-s*_,p=r*u-o*h,w=r*c-s*h,M=o*c-s*u,b=l*x-y*m,T=l*g-d*m,q=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*q-w*T+M*b;if(!S)return null;S=1/S,i[0]=(h*P-u*A+c*F)*S,i[1]=(o*A-r*P-s*F)*S,i[2]=(x*M-g*w+z*p)*S,i[3]=(d*w-y*M-f*p)*S,i[4]=(u*q-_*P-c*T)*S,i[5]=(a*P-o*q+s*T)*S,i[6]=(g*C-m*M-z*V)*S,i[7]=(l*M-d*C+f*V)*S,i[8]=(_*A-h*q+c*b)*S,i[9]=(r*q-a*A-s*b)*S,i[10]=(m*w-x*C+z*v)*S,i[11]=(y*C-l*w-f*v)*S,i[12]=(h*T-_*F-u*b)*S,i[13]=(a*F-r*T+o*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,o=t._tempVec30,_=t._tempVec31,h=t._tempVec32;s.subtract(n,e,h),h.normalize(),s.cross(i,h,o),o.normalize(),s.cross(h,o,_),r[0]=o._x,r[1]=_._x,r[2]=h._x,r[3]=0,r[4]=o._y,r[5]=_._y,r[6]=h._y,r[7]=0,r[8]=o._z,r[9]=_._z,r[10]=h._z,r[11]=0,r[12]=-s.dot(o,n),r[13]=-s.dot(_,n),r[14]=-s.dot(h,n),r[15]=1},t.ortho=function(t,n,e,i,a,r,o){var s=o.elements,_=1/(t-n),h=1/(e-i),u=1/(a-r);s[0]=-2*_,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*h,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*u,s[11]=0,s[12]=(t+n)*_,s[13]=(i+e)*h,s[14]=(r+a)*u,s[15]=1},t.perspective=function(t,n,e,i,a){var r=a.elements,o=1/Math.tan(t/2),s=1/(e-i);r[0]=o/n,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=o,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=(i+e)*s,r[11]=-1,r[12]=0,r[13]=0,r[14]=2*i*e*s,r[15]=0},t.rotateAxisAngle=function(t,n,e,i){var a,r,s,_=n._x,h=n._y,u=n._z,c=Math.sqrt(_*_+h*h+u*u);if(!(Math.abs(c)<o.zeroTolerance)){var l=t.elements,y=i.elements;_*=c=1/c,h*=c,u*=c,a=Math.sin(e),s=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+r,T=h*_*s+u*a,q=u*_*s-h*a,F=_*h*s-u*a,A=h*h*s+r,P=u*h*s+_*a,S=_*u*s+h*a,I=h*u*s-_*a,B=u*u*s+r;y[0]=d*b+g*T+C*q,y[1]=f*b+z*T+p*q,y[2]=m*b+v*T+w*q,y[3]=x*b+V*T+M*q,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*I+C*B,y[9]=f*S+z*I+p*B,y[10]=m*S+v*I+w*B,y[11]=x*S+V*I+M*B,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,o=n._y,s=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]*o,a[5]=i[5]*o,a[6]=i[6]*o,a[7]=i[7]*o,a[8]=i[8]*s,a[9]=i[9]*s,a[10]=i[10]*s,a[11]=i[11]*s,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,o=n._y,s=n._z;if(t===e)a[12]=i[0]*r+i[4]*o+i[8]*s+i[12],a[13]=i[1]*r+i[5]*o+i[9]*s+i[13],a[14]=i[2]*r+i[6]*o+i[10]*s+i[14],a[15]=i[3]*r+i[7]*o+i[11]*s+i[15];else{var _=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]=_,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]=_*r+l*o+m*s+i[12],a[13]=h*r+y*o+x*s+i[13],a[14]=u*r+d*o+g*s+i[14],a[15]=c*r+f*o+z*s+i[15]}},t.transpose=function(t,n){var e=t.elements,i=n.elements;if(n===t){var a=e[1],r=e[2],o=e[3],s=e[6],_=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]=s,i[11]=e[14],i[12]=o,i[13]=_,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 s,f._tempVec31=new s,f._tempVec32=new s,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 s,this.direction=new s,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 s.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 o.equals(t._x,n._x)&&o.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>o.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 o.equals(t._x,n._x)&&o.equals(t._y,n._y)&&o.equals(t._z,n._z)&&o.equals(t._w,n._w)},t.lerp=function(t,n,e,i){var a=t._x,r=t._y,o=t._z,s=t._w;i._x=a+(n._x-a)*e,i._y=r+(n._y-r)*e,i._z=o+(n._z-o)*e,i._w=s+(n._w-s)*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,s=Math.sqrt(e*e+i*i+a*a+r*r);s>o.zeroTolerance&&(s=1/s,n._x=e*s,n._y=i*s,n._z=a*s,n._w=r*s,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,o=t._w,s=n.elements;e._x=i*s[0]+a*s[4]+r*s[8]+o*s[12],e._y=i*s[1]+a*s[5]+r*s[9]+o*s[13],e._z=i*s[2]+a*s[6]+r*s[10]+o*s[14],e._w=i*s[3]+a*s[7]+r*s[11]+o*s[15],e._onValueChanged&&e._onValueChanged()},t.transformByQuat=function(t,n,e){var i=t._x,a=t._y,r=t._z,o=t._w,s=n._x,_=n._y,h=n._z,u=n._w,c=u*i+_*r-h*a,l=u*a+h*i-s*r,y=u*r+s*a-_*i,d=-s*i-_*a-h*r;e._x=c*u-d*s-l*h+y*_,e._y=l*u-d*_-y*s+c*h,e._z=y*u-d*h-c*_+l*s,e._w=o,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 o.equals(t._r,n._r)&&o.equals(t._g,n._g)&&o.equals(t._b,n._b)&&o.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,o=t._b,s=t._a;return i._r=a+(n._r-a)*e,i._g=r+(n._g-r)*e,i._b=o+(n._b-o)*e,i._a=s+(n._a-s)*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,o=t._z,s=n.r,_=n.g,h=n.b,u=-.488603*r,c=.488603*o,l=-.488603*a,y=1.092548*(a*r),d=-1.092548*(r*o),f=.315392*(3*o*o-1),m=-1.092548*(a*o),x=.546274*(a*a-r*r);i[0]+=.282095*s,i[1]+=.282095*_,i[2]+=.282095*h,i[3]+=s*u,i[4]+=_*u,i[5]+=h*u,i[6]+=s*c,i[7]+=_*c,i[8]+=h*c,i[9]+=s*l,i[10]+=_*l,i[11]+=h*l,i[12]+=s*y,i[13]+=_*y,i[14]+=h*y,i[15]+=s*d,i[16]+=_*d,i[17]+=h*d,i[18]+=s*f,i[19]+=_*f,i[20]+=h*f,i[21]+=s*m,i[22]+=_*m,i[23]+=h*m,i[24]+=s*x,i[25]+=_*x,i[26]+=h*x},n.evaluate=function(t,n){var e=this.coefficients,i=t._x,a=t._y,r=t._z,o=-1.023327*a,s=1.023327*r,_=-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]*o+e[6]*s+e[9]*_,f+=e[4]*o+e[7]*s+e[10]*_,m+=e[5]*o+e[8]*s+e[11]*_,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=_,t.CollisionUtil=u,t.Color=z,t.MathUtil=o,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=s,t.Vector4=g,Object.defineProperty(t,"__esModule",{value:!0})});