@galacean/effects-plugin-model 0.0.1-alpha.2 → 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.
- package/README.md +8 -8
- package/dist/index.js +3 -3
- package/dist/index.min.js +2 -2
- package/dist/index.mjs +3 -3
- package/dist/loader.mjs +1 -1
- package/package.json +4 -4
package/dist/index.min.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player model plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 飂兮
|
|
6
|
-
* Version:
|
|
6
|
+
* Version: v1.0.0
|
|
7
7
|
*/
|
|
8
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ge=t.ge||{},t.ge.modelPlugin={}),t.ge)}(this,(function(t,e){"use strict";var a="PluginModel",n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function a(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(a.prototype=e.prototype,new a)}var o=function(){return o=Object.assign||function(t){for(var e,a=1,n=arguments.length;a<n;a++)for(var r in e=arguments[a])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},o.apply(this,arguments)};function i(t,e,a,n){return new(a||(a=Promise))((function(r,o){function i(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof a?e:new a((function(t){t(e)}))).then(i,s)}c((n=n.apply(t,e||[])).next())}))}function s(t,e){var a,n,r,o,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(a)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(a=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){i.label=s[1];break}if(6===s[0]&&i.label<r[1]){i.label=r[1],r=s;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(s);break}r[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],n=0}finally{a=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function c(t,e){var a="function"==typeof Symbol&&t[Symbol.iterator];if(!a)return t;var n,r,o=a.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(a=o.return)&&a.call(o)}finally{if(r)throw r.error}}return i}function u(t,e,a){if(a||2===arguments.length)for(var n,r=0,o=e.length;r<o;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var d=function(){function t(t,e,a){this.time=t,this.data=e,this.componentCount=a,this.cachedIndex=0}return t.prototype.evaluate=function(t){var e=this.time,a=this.cachedIndex,n=e[a],r=e[a-1];t:{e:{var o=void 0;a:{n:if(!(t<n)){for(var i=a+2;;){if(void 0===n){if(t<r)break n;return a=e.length,this.cachedIndex=a,this.copySampleValue(a-1)}if(a===i)break;if(r=n,t<(n=e[++a]))break e}o=e.length;break a}if(t>=r)break t;var s=e[1];t<s&&(a=2,r=s);for(i=a-2;;){if(void 0===r)return this.cachedIndex=0,this.copySampleValue(0);if(a===i)break;if(n=r,t>=(r=e[--a-1]))break e}o=a,a=0}for(;a<o;){var c=a+o>>>1;t<e[c]?o=c:a=c+1}if(n=e[a],void 0===(r=e[a-1]))return this.cachedIndex=0,this.copySampleValue(0);if(void 0===n)return a=e.length,this.cachedIndex=a,this.copySampleValue(a-1)}this.cachedIndex=a,this.intervalChanged(a,r,n)}return this.interpolate(a,r,t,n)},t.prototype.dispose=function(){this.time=void 0,this.data=void 0},t.prototype.copySampleValue=function(t){for(var e=this.data,a=this.componentCount,n=t*a,r=new Float32Array(a),o=0;o!==a;++o)r[o]=e[n+o];return r},t}(),l=function(t){function e(e,a,n){return t.call(this,e,a,n)||this}return r(e,t),e.prototype.intervalChanged=function(t,e,a){},e.prototype.interpolate=function(t,e,a,n){for(var r,o=this.data,i=null!==(r=this.componentCount)&&void 0!==r?r:1,s=t*i,c=s-i,u=(a-e)/(n-e),d=1-u,l=new Float32Array(i),h=0;h!==i;++h)l[h]=o[c+h]*d+o[s+h]*u;return l},e}(d),h=function(t){function e(e,a,n){return t.call(this,e,a,n)||this}return r(e,t),e.prototype.intervalChanged=function(t,e,a){},e.prototype.interpolate=function(t,e,a,n){for(var r,o=this.data,i=null!==(r=this.componentCount)&&void 0!==r?r:1,s=(t-1)*i,c=new Float32Array(i),u=0;u!==i;++u)c[u]=o[s+u];return c},e}(d),f=function(){function t(){}return t.slerpFlat=function(t,e,a,n,r,o,i){var s=a[n+0],c=a[n+1],u=a[n+2],d=a[n+3],l=r[o+0],h=r[o+1],f=r[o+2],p=r[o+3];if(0===i)return t[e+0]=s,t[e+1]=c,t[e+2]=u,void(t[e+3]=d);if(1===i)return t[e+0]=l,t[e+1]=h,t[e+2]=f,void(t[e+3]=p);if(d!==p||s!==l||c!==h||u!==f){var m=1-i,_=s*l+c*h+u*f+d*p,g=_>=0?1:-1,y=1-_*_;if(y>Number.EPSILON){var v=Math.sqrt(y),x=Math.atan2(v,_*g);m=Math.sin(m*x)/v,i=Math.sin(i*x)/v}var b=i*g;if(s=s*m+l*b,c=c*m+h*b,u=u*m+f*b,d=d*m+p*b,m===1-i){var T=1/Math.sqrt(s*s+c*c+u*u+d*d);s*=T,c*=T,u*=T,d*=T}}t[e]=s,t[e+1]=c,t[e+2]=u,t[e+3]=d},t}(),p=function(t){function e(e,a,n){return t.call(this,e,a,n)||this}return r(e,t),e.prototype.intervalChanged=function(t,e,a){},e.prototype.interpolate=function(t,e,a,n){for(var r,o=this.data,i=null!==(r=this.componentCount)&&void 0!==r?r:1,s=(a-e)/(n-e),c=t*i,u=new Float32Array(i),d=c+i;c!==d;c+=4)f.slerpFlat(u,0,o,c-i,o,c,s);return u},e}(d);function m(t,e,a,n,r){switch(t){case"LINEAR":return"rotation"===r?new p(e,a,n):new l(e,a,n);case"STEP":return new h(e,a,n);default:return new l(e,a,n)}}var _,g=function(){function t(){}return t.acosClamped=function(e){return Math.acos(t.clamp(e,-1,1))},t.clamp=function(t,e,a){return t<e?e:t>a?a:t},t.equalsEpsilon=function(t,e,a,n){a=null!=a?a:0,n=null!=n?n:a;var r=Math.abs(t-e);return r<=n||r<=a*Math.max(Math.abs(t),Math.abs(e))},t.EPSILON6=1e-6,t.EPSILON7=1e-7,t.EPSILON21=1e-21,t}(),y=function(){function t(t,e){this._data=new Float32Array([null!=t?t:0,null!=e?e:0])}return Object.defineProperty(t.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data[0]=t},enumerable:!1,configurable:!0}),t.prototype.getX=function(){return this._data[0]},t.prototype.setX=function(t){this._data[0]=t},Object.defineProperty(t.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t},enumerable:!1,configurable:!0}),t.prototype.getY=function(){return this._data[1]},t.prototype.setY=function(t){this._data[1]=t},t.prototype.set=function(t,e){this._data[0]=t,this._data[1]=e},Object.defineProperty(t.prototype,"xy",{get:function(){return[this._data[0],this._data[1]]},set:function(t){this._data[0]=t[0],this._data[1]=t[1]},enumerable:!1,configurable:!0}),t.fromElements=function(e,a){var n=new t(e,a);return n.x=e,n.y=a,n},t.clone=function(e){return new t(e.x,e.y)},t.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t.x,e[a]=t.y,e},t.unpack=function(t,e,a){return a.x=t[e++],a.y=t[e],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,2*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=2){var o=r/2;a[o]=t.unpack(e,r,a[o])}return a},t.fromArray=function(e){return t.unpack(e,0,new t)},t.maximumComponent=function(t){return Math.max(t.x,t.y)},t.minimumComponent=function(t){return Math.min(t.x,t.y)},t.minimumByComponent=function(t,e,a){return a.x=Math.min(t.x,e.x),a.y=Math.min(t.y,e.y),a},t.maximumByComponent=function(t,e,a){return a.x=Math.max(t.x,e.x),a.y=Math.max(t.y,e.y),a},t.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y},t.magnitude=function(e){return Math.sqrt(t.magnitudeSquared(e))},t.distance=function(e,a){return t.subtract(e,a,v),t.magnitude(v)},t.distanceSquared=function(e,a){return t.subtract(e,a,v),t.magnitudeSquared(v)},t.normalize=function(e,a){var n=t.magnitude(e);return a.x=e.x/n,a.y=e.y/n,a},t.dot=function(t,e){return t.x*e.x+t.y*e.y},t.cross=function(t,e){return t.x*e.y-t.y*e.x},t.multiplyComponents=function(t,e,a){return a.x=t.x*e.x,a.y=t.y*e.y,a},t.divideComponents=function(t,e,a){return a.x=t.x/e.x,a.y=t.y/e.y,a},t.add=function(t,e,a){return a.x=t.x+e.x,a.y=t.y+e.y,a},t.subtract=function(t,e,a){return a.x=t.x-e.x,a.y=t.y-e.y,a},t.multiplyByScalar=function(t,e,a){return a.x=t.x*e,a.y=t.y*e,a},t.divideByScalar=function(t,e,a){return a.x=t.x/e,a.y=t.y/e,a},t.negate=function(t,e){return e.x=-t.x,e.y=-t.y,e},t.abs=function(t,e){return e.x=Math.abs(t.x),e.y=Math.abs(t.y),e},t.lerp=function(e,a,n,r){return t.multiplyByScalar(a,n,x),r=t.multiplyByScalar(e,1-n,r),t.add(x,r,r)},t.angleBetween=function(e,a){return t.normalize(e,b),t.normalize(a,T),g.acosClamped(t.dot(b,T))},t.mostOrthogonalAxis=function(e,a){var n=t.normalize(e,M);return t.abs(n,n),n.x<=n.y?t.UNIT_X.copyTo(a):t.UNIT_Y.copyTo(a),a},t.equals=function(t,e){return t===e||t.x===e.x&&t.y===e.y},t.equalsArray=function(t,e,a){return a=null!=a?a:0,t.x===e[a]&&t.y===e[a+1]},t.equalsEpsilon=function(t,e,a,n){return t===e||g.equalsEpsilon(t.x,e.x,a,n)&&g.equalsEpsilon(t.y,e.y,a,n)},t.max=function(e,a,n){return t.maximumByComponent(e,a,n),n},t.min=function(e,a,n){return t.minimumByComponent(e,a,n),n},t.mix=function(e,a,n,r){return t.lerp(e,a,n,r),r},t.floor=function(t,e){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e},t.ceil=function(t,e){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e},t.round=function(t,e){return e.x=Math.round(t.x),e.y=Math.round(t.y),e},t.prototype.toArray=function(){var e=new Array(2);return t.pack(this,e)},t.prototype.clone=function(){return t.clone(this)},t.prototype.copyTo=function(t){return t.x=this.x,t.y=this.y,t},t.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this},t.prototype.addVector=function(e){return t.add(this,e,this)},t.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this},t.prototype.subVector=function(e){return t.subtract(this,e,this)},t.prototype.multiplyScalar=function(e){return t.multiplyByScalar(this,e,this)},t.prototype.multiplyVector=function(e){return t.multiplyComponents(this,e,this)},t.prototype.divideVector=function(e){return t.divideComponents(this,e,this)},t.prototype.divideScalar=function(e){return t.divideByScalar(this,e,this)},t.prototype.min=function(){return t.minimumComponent(this)},t.prototype.max=function(){return t.maximumComponent(this)},t.prototype.clamp=function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},t.prototype.floor=function(){return t.floor(this,this)},t.prototype.ceil=function(){return t.ceil(this,this)},t.prototype.round=function(){return t.round(this,this)},t.prototype.negate=function(){return t.negate(this,this)},t.prototype.dot=function(e){return t.dot(this,e)},t.prototype.cross=function(e){return t.cross(this,e)},t.prototype.length=function(){return t.magnitude(this)},t.prototype.lengthSquared=function(){return t.magnitudeSquared(this)},t.prototype.normalize=function(){return t.normalize(this,this)},t.prototype.angleTo=function(e){return t.angleBetween(this,e)},t.prototype.distanceTo=function(e){return t.distance(this,e)},t.prototype.distanceSquaredTo=function(e){return t.distanceSquared(this,e)},t.prototype.getData=function(){return this._data},t.ZERO=Object.freeze(new t(0,0)),t.ONE=Object.freeze(new t(1,1)),t.UNIT_X=Object.freeze(new t(1,0)),t.UNIT_Y=Object.freeze(new t(0,1)),t}(),v=new y,x=new y,b=new y,T=new y,M=new y,S=function(){function t(t,e,a){this._data=new Float32Array([null!=t?t:0,null!=e?e:0,null!=a?a:0])}return Object.defineProperty(t.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data[0]=t},enumerable:!1,configurable:!0}),t.prototype.getX=function(){return this._data[0]},t.prototype.setX=function(t){this._data[0]=t},Object.defineProperty(t.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t},enumerable:!1,configurable:!0}),t.prototype.getY=function(){return this._data[1]},t.prototype.setY=function(t){this._data[1]=t},Object.defineProperty(t.prototype,"z",{get:function(){return this._data[2]},set:function(t){this._data[2]=t},enumerable:!1,configurable:!0}),t.prototype.getZ=function(){return this._data[2]},t.prototype.setZ=function(t){this._data[2]=t},t.prototype.set=function(t,e,a){this._data[0]=t,this._data[1]=e,this._data[2]=a},Object.defineProperty(t.prototype,"xyz",{get:function(){return[this._data[0],this._data[1],this._data[2]]},set:function(t){this._data[0]=t[0],this._data[1]=t[1],this._data[2]=t[2]},enumerable:!1,configurable:!0}),t.fromElements=function(e,a,n){var r=new t(e,a,n);return r.x=e,r.y=a,r.z=n,r},t.clone=function(e){return new t(e.x,e.y,e.z)},t.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t.x,e[a++]=t.y,e[a]=t.z,e},t.unpack=function(t,e,a){return a.x=t[e++],a.y=t[e++],a.z=t[e],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,3*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=3){var o=r/3;a[o]=t.unpack(e,r,a[o])}return a},t.fromArray=function(e){return this.unpack(e,0,new t)},t.maximumComponent=function(t){return Math.max(t.x,t.y,t.z)},t.minimumComponent=function(t){return Math.min(t.x,t.y,t.z)},t.minComponentIndex=function(t){return t.x<t.y?t.x<t.z?0:2:t.y<t.z?1:2},t.tryZUpVector=function(e,a){var n=e.clone().normalize(),r=[],o=[new t(0,1,0),new t(1,0,0),new t(0,0,1)];if(o.forEach((function(t){r.push(Math.abs(n.dot(t)))})),r[0]<.99)a.set(0,1,0);else{var i=99999;r.forEach((function(t,e){i>t&&(a.copyFrom(o[e]),i=t)}))}return a},t.computeUpVector=function(e,a){var n=e.clone().normalize();return 1!==t.minComponentIndex(t.abs(n,n))?a.set(0,1,0):(a.set(n.z,0,-n.x),a.normalize()),a},t.minimumByComponent=function(t,e,a){return a.x=Math.min(t.x,e.x),a.y=Math.min(t.y,e.y),a.z=Math.min(t.z,e.z),a},t.maximumByComponent=function(t,e,a){return a.x=Math.max(t.x,e.x),a.y=Math.max(t.y,e.y),a.z=Math.max(t.z,e.z),a},t.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y+t.z*t.z},t.magnitude=function(e){return Math.sqrt(t.magnitudeSquared(e))},t.distance=function(e,a){return t.subtract(e,a,C),t.magnitude(C)},t.distanceSquared=function(e,a){return t.subtract(e,a,C),t.magnitudeSquared(C)},t.normalize=function(e,a){var n=t.magnitude(e);return n>1e-5?(a.x=e.x/n,a.y=e.y/n,a.z=e.z/n):(a.x=e.x,a.y=e.y,a.z=e.z),a},t.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},t.multiplyComponents=function(t,e,a){return a.x=t.x*e.x,a.y=t.y*e.y,a.z=t.z*e.z,a},t.divideComponents=function(t,e,a){return a.x=t.x/e.x,a.y=t.y/e.y,a.z=t.z/e.z,a},t.add=function(t,e,a){return a.x=t.x+e.x,a.y=t.y+e.y,a.z=t.z+e.z,a},t.subtract=function(t,e,a){return a.x=t.x-e.x,a.y=t.y-e.y,a.z=t.z-e.z,a},t.multiplyByScalar=function(t,e,a){return a.x=t.x*e,a.y=t.y*e,a.z=t.z*e,a},t.divideByScalar=function(t,e,a){return a.x=t.x/e,a.y=t.y/e,a.z=t.z/e,a},t.negate=function(t,e){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e},t.abs=function(t,e){return e.x=Math.abs(t.x),e.y=Math.abs(t.y),e.z=Math.abs(t.z),e},t.clamp=function(e,a,n){return t.max(e,a,e),t.min(e,n,e),e},t.lerp=function(e,a,n,r){return t.multiplyByScalar(a,n,w),r=t.multiplyByScalar(e,1-n,r),t.add(w,r,r)},t.angleBetween=function(e,a){t.normalize(e,A),t.normalize(a,I);var n=t.dot(A,I),r=t.magnitude(t.cross(A,I,A));return Math.atan2(r,n)},t.mostOrthogonalAxis=function(e,a){var n=t.normalize(e,E);return t.abs(n,n),n.x<=n.y?n.x<=n.z?t.UNIT_X.copyTo(a):t.UNIT_Z.copyTo(a):n.y<=n.z?t.UNIT_Y.copyTo(a):t.UNIT_Z.copyTo(a),a},t.projectVector=function(e,a,n){var r=t.dot(e,a)/t.dot(a,a);return t.multiplyByScalar(a,r,n)},t.equals=function(t,e){return t===e||t.x===e.x&&t.y===e.y&&t.z===e.z},t.equalsArray=function(t,e,a){return a=null!=a?a:0,t.x===e[a]&&t.y===e[a+1]&&t.z===e[a+2]},t.equalsEpsilon=function(t,e,a,n){return t===e||g.equalsEpsilon(t.x,e.x,a,n)&&g.equalsEpsilon(t.y,e.y,a,n)&&g.equalsEpsilon(t.z,e.z,a,n)},t.cross=function(e,a,n){var r=e.x,o=e.y,i=e.z,s=a.x,c=a.y,u=a.z,d=o*u-i*c,l=i*s-r*u,h=r*c-o*s;return void 0===n&&(n=new t),n.x=d,n.y=l,n.z=h,n},t.midpoint=function(t,e,a){return a.x=.5*(t.x+e.x),a.y=.5*(t.y+e.y),a.z=.5*(t.z+e.z),a},t.min=function(e,a,n){return t.minimumByComponent(e,a,n),n},t.max=function(e,a,n){return t.maximumByComponent(e,a,n),n},t.mix=function(e,a,n,r){return t.lerp(e,a,n,r),r},t.floor=function(t,e){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e},t.ceil=function(t,e){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e.z=Math.ceil(t.z),e},t.round=function(t,e){return e.x=Math.round(t.x),e.y=Math.round(t.y),e.z=Math.round(t.z),e},t.prototype.copyTo=function(t){return t.x=this.x,t.y=this.y,t.z=this.z,t},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t.prototype.min=function(e){return t.min(this,e,this),this},t.prototype.max=function(e){return t.max(this,e,this),this},t.prototype.clamp=function(e,a){return t.clamp(this,e,a),this},t.prototype.toArray=function(){var e=new Array(3);return t.pack(this,e)},t.prototype.clone=function(){return t.clone(this)},t.prototype.normalize=function(){return t.normalize(this,this)},t.prototype.length=function(){return t.magnitude(this)},t.prototype.sum=function(){return this.x+this.y+this.z},t.prototype.lengthSquared=function(){return t.magnitudeSquared(this)},t.prototype.floor=function(){return t.floor(this,this)},t.prototype.ceil=function(){return t.ceil(this,this)},t.prototype.round=function(){return t.round(this,this)},t.prototype.negate=function(){return t.negate(this,this)},t.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},t.prototype.addVector=function(e){return t.add(this,e,this),this},t.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},t.prototype.subVector=function(e){return t.subtract(this,e,this)},t.prototype.multiplyScalar=function(e){return t.multiplyByScalar(this,e,this)},t.prototype.multiplyVector=function(e){return t.multiplyComponents(this,e,this)},t.prototype.divideScalar=function(e){return t.divideByScalar(this,e,this)},t.prototype.divideVector=function(e){return t.divideComponents(this,e,this)},t.prototype.dot=function(e){return t.dot(this,e)},t.prototype.cross=function(e){return t.cross(this,e)},t.prototype.distanceTo=function(e){return t.distance(this,e)},t.prototype.distanceSquaredTo=function(e){return t.distanceSquared(this,e)},t.prototype.angleTo=function(e){return t.angleBetween(this,e)},t.prototype.getData=function(){return this._data},t.prototype.applyQuaternion=function(e,a){void 0===a&&(a=new t);var n=this.x,r=this.y,o=this.z,i=e.x,s=e.y,c=e.z,u=e.w,d=a.x,l=a.y,h=a.z,f=u*(n-d)+s*(o-h)-c*(r-l),p=u*(r-l)+c*(n-d)-i*(o-h),m=u*(o-h)+i*(r-l)-s*(n-d),_=-i*(n-d)-s*(r-l)-c*(o-h);return this.x=f*u+_*-i+p*-c-m*-s+d,this.y=p*u+_*-s+m*-i-f*-c+l,this.z=m*u+_*-c+f*-s-p*-i+h,this},t.ZERO=Object.freeze(new t(0,0,0)),t.ONE=Object.freeze(new t(1,1,1)),t.UNIT_X=Object.freeze(new t(1,0,0)),t.UNIT_Y=Object.freeze(new t(0,1,0)),t.UNIT_Z=Object.freeze(new t(0,0,1)),t}(),C=new S,w=new S,A=new S,I=new S,E=new S,P=function(){function t(t,e,a,n){this._data=new Float32Array([null!=t?t:0,null!=e?e:0,null!=a?a:0,null!=n?n:1])}return Object.defineProperty(t.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data[0]=t},enumerable:!1,configurable:!0}),t.prototype.getX=function(){return this._data[0]},t.prototype.setX=function(t){this._data[0]=t},Object.defineProperty(t.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t},enumerable:!1,configurable:!0}),t.prototype.getY=function(){return this._data[1]},t.prototype.setY=function(t){this._data[1]=t},Object.defineProperty(t.prototype,"z",{get:function(){return this._data[2]},set:function(t){this._data[2]=t},enumerable:!1,configurable:!0}),t.prototype.getZ=function(){return this._data[2]},t.prototype.setZ=function(t){this._data[2]=t},Object.defineProperty(t.prototype,"w",{get:function(){return this._data[3]},set:function(t){this._data[3]=t},enumerable:!1,configurable:!0}),t.prototype.getW=function(){return this._data[3]},t.prototype.setW=function(t){this._data[3]=t},t.prototype.set=function(t,e,a,n){this._data[0]=t,this._data[1]=e,this._data[2]=a,this._data[3]=n},t.fromElements=function(e,a,n,r,o){return null==o?new t(e,a,n,r):(o.x=e,o.y=a,o.z=n,o.w=r,o)},t.clone=function(e){return new t(e.x,e.y,e.z,e.w)},t.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t.x,e[a++]=t.y,e[a++]=t.z,e[a]=t.w,e},t.unpack=function(t,e,a){return a.x=t[e++],a.y=t[e++],a.z=t[e++],a.w=t[e],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,4*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=4){var o=r/4;a[o]=t.unpack(e,r,a[o])}return a},t.fromArray=function(e){return t.unpack(e,0,new t)},t.maximumComponent=function(t){return Math.max(t.x,t.y,t.z,t.w)},t.minimumComponent=function(t){return Math.min(t.x,t.y,t.z,t.w)},t.minimumByComponent=function(t,e,a){return a.x=Math.min(t.x,e.x),a.y=Math.min(t.y,e.y),a.z=Math.min(t.z,e.z),a.w=Math.min(t.w,e.w),a},t.maximumByComponent=function(t,e,a){return a.x=Math.max(t.x,e.x),a.y=Math.max(t.y,e.y),a.z=Math.max(t.z,e.z),a.w=Math.max(t.w,e.w),a},t.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w},t.magnitude=function(e){return Math.sqrt(t.magnitudeSquared(e))},t.distance=function(e,a){return t.subtract(e,a,O),t.magnitude(O)},t.distanceSquared=function(e,a){return t.subtract(e,a,O),t.magnitudeSquared(O)},t.normalize=function(e,a){var n=t.magnitude(e);return a.x=e.x/n,a.y=e.y/n,a.z=e.z/n,a.w=e.w/n,a},t.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},t.multiplyComponents=function(t,e,a){return a.x=t.x*e.x,a.y=t.y*e.y,a.z=t.z*e.z,a.w=t.w*e.w,a},t.divideComponents=function(t,e,a){return a.x=t.x/e.x,a.y=t.y/e.y,a.z=t.z/e.z,a.w=t.w/e.w,a},t.add=function(t,e,a){return a.x=t.x+e.x,a.y=t.y+e.y,a.z=t.z+e.z,a.w=t.w+e.w,a},t.subtract=function(t,e,a){return a.x=t.x-e.x,a.y=t.y-e.y,a.z=t.z-e.z,a.w=t.w-e.w,a},t.multiplyByScalar=function(t,e,a){return a.x=t.x*e,a.y=t.y*e,a.z=t.z*e,a.w=t.w*e,a},t.divideByScalar=function(t,e,a){return a.x=t.x/e,a.y=t.y/e,a.z=t.z/e,a.w=t.w/e,a},t.negate=function(t,e){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=-t.w,e},t.abs=function(t,e){return e.x=Math.abs(t.x),e.y=Math.abs(t.y),e.z=Math.abs(t.z),e.w=Math.abs(t.w),e},t.lerp=function(e,a,n,r){return t.multiplyByScalar(a,n,N),r=t.multiplyByScalar(e,1-n,r),t.add(N,r,r)},t.mostOrthogonalAxis=function(e,a){var n=t.normalize(e,L);return t.abs(n,n),n.x<=n.y?n.x<=n.z?n.x<=n.w?t.UNIT_X.copyTo(a):t.UNIT_W.copyTo(a):n.z<=n.w?t.UNIT_Z.copyTo(a):t.UNIT_W.copyTo(a):n.y<=n.z?n.y<=n.w?t.UNIT_Y.copyTo(a):t.UNIT_W.copyTo(a):n.z<=n.w?t.UNIT_Z.copyTo(a):t.UNIT_W.copyTo(a),a},t.equals=function(t,e){return t===e||t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w},t.equalsArray=function(t,e,a){return a=null!=a?a:0,t.x===e[a]&&t.y===e[a+1]&&t.z===e[a+2]&&t.w===e[a+3]},t.equalsEpsilon=function(t,e,a,n){return t===e||g.equalsEpsilon(t.x,e.x,a,n)&&g.equalsEpsilon(t.y,e.y,a,n)&&g.equalsEpsilon(t.z,e.z,a,n)&&g.equalsEpsilon(t.w,e.w,a,n)},t.prototype.toArray=function(){var e=new Array(4);return t.pack(this,e)},t.min=function(e,a,n){return t.minimumByComponent(e,a,n),n},t.max=function(e,a,n){return t.maximumByComponent(e,a,n),n},t.mix=function(e,a,n,r){return t.lerp(e,a,n,r),r},t.floor=function(t,e){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e.w=Math.floor(t.w),e},t.ceil=function(t,e){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e.z=Math.ceil(t.z),e.w=Math.ceil(t.w),e},t.round=function(t,e){return e.x=Math.round(t.x),e.y=Math.round(t.y),e.z=Math.round(t.z),e.w=Math.round(t.w),e},t.prototype.copyTo=function(t){return t.x=this.x,t.y=this.y,t.z=this.z,t.w=this.w,t},t.prototype.clone=function(){return t.clone(this)},t.prototype.normalize=function(){return t.normalize(this,this)},t.prototype.length=function(){return t.magnitude(this)},t.prototype.lengthSquared=function(){return t.magnitudeSquared(this)},t.prototype.floor=function(){return t.floor(this,this)},t.prototype.ceil=function(){return t.ceil(this,this)},t.prototype.round=function(){return t.round(this,this)},t.prototype.negate=function(){return t.negate(this,this)},t.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},t.prototype.addVector=function(e){return t.add(this,e,this)},t.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},t.prototype.subVector=function(e){return t.subtract(this,e,this)},t.prototype.multiplyScalar=function(e){return t.multiplyByScalar(this,e,this)},t.prototype.multiplyVector=function(e){return t.multiplyComponents(this,e,this)},t.prototype.divideScalar=function(e){return t.divideByScalar(this,e,this)},t.prototype.divideVector=function(e){return t.divideComponents(this,e,this)},t.prototype.dot=function(e){return t.dot(this,e)},t.prototype.distanceTo=function(e){return t.distance(this,e)},t.prototype.distanceSquaredTo=function(e){return t.distanceSquared(this,e)},t.prototype.getData=function(){return this._data},t.ZERO=Object.freeze(new t(0,0,0,0)),t.ONE=Object.freeze(new t(1,1,1,1)),t.UNIT_X=Object.freeze(new t(1,0,0,0)),t.UNIT_Y=Object.freeze(new t(0,1,0,0)),t.UNIT_Z=Object.freeze(new t(0,0,1,0)),t.UNIT_W=Object.freeze(new t(0,0,0,1)),t}(),O=new P,N=new P,L=new P,F=function(){function t(t,e,a,n){this._data=new Float32Array(4),this._data[0]=null!=t?t:0,this._data[1]=null!=a?a:0,this._data[2]=null!=e?e:0,this._data[3]=null!=n?n:0}return t.prototype.getData=function(){return this._data},t.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t._data[0],e[a++]=t._data[1],e[a++]=t._data[2],e[a++]=t._data[3],e},t.unpack=function(t,e,a){return a._data[0]=t[e++],a._data[1]=t[e++],a._data[2]=t[e++],a._data[3]=t[e++],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,4*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=4){var o=r/4;a[o]=t.unpack(e,r,a[o])}return a},t.clone=function(e){return new t(e._data[0],e._data[2],e._data[1],e._data[3])},t.fromArray=function(e){return t.unpack(e,0,new t)},t.fromColumnMajorArray=function(e,a){return t.unpack(e,0,a)},t.fromRowMajorArray=function(e,a){return void 0===a?new t(e[0],e[1],e[2],e[3]):(a._data[0]=e[0],a._data[1]=e[2],a._data[2]=e[1],a._data[3]=e[3],a)},t.fromScale=function(t,e){return e._data[0]=t.x,e._data[1]=0,e._data[2]=0,e._data[3]=t.y,e},t.fromUniformScale=function(t,e){return e._data[0]=t,e._data[1]=0,e._data[2]=0,e._data[3]=t,e},t.fromRotation=function(t,e){var a=Math.cos(t),n=Math.sin(t);return e._data[0]=a,e._data[1]=n,e._data[2]=-n,e._data[3]=a,e},t.toArray=function(t,e){return e[0]=t._data[0],e[1]=t._data[1],e[2]=t._data[2],e[3]=t._data[3],e},t.getElement=function(t,e,a){return t._data[2*e+a]},t.getColumn=function(t,e,a){var n=2*e,r=t._data[n],o=t._data[n+1];return a.x=r,a.y=o,a},t.setColumn=function(t,e,a,n){var r=2*e;return(n=t.copyTo(n))._data[r]=a.x,n._data[r+1]=a.y,n},t.getRow=function(t,e,a){void 0===a&&(a=new y);var n=t._data[e],r=t._data[e+2];return a.x=n,a.y=r,a},t.setRow=function(t,e,a,n){return(n=t.copyTo(n))._data[e]=a.x,n._data[e+2]=a.y,n},t.scale=function(e,a,n){var r=t.getScale(e,R),o=a.x/r.x,i=a.y/r.y;return void 0===n&&(n=new t),n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*i,n._data[3]=e._data[3]*i,n},t.setUniformScale=function(e,a,n){var r=t.getScale(e,z),o=a/r.x,i=a/r.y;return void 0===n&&(n=new t),n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*i,n._data[3]=e._data[3]*i,n},t.getScale=function(t,e){return B.set(t._data[0],t._data[1]),e.x=y.magnitude(B),B.set(t._data[2],t._data[3]),e.y=y.magnitude(B),e},t.getMaximumScale=function(e){return t.getScale(e,D),y.maximumComponent(D)},t.setRotation=function(e,a,n){var r=t.getScale(e,U);return n._data[0]=a._data[0]*r.x,n._data[1]=a._data[1]*r.x,n._data[2]=a._data[2]*r.y,n._data[3]=a._data[3]*r.y,n},t.getRotation=function(e,a){var n=t.getScale(e,k);return a._data[0]=e._data[0]/n.x,a._data[1]=e._data[1]/n.x,a._data[2]=e._data[2]/n.y,a._data[3]=e._data[3]/n.y,a},t.multiply=function(t,e,a){var n=t._data[0]*e._data[0]+t._data[2]*e._data[1],r=t._data[0]*e._data[2]+t._data[2]*e._data[3],o=t._data[1]*e._data[0]+t._data[3]*e._data[1],i=t._data[1]*e._data[2]+t._data[3]*e._data[3];return a._data[0]=n,a._data[1]=o,a._data[2]=r,a._data[3]=i,a},t.add=function(t,e,a){return a._data[0]=t._data[0]+e._data[0],a._data[1]=t._data[1]+e._data[1],a._data[2]=t._data[2]+e._data[2],a._data[3]=t._data[3]+e._data[3],a},t.subtract=function(t,e,a){return a._data[0]=t._data[0]-e._data[0],a._data[1]=t._data[1]-e._data[1],a._data[2]=t._data[2]-e._data[2],a._data[3]=t._data[3]-e._data[3],a},t.multiplyByVector=function(t,e,a){var n=t._data[0]*e.x+t._data[2]*e.y,r=t._data[1]*e.x+t._data[3]*e.y;return a.x=n,a.y=r,a},t.multiplyByScalar=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3]*e,a},t.multiplyByScale=function(t,e,a){return a._data[0]=t._data[0]*e.x,a._data[1]=t._data[1]*e.x,a._data[2]=t._data[2]*e.y,a._data[3]=t._data[3]*e.y,a},t.multiplyByUniformScale=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3]*e,a},t.negate=function(t,e){return e._data[0]=-t._data[0],e._data[1]=-t._data[1],e._data[2]=-t._data[2],e._data[3]=-t._data[3],e},t.transpose=function(t,e){var a=t._data[0],n=t._data[2],r=t._data[1],o=t._data[3];return e._data[0]=a,e._data[1]=n,e._data[2]=r,e._data[3]=o,e},t.abs=function(t,e){return e._data[0]=Math.abs(t._data[0]),e._data[1]=Math.abs(t._data[1]),e._data[2]=Math.abs(t._data[2]),e._data[3]=Math.abs(t._data[3]),e},t.equals=function(t,e){return t===e||t._data[0]===e._data[0]&&t._data[1]===e._data[1]&&t._data[2]===e._data[2]&&t._data[3]===e._data[3]},t.equalsArray=function(t,e,a){return a=null!=a?a:0,t._data[0]===e[a]&&t._data[1]===e[a+1]&&t._data[2]===e[a+2]&&t._data[3]===e[a+3]},t.equalsEpsilon=function(t,e,a){return a=null!=a?a:0,t===e||Math.abs(t._data[0]-e._data[0])<=a&&Math.abs(t._data[1]-e._data[1])<=a&&Math.abs(t._data[2]-e._data[2])<=a&&Math.abs(t._data[3]-e._data[3])<=a},t.prototype.copyTo=function(t){return t._data[0]=this._data[0],t._data[1]=this._data[1],t._data[2]=this._data[2],t._data[3]=this._data[3],t},t.prototype.copyFrom=function(t){return this._data[0]=t._data[0],this._data[1]=t._data[1],this._data[2]=t._data[2],this._data[3]=t._data[3],this},t.IDENTITY=Object.freeze(new t(1,0,0,1)),t.ZERO=Object.freeze(new t(0,0,0,0)),t}(),R=new y,z=new y,B=new y,D=new y,U=new y,k=new y,V=function(){function t(t,e,a,n,r,o,i,s,c){this._data=new Float32Array(9),this._data[0]=null!=t?t:0,this._data[1]=null!=n?n:0,this._data[2]=null!=i?i:0,this._data[3]=null!=e?e:0,this._data[4]=null!=r?r:0,this._data[5]=null!=s?s:0,this._data[6]=null!=a?a:0,this._data[7]=null!=o?o:0,this._data[8]=null!=c?c:0}return t.prototype.getData=function(){return this._data},t.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t._data[0],e[a++]=t._data[1],e[a++]=t._data[2],e[a++]=t._data[3],e[a++]=t._data[4],e[a++]=t._data[5],e[a++]=t._data[6],e[a++]=t._data[7],e[a++]=t._data[8],e},t.unpack=function(t,e,a){return a._data[0]=t[e++],a._data[1]=t[e++],a._data[2]=t[e++],a._data[3]=t[e++],a._data[4]=t[e++],a._data[5]=t[e++],a._data[6]=t[e++],a._data[7]=t[e++],a._data[8]=t[e++],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,9*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=9){var o=r/9;a[o]=t.unpack(e,r,a[o])}return a},t.clone=function(e){var a=new t;return a._data[0]=e._data[0],a._data[1]=e._data[1],a._data[2]=e._data[2],a._data[3]=e._data[3],a._data[4]=e._data[4],a._data[5]=e._data[5],a._data[6]=e._data[6],a._data[7]=e._data[7],a._data[8]=e._data[8],a},t.copyTo=function(t,e){return e._data[0]=t._data[0],e._data[1]=t._data[1],e._data[2]=t._data[2],e._data[3]=t._data[3],e._data[4]=t._data[4],e._data[5]=t._data[5],e._data[6]=t._data[6],e._data[7]=t._data[7],e._data[8]=t._data[8],e},t.fromArray=function(e){return t.unpack(e,0,new t)},t.fromColumnMajorArray=function(e,a){return t.unpack(e,0,a)},t.fromRowMajorArray=function(t,e){return e._data[0]=t[0],e._data[1]=t[3],e._data[2]=t[6],e._data[3]=t[1],e._data[4]=t[4],e._data[5]=t[7],e._data[6]=t[2],e._data[7]=t[5],e._data[8]=t[8],e},t.fromQuaternion=function(t,e){var a=t.x*t.x,n=t.x*t.y,r=t.x*t.z,o=t.x*t.w,i=t.y*t.y,s=t.y*t.z,c=t.y*t.w,u=t.z*t.z,d=t.z*t.w,l=t.w*t.w,h=a-i-u+l,f=2*(n-d),p=2*(r+c),m=2*(n+d),_=-a+i-u+l,g=2*(s-o),y=2*(r-c),v=2*(s+o),x=-a-i+u+l;return e._data[0]=h,e._data[1]=m,e._data[2]=y,e._data[3]=f,e._data[4]=_,e._data[5]=v,e._data[6]=p,e._data[7]=g,e._data[8]=x,e},t.fromHeadingPitchRoll=function(t,e){var a=Math.cos(-t.pitch),n=Math.cos(-t.heading),r=Math.cos(t.roll),o=Math.sin(-t.pitch),i=Math.sin(-t.heading),s=Math.sin(t.roll),c=a*n,u=-r*i+s*o*n,d=s*i+r*o*n,l=a*i,h=r*n+s*o*i,f=-s*n+r*o*i,p=-o,m=s*a,_=r*a;return e._data[0]=c,e._data[1]=l,e._data[2]=p,e._data[3]=u,e._data[4]=h,e._data[5]=m,e._data[6]=d,e._data[7]=f,e._data[8]=_,e},t.fromScale=function(t,e){return e._data[0]=t.x,e._data[1]=0,e._data[2]=0,e._data[3]=0,e._data[4]=t.y,e._data[5]=0,e._data[6]=0,e._data[7]=0,e._data[8]=t.z,e},t.fromUniformScale=function(t,e){return e._data[0]=t,e._data[1]=0,e._data[2]=0,e._data[3]=0,e._data[4]=t,e._data[5]=0,e._data[6]=0,e._data[7]=0,e._data[8]=t,e},t.fromCrossProduct=function(t,e){return e._data[0]=0,e._data[1]=t.z,e._data[2]=-t.y,e._data[3]=-t.z,e._data[4]=0,e._data[5]=t.x,e._data[6]=t.y,e._data[7]=-t.x,e._data[8]=0,e},t.fromRotationX=function(t,e){var a=Math.cos(t),n=Math.sin(t);return e._data[0]=1,e._data[1]=0,e._data[2]=0,e._data[3]=0,e._data[4]=a,e._data[5]=n,e._data[6]=0,e._data[7]=-n,e._data[8]=a,e},t.fromRotationY=function(t,e){var a=Math.cos(t),n=Math.sin(t);return e._data[0]=a,e._data[1]=0,e._data[2]=-n,e._data[3]=0,e._data[4]=1,e._data[5]=0,e._data[6]=n,e._data[7]=0,e._data[8]=a,e},t.fromRotationZ=function(t,e){var a=Math.cos(t),n=Math.sin(t);return e._data[0]=a,e._data[1]=n,e._data[2]=0,e._data[3]=-n,e._data[4]=a,e._data[5]=0,e._data[6]=0,e._data[7]=0,e._data[8]=1,e},t.toArray=function(t,e){return e[0]=t._data[0],e[1]=t._data[1],e[2]=t._data[2],e[3]=t._data[3],e[4]=t._data[4],e[5]=t._data[5],e[6]=t._data[6],e[7]=t._data[7],e[8]=t._data[8],e},t.getElement=function(t,e,a){return t._data[3*e+a]},t.getColumn=function(t,e,a){var n=3*e,r=t._data[n],o=t._data[n+1],i=t._data[n+2];return a.x=r,a.y=o,a.z=i,a},t.setColumn=function(e,a,n,r){var o=3*a;return(r=t.copyTo(e,r))._data[o]=n.x,r._data[o+1]=n.y,r._data[o+2]=n.z,r},t.getRow=function(t,e,a){var n=t._data[e],r=t._data[e+3],o=t._data[e+6];return a.x=n,a.y=r,a.z=o,a},t.setRow=function(e,a,n,r){return(r=t.copyTo(e,r))._data[a]=n.x,r._data[a+3]=n.y,r._data[a+6]=n.z,r},t.scale=function(e,a,n){var r=t.getScale(e,j),o=a.x/r.x,i=a.y/r.y,s=a.z/r.z;return n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*o,n._data[3]=e._data[3]*i,n._data[4]=e._data[4]*i,n._data[5]=e._data[5]*i,n._data[6]=e._data[6]*s,n._data[7]=e._data[7]*s,n._data[8]=e._data[8]*s,n},t.setUniformScale=function(e,a,n){var r=t.getScale(e,G),o=a/r.x,i=a/r.y,s=a/r.z;return n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*o,n._data[3]=e._data[3]*i,n._data[4]=e._data[4]*i,n._data[5]=e._data[5]*i,n._data[6]=e._data[6]*s,n._data[7]=e._data[7]*s,n._data[8]=e._data[8]*s,n},t.getScale=function(t,e){return H.set(t._data[0],t._data[1],t._data[2]),e.x=S.magnitude(H),H.set(t._data[3],t._data[4],t._data[5]),e.y=S.magnitude(H),H.set(t._data[6],t._data[7],t._data[8]),e.z=S.magnitude(H),e},t.getMaximumScale=function(e){return t.getScale(e,W),S.maximumComponent(W)},t.setRotation=function(e,a,n){var r=t.getScale(e,q);return n._data[0]=a._data[0]*r.x,n._data[1]=a._data[1]*r.x,n._data[2]=a._data[2]*r.x,n._data[3]=a._data[3]*r.y,n._data[4]=a._data[4]*r.y,n._data[5]=a._data[5]*r.y,n._data[6]=a._data[6]*r.z,n._data[7]=a._data[7]*r.z,n._data[8]=a._data[8]*r.z,n},t.getRotation=function(e,a){var n=t.getScale(e,X);return a._data[0]=e._data[0]/n.x,a._data[1]=e._data[1]/n.x,a._data[2]=e._data[2]/n.x,a._data[3]=e._data[3]/n.y,a._data[4]=e._data[4]/n.y,a._data[5]=e._data[5]/n.y,a._data[6]=e._data[6]/n.z,a._data[7]=e._data[7]/n.z,a._data[8]=e._data[8]/n.z,a},t.multiply=function(t,e,a){var n=t._data[0]*e._data[0]+t._data[3]*e._data[1]+t._data[6]*e._data[2],r=t._data[1]*e._data[0]+t._data[4]*e._data[1]+t._data[7]*e._data[2],o=t._data[2]*e._data[0]+t._data[5]*e._data[1]+t._data[8]*e._data[2],i=t._data[0]*e._data[3]+t._data[3]*e._data[4]+t._data[6]*e._data[5],s=t._data[1]*e._data[3]+t._data[4]*e._data[4]+t._data[7]*e._data[5],c=t._data[2]*e._data[3]+t._data[5]*e._data[4]+t._data[8]*e._data[5],u=t._data[0]*e._data[6]+t._data[3]*e._data[7]+t._data[6]*e._data[8],d=t._data[1]*e._data[6]+t._data[4]*e._data[7]+t._data[7]*e._data[8],l=t._data[2]*e._data[6]+t._data[5]*e._data[7]+t._data[8]*e._data[8];return a._data[0]=n,a._data[1]=r,a._data[2]=o,a._data[3]=i,a._data[4]=s,a._data[5]=c,a._data[6]=u,a._data[7]=d,a._data[8]=l,a},t.add=function(t,e,a){return a._data[0]=t._data[0]+e._data[0],a._data[1]=t._data[1]+e._data[1],a._data[2]=t._data[2]+e._data[2],a._data[3]=t._data[3]+e._data[3],a._data[4]=t._data[4]+e._data[4],a._data[5]=t._data[5]+e._data[5],a._data[6]=t._data[6]+e._data[6],a._data[7]=t._data[7]+e._data[7],a._data[8]=t._data[8]+e._data[8],a},t.subtract=function(t,e,a){return a._data[0]=t._data[0]-e._data[0],a._data[1]=t._data[1]-e._data[1],a._data[2]=t._data[2]-e._data[2],a._data[3]=t._data[3]-e._data[3],a._data[4]=t._data[4]-e._data[4],a._data[5]=t._data[5]-e._data[5],a._data[6]=t._data[6]-e._data[6],a._data[7]=t._data[7]-e._data[7],a._data[8]=t._data[8]-e._data[8],a},t.multiplyByVector=function(t,e,a){var n=e.x,r=e.y,o=e.z,i=t._data[0]*n+t._data[3]*r+t._data[6]*o,s=t._data[1]*n+t._data[4]*r+t._data[7]*o,c=t._data[2]*n+t._data[5]*r+t._data[8]*o;return a.x=i,a.y=s,a.z=c,a},t.multiplyByScalar=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3]*e,a._data[4]=t._data[4]*e,a._data[5]=t._data[5]*e,a._data[6]=t._data[6]*e,a._data[7]=t._data[7]*e,a._data[8]=t._data[8]*e,a},t.multiplyByScale=function(t,e,a){return a._data[0]=t._data[0]*e.x,a._data[1]=t._data[1]*e.x,a._data[2]=t._data[2]*e.x,a._data[3]=t._data[3]*e.y,a._data[4]=t._data[4]*e.y,a._data[5]=t._data[5]*e.y,a._data[6]=t._data[6]*e.z,a._data[7]=t._data[7]*e.z,a._data[8]=t._data[8]*e.z,a},t.multiplyByUniformScale=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3]*e,a._data[4]=t._data[4]*e,a._data[5]=t._data[5]*e,a._data[6]=t._data[6]*e,a._data[7]=t._data[7]*e,a._data[8]=t._data[8]*e,a},t.negate=function(t,e){return e._data[0]=-t._data[0],e._data[1]=-t._data[1],e._data[2]=-t._data[2],e._data[3]=-t._data[3],e._data[4]=-t._data[4],e._data[5]=-t._data[5],e._data[6]=-t._data[6],e._data[7]=-t._data[7],e._data[8]=-t._data[8],e},t.transpose=function(t,e){var a=t._data[0],n=t._data[3],r=t._data[6],o=t._data[1],i=t._data[4],s=t._data[7],c=t._data[2],u=t._data[5],d=t._data[8];return e._data[0]=a,e._data[1]=n,e._data[2]=r,e._data[3]=o,e._data[4]=i,e._data[5]=s,e._data[6]=c,e._data[7]=u,e._data[8]=d,e},t.abs=function(e,a){return void 0===a&&(a=new t),a._data[0]=Math.abs(e._data[0]),a._data[1]=Math.abs(e._data[1]),a._data[2]=Math.abs(e._data[2]),a._data[3]=Math.abs(e._data[3]),a._data[4]=Math.abs(e._data[4]),a._data[5]=Math.abs(e._data[5]),a._data[6]=Math.abs(e._data[6]),a._data[7]=Math.abs(e._data[7]),a._data[8]=Math.abs(e._data[8]),a},t.determinant=function(t){var e=t._data[0],a=t._data[3],n=t._data[6],r=t._data[1],o=t._data[4],i=t._data[7],s=t._data[2],c=t._data[5],u=t._data[8];return e*(o*u-c*i)+r*(c*n-a*u)+s*(a*i-o*n)},t.inverse=function(e,a){var n=e._data[0],r=e._data[1],o=e._data[2],i=e._data[3],s=e._data[4],c=e._data[5],u=e._data[6],d=e._data[7],l=e._data[8],h=t.determinant(e);a._data[0]=s*l-d*c,a._data[1]=d*o-r*l,a._data[2]=r*c-s*o,a._data[3]=u*c-i*l,a._data[4]=n*l-u*o,a._data[5]=i*o-n*c,a._data[6]=i*d-u*s,a._data[7]=u*r-n*d,a._data[8]=n*s-i*r;var f=1/h;return t.multiplyByScalar(a,f,a)},t.inverseTranspose=function(e,a){return t.inverse(t.transpose(e,Y),a)},t.equals=function(t,e){return t===e||t._data[0]===e._data[0]&&t._data[1]===e._data[1]&&t._data[2]===e._data[2]&&t._data[3]===e._data[3]&&t._data[4]===e._data[4]&&t._data[5]===e._data[5]&&t._data[6]===e._data[6]&&t._data[7]===e._data[7]&&t._data[8]===e._data[8]},t.equalsEpsilon=function(t,e,a){return a=null!=a?a:0,t===e||Math.abs(t._data[0]-e._data[0])<=a&&Math.abs(t._data[1]-e._data[1])<=a&&Math.abs(t._data[2]-e._data[2])<=a&&Math.abs(t._data[3]-e._data[3])<=a&&Math.abs(t._data[4]-e._data[4])<=a&&Math.abs(t._data[5]-e._data[5])<=a&&Math.abs(t._data[6]-e._data[6])<=a&&Math.abs(t._data[7]-e._data[7])<=a&&Math.abs(t._data[8]-e._data[8])<=a},t.getElementIndex=function(t,e){return 3*t+e},t.prototype.getElement=function(e,a){return t.getElement(this,e,a)},t.prototype.clone=function(){return t.clone(this)},t.prototype.copyTo=function(e){return e=t.copyTo(this,e)},t.prototype.copyFrom=function(e){return t.copyTo(e,this),this},t.prototype.scale=function(e){return t.scale(this,e,this)},t.prototype.multiply=function(e){return t.multiply(this,e,this)},t.prototype.toArray=function(){var e=new Array(9);return t.toArray(this,e)},t.prototype.toFloat32Array=function(){var e=new Float32Array(9);return t.pack(this,e,0),e},t.prototype.multiplyByVector3=function(e){return t.multiplyByVector(this,e,new S)},t.prototype.at=function(t){return this._data[t]},t.prototype.rotate=function(t,e){var a=e.x,n=e.y,r=e.z,o=Math.sqrt(a*a+n*n+r*r);if(o){1!==o&&(a*=o=1/o,n*=o,r*=o);var i=Math.sin(t),s=Math.cos(t),c=1-s,u=this._data[0],d=this._data[1],l=this._data[2],h=this._data[3],f=this._data[4],p=this._data[5],m=this._data[6],_=this._data[7],g=this._data[8],y=this._data[9],v=this._data[10],x=this._data[11],b=a*a*c+s,T=n*a*c+r*i,M=r*a*c-n*i,S=a*n*c-r*i,C=n*n*c+s,w=r*n*c+a*i,A=a*r*c+n*i,I=n*r*c-a*i,E=r*r*c+s;return this._data[0]=u*b+f*T+g*M,this._data[1]=d*b+p*T+y*M,this._data[2]=l*b+m*T+v*M,this._data[3]=h*b+_*T+x*M,this._data[4]=u*S+f*C+g*w,this._data[5]=d*S+p*C+y*w,this._data[6]=l*S+m*C+v*w,this._data[7]=h*S+_*C+x*w,this._data[8]=u*A+f*I+g*E,this._data[9]=d*A+p*I+y*E,this._data[10]=l*A+m*I+v*E,this._data[11]=h*A+_*I+x*E,this}},t.prototype.inverse=function(){return t.inverse(this,this)},t.prototype.transpose=function(){return t.transpose(this,this)},t.IDENTITY=Object.freeze(new t(1,0,0,0,1,0,0,0,1)),t.ZERO=Object.freeze(new t(0,0,0,0,0,0,0,0,0)),t.COLUMN0ROW0=0,t.COLUMN0ROW1=1,t.COLUMN0ROW2=2,t.COLUMN1ROW0=3,t.COLUMN1ROW1=4,t.COLUMN1ROW2=5,t.COLUMN2ROW0=6,t.COLUMN2ROW1=7,t.COLUMN2ROW2=8,t}(),j=new S,G=new S,H=new S,W=new S,q=new S,X=new S,Y=new V;t.EulerOrder=void 0,(_=t.EulerOrder||(t.EulerOrder={}))[_.XYZ=0]="XYZ",_[_.XZY=1]="XZY",_[_.YXZ=2]="YXZ",_[_.YZX=3]="YZX",_[_.ZXY=4]="ZXY",_[_.ZYX=5]="ZYX";var Z=function(){function e(e,a,n,r){void 0===e&&(e=0),void 0===a&&(a=0),void 0===n&&(n=0),void 0===r&&(r=t.EulerOrder.ZYX),this._order=r,this._data=new Float32Array([e,a,n])}return Object.defineProperty(e.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data[0]=t},enumerable:!1,configurable:!0}),e.prototype.getX=function(){return this._data[0]},e.prototype.setX=function(t){this._data[0]=t},Object.defineProperty(e.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t},enumerable:!1,configurable:!0}),e.prototype.getY=function(){return this._data[1]},e.prototype.setY=function(t){this._data[1]=t},Object.defineProperty(e.prototype,"z",{get:function(){return this._data[2]},set:function(t){this._data[2]=t},enumerable:!1,configurable:!0}),e.prototype.getZ=function(){return this._data[2]},e.prototype.setZ=function(t){this._data[2]=t},Object.defineProperty(e.prototype,"order",{get:function(){return this._order},set:function(t){this._order=t},enumerable:!1,configurable:!0}),e.prototype.getOrder=function(){return this._order},e.prototype.setOrder=function(t){this._order=t},e.prototype.set=function(e,a,n,r){return this._data[0]=e,this._data[1]=a,this._data[2]=n,this._order=void 0===r?t.EulerOrder.ZYX:r,this},e.prototype.clone=function(){return e.clone(this)},e.prototype.copyTo=function(t){return t=e.copyTo(this,t)},e.prototype.copyFrom=function(t){return e.copyTo(t,this),this},e.prototype.setFromRotationMatrix=function(a,n){return void 0===n&&(n=t.EulerOrder.XYZ),e.setFromRotationMatrix(a,n,this)},e.prototype.setFromQuaternion=function(a,n){return void 0===n&&(n=t.EulerOrder.XYZ),e.setFromQuaternion(a,n,this)},e.prototype.setFromVector3=function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},e.prototype.reorder=function(t){return e.reorder(this,t)},e.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t._order===this._order},e.prototype.fromArray=function(t){return this.x=t[0],this.y=t[1],this.z=t[2],void 0!==t[3]&&(this._order=t[3]),this},e.prototype.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this._order,t},e.prototype.toVector3=function(t){return t.set(this.x,this.y,this.z),t},e.clone=function(t){var a=new e;return a.x=t.x,a.y=t.y,a.z=t.z,a.order=t.order,a},e.copyTo=function(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.order=t.order,e},e.setFromRotationMatrix=function(e,a,n){var r=g.clamp,o=e.getData(),i=o[0],s=o[4],c=o[8],u=o[1],d=o[5],l=o[9],h=o[2],f=o[6],p=o[10];switch(a=a||n._order){case t.EulerOrder.XYZ:n.y=Math.asin(r(c,-1,1)),Math.abs(c)<.9999999?(n.x=Math.atan2(-l,p),n.z=Math.atan2(-s,i)):(n.x=Math.atan2(f,d),n.z=0);break;case t.EulerOrder.YXZ:n.x=Math.asin(-r(l,-1,1)),Math.abs(l)<.9999999?(n.y=Math.atan2(c,p),n.z=Math.atan2(u,d)):(n.y=Math.atan2(-h,i),n.z=0);break;case t.EulerOrder.ZXY:n.x=Math.asin(r(f,-1,1)),Math.abs(f)<.9999999?(n.y=Math.atan2(-h,p),n.z=Math.atan2(-s,d)):(n.y=0,n.z=Math.atan2(u,i));break;case t.EulerOrder.ZYX:n.y=Math.asin(-r(h,-1,1)),Math.abs(h)<.9999999?(n.x=Math.atan2(f,p),n.z=Math.atan2(u,i)):(n.x=0,n.z=Math.atan2(-s,d));break;case t.EulerOrder.YZX:n.z=Math.asin(r(u,-1,1)),Math.abs(u)<.9999999?(n.x=Math.atan2(-l,d),n.y=Math.atan2(-h,i)):(n.x=0,n.y=Math.atan2(c,p));break;case t.EulerOrder.XZY:n.z=Math.asin(-r(s,-1,1)),Math.abs(s)<.9999999?(n.x=Math.atan2(f,d),n.y=Math.atan2(c,i)):(n.x=Math.atan2(-l,p),n.y=0);break;default:console.warn("Euler.setFromRotationMatrix() encountered an unknown order: ".concat(a))}return n._order=a,n},e.setFromQuaternion=function(t,a,n){var r=new ct;return t.toMatrix4(r),e.setFromRotationMatrix(r,a,n)},e.reorder=function(t,a){var n=new J;return J.setFromEuler(t,n),e.setFromQuaternion(n,a,t)},e}(),J=function(){function e(t,e,a,n){this._data=new Float32Array([null!=t?t:0,null!=e?e:0,null!=a?a:0,null!=n?n:0])}return Object.defineProperty(e.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data[0]=t},enumerable:!1,configurable:!0}),e.prototype.getX=function(){return this._data[0]},e.prototype.setX=function(t){this._data[0]=t},Object.defineProperty(e.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t},enumerable:!1,configurable:!0}),e.prototype.getY=function(){return this._data[1]},e.prototype.setY=function(t){this._data[1]=t},Object.defineProperty(e.prototype,"z",{get:function(){return this._data[2]},set:function(t){this._data[2]=t},enumerable:!1,configurable:!0}),e.prototype.getZ=function(){return this._data[2]},e.prototype.setZ=function(t){this._data[2]=t},Object.defineProperty(e.prototype,"w",{get:function(){return this._data[3]},set:function(t){this._data[3]=t},enumerable:!1,configurable:!0}),e.prototype.getW=function(){return this._data[3]},e.prototype.setW=function(t){this._data[3]=t},e.fromAxisAngle=function(t,e,a){var n=e/2,r=Math.sin(n),o=(Q=S.normalize(t,Q)).x*r,i=Q.y*r,s=Q.z*r,c=Math.cos(n);return a.x=o,a.y=i,a.z=s,a.w=c,a},e.fromRotationMatrix=function(t,e){var a,n,r,o,i,s=t.getData()[V.COLUMN0ROW0],c=t.getData()[V.COLUMN1ROW1],u=t.getData()[V.COLUMN2ROW2],d=s+c+u;if(d>0)i=.5*(a=Math.sqrt(d+1)),a=.5/a,n=(t.getData()[V.COLUMN1ROW2]-t.getData()[V.COLUMN2ROW1])*a,r=(t.getData()[V.COLUMN2ROW0]-t.getData()[V.COLUMN0ROW2])*a,o=(t.getData()[V.COLUMN0ROW1]-t.getData()[V.COLUMN1ROW0])*a;else{var l=K,h=0;c>s&&(h=1),u>s&&u>c&&(h=2);var f=l[h],p=l[f];a=Math.sqrt(t.getData()[V.getElementIndex(h,h)]-t.getData()[V.getElementIndex(f,f)]-t.getData()[V.getElementIndex(p,p)]+1);var m=$;m[h]=.5*a,a=.5/a,i=(t.getData()[V.getElementIndex(p,f)]-t.getData()[V.getElementIndex(f,p)])*a,m[f]=(t.getData()[V.getElementIndex(f,h)]+t.getData()[V.getElementIndex(h,f)])*a,m[p]=(t.getData()[V.getElementIndex(p,h)]+t.getData()[V.getElementIndex(h,p)])*a,n=-m[0],r=-m[1],o=-m[2]}return e.x=n,e.y=r,e.z=o,e.w=i,e},e.fromHeadingPitchRoll=function(t,a){return nt=e.fromAxisAngle(S.UNIT_X,t.roll,tt),at=e.fromAxisAngle(S.UNIT_Y,-t.pitch,a),a=e.multiply(at,nt,at),et=e.fromAxisAngle(S.UNIT_Z,-t.heading,tt),e.multiply(et,a,a)},e.setFromEuler=function(e,a){var n=e.x,r=e.y,o=e.z,i=e.order,s=Math.cos,c=Math.sin,u=s(n/2),d=s(r/2),l=s(o/2),h=c(n/2),f=c(r/2),p=c(o/2);switch(i){case t.EulerOrder.XYZ:a.x=h*d*l+u*f*p,a.y=u*f*l-h*d*p,a.z=u*d*p+h*f*l,a.w=u*d*l-h*f*p;break;case t.EulerOrder.YXZ:a.x=h*d*l+u*f*p,a.y=u*f*l-h*d*p,a.z=u*d*p-h*f*l,a.w=u*d*l+h*f*p;break;case t.EulerOrder.ZXY:a.x=h*d*l-u*f*p,a.y=u*f*l+h*d*p,a.z=u*d*p+h*f*l,a.w=u*d*l-h*f*p;break;case t.EulerOrder.ZYX:a.x=h*d*l-u*f*p,a.y=u*f*l+h*d*p,a.z=u*d*p-h*f*l,a.w=u*d*l+h*f*p;break;case t.EulerOrder.YZX:a.x=h*d*l+u*f*p,a.y=u*f*l+h*d*p,a.z=u*d*p-h*f*l,a.w=u*d*l-h*f*p;break;case t.EulerOrder.XZY:a.x=h*d*l-u*f*p,a.y=u*f*l-h*d*p,a.z=u*d*p+h*f*l,a.w=u*d*l+h*f*p;break;default:console.warn("Quaternion.setFromEuler() encountered an unknown order: ".concat(i))}return a},e.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t.x,e[a++]=t.y,e[a++]=t.z,e[a]=t.w,e},e.unpack=function(t,e,a){return a.x=t[e++],a.y=t[e++],a.z=t[e++],a.w=t[e],a},e.fromArray=function(t){return e.unpack(t,0,new e)},e.multiply=function(t,e,a){var n=t.x,r=t.y,o=t.z,i=t.w,s=e.x,c=e.y,u=e.z,d=e.w,l=i*s+n*d+r*u-o*c,h=i*c-n*u+r*d+o*s,f=i*u+n*c-r*s+o*d,p=i*d-n*s-r*c-o*u;return a.x=l,a.y=h,a.z=f,a.w=p,a},e.clone=function(t){var a=new e;return a.x=t.x,a.y=t.y,a.z=t.z,a.w=t.w,a},e.copyTo=function(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e},e.conjugate=function(t,e){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=t.w,e},e.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w},e.magnitude=function(t){return Math.sqrt(e.magnitudeSquared(t))},e.normalize=function(t,a){var n=1/e.magnitude(t),r=t.x*n,o=t.y*n,i=t.z*n,s=t.w*n;return a.x=r,a.y=o,a.z=i,a.w=s,a},e.inverse=function(t,a){var n=e.magnitudeSquared(t);return a=e.conjugate(t,a),e.multiplyByScalar(a,1/n,a)},e.add=function(t,e,a){return a.x=t.x+e.x,a.y=t.y+e.y,a.z=t.z+e.z,a.w=t.w+e.w,a},e.subtract=function(t,e,a){return a.x=t.x-e.x,a.y=t.y-e.y,a.z=t.z-e.z,a.w=t.w-e.w,a},e.negate=function(t,e){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=-t.w,e},e.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},e.multiplyByScalar=function(t,e,a){return a.x=t.x*e,a.y=t.y*e,a.z=t.z*e,a.w=t.w*e,a},e.computeAxis=function(t,e){var a=t.w;if(Math.abs(a-1)<g.EPSILON6)return e.x=e.y=e.z=0,e;var n=1/Math.sqrt(1-a*a);return e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e},e.computeAngle=function(t){return Math.abs(t.w-1)<g.EPSILON6?0:2*Math.acos(t.w)},e.lerp=function(t,a,n,r){return rt=e.multiplyByScalar(a,n,rt),r=e.multiplyByScalar(t,1-n,r),e.add(rt,r,r)},e.slerp=function(t,a,n,r){var o=e.dot(t,a),i=a;if(o<0&&(o=-o,i=ot=e.negate(a,ot)),1-o<g.EPSILON6)return e.lerp(t,i,n,r);var s=Math.acos(o);return it=e.multiplyByScalar(t,Math.sin((1-n)*s),it),st=e.multiplyByScalar(i,Math.sin(n*s),st),r=e.add(it,st,r),e.multiplyByScalar(r,1/Math.sin(s),r)},e.equals=function(t,e){return t===e||t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w},e.equalsEpsilon=function(t,e,a){return a=null!=a?a:0,t===e||Math.abs(t.x-e.x)<=a&&Math.abs(t.y-e.y)<=a&&Math.abs(t.z-e.z)<=a&&Math.abs(t.w-e.w)<=a},e.prototype.toMatrix4=function(t){var e=this.x,a=this.y,n=this.z,r=this.w,o=e+e,i=a+a,s=n+n,c=e*o,u=e*i,d=e*s,l=a*i,h=a*s,f=n*s,p=r*o,m=r*i,_=r*s;return t=ct.fromColumnMajorArray([1-(l+f),u+_,d-m,0,u-_,1-(c+f),h+p,0,d+m,h-p,1-(c+l),0,0,0,0,1],t)},e.prototype.clone=function(){return e.clone(this)},e.prototype.copyTo=function(t){return t=e.copyTo(this,t)},e.prototype.copyFrom=function(t){return e.copyTo(t,this),this},e.prototype.roll=function(){var t=this.x,e=this.y,a=this.z,n=this.w;return Math.atan2(2*(t*e+n*a),n*n+t*t-e*e-a*a)},e.prototype.pitch=function(){var t=this.x,e=this.y,a=this.z,n=this.w;return Math.atan2(2*(e*a+n*t),n*n-t*t-e*e+a*a)},e.prototype.yaw=function(){return Math.asin(2*(this.x*this.z-this.w*this.y))},e.prototype.inverse=function(){return e.inverse(this,this)},e.prototype.conjugate=function(){return e.conjugate(this,this)},e.prototype.length=function(){return e.magnitude(this)},e.prototype.normalize=function(){return e.normalize(this,this)},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},e.prototype.multiply=function(t){return e.multiply(this,t,this)},e.prototype.set=function(t,e,a,n){return this.x=t,this.y=e,this.z=a,this.w=n,this},e.prototype.setFromEuler=function(t){return e.setFromEuler(t,this)},e.prototype.toArray=function(){return[this._data[0],this._data[1],this._data[2],this._data[3]]},e.IDENTITY=Object.freeze(new e(0,0,0,1)),e.ZERO=Object.freeze(new e(0,0,0,0)),e}(),Q=new S,K=[1,2,0],$=new Array(3),tt=new J,et=new J,at=new J,nt=new J;new S,new S,new J,new J,new J;var rt=new J,ot=new J,it=new J,st=new J,ct=function(){function t(t,e,a,n,r,o,i,s,c,u,d,l,h,f,p,m){this._data=new Float32Array(16),this._data[0]=null!=t?t:0,this._data[1]=null!=r?r:0,this._data[2]=null!=c?c:0,this._data[3]=null!=h?h:0,this._data[4]=null!=e?e:0,this._data[5]=null!=o?o:0,this._data[6]=null!=u?u:0,this._data[7]=null!=f?f:0,this._data[8]=null!=a?a:0,this._data[9]=null!=i?i:0,this._data[10]=null!=d?d:0,this._data[11]=null!=p?p:0,this._data[12]=null!=n?n:0,this._data[13]=null!=s?s:0,this._data[14]=null!=l?l:0,this._data[15]=null!=m?m:0}return t.prototype.getData=function(){return this._data},t.prototype.setData=function(t){this._data=t},Object.defineProperty(t.prototype,"data",{get:function(){return this._data},enumerable:!1,configurable:!0}),t.prototype.lookAt=function(e,a,n){return t.computeLookAt(e,a,n,this)},t.prototype.perspective=function(e,a,n,r,o){return t.computePerspective(e,a,n,r,o,this)},t.prototype.orth2d=function(e,a,n,r,o,i){return t.computeOrthographic(e,a,n,r,o,i,this)},t.prototype.compose=function(e,a,n){return t.compose(e,a,n,this)},t.prototype.decompose=function(){return t.decompose(this)},t.prototype.multiplyByPoint3=function(e){return t.multiplyByPoint(this,e,e)},t.prototype.setZero=function(){for(var t=this._data,e=0;e<t.length;e++)t[e]=0},t.prototype.setIdentity=function(){for(var t=this._data,e=0;e<t.length;e++)t[e]=e%5?0:1},t.pack=function(t,e,a){if(a=null!=a?a:0,e.length<a+16)throw"数组长度不够";return e[a++]=t._data[0],e[a++]=t._data[1],e[a++]=t._data[2],e[a++]=t._data[3],e[a++]=t._data[4],e[a++]=t._data[5],e[a++]=t._data[6],e[a++]=t._data[7],e[a++]=t._data[8],e[a++]=t._data[9],e[a++]=t._data[10],e[a++]=t._data[11],e[a++]=t._data[12],e[a++]=t._data[13],e[a++]=t._data[14],e[a]=t._data[15],e},t.unpack=function(t,e,a){return e=null!=e?e:0,a._data[0]=t[e++],a._data[1]=t[e++],a._data[2]=t[e++],a._data[3]=t[e++],a._data[4]=t[e++],a._data[5]=t[e++],a._data[6]=t[e++],a._data[7]=t[e++],a._data[8]=t[e++],a._data[9]=t[e++],a._data[10]=t[e++],a._data[11]=t[e++],a._data[12]=t[e++],a._data[13]=t[e++],a._data[14]=t[e++],a._data[15]=t[e],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,16*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=16){var o=r/16;a[o]=t.unpack(e,r,a[o])}return a},t.clone=function(e){var a=new t;return a._data[0]=e.getData()[0],a._data[1]=e.getData()[1],a._data[2]=e.getData()[2],a._data[3]=e.getData()[3],a._data[4]=e.getData()[4],a._data[5]=e.getData()[5],a._data[6]=e.getData()[6],a._data[7]=e.getData()[7],a._data[8]=e.getData()[8],a._data[9]=e.getData()[9],a._data[10]=e.getData()[10],a._data[11]=e.getData()[11],a._data[12]=e.getData()[12],a._data[13]=e.getData()[13],a._data[14]=e.getData()[14],a._data[15]=e.getData()[15],a},t.copyTo=function(t,e){return e._data[0]=t.getData()[0],e._data[1]=t.getData()[1],e._data[2]=t.getData()[2],e._data[3]=t.getData()[3],e._data[4]=t.getData()[4],e._data[5]=t.getData()[5],e._data[6]=t.getData()[6],e._data[7]=t.getData()[7],e._data[8]=t.getData()[8],e._data[9]=t.getData()[9],e._data[10]=t.getData()[10],e._data[11]=t.getData()[11],e._data[12]=t.getData()[12],e._data[13]=t.getData()[13],e._data[14]=t.getData()[14],e._data[15]=t.getData()[15],e},t.fromArray=function(e){return t.unpack(e,0,new t)},t.fromColumnMajorArray=function(e,a){return t.unpack(e,0,a)},t.fromRowMajorArray=function(t,e){return e._data[0]=t[0],e._data[1]=t[4],e._data[2]=t[8],e._data[3]=t[12],e._data[4]=t[1],e._data[5]=t[5],e._data[6]=t[9],e._data[7]=t[13],e._data[8]=t[2],e._data[9]=t[6],e._data[10]=t[10],e._data[11]=t[14],e._data[12]=t[3],e._data[13]=t[7],e._data[14]=t[11],e._data[15]=t[15],e},t.fromRotationTranslation=function(t,e,a){return a._data[0]=t.getData()[0],a._data[1]=t.getData()[1],a._data[2]=t.getData()[2],a._data[3]=0,a._data[4]=t.getData()[3],a._data[5]=t.getData()[4],a._data[6]=t.getData()[5],a._data[7]=0,a._data[8]=t.getData()[6],a._data[9]=t.getData()[7],a._data[10]=t.getData()[8],a._data[11]=0,a._data[12]=e.x,a._data[13]=e.y,a._data[14]=e.z,a._data[15]=1,a},t.fromTranslationQuaternionRotationScale=function(t,e,a,n){var r=a.x,o=a.y,i=a.z,s=e.x*e.x,c=e.x*e.y,u=e.x*e.z,d=e.x*e.w,l=e.y*e.y,h=e.y*e.z,f=e.y*e.w,p=e.z*e.z,m=e.z*e.w,_=e.w*e.w,g=s-l-p+_,y=2*(c-m),v=2*(u+f),x=2*(c+m),b=-s+l-p+_,T=2*(h-d),M=2*(u-f),S=2*(h+d),C=-s-l+p+_;return n._data[0]=g*r,n._data[1]=x*r,n._data[2]=M*r,n._data[3]=0,n._data[4]=y*o,n._data[5]=b*o,n._data[6]=S*o,n._data[7]=0,n._data[8]=v*i,n._data[9]=T*i,n._data[10]=C*i,n._data[11]=0,n._data[12]=t.x,n._data[13]=t.y,n._data[14]=t.z,n._data[15]=1,n},t.fromTranslationRotationScale=function(e,a){return t.fromTranslationQuaternionRotationScale(e.translation,e.rotation,e.scale,a)},t.fromTranslation=function(e,a){return t.fromRotationTranslation(V.IDENTITY,e,a)},t.fromScale=function(t,e){return e._data[0]=t.x,e._data[1]=0,e._data[2]=0,e._data[3]=0,e._data[4]=0,e._data[5]=t.y,e._data[6]=0,e._data[7]=0,e._data[8]=0,e._data[9]=0,e._data[10]=t.z,e._data[11]=0,e._data[12]=0,e._data[13]=0,e._data[14]=0,e._data[15]=1,e},t.fromUniformScale=function(t,e){return e._data[0]=t,e._data[1]=0,e._data[2]=0,e._data[3]=0,e._data[4]=0,e._data[5]=t,e._data[6]=0,e._data[7]=0,e._data[8]=0,e._data[9]=0,e._data[10]=t,e._data[11]=0,e._data[12]=0,e._data[13]=0,e._data[14]=0,e._data[15]=1,e},t.fromRotation=function(t,e){return e._data[0]=t.getData()[0],e._data[1]=t.getData()[1],e._data[2]=t.getData()[2],e._data[3]=0,e._data[4]=t.getData()[3],e._data[5]=t.getData()[4],e._data[6]=t.getData()[5],e._data[7]=0,e._data[8]=t.getData()[6],e._data[9]=t.getData()[7],e._data[10]=t.getData()[8],e._data[11]=0,e._data[12]=0,e._data[13]=0,e._data[14]=0,e._data[15]=1,e},t.fromCamera=function(t,e){var a=t.position,n=t.direction,r=t.up;S.normalize(n,ut),S.normalize(S.cross(ut,r,dt),dt),S.normalize(S.cross(dt,ut,lt),lt);var o=dt.x,i=dt.y,s=dt.z,c=ut.x,u=ut.y,d=ut.z,l=lt.x,h=lt.y,f=lt.z,p=a.x,m=a.y,_=a.z,g=o*-p+i*-m+s*-_,y=l*-p+h*-m+f*-_,v=c*p+u*m+d*_;return e._data[0]=o,e._data[1]=l,e._data[2]=-c,e._data[3]=0,e._data[4]=i,e._data[5]=h,e._data[6]=-u,e._data[7]=0,e._data[8]=s,e._data[9]=f,e._data[10]=-d,e._data[11]=0,e._data[12]=g,e._data[13]=y,e._data[14]=v,e._data[15]=1,e},t.computePerspectiveFieldOfView=function(t,e,a,n,r,o){var i=1/Math.tan(.5*t),s=r?i:i/e,c=r?i*e:i,u=(n+a)/(a-n),d=2*n*a/(a-n);return o._data[0]=s,o._data[1]=0,o._data[2]=0,o._data[3]=0,o._data[4]=0,o._data[5]=c,o._data[6]=0,o._data[7]=0,o._data[8]=0,o._data[9]=0,o._data[10]=u,o._data[11]=-1,o._data[12]=0,o._data[13]=0,o._data[14]=d,o._data[15]=0,o},t.computeOrthographicOffCenter=function(t,e,a,n,r,o,i){var s=1/(e-t),c=1/(n-a),u=1/(o-r),d=-(e+t)*s,l=-(n+a)*c,h=-(o+r)*u;return s*=2,c*=2,u*=-2,i._data[0]=s,i._data[1]=0,i._data[2]=0,i._data[3]=0,i._data[4]=0,i._data[5]=c,i._data[6]=0,i._data[7]=0,i._data[8]=0,i._data[9]=0,i._data[10]=u,i._data[11]=0,i._data[12]=d,i._data[13]=l,i._data[14]=h,i._data[15]=1,i},t.computePerspectiveOffCenter=function(t,e,a,n,r,o,i){var s=2*r/(e-t),c=2*r/(n-a),u=(e+t)/(e-t),d=(n+a)/(n-a),l=-(o+r)/(o-r),h=-2*o*r/(o-r);return i._data[0]=s,i._data[1]=0,i._data[2]=0,i._data[3]=0,i._data[4]=0,i._data[5]=c,i._data[6]=0,i._data[7]=0,i._data[8]=u,i._data[9]=d,i._data[10]=l,i._data[11]=-1,i._data[12]=0,i._data[13]=0,i._data[14]=h,i._data[15]=0,i},t.computeInfinitePerspectiveOffCenter=function(t,e,a,n,r,o){var i=2*r/(e-t),s=2*r/(n-a),c=(e+t)/(e-t),u=(n+a)/(n-a),d=-2*r;return o._data[0]=i,o._data[1]=0,o._data[2]=0,o._data[3]=0,o._data[4]=0,o._data[5]=s,o._data[6]=0,o._data[7]=0,o._data[8]=c,o._data[9]=u,o._data[10]=-1,o._data[11]=-1,o._data[12]=0,o._data[13]=0,o._data[14]=d,o._data[15]=0,o},t.computeViewportTransformation=function(t,e,a,n){var r,o,i,s,c=null!==(r=t.x)&&void 0!==r?r:0,u=null!==(o=t.y)&&void 0!==o?o:0;e=null!=e?e:0;var d=.5*(null!==(i=t.width)&&void 0!==i?i:0),l=.5*(null!==(s=t.height)&&void 0!==s?s:0),h=.5*((a=null!=a?a:1)-e),f=d,p=l,m=h,_=c+d,g=u+l,y=e+h;return n._data[0]=f,n._data[1]=0,n._data[2]=0,n._data[3]=0,n._data[4]=0,n._data[5]=p,n._data[6]=0,n._data[7]=0,n._data[8]=0,n._data[9]=0,n._data[10]=m,n._data[11]=0,n._data[12]=_,n._data[13]=g,n._data[14]=y,n._data[15]=1,n},t.computeView=function(t,e,a,n,r){return r._data[0]=n.x,r._data[1]=a.x,r._data[2]=-e.x,r._data[3]=0,r._data[4]=n.y,r._data[5]=a.y,r._data[6]=-e.y,r._data[7]=0,r._data[8]=n.z,r._data[9]=a.z,r._data[10]=-e.z,r._data[11]=0,r._data[12]=-S.dot(n,t),r._data[13]=-S.dot(a,t),r._data[14]=S.dot(e,t),r._data[15]=1,r},t.toArray=function(t,e){return e[0]=t._data[0],e[1]=t._data[1],e[2]=t._data[2],e[3]=t._data[3],e[4]=t._data[4],e[5]=t._data[5],e[6]=t._data[6],e[7]=t._data[7],e[8]=t._data[8],e[9]=t._data[9],e[10]=t._data[10],e[11]=t._data[11],e[12]=t._data[12],e[13]=t._data[13],e[14]=t._data[14],e[15]=t._data[15],e},t.getElement=function(t,e,a){return t._data[4*e+a]},t.getColumn=function(t,e,a){var n=4*e,r=t._data[n],o=t._data[n+1],i=t._data[n+2],s=t._data[n+3];return a.x=r,a.y=o,a.z=i,a.w=s,a},t.setColumn=function(e,a,n,r){var o=4*a;return(r=t.copyTo(e,r))._data[o]=n.x,r._data[o+1]=n.y,r._data[o+2]=n.z,r._data[o+3]=n.w,r},t.getRow=function(t,e,a){var n=t._data[e],r=t._data[e+4],o=t._data[e+8],i=t._data[e+12];return a.x=n,a.y=r,a.z=o,a.w=i,a},t.setRow=function(e,a,n,r){return(r=t.copyTo(e,r))._data[a]=n.x,r._data[a+4]=n.y,r._data[a+8]=n.z,r._data[a+12]=n.w,r},t.setTranslation=function(t,e,a){return a._data[0]=t._data[0],a._data[1]=t._data[1],a._data[2]=t._data[2],a._data[3]=t._data[3],a._data[4]=t._data[4],a._data[5]=t._data[5],a._data[6]=t._data[6],a._data[7]=t._data[7],a._data[8]=t._data[8],a._data[9]=t._data[9],a._data[10]=t._data[10],a._data[11]=t._data[11],a._data[12]=e.x,a._data[13]=e.y,a._data[14]=e.z,a._data[15]=t._data[15],a},t.scale=function(e,a,n){var r=t.getScale(e,ht),o=a.x/r.x,i=a.y/r.y,s=a.z/r.y;return n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*o,n._data[3]=e._data[3],n._data[4]=e._data[4]*i,n._data[5]=e._data[5]*i,n._data[6]=e._data[6]*i,n._data[7]=e._data[7],n._data[8]=e._data[8]*s,n._data[9]=e._data[9]*s,n._data[10]=e._data[10]*s,n._data[11]=e._data[11],n._data[12]=e._data[12],n._data[13]=e._data[13],n._data[14]=e._data[14],n._data[15]=e._data[15],n},t.setUniformScale=function(e,a,n){var r=t.getScale(e,ft),o=a/r.x,i=a/r.y,s=a/r.z;return n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*o,n._data[3]=e._data[3],n._data[4]=e._data[4]*i,n._data[5]=e._data[5]*i,n._data[6]=e._data[6]*i,n._data[7]=e._data[7],n._data[8]=e._data[8]*s,n._data[9]=e._data[9]*s,n._data[10]=e._data[10]*s,n._data[11]=e._data[11],n._data[12]=e._data[12],n._data[13]=e._data[13],n._data[14]=e._data[14],n._data[15]=e._data[15],n},t.getScale=function(t,e){return e.x=Math.hypot(t._data[0],t._data[1],t._data[2]),e.y=Math.hypot(t._data[4],t._data[5],t._data[6]),e.z=Math.hypot(t._data[8],t._data[9],t._data[10]),e},t.getMaximumScale=function(e){return t.getScale(e,bt),S.maximumComponent(bt)},t.setRotation=function(e,a,n){var r=t.getScale(e,Tt);return n._data[0]=a._data[0]*r.x,n._data[1]=a._data[1]*r.x,n._data[2]=a._data[2]*r.x,n._data[3]=e._data[3],n._data[4]=a._data[3]*r.y,n._data[5]=a._data[4]*r.y,n._data[6]=a._data[5]*r.y,n._data[7]=e._data[7],n._data[8]=a._data[6]*r.z,n._data[9]=a._data[7]*r.z,n._data[10]=a._data[8]*r.z,n._data[11]=e._data[11],n._data[12]=e._data[12],n._data[13]=e._data[13],n._data[14]=e._data[14],n._data[15]=e._data[15],n},t.getRotation=function(e,a){var n=t.getScale(e,Mt);return a._data[0]=e._data[0]/n.x,a._data[1]=e._data[1]/n.x,a._data[2]=e._data[2]/n.x,a._data[3]=e._data[4]/n.y,a._data[4]=e._data[5]/n.y,a._data[5]=e._data[6]/n.y,a._data[6]=e._data[8]/n.z,a._data[7]=e._data[9]/n.z,a._data[8]=e._data[10]/n.z,a},t.getRotationMatrix3=function(e,a){var n=t.getScale(e,Mt);return a.getData()[0]=e._data[0]/n.x,a.getData()[1]=e._data[1]/n.x,a.getData()[2]=e._data[2]/n.x,a.getData()[3]=e._data[4]/n.y,a.getData()[4]=e._data[5]/n.y,a.getData()[5]=e._data[6]/n.y,a.getData()[6]=e._data[8]/n.z,a.getData()[7]=e._data[9]/n.z,a.getData()[8]=e._data[10]/n.z,a},t.getRotationQuaternion=function(e,a){return t.getRotationMatrix3(e,Et),a=J.fromRotationMatrix(Et,a)},t.multiply=function(t,e,a){var n=t._data,r=e._data,o=n[0],i=n[1],s=n[2],c=n[3],u=n[4],d=n[5],l=n[6],h=n[7],f=n[8],p=n[9],m=n[10],_=n[11],g=n[12],y=n[13],v=n[14],x=n[15],b=r[0],T=r[1],M=r[2],S=r[3],C=r[4],w=r[5],A=r[6],I=r[7],E=r[8],P=r[9],O=r[10],N=r[11],L=r[12],F=r[13],R=r[14],z=r[15],B=o*b+u*T+f*M+g*S,D=i*b+d*T+p*M+y*S,U=s*b+l*T+m*M+v*S,k=c*b+h*T+_*M+x*S,V=o*C+u*w+f*A+g*I,j=i*C+d*w+p*A+y*I,G=s*C+l*w+m*A+v*I,H=c*C+h*w+_*A+x*I,W=o*E+u*P+f*O+g*N,q=i*E+d*P+p*O+y*N,X=s*E+l*P+m*O+v*N,Y=c*E+h*P+_*O+x*N,Z=o*L+u*F+f*R+g*z,J=i*L+d*F+p*R+y*z,Q=s*L+l*F+m*R+v*z,K=c*L+h*F+_*R+x*z;return a._data[0]=B,a._data[1]=D,a._data[2]=U,a._data[3]=k,a._data[4]=V,a._data[5]=j,a._data[6]=G,a._data[7]=H,a._data[8]=W,a._data[9]=q,a._data[10]=X,a._data[11]=Y,a._data[12]=Z,a._data[13]=J,a._data[14]=Q,a._data[15]=K,a},t.mulScalerAddMatrix=function(t,e,a,n){for(var r=t._data,o=e._data,i=n._data,s=0;s<16;s++)i[s]=r[s]+o[s]*a;return n},t.add=function(t,e,a){return a._data[0]=t._data[0]+e._data[0],a._data[1]=t._data[1]+e._data[1],a._data[2]=t._data[2]+e._data[2],a._data[3]=t._data[3]+e._data[3],a._data[4]=t._data[4]+e._data[4],a._data[5]=t._data[5]+e._data[5],a._data[6]=t._data[6]+e._data[6],a._data[7]=t._data[7]+e._data[7],a._data[8]=t._data[8]+e._data[8],a._data[9]=t._data[9]+e._data[9],a._data[10]=t._data[10]+e._data[10],a._data[11]=t._data[11]+e._data[11],a._data[12]=t._data[12]+e._data[12],a._data[13]=t._data[13]+e._data[13],a._data[14]=t._data[14]+e._data[14],a._data[15]=t._data[15]+e._data[15],a},t.subtract=function(t,e,a){return a._data[0]=t._data[0]-e._data[0],a._data[1]=t._data[1]-e._data[1],a._data[2]=t._data[2]-e._data[2],a._data[3]=t._data[3]-e._data[3],a._data[4]=t._data[4]-e._data[4],a._data[5]=t._data[5]-e._data[5],a._data[6]=t._data[6]-e._data[6],a._data[7]=t._data[7]-e._data[7],a._data[8]=t._data[8]-e._data[8],a._data[9]=t._data[9]-e._data[9],a._data[10]=t._data[10]-e._data[10],a._data[11]=t._data[11]-e._data[11],a._data[12]=t._data[12]-e._data[12],a._data[13]=t._data[13]-e._data[13],a._data[14]=t._data[14]-e._data[14],a._data[15]=t._data[15]-e._data[15],a},t.multiplyTransformation=function(t,e,a){var n=t._data,r=t._data,o=n[0],i=n[1],s=n[2],c=n[4],u=n[5],d=n[6],l=n[8],h=n[9],f=n[10],p=n[12],m=n[13],_=n[14],g=r[0],y=r[1],v=r[2],x=r[4],b=r[5],T=r[6],M=r[8],S=r[9],C=r[10],w=r[12],A=r[13],I=r[14],E=o*g+c*y+l*v,P=i*g+u*y+h*v,O=s*g+d*y+f*v,N=o*x+c*b+l*T,L=i*x+u*b+h*T,F=s*x+d*b+f*T,R=o*M+c*S+l*C,z=i*M+u*S+h*C,B=s*M+d*S+f*C,D=o*w+c*A+l*I+p,U=i*w+u*A+h*I+m,k=s*w+d*A+f*I+_;return a._data[0]=E,a._data[1]=P,a._data[2]=O,a._data[3]=0,a._data[4]=N,a._data[5]=L,a._data[6]=F,a._data[7]=0,a._data[8]=R,a._data[9]=z,a._data[10]=B,a._data[11]=0,a._data[12]=D,a._data[13]=U,a._data[14]=k,a._data[15]=1,a},t.multiplyByMatrix3=function(t,e,a){var n=t._data[0],r=t._data[1],o=t._data[2],i=t._data[4],s=t._data[5],c=t._data[6],u=t._data[8],d=t._data[9],l=t._data[10],h=e.getData()[0],f=e.getData()[1],p=e.getData()[2],m=e.getData()[3],_=e.getData()[4],g=e.getData()[5],y=e.getData()[6],v=e.getData()[7],x=e.getData()[8],b=n*h+i*f+u*p,T=r*h+s*f+d*p,M=o*h+c*f+l*p,S=n*m+i*_+u*g,C=r*m+s*_+d*g,w=o*m+c*_+l*g,A=n*y+i*v+u*x,I=r*y+s*v+d*x,E=o*y+c*v+l*x;return a._data[0]=b,a._data[1]=T,a._data[2]=M,a._data[3]=0,a._data[4]=S,a._data[5]=C,a._data[6]=w,a._data[7]=0,a._data[8]=A,a._data[9]=I,a._data[10]=E,a._data[11]=0,a._data[12]=t._data[12],a._data[13]=t._data[13],a._data[14]=t._data[14],a._data[15]=t._data[15],a},t.multiplyByTranslation=function(t,e,a){var n=e.x,r=e.y,o=e.z,i=n*t._data[0]+r*t._data[4]+o*t._data[8]+t._data[12],s=n*t._data[1]+r*t._data[5]+o*t._data[9]+t._data[13],c=n*t._data[2]+r*t._data[6]+o*t._data[10]+t._data[14];return a._data[0]=t._data[0],a._data[1]=t._data[1],a._data[2]=t._data[2],a._data[3]=t._data[3],a._data[4]=t._data[4],a._data[5]=t._data[5],a._data[6]=t._data[6],a._data[7]=t._data[7],a._data[8]=t._data[8],a._data[9]=t._data[9],a._data[10]=t._data[10],a._data[11]=t._data[11],a._data[12]=i,a._data[13]=s,a._data[14]=c,a._data[15]=t._data[15],a},t.multiplyByScale=function(e,a,n){var r=a.x,o=a.y,i=a.z;return 1===r&&1===o&&1===i?t.copyTo(e,n):(void 0===n&&(n=new t),n._data[0]=r*e._data[0],n._data[1]=r*e._data[1],n._data[2]=r*e._data[2],n._data[3]=e._data[3],n._data[4]=o*e._data[4],n._data[5]=o*e._data[5],n._data[6]=o*e._data[6],n._data[7]=e._data[7],n._data[8]=i*e._data[8],n._data[9]=i*e._data[9],n._data[10]=i*e._data[10],n._data[11]=e._data[11],n._data[12]=e._data[12],n._data[13]=e._data[13],n._data[14]=e._data[14],n._data[15]=e._data[15],n)},t.multiplyByUniformScale=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3],a._data[4]=t._data[4]*e,a._data[5]=t._data[5]*e,a._data[6]=t._data[6]*e,a._data[7]=t._data[7],a._data[8]=t._data[8]*e,a._data[9]=t._data[9]*e,a._data[10]=t._data[10]*e,a._data[11]=t._data[11],a._data[12]=t._data[12],a._data[13]=t._data[13],a._data[14]=t._data[14],a._data[15]=t._data[15],a},t.multiplyByVector=function(t,e,a){var n=e.x,r=e.y,o=e.z,i=e.w,s=t._data[0]*n+t._data[4]*r+t._data[8]*o+t._data[12]*i,c=t._data[1]*n+t._data[5]*r+t._data[9]*o+t._data[13]*i,u=t._data[2]*n+t._data[6]*r+t._data[10]*o+t._data[14]*i,d=t._data[3]*n+t._data[7]*r+t._data[11]*o+t._data[15]*i;return a.x=s,a.y=c,a.z=u,a.w=d,a},t.multiplyByPointAsVector=function(t,e,a){var n=e.x,r=e.y,o=e.z,i=t._data[0]*n+t._data[4]*r+t._data[8]*o,s=t._data[1]*n+t._data[5]*r+t._data[9]*o,c=t._data[2]*n+t._data[6]*r+t._data[10]*o;return a.x=i,a.y=s,a.z=c,a},t.multiplyByPoint=function(t,e,a){var n=e.x,r=e.y,o=e.z,i=t._data[0]*n+t._data[4]*r+t._data[8]*o+t._data[12],s=t._data[1]*n+t._data[5]*r+t._data[9]*o+t._data[13],c=t._data[2]*n+t._data[6]*r+t._data[10]*o+t._data[14];return a.x=i,a.y=s,a.z=c,a},t.multiplyByScalar=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3]*e,a._data[4]=t._data[4]*e,a._data[5]=t._data[5]*e,a._data[6]=t._data[6]*e,a._data[7]=t._data[7]*e,a._data[8]=t._data[8]*e,a._data[9]=t._data[9]*e,a._data[10]=t._data[10]*e,a._data[11]=t._data[11]*e,a._data[12]=t._data[12]*e,a._data[13]=t._data[13]*e,a._data[14]=t._data[14]*e,a._data[15]=t._data[15]*e,a},t.negate=function(t,e){return e._data[0]=-t._data[0],e._data[1]=-t._data[1],e._data[2]=-t._data[2],e._data[3]=-t._data[3],e._data[4]=-t._data[4],e._data[5]=-t._data[5],e._data[6]=-t._data[6],e._data[7]=-t._data[7],e._data[8]=-t._data[8],e._data[9]=-t._data[9],e._data[10]=-t._data[10],e._data[11]=-t._data[11],e._data[12]=-t._data[12],e._data[13]=-t._data[13],e._data[14]=-t._data[14],e._data[15]=-t._data[15],e},t.transpose=function(t,e){var a=t._data[1],n=t._data[2],r=t._data[3],o=t._data[6],i=t._data[7],s=t._data[11];return e._data[0]=t._data[0],e._data[1]=t._data[4],e._data[2]=t._data[8],e._data[3]=t._data[12],e._data[4]=a,e._data[5]=t._data[5],e._data[6]=t._data[9],e._data[7]=t._data[13],e._data[8]=n,e._data[9]=o,e._data[10]=t._data[10],e._data[11]=t._data[14],e._data[12]=r,e._data[13]=i,e._data[14]=s,e._data[15]=t._data[15],e},t.abs=function(t,e){return e._data[0]=Math.abs(t._data[0]),e._data[1]=Math.abs(t._data[1]),e._data[2]=Math.abs(t._data[2]),e._data[3]=Math.abs(t._data[3]),e._data[4]=Math.abs(t._data[4]),e._data[5]=Math.abs(t._data[5]),e._data[6]=Math.abs(t._data[6]),e._data[7]=Math.abs(t._data[7]),e._data[8]=Math.abs(t._data[8]),e._data[9]=Math.abs(t._data[9]),e._data[10]=Math.abs(t._data[10]),e._data[11]=Math.abs(t._data[11]),e._data[12]=Math.abs(t._data[12]),e._data[13]=Math.abs(t._data[13]),e._data[14]=Math.abs(t._data[14]),e._data[15]=Math.abs(t._data[15]),e},t.equals=function(t,e){return t===e||t._data[12]===e._data[12]&&t._data[13]===e._data[13]&&t._data[14]===e._data[14]&&t._data[0]===e._data[0]&&t._data[1]===e._data[1]&&t._data[2]===e._data[2]&&t._data[4]===e._data[4]&&t._data[5]===e._data[5]&&t._data[6]===e._data[6]&&t._data[8]===e._data[8]&&t._data[9]===e._data[9]&&t._data[10]===e._data[10]&&t._data[3]===e._data[3]&&t._data[7]===e._data[7]&&t._data[11]===e._data[11]&&t._data[15]===e._data[15]},t.equalsEpsilon=function(t,e,a){return t===e||Math.abs(t._data[0]-e._data[0])<=a&&Math.abs(t._data[1]-e._data[1])<=a&&Math.abs(t._data[2]-e._data[2])<=a&&Math.abs(t._data[3]-e._data[3])<=a&&Math.abs(t._data[4]-e._data[4])<=a&&Math.abs(t._data[5]-e._data[5])<=a&&Math.abs(t._data[6]-e._data[6])<=a&&Math.abs(t._data[7]-e._data[7])<=a&&Math.abs(t._data[8]-e._data[8])<=a&&Math.abs(t._data[9]-e._data[9])<=a&&Math.abs(t._data[10]-e._data[10])<=a&&Math.abs(t._data[11]-e._data[11])<=a&&Math.abs(t._data[12]-e._data[12])<=a&&Math.abs(t._data[13]-e._data[13])<=a&&Math.abs(t._data[14]-e._data[14])<=a&&Math.abs(t._data[15]-e._data[15])<=a},t.getTranslation=function(t,e){return e.x=t._data[12],e.y=t._data[13],e.z=t._data[14],e},t.getMatrix3=function(t,e){return e.getData()[0]=t._data[0],e.getData()[1]=t._data[1],e.getData()[2]=t._data[2],e.getData()[3]=t._data[4],e.getData()[4]=t._data[5],e.getData()[5]=t._data[6],e.getData()[6]=t._data[8],e.getData()[7]=t._data[9],e.getData()[8]=t._data[10],e},t.inverse=function(e,a){var n=e._data[0],r=e._data[4],o=e._data[8],i=e._data[12],s=e._data[1],c=e._data[5],u=e._data[9],d=e._data[13],l=e._data[2],h=e._data[6],f=e._data[10],p=e._data[14],m=e._data[3],_=e._data[7],y=e._data[11],v=e._data[15],x=f*v,b=p*y,T=h*v,M=p*_,S=h*y,C=f*_,w=l*v,A=p*m,I=l*y,E=f*m,O=l*_,N=h*m,L=x*c+M*u+S*d-(b*c+T*u+C*d),F=b*s+w*u+E*d-(x*s+A*u+I*d),R=T*s+A*c+O*d-(M*s+w*c+N*d),z=C*s+I*c+N*u-(S*s+E*c+O*u),B=b*r+T*o+C*i-(x*r+M*o+S*i),D=x*n+A*o+I*i-(b*n+w*o+E*i),U=M*n+w*r+N*i-(T*n+A*r+O*i),k=S*n+E*r+O*o-(C*n+I*r+N*o),j=(x=o*d)*_+(M=i*c)*y+(S=r*u)*v-((b=i*u)*_+(T=r*d)*y+(C=o*c)*v),G=b*m+(w=n*d)*y+(E=o*s)*v-(x*m+(A=i*s)*y+(I=n*u)*v),H=T*m+A*_+(O=n*c)*v-(M*m+w*_+(N=r*s)*v),W=C*m+I*_+N*y-(S*m+E*_+O*y),q=T*f+C*p+b*h-(S*p+x*h+M*f),X=I*p+x*l+A*f-(w*f+E*p+b*l),Y=w*h+N*p+M*l-(O*p+T*l+A*h),Z=O*f+S*l+E*h-(I*h+N*f+C*l),J=n*L+r*F+o*R+i*z;if(Math.abs(J)<g.EPSILON21){if(V.equalsEpsilon(t.getMatrix3(e,St),Ct,g.EPSILON7)&&P.equals(t.getRow(e,3,wt),At))return a._data[0]=0,a._data[1]=0,a._data[2]=0,a._data[3]=0,a._data[4]=0,a._data[5]=0,a._data[6]=0,a._data[7]=0,a._data[8]=0,a._data[9]=0,a._data[10]=0,a._data[11]=0,a._data[12]=-e._data[12],a._data[13]=-e._data[13],a._data[14]=-e._data[14],a._data[15]=1,a;throw"matrix is not invertible because its determinate is zero"}return J=1/J,a._data[0]=L*J,a._data[1]=F*J,a._data[2]=R*J,a._data[3]=z*J,a._data[4]=B*J,a._data[5]=D*J,a._data[6]=U*J,a._data[7]=k*J,a._data[8]=j*J,a._data[9]=G*J,a._data[10]=H*J,a._data[11]=W*J,a._data[12]=q*J,a._data[13]=X*J,a._data[14]=Y*J,a._data[15]=Z*J,a},t.inverseTransformation=function(t,e){var a=t._data[0],n=t._data[1],r=t._data[2],o=t._data[4],i=t._data[5],s=t._data[6],c=t._data[8],u=t._data[9],d=t._data[10],l=t._data[12],h=t._data[13],f=t._data[14],p=-a*l-n*h-r*f,m=-o*l-i*h-s*f,_=-c*l-u*h-d*f;return e._data[0]=a,e._data[1]=o,e._data[2]=c,e._data[3]=0,e._data[4]=n,e._data[5]=i,e._data[6]=u,e._data[7]=0,e._data[8]=r,e._data[9]=s,e._data[10]=d,e._data[11]=0,e._data[12]=p,e._data[13]=m,e._data[14]=_,e._data[15]=1,e},t.inverseTranspose=function(e,a){return t.inverse(t.transpose(e,It),a)},t.equalsArray=function(t,e,a){return a=null!=a?a:0,t._data[0]===e[a]&&t._data[1]===e[a+1]&&t._data[2]===e[a+2]&&t._data[3]===e[a+3]&&t._data[4]===e[a+4]&&t._data[5]===e[a+5]&&t._data[6]===e[a+6]&&t._data[7]===e[a+7]&&t._data[8]===e[a+8]&&t._data[9]===e[a+9]&&t._data[10]===e[a+10]&&t._data[11]===e[a+11]&&t._data[12]===e[a+12]&&t._data[13]===e[a+13]&&t._data[14]===e[a+14]&&t._data[15]===e[a+15]},t.prototype.determinant=function(){var t=this._data,e=t[0],a=t[4],n=t[8],r=t[12],o=t[1],i=t[5],s=t[9],c=t[13],u=t[2],d=t[6],l=t[10],h=t[14];return t[3]*(+r*s*d-n*c*d-r*i*l+a*c*l+n*i*h-a*s*h)+t[7]*(+e*s*h-e*c*l+r*o*l-n*o*h+n*c*u-r*s*u)+t[11]*(+e*c*d-e*i*h-r*o*d+a*o*h+r*i*u-a*c*u)+t[15]*(-n*i*u-e*s*d+e*i*l+n*o*d-a*o*l+a*s*u)},t.decompose=function(e){var a=t.getTranslation(e,new S),n=t.getScale(e,new S);e.determinant()<0&&(n.x=-n.x),t.copyTo(e,Pt);var r=1/n.x,o=1/n.y,i=1/n.z;return Pt._data[0]*=r,Pt._data[1]*=r,Pt._data[2]*=r,Pt._data[4]*=o,Pt._data[5]*=o,Pt._data[6]*=o,Pt._data[8]*=i,Pt._data[9]*=i,Pt._data[10]*=i,{translation:a,rotation:t.getRotationQuaternion(Pt,new J),scale:n}},t.compose=function(e,a,n,r){return r=t.fromTranslationQuaternionRotationScale(e,a,n,r)},t.computePerspective=function(e,a,n,r,o,i){return i=t.computePerspectiveFieldOfView(e,a,n,r,o,i)},t.computeOrthographic=function(e,a,n,r,o,i,s){return s=t.computeOrthographicOffCenter(e,a,n,r,o,i,s)},t.computeLookAt=function(e,a,n,r){var o=S.subtract(a,e,new S);return r=t.fromCamera({position:e,direction:o,up:n},r)},t.prototype.clone=function(){return t.clone(this)},t.prototype.copyTo=function(e){return e=t.copyTo(this,e)},t.prototype.copyFrom=function(e){return t.copyTo(e,this),this},t.prototype.translate=function(e){return t.multiplyByTranslation(this,e,this)},t.prototype.scale=function(e){return t.scale(this,e,this)},t.prototype.multiply=function(e){return t.multiply(this,e,this)},t.prototype.toArray=function(){var e=new Array(16);return t.toArray(this,e)},t.prototype.toFloat32Array=function(){return t.pack(this,new Float32Array(16),0)},t.prototype.multiplyByVector4=function(e){return t.multiplyByVector(this,e,new P)},t.prototype.multiplyByVector3=function(e){return t.multiplyByPoint(this,e,new S)},t.prototype.at=function(t){return this._data[t]},t.prototype.rotate=function(t,e){var a=e.x,n=e.y,r=e.z,o=Math.sqrt(a*a+n*n+r*r);if(o){1!==o&&(a*=o=1/o,n*=o,r*=o);var i=Math.sin(t),s=Math.cos(t),c=1-s,u=this._data[0],d=this._data[1],l=this._data[2],h=this._data[3],f=this._data[4],p=this._data[5],m=this._data[6],_=this._data[7],g=this._data[8],y=this._data[9],v=this._data[10],x=this._data[11],b=a*a*c+s,T=n*a*c+r*i,M=r*a*c-n*i,S=a*n*c-r*i,C=n*n*c+s,w=r*n*c+a*i,A=a*r*c+n*i,I=n*r*c-a*i,E=r*r*c+s;return this._data[0]=u*b+f*T+g*M,this._data[1]=d*b+p*T+y*M,this._data[2]=l*b+m*T+v*M,this._data[3]=h*b+_*T+x*M,this._data[4]=u*S+f*C+g*w,this._data[5]=d*S+p*C+y*w,this._data[6]=l*S+m*C+v*w,this._data[7]=h*S+_*C+x*w,this._data[8]=u*A+f*I+g*E,this._data[9]=d*A+p*I+y*E,this._data[10]=l*A+m*I+v*E,this._data[11]=h*A+_*I+x*E,this}},t.prototype.inverse=function(){return t.inverse(this,this)},t.prototype.transpose=function(){return t.transpose(this,this)},t.IDENTITY=Object.freeze(new t(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)),t.ZERO=Object.freeze(new t(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)),t}(),ut=new S,dt=new S,lt=new S,ht=new S,ft=new S;new S;var pt,mt,_t,gt,yt,vt,xt,bt=new S,Tt=new S,Mt=new S,St=new V,Ct=new V,wt=new P,At=new P(0,0,0,1),It=new ct,Et=new V,Pt=new ct,Ot=function(){function t(t,e){void 0===t&&(t=new S(1/0,1/0,1/0)),void 0===e&&(e=new S(-1/0,-1/0,-1/0)),this.min=t,this.max=e}return t.prototype.set=function(t,e){return this.min.copyFrom(t),this.max.copyFrom(e),this},t.prototype.setFromArray=function(t){for(var e=Number(1/0),a=Number(1/0),n=Number(1/0),r=-1/0,o=-1/0,i=-1/0,s=0,c=t.length;s<c;s+=3){var u=t[s],d=t[s+1],l=t[s+2];u<e&&(e=u),d<a&&(a=d),l<n&&(n=l),u>r&&(r=u),d>o&&(o=d),l>i&&(i=l)}return this.min.set(e,a,n),this.max.set(r,o,i),this},t.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,a=t.length;e<a;e++)this.expandByPoint(t[e]);return this},t.prototype.setFromCenterAndSize=function(t,e){var a=e.clone().multiplyScalar(.5);return this.min.copyFrom(t).subVector(a),this.max.copyFrom(t).subVector(a),this},t.prototype.clone=function(){return(new t).copyFrom(this)},t.prototype.copyFrom=function(t){return this.min.copyFrom(t.min),this.max.copyFrom(t.max),this},t.prototype.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=Number(1/0),this.max.x=this.max.y=this.max.z=-1/0,this},t.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},t.prototype.getCenter=function(t){return this.isEmpty()?t.set(0,0,0):S.add(this.min,this.max,t).multiplyScalar(.5),t},t.prototype.getSize=function(t){return this.isEmpty()?t.set(0,0,0):S.subtract(this.max,this.min,t),t},t.prototype.expandByPoint=function(t){return S.min(this.min,t,this.min),S.max(this.max,t,this.max),this},t.prototype.expandByVector=function(t){return this.min.subVector(t),this.max.addVector(t),this},t.prototype.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},t.prototype.expandByBox=function(t){return S.min(this.min,t.min,this.min),S.max(this.max,t.max,this.max),this},t.prototype.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},t.prototype.containsBox=function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},t.prototype.intersectsBox=function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},t.prototype.intersectsSphere=function(t){var e=new S;return this.clampPoint(t.center,e),e.distanceSquaredTo(t.center)<=t.radius*t.radius},t.prototype.clampPoint=function(t,e){return e.copyFrom(t).clamp(this.min,this.max)},t.prototype.distanceToPoint=function(t){return t.clone().clamp(this.min,this.max).subVector(t).length()},t.prototype.getBoundingSphere=function(t){this.getCenter(t.center);var e=new S;return t.radius=.5*this.getSize(e).length(),t},t.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},t.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},t.prototype.transform=function(t){if(this.isEmpty())return this;var e=[];return e[0]=new S(this.min.x,this.min.y,this.min.z),e[1]=new S(this.min.x,this.min.y,this.max.z),e[2]=new S(this.min.x,this.max.y,this.min.z),e[3]=new S(this.min.x,this.max.y,this.max.z),e[4]=new S(this.max.x,this.min.y,this.min.z),e[5]=new S(this.max.x,this.min.y,this.max.z),e[6]=new S(this.max.x,this.max.y,this.min.z),e[7]=new S(this.max.x,this.max.y,this.max.z),e.forEach((function(e){return ct.multiplyByPoint(t,e,e)})),this.setFromPoints(e),this},t.prototype.translate=function(t){return this.min.addVector(t),this.max.addVector(t),this},t.prototype.equals=function(t){return S.equals(t.min,this.min)&&S.equals(t.max,this.max)},t}(),Nt=function(){function t(t,e){void 0===t&&(t=new S),void 0===e&&(e=-1),this.center=t,this.radius=e}return t.prototype.set=function(t,e){return this.center.copyFrom(t),this.radius=e,this},t.prototype.setFromPoints=function(t,e){var a=this.center;void 0!==e?a.copyFrom(e):(new Ot).setFromPoints(t).getCenter(a);for(var n=0,r=0,o=t.length;r<o;r++)n=Math.max(n,a.distanceSquaredTo(t[r]));return this.radius=Math.sqrt(n),this},t.prototype.copyFrom=function(t){return this.center.copyFrom(t.center),this.radius=t.radius,this},t.prototype.isEmpty=function(){return this.radius<0},t.prototype.makeEmpty=function(){return this.center.set(0,0,0),this.radius=-1,this},t.prototype.containsPoint=function(t){return t.distanceSquaredTo(this.center)<=this.radius*this.radius},t.prototype.distanceToPoint=function(t){return t.distanceTo(this.center)-this.radius},t.prototype.intersectsSphere=function(t){var e=this.radius+t.radius;return t.center.distanceSquaredTo(this.center)<=e*e},t.prototype.intersectsBox=function(t){return t.intersectsSphere(this)},t.prototype.clampPoint=function(t,e){var a=this.center.distanceSquaredTo(t);return e.copyFrom(t),a>this.radius*this.radius&&(e.subVector(this.center).normalize(),e.multiplyScalar(this.radius).addVector(this.center)),e},t.prototype.getBoundingBox=function(t){return void 0===t&&(t=new Ot),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)},t.prototype.translate=function(t){return this.center.addVector(t),this},t.prototype.expandByPoint=function(t){var e=t.clone().subVector(this.center),a=e.lengthSquared();if(a>this.radius*this.radius){var n=Math.sqrt(a),r=.5*(n-this.radius);this.center.addVector(e.multiplyScalar(r/n)),this.radius+=r}return this},t.prototype.union=function(t){var e=new S,a=t.center.clone().subVector(this.center);return a.normalize().multiplyScalar(t.radius),this.expandByPoint(e.copyFrom(t.center).addVector(a)),this.expandByPoint(e.copyFrom(t.center).subVector(a)),this},t.prototype.equals=function(t){return S.equals(t.center,this.center)&&t.radius===this.radius},t.prototype.clone=function(){return(new t).copyFrom(this)},t}();t.PObjectType=void 0,(pt=t.PObjectType||(t.PObjectType={}))[pt.none=0]="none",pt[pt.mesh=1]="mesh",pt[pt.texture=2]="texture",pt[pt.material=3]="material",pt[pt.light=4]="light",pt[pt.camera=5]="camera",pt[pt.skybox=6]="skybox",pt[pt.skin=7]="skin",pt[pt.morph=8]="morph",pt[pt.skeleton=9]="skeleton",pt[pt.animation=10]="animation",pt[pt.animationManager=11]="animationManager",pt[pt.reference=12]="reference",t.PLightType=void 0,(mt=t.PLightType||(t.PLightType={}))[mt.directional=0]="directional",mt[mt.point=1]="point",mt[mt.spot=2]="spot",mt[mt.ambient=3]="ambient",t.PTextureType=void 0,(_t=t.PTextureType||(t.PTextureType={}))[_t.none=0]="none",_t[_t.t2d=1]="t2d",_t[_t.t3d=2]="t3d",_t[_t.cube=3]="cube",t.PMaterialType=void 0,(gt=t.PMaterialType||(t.PMaterialType={}))[gt.none=0]="none",gt[gt.unlit=1]="unlit",gt[gt.pbr=2]="pbr",gt[gt.normalVis=3]="normalVis",gt[gt.simpleFilter=4]="simpleFilter",gt[gt.shadowBase=5]="shadowBase",gt[gt.shadowFilter=6]="shadowFilter",gt[gt.skyboxFilter=7]="skyboxFilter",t.PBlendMode=void 0,(yt=t.PBlendMode||(t.PBlendMode={}))[yt.opaque=0]="opaque",yt[yt.masked=1]="masked",yt[yt.translucent=2]="translucent",yt[yt.additive=3]="additive",t.PFaceSideMode=void 0,(vt=t.PFaceSideMode||(t.PFaceSideMode={}))[vt.both=0]="both",vt[vt.front=1]="front",vt[vt.back=2]="back",t.PShadowType=void 0,(xt=t.PShadowType||(t.PShadowType={}))[xt.none=0]="none",xt[xt.standard=1]="standard",xt[xt.variance=2]="variance",xt[xt.expVariance=3]="expVariance";var Lt=function(){function a(){this.translation=new S(0,0,0),this.rotation=new J(0,0,0,1),this.scale=new S(1,1,1)}return a.prototype.fromMatrix4=function(t){return this.setMatrix(t),this},a.prototype.fromEffectsTransform=function(t){if(t instanceof e.Transform)this.setMatrix(t.getWorldMatrix());else{var a=new e.Transform(o(o({},t),{valid:!0}));a.setValid(!0),this.setMatrix(a.getWorldMatrix())}return this},a.prototype.toEffectsTransform=function(t){var e=this.getMatrix();return t.cloneFromMatrix(e.toArray()),t},a.prototype.fromBaseTransform=function(t){return t.position?this.setTranslation(t.position):this.translation.set(0,0,0),t.rotation?this.setRotation(t.rotation):this.rotation.set(0,0,0,1),t.scale?this.setScale(t.scale):this.scale.set(1,1,1),this},a.prototype.getTranslation=function(){return this.translation},a.prototype.setTranslation=function(t){t instanceof S?this.translation.set(t.x,t.y,t.z):this.translation.set(t[0],t[1],t[2])},a.prototype.getPosition=function(){return this.translation},a.prototype.setPosition=function(t){t instanceof S?this.translation.set(t.x,t.y,t.z):this.translation.set(t[0],t[1],t[2])},a.prototype.getRotation=function(){return this.rotation},a.prototype.setRotation=function(e){e instanceof J?this.rotation.set(e.x,e.y,e.z,e.w):e instanceof Z?this.rotation.setFromEuler(e):e instanceof S?this.rotation.setFromEuler(new Z(e.x,e.y,e.z,t.EulerOrder.ZYX)):4===e.length?this.rotation.set(e[0],e[1],e[2],e[3]):this.rotation.setFromEuler(new Z(e[0],e[1],e[2],t.EulerOrder.ZYX))},a.prototype.getScale=function(){return this.scale},a.prototype.setScale=function(t){t instanceof S?this.scale.set(t.x,t.y,t.z):this.scale.set(t[0],t[1],t[2])},a.prototype.getMatrix=function(){return(new ct).compose(this.getTranslation(),this.getRotation(),this.getScale())},a.prototype.setMatrix=function(t){if(t instanceof ct){var e=t.decompose();this.setTranslation(e.translation),this.setRotation(e.rotation),this.setScale(e.scale)}else{e=ct.fromArray(t).decompose();this.setTranslation(e.translation),this.setRotation(e.rotation),this.setScale(e.scale)}},a}(),Ft=function(){function t(){this.origin=new S(0,0,0),this.xAxis=new S(1,0,0),this.yAxis=new S(0,1,0),this.zAxis=new S(0,0,1)}return t.prototype.fromPTransform=function(t,e){void 0===e&&(e=!1),this.origin.copyFrom(t.getPosition());var a=t.getRotation().toMatrix4(new ct);return e&&a.inverse(),this.fromRotationMatrix(a),this},t.prototype.fromRotationMatrix=function(t){var e=t.data;this.xAxis.set(e[0],e[1],e[2]),this.yAxis.set(e[4],e[5],e[6]),this.zAxis.set(e[8],e[9],e[10])},t}(),Rt=function(){function t(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=e.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16}return t.getInstance=function(){return this.instance||(this.instance=new this)},t.prototype.reset=function(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=e.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16},t.prototype.hasRenderMode3D=function(){return this.renderMode3D!==e.spec.RenderMode3D.none},Object.defineProperty(t.prototype,"isEditorEnv",{get:function(){return this.runtimeEnv===e.PLAYER_OPTIONS_ENV_EDITOR},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDeviceEnv",{get:function(){return!this.isEditorEnv},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isTiny3dMode",{get:function(){return"tiny3d"===this.compatibleMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOasisMode",{get:function(){return"oasis"===this.compatibleMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isGLTFMode",{get:function(){return!this.isTiny3dMode&&!this.isOasisMode},enumerable:!1,configurable:!0}),t}(),zt=1,Bt=function(){function e(){this.name="Unnamed Object",this.type=t.PObjectType.none}return e.prototype.dispose=function(){},e.prototype.isNone=function(){return this.type===t.PObjectType.none},e.prototype.isValid=function(){return this.type!==t.PObjectType.none},e.prototype.genName=function(t){return"".concat(t,"_@").concat(zt++)},e}(),Dt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._visible=!1,e._transform=new Lt,e.deleted=!1,e}return r(e,t),e.prototype.tick=function(t){},e.prototype.onVisibleChanged=function(t){this.visible=t},e.prototype.addToRenderObjectSet=function(t){},e.prototype.updateUniformsForScene=function(t){},e.prototype.onEntityRemoved=function(){this.visible=!1,this.deleted=!0},Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible&&this.isValid()},set:function(t){this._visible=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transform",{get:function(){return this._transform},set:function(t){t instanceof Lt?this._transform=t:(void 0!==t.position&&this._transform.setTranslation(t.position),void 0!==t.rotation&&this._transform.setRotation(t.rotation),void 0!==t.scale&&this._transform.setScale(t.scale))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"translation",{get:function(){return this._transform.getTranslation()},set:function(t){this._transform.setTranslation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._transform.getTranslation()},set:function(t){this._transform.setTranslation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this._transform.getRotation()},set:function(t){this._transform.setRotation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this._transform.getScale()},set:function(t){this._transform.setScale(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"matrix",{get:function(){return this._transform.getMatrix()},set:function(t){this._transform.setMatrix(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coordinate",{get:function(){var t=new Ft;return t.fromPTransform(this._transform),t},enumerable:!1,configurable:!0}),e}(Bt);var Ut={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,f32:Float32Array,i32:Int32Array,u32:Uint32Array};function kt(t,a){if(2!=a.length||a[0]!==e.spec.ValueType.BINARY||!(a[1]instanceof Array))return a;var n=c(a[1],4),r=n[0],o=n[1],i=n[2],s=n[3];if(!s)return t[r].slice(o,i);var u=Ut[s]||Uint8Array;return new u(t[r],o,i/u.BYTES_PER_ELEMENT)}function Vt(t,a,n){var r=ct.fromArray(a),o=ct.inverse(r,new ct),i=new P(t.center[0],t.center[1],t.center[2],1),s=new S(t.direction[0],t.direction[1],t.direction[2]),c=ct.multiplyByVector(o,i,new P),u=function(t,e){var a=e.x,n=e.y,r=e.z,o=new S;return o.x=t.data[0]*a+t.data[4]*n+t.data[8]*r,o.y=t.data[1]*a+t.data[5]*n+t.data[9]*r,o.z=t.data[2]*a+t.data[6]*n+t.data[10]*r,o.normalize()}(o,s),d=e.intersectRayBox([],[c.x,c.y,c.z],[u.x,u.y,u.z],n.center,n.size);if(null!==d){var l=ct.multiplyByVector(r,new P(d[0],d[1],d[2],1),new P);return[[l.x,l.y,l.z]]}}function jt(t,e,a,n){var r=0,o=0,i=0,s=0,c=0,u=0,d=1/e.x,l=1/e.y,h=1/e.z;if(d>=0?(r=(a.x-t.x)*d,o=(n.x-t.x)*d):(r=(n.x-t.x)*d,o=(a.x-t.x)*d),l>=0?(i=(a.y-t.y)*l,s=(n.y-t.y)*l):(i=(n.y-t.y)*l,s=(a.y-t.y)*l),!(r>s||i>o||((i>r||r!=r)&&(r=i),(s<o||o!=o)&&(o=s),h>=0?(c=(a.z-t.z)*h,u=(n.z-t.z)*h):(c=(n.z-t.z)*h,u=(a.z-t.z)*h),r>u||c>o||((c>r||r!=r)&&(r=c),(u<o||o!=o)&&(o=u),o<0))))return r>=0?r:o}var Gt=new S,Ht=new S,Wt=new S,qt=new S;function Xt(t,e,a,n,r,o){S.subtract(n,a,Ht),S.subtract(r,a,Wt),S.cross(Ht,Wt,qt);var i=e.dot(qt),s=0;if(i>0){if(o)return;s=1}else{if(!(i<0))return;s=-1,i=-i}S.subtract(t,a,Gt),S.cross(Gt,Wt,Wt);var c=s*e.dot(Wt);if(!(c<0)){S.cross(Ht,Gt,Ht);var u=s*e.dot(Ht);if(!(u<0||c+u>i)){var d=-s*Gt.dot(qt);if(!(d<0))return d/i}}}var Yt,Zt,Jt,Qt=function(){function t(){}return t.createTexture2D=function(a,n,r,o,c){return i(this,void 0,void 0,(function(){var i,u,d,l;return s(this,(function(s){return void 0===n.imageData?(console.error("createTexture2D: Invalid image data from ".concat(n)),[2,e.Texture.create(a,{name:"createTexture2D",sourceType:e.TextureSourceType.data,data:{data:new Uint8Array([255,255,255,255]),width:1,height:1}})]):(i=new Blob([n.imageData],{type:n.mimeType}),u=window.URL||window.webkitURL,d=u.createObjectURL(i),(l=new Image).src=d,[2,new Promise((function(n,i){l.onload=function(){var i,s,h,f,p=null!==(i=r.minFilter)&&void 0!==i?i:e.glContext.LINEAR_MIPMAP_LINEAR,m=!1;c&&(p=e.glContext.LINEAR_MIPMAP_LINEAR,t.isPow2(l.width)&&t.isPow2(l.height)||(p=e.glContext.LINEAR),m=!o);var _=!1;p!=e.glContext.NEAREST_MIPMAP_NEAREST&&p!=e.glContext.LINEAR_MIPMAP_NEAREST&&p!=e.glContext.NEAREST_MIPMAP_LINEAR&&p!=e.glContext.LINEAR_MIPMAP_LINEAR||(_=!0);var g=e.Texture.create(a,{name:"createTexture2D",wrapS:null!==(s=r.wrapS)&&void 0!==s?s:e.glContext.REPEAT,wrapT:null!==(h=r.wrapT)&&void 0!==h?h:e.glContext.REPEAT,magFilter:null!==(f=r.magFilter)&&void 0!==f?f:e.glContext.LINEAR,minFilter:p,anisotropic:1,premultiplyAlpha:m,sourceType:e.TextureSourceType.image,image:l,generateMipmap:_});n(g),u.revokeObjectURL(d)},l.onerror=i}))])}))}))},t.createTextureList=function(t,e,a){return i(this,void 0,void 0,(function(){var n=this;return s(this,(function(r){switch(r.label){case 0:return[4,Promise.all(a.map((function(a){return n.createTexture2D(t,e[a.source],a)})))];case 1:return[2,r.sent()]}}))}))},t.getTextureCubeData=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return[4,te.loadImageFromImageData(t[0])];case 1:return e=[a.sent()],[4,te.loadImageFromImageData(t[1])];case 2:return e=e.concat([a.sent()]),[4,te.loadImageFromImageData(t[2])];case 3:return e=e.concat([a.sent()]),[4,te.loadImageFromImageData(t[3])];case 4:return e=e.concat([a.sent()]),[4,te.loadImageFromImageData(t[4])];case 5:return e=e.concat([a.sent()]),[4,te.loadImageFromImageData(t[5])];case 6:return[2,e.concat([a.sent()])]}}))}))},t.getTextureCubeMipmapData=function(t){return i(this,void 0,void 0,(function(){var e,a,n,r;return s(this,(function(o){switch(o.label){case 0:e=[],a=0,o.label=1;case 1:return a<t.length?(r=(n=e).push,[4,this.getTextureCubeData(t[a])]):[3,4];case 2:r.apply(n,[o.sent()]),o.label=3;case 3:return a++,[3,1];case 4:return[2,e]}}))}))},t.createTextureCubeFromURL=function(t,a){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return[4,e.getDefaultTextureFactory().loadSource({type:e.TextureSourceType.image,target:e.glContext.TEXTURE_CUBE_MAP,map:a},this.cubemapTexConfig)];case 1:return n=r.sent(),[2,e.Texture.create(t,n)]}}))}))},t.createTextureCubeMipmapFromURL=function(t,a){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return[4,e.getDefaultTextureFactory().loadSource({type:e.TextureSourceType.mipmaps,target:e.glContext.TEXTURE_CUBE_MAP,maps:a},this.cubemapMipTexConfig)];case 1:return n=r.sent(),[2,e.Texture.create(t,n)]}}))}))},t.createTextureCubeFromBuffer=function(a,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return[4,t.getTextureCubeData(n)];case 1:return r=i.sent(),[2,e.Texture.create(a,o({name:"createTextureCubeFromBuffer",sourceType:e.TextureSourceType.image,cube:r,target:e.glContext.TEXTURE_CUBE_MAP},this.cubemapTexConfig))]}}))}))},t.createTextureCubeMipmapFromBuffer=function(a,n,r){return i(this,void 0,void 0,(function(){var i,c,u,d,l;return s(this,(function(s){switch(s.label){case 0:return[4,t.getTextureCubeMipmapData(n)];case 1:for(i=s.sent(),c=0;Math.pow(2,c)<r;)++c;s.label=2;case 2:return i.length<=c?(u=Math.pow(2,c-i.length),d="https://gw.alipayobjects.com/zos/gltf-asset/67896749597915/img".concat(u,".png"),[4,e.loadImage(d)]):[3,4];case 3:return l=s.sent(),i.push([l,l,l,l,l,l]),[3,2];case 4:return[2,e.Texture.create(a,o({name:"createTextureCubeMipmapFromBuffer",sourceType:e.TextureSourceType.mipmaps,mipmaps:i,target:e.glContext.TEXTURE_CUBE_MAP},this.cubemapMipTexConfig))]}}))}))},t.getTexture=function(t,e){return t<0||t>=e.length?void 0:e[t]},t.createTextureFromImage=function(t,a){var n={name:"createTextureFromImage",image:a,sourceType:e.TextureSourceType.image,flipY:!1,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR,wrapT:e.glContext.REPEAT,wrapS:e.glContext.REPEAT};return e.Texture.create(t,n)},t.createRenderPass=function(t,a,n,r,o){var i=r instanceof e.Mesh?[r]:r;return new e.RenderPass(t,{name:a,priority:n,attachments:o.colorAttachments,depthStencilAttachment:o.depthAttachment,clearAction:{clearDepth:1,clearStencil:0,clearColor:[0,0,0,0],colorAction:e.TextureLoadAction.clear,depthAction:e.TextureLoadAction.clear},meshes:i,viewport:o.viewport})},t.deleteTexture=function(t){t.dispose()},t.deleteMesh=function(t){t.dispose({geometries:e.DestroyOptions.destroy,material:{textures:e.DestroyOptions.destroy}})},t.deleteGeometry=function(t){t.dispose()},t.deleteRenderPass=function(t){t.dispose({meshes:{geometries:e.DestroyOptions.destroy,material:{textures:e.DestroyOptions.destroy}},depthStencilAttachment:e.RenderPassDestroyAttachmentType.force,colorAttachment:e.RenderPassDestroyAttachmentType.force,semantics:e.DestroyOptions.destroy})},t.isTransparentMesh=function(t){return!0===t.material.blending},t.isSupportFloatTexture=function(t){return 0!==t.gpuCapability.detail.floatTexture},t.isSupportHalfFloatTexture=function(t){return 0!==t.gpuCapability.detail.halfFloatTexture},t.isPow2=function(t){return!(t&t-1||!t)},t.cubemapTexConfig={name:"cubemap texture",wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR},t.cubemapMipTexConfig={wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR_MIPMAP_LINEAR},t}(),Kt=function(){function t(){}return t.createFilterMesh=function(a,n,r,o){var i=Rt.getInstance(),s=r.vertexShaderCode,c=r.fragmentShaderCode,u=e.Geometry.create(a,t.getPlaneGeometry()),d=e.Material.create(a,{shader:{vertex:s,fragment:c,shared:i.shaderShared},uniformSemantics:o});return r.setMaterialStates(d),e.Mesh.create(a,{name:n,worldMatrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],material:d,geometry:u})},t.getPlaneGeometry=function(){var a=t.getPlaneVertexArray();return{attributes:{a_Position:{type:e.glContext.FLOAT,size:3,data:a,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:0},a_UV1:{type:e.glContext.FLOAT,size:2,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:3*Float32Array.BYTES_PER_ELEMENT,dataSource:"a_Position"},a_Normal:{type:e.glContext.FLOAT,size:3,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:5*Float32Array.BYTES_PER_ELEMENT,dataSource:"a_Position"}},drawStart:0,drawCount:a.length/8}},t.getPlaneVertexArray=function(){return new Float32Array([-1,-1,0,0,0,0,0,1,1,-1,0,1,0,0,0,1,1,1,0,1,1,0,0,1,-1,-1,0,0,0,0,0,1,1,1,0,1,1,0,0,1,-1,1,0,0,1,0,0,1])},t}(),$t=function(){function t(){}return t.createLightOptions=function(t){var e,a,n,r,o,i,s,c,u=null!==(e=t.color)&&void 0!==e?e:[255,255,255,255];return"point"===t.type?{color:u,intensity:null!==(a=t.intensity)&&void 0!==a?a:1,lightType:"point",range:null!==(n=t.range)&&void 0!==n?n:0}:"spot"===t.type?{color:u,intensity:null!==(r=t.intensity)&&void 0!==r?r:1,lightType:"spot",range:null!==(o=t.range)&&void 0!==o?o:0,innerConeAngle:null!==(i=t.innerConeAngle)&&void 0!==i?i:0,outerConeAngle:null!==(s=t.outerConeAngle)&&void 0!==s?s:Math.PI/4}:{color:u,intensity:null!==(c=t.intensity)&&void 0!==c?c:1,lightType:"directional"}},t.createCameraOptions=function(t){if(void 0!==t.perspective){var e=t.perspective;e.znear,e.zfar,e.yfov}},t.toPlayerColor3=function(t){return[this.scaleTo255(t[0]),this.scaleTo255(t[1]),this.scaleTo255(t[2])]},t.toPlayerColor4=function(t){return[this.scaleTo255(t[0]),this.scaleTo255(t[1]),this.scaleTo255(t[2]),this.scaleTo255(t[3])]},t.toPluginColor3=function(t){return[this.scaleTo1(t[0]),this.scaleTo1(t[1]),this.scaleTo1(t[2])]},t.toPluginColor4=function(t){return[this.scaleTo1(t[0]),this.scaleTo1(t[1]),this.scaleTo1(t[2]),this.scaleTo1(t[3])]},t.createUVTransform=function(t){if(void 0!==t&&(void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale)){var e=V.IDENTITY.clone(),a=new V;if(void 0!==t.offset&&(V.fromColumnMajorArray([1,0,0,0,1,0,t.offset[0],t.offset[1],1],a),e.multiply(a)),void 0!==t.rotation){var n=Math.cos(t.rotation),r=Math.sin(t.rotation);V.fromColumnMajorArray([n,r,0,-r,n,0,0,0,1],a),e.multiply(a)}return void 0!==t.scale&&(V.fromColumnMajorArray([t.scale[0],0,0,0,t.scale[1],0,0,0,1],a),e.multiply(a)),V.transpose(e,e),e}},t.clamp=function(t,e,a){return Math.max(Math.min(t,a),e)},t.scaleTo255=function(t){var e=Math.round(255*t);return Math.max(0,Math.min(e,255))},t.scaleTo1=function(t){var e=t/255;return Math.max(0,Math.min(e,1))},t.focusOnPoint=function(t,a,n){var r=S.fromArray(t),o=S.fromArray(n),i=(new S).copyFrom(r).subVector(o);ct.IDENTITY.clone().rotate(a*e.DEG2RAD,new S(0,1,0)).multiplyByPoint3(i);var s=i.clone().addVector(o),c=(new ct).lookAt(s,o,new S(0,1,0)).inverse(),u=new e.Transform;return u.setValid(!0),u.cloneFromMatrix(c.toArray()),u},t.preprocessEffectsScene=function(t,a,n,r){var o=this,i=a!==e.PLAYER_OPTIONS_ENV_EDITOR,s="tiny3d"===n,c=t.jsonScene;if(void 0===c||void 0===c.compositions)return{};var u=!1;if(i){var d=t.textureOptions;c.compositions.forEach((function(t){t.items.forEach((function(t){if("mesh"===t.type)t.content.options.primitives.forEach((function(t){var a=t.material;a.type===e.spec.MaterialType.pbr?(void 0!==a.baseColorTexture&&o.preprocessTextureOptions(a.baseColorTexture,d,!0,s),void 0!==a.metallicRoughnessTexture&&o.preprocessTextureOptions(a.metallicRoughnessTexture,d,!1,s),void 0!==a.normalTexture&&o.preprocessTextureOptions(a.normalTexture,d,!1,s),void 0!==a.occlusionTexture&&o.preprocessTextureOptions(a.occlusionTexture,d,!1,s),void 0!==a.emissiveTexture&&o.preprocessTextureOptions(a.emissiveTexture,d,!1,s)):void 0!==a.baseColorTexture&&o.preprocessTextureOptions(a.baseColorTexture,d,!0,s)}));else if("skybox"===t.type){u=!0;var a=t.content.options;o.preprocessTextureOptions(a.specularImage,d,!1,s),void 0!==a.diffuseImage&&o.preprocessTextureOptions(a.diffuseImage,d,!1,s)}}))}))}else c.compositions.forEach((function(t){t.items.forEach((function(t){"skybox"===t.type&&(u=!0)}))}));return r&&c.compositions.forEach((function(t){var a=0;t.items.forEach((function(t){"light"!==t.type&&"skybox"!==t.type||++a})),0==a&&(t.items.push({id:"dir-light1",duration:100,name:"dir-light1",type:e.spec.ItemType.light,transform:{rotation:[45,-45,0]},pluginName:"model",endBehavior:0,content:{options:{lightType:"directional",color:[255,255,255,255],intensity:1.5}}}),t.items.push({id:"dir-light2",duration:100,name:"dir-light2",type:e.spec.ItemType.light,transform:{rotation:[0,90,0]},pluginName:"model",endBehavior:0,content:{options:{lightType:"directional",color:[255,255,255,255],intensity:.2}}}))})),{loadSkybox:u}},t.preprocessTextureOptions=function(t,a,n,r){if(!(t<0||t>=a.length)){var o=a[t];r&&void 0!==o&&(void 0===o.target||o.target===e.glContext.TEXTURE_2D?(o.wrapS=e.glContext.REPEAT,o.wrapT=e.glContext.REPEAT,o.magFilter=e.glContext.LINEAR,o.minFilter=e.glContext.LINEAR_MIPMAP_LINEAR,o.generateMipmap=!0,n||(o.premultiplyAlpha=!0)):o.target===e.glContext.TEXTURE_CUBE_MAP&&(o.wrapS=e.glContext.CLAMP_TO_EDGE,o.wrapT=e.glContext.CLAMP_TO_EDGE,void 0!==o.mipmaps?(o.magFilter=e.glContext.LINEAR,o.minFilter=e.glContext.LINEAR_MIPMAP_LINEAR):(o.magFilter=e.glContext.LINEAR,o.minFilter=e.glContext.LINEAR)))}},t.setupItem3DOptions=function(t,a,n){var r=this;if(!(void 0===t||t.bins.length<=0)){var o=0,i=t.jsonScene;if(i.compositions.forEach((function(t,e){t.id===i.compositionId&&(o=e)})),o>=0&&o<i.compositions.length)i.compositions[o].items.forEach((function(i,s){if("mesh"===i.type){var c=i,u=c.content.options.skin;if(c.content.options.primitives.forEach((function(i,c){if(!(i.geometry instanceof e.Geometry)){var u="Geom_C".concat(o,"_I").concat(s,"_P").concat(c),d=a.getOrCreateGeometry(u,i.geometry,t.bins),l=i;l.geometry=d;var h,f=i.material;if(f.type===e.spec.MaterialType.pbr)(h=l.material).baseColorTexture=r.getTextureObj(n.textures,f.baseColorTexture),h.metallicRoughnessTexture=r.getTextureObj(n.textures,f.metallicRoughnessTexture),h.normalTexture=r.getTextureObj(n.textures,f.normalTexture),h.occlusionTexture=r.getTextureObj(n.textures,f.occlusionTexture),h.emissiveTexture=r.getTextureObj(n.textures,f.emissiveTexture);else(h=l.material).baseColorTexture=r.getTextureObj(n.textures,f.baseColorTexture)}})),void 0!==u&&void 0!==u.inverseBindMatrices){var d=u,l=kt(t.bins,u.inverseBindMatrices);l instanceof Float32Array?d.inverseBindMatrices=l:console.error("setupItem3DOptions: Invalid inverseBindMatrices type, ".concat(l))}}else if("tree"===i.type){var h=i,f=i.content.options.tree.animations,p=h.content.options.tree.animations;void 0!==f&&void 0!==p&&f.forEach((function(e,a){var n=p[a];e.tracks.forEach((function(e,a){var r=kt(t.bins,e.input),o=kt(t.bins,e.output),i=n.tracks[a];r instanceof Float32Array?i.input=r:console.error("setupItem3DOptions: Type of inputArray should be float32, ".concat(r)),o instanceof Float32Array?i.output=o:console.error("setupItem3DOptions: Type of outputArray should be float32, ".concat(o))}))}))}else if("skybox"===i.type){var m=i,_=i.content.options,g=m.content.options,y=r.getTextureObj(n.textures,_.specularImage);void 0===y&&console.error("setupItem3DOptions: skybox specualrImage is undefined, ".concat(oe.stringify(_))),g.specularImage=y;var v=r.getTextureObj(n.textures,_.diffuseImage);void 0!==v&&(g.diffuseImage=v)}}))}},t.createGeometry=function(t,a,n){var r=function(t,e){var a,n,r=t.attributes,i=o({},t);return i.indices?(i.indices=o({},i.indices),i.indices.data&&(i.indices.data=kt(e,null===(a=t.indices)||void 0===a?void 0:a.data))):i.index&&(i.indices=o({},i.index),i.indices.data&&(i.indices.data=kt(e,null===(n=t.index)||void 0===n?void 0:n.data))),Object.keys(r).forEach((function(t){var a=r[t],n=a.data;i.attributes[t]=o({},a),n&&(i.attributes[t].data=kt(e,n))})),i}(a,n),i={};for(var s in r.attributes){var c=r.attributes[s];i[this.getAttributeName(s)]=c}return r.attributes=i,e.Geometry.create(t,r)},t.getIndexArray=function(t,e){switch(t){case WebGLRenderingContext.UNSIGNED_INT:case WebGLRenderingContext.UNSIGNED_SHORT:case WebGLRenderingContext.UNSIGNED_BYTE:return e;default:console.error("Invalid index attribute type ".concat(t))}},t.getAttributeName=function(t){switch(t){case"POSITION":return"a_Position";case"NORMAL":return"a_Normal";case"TANGENT":return"a_Tangent";case"TEXCOORD_0":return"a_UV1";case"TEXCOORD_1":return"a_UV2";case"JOINTS_0":return"a_Joint1";case"WEIGHTS_0":return"a_Weight1"}return t.startsWith("a_")||console.warn("Unknown attribute name: ".concat(t)),t},t.getTextureObj=function(t,e){return"number"!=typeof e?e:((e<0||e>=t.length)&&console.error("Invalid index for textures: ".concat(e,", ").concat(t.length)),t[e])},t}(),te=function(){function t(){}return t.getImageFileName=function(t,e){var a=t.lastIndexOf("/"),n=t.lastIndexOf("."),r=t.substring(a+1,n);return e?r+e:r},t.getCurrnetTimeStr=function(){var t=new Date(Date.now()),e=t.toLocaleString("zh-CN"),a="".concat(t.getMilliseconds());return e.split(/[ /:]+/).join("")+a.padStart(3,"0")},t.saveFileForURL=function(t,e){var a=document.createElement("a");a.setAttribute("download",e),a.target="_blank",a.href=t,a.click()},t.createPlayer=function(t){void 0===t&&(t=!0);var a=document.createElement("canvas");return a.width=512,a.height=512,new e.Player({canvas:a,renderFramework:"webgl2",env:e.PLAYER_OPTIONS_ENV_EDITOR,willCaptureImage:!0,manualRender:t})},t.sleep=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new Promise((function(e){return setTimeout(e,t)}))]}))}))},t.loadImageFromGLTFImage=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(a){return[2,e.loadImage(new Blob([t.imageData],{type:t.mimeType}))]}))}))},t.loadImageFromImageData=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(a){return[2,e.loadImage(new Blob([t.data],{type:t.mimeType}))]}))}))},t.getCanvasArrayBuffer=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new Promise((function(e,a){t.toBlob((function(t){t?e(t.arrayBuffer()):a(Error("no canvas blob"))}),"image/png",1)}))]}))}))},t.getImageArrayBuffer=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(a){return(e=document.createElement("canvas")).width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),[2,this.getCanvasArrayBuffer(e)]}))}))},t.getCanvasImageData=function(t){return t.getContext("2d").getImageData(0,0,t.width,t.height)},t.flipImageData=function(t){var e=document.createElement("canvas"),a=e.getContext("2d");return e.width=t.width,e.height=t.height,a.putImageData(t,0,0),a.globalCompositeOperation="copy",a.scale(1,-1),a.translate(0,-t.height),a.drawImage(e,0,0),a.setTransform(1,0,0,1,0,0),a.globalCompositeOperation="source-over",a.getImageData(0,0,e.width,e.height)},t.getImageData=function(t){var e=document.createElement("canvas");e.width=t.width,e.height=t.height;var a=e.getContext("2d");return a.drawImage(t,0,0),this.flipImageData(a.getImageData(0,0,e.width,e.height))},t.getWebGLCanvasImageBuffer=function(t){var e=t.getContext("webgl2"),a=new Uint8Array(t.width*t.height*4);return e.readPixels(0,0,t.width,t.height,e.RGBA,e.UNSIGNED_BYTE,a),a},t}(),ee=function(){function t(){this.component=0,this.length=0,this.offset=0,this.stride=0,this.typeSize=0}return t.prototype.getBoundingBox=function(t){for(var e=this.offset,a=new S;e+this.component<=this.length;)2==this.component?a.set(this.data[e],this.data[e+1],0):a.set(this.data[e],this.data[e+1],this.data[e+2]),t.expandByPoint(a),e+=this.stride;return t},t}(),ae=function(){function t(){this.length=0,this.offset=0,this.stride=0,this.typeSize=0,this.compCount=0,this.signed=!1,this.compressed=!1,this.compressScale=1}return t.prototype.create=function(t,e){var a,n;switch(t.type){case WebGLRenderingContext.INT:this.typeSize=4,this.signed=!0,this.compressScale=1/2147483647;break;case WebGLRenderingContext.SHORT:this.typeSize=2,this.signed=!0,this.compressScale=1/32767;break;default:this.typeSize=4,this.signed=!0,this.compressScale=1}this.data=e,this.length=this.data.length,this.compCount=t.size,this.offset=null!==(a=t.offset)&&void 0!==a?a:0,this.offset>0&&(this.offset%this.typeSize!=0&&console.error("Invalid offset ".concat(this.offset,", type size ").concat(this.typeSize)),this.offset=this.offset/this.typeSize),this.stride=null!==(n=t.stride)&&void 0!==n?n:0,this.stride>0?(this.stride%this.typeSize!=0&&console.error("Invalid stride ".concat(this.stride,", type size ").concat(this.typeSize)),this.stride=this.stride/this.typeSize):this.stride=this.compCount,this.compressed=!0===t.normalize},t.prototype.getData=function(t){var e=this.offset;if(!((e+=t*this.stride)+this.compCount>this.length)){var a;if(a=2===this.compCount?[this.data[e],this.data[e+1],0,0]:3===this.compCount?[this.data[e],this.data[e+1],this.data[e+2],0]:[this.data[e],this.data[e+1],this.data[e+2],this.data[e+3]],this.compressed)for(var n=0;n<this.compCount;n++)a[n]*=this.compressScale,this.signed&&(a[n]=Math.max(a[n],-1));return a}},t.prototype.getLength=function(){return Math.round((this.length-this.offset)/this.stride)},t}(),ne=function(){function t(){this.drawStart=0,this.drawCount=0,this.bindMatrices=[]}return t.prototype.create=function(t,e){this.drawStart=0,this.drawCount=Math.abs(t.getDrawCount());var a=t.attributes;this.index=t.getIndexData();var n=a.a_Position,r=t.getAttributeData("a_Position");this.position=new ae,this.position.create(n,r);var o=a.a_Joint1,i=a.a_Weight1;if(void 0!==o&&void 0!==i){var s=t.getAttributeData("a_Joint1"),c=t.getAttributeData("a_Weight1");this.joint=new ae,this.joint.create(o,s),this.weight=new ae,this.weight.create(i,c)}this.bindMatrices=e},t.prototype.getBoundingBox=function(t){var e=this;t.makeEmpty();var a=new ct,n=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0,r=new Set;if(void 0!==this.index)for(var o=0;o<this.drawCount;o++){var i=this.drawStart+o;i<this.index.length&&r.add(this.index[i])}else for(o=0;o<this.drawCount;o++)r.add(this.drawStart+o);return r.forEach((function(r){var o,i,s=e.position.getData(r);if(void 0!==s){var c=S.fromArray(s);if(n){var u=null===(o=e.joint)||void 0===o?void 0:o.getData(r),d=null===(i=e.weight)||void 0===i?void 0:i.getData(r);if(void 0!==u&&void 0!==d){a.setZero();for(var l=!1,h=0;h<4;h++)if(0!==d[h]){if(u[h]<0||u[h]>=e.bindMatrices.length){l=!0;break}var f=e.bindMatrices[u[h]];ct.mulScalerAddMatrix(a,f,d[h],a)}if(!l){var p=a.multiplyByVector4(new P(c.x,c.y,c.z,1));Math.abs(p.w)>1e-4&&(p.multiplyScalar(1/p.w),c.set(p.x,p.y,p.z))}}}t.expandByPoint(c)}})),t},t}(),re=function(){function t(){this.drawStart=0,this.drawCount=0,this.doubleSided=!1,this.bindMatrices=[],this.hasAnimation=!1,this.skinMatrix=new ct}return t.prototype.create=function(t,e,a){this.drawStart=0,this.drawCount=Math.abs(t.getDrawCount());var n=t.attributes;this.index=t.getIndexData();var r=n.a_Position,o=t.getAttributeData("a_Position");this.position=new ae,this.position.create(r,o);var i=n.a_Joint1,s=n.a_Weight1;if(void 0!==i&&void 0!==s){var c=t.getAttributeData("a_Joint1"),u=t.getAttributeData("a_Weight1");this.joint=new ae,this.joint.create(i,c),this.weight=new ae,this.weight.create(s,u)}this.doubleSided=e,this.bindMatrices=a,this.hasAnimation=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0},t.prototype.getHitPoint=function(t,e){for(var a,n=new S,r=new S,o=new S,i=new P,s=new P,c=new P,u=!this.doubleSided,d=0;d+2<this.drawCount;d+=3){var l=this.drawStart+d,h=this.drawStart+d+1,f=this.drawStart+d+2;void 0!==this.index&&(l=this.index[l],h=this.index[h],f=this.index[f]);var p=this.getPosition(l,n,i),m=this.getPosition(h,r,s),_=this.getPosition(f,o,c);if(void 0!==p&&void 0!==m&&void 0!==_){var g=Xt(t,e,p,m,_,u);void 0!==g&&(void 0===a||a>g)&&(a=g)}}return a},t.prototype.getPosition=function(t,e,a){var n,r,o=this.position.getData(t);if(void 0!==o){if(this.hasAnimation){var i=null===(n=this.joint)||void 0===n?void 0:n.getData(t),s=null===(r=this.weight)||void 0===r?void 0:r.getData(t);if(void 0!==i&&void 0!==s){var c=this.skinMatrix;c.setZero();for(var u=0;u<4;u++)if(0!==s[u]){var d=this.bindMatrices[i[u]];ct.mulScalerAddMatrix(c,d,s[u],c)}a.set(o[0],o[1],o[2],1);var l=c.multiplyByVector4(a),h=1/l.w;e.set(l.x*h,l.y*h,l.z*h)}}else e.set(o[0],o[1],o[2]);return e}},t}(),oe=function(){function t(){}return t.checkNumber=function(t){return"number"==typeof t},t.checkNumberUndef=function(t){return void 0===t||this.checkNumber(t)},t.checkNumber01=function(t){return this.checkNumber(t)&&t>=0&&t<=1},t.checkNumber01Undef=function(t){return void 0===t||this.checkNumber01(t)},t.checkPositive=function(t){return this.checkNumber(t)&&t>0},t.checkNonnegative=function(t){return this.checkNumber(t)&&t>=0},t.checkNonnegativeUndef=function(t){return void 0===t||this.checkNonnegative(t)},t.checkBoolean=function(t){return"boolean"==typeof t},t.checkBooleanUndef=function(t){return void 0===t||this.checkBoolean(t)},t.checkString=function(t){return"string"==typeof t},t.checkStringUndef=function(t){return void 0===t||this.checkString(t)},t.checkFloat32Array=function(t){return t instanceof Float32Array},t.checkFloat32ArrayUndef=function(t){return void 0===t||this.checkFloat32Array(t)},t.checkParent=function(t){return void 0===t||!!this.checkNumber(t)&&t>=0},t.checkTexCoord=function(t){return void 0===t||!!this.checkNumber(t)&&(t>=0&&t<=1)},t.checkVec2=function(t){var e=this;return!!Array.isArray(t)&&(2==t.length&&t.every((function(t){return e.checkNumber(t)})))},t.checkVec2Undef=function(t){return void 0===t||this.checkVec2(t)},t.checkVec3=function(t){var e=this;return!!Array.isArray(t)&&(3==t.length&&t.every((function(t){return e.checkNumber(t)})))},t.checkNonnegative3=function(t){var e=this;return!!Array.isArray(t)&&(3==t.length&&t.every((function(t){return e.checkNonnegative(t)})))},t.checkVec4=function(t){var e=this;return!!Array.isArray(t)&&(4==t.length&&t.every((function(t){return e.checkNumber(t)})))},t.checkNonnegative4=function(t){var e=this;return!!Array.isArray(t)&&(4==t.length&&t.every((function(t){return e.checkNonnegative(t)})))},t.checkNumberArray=function(t){var e=this;return!!Array.isArray(t)&&t.every((function(t){return e.checkNumber(t)}))},t.checkTexture=function(t){return t instanceof e.Texture&&(t.isDestroyed&&console.error("Texture is destroyed, ".concat(t.name)),!t.isDestroyed)},t.checkTextureUndef=function(t){return void 0===t||this.checkTexture(t)},t.checkTexTransform=function(t){return!!this.checkVec2Undef(t.offset)&&(!!this.checkNumberUndef(t.rotation)&&(!!this.checkVec2Undef(t.scale)&&(void 0===t.scale||!(Math.abs(t.scale[0])<1e-5||Math.abs(t.scale[1])<1e-5))))},t.checkTexTransformUndef=function(t){return void 0===t||this.checkTexTransform(t)},t.checkMatBlending=function(t){return void 0===t||t===e.spec.MaterialBlending.opaque||t===e.spec.MaterialBlending.masked||t===e.spec.MaterialBlending.translucent||t===e.spec.MaterialBlending.additive},t.checkMatSide=function(t){return void 0===t||t===e.spec.SideMode.BACK||t===e.spec.SideMode.DOUBLE||t===e.spec.SideMode.FRONT},t.checkAnimPath=function(t){return"translation"===t||"rotation"===t||"scale"===t||"weights"===t},t.checkAnimInterp=function(t){return"LINEAR"===t||"STEP"===t||"CUBICSPLINE"===t},t.assertGeometry=function(t,a){t instanceof e.Geometry||console.error("Invalid geometry type ".concat(this.stringify(t))),!0===t.isDestroyed&&console.error("Geometry object is destroyed"),this.checkNonnegative(t.getDrawStart())||console.error("Invalid geometry draw start: ".concat(t.getDrawStart(),", ").concat(this.stringify(t)))},t.assertGeometryBuffer=function(t,e,a){var n=this.createAttributeArray(t,e);void 0!==n&&n.getLength()<a&&console.error("".concat(e," Length(").concat(n.getLength(),") is less than draw count(").concat(a,"), ").concat(this.stringify(t)))},t.createAttributeArray=function(t,e){var a=t.attributes;if(void 0!==a){var n=a[e];if(void 0!==n){var r=t.getAttributeData(e);if(void 0!==r){var o=new ae;return o.create(n,r),o}}}},t.assertModelSkinOptions=function(t){if(this.checkStringUndef(t.name)||console.error("Invalid skin name ".concat(t.name,", ").concat(this.stringify(t))),this.checkNumberArray(t.joints)||console.error("Invalid skin joints ".concat(t.joints,", ").concat(this.stringify(t))),this.checkNumberUndef(t.skeleton)||console.error("Invalid skin skeleton ".concat(t.skeleton,", ").concat(this.stringify(t))),this.checkFloat32ArrayUndef(t.inverseBindMatrices)||console.error("Invalid skin inverseBindMatrices ".concat(t.inverseBindMatrices,", ").concat(this.stringify(t))),void 0!==t.inverseBindMatrices){(t.inverseBindMatrices.length<=0||t.inverseBindMatrices.length%16!=0)&&console.error("Invalid skin inverseBindMatrices length ".concat(t.inverseBindMatrices,", ").concat(this.stringify(t))),16*t.joints.length!==t.inverseBindMatrices.length&&console.error("Mismatch: skin joints and inverseBindMatrices length, ".concat(t.joints,", ").concat(t.inverseBindMatrices,", ").concat(this.stringify(t)));for(var e=new ct,a=0;a<t.inverseBindMatrices.length;a+=16){for(var n=0;n<16;n++)e.data[n]=t.inverseBindMatrices[a+n];Math.abs(e.determinant())<1e-5&&console.error("Determinant of inverseBindMatrices is too small ".concat(e.determinant(),", index ").concat(a/16,", ").concat(this.stringify(t)))}}else t.joints.length<=0&&console.error("Invalid skin joints length ".concat(t.joints,", ").concat(this.stringify(t)))},t.assertMatOptions=function(t){t.type===e.spec.MaterialType.unlit?(this.checkString(t.name)||console.error("Invalid material name ".concat(t.name,", ").concat(this.stringify(t))),this.checkNonnegative4(t.baseColorFactor)||console.error("Invalid material baseColorFactor ".concat(t.baseColorFactor,", ").concat(this.stringify(t))),this.checkTextureUndef(t.baseColorTexture)||console.error("Invalid material baseColorTexture ".concat(t.baseColorTexture,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform ".concat(t.baseColorTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate ".concat(t.baseColorTextureCoordinate,", ").concat(this.stringify(t))),this.checkBooleanUndef(t.depthMask)||console.error("Invalid material depthMask ".concat(t.depthMask,", ").concat(this.stringify(t))),this.checkMatBlending(t.blending)||console.error("Invalid material blending ".concat(t.blending,", ").concat(this.stringify(t))),this.checkMatSide(t.side)||console.error("Invalid material side ".concat(t.side,", ").concat(this.stringify(t))),t.blending===e.spec.MaterialBlending.masked&&void 0===t.alphaCutOff&&console.error("Material alphaCutOff is required for mask, ".concat(this.stringify(t))),this.checkNumber01Undef(t.alphaCutOff)||console.error("Invalid material alphaCutOff ".concat(t.alphaCutOff,", ").concat(this.stringify(t)))):t.type===e.spec.MaterialType.pbr?(this.checkString(t.name)||console.error("Invalid material name ".concat(t.name,", ").concat(this.stringify(t))),this.checkNonnegative4(t.baseColorFactor)||console.error("Invalid material baseColorFactor ".concat(t.baseColorFactor,", ").concat(this.stringify(t))),this.checkTextureUndef(t.baseColorTexture)||console.error("Invalid material baseColorTexture ".concat(t.baseColorTexture,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform ".concat(t.baseColorTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate ".concat(t.baseColorTextureCoordinate,", ").concat(this.stringify(t))),this.checkBooleanUndef(t.useSpecularAA)||console.error("Invalid material useSpecularAA ".concat(t.useSpecularAA,", ").concat(this.stringify(t))),this.checkNumber01(t.metallicFactor)||console.error("Invalid material metallicFactor ".concat(t.metallicFactor,", ").concat(this.stringify(t))),this.checkNonnegative(t.roughnessFactor)||console.error("Invalid material roughnessFactor ".concat(t.roughnessFactor,", ").concat(this.stringify(t))),this.checkTextureUndef(t.metallicRoughnessTexture)||console.error("Invalid material metallicRoughnessTexture ".concat(t.metallicRoughnessTexture,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.metallicRoughnessTextureTransform)||console.error("Invalid material metallicRoughnessTextureTransform ".concat(t.metallicRoughnessTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.metallicRoughnessTextureCoordinate)||console.error("Invalid material metallicRoughnessTextureCoordinate ".concat(t.metallicRoughnessTextureCoordinate,", ").concat(this.stringify(t))),this.checkTextureUndef(t.normalTexture)||console.error("Invalid material normalTexture ".concat(t.normalTexture,", ").concat(this.stringify(t))),this.checkNonnegativeUndef(t.normalTextureScale)||console.error("Invalid material normalTextureScale ".concat(t.normalTextureScale,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.normalTextureTransform)||console.error("Invalid material normalTextureTransform ".concat(t.normalTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.normalTextureCoordinate)||console.error("Invalid material normalTextureCoordinate ".concat(t.normalTextureCoordinate,", ").concat(this.stringify(t))),this.checkTextureUndef(t.occlusionTexture)||console.error("Invalid material occlusionTexture ".concat(t.occlusionTexture,", ").concat(this.stringify(t))),this.checkNumber01Undef(t.occlusionTextureStrength)||console.error("Invalid material occlusionTextureStrength ".concat(t.occlusionTextureStrength,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.occlusionTextureTransform)||console.error("Invalid material occlusionTextureTransform ".concat(t.occlusionTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.occlusionTextureCoordinate)||console.error("Invalid material occlusionTextureCoordinate ".concat(t.occlusionTextureCoordinate,", ").concat(this.stringify(t))),this.checkNonnegative4(t.emissiveFactor)||console.error("Invalid material emissiveFactor ".concat(t.emissiveFactor,", ").concat(this.stringify(t))),this.checkNonnegative(t.emissiveIntensity)||console.error("Invalid material emissiveIntensity ".concat(t.emissiveIntensity,", ").concat(this.stringify(t))),this.checkTextureUndef(t.emissiveTexture)||console.error("Invalid material emissiveTexture ".concat(t.emissiveTexture,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.emissiveTextureTransform)||console.error("Invalid material emissiveTextureTransform ".concat(t.emissiveTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.emissiveTextureCoordinate)||console.error("Invalid material emissiveTextureCoordinate ".concat(t.emissiveTextureCoordinate,", ").concat(this.stringify(t))),this.checkBooleanUndef(t.depthMask)||console.error("Invalid material depthMask ".concat(t.depthMask,", ").concat(this.stringify(t))),this.checkMatBlending(t.blending)||console.error("Invalid material blending ".concat(t.blending,", ").concat(this.stringify(t))),this.checkMatSide(t.side)||console.error("Invalid material side ".concat(t.side,", ").concat(this.stringify(t))),t.blending===e.spec.MaterialBlending.masked&&void 0===t.alphaCutOff&&console.error("Material alphaCutOff is required for mask, ".concat(this.stringify(t))),this.checkNumber01Undef(t.alphaCutOff)||console.error("Invalid material alphaCutOff ".concat(t.alphaCutOff,", ").concat(this.stringify(t)))):console.error("Invalid material type ".concat(this.stringify(t)))},t.assertPrimOptions=function(t,e){return this.assertGeometry(t.geometry,e),this.assertMatOptions(t.material),!0},t.assertModelMeshOptions=function(t){this.checkParent(t.parent)||console.error("Invalid mesh parent ".concat(t.parent,", ").concat(this.stringify(t))),void 0!==t.skin&&this.assertModelSkinOptions(t.skin);for(var e=[],a=0;a<t.primitives.length;a++){var n=t.primitives[a];this.assertPrimOptions(n)||console.error("Invalid primitive ".concat(n,", ").concat(this.stringify(t)));var r=new le;r.create(n.geometry),e.push(r)}for(a=1;a<e.length;a++){var o=e[a-1],i=e[a];o.equals(i)||console.error("Morph states mismatch: ".concat(this.stringify(o),", ").concat(this.stringify(i),", ").concat(this.stringify(t)))}this.checkBooleanUndef(t.hide)||console.error("Invalid mesh hide ".concat(t.hide,", ").concat(this.stringify(t)))},t.assertModelCameraOptions=function(t){this.checkParent(t.parent)||console.error("Invalid camera parent ".concat(t.parent,", ").concat(this.stringify(t))),this.checkNumberUndef(t.aspect)||console.error("Invalid camera aspect ".concat(t.aspect,", ").concat(this.stringify(t))),this.checkPositive(t.near)||console.error("Invalid camera near ".concat(t.near,", ").concat(this.stringify(t))),(!this.checkPositive(t.far)||t.far<=t.near)&&console.error("Invalid camera far ".concat(t.far,", ").concat(this.stringify(t))),this.checkPositive(t.fov)||console.error("Invalid camera fov ".concat(t.fov,", ").concat(this.stringify(t))),this.checkNumber01(t.clipMode)||console.error("Invalid camera clipMode ".concat(t.clipMode,", ").concat(this.stringify(t)))},t.assertModelLightOptions=function(t){"directional"===t.lightType?(this.checkParent(t.parent)||console.error("Invalid light parent ".concat(t.parent,", ").concat(this.stringify(t))),this.checkNonnegative4(t.color)||console.error("Invalid light color ".concat(t.color,", ").concat(this.stringify(t))),this.checkNonnegative(t.intensity)||console.error("Invalid light intensity ".concat(t.intensity,", ").concat(this.stringify(t)))):"point"===t.lightType?(this.checkParent(t.parent)||console.error("Invalid light parent ".concat(t.parent,", ").concat(this.stringify(t))),this.checkNonnegative4(t.color)||console.error("Invalid light color ".concat(t.color,", ").concat(this.stringify(t))),this.checkNonnegative(t.intensity)||console.error("Invalid light intensity ".concat(t.intensity,", ").concat(this.stringify(t))),this.checkNonnegative(t.range)||console.error("Invalid light range ".concat(t.range,", ").concat(this.stringify(t)))):"spot"===t.lightType?(this.checkParent(t.parent)||console.error("Invalid light parent ".concat(t.parent,", ").concat(this.stringify(t))),this.checkNonnegative4(t.color)||console.error("Invalid light color ".concat(t.color,", ").concat(this.stringify(t))),this.checkNonnegative(t.intensity)||console.error("Invalid light intensity ".concat(t.intensity,", ").concat(this.stringify(t))),this.checkNonnegative(t.range)||console.error("Invalid light range ".concat(t.range,", ").concat(this.stringify(t))),this.checkNonnegative(t.innerConeAngle)||console.error("Invalid light innerConeAngle ".concat(t.innerConeAngle,", ").concat(this.stringify(t))),this.checkNonnegative(t.outerConeAngle)||console.error("Invalid light outerConeAngle ".concat(t.outerConeAngle,", ").concat(this.stringify(t)))):"ambient"===t.lightType?(this.checkParent(t.parent)||console.error("Invalid light parent ".concat(t.parent,", ").concat(this.stringify(t))),this.checkNonnegative4(t.color)||console.error("Invalid light color ".concat(t.color,", ").concat(this.stringify(t))),this.checkNonnegative(t.intensity)||console.error("Invalid light intensity ".concat(t.intensity,", ").concat(this.stringify(t)))):console.error("Invalid light type ".concat(this.stringify(t)))},t.assertModelSkyboxOptions=function(t){var e=this;this.checkBoolean(t.renderable)||console.error("Invalid skybox renderable ".concat(t.renderable,", ").concat(this.stringify(t))),this.checkNonnegative(t.intensity)||console.error("Invalid skybox intensity ".concat(t.intensity,", ").concat(this.stringify(t))),this.checkNonnegative(t.reflectionsIntensity)||console.error("Invalid skybox reflectionsIntensity ".concat(t.reflectionsIntensity,", ").concat(this.stringify(t)));var a=t.irradianceCoeffs;void 0!==a?(Array.isArray(a)&&9==a.length||console.error("Invalid skybox irradianceCoeffs ".concat(a,", ").concat(this.stringify(t))),a.forEach((function(t){e.checkVec3(t)||console.error("Invalid skybox irradianceCoeffs ".concat(a,", ").concat(e.stringify(t)))}))):void 0!==t.diffuseImage?this.checkTexture(t.diffuseImage)||console.error("Invalid skybox diffuseImage ".concat(t.diffuseImage,", ").concat(this.stringify(t))):console.error("Invalid skybox, irradianceCoeffs or diffuseImage should give one, ".concat(this.stringify(t))),this.checkTexture(t.specularImage)||console.error("Invalid skybox specularImage ".concat(t.specularImage,", ").concat(this.stringify(t))),this.checkPositive(t.specularImageSize)||console.error("Invalid skybox specularImageSize ".concat(t.specularImageSize,", ").concat(this.stringify(t))),this.checkPositive(t.specularMipCount)||console.error("Invalid skybox specularMipCount ".concat(t.specularMipCount,", ").concat(this.stringify(t))),this.pow2(t.specularMipCount)>t.specularImageSize&&console.error("Invalid skybox specularMipCount or specularImageSize, ".concat(this.stringify(t)))},t.checkModelAnimTrackOptions=function(t){return this.checkNonnegative(t.node)?this.checkFloat32Array(t.input)?this.checkFloat32Array(t.output)?this.checkAnimPath(t.path)?!!this.checkAnimInterp(t.interpolation)||(console.error("Invalid track interpolation ".concat(t.interpolation,", ").concat(this.stringify(t))),!1):(console.error("Invalid track path ".concat(t.path,", ").concat(this.stringify(t))),!1):(console.error("Invalid track input ".concat(t.output,", ").concat(this.stringify(t))),!1):(console.error("Invalid track input ".concat(t.input,", ").concat(this.stringify(t))),!1):(console.error("Invalid track node ".concat(t.node,", ").concat(this.stringify(t))),!1)},t.assertModelAnimOptions=function(t){var e=this;this.checkStringUndef(t.name)||console.error("Invalid animation name ".concat(t.name,", ").concat(this.stringify(t))),Array.isArray(t.tracks)||console.error("Invalid animation tracks ".concat(t.tracks,", ").concat(this.stringify(t))),t.tracks.forEach((function(a){e.checkModelAnimTrackOptions(a)||console.error("Invalid animation track ".concat(a,", ").concat(e.stringify(t)))}))},t.assertTreeOptions=function(t){var e=this;this.checkNumberUndef(t.animation)||console.error("Invalid tree animation ".concat(t.animation,", ").concat(this.stringify(t))),void 0!==t.animations&&(Array.isArray(t.animations)||console.error("Invalid tree animations ".concat(t.animations,", ").concat(this.stringify(t))),t.animations.forEach((function(t){e.assertModelAnimOptions(t)})),void 0!==t.animation&&(t.animation<-1||t.animation>=t.animations.length)&&console.error("Invalid tree animations ".concat(t.animations,", ").concat(this.stringify(t))))},t.stringify=function(t){var a={};for(var n in t)"internal"!==n&&"function"!=typeof t[n]&&(t[n]instanceof e.Texture||t[n]instanceof e.Geometry?a[n]=t[n].name:t[n]instanceof e.Renderer||(a[n]=t[n]));return JSON.stringify(a)},t.pow2=function(t){for(var e=1;t-- >0;)e*=2;return e},t}(),ie=function(){function t(t){this.size=t,this.data=new Uint16Array(t)}return t.prototype.set=function(t,e){for(var a=0;a<t.length;a++)this.data[a+e]=se(t[a])},Object.defineProperty(t.prototype,"bytes",{get:function(){return 2*this.size},enumerable:!1,configurable:!0}),t}(),se=(Yt=new Float32Array(1),Zt=new Int32Array(Yt.buffer),function(t){Yt[0]=t;var e=Zt[0],a=e>>16&32768,n=e>>12&2047,r=e>>23&255;return r<103?a:r>142?(a|=31744,a|=(255==r?0:1)&&8388607&e):r<113?a|=((n|=2048)>>114-r)+(n>>113-r&1):(a|=r-112<<10|n>>1,a+=1&n)});t.TextureDataMode=void 0,(Jt=t.TextureDataMode||(t.TextureDataMode={}))[Jt.none=0]="none",Jt[Jt.float=1]="float",Jt[Jt.half_float=2]="half_float";var ce,ue,de=function(e){function a(){var a=null!==e&&e.apply(this,arguments)||this;return a.skeleton=0,a.jointList=[],a.inverseBindMatrices=[],a.animationMatrices=[],a.textureDataMode=t.TextureDataMode.none,a}return r(a,e),a.prototype.create=function(e,a,n){var r,o;this.name=this.genName(null!==(r=e.name)&&void 0!==r?r:"Unnamed skin"),this.type=t.PObjectType.skin,this.parentItem=n,this.skeleton=null!==(o=e.skeleton)&&void 0!==o?o:-1,this.jointList=e.joints,this.animationMatrices=[],this.inverseBindMatrices=[],this.textureDataMode=this.getTextureDataMode(this.getJointCount(),a);var i=e.inverseBindMatrices;if(void 0!==i&&i.length>0){if(i.length%16!=0||i.length!==16*this.jointList.length)throw new Error("Invalid array length, inverse bind matrices ".concat(i.length,", joint array ").concat(this.jointList.length));for(var s=i.length/16,c=0;c<s;c++){var u=new ct;ct.unpack(i,16*c,u),this.inverseBindMatrices.push(u)}}},a.prototype.updateSkinMatrices=function(){var t=this;if(this.animationMatrices=[],void 0!==this.parentItem)for(var e=this.parentItem.content,a=0;a<this.jointList.length;a++){var n=this.jointList[a],r=e.getNodeById(n);if(void 0===r){console.error("Can't find joint ".concat(n," in node tree ").concat(this.parentItem,"."));break}var o=r.transform.getWorldMatrix(),i=ct.fromArray(o);this.animationMatrices.push(i)}this.animationMatrices.length===this.inverseBindMatrices.length?this.animationMatrices.forEach((function(e,a){e.multiply(t.inverseBindMatrices[a])})):(this.animationMatrices=this.inverseBindMatrices,console.error("Some error occured, replace skin animation matrices by inverse bind matrices"))},a.prototype.computeMeshAnimMatrices=function(t,e,a){var n=t.clone().inverse(),r=new ct;this.animationMatrices.forEach((function(t,o){var i=ct.multiply(n,t,r);i.data.forEach((function(t,a){return e[16*o+a]=t})),i.clone().inverse().transpose().data.forEach((function(t,e){return a[16*o+e]=t}))}))},a.prototype.updateParentItem=function(t){this.parentItem=t},a.prototype.getJointCount=function(){return this.jointList.length},a.prototype.isTextureDataMode=function(){return this.textureDataMode!==t.TextureDataMode.none},a.prototype.dispose=function(){this.parentItem=void 0,this.jointList=[],this.inverseBindMatrices=[],this.animationMatrices=[]},a.prototype.getTextureDataMode=function(e,a){var n=a.gpuCapability.detail,r=n.maxVertexUniforms-25;if(e>Math.floor(r/8)){if(n.floatTexture)return t.TextureDataMode.float;if(n.halfFloatTexture)return t.TextureDataMode.half_float;throw new Error("Too many joint count ".concat(e,", half float texture not support"))}return t.TextureDataMode.none},a}(Bt),le=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.morphWeightsLength=0,t.hasPositionMorph=!1,t.hasNormalMorph=!1,t.hasTangentMorph=!1,t}return r(a,e),a.prototype.create=function(e){var n=this;this.name=this.genName("Morph target"),this.type=t.PObjectType.morph;var r=this.getAttributeMorphCount(a.positionNameList,e),o=this.getAttributeMorphCount(a.normalNameList,e),i=this.getAttributeMorphCount(a.tangentNameList,e),s=[r,o,i];return this.morphWeightsLength=0,s.forEach((function(t){t>0&&(0===n.morphWeightsLength?n.morphWeightsLength=t:n.morphWeightsLength=Math.min(n.morphWeightsLength,t))})),this.morphWeightsLength>0&&(this.morphWeightsArray=new Float32Array(this.morphWeightsLength),this.hasPositionMorph=r==this.morphWeightsLength,this.hasNormalMorph=o==this.morphWeightsLength,this.hasTangentMorph=i==this.morphWeightsLength),r>0&&r!=this.morphWeightsLength?(console.error("Position morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(r)),!1):o>0&&o!=this.morphWeightsLength?(console.error("Normal morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(o)),!1):i>0&&i!=this.morphWeightsLength?(console.error("Tangent morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(i)),!1):!(this.morphWeightsLength>5)||(console.error("Tangent morph count should not greater than 5, current ".concat(this.morphWeightsLength)),!1)},a.prototype.dispose=function(){this.morphWeightsArray=void 0},a.prototype.initWeights=function(t){if(void 0!==this.morphWeightsArray){var e=this.morphWeightsArray;t.forEach((function(t,a){a<e.length&&(e[a]=t)}))}},a.prototype.hasMorph=function(){return this.morphWeightsLength>0&&(this.hasPositionMorph||this.hasNormalMorph||this.hasTangentMorph)},a.prototype.equals=function(t){return this.morphWeightsLength===t.morphWeightsLength&&this.hasPositionMorph===t.hasPositionMorph&&this.hasNormalMorph===t.hasNormalMorph&&this.hasTangentMorph===t.hasTangentMorph},a.prototype.getMorphWeightsArray=function(){return this.morphWeightsArray},a.prototype.getAttributeMorphCount=function(t,e){for(var a=0;a<t.length;a++){var n=t[a];if(void 0===e.getAttributeData(n))return a}return t.length},a.positionNameList=["a_Target_Position0","a_Target_Position1","a_Target_Position2","a_Target_Position3","a_Target_Position4","a_Target_Position5","a_Target_Position6","a_Target_Position7"],a.normalNameList=["a_Target_Normal0","a_Target_Normal1","a_Target_Normal2","a_Target_Normal3","a_Target_Normal4","a_Target_Normal5","a_Target_Normal6","a_Target_Normal7"],a.tangentNameList=["a_Target_Tangent0","a_Target_Tangent1","a_Target_Tangent2","a_Target_Tangent3","a_Target_Tangent4","a_Target_Tangent5","a_Target_Tangent6","a_Target_Tangent7"],a}(Bt);t.PAnimInterpType=void 0,(ce=t.PAnimInterpType||(t.PAnimInterpType={}))[ce.linear=0]="linear",ce[ce.step=1]="step",ce[ce.cubicSpline=2]="cubicSpline",t.PAnimPathType=void 0,(ue=t.PAnimPathType||(t.PAnimPathType={}))[ue.translation=0]="translation",ue[ue.rotation=1]="rotation",ue[ue.scale=2]="scale",ue[ue.weights=3]="weights";var he,fe=function(){function e(e){this.path=t.PAnimPathType.translation,this.interp=t.PAnimInterpType.linear;var a=e.node,n=e.input,r=e.output,o=e.path,i=e.interpolation;if(this.node=a,this.timeArray=n,this.dataArray=r,"translation"===o?(this.path=t.PAnimPathType.translation,this.component=3):"rotation"===o?(this.path=t.PAnimPathType.rotation,this.component=4):"scale"===o?(this.path=t.PAnimPathType.scale,this.component=3):"weights"===o?(this.path=t.PAnimPathType.weights,this.component=this.dataArray.length/this.timeArray.length,this.component<=0?console.error("Invalid weights component: ".concat(this.timeArray.length,", ").concat(this.component,", ").concat(this.dataArray.length)):this.timeArray.length*this.component!=this.dataArray.length&&console.error("Invalid weights array length: ".concat(this.timeArray.length,", ").concat(this.component,", ").concat(this.dataArray.length))):console.error("Invalid path status: ".concat(o)),this.timeArray.length*this.component>this.dataArray.length)throw new Error("Data length mismatch: ".concat(this.timeArray.length,", ").concat(this.component,", ").concat(this.dataArray.length));this.interp="LINEAR"===i?t.PAnimInterpType.linear:"STEP"===i?t.PAnimInterpType.step:t.PAnimInterpType.cubicSpline,this.sampler=m(this.getInterpInfo(),this.timeArray,this.dataArray,this.component,this.getPathInfo())}return e.prototype.dispose=function(){var t;this.timeArray=void 0,this.dataArray=void 0,null===(t=this.sampler)||void 0===t||t.dispose(),this.sampler=void 0},e.prototype.tick=function(e,a,n){var r=a.content.getNodeById(this.node);if(void 0!==this.sampler&&void 0!==r){var o=this.sampler.evaluate(e);switch(this.path){case t.PAnimPathType.translation:r.transform.setPosition(o[0],o[1],o[2]);break;case t.PAnimPathType.rotation:r.transform.setQuaternion(o[0],o[1],o[2],o[3]);break;case t.PAnimPathType.scale:r.transform.setScale(o[0],o[1],o[2]);break;case t.PAnimPathType.weights:var i=this.genParentId(a.id,this.node),s=null==n?void 0:n.queryMesh(i);void 0!==s&&s.updateMorphWeights(o)}}else void 0!==this.sampler&&console.error("AnimTrack: error",this.sampler,r)},e.prototype.getEndTime=function(){var t=this.timeArray.length-1;return this.timeArray[t]},e.prototype.genParentId=function(t,e){return"".concat(t,"^").concat(e)},e.prototype.getPathInfo=function(){return this.path===t.PAnimPathType.scale?"scale":this.path===t.PAnimPathType.rotation?"rotation":"translation"},e.prototype.getInterpInfo=function(){return this.interp===t.PAnimInterpType.cubicSpline?"CUBICSPLINE":this.interp===t.PAnimInterpType.step?"STEP":"LINEAR"},e}(),pe=function(){function t(t){this.engine=t,this.isHalfFloat=!0,this.width=0,this.height=0}return t.prototype.create=function(t,a,n){var r,o;this.width=4,this.height=t,this.isHalfFloat=a,this.isHalfFloat&&(this.buffer=new ie(4*this.getSize()));var i=null!==(o=null===(r=this.buffer)||void 0===r?void 0:r.data)&&void 0!==o?o:new Float32Array(4*this.getSize()),s=this.isHalfFloat?e.glContext.HALF_FLOAT:e.glContext.FLOAT;this.texture=e.Texture.create(this.engine,{name:n,data:{width:this.width,height:this.height,data:i},target:e.glContext.TEXTURE_2D,format:e.glContext.RGBA,type:s,wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,minFilter:e.glContext.NEAREST,magFilter:e.glContext.NEAREST})},t.prototype.update=function(t){var a,n;void 0!==this.buffer&&this.buffer.set(t,0),void 0!==this.texture&&this.texture.updateSource({sourceType:e.TextureSourceType.data,data:{width:this.width,height:this.height,data:null!==(n=null===(a=this.buffer)||void 0===a?void 0:a.data)&&void 0!==n?n:t},target:e.glContext.TEXTURE_2D})},t.prototype.dispose=function(){var t;this.engine=null,this.buffer=void 0,null===(t=this.texture)||void 0===t||t.dispose()},t.prototype.getSize=function(){return this.width*this.height},t.prototype.getTexture=function(){return this.texture},t}(),me=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.time=0,t.duration=0,t.tracks=[],t}return r(a,e),a.prototype.create=function(e){var a,n=this;this.name=this.genName(null!==(a=e.name)&&void 0!==a?a:"Unnamed animation"),this.type=t.PObjectType.animation,this.time=0,this.duration=0,this.tracks=[],e.tracks.forEach((function(t){var e=new fe(t);n.tracks.push(e),n.duration=Math.max(n.duration,e.getEndTime())}))},a.prototype.tick=function(t,e,a){this.time=t;var n=this.time%this.duration;this.tracks.forEach((function(t){t.tick(n,e,a)}))},a.prototype.dispose=function(){this.tracks.forEach((function(t){t.dispose()})),this.tracks=[]},a}(Bt),_e=function(e){function a(a,n){var r,o,i,s=e.call(this)||this;s.animation=0,s.speed=0,s.delay=0,s.time=0,s.animations=[],s.name=s.genName(null!==(r=n.name)&&void 0!==r?r:"Unnamed tree"),s.type=t.PObjectType.animationManager,s.ownerItem=n,s.animation=null!==(o=a.animation)&&void 0!==o?o:-1,s.speed=1,s.delay=null!==(i=n.delay)&&void 0!==i?i:0,s.animations=[],void 0!==a.animations&&a.animations.forEach((function(t){var e=s.createAnimation(t);s.animations.push(e)}));var c=n.composition;return null!=c&&(s.sceneManager=c.loaderData.sceneManager),s}return r(a,e),a.prototype.createAnimation=function(t){var e=new me;return e.create(t),e},a.prototype.tick=function(t){var e=this,a=t*this.speed*.001;this.time+=a;var n=this.time-this.delay;n>=0&&(this.animation>=0&&this.animation<this.animations.length?this.animations[this.animation].tick(n,this.ownerItem,this.sceneManager):-88888888==this.animation&&this.animations.forEach((function(t){t.tick(n,e.ownerItem,e.sceneManager)})))},a.prototype.dispose=function(){this.ownerItem=null,this.animations.forEach((function(t){t.dispose()})),this.animations=[],this.sceneManager=null},a.prototype.getTreeItem=function(){return this.ownerItem},a}(Bt),ge=function(){function t(t){this.engine=t,this.managers=[]}return t.prototype.create=function(t){var e=this;this.managers=[],t.forEach((function(t){var a=new _e(t.options,t);e.managers.push(a)}))},t.prototype.insert=function(t){this.managers.push(t)},t.prototype.delete=function(t){var e=-1;this.managers.forEach((function(a,n){a===t&&(e=n)})),e>=0&&this.managers.splice(e,1)},t.prototype.dispose=function(){this.managers.forEach((function(t){t.dispose()})),this.managers=[]},t}(),ye={"animation.vert.glsl":"#ifdef HAS_TARGET_POSITION0\nvsIn vec3 a_Target_Position0;\n#endif\n#ifdef HAS_TARGET_POSITION1\nvsIn vec3 a_Target_Position1;\n#endif\n#ifdef HAS_TARGET_POSITION2\nvsIn vec3 a_Target_Position2;\n#endif\n#ifdef HAS_TARGET_POSITION3\nvsIn vec3 a_Target_Position3;\n#endif\n#ifdef HAS_TARGET_POSITION4\nvsIn vec3 a_Target_Position4;\n#endif\n#ifdef HAS_TARGET_POSITION5\nvsIn vec3 a_Target_Position5;\n#endif\n#ifdef HAS_TARGET_POSITION6\nvsIn vec3 a_Target_Position6;\n#endif\n#ifdef HAS_TARGET_POSITION7\nvsIn vec3 a_Target_Position7;\n#endif\n#ifdef HAS_TARGET_NORMAL0\nvsIn vec3 a_Target_Normal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nvsIn vec3 a_Target_Normal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nvsIn vec3 a_Target_Normal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nvsIn vec3 a_Target_Normal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nvsIn vec3 a_Target_Normal4;\n#endif\n#ifdef HAS_TARGET_TANGENT0\nvsIn vec3 a_Target_Tangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\nvsIn vec3 a_Target_Tangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\nvsIn vec3 a_Target_Tangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\nvsIn vec3 a_Target_Tangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\nvsIn vec3 a_Target_Tangent4;\n#endif\n#ifdef USE_MORPHING\nuniform float u_morphWeights[WEIGHT_COUNT];\n#endif\n#ifdef HAS_JOINT_SET1\nvsIn vec4 a_Joint1;\n#endif\n#ifdef HAS_JOINT_SET2\nvsIn vec4 a_Joint2;\n#endif\n#ifdef HAS_WEIGHT_SET1\nvsIn vec4 a_Weight1;\n#endif\n#ifdef HAS_WEIGHT_SET2\nvsIn vec4 a_Weight2;\n#endif\n#ifdef USE_SKINNING\n#ifdef USE_SKINNING_TEXTURE\nuniform sampler2D u_jointMatrixSampler;uniform sampler2D u_jointNormalMatrixSampler;\n#else\nuniform mat4 u_jointMatrix[JOINT_COUNT];uniform mat4 u_jointNormalMatrix[JOINT_COUNT];\n#endif\n#endif\n#define ROW0_U ((0.5 + 0.0) / 4.0)\n#define ROW1_U ((0.5 + 1.0) / 4.0)\n#define ROW2_U ((0.5 + 2.0) / 4.0)\n#define ROW3_U ((0.5 + 3.0) / 4.0)\n#ifdef USE_SKINNING\nmat4 getJointMatrix(float boneNdx){\n#ifdef USE_SKINNING_TEXTURE\nfloat v=(boneNdx+0.5)/float(JOINT_COUNT);return mat4(texture2D(u_jointMatrixSampler,vec2(ROW0_U,v)),texture2D(u_jointMatrixSampler,vec2(ROW1_U,v)),texture2D(u_jointMatrixSampler,vec2(ROW2_U,v)),texture2D(u_jointMatrixSampler,vec2(ROW3_U,v)));\n#else\nreturn u_jointMatrix[int(boneNdx)];\n#endif\n}mat4 getJointNormalMatrix(float boneNdx){\n#ifdef USE_SKINNING_TEXTURE\nfloat v=(boneNdx+0.5)/float(JOINT_COUNT);return mat4(texture2D(u_jointNormalMatrixSampler,vec2(ROW0_U,v)),texture2D(u_jointNormalMatrixSampler,vec2(ROW1_U,v)),texture2D(u_jointNormalMatrixSampler,vec2(ROW2_U,v)),texture2D(u_jointNormalMatrixSampler,vec2(ROW3_U,v)));\n#else\nreturn u_jointNormalMatrix[int(boneNdx)];\n#endif\n}mat4 getSkinningMatrix(){mat4 skin=mat4(0);\n#if defined(HAS_WEIGHT_SET1) && defined(HAS_JOINT_SET1)\nskin+=a_Weight1.x*getJointMatrix(a_Joint1.x)+a_Weight1.y*getJointMatrix(a_Joint1.y)+a_Weight1.z*getJointMatrix(a_Joint1.z)+a_Weight1.w*getJointMatrix(a_Joint1.w);\n#endif\nreturn skin;}mat4 getSkinningNormalMatrix(){mat4 skin=mat4(0);\n#if defined(HAS_WEIGHT_SET1) && defined(HAS_JOINT_SET1)\nskin+=a_Weight1.x*getJointNormalMatrix(a_Joint1.x)+a_Weight1.y*getJointNormalMatrix(a_Joint1.y)+a_Weight1.z*getJointNormalMatrix(a_Joint1.z)+a_Weight1.w*getJointNormalMatrix(a_Joint1.w);\n#endif\nreturn skin;}\n#endif\n#ifdef USE_MORPHING\nvec4 getTargetPosition(){vec4 pos=vec4(0);\n#ifdef HAS_TARGET_POSITION0\npos.xyz+=u_morphWeights[0]*a_Target_Position0;\n#endif\n#ifdef HAS_TARGET_POSITION1\npos.xyz+=u_morphWeights[1]*a_Target_Position1;\n#endif\n#ifdef HAS_TARGET_POSITION2\npos.xyz+=u_morphWeights[2]*a_Target_Position2;\n#endif\n#ifdef HAS_TARGET_POSITION3\npos.xyz+=u_morphWeights[3]*a_Target_Position3;\n#endif\n#ifdef HAS_TARGET_POSITION4\npos.xyz+=u_morphWeights[4]*a_Target_Position4;\n#endif\nreturn pos;}vec4 getTargetNormal(){vec4 normal=vec4(0);\n#ifdef HAS_TARGET_NORMAL0\nnormal.xyz+=u_morphWeights[0]*a_Target_Normal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nnormal.xyz+=u_morphWeights[1]*a_Target_Normal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nnormal.xyz+=u_morphWeights[2]*a_Target_Normal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nnormal.xyz+=u_morphWeights[3]*a_Target_Normal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nnormal.xyz+=u_morphWeights[4]*a_Target_Normal4;\n#endif\nreturn normal;}vec4 getTargetTangent(){vec4 tangent=vec4(0);\n#ifdef HAS_TARGET_TANGENT0\ntangent.xyz+=u_morphWeights[0]*a_Target_Tangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\ntangent.xyz+=u_morphWeights[1]*a_Target_Tangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\ntangent.xyz+=u_morphWeights[2]*a_Target_Tangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\ntangent.xyz+=u_morphWeights[3]*a_Target_Tangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\ntangent.xyz+=u_morphWeights[4]*a_Target_Tangent4;\n#endif\nreturn tangent;}\n#endif\n","extensions.frag.glsl":"vec3 _dFdx(vec3 coord){\n#if defined(GL_OES_standard_derivatives) || defined(WEBGL2)\nreturn dFdx(coord);\n#endif\nreturn vec3(0.0);}vec3 _dFdy(vec3 coord){\n#if defined(GL_OES_standard_derivatives) || defined(WEBGL2)\nreturn dFdy(coord);\n#endif\nreturn vec3(0.0);}\n#ifdef USE_TEX_LOD\nvec4 _textureCubeLodEXT(samplerCube sampler,vec3 coord,float lod){\n#if defined(WEBGL2) || defined(GL_EXT_shader_texture_lod)\nreturn textureCubeLodEXT(sampler,coord,lod);\n#else\nreturn textureCube(sampler,coord,lod);\n#endif\n}\n#endif\n","tonemapping.frag.glsl":"uniform float u_Exposure;const float GAMMA=2.2;const float INV_GAMMA=1.0/GAMMA;vec3 LINEARtoSRGB(vec3 color){return pow(color,vec3(INV_GAMMA));}vec4 SRGBtoLINEAR(vec4 srgbIn){return vec4(pow(srgbIn.xyz,vec3(GAMMA)),srgbIn.w);}vec3 toneMapUncharted2Impl(vec3 color){const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;return((color*(A*color+C*B)+D*E)/(color*(A*color+B)+D*F))-E/F;}vec3 toneMapUncharted(vec3 color){const float W=11.2;color=toneMapUncharted2Impl(color*2.0);vec3 whiteScale=1.0/toneMapUncharted2Impl(vec3(W));return LINEARtoSRGB(color*whiteScale);}vec3 toneMapHejlRichard(vec3 color){color=max(vec3(0.0),color-vec3(0.004));return(color*(6.2*color+.5))/(color*(6.2*color+1.7)+0.06);}vec3 toneMapACES(vec3 color){const float A=2.51;const float B=0.03;const float C=2.43;const float D=0.59;const float E=0.14;return LINEARtoSRGB(clamp((color*(A*color+B))/(color*(C*color+D)+E),0.0,1.0));}vec3 toneMap(vec3 color){color*=u_Exposure;\n#ifdef TONEMAP_UNCHARTED\nreturn toneMapUncharted(color);\n#endif\n#ifdef TONEMAP_HEJLRICHARD\nreturn toneMapHejlRichard(color);\n#endif\n#ifdef TONEMAP_ACES\nreturn toneMapACES(color);\n#endif\nreturn LINEARtoSRGB(color);}","textures.vert.glsl":"fsIn vec2 v_UVCoord1;fsIn vec2 v_UVCoord2;\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D u_NormalSampler;uniform float u_NormalScale;uniform int u_NormalUVSet;uniform mat3 u_NormalUVTransform;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D u_EmissiveSampler;uniform int u_EmissiveUVSet;uniform vec3 u_EmissiveFactor;uniform mat3 u_EmissiveUVTransform;\n#endif\n#ifdef HAS_EMISSIVE\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_OCCLUSION_MAP\nuniform sampler2D u_OcclusionSampler;uniform int u_OcclusionUVSet;uniform float u_OcclusionStrength;uniform mat3 u_OcclusionUVTransform;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nuniform sampler2D u_BaseColorSampler;uniform int u_BaseColorUVSet;uniform mat3 u_BaseColorUVTransform;\n#endif\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nuniform sampler2D u_MetallicRoughnessSampler;uniform int u_MetallicRoughnessUVSet;uniform mat3 u_MetallicRoughnessUVTransform;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D u_DiffuseSampler;uniform int u_DiffuseUVSet;uniform mat3 u_DiffuseUVTransform;\n#endif\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nuniform sampler2D u_SpecularGlossinessSampler;uniform int u_SpecularGlossinessUVSet;uniform mat3 u_SpecularGlossinessUVTransform;\n#endif\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;uniform samplerCube u_SpecularEnvSampler;uniform sampler2D u_brdfLUT;uniform vec2 u_IblIntensity;\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients u_shCoefficients;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform sampler2D u_ShadowSampler;\n#endif\nvec2 getNormalUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_NORMAL_MAP\nuv.xy=u_NormalUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_NORMAL_UV_TRANSFORM\nuv*=u_NormalUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getEmissiveUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_EMISSIVE_MAP\nuv.xy=u_EmissiveUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_EMISSIVE_UV_TRANSFORM\nuv*=u_EmissiveUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getOcclusionUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_OCCLUSION_MAP\nuv.xy=u_OcclusionUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_OCCLUSION_UV_TRANSFORM\nuv*=u_OcclusionUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getBaseColorUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_BASE_COLOR_MAP\nuv.xy=u_BaseColorUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_BASECOLOR_UV_TRANSFORM\nuv*=u_BaseColorUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getMetallicRoughnessUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nuv.xy=u_MetallicRoughnessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_METALLICROUGHNESS_UV_TRANSFORM\nuv*=u_MetallicRoughnessUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getSpecularGlossinessUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nuv.xy=u_SpecularGlossinessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_SPECULARGLOSSINESS_UV_TRANSFORM\nuv*=u_SpecularGlossinessUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getDiffuseUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_DIFFUSE_MAP\nuv.xy=u_DiffuseUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_DIFFUSE_UV_TRANSFORM\nuv*=u_DiffuseUVTransform;\n#endif\n#endif\nreturn uv.xy;}","functions.frag.glsl":"const float M_PI=3.141592653589793;const float c_MinReflectance=0.04;fsIn vec3 v_Position;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nfsIn mat3 v_TBN;\n#else\nfsIn vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nfsIn vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nfsIn vec4 v_Color;\n#endif\nstruct AngularInfo{float NdotL;float NdotV;float NdotH;float LdotH;float VdotH;vec3 padding;};vec4 getVertexColor(){vec4 color=vec4(1.0,1.0,1.0,1.0);\n#ifdef HAS_VERTEX_COLOR_VEC3\ncolor.rgb=v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\ncolor=v_Color;\n#endif\nreturn color;}vec3 getNormal(){vec2 UV=getNormalUV();\n#ifndef HAS_TANGENTS\nvec3 pos_dx=_dFdx(v_Position);vec3 pos_dy=_dFdy(v_Position);vec3 tex_dx=_dFdx(vec3(UV,0.0));vec3 tex_dy=_dFdy(vec3(UV,0.0));vec3 t=(tex_dy.t*pos_dx-tex_dx.t*pos_dy)/(tex_dx.s*tex_dy.t-tex_dy.s*tex_dx.t);\n#ifdef HAS_NORMALS\nvec3 ng=normalize(v_Normal);\n#else\nvec3 ng=cross(pos_dx,pos_dy);\n#endif\nt=normalize(t-ng*dot(ng,t));vec3 b=normalize(cross(ng,t));mat3 tbn=mat3(t,b,ng);\n#else\nmat3 tbn=v_TBN;\n#endif\n#ifdef HAS_NORMAL_MAP\nvec3 n=texture2D(u_NormalSampler,UV).rgb;n=normalize(tbn*((2.0*n-1.0)*vec3(u_NormalScale,u_NormalScale,1.0)));\n#else\nvec3 n=normalize(tbn[2].xyz);\n#endif\n#ifdef DOUBLE_SIDED\nfloat faceDirection=gl_FrontFacing ? 1.0 :-1.0;n=n*faceDirection;\n#endif\nreturn n;}float getPerceivedBrightness(vec3 vector){return sqrt(0.299*vector.r*vector.r+0.587*vector.g*vector.g+0.114*vector.b*vector.b);}float solveMetallic(vec3 diffuse,vec3 specular,float oneMinusSpecularStrength){float specularBrightness=getPerceivedBrightness(specular);if(specularBrightness<c_MinReflectance){return 0.0;}float diffuseBrightness=getPerceivedBrightness(diffuse);float a=c_MinReflectance;float b=diffuseBrightness*oneMinusSpecularStrength/(1.0-c_MinReflectance)+specularBrightness-2.0*c_MinReflectance;float c=c_MinReflectance-specularBrightness;float D=b*b-4.0*a*c;return clamp((-b+sqrt(D))/(2.0*a),0.0,1.0);}AngularInfo getAngularInfo(vec3 pointToLight,vec3 normal,vec3 view){vec3 n=normalize(normal);vec3 v=normalize(view);vec3 l=normalize(pointToLight);vec3 h=normalize(l+v);float NdotL=clamp(dot(n,l),0.0,1.0);float NdotV=clamp(dot(n,v),0.0,1.0);float NdotH=clamp(dot(n,h),0.0,1.0);float LdotH=clamp(dot(l,h),0.0,1.0);float VdotH=clamp(dot(v,h),0.0,1.0);return AngularInfo(NdotL,NdotV,NdotH,LdotH,VdotH,vec3(0,0,0));}float getAARoughnessFactor(vec3 normal){vec3 dxy=max(abs(_dFdx(normal)),abs(_dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z)*2.0;}\n#ifdef DEBUG_UV\nuniform float u_DebugUVGridSize;float getDebugUVColor(vec2 uv,vec3 n){float s=dot(abs(n),vec3(1,1,1))*0.6;uv=uv/(u_DebugUVGridSize*2.0);uv=uv-floor(uv);uv=uv*2.0-vec2(1.0);return s*(uv.x*uv.y>=0.0 ? 0.2: 1.0);}\n#endif\n","shadow.frag.glsl":"#ifdef USE_SHADOW_MAPPING\nuniform vec2 u_ShadowMapSizeInv;fsIn vec4 v_PositionLightSpace;fsIn vec4 v_dPositionLightSpace;\n#endif\nfloat linstep(float low,float high,float v){return clamp((v-low)/(high-low),0.0,1.0);}\n#ifdef USE_SHADOW_MAPPING\nfloat chebyshev(vec2 moments,float depth,float minVar){float p=step(depth,moments.x+SHADOWMAP_BAIS);float variance=max(moments.y-moments.x*moments.x,minVar);float d=depth-(moments.x+SHADOWMAP_BAIS);float pMax=linstep(0.2,1.0,variance/(variance+d*d));return mix(0.1,1.0,min(max(p,pMax),1.0));}float getShadowContributionSM(){vec3 coords=v_PositionLightSpace.xyz/v_PositionLightSpace.w*0.5+0.5;if(coords.z<0.01||coords.z>0.99||coords.x<0.01||coords.x>0.99||coords.y<0.01||coords.y>0.99){return 1.0;}vec2 moments=vec2(1.0)-texture2D(u_ShadowSampler,coords.xy).xy;return coords.z<moments.x*1.008+0.008? 1.0: 0.2;}float getShadowContributionVSM(){vec3 coords=v_PositionLightSpace.xyz/v_PositionLightSpace.w*0.5+0.5;if(coords.z<0.01||coords.z>0.99||coords.x<0.01||coords.x>0.99||coords.y<0.01||coords.y>0.99){return 1.0;}vec2 moments=vec2(1.0)-texture2D(u_ShadowSampler,coords.xy).xy;return chebyshev(moments,coords.z,0.00002);}float computeEVSMShadow(vec2 coords,float pos,float neg){vec4 moments=texture2D(u_ShadowSampler,coords);float posShadow=chebyshev(moments.xy,pos,0.00002);float negShadow=chebyshev(moments.zw,neg,0.00002);return min(posShadow,negShadow);}float getShadowContributionEVSM(){vec3 coords=v_PositionLightSpace.xyz/v_PositionLightSpace.w*0.5+0.5;if(coords.z<0.01||coords.z>0.99||coords.x<0.01||coords.x>0.99||coords.y<0.01||coords.y>0.99){return 1.0;}float depth=coords.z;float pos=EVSM_FUNC0(depth);float neg=EVSM_FUNC1(depth);\n#ifdef SHADOWMAP_EVSM_PCF\nvec2 newCoords=v_dPositionLightSpace.xy/v_dPositionLightSpace.w*0.5+0.5;vec2 dCoords=min(abs(newCoords-coords.xy),u_ShadowMapSizeInv);if(max(dCoords.x,dCoords.y)>=min(u_ShadowMapSizeInv.x,u_ShadowMapSizeInv.y)*0.5){vec2 coords0=coords.xy+vec2(-1.0,-1.0)*dCoords;vec2 coords1=coords.xy+vec2(-1.0,1.0)*dCoords;vec2 coords2=coords.xy+vec2(1.0,-1.0)*dCoords;vec2 coords3=coords.xy+vec2(1.0,1.0)*dCoords;float shadow0=computeEVSMShadow(coords0,pos,neg);float shadow1=computeEVSMShadow(coords1,pos,neg);float shadow2=computeEVSMShadow(coords2,pos,neg);float shadow3=computeEVSMShadow(coords3,pos,neg);return(shadow0+shadow1+shadow2+shadow3)*0.25;}else{return computeEVSMShadow(coords.xy,pos,neg);}\n#else\nreturn computeEVSMShadow(coords.xy,pos,neg);\n#endif\n}float getShadowContribution(){\n#if defined(SHADOWMAP_STANDARD)\nreturn getShadowContributionSM();\n#elif defined(SHADOWMAP_VSM)\nreturn getShadowContributionVSM();\n#else\nreturn getShadowContributionEVSM();\n#endif\n}\n#endif\n","webglCompatibility.glsl":"#ifdef WEBGL2\n#define vsIn in\n#define vsOut out\n#define fsIn in\n#define fsOut out\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\n#else\n#define vsIn attribute\n#define vsOut varying\n#define fsIn varying\n#define fsOut varying\n#endif\n","shadowCommon.vert.glsl":"\n#define SHADOWMAP_BAIS 0.001\n#define EVSM_FUNC0(DEPTH) -exp(-7.0 * DEPTH)\n#define EVSM_FUNC1(DEPTH) -exp(-6.0 * DEPTH)\n"};!function(t){t.build=function(t,e,a){for(var n;null!==(n=/#include <(.+)>/gm.exec(t));)t=t.replace(n[0],ye[n[1]]);return t=t.replace(/#define FEATURES/,e.map((function(t){return"#define ".concat(t)})).join("\n")),a?"#version 300 es\n"+t:"#version 100\n"+t}}(he||(he={}));var ve=function(){function e(){}return e.getVertexShaderCode=function(e){var a=e.isWebGL2,n=e.featureList,r=e.material.materialType;switch(r){case t.PMaterialType.unlit:case t.PMaterialType.pbr:case t.PMaterialType.shadowBase:return he.build("precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\n#include <animation.vert.glsl>\nvsIn vec4 a_Position;vsOut vec3 v_Position;\n#ifdef HAS_NORMALS\nvsIn vec4 a_Normal;\n#endif\n#ifdef HAS_TANGENTS\nvsIn vec4 a_Tangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvsOut mat3 v_TBN;\n#else\nvsOut vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nvsIn vec2 a_UV1;\n#endif\n#ifdef HAS_UV_SET2\nvsIn vec2 a_UV2;\n#endif\nvsOut vec2 v_UVCoord1;vsOut vec2 v_UVCoord2;\n#ifdef HAS_VERTEX_COLOR_VEC3\nvsIn vec3 a_Color;vsOut vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nvsIn vec4 a_Color;vsOut vec4 v_Color;\n#endif\nuniform mat4 u_ViewProjectionMatrix;uniform mat4 u_ModelMatrix;uniform mat4 u_NormalMatrix;\n#ifdef EDITOR_TRANSFORM\nuniform vec4 uEditorTransform;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform mat4 u_LightViewProjectionMatrix;uniform float u_DeltaSceneSize;vsOut vec4 v_PositionLightSpace;vsOut vec4 v_dPositionLightSpace;\n#endif\nvec4 getPosition(){vec4 pos=vec4(a_Position.xyz,1.0);\n#ifdef USE_MORPHING\npos+=getTargetPosition();\n#endif\n#ifdef USE_SKINNING\npos=getSkinningMatrix()*pos;\n#endif\nreturn pos;}\n#ifdef HAS_NORMALS\nvec4 getNormal(){vec4 normal=a_Normal;\n#ifdef USE_MORPHING\nnormal+=getTargetNormal();\n#endif\n#ifdef USE_SKINNING\nnormal=getSkinningNormalMatrix()*normal;\n#endif\nreturn normalize(normal);}\n#endif\n#ifdef HAS_TANGENTS\nvec4 getTangent(){vec4 tangent=a_Tangent;\n#ifdef USE_MORPHING\ntangent+=getTargetTangent();\n#endif\n#ifdef USE_SKINNING\ntangent=getSkinningMatrix()*tangent;\n#endif\nreturn normalize(tangent);}\n#endif\nvoid main(){vec4 pos=u_ModelMatrix*getPosition();v_Position=vec3(pos.xyz)/pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec4 tangent=getTangent();vec3 normalW=normalize(vec3(u_NormalMatrix*vec4(getNormal().xyz,0.0)));vec3 tangentW=normalize(vec3(u_ModelMatrix*vec4(tangent.xyz,0.0)));vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\n#else\nv_Normal=normalize(vec3(u_NormalMatrix*vec4(getNormal().xyz,0.0)));\n#endif\n#endif\nv_UVCoord1=vec2(0.0,0.0);v_UVCoord2=vec2(0.0,0.0);\n#ifdef HAS_UV_SET1\nv_UVCoord1=a_UV1;\n#endif\n#ifdef HAS_UV_SET2\nv_UVCoord2=a_UV2;\n#endif\n#if defined(HAS_VERTEX_COLOR_VEC3) || defined(HAS_VERTEX_COLOR_VEC4)\nv_Color=a_Color;\n#endif\n#ifdef USE_SHADOW_MAPPING\nv_PositionLightSpace=u_LightViewProjectionMatrix*pos;vec3 dpos=vec3(u_DeltaSceneSize);v_dPositionLightSpace=u_LightViewProjectionMatrix*(pos+vec4(dpos,0));\n#endif\ngl_Position=u_ViewProjectionMatrix*pos;\n#ifdef EDITOR_TRANSFORM\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}",n,a);case t.PMaterialType.skyboxFilter:return he.build("precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\nvsIn vec3 a_Position;vsOut vec3 v_CameraDir;uniform mat4 u_InvViewProjectionMatrix;void main(){vec4 dir=u_InvViewProjectionMatrix*vec4(a_Position.xy,1,1);v_CameraDir=normalize(dir.xyz/dir.w);gl_Position=vec4(a_Position.xy,0.99999,1);}",n,a);default:throw new Error("Invalid material type ".concat(r," for getVertexShaderString!"))}},e.getFragmentShaderCode=function(e){var a=e.isWebGL2,n=e.featureList,r=e.material.materialType;switch(r){case t.PMaterialType.unlit:case t.PMaterialType.pbr:return he.build("\n#define FEATURES\n#ifndef WEBGL2\n#extension GL_OES_standard_derivatives : enable\n#endif\n#if !defined(WEBGL2) && defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef USE_HDR\n#extension GL_OES_texture_float : enable\n#extension GL_OES_texture_float_linear : enable\n#endif\n#if !defined(WEBGL2) && defined(USE_WBOIT)\n#extension GL_EXT_draw_buffers: require\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\n#ifdef USE_WBOIT\nlayout(location=0)out vec4 outFragColor0;layout(location=1)out vec4 outFragColor1;\n#else\nout vec4 outFragColor;\n#endif\n#else\n#ifdef USE_WBOIT\n#define outFragColor0 gl_FragData[0]\n#define outFragColor1 gl_FragData[1]\n#else\n#define outFragColor gl_FragColor\n#endif\n#endif\n#include <webglCompatibility.glsl>\n#include <extensions.frag.glsl>\n#include <tonemapping.frag.glsl>\n#include <textures.vert.glsl>\n#include <functions.frag.glsl>\n#include <shadowCommon.vert.glsl>\n#include <shadow.frag.glsl>\nstruct Light{vec3 direction;float range;vec3 color;float intensity;vec3 position;float innerConeCos;float outerConeCos;int type;vec2 padding;};const int LightType_Directional=0;const int LightType_Point=1;const int LightType_Spot=2;const int LightType_Ambient=3;\n#ifdef USE_PUNCTUAL\nuniform Light u_Lights[LIGHT_COUNT];\n#endif\n#if defined(MATERIAL_SPECULARGLOSSINESS) || defined(MATERIAL_METALLICROUGHNESS)\nuniform float u_MetallicFactor;uniform float u_RoughnessFactor;uniform vec4 u_BaseColorFactor;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\nuniform vec3 u_SpecularFactor;uniform vec4 u_DiffuseFactor;uniform float u_GlossinessFactor;\n#endif\n#ifdef ALPHAMODE_MASK\nuniform float u_AlphaCutoff;\n#endif\n#ifdef ADD_FOG\nuniform vec4 u_FogColor;\n#ifdef LINEAR_FOG\nuniform float u_FogNear;uniform float u_FogFar;\n#endif\n#ifdef EXP_FOG\nuniform float u_FogDensity;\n#endif\n#endif\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\nuniform vec3 u_Camera;uniform int u_MipCount;struct MaterialInfo{float perceptualRoughness;vec3 reflectance0;float alphaRoughness;vec3 diffuseColor;vec3 reflectance90;vec3 specularColor;};\n#ifdef ADD_FOG\nvec3 getMixFogColor(vec3 baseColor){vec3 distance=u_Camera-v_Position;float fogAmount=0.0;\n#ifdef LINEAR_FOG\nfogAmount=smoothstep(u_FogNear,u_FogFar,distance[2]);\n#endif\n#ifdef EXP_FOG\n#define LOG2 1.442695\nfogAmount=1.-exp2(-u_FogDensity*u_FogDensity*distance[2]*distance[2]*LOG2);fogAmount=clamp(fogAmount,0.,1.);\n#endif\nvec3 mixColor=baseColor.rgb+(vec3(u_FogColor)-baseColor.rgb)*fogAmount;return mixColor;}\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 getIrradiance(vec3 norm,SHCoefficients c){float x=norm.x;float y=norm.y;float z=norm.z;float c1=0.429043;float c2=0.511664;float c3=0.743125;float c4=0.886227;float c5=0.247708;vec3 irradiance=c1*c.l22*(x*x-y*y)+c3*c.l20*(z*z)+c4*c.l00-c5*c.l20+2.0*c1*(c.l2m2*x*y+c.l21*x*z+c.l2m1*y*z)+2.0*c2*(c.l11*x+c.l1m1*y+c.l10*z);return irradiance;}\n#endif\n#ifdef USE_IBL\nvec3 getIBLContribution(MaterialInfo materialInfo,vec3 n,vec3 v){float NdotV=clamp(dot(n,v),0.0,1.0);float lod=clamp(materialInfo.perceptualRoughness*float(u_MipCount),0.0,float(u_MipCount));vec3 reflection=normalize(reflect(-v,n));vec2 brdfSamplePoint=clamp(vec2(NdotV,materialInfo.perceptualRoughness),vec2(0.0,0.0),vec2(1.0,1.0));vec2 brdf=texture2D(u_brdfLUT,brdfSamplePoint).rg;vec4 diffuseColor=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,u_shCoefficients);diffuseColor=vec4(irradiance,1.0);\n#else\ndiffuseColor=textureCube(u_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(u_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(u_SpecularEnvSampler,reflection,lod);\n#endif\n#ifdef USE_HDR\nvec3 diffuseLight=diffuseColor.rgb;vec3 specularLight=specularSample.rgb;\n#else\nvec3 diffuseLight=SRGBtoLINEAR(diffuseColor).rgb;vec3 specularLight=SRGBtoLINEAR(specularSample).rgb;\n#endif\nvec3 diffuse=diffuseLight*materialInfo.diffuseColor;vec3 specular=specularLight*(materialInfo.specularColor*brdf.x+brdf.y);return diffuse*u_IblIntensity[0]+specular*u_IblIntensity[1];}\n#endif\nvec3 diffuse(MaterialInfo materialInfo){return materialInfo.diffuseColor/M_PI;}vec3 specularReflection(MaterialInfo materialInfo,AngularInfo angularInfo){return materialInfo.reflectance0+(materialInfo.reflectance90-materialInfo.reflectance0)*pow(clamp(1.0-angularInfo.VdotH,0.0,1.0),5.0);}float visibilityOcclusion(MaterialInfo materialInfo,AngularInfo angularInfo){float NdotL=angularInfo.NdotL;float NdotV=angularInfo.NdotV;float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGX=GGXV+GGXL;if(GGX>0.0){return 0.5/GGX;}return 0.0;}float microfacetDistribution(MaterialInfo materialInfo,AngularInfo angularInfo){float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float f=(angularInfo.NdotH*alphaRoughnessSq-angularInfo.NdotH)*angularInfo.NdotH+1.0;return alphaRoughnessSq/(M_PI*f*f);}vec3 getPointShade(vec3 pointToLight,MaterialInfo materialInfo,vec3 normal,vec3 view){AngularInfo angularInfo=getAngularInfo(pointToLight,normal,view);if(angularInfo.NdotL>0.0||angularInfo.NdotV>0.0){vec3 F=specularReflection(materialInfo,angularInfo);float Vis=visibilityOcclusion(materialInfo,angularInfo);float D=microfacetDistribution(materialInfo,angularInfo);vec3 diffuseContrib=(1.0-F)*diffuse(materialInfo);vec3 specContrib=F*Vis*D;return angularInfo.NdotL*(diffuseContrib+specContrib);}return vec3(0.0,0.0,0.0);}float getRangeAttenuation(float range,float distance){if(range<=0.0){return 1.0;}return 1.0/(pow(5.0*distance/range,2.0)+1.0);}float getSpotAttenuation(vec3 pointToLight,vec3 spotDirection,float outerConeCos,float innerConeCos){float actualCos=dot(normalize(spotDirection),normalize(-pointToLight));if(actualCos>outerConeCos){if(actualCos<innerConeCos){return smoothstep(outerConeCos,innerConeCos,actualCos);}return 1.0;}return 0.0;}vec3 applyDirectionalLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=-light.direction;vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return light.intensity*light.color*shade;}vec3 applyPointLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float attenuation=getRangeAttenuation(light.range,distance);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view);return light.color*shade*attenuation*light.intensity;}vec3 applySpotLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float rangeAttenuation=getRangeAttenuation(light.range,distance);float spotAttenuation=getSpotAttenuation(pointToLight,light.direction,light.outerConeCos,light.innerConeCos);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return rangeAttenuation*spotAttenuation*light.intensity*light.color*shade;}vec3 applyAmbientLight(Light light,MaterialInfo materialInfo){return light.intensity*light.color*diffuse(materialInfo);}float weight(float z,float a){return clamp(pow(min(1.0,a*10.0)+0.01,3.0)*1e8*pow(1.0-z*0.9,3.0),1e-2,3e3);}void writeFragmentColor(vec4 fragColor){\n#if !defined(ALPHAMODE_OPAQUE) && defined(USE_WBOIT)\nfloat w=weight(gl_FragCoord.z,fragColor.a);fragColor.rgb*=fragColor.a;outFragColor0=vec4(fragColor.rgb*w,fragColor.a);outFragColor1=vec4(fragColor.a*w);\n#else\noutFragColor=fragColor;\n#endif\n}void main(){float perceptualRoughness=0.0;float metallic=0.0;vec4 baseColor=vec4(0.0,0.0,0.0,1.0);vec3 diffuseColor=vec3(0.0);vec3 specularColor=vec3(0.0);vec3 f0=vec3(0.04);\n#ifdef PREVIEW_BORDER\nwriteFragmentColor(uPreviewColor);return;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nvec4 sgSample=SRGBtoLINEAR(texture2D(u_SpecularGlossinessSampler,getSpecularGlossinessUV()));perceptualRoughness=(1.0-sgSample.a*u_GlossinessFactor);f0=sgSample.rgb*u_SpecularFactor;\n#else\nf0=u_SpecularFactor;perceptualRoughness=1.0-u_GlossinessFactor;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nbaseColor=SRGBtoLINEAR(texture2D(u_DiffuseSampler,getDiffuseUV()))*u_DiffuseFactor;\n#else\nbaseColor=SRGBtoLINEAR(u_DiffuseFactor);\n#endif\nbaseColor*=getVertexColor();specularColor=f0;float oneMinusSpecularStrength=1.0-max(max(f0.r,f0.g),f0.b);diffuseColor=baseColor.rgb*oneMinusSpecularStrength;\n#ifdef DEBUG_METALLIC\nmetallic=solveMetallic(baseColor.rgb,specularColor,oneMinusSpecularStrength);\n#endif\n#endif\n#ifdef MATERIAL_METALLICROUGHNESS\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nvec4 mrSample=texture2D(u_MetallicRoughnessSampler,getMetallicRoughnessUV());perceptualRoughness=mrSample.g*u_RoughnessFactor;metallic=mrSample.b*u_MetallicFactor;\n#else\nmetallic=u_MetallicFactor;perceptualRoughness=u_RoughnessFactor;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nbaseColor=SRGBtoLINEAR(texture2D(u_BaseColorSampler,getBaseColorUV()))*u_BaseColorFactor;\n#else\nbaseColor=SRGBtoLINEAR(u_BaseColorFactor);\n#endif\nbaseColor*=getVertexColor();diffuseColor=baseColor.rgb*(vec3(1.0)-f0)*(1.0-metallic);specularColor=mix(f0,baseColor.rgb,metallic);\n#endif\n#ifdef ALPHAMODE_MASK\nif(baseColor.a<u_AlphaCutoff){discard;}baseColor.a=1.0;\n#endif\n#ifdef ALPHAMODE_OPAQUE\nbaseColor.a=1.0;\n#endif\n#ifdef MATERIAL_UNLIT\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec3 mixColor=getMixFogColor(baseColor.rgb);vec4 fragColorUnlit=vec4(LINEARtoSRGB(mixColor)*baseColor.a,baseColor.a);\n#else\nvec4 fragColorUnlit=vec4(LINEARtoSRGB(baseColor.rgb)*baseColor.a,baseColor.a);\n#endif\nwriteFragmentColor(fragColorUnlit);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),getNormal()));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=getNormal()*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\noutFragColor.rgb=vec3(1.0);\n#endif\n#ifdef DEBUG_EMISSIVE\noutFragColor.rgb=vec3(0.0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\nreturn;\n#endif\nmetallic=clamp(metallic,0.0,1.0);float alphaRoughness=perceptualRoughness*perceptualRoughness;vec3 normal=getNormal();\n#ifdef USE_SPECULAR_AA\nfloat AARoughnessFactor=getAARoughnessFactor(normal);perceptualRoughness+=AARoughnessFactor;alphaRoughness+=AARoughnessFactor;\n#endif\nperceptualRoughness=clamp(perceptualRoughness,0.04,1.0);alphaRoughness=clamp(alphaRoughness,0.04,1.0);float reflectance=max(max(specularColor.r,specularColor.g),specularColor.b);vec3 specularEnvironmentR0=specularColor.rgb;vec3 specularEnvironmentR90=vec3(clamp(reflectance*50.0,0.0,1.0));MaterialInfo materialInfo=MaterialInfo(perceptualRoughness,specularEnvironmentR0,alphaRoughness,diffuseColor,specularEnvironmentR90,specularColor);vec3 color=vec3(0.0,0.0,0.0);vec3 view=normalize(u_Camera-v_Position);float shadow=1.0;\n#ifdef USE_SHADOW_MAPPING\nshadow=getShadowContribution();\n#endif\n#ifdef USE_PUNCTUAL\nfor(int i=0;i<LIGHT_COUNT;++i){Light light=u_Lights[i];if(light.type==LightType_Directional){color+=applyDirectionalLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Point){color+=applyPointLight(light,materialInfo,normal,view);}else if(light.type==LightType_Spot){color+=applySpotLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Ambient){color+=applyAmbientLight(light,materialInfo);}}\n#endif\n#ifdef USE_IBL\ncolor+=getIBLContribution(materialInfo,normal,view);\n#endif\nfloat ao=1.0;\n#ifdef HAS_OCCLUSION_MAP\nao=texture2D(u_OcclusionSampler,getOcclusionUV()).r;color=mix(color,color*ao,u_OcclusionStrength);\n#endif\nvec3 emissive=vec3(0);\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec4 toneMapColor=SRGBtoLINEAR(vec4(toneMap(color),baseColor.a));color=getMixFogColor(toneMapColor.rgb);vec4 fragColorOut=vec4(LINEARtoSRGB(color.rgb)*baseColor.a,baseColor.a);\n#else\ncolor=toneMap(color)*baseColor.a;\n#ifdef HAS_EMISSIVE\ncolor+=u_EmissiveFactor;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(u_EmissiveSampler,getEmissiveUV())).rgb*u_EmissiveFactor;color+=emissive;\n#endif\nvec4 fragColorOut=vec4(color,baseColor.a);\n#endif\nwriteFragmentColor(fragColorOut);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),normal));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=normal*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\n#ifdef HAS_OCCLUSION_MAP\noutFragColor.rgb=vec3(mix(1.0,ao,u_OcclusionStrength));\n#else\noutFragColor.rgb=vec3(1.0);\n#endif\n#endif\n#ifdef DEBUG_EMISSIVE\n#ifdef HAS_EMISSIVE\nemissive=u_EmissiveFactor;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(u_EmissiveSampler,getEmissiveUV())).rgb*u_EmissiveFactor;\n#endif\noutFragColor.rgb=LINEARtoSRGB(emissive);\n#endif\n#ifdef DEBUG_F0\noutFragColor.rgb=vec3(f0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\n}",n,a);case t.PMaterialType.shadowBase:return he.build("#define FEATURES\n#include <shadowCommon.vert.glsl>\n#include <webglCompatibility.glsl>\n#if defined(SHADOWMAP_VSM) && !defined(WEBGL2)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\nout vec4 outFragColor;\n#else\n#define outFragColor gl_FragColor\n#endif\nvec4 CalcMomentVSM(float depth){float dx=0.0;float dy=0.0;\n#if defined(SHADOWMAP_VSM) && (defined(GL_OES_standard_derivatives) || defined(WEBGL2))\ndx=dFdx(depth);dy=dFdy(depth);\n#endif\nfloat moment2=depth*depth+0.25*(dx*dx+dy*dy);return vec4(1.0-depth,1.0-moment2,0.0,1.0);}vec4 CalcMomentEVSM(float depth){float pos=EVSM_FUNC0(depth);float neg=EVSM_FUNC1(depth);return vec4(pos,pos*pos,neg,neg*neg);}void main(){\n#if defined(SHADOWMAP_STANDARD) || defined(SHADOWMAP_VSM)\noutFragColor=CalcMomentVSM(gl_FragCoord.z);\n#else\noutFragColor=CalcMomentEVSM(gl_FragCoord.z);\n#endif\n}",n,a);case t.PMaterialType.skyboxFilter:return he.build("precision highp float;\n#define FEATURES\n#if !defined(WEBGL2) && defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#if !defined(WEBGL2)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#include <webglCompatibility.glsl>\n#include <extensions.frag.glsl>\n#ifdef WEBGL2\nout vec4 outFragColor;\n#else\n#define outFragColor gl_FragColor\n#endif\nuniform sampler2D u_brdfLUT;uniform vec2 u_IblIntensity;uniform int u_MipCount;uniform samplerCube u_DiffuseEnvSampler;uniform samplerCube u_SpecularEnvSampler;fsIn vec3 v_CameraDir;\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients u_shCoefficients;vec3 getIrradiance(vec3 norm,SHCoefficients c){float x=norm.x;float y=norm.y;float z=norm.z;float c1=0.429043;float c2=0.511664;float c3=0.743125;float c4=0.886227;float c5=0.247708;vec3 irradiance=c1*c.l22*(x*x-y*y)+c3*c.l20*(z*z)+c4*c.l00-c5*c.l20+2.0*c1*(c.l2m2*x*y+c.l21*x*z+c.l2m1*y*z)+2.0*c2*(c.l11*x+c.l1m1*y+c.l10*z);return irradiance;}\n#endif\nvec3 getIBLContribution(vec3 n,vec3 v){const float metallic=0.9;const float perceptualRoughness=0.1;const vec4 baseColor=vec4(1.0);const vec3 f0=vec3(0.04);const vec3 diffuseColor=baseColor.rgb*(vec3(1.0)-f0)*(1.0-metallic);const vec3 specularColor=mix(f0,baseColor.rgb,metallic);float NdotV=clamp(dot(n,v),0.0,1.0);float lod=clamp(perceptualRoughness*float(u_MipCount),0.0,float(u_MipCount));vec3 reflection=normalize(reflect(-v,n));vec2 brdfSamplePoint=clamp(vec2(NdotV,perceptualRoughness),vec2(0.0,0.0),vec2(1.0,1.0));vec2 brdf=texture2D(u_brdfLUT,brdfSamplePoint).rg;vec4 diffuseSample=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,u_shCoefficients);diffuseSample=vec4(irradiance,1.0);\n#else\ndiffuseSample=textureCube(u_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(u_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(u_SpecularEnvSampler,reflection,lod);\n#endif\nvec3 diffuseLight=diffuseSample.rgb;vec3 specularLight=specularSample.rgb;vec3 diffuse=diffuseLight*diffuseColor;vec3 specular=specularLight*(specularColor*brdf.x+brdf.y);return diffuse*u_IblIntensity[0]+specular*u_IblIntensity[1];}void main(){vec3 dir=normalize(v_CameraDir);outFragColor=vec4(getIBLContribution(dir,dir),1.0);}",n,a);default:throw new Error("Invalid material type ".concat(r," for getFragmentShaderString!"))}},e.environment="webgl1",e}();function xe(t){return{vertexShaderCode:ve.getVertexShaderCode(t),fragmentShaderCode:ve.getFragmentShaderCode(t)}}function be(t){return{vertexShaderCode:ve.getVertexShaderCode(t),fragmentShaderCode:ve.getFragmentShaderCode(t)}}function Te(t){return{vertexShaderCode:ve.getVertexShaderCode(t),fragmentShaderCode:ve.getFragmentShaderCode(t)}}function Me(t){return{vertexShaderCode:we({hasNormals:!0}),fragmentShaderCode:"\n #version 100\n precision highp float;\n varying vec3 v_Normal;\n void main(){\n gl_FragColor = vec4(v_Normal * 0.5 + 0.5, 1);\n }\n "}}function Se(t){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform sampler2D u_FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n gl_FragColor = texture2D(u_FilterSampler, v_UVCoord1) * vec4(0.5);\n }\n "}}function Ce(t){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform vec2 u_BlurScale;\n uniform sampler2D u_FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0);\n vec2 offset0 = vec2(0.53805) * u_BlurScale.xy;\n vec2 offset1 = vec2(2.06278) * u_BlurScale.xy;\n color += (texture2D(u_FilterSampler, v_UVCoord1 + offset0) + texture2D(u_FilterSampler, v_UVCoord1 - offset0)) * 0.44908;\n color += (texture2D(u_FilterSampler, v_UVCoord1 + offset1) + texture2D(u_FilterSampler, v_UVCoord1 - offset1)) * 0.05092;\n gl_FragColor = color;\n }\n "}}function we(t){void 0===t&&(t={});var e=["#version 100"];return t.hasUVs&&e.push("#define HAS_UVS 1"),t.hasNormals&&e.push("#define HAS_NORMALS 1"),e.push("\n precision highp float;\n\n uniform mat4 u_ModelMatrix;\n uniform mat4 u_ViewProjectionMatrix;\n attribute vec3 a_Position;\n varying vec3 v_Position;\n\n #ifdef HAS_UVS\n attribute vec2 a_UV1;\n varying vec2 v_UVCoord1;\n #endif\n\n #ifdef HAS_NORMALS\n uniform mat4 u_NormalMatrix;\n attribute vec3 a_Normal;\n varying vec3 v_Normal;\n #endif\n\n void main(){\n vec4 pos = u_ModelMatrix * vec4(a_Position, 1);\n v_Position = pos.xyz / pos.w;\n\n #ifdef HAS_UVS\n v_UVCoord1 = a_UV1;\n #endif\n\n #ifdef HAS_NORMALS\n v_Normal = normalize(vec3(u_ModelMatrix * vec4(a_Normal, 0)));\n #endif\n\n gl_Position = u_ViewProjectionMatrix * pos;\n }\n "),e.join("\n")}var Ae=function(){function e(){this.funcMap=new Map,this.funcMap.set(t.PMaterialType.unlit,xe),this.funcMap.set(t.PMaterialType.pbr,xe),this.funcMap.set(t.PMaterialType.shadowBase,be),this.funcMap.set(t.PMaterialType.shadowFilter,Ce),this.funcMap.set(t.PMaterialType.normalVis,Me),this.funcMap.set(t.PMaterialType.simpleFilter,Se),this.funcMap.set(t.PMaterialType.skyboxFilter,Te)}return e.getInstance=function(){return this._instance||(this._instance=new this)},e.prototype.genShaderCode=function(t){var e=t.material.materialType,a=this.funcMap.get(e);if(void 0!==a)return a(t);throw new Error("Invalid material type ".concat(e,", shader content ").concat(t))},e}(),Ie=function(a){function n(){var e=null!==a&&a.apply(this,arguments)||this;return e.materialType=t.PMaterialType.none,e.vertexShaderCode="",e.fragmentShaderCode="",e.depthMask=!0,e.depthTestHint=!0,e.blendMode=t.PBlendMode.opaque,e.alphaCutOff=.5,e.faceSideMode=t.PFaceSideMode.front,e}return r(n,a),n.prototype.getShaderFeatures=function(){var e=[];return this.isOpaque()?e.push("ALPHAMODE_OPAQUE 1"):this.isMasked()&&e.push("ALPHAMODE_MASK 1"),this.faceSideMode===t.PFaceSideMode.both&&e.push("DOUBLE_SIDED 1"),e},n.prototype.updateUniforms=function(t){if(this.isMasked()&&t.setFloat("u_AlphaCutoff",this.alphaCutOff),Rt.getInstance().renderMode3D===e.spec.RenderMode3D.uv){var a=Rt.getInstance().renderMode3DUVGridSize;t.setFloat("u_DebugUVGridSize",a)}},n.prototype.build=function(e){var a=this.getShaderFeatures();void 0!==e&&a.push.apply(a,u([],c(e),!1));var n=Rt.getInstance().isWebGL2;(n&&a.push("WEBGL2"),this.materialType!==t.PMaterialType.shadowBase)&&(Rt.getInstance().isEditorEnv&&a.push("EDITOR_TRANSFORM"));var r=Ae.getInstance().genShaderCode({material:this,isWebGL2:n,featureList:a});this.vertexShaderCode=r.vertexShaderCode,this.fragmentShaderCode=r.fragmentShaderCode},n.prototype.getBlendMode=function(a){return a===e.spec.MaterialBlending.masked?t.PBlendMode.masked:a===e.spec.MaterialBlending.translucent?t.PBlendMode.translucent:a===e.spec.MaterialBlending.additive?t.PBlendMode.additive:t.PBlendMode.opaque},n.prototype.getFaceSideMode=function(a){return a===e.spec.SideMode.DOUBLE?t.PFaceSideMode.both:a===e.spec.SideMode.BACK?t.PFaceSideMode.back:t.PFaceSideMode.front},n.prototype.setMaterialStates=function(a){this.blendMode===t.PBlendMode.translucent||this.blendMode===t.PBlendMode.additive?(a.blending=!0,a.depthTest=!0,a.blendEquation=[e.glContext.FUNC_ADD,e.glContext.FUNC_ADD],this.blendMode===t.PBlendMode.translucent?a.blendFunction=[e.glContext.ONE,e.glContext.ONE_MINUS_SRC_ALPHA,e.glContext.ONE,e.glContext.ONE_MINUS_SRC_ALPHA]:a.blendFunction=[e.glContext.ONE,e.glContext.ONE,e.glContext.ONE,e.glContext.ONE],a.depthMask=this.depthMask):Rt.getInstance().isTiny3dMode?(a.blending=!1,a.depthTest=!0,a.depthMask=!0):(a.blending=!1,a.depthTest=this.depthTestHint,a.depthMask=this.depthMask),this.setFaceSideStates(a)},n.prototype.setFaceSideStates=function(t){this.isBothFace()?t.culling=!1:this.isBackFace()?(t.cullFace=e.glContext.FRONT,t.frontFace=e.glContext.CCW,t.culling=!0):(t.cullFace=e.glContext.BACK,t.frontFace=e.glContext.CCW,t.culling=!0)},n.prototype.dispose=function(){this.vertexShaderCode="",this.fragmentShaderCode=""},n.prototype.isValid=function(){return this.materialType!==t.PMaterialType.none&&a.prototype.isValid.call(this)},n.prototype.isOpaque=function(){return this.blendMode===t.PBlendMode.opaque},n.prototype.isMasked=function(){return this.blendMode===t.PBlendMode.masked},n.prototype.isTranslucent=function(){return this.blendMode===t.PBlendMode.translucent},n.prototype.isAdditive=function(){return this.blendMode===t.PBlendMode.additive},n.prototype.requireBlend=function(){return this.blendMode===t.PBlendMode.translucent||this.blendMode===t.PBlendMode.additive},n.prototype.isFrontFace=function(){return this.faceSideMode===t.PFaceSideMode.front},n.prototype.isBackFace=function(){return this.faceSideMode===t.PFaceSideMode.back},n.prototype.isBothFace=function(){return this.faceSideMode===t.PFaceSideMode.both},n}(Bt),Ee=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.baseColorFactor=new P(1,1,1,1),t}return r(a,e),a.prototype.create=function(e){var a;this.name=e.name,this.type=t.PObjectType.material,this.materialType=t.PMaterialType.unlit,e.baseColorTexture&&(this.baseColorTexture=e.baseColorTexture),this.setBaseColorFactor($t.toPluginColor4(e.baseColorFactor)),!1===e.depthMask?this.depthMask=!1:this.depthMask=!0,this.blendMode=this.getBlendMode(e.blending),this.alphaCutOff=null!==(a=e.alphaCutOff)&&void 0!==a?a:0,this.faceSideMode=this.getFaceSideMode(e.side)},a.prototype.dispose=function(){e.prototype.dispose.call(this),this.baseColorTexture=void 0},a.prototype.getShaderFeatures=function(){var t=e.prototype.getShaderFeatures.call(this);return t.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&t.push("HAS_BASE_COLOR_MAP 1"),t.push("MATERIAL_UNLIT 1"),t},a.prototype.updateUniforms=function(t){e.prototype.updateUniforms.call(this,t);var a=V.IDENTITY.clone();t.setVector4("u_BaseColorFactor",this.baseColorFactor.toArray()),this.hasBaseColorTexture()&&(t.setTexture("u_BaseColorSampler",this.getBaseColorTexture()),t.setInt("u_BaseColorUVSet",0),t.setMatrix("u_BaseColorUVTransform",a.toArray())),t.setFloat("u_MetallicFactor",0),t.setFloat("u_RoughnessFactor",0),t.setFloat("u_Exposure",1)},a.prototype.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},a.prototype.getBaseColorTexture=function(){return this.baseColorTexture},a.prototype.setBaseColorTexture=function(t){this.baseColorTexture=t},a.prototype.getBaseColorFactor=function(){return this.baseColorFactor},a.prototype.setBaseColorFactor=function(t){t instanceof P?this.baseColorFactor.set(t.x,t.y,t.z,t.w):this.baseColorFactor.set(t[0],t[1],t[2],t[3])},a}(Ie),Pe=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.baseColorFactor=new P(1,1,1,1),t.useSpecularAA=!1,t.metallicFactor=0,t.roughnessFactor=1,t.normalTextureScale=1,t.occlusionTextureStrength=1,t.emissiveFactor=new S(0,0,0),t.emissiveIntensity=1,t.enableShadow=!1,t}return r(a,e),a.prototype.create=function(e){var a,n,r,o,i;this.name=e.name,this.type=t.PObjectType.material,this.materialType=t.PMaterialType.pbr,e.baseColorTexture&&(this.baseColorTexture=e.baseColorTexture),e.baseColorTextureTransform&&(this.baseColorTextureTrans=$t.createUVTransform(e.baseColorTextureTransform)),this.setBaseColorFactor($t.toPluginColor4(e.baseColorFactor)),e.metallicRoughnessTexture&&(this.metallicRoughnessTexture=e.metallicRoughnessTexture),e.metallicRoughnessTextureTransform&&(this.metallicRoughnessTextureTrans=$t.createUVTransform(e.metallicRoughnessTextureTransform)),this.useSpecularAA=null!==(a=e.useSpecularAA)&&void 0!==a&&a,this.metallicFactor=e.metallicFactor,this.roughnessFactor=$t.clamp(e.roughnessFactor,0,1),e.normalTexture&&(this.normalTexture=e.normalTexture),e.normalTextureTransform&&(this.normalTextureTrans=$t.createUVTransform(e.normalTextureTransform)),this.normalTextureScale=null!==(n=e.normalTextureScale)&&void 0!==n?n:1,e.occlusionTexture&&(this.occlusionTexture=e.occlusionTexture),e.occlusionTextureTransform&&(this.occlusionTextureTrans=$t.createUVTransform(e.occlusionTextureTransform)),this.occlusionTextureStrength=null!==(r=e.occlusionTextureStrength)&&void 0!==r?r:1,e.emissiveTexture&&(this.emissiveTexture=e.emissiveTexture),e.emissiveTextureTransform&&(this.emissiveTextureTrans=$t.createUVTransform(e.emissiveTextureTransform));var s=$t.toPluginColor4(e.emissiveFactor);this.emissiveFactor=S.fromArray(s),this.emissiveIntensity=e.emissiveIntensity,this.enableShadow=null!==(o=e.enableShadow)&&void 0!==o&&o,!1===e.depthMask?this.depthMask=!1:this.depthMask=!0,this.blendMode=this.getBlendMode(e.blending),this.alphaCutOff=null!==(i=e.alphaCutOff)&&void 0!==i?i:0,this.faceSideMode=this.getFaceSideMode(e.side)},a.prototype.dispose=function(){e.prototype.dispose.call(this),this.baseColorTexture=void 0,this.metallicRoughnessTexture=void 0,this.normalTexture=void 0,this.occlusionTexture=void 0,this.emissiveTexture=void 0},a.prototype.getShaderFeatures=function(){var t=e.prototype.getShaderFeatures.call(this);return t.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&(t.push("HAS_BASE_COLOR_MAP 1"),void 0!==this.baseColorTextureTrans&&t.push("HAS_BASECOLOR_UV_TRANSFORM 1")),this.hasMetallicRoughnessTexture()&&(t.push("HAS_METALLIC_ROUGHNESS_MAP 1"),void 0!==this.metallicRoughnessTextureTrans&&t.push("HAS_METALLICROUGHNESS_UV_TRANSFORM 1")),this.useSpecularAA&&t.push("USE_SPECULAR_AA 1"),this.hasNormalTexture()&&(t.push("HAS_NORMAL_MAP 1"),void 0!==this.normalTextureTrans&&t.push("HAS_NORMAL_UV_TRANSFORM 1")),this.hasOcclusionTexture()&&(t.push("HAS_OCCLUSION_MAP 1"),void 0!==this.occlusionTextureTrans&&t.push("HAS_OCCLUSION_UV_TRANSFORM 1")),this.hasEmissiveTexture()?(t.push("HAS_EMISSIVE_MAP 1"),void 0!==this.emissiveTextureTrans&&t.push("HAS_EMISSIVE_UV_TRANSFORM 1")):this.hasEmissiveFactor()&&t.push("HAS_EMISSIVE 1"),t},a.prototype.updateUniforms=function(t){e.prototype.updateUniforms.call(this,t);var a=V.IDENTITY.clone();if(t.setVector4("u_BaseColorFactor",this.baseColorFactor.toArray()),void 0!==this.baseColorTexture&&(t.setTexture("u_BaseColorSampler",this.baseColorTexture),t.setInt("u_BaseColorUVSet",0),void 0!==this.baseColorTextureTrans?t.setMatrix3("u_BaseColorUVTransform",this.baseColorTextureTrans.toArray()):t.setMatrix3("u_BaseColorUVTransform",a.toArray())),t.setFloat("u_MetallicFactor",this.metallicFactor),t.setFloat("u_RoughnessFactor",this.roughnessFactor),void 0!==this.metallicRoughnessTexture&&(t.setTexture("u_MetallicRoughnessSampler",this.metallicRoughnessTexture),t.setInt("u_MetallicRoughnessUVSet",0),void 0!==this.metallicRoughnessTextureTrans?t.setMatrix3("u_MetallicRoughnessUVTransform",this.metallicRoughnessTextureTrans.toArray()):t.setMatrix3("u_MetallicRoughnessUVTransform",a.toArray())),void 0!==this.normalTexture&&(t.setTexture("u_NormalSampler",this.normalTexture),t.setFloat("u_NormalScale",this.normalTextureScale),t.setInt("u_NormalUVSet",0),void 0!==this.normalTextureTrans?t.setMatrix3("u_NormalUVTransform",this.normalTextureTrans.toArray()):t.setMatrix3("u_NormalUVTransform",a.toArray())),void 0!==this.occlusionTexture&&(t.setTexture("u_OcclusionSampler",this.occlusionTexture),t.setFloat("u_OcclusionStrength",this.occlusionTextureStrength),t.setInt("u_OcclusionUVSet",0),void 0!==this.occlusionTextureTrans?t.setMatrix3("u_OcclusionUVTransform",this.occlusionTextureTrans.toArray()):t.setMatrix3("u_OcclusionUVTransform",a.toArray())),void 0!==this.emissiveTexture){var n=this.getEmissiveFactor();t.setTexture("u_EmissiveSampler",this.emissiveTexture),t.setVector3("u_EmissiveFactor",n.toArray()),t.setInt("u_EmissiveUVSet",0),void 0!==this.emissiveTextureTrans?t.setMatrix3("u_EmissiveUVTransform",this.emissiveTextureTrans.toArray()):t.setMatrix3("u_EmissiveUVTransform",a.toArray())}else if(this.hasEmissiveFactor()){n=this.getEmissiveFactor();t.setVector3("u_EmissiveFactor",n.toArray())}t.setFloat("u_Exposure",3)},a.prototype.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},a.prototype.hasBaseColorTextureTrans=function(){return void 0!==this.baseColorTextureTrans},a.prototype.setBaseColorTexture=function(t){this.baseColorTexture=t},a.prototype.getBaseColorFactor=function(){return this.baseColorFactor},a.prototype.setBaseColorFactor=function(t){t instanceof P?this.baseColorFactor.set(t.x,t.y,t.z,t.w):this.baseColorFactor.set(t[0],t[1],t[2],t[3])},a.prototype.hasMetallicRoughnessTexture=function(){return void 0!==this.metallicRoughnessTexture},a.prototype.hasMetallicRoughnessTextureTrans=function(){return void 0!==this.metallicRoughnessTextureTrans},a.prototype.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture},a.prototype.setMetallicRoughnessTexture=function(t){this.metallicRoughnessTexture=t},a.prototype.hasNormalTexture=function(){return void 0!==this.normalTexture},a.prototype.hasNormalTextureTrans=function(){return void 0!==this.normalTextureTrans},a.prototype.getNormalTexture=function(){return this.normalTexture},a.prototype.setNormalTexture=function(t){this.normalTexture=t},a.prototype.hasOcclusionTexture=function(){return void 0!==this.occlusionTexture},a.prototype.hasOcclusionTextureTrans=function(){return void 0!==this.occlusionTextureTrans},a.prototype.getOcclusionTexture=function(){return this.occlusionTexture},a.prototype.setOcclusionTexture=function(t){this.occlusionTexture=t},a.prototype.hasEmissiveTexture=function(){return void 0!==this.emissiveTexture},a.prototype.hasEmissiveTextureTrans=function(){return void 0!==this.emissiveTextureTrans},a.prototype.getEmissiveTexture=function(){return this.emissiveTexture},a.prototype.setEmissiveTexture=function(t){this.emissiveTexture=t},a.prototype.hasEmissiveFactor=function(){return this.emissiveFactor.sum()*this.emissiveIntensity>0},a.prototype.getEmissiveFactor=function(){return this.emissiveFactor.clone().multiplyScalar(this.emissiveIntensity)},a.prototype.setEmissiveFactor=function(t){t instanceof S?this.emissiveFactor.set(t.x,t.y,t.z):this.emissiveFactor.set(t[0],t[1],t[2])},a}(Ie);function Oe(t){if(t.type===e.spec.MaterialType.pbr){var a=new Pe;return a.create(t),a}var n=new Ee;return n.create(t),n}var Ne,Le=function(e){function a(a,n){var r=e.call(this)||this;r.renderable=!0,r.intensity=1,r.reflectionsIntensity=1,r.specularImageSize=0,r.specularMipCount=0,r.priority=0,r.isBuilt=!1,r.name=a.name,r.type=t.PObjectType.skybox,r.visible=!1,r.ownerItem=n;var o=a.content.options;return r.renderable=o.renderable,r.intensity=o.intensity,r.reflectionsIntensity=o.reflectionsIntensity,r.irradianceCoeffs=o.irradianceCoeffs,r.diffuseImage=o.diffuseImage,r.specularImage=o.specularImage,r.specularImageSize=o.specularImageSize,r.specularMipCount=o.specularMipCount,r.priority=(null==n?void 0:n.listIndex)||0,r}return r(a,e),a.prototype.setup=function(t){this.brdfLUT=t},a.prototype.build=function(t){this.isBuilt||(this.isBuilt=!0,this.skyboxMaterial=new Fe,this.skyboxMaterial.create(this),this.skyboxMaterial.build(),this.skyboxMesh=t.getFilterMesh("SkyboxFilterPlane",this.skyboxMaterial,{}),this.skyboxMesh.priority=this.priority,this.skyboxMaterial.updateUniforms(this.skyboxMesh.material))},a.prototype.dispose=function(){var t;this.diffuseImage=void 0,this.specularImage=void 0,this.brdfLUT=void 0,this.skyboxMesh=void 0,null===(t=this.skyboxMaterial)||void 0===t||t.dispose(),this.skyboxMaterial=void 0},a.prototype.addToRenderObjectSet=function(t){this.visible&&this.renderable&&void 0!==this.skyboxMesh&&t.add(this.skyboxMesh)},a.prototype.updateUniformsForScene=function(t){if(this.visible&&this.renderable&&void 0!==this.skyboxMesh&&void 0!==this.skyboxMaterial){var e=t.camera,a=t.viewMatrix,n=e.getNewProjectionMatrix(e.fovy).multiply(a).inverse(),r=this.skyboxMesh.material;this.skyboxMaterial.updateUniforms(r),r.setMatrix("u_InvViewProjectionMatrix",n.toArray())}},Object.defineProperty(a.prototype,"available",{get:function(){return!!this.isValid()&&(!(this.intensity<=0&&this.reflectionsIntensity<=0)&&((void 0!==this.irradianceCoeffs||void 0!==this.diffuseImage)&&(void 0!==this.specularImage&&this.specularMipCount>0)))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"currentIntensity",{get:function(){return this.visible?this.intensity:0},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"currentReflectionsIntensity",{get:function(){return this.visible?this.reflectionsIntensity:0},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"hasDiffuseImage",{get:function(){return void 0!==this.diffuseImage},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"hasIrradianceCoeffs",{get:function(){return void 0!==this.irradianceCoeffs},enumerable:!1,configurable:!0}),a}(Dt),Fe=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.intensity=1,t.reflectionsIntensity=1,t.specularMipCount=0,t}return r(a,e),a.prototype.create=function(e){this.type=t.PObjectType.material,this.materialType=t.PMaterialType.skyboxFilter,this.depthTestHint=!1,this.name=e.name,this.intensity=e.intensity,this.reflectionsIntensity=e.reflectionsIntensity,this.brdfLUT=e.brdfLUT,this.irradianceCoeffs=e.irradianceCoeffs,this.diffuseImage=e.diffuseImage,this.specularImage=e.specularImage,this.specularMipCount=e.specularMipCount},a.prototype.dispose=function(){e.prototype.dispose.call(this),this.brdfLUT=void 0,this.irradianceCoeffs=void 0,this.diffuseImage=void 0,this.specularImage=void 0},a.prototype.getShaderFeatures=function(){var t=[];return t.push("USE_IBL 1"),t.push("USE_TEX_LOD 1"),void 0===this.diffuseImage&&t.push("IRRADIANCE_COEFFICIENTS 1"),t},a.prototype.updateUniforms=function(t){if(void 0===this.brdfLUT)throw new Error("Setup brdfLUT for skybox at first.");if(t.setVector2("u_IblIntensity",[2,2]),t.setTexture("u_brdfLUT",this.brdfLUT),void 0!==this.diffuseImage)t.setTexture("u_DiffuseEnvSampler",this.diffuseImage);else{var e=this.irradianceCoeffs;if(void 0===e||9!=e.length)throw new Error("Invalid skybox irradiance coeffs ".concat(e));["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(a,n){t.setVector3("u_shCoefficients.".concat(a),e[n])}))}t.setInt("u_MipCount",this.specularMipCount),t.setTexture("u_SpecularEnvSampler",this.specularImage)},a.prototype.setMaterialStates=function(t){t.depthTest=!0,t.depthMask=!1,this.setFaceSideStates(t)},a}(Ie);t.PSkyboxType=void 0,(Ne=t.PSkyboxType||(t.PSkyboxType={}))[Ne.NFT=0]="NFT",Ne[Ne.FARM=1]="FARM";var Re=function(){function a(){}return a.getBrdfLutTextureOptions=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(a){switch(a.label){case 0:return"https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png",[4,e.loadImage("https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png")];case 1:return t=a.sent(),[2,{name:"brdfLut",wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR,anisotropic:1,sourceType:e.TextureSourceType.image,image:t,generateMipmap:!1,flipY:!1,premultiplyAlpha:!1}]}}))}))},a.createBrdfLutTexture=function(t){return i(this,void 0,void 0,(function(){var a;return s(this,(function(n){switch(n.label){case 0:return[4,this.getBrdfLutTextureOptions()];case 1:return a=n.sent(),[2,e.Texture.create(t,a)]}}))}))},a.createSkyboxOptions=function(t,e){return i(this,void 0,void 0,(function(){var a,n,r,o,i,c,u,d;return s(this,(function(s){switch(s.label){case 0:return[4,this.createSpecularCubeMap(t,e)];case 1:return a=s.sent(),[4,this.createDiffuseCubeMap(t,e)];case 2:return n=s.sent(),r=e.renderable,o=e.intensity,i=e.reflectionsIntensity,c=e.irradianceCoeffs,u=e.specularImageSize,d=e.specularMipCount,[2,{renderable:r,intensity:o,reflectionsIntensity:i,irradianceCoeffs:c,diffuseImage:n,specularImage:a,specularImageSize:u,specularMipCount:d}]}}))}))},a.createSpecularCubeMap=function(t,a){return i(this,void 0,void 0,(function(){return s(this,(function(n){return e.glContext.CLAMP_TO_EDGE,e.glContext.CLAMP_TO_EDGE,e.glContext.LINEAR,e.glContext.LINEAR_MIPMAP_LINEAR,"url"===a.type?[2,Qt.createTextureCubeMipmapFromURL(t,a.specularImage)]:[2,Qt.createTextureCubeMipmapFromBuffer(t,a.specularImage,a.specularImageSize)]}))}))},a.createDiffuseCubeMap=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(a){return void 0===e.diffuseImage?[2]:"url"===e.type?[2,Qt.createTextureCubeFromURL(t,e.diffuseImage)]:[2,Qt.createTextureCubeFromBuffer(t,e.diffuseImage)]}))}))},a.getSkyboxParams=function(e){void 0===e&&(e=t.PSkyboxType.NFT);var a=this.getSpecularImageList(e);return{type:"url",renderable:!0,intensity:1.8,reflectionsIntensity:1.8,irradianceCoeffs:this.getIrradianceCoeffs(e),diffuseImage:this.getDiffuseImageList(e,a),specularImage:a,specularImageSize:Math.pow(2,a.length-1),specularMipCount:a.length-1}},a.prototype.checkCubeMapImage=function(t){return i(this,void 0,void 0,(function(){var a,n,r,o;return s(this,(function(i){switch(i.label){case 0:n=[],r=0,i.label=1;case 1:return r<t.length?[4,e.loadImage(t[r])]:[3,4];case 2:if(o=i.sent(),r>0)if(r%6==0){if(2*o.width!==a.width||2*o.height!==a.height)throw new Error("Invalid cube map list1: index ".concat(r,", image0 ").concat(a,", image1 ").concat(o))}else if(o.width!==a.width||o.height!==a.height)throw new Error("Invalid cube map list2: index ".concat(r,", image0 ").concat(a,", image1 ").concat(o));r%6==0&&n.push([]),n[n.length-1].push(o),a=o,i.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}))},a.getIrradianceCoeffs=function(e){var a=[];switch(e){case t.PSkyboxType.NFT:return;case t.PSkyboxType.FARM:a=[.2665672302246094,.27008703351020813,.2836797833442688,-.15421263873577118,-.15587495267391205,-.16371899843215942,.06483837962150574,.06468029320240021,.06616337597370148,-.11598809063434601,-.11796595901250839,-.1261979341506958,.023678265511989594,.02456280030310154,.02591511607170105,-.032404184341430664,-.03217344358563423,-.03126845508813858,.009165619499981403,.009345818310976028,.008521141484379768,-.021998587995767593,-.02203795686364174,-.021759089082479477,.00046658870996907353,.0005610908847302198,.0007202711421996355];break;default:a=[.3746267259120941,.3523011803627014,.33955901861190796,.12082185596227646,.18179306387901306,.26912716031074524,-.020699946209788322,-.004648427478969097,.00797625258564949,-.06842170655727386,-.05139023810625076,-.03317255899310112,.044127799570560455,.028159862384200096,.007428745273500681,.07887077331542969,.06773484498262405,.04738233983516693,-.012322401627898216,-.015187464654445648,-.02020176313817501,-.1091032400727272,-.0823250338435173,-.046844951808452606,-.05779704451560974,-.06689254194498062,-.08212742954492569]}for(var n=[],r=0;r<a.length;r+=3)n.push([a[r],a[r+1],a[r+2]]);return n},a.getDiffuseImageList=function(e,a){if(e==t.PSkyboxType.NFT)return a[a.length-1]},a.getSpecularImageList=function(e){var a=[];if(e===t.PSkyboxType.FARM)a.push.apply(a,u([],c(this.getSpecularImageListAntFarm()),!1));else a.push.apply(a,u([],c(this.getSpecularImageListNFT()),!1));var n=[];return a.forEach((function(t,e){e%6==0&&n.push([]),n[n.length-1].push(t)})),n},a.getSpecularImageListNFT=function(){return["https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img0.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img1.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img2.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img3.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img5.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img4.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img6.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img7.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img8.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img9.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img11.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img10.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img12.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img13.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img14.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img15.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img17.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img16.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img18.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img19.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img20.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img21.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img23.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img22.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img24.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img25.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img26.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img27.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img29.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img28.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img30.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img31.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img32.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img33.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img35.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img34.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img36.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img37.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img38.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img39.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img41.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img40.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img42.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img43.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img44.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img45.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img47.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img46.png"]},a.getSpecularImageListAntFarm=function(){return["https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_5.png"]},a}(),ze=function(){function t(t){this.engine=t,this.loadSkybox=!1,this.meshCache=new Map,this.textureCache=new Map,this.geometryCache=new Map,this.renderPassCache=new Map}return t.loadStaticResources=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return void 0!==this.brdfLutTexOptions?[2]:(t=this,[4,Re.getBrdfLutTextureOptions()]);case 1:return t.brdfLutTexOptions=e.sent(),[2]}}))}))},t.genSkyboxOptions=function(e,a){return i(this,void 0,void 0,(function(){var n,r;return s(this,(function(o){switch(o.label){case 0:return void 0===(n=a)&&(n=Re.getSkyboxParams()),r=t,[4,Re.createSkyboxOptions(e,n)];case 1:return r.skyboxOptions=o.sent(),[2,t.skyboxOptions]}}))}))},t.prototype.setup=function(a){if(this.loadSkybox=a,void 0===this.brdfLutTexture||this.brdfLutTexture.isDestroyed){if(void 0===t.brdfLutTexOptions)throw new Error("Please load brdfLutTexOptions at first");var n="brdfLutTexture";this.brdfLutTexture=e.Texture.create(this.engine,t.brdfLutTexOptions),this.deleteTexture(n),this.setTexture(n,this.brdfLutTexture)}},t.prototype.getTexture=function(t){return this.textureCache.get(t)},t.prototype.setTexture=function(t,e){this.textureCache.set(t,e)},t.prototype.getOrCreateTexture=function(t,a){var n=this.textureCache.get(t);if(void 0!==n)return n;var r=e.Texture.create(this.engine,a);return this.textureCache.set(t,r),r},t.prototype.deleteTexture=function(t){var e=this.textureCache.get(t);return void 0!==e&&e.dispose(),this.textureCache.delete(t)},t.prototype.getOrCreateGeometry=function(t,e,a){var n=this.geometryCache.get(t);if(void 0!==n)return n;var r=$t.createGeometry(this.engine,e,a);return this.geometryCache.set(t,r),r},t.prototype.getFilterMesh=function(t,e,a){var n=this.meshCache.get(t);if(void 0!==n)return n;var r=Kt.createFilterMesh(this.engine,t,e,a);return this.meshCache.set(t,r),r},t.prototype.getShadowBasePass=function(t,e,a,n){return this.getRenderPass(t,e,a,n)},t.prototype.getShadowFilterPass=function(t,e,a,n){return this.getRenderPass(t,e,a,n)},t.prototype.getRenderPass=function(t,e,a,n){var r=this.renderPassCache.get(t);if(void 0!==r)return r.setMeshes([]),a.forEach((function(t){r.addMesh(t)})),r;var o=this.engine.renderer,i=Qt.createRenderPass(o,t,e,a,n);return this.renderPassCache.set(t,i),i},t.prototype.dispose=function(){this.engine=null,this.brdfLutTexture=void 0,this.meshCache.forEach((function(t){Qt.deleteMesh(t)})),this.meshCache.clear(),this.textureCache.forEach((function(t){Qt.deleteTexture(t)})),this.textureCache.clear(),this.geometryCache.forEach((function(t){Qt.deleteGeometry(t)})),this.geometryCache.clear(),this.renderPassCache.forEach((function(t){Qt.deleteRenderPass(t)})),this.renderPassCache.clear()},t.prototype.getRenderPasses=function(){var t=[];return this.renderPassCache.forEach((function(e){t.push(e)})),t},t.prototype.getBrdfLutTexture=function(){return this.brdfLutTexture},t.prototype.getSkyboxOptions=function(){return t.skyboxOptions},t}(),Be=Math.PI/180,De=function(a){function n(n,r,o,i){var s,c=a.call(this)||this;c.width=512,c.height=512,c.nearPlane=.001,c.farPlane=1e3,c.fovy=45,c.aspect=1,c.clipMode=e.spec.CameraClipMode.landscape,c.projectionMatrix=new ct,c.viewMatrix=new ct,c.name=n.name,c.type=t.PObjectType.camera,c.visible=!1,c.ownerItem=i,c.width=r,c.height=o;var u=n.content.options;return c.nearPlane=u.near,c.farPlane=u.far,c.fovy=u.fov,c.aspect=null!==(s=u.aspect)&&void 0!==s?s:c.width/c.height,c.clipMode=u.clipMode,c.update(),c}return r(n,a),n.prototype.update=function(){void 0!==this.ownerItem&&this.transform.fromEffectsTransform(this.ownerItem.transform),this.projectionMatrix.perspective(this.fovy*Be,this.aspect,this.nearPlane,this.farPlane,this.isReversed()),this.viewMatrix=this.matrix.inverse()},n.prototype.getNewProjectionMatrix=function(t){return(new ct).perspective(Math.min(1.25*t,140)*Be,this.aspect,this.nearPlane,this.farPlane,this.isReversed())},n.prototype.computeViewAABB=function(t){var e=Math.tan(this.fovy*Be*.5),a=this.aspect,n=0,r=0,o=0,i=0;this.isReversed()?(n=(o=this.farPlane*e)/a,r=(i=this.nearPlane*e)/a):(o=a*(n=this.farPlane*e),i=a*(r=this.nearPlane*e)),t.makeEmpty();var s=this.matrix;return t.expandByPoint(s.multiplyByPoint3(new S(o,n,-this.farPlane))),t.expandByPoint(s.multiplyByPoint3(new S(o,-n,-this.farPlane))),t.expandByPoint(s.multiplyByPoint3(new S(-o,n,-this.farPlane))),t.expandByPoint(s.multiplyByPoint3(new S(-o,-n,-this.farPlane))),t.expandByPoint(s.multiplyByPoint3(new S(i,r,-this.nearPlane))),t.expandByPoint(s.multiplyByPoint3(new S(i,-r,-this.nearPlane))),t.expandByPoint(s.multiplyByPoint3(new S(-i,r,-this.nearPlane))),t.expandByPoint(s.multiplyByPoint3(new S(-i,-r,-this.nearPlane))),t},n.prototype.getSize=function(){return new y(this.width,this.height)},n.prototype.isReversed=function(){return this.clipMode===e.spec.CameraClipMode.portrait},n.prototype.getEye=function(){return this.translation},n.prototype.setEye=function(t){this.translation=t},n}(Dt),Ue=function(){function t(){this.winWidth=512,this.winHeight=512,this.cameraList=[],this.defaultCamera=new De({id:"camera",name:"camera",type:"camera",duration:10,pluginName:"model",content:{options:{fov:60,far:1e3,near:.001,position:[0,0,-1.5],clipMode:e.spec.CameraClipMode.portrait}},endBehavior:e.spec.END_BEHAVIOR_FORWARD},512,512)}return t.prototype.initial=function(t,e){this.winWidth=t,this.winHeight=e;var a=this.defaultCamera;a.width=t,a.height=e,a.aspect=t/e,a.update()},t.prototype.insert=function(t,e){var a=new De(t,this.winWidth,this.winHeight,e);return this.cameraList.push(a),a},t.prototype.insertCamera=function(t){this.cameraList.push(t)},t.prototype.remove=function(t){if(t instanceof De){var e=this.cameraList.findIndex((function(e){return e===t}));-1!==e&&this.cameraList.splice(e,1)}else t>=0&&t<this.cameraList.length&&this.cameraList.splice(t,1)},t.prototype.dispose=function(){this.cameraList=[]},t.prototype.updateDefaultCamera=function(t,e,a,n,r,o){this.defaultCamera.fovy=t,this.defaultCamera.nearPlane=e,this.defaultCamera.farPlane=a,this.defaultCamera.position=n,this.defaultCamera.rotation=r,this.defaultCamera.clipMode=o,this.defaultCamera.update()},t.prototype.getCameraList=function(){return this.cameraList},t.prototype.getDefaultCamera=function(){return this.defaultCamera},t.prototype.getCameraCount=function(){return this.cameraList.length},t.prototype.getActiveCamera=function(){return this.defaultCamera},t.prototype.getAspect=function(){return this.winWidth/this.winHeight},t}(),ke=function(e){function a(a,n){var r=e.call(this)||this;r.direction=new S(0,0,1),r.range=0,r.color=new S(1,1,1),r.intensity=0,r.outerConeAngle=0,r.innerConeAngle=0,r.lightType=t.PLightType.ambient,r.padding=new y(0,0),r.name=a.name,r.type=t.PObjectType.light,r.visible=!1,r.ownerItem=n,void 0!==n&&r.transform.fromEffectsTransform(n.transform),r.direction=new S(0,0,-1),r.range=0,r.outerConeAngle=0,r.innerConeAngle=0;var o=a.content.options,i=$t.toPluginColor4(o.color);return r.color=new S(i[0],i[1],i[2]),r.intensity=o.intensity,"point"===o.lightType?(r.lightType=t.PLightType.point,r.range=o.range):"spot"===o.lightType?(r.lightType=t.PLightType.spot,r.range=o.range,r.outerConeAngle=o.outerConeAngle,r.innerConeAngle=o.innerConeAngle):"directional"===o.lightType?r.lightType=t.PLightType.directional:r.lightType=t.PLightType.ambient,r}return r(a,e),a.prototype.tick=function(t){void 0!==this.ownerItem&&this.transform.fromEffectsTransform(this.ownerItem.transform)},a.prototype.isDirectional=function(){return this.lightType===t.PLightType.directional},a.prototype.isPoint=function(){return this.lightType===t.PLightType.point},a.prototype.isSpot=function(){return this.lightType===t.PLightType.spot},a.prototype.isAmbient=function(){return this.lightType===t.PLightType.ambient},Object.defineProperty(a.prototype,"position",{get:function(){return this.translation},enumerable:!1,configurable:!0}),a.prototype.getWorldPosition=function(){return this.translation},a.prototype.getWorldDirection=function(){var t=this.matrix;return ct.multiplyByPointAsVector(t,this.direction,new S)},a}(Dt),Ve=function(){function t(){this.lightList=[]}return t.prototype.tick=function(t){this.lightList.forEach((function(e){e.tick(t)}))},t.prototype.insertItem=function(t,e){var a=new ke(t,e);return this.lightList.push(a),a},t.prototype.insertLight=function(t){return this.lightList.push(t),t},t.prototype.remove=function(t){var e=this.lightList.findIndex((function(e){return e===t}));-1!==e&&this.lightList.splice(e,1)},t.prototype.dispose=function(){this.lightList=[]},Object.defineProperty(t.prototype,"lightCount",{get:function(){return this.lightList.length},enumerable:!1,configurable:!0}),t}(),je=function(){function t(t){var e,a;this.resolution=null!==(e=t.resolution)&&void 0!==e?e:new y(512,512),this.colorAttachments=null!==(a=t.colorAttachments)&&void 0!==a?a:[],this.depthAttachment=t.depthAttachment}return t.prototype.addDepthAttachment=function(t){var a;this.depthAttachment={storageType:null!==(a=t.storageType)&&void 0!==a?a:e.RenderPassAttachmentStorageType.depth_16_texture}},t.prototype.addDefaultDepthAttachment=function(){this.depthAttachment={storageType:e.RenderPassAttachmentStorageType.depth_16_texture}},t.prototype.deleteDepthAttachment=function(){this.depthAttachment=void 0},t.prototype.addColorAttachment=function(t){var a,n,r,o;this.colorAttachments.push({texture:{format:null!==(a=t.format)&&void 0!==a?a:e.glContext.RGBA,type:null!==(n=t.type)&&void 0!==n?n:e.glContext.HALF_FLOAT,minFilter:null!==(r=t.filter)&&void 0!==r?r:e.glContext.LINEAR,magFilter:null!==(o=t.filter)&&void 0!==o?o:e.glContext.LINEAR}})},t.prototype.deleteColorAttachment=function(t){t>=0&&t<this.colorAttachments.length&&this.colorAttachments.splice(t,1)},Object.defineProperty(t.prototype,"viewport",{get:function(){return[0,0,this.resolution.x,this.resolution.y]},enumerable:!1,configurable:!0}),t}(),Ge=function(){function t(t,a){var n=e.Material.create(t,{shader:{vertex:this.vertexShader,fragment:this.fragmentShader,shared:!0}});n.depthTest=!0,n.depthMask=!0,this.mesh=e.Mesh.create(t,{name:"boxMesh",material:n,geometry:e.Geometry.create(t,this.geometry),priority:a})}return t.prototype.update=function(t,e,a,n){var r=this.mesh.material;r.setMatrix("u_ModelMatrix",t.toArray()),r.setMatrix("u_ViewProjectionMatrix",e.toArray());for(var o=0;o<a.length;o+=3)r.setVector3("u_PositionList[".concat(o/3,"]"),[a[o],a[o+1],a[o+2]]);r.setVector3("u_LineColor",n.toArray())},t.prototype.dispose=function(){this.mesh.dispose(),this.mesh=void 0},Object.defineProperty(t.prototype,"vertexShader",{get:function(){return"\n #version 100\n precision highp float;\n\n uniform mat4 u_ModelMatrix;\n uniform mat4 u_ViewProjectionMatrix;\n uniform vec3 u_PositionList[8];\n attribute vec3 a_Position;\n void main(){\n int index = int(a_Position.x + 0.5);\n vec4 pos = u_ModelMatrix * vec4(u_PositionList[index], 1);\n gl_Position = u_ViewProjectionMatrix * pos;\n }\n "},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fragmentShader",{get:function(){return"\n #version 100\n precision highp float;\n\n uniform vec3 u_LineColor;\n void main(){\n gl_FragColor = vec4(u_LineColor, 1);\n }\n "},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){var t=new Float32Array([0,1,2,3,4,5,6,7]),a=new Uint32Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);return{attributes:{a_Position:{type:e.glContext.FLOAT,size:1,data:t,stride:Float32Array.BYTES_PER_ELEMENT,offset:0}},mode:e.glContext.LINES,indices:{data:a},drawStart:0,drawCount:24}},enumerable:!1,configurable:!0}),t}(),He=function(){function t(){this.now=new Set,this.last=new Set}return t.prototype.clear=function(){this.now.clear(),this.last.clear()},t.prototype.forward=function(){var t=this.last;this.last=this.now,this.now=t,this.now.clear()},t.prototype.forAddedItem=function(t){var e=this;this.now.forEach((function(a){e.last.has(a)||t(a)}))},t.prototype.forRemovedItem=function(t){var e=this;this.last.forEach((function(a){e.now.has(a)||t(a)}))},t}();!function(e){function a(){return null!==e&&e.apply(this,arguments)||this}r(a,e),a.prototype.create=function(e){this.type=t.PObjectType.material,this.materialType=t.PMaterialType.shadowBase,this.name=e.name,this.shadowType=e.shadowType},a.prototype.getShaderFeatures=function(){return[]},a.prototype.updateUniforms=function(t){}}(Ie);var We=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return r(a,e),a.prototype.create=function(e){this.type=t.PObjectType.material,this.materialType=t.PMaterialType.shadowBase,this.name=e.name,this.shadowType=e.shadowType},a.prototype.getShaderFeatures=function(){return[]},a.prototype.updateUniforms=function(t){},a}(Ie),qe=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return r(a,e),a.prototype.create=function(e){this.type=t.PObjectType.material,this.materialType=t.PMaterialType.shadowFilter,this.depthTestHint=!1,this.name=e.name,this.blurScale=e.blurScale},a.prototype.getShaderFeatures=function(){return[]},a.prototype.updateUniforms=function(t){t.setVector2("u_BlurScale",this.blurScale.toArray())},a}(Ie),Xe=function(){function a(){this.enable=!1,this.quality="medium",this.softness=1.5,this.width=1024,this.height=1024,this.type=e.glContext.HALF_FLOAT,this.format=e.glContext.RGBA,this.filter=e.glContext.LINEAR,this.baseFBOOpts=this.getBaseFBOOptions(),this.filterFBOOpts=this.getFilterFBOOptions(),this.runtimeEnable=!1,this.meshList=[],this.primitiveList=[],this.viewAABB=new Ot,this.sceneAABB=new Ot,this.shadowAABB=new Ot,this.lightView=new ct,this.lightProjection=new ct,this.lightViewProjection=new ct,this.xFilterMaterial=new qe,this.yFilterMaterial=new qe,this.meshCacheSet=new He,this.renderPassCacheSet=new He}return a.prototype.initial=function(t,e){var a,n,r,o=this;this.runtimeEnable=!1,this.meshList=[],this.primitiveList=[],this.shadowLight=void 0,this.meshCacheSet.clear(),this.renderPassCacheSet.clear(),this.sceneManager=t,this.renderer=t.getRenderer(),this.engine=this.renderer.engine,this.enable=null===(n=null==e?void 0:e.enable)||void 0===n||n,this.quality=null!==(r=null==e?void 0:e.quality)&&void 0!==r?r:"medium",this.softness=this.getSoftness(e),a=c(this.getTextureSize(e),2),this.width=a[0],this.height=a[1],this.type=this.getTextureType(e),this.format=this.getTextureFormat(e),this.filter=this.getTextureFilter(e),this.enable&&this.isSupportTextureOptions()&&(this.shadowLight=this.getShadowLight(t),void 0!==this.shadowLight&&(t.meshList.forEach((function(t){var e=0;t.primitives.forEach((function(t){t.isEnableShadow()&&(e+=1)})),e>0&&o.meshList.push(t)})),this.meshList.length<=0||(this.runtimeEnable=!0,this.xFilterMaterial.create({name:"ShadowXFilterPass",blurScale:new y(this.softness/this.width,0)}),this.yFilterMaterial.create({name:"ShadowYFilterPass",blurScale:new y(0,this.softness/this.height)}),this.xFilterMaterial.build([]),this.yFilterMaterial.build([]))))},a.prototype.build=function(){if(this.isEnable()){var t=this.sceneManager.getSceneCache();this.basePass=t.getShadowBasePass(this.basePassName,900,[],this.baseFBOOpts);var e=t.getFilterMesh(this.xFilterMeshName,this.xFilterMaterial,{u_FilterSampler:"Shadow0Color"}),a=t.getFilterMesh(this.yFilterMeshName,this.yFilterMaterial,{u_FilterSampler:"Shadow1Color"});this.xFilterMaterial.updateUniforms(e.material),this.yFilterMaterial.updateUniforms(a.material),this.xFilterPass=t.getShadowFilterPass(this.xFilterPassName,901,[e],this.filterFBOOpts),this.yFilterPass=t.getShadowFilterPass(this.yFilterPassName,902,[a],this.filterFBOOpts)}},a.prototype.tick=function(t){this.isEnable()&&(this.primitiveList=this.getCurrentPrimitiveList(),this.primitiveList.length<=0||(this.updateAABBInfo(),this.updateLightViewProjection(),this.updateShadowUniforms(),t.shadowMapSizeInv=new y(1/this.width,1/this.height),t.lightViewMatrix=this.lightView,t.lightProjectionMatrix=this.lightProjection,t.lightViewProjectionMatrix=this.lightViewProjection))},a.prototype.updateAABBInfo=function(){var t=this;this.sceneAABB.makeEmpty(),this.primitiveList.forEach((function(e){var a=e.getWorldBoundingBox();t.sceneAABB.expandByBox(a)})),this.viewAABB.makeEmpty(),this.sceneManager.activeCamera.computeViewAABB(this.viewAABB),this.shadowAABB.makeEmpty(),this.shadowAABB.expandByBox(this.viewAABB),this.sceneAABB.isEmpty()||this.shadowAABB.intersect(this.sceneAABB)},a.prototype.updateLightViewProjection=function(){void 0!==this.shadowLight&&(this.shadowLight.lightType===t.PLightType.directional?this.updateDirectionalLightViewProjection(this.shadowLight):this.shadowLight.lightType===t.PLightType.spot?this.updateSpotLightViewProjection(this.shadowLight):console.warn("Invalid light type for casting shadow: ".concat(this.shadowLight)))},a.prototype.updateDirectionalLightViewProjection=function(t){if(t.isDirectional()){var e=this.shadowAABB,a=e.getCenter(new S),n=t.getWorldDirection(),r=a.clone().addVector(n),o=S.computeUpVector(n,new S),i=(new ct).lookAt(a,r,o),s=e.clone().transform(i),c=s.getCenter(new S),u=s.getSize(new S).multiplyScalar(.5);u.x=Math.max(u.x,u.y),u.y=Math.max(u.x,u.y);var d=u.clone().multiplyScalar(-1.001).addVector(c),l=u.clone().multiplyScalar(1.001).addVector(c),h=(new ct).orth2d(d.x,l.x,d.y,l.y,d.z,l.z);return this.lightView.copyFrom(i),this.lightProjection.copyFrom(h),ct.multiply(h,i,this.lightViewProjection)}this.lightViewProjection.setIdentity()},a.prototype.updateSpotLightViewProjection=function(t){if(t.isSpot()){var e=t.getWorldPosition(),a=t.direction.clone(),n=a.clone().multiplyScalar(10),r=e.clone().addVector(n),o=S.computeUpVector(a,new S),i=(new ct).lookAt(e,r,o),s=this.shadowAABB.clone().transform(i),c=[new S(s.min.x,s.min.y,s.min.z),new S(s.min.x,s.min.y,s.max.z),new S(s.min.x,s.max.y,s.min.z),new S(s.min.x,s.max.y,s.max.z),new S(s.max.x,s.min.y,s.min.z),new S(s.max.x,s.min.y,s.max.z),new S(s.max.x,s.max.y,s.min.z),new S(s.max.x,s.max.y,s.max.z)],u=1,d=1e4,l=-1e4;c.map((function(t){if(t.z<=0){var e=new S(0,t.y,t.z).normalize();u=Math.min(u,-e.z),d=Math.min(d,-t.z),l=Math.max(l,-t.z)}}));var h=Math.acos(u),f=2*Math.min(h,t.outerConeAngle),p=(new ct).perspective(f,1,d,l,!1);return ct.multiply(p,i,this.lightViewProjection)}this.lightViewProjection.setIdentity()},a.prototype.getShadowOptions=function(){return{viewProjectionMatrix:this.lightViewProjection,softness:this.softness}},a.prototype.updateShadowUniforms=function(){var t=this.getShadowOptions();this.primitiveList.forEach((function(e){e.updateUniformForShadow(t)}))},a.prototype.getShadowLight=function(e){for(var a=e.lightManager.lightList,n=0;n<a.length;n++){var r=a[n];if(r.lightType===t.PLightType.directional||r.lightType===t.PLightType.spot)return r}},a.prototype.getShadowPrimitiveCount=function(t){var e=0;return t.meshList.forEach((function(t){t.primitives.forEach((function(t){t.isEnableShadow()&&(e+=1)}))})),e},a.prototype.updateRenderPass=function(t){var e=this;if(void 0!==this.basePass){var a=this.basePass;this.meshCacheSet.forward(),this.primitiveList.forEach((function(t){t.isEnableShadow()&&void 0!==t.shadowMesh&&e.meshCacheSet.now.add(t.shadowMesh)})),this.meshCacheSet.forRemovedItem((function(t){a.removeMesh(t)})),this.meshCacheSet.forAddedItem((function(t){a.addMesh(t)}))}this.renderPassCacheSet.forward(),this.hasRenderObject()&&(void 0!==this.basePass&&this.renderPassCacheSet.now.add(this.basePass),void 0!==this.xFilterPass&&this.renderPassCacheSet.now.add(this.xFilterPass),void 0!==this.yFilterPass&&this.renderPassCacheSet.now.add(this.yFilterPass));var n=!1;this.renderPassCacheSet.forRemovedItem((function(e){t.removeRenderPass(e),n=!0}));var r=!1;this.renderPassCacheSet.forAddedItem((function(e){t.addRenderPass(e),r=!0})),r?this.updateFrameSemantics(t.semantics,!0):n&&this.updateFrameSemantics(t.semantics,!1)},a.prototype.updateFrameSemantics=function(t,e){var a=this;e?(void 0!==this.basePass&&t.setSemantic("Shadow0Color",(function(){return a.basePass.attachments[0].texture})),void 0!==this.xFilterPass&&t.setSemantic("Shadow1Color",(function(){return a.xFilterPass.attachments[0].texture})),void 0!==this.yFilterPass&&t.setSemantic("ShadowNColor",(function(){return a.yFilterPass.attachments[0].texture}))):(t.setSemantic("Shadow0Color",void 0),t.setSemantic("Shadow1Color",void 0),t.setSemantic("ShadowNColor",void 0))},a.prototype.isEnable=function(){return this.enable&&this.runtimeEnable},a.prototype.hasRenderObject=function(){return this.isEnable()&&this.primitiveList.length>0},a.prototype.getCurrentPrimitiveList=function(){var t=[];return this.meshList.forEach((function(e){e.visible&&e.primitives.forEach((function(e){e.isEnableShadow()&&void 0!==e.shadowMesh&&t.push(e)}))})),t},a.prototype.isSupportTextureOptions=function(){return this.type===e.glContext.FLOAT?Qt.isSupportFloatTexture(this.engine):this.type!==e.glContext.HALF_FLOAT||Qt.isSupportHalfFloatTexture(this.engine)},a.prototype.getBaseFBOOptions=function(){var t=new y(this.width,this.height),a={texture:{format:this.format,type:this.type,minFilter:this.filter,magFilter:this.filter}},n={storageType:e.RenderPassAttachmentStorageType.depth_16_opaque};return new je({resolution:t,colorAttachments:[a],depthAttachment:n})},a.prototype.getFilterFBOOptions=function(){var t=new y(this.width,this.height),e={texture:{format:this.format,type:this.type,minFilter:this.filter,magFilter:this.filter}};return new je({resolution:t,colorAttachments:[e]})},a.prototype.getSoftness=function(t){var e,a=null!==(e=null==t?void 0:t.softness)&&void 0!==e?e:1.5;return a>=0&&a<=2?a:(console.error("Invalid softness value from shadow init options, ".concat(a)),g.clamp(a,0,2))},a.prototype.getTextureSize=function(t){var e,a,n=null!==(e=null==t?void 0:t.width)&&void 0!==e?e:1024,r=null!==(a=null==t?void 0:t.height)&&void 0!==a?a:1024;return n===r&&n>0&&n<=4096?[n,r]:(console.error("Invalid texture size from shadow init options, ".concat(n,"x").concat(r)),[1024,1024])},a.prototype.getTextureType=function(t){var a,n=null!==(a=null==t?void 0:t.type)&&void 0!==a?a:e.glContext.HALF_FLOAT;return n===e.glContext.UNSIGNED_BYTE||n===e.glContext.HALF_FLOAT||n===e.glContext.FLOAT?n:(console.error("Invalid texture type from shadow init options, ".concat(n)),e.glContext.HALF_FLOAT)},a.prototype.getTextureFormat=function(t){var a,n=null!==(a=null==t?void 0:t.format)&&void 0!==a?a:e.glContext.RGBA;return n===e.glContext.RGBA?n:(console.error("Invalid texture format from shadow init options, ".concat(n)),e.glContext.RGBA)},a.prototype.getTextureFilter=function(t){var a,n=null!==(a=null==t?void 0:t.filter)&&void 0!==a?a:e.glContext.LINEAR;return n===e.glContext.NEAREST||n===e.glContext.LINEAR?n:(console.error("Invalid texture filter from shadow init options, ".concat(n)),e.glContext.LINEAR)},Object.defineProperty(a.prototype,"mainPassUniformSemantics",{get:function(){return{u_ShadowSampler:"ShadowNColor"}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"basePassName",{get:function(){return this.sceneManager.compName+"_ShadowBasePass"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"xFilterPassName",{get:function(){return this.sceneManager.compName+"_ShadowXFilterPass"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"yFilterPassName",{get:function(){return this.sceneManager.compName+"_ShadowYFilterPass"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"xFilterMeshName",{get:function(){return this.sceneManager.compName+"_ShadowXFilterMesh"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"yFilterMeshName",{get:function(){return this.sceneManager.compName+"_ShadowYFilterMesh"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shadowPassList",{get:function(){var t=[];return void 0!==this.basePass&&t.push(this.basePass),void 0!==this.xFilterPass&&t.push(this.xFilterPass),void 0!==this.yFilterPass&&t.push(this.yFilterPass),t},enumerable:!1,configurable:!0}),a}(),Ye=function(a){function n(e,n,r,o){var i=a.call(this)||this;i.engine=e,i.parentIndex=-1,i.primitives=[],i.hide=!0,i.priority=0,i.boundingBox=new Ot,i.visBoundingBox=!1,i.isBuilt=!1,i.isDisposed=!1;var s=new Qe(n,o);return i.name=s.getName(),i.type=t.PObjectType.mesh,i.visible=!1,i.ownerItem=r,i.parentIndex=s.getParentIndex(),i.parentItem=s.parentItem,i.parentItemId=s.getParentId(),i.skin=s.getSkinObj(e),i.morph=s.getMorphObj(),i.hide=s.isHide(),i.priority=(null==r?void 0:r.listIndex)||0,i.primitives=[],s.getPrimitives().forEach((function(t){var e=new Ze(i.engine);e.create(t,i),i.primitives.push(e)})),i.primitives.length<=0&&console.warn("No primitive inside mesh item ".concat(s.getName())),i.boundingBox=i.getItemBoundingBox(n.content.interaction),Rt.getInstance().visBoundingBox&&(i.boundingBoxMesh=new Ge(i.engine,i.priority)),i}return r(n,a),n.prototype.build=function(t,e,a){this.isBuilt||(this.isBuilt=!0,this.primitives.forEach((function(n){n.build(t,e,a)})))},n.prototype.tick=function(t){this.visible&&(void 0!==this.ownerItem&&this.transform.setMatrix(this.ownerItem.transform.getWorldMatrix()),void 0!==this.skin&&this.skin.updateSkinMatrices())},n.prototype.addToRenderObjectSet=function(t){this.visible&&(this.primitives.forEach((function(e){t.add(e.effectsMesh)})),this.visBoundingBox&&void 0!==this.boundingBoxMesh&&t.add(this.boundingBoxMesh.mesh))},n.prototype.dispose=function(){var t,e,a;this.isDisposed||(this.isDisposed=!0,this.engine=null,this.parentItem=void 0,null===(t=this.skin)||void 0===t||t.dispose(),this.skin=void 0,null===(e=this.morph)||void 0===e||e.dispose(),this.morph=void 0,this.primitives.forEach((function(t){t.dispose()})),this.primitives=[],null===(a=this.boundingBoxMesh)||void 0===a||a.dispose(),this.boundingBoxMesh=void 0)},n.prototype.updateMorphWeights=function(t){if(void 0!==this.morph&&this.morph.hasMorph()){var e=this.morph.morphWeightsArray;if(void 0!==e){if(e.length!=t.length)throw new Error("weight array length mismatch");for(var a=0;a<e.length;a++)e[a]=t[a]}}},n.prototype.updateParentItem=function(t){this.parentItem=t,void 0!==this.skin&&this.skin.updateParentItem(t)},n.prototype.updateUniformsForScene=function(t){var e=this.matrix,a=e.clone().inverse().transpose();if(this.primitives.forEach((function(n){n.updateUniformsForScene(e,a,t)})),0===t.deltaSeconds&&void 0!==this.boundingBoxMesh){this.computeBoundingBox(e);var n=new S(1,1,1),r=this.boundingBox.min,o=this.boundingBox.max,i=new Float32Array([r.x,r.y,r.z,o.x,r.y,r.z,o.x,o.y,r.z,r.x,o.y,r.z,r.x,r.y,o.z,o.x,r.y,o.z,o.x,o.y,o.z,r.x,o.y,o.z]);this.boundingBoxMesh.update(e,t.viewProjectionMatrix,i,n)}},n.prototype.updateUniformForShadow=function(t){this.primitives.forEach((function(e){e.updateUniformForShadow(t)}))},n.prototype.hitTesting=function(t,e){var a,n=this.matrix,r=n.clone().inverse(),o=ct.multiplyByPoint(r,t,new S),i=ct.multiplyByPointAsVector(r,e,new S),s=this.boundingBox,c=jt(o,i,s.min,s.max);return void 0===c?[]:(Rt.getInstance().isEditorEnv?this.primitives.forEach((function(t){var e=t.hitTesting(o,i,n,r);void 0!==e&&(void 0===a||a>e)&&(a=e)})):a=c,void 0===a?[]:(i.multiplyScalar(a),o.addVector(i),n.multiplyByPoint3(o),[[o.x,o.y,o.z]]))},n.prototype.computeBoundingBox=function(t){var e=this.boundingBox.makeEmpty(),a=t.clone().inverse();return this.primitives.forEach((function(t){var n=t.computeBoundingBox(a);e.union(n)})),e},n.prototype.getItemBoundingBox=function(t){var a,n,r,o;if(void 0===t)return new Ot;if(t.type===e.spec.ModelBoundingType.box){var i=null!==(a=t.center)&&void 0!==a?a:[0,0,0],s=null!==(n=t.size)&&void 0!==n?n:[0,0,0],c=S.fromArray(i),u=S.fromArray(s).multiplyScalar(.5),d=c.clone().subVector(u),l=c.clone().addVector(u);return new Ot(d,l)}i=null!==(r=t.center)&&void 0!==r?r:[0,0,0];var h=.5*(null!==(o=t.radius)&&void 0!==o?o:0);d=(c=S.fromArray(i)).clone().subScalar(h),l=c.clone().addScalar(h);return new Ot(d,l)},n.prototype.getParentId=function(){return this.parentItemId},Object.defineProperty(n.prototype,"hasSkin",{get:function(){return void 0!==this.skin},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"mriMeshs",{get:function(){return this.primitives.map((function(t){return t.effectsMesh}))},enumerable:!1,configurable:!0}),n}(Dt),Ze=function(){function a(e){this.engine=e,this.name="",this.effectsPriority=0,this.boundingBox=new Ot,this.isCompressed=!1,this.shadowType=t.PShadowType.none}return a.prototype.create=function(e,a){if(this.parent=a,this.skin=a.skin,this.morph=a.morph,this.setGeometry(e.geometry),this.setMaterial(e.material),this.name=a.name,this.effectsPriority=a.priority,this.geometry.setHide(a.hide),void 0!==this.skin){var n=this.skin.getJointCount();if(this.jointMatrixList=new Float32Array(16*n),this.jointNormalMatList=new Float32Array(16*n),this.skin.isTextureDataMode()){var r=this.skin.textureDataMode===t.TextureDataMode.half_float;this.jointMatrixTexture=new pe(this.engine),this.jointNormalMatTexture=new pe(this.engine),this.jointMatrixTexture.create(n,r,"jointMatrixTexture"),this.jointNormalMatTexture.create(n,r,"jointNormalMatTexture")}}else(this.geometry.hasWeights()||this.geometry.hasJoints())&&console.warn("Geometry has weight and/or joint array, but the skin is missing.");this.isCompressed=this.geometry.isCompressed(),this.shadowType=t.PShadowType.none,this.material instanceof Pe&&this.material.enableShadow&&(this.shadowType=t.PShadowType.expVariance)},a.prototype.build=function(t,a,n){var r=Rt.getInstance(),o=this.getFeatureList(t,!0,n);this.material.build(o);var i=this.isEnableShadow()?a:{};i.u_ViewProjectionMatrix="VIEWPROJECTION",i.u_ModelMatrix="MODEL",i.uEditorTransform="EDITOR_TRANSFORM";var s=e.Material.create(this.engine,{shader:{vertex:this.material.vertexShaderCode,fragment:this.material.fragmentShaderCode,shared:r.shaderShared},uniformSemantics:i});this.material.setMaterialStates(s);var c=e.Mesh.create(this.engine,{name:this.name,material:s,geometry:this.getEffectsGeometry(),priority:this.effectsPriority});if(void 0!==this.effectsMesh&&this.effectsMesh.dispose(),this.effectsMesh=c,this.isEnableShadow()){this.shadowMaterial=new We,this.shadowMaterial.create({name:this.name+"_ShadowMaterial",shadowType:this.shadowType});var u=this.getFeatureList(t,!1,n);this.shadowMaterial.build(u);var d=this.shadowMaterial.vertexShaderCode,l=this.shadowMaterial.fragmentShaderCode,h=e.Material.create(this.engine,{shader:{vertex:d,fragment:l,shared:r.shaderShared}});this.shadowMaterial.setMaterialStates(h);var f=e.Mesh.create(this.engine,{name:this.name+"_shadow",material:h,geometry:this.getEffectsGeometry(),priority:this.effectsPriority});void 0!==this.shadowMesh&&this.shadowMesh.dispose(),this.shadowMesh=f}},a.prototype.getFeatureList=function(e,a,n){var r=[];if(this.geometry.hasNormals()&&r.push("HAS_NORMALS 1"),this.geometry.hasTangents()&&r.push("HAS_TANGENTS 1"),this.geometry.hasUVCoords(1)&&r.push("HAS_UV_SET1 1"),this.geometry.hasUVCoords(2)&&r.push("HAS_UV_SET2 1"),void 0!==this.morph&&this.morph.hasMorph()){r.push("USE_MORPHING"),r.push("WEIGHT_COUNT ".concat(this.morph.morphWeightsLength));for(var o=0;o<this.morph.morphWeightsLength;o++)this.morph.hasPositionMorph&&r.push("HAS_TARGET_POSITION".concat(o)),this.morph.hasNormalMorph&&r.push("HAS_TARGET_NORMAL".concat(o)),this.morph.hasTangentMorph&&r.push("HAS_TARGET_TANGENT".concat(o))}void 0!==this.skin&&(r.push("USE_SKINNING 1"),r.push("JOINT_COUNT ".concat(this.skin.getJointCount())),r.push("HAS_JOINT_SET1 1"),r.push("HAS_WEIGHT_SET1 1"),this.skin.textureDataMode&&r.push("USE_SKINNING_TEXTURE 1")),this.isEnableShadow()&&(this.shadowType===t.PShadowType.standard?r.push("SHADOWMAP_STANDARD 1"):this.shadowType===t.PShadowType.variance?r.push("SHADOWMAP_VSM 1"):(r.push("SHADOWMAP_EVSM 1"),r.push("SHADOWMAP_EVSM_PCF 1")),a&&r.push("USE_SHADOW_MAPPING 1")),this.material.materialType!==t.PMaterialType.unlit&&(e>0&&this.geometry.hasNormals()&&(r.push("USE_PUNCTUAL 1"),r.push("LIGHT_COUNT ".concat(e))),void 0!==n&&n.available&&(r.push("USE_IBL 1"),r.push("USE_TEX_LOD 1"),n.hasDiffuseImage||r.push("IRRADIANCE_COEFFICIENTS 1")));var i=Rt.getInstance().renderMode3D,s=this.getRenderMode3DDefine(i);return void 0!==s&&(r.push("DEBUG_OUTPUT 1"),r.push("".concat(s," 1"))),r},a.prototype.addToRenderObjectSet=function(t){t.add(this.effectsMesh)},a.prototype.dispose=function(){var t,a,n,r;this.engine=null,this.parent=void 0,this.skin=void 0,this.morph=void 0,this.geometry.dispose(),this.material.dispose(),this.jointMatrixList=void 0,this.jointNormalMatList=void 0,null===(t=this.jointMatrixTexture)||void 0===t||t.dispose(),this.jointMatrixTexture=void 0,null===(a=this.jointNormalMatTexture)||void 0===a||a.dispose(),this.jointNormalMatTexture=void 0,this.effectsMesh.dispose({geometries:e.DestroyOptions.keep,material:e.DestroyOptions.keep}),this.effectsMesh=void 0,null===(n=this.shadowMesh)||void 0===n||n.dispose({geometries:e.DestroyOptions.keep,material:e.DestroyOptions.keep}),this.shadowMesh=void 0,null===(r=this.shadowMaterial)||void 0===r||r.dispose(),this.shadowMaterial=void 0},a.prototype.updateUniformsForScene=function(t,e,a){this.updateUniformsByAnimation(t,e),this.updateUniformsByScene(a),this.material.updateUniforms(this.getModelMaterial())},a.prototype.updateUniformForShadow=function(t){var e=this.getShadowModelMaterial();void 0!==e&&(e.setMatrix("u_ViewProjectionMatrix",t.viewProjectionMatrix.toArray()),void 0!==this.shadowMaterial&&this.shadowMaterial.updateUniforms(e))},a.prototype.hitTesting=function(e,a,n,r){var o=this.boundingBox,i=jt(e,a,o.min,o.max),s=[];if(void 0!==i){if(void 0!==this.skin)this.skin.animationMatrices.forEach((function(t){s.push(ct.multiply(r,t,new ct))}));var c=new re,u=this.material.faceSideMode===t.PFaceSideMode.both;return c.create(this.geometry.geometry,u,s),c.getHitPoint(e,a)}},a.prototype.computeBoundingBox=function(t){if(void 0===this.skin&&!this.boundingBox.isEmpty())return this.boundingBox;var e=[];void 0!==this.skin&&this.skin.animationMatrices.forEach((function(a){e.push(ct.multiply(t,a,new ct))}));var a=new ne;return a.create(this.geometry.geometry,e),a.getBoundingBox(this.boundingBox)},a.prototype.getRenderMode3DDefine=function(t){switch(t){case e.spec.RenderMode3D.uv:return"DEBUG_UV";case e.spec.RenderMode3D.normal:return"DEBUG_NORMAL";case e.spec.RenderMode3D.basecolor:return"DEBUG_BASECOLOR";case e.spec.RenderMode3D.alpha:return"DEBUG_ALPHA";case e.spec.RenderMode3D.metallic:return"DEBUG_METALLIC";case e.spec.RenderMode3D.roughness:return"DEBUG_ROUGHNESS";case e.spec.RenderMode3D.ao:return"DEBUG_OCCLUSION";case e.spec.RenderMode3D.emissive:return"DEBUG_EMISSIVE"}},a.prototype.updateUniformsByAnimation=function(t,e){var a=this.getModelMaterial(),n=this.getShadowModelMaterial();a.setMatrix("u_ModelMatrix",t.toArray()),a.setMatrix("u_NormalMatrix",e.toArray()),void 0!==n&&(n.setMatrix("u_ModelMatrix",t.toArray()),n.setMatrix("u_NormalMatrix",e.toArray()));var r=this.skin;if(void 0!==r){var o=this.jointMatrixList,i=this.jointNormalMatList;if(r.computeMeshAnimMatrices(t,o,i),r.textureDataMode){var s=this.jointMatrixTexture,c=this.jointNormalMatTexture;s.update(o),c.update(i),a.setTexture("u_jointMatrixSampler",s.getTexture()),a.setTexture("u_jointNormalMatrixSampler",c.getTexture())}else{var u=[],d=[];o.forEach((function(t){return u.push(t)})),i.forEach((function(t){return d.push(t)})),a.setMatrixNumberArray("u_jointMatrix",u),a.setMatrixNumberArray("u_jointNormalMatrix",d),void 0!==n&&(n.setMatrixNumberArray("u_jointMatrix",u),n.setMatrixNumberArray("u_jointNormalMatrix",d))}}var l=this.morph;if(void 0!==l&&l.hasMorph()){var h=l.morphWeightsArray,f=[];h.forEach((function(t){return f.push(t)})),a.setFloats("u_morphWeights",f),void 0!==n&&n.setFloats("u_morphWeights",f)}},a.prototype.updateUniformsByScene=function(t){var e,a=this.getModelMaterial();if(a.setMatrix("u_ViewProjectionMatrix",t.viewProjectionMatrix.toArray()),a.setVector3("u_Camera",t.cameraPosition.toArray()),this.isEnableShadow(),!this.isUnlitMaterial()){for(var n=t.maxLightCount,r=t.lightList,o=0;o<n;o++)if(o<r.length){var i=r[o],s=i.visible?i.intensity:0;a.setVector3("u_Lights[".concat(o,"].direction"),i.getWorldDirection().toArray()),a.setFloat("u_Lights[".concat(o,"].range"),i.range),a.setVector3("u_Lights[".concat(o,"].color"),i.color.toArray()),a.setFloat("u_Lights[".concat(o,"].intensity"),s),a.setVector3("u_Lights[".concat(o,"].position"),i.getWorldPosition().toArray()),a.setFloat("u_Lights[".concat(o,"].innerConeCos"),Math.cos(i.innerConeAngle)),a.setFloat("u_Lights[".concat(o,"].outerConeCos"),Math.cos(i.outerConeAngle)),a.setInt("u_Lights[".concat(o,"].type"),i.lightType),a.setVector2("u_Lights[".concat(o,"].padding"),i.padding.toArray())}else a.setVector3("u_Lights[".concat(o,"].direction"),[0,0,0]),a.setFloat("u_Lights[".concat(o,"].range"),0),a.setVector3("u_Lights[".concat(o,"].color"),[0,0,0]),a.setFloat("u_Lights[".concat(o,"].intensity"),0),a.setVector3("u_Lights[".concat(o,"].position"),[0,0,0]),a.setFloat("u_Lights[".concat(o,"].innerConeCos"),0),a.setFloat("u_Lights[".concat(o,"].outerConeCos"),0),a.setInt("u_Lights[".concat(o,"].type"),99999),a.setVector2("u_Lights[".concat(o,"].padding"),[0,0]);var c=t.skybox;if(void 0!==c&&c.available){if(a.setVector2("u_IblIntensity",[c.currentIntensity,c.currentReflectionsIntensity]),a.setTexture("u_brdfLUT",c.brdfLUT),void 0!==c.diffuseImage)a.setTexture("u_DiffuseEnvSampler",c.diffuseImage);else{var u=c.irradianceCoeffs;["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(t,e){a.setVector3("u_shCoefficients.".concat(t),u[e])}))}a.setInt("u_MipCount",null!==(e=c.specularMipCount)&&void 0!==e?e:1),a.setTexture("u_SpecularEnvSampler",c.specularImage)}}},a.prototype.hasSkin=function(){return void 0!==this.skin},a.prototype.getEffectsGeometry=function(){return this.geometry.geometry},a.prototype.setGeometry=function(t){this.geometry=t instanceof Je?t:new Je(t)},a.prototype.setMaterial=function(t){this.material=t instanceof Ee||t instanceof Pe?t:Oe(t)},a.prototype.getModelMaterial=function(){return this.effectsMesh.material},a.prototype.getShadowModelMaterial=function(){var t;return null===(t=this.shadowMesh)||void 0===t?void 0:t.material},a.prototype.isEnableShadow=function(){return this.shadowType!==t.PShadowType.none&&this.material.materialType!==t.PMaterialType.unlit},a.prototype.isUnlitMaterial=function(){return this.material.materialType===t.PMaterialType.unlit},a.prototype.hasMorph=function(){return void 0!==this.morph&&this.morph.hasMorph()},a.prototype.getWorldBoundingBox=function(){if(void 0===this.parent)return this.boundingBox.isEmpty()&&this.computeBoundingBox(ct.IDENTITY.clone()),this.boundingBox;var t=this.parent.matrix;return this.boundingBox.isEmpty()&&this.computeBoundingBox(t.clone().inverse()),this.boundingBox.clone().transform(t)},a}(),Je=function(){function t(t){this.geometry=t,this.attributeNames=t.getAttributeNames()}return t.prototype.dispose=function(){this.geometry=void 0,this.attributeNames=[]},t.prototype.hasAttribute=function(t){return-1!==this.attributeNames.findIndex((function(e){return e===t}))},t.prototype.setHide=function(t){var e=this.geometry;if(0===e.getDrawCount()){var a=e.getIndexData();void 0!==a&&e.setDrawCount(a.length)}t?e.getDrawCount()>=0&&e.setDrawCount(-e.getDrawCount()):e.getDrawCount()<0&&e.setDrawCount(-e.getDrawCount())},t.prototype.isCompressed=function(){this.geometry.getAttributeData("a_Position");return!1},t.prototype.hasPositions=function(){return this.hasAttribute("a_Position")},t.prototype.hasNormals=function(){return this.hasAttribute("a_Normal")},t.prototype.hasTangents=function(){return this.hasAttribute("a_Tangent")},t.prototype.hasUVCoords=function(t){return this.hasAttribute("a_UV".concat(t))},t.prototype.hasColors=function(){return this.hasAttribute("a_Color")},t.prototype.hasJoints=function(){return this.hasAttribute("a_Joint1")},t.prototype.hasWeights=function(){return this.hasAttribute("a_Weight1")},t}(),Qe=function(){function t(t,e){this.item=t,this.parentItem=e,this.options=t.content.options;var a=!0,n=new le,r=t.content.options;r.primitives.forEach((function(t,e){if(0===e)n.create(t.geometry);else{var r=new le;r.create(t.geometry)?n.equals(r)||(a=!1,console.error("Morpth target mismatch between primtives: ".concat(JSON.stringify(n),", ").concat(JSON.stringify(r)))):a=!1}})),a?(void 0!==r.weights&&n.initWeights(r.weights),this.morphObj=n):this.morphObj=new le}return t.prototype.hasMorphTarget=function(){return this.morphObj.hasMorph()},t.prototype.getMorphObj=function(){if(this.hasMorphTarget())return this.morphObj},t.prototype.getParentId=function(){return this.item.parentId},t.prototype.getName=function(){return this.item.name},t.prototype.isHide=function(){return!0===this.options.hide},t.prototype.getParentNode=function(){var t=this.getParentIndex();if(void 0!==this.parentItem&&t>=0)return this.parentItem.content.getNodeById(t)},t.prototype.getParentIndex=function(){var t;return null!==(t=this.options.parent)&&void 0!==t?t:-1},t.prototype.getPrimitives=function(){return this.options.primitives},t.prototype.getPrimitiveCount=function(){return this.options.primitives.length},t.prototype.hasSkin=function(){return void 0!==this.options.skin},t.prototype.getSkinOpts=function(){return this.options.skin},t.prototype.getSkinObj=function(t){var e=this.getSkinOpts();if(void 0!==e){var a=new de;return a.create(e,t,this.parentItem),a}},t}(),Ke=function(){function a(t){this.maxLightCount=16,this.renderSkybox=!1,this.compName="SceneManger",this.itemList=[],this.meshList=[],this.engine=t,this.lightManager=new Ve,this.cameraManager=new Ue,this.shadowManager=new Xe,this.parentId2Mesh=new Map,this.enableDynamicSort=!1,this.tickCount=0,this.lastTickSecond=-1,this.sceneAABBCache=new Ot,this.renderedMeshSet=new He,this.allRenderedMeshSet=new Set}return a.prototype.initial=function(t){this.clean(),this.compName=t.componentName,this.renderer=t.renderer,this.engine=t.renderer.engine,this.sceneCache=t.sceneCache,this.enableDynamicSort=!0===t.enableDynamicSort,this.renderSkybox=t.renderSkybox,this.maxLightCount=t.lightItemCount,this.cameraManager.initial(this.renderer.getWidth(),this.renderer.getHeight()),this.brdfLUT=this.sceneCache.getBrdfLutTexture(),this.initGlobalState(t),this.maxLightCount>8&&console.warn("Too many light items: ".concat(this.maxLightCount," light(s)"))},a.prototype.initGlobalState=function(t){var a,n,r,o,i,s=this.engine.gpuCapability,c=Rt.getInstance();c.reset(),c.isWebGL2=2===s.level,c.runtimeEnv=null!==(a=t.runtimeEnv)&&void 0!==a?a:e.PLAYER_OPTIONS_ENV_EDITOR,c.compatibleMode=null!==(n=t.compatibleMode)&&void 0!==n?n:"gltf",c.visBoundingBox=null!==(r=t.visBoundingBox)&&void 0!==r&&r,c.renderMode3D=null!==(o=t.renderMode3D)&&void 0!==o?o:e.spec.RenderMode3D.none,c.renderMode3DUVGridSize=null!==(i=t.renderMode3DUVGridSize)&&void 0!==i?i:1/16},a.prototype.clean=function(){this.dispose(),this.compName="",this.renderer=void 0,this.sceneCache=void 0,this.itemList=[],this.meshList=[],this.lightManager=new Ve,this.cameraManager=new Ue,this.shadowManager=new Xe,this.parentId2Mesh=new Map,this.brdfLUT=void 0,this.skybox=void 0,this.lastTickSecond=-1,this.tickCount=0,this.renderedMeshSet=new He,this.allRenderedMeshSet=new Set},a.prototype.dispose=function(){var t;this.itemList.forEach((function(t){return t.dispose()})),this.itemList=[],this.meshList.forEach((function(t){return t.dispose()})),this.meshList=[],this.lightManager.dispose(),this.cameraManager.dispose(),this.brdfLUT=void 0,null===(t=this.skybox)||void 0===t||t.dispose(),this.skybox=void 0,this.renderedMeshSet.clear(),this.allRenderedMeshSet.clear(),this.renderer=void 0,this.sceneCache=void 0,this.engine=void 0,this.parentId2Mesh.clear()},a.prototype.addItem=function(t){var a=t.content;if(a instanceof Ye){var n=a;void 0!==n.parentItemId&&this.parentId2Mesh.set(n.parentItemId,n),e.addItem(this.meshList,n),this.buildItem(a)}else if(a instanceof Le){var r=a;r.setup(this.brdfLUT),this.renderSkybox||(r.renderable=!1),this.skybox=r,this.buildItem(a)}else a instanceof ke?this.lightManager.insertLight(a):this.cameraManager.insertCamera(a);e.addItem(this.itemList,a)},a.prototype.removeItem=function(t){var a=t.content;if(a instanceof Ye){var n=a;void 0!==n.parentItemId&&this.parentId2Mesh.delete(n.parentItemId),e.removeItem(this.meshList,n)}else a instanceof Le?this.skybox=void 0:a instanceof ke?this.lightManager.remove(a):this.cameraManager.remove(a);e.removeItem(this.itemList,a)},a.prototype.updateDefaultCamera=function(t){var a=new e.Transform(o(o({},t),{valid:!0})),n=(new Lt).fromEffectsTransform(a);this.cameraManager.updateDefaultCamera(t.fov,t.near,t.far,t.position,n.getRotation(),t.clipMode)},a.prototype.buildItem=function(t){t instanceof Ye?t.build(this.maxLightCount,{},this.skybox):t instanceof Le&&t.build(this.getSceneCache())},a.prototype.build=function(){var t=this;this.meshList.forEach((function(e){e.build(t.maxLightCount,{},t.skybox)})),void 0!==this.skybox&&this.skybox.build(this.getSceneCache())},a.prototype.tick=function(t){var e=this,a=t,n=this.activeCamera,r=n.viewMatrix,o=n.projectionMatrix,i=o.clone().multiply(r),s={deltaSeconds:a,camera:n,cameraPosition:n.getEye(),viewMatrix:r,projectionMatrix:o,viewProjectionMatrix:i,winSize:n.getSize(),sceneRadius:1,lightList:this.lightManager.lightList,maxLightCount:this.maxLightCount,skybox:this.skybox};this.build(),this.lightManager.tick(a),this.renderedMeshSet.forward(),this.itemList.forEach((function(t){t.tick(a),t.updateUniformsForScene(s),t.addToRenderObjectSet(e.renderedMeshSet.now)})),this.enableDynamicSort&&this.dynamicSortMeshes(s),this.tickCount+=1,this.lastTickSecond+=a},a.prototype.updateDefaultRenderPass=function(t){var e=this;this.enableDynamicSort?(this.renderedMeshSet.last.forEach((function(e){t.removeMeshFromDefaultRenderPass(e)})),this.renderedMeshSet.now.forEach((function(a){t.addMeshToDefaultRenderPass(a),e.allRenderedMeshSet.add(a)}))):(this.renderedMeshSet.forRemovedItem((function(e){t.removeMeshFromDefaultRenderPass(e)})),this.renderedMeshSet.forAddedItem((function(a){t.addMeshToDefaultRenderPass(a),e.allRenderedMeshSet.add(a)})))},a.prototype.dynamicSortMeshes=function(t){var e=[],a=[];this.renderedMeshSet.now.forEach((function(t){e.push(t),a.push(t.priority)})),a.sort((function(t,e){return t-e}));var n=t.viewMatrix;e.sort((function(t,e){var a=Qt.isTransparentMesh(t),r=Qt.isTransparentMesh(e);if(a&&r){var o=S.unpack(t.worldMatrix,12,new S),i=S.unpack(e.worldMatrix,12,new S),s=n.multiplyByPoint3(o),c=n.multiplyByPoint3(i);return s.z-c.z}return a?1:r?-1:0}));for(var r=0;r<e.length;r++){var o=e[r],i=a[r];o.priority=i}},a.prototype.queryMesh=function(t){var e=this.parentId2Mesh.get(t);if(void 0!==e&&e.visible)return e},a.prototype.removeAllMeshesFromDefaultPass=function(t){this.renderedMeshSet.now.forEach((function(e){t.removeMeshFromDefaultRenderPass(e)}))},a.prototype.getSceneAABB=function(e){var a=null!=e?e:new Ot;return this.itemList.forEach((function(e){if(e.type===t.PObjectType.mesh){var n=e;if(n.ownerItem){var r=n.ownerItem.getWorldTransform(),o=ct.fromArray(r.getWorldMatrix()),i=n.computeBoundingBox(o);i.transform(o),a.union(i)}else a.union(n.computeBoundingBox(ct.IDENTITY.clone()))}})),a},a.prototype.printDebugInfo=function(){console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),this.meshList.forEach((function(t,e){console.info("Mesh: ",e,t)})),this.cameraManager.getCameraList().forEach((function(t,e){console.info("Camera: ",e,t)})),console.info("Default Camera: ",this.cameraManager.getDefaultCamera()),this.lightManager.lightList.forEach((function(t,e){console.info("Light: ",e,t)})),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")},a.prototype.getRenderer=function(){return this.renderer},a.prototype.getSceneCache=function(){return this.sceneCache},Object.defineProperty(a.prototype,"activeCamera",{get:function(){return this.cameraManager.getActiveCamera()},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"lightCount",{get:function(){return this.lightManager.lightCount},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shaderLightCount",{get:function(){return Math.min(10,this.lightManager.lightCount)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"enableShadowPass",{get:function(){return this.shadowManager.isEnable()},enumerable:!1,configurable:!0}),a}(),$e="_Native",ta=new Map;function ea(t,e){for(var a,n="".concat(t),r=[],o=0;o<e.length;o++)"number"==typeof e[o]&&ta.has(e[o])?r.push(ta.get(e[o])+"(".concat(e[o],")")):r.push(null===(a=e[o])||void 0===a?void 0:a.toString());return n+(r.length>0?"("+r.join(", ")+")":"()")}function aa(t,e){return function(){var a=t[e+$e].apply(this,arguments),n=t.getError();return n>0?(console.info("OpenGLError: "+function(t){var e,a=new Map;return a.set(WebGLRenderingContext.NO_ERROR,"NO_ERROR"),a.set(WebGLRenderingContext.INVALID_ENUM,"INVALID_ENUM"),a.set(WebGLRenderingContext.INVALID_VALUE,"INVALID_VALUE"),a.set(WebGLRenderingContext.INVALID_OPERATION,"INVALID_OPERATION"),a.set(WebGLRenderingContext.INVALID_FRAMEBUFFER_OPERATION,"INVALID_FRAMEBUFFER_OPERATION"),a.set(WebGLRenderingContext.OUT_OF_MEMORY,"OUT_OF_MEMORY"),a.set(WebGLRenderingContext.CONTEXT_LOST_WEBGL,"CONTEXT_LOST_WEBGL"),(null!==(e=a.get(t))&&void 0!==e?e:"UNKNOWN_ERROR")+"(".concat(t,")")}(n)+" ===> "+ea(e,arguments)),console.trace()):console.info(ea(e,arguments)),a}}var na,ra=function(){function t(t,e){this.baseTransform=e.transform,this.animationManager=new _e(t,e),this.build(t)}return t.prototype.tick=function(t){this.animationManager.tick(t)},t.prototype.getNodes=function(){return this.nodes},t.prototype.getNodeById=function(t){var e=this.cacheMap;if(!e[t]){var a="^".concat(t);e[t]=this.allNodes.find((function(t){return t.id===a}))}return e[t]},t.prototype.getNodeByName=function(t){var e=this.cacheMap;return e[t]||(e[t]=this.allNodes.find((function(e){return e.name===t}))),e[t]},t.prototype.getNodeTransform=function(t){var e=this.getNodeById(t);return e?e.transform:this.baseTransform},t.prototype.dispose=function(){var t;this.allNodes=[],this.nodes=[],this.cacheMap={},this.baseTransform=null,null===(t=this.animationManager)||void 0===t||t.dispose(),this.animationManager=null},t.prototype.build=function(t){var a=this,n=this.baseTransform,r=t.nodes.map((function(t,r){return{name:t.name||t.id||r+"",transform:new e.Transform(o(o({},t.transform),{valid:!0}),n),id:"^".concat(t.id||r),children:[],tree:a}}));this.cacheMap={},r.forEach((function(e,a){var o=t.nodes[a].children;e.transform.name=e.name,e.transform.setValid(!0),o&&o.forEach((function(t){var a=r[t];a&&a!==e&&(a.transform.parentTransform!==n&&console.error("Node parent has been set."),a.transform.parentTransform=e.transform,e.children.push(a))}))})),this.allNodes=r,this.nodes=t.children.map((function(t){return r[t]}))},t}(),oa=function(t){function a(){return null!==t&&t.apply(this,arguments)||this}return r(a,t),Object.defineProperty(a.prototype,"type",{get:function(){return e.VFX_ITEM_TYPE_TREE},enumerable:!1,configurable:!0}),a.prototype.onConstructed=function(t){this.options=t.content.options.tree,this.timeline=new e.TimelineComponent(t.content,this),this.timeline.getRenderData(0,!0)},a.prototype.onLifetimeBegin=function(){this.content.baseTransform.setValid(!0)},a.prototype.onItemRemoved=function(t,e){void 0!==this.content&&this.content.dispose()},a.prototype.onItemUpdate=function(t,e){var a,n=.001*(this.timeInms-this.delayInms);null===(a=this.timeline)||void 0===a||a.getRenderData(n,!0),this.content.tick(t)},a.prototype.doCreateContent=function(){return new ra(this.options,this)},a.prototype.getNodeTransform=function(t){if(void 0===this.content)return this.transform;var e=this.id+"^";if(0===t.indexOf(e)){var a=t.substring(e.length);return this.content.getNodeTransform(a)}return this.transform},a}(e.VFXItem),ia=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),Object.defineProperty(n.prototype,"type",{get:function(){return a},set:function(t){},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(t){var a;this.options=t,this.duration=t.duration,this.delay=null!==(a=t.delay)&&void 0!==a?a:0;var n=t.content.interaction;this.bounding=n&&JSON.parse(JSON.stringify(n)),t.type!==e.spec.ItemType.camera&&t.type!==e.spec.ItemType.light||(this.timeline=new e.TimelineComponent(t.content,this),this.timeline.getRenderData(0,!0)),t.type===e.spec.ItemType.skybox&&this.overwriteSkyboxFromCache(t.content.options)},n.prototype.handleVisibleChanged=function(t){void 0!==this.content&&this.content.onVisibleChanged(t)},n.prototype.doCreateContent=function(t){var e,a;switch(null===(e=this.options)||void 0===e?void 0:e.type){case"mesh":var n=this.options.content.options;oe.assertModelMeshOptions(n);var r=null===(a=this.composition)||void 0===a?void 0:a.getEngine();return new Ye(r,this.options,this);case"camera":var o=this.options.content.options;oe.assertModelCameraOptions(o);var i=t.width,s=t.height;return new De(this.options,i,s,this);case"light":var c=this.options.content.options;return oe.assertModelLightOptions(c),new ke(this.options,this);case"skybox":var u=this.options.content.options;return oe.assertModelSkyboxOptions(u),new Le(this.options,this);default:throw new Error("Invalid model item type, options: ".concat(this.options))}},n.prototype.overwriteSkyboxFromCache=function(t){var e,a=(null===(e=this.composition)||void 0===e?void 0:e.loaderData.cache).getSkyboxOptions();void 0!==a&&(void 0===t.specularImage||void 0===t.diffuseImage&&void 0===t.irradianceCoeffs)&&(t.diffuseImage=a.diffuseImage,t.irradianceCoeffs=a.irradianceCoeffs,t.specularImage=a.specularImage,t.specularImageSize=a.specularImageSize,t.specularMipCount=a.specularMipCount)},n.prototype.computeBoundingBox=function(){var t;if(void 0!==this._content&&this._content instanceof Ye){var a=ct.fromArray(this.transform.getWorldMatrix()),n=this._content.computeBoundingBox(a),r=n.getCenter(new S),o=n.getSize(new S);return this.bounding={behavior:null===(t=this.bounding)||void 0===t?void 0:t.behavior,type:e.spec.ModelBoundingType.box,center:[r.x,r.y,r.z],size:[o.x,o.y,o.z]},this.bounding}},n.prototype.updateTransform=function(){var t=this._content;if(void 0!==t){var e=new ct;e.setData(this.transform.getWorldMatrix()),t.matrix=e,t instanceof De&&this.composition&&(this.composition.camera.position=this.transform.position,this.composition.camera.setQuat(this.transform.quat),this.composition.camera.near=t.nearPlane,this.composition.camera.far=t.farPlane,this.composition.camera.fov=t.fovy)}},n.prototype.updateTransformPosition=function(t,e,a){var n;null===(n=this.timeline)||void 0===n||n.updatePosition(t,e,a),this.transform.setPosition(t,e,a)},n.prototype.onLifetimeBegin=function(t,e){void 0!==this.content&&(this.content instanceof Ye&&this.parent instanceof oa&&this.content.updateParentItem(this.parent),this.content.onVisibleChanged(!0))},n.prototype.onItemUpdate=function(t,e){var a,n=.001*(this.timeInms-this.delayInms);null===(a=this.timeline)||void 0===a||a.getRenderData(n,!0),this.updateTransform()},n.prototype.onItemRemoved=function(t,e){void 0!==this.content&&(this.content.onEntityRemoved(),this.content.dispose())},n.prototype.getHitTestParams=function(t){this.computeBoundingBox();var a=this.bounding;if(a&&(t||Number.isInteger(a.behavior))){var n=a.type;if(n===e.spec.ModelBoundingType.box){if(this.content instanceof Ye){var r=this.content;return{behavior:a.behavior,type:e.HitTestType.custom,collect:function(t,e){var a=S.fromArray(t.center),n=S.fromArray(t.direction);return r.hitTesting(a,n)}}}var o=this.transform.getWorldMatrix();return{behavior:a.behavior,type:e.HitTestType.custom,collect:function(t,e){return Vt(t,o,a)}}}if(n===e.spec.ModelBoundingType.sphere){var i=[0,0,0];this.transform.assignWorldTRS(i);var s=a.center?a.center.slice():[0,0,0];return s[0]+=i[0],s[1]+=i[1],s[2]+=i[2],{type:n,behavior:a.behavior,radius:a.radius||0,center:s}}}},n}(e.VFXItem),sa=function(n){function o(){var t=null!==n&&n.apply(this,arguments)||this;return t.name="model",t.deltaTime=0,t.runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,t.compatibleMode="gltf",t.renderSkybox=!0,t.visBoundingBox=!1,t.autoAdjustScene=!1,t.enableDynamicSort=!1,t.renderMode3D=e.spec.RenderMode3D.none,t.renderMode3DUVGridSize=1/16,t}return r(o,n),o.prepareResource=function(t,e){var a,n,r;return i(this,void 0,void 0,(function(){var o,i,c,u,d;return s(this,(function(s){switch(s.label){case 0:return o=null!==(a=e.env)&&void 0!==a?a:"",i="gltf",c=!1,void 0!==e.pluginData&&(u=["compatibleMode","renderSkybox","visBoundingBox","autoAdjustScene","enableDynamicSort","renderMode3D","renderMode3DUVGridSize"],d=e.pluginData,u.forEach((function(e){return t.storage[e]=d[e]})),t.storage.runtimeEnv=o,i=null!==(n=e.pluginData.compatibleMode)&&void 0!==n?n:i,c=null!==(r=e.pluginData.autoAdjustScene)&&void 0!==r?r:c),$t.preprocessEffectsScene(t,o,i,c),[4,ze.loadStaticResources()];case 1:return s.sent(),[2]}}))}))},o.prototype.onCompositionConstructed=function(t,e){var a,n,r,o,i,s,c,u;this.runtimeEnv=null!==(a=e.storage.runtimeEnv)&&void 0!==a?a:this.runtimeEnv,this.compatibleMode=null!==(n=e.storage.compatibleMode)&&void 0!==n?n:this.compatibleMode,this.renderSkybox=null!==(r=e.storage.renderSkybox)&&void 0!==r?r:this.renderSkybox,this.visBoundingBox=null!==(o=e.storage.visBoundingBox)&&void 0!==o?o:this.visBoundingBox,this.autoAdjustScene=null!==(i=e.storage.autoAdjustScene)&&void 0!==i?i:this.autoAdjustScene,this.enableDynamicSort=null!==(s=e.storage.enableDynamicSort)&&void 0!==s?s:this.enableDynamicSort,this.renderMode3D=null!==(c=e.storage.renderMode3D)&&void 0!==c?c:this.renderMode3D,this.renderMode3DUVGridSize=null!==(u=e.storage.renderMode3DUVGridSize)&&void 0!==u?u:this.renderMode3DUVGridSize;var d=t.renderer.engine;t.loaderData.sceneManager=new Ke(d);var l=new ze(d);l.setup(!1),t.loaderData.cache=l,$t.setupItem3DOptions(e,l,t)},o.prototype.onCompositionWillReset=function(t,e){this.getCache(t).getRenderPasses().forEach((function(t){e.removeRenderPass(t)})),this.getSceneManager(t).removeAllMeshesFromDefaultPass(e)},o.prototype.onCompositionReset=function(t,e){var a=this.getSceneManager(t),n=this.getCache(t),r=this.getLightItemCount(t);a.initial({componentName:"".concat(t.id),renderer:t.renderer,sceneCache:n,runtimeEnv:this.runtimeEnv,compatibleMode:this.compatibleMode,visBoundingBox:this.visBoundingBox,enableDynamicSort:this.enableDynamicSort,renderMode3D:this.renderMode3D,renderMode3DUVGridSize:this.renderMode3DUVGridSize,renderSkybox:this.renderSkybox,lightItemCount:r}),this.updateSceneCamera(t,a)},o.prototype.onCompositionDestroyed=function(t){this.disposeSceneManager(t),this.disposeCache(t)},o.prototype.onCompositionUpdate=function(t,e){this.deltaTime=e},o.prototype.onCompositionItemLifeBegin=function(t,e){e.type===a&&this.getSceneManager(t).addItem(e)},o.prototype.onCompositionItemRemoved=function(t,e){e.type===a&&this.getSceneManager(t).removeItem(e)},o.prototype.prepareRenderFrame=function(t,n){var r,o,i,s=this.getSceneManager(t);if(this.autoAdjustScene&&1==s.tickCount){var c=t.camera,u=(new Lt).fromEffectsTransform(c),d=(new Ft).fromPTransform(u).zAxis.clone(),l=null!==(r=c.fov)&&void 0!==r?r:45,h=null!==(o=c.aspect)&&void 0!==o?o:1,f=s.getSceneAABB(),p=f.clone().transform(u.getMatrix()).getSize(new S).multiplyScalar(.5),m=p.x,_=p.y,g=_*Math.max(m/_/h,1),y=f.getCenter(new S),v=g/Math.tan(.5*l*e.DEG2RAD),x=y.clone().addVector(d.clone().multiplyScalar(v+p.z));t.camera.position=x.toArray(),null===(i=t.items)||void 0===i||i.forEach((function(t){if(t.type===a){var e=t;if(e.content instanceof De){var n=ct.fromArray(e.transform.parentTransform.getWorldMatrix()).inverse().multiplyByPoint3(x);e.updateTransformPosition(n.x,n.y,n.z),console.info("Scene AABB [".concat(f.min.toArray(),"], [").concat(f.max.toArray(),"]")),console.info("Update camera position [".concat(n.toArray(),"]"))}}}))}return this.updateSceneCamera(t,s),s.tick(this.deltaTime),s.updateDefaultRenderPass(n),!0},o.prototype.postProcessFrame=function(t,e){this.getSceneManager(t).shadowManager.updateRenderPass(e)},o.prototype.getLightItemCount=function(e){var a=0;return e.items.forEach((function(e){var n,r;e instanceof ia&&((null===(n=e.content)||void 0===n?void 0:n.type)!==t.PObjectType.light&&"light"!==(null===(r=e.options)||void 0===r?void 0:r.type)||a++)})),a},o.prototype.updateSceneCamera=function(t,e){e.updateDefaultCamera(t.camera.getOptions())},o.prototype.getSceneManager=function(t){return t.loaderData.sceneManager},o.prototype.getCache=function(t){return t.loaderData.cache},o.prototype.disposeCache=function(t){var e=t.loaderData;e.cache.dispose(),delete e.cache},o.prototype.disposeSceneManager=function(t){var e=t.loaderData;e.sceneManager.dispose(),delete e.sceneManager},o}(e.AbstractPlugin),ca=function(t){function a(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="tree",e.order=2,e}return r(a,t),a.prototype.onCompositionConstructed=function(t,e){var a=t.getEngine(),n=new ge(a);t.loaderData.animSystem=n},a.prototype.onCompositionWillReset=function(t,e){var a=this.getAnimationSystem(t);void 0!==a&&a.dispose()},a.prototype.onCompositionDestroyed=function(t){var e=this.getAnimationSystem(t);void 0!==e&&e.dispose(),delete t.loaderData.animSystem},a.prototype.onCompositionItemLifeBegin=function(t,a){if(a.type===e.VFX_ITEM_TYPE_TREE){var n=this.getAnimationSystem(t),r=a.content;null==n||n.insert(r.animationManager)}},a.prototype.onCompositionItemRemoved=function(t,a){if(a.type===e.VFX_ITEM_TYPE_TREE){var n=this.getAnimationSystem(t),r=a.content;null==n||n.delete(r.animationManager)}},a.prototype.getAnimationSystem=function(t){var e=t.loaderData.animSystem;if(void 0!==e)return e},a}(e.AbstractPlugin);t.CameraGestureType=void 0,(na=t.CameraGestureType||(t.CameraGestureType={}))[na.none=0]="none",na[na.translate=1]="translate",na[na.rotate_focus=2]="rotate_focus",na[na.rotate_self=3]="rotate_self",na[na.scale=4]="scale";var ua,da=function(){function a(e){this.composition=e,this.cameraTransform=new Lt,this.cameraCoordiante=new Ft,this.startParams={type:t.CameraGestureType.none,mouseEvent:!1,clientX:0,clientY:0,clientWidth:512,clientHeight:512,target:""}}return a.prototype.getItem=function(){var t,e=this;return null===(t=this.composition.items)||void 0===t?void 0:t.find((function(t){return t.id===e.getCurrentTarget()}))},a.prototype.getCurrentTarget=function(){return this.startParams.target},a.prototype.getCurrentType=function(){return this.startParams.type},a.prototype.onKeyEvent=function(a){var n,r,i,s;this.startParams.target!==a.cameraID&&(this.startParams.target=a.cameraID,this.startParams.type=t.CameraGestureType.translate);var c=this.getItem();if(void 0===c)return console.warn("can't find camera item ".concat(this.startParams.target)),this.composition.camera.getOptions();var u=this.composition.camera,d=new e.Transform(o(o({},u.getOptions()),{valid:!0})),l=(new Lt).fromEffectsTransform(d),h=(new Ft).fromPTransform(l),f=null!==(n=a.xAxis)&&void 0!==n?n:0,p=null!==(r=a.yAxis)&&void 0!==r?r:0,m=null!==(i=a.zAxis)&&void 0!==i?i:0,_=h.xAxis.multiplyScalar(f);if(_.addVector(h.yAxis.multiplyScalar(p)),_.addVector(h.zAxis.multiplyScalar(m)),_.lengthSquared()<1e-5)return u.getOptions();_.normalize();var g=null!==(s=a.speed)&&void 0!==s?s:.1,y=l.getPosition();return y.addVector(_.clone().multiplyScalar(g)),c.transform.setPosition(y.x,y.y,y.z),c.updateTransform(),this.startParams.type===t.CameraGestureType.rotate_self&&(this.cameraTransform.setPosition(y),this.cameraCoordiante.origin=y),u.getOptions()},a.prototype.onXYMoveBegin=function(e,a,n,r,o){var i={type:t.CameraGestureType.translate,mouseEvent:!0,clientX:e,clientY:a,clientWidth:n,clientHeight:r,target:o};return this.startGesture(i)},a.prototype.onXYMoving=function(e,a,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,o={type:t.CameraGestureType.translate,mouseEvent:!0,clientX:e,clientY:a,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:null!=n?n:.015};return this.moveGesture(o)},a.prototype.onXYMoveEnd=function(){this.endGesture()},a.prototype.onZMoveBegin=function(e,a,n,r,o){var i={type:t.CameraGestureType.scale,mouseEvent:!0,clientX:e,clientY:a,clientWidth:n,clientHeight:r,target:o};return this.startGesture(i)},a.prototype.onZMoving=function(e,a,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,o={type:t.CameraGestureType.scale,mouseEvent:!0,clientX:e,clientY:a,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:null!=n?n:.015};return this.moveGesture(o)},a.prototype.onZMoveEnd=function(){this.endGesture()},a.prototype.onRotateBegin=function(e,a,n,r,o){var i={type:t.CameraGestureType.rotate_self,mouseEvent:!0,clientX:e,clientY:a,clientWidth:n,clientHeight:r,target:o};return this.startGesture(i)},a.prototype.onRotating=function(e,a,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,o={type:t.CameraGestureType.rotate_self,mouseEvent:!0,clientX:e,clientY:a,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:null!=n?n:1.5};return this.moveGesture(o)},a.prototype.onRotateEnd=function(){this.endGesture()},a.prototype.onRotatePointBegin=function(e,a,n,r,o,i){var s={type:t.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:e,clientY:a,clientWidth:n,clientHeight:r,focusPoint:o,target:i};return this.startGesture(s)},a.prototype.onRotatingPoint=function(e,a,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,o={type:t.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:e,clientY:a,clientWidth:r.clientWidth,clientHeight:r.clientHeight,focusPoint:r.focusPoint,target:r.target,speed:null!=n?n:8};return this.moveGesture(o)},a.prototype.onRotatePointEnd=function(){this.endGesture()},a.prototype.moveTo=function(e,a){var n;this.startParams.target=e,this.startParams.type=t.CameraGestureType.none;var r=this.getItem();void 0!==r?((n=r.transform).setPosition.apply(n,u([],c(a),!1)),r.updateTransform()):console.warn("can't find camera item")},a.prototype.rotateTo=function(e,a){var n;this.startParams.target=e,this.startParams.type=t.CameraGestureType.none;var r=this.getItem();void 0!==r?((n=r.transform).setQuaternion.apply(n,u([],c(a),!1)),r.updateTransform()):console.warn("can't find camera item")},a.prototype.onFocusPoint=function(e,a,n){this.startParams.target=e,this.startParams.type=t.CameraGestureType.none;var r=this.getItem();if(void 0!==r){var o=null!=n?n:5,i=S.fromArray(a),s=(new Lt).fromEffectsTransform(r.transform),c=(new Ft).fromPTransform(s).zAxis.clone().multiplyScalar(1).clone().multiplyScalar(o),u=i.clone().addVector(c);r.transform.setPosition(u.x,u.y,u.z),r.updateTransform(),this.startParams.target=""}else console.warn("can't find camera item")},a.prototype.getCameraTransform=function(){var t=this.composition.camera,a=new e.Transform(t.getOptions());return a.setValid(!0),a},a.prototype.initKeyEvent=function(e,a){this.startParams.target=e,this.startParams.speed=a,this.startParams.type=t.CameraGestureType.translate,this.updateCameraTransform(this.composition.camera.getOptions())},a.prototype.startGesture=function(t){return this.startParams=t,this.updateCameraTransform(this.composition.camera.getOptions()),this.getItem()||console.warn("invalid target"),this.composition.camera.getOptions()},a.prototype.moveGesture=function(e){var a;if(this.getCurrentType()===e.type){var n=this.getItem();if(void 0===n)return console.warn("can't find camera item"),this.composition.camera.getOptions();var r=null!==(a=e.speed)&&void 0!==a?a:1.015,o=this.cameraCoordiante.xAxis,i=this.cameraCoordiante.yAxis,s=this.cameraCoordiante.zAxis,c=e.clientX-this.startParams.clientX,u=e.clientY-this.startParams.clientY;if(e.type===t.CameraGestureType.translate)(d=this.cameraTransform.getPosition().clone()).addVector(o.clone().multiplyScalar(-c*r)),d.addVector(i.clone().multiplyScalar(u*r)),n.transform.setPosition(d.x,d.y,d.z),n.updateTransform();else if(e.type===t.CameraGestureType.scale){var d;(d=this.cameraTransform.getPosition().clone()).addVector(s.clone().multiplyScalar(u*r)),n.transform.setPosition(d.x,d.y,d.z),n.updateTransform()}else if(e.type===t.CameraGestureType.rotate_self){var l=c/e.clientWidth,h=u/e.clientHeight,f=l*Math.PI*r*.5,p=h*Math.PI*r*.5,m=J.fromAxisAngle(S.UNIT_Y,-f,new J),_=J.fromAxisAngle(o,-p,new J);m.multiply(_),m.multiply(this.cameraTransform.getRotation()),n.transform.setQuaternion(m.x,m.y,m.z,m.w),n.updateTransform()}else if(e.type===t.CameraGestureType.rotate_focus){l=c/e.clientWidth,h=u/e.clientHeight,f=l*Math.PI*r,p=h*Math.PI*r,m=J.fromAxisAngle(S.UNIT_Y,-f,new J),_=J.fromAxisAngle(o,-p,new J);m.multiply(_);var g=m.toMatrix4(new ct),y=S.fromArray(e.focusPoint),v=this.cameraCoordiante.origin.clone().subVector(y);g.multiplyByPoint3(v);var x=v.addVector(y);m.multiply(this.cameraTransform.getRotation()),n.transform.setPosition(x.x,x.y,x.z),n.transform.setQuaternion(m.x,m.y,m.z,m.w),n.updateTransform()}else console.warn("not implement")}else console.warn("invalid move type");return this.composition.camera.getOptions()},a.prototype.endGesture=function(){this.startParams.type=t.CameraGestureType.none,this.startParams.mouseEvent=!1,this.startParams.target=""},a.prototype.updateCameraTransform=function(t){var a=new e.Transform(t);a.setValid(!0),this.cameraTransform.fromEffectsTransform(a),this.cameraCoordiante.fromPTransform(this.cameraTransform)},a}(),la=function(){function a(){}return a.getTransformFromMat4=function(t){var e=ct.decompose(t);return{position:e.translation.xyz,rotation:a.getEulerFromQuat(e.rotation),scale:e.scale.xyz}},a.getEffectsTransformFromMat4=function(t){var a=new e.Transform({valid:!0});return a.cloneFromMatrix(t.toArray()),{position:a.position,rotation:a.rotation,scale:a.scale}},a.getTransformFromTranslation=function(t){return{position:t.xyz}},a.getTransformFromDirection=function(t){var e=S.fromArray([1,0,0]),n=t.clone().normalize(),r=S.cross(e,n);if(r.length()<.01)return{};r.normalize();var o=S.dot(n,e),i=Math.acos(o),s=ct.IDENTITY.clone().rotate(i,r);return a.getTransformFromMat4(s)},a.getEffectsTransformFromDirection=function(t){var e=S.fromArray([0,0,1]),n=t.clone().normalize(),r=S.cross(e,n);if(r.length()<.01)return{};r.normalize();var o=S.dot(n,e),i=Math.acos(o),s=ct.IDENTITY.clone().rotate(i,r);return a.getEffectsTransformFromMat4(s)},a.getTransformFromTransDir=function(t,e){var n=a.getTransformFromDirection(e);return n.position=t.xyz,n},a.getEffectsTransformFromTransDir=function(t,e){var n=a.getEffectsTransformFromDirection(e);return n.position=t.xyz,n},a.getEulerFromQuat=function(e){var a=new Z,n=new J(e.x,e.y,e.z,e.w);return a.order=t.EulerOrder.ZYX,a.setFromQuaternion(n),[a.x,a.y,a.z]},a.getQuatFromEuler=function(t){var e=new J;return e.setFromEuler(t),[e.x,e.y,e.z,e.w]},a.toPlayerColor3=function(t){return[a.scaleTo255(t[0]),a.scaleTo255(t[1]),a.scaleTo255(t[2])]},a.toPlayerColor4=function(t){return[a.scaleTo255(t[0]),a.scaleTo255(t[1]),a.scaleTo255(t[2]),a.scaleTo255(t[3])]},a.scaleTo255=function(t){var e=255*t;return Math.max(0,Math.min(e,255))},a.scaleTo1=function(t){var e=t/255;return Math.max(0,Math.min(e,1))},a}();var ha=function(){function a(){}return a.prototype.initial=function(t,e){this.engine=t,this._loaderOptions=null!=e?e:{}},a.prototype.processLight=function(t,e){var a=this;t.forEach((function(t){void 0===t.color?t.color=e?[255,255,255,255]:[1,1,1,1]:(t.color[0]=a.scaleColorVal(t.color[0],e),t.color[1]=a.scaleColorVal(t.color[1],e),t.color[2]=a.scaleColorVal(t.color[2],e),t.color[3]=a.scaleColorVal(t.color[3],e))}))},a.prototype.processCamera=function(t,e){var a=e?180/Math.PI:Math.PI/180;t.forEach((function(t){void 0!==t.perspective&&(t.perspective.yfov*=a)}))},a.prototype.processMaterial=function(t,e){var a=this;t.forEach((function(t){void 0===t.baseColorFactor?t.baseColorFactor=e?[255,255,255,255]:[1,1,1,1]:(t.baseColorFactor[0]=a.scaleColorVal(t.baseColorFactor[0],e),t.baseColorFactor[1]=a.scaleColorVal(t.baseColorFactor[1],e),t.baseColorFactor[2]=a.scaleColorVal(t.baseColorFactor[2],e),t.baseColorFactor[3]=a.scaleColorVal(t.baseColorFactor[3],e)),void 0===t.emissiveFactor?t.emissiveFactor=e?[255,255,255,255]:[1,1,1,1]:(t.emissiveFactor[0]=a.scaleColorVal(t.emissiveFactor[0],e),t.emissiveFactor[1]=a.scaleColorVal(t.emissiveFactor[1],e),t.emissiveFactor[2]=a.scaleColorVal(t.emissiveFactor[2],e),t.emissiveFactor[3]=a.scaleColorVal(t.emissiveFactor[3],e)),e&&void 0!==t.occlusionTexture&&void 0===t.occlusionTexture.strength&&(t.occlusionTexture.strength=a.isTiny3dMode()?0:1)}))},a.prototype.createTreeOptions=function(t){return{nodes:t.nodes.map((function(t,e){var a,n,r,o=t.children.map((function(t){if(void 0===t.nodeIndex)throw new Error("Undefined nodeIndex for child ".concat(t));return t.nodeIndex}));if(void 0!==t.matrix){if(16!==t.matrix.length)throw new Error("Invalid matrix length ".concat(t.matrix.length," for node ").concat(t));var i=ct.fromArray(t.matrix).decompose();a=i.translation.toArray(),n=i.rotation.toArray(),r=i.scale.toArray()}else void 0!==t.translation&&(a=t.translation),void 0!==t.rotation&&(n=t.rotation),void 0!==t.scale&&(r=t.scale);return t.nodeIndex=e,{name:t.name,transform:{position:a,quat:n,scale:r},children:o,id:"".concat(t.nodeIndex)}})),children:t.rootNodes.map((function(t){if(void 0===t.nodeIndex)throw new Error("Undefined nodeIndex for root ".concat(t));return t.nodeIndex})),animation:-1,animations:[]}},a.prototype.createAnimations=function(t){return t.map((function(t){var e=t.channels.map((function(t){return{input:t.input.array,output:t.output.array,node:t.target.node,path:t.target.path,interpolation:t.interpolation}}));return{name:t.name,tracks:e}}))},a.prototype.createGeometry=function(t,e){return new pa(this.engine,t,e).geometry},a.prototype.createMaterial=function(t){return new ma(t,[],this.isTiny3dMode()).material},a.prototype.createTexture2D=function(t,e,a){return Qt.createTexture2D(this.engine,t,e,a,this.isTiny3dMode())},a.prototype.createTextureCube=function(t,e){var a=this;if(0==t.length)throw new Error("createTextureCube: Invalid cubeImages length ".concat(t));var n=[];return t.forEach((function(t){var e;if(6!=t.length)throw new Error("createTextureCube: cubeimage count should always be 6, ".concat(t));var r=[];t.forEach((function(t){if(void 0===t.imageData)throw new Error("createTextureCube: Invalid image data from ".concat(t));r.push({type:"buffer",data:t.imageData,mimeType:t.mimeType})})),a.isTiny3dMode()&&(e=c([r[5],r[4]],2),r[4]=e[0],r[5]=e[1]),n.push(r)})),1==n.length?Qt.createTextureCubeFromBuffer(this.engine,n[0]):Qt.createTextureCubeMipmapFromBuffer(this.engine,n,null!=e?e:Math.pow(2,n.length-1))},a.prototype.createSkybox=function(t){var e,a,n=this,r=null!==(e=t.reflectionsIntensity)&&void 0!==e?e:t.intensity,o=t.irradianceCoefficients,i=t.specularImages.map((function(t){var e,a=t.map((function(t){return{type:"buffer",data:t.imageData,mimeType:t.mimeType}}));return n.isTiny3dMode()&&(e=c([a[5],a[4]],2),a[4]=e[0],a[5]=e[1]),a})),s=i.length-1,u=null!==(a=t.specularImageSize)&&void 0!==a?a:Math.pow(2,s),d={type:"buffer",renderable:this.isSkyboxVis(),intensity:t.intensity,reflectionsIntensity:r,irradianceCoeffs:o,specularImage:i,specularMipCount:s,specularImageSize:u};return Re.createSkyboxOptions(this.engine,d)},a.prototype.createDefaultSkybox=function(e){if("NFT"!==e&&"FARM"!==e)throw new Error("Invalid skybox type name ".concat(e));var a="NFT"===e?t.PSkyboxType.NFT:t.PSkyboxType.FARM,n=Re.getSkyboxParams(a);return Re.createSkyboxOptions(this.engine,n)},a.prototype.scaleColorVal=function(t,e){return e?la.scaleTo255(t):la.scaleTo1(t)},a.prototype.scaleColorVec=function(t,e){var a=this;return t.map((function(t){return a.scaleColorVal(t,e)}))},a.prototype.loadScene=function(t){var a;return i(this,void 0,void 0,(function(){var n,r,o,i,c,u=this;return s(this,(function(s){switch(s.label){case 0:if(this._clear(),this._sceneOptions=t,this.engine=null===(a=t.effects.renderer)||void 0===a?void 0:a.engine,this._loaderOptions={compatibleMode:t.gltf.compatibleMode},"string"==typeof(n=t.gltf.resource)||n instanceof Uint8Array)throw new Error("Please load resource by GLTFTools at first");return this._gltfScene=n.scenes[0],this._gltfSkins=this._gltfScene.skins,this._gltfMeshs=n.meshes,this._gltfLights=this._gltfScene.lights,this._gltfCameras=this._gltfScene.cameras,this._gltfImages=n.images,this._gltfTextures=n.textures,this._gltfMaterials=n.materials,this._gltfAnimations=n.animations,this._gltfImageBasedLights=n.imageBasedLights,[4,this._preprocess()];case 1:return s.sent(),o="sceneTree",(r=[]).push(this._createItemTree(o,this._gltfScene)),void 0!==(i=this._createItemSkybox())&&r.push(i),this._gltfScene.nodes.forEach((function(t){if(void 0!==t.mesh){var e=u._createItemMesh(t,o);void 0!==e&&r.push(e)}if(void 0!==t.light){var a=u._createItemLight(t,o);void 0!==a&&r.push(a)}if(void 0!==t.camera){var n=u._createItemCamera(t,o);void 0!==n&&r.push(n)}})),c=new Ot,this._gltfScene.rootNodes.forEach((function(t){var a=new e.Transform({valid:!0});u._computeSceneAABB(t,a,c)})),[2,{source:this.getRemarkString(),items:r,sceneAABB:{min:c.min.toArray(),max:c.max.toArray()}}]}}))}))},a.prototype._preprocess=function(){return i(this,void 0,void 0,(function(){var e,a,n,r,o,i,u,d=this;return s(this,(function(s){switch(s.label){case 0:this.getTextureManager().initial(this._gltfImages,this._gltfTextures),e=0,s.label=1;case 1:return e<this._gltfMaterials.length?(a=this._gltfMaterials[e],[4,this.tryAddTexture2D(e,a.baseColorTexture,!0)]):[3,8];case 2:return s.sent(),_a.isUnlitMaterial(a)?[3,7]:[4,this.tryAddTexture2D(e,a.metallicRoughnessTexture,!1)];case 3:return s.sent(),[4,this.tryAddTexture2D(e,a.normalTexture,!1)];case 4:return s.sent(),[4,this.tryAddTexture2D(e,a.emissiveTexture,!1)];case 5:return s.sent(),[4,this.tryAddTexture2D(e,a.occlusionTexture,!1)];case 6:s.sent(),s.label=7;case 7:return e++,[3,1];case 8:return this._gltfImageBasedLights.length>0&&!this.ignoreSkybox()?(n=this._gltfImageBasedLights[0],this.isEnvironmentTest()&&n.specularImages.forEach((function(t){var e,a;d.isTiny3dMode()&&(e=c([t[5],t[4]],2),t[4]=e[0],t[5]=e[1]),a=c([t[3],t[2]],2),t[2]=a[0],t[3]=a[1]})),r=this,[4,this.createSkybox(n)]):[3,10];case 9:return r._skyboxOptions=s.sent(),[3,12];case 10:return void 0===(o=this.getSkyboxType())?[3,12]:(i=o===t.PSkyboxType.FARM?"FARM":"NFT",u=this,[4,this.createDefaultSkybox(i)]);case 11:u._skyboxOptions=s.sent(),s.label=12;case 12:return this._skyboxOptions&&(this._skyboxOptions.renderable=this.isSkyboxVis()),this._gltfData2PlayerData(this._gltfScene,this._gltfMaterials),[2]}}))}))},a.prototype.tryAddTexture2D=function(t,e,a){var n=this;if(void 0!==e&&void 0===this.getTexture2D(t,e,a,!0)){var r=e.index,o=this._gltfTextures[r],i=this._gltfImages[o.source];return Qt.createTexture2D(this.engine,i,o,a,this.isTiny3dMode()).then((function(e){n.getTextureManager().addTexture(t,r,e,a)}))}},a.prototype.getTexture2D=function(t,e,a,n){if(void 0!==e){var r=e.index,o=this.getTextureManager().getTexture(t,r,a);return void 0===o&&!0!==n&&console.warn("Can't find texture for mat ".concat(t,", tex ").concat(JSON.stringify(e),", basecolor ").concat(a)),o}},a.prototype._gltfData2PlayerData=function(t,e){this.processCamera(t.cameras,!0),this.processLight(t.lights,!0),this.processMaterial(e,!0)},a.prototype._createItemTree=function(t,a){var n=this.createTreeOptions(a),r=this.createAnimations(this._gltfAnimations);return n.animations=r,n.animation=this.getPlayAnimationIndex(n),{id:t,name:a.name,duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:e.spec.ItemType.tree,content:{options:{tree:n}}}},a.prototype._createItemMesh=function(t,a){var n,r,o=this,i=t.mesh;if(void 0===i)throw new Error("Invalid mesh index in node ".concat(t));if(void 0!==t.skin){var s=this._gltfSkins[t.skin];r={name:s.name,joints:s.jointIndexList,skeleton:s.skeleton,inverseBindMatrices:s.inverseBindMatrices}}var c=this._gltfMeshs[i],u=c.primitives.map((function(t){var a=t.material,n=o._gltfMaterials[a],i=o.createGeometry(t,void 0!==r),s=o.createMaterial(n);return s.baseColorTexture=o.getTexture2D(a,n.baseColorTexture,!0),s.type===e.spec.MaterialType.pbr&&(s.metallicRoughnessTexture=o.getTexture2D(a,n.metallicRoughnessTexture,!1),s.normalTexture=o.getTexture2D(a,n.normalTexture,!1),s.emissiveTexture=o.getTexture2D(a,n.emissiveTexture,!1),s.occlusionTexture=o.getTexture2D(a,n.occlusionTexture,!1)),{geometry:i,material:s}})),d={parent:t.nodeIndex,skin:r,primitives:u,weights:c.weights},l=_a.createBoxFromGLTFBound(c.bounds),h=l.getSize(new S),f=l.getCenter(new S),p={behavior:e.spec.InteractBehavior.NOTIFY,type:e.spec.ModelBoundingType.box,size:[h.x,h.y,h.z],center:[f.x,f.y,f.z]};return{id:"mesh_ni".concat(null!==(n=t.nodeIndex)&&void 0!==n?n:0,"_mi").concat(i),parentId:"".concat(a,"^").concat(t.nodeIndex),name:c.name,duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:e.spec.ItemType.mesh,pluginName:"model",content:{options:d,interaction:p}}},a.prototype._createItemLight=function(t,a){var n,r,o=t.light;if(void 0!==o){var i=this._gltfLights[o],s=this.createLightOptions(i);return{id:"light_ni".concat(null!==(n=t.nodeIndex)&&void 0!==n?n:0,"_li").concat(o),parentId:"".concat(a,"^").concat(t.nodeIndex),name:null!==(r=i.name)&&void 0!==r?r:"light",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:e.spec.ItemType.light,pluginName:"model",content:{options:s}}}},a.prototype._createItemCamera=function(t,e){var a,n,r=t.camera;if(void 0!==r){var o=this._gltfCameras[r],i=this.createCameraOptions(o);if(void 0!==i)return{id:"camera_ni".concat(null!==(a=t.nodeIndex)&&void 0!==a?a:0,"_ci").concat(r),parentId:"".concat(e,"^").concat(t.nodeIndex),name:null!==(n=o.name)&&void 0!==n?n:"camera",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:"camera",pluginName:"model",content:{options:i}}}},a.prototype._createItemSkybox=function(){if(void 0!==this._skyboxOptions)return{id:"skybox_0",name:"skybox",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:"skybox",pluginName:"model",content:{options:this._skyboxOptions}}},a.prototype._computeSceneAABB=function(t,a,n){var r=this,o={};if(t.matrix){var i=ct.fromArray(t.matrix).decompose();o.position=i.translation.toArray(),o.quat=i.rotation.toArray(),o.scale=i.scale.toArray()}else t.translation&&(o.position=t.translation),t.rotation&&(o.quat=t.rotation),t.scale&&(o.scale=t.scale);var s=new e.Transform(o,a);if(s.setValid(!0),void 0!==t.mesh){var c=this._gltfMeshs[t.mesh],u=_a.createBoxFromGLTFBound(c.bounds);u.transform(ct.fromArray(s.getWorldMatrix())),n.union(u)}t.children.forEach((function(t){r._computeSceneAABB(t,s,n)}))},a.prototype.createLightOptions=function(t){return $t.createLightOptions(t)},a.prototype.createCameraOptions=function(t){return $t.createCameraOptions(t)},a.prototype._clear=function(){this._textureManager&&(this._textureManager.dispose(),this._textureManager=void 0),this._textureManager=new fa(this)},a.prototype.getPlayAnimationIndex=function(t){var e=t.animations;if(void 0===e||e.length<=0)return-1;if(this.isPlayAllAnimation())return-88888888;var a=this._sceneOptions.effects.playAnimation;if(void 0===a)return-1;if("number"==typeof a)return a>=0&&a<e.length?a:-1;var n=-1;return e.forEach((function(t,e){t.name===a&&(n=e)})),n},a.prototype.isPlayAnimation=function(){return void 0!==this._sceneOptions.effects.playAnimation},a.prototype.isPlayAllAnimation=function(){return!0===this._sceneOptions.effects.playAllAnimation},a.prototype.getRemarkString=function(){var t=this._sceneOptions.gltf.remark;return void 0===t?"Unknown":"string"==typeof t?t:"BinaryBuffer"},a.prototype.isTiny3dMode=function(){return"tiny3d"===this._loaderOptions.compatibleMode},a.prototype.getTextureManager=function(){return this._textureManager},a.prototype.getItemDuration=function(){var t;return null!==(t=this._sceneOptions.effects.duration)&&void 0!==t?t:9999},a.prototype.getItemEndBehavior=function(){var t;return null!==(t=this._sceneOptions.effects.endBehavior)&&void 0!==t?t:e.spec.ItemEndBehavior.loop},a.prototype.getSkyboxType=function(){switch(this._sceneOptions.gltf.skyboxType){case"NFT":return t.PSkyboxType.NFT;case"FARM":return t.PSkyboxType.FARM}},a.prototype.isSkyboxVis=function(){return!0===this._sceneOptions.gltf.skyboxVis},a.prototype.ignoreSkybox=function(){return!0===this._sceneOptions.gltf.ignoreSkybox},a.prototype.isEnvironmentTest=function(){return"string"==typeof this._sceneOptions.gltf.remark&&this._sceneOptions.gltf.remark.includes("EnvironmentTest")},a}(),fa=function(){function t(t){this._owner=t,this._gltfImages=[],this._gltfTextures=[],this._textureMap=new Map}return t.prototype.initial=function(t,e){this._gltfImages=t,this._gltfTextures=e,this._textureMap.clear()},t.prototype.dispose=function(){this._textureMap.clear()},t.prototype.addTexture=function(t,e,a,n){var r=n?1e5*t+e:e;this._textureMap.set(r,a)},t.prototype.getTexture=function(t,e,a){var n=a?1e5*t+e:e;return this._textureMap.get(n)},t}(),pa=function(){function t(t,e,a){this.engine=t,this.gltfGeometry=e,this.hasSkinAnimation=a}return Object.defineProperty(t.prototype,"geometry",{get:function(){var t=this,a={};if(!this.hasPosition)throw new Error("Position attribute missing");var n=this.positionAttrib;(a.a_Position=this._getBufferAttrib(n),this.hasNormal)&&(void 0!==(n=this.normalAttrib)&&(a.a_Normal=this._getBufferAttrib(n)));this.hasTangent&&(void 0!==(n=this.tangentAttrib)&&(a.a_Tangent=this._getBufferAttrib(n)));if(this.texCoordList.forEach((function(e){var n=t.texCoordAttrib(e),r="a_UV".concat(e+1);a[r]=t._getBufferAttrib(n)})),this.hasSkinAnimation){var r=this.jointAttribute;void 0!==r&&(a.a_Joint1=this._getBufferAttrib(r));var o=this.weightAttribute;void 0!==o&&(a.a_Weight1=this._getBufferAttrib(o))}for(var i=0;i<8;i++){var s=this.getTargetPosition(i);void 0!==s&&(a["a_Target_Position".concat(i)]=this._getBufferAttrib(s));var c=this.getTargetNormal(i);void 0!==c&&(a["a_Target_Normal".concat(i)]=this._getBufferAttrib(c));var u=this.getTargetTangent(i);void 0!==u&&(a["a_Target_Tangent".concat(i)]=this._getBufferAttrib(u))}var d=this.indexArray;return void 0!==d?e.Geometry.create(this.engine,{attributes:a,indices:{data:d},drawStart:0,drawCount:d.length,mode:e.glContext.TRIANGLES}):e.Geometry.create(this.engine,{attributes:a,drawStart:0,drawCount:this.positionAttrib.array.length/3,mode:e.glContext.TRIANGLES})},enumerable:!1,configurable:!0}),t.prototype._getBufferAttrib=function(t){return{type:t.type,size:t.itemSize,data:t.array,normalize:t.normalized}},Object.defineProperty(t.prototype,"positionAttrib",{get:function(){return this.gltfGeometry.getPosition()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalAttrib",{get:function(){return this.gltfGeometry.getNormal()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tangentAttrib",{get:function(){return this.gltfGeometry.getTangent()},enumerable:!1,configurable:!0}),t.prototype.texCoordAttrib=function(t){return this.gltfGeometry.getTexCoord(t)},Object.defineProperty(t.prototype,"jointAttribute",{get:function(){return this.gltfGeometry.getJoints(0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"weightAttribute",{get:function(){return this.gltfGeometry.getWeights(0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPosition",{get:function(){return void 0!==this.positionAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasNormal",{get:function(){return void 0!==this.normalAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasTangent",{get:function(){return void 0!==this.tangentAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasTexCoord",{get:function(){return this.texCoordCount>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"texCoordCount",{get:function(){for(var t=0;t<10;t++)if(void 0===this.texCoordAttrib(t))return t;return 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasJointAttribute",{get:function(){return void 0!==this.jointAttribute},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasWeightAttribute",{get:function(){return void 0!==this.weightAttribute},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexArray",{get:function(){if(void 0!==this.gltfGeometry.indices)switch(this.gltfGeometry.indices.type){case WebGLRenderingContext.UNSIGNED_INT:case WebGLRenderingContext.UNSIGNED_SHORT:case WebGLRenderingContext.UNSIGNED_BYTE:return this.gltfGeometry.indices.array}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexCount",{get:function(){return void 0!==this.gltfGeometry.indices?this.gltfGeometry.indices.array.length:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"texCoordList",{get:function(){for(var t=[],e=0;e<10&&void 0!==this.texCoordAttrib(e);e++)t.push(e);return t},enumerable:!1,configurable:!0}),t.prototype.getTargetPosition=function(t){return this.gltfGeometry.getAttribute("POSITION".concat(t))},t.prototype.getTargetNormal=function(t){return this.gltfGeometry.getAttribute("NORMAL".concat(t))},t.prototype.getTargetTangent=function(t){return this.gltfGeometry.getAttribute("TANGENT".concat(t))},t}(),ma=function(){function t(t,e,a){this.gltfMaterial=t,this.textures=e,this.tiny3dMode=a}return Object.defineProperty(t.prototype,"material",{get:function(){var t,a,n,r=this.gltfMaterial,o=_a.isUnlitMaterial(r),i=e.spec.MaterialBlending.opaque;switch(r.alphaMode){case"OPAQUE":i=e.spec.MaterialBlending.opaque;break;case"MASK":i=e.spec.MaterialBlending.masked;break;case"BLEND":i=e.spec.MaterialBlending.translucent}var s=r.doubleSided?e.spec.SideMode.DOUBLE:e.spec.SideMode.FRONT,c=null!==(t=r.alphaCutOff)&&void 0!==t?t:.5,u=r.name;return o?{name:u,type:e.spec.MaterialType.unlit,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,depthMask:null===(a=r.extras)||void 0===a?void 0:a.depthMask,blending:i,alphaCutOff:c,side:s}:{name:u,type:e.spec.MaterialType.pbr,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,useSpecularAA:this.getSpecularAA(),metallicRoughnessTexture:this.metallicRoughnessTextureObj,metallicRoughnessTextureCoordinate:this.metallicRoughnessTextureCoord,metallicRoughnessTextureTransform:this.metallicRoughnessTextureTransfrom,metallicFactor:this.metalicFactor,roughnessFactor:this.roughnessFactor,normalTexture:this.normalTextureObj,normalTextureCoordinate:this.normalTextureCoord,normalTextureTransform:this.normalTextureTransfrom,normalTextureScale:this.normalTextureScale,occlusionTexture:this.occlusionTextureObj,occlusionTextureCoordinate:this.occlusionTextureCoord,occlusionTextureTransform:this.occlusionTextureTransfrom,occlusionTextureStrength:this.occlusionTextureStrength,emissiveTexture:this.emissiveTextureObj,emissiveTextureCoordinate:this.emissiveTextureCoord,emissiveTextureTransform:this.emissiveTextureTransfrom,emissiveFactor:this.emissiveFactor,emissiveIntensity:1,depthMask:null===(n=r.extras)||void 0===n?void 0:n.depthMask,blending:i,alphaCutOff:c,side:s,enableShadow:!1}},enumerable:!1,configurable:!0}),t.prototype.getTextureObject=function(t){if(!(t<0||t>=this.textures.length))return this.textures[t]},t.prototype.getTextureObj=function(t){return t?this.getTextureObject(t.index):void 0},t.prototype.getTextureCoord=function(t){return t?t.texCoord:void 0},t.prototype.getTextureTransform=function(t){var e,a=null===(e=null==t?void 0:t.extensions)||void 0===e?void 0:e.KHR_texture_transform;if(void 0!==a&&(void 0!==a.offset||void 0!==a.rotation||void 0!==a.scale))return{offset:a.offset,rotation:a.rotation,scale:a.scale}},Object.defineProperty(t.prototype,"baseColorTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"baseColorTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"baseColorTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metallicRoughnessTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metallicRoughnessTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metallicRoughnessTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"occlusionTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"occlusionTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"occlusionTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"emissiveTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"emissiveTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"emissiveTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasEmissive",{get:function(){var t=this.emissiveFactor;return t[0]+t[1]+t[2]>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"baseColorFactor",{get:function(){var t=this.gltfMaterial.baseColorFactor;return void 0===t||4!=t.length?[1,1,1,1]:[t[0],t[1],t[2],t[3]]},enumerable:!1,configurable:!0}),t.prototype.getSpecularAA=function(){var t;return null===(t=this.gltfMaterial.extras)||void 0===t?void 0:t.useSpecularAA},Object.defineProperty(t.prototype,"metalicFactor",{get:function(){var t;return null!==(t=this.gltfMaterial.metallicFactor)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughnessFactor",{get:function(){var t;return null!==(t=this.gltfMaterial.roughnessFactor)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalTextureScale",{get:function(){var t,e;return null!==(e=null===(t=this.gltfMaterial.normalTexture)||void 0===t?void 0:t.scale)&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"occlusionTextureStrength",{get:function(){var t,e;return null!==(e=null===(t=this.gltfMaterial.occlusionTexture)||void 0===t?void 0:t.strength)&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"emissiveFactor",{get:function(){var t=this.gltfMaterial.emissiveFactor;return void 0===t||4!=t.length?[0,0,0,1]:[t[0],t[1],t[2],1]},enumerable:!1,configurable:!0}),t}(),_a=function(){function t(){}return t.isUnlitMaterial=function(t){var e;return void 0!==(null===(e=t.extensions)||void 0===e?void 0:e.KHR_materials_unlit)},t.createBoxFromGLTFBound=function(t){var e=S.fromArray(t.box.min),a=S.fromArray(t.box.max);return new Ot(e,a)},t}();e.registerPlugin("tree",ca,oa,!0),e.registerPlugin("model",sa,ia);console.debug("[Galacean Effects Plugin Model] version: 0.0.1-alpha.2"),t.Box3=Ot,t.BoxMesh=Ge,t.CameraGestureHandlerImp=da,t.CheckerHelper=oe,t.CompositionCache=ze,t.CompositionHitTest=function(t,e,a){var n=t.hitTest(e,a,!0),r=t.getHitTestRay(e,a);if(n.length<=0)return[];var o=r.center,i=r.direction,s=n.map((function(t,e){for(var a=t.position,n=[0,0,0],r=0;r<3;r++)n[r]=(a[r]-o[r])/i[r];return[e,Math.max.apply(Math,u([],c(n),!1))]}));return s.sort((function(t,e){return(t[1]>=0?t[1]:t[1]+1e9)-(e[1]>=0?e[1]:e[1]+1e9)})),s.map((function(t){return n[t[0]]}))},t.Euler=Z,t.FBOOptions=je,t.Float16ArrayWrapper=ie,t.GeometryBoxProxy=ne,t.HitTestingProxy=re,t.HookOGLFunc=function(t){console.info("HookOGLFunc "+Object.getPrototypeOf(t));var e=0;for(var a in Object.getPrototypeOf(t))"getError"!==a&&"function"==typeof t[a]&&(++e,t[a+$e]=t[a],t[a]=aa(t,a));console.info("HookCount "+e),function(t){for(var e in Object.getPrototypeOf(t))"number"==typeof t[e]&&ta.set(t[e],e)}(t)},t.InterpolationSampler=d,t.LoaderHelper=la,t.LoaderImpl=ha,t.Matrix2=F,t.Matrix3=V,t.Matrix4=ct,t.MeshHelper=Kt,t.ModelPlugin=sa,t.ModelTreeItem=ra,t.ModelTreePlugin=ca,t.ModelTreeVFXItem=oa,t.ModelVFXItem=ia,t.PAnimTexture=pe,t.PAnimTrack=fe,t.PAnimation=me,t.PAnimationManager=_e,t.PAnimationSystem=ge,t.PCamera=De,t.PCameraManager=Ue,t.PCoordinate=Ft,t.PEntity=Dt,t.PGeometry=Je,t.PGlobalState=Rt,t.PLight=ke,t.PLightManager=Ve,t.PMaterialBase=Ie,t.PMaterialPBR=Pe,t.PMaterialSkyboxFilter=Fe,t.PMaterialUnlit=Ee,t.PMesh=Ye,t.PMorph=le,t.PObject=Bt,t.PPrimitive=Ze,t.PSceneManager=Ke,t.PShaderManager=Ae,t.PSkin=de,t.PSkybox=Le,t.PSkyboxCreator=Re,t.PTransform=Lt,t.PluginHelper=$t,t.Quaternion=J,t.RayBoxTesting=jt,t.RayIntersectsBoxWithRotation=Vt,t.RayTriangleTesting=Xt,t.Sphere=Nt,t.ToggleItemBounding=function(e,n){var r;null===(r=e.items)||void 0===r||r.forEach((function(e){if(e.type===a){var r=e;if(r.content.type===t.PObjectType.mesh){var o=r.content;r.id===n?o.visBoundingBox=!0:o.visBoundingBox=!1}}}))},t.TwoStatesSet=He,t.VFX_ITEM_TYPE_3D=a,t.Vector2=y,t.Vector3=S,t.Vector4=P,t.VertexAttribBuffer=ee,t.WebGLHelper=Qt,t.WebHelper=te,t.createAnimationSampler=m,t.createInternalMaterial=function(t){return{}},t.createPluginMaterial=Oe,t.getDefaultEffectsGLTFLoader=function(t,e){return ua||(ua=new ha),ua.initial(t,e),ua},t.getDiffuseOnlyShaderCode=function(t){return{vertexShaderCode:we({hasNormals:!0}),fragmentShaderCode:"\n #version 100\n precision highp float;\n varying vec3 v_Normal;\n void main(){\n vec3 lightDir = normalize(vec3(1, 1, 1));\n gl_FragColor = vec4(max(0.0, dot(v_Normal, lightDir)) * 0.8);\n }\n "}},t.getGaussianBlurShaderCodeV1=function(t){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform vec2 u_BlurScale;\n uniform sampler2D u_FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(-3.0) * u_BlurScale.xy)) * (1.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(-2.0) * u_BlurScale.xy)) * (6.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(-1.0) * u_BlurScale.xy)) * (15.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+0.0) * u_BlurScale.xy)) * (20.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+1.0) * u_BlurScale.xy)) * (15.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+2.0) * u_BlurScale.xy)) * (6.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+3.0) * u_BlurScale.xy)) * (1.0/64.0);\n gl_FragColor = color;\n }\n "}},t.getGaussianBlurShaderCodeV2=Ce,t.getKawaseBlurShaderCode=function(t){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform float u_Offset;\n uniform vec2 u_TextureSizeInv;\n uniform sampler2D u_TexturSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0.0);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2(-u_Offset-0.5,-u_Offset-0.5) * u_TextureSizeInv);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2(-u_Offset-0.5, u_Offset+0.5) * u_TextureSizeInv);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2( u_Offset+0.5,-u_Offset-0.5) * u_TextureSizeInv);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2( u_Offset+0.5, u_Offset+0.5) * u_TextureSizeInv);\n gl_FragColor = color * 0.25;\n }\n "}},t.getNormalVisShaderCode=Me,t.getPBRPassShaderCode=xe,t.getPMeshList=function(e){var n=[],r=e.getCompositions()[0];return null==r||r.items.forEach((function(e){if(e.type===a){var r=e;r.content&&r.content.type===t.PObjectType.mesh&&n.push(r.content)}})),n},t.getQuadFilterShaderCode=function(t){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform sampler2D u_ColorSampler;\n\n varying vec2 v_UVCoord1;\n void main(){\n gl_FragColor = texture2D(u_ColorSampler, v_UVCoord1);\n }\n "}},t.getRendererGPUInfo=function(t){var e=t.gpuCapability;return JSON.stringify(e,void 0,2)},t.getShadowPassShaderCode=be,t.getSimpleFilterShaderCode=Se,t.getSkyBoxShaderCode=Te,t.getTransparecyBaseShader=function(t){return t?we({hasNormals:!0}):"\n #version 100\n #extension GL_EXT_draw_buffers: require\n\n precision highp float;\n uniform vec4 u_BaseColorFactor;\n\n #ifdef HAS_UVS\n uniform sampler2D u_BaseColorSampler;\n varying vec2 v_UVCoord1;\n #endif\n\n varying vec3 v_Normal;\n\n float weight(float z, float a) {\n return clamp(pow(min(1.0, a * 10.0) + 0.01, 3.0) * 1e8 * pow(1.0 - z * 0.9, 3.0), 1e-2, 3e3);\n }\n\n void main() {\n vec4 color = u_BaseColorFactor;\n\n #ifdef HAS_UVS\n color *= texture2D(u_BaseColorSampler, v_UVCoord1);\n #endif\n\n color.rgb *= color.a * dot(normalize(v_Normal), normalize(vec3(0, 1, 3))) * 5.0;\n float w = weight(gl_FragCoord.z, color.a);\n gl_FragData[0] = vec4(color.rgb * w, color.a);\n gl_FragData[1] = vec4(color.a * w);\n }\n "},t.getTransparecyFilterShader=function(t){return t?"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ":"\n #version 100\n precision highp float;\n uniform sampler2D u_AccumColorSampler;\n uniform sampler2D u_AccumAlphaSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 accumColor = texture2D(u_AccumColorSampler, v_UVCoord1);\n vec4 accumAlpha = texture2D(u_AccumAlphaSampler, v_UVCoord1);\n float finalAlpha = 1.0 - accumColor.a;\n vec3 finalColor = accumColor.rgb / clamp(accumAlpha.r, 0.001, 50000.0);\n gl_FragColor = vec4(finalColor, finalAlpha);\n }\n "},t.setDefaultEffectsGLTFLoader=function(t){ua=t},t.version="0.0.1-alpha.2",Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
8
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ge=t.ge||{},t.ge.modelPlugin={}),t.ge)}(this,(function(t,e){"use strict";var a="PluginModel",n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function a(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(a.prototype=e.prototype,new a)}var o=function(){return o=Object.assign||function(t){for(var e,a=1,n=arguments.length;a<n;a++)for(var r in e=arguments[a])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},o.apply(this,arguments)};function i(t,e,a,n){return new(a||(a=Promise))((function(r,o){function i(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof a?e:new a((function(t){t(e)}))).then(i,s)}c((n=n.apply(t,e||[])).next())}))}function s(t,e){var a,n,r,o,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(a)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(a=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){i.label=s[1];break}if(6===s[0]&&i.label<r[1]){i.label=r[1],r=s;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(s);break}r[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t],n=0}finally{a=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function c(t,e){var a="function"==typeof Symbol&&t[Symbol.iterator];if(!a)return t;var n,r,o=a.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(a=o.return)&&a.call(o)}finally{if(r)throw r.error}}return i}function u(t,e,a){if(a||2===arguments.length)for(var n,r=0,o=e.length;r<o;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var d=function(){function t(t,e,a){this.time=t,this.data=e,this.componentCount=a,this.cachedIndex=0}return t.prototype.evaluate=function(t){var e=this.time,a=this.cachedIndex,n=e[a],r=e[a-1];t:{e:{var o=void 0;a:{n:if(!(t<n)){for(var i=a+2;;){if(void 0===n){if(t<r)break n;return a=e.length,this.cachedIndex=a,this.copySampleValue(a-1)}if(a===i)break;if(r=n,t<(n=e[++a]))break e}o=e.length;break a}if(t>=r)break t;var s=e[1];t<s&&(a=2,r=s);for(i=a-2;;){if(void 0===r)return this.cachedIndex=0,this.copySampleValue(0);if(a===i)break;if(n=r,t>=(r=e[--a-1]))break e}o=a,a=0}for(;a<o;){var c=a+o>>>1;t<e[c]?o=c:a=c+1}if(n=e[a],void 0===(r=e[a-1]))return this.cachedIndex=0,this.copySampleValue(0);if(void 0===n)return a=e.length,this.cachedIndex=a,this.copySampleValue(a-1)}this.cachedIndex=a,this.intervalChanged(a,r,n)}return this.interpolate(a,r,t,n)},t.prototype.dispose=function(){this.time=void 0,this.data=void 0},t.prototype.copySampleValue=function(t){for(var e=this.data,a=this.componentCount,n=t*a,r=new Float32Array(a),o=0;o!==a;++o)r[o]=e[n+o];return r},t}(),l=function(t){function e(e,a,n){return t.call(this,e,a,n)||this}return r(e,t),e.prototype.intervalChanged=function(t,e,a){},e.prototype.interpolate=function(t,e,a,n){for(var r,o=this.data,i=null!==(r=this.componentCount)&&void 0!==r?r:1,s=t*i,c=s-i,u=(a-e)/(n-e),d=1-u,l=new Float32Array(i),h=0;h!==i;++h)l[h]=o[c+h]*d+o[s+h]*u;return l},e}(d),h=function(t){function e(e,a,n){return t.call(this,e,a,n)||this}return r(e,t),e.prototype.intervalChanged=function(t,e,a){},e.prototype.interpolate=function(t,e,a,n){for(var r,o=this.data,i=null!==(r=this.componentCount)&&void 0!==r?r:1,s=(t-1)*i,c=new Float32Array(i),u=0;u!==i;++u)c[u]=o[s+u];return c},e}(d),f=function(){function t(){}return t.slerpFlat=function(t,e,a,n,r,o,i){var s=a[n+0],c=a[n+1],u=a[n+2],d=a[n+3],l=r[o+0],h=r[o+1],f=r[o+2],p=r[o+3];if(0===i)return t[e+0]=s,t[e+1]=c,t[e+2]=u,void(t[e+3]=d);if(1===i)return t[e+0]=l,t[e+1]=h,t[e+2]=f,void(t[e+3]=p);if(d!==p||s!==l||c!==h||u!==f){var m=1-i,_=s*l+c*h+u*f+d*p,g=_>=0?1:-1,y=1-_*_;if(y>Number.EPSILON){var v=Math.sqrt(y),x=Math.atan2(v,_*g);m=Math.sin(m*x)/v,i=Math.sin(i*x)/v}var b=i*g;if(s=s*m+l*b,c=c*m+h*b,u=u*m+f*b,d=d*m+p*b,m===1-i){var T=1/Math.sqrt(s*s+c*c+u*u+d*d);s*=T,c*=T,u*=T,d*=T}}t[e]=s,t[e+1]=c,t[e+2]=u,t[e+3]=d},t}(),p=function(t){function e(e,a,n){return t.call(this,e,a,n)||this}return r(e,t),e.prototype.intervalChanged=function(t,e,a){},e.prototype.interpolate=function(t,e,a,n){for(var r,o=this.data,i=null!==(r=this.componentCount)&&void 0!==r?r:1,s=(a-e)/(n-e),c=t*i,u=new Float32Array(i),d=c+i;c!==d;c+=4)f.slerpFlat(u,0,o,c-i,o,c,s);return u},e}(d);function m(t,e,a,n,r){switch(t){case"LINEAR":return"rotation"===r?new p(e,a,n):new l(e,a,n);case"STEP":return new h(e,a,n);default:return new l(e,a,n)}}var _,g=function(){function t(){}return t.acosClamped=function(e){return Math.acos(t.clamp(e,-1,1))},t.clamp=function(t,e,a){return t<e?e:t>a?a:t},t.equalsEpsilon=function(t,e,a,n){a=null!=a?a:0,n=null!=n?n:a;var r=Math.abs(t-e);return r<=n||r<=a*Math.max(Math.abs(t),Math.abs(e))},t.EPSILON6=1e-6,t.EPSILON7=1e-7,t.EPSILON21=1e-21,t}(),y=function(){function t(t,e){this._data=new Float32Array([null!=t?t:0,null!=e?e:0])}return Object.defineProperty(t.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data[0]=t},enumerable:!1,configurable:!0}),t.prototype.getX=function(){return this._data[0]},t.prototype.setX=function(t){this._data[0]=t},Object.defineProperty(t.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t},enumerable:!1,configurable:!0}),t.prototype.getY=function(){return this._data[1]},t.prototype.setY=function(t){this._data[1]=t},t.prototype.set=function(t,e){this._data[0]=t,this._data[1]=e},Object.defineProperty(t.prototype,"xy",{get:function(){return[this._data[0],this._data[1]]},set:function(t){this._data[0]=t[0],this._data[1]=t[1]},enumerable:!1,configurable:!0}),t.fromElements=function(e,a){var n=new t(e,a);return n.x=e,n.y=a,n},t.clone=function(e){return new t(e.x,e.y)},t.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t.x,e[a]=t.y,e},t.unpack=function(t,e,a){return a.x=t[e++],a.y=t[e],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,2*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=2){var o=r/2;a[o]=t.unpack(e,r,a[o])}return a},t.fromArray=function(e){return t.unpack(e,0,new t)},t.maximumComponent=function(t){return Math.max(t.x,t.y)},t.minimumComponent=function(t){return Math.min(t.x,t.y)},t.minimumByComponent=function(t,e,a){return a.x=Math.min(t.x,e.x),a.y=Math.min(t.y,e.y),a},t.maximumByComponent=function(t,e,a){return a.x=Math.max(t.x,e.x),a.y=Math.max(t.y,e.y),a},t.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y},t.magnitude=function(e){return Math.sqrt(t.magnitudeSquared(e))},t.distance=function(e,a){return t.subtract(e,a,v),t.magnitude(v)},t.distanceSquared=function(e,a){return t.subtract(e,a,v),t.magnitudeSquared(v)},t.normalize=function(e,a){var n=t.magnitude(e);return a.x=e.x/n,a.y=e.y/n,a},t.dot=function(t,e){return t.x*e.x+t.y*e.y},t.cross=function(t,e){return t.x*e.y-t.y*e.x},t.multiplyComponents=function(t,e,a){return a.x=t.x*e.x,a.y=t.y*e.y,a},t.divideComponents=function(t,e,a){return a.x=t.x/e.x,a.y=t.y/e.y,a},t.add=function(t,e,a){return a.x=t.x+e.x,a.y=t.y+e.y,a},t.subtract=function(t,e,a){return a.x=t.x-e.x,a.y=t.y-e.y,a},t.multiplyByScalar=function(t,e,a){return a.x=t.x*e,a.y=t.y*e,a},t.divideByScalar=function(t,e,a){return a.x=t.x/e,a.y=t.y/e,a},t.negate=function(t,e){return e.x=-t.x,e.y=-t.y,e},t.abs=function(t,e){return e.x=Math.abs(t.x),e.y=Math.abs(t.y),e},t.lerp=function(e,a,n,r){return t.multiplyByScalar(a,n,x),r=t.multiplyByScalar(e,1-n,r),t.add(x,r,r)},t.angleBetween=function(e,a){return t.normalize(e,b),t.normalize(a,T),g.acosClamped(t.dot(b,T))},t.mostOrthogonalAxis=function(e,a){var n=t.normalize(e,M);return t.abs(n,n),n.x<=n.y?t.UNIT_X.copyTo(a):t.UNIT_Y.copyTo(a),a},t.equals=function(t,e){return t===e||t.x===e.x&&t.y===e.y},t.equalsArray=function(t,e,a){return a=null!=a?a:0,t.x===e[a]&&t.y===e[a+1]},t.equalsEpsilon=function(t,e,a,n){return t===e||g.equalsEpsilon(t.x,e.x,a,n)&&g.equalsEpsilon(t.y,e.y,a,n)},t.max=function(e,a,n){return t.maximumByComponent(e,a,n),n},t.min=function(e,a,n){return t.minimumByComponent(e,a,n),n},t.mix=function(e,a,n,r){return t.lerp(e,a,n,r),r},t.floor=function(t,e){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e},t.ceil=function(t,e){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e},t.round=function(t,e){return e.x=Math.round(t.x),e.y=Math.round(t.y),e},t.prototype.toArray=function(){var e=new Array(2);return t.pack(this,e)},t.prototype.clone=function(){return t.clone(this)},t.prototype.copyTo=function(t){return t.x=this.x,t.y=this.y,t},t.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this},t.prototype.addVector=function(e){return t.add(this,e,this)},t.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this},t.prototype.subVector=function(e){return t.subtract(this,e,this)},t.prototype.multiplyScalar=function(e){return t.multiplyByScalar(this,e,this)},t.prototype.multiplyVector=function(e){return t.multiplyComponents(this,e,this)},t.prototype.divideVector=function(e){return t.divideComponents(this,e,this)},t.prototype.divideScalar=function(e){return t.divideByScalar(this,e,this)},t.prototype.min=function(){return t.minimumComponent(this)},t.prototype.max=function(){return t.maximumComponent(this)},t.prototype.clamp=function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},t.prototype.floor=function(){return t.floor(this,this)},t.prototype.ceil=function(){return t.ceil(this,this)},t.prototype.round=function(){return t.round(this,this)},t.prototype.negate=function(){return t.negate(this,this)},t.prototype.dot=function(e){return t.dot(this,e)},t.prototype.cross=function(e){return t.cross(this,e)},t.prototype.length=function(){return t.magnitude(this)},t.prototype.lengthSquared=function(){return t.magnitudeSquared(this)},t.prototype.normalize=function(){return t.normalize(this,this)},t.prototype.angleTo=function(e){return t.angleBetween(this,e)},t.prototype.distanceTo=function(e){return t.distance(this,e)},t.prototype.distanceSquaredTo=function(e){return t.distanceSquared(this,e)},t.prototype.getData=function(){return this._data},t.ZERO=Object.freeze(new t(0,0)),t.ONE=Object.freeze(new t(1,1)),t.UNIT_X=Object.freeze(new t(1,0)),t.UNIT_Y=Object.freeze(new t(0,1)),t}(),v=new y,x=new y,b=new y,T=new y,M=new y,S=function(){function t(t,e,a){this._data=new Float32Array([null!=t?t:0,null!=e?e:0,null!=a?a:0])}return Object.defineProperty(t.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data[0]=t},enumerable:!1,configurable:!0}),t.prototype.getX=function(){return this._data[0]},t.prototype.setX=function(t){this._data[0]=t},Object.defineProperty(t.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t},enumerable:!1,configurable:!0}),t.prototype.getY=function(){return this._data[1]},t.prototype.setY=function(t){this._data[1]=t},Object.defineProperty(t.prototype,"z",{get:function(){return this._data[2]},set:function(t){this._data[2]=t},enumerable:!1,configurable:!0}),t.prototype.getZ=function(){return this._data[2]},t.prototype.setZ=function(t){this._data[2]=t},t.prototype.set=function(t,e,a){this._data[0]=t,this._data[1]=e,this._data[2]=a},Object.defineProperty(t.prototype,"xyz",{get:function(){return[this._data[0],this._data[1],this._data[2]]},set:function(t){this._data[0]=t[0],this._data[1]=t[1],this._data[2]=t[2]},enumerable:!1,configurable:!0}),t.fromElements=function(e,a,n){var r=new t(e,a,n);return r.x=e,r.y=a,r.z=n,r},t.clone=function(e){return new t(e.x,e.y,e.z)},t.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t.x,e[a++]=t.y,e[a]=t.z,e},t.unpack=function(t,e,a){return a.x=t[e++],a.y=t[e++],a.z=t[e],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,3*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=3){var o=r/3;a[o]=t.unpack(e,r,a[o])}return a},t.fromArray=function(e){return this.unpack(e,0,new t)},t.maximumComponent=function(t){return Math.max(t.x,t.y,t.z)},t.minimumComponent=function(t){return Math.min(t.x,t.y,t.z)},t.minComponentIndex=function(t){return t.x<t.y?t.x<t.z?0:2:t.y<t.z?1:2},t.tryZUpVector=function(e,a){var n=e.clone().normalize(),r=[],o=[new t(0,1,0),new t(1,0,0),new t(0,0,1)];if(o.forEach((function(t){r.push(Math.abs(n.dot(t)))})),r[0]<.99)a.set(0,1,0);else{var i=99999;r.forEach((function(t,e){i>t&&(a.copyFrom(o[e]),i=t)}))}return a},t.computeUpVector=function(e,a){var n=e.clone().normalize();return 1!==t.minComponentIndex(t.abs(n,n))?a.set(0,1,0):(a.set(n.z,0,-n.x),a.normalize()),a},t.minimumByComponent=function(t,e,a){return a.x=Math.min(t.x,e.x),a.y=Math.min(t.y,e.y),a.z=Math.min(t.z,e.z),a},t.maximumByComponent=function(t,e,a){return a.x=Math.max(t.x,e.x),a.y=Math.max(t.y,e.y),a.z=Math.max(t.z,e.z),a},t.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y+t.z*t.z},t.magnitude=function(e){return Math.sqrt(t.magnitudeSquared(e))},t.distance=function(e,a){return t.subtract(e,a,C),t.magnitude(C)},t.distanceSquared=function(e,a){return t.subtract(e,a,C),t.magnitudeSquared(C)},t.normalize=function(e,a){var n=t.magnitude(e);return n>1e-5?(a.x=e.x/n,a.y=e.y/n,a.z=e.z/n):(a.x=e.x,a.y=e.y,a.z=e.z),a},t.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},t.multiplyComponents=function(t,e,a){return a.x=t.x*e.x,a.y=t.y*e.y,a.z=t.z*e.z,a},t.divideComponents=function(t,e,a){return a.x=t.x/e.x,a.y=t.y/e.y,a.z=t.z/e.z,a},t.add=function(t,e,a){return a.x=t.x+e.x,a.y=t.y+e.y,a.z=t.z+e.z,a},t.subtract=function(t,e,a){return a.x=t.x-e.x,a.y=t.y-e.y,a.z=t.z-e.z,a},t.multiplyByScalar=function(t,e,a){return a.x=t.x*e,a.y=t.y*e,a.z=t.z*e,a},t.divideByScalar=function(t,e,a){return a.x=t.x/e,a.y=t.y/e,a.z=t.z/e,a},t.negate=function(t,e){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e},t.abs=function(t,e){return e.x=Math.abs(t.x),e.y=Math.abs(t.y),e.z=Math.abs(t.z),e},t.clamp=function(e,a,n){return t.max(e,a,e),t.min(e,n,e),e},t.lerp=function(e,a,n,r){return t.multiplyByScalar(a,n,w),r=t.multiplyByScalar(e,1-n,r),t.add(w,r,r)},t.angleBetween=function(e,a){t.normalize(e,A),t.normalize(a,I);var n=t.dot(A,I),r=t.magnitude(t.cross(A,I,A));return Math.atan2(r,n)},t.mostOrthogonalAxis=function(e,a){var n=t.normalize(e,E);return t.abs(n,n),n.x<=n.y?n.x<=n.z?t.UNIT_X.copyTo(a):t.UNIT_Z.copyTo(a):n.y<=n.z?t.UNIT_Y.copyTo(a):t.UNIT_Z.copyTo(a),a},t.projectVector=function(e,a,n){var r=t.dot(e,a)/t.dot(a,a);return t.multiplyByScalar(a,r,n)},t.equals=function(t,e){return t===e||t.x===e.x&&t.y===e.y&&t.z===e.z},t.equalsArray=function(t,e,a){return a=null!=a?a:0,t.x===e[a]&&t.y===e[a+1]&&t.z===e[a+2]},t.equalsEpsilon=function(t,e,a,n){return t===e||g.equalsEpsilon(t.x,e.x,a,n)&&g.equalsEpsilon(t.y,e.y,a,n)&&g.equalsEpsilon(t.z,e.z,a,n)},t.cross=function(e,a,n){var r=e.x,o=e.y,i=e.z,s=a.x,c=a.y,u=a.z,d=o*u-i*c,l=i*s-r*u,h=r*c-o*s;return void 0===n&&(n=new t),n.x=d,n.y=l,n.z=h,n},t.midpoint=function(t,e,a){return a.x=.5*(t.x+e.x),a.y=.5*(t.y+e.y),a.z=.5*(t.z+e.z),a},t.min=function(e,a,n){return t.minimumByComponent(e,a,n),n},t.max=function(e,a,n){return t.maximumByComponent(e,a,n),n},t.mix=function(e,a,n,r){return t.lerp(e,a,n,r),r},t.floor=function(t,e){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e},t.ceil=function(t,e){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e.z=Math.ceil(t.z),e},t.round=function(t,e){return e.x=Math.round(t.x),e.y=Math.round(t.y),e.z=Math.round(t.z),e},t.prototype.copyTo=function(t){return t.x=this.x,t.y=this.y,t.z=this.z,t},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t.prototype.min=function(e){return t.min(this,e,this),this},t.prototype.max=function(e){return t.max(this,e,this),this},t.prototype.clamp=function(e,a){return t.clamp(this,e,a),this},t.prototype.toArray=function(){var e=new Array(3);return t.pack(this,e)},t.prototype.clone=function(){return t.clone(this)},t.prototype.normalize=function(){return t.normalize(this,this)},t.prototype.length=function(){return t.magnitude(this)},t.prototype.sum=function(){return this.x+this.y+this.z},t.prototype.lengthSquared=function(){return t.magnitudeSquared(this)},t.prototype.floor=function(){return t.floor(this,this)},t.prototype.ceil=function(){return t.ceil(this,this)},t.prototype.round=function(){return t.round(this,this)},t.prototype.negate=function(){return t.negate(this,this)},t.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},t.prototype.addVector=function(e){return t.add(this,e,this),this},t.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},t.prototype.subVector=function(e){return t.subtract(this,e,this)},t.prototype.multiplyScalar=function(e){return t.multiplyByScalar(this,e,this)},t.prototype.multiplyVector=function(e){return t.multiplyComponents(this,e,this)},t.prototype.divideScalar=function(e){return t.divideByScalar(this,e,this)},t.prototype.divideVector=function(e){return t.divideComponents(this,e,this)},t.prototype.dot=function(e){return t.dot(this,e)},t.prototype.cross=function(e){return t.cross(this,e)},t.prototype.distanceTo=function(e){return t.distance(this,e)},t.prototype.distanceSquaredTo=function(e){return t.distanceSquared(this,e)},t.prototype.angleTo=function(e){return t.angleBetween(this,e)},t.prototype.getData=function(){return this._data},t.prototype.applyQuaternion=function(e,a){void 0===a&&(a=new t);var n=this.x,r=this.y,o=this.z,i=e.x,s=e.y,c=e.z,u=e.w,d=a.x,l=a.y,h=a.z,f=u*(n-d)+s*(o-h)-c*(r-l),p=u*(r-l)+c*(n-d)-i*(o-h),m=u*(o-h)+i*(r-l)-s*(n-d),_=-i*(n-d)-s*(r-l)-c*(o-h);return this.x=f*u+_*-i+p*-c-m*-s+d,this.y=p*u+_*-s+m*-i-f*-c+l,this.z=m*u+_*-c+f*-s-p*-i+h,this},t.ZERO=Object.freeze(new t(0,0,0)),t.ONE=Object.freeze(new t(1,1,1)),t.UNIT_X=Object.freeze(new t(1,0,0)),t.UNIT_Y=Object.freeze(new t(0,1,0)),t.UNIT_Z=Object.freeze(new t(0,0,1)),t}(),C=new S,w=new S,A=new S,I=new S,E=new S,P=function(){function t(t,e,a,n){this._data=new Float32Array([null!=t?t:0,null!=e?e:0,null!=a?a:0,null!=n?n:1])}return Object.defineProperty(t.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data[0]=t},enumerable:!1,configurable:!0}),t.prototype.getX=function(){return this._data[0]},t.prototype.setX=function(t){this._data[0]=t},Object.defineProperty(t.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t},enumerable:!1,configurable:!0}),t.prototype.getY=function(){return this._data[1]},t.prototype.setY=function(t){this._data[1]=t},Object.defineProperty(t.prototype,"z",{get:function(){return this._data[2]},set:function(t){this._data[2]=t},enumerable:!1,configurable:!0}),t.prototype.getZ=function(){return this._data[2]},t.prototype.setZ=function(t){this._data[2]=t},Object.defineProperty(t.prototype,"w",{get:function(){return this._data[3]},set:function(t){this._data[3]=t},enumerable:!1,configurable:!0}),t.prototype.getW=function(){return this._data[3]},t.prototype.setW=function(t){this._data[3]=t},t.prototype.set=function(t,e,a,n){this._data[0]=t,this._data[1]=e,this._data[2]=a,this._data[3]=n},t.fromElements=function(e,a,n,r,o){return null==o?new t(e,a,n,r):(o.x=e,o.y=a,o.z=n,o.w=r,o)},t.clone=function(e){return new t(e.x,e.y,e.z,e.w)},t.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t.x,e[a++]=t.y,e[a++]=t.z,e[a]=t.w,e},t.unpack=function(t,e,a){return a.x=t[e++],a.y=t[e++],a.z=t[e++],a.w=t[e],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,4*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=4){var o=r/4;a[o]=t.unpack(e,r,a[o])}return a},t.fromArray=function(e){return t.unpack(e,0,new t)},t.maximumComponent=function(t){return Math.max(t.x,t.y,t.z,t.w)},t.minimumComponent=function(t){return Math.min(t.x,t.y,t.z,t.w)},t.minimumByComponent=function(t,e,a){return a.x=Math.min(t.x,e.x),a.y=Math.min(t.y,e.y),a.z=Math.min(t.z,e.z),a.w=Math.min(t.w,e.w),a},t.maximumByComponent=function(t,e,a){return a.x=Math.max(t.x,e.x),a.y=Math.max(t.y,e.y),a.z=Math.max(t.z,e.z),a.w=Math.max(t.w,e.w),a},t.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w},t.magnitude=function(e){return Math.sqrt(t.magnitudeSquared(e))},t.distance=function(e,a){return t.subtract(e,a,O),t.magnitude(O)},t.distanceSquared=function(e,a){return t.subtract(e,a,O),t.magnitudeSquared(O)},t.normalize=function(e,a){var n=t.magnitude(e);return a.x=e.x/n,a.y=e.y/n,a.z=e.z/n,a.w=e.w/n,a},t.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},t.multiplyComponents=function(t,e,a){return a.x=t.x*e.x,a.y=t.y*e.y,a.z=t.z*e.z,a.w=t.w*e.w,a},t.divideComponents=function(t,e,a){return a.x=t.x/e.x,a.y=t.y/e.y,a.z=t.z/e.z,a.w=t.w/e.w,a},t.add=function(t,e,a){return a.x=t.x+e.x,a.y=t.y+e.y,a.z=t.z+e.z,a.w=t.w+e.w,a},t.subtract=function(t,e,a){return a.x=t.x-e.x,a.y=t.y-e.y,a.z=t.z-e.z,a.w=t.w-e.w,a},t.multiplyByScalar=function(t,e,a){return a.x=t.x*e,a.y=t.y*e,a.z=t.z*e,a.w=t.w*e,a},t.divideByScalar=function(t,e,a){return a.x=t.x/e,a.y=t.y/e,a.z=t.z/e,a.w=t.w/e,a},t.negate=function(t,e){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=-t.w,e},t.abs=function(t,e){return e.x=Math.abs(t.x),e.y=Math.abs(t.y),e.z=Math.abs(t.z),e.w=Math.abs(t.w),e},t.lerp=function(e,a,n,r){return t.multiplyByScalar(a,n,N),r=t.multiplyByScalar(e,1-n,r),t.add(N,r,r)},t.mostOrthogonalAxis=function(e,a){var n=t.normalize(e,L);return t.abs(n,n),n.x<=n.y?n.x<=n.z?n.x<=n.w?t.UNIT_X.copyTo(a):t.UNIT_W.copyTo(a):n.z<=n.w?t.UNIT_Z.copyTo(a):t.UNIT_W.copyTo(a):n.y<=n.z?n.y<=n.w?t.UNIT_Y.copyTo(a):t.UNIT_W.copyTo(a):n.z<=n.w?t.UNIT_Z.copyTo(a):t.UNIT_W.copyTo(a),a},t.equals=function(t,e){return t===e||t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w},t.equalsArray=function(t,e,a){return a=null!=a?a:0,t.x===e[a]&&t.y===e[a+1]&&t.z===e[a+2]&&t.w===e[a+3]},t.equalsEpsilon=function(t,e,a,n){return t===e||g.equalsEpsilon(t.x,e.x,a,n)&&g.equalsEpsilon(t.y,e.y,a,n)&&g.equalsEpsilon(t.z,e.z,a,n)&&g.equalsEpsilon(t.w,e.w,a,n)},t.prototype.toArray=function(){var e=new Array(4);return t.pack(this,e)},t.min=function(e,a,n){return t.minimumByComponent(e,a,n),n},t.max=function(e,a,n){return t.maximumByComponent(e,a,n),n},t.mix=function(e,a,n,r){return t.lerp(e,a,n,r),r},t.floor=function(t,e){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e.w=Math.floor(t.w),e},t.ceil=function(t,e){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e.z=Math.ceil(t.z),e.w=Math.ceil(t.w),e},t.round=function(t,e){return e.x=Math.round(t.x),e.y=Math.round(t.y),e.z=Math.round(t.z),e.w=Math.round(t.w),e},t.prototype.copyTo=function(t){return t.x=this.x,t.y=this.y,t.z=this.z,t.w=this.w,t},t.prototype.clone=function(){return t.clone(this)},t.prototype.normalize=function(){return t.normalize(this,this)},t.prototype.length=function(){return t.magnitude(this)},t.prototype.lengthSquared=function(){return t.magnitudeSquared(this)},t.prototype.floor=function(){return t.floor(this,this)},t.prototype.ceil=function(){return t.ceil(this,this)},t.prototype.round=function(){return t.round(this,this)},t.prototype.negate=function(){return t.negate(this,this)},t.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},t.prototype.addVector=function(e){return t.add(this,e,this)},t.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},t.prototype.subVector=function(e){return t.subtract(this,e,this)},t.prototype.multiplyScalar=function(e){return t.multiplyByScalar(this,e,this)},t.prototype.multiplyVector=function(e){return t.multiplyComponents(this,e,this)},t.prototype.divideScalar=function(e){return t.divideByScalar(this,e,this)},t.prototype.divideVector=function(e){return t.divideComponents(this,e,this)},t.prototype.dot=function(e){return t.dot(this,e)},t.prototype.distanceTo=function(e){return t.distance(this,e)},t.prototype.distanceSquaredTo=function(e){return t.distanceSquared(this,e)},t.prototype.getData=function(){return this._data},t.ZERO=Object.freeze(new t(0,0,0,0)),t.ONE=Object.freeze(new t(1,1,1,1)),t.UNIT_X=Object.freeze(new t(1,0,0,0)),t.UNIT_Y=Object.freeze(new t(0,1,0,0)),t.UNIT_Z=Object.freeze(new t(0,0,1,0)),t.UNIT_W=Object.freeze(new t(0,0,0,1)),t}(),O=new P,N=new P,L=new P,F=function(){function t(t,e,a,n){this._data=new Float32Array(4),this._data[0]=null!=t?t:0,this._data[1]=null!=a?a:0,this._data[2]=null!=e?e:0,this._data[3]=null!=n?n:0}return t.prototype.getData=function(){return this._data},t.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t._data[0],e[a++]=t._data[1],e[a++]=t._data[2],e[a++]=t._data[3],e},t.unpack=function(t,e,a){return a._data[0]=t[e++],a._data[1]=t[e++],a._data[2]=t[e++],a._data[3]=t[e++],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,4*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=4){var o=r/4;a[o]=t.unpack(e,r,a[o])}return a},t.clone=function(e){return new t(e._data[0],e._data[2],e._data[1],e._data[3])},t.fromArray=function(e){return t.unpack(e,0,new t)},t.fromColumnMajorArray=function(e,a){return t.unpack(e,0,a)},t.fromRowMajorArray=function(e,a){return void 0===a?new t(e[0],e[1],e[2],e[3]):(a._data[0]=e[0],a._data[1]=e[2],a._data[2]=e[1],a._data[3]=e[3],a)},t.fromScale=function(t,e){return e._data[0]=t.x,e._data[1]=0,e._data[2]=0,e._data[3]=t.y,e},t.fromUniformScale=function(t,e){return e._data[0]=t,e._data[1]=0,e._data[2]=0,e._data[3]=t,e},t.fromRotation=function(t,e){var a=Math.cos(t),n=Math.sin(t);return e._data[0]=a,e._data[1]=n,e._data[2]=-n,e._data[3]=a,e},t.toArray=function(t,e){return e[0]=t._data[0],e[1]=t._data[1],e[2]=t._data[2],e[3]=t._data[3],e},t.getElement=function(t,e,a){return t._data[2*e+a]},t.getColumn=function(t,e,a){var n=2*e,r=t._data[n],o=t._data[n+1];return a.x=r,a.y=o,a},t.setColumn=function(t,e,a,n){var r=2*e;return(n=t.copyTo(n))._data[r]=a.x,n._data[r+1]=a.y,n},t.getRow=function(t,e,a){void 0===a&&(a=new y);var n=t._data[e],r=t._data[e+2];return a.x=n,a.y=r,a},t.setRow=function(t,e,a,n){return(n=t.copyTo(n))._data[e]=a.x,n._data[e+2]=a.y,n},t.scale=function(e,a,n){var r=t.getScale(e,R),o=a.x/r.x,i=a.y/r.y;return void 0===n&&(n=new t),n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*i,n._data[3]=e._data[3]*i,n},t.setUniformScale=function(e,a,n){var r=t.getScale(e,z),o=a/r.x,i=a/r.y;return void 0===n&&(n=new t),n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*i,n._data[3]=e._data[3]*i,n},t.getScale=function(t,e){return B.set(t._data[0],t._data[1]),e.x=y.magnitude(B),B.set(t._data[2],t._data[3]),e.y=y.magnitude(B),e},t.getMaximumScale=function(e){return t.getScale(e,D),y.maximumComponent(D)},t.setRotation=function(e,a,n){var r=t.getScale(e,U);return n._data[0]=a._data[0]*r.x,n._data[1]=a._data[1]*r.x,n._data[2]=a._data[2]*r.y,n._data[3]=a._data[3]*r.y,n},t.getRotation=function(e,a){var n=t.getScale(e,k);return a._data[0]=e._data[0]/n.x,a._data[1]=e._data[1]/n.x,a._data[2]=e._data[2]/n.y,a._data[3]=e._data[3]/n.y,a},t.multiply=function(t,e,a){var n=t._data[0]*e._data[0]+t._data[2]*e._data[1],r=t._data[0]*e._data[2]+t._data[2]*e._data[3],o=t._data[1]*e._data[0]+t._data[3]*e._data[1],i=t._data[1]*e._data[2]+t._data[3]*e._data[3];return a._data[0]=n,a._data[1]=o,a._data[2]=r,a._data[3]=i,a},t.add=function(t,e,a){return a._data[0]=t._data[0]+e._data[0],a._data[1]=t._data[1]+e._data[1],a._data[2]=t._data[2]+e._data[2],a._data[3]=t._data[3]+e._data[3],a},t.subtract=function(t,e,a){return a._data[0]=t._data[0]-e._data[0],a._data[1]=t._data[1]-e._data[1],a._data[2]=t._data[2]-e._data[2],a._data[3]=t._data[3]-e._data[3],a},t.multiplyByVector=function(t,e,a){var n=t._data[0]*e.x+t._data[2]*e.y,r=t._data[1]*e.x+t._data[3]*e.y;return a.x=n,a.y=r,a},t.multiplyByScalar=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3]*e,a},t.multiplyByScale=function(t,e,a){return a._data[0]=t._data[0]*e.x,a._data[1]=t._data[1]*e.x,a._data[2]=t._data[2]*e.y,a._data[3]=t._data[3]*e.y,a},t.multiplyByUniformScale=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3]*e,a},t.negate=function(t,e){return e._data[0]=-t._data[0],e._data[1]=-t._data[1],e._data[2]=-t._data[2],e._data[3]=-t._data[3],e},t.transpose=function(t,e){var a=t._data[0],n=t._data[2],r=t._data[1],o=t._data[3];return e._data[0]=a,e._data[1]=n,e._data[2]=r,e._data[3]=o,e},t.abs=function(t,e){return e._data[0]=Math.abs(t._data[0]),e._data[1]=Math.abs(t._data[1]),e._data[2]=Math.abs(t._data[2]),e._data[3]=Math.abs(t._data[3]),e},t.equals=function(t,e){return t===e||t._data[0]===e._data[0]&&t._data[1]===e._data[1]&&t._data[2]===e._data[2]&&t._data[3]===e._data[3]},t.equalsArray=function(t,e,a){return a=null!=a?a:0,t._data[0]===e[a]&&t._data[1]===e[a+1]&&t._data[2]===e[a+2]&&t._data[3]===e[a+3]},t.equalsEpsilon=function(t,e,a){return a=null!=a?a:0,t===e||Math.abs(t._data[0]-e._data[0])<=a&&Math.abs(t._data[1]-e._data[1])<=a&&Math.abs(t._data[2]-e._data[2])<=a&&Math.abs(t._data[3]-e._data[3])<=a},t.prototype.copyTo=function(t){return t._data[0]=this._data[0],t._data[1]=this._data[1],t._data[2]=this._data[2],t._data[3]=this._data[3],t},t.prototype.copyFrom=function(t){return this._data[0]=t._data[0],this._data[1]=t._data[1],this._data[2]=t._data[2],this._data[3]=t._data[3],this},t.IDENTITY=Object.freeze(new t(1,0,0,1)),t.ZERO=Object.freeze(new t(0,0,0,0)),t}(),R=new y,z=new y,B=new y,D=new y,U=new y,k=new y,V=function(){function t(t,e,a,n,r,o,i,s,c){this._data=new Float32Array(9),this._data[0]=null!=t?t:0,this._data[1]=null!=n?n:0,this._data[2]=null!=i?i:0,this._data[3]=null!=e?e:0,this._data[4]=null!=r?r:0,this._data[5]=null!=s?s:0,this._data[6]=null!=a?a:0,this._data[7]=null!=o?o:0,this._data[8]=null!=c?c:0}return t.prototype.getData=function(){return this._data},t.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t._data[0],e[a++]=t._data[1],e[a++]=t._data[2],e[a++]=t._data[3],e[a++]=t._data[4],e[a++]=t._data[5],e[a++]=t._data[6],e[a++]=t._data[7],e[a++]=t._data[8],e},t.unpack=function(t,e,a){return a._data[0]=t[e++],a._data[1]=t[e++],a._data[2]=t[e++],a._data[3]=t[e++],a._data[4]=t[e++],a._data[5]=t[e++],a._data[6]=t[e++],a._data[7]=t[e++],a._data[8]=t[e++],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,9*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=9){var o=r/9;a[o]=t.unpack(e,r,a[o])}return a},t.clone=function(e){var a=new t;return a._data[0]=e._data[0],a._data[1]=e._data[1],a._data[2]=e._data[2],a._data[3]=e._data[3],a._data[4]=e._data[4],a._data[5]=e._data[5],a._data[6]=e._data[6],a._data[7]=e._data[7],a._data[8]=e._data[8],a},t.copyTo=function(t,e){return e._data[0]=t._data[0],e._data[1]=t._data[1],e._data[2]=t._data[2],e._data[3]=t._data[3],e._data[4]=t._data[4],e._data[5]=t._data[5],e._data[6]=t._data[6],e._data[7]=t._data[7],e._data[8]=t._data[8],e},t.fromArray=function(e){return t.unpack(e,0,new t)},t.fromColumnMajorArray=function(e,a){return t.unpack(e,0,a)},t.fromRowMajorArray=function(t,e){return e._data[0]=t[0],e._data[1]=t[3],e._data[2]=t[6],e._data[3]=t[1],e._data[4]=t[4],e._data[5]=t[7],e._data[6]=t[2],e._data[7]=t[5],e._data[8]=t[8],e},t.fromQuaternion=function(t,e){var a=t.x*t.x,n=t.x*t.y,r=t.x*t.z,o=t.x*t.w,i=t.y*t.y,s=t.y*t.z,c=t.y*t.w,u=t.z*t.z,d=t.z*t.w,l=t.w*t.w,h=a-i-u+l,f=2*(n-d),p=2*(r+c),m=2*(n+d),_=-a+i-u+l,g=2*(s-o),y=2*(r-c),v=2*(s+o),x=-a-i+u+l;return e._data[0]=h,e._data[1]=m,e._data[2]=y,e._data[3]=f,e._data[4]=_,e._data[5]=v,e._data[6]=p,e._data[7]=g,e._data[8]=x,e},t.fromHeadingPitchRoll=function(t,e){var a=Math.cos(-t.pitch),n=Math.cos(-t.heading),r=Math.cos(t.roll),o=Math.sin(-t.pitch),i=Math.sin(-t.heading),s=Math.sin(t.roll),c=a*n,u=-r*i+s*o*n,d=s*i+r*o*n,l=a*i,h=r*n+s*o*i,f=-s*n+r*o*i,p=-o,m=s*a,_=r*a;return e._data[0]=c,e._data[1]=l,e._data[2]=p,e._data[3]=u,e._data[4]=h,e._data[5]=m,e._data[6]=d,e._data[7]=f,e._data[8]=_,e},t.fromScale=function(t,e){return e._data[0]=t.x,e._data[1]=0,e._data[2]=0,e._data[3]=0,e._data[4]=t.y,e._data[5]=0,e._data[6]=0,e._data[7]=0,e._data[8]=t.z,e},t.fromUniformScale=function(t,e){return e._data[0]=t,e._data[1]=0,e._data[2]=0,e._data[3]=0,e._data[4]=t,e._data[5]=0,e._data[6]=0,e._data[7]=0,e._data[8]=t,e},t.fromCrossProduct=function(t,e){return e._data[0]=0,e._data[1]=t.z,e._data[2]=-t.y,e._data[3]=-t.z,e._data[4]=0,e._data[5]=t.x,e._data[6]=t.y,e._data[7]=-t.x,e._data[8]=0,e},t.fromRotationX=function(t,e){var a=Math.cos(t),n=Math.sin(t);return e._data[0]=1,e._data[1]=0,e._data[2]=0,e._data[3]=0,e._data[4]=a,e._data[5]=n,e._data[6]=0,e._data[7]=-n,e._data[8]=a,e},t.fromRotationY=function(t,e){var a=Math.cos(t),n=Math.sin(t);return e._data[0]=a,e._data[1]=0,e._data[2]=-n,e._data[3]=0,e._data[4]=1,e._data[5]=0,e._data[6]=n,e._data[7]=0,e._data[8]=a,e},t.fromRotationZ=function(t,e){var a=Math.cos(t),n=Math.sin(t);return e._data[0]=a,e._data[1]=n,e._data[2]=0,e._data[3]=-n,e._data[4]=a,e._data[5]=0,e._data[6]=0,e._data[7]=0,e._data[8]=1,e},t.toArray=function(t,e){return e[0]=t._data[0],e[1]=t._data[1],e[2]=t._data[2],e[3]=t._data[3],e[4]=t._data[4],e[5]=t._data[5],e[6]=t._data[6],e[7]=t._data[7],e[8]=t._data[8],e},t.getElement=function(t,e,a){return t._data[3*e+a]},t.getColumn=function(t,e,a){var n=3*e,r=t._data[n],o=t._data[n+1],i=t._data[n+2];return a.x=r,a.y=o,a.z=i,a},t.setColumn=function(e,a,n,r){var o=3*a;return(r=t.copyTo(e,r))._data[o]=n.x,r._data[o+1]=n.y,r._data[o+2]=n.z,r},t.getRow=function(t,e,a){var n=t._data[e],r=t._data[e+3],o=t._data[e+6];return a.x=n,a.y=r,a.z=o,a},t.setRow=function(e,a,n,r){return(r=t.copyTo(e,r))._data[a]=n.x,r._data[a+3]=n.y,r._data[a+6]=n.z,r},t.scale=function(e,a,n){var r=t.getScale(e,j),o=a.x/r.x,i=a.y/r.y,s=a.z/r.z;return n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*o,n._data[3]=e._data[3]*i,n._data[4]=e._data[4]*i,n._data[5]=e._data[5]*i,n._data[6]=e._data[6]*s,n._data[7]=e._data[7]*s,n._data[8]=e._data[8]*s,n},t.setUniformScale=function(e,a,n){var r=t.getScale(e,G),o=a/r.x,i=a/r.y,s=a/r.z;return n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*o,n._data[3]=e._data[3]*i,n._data[4]=e._data[4]*i,n._data[5]=e._data[5]*i,n._data[6]=e._data[6]*s,n._data[7]=e._data[7]*s,n._data[8]=e._data[8]*s,n},t.getScale=function(t,e){return H.set(t._data[0],t._data[1],t._data[2]),e.x=S.magnitude(H),H.set(t._data[3],t._data[4],t._data[5]),e.y=S.magnitude(H),H.set(t._data[6],t._data[7],t._data[8]),e.z=S.magnitude(H),e},t.getMaximumScale=function(e){return t.getScale(e,W),S.maximumComponent(W)},t.setRotation=function(e,a,n){var r=t.getScale(e,q);return n._data[0]=a._data[0]*r.x,n._data[1]=a._data[1]*r.x,n._data[2]=a._data[2]*r.x,n._data[3]=a._data[3]*r.y,n._data[4]=a._data[4]*r.y,n._data[5]=a._data[5]*r.y,n._data[6]=a._data[6]*r.z,n._data[7]=a._data[7]*r.z,n._data[8]=a._data[8]*r.z,n},t.getRotation=function(e,a){var n=t.getScale(e,X);return a._data[0]=e._data[0]/n.x,a._data[1]=e._data[1]/n.x,a._data[2]=e._data[2]/n.x,a._data[3]=e._data[3]/n.y,a._data[4]=e._data[4]/n.y,a._data[5]=e._data[5]/n.y,a._data[6]=e._data[6]/n.z,a._data[7]=e._data[7]/n.z,a._data[8]=e._data[8]/n.z,a},t.multiply=function(t,e,a){var n=t._data[0]*e._data[0]+t._data[3]*e._data[1]+t._data[6]*e._data[2],r=t._data[1]*e._data[0]+t._data[4]*e._data[1]+t._data[7]*e._data[2],o=t._data[2]*e._data[0]+t._data[5]*e._data[1]+t._data[8]*e._data[2],i=t._data[0]*e._data[3]+t._data[3]*e._data[4]+t._data[6]*e._data[5],s=t._data[1]*e._data[3]+t._data[4]*e._data[4]+t._data[7]*e._data[5],c=t._data[2]*e._data[3]+t._data[5]*e._data[4]+t._data[8]*e._data[5],u=t._data[0]*e._data[6]+t._data[3]*e._data[7]+t._data[6]*e._data[8],d=t._data[1]*e._data[6]+t._data[4]*e._data[7]+t._data[7]*e._data[8],l=t._data[2]*e._data[6]+t._data[5]*e._data[7]+t._data[8]*e._data[8];return a._data[0]=n,a._data[1]=r,a._data[2]=o,a._data[3]=i,a._data[4]=s,a._data[5]=c,a._data[6]=u,a._data[7]=d,a._data[8]=l,a},t.add=function(t,e,a){return a._data[0]=t._data[0]+e._data[0],a._data[1]=t._data[1]+e._data[1],a._data[2]=t._data[2]+e._data[2],a._data[3]=t._data[3]+e._data[3],a._data[4]=t._data[4]+e._data[4],a._data[5]=t._data[5]+e._data[5],a._data[6]=t._data[6]+e._data[6],a._data[7]=t._data[7]+e._data[7],a._data[8]=t._data[8]+e._data[8],a},t.subtract=function(t,e,a){return a._data[0]=t._data[0]-e._data[0],a._data[1]=t._data[1]-e._data[1],a._data[2]=t._data[2]-e._data[2],a._data[3]=t._data[3]-e._data[3],a._data[4]=t._data[4]-e._data[4],a._data[5]=t._data[5]-e._data[5],a._data[6]=t._data[6]-e._data[6],a._data[7]=t._data[7]-e._data[7],a._data[8]=t._data[8]-e._data[8],a},t.multiplyByVector=function(t,e,a){var n=e.x,r=e.y,o=e.z,i=t._data[0]*n+t._data[3]*r+t._data[6]*o,s=t._data[1]*n+t._data[4]*r+t._data[7]*o,c=t._data[2]*n+t._data[5]*r+t._data[8]*o;return a.x=i,a.y=s,a.z=c,a},t.multiplyByScalar=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3]*e,a._data[4]=t._data[4]*e,a._data[5]=t._data[5]*e,a._data[6]=t._data[6]*e,a._data[7]=t._data[7]*e,a._data[8]=t._data[8]*e,a},t.multiplyByScale=function(t,e,a){return a._data[0]=t._data[0]*e.x,a._data[1]=t._data[1]*e.x,a._data[2]=t._data[2]*e.x,a._data[3]=t._data[3]*e.y,a._data[4]=t._data[4]*e.y,a._data[5]=t._data[5]*e.y,a._data[6]=t._data[6]*e.z,a._data[7]=t._data[7]*e.z,a._data[8]=t._data[8]*e.z,a},t.multiplyByUniformScale=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3]*e,a._data[4]=t._data[4]*e,a._data[5]=t._data[5]*e,a._data[6]=t._data[6]*e,a._data[7]=t._data[7]*e,a._data[8]=t._data[8]*e,a},t.negate=function(t,e){return e._data[0]=-t._data[0],e._data[1]=-t._data[1],e._data[2]=-t._data[2],e._data[3]=-t._data[3],e._data[4]=-t._data[4],e._data[5]=-t._data[5],e._data[6]=-t._data[6],e._data[7]=-t._data[7],e._data[8]=-t._data[8],e},t.transpose=function(t,e){var a=t._data[0],n=t._data[3],r=t._data[6],o=t._data[1],i=t._data[4],s=t._data[7],c=t._data[2],u=t._data[5],d=t._data[8];return e._data[0]=a,e._data[1]=n,e._data[2]=r,e._data[3]=o,e._data[4]=i,e._data[5]=s,e._data[6]=c,e._data[7]=u,e._data[8]=d,e},t.abs=function(e,a){return void 0===a&&(a=new t),a._data[0]=Math.abs(e._data[0]),a._data[1]=Math.abs(e._data[1]),a._data[2]=Math.abs(e._data[2]),a._data[3]=Math.abs(e._data[3]),a._data[4]=Math.abs(e._data[4]),a._data[5]=Math.abs(e._data[5]),a._data[6]=Math.abs(e._data[6]),a._data[7]=Math.abs(e._data[7]),a._data[8]=Math.abs(e._data[8]),a},t.determinant=function(t){var e=t._data[0],a=t._data[3],n=t._data[6],r=t._data[1],o=t._data[4],i=t._data[7],s=t._data[2],c=t._data[5],u=t._data[8];return e*(o*u-c*i)+r*(c*n-a*u)+s*(a*i-o*n)},t.inverse=function(e,a){var n=e._data[0],r=e._data[1],o=e._data[2],i=e._data[3],s=e._data[4],c=e._data[5],u=e._data[6],d=e._data[7],l=e._data[8],h=t.determinant(e);a._data[0]=s*l-d*c,a._data[1]=d*o-r*l,a._data[2]=r*c-s*o,a._data[3]=u*c-i*l,a._data[4]=n*l-u*o,a._data[5]=i*o-n*c,a._data[6]=i*d-u*s,a._data[7]=u*r-n*d,a._data[8]=n*s-i*r;var f=1/h;return t.multiplyByScalar(a,f,a)},t.inverseTranspose=function(e,a){return t.inverse(t.transpose(e,Y),a)},t.equals=function(t,e){return t===e||t._data[0]===e._data[0]&&t._data[1]===e._data[1]&&t._data[2]===e._data[2]&&t._data[3]===e._data[3]&&t._data[4]===e._data[4]&&t._data[5]===e._data[5]&&t._data[6]===e._data[6]&&t._data[7]===e._data[7]&&t._data[8]===e._data[8]},t.equalsEpsilon=function(t,e,a){return a=null!=a?a:0,t===e||Math.abs(t._data[0]-e._data[0])<=a&&Math.abs(t._data[1]-e._data[1])<=a&&Math.abs(t._data[2]-e._data[2])<=a&&Math.abs(t._data[3]-e._data[3])<=a&&Math.abs(t._data[4]-e._data[4])<=a&&Math.abs(t._data[5]-e._data[5])<=a&&Math.abs(t._data[6]-e._data[6])<=a&&Math.abs(t._data[7]-e._data[7])<=a&&Math.abs(t._data[8]-e._data[8])<=a},t.getElementIndex=function(t,e){return 3*t+e},t.prototype.getElement=function(e,a){return t.getElement(this,e,a)},t.prototype.clone=function(){return t.clone(this)},t.prototype.copyTo=function(e){return e=t.copyTo(this,e)},t.prototype.copyFrom=function(e){return t.copyTo(e,this),this},t.prototype.scale=function(e){return t.scale(this,e,this)},t.prototype.multiply=function(e){return t.multiply(this,e,this)},t.prototype.toArray=function(){var e=new Array(9);return t.toArray(this,e)},t.prototype.toFloat32Array=function(){var e=new Float32Array(9);return t.pack(this,e,0),e},t.prototype.multiplyByVector3=function(e){return t.multiplyByVector(this,e,new S)},t.prototype.at=function(t){return this._data[t]},t.prototype.rotate=function(t,e){var a=e.x,n=e.y,r=e.z,o=Math.sqrt(a*a+n*n+r*r);if(o){1!==o&&(a*=o=1/o,n*=o,r*=o);var i=Math.sin(t),s=Math.cos(t),c=1-s,u=this._data[0],d=this._data[1],l=this._data[2],h=this._data[3],f=this._data[4],p=this._data[5],m=this._data[6],_=this._data[7],g=this._data[8],y=this._data[9],v=this._data[10],x=this._data[11],b=a*a*c+s,T=n*a*c+r*i,M=r*a*c-n*i,S=a*n*c-r*i,C=n*n*c+s,w=r*n*c+a*i,A=a*r*c+n*i,I=n*r*c-a*i,E=r*r*c+s;return this._data[0]=u*b+f*T+g*M,this._data[1]=d*b+p*T+y*M,this._data[2]=l*b+m*T+v*M,this._data[3]=h*b+_*T+x*M,this._data[4]=u*S+f*C+g*w,this._data[5]=d*S+p*C+y*w,this._data[6]=l*S+m*C+v*w,this._data[7]=h*S+_*C+x*w,this._data[8]=u*A+f*I+g*E,this._data[9]=d*A+p*I+y*E,this._data[10]=l*A+m*I+v*E,this._data[11]=h*A+_*I+x*E,this}},t.prototype.inverse=function(){return t.inverse(this,this)},t.prototype.transpose=function(){return t.transpose(this,this)},t.IDENTITY=Object.freeze(new t(1,0,0,0,1,0,0,0,1)),t.ZERO=Object.freeze(new t(0,0,0,0,0,0,0,0,0)),t.COLUMN0ROW0=0,t.COLUMN0ROW1=1,t.COLUMN0ROW2=2,t.COLUMN1ROW0=3,t.COLUMN1ROW1=4,t.COLUMN1ROW2=5,t.COLUMN2ROW0=6,t.COLUMN2ROW1=7,t.COLUMN2ROW2=8,t}(),j=new S,G=new S,H=new S,W=new S,q=new S,X=new S,Y=new V;t.EulerOrder=void 0,(_=t.EulerOrder||(t.EulerOrder={}))[_.XYZ=0]="XYZ",_[_.XZY=1]="XZY",_[_.YXZ=2]="YXZ",_[_.YZX=3]="YZX",_[_.ZXY=4]="ZXY",_[_.ZYX=5]="ZYX";var Z=function(){function e(e,a,n,r){void 0===e&&(e=0),void 0===a&&(a=0),void 0===n&&(n=0),void 0===r&&(r=t.EulerOrder.ZYX),this._order=r,this._data=new Float32Array([e,a,n])}return Object.defineProperty(e.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data[0]=t},enumerable:!1,configurable:!0}),e.prototype.getX=function(){return this._data[0]},e.prototype.setX=function(t){this._data[0]=t},Object.defineProperty(e.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t},enumerable:!1,configurable:!0}),e.prototype.getY=function(){return this._data[1]},e.prototype.setY=function(t){this._data[1]=t},Object.defineProperty(e.prototype,"z",{get:function(){return this._data[2]},set:function(t){this._data[2]=t},enumerable:!1,configurable:!0}),e.prototype.getZ=function(){return this._data[2]},e.prototype.setZ=function(t){this._data[2]=t},Object.defineProperty(e.prototype,"order",{get:function(){return this._order},set:function(t){this._order=t},enumerable:!1,configurable:!0}),e.prototype.getOrder=function(){return this._order},e.prototype.setOrder=function(t){this._order=t},e.prototype.set=function(e,a,n,r){return this._data[0]=e,this._data[1]=a,this._data[2]=n,this._order=void 0===r?t.EulerOrder.ZYX:r,this},e.prototype.clone=function(){return e.clone(this)},e.prototype.copyTo=function(t){return t=e.copyTo(this,t)},e.prototype.copyFrom=function(t){return e.copyTo(t,this),this},e.prototype.setFromRotationMatrix=function(a,n){return void 0===n&&(n=t.EulerOrder.XYZ),e.setFromRotationMatrix(a,n,this)},e.prototype.setFromQuaternion=function(a,n){return void 0===n&&(n=t.EulerOrder.XYZ),e.setFromQuaternion(a,n,this)},e.prototype.setFromVector3=function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},e.prototype.reorder=function(t){return e.reorder(this,t)},e.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t._order===this._order},e.prototype.fromArray=function(t){return this.x=t[0],this.y=t[1],this.z=t[2],void 0!==t[3]&&(this._order=t[3]),this},e.prototype.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this._order,t},e.prototype.toVector3=function(t){return t.set(this.x,this.y,this.z),t},e.clone=function(t){var a=new e;return a.x=t.x,a.y=t.y,a.z=t.z,a.order=t.order,a},e.copyTo=function(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.order=t.order,e},e.setFromRotationMatrix=function(e,a,n){var r=g.clamp,o=e.getData(),i=o[0],s=o[4],c=o[8],u=o[1],d=o[5],l=o[9],h=o[2],f=o[6],p=o[10];switch(a=a||n._order){case t.EulerOrder.XYZ:n.y=Math.asin(r(c,-1,1)),Math.abs(c)<.9999999?(n.x=Math.atan2(-l,p),n.z=Math.atan2(-s,i)):(n.x=Math.atan2(f,d),n.z=0);break;case t.EulerOrder.YXZ:n.x=Math.asin(-r(l,-1,1)),Math.abs(l)<.9999999?(n.y=Math.atan2(c,p),n.z=Math.atan2(u,d)):(n.y=Math.atan2(-h,i),n.z=0);break;case t.EulerOrder.ZXY:n.x=Math.asin(r(f,-1,1)),Math.abs(f)<.9999999?(n.y=Math.atan2(-h,p),n.z=Math.atan2(-s,d)):(n.y=0,n.z=Math.atan2(u,i));break;case t.EulerOrder.ZYX:n.y=Math.asin(-r(h,-1,1)),Math.abs(h)<.9999999?(n.x=Math.atan2(f,p),n.z=Math.atan2(u,i)):(n.x=0,n.z=Math.atan2(-s,d));break;case t.EulerOrder.YZX:n.z=Math.asin(r(u,-1,1)),Math.abs(u)<.9999999?(n.x=Math.atan2(-l,d),n.y=Math.atan2(-h,i)):(n.x=0,n.y=Math.atan2(c,p));break;case t.EulerOrder.XZY:n.z=Math.asin(-r(s,-1,1)),Math.abs(s)<.9999999?(n.x=Math.atan2(f,d),n.y=Math.atan2(c,i)):(n.x=Math.atan2(-l,p),n.y=0);break;default:console.warn("Euler.setFromRotationMatrix() encountered an unknown order: ".concat(a))}return n._order=a,n},e.setFromQuaternion=function(t,a,n){var r=new ct;return t.toMatrix4(r),e.setFromRotationMatrix(r,a,n)},e.reorder=function(t,a){var n=new J;return J.setFromEuler(t,n),e.setFromQuaternion(n,a,t)},e}(),J=function(){function e(t,e,a,n){this._data=new Float32Array([null!=t?t:0,null!=e?e:0,null!=a?a:0,null!=n?n:0])}return Object.defineProperty(e.prototype,"x",{get:function(){return this._data[0]},set:function(t){this._data[0]=t},enumerable:!1,configurable:!0}),e.prototype.getX=function(){return this._data[0]},e.prototype.setX=function(t){this._data[0]=t},Object.defineProperty(e.prototype,"y",{get:function(){return this._data[1]},set:function(t){this._data[1]=t},enumerable:!1,configurable:!0}),e.prototype.getY=function(){return this._data[1]},e.prototype.setY=function(t){this._data[1]=t},Object.defineProperty(e.prototype,"z",{get:function(){return this._data[2]},set:function(t){this._data[2]=t},enumerable:!1,configurable:!0}),e.prototype.getZ=function(){return this._data[2]},e.prototype.setZ=function(t){this._data[2]=t},Object.defineProperty(e.prototype,"w",{get:function(){return this._data[3]},set:function(t){this._data[3]=t},enumerable:!1,configurable:!0}),e.prototype.getW=function(){return this._data[3]},e.prototype.setW=function(t){this._data[3]=t},e.fromAxisAngle=function(t,e,a){var n=e/2,r=Math.sin(n),o=(Q=S.normalize(t,Q)).x*r,i=Q.y*r,s=Q.z*r,c=Math.cos(n);return a.x=o,a.y=i,a.z=s,a.w=c,a},e.fromRotationMatrix=function(t,e){var a,n,r,o,i,s=t.getData()[V.COLUMN0ROW0],c=t.getData()[V.COLUMN1ROW1],u=t.getData()[V.COLUMN2ROW2],d=s+c+u;if(d>0)i=.5*(a=Math.sqrt(d+1)),a=.5/a,n=(t.getData()[V.COLUMN1ROW2]-t.getData()[V.COLUMN2ROW1])*a,r=(t.getData()[V.COLUMN2ROW0]-t.getData()[V.COLUMN0ROW2])*a,o=(t.getData()[V.COLUMN0ROW1]-t.getData()[V.COLUMN1ROW0])*a;else{var l=K,h=0;c>s&&(h=1),u>s&&u>c&&(h=2);var f=l[h],p=l[f];a=Math.sqrt(t.getData()[V.getElementIndex(h,h)]-t.getData()[V.getElementIndex(f,f)]-t.getData()[V.getElementIndex(p,p)]+1);var m=$;m[h]=.5*a,a=.5/a,i=(t.getData()[V.getElementIndex(p,f)]-t.getData()[V.getElementIndex(f,p)])*a,m[f]=(t.getData()[V.getElementIndex(f,h)]+t.getData()[V.getElementIndex(h,f)])*a,m[p]=(t.getData()[V.getElementIndex(p,h)]+t.getData()[V.getElementIndex(h,p)])*a,n=-m[0],r=-m[1],o=-m[2]}return e.x=n,e.y=r,e.z=o,e.w=i,e},e.fromHeadingPitchRoll=function(t,a){return nt=e.fromAxisAngle(S.UNIT_X,t.roll,tt),at=e.fromAxisAngle(S.UNIT_Y,-t.pitch,a),a=e.multiply(at,nt,at),et=e.fromAxisAngle(S.UNIT_Z,-t.heading,tt),e.multiply(et,a,a)},e.setFromEuler=function(e,a){var n=e.x,r=e.y,o=e.z,i=e.order,s=Math.cos,c=Math.sin,u=s(n/2),d=s(r/2),l=s(o/2),h=c(n/2),f=c(r/2),p=c(o/2);switch(i){case t.EulerOrder.XYZ:a.x=h*d*l+u*f*p,a.y=u*f*l-h*d*p,a.z=u*d*p+h*f*l,a.w=u*d*l-h*f*p;break;case t.EulerOrder.YXZ:a.x=h*d*l+u*f*p,a.y=u*f*l-h*d*p,a.z=u*d*p-h*f*l,a.w=u*d*l+h*f*p;break;case t.EulerOrder.ZXY:a.x=h*d*l-u*f*p,a.y=u*f*l+h*d*p,a.z=u*d*p+h*f*l,a.w=u*d*l-h*f*p;break;case t.EulerOrder.ZYX:a.x=h*d*l-u*f*p,a.y=u*f*l+h*d*p,a.z=u*d*p-h*f*l,a.w=u*d*l+h*f*p;break;case t.EulerOrder.YZX:a.x=h*d*l+u*f*p,a.y=u*f*l+h*d*p,a.z=u*d*p-h*f*l,a.w=u*d*l-h*f*p;break;case t.EulerOrder.XZY:a.x=h*d*l-u*f*p,a.y=u*f*l-h*d*p,a.z=u*d*p+h*f*l,a.w=u*d*l+h*f*p;break;default:console.warn("Quaternion.setFromEuler() encountered an unknown order: ".concat(i))}return a},e.pack=function(t,e,a){return a=null!=a?a:0,e[a++]=t.x,e[a++]=t.y,e[a++]=t.z,e[a]=t.w,e},e.unpack=function(t,e,a){return a.x=t[e++],a.y=t[e++],a.z=t[e++],a.w=t[e],a},e.fromArray=function(t){return e.unpack(t,0,new e)},e.multiply=function(t,e,a){var n=t.x,r=t.y,o=t.z,i=t.w,s=e.x,c=e.y,u=e.z,d=e.w,l=i*s+n*d+r*u-o*c,h=i*c-n*u+r*d+o*s,f=i*u+n*c-r*s+o*d,p=i*d-n*s-r*c-o*u;return a.x=l,a.y=h,a.z=f,a.w=p,a},e.clone=function(t){var a=new e;return a.x=t.x,a.y=t.y,a.z=t.z,a.w=t.w,a},e.copyTo=function(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e},e.conjugate=function(t,e){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=t.w,e},e.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w},e.magnitude=function(t){return Math.sqrt(e.magnitudeSquared(t))},e.normalize=function(t,a){var n=1/e.magnitude(t),r=t.x*n,o=t.y*n,i=t.z*n,s=t.w*n;return a.x=r,a.y=o,a.z=i,a.w=s,a},e.inverse=function(t,a){var n=e.magnitudeSquared(t);return a=e.conjugate(t,a),e.multiplyByScalar(a,1/n,a)},e.add=function(t,e,a){return a.x=t.x+e.x,a.y=t.y+e.y,a.z=t.z+e.z,a.w=t.w+e.w,a},e.subtract=function(t,e,a){return a.x=t.x-e.x,a.y=t.y-e.y,a.z=t.z-e.z,a.w=t.w-e.w,a},e.negate=function(t,e){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=-t.w,e},e.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},e.multiplyByScalar=function(t,e,a){return a.x=t.x*e,a.y=t.y*e,a.z=t.z*e,a.w=t.w*e,a},e.computeAxis=function(t,e){var a=t.w;if(Math.abs(a-1)<g.EPSILON6)return e.x=e.y=e.z=0,e;var n=1/Math.sqrt(1-a*a);return e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e},e.computeAngle=function(t){return Math.abs(t.w-1)<g.EPSILON6?0:2*Math.acos(t.w)},e.lerp=function(t,a,n,r){return rt=e.multiplyByScalar(a,n,rt),r=e.multiplyByScalar(t,1-n,r),e.add(rt,r,r)},e.slerp=function(t,a,n,r){var o=e.dot(t,a),i=a;if(o<0&&(o=-o,i=ot=e.negate(a,ot)),1-o<g.EPSILON6)return e.lerp(t,i,n,r);var s=Math.acos(o);return it=e.multiplyByScalar(t,Math.sin((1-n)*s),it),st=e.multiplyByScalar(i,Math.sin(n*s),st),r=e.add(it,st,r),e.multiplyByScalar(r,1/Math.sin(s),r)},e.equals=function(t,e){return t===e||t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w},e.equalsEpsilon=function(t,e,a){return a=null!=a?a:0,t===e||Math.abs(t.x-e.x)<=a&&Math.abs(t.y-e.y)<=a&&Math.abs(t.z-e.z)<=a&&Math.abs(t.w-e.w)<=a},e.prototype.toMatrix4=function(t){var e=this.x,a=this.y,n=this.z,r=this.w,o=e+e,i=a+a,s=n+n,c=e*o,u=e*i,d=e*s,l=a*i,h=a*s,f=n*s,p=r*o,m=r*i,_=r*s;return t=ct.fromColumnMajorArray([1-(l+f),u+_,d-m,0,u-_,1-(c+f),h+p,0,d+m,h-p,1-(c+l),0,0,0,0,1],t)},e.prototype.clone=function(){return e.clone(this)},e.prototype.copyTo=function(t){return t=e.copyTo(this,t)},e.prototype.copyFrom=function(t){return e.copyTo(t,this),this},e.prototype.roll=function(){var t=this.x,e=this.y,a=this.z,n=this.w;return Math.atan2(2*(t*e+n*a),n*n+t*t-e*e-a*a)},e.prototype.pitch=function(){var t=this.x,e=this.y,a=this.z,n=this.w;return Math.atan2(2*(e*a+n*t),n*n-t*t-e*e+a*a)},e.prototype.yaw=function(){return Math.asin(2*(this.x*this.z-this.w*this.y))},e.prototype.inverse=function(){return e.inverse(this,this)},e.prototype.conjugate=function(){return e.conjugate(this,this)},e.prototype.length=function(){return e.magnitude(this)},e.prototype.normalize=function(){return e.normalize(this,this)},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},e.prototype.multiply=function(t){return e.multiply(this,t,this)},e.prototype.set=function(t,e,a,n){return this.x=t,this.y=e,this.z=a,this.w=n,this},e.prototype.setFromEuler=function(t){return e.setFromEuler(t,this)},e.prototype.toArray=function(){return[this._data[0],this._data[1],this._data[2],this._data[3]]},e.IDENTITY=Object.freeze(new e(0,0,0,1)),e.ZERO=Object.freeze(new e(0,0,0,0)),e}(),Q=new S,K=[1,2,0],$=new Array(3),tt=new J,et=new J,at=new J,nt=new J;new S,new S,new J,new J,new J;var rt=new J,ot=new J,it=new J,st=new J,ct=function(){function t(t,e,a,n,r,o,i,s,c,u,d,l,h,f,p,m){this._data=new Float32Array(16),this._data[0]=null!=t?t:0,this._data[1]=null!=r?r:0,this._data[2]=null!=c?c:0,this._data[3]=null!=h?h:0,this._data[4]=null!=e?e:0,this._data[5]=null!=o?o:0,this._data[6]=null!=u?u:0,this._data[7]=null!=f?f:0,this._data[8]=null!=a?a:0,this._data[9]=null!=i?i:0,this._data[10]=null!=d?d:0,this._data[11]=null!=p?p:0,this._data[12]=null!=n?n:0,this._data[13]=null!=s?s:0,this._data[14]=null!=l?l:0,this._data[15]=null!=m?m:0}return t.prototype.getData=function(){return this._data},t.prototype.setData=function(t){this._data=t},Object.defineProperty(t.prototype,"data",{get:function(){return this._data},enumerable:!1,configurable:!0}),t.prototype.lookAt=function(e,a,n){return t.computeLookAt(e,a,n,this)},t.prototype.perspective=function(e,a,n,r,o){return t.computePerspective(e,a,n,r,o,this)},t.prototype.orth2d=function(e,a,n,r,o,i){return t.computeOrthographic(e,a,n,r,o,i,this)},t.prototype.compose=function(e,a,n){return t.compose(e,a,n,this)},t.prototype.decompose=function(){return t.decompose(this)},t.prototype.multiplyByPoint3=function(e){return t.multiplyByPoint(this,e,e)},t.prototype.setZero=function(){for(var t=this._data,e=0;e<t.length;e++)t[e]=0},t.prototype.setIdentity=function(){for(var t=this._data,e=0;e<t.length;e++)t[e]=e%5?0:1},t.pack=function(t,e,a){if(a=null!=a?a:0,e.length<a+16)throw"数组长度不够";return e[a++]=t._data[0],e[a++]=t._data[1],e[a++]=t._data[2],e[a++]=t._data[3],e[a++]=t._data[4],e[a++]=t._data[5],e[a++]=t._data[6],e[a++]=t._data[7],e[a++]=t._data[8],e[a++]=t._data[9],e[a++]=t._data[10],e[a++]=t._data[11],e[a++]=t._data[12],e[a++]=t._data[13],e[a++]=t._data[14],e[a]=t._data[15],e},t.unpack=function(t,e,a){return e=null!=e?e:0,a._data[0]=t[e++],a._data[1]=t[e++],a._data[2]=t[e++],a._data[3]=t[e++],a._data[4]=t[e++],a._data[5]=t[e++],a._data[6]=t[e++],a._data[7]=t[e++],a._data[8]=t[e++],a._data[9]=t[e++],a._data[10]=t[e++],a._data[11]=t[e++],a._data[12]=t[e++],a._data[13]=t[e++],a._data[14]=t[e++],a._data[15]=t[e],a},t.packArray=function(e,a){for(var n=e.length,r=0;r<n;++r)t.pack(e[r],a,16*r);return a},t.unpackArray=function(e,a){for(var n=e.length,r=0;r<n;r+=16){var o=r/16;a[o]=t.unpack(e,r,a[o])}return a},t.clone=function(e){var a=new t;return a._data[0]=e.getData()[0],a._data[1]=e.getData()[1],a._data[2]=e.getData()[2],a._data[3]=e.getData()[3],a._data[4]=e.getData()[4],a._data[5]=e.getData()[5],a._data[6]=e.getData()[6],a._data[7]=e.getData()[7],a._data[8]=e.getData()[8],a._data[9]=e.getData()[9],a._data[10]=e.getData()[10],a._data[11]=e.getData()[11],a._data[12]=e.getData()[12],a._data[13]=e.getData()[13],a._data[14]=e.getData()[14],a._data[15]=e.getData()[15],a},t.copyTo=function(t,e){return e._data[0]=t.getData()[0],e._data[1]=t.getData()[1],e._data[2]=t.getData()[2],e._data[3]=t.getData()[3],e._data[4]=t.getData()[4],e._data[5]=t.getData()[5],e._data[6]=t.getData()[6],e._data[7]=t.getData()[7],e._data[8]=t.getData()[8],e._data[9]=t.getData()[9],e._data[10]=t.getData()[10],e._data[11]=t.getData()[11],e._data[12]=t.getData()[12],e._data[13]=t.getData()[13],e._data[14]=t.getData()[14],e._data[15]=t.getData()[15],e},t.fromArray=function(e){return t.unpack(e,0,new t)},t.fromColumnMajorArray=function(e,a){return t.unpack(e,0,a)},t.fromRowMajorArray=function(t,e){return e._data[0]=t[0],e._data[1]=t[4],e._data[2]=t[8],e._data[3]=t[12],e._data[4]=t[1],e._data[5]=t[5],e._data[6]=t[9],e._data[7]=t[13],e._data[8]=t[2],e._data[9]=t[6],e._data[10]=t[10],e._data[11]=t[14],e._data[12]=t[3],e._data[13]=t[7],e._data[14]=t[11],e._data[15]=t[15],e},t.fromRotationTranslation=function(t,e,a){return a._data[0]=t.getData()[0],a._data[1]=t.getData()[1],a._data[2]=t.getData()[2],a._data[3]=0,a._data[4]=t.getData()[3],a._data[5]=t.getData()[4],a._data[6]=t.getData()[5],a._data[7]=0,a._data[8]=t.getData()[6],a._data[9]=t.getData()[7],a._data[10]=t.getData()[8],a._data[11]=0,a._data[12]=e.x,a._data[13]=e.y,a._data[14]=e.z,a._data[15]=1,a},t.fromTranslationQuaternionRotationScale=function(t,e,a,n){var r=a.x,o=a.y,i=a.z,s=e.x*e.x,c=e.x*e.y,u=e.x*e.z,d=e.x*e.w,l=e.y*e.y,h=e.y*e.z,f=e.y*e.w,p=e.z*e.z,m=e.z*e.w,_=e.w*e.w,g=s-l-p+_,y=2*(c-m),v=2*(u+f),x=2*(c+m),b=-s+l-p+_,T=2*(h-d),M=2*(u-f),S=2*(h+d),C=-s-l+p+_;return n._data[0]=g*r,n._data[1]=x*r,n._data[2]=M*r,n._data[3]=0,n._data[4]=y*o,n._data[5]=b*o,n._data[6]=S*o,n._data[7]=0,n._data[8]=v*i,n._data[9]=T*i,n._data[10]=C*i,n._data[11]=0,n._data[12]=t.x,n._data[13]=t.y,n._data[14]=t.z,n._data[15]=1,n},t.fromTranslationRotationScale=function(e,a){return t.fromTranslationQuaternionRotationScale(e.translation,e.rotation,e.scale,a)},t.fromTranslation=function(e,a){return t.fromRotationTranslation(V.IDENTITY,e,a)},t.fromScale=function(t,e){return e._data[0]=t.x,e._data[1]=0,e._data[2]=0,e._data[3]=0,e._data[4]=0,e._data[5]=t.y,e._data[6]=0,e._data[7]=0,e._data[8]=0,e._data[9]=0,e._data[10]=t.z,e._data[11]=0,e._data[12]=0,e._data[13]=0,e._data[14]=0,e._data[15]=1,e},t.fromUniformScale=function(t,e){return e._data[0]=t,e._data[1]=0,e._data[2]=0,e._data[3]=0,e._data[4]=0,e._data[5]=t,e._data[6]=0,e._data[7]=0,e._data[8]=0,e._data[9]=0,e._data[10]=t,e._data[11]=0,e._data[12]=0,e._data[13]=0,e._data[14]=0,e._data[15]=1,e},t.fromRotation=function(t,e){return e._data[0]=t.getData()[0],e._data[1]=t.getData()[1],e._data[2]=t.getData()[2],e._data[3]=0,e._data[4]=t.getData()[3],e._data[5]=t.getData()[4],e._data[6]=t.getData()[5],e._data[7]=0,e._data[8]=t.getData()[6],e._data[9]=t.getData()[7],e._data[10]=t.getData()[8],e._data[11]=0,e._data[12]=0,e._data[13]=0,e._data[14]=0,e._data[15]=1,e},t.fromCamera=function(t,e){var a=t.position,n=t.direction,r=t.up;S.normalize(n,ut),S.normalize(S.cross(ut,r,dt),dt),S.normalize(S.cross(dt,ut,lt),lt);var o=dt.x,i=dt.y,s=dt.z,c=ut.x,u=ut.y,d=ut.z,l=lt.x,h=lt.y,f=lt.z,p=a.x,m=a.y,_=a.z,g=o*-p+i*-m+s*-_,y=l*-p+h*-m+f*-_,v=c*p+u*m+d*_;return e._data[0]=o,e._data[1]=l,e._data[2]=-c,e._data[3]=0,e._data[4]=i,e._data[5]=h,e._data[6]=-u,e._data[7]=0,e._data[8]=s,e._data[9]=f,e._data[10]=-d,e._data[11]=0,e._data[12]=g,e._data[13]=y,e._data[14]=v,e._data[15]=1,e},t.computePerspectiveFieldOfView=function(t,e,a,n,r,o){var i=1/Math.tan(.5*t),s=r?i:i/e,c=r?i*e:i,u=(n+a)/(a-n),d=2*n*a/(a-n);return o._data[0]=s,o._data[1]=0,o._data[2]=0,o._data[3]=0,o._data[4]=0,o._data[5]=c,o._data[6]=0,o._data[7]=0,o._data[8]=0,o._data[9]=0,o._data[10]=u,o._data[11]=-1,o._data[12]=0,o._data[13]=0,o._data[14]=d,o._data[15]=0,o},t.computeOrthographicOffCenter=function(t,e,a,n,r,o,i){var s=1/(e-t),c=1/(n-a),u=1/(o-r),d=-(e+t)*s,l=-(n+a)*c,h=-(o+r)*u;return s*=2,c*=2,u*=-2,i._data[0]=s,i._data[1]=0,i._data[2]=0,i._data[3]=0,i._data[4]=0,i._data[5]=c,i._data[6]=0,i._data[7]=0,i._data[8]=0,i._data[9]=0,i._data[10]=u,i._data[11]=0,i._data[12]=d,i._data[13]=l,i._data[14]=h,i._data[15]=1,i},t.computePerspectiveOffCenter=function(t,e,a,n,r,o,i){var s=2*r/(e-t),c=2*r/(n-a),u=(e+t)/(e-t),d=(n+a)/(n-a),l=-(o+r)/(o-r),h=-2*o*r/(o-r);return i._data[0]=s,i._data[1]=0,i._data[2]=0,i._data[3]=0,i._data[4]=0,i._data[5]=c,i._data[6]=0,i._data[7]=0,i._data[8]=u,i._data[9]=d,i._data[10]=l,i._data[11]=-1,i._data[12]=0,i._data[13]=0,i._data[14]=h,i._data[15]=0,i},t.computeInfinitePerspectiveOffCenter=function(t,e,a,n,r,o){var i=2*r/(e-t),s=2*r/(n-a),c=(e+t)/(e-t),u=(n+a)/(n-a),d=-2*r;return o._data[0]=i,o._data[1]=0,o._data[2]=0,o._data[3]=0,o._data[4]=0,o._data[5]=s,o._data[6]=0,o._data[7]=0,o._data[8]=c,o._data[9]=u,o._data[10]=-1,o._data[11]=-1,o._data[12]=0,o._data[13]=0,o._data[14]=d,o._data[15]=0,o},t.computeViewportTransformation=function(t,e,a,n){var r,o,i,s,c=null!==(r=t.x)&&void 0!==r?r:0,u=null!==(o=t.y)&&void 0!==o?o:0;e=null!=e?e:0;var d=.5*(null!==(i=t.width)&&void 0!==i?i:0),l=.5*(null!==(s=t.height)&&void 0!==s?s:0),h=.5*((a=null!=a?a:1)-e),f=d,p=l,m=h,_=c+d,g=u+l,y=e+h;return n._data[0]=f,n._data[1]=0,n._data[2]=0,n._data[3]=0,n._data[4]=0,n._data[5]=p,n._data[6]=0,n._data[7]=0,n._data[8]=0,n._data[9]=0,n._data[10]=m,n._data[11]=0,n._data[12]=_,n._data[13]=g,n._data[14]=y,n._data[15]=1,n},t.computeView=function(t,e,a,n,r){return r._data[0]=n.x,r._data[1]=a.x,r._data[2]=-e.x,r._data[3]=0,r._data[4]=n.y,r._data[5]=a.y,r._data[6]=-e.y,r._data[7]=0,r._data[8]=n.z,r._data[9]=a.z,r._data[10]=-e.z,r._data[11]=0,r._data[12]=-S.dot(n,t),r._data[13]=-S.dot(a,t),r._data[14]=S.dot(e,t),r._data[15]=1,r},t.toArray=function(t,e){return e[0]=t._data[0],e[1]=t._data[1],e[2]=t._data[2],e[3]=t._data[3],e[4]=t._data[4],e[5]=t._data[5],e[6]=t._data[6],e[7]=t._data[7],e[8]=t._data[8],e[9]=t._data[9],e[10]=t._data[10],e[11]=t._data[11],e[12]=t._data[12],e[13]=t._data[13],e[14]=t._data[14],e[15]=t._data[15],e},t.getElement=function(t,e,a){return t._data[4*e+a]},t.getColumn=function(t,e,a){var n=4*e,r=t._data[n],o=t._data[n+1],i=t._data[n+2],s=t._data[n+3];return a.x=r,a.y=o,a.z=i,a.w=s,a},t.setColumn=function(e,a,n,r){var o=4*a;return(r=t.copyTo(e,r))._data[o]=n.x,r._data[o+1]=n.y,r._data[o+2]=n.z,r._data[o+3]=n.w,r},t.getRow=function(t,e,a){var n=t._data[e],r=t._data[e+4],o=t._data[e+8],i=t._data[e+12];return a.x=n,a.y=r,a.z=o,a.w=i,a},t.setRow=function(e,a,n,r){return(r=t.copyTo(e,r))._data[a]=n.x,r._data[a+4]=n.y,r._data[a+8]=n.z,r._data[a+12]=n.w,r},t.setTranslation=function(t,e,a){return a._data[0]=t._data[0],a._data[1]=t._data[1],a._data[2]=t._data[2],a._data[3]=t._data[3],a._data[4]=t._data[4],a._data[5]=t._data[5],a._data[6]=t._data[6],a._data[7]=t._data[7],a._data[8]=t._data[8],a._data[9]=t._data[9],a._data[10]=t._data[10],a._data[11]=t._data[11],a._data[12]=e.x,a._data[13]=e.y,a._data[14]=e.z,a._data[15]=t._data[15],a},t.scale=function(e,a,n){var r=t.getScale(e,ht),o=a.x/r.x,i=a.y/r.y,s=a.z/r.y;return n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*o,n._data[3]=e._data[3],n._data[4]=e._data[4]*i,n._data[5]=e._data[5]*i,n._data[6]=e._data[6]*i,n._data[7]=e._data[7],n._data[8]=e._data[8]*s,n._data[9]=e._data[9]*s,n._data[10]=e._data[10]*s,n._data[11]=e._data[11],n._data[12]=e._data[12],n._data[13]=e._data[13],n._data[14]=e._data[14],n._data[15]=e._data[15],n},t.setUniformScale=function(e,a,n){var r=t.getScale(e,ft),o=a/r.x,i=a/r.y,s=a/r.z;return n._data[0]=e._data[0]*o,n._data[1]=e._data[1]*o,n._data[2]=e._data[2]*o,n._data[3]=e._data[3],n._data[4]=e._data[4]*i,n._data[5]=e._data[5]*i,n._data[6]=e._data[6]*i,n._data[7]=e._data[7],n._data[8]=e._data[8]*s,n._data[9]=e._data[9]*s,n._data[10]=e._data[10]*s,n._data[11]=e._data[11],n._data[12]=e._data[12],n._data[13]=e._data[13],n._data[14]=e._data[14],n._data[15]=e._data[15],n},t.getScale=function(t,e){return e.x=Math.hypot(t._data[0],t._data[1],t._data[2]),e.y=Math.hypot(t._data[4],t._data[5],t._data[6]),e.z=Math.hypot(t._data[8],t._data[9],t._data[10]),e},t.getMaximumScale=function(e){return t.getScale(e,bt),S.maximumComponent(bt)},t.setRotation=function(e,a,n){var r=t.getScale(e,Tt);return n._data[0]=a._data[0]*r.x,n._data[1]=a._data[1]*r.x,n._data[2]=a._data[2]*r.x,n._data[3]=e._data[3],n._data[4]=a._data[3]*r.y,n._data[5]=a._data[4]*r.y,n._data[6]=a._data[5]*r.y,n._data[7]=e._data[7],n._data[8]=a._data[6]*r.z,n._data[9]=a._data[7]*r.z,n._data[10]=a._data[8]*r.z,n._data[11]=e._data[11],n._data[12]=e._data[12],n._data[13]=e._data[13],n._data[14]=e._data[14],n._data[15]=e._data[15],n},t.getRotation=function(e,a){var n=t.getScale(e,Mt);return a._data[0]=e._data[0]/n.x,a._data[1]=e._data[1]/n.x,a._data[2]=e._data[2]/n.x,a._data[3]=e._data[4]/n.y,a._data[4]=e._data[5]/n.y,a._data[5]=e._data[6]/n.y,a._data[6]=e._data[8]/n.z,a._data[7]=e._data[9]/n.z,a._data[8]=e._data[10]/n.z,a},t.getRotationMatrix3=function(e,a){var n=t.getScale(e,Mt);return a.getData()[0]=e._data[0]/n.x,a.getData()[1]=e._data[1]/n.x,a.getData()[2]=e._data[2]/n.x,a.getData()[3]=e._data[4]/n.y,a.getData()[4]=e._data[5]/n.y,a.getData()[5]=e._data[6]/n.y,a.getData()[6]=e._data[8]/n.z,a.getData()[7]=e._data[9]/n.z,a.getData()[8]=e._data[10]/n.z,a},t.getRotationQuaternion=function(e,a){return t.getRotationMatrix3(e,Et),a=J.fromRotationMatrix(Et,a)},t.multiply=function(t,e,a){var n=t._data,r=e._data,o=n[0],i=n[1],s=n[2],c=n[3],u=n[4],d=n[5],l=n[6],h=n[7],f=n[8],p=n[9],m=n[10],_=n[11],g=n[12],y=n[13],v=n[14],x=n[15],b=r[0],T=r[1],M=r[2],S=r[3],C=r[4],w=r[5],A=r[6],I=r[7],E=r[8],P=r[9],O=r[10],N=r[11],L=r[12],F=r[13],R=r[14],z=r[15],B=o*b+u*T+f*M+g*S,D=i*b+d*T+p*M+y*S,U=s*b+l*T+m*M+v*S,k=c*b+h*T+_*M+x*S,V=o*C+u*w+f*A+g*I,j=i*C+d*w+p*A+y*I,G=s*C+l*w+m*A+v*I,H=c*C+h*w+_*A+x*I,W=o*E+u*P+f*O+g*N,q=i*E+d*P+p*O+y*N,X=s*E+l*P+m*O+v*N,Y=c*E+h*P+_*O+x*N,Z=o*L+u*F+f*R+g*z,J=i*L+d*F+p*R+y*z,Q=s*L+l*F+m*R+v*z,K=c*L+h*F+_*R+x*z;return a._data[0]=B,a._data[1]=D,a._data[2]=U,a._data[3]=k,a._data[4]=V,a._data[5]=j,a._data[6]=G,a._data[7]=H,a._data[8]=W,a._data[9]=q,a._data[10]=X,a._data[11]=Y,a._data[12]=Z,a._data[13]=J,a._data[14]=Q,a._data[15]=K,a},t.mulScalerAddMatrix=function(t,e,a,n){for(var r=t._data,o=e._data,i=n._data,s=0;s<16;s++)i[s]=r[s]+o[s]*a;return n},t.add=function(t,e,a){return a._data[0]=t._data[0]+e._data[0],a._data[1]=t._data[1]+e._data[1],a._data[2]=t._data[2]+e._data[2],a._data[3]=t._data[3]+e._data[3],a._data[4]=t._data[4]+e._data[4],a._data[5]=t._data[5]+e._data[5],a._data[6]=t._data[6]+e._data[6],a._data[7]=t._data[7]+e._data[7],a._data[8]=t._data[8]+e._data[8],a._data[9]=t._data[9]+e._data[9],a._data[10]=t._data[10]+e._data[10],a._data[11]=t._data[11]+e._data[11],a._data[12]=t._data[12]+e._data[12],a._data[13]=t._data[13]+e._data[13],a._data[14]=t._data[14]+e._data[14],a._data[15]=t._data[15]+e._data[15],a},t.subtract=function(t,e,a){return a._data[0]=t._data[0]-e._data[0],a._data[1]=t._data[1]-e._data[1],a._data[2]=t._data[2]-e._data[2],a._data[3]=t._data[3]-e._data[3],a._data[4]=t._data[4]-e._data[4],a._data[5]=t._data[5]-e._data[5],a._data[6]=t._data[6]-e._data[6],a._data[7]=t._data[7]-e._data[7],a._data[8]=t._data[8]-e._data[8],a._data[9]=t._data[9]-e._data[9],a._data[10]=t._data[10]-e._data[10],a._data[11]=t._data[11]-e._data[11],a._data[12]=t._data[12]-e._data[12],a._data[13]=t._data[13]-e._data[13],a._data[14]=t._data[14]-e._data[14],a._data[15]=t._data[15]-e._data[15],a},t.multiplyTransformation=function(t,e,a){var n=t._data,r=t._data,o=n[0],i=n[1],s=n[2],c=n[4],u=n[5],d=n[6],l=n[8],h=n[9],f=n[10],p=n[12],m=n[13],_=n[14],g=r[0],y=r[1],v=r[2],x=r[4],b=r[5],T=r[6],M=r[8],S=r[9],C=r[10],w=r[12],A=r[13],I=r[14],E=o*g+c*y+l*v,P=i*g+u*y+h*v,O=s*g+d*y+f*v,N=o*x+c*b+l*T,L=i*x+u*b+h*T,F=s*x+d*b+f*T,R=o*M+c*S+l*C,z=i*M+u*S+h*C,B=s*M+d*S+f*C,D=o*w+c*A+l*I+p,U=i*w+u*A+h*I+m,k=s*w+d*A+f*I+_;return a._data[0]=E,a._data[1]=P,a._data[2]=O,a._data[3]=0,a._data[4]=N,a._data[5]=L,a._data[6]=F,a._data[7]=0,a._data[8]=R,a._data[9]=z,a._data[10]=B,a._data[11]=0,a._data[12]=D,a._data[13]=U,a._data[14]=k,a._data[15]=1,a},t.multiplyByMatrix3=function(t,e,a){var n=t._data[0],r=t._data[1],o=t._data[2],i=t._data[4],s=t._data[5],c=t._data[6],u=t._data[8],d=t._data[9],l=t._data[10],h=e.getData()[0],f=e.getData()[1],p=e.getData()[2],m=e.getData()[3],_=e.getData()[4],g=e.getData()[5],y=e.getData()[6],v=e.getData()[7],x=e.getData()[8],b=n*h+i*f+u*p,T=r*h+s*f+d*p,M=o*h+c*f+l*p,S=n*m+i*_+u*g,C=r*m+s*_+d*g,w=o*m+c*_+l*g,A=n*y+i*v+u*x,I=r*y+s*v+d*x,E=o*y+c*v+l*x;return a._data[0]=b,a._data[1]=T,a._data[2]=M,a._data[3]=0,a._data[4]=S,a._data[5]=C,a._data[6]=w,a._data[7]=0,a._data[8]=A,a._data[9]=I,a._data[10]=E,a._data[11]=0,a._data[12]=t._data[12],a._data[13]=t._data[13],a._data[14]=t._data[14],a._data[15]=t._data[15],a},t.multiplyByTranslation=function(t,e,a){var n=e.x,r=e.y,o=e.z,i=n*t._data[0]+r*t._data[4]+o*t._data[8]+t._data[12],s=n*t._data[1]+r*t._data[5]+o*t._data[9]+t._data[13],c=n*t._data[2]+r*t._data[6]+o*t._data[10]+t._data[14];return a._data[0]=t._data[0],a._data[1]=t._data[1],a._data[2]=t._data[2],a._data[3]=t._data[3],a._data[4]=t._data[4],a._data[5]=t._data[5],a._data[6]=t._data[6],a._data[7]=t._data[7],a._data[8]=t._data[8],a._data[9]=t._data[9],a._data[10]=t._data[10],a._data[11]=t._data[11],a._data[12]=i,a._data[13]=s,a._data[14]=c,a._data[15]=t._data[15],a},t.multiplyByScale=function(e,a,n){var r=a.x,o=a.y,i=a.z;return 1===r&&1===o&&1===i?t.copyTo(e,n):(void 0===n&&(n=new t),n._data[0]=r*e._data[0],n._data[1]=r*e._data[1],n._data[2]=r*e._data[2],n._data[3]=e._data[3],n._data[4]=o*e._data[4],n._data[5]=o*e._data[5],n._data[6]=o*e._data[6],n._data[7]=e._data[7],n._data[8]=i*e._data[8],n._data[9]=i*e._data[9],n._data[10]=i*e._data[10],n._data[11]=e._data[11],n._data[12]=e._data[12],n._data[13]=e._data[13],n._data[14]=e._data[14],n._data[15]=e._data[15],n)},t.multiplyByUniformScale=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3],a._data[4]=t._data[4]*e,a._data[5]=t._data[5]*e,a._data[6]=t._data[6]*e,a._data[7]=t._data[7],a._data[8]=t._data[8]*e,a._data[9]=t._data[9]*e,a._data[10]=t._data[10]*e,a._data[11]=t._data[11],a._data[12]=t._data[12],a._data[13]=t._data[13],a._data[14]=t._data[14],a._data[15]=t._data[15],a},t.multiplyByVector=function(t,e,a){var n=e.x,r=e.y,o=e.z,i=e.w,s=t._data[0]*n+t._data[4]*r+t._data[8]*o+t._data[12]*i,c=t._data[1]*n+t._data[5]*r+t._data[9]*o+t._data[13]*i,u=t._data[2]*n+t._data[6]*r+t._data[10]*o+t._data[14]*i,d=t._data[3]*n+t._data[7]*r+t._data[11]*o+t._data[15]*i;return a.x=s,a.y=c,a.z=u,a.w=d,a},t.multiplyByPointAsVector=function(t,e,a){var n=e.x,r=e.y,o=e.z,i=t._data[0]*n+t._data[4]*r+t._data[8]*o,s=t._data[1]*n+t._data[5]*r+t._data[9]*o,c=t._data[2]*n+t._data[6]*r+t._data[10]*o;return a.x=i,a.y=s,a.z=c,a},t.multiplyByPoint=function(t,e,a){var n=e.x,r=e.y,o=e.z,i=t._data[0]*n+t._data[4]*r+t._data[8]*o+t._data[12],s=t._data[1]*n+t._data[5]*r+t._data[9]*o+t._data[13],c=t._data[2]*n+t._data[6]*r+t._data[10]*o+t._data[14];return a.x=i,a.y=s,a.z=c,a},t.multiplyByScalar=function(t,e,a){return a._data[0]=t._data[0]*e,a._data[1]=t._data[1]*e,a._data[2]=t._data[2]*e,a._data[3]=t._data[3]*e,a._data[4]=t._data[4]*e,a._data[5]=t._data[5]*e,a._data[6]=t._data[6]*e,a._data[7]=t._data[7]*e,a._data[8]=t._data[8]*e,a._data[9]=t._data[9]*e,a._data[10]=t._data[10]*e,a._data[11]=t._data[11]*e,a._data[12]=t._data[12]*e,a._data[13]=t._data[13]*e,a._data[14]=t._data[14]*e,a._data[15]=t._data[15]*e,a},t.negate=function(t,e){return e._data[0]=-t._data[0],e._data[1]=-t._data[1],e._data[2]=-t._data[2],e._data[3]=-t._data[3],e._data[4]=-t._data[4],e._data[5]=-t._data[5],e._data[6]=-t._data[6],e._data[7]=-t._data[7],e._data[8]=-t._data[8],e._data[9]=-t._data[9],e._data[10]=-t._data[10],e._data[11]=-t._data[11],e._data[12]=-t._data[12],e._data[13]=-t._data[13],e._data[14]=-t._data[14],e._data[15]=-t._data[15],e},t.transpose=function(t,e){var a=t._data[1],n=t._data[2],r=t._data[3],o=t._data[6],i=t._data[7],s=t._data[11];return e._data[0]=t._data[0],e._data[1]=t._data[4],e._data[2]=t._data[8],e._data[3]=t._data[12],e._data[4]=a,e._data[5]=t._data[5],e._data[6]=t._data[9],e._data[7]=t._data[13],e._data[8]=n,e._data[9]=o,e._data[10]=t._data[10],e._data[11]=t._data[14],e._data[12]=r,e._data[13]=i,e._data[14]=s,e._data[15]=t._data[15],e},t.abs=function(t,e){return e._data[0]=Math.abs(t._data[0]),e._data[1]=Math.abs(t._data[1]),e._data[2]=Math.abs(t._data[2]),e._data[3]=Math.abs(t._data[3]),e._data[4]=Math.abs(t._data[4]),e._data[5]=Math.abs(t._data[5]),e._data[6]=Math.abs(t._data[6]),e._data[7]=Math.abs(t._data[7]),e._data[8]=Math.abs(t._data[8]),e._data[9]=Math.abs(t._data[9]),e._data[10]=Math.abs(t._data[10]),e._data[11]=Math.abs(t._data[11]),e._data[12]=Math.abs(t._data[12]),e._data[13]=Math.abs(t._data[13]),e._data[14]=Math.abs(t._data[14]),e._data[15]=Math.abs(t._data[15]),e},t.equals=function(t,e){return t===e||t._data[12]===e._data[12]&&t._data[13]===e._data[13]&&t._data[14]===e._data[14]&&t._data[0]===e._data[0]&&t._data[1]===e._data[1]&&t._data[2]===e._data[2]&&t._data[4]===e._data[4]&&t._data[5]===e._data[5]&&t._data[6]===e._data[6]&&t._data[8]===e._data[8]&&t._data[9]===e._data[9]&&t._data[10]===e._data[10]&&t._data[3]===e._data[3]&&t._data[7]===e._data[7]&&t._data[11]===e._data[11]&&t._data[15]===e._data[15]},t.equalsEpsilon=function(t,e,a){return t===e||Math.abs(t._data[0]-e._data[0])<=a&&Math.abs(t._data[1]-e._data[1])<=a&&Math.abs(t._data[2]-e._data[2])<=a&&Math.abs(t._data[3]-e._data[3])<=a&&Math.abs(t._data[4]-e._data[4])<=a&&Math.abs(t._data[5]-e._data[5])<=a&&Math.abs(t._data[6]-e._data[6])<=a&&Math.abs(t._data[7]-e._data[7])<=a&&Math.abs(t._data[8]-e._data[8])<=a&&Math.abs(t._data[9]-e._data[9])<=a&&Math.abs(t._data[10]-e._data[10])<=a&&Math.abs(t._data[11]-e._data[11])<=a&&Math.abs(t._data[12]-e._data[12])<=a&&Math.abs(t._data[13]-e._data[13])<=a&&Math.abs(t._data[14]-e._data[14])<=a&&Math.abs(t._data[15]-e._data[15])<=a},t.getTranslation=function(t,e){return e.x=t._data[12],e.y=t._data[13],e.z=t._data[14],e},t.getMatrix3=function(t,e){return e.getData()[0]=t._data[0],e.getData()[1]=t._data[1],e.getData()[2]=t._data[2],e.getData()[3]=t._data[4],e.getData()[4]=t._data[5],e.getData()[5]=t._data[6],e.getData()[6]=t._data[8],e.getData()[7]=t._data[9],e.getData()[8]=t._data[10],e},t.inverse=function(e,a){var n=e._data[0],r=e._data[4],o=e._data[8],i=e._data[12],s=e._data[1],c=e._data[5],u=e._data[9],d=e._data[13],l=e._data[2],h=e._data[6],f=e._data[10],p=e._data[14],m=e._data[3],_=e._data[7],y=e._data[11],v=e._data[15],x=f*v,b=p*y,T=h*v,M=p*_,S=h*y,C=f*_,w=l*v,A=p*m,I=l*y,E=f*m,O=l*_,N=h*m,L=x*c+M*u+S*d-(b*c+T*u+C*d),F=b*s+w*u+E*d-(x*s+A*u+I*d),R=T*s+A*c+O*d-(M*s+w*c+N*d),z=C*s+I*c+N*u-(S*s+E*c+O*u),B=b*r+T*o+C*i-(x*r+M*o+S*i),D=x*n+A*o+I*i-(b*n+w*o+E*i),U=M*n+w*r+N*i-(T*n+A*r+O*i),k=S*n+E*r+O*o-(C*n+I*r+N*o),j=(x=o*d)*_+(M=i*c)*y+(S=r*u)*v-((b=i*u)*_+(T=r*d)*y+(C=o*c)*v),G=b*m+(w=n*d)*y+(E=o*s)*v-(x*m+(A=i*s)*y+(I=n*u)*v),H=T*m+A*_+(O=n*c)*v-(M*m+w*_+(N=r*s)*v),W=C*m+I*_+N*y-(S*m+E*_+O*y),q=T*f+C*p+b*h-(S*p+x*h+M*f),X=I*p+x*l+A*f-(w*f+E*p+b*l),Y=w*h+N*p+M*l-(O*p+T*l+A*h),Z=O*f+S*l+E*h-(I*h+N*f+C*l),J=n*L+r*F+o*R+i*z;if(Math.abs(J)<g.EPSILON21){if(V.equalsEpsilon(t.getMatrix3(e,St),Ct,g.EPSILON7)&&P.equals(t.getRow(e,3,wt),At))return a._data[0]=0,a._data[1]=0,a._data[2]=0,a._data[3]=0,a._data[4]=0,a._data[5]=0,a._data[6]=0,a._data[7]=0,a._data[8]=0,a._data[9]=0,a._data[10]=0,a._data[11]=0,a._data[12]=-e._data[12],a._data[13]=-e._data[13],a._data[14]=-e._data[14],a._data[15]=1,a;throw"matrix is not invertible because its determinate is zero"}return J=1/J,a._data[0]=L*J,a._data[1]=F*J,a._data[2]=R*J,a._data[3]=z*J,a._data[4]=B*J,a._data[5]=D*J,a._data[6]=U*J,a._data[7]=k*J,a._data[8]=j*J,a._data[9]=G*J,a._data[10]=H*J,a._data[11]=W*J,a._data[12]=q*J,a._data[13]=X*J,a._data[14]=Y*J,a._data[15]=Z*J,a},t.inverseTransformation=function(t,e){var a=t._data[0],n=t._data[1],r=t._data[2],o=t._data[4],i=t._data[5],s=t._data[6],c=t._data[8],u=t._data[9],d=t._data[10],l=t._data[12],h=t._data[13],f=t._data[14],p=-a*l-n*h-r*f,m=-o*l-i*h-s*f,_=-c*l-u*h-d*f;return e._data[0]=a,e._data[1]=o,e._data[2]=c,e._data[3]=0,e._data[4]=n,e._data[5]=i,e._data[6]=u,e._data[7]=0,e._data[8]=r,e._data[9]=s,e._data[10]=d,e._data[11]=0,e._data[12]=p,e._data[13]=m,e._data[14]=_,e._data[15]=1,e},t.inverseTranspose=function(e,a){return t.inverse(t.transpose(e,It),a)},t.equalsArray=function(t,e,a){return a=null!=a?a:0,t._data[0]===e[a]&&t._data[1]===e[a+1]&&t._data[2]===e[a+2]&&t._data[3]===e[a+3]&&t._data[4]===e[a+4]&&t._data[5]===e[a+5]&&t._data[6]===e[a+6]&&t._data[7]===e[a+7]&&t._data[8]===e[a+8]&&t._data[9]===e[a+9]&&t._data[10]===e[a+10]&&t._data[11]===e[a+11]&&t._data[12]===e[a+12]&&t._data[13]===e[a+13]&&t._data[14]===e[a+14]&&t._data[15]===e[a+15]},t.prototype.determinant=function(){var t=this._data,e=t[0],a=t[4],n=t[8],r=t[12],o=t[1],i=t[5],s=t[9],c=t[13],u=t[2],d=t[6],l=t[10],h=t[14];return t[3]*(+r*s*d-n*c*d-r*i*l+a*c*l+n*i*h-a*s*h)+t[7]*(+e*s*h-e*c*l+r*o*l-n*o*h+n*c*u-r*s*u)+t[11]*(+e*c*d-e*i*h-r*o*d+a*o*h+r*i*u-a*c*u)+t[15]*(-n*i*u-e*s*d+e*i*l+n*o*d-a*o*l+a*s*u)},t.decompose=function(e){var a=t.getTranslation(e,new S),n=t.getScale(e,new S);e.determinant()<0&&(n.x=-n.x),t.copyTo(e,Pt);var r=1/n.x,o=1/n.y,i=1/n.z;return Pt._data[0]*=r,Pt._data[1]*=r,Pt._data[2]*=r,Pt._data[4]*=o,Pt._data[5]*=o,Pt._data[6]*=o,Pt._data[8]*=i,Pt._data[9]*=i,Pt._data[10]*=i,{translation:a,rotation:t.getRotationQuaternion(Pt,new J),scale:n}},t.compose=function(e,a,n,r){return r=t.fromTranslationQuaternionRotationScale(e,a,n,r)},t.computePerspective=function(e,a,n,r,o,i){return i=t.computePerspectiveFieldOfView(e,a,n,r,o,i)},t.computeOrthographic=function(e,a,n,r,o,i,s){return s=t.computeOrthographicOffCenter(e,a,n,r,o,i,s)},t.computeLookAt=function(e,a,n,r){var o=S.subtract(a,e,new S);return r=t.fromCamera({position:e,direction:o,up:n},r)},t.prototype.clone=function(){return t.clone(this)},t.prototype.copyTo=function(e){return e=t.copyTo(this,e)},t.prototype.copyFrom=function(e){return t.copyTo(e,this),this},t.prototype.translate=function(e){return t.multiplyByTranslation(this,e,this)},t.prototype.scale=function(e){return t.scale(this,e,this)},t.prototype.multiply=function(e){return t.multiply(this,e,this)},t.prototype.toArray=function(){var e=new Array(16);return t.toArray(this,e)},t.prototype.toFloat32Array=function(){return t.pack(this,new Float32Array(16),0)},t.prototype.multiplyByVector4=function(e){return t.multiplyByVector(this,e,new P)},t.prototype.multiplyByVector3=function(e){return t.multiplyByPoint(this,e,new S)},t.prototype.at=function(t){return this._data[t]},t.prototype.rotate=function(t,e){var a=e.x,n=e.y,r=e.z,o=Math.sqrt(a*a+n*n+r*r);if(o){1!==o&&(a*=o=1/o,n*=o,r*=o);var i=Math.sin(t),s=Math.cos(t),c=1-s,u=this._data[0],d=this._data[1],l=this._data[2],h=this._data[3],f=this._data[4],p=this._data[5],m=this._data[6],_=this._data[7],g=this._data[8],y=this._data[9],v=this._data[10],x=this._data[11],b=a*a*c+s,T=n*a*c+r*i,M=r*a*c-n*i,S=a*n*c-r*i,C=n*n*c+s,w=r*n*c+a*i,A=a*r*c+n*i,I=n*r*c-a*i,E=r*r*c+s;return this._data[0]=u*b+f*T+g*M,this._data[1]=d*b+p*T+y*M,this._data[2]=l*b+m*T+v*M,this._data[3]=h*b+_*T+x*M,this._data[4]=u*S+f*C+g*w,this._data[5]=d*S+p*C+y*w,this._data[6]=l*S+m*C+v*w,this._data[7]=h*S+_*C+x*w,this._data[8]=u*A+f*I+g*E,this._data[9]=d*A+p*I+y*E,this._data[10]=l*A+m*I+v*E,this._data[11]=h*A+_*I+x*E,this}},t.prototype.inverse=function(){return t.inverse(this,this)},t.prototype.transpose=function(){return t.transpose(this,this)},t.IDENTITY=Object.freeze(new t(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)),t.ZERO=Object.freeze(new t(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)),t}(),ut=new S,dt=new S,lt=new S,ht=new S,ft=new S;new S;var pt,mt,_t,gt,yt,vt,xt,bt=new S,Tt=new S,Mt=new S,St=new V,Ct=new V,wt=new P,At=new P(0,0,0,1),It=new ct,Et=new V,Pt=new ct,Ot=function(){function t(t,e){void 0===t&&(t=new S(1/0,1/0,1/0)),void 0===e&&(e=new S(-1/0,-1/0,-1/0)),this.min=t,this.max=e}return t.prototype.set=function(t,e){return this.min.copyFrom(t),this.max.copyFrom(e),this},t.prototype.setFromArray=function(t){for(var e=Number(1/0),a=Number(1/0),n=Number(1/0),r=-1/0,o=-1/0,i=-1/0,s=0,c=t.length;s<c;s+=3){var u=t[s],d=t[s+1],l=t[s+2];u<e&&(e=u),d<a&&(a=d),l<n&&(n=l),u>r&&(r=u),d>o&&(o=d),l>i&&(i=l)}return this.min.set(e,a,n),this.max.set(r,o,i),this},t.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,a=t.length;e<a;e++)this.expandByPoint(t[e]);return this},t.prototype.setFromCenterAndSize=function(t,e){var a=e.clone().multiplyScalar(.5);return this.min.copyFrom(t).subVector(a),this.max.copyFrom(t).subVector(a),this},t.prototype.clone=function(){return(new t).copyFrom(this)},t.prototype.copyFrom=function(t){return this.min.copyFrom(t.min),this.max.copyFrom(t.max),this},t.prototype.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=Number(1/0),this.max.x=this.max.y=this.max.z=-1/0,this},t.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},t.prototype.getCenter=function(t){return this.isEmpty()?t.set(0,0,0):S.add(this.min,this.max,t).multiplyScalar(.5),t},t.prototype.getSize=function(t){return this.isEmpty()?t.set(0,0,0):S.subtract(this.max,this.min,t),t},t.prototype.expandByPoint=function(t){return S.min(this.min,t,this.min),S.max(this.max,t,this.max),this},t.prototype.expandByVector=function(t){return this.min.subVector(t),this.max.addVector(t),this},t.prototype.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},t.prototype.expandByBox=function(t){return S.min(this.min,t.min,this.min),S.max(this.max,t.max,this.max),this},t.prototype.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},t.prototype.containsBox=function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},t.prototype.intersectsBox=function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},t.prototype.intersectsSphere=function(t){var e=new S;return this.clampPoint(t.center,e),e.distanceSquaredTo(t.center)<=t.radius*t.radius},t.prototype.clampPoint=function(t,e){return e.copyFrom(t).clamp(this.min,this.max)},t.prototype.distanceToPoint=function(t){return t.clone().clamp(this.min,this.max).subVector(t).length()},t.prototype.getBoundingSphere=function(t){this.getCenter(t.center);var e=new S;return t.radius=.5*this.getSize(e).length(),t},t.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},t.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},t.prototype.transform=function(t){if(this.isEmpty())return this;var e=[];return e[0]=new S(this.min.x,this.min.y,this.min.z),e[1]=new S(this.min.x,this.min.y,this.max.z),e[2]=new S(this.min.x,this.max.y,this.min.z),e[3]=new S(this.min.x,this.max.y,this.max.z),e[4]=new S(this.max.x,this.min.y,this.min.z),e[5]=new S(this.max.x,this.min.y,this.max.z),e[6]=new S(this.max.x,this.max.y,this.min.z),e[7]=new S(this.max.x,this.max.y,this.max.z),e.forEach((function(e){return ct.multiplyByPoint(t,e,e)})),this.setFromPoints(e),this},t.prototype.translate=function(t){return this.min.addVector(t),this.max.addVector(t),this},t.prototype.equals=function(t){return S.equals(t.min,this.min)&&S.equals(t.max,this.max)},t}(),Nt=function(){function t(t,e){void 0===t&&(t=new S),void 0===e&&(e=-1),this.center=t,this.radius=e}return t.prototype.set=function(t,e){return this.center.copyFrom(t),this.radius=e,this},t.prototype.setFromPoints=function(t,e){var a=this.center;void 0!==e?a.copyFrom(e):(new Ot).setFromPoints(t).getCenter(a);for(var n=0,r=0,o=t.length;r<o;r++)n=Math.max(n,a.distanceSquaredTo(t[r]));return this.radius=Math.sqrt(n),this},t.prototype.copyFrom=function(t){return this.center.copyFrom(t.center),this.radius=t.radius,this},t.prototype.isEmpty=function(){return this.radius<0},t.prototype.makeEmpty=function(){return this.center.set(0,0,0),this.radius=-1,this},t.prototype.containsPoint=function(t){return t.distanceSquaredTo(this.center)<=this.radius*this.radius},t.prototype.distanceToPoint=function(t){return t.distanceTo(this.center)-this.radius},t.prototype.intersectsSphere=function(t){var e=this.radius+t.radius;return t.center.distanceSquaredTo(this.center)<=e*e},t.prototype.intersectsBox=function(t){return t.intersectsSphere(this)},t.prototype.clampPoint=function(t,e){var a=this.center.distanceSquaredTo(t);return e.copyFrom(t),a>this.radius*this.radius&&(e.subVector(this.center).normalize(),e.multiplyScalar(this.radius).addVector(this.center)),e},t.prototype.getBoundingBox=function(t){return void 0===t&&(t=new Ot),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)},t.prototype.translate=function(t){return this.center.addVector(t),this},t.prototype.expandByPoint=function(t){var e=t.clone().subVector(this.center),a=e.lengthSquared();if(a>this.radius*this.radius){var n=Math.sqrt(a),r=.5*(n-this.radius);this.center.addVector(e.multiplyScalar(r/n)),this.radius+=r}return this},t.prototype.union=function(t){var e=new S,a=t.center.clone().subVector(this.center);return a.normalize().multiplyScalar(t.radius),this.expandByPoint(e.copyFrom(t.center).addVector(a)),this.expandByPoint(e.copyFrom(t.center).subVector(a)),this},t.prototype.equals=function(t){return S.equals(t.center,this.center)&&t.radius===this.radius},t.prototype.clone=function(){return(new t).copyFrom(this)},t}();t.PObjectType=void 0,(pt=t.PObjectType||(t.PObjectType={}))[pt.none=0]="none",pt[pt.mesh=1]="mesh",pt[pt.texture=2]="texture",pt[pt.material=3]="material",pt[pt.light=4]="light",pt[pt.camera=5]="camera",pt[pt.skybox=6]="skybox",pt[pt.skin=7]="skin",pt[pt.morph=8]="morph",pt[pt.skeleton=9]="skeleton",pt[pt.animation=10]="animation",pt[pt.animationManager=11]="animationManager",pt[pt.reference=12]="reference",t.PLightType=void 0,(mt=t.PLightType||(t.PLightType={}))[mt.directional=0]="directional",mt[mt.point=1]="point",mt[mt.spot=2]="spot",mt[mt.ambient=3]="ambient",t.PTextureType=void 0,(_t=t.PTextureType||(t.PTextureType={}))[_t.none=0]="none",_t[_t.t2d=1]="t2d",_t[_t.t3d=2]="t3d",_t[_t.cube=3]="cube",t.PMaterialType=void 0,(gt=t.PMaterialType||(t.PMaterialType={}))[gt.none=0]="none",gt[gt.unlit=1]="unlit",gt[gt.pbr=2]="pbr",gt[gt.normalVis=3]="normalVis",gt[gt.simpleFilter=4]="simpleFilter",gt[gt.shadowBase=5]="shadowBase",gt[gt.shadowFilter=6]="shadowFilter",gt[gt.skyboxFilter=7]="skyboxFilter",t.PBlendMode=void 0,(yt=t.PBlendMode||(t.PBlendMode={}))[yt.opaque=0]="opaque",yt[yt.masked=1]="masked",yt[yt.translucent=2]="translucent",yt[yt.additive=3]="additive",t.PFaceSideMode=void 0,(vt=t.PFaceSideMode||(t.PFaceSideMode={}))[vt.both=0]="both",vt[vt.front=1]="front",vt[vt.back=2]="back",t.PShadowType=void 0,(xt=t.PShadowType||(t.PShadowType={}))[xt.none=0]="none",xt[xt.standard=1]="standard",xt[xt.variance=2]="variance",xt[xt.expVariance=3]="expVariance";var Lt=function(){function a(){this.translation=new S(0,0,0),this.rotation=new J(0,0,0,1),this.scale=new S(1,1,1)}return a.prototype.fromMatrix4=function(t){return this.setMatrix(t),this},a.prototype.fromEffectsTransform=function(t){if(t instanceof e.Transform)this.setMatrix(t.getWorldMatrix());else{var a=new e.Transform(o(o({},t),{valid:!0}));a.setValid(!0),this.setMatrix(a.getWorldMatrix())}return this},a.prototype.toEffectsTransform=function(t){var e=this.getMatrix();return t.cloneFromMatrix(e.toArray()),t},a.prototype.fromBaseTransform=function(t){return t.position?this.setTranslation(t.position):this.translation.set(0,0,0),t.rotation?this.setRotation(t.rotation):this.rotation.set(0,0,0,1),t.scale?this.setScale(t.scale):this.scale.set(1,1,1),this},a.prototype.getTranslation=function(){return this.translation},a.prototype.setTranslation=function(t){t instanceof S?this.translation.set(t.x,t.y,t.z):this.translation.set(t[0],t[1],t[2])},a.prototype.getPosition=function(){return this.translation},a.prototype.setPosition=function(t){t instanceof S?this.translation.set(t.x,t.y,t.z):this.translation.set(t[0],t[1],t[2])},a.prototype.getRotation=function(){return this.rotation},a.prototype.setRotation=function(e){e instanceof J?this.rotation.set(e.x,e.y,e.z,e.w):e instanceof Z?this.rotation.setFromEuler(e):e instanceof S?this.rotation.setFromEuler(new Z(e.x,e.y,e.z,t.EulerOrder.ZYX)):4===e.length?this.rotation.set(e[0],e[1],e[2],e[3]):this.rotation.setFromEuler(new Z(e[0],e[1],e[2],t.EulerOrder.ZYX))},a.prototype.getScale=function(){return this.scale},a.prototype.setScale=function(t){t instanceof S?this.scale.set(t.x,t.y,t.z):this.scale.set(t[0],t[1],t[2])},a.prototype.getMatrix=function(){return(new ct).compose(this.getTranslation(),this.getRotation(),this.getScale())},a.prototype.setMatrix=function(t){if(t instanceof ct){var e=t.decompose();this.setTranslation(e.translation),this.setRotation(e.rotation),this.setScale(e.scale)}else{e=ct.fromArray(t).decompose();this.setTranslation(e.translation),this.setRotation(e.rotation),this.setScale(e.scale)}},a}(),Ft=function(){function t(){this.origin=new S(0,0,0),this.xAxis=new S(1,0,0),this.yAxis=new S(0,1,0),this.zAxis=new S(0,0,1)}return t.prototype.fromPTransform=function(t,e){void 0===e&&(e=!1),this.origin.copyFrom(t.getPosition());var a=t.getRotation().toMatrix4(new ct);return e&&a.inverse(),this.fromRotationMatrix(a),this},t.prototype.fromRotationMatrix=function(t){var e=t.data;this.xAxis.set(e[0],e[1],e[2]),this.yAxis.set(e[4],e[5],e[6]),this.zAxis.set(e[8],e[9],e[10])},t}(),Rt=function(){function t(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=e.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16}return t.getInstance=function(){return this.instance||(this.instance=new this)},t.prototype.reset=function(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=e.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16},t.prototype.hasRenderMode3D=function(){return this.renderMode3D!==e.spec.RenderMode3D.none},Object.defineProperty(t.prototype,"isEditorEnv",{get:function(){return this.runtimeEnv===e.PLAYER_OPTIONS_ENV_EDITOR},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDeviceEnv",{get:function(){return!this.isEditorEnv},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isTiny3dMode",{get:function(){return"tiny3d"===this.compatibleMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isOasisMode",{get:function(){return"oasis"===this.compatibleMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isGLTFMode",{get:function(){return!this.isTiny3dMode&&!this.isOasisMode},enumerable:!1,configurable:!0}),t}(),zt=1,Bt=function(){function e(){this.name="Unnamed Object",this.type=t.PObjectType.none}return e.prototype.dispose=function(){},e.prototype.isNone=function(){return this.type===t.PObjectType.none},e.prototype.isValid=function(){return this.type!==t.PObjectType.none},e.prototype.genName=function(t){return"".concat(t,"_@").concat(zt++)},e}(),Dt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._visible=!1,e._transform=new Lt,e.deleted=!1,e}return r(e,t),e.prototype.tick=function(t){},e.prototype.onVisibleChanged=function(t){this.visible=t},e.prototype.addToRenderObjectSet=function(t){},e.prototype.updateUniformsForScene=function(t){},e.prototype.onEntityRemoved=function(){this.visible=!1,this.deleted=!0},Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible&&this.isValid()},set:function(t){this._visible=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transform",{get:function(){return this._transform},set:function(t){t instanceof Lt?this._transform=t:(void 0!==t.position&&this._transform.setTranslation(t.position),void 0!==t.rotation&&this._transform.setRotation(t.rotation),void 0!==t.scale&&this._transform.setScale(t.scale))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"translation",{get:function(){return this._transform.getTranslation()},set:function(t){this._transform.setTranslation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._transform.getTranslation()},set:function(t){this._transform.setTranslation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this._transform.getRotation()},set:function(t){this._transform.setRotation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this._transform.getScale()},set:function(t){this._transform.setScale(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"matrix",{get:function(){return this._transform.getMatrix()},set:function(t){this._transform.setMatrix(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coordinate",{get:function(){var t=new Ft;return t.fromPTransform(this._transform),t},enumerable:!1,configurable:!0}),e}(Bt);var Ut={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,f32:Float32Array,i32:Int32Array,u32:Uint32Array};function kt(t,a){if(2!=a.length||a[0]!==e.spec.ValueType.BINARY||!(a[1]instanceof Array))return a;var n=c(a[1],4),r=n[0],o=n[1],i=n[2],s=n[3];if(!s)return t[r].slice(o,i);var u=Ut[s]||Uint8Array;return new u(t[r],o,i/u.BYTES_PER_ELEMENT)}function Vt(t,a,n){var r=ct.fromArray(a),o=ct.inverse(r,new ct),i=new P(t.center[0],t.center[1],t.center[2],1),s=new S(t.direction[0],t.direction[1],t.direction[2]),c=ct.multiplyByVector(o,i,new P),u=function(t,e){var a=e.x,n=e.y,r=e.z,o=new S;return o.x=t.data[0]*a+t.data[4]*n+t.data[8]*r,o.y=t.data[1]*a+t.data[5]*n+t.data[9]*r,o.z=t.data[2]*a+t.data[6]*n+t.data[10]*r,o.normalize()}(o,s),d=e.intersectRayBox([],[c.x,c.y,c.z],[u.x,u.y,u.z],n.center,n.size);if(null!==d){var l=ct.multiplyByVector(r,new P(d[0],d[1],d[2],1),new P);return[[l.x,l.y,l.z]]}}function jt(t,e,a,n){var r=0,o=0,i=0,s=0,c=0,u=0,d=1/e.x,l=1/e.y,h=1/e.z;if(d>=0?(r=(a.x-t.x)*d,o=(n.x-t.x)*d):(r=(n.x-t.x)*d,o=(a.x-t.x)*d),l>=0?(i=(a.y-t.y)*l,s=(n.y-t.y)*l):(i=(n.y-t.y)*l,s=(a.y-t.y)*l),!(r>s||i>o||((i>r||r!=r)&&(r=i),(s<o||o!=o)&&(o=s),h>=0?(c=(a.z-t.z)*h,u=(n.z-t.z)*h):(c=(n.z-t.z)*h,u=(a.z-t.z)*h),r>u||c>o||((c>r||r!=r)&&(r=c),(u<o||o!=o)&&(o=u),o<0))))return r>=0?r:o}var Gt=new S,Ht=new S,Wt=new S,qt=new S;function Xt(t,e,a,n,r,o){S.subtract(n,a,Ht),S.subtract(r,a,Wt),S.cross(Ht,Wt,qt);var i=e.dot(qt),s=0;if(i>0){if(o)return;s=1}else{if(!(i<0))return;s=-1,i=-i}S.subtract(t,a,Gt),S.cross(Gt,Wt,Wt);var c=s*e.dot(Wt);if(!(c<0)){S.cross(Ht,Gt,Ht);var u=s*e.dot(Ht);if(!(u<0||c+u>i)){var d=-s*Gt.dot(qt);if(!(d<0))return d/i}}}var Yt,Zt,Jt,Qt=function(){function t(){}return t.createTexture2D=function(a,n,r,o,c){return i(this,void 0,void 0,(function(){var i,u,d,l;return s(this,(function(s){return void 0===n.imageData?(console.error("createTexture2D: Invalid image data from ".concat(n)),[2,e.Texture.create(a,{name:"createTexture2D",sourceType:e.TextureSourceType.data,data:{data:new Uint8Array([255,255,255,255]),width:1,height:1}})]):(i=new Blob([n.imageData],{type:n.mimeType}),u=window.URL||window.webkitURL,d=u.createObjectURL(i),(l=new Image).src=d,[2,new Promise((function(n,i){l.onload=function(){var i,s,h,f,p=null!==(i=r.minFilter)&&void 0!==i?i:e.glContext.LINEAR_MIPMAP_LINEAR,m=!1;c&&(p=e.glContext.LINEAR_MIPMAP_LINEAR,t.isPow2(l.width)&&t.isPow2(l.height)||(p=e.glContext.LINEAR),m=!o);var _=!1;p!=e.glContext.NEAREST_MIPMAP_NEAREST&&p!=e.glContext.LINEAR_MIPMAP_NEAREST&&p!=e.glContext.NEAREST_MIPMAP_LINEAR&&p!=e.glContext.LINEAR_MIPMAP_LINEAR||(_=!0);var g=e.Texture.create(a,{name:"createTexture2D",wrapS:null!==(s=r.wrapS)&&void 0!==s?s:e.glContext.REPEAT,wrapT:null!==(h=r.wrapT)&&void 0!==h?h:e.glContext.REPEAT,magFilter:null!==(f=r.magFilter)&&void 0!==f?f:e.glContext.LINEAR,minFilter:p,anisotropic:1,premultiplyAlpha:m,sourceType:e.TextureSourceType.image,image:l,generateMipmap:_});n(g),u.revokeObjectURL(d)},l.onerror=i}))])}))}))},t.createTextureList=function(t,e,a){return i(this,void 0,void 0,(function(){var n=this;return s(this,(function(r){switch(r.label){case 0:return[4,Promise.all(a.map((function(a){return n.createTexture2D(t,e[a.source],a)})))];case 1:return[2,r.sent()]}}))}))},t.getTextureCubeData=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return[4,te.loadImageFromImageData(t[0])];case 1:return e=[a.sent()],[4,te.loadImageFromImageData(t[1])];case 2:return e=e.concat([a.sent()]),[4,te.loadImageFromImageData(t[2])];case 3:return e=e.concat([a.sent()]),[4,te.loadImageFromImageData(t[3])];case 4:return e=e.concat([a.sent()]),[4,te.loadImageFromImageData(t[4])];case 5:return e=e.concat([a.sent()]),[4,te.loadImageFromImageData(t[5])];case 6:return[2,e.concat([a.sent()])]}}))}))},t.getTextureCubeMipmapData=function(t){return i(this,void 0,void 0,(function(){var e,a,n,r;return s(this,(function(o){switch(o.label){case 0:e=[],a=0,o.label=1;case 1:return a<t.length?(r=(n=e).push,[4,this.getTextureCubeData(t[a])]):[3,4];case 2:r.apply(n,[o.sent()]),o.label=3;case 3:return a++,[3,1];case 4:return[2,e]}}))}))},t.createTextureCubeFromURL=function(t,a){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return[4,e.getDefaultTextureFactory().loadSource({type:e.TextureSourceType.image,target:e.glContext.TEXTURE_CUBE_MAP,map:a},this.cubemapTexConfig)];case 1:return n=r.sent(),[2,e.Texture.create(t,n)]}}))}))},t.createTextureCubeMipmapFromURL=function(t,a){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return[4,e.getDefaultTextureFactory().loadSource({type:e.TextureSourceType.mipmaps,target:e.glContext.TEXTURE_CUBE_MAP,maps:a},this.cubemapMipTexConfig)];case 1:return n=r.sent(),[2,e.Texture.create(t,n)]}}))}))},t.createTextureCubeFromBuffer=function(a,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return[4,t.getTextureCubeData(n)];case 1:return r=i.sent(),[2,e.Texture.create(a,o({name:"createTextureCubeFromBuffer",sourceType:e.TextureSourceType.image,cube:r,target:e.glContext.TEXTURE_CUBE_MAP},this.cubemapTexConfig))]}}))}))},t.createTextureCubeMipmapFromBuffer=function(a,n,r){return i(this,void 0,void 0,(function(){var i,c,u,d,l;return s(this,(function(s){switch(s.label){case 0:return[4,t.getTextureCubeMipmapData(n)];case 1:for(i=s.sent(),c=0;Math.pow(2,c)<r;)++c;s.label=2;case 2:return i.length<=c?(u=Math.pow(2,c-i.length),d="https://gw.alipayobjects.com/zos/gltf-asset/67896749597915/img".concat(u,".png"),[4,e.loadImage(d)]):[3,4];case 3:return l=s.sent(),i.push([l,l,l,l,l,l]),[3,2];case 4:return[2,e.Texture.create(a,o({name:"createTextureCubeMipmapFromBuffer",sourceType:e.TextureSourceType.mipmaps,mipmaps:i,target:e.glContext.TEXTURE_CUBE_MAP},this.cubemapMipTexConfig))]}}))}))},t.getTexture=function(t,e){return t<0||t>=e.length?void 0:e[t]},t.createTextureFromImage=function(t,a){var n={name:"createTextureFromImage",image:a,sourceType:e.TextureSourceType.image,flipY:!1,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR,wrapT:e.glContext.REPEAT,wrapS:e.glContext.REPEAT};return e.Texture.create(t,n)},t.createRenderPass=function(t,a,n,r,o){var i=r instanceof e.Mesh?[r]:r;return new e.RenderPass(t,{name:a,priority:n,attachments:o.colorAttachments,depthStencilAttachment:o.depthAttachment,clearAction:{clearDepth:1,clearStencil:0,clearColor:[0,0,0,0],colorAction:e.TextureLoadAction.clear,depthAction:e.TextureLoadAction.clear},meshes:i,viewport:o.viewport})},t.deleteTexture=function(t){t.dispose()},t.deleteMesh=function(t){t.dispose({geometries:e.DestroyOptions.destroy,material:{textures:e.DestroyOptions.destroy}})},t.deleteGeometry=function(t){t.dispose()},t.deleteRenderPass=function(t){t.dispose({meshes:{geometries:e.DestroyOptions.destroy,material:{textures:e.DestroyOptions.destroy}},depthStencilAttachment:e.RenderPassDestroyAttachmentType.force,colorAttachment:e.RenderPassDestroyAttachmentType.force,semantics:e.DestroyOptions.destroy})},t.isTransparentMesh=function(t){return!0===t.material.blending},t.isSupportFloatTexture=function(t){return 0!==t.gpuCapability.detail.floatTexture},t.isSupportHalfFloatTexture=function(t){return 0!==t.gpuCapability.detail.halfFloatTexture},t.isPow2=function(t){return!(t&t-1||!t)},t.cubemapTexConfig={name:"cubemap texture",wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR},t.cubemapMipTexConfig={wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR_MIPMAP_LINEAR},t}(),Kt=function(){function t(){}return t.createFilterMesh=function(a,n,r,o){var i=Rt.getInstance(),s=r.vertexShaderCode,c=r.fragmentShaderCode,u=e.Geometry.create(a,t.getPlaneGeometry()),d=e.Material.create(a,{shader:{vertex:s,fragment:c,shared:i.shaderShared},uniformSemantics:o});return r.setMaterialStates(d),e.Mesh.create(a,{name:n,worldMatrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],material:d,geometry:u})},t.getPlaneGeometry=function(){var a=t.getPlaneVertexArray();return{attributes:{a_Position:{type:e.glContext.FLOAT,size:3,data:a,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:0},a_UV1:{type:e.glContext.FLOAT,size:2,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:3*Float32Array.BYTES_PER_ELEMENT,dataSource:"a_Position"},a_Normal:{type:e.glContext.FLOAT,size:3,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:5*Float32Array.BYTES_PER_ELEMENT,dataSource:"a_Position"}},drawStart:0,drawCount:a.length/8}},t.getPlaneVertexArray=function(){return new Float32Array([-1,-1,0,0,0,0,0,1,1,-1,0,1,0,0,0,1,1,1,0,1,1,0,0,1,-1,-1,0,0,0,0,0,1,1,1,0,1,1,0,0,1,-1,1,0,0,1,0,0,1])},t}(),$t=function(){function t(){}return t.createLightOptions=function(t){var e,a,n,r,o,i,s,c,u=null!==(e=t.color)&&void 0!==e?e:[255,255,255,255];return"point"===t.type?{color:u,intensity:null!==(a=t.intensity)&&void 0!==a?a:1,lightType:"point",range:null!==(n=t.range)&&void 0!==n?n:0}:"spot"===t.type?{color:u,intensity:null!==(r=t.intensity)&&void 0!==r?r:1,lightType:"spot",range:null!==(o=t.range)&&void 0!==o?o:0,innerConeAngle:null!==(i=t.innerConeAngle)&&void 0!==i?i:0,outerConeAngle:null!==(s=t.outerConeAngle)&&void 0!==s?s:Math.PI/4}:{color:u,intensity:null!==(c=t.intensity)&&void 0!==c?c:1,lightType:"directional"}},t.createCameraOptions=function(t){if(void 0!==t.perspective){var e=t.perspective;e.znear,e.zfar,e.yfov}},t.toPlayerColor3=function(t){return[this.scaleTo255(t[0]),this.scaleTo255(t[1]),this.scaleTo255(t[2])]},t.toPlayerColor4=function(t){return[this.scaleTo255(t[0]),this.scaleTo255(t[1]),this.scaleTo255(t[2]),this.scaleTo255(t[3])]},t.toPluginColor3=function(t){return[this.scaleTo1(t[0]),this.scaleTo1(t[1]),this.scaleTo1(t[2])]},t.toPluginColor4=function(t){return[this.scaleTo1(t[0]),this.scaleTo1(t[1]),this.scaleTo1(t[2]),this.scaleTo1(t[3])]},t.createUVTransform=function(t){if(void 0!==t&&(void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale)){var e=V.IDENTITY.clone(),a=new V;if(void 0!==t.offset&&(V.fromColumnMajorArray([1,0,0,0,1,0,t.offset[0],t.offset[1],1],a),e.multiply(a)),void 0!==t.rotation){var n=Math.cos(t.rotation),r=Math.sin(t.rotation);V.fromColumnMajorArray([n,r,0,-r,n,0,0,0,1],a),e.multiply(a)}return void 0!==t.scale&&(V.fromColumnMajorArray([t.scale[0],0,0,0,t.scale[1],0,0,0,1],a),e.multiply(a)),V.transpose(e,e),e}},t.clamp=function(t,e,a){return Math.max(Math.min(t,a),e)},t.scaleTo255=function(t){var e=Math.round(255*t);return Math.max(0,Math.min(e,255))},t.scaleTo1=function(t){var e=t/255;return Math.max(0,Math.min(e,1))},t.focusOnPoint=function(t,a,n){var r=S.fromArray(t),o=S.fromArray(n),i=(new S).copyFrom(r).subVector(o);ct.IDENTITY.clone().rotate(a*e.DEG2RAD,new S(0,1,0)).multiplyByPoint3(i);var s=i.clone().addVector(o),c=(new ct).lookAt(s,o,new S(0,1,0)).inverse(),u=new e.Transform;return u.setValid(!0),u.cloneFromMatrix(c.toArray()),u},t.preprocessEffectsScene=function(t,a,n,r){var o=this,i=a!==e.PLAYER_OPTIONS_ENV_EDITOR,s="tiny3d"===n,c=t.jsonScene;if(void 0===c||void 0===c.compositions)return{};var u=!1;if(i){var d=t.textureOptions;c.compositions.forEach((function(t){t.items.forEach((function(t){if("mesh"===t.type)t.content.options.primitives.forEach((function(t){var a=t.material;a.type===e.spec.MaterialType.pbr?(void 0!==a.baseColorTexture&&o.preprocessTextureOptions(a.baseColorTexture,d,!0,s),void 0!==a.metallicRoughnessTexture&&o.preprocessTextureOptions(a.metallicRoughnessTexture,d,!1,s),void 0!==a.normalTexture&&o.preprocessTextureOptions(a.normalTexture,d,!1,s),void 0!==a.occlusionTexture&&o.preprocessTextureOptions(a.occlusionTexture,d,!1,s),void 0!==a.emissiveTexture&&o.preprocessTextureOptions(a.emissiveTexture,d,!1,s)):void 0!==a.baseColorTexture&&o.preprocessTextureOptions(a.baseColorTexture,d,!0,s)}));else if("skybox"===t.type){u=!0;var a=t.content.options;o.preprocessTextureOptions(a.specularImage,d,!1,s),void 0!==a.diffuseImage&&o.preprocessTextureOptions(a.diffuseImage,d,!1,s)}}))}))}else c.compositions.forEach((function(t){t.items.forEach((function(t){"skybox"===t.type&&(u=!0)}))}));return r&&c.compositions.forEach((function(t){var a=0;t.items.forEach((function(t){"light"!==t.type&&"skybox"!==t.type||++a})),0==a&&(t.items.push({id:"dir-light1",duration:100,name:"dir-light1",type:e.spec.ItemType.light,transform:{rotation:[45,-45,0]},pluginName:"model",endBehavior:0,content:{options:{lightType:"directional",color:[255,255,255,255],intensity:1.5}}}),t.items.push({id:"dir-light2",duration:100,name:"dir-light2",type:e.spec.ItemType.light,transform:{rotation:[0,90,0]},pluginName:"model",endBehavior:0,content:{options:{lightType:"directional",color:[255,255,255,255],intensity:.2}}}))})),{loadSkybox:u}},t.preprocessTextureOptions=function(t,a,n,r){if(!(t<0||t>=a.length)){var o=a[t];r&&void 0!==o&&(void 0===o.target||o.target===e.glContext.TEXTURE_2D?(o.wrapS=e.glContext.REPEAT,o.wrapT=e.glContext.REPEAT,o.magFilter=e.glContext.LINEAR,o.minFilter=e.glContext.LINEAR_MIPMAP_LINEAR,o.generateMipmap=!0,n||(o.premultiplyAlpha=!0)):o.target===e.glContext.TEXTURE_CUBE_MAP&&(o.wrapS=e.glContext.CLAMP_TO_EDGE,o.wrapT=e.glContext.CLAMP_TO_EDGE,void 0!==o.mipmaps?(o.magFilter=e.glContext.LINEAR,o.minFilter=e.glContext.LINEAR_MIPMAP_LINEAR):(o.magFilter=e.glContext.LINEAR,o.minFilter=e.glContext.LINEAR)))}},t.setupItem3DOptions=function(t,a,n){var r=this;if(!(void 0===t||t.bins.length<=0)){var o=0,i=t.jsonScene;if(i.compositions.forEach((function(t,e){t.id===i.compositionId&&(o=e)})),o>=0&&o<i.compositions.length)i.compositions[o].items.forEach((function(i,s){if("mesh"===i.type){var c=i,u=c.content.options.skin;if(c.content.options.primitives.forEach((function(i,c){if(!(i.geometry instanceof e.Geometry)){var u="Geom_C".concat(o,"_I").concat(s,"_P").concat(c),d=a.getOrCreateGeometry(u,i.geometry,t.bins),l=i;l.geometry=d;var h,f=i.material;if(f.type===e.spec.MaterialType.pbr)(h=l.material).baseColorTexture=r.getTextureObj(n.textures,f.baseColorTexture),h.metallicRoughnessTexture=r.getTextureObj(n.textures,f.metallicRoughnessTexture),h.normalTexture=r.getTextureObj(n.textures,f.normalTexture),h.occlusionTexture=r.getTextureObj(n.textures,f.occlusionTexture),h.emissiveTexture=r.getTextureObj(n.textures,f.emissiveTexture);else(h=l.material).baseColorTexture=r.getTextureObj(n.textures,f.baseColorTexture)}})),void 0!==u&&void 0!==u.inverseBindMatrices){var d=u,l=kt(t.bins,u.inverseBindMatrices);l instanceof Float32Array?d.inverseBindMatrices=l:console.error("setupItem3DOptions: Invalid inverseBindMatrices type, ".concat(l))}}else if("tree"===i.type){var h=i,f=i.content.options.tree.animations,p=h.content.options.tree.animations;void 0!==f&&void 0!==p&&f.forEach((function(e,a){var n=p[a];e.tracks.forEach((function(e,a){var r=kt(t.bins,e.input),o=kt(t.bins,e.output),i=n.tracks[a];r instanceof Float32Array?i.input=r:console.error("setupItem3DOptions: Type of inputArray should be float32, ".concat(r)),o instanceof Float32Array?i.output=o:console.error("setupItem3DOptions: Type of outputArray should be float32, ".concat(o))}))}))}else if("skybox"===i.type){var m=i,_=i.content.options,g=m.content.options,y=r.getTextureObj(n.textures,_.specularImage);void 0===y&&console.error("setupItem3DOptions: skybox specualrImage is undefined, ".concat(oe.stringify(_))),g.specularImage=y;var v=r.getTextureObj(n.textures,_.diffuseImage);void 0!==v&&(g.diffuseImage=v)}}))}},t.createGeometry=function(t,a,n){var r=function(t,e){var a,n,r=t.attributes,i=o({},t);return i.indices?(i.indices=o({},i.indices),i.indices.data&&(i.indices.data=kt(e,null===(a=t.indices)||void 0===a?void 0:a.data))):i.index&&(i.indices=o({},i.index),i.indices.data&&(i.indices.data=kt(e,null===(n=t.index)||void 0===n?void 0:n.data))),Object.keys(r).forEach((function(t){var a=r[t],n=a.data;i.attributes[t]=o({},a),n&&(i.attributes[t].data=kt(e,n))})),i}(a,n),i={};for(var s in r.attributes){var c=r.attributes[s];i[this.getAttributeName(s)]=c}return r.attributes=i,e.Geometry.create(t,r)},t.getIndexArray=function(t,e){switch(t){case WebGLRenderingContext.UNSIGNED_INT:case WebGLRenderingContext.UNSIGNED_SHORT:case WebGLRenderingContext.UNSIGNED_BYTE:return e;default:console.error("Invalid index attribute type ".concat(t))}},t.getAttributeName=function(t){switch(t){case"POSITION":return"a_Position";case"NORMAL":return"a_Normal";case"TANGENT":return"a_Tangent";case"TEXCOORD_0":return"a_UV1";case"TEXCOORD_1":return"a_UV2";case"JOINTS_0":return"a_Joint1";case"WEIGHTS_0":return"a_Weight1"}return t.startsWith("a_")||console.warn("Unknown attribute name: ".concat(t)),t},t.getTextureObj=function(t,e){return"number"!=typeof e?e:((e<0||e>=t.length)&&console.error("Invalid index for textures: ".concat(e,", ").concat(t.length)),t[e])},t}(),te=function(){function t(){}return t.getImageFileName=function(t,e){var a=t.lastIndexOf("/"),n=t.lastIndexOf("."),r=t.substring(a+1,n);return e?r+e:r},t.getCurrnetTimeStr=function(){var t=new Date(Date.now()),e=t.toLocaleString("zh-CN"),a="".concat(t.getMilliseconds());return e.split(/[ /:]+/).join("")+a.padStart(3,"0")},t.saveFileForURL=function(t,e){var a=document.createElement("a");a.setAttribute("download",e),a.target="_blank",a.href=t,a.click()},t.createPlayer=function(t){void 0===t&&(t=!0);var a=document.createElement("canvas");return a.width=512,a.height=512,new e.Player({canvas:a,renderFramework:"webgl2",env:e.PLAYER_OPTIONS_ENV_EDITOR,willCaptureImage:!0,manualRender:t})},t.sleep=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new Promise((function(e){return setTimeout(e,t)}))]}))}))},t.loadImageFromGLTFImage=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(a){return[2,e.loadImage(new Blob([t.imageData],{type:t.mimeType}))]}))}))},t.loadImageFromImageData=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(a){return[2,e.loadImage(new Blob([t.data],{type:t.mimeType}))]}))}))},t.getCanvasArrayBuffer=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new Promise((function(e,a){t.toBlob((function(t){t?e(t.arrayBuffer()):a(Error("no canvas blob"))}),"image/png",1)}))]}))}))},t.getImageArrayBuffer=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(a){return(e=document.createElement("canvas")).width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),[2,this.getCanvasArrayBuffer(e)]}))}))},t.getCanvasImageData=function(t){return t.getContext("2d").getImageData(0,0,t.width,t.height)},t.flipImageData=function(t){var e=document.createElement("canvas"),a=e.getContext("2d");return e.width=t.width,e.height=t.height,a.putImageData(t,0,0),a.globalCompositeOperation="copy",a.scale(1,-1),a.translate(0,-t.height),a.drawImage(e,0,0),a.setTransform(1,0,0,1,0,0),a.globalCompositeOperation="source-over",a.getImageData(0,0,e.width,e.height)},t.getImageData=function(t){var e=document.createElement("canvas");e.width=t.width,e.height=t.height;var a=e.getContext("2d");return a.drawImage(t,0,0),this.flipImageData(a.getImageData(0,0,e.width,e.height))},t.getWebGLCanvasImageBuffer=function(t){var e=t.getContext("webgl2"),a=new Uint8Array(t.width*t.height*4);return e.readPixels(0,0,t.width,t.height,e.RGBA,e.UNSIGNED_BYTE,a),a},t}(),ee=function(){function t(){this.component=0,this.length=0,this.offset=0,this.stride=0,this.typeSize=0}return t.prototype.getBoundingBox=function(t){for(var e=this.offset,a=new S;e+this.component<=this.length;)2==this.component?a.set(this.data[e],this.data[e+1],0):a.set(this.data[e],this.data[e+1],this.data[e+2]),t.expandByPoint(a),e+=this.stride;return t},t}(),ae=function(){function t(){this.length=0,this.offset=0,this.stride=0,this.typeSize=0,this.compCount=0,this.signed=!1,this.compressed=!1,this.compressScale=1}return t.prototype.create=function(t,e){var a,n;switch(t.type){case WebGLRenderingContext.INT:this.typeSize=4,this.signed=!0,this.compressScale=1/2147483647;break;case WebGLRenderingContext.SHORT:this.typeSize=2,this.signed=!0,this.compressScale=1/32767;break;default:this.typeSize=4,this.signed=!0,this.compressScale=1}this.data=e,this.length=this.data.length,this.compCount=t.size,this.offset=null!==(a=t.offset)&&void 0!==a?a:0,this.offset>0&&(this.offset%this.typeSize!=0&&console.error("Invalid offset ".concat(this.offset,", type size ").concat(this.typeSize)),this.offset=this.offset/this.typeSize),this.stride=null!==(n=t.stride)&&void 0!==n?n:0,this.stride>0?(this.stride%this.typeSize!=0&&console.error("Invalid stride ".concat(this.stride,", type size ").concat(this.typeSize)),this.stride=this.stride/this.typeSize):this.stride=this.compCount,this.compressed=!0===t.normalize},t.prototype.getData=function(t){var e=this.offset;if(!((e+=t*this.stride)+this.compCount>this.length)){var a;if(a=2===this.compCount?[this.data[e],this.data[e+1],0,0]:3===this.compCount?[this.data[e],this.data[e+1],this.data[e+2],0]:[this.data[e],this.data[e+1],this.data[e+2],this.data[e+3]],this.compressed)for(var n=0;n<this.compCount;n++)a[n]*=this.compressScale,this.signed&&(a[n]=Math.max(a[n],-1));return a}},t.prototype.getLength=function(){return Math.round((this.length-this.offset)/this.stride)},t}(),ne=function(){function t(){this.drawStart=0,this.drawCount=0,this.bindMatrices=[]}return t.prototype.create=function(t,e){this.drawStart=0,this.drawCount=Math.abs(t.getDrawCount());var a=t.attributes;this.index=t.getIndexData();var n=a.a_Position,r=t.getAttributeData("a_Position");this.position=new ae,this.position.create(n,r);var o=a.a_Joint1,i=a.a_Weight1;if(void 0!==o&&void 0!==i){var s=t.getAttributeData("a_Joint1"),c=t.getAttributeData("a_Weight1");this.joint=new ae,this.joint.create(o,s),this.weight=new ae,this.weight.create(i,c)}this.bindMatrices=e},t.prototype.getBoundingBox=function(t){var e=this;t.makeEmpty();var a=new ct,n=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0,r=new Set;if(void 0!==this.index)for(var o=0;o<this.drawCount;o++){var i=this.drawStart+o;i<this.index.length&&r.add(this.index[i])}else for(o=0;o<this.drawCount;o++)r.add(this.drawStart+o);return r.forEach((function(r){var o,i,s=e.position.getData(r);if(void 0!==s){var c=S.fromArray(s);if(n){var u=null===(o=e.joint)||void 0===o?void 0:o.getData(r),d=null===(i=e.weight)||void 0===i?void 0:i.getData(r);if(void 0!==u&&void 0!==d){a.setZero();for(var l=!1,h=0;h<4;h++)if(0!==d[h]){if(u[h]<0||u[h]>=e.bindMatrices.length){l=!0;break}var f=e.bindMatrices[u[h]];ct.mulScalerAddMatrix(a,f,d[h],a)}if(!l){var p=a.multiplyByVector4(new P(c.x,c.y,c.z,1));Math.abs(p.w)>1e-4&&(p.multiplyScalar(1/p.w),c.set(p.x,p.y,p.z))}}}t.expandByPoint(c)}})),t},t}(),re=function(){function t(){this.drawStart=0,this.drawCount=0,this.doubleSided=!1,this.bindMatrices=[],this.hasAnimation=!1,this.skinMatrix=new ct}return t.prototype.create=function(t,e,a){this.drawStart=0,this.drawCount=Math.abs(t.getDrawCount());var n=t.attributes;this.index=t.getIndexData();var r=n.a_Position,o=t.getAttributeData("a_Position");this.position=new ae,this.position.create(r,o);var i=n.a_Joint1,s=n.a_Weight1;if(void 0!==i&&void 0!==s){var c=t.getAttributeData("a_Joint1"),u=t.getAttributeData("a_Weight1");this.joint=new ae,this.joint.create(i,c),this.weight=new ae,this.weight.create(s,u)}this.doubleSided=e,this.bindMatrices=a,this.hasAnimation=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0},t.prototype.getHitPoint=function(t,e){for(var a,n=new S,r=new S,o=new S,i=new P,s=new P,c=new P,u=!this.doubleSided,d=0;d+2<this.drawCount;d+=3){var l=this.drawStart+d,h=this.drawStart+d+1,f=this.drawStart+d+2;void 0!==this.index&&(l=this.index[l],h=this.index[h],f=this.index[f]);var p=this.getPosition(l,n,i),m=this.getPosition(h,r,s),_=this.getPosition(f,o,c);if(void 0!==p&&void 0!==m&&void 0!==_){var g=Xt(t,e,p,m,_,u);void 0!==g&&(void 0===a||a>g)&&(a=g)}}return a},t.prototype.getPosition=function(t,e,a){var n,r,o=this.position.getData(t);if(void 0!==o){if(this.hasAnimation){var i=null===(n=this.joint)||void 0===n?void 0:n.getData(t),s=null===(r=this.weight)||void 0===r?void 0:r.getData(t);if(void 0!==i&&void 0!==s){var c=this.skinMatrix;c.setZero();for(var u=0;u<4;u++)if(0!==s[u]){var d=this.bindMatrices[i[u]];ct.mulScalerAddMatrix(c,d,s[u],c)}a.set(o[0],o[1],o[2],1);var l=c.multiplyByVector4(a),h=1/l.w;e.set(l.x*h,l.y*h,l.z*h)}}else e.set(o[0],o[1],o[2]);return e}},t}(),oe=function(){function t(){}return t.checkNumber=function(t){return"number"==typeof t},t.checkNumberUndef=function(t){return void 0===t||this.checkNumber(t)},t.checkNumber01=function(t){return this.checkNumber(t)&&t>=0&&t<=1},t.checkNumber01Undef=function(t){return void 0===t||this.checkNumber01(t)},t.checkPositive=function(t){return this.checkNumber(t)&&t>0},t.checkNonnegative=function(t){return this.checkNumber(t)&&t>=0},t.checkNonnegativeUndef=function(t){return void 0===t||this.checkNonnegative(t)},t.checkBoolean=function(t){return"boolean"==typeof t},t.checkBooleanUndef=function(t){return void 0===t||this.checkBoolean(t)},t.checkString=function(t){return"string"==typeof t},t.checkStringUndef=function(t){return void 0===t||this.checkString(t)},t.checkFloat32Array=function(t){return t instanceof Float32Array},t.checkFloat32ArrayUndef=function(t){return void 0===t||this.checkFloat32Array(t)},t.checkParent=function(t){return void 0===t||!!this.checkNumber(t)&&t>=0},t.checkTexCoord=function(t){return void 0===t||!!this.checkNumber(t)&&(t>=0&&t<=1)},t.checkVec2=function(t){var e=this;return!!Array.isArray(t)&&(2==t.length&&t.every((function(t){return e.checkNumber(t)})))},t.checkVec2Undef=function(t){return void 0===t||this.checkVec2(t)},t.checkVec3=function(t){var e=this;return!!Array.isArray(t)&&(3==t.length&&t.every((function(t){return e.checkNumber(t)})))},t.checkNonnegative3=function(t){var e=this;return!!Array.isArray(t)&&(3==t.length&&t.every((function(t){return e.checkNonnegative(t)})))},t.checkVec4=function(t){var e=this;return!!Array.isArray(t)&&(4==t.length&&t.every((function(t){return e.checkNumber(t)})))},t.checkNonnegative4=function(t){var e=this;return!!Array.isArray(t)&&(4==t.length&&t.every((function(t){return e.checkNonnegative(t)})))},t.checkNumberArray=function(t){var e=this;return!!Array.isArray(t)&&t.every((function(t){return e.checkNumber(t)}))},t.checkTexture=function(t){return t instanceof e.Texture&&(t.isDestroyed&&console.error("Texture is destroyed, ".concat(t.name)),!t.isDestroyed)},t.checkTextureUndef=function(t){return void 0===t||this.checkTexture(t)},t.checkTexTransform=function(t){return!!this.checkVec2Undef(t.offset)&&(!!this.checkNumberUndef(t.rotation)&&(!!this.checkVec2Undef(t.scale)&&(void 0===t.scale||!(Math.abs(t.scale[0])<1e-5||Math.abs(t.scale[1])<1e-5))))},t.checkTexTransformUndef=function(t){return void 0===t||this.checkTexTransform(t)},t.checkMatBlending=function(t){return void 0===t||t===e.spec.MaterialBlending.opaque||t===e.spec.MaterialBlending.masked||t===e.spec.MaterialBlending.translucent||t===e.spec.MaterialBlending.additive},t.checkMatSide=function(t){return void 0===t||t===e.spec.SideMode.BACK||t===e.spec.SideMode.DOUBLE||t===e.spec.SideMode.FRONT},t.checkAnimPath=function(t){return"translation"===t||"rotation"===t||"scale"===t||"weights"===t},t.checkAnimInterp=function(t){return"LINEAR"===t||"STEP"===t||"CUBICSPLINE"===t},t.assertGeometry=function(t,a){t instanceof e.Geometry||console.error("Invalid geometry type ".concat(this.stringify(t))),!0===t.isDestroyed&&console.error("Geometry object is destroyed"),this.checkNonnegative(t.getDrawStart())||console.error("Invalid geometry draw start: ".concat(t.getDrawStart(),", ").concat(this.stringify(t)))},t.assertGeometryBuffer=function(t,e,a){var n=this.createAttributeArray(t,e);void 0!==n&&n.getLength()<a&&console.error("".concat(e," Length(").concat(n.getLength(),") is less than draw count(").concat(a,"), ").concat(this.stringify(t)))},t.createAttributeArray=function(t,e){var a=t.attributes;if(void 0!==a){var n=a[e];if(void 0!==n){var r=t.getAttributeData(e);if(void 0!==r){var o=new ae;return o.create(n,r),o}}}},t.assertModelSkinOptions=function(t){if(this.checkStringUndef(t.name)||console.error("Invalid skin name ".concat(t.name,", ").concat(this.stringify(t))),this.checkNumberArray(t.joints)||console.error("Invalid skin joints ".concat(t.joints,", ").concat(this.stringify(t))),this.checkNumberUndef(t.skeleton)||console.error("Invalid skin skeleton ".concat(t.skeleton,", ").concat(this.stringify(t))),this.checkFloat32ArrayUndef(t.inverseBindMatrices)||console.error("Invalid skin inverseBindMatrices ".concat(t.inverseBindMatrices,", ").concat(this.stringify(t))),void 0!==t.inverseBindMatrices){(t.inverseBindMatrices.length<=0||t.inverseBindMatrices.length%16!=0)&&console.error("Invalid skin inverseBindMatrices length ".concat(t.inverseBindMatrices,", ").concat(this.stringify(t))),16*t.joints.length!==t.inverseBindMatrices.length&&console.error("Mismatch: skin joints and inverseBindMatrices length, ".concat(t.joints,", ").concat(t.inverseBindMatrices,", ").concat(this.stringify(t)));for(var e=new ct,a=0;a<t.inverseBindMatrices.length;a+=16){for(var n=0;n<16;n++)e.data[n]=t.inverseBindMatrices[a+n];Math.abs(e.determinant())<1e-5&&console.error("Determinant of inverseBindMatrices is too small ".concat(e.determinant(),", index ").concat(a/16,", ").concat(this.stringify(t)))}}else t.joints.length<=0&&console.error("Invalid skin joints length ".concat(t.joints,", ").concat(this.stringify(t)))},t.assertMatOptions=function(t){t.type===e.spec.MaterialType.unlit?(this.checkString(t.name)||console.error("Invalid material name ".concat(t.name,", ").concat(this.stringify(t))),this.checkNonnegative4(t.baseColorFactor)||console.error("Invalid material baseColorFactor ".concat(t.baseColorFactor,", ").concat(this.stringify(t))),this.checkTextureUndef(t.baseColorTexture)||console.error("Invalid material baseColorTexture ".concat(t.baseColorTexture,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform ".concat(t.baseColorTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate ".concat(t.baseColorTextureCoordinate,", ").concat(this.stringify(t))),this.checkBooleanUndef(t.depthMask)||console.error("Invalid material depthMask ".concat(t.depthMask,", ").concat(this.stringify(t))),this.checkMatBlending(t.blending)||console.error("Invalid material blending ".concat(t.blending,", ").concat(this.stringify(t))),this.checkMatSide(t.side)||console.error("Invalid material side ".concat(t.side,", ").concat(this.stringify(t))),t.blending===e.spec.MaterialBlending.masked&&void 0===t.alphaCutOff&&console.error("Material alphaCutOff is required for mask, ".concat(this.stringify(t))),this.checkNumber01Undef(t.alphaCutOff)||console.error("Invalid material alphaCutOff ".concat(t.alphaCutOff,", ").concat(this.stringify(t)))):t.type===e.spec.MaterialType.pbr?(this.checkString(t.name)||console.error("Invalid material name ".concat(t.name,", ").concat(this.stringify(t))),this.checkNonnegative4(t.baseColorFactor)||console.error("Invalid material baseColorFactor ".concat(t.baseColorFactor,", ").concat(this.stringify(t))),this.checkTextureUndef(t.baseColorTexture)||console.error("Invalid material baseColorTexture ".concat(t.baseColorTexture,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform ".concat(t.baseColorTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate ".concat(t.baseColorTextureCoordinate,", ").concat(this.stringify(t))),this.checkBooleanUndef(t.useSpecularAA)||console.error("Invalid material useSpecularAA ".concat(t.useSpecularAA,", ").concat(this.stringify(t))),this.checkNumber01(t.metallicFactor)||console.error("Invalid material metallicFactor ".concat(t.metallicFactor,", ").concat(this.stringify(t))),this.checkNonnegative(t.roughnessFactor)||console.error("Invalid material roughnessFactor ".concat(t.roughnessFactor,", ").concat(this.stringify(t))),this.checkTextureUndef(t.metallicRoughnessTexture)||console.error("Invalid material metallicRoughnessTexture ".concat(t.metallicRoughnessTexture,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.metallicRoughnessTextureTransform)||console.error("Invalid material metallicRoughnessTextureTransform ".concat(t.metallicRoughnessTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.metallicRoughnessTextureCoordinate)||console.error("Invalid material metallicRoughnessTextureCoordinate ".concat(t.metallicRoughnessTextureCoordinate,", ").concat(this.stringify(t))),this.checkTextureUndef(t.normalTexture)||console.error("Invalid material normalTexture ".concat(t.normalTexture,", ").concat(this.stringify(t))),this.checkNonnegativeUndef(t.normalTextureScale)||console.error("Invalid material normalTextureScale ".concat(t.normalTextureScale,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.normalTextureTransform)||console.error("Invalid material normalTextureTransform ".concat(t.normalTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.normalTextureCoordinate)||console.error("Invalid material normalTextureCoordinate ".concat(t.normalTextureCoordinate,", ").concat(this.stringify(t))),this.checkTextureUndef(t.occlusionTexture)||console.error("Invalid material occlusionTexture ".concat(t.occlusionTexture,", ").concat(this.stringify(t))),this.checkNumber01Undef(t.occlusionTextureStrength)||console.error("Invalid material occlusionTextureStrength ".concat(t.occlusionTextureStrength,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.occlusionTextureTransform)||console.error("Invalid material occlusionTextureTransform ".concat(t.occlusionTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.occlusionTextureCoordinate)||console.error("Invalid material occlusionTextureCoordinate ".concat(t.occlusionTextureCoordinate,", ").concat(this.stringify(t))),this.checkNonnegative4(t.emissiveFactor)||console.error("Invalid material emissiveFactor ".concat(t.emissiveFactor,", ").concat(this.stringify(t))),this.checkNonnegative(t.emissiveIntensity)||console.error("Invalid material emissiveIntensity ".concat(t.emissiveIntensity,", ").concat(this.stringify(t))),this.checkTextureUndef(t.emissiveTexture)||console.error("Invalid material emissiveTexture ".concat(t.emissiveTexture,", ").concat(this.stringify(t))),this.checkTexTransformUndef(t.emissiveTextureTransform)||console.error("Invalid material emissiveTextureTransform ".concat(t.emissiveTextureTransform,", ").concat(this.stringify(t))),this.checkTexCoord(t.emissiveTextureCoordinate)||console.error("Invalid material emissiveTextureCoordinate ".concat(t.emissiveTextureCoordinate,", ").concat(this.stringify(t))),this.checkBooleanUndef(t.depthMask)||console.error("Invalid material depthMask ".concat(t.depthMask,", ").concat(this.stringify(t))),this.checkMatBlending(t.blending)||console.error("Invalid material blending ".concat(t.blending,", ").concat(this.stringify(t))),this.checkMatSide(t.side)||console.error("Invalid material side ".concat(t.side,", ").concat(this.stringify(t))),t.blending===e.spec.MaterialBlending.masked&&void 0===t.alphaCutOff&&console.error("Material alphaCutOff is required for mask, ".concat(this.stringify(t))),this.checkNumber01Undef(t.alphaCutOff)||console.error("Invalid material alphaCutOff ".concat(t.alphaCutOff,", ").concat(this.stringify(t)))):console.error("Invalid material type ".concat(this.stringify(t)))},t.assertPrimOptions=function(t,e){return this.assertGeometry(t.geometry,e),this.assertMatOptions(t.material),!0},t.assertModelMeshOptions=function(t){this.checkParent(t.parent)||console.error("Invalid mesh parent ".concat(t.parent,", ").concat(this.stringify(t))),void 0!==t.skin&&this.assertModelSkinOptions(t.skin);for(var e=[],a=0;a<t.primitives.length;a++){var n=t.primitives[a];this.assertPrimOptions(n)||console.error("Invalid primitive ".concat(n,", ").concat(this.stringify(t)));var r=new le;r.create(n.geometry),e.push(r)}for(a=1;a<e.length;a++){var o=e[a-1],i=e[a];o.equals(i)||console.error("Morph states mismatch: ".concat(this.stringify(o),", ").concat(this.stringify(i),", ").concat(this.stringify(t)))}this.checkBooleanUndef(t.hide)||console.error("Invalid mesh hide ".concat(t.hide,", ").concat(this.stringify(t)))},t.assertModelCameraOptions=function(t){this.checkParent(t.parent)||console.error("Invalid camera parent ".concat(t.parent,", ").concat(this.stringify(t))),this.checkNumberUndef(t.aspect)||console.error("Invalid camera aspect ".concat(t.aspect,", ").concat(this.stringify(t))),this.checkPositive(t.near)||console.error("Invalid camera near ".concat(t.near,", ").concat(this.stringify(t))),(!this.checkPositive(t.far)||t.far<=t.near)&&console.error("Invalid camera far ".concat(t.far,", ").concat(this.stringify(t))),this.checkPositive(t.fov)||console.error("Invalid camera fov ".concat(t.fov,", ").concat(this.stringify(t))),this.checkNumber01(t.clipMode)||console.error("Invalid camera clipMode ".concat(t.clipMode,", ").concat(this.stringify(t)))},t.assertModelLightOptions=function(t){"directional"===t.lightType?(this.checkParent(t.parent)||console.error("Invalid light parent ".concat(t.parent,", ").concat(this.stringify(t))),this.checkNonnegative4(t.color)||console.error("Invalid light color ".concat(t.color,", ").concat(this.stringify(t))),this.checkNonnegative(t.intensity)||console.error("Invalid light intensity ".concat(t.intensity,", ").concat(this.stringify(t)))):"point"===t.lightType?(this.checkParent(t.parent)||console.error("Invalid light parent ".concat(t.parent,", ").concat(this.stringify(t))),this.checkNonnegative4(t.color)||console.error("Invalid light color ".concat(t.color,", ").concat(this.stringify(t))),this.checkNonnegative(t.intensity)||console.error("Invalid light intensity ".concat(t.intensity,", ").concat(this.stringify(t))),this.checkNonnegative(t.range)||console.error("Invalid light range ".concat(t.range,", ").concat(this.stringify(t)))):"spot"===t.lightType?(this.checkParent(t.parent)||console.error("Invalid light parent ".concat(t.parent,", ").concat(this.stringify(t))),this.checkNonnegative4(t.color)||console.error("Invalid light color ".concat(t.color,", ").concat(this.stringify(t))),this.checkNonnegative(t.intensity)||console.error("Invalid light intensity ".concat(t.intensity,", ").concat(this.stringify(t))),this.checkNonnegative(t.range)||console.error("Invalid light range ".concat(t.range,", ").concat(this.stringify(t))),this.checkNonnegative(t.innerConeAngle)||console.error("Invalid light innerConeAngle ".concat(t.innerConeAngle,", ").concat(this.stringify(t))),this.checkNonnegative(t.outerConeAngle)||console.error("Invalid light outerConeAngle ".concat(t.outerConeAngle,", ").concat(this.stringify(t)))):"ambient"===t.lightType?(this.checkParent(t.parent)||console.error("Invalid light parent ".concat(t.parent,", ").concat(this.stringify(t))),this.checkNonnegative4(t.color)||console.error("Invalid light color ".concat(t.color,", ").concat(this.stringify(t))),this.checkNonnegative(t.intensity)||console.error("Invalid light intensity ".concat(t.intensity,", ").concat(this.stringify(t)))):console.error("Invalid light type ".concat(this.stringify(t)))},t.assertModelSkyboxOptions=function(t){var e=this;this.checkBoolean(t.renderable)||console.error("Invalid skybox renderable ".concat(t.renderable,", ").concat(this.stringify(t))),this.checkNonnegative(t.intensity)||console.error("Invalid skybox intensity ".concat(t.intensity,", ").concat(this.stringify(t))),this.checkNonnegative(t.reflectionsIntensity)||console.error("Invalid skybox reflectionsIntensity ".concat(t.reflectionsIntensity,", ").concat(this.stringify(t)));var a=t.irradianceCoeffs;void 0!==a?(Array.isArray(a)&&9==a.length||console.error("Invalid skybox irradianceCoeffs ".concat(a,", ").concat(this.stringify(t))),a.forEach((function(t){e.checkVec3(t)||console.error("Invalid skybox irradianceCoeffs ".concat(a,", ").concat(e.stringify(t)))}))):void 0!==t.diffuseImage?this.checkTexture(t.diffuseImage)||console.error("Invalid skybox diffuseImage ".concat(t.diffuseImage,", ").concat(this.stringify(t))):console.error("Invalid skybox, irradianceCoeffs or diffuseImage should give one, ".concat(this.stringify(t))),this.checkTexture(t.specularImage)||console.error("Invalid skybox specularImage ".concat(t.specularImage,", ").concat(this.stringify(t))),this.checkPositive(t.specularImageSize)||console.error("Invalid skybox specularImageSize ".concat(t.specularImageSize,", ").concat(this.stringify(t))),this.checkPositive(t.specularMipCount)||console.error("Invalid skybox specularMipCount ".concat(t.specularMipCount,", ").concat(this.stringify(t))),this.pow2(t.specularMipCount)>t.specularImageSize&&console.error("Invalid skybox specularMipCount or specularImageSize, ".concat(this.stringify(t)))},t.checkModelAnimTrackOptions=function(t){return this.checkNonnegative(t.node)?this.checkFloat32Array(t.input)?this.checkFloat32Array(t.output)?this.checkAnimPath(t.path)?!!this.checkAnimInterp(t.interpolation)||(console.error("Invalid track interpolation ".concat(t.interpolation,", ").concat(this.stringify(t))),!1):(console.error("Invalid track path ".concat(t.path,", ").concat(this.stringify(t))),!1):(console.error("Invalid track input ".concat(t.output,", ").concat(this.stringify(t))),!1):(console.error("Invalid track input ".concat(t.input,", ").concat(this.stringify(t))),!1):(console.error("Invalid track node ".concat(t.node,", ").concat(this.stringify(t))),!1)},t.assertModelAnimOptions=function(t){var e=this;this.checkStringUndef(t.name)||console.error("Invalid animation name ".concat(t.name,", ").concat(this.stringify(t))),Array.isArray(t.tracks)||console.error("Invalid animation tracks ".concat(t.tracks,", ").concat(this.stringify(t))),t.tracks.forEach((function(a){e.checkModelAnimTrackOptions(a)||console.error("Invalid animation track ".concat(a,", ").concat(e.stringify(t)))}))},t.assertTreeOptions=function(t){var e=this;this.checkNumberUndef(t.animation)||console.error("Invalid tree animation ".concat(t.animation,", ").concat(this.stringify(t))),void 0!==t.animations&&(Array.isArray(t.animations)||console.error("Invalid tree animations ".concat(t.animations,", ").concat(this.stringify(t))),t.animations.forEach((function(t){e.assertModelAnimOptions(t)})),void 0!==t.animation&&(t.animation<-1||t.animation>=t.animations.length)&&console.error("Invalid tree animations ".concat(t.animations,", ").concat(this.stringify(t))))},t.stringify=function(t){var a={};for(var n in t)"internal"!==n&&"function"!=typeof t[n]&&(t[n]instanceof e.Texture||t[n]instanceof e.Geometry?a[n]=t[n].name:t[n]instanceof e.Renderer||(a[n]=t[n]));return JSON.stringify(a)},t.pow2=function(t){for(var e=1;t-- >0;)e*=2;return e},t}(),ie=function(){function t(t){this.size=t,this.data=new Uint16Array(t)}return t.prototype.set=function(t,e){for(var a=0;a<t.length;a++)this.data[a+e]=se(t[a])},Object.defineProperty(t.prototype,"bytes",{get:function(){return 2*this.size},enumerable:!1,configurable:!0}),t}(),se=(Yt=new Float32Array(1),Zt=new Int32Array(Yt.buffer),function(t){Yt[0]=t;var e=Zt[0],a=e>>16&32768,n=e>>12&2047,r=e>>23&255;return r<103?a:r>142?(a|=31744,a|=(255==r?0:1)&&8388607&e):r<113?a|=((n|=2048)>>114-r)+(n>>113-r&1):(a|=r-112<<10|n>>1,a+=1&n)});t.TextureDataMode=void 0,(Jt=t.TextureDataMode||(t.TextureDataMode={}))[Jt.none=0]="none",Jt[Jt.float=1]="float",Jt[Jt.half_float=2]="half_float";var ce,ue,de=function(e){function a(){var a=null!==e&&e.apply(this,arguments)||this;return a.skeleton=0,a.jointList=[],a.inverseBindMatrices=[],a.animationMatrices=[],a.textureDataMode=t.TextureDataMode.none,a}return r(a,e),a.prototype.create=function(e,a,n){var r,o;this.name=this.genName(null!==(r=e.name)&&void 0!==r?r:"Unnamed skin"),this.type=t.PObjectType.skin,this.parentItem=n,this.skeleton=null!==(o=e.skeleton)&&void 0!==o?o:-1,this.jointList=e.joints,this.animationMatrices=[],this.inverseBindMatrices=[],this.textureDataMode=this.getTextureDataMode(this.getJointCount(),a);var i=e.inverseBindMatrices;if(void 0!==i&&i.length>0){if(i.length%16!=0||i.length!==16*this.jointList.length)throw new Error("Invalid array length, inverse bind matrices ".concat(i.length,", joint array ").concat(this.jointList.length));for(var s=i.length/16,c=0;c<s;c++){var u=new ct;ct.unpack(i,16*c,u),this.inverseBindMatrices.push(u)}}},a.prototype.updateSkinMatrices=function(){var t=this;if(this.animationMatrices=[],void 0!==this.parentItem)for(var e=this.parentItem.content,a=0;a<this.jointList.length;a++){var n=this.jointList[a],r=e.getNodeById(n);if(void 0===r){console.error("Can't find joint ".concat(n," in node tree ").concat(this.parentItem,"."));break}var o=r.transform.getWorldMatrix(),i=ct.fromArray(o);this.animationMatrices.push(i)}this.animationMatrices.length===this.inverseBindMatrices.length?this.animationMatrices.forEach((function(e,a){e.multiply(t.inverseBindMatrices[a])})):(this.animationMatrices=this.inverseBindMatrices,console.error("Some error occured, replace skin animation matrices by inverse bind matrices"))},a.prototype.computeMeshAnimMatrices=function(t,e,a){var n=t.clone().inverse(),r=new ct;this.animationMatrices.forEach((function(t,o){var i=ct.multiply(n,t,r);i.data.forEach((function(t,a){return e[16*o+a]=t})),i.clone().inverse().transpose().data.forEach((function(t,e){return a[16*o+e]=t}))}))},a.prototype.updateParentItem=function(t){this.parentItem=t},a.prototype.getJointCount=function(){return this.jointList.length},a.prototype.isTextureDataMode=function(){return this.textureDataMode!==t.TextureDataMode.none},a.prototype.dispose=function(){this.parentItem=void 0,this.jointList=[],this.inverseBindMatrices=[],this.animationMatrices=[]},a.prototype.getTextureDataMode=function(e,a){var n=a.gpuCapability.detail,r=n.maxVertexUniforms-25;if(e>Math.floor(r/8)){if(n.floatTexture)return t.TextureDataMode.float;if(n.halfFloatTexture)return t.TextureDataMode.half_float;throw new Error("Too many joint count ".concat(e,", half float texture not support"))}return t.TextureDataMode.none},a}(Bt),le=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.morphWeightsLength=0,t.hasPositionMorph=!1,t.hasNormalMorph=!1,t.hasTangentMorph=!1,t}return r(a,e),a.prototype.create=function(e){var n=this;this.name=this.genName("Morph target"),this.type=t.PObjectType.morph;var r=this.getAttributeMorphCount(a.positionNameList,e),o=this.getAttributeMorphCount(a.normalNameList,e),i=this.getAttributeMorphCount(a.tangentNameList,e),s=[r,o,i];return this.morphWeightsLength=0,s.forEach((function(t){t>0&&(0===n.morphWeightsLength?n.morphWeightsLength=t:n.morphWeightsLength=Math.min(n.morphWeightsLength,t))})),this.morphWeightsLength>0&&(this.morphWeightsArray=new Float32Array(this.morphWeightsLength),this.hasPositionMorph=r==this.morphWeightsLength,this.hasNormalMorph=o==this.morphWeightsLength,this.hasTangentMorph=i==this.morphWeightsLength),r>0&&r!=this.morphWeightsLength?(console.error("Position morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(r)),!1):o>0&&o!=this.morphWeightsLength?(console.error("Normal morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(o)),!1):i>0&&i!=this.morphWeightsLength?(console.error("Tangent morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(i)),!1):!(this.morphWeightsLength>5)||(console.error("Tangent morph count should not greater than 5, current ".concat(this.morphWeightsLength)),!1)},a.prototype.dispose=function(){this.morphWeightsArray=void 0},a.prototype.initWeights=function(t){if(void 0!==this.morphWeightsArray){var e=this.morphWeightsArray;t.forEach((function(t,a){a<e.length&&(e[a]=t)}))}},a.prototype.hasMorph=function(){return this.morphWeightsLength>0&&(this.hasPositionMorph||this.hasNormalMorph||this.hasTangentMorph)},a.prototype.equals=function(t){return this.morphWeightsLength===t.morphWeightsLength&&this.hasPositionMorph===t.hasPositionMorph&&this.hasNormalMorph===t.hasNormalMorph&&this.hasTangentMorph===t.hasTangentMorph},a.prototype.getMorphWeightsArray=function(){return this.morphWeightsArray},a.prototype.getAttributeMorphCount=function(t,e){for(var a=0;a<t.length;a++){var n=t[a];if(void 0===e.getAttributeData(n))return a}return t.length},a.positionNameList=["a_Target_Position0","a_Target_Position1","a_Target_Position2","a_Target_Position3","a_Target_Position4","a_Target_Position5","a_Target_Position6","a_Target_Position7"],a.normalNameList=["a_Target_Normal0","a_Target_Normal1","a_Target_Normal2","a_Target_Normal3","a_Target_Normal4","a_Target_Normal5","a_Target_Normal6","a_Target_Normal7"],a.tangentNameList=["a_Target_Tangent0","a_Target_Tangent1","a_Target_Tangent2","a_Target_Tangent3","a_Target_Tangent4","a_Target_Tangent5","a_Target_Tangent6","a_Target_Tangent7"],a}(Bt);t.PAnimInterpType=void 0,(ce=t.PAnimInterpType||(t.PAnimInterpType={}))[ce.linear=0]="linear",ce[ce.step=1]="step",ce[ce.cubicSpline=2]="cubicSpline",t.PAnimPathType=void 0,(ue=t.PAnimPathType||(t.PAnimPathType={}))[ue.translation=0]="translation",ue[ue.rotation=1]="rotation",ue[ue.scale=2]="scale",ue[ue.weights=3]="weights";var he,fe=function(){function e(e){this.path=t.PAnimPathType.translation,this.interp=t.PAnimInterpType.linear;var a=e.node,n=e.input,r=e.output,o=e.path,i=e.interpolation;if(this.node=a,this.timeArray=n,this.dataArray=r,"translation"===o?(this.path=t.PAnimPathType.translation,this.component=3):"rotation"===o?(this.path=t.PAnimPathType.rotation,this.component=4):"scale"===o?(this.path=t.PAnimPathType.scale,this.component=3):"weights"===o?(this.path=t.PAnimPathType.weights,this.component=this.dataArray.length/this.timeArray.length,this.component<=0?console.error("Invalid weights component: ".concat(this.timeArray.length,", ").concat(this.component,", ").concat(this.dataArray.length)):this.timeArray.length*this.component!=this.dataArray.length&&console.error("Invalid weights array length: ".concat(this.timeArray.length,", ").concat(this.component,", ").concat(this.dataArray.length))):console.error("Invalid path status: ".concat(o)),this.timeArray.length*this.component>this.dataArray.length)throw new Error("Data length mismatch: ".concat(this.timeArray.length,", ").concat(this.component,", ").concat(this.dataArray.length));this.interp="LINEAR"===i?t.PAnimInterpType.linear:"STEP"===i?t.PAnimInterpType.step:t.PAnimInterpType.cubicSpline,this.sampler=m(this.getInterpInfo(),this.timeArray,this.dataArray,this.component,this.getPathInfo())}return e.prototype.dispose=function(){var t;this.timeArray=void 0,this.dataArray=void 0,null===(t=this.sampler)||void 0===t||t.dispose(),this.sampler=void 0},e.prototype.tick=function(e,a,n){var r=a.content.getNodeById(this.node);if(void 0!==this.sampler&&void 0!==r){var o=this.sampler.evaluate(e);switch(this.path){case t.PAnimPathType.translation:r.transform.setPosition(o[0],o[1],o[2]);break;case t.PAnimPathType.rotation:r.transform.setQuaternion(o[0],o[1],o[2],o[3]);break;case t.PAnimPathType.scale:r.transform.setScale(o[0],o[1],o[2]);break;case t.PAnimPathType.weights:var i=this.genParentId(a.id,this.node),s=null==n?void 0:n.queryMesh(i);void 0!==s&&s.updateMorphWeights(o)}}else void 0!==this.sampler&&console.error("AnimTrack: error",this.sampler,r)},e.prototype.getEndTime=function(){var t=this.timeArray.length-1;return this.timeArray[t]},e.prototype.genParentId=function(t,e){return"".concat(t,"^").concat(e)},e.prototype.getPathInfo=function(){return this.path===t.PAnimPathType.scale?"scale":this.path===t.PAnimPathType.rotation?"rotation":"translation"},e.prototype.getInterpInfo=function(){return this.interp===t.PAnimInterpType.cubicSpline?"CUBICSPLINE":this.interp===t.PAnimInterpType.step?"STEP":"LINEAR"},e}(),pe=function(){function t(t){this.engine=t,this.isHalfFloat=!0,this.width=0,this.height=0}return t.prototype.create=function(t,a,n){var r,o;this.width=4,this.height=t,this.isHalfFloat=a,this.isHalfFloat&&(this.buffer=new ie(4*this.getSize()));var i=null!==(o=null===(r=this.buffer)||void 0===r?void 0:r.data)&&void 0!==o?o:new Float32Array(4*this.getSize()),s=this.isHalfFloat?e.glContext.HALF_FLOAT:e.glContext.FLOAT;this.texture=e.Texture.create(this.engine,{name:n,data:{width:this.width,height:this.height,data:i},target:e.glContext.TEXTURE_2D,format:e.glContext.RGBA,type:s,wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,minFilter:e.glContext.NEAREST,magFilter:e.glContext.NEAREST})},t.prototype.update=function(t){var a,n;void 0!==this.buffer&&this.buffer.set(t,0),void 0!==this.texture&&this.texture.updateSource({sourceType:e.TextureSourceType.data,data:{width:this.width,height:this.height,data:null!==(n=null===(a=this.buffer)||void 0===a?void 0:a.data)&&void 0!==n?n:t},target:e.glContext.TEXTURE_2D})},t.prototype.dispose=function(){var t;this.engine=null,this.buffer=void 0,null===(t=this.texture)||void 0===t||t.dispose()},t.prototype.getSize=function(){return this.width*this.height},t.prototype.getTexture=function(){return this.texture},t}(),me=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.time=0,t.duration=0,t.tracks=[],t}return r(a,e),a.prototype.create=function(e){var a,n=this;this.name=this.genName(null!==(a=e.name)&&void 0!==a?a:"Unnamed animation"),this.type=t.PObjectType.animation,this.time=0,this.duration=0,this.tracks=[],e.tracks.forEach((function(t){var e=new fe(t);n.tracks.push(e),n.duration=Math.max(n.duration,e.getEndTime())}))},a.prototype.tick=function(t,e,a){this.time=t;var n=this.time%this.duration;this.tracks.forEach((function(t){t.tick(n,e,a)}))},a.prototype.dispose=function(){this.tracks.forEach((function(t){t.dispose()})),this.tracks=[]},a}(Bt),_e=function(e){function a(a,n){var r,o,i,s=e.call(this)||this;s.animation=0,s.speed=0,s.delay=0,s.time=0,s.animations=[],s.name=s.genName(null!==(r=n.name)&&void 0!==r?r:"Unnamed tree"),s.type=t.PObjectType.animationManager,s.ownerItem=n,s.animation=null!==(o=a.animation)&&void 0!==o?o:-1,s.speed=1,s.delay=null!==(i=n.delay)&&void 0!==i?i:0,s.animations=[],void 0!==a.animations&&a.animations.forEach((function(t){var e=s.createAnimation(t);s.animations.push(e)}));var c=n.composition;return null!=c&&(s.sceneManager=c.loaderData.sceneManager),s}return r(a,e),a.prototype.createAnimation=function(t){var e=new me;return e.create(t),e},a.prototype.tick=function(t){var e=this,a=t*this.speed*.001;this.time+=a;var n=this.time-this.delay;n>=0&&(this.animation>=0&&this.animation<this.animations.length?this.animations[this.animation].tick(n,this.ownerItem,this.sceneManager):-88888888==this.animation&&this.animations.forEach((function(t){t.tick(n,e.ownerItem,e.sceneManager)})))},a.prototype.dispose=function(){this.ownerItem=null,this.animations.forEach((function(t){t.dispose()})),this.animations=[],this.sceneManager=null},a.prototype.getTreeItem=function(){return this.ownerItem},a}(Bt),ge=function(){function t(t){this.engine=t,this.managers=[]}return t.prototype.create=function(t){var e=this;this.managers=[],t.forEach((function(t){var a=new _e(t.options,t);e.managers.push(a)}))},t.prototype.insert=function(t){this.managers.push(t)},t.prototype.delete=function(t){var e=-1;this.managers.forEach((function(a,n){a===t&&(e=n)})),e>=0&&this.managers.splice(e,1)},t.prototype.dispose=function(){this.managers.forEach((function(t){t.dispose()})),this.managers=[]},t}(),ye={"animation.vert.glsl":"#ifdef HAS_TARGET_POSITION0\nvsIn vec3 a_Target_Position0;\n#endif\n#ifdef HAS_TARGET_POSITION1\nvsIn vec3 a_Target_Position1;\n#endif\n#ifdef HAS_TARGET_POSITION2\nvsIn vec3 a_Target_Position2;\n#endif\n#ifdef HAS_TARGET_POSITION3\nvsIn vec3 a_Target_Position3;\n#endif\n#ifdef HAS_TARGET_POSITION4\nvsIn vec3 a_Target_Position4;\n#endif\n#ifdef HAS_TARGET_POSITION5\nvsIn vec3 a_Target_Position5;\n#endif\n#ifdef HAS_TARGET_POSITION6\nvsIn vec3 a_Target_Position6;\n#endif\n#ifdef HAS_TARGET_POSITION7\nvsIn vec3 a_Target_Position7;\n#endif\n#ifdef HAS_TARGET_NORMAL0\nvsIn vec3 a_Target_Normal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nvsIn vec3 a_Target_Normal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nvsIn vec3 a_Target_Normal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nvsIn vec3 a_Target_Normal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nvsIn vec3 a_Target_Normal4;\n#endif\n#ifdef HAS_TARGET_TANGENT0\nvsIn vec3 a_Target_Tangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\nvsIn vec3 a_Target_Tangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\nvsIn vec3 a_Target_Tangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\nvsIn vec3 a_Target_Tangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\nvsIn vec3 a_Target_Tangent4;\n#endif\n#ifdef USE_MORPHING\nuniform float u_morphWeights[WEIGHT_COUNT];\n#endif\n#ifdef HAS_JOINT_SET1\nvsIn vec4 a_Joint1;\n#endif\n#ifdef HAS_JOINT_SET2\nvsIn vec4 a_Joint2;\n#endif\n#ifdef HAS_WEIGHT_SET1\nvsIn vec4 a_Weight1;\n#endif\n#ifdef HAS_WEIGHT_SET2\nvsIn vec4 a_Weight2;\n#endif\n#ifdef USE_SKINNING\n#ifdef USE_SKINNING_TEXTURE\nuniform sampler2D u_jointMatrixSampler;uniform sampler2D u_jointNormalMatrixSampler;\n#else\nuniform mat4 u_jointMatrix[JOINT_COUNT];uniform mat4 u_jointNormalMatrix[JOINT_COUNT];\n#endif\n#endif\n#define ROW0_U ((0.5 + 0.0) / 4.0)\n#define ROW1_U ((0.5 + 1.0) / 4.0)\n#define ROW2_U ((0.5 + 2.0) / 4.0)\n#define ROW3_U ((0.5 + 3.0) / 4.0)\n#ifdef USE_SKINNING\nmat4 getJointMatrix(float boneNdx){\n#ifdef USE_SKINNING_TEXTURE\nfloat v=(boneNdx+0.5)/float(JOINT_COUNT);return mat4(texture2D(u_jointMatrixSampler,vec2(ROW0_U,v)),texture2D(u_jointMatrixSampler,vec2(ROW1_U,v)),texture2D(u_jointMatrixSampler,vec2(ROW2_U,v)),texture2D(u_jointMatrixSampler,vec2(ROW3_U,v)));\n#else\nreturn u_jointMatrix[int(boneNdx)];\n#endif\n}mat4 getJointNormalMatrix(float boneNdx){\n#ifdef USE_SKINNING_TEXTURE\nfloat v=(boneNdx+0.5)/float(JOINT_COUNT);return mat4(texture2D(u_jointNormalMatrixSampler,vec2(ROW0_U,v)),texture2D(u_jointNormalMatrixSampler,vec2(ROW1_U,v)),texture2D(u_jointNormalMatrixSampler,vec2(ROW2_U,v)),texture2D(u_jointNormalMatrixSampler,vec2(ROW3_U,v)));\n#else\nreturn u_jointNormalMatrix[int(boneNdx)];\n#endif\n}mat4 getSkinningMatrix(){mat4 skin=mat4(0);\n#if defined(HAS_WEIGHT_SET1) && defined(HAS_JOINT_SET1)\nskin+=a_Weight1.x*getJointMatrix(a_Joint1.x)+a_Weight1.y*getJointMatrix(a_Joint1.y)+a_Weight1.z*getJointMatrix(a_Joint1.z)+a_Weight1.w*getJointMatrix(a_Joint1.w);\n#endif\nreturn skin;}mat4 getSkinningNormalMatrix(){mat4 skin=mat4(0);\n#if defined(HAS_WEIGHT_SET1) && defined(HAS_JOINT_SET1)\nskin+=a_Weight1.x*getJointNormalMatrix(a_Joint1.x)+a_Weight1.y*getJointNormalMatrix(a_Joint1.y)+a_Weight1.z*getJointNormalMatrix(a_Joint1.z)+a_Weight1.w*getJointNormalMatrix(a_Joint1.w);\n#endif\nreturn skin;}\n#endif\n#ifdef USE_MORPHING\nvec4 getTargetPosition(){vec4 pos=vec4(0);\n#ifdef HAS_TARGET_POSITION0\npos.xyz+=u_morphWeights[0]*a_Target_Position0;\n#endif\n#ifdef HAS_TARGET_POSITION1\npos.xyz+=u_morphWeights[1]*a_Target_Position1;\n#endif\n#ifdef HAS_TARGET_POSITION2\npos.xyz+=u_morphWeights[2]*a_Target_Position2;\n#endif\n#ifdef HAS_TARGET_POSITION3\npos.xyz+=u_morphWeights[3]*a_Target_Position3;\n#endif\n#ifdef HAS_TARGET_POSITION4\npos.xyz+=u_morphWeights[4]*a_Target_Position4;\n#endif\nreturn pos;}vec4 getTargetNormal(){vec4 normal=vec4(0);\n#ifdef HAS_TARGET_NORMAL0\nnormal.xyz+=u_morphWeights[0]*a_Target_Normal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nnormal.xyz+=u_morphWeights[1]*a_Target_Normal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nnormal.xyz+=u_morphWeights[2]*a_Target_Normal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nnormal.xyz+=u_morphWeights[3]*a_Target_Normal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nnormal.xyz+=u_morphWeights[4]*a_Target_Normal4;\n#endif\nreturn normal;}vec4 getTargetTangent(){vec4 tangent=vec4(0);\n#ifdef HAS_TARGET_TANGENT0\ntangent.xyz+=u_morphWeights[0]*a_Target_Tangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\ntangent.xyz+=u_morphWeights[1]*a_Target_Tangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\ntangent.xyz+=u_morphWeights[2]*a_Target_Tangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\ntangent.xyz+=u_morphWeights[3]*a_Target_Tangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\ntangent.xyz+=u_morphWeights[4]*a_Target_Tangent4;\n#endif\nreturn tangent;}\n#endif\n","extensions.frag.glsl":"vec3 _dFdx(vec3 coord){\n#if defined(GL_OES_standard_derivatives) || defined(WEBGL2)\nreturn dFdx(coord);\n#endif\nreturn vec3(0.0);}vec3 _dFdy(vec3 coord){\n#if defined(GL_OES_standard_derivatives) || defined(WEBGL2)\nreturn dFdy(coord);\n#endif\nreturn vec3(0.0);}\n#ifdef USE_TEX_LOD\nvec4 _textureCubeLodEXT(samplerCube sampler,vec3 coord,float lod){\n#if defined(WEBGL2) || defined(GL_EXT_shader_texture_lod)\nreturn textureCubeLodEXT(sampler,coord,lod);\n#else\nreturn textureCube(sampler,coord,lod);\n#endif\n}\n#endif\n","tonemapping.frag.glsl":"uniform float u_Exposure;const float GAMMA=2.2;const float INV_GAMMA=1.0/GAMMA;vec3 LINEARtoSRGB(vec3 color){return pow(color,vec3(INV_GAMMA));}vec4 SRGBtoLINEAR(vec4 srgbIn){return vec4(pow(srgbIn.xyz,vec3(GAMMA)),srgbIn.w);}vec3 toneMapUncharted2Impl(vec3 color){const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;return((color*(A*color+C*B)+D*E)/(color*(A*color+B)+D*F))-E/F;}vec3 toneMapUncharted(vec3 color){const float W=11.2;color=toneMapUncharted2Impl(color*2.0);vec3 whiteScale=1.0/toneMapUncharted2Impl(vec3(W));return LINEARtoSRGB(color*whiteScale);}vec3 toneMapHejlRichard(vec3 color){color=max(vec3(0.0),color-vec3(0.004));return(color*(6.2*color+.5))/(color*(6.2*color+1.7)+0.06);}vec3 toneMapACES(vec3 color){const float A=2.51;const float B=0.03;const float C=2.43;const float D=0.59;const float E=0.14;return LINEARtoSRGB(clamp((color*(A*color+B))/(color*(C*color+D)+E),0.0,1.0));}vec3 toneMap(vec3 color){color*=u_Exposure;\n#ifdef TONEMAP_UNCHARTED\nreturn toneMapUncharted(color);\n#endif\n#ifdef TONEMAP_HEJLRICHARD\nreturn toneMapHejlRichard(color);\n#endif\n#ifdef TONEMAP_ACES\nreturn toneMapACES(color);\n#endif\nreturn LINEARtoSRGB(color);}","textures.vert.glsl":"fsIn vec2 v_UVCoord1;fsIn vec2 v_UVCoord2;\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D u_NormalSampler;uniform float u_NormalScale;uniform int u_NormalUVSet;uniform mat3 u_NormalUVTransform;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D u_EmissiveSampler;uniform int u_EmissiveUVSet;uniform vec3 u_EmissiveFactor;uniform mat3 u_EmissiveUVTransform;\n#endif\n#ifdef HAS_EMISSIVE\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_OCCLUSION_MAP\nuniform sampler2D u_OcclusionSampler;uniform int u_OcclusionUVSet;uniform float u_OcclusionStrength;uniform mat3 u_OcclusionUVTransform;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nuniform sampler2D u_BaseColorSampler;uniform int u_BaseColorUVSet;uniform mat3 u_BaseColorUVTransform;\n#endif\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nuniform sampler2D u_MetallicRoughnessSampler;uniform int u_MetallicRoughnessUVSet;uniform mat3 u_MetallicRoughnessUVTransform;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D u_DiffuseSampler;uniform int u_DiffuseUVSet;uniform mat3 u_DiffuseUVTransform;\n#endif\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nuniform sampler2D u_SpecularGlossinessSampler;uniform int u_SpecularGlossinessUVSet;uniform mat3 u_SpecularGlossinessUVTransform;\n#endif\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;uniform samplerCube u_SpecularEnvSampler;uniform sampler2D u_brdfLUT;uniform vec2 u_IblIntensity;\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients u_shCoefficients;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform sampler2D u_ShadowSampler;\n#endif\nvec2 getNormalUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_NORMAL_MAP\nuv.xy=u_NormalUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_NORMAL_UV_TRANSFORM\nuv*=u_NormalUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getEmissiveUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_EMISSIVE_MAP\nuv.xy=u_EmissiveUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_EMISSIVE_UV_TRANSFORM\nuv*=u_EmissiveUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getOcclusionUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_OCCLUSION_MAP\nuv.xy=u_OcclusionUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_OCCLUSION_UV_TRANSFORM\nuv*=u_OcclusionUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getBaseColorUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_BASE_COLOR_MAP\nuv.xy=u_BaseColorUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_BASECOLOR_UV_TRANSFORM\nuv*=u_BaseColorUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getMetallicRoughnessUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nuv.xy=u_MetallicRoughnessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_METALLICROUGHNESS_UV_TRANSFORM\nuv*=u_MetallicRoughnessUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getSpecularGlossinessUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nuv.xy=u_SpecularGlossinessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_SPECULARGLOSSINESS_UV_TRANSFORM\nuv*=u_SpecularGlossinessUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getDiffuseUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_DIFFUSE_MAP\nuv.xy=u_DiffuseUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#ifdef HAS_DIFFUSE_UV_TRANSFORM\nuv*=u_DiffuseUVTransform;\n#endif\n#endif\nreturn uv.xy;}","functions.frag.glsl":"const float M_PI=3.141592653589793;const float c_MinReflectance=0.04;fsIn vec3 v_Position;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nfsIn mat3 v_TBN;\n#else\nfsIn vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nfsIn vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nfsIn vec4 v_Color;\n#endif\nstruct AngularInfo{float NdotL;float NdotV;float NdotH;float LdotH;float VdotH;vec3 padding;};vec4 getVertexColor(){vec4 color=vec4(1.0,1.0,1.0,1.0);\n#ifdef HAS_VERTEX_COLOR_VEC3\ncolor.rgb=v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\ncolor=v_Color;\n#endif\nreturn color;}vec3 getNormal(){vec2 UV=getNormalUV();\n#ifndef HAS_TANGENTS\nvec3 pos_dx=_dFdx(v_Position);vec3 pos_dy=_dFdy(v_Position);vec3 tex_dx=_dFdx(vec3(UV,0.0));vec3 tex_dy=_dFdy(vec3(UV,0.0));vec3 t=(tex_dy.t*pos_dx-tex_dx.t*pos_dy)/(tex_dx.s*tex_dy.t-tex_dy.s*tex_dx.t);\n#ifdef HAS_NORMALS\nvec3 ng=normalize(v_Normal);\n#else\nvec3 ng=cross(pos_dx,pos_dy);\n#endif\nt=normalize(t-ng*dot(ng,t));vec3 b=normalize(cross(ng,t));mat3 tbn=mat3(t,b,ng);\n#else\nmat3 tbn=v_TBN;\n#endif\n#ifdef HAS_NORMAL_MAP\nvec3 n=texture2D(u_NormalSampler,UV).rgb;n=normalize(tbn*((2.0*n-1.0)*vec3(u_NormalScale,u_NormalScale,1.0)));\n#else\nvec3 n=normalize(tbn[2].xyz);\n#endif\n#ifdef DOUBLE_SIDED\nfloat faceDirection=gl_FrontFacing ? 1.0 :-1.0;n=n*faceDirection;\n#endif\nreturn n;}float getPerceivedBrightness(vec3 vector){return sqrt(0.299*vector.r*vector.r+0.587*vector.g*vector.g+0.114*vector.b*vector.b);}float solveMetallic(vec3 diffuse,vec3 specular,float oneMinusSpecularStrength){float specularBrightness=getPerceivedBrightness(specular);if(specularBrightness<c_MinReflectance){return 0.0;}float diffuseBrightness=getPerceivedBrightness(diffuse);float a=c_MinReflectance;float b=diffuseBrightness*oneMinusSpecularStrength/(1.0-c_MinReflectance)+specularBrightness-2.0*c_MinReflectance;float c=c_MinReflectance-specularBrightness;float D=b*b-4.0*a*c;return clamp((-b+sqrt(D))/(2.0*a),0.0,1.0);}AngularInfo getAngularInfo(vec3 pointToLight,vec3 normal,vec3 view){vec3 n=normalize(normal);vec3 v=normalize(view);vec3 l=normalize(pointToLight);vec3 h=normalize(l+v);float NdotL=clamp(dot(n,l),0.0,1.0);float NdotV=clamp(dot(n,v),0.0,1.0);float NdotH=clamp(dot(n,h),0.0,1.0);float LdotH=clamp(dot(l,h),0.0,1.0);float VdotH=clamp(dot(v,h),0.0,1.0);return AngularInfo(NdotL,NdotV,NdotH,LdotH,VdotH,vec3(0,0,0));}float getAARoughnessFactor(vec3 normal){vec3 dxy=max(abs(_dFdx(normal)),abs(_dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z)*2.0;}\n#ifdef DEBUG_UV\nuniform float u_DebugUVGridSize;float getDebugUVColor(vec2 uv,vec3 n){float s=dot(abs(n),vec3(1,1,1))*0.6;uv=uv/(u_DebugUVGridSize*2.0);uv=uv-floor(uv);uv=uv*2.0-vec2(1.0);return s*(uv.x*uv.y>=0.0 ? 0.2: 1.0);}\n#endif\n","shadow.frag.glsl":"#ifdef USE_SHADOW_MAPPING\nuniform vec2 u_ShadowMapSizeInv;fsIn vec4 v_PositionLightSpace;fsIn vec4 v_dPositionLightSpace;\n#endif\nfloat linstep(float low,float high,float v){return clamp((v-low)/(high-low),0.0,1.0);}\n#ifdef USE_SHADOW_MAPPING\nfloat chebyshev(vec2 moments,float depth,float minVar){float p=step(depth,moments.x+SHADOWMAP_BAIS);float variance=max(moments.y-moments.x*moments.x,minVar);float d=depth-(moments.x+SHADOWMAP_BAIS);float pMax=linstep(0.2,1.0,variance/(variance+d*d));return mix(0.1,1.0,min(max(p,pMax),1.0));}float getShadowContributionSM(){vec3 coords=v_PositionLightSpace.xyz/v_PositionLightSpace.w*0.5+0.5;if(coords.z<0.01||coords.z>0.99||coords.x<0.01||coords.x>0.99||coords.y<0.01||coords.y>0.99){return 1.0;}vec2 moments=vec2(1.0)-texture2D(u_ShadowSampler,coords.xy).xy;return coords.z<moments.x*1.008+0.008? 1.0: 0.2;}float getShadowContributionVSM(){vec3 coords=v_PositionLightSpace.xyz/v_PositionLightSpace.w*0.5+0.5;if(coords.z<0.01||coords.z>0.99||coords.x<0.01||coords.x>0.99||coords.y<0.01||coords.y>0.99){return 1.0;}vec2 moments=vec2(1.0)-texture2D(u_ShadowSampler,coords.xy).xy;return chebyshev(moments,coords.z,0.00002);}float computeEVSMShadow(vec2 coords,float pos,float neg){vec4 moments=texture2D(u_ShadowSampler,coords);float posShadow=chebyshev(moments.xy,pos,0.00002);float negShadow=chebyshev(moments.zw,neg,0.00002);return min(posShadow,negShadow);}float getShadowContributionEVSM(){vec3 coords=v_PositionLightSpace.xyz/v_PositionLightSpace.w*0.5+0.5;if(coords.z<0.01||coords.z>0.99||coords.x<0.01||coords.x>0.99||coords.y<0.01||coords.y>0.99){return 1.0;}float depth=coords.z;float pos=EVSM_FUNC0(depth);float neg=EVSM_FUNC1(depth);\n#ifdef SHADOWMAP_EVSM_PCF\nvec2 newCoords=v_dPositionLightSpace.xy/v_dPositionLightSpace.w*0.5+0.5;vec2 dCoords=min(abs(newCoords-coords.xy),u_ShadowMapSizeInv);if(max(dCoords.x,dCoords.y)>=min(u_ShadowMapSizeInv.x,u_ShadowMapSizeInv.y)*0.5){vec2 coords0=coords.xy+vec2(-1.0,-1.0)*dCoords;vec2 coords1=coords.xy+vec2(-1.0,1.0)*dCoords;vec2 coords2=coords.xy+vec2(1.0,-1.0)*dCoords;vec2 coords3=coords.xy+vec2(1.0,1.0)*dCoords;float shadow0=computeEVSMShadow(coords0,pos,neg);float shadow1=computeEVSMShadow(coords1,pos,neg);float shadow2=computeEVSMShadow(coords2,pos,neg);float shadow3=computeEVSMShadow(coords3,pos,neg);return(shadow0+shadow1+shadow2+shadow3)*0.25;}else{return computeEVSMShadow(coords.xy,pos,neg);}\n#else\nreturn computeEVSMShadow(coords.xy,pos,neg);\n#endif\n}float getShadowContribution(){\n#if defined(SHADOWMAP_STANDARD)\nreturn getShadowContributionSM();\n#elif defined(SHADOWMAP_VSM)\nreturn getShadowContributionVSM();\n#else\nreturn getShadowContributionEVSM();\n#endif\n}\n#endif\n","webglCompatibility.glsl":"#ifdef WEBGL2\n#define vsIn in\n#define vsOut out\n#define fsIn in\n#define fsOut out\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\n#else\n#define vsIn attribute\n#define vsOut varying\n#define fsIn varying\n#define fsOut varying\n#endif\n","shadowCommon.vert.glsl":"\n#define SHADOWMAP_BAIS 0.001\n#define EVSM_FUNC0(DEPTH) -exp(-7.0 * DEPTH)\n#define EVSM_FUNC1(DEPTH) -exp(-6.0 * DEPTH)\n"};!function(t){t.build=function(t,e,a){for(var n;null!==(n=/#include <(.+)>/gm.exec(t));)t=t.replace(n[0],ye[n[1]]);return t=t.replace(/#define FEATURES/,e.map((function(t){return"#define ".concat(t)})).join("\n")),a?"#version 300 es\n"+t:"#version 100\n"+t}}(he||(he={}));var ve=function(){function e(){}return e.getVertexShaderCode=function(e){var a=e.isWebGL2,n=e.featureList,r=e.material.materialType;switch(r){case t.PMaterialType.unlit:case t.PMaterialType.pbr:case t.PMaterialType.shadowBase:return he.build("precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\n#include <animation.vert.glsl>\nvsIn vec4 a_Position;vsOut vec3 v_Position;\n#ifdef HAS_NORMALS\nvsIn vec4 a_Normal;\n#endif\n#ifdef HAS_TANGENTS\nvsIn vec4 a_Tangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvsOut mat3 v_TBN;\n#else\nvsOut vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nvsIn vec2 a_UV1;\n#endif\n#ifdef HAS_UV_SET2\nvsIn vec2 a_UV2;\n#endif\nvsOut vec2 v_UVCoord1;vsOut vec2 v_UVCoord2;\n#ifdef HAS_VERTEX_COLOR_VEC3\nvsIn vec3 a_Color;vsOut vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nvsIn vec4 a_Color;vsOut vec4 v_Color;\n#endif\nuniform mat4 u_ViewProjectionMatrix;uniform mat4 u_ModelMatrix;uniform mat4 u_NormalMatrix;\n#ifdef EDITOR_TRANSFORM\nuniform vec4 uEditorTransform;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform mat4 u_LightViewProjectionMatrix;uniform float u_DeltaSceneSize;vsOut vec4 v_PositionLightSpace;vsOut vec4 v_dPositionLightSpace;\n#endif\nvec4 getPosition(){vec4 pos=vec4(a_Position.xyz,1.0);\n#ifdef USE_MORPHING\npos+=getTargetPosition();\n#endif\n#ifdef USE_SKINNING\npos=getSkinningMatrix()*pos;\n#endif\nreturn pos;}\n#ifdef HAS_NORMALS\nvec4 getNormal(){vec4 normal=a_Normal;\n#ifdef USE_MORPHING\nnormal+=getTargetNormal();\n#endif\n#ifdef USE_SKINNING\nnormal=getSkinningNormalMatrix()*normal;\n#endif\nreturn normalize(normal);}\n#endif\n#ifdef HAS_TANGENTS\nvec4 getTangent(){vec4 tangent=a_Tangent;\n#ifdef USE_MORPHING\ntangent+=getTargetTangent();\n#endif\n#ifdef USE_SKINNING\ntangent=getSkinningMatrix()*tangent;\n#endif\nreturn normalize(tangent);}\n#endif\nvoid main(){vec4 pos=u_ModelMatrix*getPosition();v_Position=vec3(pos.xyz)/pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec4 tangent=getTangent();vec3 normalW=normalize(vec3(u_NormalMatrix*vec4(getNormal().xyz,0.0)));vec3 tangentW=normalize(vec3(u_ModelMatrix*vec4(tangent.xyz,0.0)));vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\n#else\nv_Normal=normalize(vec3(u_NormalMatrix*vec4(getNormal().xyz,0.0)));\n#endif\n#endif\nv_UVCoord1=vec2(0.0,0.0);v_UVCoord2=vec2(0.0,0.0);\n#ifdef HAS_UV_SET1\nv_UVCoord1=a_UV1;\n#endif\n#ifdef HAS_UV_SET2\nv_UVCoord2=a_UV2;\n#endif\n#if defined(HAS_VERTEX_COLOR_VEC3) || defined(HAS_VERTEX_COLOR_VEC4)\nv_Color=a_Color;\n#endif\n#ifdef USE_SHADOW_MAPPING\nv_PositionLightSpace=u_LightViewProjectionMatrix*pos;vec3 dpos=vec3(u_DeltaSceneSize);v_dPositionLightSpace=u_LightViewProjectionMatrix*(pos+vec4(dpos,0));\n#endif\ngl_Position=u_ViewProjectionMatrix*pos;\n#ifdef EDITOR_TRANSFORM\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}",n,a);case t.PMaterialType.skyboxFilter:return he.build("precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\nvsIn vec3 a_Position;vsOut vec3 v_CameraDir;uniform mat4 u_InvViewProjectionMatrix;void main(){vec4 dir=u_InvViewProjectionMatrix*vec4(a_Position.xy,1,1);v_CameraDir=normalize(dir.xyz/dir.w);gl_Position=vec4(a_Position.xy,0.99999,1);}",n,a);default:throw new Error("Invalid material type ".concat(r," for getVertexShaderString!"))}},e.getFragmentShaderCode=function(e){var a=e.isWebGL2,n=e.featureList,r=e.material.materialType;switch(r){case t.PMaterialType.unlit:case t.PMaterialType.pbr:return he.build("\n#define FEATURES\n#ifndef WEBGL2\n#extension GL_OES_standard_derivatives : enable\n#endif\n#if !defined(WEBGL2) && defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef USE_HDR\n#extension GL_OES_texture_float : enable\n#extension GL_OES_texture_float_linear : enable\n#endif\n#if !defined(WEBGL2) && defined(USE_WBOIT)\n#extension GL_EXT_draw_buffers: require\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\n#ifdef USE_WBOIT\nlayout(location=0)out vec4 outFragColor0;layout(location=1)out vec4 outFragColor1;\n#else\nout vec4 outFragColor;\n#endif\n#else\n#ifdef USE_WBOIT\n#define outFragColor0 gl_FragData[0]\n#define outFragColor1 gl_FragData[1]\n#else\n#define outFragColor gl_FragColor\n#endif\n#endif\n#include <webglCompatibility.glsl>\n#include <extensions.frag.glsl>\n#include <tonemapping.frag.glsl>\n#include <textures.vert.glsl>\n#include <functions.frag.glsl>\n#include <shadowCommon.vert.glsl>\n#include <shadow.frag.glsl>\nstruct Light{vec3 direction;float range;vec3 color;float intensity;vec3 position;float innerConeCos;float outerConeCos;int type;vec2 padding;};const int LightType_Directional=0;const int LightType_Point=1;const int LightType_Spot=2;const int LightType_Ambient=3;\n#ifdef USE_PUNCTUAL\nuniform Light u_Lights[LIGHT_COUNT];\n#endif\n#if defined(MATERIAL_SPECULARGLOSSINESS) || defined(MATERIAL_METALLICROUGHNESS)\nuniform float u_MetallicFactor;uniform float u_RoughnessFactor;uniform vec4 u_BaseColorFactor;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\nuniform vec3 u_SpecularFactor;uniform vec4 u_DiffuseFactor;uniform float u_GlossinessFactor;\n#endif\n#ifdef ALPHAMODE_MASK\nuniform float u_AlphaCutoff;\n#endif\n#ifdef ADD_FOG\nuniform vec4 u_FogColor;\n#ifdef LINEAR_FOG\nuniform float u_FogNear;uniform float u_FogFar;\n#endif\n#ifdef EXP_FOG\nuniform float u_FogDensity;\n#endif\n#endif\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\nuniform vec3 u_Camera;uniform int u_MipCount;struct MaterialInfo{float perceptualRoughness;vec3 reflectance0;float alphaRoughness;vec3 diffuseColor;vec3 reflectance90;vec3 specularColor;};\n#ifdef ADD_FOG\nvec3 getMixFogColor(vec3 baseColor){vec3 distance=u_Camera-v_Position;float fogAmount=0.0;\n#ifdef LINEAR_FOG\nfogAmount=smoothstep(u_FogNear,u_FogFar,distance[2]);\n#endif\n#ifdef EXP_FOG\n#define LOG2 1.442695\nfogAmount=1.-exp2(-u_FogDensity*u_FogDensity*distance[2]*distance[2]*LOG2);fogAmount=clamp(fogAmount,0.,1.);\n#endif\nvec3 mixColor=baseColor.rgb+(vec3(u_FogColor)-baseColor.rgb)*fogAmount;return mixColor;}\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 getIrradiance(vec3 norm,SHCoefficients c){float x=norm.x;float y=norm.y;float z=norm.z;float c1=0.429043;float c2=0.511664;float c3=0.743125;float c4=0.886227;float c5=0.247708;vec3 irradiance=c1*c.l22*(x*x-y*y)+c3*c.l20*(z*z)+c4*c.l00-c5*c.l20+2.0*c1*(c.l2m2*x*y+c.l21*x*z+c.l2m1*y*z)+2.0*c2*(c.l11*x+c.l1m1*y+c.l10*z);return irradiance;}\n#endif\n#ifdef USE_IBL\nvec3 getIBLContribution(MaterialInfo materialInfo,vec3 n,vec3 v){float NdotV=clamp(dot(n,v),0.0,1.0);float lod=clamp(materialInfo.perceptualRoughness*float(u_MipCount),0.0,float(u_MipCount));vec3 reflection=normalize(reflect(-v,n));vec2 brdfSamplePoint=clamp(vec2(NdotV,materialInfo.perceptualRoughness),vec2(0.0,0.0),vec2(1.0,1.0));vec2 brdf=texture2D(u_brdfLUT,brdfSamplePoint).rg;vec4 diffuseColor=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,u_shCoefficients);diffuseColor=vec4(irradiance,1.0);\n#else\ndiffuseColor=textureCube(u_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(u_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(u_SpecularEnvSampler,reflection,lod);\n#endif\n#ifdef USE_HDR\nvec3 diffuseLight=diffuseColor.rgb;vec3 specularLight=specularSample.rgb;\n#else\nvec3 diffuseLight=SRGBtoLINEAR(diffuseColor).rgb;vec3 specularLight=SRGBtoLINEAR(specularSample).rgb;\n#endif\nvec3 diffuse=diffuseLight*materialInfo.diffuseColor;vec3 specular=specularLight*(materialInfo.specularColor*brdf.x+brdf.y);return diffuse*u_IblIntensity[0]+specular*u_IblIntensity[1];}\n#endif\nvec3 diffuse(MaterialInfo materialInfo){return materialInfo.diffuseColor/M_PI;}vec3 specularReflection(MaterialInfo materialInfo,AngularInfo angularInfo){return materialInfo.reflectance0+(materialInfo.reflectance90-materialInfo.reflectance0)*pow(clamp(1.0-angularInfo.VdotH,0.0,1.0),5.0);}float visibilityOcclusion(MaterialInfo materialInfo,AngularInfo angularInfo){float NdotL=angularInfo.NdotL;float NdotV=angularInfo.NdotV;float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGX=GGXV+GGXL;if(GGX>0.0){return 0.5/GGX;}return 0.0;}float microfacetDistribution(MaterialInfo materialInfo,AngularInfo angularInfo){float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float f=(angularInfo.NdotH*alphaRoughnessSq-angularInfo.NdotH)*angularInfo.NdotH+1.0;return alphaRoughnessSq/(M_PI*f*f);}vec3 getPointShade(vec3 pointToLight,MaterialInfo materialInfo,vec3 normal,vec3 view){AngularInfo angularInfo=getAngularInfo(pointToLight,normal,view);if(angularInfo.NdotL>0.0||angularInfo.NdotV>0.0){vec3 F=specularReflection(materialInfo,angularInfo);float Vis=visibilityOcclusion(materialInfo,angularInfo);float D=microfacetDistribution(materialInfo,angularInfo);vec3 diffuseContrib=(1.0-F)*diffuse(materialInfo);vec3 specContrib=F*Vis*D;return angularInfo.NdotL*(diffuseContrib+specContrib);}return vec3(0.0,0.0,0.0);}float getRangeAttenuation(float range,float distance){if(range<=0.0){return 1.0;}return 1.0/(pow(5.0*distance/range,2.0)+1.0);}float getSpotAttenuation(vec3 pointToLight,vec3 spotDirection,float outerConeCos,float innerConeCos){float actualCos=dot(normalize(spotDirection),normalize(-pointToLight));if(actualCos>outerConeCos){if(actualCos<innerConeCos){return smoothstep(outerConeCos,innerConeCos,actualCos);}return 1.0;}return 0.0;}vec3 applyDirectionalLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=-light.direction;vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return light.intensity*light.color*shade;}vec3 applyPointLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float attenuation=getRangeAttenuation(light.range,distance);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view);return light.color*shade*attenuation*light.intensity;}vec3 applySpotLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float rangeAttenuation=getRangeAttenuation(light.range,distance);float spotAttenuation=getSpotAttenuation(pointToLight,light.direction,light.outerConeCos,light.innerConeCos);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return rangeAttenuation*spotAttenuation*light.intensity*light.color*shade;}vec3 applyAmbientLight(Light light,MaterialInfo materialInfo){return light.intensity*light.color*diffuse(materialInfo);}float weight(float z,float a){return clamp(pow(min(1.0,a*10.0)+0.01,3.0)*1e8*pow(1.0-z*0.9,3.0),1e-2,3e3);}void writeFragmentColor(vec4 fragColor){\n#if !defined(ALPHAMODE_OPAQUE) && defined(USE_WBOIT)\nfloat w=weight(gl_FragCoord.z,fragColor.a);fragColor.rgb*=fragColor.a;outFragColor0=vec4(fragColor.rgb*w,fragColor.a);outFragColor1=vec4(fragColor.a*w);\n#else\noutFragColor=fragColor;\n#endif\n}void main(){float perceptualRoughness=0.0;float metallic=0.0;vec4 baseColor=vec4(0.0,0.0,0.0,1.0);vec3 diffuseColor=vec3(0.0);vec3 specularColor=vec3(0.0);vec3 f0=vec3(0.04);\n#ifdef PREVIEW_BORDER\nwriteFragmentColor(uPreviewColor);return;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nvec4 sgSample=SRGBtoLINEAR(texture2D(u_SpecularGlossinessSampler,getSpecularGlossinessUV()));perceptualRoughness=(1.0-sgSample.a*u_GlossinessFactor);f0=sgSample.rgb*u_SpecularFactor;\n#else\nf0=u_SpecularFactor;perceptualRoughness=1.0-u_GlossinessFactor;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nbaseColor=SRGBtoLINEAR(texture2D(u_DiffuseSampler,getDiffuseUV()))*u_DiffuseFactor;\n#else\nbaseColor=SRGBtoLINEAR(u_DiffuseFactor);\n#endif\nbaseColor*=getVertexColor();specularColor=f0;float oneMinusSpecularStrength=1.0-max(max(f0.r,f0.g),f0.b);diffuseColor=baseColor.rgb*oneMinusSpecularStrength;\n#ifdef DEBUG_METALLIC\nmetallic=solveMetallic(baseColor.rgb,specularColor,oneMinusSpecularStrength);\n#endif\n#endif\n#ifdef MATERIAL_METALLICROUGHNESS\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nvec4 mrSample=texture2D(u_MetallicRoughnessSampler,getMetallicRoughnessUV());perceptualRoughness=mrSample.g*u_RoughnessFactor;metallic=mrSample.b*u_MetallicFactor;\n#else\nmetallic=u_MetallicFactor;perceptualRoughness=u_RoughnessFactor;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nbaseColor=SRGBtoLINEAR(texture2D(u_BaseColorSampler,getBaseColorUV()))*u_BaseColorFactor;\n#else\nbaseColor=SRGBtoLINEAR(u_BaseColorFactor);\n#endif\nbaseColor*=getVertexColor();diffuseColor=baseColor.rgb*(vec3(1.0)-f0)*(1.0-metallic);specularColor=mix(f0,baseColor.rgb,metallic);\n#endif\n#ifdef ALPHAMODE_MASK\nif(baseColor.a<u_AlphaCutoff){discard;}baseColor.a=1.0;\n#endif\n#ifdef ALPHAMODE_OPAQUE\nbaseColor.a=1.0;\n#endif\n#ifdef MATERIAL_UNLIT\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec3 mixColor=getMixFogColor(baseColor.rgb);vec4 fragColorUnlit=vec4(LINEARtoSRGB(mixColor)*baseColor.a,baseColor.a);\n#else\nvec4 fragColorUnlit=vec4(LINEARtoSRGB(baseColor.rgb)*baseColor.a,baseColor.a);\n#endif\nwriteFragmentColor(fragColorUnlit);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),getNormal()));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=getNormal()*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\noutFragColor.rgb=vec3(1.0);\n#endif\n#ifdef DEBUG_EMISSIVE\noutFragColor.rgb=vec3(0.0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\nreturn;\n#endif\nmetallic=clamp(metallic,0.0,1.0);float alphaRoughness=perceptualRoughness*perceptualRoughness;vec3 normal=getNormal();\n#ifdef USE_SPECULAR_AA\nfloat AARoughnessFactor=getAARoughnessFactor(normal);perceptualRoughness+=AARoughnessFactor;alphaRoughness+=AARoughnessFactor;\n#endif\nperceptualRoughness=clamp(perceptualRoughness,0.04,1.0);alphaRoughness=clamp(alphaRoughness,0.04,1.0);float reflectance=max(max(specularColor.r,specularColor.g),specularColor.b);vec3 specularEnvironmentR0=specularColor.rgb;vec3 specularEnvironmentR90=vec3(clamp(reflectance*50.0,0.0,1.0));MaterialInfo materialInfo=MaterialInfo(perceptualRoughness,specularEnvironmentR0,alphaRoughness,diffuseColor,specularEnvironmentR90,specularColor);vec3 color=vec3(0.0,0.0,0.0);vec3 view=normalize(u_Camera-v_Position);float shadow=1.0;\n#ifdef USE_SHADOW_MAPPING\nshadow=getShadowContribution();\n#endif\n#ifdef USE_PUNCTUAL\nfor(int i=0;i<LIGHT_COUNT;++i){Light light=u_Lights[i];if(light.type==LightType_Directional){color+=applyDirectionalLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Point){color+=applyPointLight(light,materialInfo,normal,view);}else if(light.type==LightType_Spot){color+=applySpotLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Ambient){color+=applyAmbientLight(light,materialInfo);}}\n#endif\n#ifdef USE_IBL\ncolor+=getIBLContribution(materialInfo,normal,view);\n#endif\nfloat ao=1.0;\n#ifdef HAS_OCCLUSION_MAP\nao=texture2D(u_OcclusionSampler,getOcclusionUV()).r;color=mix(color,color*ao,u_OcclusionStrength);\n#endif\nvec3 emissive=vec3(0);\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec4 toneMapColor=SRGBtoLINEAR(vec4(toneMap(color),baseColor.a));color=getMixFogColor(toneMapColor.rgb);vec4 fragColorOut=vec4(LINEARtoSRGB(color.rgb)*baseColor.a,baseColor.a);\n#else\ncolor=toneMap(color)*baseColor.a;\n#ifdef HAS_EMISSIVE\ncolor+=u_EmissiveFactor;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(u_EmissiveSampler,getEmissiveUV())).rgb*u_EmissiveFactor;color+=emissive;\n#endif\nvec4 fragColorOut=vec4(color,baseColor.a);\n#endif\nwriteFragmentColor(fragColorOut);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),normal));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=normal*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\n#ifdef HAS_OCCLUSION_MAP\noutFragColor.rgb=vec3(mix(1.0,ao,u_OcclusionStrength));\n#else\noutFragColor.rgb=vec3(1.0);\n#endif\n#endif\n#ifdef DEBUG_EMISSIVE\n#ifdef HAS_EMISSIVE\nemissive=u_EmissiveFactor;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(u_EmissiveSampler,getEmissiveUV())).rgb*u_EmissiveFactor;\n#endif\noutFragColor.rgb=LINEARtoSRGB(emissive);\n#endif\n#ifdef DEBUG_F0\noutFragColor.rgb=vec3(f0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\n}",n,a);case t.PMaterialType.shadowBase:return he.build("#define FEATURES\n#include <shadowCommon.vert.glsl>\n#include <webglCompatibility.glsl>\n#if defined(SHADOWMAP_VSM) && !defined(WEBGL2)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\nout vec4 outFragColor;\n#else\n#define outFragColor gl_FragColor\n#endif\nvec4 CalcMomentVSM(float depth){float dx=0.0;float dy=0.0;\n#if defined(SHADOWMAP_VSM) && (defined(GL_OES_standard_derivatives) || defined(WEBGL2))\ndx=dFdx(depth);dy=dFdy(depth);\n#endif\nfloat moment2=depth*depth+0.25*(dx*dx+dy*dy);return vec4(1.0-depth,1.0-moment2,0.0,1.0);}vec4 CalcMomentEVSM(float depth){float pos=EVSM_FUNC0(depth);float neg=EVSM_FUNC1(depth);return vec4(pos,pos*pos,neg,neg*neg);}void main(){\n#if defined(SHADOWMAP_STANDARD) || defined(SHADOWMAP_VSM)\noutFragColor=CalcMomentVSM(gl_FragCoord.z);\n#else\noutFragColor=CalcMomentEVSM(gl_FragCoord.z);\n#endif\n}",n,a);case t.PMaterialType.skyboxFilter:return he.build("precision highp float;\n#define FEATURES\n#if !defined(WEBGL2) && defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#if !defined(WEBGL2)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#include <webglCompatibility.glsl>\n#include <extensions.frag.glsl>\n#ifdef WEBGL2\nout vec4 outFragColor;\n#else\n#define outFragColor gl_FragColor\n#endif\nuniform sampler2D u_brdfLUT;uniform vec2 u_IblIntensity;uniform int u_MipCount;uniform samplerCube u_DiffuseEnvSampler;uniform samplerCube u_SpecularEnvSampler;fsIn vec3 v_CameraDir;\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients u_shCoefficients;vec3 getIrradiance(vec3 norm,SHCoefficients c){float x=norm.x;float y=norm.y;float z=norm.z;float c1=0.429043;float c2=0.511664;float c3=0.743125;float c4=0.886227;float c5=0.247708;vec3 irradiance=c1*c.l22*(x*x-y*y)+c3*c.l20*(z*z)+c4*c.l00-c5*c.l20+2.0*c1*(c.l2m2*x*y+c.l21*x*z+c.l2m1*y*z)+2.0*c2*(c.l11*x+c.l1m1*y+c.l10*z);return irradiance;}\n#endif\nvec3 getIBLContribution(vec3 n,vec3 v){const float metallic=0.9;const float perceptualRoughness=0.1;const vec4 baseColor=vec4(1.0);const vec3 f0=vec3(0.04);const vec3 diffuseColor=baseColor.rgb*(vec3(1.0)-f0)*(1.0-metallic);const vec3 specularColor=mix(f0,baseColor.rgb,metallic);float NdotV=clamp(dot(n,v),0.0,1.0);float lod=clamp(perceptualRoughness*float(u_MipCount),0.0,float(u_MipCount));vec3 reflection=normalize(reflect(-v,n));vec2 brdfSamplePoint=clamp(vec2(NdotV,perceptualRoughness),vec2(0.0,0.0),vec2(1.0,1.0));vec2 brdf=texture2D(u_brdfLUT,brdfSamplePoint).rg;vec4 diffuseSample=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,u_shCoefficients);diffuseSample=vec4(irradiance,1.0);\n#else\ndiffuseSample=textureCube(u_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(u_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(u_SpecularEnvSampler,reflection,lod);\n#endif\nvec3 diffuseLight=diffuseSample.rgb;vec3 specularLight=specularSample.rgb;vec3 diffuse=diffuseLight*diffuseColor;vec3 specular=specularLight*(specularColor*brdf.x+brdf.y);return diffuse*u_IblIntensity[0]+specular*u_IblIntensity[1];}void main(){vec3 dir=normalize(v_CameraDir);outFragColor=vec4(getIBLContribution(dir,dir),1.0);}",n,a);default:throw new Error("Invalid material type ".concat(r," for getFragmentShaderString!"))}},e.environment="webgl1",e}();function xe(t){return{vertexShaderCode:ve.getVertexShaderCode(t),fragmentShaderCode:ve.getFragmentShaderCode(t)}}function be(t){return{vertexShaderCode:ve.getVertexShaderCode(t),fragmentShaderCode:ve.getFragmentShaderCode(t)}}function Te(t){return{vertexShaderCode:ve.getVertexShaderCode(t),fragmentShaderCode:ve.getFragmentShaderCode(t)}}function Me(t){return{vertexShaderCode:we({hasNormals:!0}),fragmentShaderCode:"\n #version 100\n precision highp float;\n varying vec3 v_Normal;\n void main(){\n gl_FragColor = vec4(v_Normal * 0.5 + 0.5, 1);\n }\n "}}function Se(t){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform sampler2D u_FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n gl_FragColor = texture2D(u_FilterSampler, v_UVCoord1) * vec4(0.5);\n }\n "}}function Ce(t){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform vec2 u_BlurScale;\n uniform sampler2D u_FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0);\n vec2 offset0 = vec2(0.53805) * u_BlurScale.xy;\n vec2 offset1 = vec2(2.06278) * u_BlurScale.xy;\n color += (texture2D(u_FilterSampler, v_UVCoord1 + offset0) + texture2D(u_FilterSampler, v_UVCoord1 - offset0)) * 0.44908;\n color += (texture2D(u_FilterSampler, v_UVCoord1 + offset1) + texture2D(u_FilterSampler, v_UVCoord1 - offset1)) * 0.05092;\n gl_FragColor = color;\n }\n "}}function we(t){void 0===t&&(t={});var e=["#version 100"];return t.hasUVs&&e.push("#define HAS_UVS 1"),t.hasNormals&&e.push("#define HAS_NORMALS 1"),e.push("\n precision highp float;\n\n uniform mat4 u_ModelMatrix;\n uniform mat4 u_ViewProjectionMatrix;\n attribute vec3 a_Position;\n varying vec3 v_Position;\n\n #ifdef HAS_UVS\n attribute vec2 a_UV1;\n varying vec2 v_UVCoord1;\n #endif\n\n #ifdef HAS_NORMALS\n uniform mat4 u_NormalMatrix;\n attribute vec3 a_Normal;\n varying vec3 v_Normal;\n #endif\n\n void main(){\n vec4 pos = u_ModelMatrix * vec4(a_Position, 1);\n v_Position = pos.xyz / pos.w;\n\n #ifdef HAS_UVS\n v_UVCoord1 = a_UV1;\n #endif\n\n #ifdef HAS_NORMALS\n v_Normal = normalize(vec3(u_ModelMatrix * vec4(a_Normal, 0)));\n #endif\n\n gl_Position = u_ViewProjectionMatrix * pos;\n }\n "),e.join("\n")}var Ae=function(){function e(){this.funcMap=new Map,this.funcMap.set(t.PMaterialType.unlit,xe),this.funcMap.set(t.PMaterialType.pbr,xe),this.funcMap.set(t.PMaterialType.shadowBase,be),this.funcMap.set(t.PMaterialType.shadowFilter,Ce),this.funcMap.set(t.PMaterialType.normalVis,Me),this.funcMap.set(t.PMaterialType.simpleFilter,Se),this.funcMap.set(t.PMaterialType.skyboxFilter,Te)}return e.getInstance=function(){return this._instance||(this._instance=new this)},e.prototype.genShaderCode=function(t){var e=t.material.materialType,a=this.funcMap.get(e);if(void 0!==a)return a(t);throw new Error("Invalid material type ".concat(e,", shader content ").concat(t))},e}(),Ie=function(a){function n(){var e=null!==a&&a.apply(this,arguments)||this;return e.materialType=t.PMaterialType.none,e.vertexShaderCode="",e.fragmentShaderCode="",e.depthMask=!0,e.depthTestHint=!0,e.blendMode=t.PBlendMode.opaque,e.alphaCutOff=.5,e.faceSideMode=t.PFaceSideMode.front,e}return r(n,a),n.prototype.getShaderFeatures=function(){var e=[];return this.isOpaque()?e.push("ALPHAMODE_OPAQUE 1"):this.isMasked()&&e.push("ALPHAMODE_MASK 1"),this.faceSideMode===t.PFaceSideMode.both&&e.push("DOUBLE_SIDED 1"),e},n.prototype.updateUniforms=function(t){if(this.isMasked()&&t.setFloat("u_AlphaCutoff",this.alphaCutOff),Rt.getInstance().renderMode3D===e.spec.RenderMode3D.uv){var a=Rt.getInstance().renderMode3DUVGridSize;t.setFloat("u_DebugUVGridSize",a)}},n.prototype.build=function(e){var a=this.getShaderFeatures();void 0!==e&&a.push.apply(a,u([],c(e),!1));var n=Rt.getInstance().isWebGL2;(n&&a.push("WEBGL2"),this.materialType!==t.PMaterialType.shadowBase)&&(Rt.getInstance().isEditorEnv&&a.push("EDITOR_TRANSFORM"));var r=Ae.getInstance().genShaderCode({material:this,isWebGL2:n,featureList:a});this.vertexShaderCode=r.vertexShaderCode,this.fragmentShaderCode=r.fragmentShaderCode},n.prototype.getBlendMode=function(a){return a===e.spec.MaterialBlending.masked?t.PBlendMode.masked:a===e.spec.MaterialBlending.translucent?t.PBlendMode.translucent:a===e.spec.MaterialBlending.additive?t.PBlendMode.additive:t.PBlendMode.opaque},n.prototype.getFaceSideMode=function(a){return a===e.spec.SideMode.DOUBLE?t.PFaceSideMode.both:a===e.spec.SideMode.BACK?t.PFaceSideMode.back:t.PFaceSideMode.front},n.prototype.setMaterialStates=function(a){this.blendMode===t.PBlendMode.translucent||this.blendMode===t.PBlendMode.additive?(a.blending=!0,a.depthTest=!0,a.blendEquation=[e.glContext.FUNC_ADD,e.glContext.FUNC_ADD],this.blendMode===t.PBlendMode.translucent?a.blendFunction=[e.glContext.ONE,e.glContext.ONE_MINUS_SRC_ALPHA,e.glContext.ONE,e.glContext.ONE_MINUS_SRC_ALPHA]:a.blendFunction=[e.glContext.ONE,e.glContext.ONE,e.glContext.ONE,e.glContext.ONE],a.depthMask=this.depthMask):Rt.getInstance().isTiny3dMode?(a.blending=!1,a.depthTest=!0,a.depthMask=!0):(a.blending=!1,a.depthTest=this.depthTestHint,a.depthMask=this.depthMask),this.setFaceSideStates(a)},n.prototype.setFaceSideStates=function(t){this.isBothFace()?t.culling=!1:this.isBackFace()?(t.cullFace=e.glContext.FRONT,t.frontFace=e.glContext.CCW,t.culling=!0):(t.cullFace=e.glContext.BACK,t.frontFace=e.glContext.CCW,t.culling=!0)},n.prototype.dispose=function(){this.vertexShaderCode="",this.fragmentShaderCode=""},n.prototype.isValid=function(){return this.materialType!==t.PMaterialType.none&&a.prototype.isValid.call(this)},n.prototype.isOpaque=function(){return this.blendMode===t.PBlendMode.opaque},n.prototype.isMasked=function(){return this.blendMode===t.PBlendMode.masked},n.prototype.isTranslucent=function(){return this.blendMode===t.PBlendMode.translucent},n.prototype.isAdditive=function(){return this.blendMode===t.PBlendMode.additive},n.prototype.requireBlend=function(){return this.blendMode===t.PBlendMode.translucent||this.blendMode===t.PBlendMode.additive},n.prototype.isFrontFace=function(){return this.faceSideMode===t.PFaceSideMode.front},n.prototype.isBackFace=function(){return this.faceSideMode===t.PFaceSideMode.back},n.prototype.isBothFace=function(){return this.faceSideMode===t.PFaceSideMode.both},n}(Bt),Ee=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.baseColorFactor=new P(1,1,1,1),t}return r(a,e),a.prototype.create=function(e){var a;this.name=e.name,this.type=t.PObjectType.material,this.materialType=t.PMaterialType.unlit,e.baseColorTexture&&(this.baseColorTexture=e.baseColorTexture),this.setBaseColorFactor($t.toPluginColor4(e.baseColorFactor)),!1===e.depthMask?this.depthMask=!1:this.depthMask=!0,this.blendMode=this.getBlendMode(e.blending),this.alphaCutOff=null!==(a=e.alphaCutOff)&&void 0!==a?a:0,this.faceSideMode=this.getFaceSideMode(e.side)},a.prototype.dispose=function(){e.prototype.dispose.call(this),this.baseColorTexture=void 0},a.prototype.getShaderFeatures=function(){var t=e.prototype.getShaderFeatures.call(this);return t.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&t.push("HAS_BASE_COLOR_MAP 1"),t.push("MATERIAL_UNLIT 1"),t},a.prototype.updateUniforms=function(t){e.prototype.updateUniforms.call(this,t);var a=V.IDENTITY.clone();t.setVector4("u_BaseColorFactor",this.baseColorFactor.toArray()),this.hasBaseColorTexture()&&(t.setTexture("u_BaseColorSampler",this.getBaseColorTexture()),t.setInt("u_BaseColorUVSet",0),t.setMatrix("u_BaseColorUVTransform",a.toArray())),t.setFloat("u_MetallicFactor",0),t.setFloat("u_RoughnessFactor",0),t.setFloat("u_Exposure",1)},a.prototype.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},a.prototype.getBaseColorTexture=function(){return this.baseColorTexture},a.prototype.setBaseColorTexture=function(t){this.baseColorTexture=t},a.prototype.getBaseColorFactor=function(){return this.baseColorFactor},a.prototype.setBaseColorFactor=function(t){t instanceof P?this.baseColorFactor.set(t.x,t.y,t.z,t.w):this.baseColorFactor.set(t[0],t[1],t[2],t[3])},a}(Ie),Pe=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.baseColorFactor=new P(1,1,1,1),t.useSpecularAA=!1,t.metallicFactor=0,t.roughnessFactor=1,t.normalTextureScale=1,t.occlusionTextureStrength=1,t.emissiveFactor=new S(0,0,0),t.emissiveIntensity=1,t.enableShadow=!1,t}return r(a,e),a.prototype.create=function(e){var a,n,r,o,i;this.name=e.name,this.type=t.PObjectType.material,this.materialType=t.PMaterialType.pbr,e.baseColorTexture&&(this.baseColorTexture=e.baseColorTexture),e.baseColorTextureTransform&&(this.baseColorTextureTrans=$t.createUVTransform(e.baseColorTextureTransform)),this.setBaseColorFactor($t.toPluginColor4(e.baseColorFactor)),e.metallicRoughnessTexture&&(this.metallicRoughnessTexture=e.metallicRoughnessTexture),e.metallicRoughnessTextureTransform&&(this.metallicRoughnessTextureTrans=$t.createUVTransform(e.metallicRoughnessTextureTransform)),this.useSpecularAA=null!==(a=e.useSpecularAA)&&void 0!==a&&a,this.metallicFactor=e.metallicFactor,this.roughnessFactor=$t.clamp(e.roughnessFactor,0,1),e.normalTexture&&(this.normalTexture=e.normalTexture),e.normalTextureTransform&&(this.normalTextureTrans=$t.createUVTransform(e.normalTextureTransform)),this.normalTextureScale=null!==(n=e.normalTextureScale)&&void 0!==n?n:1,e.occlusionTexture&&(this.occlusionTexture=e.occlusionTexture),e.occlusionTextureTransform&&(this.occlusionTextureTrans=$t.createUVTransform(e.occlusionTextureTransform)),this.occlusionTextureStrength=null!==(r=e.occlusionTextureStrength)&&void 0!==r?r:1,e.emissiveTexture&&(this.emissiveTexture=e.emissiveTexture),e.emissiveTextureTransform&&(this.emissiveTextureTrans=$t.createUVTransform(e.emissiveTextureTransform));var s=$t.toPluginColor4(e.emissiveFactor);this.emissiveFactor=S.fromArray(s),this.emissiveIntensity=e.emissiveIntensity,this.enableShadow=null!==(o=e.enableShadow)&&void 0!==o&&o,!1===e.depthMask?this.depthMask=!1:this.depthMask=!0,this.blendMode=this.getBlendMode(e.blending),this.alphaCutOff=null!==(i=e.alphaCutOff)&&void 0!==i?i:0,this.faceSideMode=this.getFaceSideMode(e.side)},a.prototype.dispose=function(){e.prototype.dispose.call(this),this.baseColorTexture=void 0,this.metallicRoughnessTexture=void 0,this.normalTexture=void 0,this.occlusionTexture=void 0,this.emissiveTexture=void 0},a.prototype.getShaderFeatures=function(){var t=e.prototype.getShaderFeatures.call(this);return t.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&(t.push("HAS_BASE_COLOR_MAP 1"),void 0!==this.baseColorTextureTrans&&t.push("HAS_BASECOLOR_UV_TRANSFORM 1")),this.hasMetallicRoughnessTexture()&&(t.push("HAS_METALLIC_ROUGHNESS_MAP 1"),void 0!==this.metallicRoughnessTextureTrans&&t.push("HAS_METALLICROUGHNESS_UV_TRANSFORM 1")),this.useSpecularAA&&t.push("USE_SPECULAR_AA 1"),this.hasNormalTexture()&&(t.push("HAS_NORMAL_MAP 1"),void 0!==this.normalTextureTrans&&t.push("HAS_NORMAL_UV_TRANSFORM 1")),this.hasOcclusionTexture()&&(t.push("HAS_OCCLUSION_MAP 1"),void 0!==this.occlusionTextureTrans&&t.push("HAS_OCCLUSION_UV_TRANSFORM 1")),this.hasEmissiveTexture()?(t.push("HAS_EMISSIVE_MAP 1"),void 0!==this.emissiveTextureTrans&&t.push("HAS_EMISSIVE_UV_TRANSFORM 1")):this.hasEmissiveFactor()&&t.push("HAS_EMISSIVE 1"),t},a.prototype.updateUniforms=function(t){e.prototype.updateUniforms.call(this,t);var a=V.IDENTITY.clone();if(t.setVector4("u_BaseColorFactor",this.baseColorFactor.toArray()),void 0!==this.baseColorTexture&&(t.setTexture("u_BaseColorSampler",this.baseColorTexture),t.setInt("u_BaseColorUVSet",0),void 0!==this.baseColorTextureTrans?t.setMatrix3("u_BaseColorUVTransform",this.baseColorTextureTrans.toArray()):t.setMatrix3("u_BaseColorUVTransform",a.toArray())),t.setFloat("u_MetallicFactor",this.metallicFactor),t.setFloat("u_RoughnessFactor",this.roughnessFactor),void 0!==this.metallicRoughnessTexture&&(t.setTexture("u_MetallicRoughnessSampler",this.metallicRoughnessTexture),t.setInt("u_MetallicRoughnessUVSet",0),void 0!==this.metallicRoughnessTextureTrans?t.setMatrix3("u_MetallicRoughnessUVTransform",this.metallicRoughnessTextureTrans.toArray()):t.setMatrix3("u_MetallicRoughnessUVTransform",a.toArray())),void 0!==this.normalTexture&&(t.setTexture("u_NormalSampler",this.normalTexture),t.setFloat("u_NormalScale",this.normalTextureScale),t.setInt("u_NormalUVSet",0),void 0!==this.normalTextureTrans?t.setMatrix3("u_NormalUVTransform",this.normalTextureTrans.toArray()):t.setMatrix3("u_NormalUVTransform",a.toArray())),void 0!==this.occlusionTexture&&(t.setTexture("u_OcclusionSampler",this.occlusionTexture),t.setFloat("u_OcclusionStrength",this.occlusionTextureStrength),t.setInt("u_OcclusionUVSet",0),void 0!==this.occlusionTextureTrans?t.setMatrix3("u_OcclusionUVTransform",this.occlusionTextureTrans.toArray()):t.setMatrix3("u_OcclusionUVTransform",a.toArray())),void 0!==this.emissiveTexture){var n=this.getEmissiveFactor();t.setTexture("u_EmissiveSampler",this.emissiveTexture),t.setVector3("u_EmissiveFactor",n.toArray()),t.setInt("u_EmissiveUVSet",0),void 0!==this.emissiveTextureTrans?t.setMatrix3("u_EmissiveUVTransform",this.emissiveTextureTrans.toArray()):t.setMatrix3("u_EmissiveUVTransform",a.toArray())}else if(this.hasEmissiveFactor()){n=this.getEmissiveFactor();t.setVector3("u_EmissiveFactor",n.toArray())}t.setFloat("u_Exposure",3)},a.prototype.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},a.prototype.hasBaseColorTextureTrans=function(){return void 0!==this.baseColorTextureTrans},a.prototype.setBaseColorTexture=function(t){this.baseColorTexture=t},a.prototype.getBaseColorFactor=function(){return this.baseColorFactor},a.prototype.setBaseColorFactor=function(t){t instanceof P?this.baseColorFactor.set(t.x,t.y,t.z,t.w):this.baseColorFactor.set(t[0],t[1],t[2],t[3])},a.prototype.hasMetallicRoughnessTexture=function(){return void 0!==this.metallicRoughnessTexture},a.prototype.hasMetallicRoughnessTextureTrans=function(){return void 0!==this.metallicRoughnessTextureTrans},a.prototype.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture},a.prototype.setMetallicRoughnessTexture=function(t){this.metallicRoughnessTexture=t},a.prototype.hasNormalTexture=function(){return void 0!==this.normalTexture},a.prototype.hasNormalTextureTrans=function(){return void 0!==this.normalTextureTrans},a.prototype.getNormalTexture=function(){return this.normalTexture},a.prototype.setNormalTexture=function(t){this.normalTexture=t},a.prototype.hasOcclusionTexture=function(){return void 0!==this.occlusionTexture},a.prototype.hasOcclusionTextureTrans=function(){return void 0!==this.occlusionTextureTrans},a.prototype.getOcclusionTexture=function(){return this.occlusionTexture},a.prototype.setOcclusionTexture=function(t){this.occlusionTexture=t},a.prototype.hasEmissiveTexture=function(){return void 0!==this.emissiveTexture},a.prototype.hasEmissiveTextureTrans=function(){return void 0!==this.emissiveTextureTrans},a.prototype.getEmissiveTexture=function(){return this.emissiveTexture},a.prototype.setEmissiveTexture=function(t){this.emissiveTexture=t},a.prototype.hasEmissiveFactor=function(){return this.emissiveFactor.sum()*this.emissiveIntensity>0},a.prototype.getEmissiveFactor=function(){return this.emissiveFactor.clone().multiplyScalar(this.emissiveIntensity)},a.prototype.setEmissiveFactor=function(t){t instanceof S?this.emissiveFactor.set(t.x,t.y,t.z):this.emissiveFactor.set(t[0],t[1],t[2])},a}(Ie);function Oe(t){if(t.type===e.spec.MaterialType.pbr){var a=new Pe;return a.create(t),a}var n=new Ee;return n.create(t),n}var Ne,Le=function(e){function a(a,n){var r=e.call(this)||this;r.renderable=!0,r.intensity=1,r.reflectionsIntensity=1,r.specularImageSize=0,r.specularMipCount=0,r.priority=0,r.isBuilt=!1,r.name=a.name,r.type=t.PObjectType.skybox,r.visible=!1,r.ownerItem=n;var o=a.content.options;return r.renderable=o.renderable,r.intensity=o.intensity,r.reflectionsIntensity=o.reflectionsIntensity,r.irradianceCoeffs=o.irradianceCoeffs,r.diffuseImage=o.diffuseImage,r.specularImage=o.specularImage,r.specularImageSize=o.specularImageSize,r.specularMipCount=o.specularMipCount,r.priority=(null==n?void 0:n.listIndex)||0,r}return r(a,e),a.prototype.setup=function(t){this.brdfLUT=t},a.prototype.build=function(t){this.isBuilt||(this.isBuilt=!0,this.skyboxMaterial=new Fe,this.skyboxMaterial.create(this),this.skyboxMaterial.build(),this.skyboxMesh=t.getFilterMesh("SkyboxFilterPlane",this.skyboxMaterial,{}),this.skyboxMesh.priority=this.priority,this.skyboxMaterial.updateUniforms(this.skyboxMesh.material))},a.prototype.dispose=function(){var t;this.diffuseImage=void 0,this.specularImage=void 0,this.brdfLUT=void 0,this.skyboxMesh=void 0,null===(t=this.skyboxMaterial)||void 0===t||t.dispose(),this.skyboxMaterial=void 0},a.prototype.addToRenderObjectSet=function(t){this.visible&&this.renderable&&void 0!==this.skyboxMesh&&t.add(this.skyboxMesh)},a.prototype.updateUniformsForScene=function(t){if(this.visible&&this.renderable&&void 0!==this.skyboxMesh&&void 0!==this.skyboxMaterial){var e=t.camera,a=t.viewMatrix,n=e.getNewProjectionMatrix(e.fovy).multiply(a).inverse(),r=this.skyboxMesh.material;this.skyboxMaterial.updateUniforms(r),r.setMatrix("u_InvViewProjectionMatrix",n.toArray())}},Object.defineProperty(a.prototype,"available",{get:function(){return!!this.isValid()&&(!(this.intensity<=0&&this.reflectionsIntensity<=0)&&((void 0!==this.irradianceCoeffs||void 0!==this.diffuseImage)&&(void 0!==this.specularImage&&this.specularMipCount>0)))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"currentIntensity",{get:function(){return this.visible?this.intensity:0},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"currentReflectionsIntensity",{get:function(){return this.visible?this.reflectionsIntensity:0},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"hasDiffuseImage",{get:function(){return void 0!==this.diffuseImage},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"hasIrradianceCoeffs",{get:function(){return void 0!==this.irradianceCoeffs},enumerable:!1,configurable:!0}),a}(Dt),Fe=function(e){function a(){var t=null!==e&&e.apply(this,arguments)||this;return t.intensity=1,t.reflectionsIntensity=1,t.specularMipCount=0,t}return r(a,e),a.prototype.create=function(e){this.type=t.PObjectType.material,this.materialType=t.PMaterialType.skyboxFilter,this.depthTestHint=!1,this.name=e.name,this.intensity=e.intensity,this.reflectionsIntensity=e.reflectionsIntensity,this.brdfLUT=e.brdfLUT,this.irradianceCoeffs=e.irradianceCoeffs,this.diffuseImage=e.diffuseImage,this.specularImage=e.specularImage,this.specularMipCount=e.specularMipCount},a.prototype.dispose=function(){e.prototype.dispose.call(this),this.brdfLUT=void 0,this.irradianceCoeffs=void 0,this.diffuseImage=void 0,this.specularImage=void 0},a.prototype.getShaderFeatures=function(){var t=[];return t.push("USE_IBL 1"),t.push("USE_TEX_LOD 1"),void 0===this.diffuseImage&&t.push("IRRADIANCE_COEFFICIENTS 1"),t},a.prototype.updateUniforms=function(t){if(void 0===this.brdfLUT)throw new Error("Setup brdfLUT for skybox at first.");if(t.setVector2("u_IblIntensity",[2,2]),t.setTexture("u_brdfLUT",this.brdfLUT),void 0!==this.diffuseImage)t.setTexture("u_DiffuseEnvSampler",this.diffuseImage);else{var e=this.irradianceCoeffs;if(void 0===e||9!=e.length)throw new Error("Invalid skybox irradiance coeffs ".concat(e));["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(a,n){t.setVector3("u_shCoefficients.".concat(a),e[n])}))}t.setInt("u_MipCount",this.specularMipCount),t.setTexture("u_SpecularEnvSampler",this.specularImage)},a.prototype.setMaterialStates=function(t){t.depthTest=!0,t.depthMask=!1,this.setFaceSideStates(t)},a}(Ie);t.PSkyboxType=void 0,(Ne=t.PSkyboxType||(t.PSkyboxType={}))[Ne.NFT=0]="NFT",Ne[Ne.FARM=1]="FARM";var Re=function(){function a(){}return a.getBrdfLutTextureOptions=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(a){switch(a.label){case 0:return"https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png",[4,e.loadImage("https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png")];case 1:return t=a.sent(),[2,{name:"brdfLut",wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR,anisotropic:1,sourceType:e.TextureSourceType.image,image:t,generateMipmap:!1,flipY:!1,premultiplyAlpha:!1}]}}))}))},a.createBrdfLutTexture=function(t){return i(this,void 0,void 0,(function(){var a;return s(this,(function(n){switch(n.label){case 0:return[4,this.getBrdfLutTextureOptions()];case 1:return a=n.sent(),[2,e.Texture.create(t,a)]}}))}))},a.createSkyboxOptions=function(t,e){return i(this,void 0,void 0,(function(){var a,n,r,o,i,c,u,d;return s(this,(function(s){switch(s.label){case 0:return[4,this.createSpecularCubeMap(t,e)];case 1:return a=s.sent(),[4,this.createDiffuseCubeMap(t,e)];case 2:return n=s.sent(),r=e.renderable,o=e.intensity,i=e.reflectionsIntensity,c=e.irradianceCoeffs,u=e.specularImageSize,d=e.specularMipCount,[2,{renderable:r,intensity:o,reflectionsIntensity:i,irradianceCoeffs:c,diffuseImage:n,specularImage:a,specularImageSize:u,specularMipCount:d}]}}))}))},a.createSpecularCubeMap=function(t,a){return i(this,void 0,void 0,(function(){return s(this,(function(n){return e.glContext.CLAMP_TO_EDGE,e.glContext.CLAMP_TO_EDGE,e.glContext.LINEAR,e.glContext.LINEAR_MIPMAP_LINEAR,"url"===a.type?[2,Qt.createTextureCubeMipmapFromURL(t,a.specularImage)]:[2,Qt.createTextureCubeMipmapFromBuffer(t,a.specularImage,a.specularImageSize)]}))}))},a.createDiffuseCubeMap=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(a){return void 0===e.diffuseImage?[2]:"url"===e.type?[2,Qt.createTextureCubeFromURL(t,e.diffuseImage)]:[2,Qt.createTextureCubeFromBuffer(t,e.diffuseImage)]}))}))},a.getSkyboxParams=function(e){void 0===e&&(e=t.PSkyboxType.NFT);var a=this.getSpecularImageList(e);return{type:"url",renderable:!0,intensity:1.8,reflectionsIntensity:1.8,irradianceCoeffs:this.getIrradianceCoeffs(e),diffuseImage:this.getDiffuseImageList(e,a),specularImage:a,specularImageSize:Math.pow(2,a.length-1),specularMipCount:a.length-1}},a.prototype.checkCubeMapImage=function(t){return i(this,void 0,void 0,(function(){var a,n,r,o;return s(this,(function(i){switch(i.label){case 0:n=[],r=0,i.label=1;case 1:return r<t.length?[4,e.loadImage(t[r])]:[3,4];case 2:if(o=i.sent(),r>0)if(r%6==0){if(2*o.width!==a.width||2*o.height!==a.height)throw new Error("Invalid cube map list1: index ".concat(r,", image0 ").concat(a,", image1 ").concat(o))}else if(o.width!==a.width||o.height!==a.height)throw new Error("Invalid cube map list2: index ".concat(r,", image0 ").concat(a,", image1 ").concat(o));r%6==0&&n.push([]),n[n.length-1].push(o),a=o,i.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}))},a.getIrradianceCoeffs=function(e){var a=[];switch(e){case t.PSkyboxType.NFT:return;case t.PSkyboxType.FARM:a=[.2665672302246094,.27008703351020813,.2836797833442688,-.15421263873577118,-.15587495267391205,-.16371899843215942,.06483837962150574,.06468029320240021,.06616337597370148,-.11598809063434601,-.11796595901250839,-.1261979341506958,.023678265511989594,.02456280030310154,.02591511607170105,-.032404184341430664,-.03217344358563423,-.03126845508813858,.009165619499981403,.009345818310976028,.008521141484379768,-.021998587995767593,-.02203795686364174,-.021759089082479477,.00046658870996907353,.0005610908847302198,.0007202711421996355];break;default:a=[.3746267259120941,.3523011803627014,.33955901861190796,.12082185596227646,.18179306387901306,.26912716031074524,-.020699946209788322,-.004648427478969097,.00797625258564949,-.06842170655727386,-.05139023810625076,-.03317255899310112,.044127799570560455,.028159862384200096,.007428745273500681,.07887077331542969,.06773484498262405,.04738233983516693,-.012322401627898216,-.015187464654445648,-.02020176313817501,-.1091032400727272,-.0823250338435173,-.046844951808452606,-.05779704451560974,-.06689254194498062,-.08212742954492569]}for(var n=[],r=0;r<a.length;r+=3)n.push([a[r],a[r+1],a[r+2]]);return n},a.getDiffuseImageList=function(e,a){if(e==t.PSkyboxType.NFT)return a[a.length-1]},a.getSpecularImageList=function(e){var a=[];if(e===t.PSkyboxType.FARM)a.push.apply(a,u([],c(this.getSpecularImageListAntFarm()),!1));else a.push.apply(a,u([],c(this.getSpecularImageListNFT()),!1));var n=[];return a.forEach((function(t,e){e%6==0&&n.push([]),n[n.length-1].push(t)})),n},a.getSpecularImageListNFT=function(){return["https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img0.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img1.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img2.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img3.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img5.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img4.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img6.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img7.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img8.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img9.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img11.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img10.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img12.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img13.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img14.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img15.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img17.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img16.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img18.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img19.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img20.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img21.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img23.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img22.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img24.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img25.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img26.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img27.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img29.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img28.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img30.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img31.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img32.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img33.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img35.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img34.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img36.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img37.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img38.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img39.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img41.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img40.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img42.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img43.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img44.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img45.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img47.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img46.png"]},a.getSpecularImageListAntFarm=function(){return["https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_5.png"]},a}(),ze=function(){function t(t){this.engine=t,this.loadSkybox=!1,this.meshCache=new Map,this.textureCache=new Map,this.geometryCache=new Map,this.renderPassCache=new Map}return t.loadStaticResources=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return void 0!==this.brdfLutTexOptions?[2]:(t=this,[4,Re.getBrdfLutTextureOptions()]);case 1:return t.brdfLutTexOptions=e.sent(),[2]}}))}))},t.genSkyboxOptions=function(e,a){return i(this,void 0,void 0,(function(){var n,r;return s(this,(function(o){switch(o.label){case 0:return void 0===(n=a)&&(n=Re.getSkyboxParams()),r=t,[4,Re.createSkyboxOptions(e,n)];case 1:return r.skyboxOptions=o.sent(),[2,t.skyboxOptions]}}))}))},t.prototype.setup=function(a){if(this.loadSkybox=a,void 0===this.brdfLutTexture||this.brdfLutTexture.isDestroyed){if(void 0===t.brdfLutTexOptions)throw new Error("Please load brdfLutTexOptions at first");var n="brdfLutTexture";this.brdfLutTexture=e.Texture.create(this.engine,t.brdfLutTexOptions),this.deleteTexture(n),this.setTexture(n,this.brdfLutTexture)}},t.prototype.getTexture=function(t){return this.textureCache.get(t)},t.prototype.setTexture=function(t,e){this.textureCache.set(t,e)},t.prototype.getOrCreateTexture=function(t,a){var n=this.textureCache.get(t);if(void 0!==n)return n;var r=e.Texture.create(this.engine,a);return this.textureCache.set(t,r),r},t.prototype.deleteTexture=function(t){var e=this.textureCache.get(t);return void 0!==e&&e.dispose(),this.textureCache.delete(t)},t.prototype.getOrCreateGeometry=function(t,e,a){var n=this.geometryCache.get(t);if(void 0!==n)return n;var r=$t.createGeometry(this.engine,e,a);return this.geometryCache.set(t,r),r},t.prototype.getFilterMesh=function(t,e,a){var n=this.meshCache.get(t);if(void 0!==n)return n;var r=Kt.createFilterMesh(this.engine,t,e,a);return this.meshCache.set(t,r),r},t.prototype.getShadowBasePass=function(t,e,a,n){return this.getRenderPass(t,e,a,n)},t.prototype.getShadowFilterPass=function(t,e,a,n){return this.getRenderPass(t,e,a,n)},t.prototype.getRenderPass=function(t,e,a,n){var r=this.renderPassCache.get(t);if(void 0!==r)return r.setMeshes([]),a.forEach((function(t){r.addMesh(t)})),r;var o=this.engine.renderer,i=Qt.createRenderPass(o,t,e,a,n);return this.renderPassCache.set(t,i),i},t.prototype.dispose=function(){this.engine=null,this.brdfLutTexture=void 0,this.meshCache.forEach((function(t){Qt.deleteMesh(t)})),this.meshCache.clear(),this.textureCache.forEach((function(t){Qt.deleteTexture(t)})),this.textureCache.clear(),this.geometryCache.forEach((function(t){Qt.deleteGeometry(t)})),this.geometryCache.clear(),this.renderPassCache.forEach((function(t){Qt.deleteRenderPass(t)})),this.renderPassCache.clear()},t.prototype.getRenderPasses=function(){var t=[];return this.renderPassCache.forEach((function(e){t.push(e)})),t},t.prototype.getBrdfLutTexture=function(){return this.brdfLutTexture},t.prototype.getSkyboxOptions=function(){return t.skyboxOptions},t}(),Be=Math.PI/180,De=function(a){function n(n,r,o,i){var s,c=a.call(this)||this;c.width=512,c.height=512,c.nearPlane=.001,c.farPlane=1e3,c.fovy=45,c.aspect=1,c.clipMode=e.spec.CameraClipMode.landscape,c.projectionMatrix=new ct,c.viewMatrix=new ct,c.name=n.name,c.type=t.PObjectType.camera,c.visible=!1,c.ownerItem=i,c.width=r,c.height=o;var u=n.content.options;return c.nearPlane=u.near,c.farPlane=u.far,c.fovy=u.fov,c.aspect=null!==(s=u.aspect)&&void 0!==s?s:c.width/c.height,c.clipMode=u.clipMode,c.update(),c}return r(n,a),n.prototype.update=function(){void 0!==this.ownerItem&&this.transform.fromEffectsTransform(this.ownerItem.transform),this.projectionMatrix.perspective(this.fovy*Be,this.aspect,this.nearPlane,this.farPlane,this.isReversed()),this.viewMatrix=this.matrix.inverse()},n.prototype.getNewProjectionMatrix=function(t){return(new ct).perspective(Math.min(1.25*t,140)*Be,this.aspect,this.nearPlane,this.farPlane,this.isReversed())},n.prototype.computeViewAABB=function(t){var e=Math.tan(this.fovy*Be*.5),a=this.aspect,n=0,r=0,o=0,i=0;this.isReversed()?(n=(o=this.farPlane*e)/a,r=(i=this.nearPlane*e)/a):(o=a*(n=this.farPlane*e),i=a*(r=this.nearPlane*e)),t.makeEmpty();var s=this.matrix;return t.expandByPoint(s.multiplyByPoint3(new S(o,n,-this.farPlane))),t.expandByPoint(s.multiplyByPoint3(new S(o,-n,-this.farPlane))),t.expandByPoint(s.multiplyByPoint3(new S(-o,n,-this.farPlane))),t.expandByPoint(s.multiplyByPoint3(new S(-o,-n,-this.farPlane))),t.expandByPoint(s.multiplyByPoint3(new S(i,r,-this.nearPlane))),t.expandByPoint(s.multiplyByPoint3(new S(i,-r,-this.nearPlane))),t.expandByPoint(s.multiplyByPoint3(new S(-i,r,-this.nearPlane))),t.expandByPoint(s.multiplyByPoint3(new S(-i,-r,-this.nearPlane))),t},n.prototype.getSize=function(){return new y(this.width,this.height)},n.prototype.isReversed=function(){return this.clipMode===e.spec.CameraClipMode.portrait},n.prototype.getEye=function(){return this.translation},n.prototype.setEye=function(t){this.translation=t},n}(Dt),Ue=function(){function t(){this.winWidth=512,this.winHeight=512,this.cameraList=[],this.defaultCamera=new De({id:"camera",name:"camera",type:"camera",duration:10,pluginName:"model",content:{options:{fov:60,far:1e3,near:.001,position:[0,0,-1.5],clipMode:e.spec.CameraClipMode.portrait}},endBehavior:e.spec.END_BEHAVIOR_FORWARD},512,512)}return t.prototype.initial=function(t,e){this.winWidth=t,this.winHeight=e;var a=this.defaultCamera;a.width=t,a.height=e,a.aspect=t/e,a.update()},t.prototype.insert=function(t,e){var a=new De(t,this.winWidth,this.winHeight,e);return this.cameraList.push(a),a},t.prototype.insertCamera=function(t){this.cameraList.push(t)},t.prototype.remove=function(t){if(t instanceof De){var e=this.cameraList.findIndex((function(e){return e===t}));-1!==e&&this.cameraList.splice(e,1)}else t>=0&&t<this.cameraList.length&&this.cameraList.splice(t,1)},t.prototype.dispose=function(){this.cameraList=[]},t.prototype.updateDefaultCamera=function(t,e,a,n,r,o){this.defaultCamera.fovy=t,this.defaultCamera.nearPlane=e,this.defaultCamera.farPlane=a,this.defaultCamera.position=n,this.defaultCamera.rotation=r,this.defaultCamera.clipMode=o,this.defaultCamera.update()},t.prototype.getCameraList=function(){return this.cameraList},t.prototype.getDefaultCamera=function(){return this.defaultCamera},t.prototype.getCameraCount=function(){return this.cameraList.length},t.prototype.getActiveCamera=function(){return this.defaultCamera},t.prototype.getAspect=function(){return this.winWidth/this.winHeight},t}(),ke=function(e){function a(a,n){var r=e.call(this)||this;r.direction=new S(0,0,1),r.range=0,r.color=new S(1,1,1),r.intensity=0,r.outerConeAngle=0,r.innerConeAngle=0,r.lightType=t.PLightType.ambient,r.padding=new y(0,0),r.name=a.name,r.type=t.PObjectType.light,r.visible=!1,r.ownerItem=n,void 0!==n&&r.transform.fromEffectsTransform(n.transform),r.direction=new S(0,0,-1),r.range=0,r.outerConeAngle=0,r.innerConeAngle=0;var o=a.content.options,i=$t.toPluginColor4(o.color);return r.color=new S(i[0],i[1],i[2]),r.intensity=o.intensity,"point"===o.lightType?(r.lightType=t.PLightType.point,r.range=o.range):"spot"===o.lightType?(r.lightType=t.PLightType.spot,r.range=o.range,r.outerConeAngle=o.outerConeAngle,r.innerConeAngle=o.innerConeAngle):"directional"===o.lightType?r.lightType=t.PLightType.directional:r.lightType=t.PLightType.ambient,r}return r(a,e),a.prototype.tick=function(t){void 0!==this.ownerItem&&this.transform.fromEffectsTransform(this.ownerItem.transform)},a.prototype.isDirectional=function(){return this.lightType===t.PLightType.directional},a.prototype.isPoint=function(){return this.lightType===t.PLightType.point},a.prototype.isSpot=function(){return this.lightType===t.PLightType.spot},a.prototype.isAmbient=function(){return this.lightType===t.PLightType.ambient},Object.defineProperty(a.prototype,"position",{get:function(){return this.translation},enumerable:!1,configurable:!0}),a.prototype.getWorldPosition=function(){return this.translation},a.prototype.getWorldDirection=function(){var t=this.matrix;return ct.multiplyByPointAsVector(t,this.direction,new S)},a}(Dt),Ve=function(){function t(){this.lightList=[]}return t.prototype.tick=function(t){this.lightList.forEach((function(e){e.tick(t)}))},t.prototype.insertItem=function(t,e){var a=new ke(t,e);return this.lightList.push(a),a},t.prototype.insertLight=function(t){return this.lightList.push(t),t},t.prototype.remove=function(t){var e=this.lightList.findIndex((function(e){return e===t}));-1!==e&&this.lightList.splice(e,1)},t.prototype.dispose=function(){this.lightList=[]},Object.defineProperty(t.prototype,"lightCount",{get:function(){return this.lightList.length},enumerable:!1,configurable:!0}),t}(),je=function(){function t(t){var e,a;this.resolution=null!==(e=t.resolution)&&void 0!==e?e:new y(512,512),this.colorAttachments=null!==(a=t.colorAttachments)&&void 0!==a?a:[],this.depthAttachment=t.depthAttachment}return t.prototype.addDepthAttachment=function(t){var a;this.depthAttachment={storageType:null!==(a=t.storageType)&&void 0!==a?a:e.RenderPassAttachmentStorageType.depth_16_texture}},t.prototype.addDefaultDepthAttachment=function(){this.depthAttachment={storageType:e.RenderPassAttachmentStorageType.depth_16_texture}},t.prototype.deleteDepthAttachment=function(){this.depthAttachment=void 0},t.prototype.addColorAttachment=function(t){var a,n,r,o;this.colorAttachments.push({texture:{format:null!==(a=t.format)&&void 0!==a?a:e.glContext.RGBA,type:null!==(n=t.type)&&void 0!==n?n:e.glContext.HALF_FLOAT,minFilter:null!==(r=t.filter)&&void 0!==r?r:e.glContext.LINEAR,magFilter:null!==(o=t.filter)&&void 0!==o?o:e.glContext.LINEAR}})},t.prototype.deleteColorAttachment=function(t){t>=0&&t<this.colorAttachments.length&&this.colorAttachments.splice(t,1)},Object.defineProperty(t.prototype,"viewport",{get:function(){return[0,0,this.resolution.x,this.resolution.y]},enumerable:!1,configurable:!0}),t}(),Ge=function(){function t(t,a){var n=e.Material.create(t,{shader:{vertex:this.vertexShader,fragment:this.fragmentShader,shared:!0}});n.depthTest=!0,n.depthMask=!0,this.mesh=e.Mesh.create(t,{name:"boxMesh",material:n,geometry:e.Geometry.create(t,this.geometry),priority:a})}return t.prototype.update=function(t,e,a,n){var r=this.mesh.material;r.setMatrix("u_ModelMatrix",t.toArray()),r.setMatrix("u_ViewProjectionMatrix",e.toArray());for(var o=0;o<a.length;o+=3)r.setVector3("u_PositionList[".concat(o/3,"]"),[a[o],a[o+1],a[o+2]]);r.setVector3("u_LineColor",n.toArray())},t.prototype.dispose=function(){this.mesh.dispose(),this.mesh=void 0},Object.defineProperty(t.prototype,"vertexShader",{get:function(){return"\n #version 100\n precision highp float;\n\n uniform mat4 u_ModelMatrix;\n uniform mat4 u_ViewProjectionMatrix;\n uniform vec3 u_PositionList[8];\n attribute vec3 a_Position;\n void main(){\n int index = int(a_Position.x + 0.5);\n vec4 pos = u_ModelMatrix * vec4(u_PositionList[index], 1);\n gl_Position = u_ViewProjectionMatrix * pos;\n }\n "},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fragmentShader",{get:function(){return"\n #version 100\n precision highp float;\n\n uniform vec3 u_LineColor;\n void main(){\n gl_FragColor = vec4(u_LineColor, 1);\n }\n "},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"geometry",{get:function(){var t=new Float32Array([0,1,2,3,4,5,6,7]),a=new Uint32Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);return{attributes:{a_Position:{type:e.glContext.FLOAT,size:1,data:t,stride:Float32Array.BYTES_PER_ELEMENT,offset:0}},mode:e.glContext.LINES,indices:{data:a},drawStart:0,drawCount:24}},enumerable:!1,configurable:!0}),t}(),He=function(){function t(){this.now=new Set,this.last=new Set}return t.prototype.clear=function(){this.now.clear(),this.last.clear()},t.prototype.forward=function(){var t=this.last;this.last=this.now,this.now=t,this.now.clear()},t.prototype.forAddedItem=function(t){var e=this;this.now.forEach((function(a){e.last.has(a)||t(a)}))},t.prototype.forRemovedItem=function(t){var e=this;this.last.forEach((function(a){e.now.has(a)||t(a)}))},t}();!function(e){function a(){return null!==e&&e.apply(this,arguments)||this}r(a,e),a.prototype.create=function(e){this.type=t.PObjectType.material,this.materialType=t.PMaterialType.shadowBase,this.name=e.name,this.shadowType=e.shadowType},a.prototype.getShaderFeatures=function(){return[]},a.prototype.updateUniforms=function(t){}}(Ie);var We=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return r(a,e),a.prototype.create=function(e){this.type=t.PObjectType.material,this.materialType=t.PMaterialType.shadowBase,this.name=e.name,this.shadowType=e.shadowType},a.prototype.getShaderFeatures=function(){return[]},a.prototype.updateUniforms=function(t){},a}(Ie),qe=function(e){function a(){return null!==e&&e.apply(this,arguments)||this}return r(a,e),a.prototype.create=function(e){this.type=t.PObjectType.material,this.materialType=t.PMaterialType.shadowFilter,this.depthTestHint=!1,this.name=e.name,this.blurScale=e.blurScale},a.prototype.getShaderFeatures=function(){return[]},a.prototype.updateUniforms=function(t){t.setVector2("u_BlurScale",this.blurScale.toArray())},a}(Ie),Xe=function(){function a(){this.enable=!1,this.quality="medium",this.softness=1.5,this.width=1024,this.height=1024,this.type=e.glContext.HALF_FLOAT,this.format=e.glContext.RGBA,this.filter=e.glContext.LINEAR,this.baseFBOOpts=this.getBaseFBOOptions(),this.filterFBOOpts=this.getFilterFBOOptions(),this.runtimeEnable=!1,this.meshList=[],this.primitiveList=[],this.viewAABB=new Ot,this.sceneAABB=new Ot,this.shadowAABB=new Ot,this.lightView=new ct,this.lightProjection=new ct,this.lightViewProjection=new ct,this.xFilterMaterial=new qe,this.yFilterMaterial=new qe,this.meshCacheSet=new He,this.renderPassCacheSet=new He}return a.prototype.initial=function(t,e){var a,n,r,o=this;this.runtimeEnable=!1,this.meshList=[],this.primitiveList=[],this.shadowLight=void 0,this.meshCacheSet.clear(),this.renderPassCacheSet.clear(),this.sceneManager=t,this.renderer=t.getRenderer(),this.engine=this.renderer.engine,this.enable=null===(n=null==e?void 0:e.enable)||void 0===n||n,this.quality=null!==(r=null==e?void 0:e.quality)&&void 0!==r?r:"medium",this.softness=this.getSoftness(e),a=c(this.getTextureSize(e),2),this.width=a[0],this.height=a[1],this.type=this.getTextureType(e),this.format=this.getTextureFormat(e),this.filter=this.getTextureFilter(e),this.enable&&this.isSupportTextureOptions()&&(this.shadowLight=this.getShadowLight(t),void 0!==this.shadowLight&&(t.meshList.forEach((function(t){var e=0;t.primitives.forEach((function(t){t.isEnableShadow()&&(e+=1)})),e>0&&o.meshList.push(t)})),this.meshList.length<=0||(this.runtimeEnable=!0,this.xFilterMaterial.create({name:"ShadowXFilterPass",blurScale:new y(this.softness/this.width,0)}),this.yFilterMaterial.create({name:"ShadowYFilterPass",blurScale:new y(0,this.softness/this.height)}),this.xFilterMaterial.build([]),this.yFilterMaterial.build([]))))},a.prototype.build=function(){if(this.isEnable()){var t=this.sceneManager.getSceneCache();this.basePass=t.getShadowBasePass(this.basePassName,900,[],this.baseFBOOpts);var e=t.getFilterMesh(this.xFilterMeshName,this.xFilterMaterial,{u_FilterSampler:"Shadow0Color"}),a=t.getFilterMesh(this.yFilterMeshName,this.yFilterMaterial,{u_FilterSampler:"Shadow1Color"});this.xFilterMaterial.updateUniforms(e.material),this.yFilterMaterial.updateUniforms(a.material),this.xFilterPass=t.getShadowFilterPass(this.xFilterPassName,901,[e],this.filterFBOOpts),this.yFilterPass=t.getShadowFilterPass(this.yFilterPassName,902,[a],this.filterFBOOpts)}},a.prototype.tick=function(t){this.isEnable()&&(this.primitiveList=this.getCurrentPrimitiveList(),this.primitiveList.length<=0||(this.updateAABBInfo(),this.updateLightViewProjection(),this.updateShadowUniforms(),t.shadowMapSizeInv=new y(1/this.width,1/this.height),t.lightViewMatrix=this.lightView,t.lightProjectionMatrix=this.lightProjection,t.lightViewProjectionMatrix=this.lightViewProjection))},a.prototype.updateAABBInfo=function(){var t=this;this.sceneAABB.makeEmpty(),this.primitiveList.forEach((function(e){var a=e.getWorldBoundingBox();t.sceneAABB.expandByBox(a)})),this.viewAABB.makeEmpty(),this.sceneManager.activeCamera.computeViewAABB(this.viewAABB),this.shadowAABB.makeEmpty(),this.shadowAABB.expandByBox(this.viewAABB),this.sceneAABB.isEmpty()||this.shadowAABB.intersect(this.sceneAABB)},a.prototype.updateLightViewProjection=function(){void 0!==this.shadowLight&&(this.shadowLight.lightType===t.PLightType.directional?this.updateDirectionalLightViewProjection(this.shadowLight):this.shadowLight.lightType===t.PLightType.spot?this.updateSpotLightViewProjection(this.shadowLight):console.warn("Invalid light type for casting shadow: ".concat(this.shadowLight)))},a.prototype.updateDirectionalLightViewProjection=function(t){if(t.isDirectional()){var e=this.shadowAABB,a=e.getCenter(new S),n=t.getWorldDirection(),r=a.clone().addVector(n),o=S.computeUpVector(n,new S),i=(new ct).lookAt(a,r,o),s=e.clone().transform(i),c=s.getCenter(new S),u=s.getSize(new S).multiplyScalar(.5);u.x=Math.max(u.x,u.y),u.y=Math.max(u.x,u.y);var d=u.clone().multiplyScalar(-1.001).addVector(c),l=u.clone().multiplyScalar(1.001).addVector(c),h=(new ct).orth2d(d.x,l.x,d.y,l.y,d.z,l.z);return this.lightView.copyFrom(i),this.lightProjection.copyFrom(h),ct.multiply(h,i,this.lightViewProjection)}this.lightViewProjection.setIdentity()},a.prototype.updateSpotLightViewProjection=function(t){if(t.isSpot()){var e=t.getWorldPosition(),a=t.direction.clone(),n=a.clone().multiplyScalar(10),r=e.clone().addVector(n),o=S.computeUpVector(a,new S),i=(new ct).lookAt(e,r,o),s=this.shadowAABB.clone().transform(i),c=[new S(s.min.x,s.min.y,s.min.z),new S(s.min.x,s.min.y,s.max.z),new S(s.min.x,s.max.y,s.min.z),new S(s.min.x,s.max.y,s.max.z),new S(s.max.x,s.min.y,s.min.z),new S(s.max.x,s.min.y,s.max.z),new S(s.max.x,s.max.y,s.min.z),new S(s.max.x,s.max.y,s.max.z)],u=1,d=1e4,l=-1e4;c.map((function(t){if(t.z<=0){var e=new S(0,t.y,t.z).normalize();u=Math.min(u,-e.z),d=Math.min(d,-t.z),l=Math.max(l,-t.z)}}));var h=Math.acos(u),f=2*Math.min(h,t.outerConeAngle),p=(new ct).perspective(f,1,d,l,!1);return ct.multiply(p,i,this.lightViewProjection)}this.lightViewProjection.setIdentity()},a.prototype.getShadowOptions=function(){return{viewProjectionMatrix:this.lightViewProjection,softness:this.softness}},a.prototype.updateShadowUniforms=function(){var t=this.getShadowOptions();this.primitiveList.forEach((function(e){e.updateUniformForShadow(t)}))},a.prototype.getShadowLight=function(e){for(var a=e.lightManager.lightList,n=0;n<a.length;n++){var r=a[n];if(r.lightType===t.PLightType.directional||r.lightType===t.PLightType.spot)return r}},a.prototype.getShadowPrimitiveCount=function(t){var e=0;return t.meshList.forEach((function(t){t.primitives.forEach((function(t){t.isEnableShadow()&&(e+=1)}))})),e},a.prototype.updateRenderPass=function(t){var e=this;if(void 0!==this.basePass){var a=this.basePass;this.meshCacheSet.forward(),this.primitiveList.forEach((function(t){t.isEnableShadow()&&void 0!==t.shadowMesh&&e.meshCacheSet.now.add(t.shadowMesh)})),this.meshCacheSet.forRemovedItem((function(t){a.removeMesh(t)})),this.meshCacheSet.forAddedItem((function(t){a.addMesh(t)}))}this.renderPassCacheSet.forward(),this.hasRenderObject()&&(void 0!==this.basePass&&this.renderPassCacheSet.now.add(this.basePass),void 0!==this.xFilterPass&&this.renderPassCacheSet.now.add(this.xFilterPass),void 0!==this.yFilterPass&&this.renderPassCacheSet.now.add(this.yFilterPass));var n=!1;this.renderPassCacheSet.forRemovedItem((function(e){t.removeRenderPass(e),n=!0}));var r=!1;this.renderPassCacheSet.forAddedItem((function(e){t.addRenderPass(e),r=!0})),r?this.updateFrameSemantics(t.semantics,!0):n&&this.updateFrameSemantics(t.semantics,!1)},a.prototype.updateFrameSemantics=function(t,e){var a=this;e?(void 0!==this.basePass&&t.setSemantic("Shadow0Color",(function(){return a.basePass.attachments[0].texture})),void 0!==this.xFilterPass&&t.setSemantic("Shadow1Color",(function(){return a.xFilterPass.attachments[0].texture})),void 0!==this.yFilterPass&&t.setSemantic("ShadowNColor",(function(){return a.yFilterPass.attachments[0].texture}))):(t.setSemantic("Shadow0Color",void 0),t.setSemantic("Shadow1Color",void 0),t.setSemantic("ShadowNColor",void 0))},a.prototype.isEnable=function(){return this.enable&&this.runtimeEnable},a.prototype.hasRenderObject=function(){return this.isEnable()&&this.primitiveList.length>0},a.prototype.getCurrentPrimitiveList=function(){var t=[];return this.meshList.forEach((function(e){e.visible&&e.primitives.forEach((function(e){e.isEnableShadow()&&void 0!==e.shadowMesh&&t.push(e)}))})),t},a.prototype.isSupportTextureOptions=function(){return this.type===e.glContext.FLOAT?Qt.isSupportFloatTexture(this.engine):this.type!==e.glContext.HALF_FLOAT||Qt.isSupportHalfFloatTexture(this.engine)},a.prototype.getBaseFBOOptions=function(){var t=new y(this.width,this.height),a={texture:{format:this.format,type:this.type,minFilter:this.filter,magFilter:this.filter}},n={storageType:e.RenderPassAttachmentStorageType.depth_16_opaque};return new je({resolution:t,colorAttachments:[a],depthAttachment:n})},a.prototype.getFilterFBOOptions=function(){var t=new y(this.width,this.height),e={texture:{format:this.format,type:this.type,minFilter:this.filter,magFilter:this.filter}};return new je({resolution:t,colorAttachments:[e]})},a.prototype.getSoftness=function(t){var e,a=null!==(e=null==t?void 0:t.softness)&&void 0!==e?e:1.5;return a>=0&&a<=2?a:(console.error("Invalid softness value from shadow init options, ".concat(a)),g.clamp(a,0,2))},a.prototype.getTextureSize=function(t){var e,a,n=null!==(e=null==t?void 0:t.width)&&void 0!==e?e:1024,r=null!==(a=null==t?void 0:t.height)&&void 0!==a?a:1024;return n===r&&n>0&&n<=4096?[n,r]:(console.error("Invalid texture size from shadow init options, ".concat(n,"x").concat(r)),[1024,1024])},a.prototype.getTextureType=function(t){var a,n=null!==(a=null==t?void 0:t.type)&&void 0!==a?a:e.glContext.HALF_FLOAT;return n===e.glContext.UNSIGNED_BYTE||n===e.glContext.HALF_FLOAT||n===e.glContext.FLOAT?n:(console.error("Invalid texture type from shadow init options, ".concat(n)),e.glContext.HALF_FLOAT)},a.prototype.getTextureFormat=function(t){var a,n=null!==(a=null==t?void 0:t.format)&&void 0!==a?a:e.glContext.RGBA;return n===e.glContext.RGBA?n:(console.error("Invalid texture format from shadow init options, ".concat(n)),e.glContext.RGBA)},a.prototype.getTextureFilter=function(t){var a,n=null!==(a=null==t?void 0:t.filter)&&void 0!==a?a:e.glContext.LINEAR;return n===e.glContext.NEAREST||n===e.glContext.LINEAR?n:(console.error("Invalid texture filter from shadow init options, ".concat(n)),e.glContext.LINEAR)},Object.defineProperty(a.prototype,"mainPassUniformSemantics",{get:function(){return{u_ShadowSampler:"ShadowNColor"}},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"basePassName",{get:function(){return this.sceneManager.compName+"_ShadowBasePass"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"xFilterPassName",{get:function(){return this.sceneManager.compName+"_ShadowXFilterPass"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"yFilterPassName",{get:function(){return this.sceneManager.compName+"_ShadowYFilterPass"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"xFilterMeshName",{get:function(){return this.sceneManager.compName+"_ShadowXFilterMesh"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"yFilterMeshName",{get:function(){return this.sceneManager.compName+"_ShadowYFilterMesh"},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shadowPassList",{get:function(){var t=[];return void 0!==this.basePass&&t.push(this.basePass),void 0!==this.xFilterPass&&t.push(this.xFilterPass),void 0!==this.yFilterPass&&t.push(this.yFilterPass),t},enumerable:!1,configurable:!0}),a}(),Ye=function(a){function n(e,n,r,o){var i=a.call(this)||this;i.engine=e,i.parentIndex=-1,i.primitives=[],i.hide=!0,i.priority=0,i.boundingBox=new Ot,i.visBoundingBox=!1,i.isBuilt=!1,i.isDisposed=!1;var s=new Qe(n,o);return i.name=s.getName(),i.type=t.PObjectType.mesh,i.visible=!1,i.ownerItem=r,i.parentIndex=s.getParentIndex(),i.parentItem=s.parentItem,i.parentItemId=s.getParentId(),i.skin=s.getSkinObj(e),i.morph=s.getMorphObj(),i.hide=s.isHide(),i.priority=(null==r?void 0:r.listIndex)||0,i.primitives=[],s.getPrimitives().forEach((function(t){var e=new Ze(i.engine);e.create(t,i),i.primitives.push(e)})),i.primitives.length<=0&&console.warn("No primitive inside mesh item ".concat(s.getName())),i.boundingBox=i.getItemBoundingBox(n.content.interaction),Rt.getInstance().visBoundingBox&&(i.boundingBoxMesh=new Ge(i.engine,i.priority)),i}return r(n,a),n.prototype.build=function(t,e,a){this.isBuilt||(this.isBuilt=!0,this.primitives.forEach((function(n){n.build(t,e,a)})))},n.prototype.tick=function(t){this.visible&&(void 0!==this.ownerItem&&this.transform.setMatrix(this.ownerItem.transform.getWorldMatrix()),void 0!==this.skin&&this.skin.updateSkinMatrices())},n.prototype.addToRenderObjectSet=function(t){this.visible&&(this.primitives.forEach((function(e){t.add(e.effectsMesh)})),this.visBoundingBox&&void 0!==this.boundingBoxMesh&&t.add(this.boundingBoxMesh.mesh))},n.prototype.dispose=function(){var t,e,a;this.isDisposed||(this.isDisposed=!0,this.engine=null,this.parentItem=void 0,null===(t=this.skin)||void 0===t||t.dispose(),this.skin=void 0,null===(e=this.morph)||void 0===e||e.dispose(),this.morph=void 0,this.primitives.forEach((function(t){t.dispose()})),this.primitives=[],null===(a=this.boundingBoxMesh)||void 0===a||a.dispose(),this.boundingBoxMesh=void 0)},n.prototype.updateMorphWeights=function(t){if(void 0!==this.morph&&this.morph.hasMorph()){var e=this.morph.morphWeightsArray;if(void 0!==e){if(e.length!=t.length)throw new Error("weight array length mismatch");for(var a=0;a<e.length;a++)e[a]=t[a]}}},n.prototype.updateParentItem=function(t){this.parentItem=t,void 0!==this.skin&&this.skin.updateParentItem(t)},n.prototype.updateUniformsForScene=function(t){var e=this.matrix,a=e.clone().inverse().transpose();if(this.primitives.forEach((function(n){n.updateUniformsForScene(e,a,t)})),0===t.deltaSeconds&&void 0!==this.boundingBoxMesh){this.computeBoundingBox(e);var n=new S(1,1,1),r=this.boundingBox.min,o=this.boundingBox.max,i=new Float32Array([r.x,r.y,r.z,o.x,r.y,r.z,o.x,o.y,r.z,r.x,o.y,r.z,r.x,r.y,o.z,o.x,r.y,o.z,o.x,o.y,o.z,r.x,o.y,o.z]);this.boundingBoxMesh.update(e,t.viewProjectionMatrix,i,n)}},n.prototype.updateUniformForShadow=function(t){this.primitives.forEach((function(e){e.updateUniformForShadow(t)}))},n.prototype.hitTesting=function(t,e){var a,n=this.matrix,r=n.clone().inverse(),o=ct.multiplyByPoint(r,t,new S),i=ct.multiplyByPointAsVector(r,e,new S),s=this.boundingBox,c=jt(o,i,s.min,s.max);return void 0===c?[]:(Rt.getInstance().isEditorEnv?this.primitives.forEach((function(t){var e=t.hitTesting(o,i,n,r);void 0!==e&&(void 0===a||a>e)&&(a=e)})):a=c,void 0===a?[]:(i.multiplyScalar(a),o.addVector(i),n.multiplyByPoint3(o),[[o.x,o.y,o.z]]))},n.prototype.computeBoundingBox=function(t){var e=this.boundingBox.makeEmpty(),a=t.clone().inverse();return this.primitives.forEach((function(t){var n=t.computeBoundingBox(a);e.union(n)})),e},n.prototype.getItemBoundingBox=function(t){var a,n,r,o;if(void 0===t)return new Ot;if(t.type===e.spec.ModelBoundingType.box){var i=null!==(a=t.center)&&void 0!==a?a:[0,0,0],s=null!==(n=t.size)&&void 0!==n?n:[0,0,0],c=S.fromArray(i),u=S.fromArray(s).multiplyScalar(.5),d=c.clone().subVector(u),l=c.clone().addVector(u);return new Ot(d,l)}i=null!==(r=t.center)&&void 0!==r?r:[0,0,0];var h=.5*(null!==(o=t.radius)&&void 0!==o?o:0);d=(c=S.fromArray(i)).clone().subScalar(h),l=c.clone().addScalar(h);return new Ot(d,l)},n.prototype.getParentId=function(){return this.parentItemId},Object.defineProperty(n.prototype,"hasSkin",{get:function(){return void 0!==this.skin},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"mriMeshs",{get:function(){return this.primitives.map((function(t){return t.effectsMesh}))},enumerable:!1,configurable:!0}),n}(Dt),Ze=function(){function a(e){this.engine=e,this.name="",this.effectsPriority=0,this.boundingBox=new Ot,this.isCompressed=!1,this.shadowType=t.PShadowType.none}return a.prototype.create=function(e,a){if(this.parent=a,this.skin=a.skin,this.morph=a.morph,this.setGeometry(e.geometry),this.setMaterial(e.material),this.name=a.name,this.effectsPriority=a.priority,this.geometry.setHide(a.hide),void 0!==this.skin){var n=this.skin.getJointCount();if(this.jointMatrixList=new Float32Array(16*n),this.jointNormalMatList=new Float32Array(16*n),this.skin.isTextureDataMode()){var r=this.skin.textureDataMode===t.TextureDataMode.half_float;this.jointMatrixTexture=new pe(this.engine),this.jointNormalMatTexture=new pe(this.engine),this.jointMatrixTexture.create(n,r,"jointMatrixTexture"),this.jointNormalMatTexture.create(n,r,"jointNormalMatTexture")}}else(this.geometry.hasWeights()||this.geometry.hasJoints())&&console.warn("Geometry has weight and/or joint array, but the skin is missing.");this.isCompressed=this.geometry.isCompressed(),this.shadowType=t.PShadowType.none,this.material instanceof Pe&&this.material.enableShadow&&(this.shadowType=t.PShadowType.expVariance)},a.prototype.build=function(t,a,n){var r=Rt.getInstance(),o=this.getFeatureList(t,!0,n);this.material.build(o);var i=this.isEnableShadow()?a:{};i.u_ViewProjectionMatrix="VIEWPROJECTION",i.u_ModelMatrix="MODEL",i.uEditorTransform="EDITOR_TRANSFORM";var s=e.Material.create(this.engine,{shader:{vertex:this.material.vertexShaderCode,fragment:this.material.fragmentShaderCode,shared:r.shaderShared},uniformSemantics:i});this.material.setMaterialStates(s);var c=e.Mesh.create(this.engine,{name:this.name,material:s,geometry:this.getEffectsGeometry(),priority:this.effectsPriority});if(void 0!==this.effectsMesh&&this.effectsMesh.dispose(),this.effectsMesh=c,this.isEnableShadow()){this.shadowMaterial=new We,this.shadowMaterial.create({name:this.name+"_ShadowMaterial",shadowType:this.shadowType});var u=this.getFeatureList(t,!1,n);this.shadowMaterial.build(u);var d=this.shadowMaterial.vertexShaderCode,l=this.shadowMaterial.fragmentShaderCode,h=e.Material.create(this.engine,{shader:{vertex:d,fragment:l,shared:r.shaderShared}});this.shadowMaterial.setMaterialStates(h);var f=e.Mesh.create(this.engine,{name:this.name+"_shadow",material:h,geometry:this.getEffectsGeometry(),priority:this.effectsPriority});void 0!==this.shadowMesh&&this.shadowMesh.dispose(),this.shadowMesh=f}},a.prototype.getFeatureList=function(e,a,n){var r=[];if(this.geometry.hasNormals()&&r.push("HAS_NORMALS 1"),this.geometry.hasTangents()&&r.push("HAS_TANGENTS 1"),this.geometry.hasUVCoords(1)&&r.push("HAS_UV_SET1 1"),this.geometry.hasUVCoords(2)&&r.push("HAS_UV_SET2 1"),void 0!==this.morph&&this.morph.hasMorph()){r.push("USE_MORPHING"),r.push("WEIGHT_COUNT ".concat(this.morph.morphWeightsLength));for(var o=0;o<this.morph.morphWeightsLength;o++)this.morph.hasPositionMorph&&r.push("HAS_TARGET_POSITION".concat(o)),this.morph.hasNormalMorph&&r.push("HAS_TARGET_NORMAL".concat(o)),this.morph.hasTangentMorph&&r.push("HAS_TARGET_TANGENT".concat(o))}void 0!==this.skin&&(r.push("USE_SKINNING 1"),r.push("JOINT_COUNT ".concat(this.skin.getJointCount())),r.push("HAS_JOINT_SET1 1"),r.push("HAS_WEIGHT_SET1 1"),this.skin.textureDataMode&&r.push("USE_SKINNING_TEXTURE 1")),this.isEnableShadow()&&(this.shadowType===t.PShadowType.standard?r.push("SHADOWMAP_STANDARD 1"):this.shadowType===t.PShadowType.variance?r.push("SHADOWMAP_VSM 1"):(r.push("SHADOWMAP_EVSM 1"),r.push("SHADOWMAP_EVSM_PCF 1")),a&&r.push("USE_SHADOW_MAPPING 1")),this.material.materialType!==t.PMaterialType.unlit&&(e>0&&this.geometry.hasNormals()&&(r.push("USE_PUNCTUAL 1"),r.push("LIGHT_COUNT ".concat(e))),void 0!==n&&n.available&&(r.push("USE_IBL 1"),r.push("USE_TEX_LOD 1"),n.hasDiffuseImage||r.push("IRRADIANCE_COEFFICIENTS 1")));var i=Rt.getInstance().renderMode3D,s=this.getRenderMode3DDefine(i);return void 0!==s&&(r.push("DEBUG_OUTPUT 1"),r.push("".concat(s," 1"))),r},a.prototype.addToRenderObjectSet=function(t){t.add(this.effectsMesh)},a.prototype.dispose=function(){var t,a,n,r;this.engine=null,this.parent=void 0,this.skin=void 0,this.morph=void 0,this.geometry.dispose(),this.material.dispose(),this.jointMatrixList=void 0,this.jointNormalMatList=void 0,null===(t=this.jointMatrixTexture)||void 0===t||t.dispose(),this.jointMatrixTexture=void 0,null===(a=this.jointNormalMatTexture)||void 0===a||a.dispose(),this.jointNormalMatTexture=void 0,this.effectsMesh.dispose({geometries:e.DestroyOptions.keep,material:e.DestroyOptions.keep}),this.effectsMesh=void 0,null===(n=this.shadowMesh)||void 0===n||n.dispose({geometries:e.DestroyOptions.keep,material:e.DestroyOptions.keep}),this.shadowMesh=void 0,null===(r=this.shadowMaterial)||void 0===r||r.dispose(),this.shadowMaterial=void 0},a.prototype.updateUniformsForScene=function(t,e,a){this.updateUniformsByAnimation(t,e),this.updateUniformsByScene(a),this.material.updateUniforms(this.getModelMaterial())},a.prototype.updateUniformForShadow=function(t){var e=this.getShadowModelMaterial();void 0!==e&&(e.setMatrix("u_ViewProjectionMatrix",t.viewProjectionMatrix.toArray()),void 0!==this.shadowMaterial&&this.shadowMaterial.updateUniforms(e))},a.prototype.hitTesting=function(e,a,n,r){var o=this.boundingBox,i=jt(e,a,o.min,o.max),s=[];if(void 0!==i){if(void 0!==this.skin)this.skin.animationMatrices.forEach((function(t){s.push(ct.multiply(r,t,new ct))}));var c=new re,u=this.material.faceSideMode===t.PFaceSideMode.both;return c.create(this.geometry.geometry,u,s),c.getHitPoint(e,a)}},a.prototype.computeBoundingBox=function(t){if(void 0===this.skin&&!this.boundingBox.isEmpty())return this.boundingBox;var e=[];void 0!==this.skin&&this.skin.animationMatrices.forEach((function(a){e.push(ct.multiply(t,a,new ct))}));var a=new ne;return a.create(this.geometry.geometry,e),a.getBoundingBox(this.boundingBox)},a.prototype.getRenderMode3DDefine=function(t){switch(t){case e.spec.RenderMode3D.uv:return"DEBUG_UV";case e.spec.RenderMode3D.normal:return"DEBUG_NORMAL";case e.spec.RenderMode3D.basecolor:return"DEBUG_BASECOLOR";case e.spec.RenderMode3D.alpha:return"DEBUG_ALPHA";case e.spec.RenderMode3D.metallic:return"DEBUG_METALLIC";case e.spec.RenderMode3D.roughness:return"DEBUG_ROUGHNESS";case e.spec.RenderMode3D.ao:return"DEBUG_OCCLUSION";case e.spec.RenderMode3D.emissive:return"DEBUG_EMISSIVE"}},a.prototype.updateUniformsByAnimation=function(t,e){var a=this.getModelMaterial(),n=this.getShadowModelMaterial();a.setMatrix("u_ModelMatrix",t.toArray()),a.setMatrix("u_NormalMatrix",e.toArray()),void 0!==n&&(n.setMatrix("u_ModelMatrix",t.toArray()),n.setMatrix("u_NormalMatrix",e.toArray()));var r=this.skin;if(void 0!==r){var o=this.jointMatrixList,i=this.jointNormalMatList;if(r.computeMeshAnimMatrices(t,o,i),r.textureDataMode){var s=this.jointMatrixTexture,c=this.jointNormalMatTexture;s.update(o),c.update(i),a.setTexture("u_jointMatrixSampler",s.getTexture()),a.setTexture("u_jointNormalMatrixSampler",c.getTexture())}else{var u=[],d=[];o.forEach((function(t){return u.push(t)})),i.forEach((function(t){return d.push(t)})),a.setMatrixNumberArray("u_jointMatrix",u),a.setMatrixNumberArray("u_jointNormalMatrix",d),void 0!==n&&(n.setMatrixNumberArray("u_jointMatrix",u),n.setMatrixNumberArray("u_jointNormalMatrix",d))}}var l=this.morph;if(void 0!==l&&l.hasMorph()){var h=l.morphWeightsArray,f=[];h.forEach((function(t){return f.push(t)})),a.setFloats("u_morphWeights",f),void 0!==n&&n.setFloats("u_morphWeights",f)}},a.prototype.updateUniformsByScene=function(t){var e,a=this.getModelMaterial();if(a.setMatrix("u_ViewProjectionMatrix",t.viewProjectionMatrix.toArray()),a.setVector3("u_Camera",t.cameraPosition.toArray()),this.isEnableShadow(),!this.isUnlitMaterial()){for(var n=t.maxLightCount,r=t.lightList,o=0;o<n;o++)if(o<r.length){var i=r[o],s=i.visible?i.intensity:0;a.setVector3("u_Lights[".concat(o,"].direction"),i.getWorldDirection().toArray()),a.setFloat("u_Lights[".concat(o,"].range"),i.range),a.setVector3("u_Lights[".concat(o,"].color"),i.color.toArray()),a.setFloat("u_Lights[".concat(o,"].intensity"),s),a.setVector3("u_Lights[".concat(o,"].position"),i.getWorldPosition().toArray()),a.setFloat("u_Lights[".concat(o,"].innerConeCos"),Math.cos(i.innerConeAngle)),a.setFloat("u_Lights[".concat(o,"].outerConeCos"),Math.cos(i.outerConeAngle)),a.setInt("u_Lights[".concat(o,"].type"),i.lightType),a.setVector2("u_Lights[".concat(o,"].padding"),i.padding.toArray())}else a.setVector3("u_Lights[".concat(o,"].direction"),[0,0,0]),a.setFloat("u_Lights[".concat(o,"].range"),0),a.setVector3("u_Lights[".concat(o,"].color"),[0,0,0]),a.setFloat("u_Lights[".concat(o,"].intensity"),0),a.setVector3("u_Lights[".concat(o,"].position"),[0,0,0]),a.setFloat("u_Lights[".concat(o,"].innerConeCos"),0),a.setFloat("u_Lights[".concat(o,"].outerConeCos"),0),a.setInt("u_Lights[".concat(o,"].type"),99999),a.setVector2("u_Lights[".concat(o,"].padding"),[0,0]);var c=t.skybox;if(void 0!==c&&c.available){if(a.setVector2("u_IblIntensity",[c.currentIntensity,c.currentReflectionsIntensity]),a.setTexture("u_brdfLUT",c.brdfLUT),void 0!==c.diffuseImage)a.setTexture("u_DiffuseEnvSampler",c.diffuseImage);else{var u=c.irradianceCoeffs;["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(t,e){a.setVector3("u_shCoefficients.".concat(t),u[e])}))}a.setInt("u_MipCount",null!==(e=c.specularMipCount)&&void 0!==e?e:1),a.setTexture("u_SpecularEnvSampler",c.specularImage)}}},a.prototype.hasSkin=function(){return void 0!==this.skin},a.prototype.getEffectsGeometry=function(){return this.geometry.geometry},a.prototype.setGeometry=function(t){this.geometry=t instanceof Je?t:new Je(t)},a.prototype.setMaterial=function(t){this.material=t instanceof Ee||t instanceof Pe?t:Oe(t)},a.prototype.getModelMaterial=function(){return this.effectsMesh.material},a.prototype.getShadowModelMaterial=function(){var t;return null===(t=this.shadowMesh)||void 0===t?void 0:t.material},a.prototype.isEnableShadow=function(){return this.shadowType!==t.PShadowType.none&&this.material.materialType!==t.PMaterialType.unlit},a.prototype.isUnlitMaterial=function(){return this.material.materialType===t.PMaterialType.unlit},a.prototype.hasMorph=function(){return void 0!==this.morph&&this.morph.hasMorph()},a.prototype.getWorldBoundingBox=function(){if(void 0===this.parent)return this.boundingBox.isEmpty()&&this.computeBoundingBox(ct.IDENTITY.clone()),this.boundingBox;var t=this.parent.matrix;return this.boundingBox.isEmpty()&&this.computeBoundingBox(t.clone().inverse()),this.boundingBox.clone().transform(t)},a}(),Je=function(){function t(t){this.geometry=t,this.attributeNames=t.getAttributeNames()}return t.prototype.dispose=function(){this.geometry=void 0,this.attributeNames=[]},t.prototype.hasAttribute=function(t){return-1!==this.attributeNames.findIndex((function(e){return e===t}))},t.prototype.setHide=function(t){var e=this.geometry;if(0===e.getDrawCount()){var a=e.getIndexData();void 0!==a&&e.setDrawCount(a.length)}t?e.getDrawCount()>=0&&e.setDrawCount(-e.getDrawCount()):e.getDrawCount()<0&&e.setDrawCount(-e.getDrawCount())},t.prototype.isCompressed=function(){this.geometry.getAttributeData("a_Position");return!1},t.prototype.hasPositions=function(){return this.hasAttribute("a_Position")},t.prototype.hasNormals=function(){return this.hasAttribute("a_Normal")},t.prototype.hasTangents=function(){return this.hasAttribute("a_Tangent")},t.prototype.hasUVCoords=function(t){return this.hasAttribute("a_UV".concat(t))},t.prototype.hasColors=function(){return this.hasAttribute("a_Color")},t.prototype.hasJoints=function(){return this.hasAttribute("a_Joint1")},t.prototype.hasWeights=function(){return this.hasAttribute("a_Weight1")},t}(),Qe=function(){function t(t,e){this.item=t,this.parentItem=e,this.options=t.content.options;var a=!0,n=new le,r=t.content.options;r.primitives.forEach((function(t,e){if(0===e)n.create(t.geometry);else{var r=new le;r.create(t.geometry)?n.equals(r)||(a=!1,console.error("Morpth target mismatch between primtives: ".concat(JSON.stringify(n),", ").concat(JSON.stringify(r)))):a=!1}})),a?(void 0!==r.weights&&n.initWeights(r.weights),this.morphObj=n):this.morphObj=new le}return t.prototype.hasMorphTarget=function(){return this.morphObj.hasMorph()},t.prototype.getMorphObj=function(){if(this.hasMorphTarget())return this.morphObj},t.prototype.getParentId=function(){return this.item.parentId},t.prototype.getName=function(){return this.item.name},t.prototype.isHide=function(){return!0===this.options.hide},t.prototype.getParentNode=function(){var t=this.getParentIndex();if(void 0!==this.parentItem&&t>=0)return this.parentItem.content.getNodeById(t)},t.prototype.getParentIndex=function(){var t;return null!==(t=this.options.parent)&&void 0!==t?t:-1},t.prototype.getPrimitives=function(){return this.options.primitives},t.prototype.getPrimitiveCount=function(){return this.options.primitives.length},t.prototype.hasSkin=function(){return void 0!==this.options.skin},t.prototype.getSkinOpts=function(){return this.options.skin},t.prototype.getSkinObj=function(t){var e=this.getSkinOpts();if(void 0!==e){var a=new de;return a.create(e,t,this.parentItem),a}},t}(),Ke=function(){function a(t){this.maxLightCount=16,this.renderSkybox=!1,this.compName="SceneManger",this.itemList=[],this.meshList=[],this.engine=t,this.lightManager=new Ve,this.cameraManager=new Ue,this.shadowManager=new Xe,this.parentId2Mesh=new Map,this.enableDynamicSort=!1,this.tickCount=0,this.lastTickSecond=-1,this.sceneAABBCache=new Ot,this.renderedMeshSet=new He,this.allRenderedMeshSet=new Set}return a.prototype.initial=function(t){this.clean(),this.compName=t.componentName,this.renderer=t.renderer,this.engine=t.renderer.engine,this.sceneCache=t.sceneCache,this.enableDynamicSort=!0===t.enableDynamicSort,this.renderSkybox=t.renderSkybox,this.maxLightCount=t.lightItemCount,this.cameraManager.initial(this.renderer.getWidth(),this.renderer.getHeight()),this.brdfLUT=this.sceneCache.getBrdfLutTexture(),this.initGlobalState(t),this.maxLightCount>8&&console.warn("Too many light items: ".concat(this.maxLightCount," light(s)"))},a.prototype.initGlobalState=function(t){var a,n,r,o,i,s=this.engine.gpuCapability,c=Rt.getInstance();c.reset(),c.isWebGL2=2===s.level,c.runtimeEnv=null!==(a=t.runtimeEnv)&&void 0!==a?a:e.PLAYER_OPTIONS_ENV_EDITOR,c.compatibleMode=null!==(n=t.compatibleMode)&&void 0!==n?n:"gltf",c.visBoundingBox=null!==(r=t.visBoundingBox)&&void 0!==r&&r,c.renderMode3D=null!==(o=t.renderMode3D)&&void 0!==o?o:e.spec.RenderMode3D.none,c.renderMode3DUVGridSize=null!==(i=t.renderMode3DUVGridSize)&&void 0!==i?i:1/16},a.prototype.clean=function(){this.dispose(),this.compName="",this.renderer=void 0,this.sceneCache=void 0,this.itemList=[],this.meshList=[],this.lightManager=new Ve,this.cameraManager=new Ue,this.shadowManager=new Xe,this.parentId2Mesh=new Map,this.brdfLUT=void 0,this.skybox=void 0,this.lastTickSecond=-1,this.tickCount=0,this.renderedMeshSet=new He,this.allRenderedMeshSet=new Set},a.prototype.dispose=function(){var t;this.itemList.forEach((function(t){return t.dispose()})),this.itemList=[],this.meshList.forEach((function(t){return t.dispose()})),this.meshList=[],this.lightManager.dispose(),this.cameraManager.dispose(),this.brdfLUT=void 0,null===(t=this.skybox)||void 0===t||t.dispose(),this.skybox=void 0,this.renderedMeshSet.clear(),this.allRenderedMeshSet.clear(),this.renderer=void 0,this.sceneCache=void 0,this.engine=void 0,this.parentId2Mesh.clear()},a.prototype.addItem=function(t){var a=t.content;if(a instanceof Ye){var n=a;void 0!==n.parentItemId&&this.parentId2Mesh.set(n.parentItemId,n),e.addItem(this.meshList,n),this.buildItem(a)}else if(a instanceof Le){var r=a;r.setup(this.brdfLUT),this.renderSkybox||(r.renderable=!1),this.skybox=r,this.buildItem(a)}else a instanceof ke?this.lightManager.insertLight(a):this.cameraManager.insertCamera(a);e.addItem(this.itemList,a)},a.prototype.removeItem=function(t){var a=t.content;if(a instanceof Ye){var n=a;void 0!==n.parentItemId&&this.parentId2Mesh.delete(n.parentItemId),e.removeItem(this.meshList,n)}else a instanceof Le?this.skybox=void 0:a instanceof ke?this.lightManager.remove(a):this.cameraManager.remove(a);e.removeItem(this.itemList,a)},a.prototype.updateDefaultCamera=function(t){var a=new e.Transform(o(o({},t),{valid:!0})),n=(new Lt).fromEffectsTransform(a);this.cameraManager.updateDefaultCamera(t.fov,t.near,t.far,t.position,n.getRotation(),t.clipMode)},a.prototype.buildItem=function(t){t instanceof Ye?t.build(this.maxLightCount,{},this.skybox):t instanceof Le&&t.build(this.getSceneCache())},a.prototype.build=function(){var t=this;this.meshList.forEach((function(e){e.build(t.maxLightCount,{},t.skybox)})),void 0!==this.skybox&&this.skybox.build(this.getSceneCache())},a.prototype.tick=function(t){var e=this,a=t,n=this.activeCamera,r=n.viewMatrix,o=n.projectionMatrix,i=o.clone().multiply(r),s={deltaSeconds:a,camera:n,cameraPosition:n.getEye(),viewMatrix:r,projectionMatrix:o,viewProjectionMatrix:i,winSize:n.getSize(),sceneRadius:1,lightList:this.lightManager.lightList,maxLightCount:this.maxLightCount,skybox:this.skybox};this.build(),this.lightManager.tick(a),this.renderedMeshSet.forward(),this.itemList.forEach((function(t){t.tick(a),t.updateUniformsForScene(s),t.addToRenderObjectSet(e.renderedMeshSet.now)})),this.enableDynamicSort&&this.dynamicSortMeshes(s),this.tickCount+=1,this.lastTickSecond+=a},a.prototype.updateDefaultRenderPass=function(t){var e=this;this.enableDynamicSort?(this.renderedMeshSet.last.forEach((function(e){t.removeMeshFromDefaultRenderPass(e)})),this.renderedMeshSet.now.forEach((function(a){t.addMeshToDefaultRenderPass(a),e.allRenderedMeshSet.add(a)}))):(this.renderedMeshSet.forRemovedItem((function(e){t.removeMeshFromDefaultRenderPass(e)})),this.renderedMeshSet.forAddedItem((function(a){t.addMeshToDefaultRenderPass(a),e.allRenderedMeshSet.add(a)})))},a.prototype.dynamicSortMeshes=function(t){var e=[],a=[];this.renderedMeshSet.now.forEach((function(t){e.push(t),a.push(t.priority)})),a.sort((function(t,e){return t-e}));var n=t.viewMatrix;e.sort((function(t,e){var a=Qt.isTransparentMesh(t),r=Qt.isTransparentMesh(e);if(a&&r){var o=S.unpack(t.worldMatrix,12,new S),i=S.unpack(e.worldMatrix,12,new S),s=n.multiplyByPoint3(o),c=n.multiplyByPoint3(i);return s.z-c.z}return a?1:r?-1:0}));for(var r=0;r<e.length;r++){var o=e[r],i=a[r];o.priority=i}},a.prototype.queryMesh=function(t){var e=this.parentId2Mesh.get(t);if(void 0!==e&&e.visible)return e},a.prototype.removeAllMeshesFromDefaultPass=function(t){this.renderedMeshSet.now.forEach((function(e){t.removeMeshFromDefaultRenderPass(e)}))},a.prototype.getSceneAABB=function(e){var a=null!=e?e:new Ot;return this.itemList.forEach((function(e){if(e.type===t.PObjectType.mesh){var n=e;if(n.ownerItem){var r=n.ownerItem.getWorldTransform(),o=ct.fromArray(r.getWorldMatrix()),i=n.computeBoundingBox(o);i.transform(o),a.union(i)}else a.union(n.computeBoundingBox(ct.IDENTITY.clone()))}})),a},a.prototype.printDebugInfo=function(){console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),this.meshList.forEach((function(t,e){console.info("Mesh: ",e,t)})),this.cameraManager.getCameraList().forEach((function(t,e){console.info("Camera: ",e,t)})),console.info("Default Camera: ",this.cameraManager.getDefaultCamera()),this.lightManager.lightList.forEach((function(t,e){console.info("Light: ",e,t)})),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")},a.prototype.getRenderer=function(){return this.renderer},a.prototype.getSceneCache=function(){return this.sceneCache},Object.defineProperty(a.prototype,"activeCamera",{get:function(){return this.cameraManager.getActiveCamera()},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"lightCount",{get:function(){return this.lightManager.lightCount},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"shaderLightCount",{get:function(){return Math.min(10,this.lightManager.lightCount)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"enableShadowPass",{get:function(){return this.shadowManager.isEnable()},enumerable:!1,configurable:!0}),a}(),$e="_Native",ta=new Map;function ea(t,e){for(var a,n="".concat(t),r=[],o=0;o<e.length;o++)"number"==typeof e[o]&&ta.has(e[o])?r.push(ta.get(e[o])+"(".concat(e[o],")")):r.push(null===(a=e[o])||void 0===a?void 0:a.toString());return n+(r.length>0?"("+r.join(", ")+")":"()")}function aa(t,e){return function(){var a=t[e+$e].apply(this,arguments),n=t.getError();return n>0?(console.info("OpenGLError: "+function(t){var e,a=new Map;return a.set(WebGLRenderingContext.NO_ERROR,"NO_ERROR"),a.set(WebGLRenderingContext.INVALID_ENUM,"INVALID_ENUM"),a.set(WebGLRenderingContext.INVALID_VALUE,"INVALID_VALUE"),a.set(WebGLRenderingContext.INVALID_OPERATION,"INVALID_OPERATION"),a.set(WebGLRenderingContext.INVALID_FRAMEBUFFER_OPERATION,"INVALID_FRAMEBUFFER_OPERATION"),a.set(WebGLRenderingContext.OUT_OF_MEMORY,"OUT_OF_MEMORY"),a.set(WebGLRenderingContext.CONTEXT_LOST_WEBGL,"CONTEXT_LOST_WEBGL"),(null!==(e=a.get(t))&&void 0!==e?e:"UNKNOWN_ERROR")+"(".concat(t,")")}(n)+" ===> "+ea(e,arguments)),console.trace()):console.info(ea(e,arguments)),a}}var na,ra=function(){function t(t,e){this.baseTransform=e.transform,this.animationManager=new _e(t,e),this.build(t)}return t.prototype.tick=function(t){this.animationManager.tick(t)},t.prototype.getNodes=function(){return this.nodes},t.prototype.getNodeById=function(t){var e=this.cacheMap;if(!e[t]){var a="^".concat(t);e[t]=this.allNodes.find((function(t){return t.id===a}))}return e[t]},t.prototype.getNodeByName=function(t){var e=this.cacheMap;return e[t]||(e[t]=this.allNodes.find((function(e){return e.name===t}))),e[t]},t.prototype.getNodeTransform=function(t){var e=this.getNodeById(t);return e?e.transform:this.baseTransform},t.prototype.dispose=function(){var t;this.allNodes=[],this.nodes=[],this.cacheMap={},this.baseTransform=null,null===(t=this.animationManager)||void 0===t||t.dispose(),this.animationManager=null},t.prototype.build=function(t){var a=this,n=this.baseTransform,r=t.nodes.map((function(t,r){return{name:t.name||t.id||r+"",transform:new e.Transform(o(o({},t.transform),{valid:!0}),n),id:"^".concat(t.id||r),children:[],tree:a}}));this.cacheMap={},r.forEach((function(e,a){var o=t.nodes[a].children;e.transform.name=e.name,e.transform.setValid(!0),o&&o.forEach((function(t){var a=r[t];a&&a!==e&&(a.transform.parentTransform!==n&&console.error("Node parent has been set."),a.transform.parentTransform=e.transform,e.children.push(a))}))})),this.allNodes=r,this.nodes=t.children.map((function(t){return r[t]}))},t}(),oa=function(t){function a(){return null!==t&&t.apply(this,arguments)||this}return r(a,t),Object.defineProperty(a.prototype,"type",{get:function(){return e.VFX_ITEM_TYPE_TREE},enumerable:!1,configurable:!0}),a.prototype.onConstructed=function(t){this.options=t.content.options.tree,this.timeline=new e.TimelineComponent(t.content,this),this.timeline.getRenderData(0,!0)},a.prototype.onLifetimeBegin=function(){this.content.baseTransform.setValid(!0)},a.prototype.onItemRemoved=function(t,e){void 0!==this.content&&this.content.dispose()},a.prototype.onItemUpdate=function(t,e){var a,n=.001*(this.timeInms-this.delayInms);null===(a=this.timeline)||void 0===a||a.getRenderData(n,!0),this.content.tick(t)},a.prototype.doCreateContent=function(){return new ra(this.options,this)},a.prototype.getNodeTransform=function(t){if(void 0===this.content)return this.transform;var e=this.id+"^";if(0===t.indexOf(e)){var a=t.substring(e.length);return this.content.getNodeTransform(a)}return this.transform},a}(e.VFXItem),ia=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),Object.defineProperty(n.prototype,"type",{get:function(){return a},set:function(t){},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(t){var a;this.options=t,this.duration=t.duration,this.delay=null!==(a=t.delay)&&void 0!==a?a:0;var n=t.content.interaction;this.bounding=n&&JSON.parse(JSON.stringify(n)),t.type!==e.spec.ItemType.camera&&t.type!==e.spec.ItemType.light||(this.timeline=new e.TimelineComponent(t.content,this),this.timeline.getRenderData(0,!0)),t.type===e.spec.ItemType.skybox&&this.overwriteSkyboxFromCache(t.content.options)},n.prototype.handleVisibleChanged=function(t){void 0!==this.content&&this.content.onVisibleChanged(t)},n.prototype.doCreateContent=function(t){var e,a;switch(null===(e=this.options)||void 0===e?void 0:e.type){case"mesh":var n=this.options.content.options;oe.assertModelMeshOptions(n);var r=null===(a=this.composition)||void 0===a?void 0:a.getEngine();return new Ye(r,this.options,this);case"camera":var o=this.options.content.options;oe.assertModelCameraOptions(o);var i=t.width,s=t.height;return new De(this.options,i,s,this);case"light":var c=this.options.content.options;return oe.assertModelLightOptions(c),new ke(this.options,this);case"skybox":var u=this.options.content.options;return oe.assertModelSkyboxOptions(u),new Le(this.options,this);default:throw new Error("Invalid model item type, options: ".concat(this.options))}},n.prototype.overwriteSkyboxFromCache=function(t){var e,a=(null===(e=this.composition)||void 0===e?void 0:e.loaderData.cache).getSkyboxOptions();void 0!==a&&(void 0===t.specularImage||void 0===t.diffuseImage&&void 0===t.irradianceCoeffs)&&(t.diffuseImage=a.diffuseImage,t.irradianceCoeffs=a.irradianceCoeffs,t.specularImage=a.specularImage,t.specularImageSize=a.specularImageSize,t.specularMipCount=a.specularMipCount)},n.prototype.computeBoundingBox=function(){var t;if(void 0!==this._content&&this._content instanceof Ye){var a=ct.fromArray(this.transform.getWorldMatrix()),n=this._content.computeBoundingBox(a),r=n.getCenter(new S),o=n.getSize(new S);return this.bounding={behavior:null===(t=this.bounding)||void 0===t?void 0:t.behavior,type:e.spec.ModelBoundingType.box,center:[r.x,r.y,r.z],size:[o.x,o.y,o.z]},this.bounding}},n.prototype.updateTransform=function(){var t=this._content;if(void 0!==t){var e=new ct;e.setData(this.transform.getWorldMatrix()),t.matrix=e,t instanceof De&&this.composition&&(this.composition.camera.position=this.transform.position,this.composition.camera.setQuat(this.transform.quat),this.composition.camera.near=t.nearPlane,this.composition.camera.far=t.farPlane,this.composition.camera.fov=t.fovy)}},n.prototype.updateTransformPosition=function(t,e,a){var n;null===(n=this.timeline)||void 0===n||n.updatePosition(t,e,a),this.transform.setPosition(t,e,a)},n.prototype.onLifetimeBegin=function(t,e){void 0!==this.content&&(this.content instanceof Ye&&this.parent instanceof oa&&this.content.updateParentItem(this.parent),this.content.onVisibleChanged(!0))},n.prototype.onItemUpdate=function(t,e){var a,n=.001*(this.timeInms-this.delayInms);null===(a=this.timeline)||void 0===a||a.getRenderData(n,!0),this.updateTransform()},n.prototype.onItemRemoved=function(t,e){void 0!==this.content&&(this.content.onEntityRemoved(),this.content.dispose())},n.prototype.getHitTestParams=function(t){this.computeBoundingBox();var a=this.bounding;if(a&&(t||Number.isInteger(a.behavior))){var n=a.type;if(n===e.spec.ModelBoundingType.box){if(this.content instanceof Ye){var r=this.content;return{behavior:a.behavior,type:e.HitTestType.custom,collect:function(t,e){var a=S.fromArray(t.center),n=S.fromArray(t.direction);return r.hitTesting(a,n)}}}var o=this.transform.getWorldMatrix();return{behavior:a.behavior,type:e.HitTestType.custom,collect:function(t,e){return Vt(t,o,a)}}}if(n===e.spec.ModelBoundingType.sphere){var i=[0,0,0];this.transform.assignWorldTRS(i);var s=a.center?a.center.slice():[0,0,0];return s[0]+=i[0],s[1]+=i[1],s[2]+=i[2],{type:n,behavior:a.behavior,radius:a.radius||0,center:s}}}},n}(e.VFXItem),sa=function(n){function o(){var t=null!==n&&n.apply(this,arguments)||this;return t.name="model",t.deltaTime=0,t.runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,t.compatibleMode="gltf",t.renderSkybox=!0,t.visBoundingBox=!1,t.autoAdjustScene=!1,t.enableDynamicSort=!1,t.renderMode3D=e.spec.RenderMode3D.none,t.renderMode3DUVGridSize=1/16,t}return r(o,n),o.prepareResource=function(t,e){var a,n,r;return i(this,void 0,void 0,(function(){var o,i,c,u,d;return s(this,(function(s){switch(s.label){case 0:return o=null!==(a=e.env)&&void 0!==a?a:"",i="gltf",c=!1,void 0!==e.pluginData&&(u=["compatibleMode","renderSkybox","visBoundingBox","autoAdjustScene","enableDynamicSort","renderMode3D","renderMode3DUVGridSize"],d=e.pluginData,u.forEach((function(e){return t.storage[e]=d[e]})),t.storage.runtimeEnv=o,i=null!==(n=e.pluginData.compatibleMode)&&void 0!==n?n:i,c=null!==(r=e.pluginData.autoAdjustScene)&&void 0!==r?r:c),$t.preprocessEffectsScene(t,o,i,c),[4,ze.loadStaticResources()];case 1:return s.sent(),[2]}}))}))},o.prototype.onCompositionConstructed=function(t,e){var a,n,r,o,i,s,c,u;this.runtimeEnv=null!==(a=e.storage.runtimeEnv)&&void 0!==a?a:this.runtimeEnv,this.compatibleMode=null!==(n=e.storage.compatibleMode)&&void 0!==n?n:this.compatibleMode,this.renderSkybox=null!==(r=e.storage.renderSkybox)&&void 0!==r?r:this.renderSkybox,this.visBoundingBox=null!==(o=e.storage.visBoundingBox)&&void 0!==o?o:this.visBoundingBox,this.autoAdjustScene=null!==(i=e.storage.autoAdjustScene)&&void 0!==i?i:this.autoAdjustScene,this.enableDynamicSort=null!==(s=e.storage.enableDynamicSort)&&void 0!==s?s:this.enableDynamicSort,this.renderMode3D=null!==(c=e.storage.renderMode3D)&&void 0!==c?c:this.renderMode3D,this.renderMode3DUVGridSize=null!==(u=e.storage.renderMode3DUVGridSize)&&void 0!==u?u:this.renderMode3DUVGridSize;var d=t.renderer.engine;t.loaderData.sceneManager=new Ke(d);var l=new ze(d);l.setup(!1),t.loaderData.cache=l,$t.setupItem3DOptions(e,l,t)},o.prototype.onCompositionWillReset=function(t,e){this.getCache(t).getRenderPasses().forEach((function(t){e.removeRenderPass(t)})),this.getSceneManager(t).removeAllMeshesFromDefaultPass(e)},o.prototype.onCompositionReset=function(t,e){var a=this.getSceneManager(t),n=this.getCache(t),r=this.getLightItemCount(t);a.initial({componentName:"".concat(t.id),renderer:t.renderer,sceneCache:n,runtimeEnv:this.runtimeEnv,compatibleMode:this.compatibleMode,visBoundingBox:this.visBoundingBox,enableDynamicSort:this.enableDynamicSort,renderMode3D:this.renderMode3D,renderMode3DUVGridSize:this.renderMode3DUVGridSize,renderSkybox:this.renderSkybox,lightItemCount:r}),this.updateSceneCamera(t,a)},o.prototype.onCompositionDestroyed=function(t){this.disposeSceneManager(t),this.disposeCache(t)},o.prototype.onCompositionUpdate=function(t,e){this.deltaTime=e},o.prototype.onCompositionItemLifeBegin=function(t,e){e.type===a&&this.getSceneManager(t).addItem(e)},o.prototype.onCompositionItemRemoved=function(t,e){e.type===a&&this.getSceneManager(t).removeItem(e)},o.prototype.prepareRenderFrame=function(t,n){var r,o,i,s=this.getSceneManager(t);if(this.autoAdjustScene&&1==s.tickCount){var c=t.camera,u=(new Lt).fromEffectsTransform(c),d=(new Ft).fromPTransform(u).zAxis.clone(),l=null!==(r=c.fov)&&void 0!==r?r:45,h=null!==(o=c.aspect)&&void 0!==o?o:1,f=s.getSceneAABB(),p=f.clone().transform(u.getMatrix()).getSize(new S).multiplyScalar(.5),m=p.x,_=p.y,g=_*Math.max(m/_/h,1),y=f.getCenter(new S),v=g/Math.tan(.5*l*e.DEG2RAD),x=y.clone().addVector(d.clone().multiplyScalar(v+p.z));t.camera.position=x.toArray(),null===(i=t.items)||void 0===i||i.forEach((function(t){if(t.type===a){var e=t;if(e.content instanceof De){var n=ct.fromArray(e.transform.parentTransform.getWorldMatrix()).inverse().multiplyByPoint3(x);e.updateTransformPosition(n.x,n.y,n.z),console.info("Scene AABB [".concat(f.min.toArray(),"], [").concat(f.max.toArray(),"]")),console.info("Update camera position [".concat(n.toArray(),"]"))}}}))}return this.updateSceneCamera(t,s),s.tick(this.deltaTime),s.updateDefaultRenderPass(n),!0},o.prototype.postProcessFrame=function(t,e){this.getSceneManager(t).shadowManager.updateRenderPass(e)},o.prototype.getLightItemCount=function(e){var a=0;return e.items.forEach((function(e){var n,r;e instanceof ia&&((null===(n=e.content)||void 0===n?void 0:n.type)!==t.PObjectType.light&&"light"!==(null===(r=e.options)||void 0===r?void 0:r.type)||a++)})),a},o.prototype.updateSceneCamera=function(t,e){e.updateDefaultCamera(t.camera.getOptions())},o.prototype.getSceneManager=function(t){return t.loaderData.sceneManager},o.prototype.getCache=function(t){return t.loaderData.cache},o.prototype.disposeCache=function(t){var e=t.loaderData;e.cache.dispose(),delete e.cache},o.prototype.disposeSceneManager=function(t){var e=t.loaderData;e.sceneManager.dispose(),delete e.sceneManager},o}(e.AbstractPlugin),ca=function(t){function a(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="tree",e.order=2,e}return r(a,t),a.prototype.onCompositionConstructed=function(t,e){var a=t.getEngine(),n=new ge(a);t.loaderData.animSystem=n},a.prototype.onCompositionWillReset=function(t,e){var a=this.getAnimationSystem(t);void 0!==a&&a.dispose()},a.prototype.onCompositionDestroyed=function(t){var e=this.getAnimationSystem(t);void 0!==e&&e.dispose(),delete t.loaderData.animSystem},a.prototype.onCompositionItemLifeBegin=function(t,a){if(a.type===e.VFX_ITEM_TYPE_TREE){var n=this.getAnimationSystem(t),r=a.content;null==n||n.insert(r.animationManager)}},a.prototype.onCompositionItemRemoved=function(t,a){if(a.type===e.VFX_ITEM_TYPE_TREE){var n=this.getAnimationSystem(t),r=a.content;null==n||n.delete(r.animationManager)}},a.prototype.getAnimationSystem=function(t){var e=t.loaderData.animSystem;if(void 0!==e)return e},a}(e.AbstractPlugin);t.CameraGestureType=void 0,(na=t.CameraGestureType||(t.CameraGestureType={}))[na.none=0]="none",na[na.translate=1]="translate",na[na.rotate_focus=2]="rotate_focus",na[na.rotate_self=3]="rotate_self",na[na.scale=4]="scale";var ua,da=function(){function a(e){this.composition=e,this.cameraTransform=new Lt,this.cameraCoordiante=new Ft,this.startParams={type:t.CameraGestureType.none,mouseEvent:!1,clientX:0,clientY:0,clientWidth:512,clientHeight:512,target:""}}return a.prototype.getItem=function(){var t,e=this;return null===(t=this.composition.items)||void 0===t?void 0:t.find((function(t){return t.id===e.getCurrentTarget()}))},a.prototype.getCurrentTarget=function(){return this.startParams.target},a.prototype.getCurrentType=function(){return this.startParams.type},a.prototype.onKeyEvent=function(a){var n,r,i,s;this.startParams.target!==a.cameraID&&(this.startParams.target=a.cameraID,this.startParams.type=t.CameraGestureType.translate);var c=this.getItem();if(void 0===c)return console.warn("can't find camera item ".concat(this.startParams.target)),this.composition.camera.getOptions();var u=this.composition.camera,d=new e.Transform(o(o({},u.getOptions()),{valid:!0})),l=(new Lt).fromEffectsTransform(d),h=(new Ft).fromPTransform(l),f=null!==(n=a.xAxis)&&void 0!==n?n:0,p=null!==(r=a.yAxis)&&void 0!==r?r:0,m=null!==(i=a.zAxis)&&void 0!==i?i:0,_=h.xAxis.multiplyScalar(f);if(_.addVector(h.yAxis.multiplyScalar(p)),_.addVector(h.zAxis.multiplyScalar(m)),_.lengthSquared()<1e-5)return u.getOptions();_.normalize();var g=null!==(s=a.speed)&&void 0!==s?s:.1,y=l.getPosition();return y.addVector(_.clone().multiplyScalar(g)),c.transform.setPosition(y.x,y.y,y.z),c.updateTransform(),this.startParams.type===t.CameraGestureType.rotate_self&&(this.cameraTransform.setPosition(y),this.cameraCoordiante.origin=y),u.getOptions()},a.prototype.onXYMoveBegin=function(e,a,n,r,o){var i={type:t.CameraGestureType.translate,mouseEvent:!0,clientX:e,clientY:a,clientWidth:n,clientHeight:r,target:o};return this.startGesture(i)},a.prototype.onXYMoving=function(e,a,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,o={type:t.CameraGestureType.translate,mouseEvent:!0,clientX:e,clientY:a,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:null!=n?n:.015};return this.moveGesture(o)},a.prototype.onXYMoveEnd=function(){this.endGesture()},a.prototype.onZMoveBegin=function(e,a,n,r,o){var i={type:t.CameraGestureType.scale,mouseEvent:!0,clientX:e,clientY:a,clientWidth:n,clientHeight:r,target:o};return this.startGesture(i)},a.prototype.onZMoving=function(e,a,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,o={type:t.CameraGestureType.scale,mouseEvent:!0,clientX:e,clientY:a,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:null!=n?n:.015};return this.moveGesture(o)},a.prototype.onZMoveEnd=function(){this.endGesture()},a.prototype.onRotateBegin=function(e,a,n,r,o){var i={type:t.CameraGestureType.rotate_self,mouseEvent:!0,clientX:e,clientY:a,clientWidth:n,clientHeight:r,target:o};return this.startGesture(i)},a.prototype.onRotating=function(e,a,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,o={type:t.CameraGestureType.rotate_self,mouseEvent:!0,clientX:e,clientY:a,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:null!=n?n:1.5};return this.moveGesture(o)},a.prototype.onRotateEnd=function(){this.endGesture()},a.prototype.onRotatePointBegin=function(e,a,n,r,o,i){var s={type:t.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:e,clientY:a,clientWidth:n,clientHeight:r,focusPoint:o,target:i};return this.startGesture(s)},a.prototype.onRotatingPoint=function(e,a,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,o={type:t.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:e,clientY:a,clientWidth:r.clientWidth,clientHeight:r.clientHeight,focusPoint:r.focusPoint,target:r.target,speed:null!=n?n:8};return this.moveGesture(o)},a.prototype.onRotatePointEnd=function(){this.endGesture()},a.prototype.moveTo=function(e,a){var n;this.startParams.target=e,this.startParams.type=t.CameraGestureType.none;var r=this.getItem();void 0!==r?((n=r.transform).setPosition.apply(n,u([],c(a),!1)),r.updateTransform()):console.warn("can't find camera item")},a.prototype.rotateTo=function(e,a){var n;this.startParams.target=e,this.startParams.type=t.CameraGestureType.none;var r=this.getItem();void 0!==r?((n=r.transform).setQuaternion.apply(n,u([],c(a),!1)),r.updateTransform()):console.warn("can't find camera item")},a.prototype.onFocusPoint=function(e,a,n){this.startParams.target=e,this.startParams.type=t.CameraGestureType.none;var r=this.getItem();if(void 0!==r){var o=null!=n?n:5,i=S.fromArray(a),s=(new Lt).fromEffectsTransform(r.transform),c=(new Ft).fromPTransform(s).zAxis.clone().multiplyScalar(1).clone().multiplyScalar(o),u=i.clone().addVector(c);r.transform.setPosition(u.x,u.y,u.z),r.updateTransform(),this.startParams.target=""}else console.warn("can't find camera item")},a.prototype.getCameraTransform=function(){var t=this.composition.camera,a=new e.Transform(t.getOptions());return a.setValid(!0),a},a.prototype.initKeyEvent=function(e,a){this.startParams.target=e,this.startParams.speed=a,this.startParams.type=t.CameraGestureType.translate,this.updateCameraTransform(this.composition.camera.getOptions())},a.prototype.startGesture=function(t){return this.startParams=t,this.updateCameraTransform(this.composition.camera.getOptions()),this.getItem()||console.warn("invalid target"),this.composition.camera.getOptions()},a.prototype.moveGesture=function(e){var a;if(this.getCurrentType()===e.type){var n=this.getItem();if(void 0===n)return console.warn("can't find camera item"),this.composition.camera.getOptions();var r=null!==(a=e.speed)&&void 0!==a?a:1.015,o=this.cameraCoordiante.xAxis,i=this.cameraCoordiante.yAxis,s=this.cameraCoordiante.zAxis,c=e.clientX-this.startParams.clientX,u=e.clientY-this.startParams.clientY;if(e.type===t.CameraGestureType.translate)(d=this.cameraTransform.getPosition().clone()).addVector(o.clone().multiplyScalar(-c*r)),d.addVector(i.clone().multiplyScalar(u*r)),n.transform.setPosition(d.x,d.y,d.z),n.updateTransform();else if(e.type===t.CameraGestureType.scale){var d;(d=this.cameraTransform.getPosition().clone()).addVector(s.clone().multiplyScalar(u*r)),n.transform.setPosition(d.x,d.y,d.z),n.updateTransform()}else if(e.type===t.CameraGestureType.rotate_self){var l=c/e.clientWidth,h=u/e.clientHeight,f=l*Math.PI*r*.5,p=h*Math.PI*r*.5,m=J.fromAxisAngle(S.UNIT_Y,-f,new J),_=J.fromAxisAngle(o,-p,new J);m.multiply(_),m.multiply(this.cameraTransform.getRotation()),n.transform.setQuaternion(m.x,m.y,m.z,m.w),n.updateTransform()}else if(e.type===t.CameraGestureType.rotate_focus){l=c/e.clientWidth,h=u/e.clientHeight,f=l*Math.PI*r,p=h*Math.PI*r,m=J.fromAxisAngle(S.UNIT_Y,-f,new J),_=J.fromAxisAngle(o,-p,new J);m.multiply(_);var g=m.toMatrix4(new ct),y=S.fromArray(e.focusPoint),v=this.cameraCoordiante.origin.clone().subVector(y);g.multiplyByPoint3(v);var x=v.addVector(y);m.multiply(this.cameraTransform.getRotation()),n.transform.setPosition(x.x,x.y,x.z),n.transform.setQuaternion(m.x,m.y,m.z,m.w),n.updateTransform()}else console.warn("not implement")}else console.warn("invalid move type");return this.composition.camera.getOptions()},a.prototype.endGesture=function(){this.startParams.type=t.CameraGestureType.none,this.startParams.mouseEvent=!1,this.startParams.target=""},a.prototype.updateCameraTransform=function(t){var a=new e.Transform(t);a.setValid(!0),this.cameraTransform.fromEffectsTransform(a),this.cameraCoordiante.fromPTransform(this.cameraTransform)},a}(),la=function(){function a(){}return a.getTransformFromMat4=function(t){var e=ct.decompose(t);return{position:e.translation.xyz,rotation:a.getEulerFromQuat(e.rotation),scale:e.scale.xyz}},a.getEffectsTransformFromMat4=function(t){var a=new e.Transform({valid:!0});return a.cloneFromMatrix(t.toArray()),{position:a.position,rotation:a.rotation,scale:a.scale}},a.getTransformFromTranslation=function(t){return{position:t.xyz}},a.getTransformFromDirection=function(t){var e=S.fromArray([1,0,0]),n=t.clone().normalize(),r=S.cross(e,n);if(r.length()<.01)return{};r.normalize();var o=S.dot(n,e),i=Math.acos(o),s=ct.IDENTITY.clone().rotate(i,r);return a.getTransformFromMat4(s)},a.getEffectsTransformFromDirection=function(t){var e=S.fromArray([0,0,1]),n=t.clone().normalize(),r=S.cross(e,n);if(r.length()<.01)return{};r.normalize();var o=S.dot(n,e),i=Math.acos(o),s=ct.IDENTITY.clone().rotate(i,r);return a.getEffectsTransformFromMat4(s)},a.getTransformFromTransDir=function(t,e){var n=a.getTransformFromDirection(e);return n.position=t.xyz,n},a.getEffectsTransformFromTransDir=function(t,e){var n=a.getEffectsTransformFromDirection(e);return n.position=t.xyz,n},a.getEulerFromQuat=function(e){var a=new Z,n=new J(e.x,e.y,e.z,e.w);return a.order=t.EulerOrder.ZYX,a.setFromQuaternion(n),[a.x,a.y,a.z]},a.getQuatFromEuler=function(t){var e=new J;return e.setFromEuler(t),[e.x,e.y,e.z,e.w]},a.toPlayerColor3=function(t){return[a.scaleTo255(t[0]),a.scaleTo255(t[1]),a.scaleTo255(t[2])]},a.toPlayerColor4=function(t){return[a.scaleTo255(t[0]),a.scaleTo255(t[1]),a.scaleTo255(t[2]),a.scaleTo255(t[3])]},a.scaleTo255=function(t){var e=255*t;return Math.max(0,Math.min(e,255))},a.scaleTo1=function(t){var e=t/255;return Math.max(0,Math.min(e,1))},a}();var ha=function(){function a(){}return a.prototype.initial=function(t,e){this.engine=t,this._loaderOptions=null!=e?e:{}},a.prototype.processLight=function(t,e){var a=this;t.forEach((function(t){void 0===t.color?t.color=e?[255,255,255,255]:[1,1,1,1]:(t.color[0]=a.scaleColorVal(t.color[0],e),t.color[1]=a.scaleColorVal(t.color[1],e),t.color[2]=a.scaleColorVal(t.color[2],e),t.color[3]=a.scaleColorVal(t.color[3],e))}))},a.prototype.processCamera=function(t,e){var a=e?180/Math.PI:Math.PI/180;t.forEach((function(t){void 0!==t.perspective&&(t.perspective.yfov*=a)}))},a.prototype.processMaterial=function(t,e){var a=this;t.forEach((function(t){void 0===t.baseColorFactor?t.baseColorFactor=e?[255,255,255,255]:[1,1,1,1]:(t.baseColorFactor[0]=a.scaleColorVal(t.baseColorFactor[0],e),t.baseColorFactor[1]=a.scaleColorVal(t.baseColorFactor[1],e),t.baseColorFactor[2]=a.scaleColorVal(t.baseColorFactor[2],e),t.baseColorFactor[3]=a.scaleColorVal(t.baseColorFactor[3],e)),void 0===t.emissiveFactor?t.emissiveFactor=e?[255,255,255,255]:[1,1,1,1]:(t.emissiveFactor[0]=a.scaleColorVal(t.emissiveFactor[0],e),t.emissiveFactor[1]=a.scaleColorVal(t.emissiveFactor[1],e),t.emissiveFactor[2]=a.scaleColorVal(t.emissiveFactor[2],e),t.emissiveFactor[3]=a.scaleColorVal(t.emissiveFactor[3],e)),e&&void 0!==t.occlusionTexture&&void 0===t.occlusionTexture.strength&&(t.occlusionTexture.strength=a.isTiny3dMode()?0:1)}))},a.prototype.createTreeOptions=function(t){return{nodes:t.nodes.map((function(t,e){var a,n,r,o=t.children.map((function(t){if(void 0===t.nodeIndex)throw new Error("Undefined nodeIndex for child ".concat(t));return t.nodeIndex}));if(void 0!==t.matrix){if(16!==t.matrix.length)throw new Error("Invalid matrix length ".concat(t.matrix.length," for node ").concat(t));var i=ct.fromArray(t.matrix).decompose();a=i.translation.toArray(),n=i.rotation.toArray(),r=i.scale.toArray()}else void 0!==t.translation&&(a=t.translation),void 0!==t.rotation&&(n=t.rotation),void 0!==t.scale&&(r=t.scale);return t.nodeIndex=e,{name:t.name,transform:{position:a,quat:n,scale:r},children:o,id:"".concat(t.nodeIndex)}})),children:t.rootNodes.map((function(t){if(void 0===t.nodeIndex)throw new Error("Undefined nodeIndex for root ".concat(t));return t.nodeIndex})),animation:-1,animations:[]}},a.prototype.createAnimations=function(t){return t.map((function(t){var e=t.channels.map((function(t){return{input:t.input.array,output:t.output.array,node:t.target.node,path:t.target.path,interpolation:t.interpolation}}));return{name:t.name,tracks:e}}))},a.prototype.createGeometry=function(t,e){return new pa(this.engine,t,e).geometry},a.prototype.createMaterial=function(t){return new ma(t,[],this.isTiny3dMode()).material},a.prototype.createTexture2D=function(t,e,a){return Qt.createTexture2D(this.engine,t,e,a,this.isTiny3dMode())},a.prototype.createTextureCube=function(t,e){var a=this;if(0==t.length)throw new Error("createTextureCube: Invalid cubeImages length ".concat(t));var n=[];return t.forEach((function(t){var e;if(6!=t.length)throw new Error("createTextureCube: cubeimage count should always be 6, ".concat(t));var r=[];t.forEach((function(t){if(void 0===t.imageData)throw new Error("createTextureCube: Invalid image data from ".concat(t));r.push({type:"buffer",data:t.imageData,mimeType:t.mimeType})})),a.isTiny3dMode()&&(e=c([r[5],r[4]],2),r[4]=e[0],r[5]=e[1]),n.push(r)})),1==n.length?Qt.createTextureCubeFromBuffer(this.engine,n[0]):Qt.createTextureCubeMipmapFromBuffer(this.engine,n,null!=e?e:Math.pow(2,n.length-1))},a.prototype.createSkybox=function(t){var e,a,n=this,r=null!==(e=t.reflectionsIntensity)&&void 0!==e?e:t.intensity,o=t.irradianceCoefficients,i=t.specularImages.map((function(t){var e,a=t.map((function(t){return{type:"buffer",data:t.imageData,mimeType:t.mimeType}}));return n.isTiny3dMode()&&(e=c([a[5],a[4]],2),a[4]=e[0],a[5]=e[1]),a})),s=i.length-1,u=null!==(a=t.specularImageSize)&&void 0!==a?a:Math.pow(2,s),d={type:"buffer",renderable:this.isSkyboxVis(),intensity:t.intensity,reflectionsIntensity:r,irradianceCoeffs:o,specularImage:i,specularMipCount:s,specularImageSize:u};return Re.createSkyboxOptions(this.engine,d)},a.prototype.createDefaultSkybox=function(e){if("NFT"!==e&&"FARM"!==e)throw new Error("Invalid skybox type name ".concat(e));var a="NFT"===e?t.PSkyboxType.NFT:t.PSkyboxType.FARM,n=Re.getSkyboxParams(a);return Re.createSkyboxOptions(this.engine,n)},a.prototype.scaleColorVal=function(t,e){return e?la.scaleTo255(t):la.scaleTo1(t)},a.prototype.scaleColorVec=function(t,e){var a=this;return t.map((function(t){return a.scaleColorVal(t,e)}))},a.prototype.loadScene=function(t){var a;return i(this,void 0,void 0,(function(){var n,r,o,i,c,u=this;return s(this,(function(s){switch(s.label){case 0:if(this._clear(),this._sceneOptions=t,this.engine=null===(a=t.effects.renderer)||void 0===a?void 0:a.engine,this._loaderOptions={compatibleMode:t.gltf.compatibleMode},"string"==typeof(n=t.gltf.resource)||n instanceof Uint8Array)throw new Error("Please load resource by GLTFTools at first");return this._gltfScene=n.scenes[0],this._gltfSkins=this._gltfScene.skins,this._gltfMeshs=n.meshes,this._gltfLights=this._gltfScene.lights,this._gltfCameras=this._gltfScene.cameras,this._gltfImages=n.images,this._gltfTextures=n.textures,this._gltfMaterials=n.materials,this._gltfAnimations=n.animations,this._gltfImageBasedLights=n.imageBasedLights,[4,this._preprocess()];case 1:return s.sent(),o="sceneTree",(r=[]).push(this._createItemTree(o,this._gltfScene)),void 0!==(i=this._createItemSkybox())&&r.push(i),this._gltfScene.nodes.forEach((function(t){if(void 0!==t.mesh){var e=u._createItemMesh(t,o);void 0!==e&&r.push(e)}if(void 0!==t.light){var a=u._createItemLight(t,o);void 0!==a&&r.push(a)}if(void 0!==t.camera){var n=u._createItemCamera(t,o);void 0!==n&&r.push(n)}})),c=new Ot,this._gltfScene.rootNodes.forEach((function(t){var a=new e.Transform({valid:!0});u._computeSceneAABB(t,a,c)})),[2,{source:this.getRemarkString(),items:r,sceneAABB:{min:c.min.toArray(),max:c.max.toArray()}}]}}))}))},a.prototype._preprocess=function(){return i(this,void 0,void 0,(function(){var e,a,n,r,o,i,u,d=this;return s(this,(function(s){switch(s.label){case 0:this.getTextureManager().initial(this._gltfImages,this._gltfTextures),e=0,s.label=1;case 1:return e<this._gltfMaterials.length?(a=this._gltfMaterials[e],[4,this.tryAddTexture2D(e,a.baseColorTexture,!0)]):[3,8];case 2:return s.sent(),_a.isUnlitMaterial(a)?[3,7]:[4,this.tryAddTexture2D(e,a.metallicRoughnessTexture,!1)];case 3:return s.sent(),[4,this.tryAddTexture2D(e,a.normalTexture,!1)];case 4:return s.sent(),[4,this.tryAddTexture2D(e,a.emissiveTexture,!1)];case 5:return s.sent(),[4,this.tryAddTexture2D(e,a.occlusionTexture,!1)];case 6:s.sent(),s.label=7;case 7:return e++,[3,1];case 8:return this._gltfImageBasedLights.length>0&&!this.ignoreSkybox()?(n=this._gltfImageBasedLights[0],this.isEnvironmentTest()&&n.specularImages.forEach((function(t){var e,a;d.isTiny3dMode()&&(e=c([t[5],t[4]],2),t[4]=e[0],t[5]=e[1]),a=c([t[3],t[2]],2),t[2]=a[0],t[3]=a[1]})),r=this,[4,this.createSkybox(n)]):[3,10];case 9:return r._skyboxOptions=s.sent(),[3,12];case 10:return void 0===(o=this.getSkyboxType())?[3,12]:(i=o===t.PSkyboxType.FARM?"FARM":"NFT",u=this,[4,this.createDefaultSkybox(i)]);case 11:u._skyboxOptions=s.sent(),s.label=12;case 12:return this._skyboxOptions&&(this._skyboxOptions.renderable=this.isSkyboxVis()),this._gltfData2PlayerData(this._gltfScene,this._gltfMaterials),[2]}}))}))},a.prototype.tryAddTexture2D=function(t,e,a){var n=this;if(void 0!==e&&void 0===this.getTexture2D(t,e,a,!0)){var r=e.index,o=this._gltfTextures[r],i=this._gltfImages[o.source];return Qt.createTexture2D(this.engine,i,o,a,this.isTiny3dMode()).then((function(e){n.getTextureManager().addTexture(t,r,e,a)}))}},a.prototype.getTexture2D=function(t,e,a,n){if(void 0!==e){var r=e.index,o=this.getTextureManager().getTexture(t,r,a);return void 0===o&&!0!==n&&console.warn("Can't find texture for mat ".concat(t,", tex ").concat(JSON.stringify(e),", basecolor ").concat(a)),o}},a.prototype._gltfData2PlayerData=function(t,e){this.processCamera(t.cameras,!0),this.processLight(t.lights,!0),this.processMaterial(e,!0)},a.prototype._createItemTree=function(t,a){var n=this.createTreeOptions(a),r=this.createAnimations(this._gltfAnimations);return n.animations=r,n.animation=this.getPlayAnimationIndex(n),{id:t,name:a.name,duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:e.spec.ItemType.tree,content:{options:{tree:n}}}},a.prototype._createItemMesh=function(t,a){var n,r,o=this,i=t.mesh;if(void 0===i)throw new Error("Invalid mesh index in node ".concat(t));if(void 0!==t.skin){var s=this._gltfSkins[t.skin];r={name:s.name,joints:s.jointIndexList,skeleton:s.skeleton,inverseBindMatrices:s.inverseBindMatrices}}var c=this._gltfMeshs[i],u=c.primitives.map((function(t){var a=t.material,n=o._gltfMaterials[a],i=o.createGeometry(t,void 0!==r),s=o.createMaterial(n);return s.baseColorTexture=o.getTexture2D(a,n.baseColorTexture,!0),s.type===e.spec.MaterialType.pbr&&(s.metallicRoughnessTexture=o.getTexture2D(a,n.metallicRoughnessTexture,!1),s.normalTexture=o.getTexture2D(a,n.normalTexture,!1),s.emissiveTexture=o.getTexture2D(a,n.emissiveTexture,!1),s.occlusionTexture=o.getTexture2D(a,n.occlusionTexture,!1)),{geometry:i,material:s}})),d={parent:t.nodeIndex,skin:r,primitives:u,weights:c.weights},l=_a.createBoxFromGLTFBound(c.bounds),h=l.getSize(new S),f=l.getCenter(new S),p={behavior:e.spec.InteractBehavior.NOTIFY,type:e.spec.ModelBoundingType.box,size:[h.x,h.y,h.z],center:[f.x,f.y,f.z]};return{id:"mesh_ni".concat(null!==(n=t.nodeIndex)&&void 0!==n?n:0,"_mi").concat(i),parentId:"".concat(a,"^").concat(t.nodeIndex),name:c.name,duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:e.spec.ItemType.mesh,pluginName:"model",content:{options:d,interaction:p}}},a.prototype._createItemLight=function(t,a){var n,r,o=t.light;if(void 0!==o){var i=this._gltfLights[o],s=this.createLightOptions(i);return{id:"light_ni".concat(null!==(n=t.nodeIndex)&&void 0!==n?n:0,"_li").concat(o),parentId:"".concat(a,"^").concat(t.nodeIndex),name:null!==(r=i.name)&&void 0!==r?r:"light",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:e.spec.ItemType.light,pluginName:"model",content:{options:s}}}},a.prototype._createItemCamera=function(t,e){var a,n,r=t.camera;if(void 0!==r){var o=this._gltfCameras[r],i=this.createCameraOptions(o);if(void 0!==i)return{id:"camera_ni".concat(null!==(a=t.nodeIndex)&&void 0!==a?a:0,"_ci").concat(r),parentId:"".concat(e,"^").concat(t.nodeIndex),name:null!==(n=o.name)&&void 0!==n?n:"camera",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:"camera",pluginName:"model",content:{options:i}}}},a.prototype._createItemSkybox=function(){if(void 0!==this._skyboxOptions)return{id:"skybox_0",name:"skybox",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:"skybox",pluginName:"model",content:{options:this._skyboxOptions}}},a.prototype._computeSceneAABB=function(t,a,n){var r=this,o={};if(t.matrix){var i=ct.fromArray(t.matrix).decompose();o.position=i.translation.toArray(),o.quat=i.rotation.toArray(),o.scale=i.scale.toArray()}else t.translation&&(o.position=t.translation),t.rotation&&(o.quat=t.rotation),t.scale&&(o.scale=t.scale);var s=new e.Transform(o,a);if(s.setValid(!0),void 0!==t.mesh){var c=this._gltfMeshs[t.mesh],u=_a.createBoxFromGLTFBound(c.bounds);u.transform(ct.fromArray(s.getWorldMatrix())),n.union(u)}t.children.forEach((function(t){r._computeSceneAABB(t,s,n)}))},a.prototype.createLightOptions=function(t){return $t.createLightOptions(t)},a.prototype.createCameraOptions=function(t){return $t.createCameraOptions(t)},a.prototype._clear=function(){this._textureManager&&(this._textureManager.dispose(),this._textureManager=void 0),this._textureManager=new fa(this)},a.prototype.getPlayAnimationIndex=function(t){var e=t.animations;if(void 0===e||e.length<=0)return-1;if(this.isPlayAllAnimation())return-88888888;var a=this._sceneOptions.effects.playAnimation;if(void 0===a)return-1;if("number"==typeof a)return a>=0&&a<e.length?a:-1;var n=-1;return e.forEach((function(t,e){t.name===a&&(n=e)})),n},a.prototype.isPlayAnimation=function(){return void 0!==this._sceneOptions.effects.playAnimation},a.prototype.isPlayAllAnimation=function(){return!0===this._sceneOptions.effects.playAllAnimation},a.prototype.getRemarkString=function(){var t=this._sceneOptions.gltf.remark;return void 0===t?"Unknown":"string"==typeof t?t:"BinaryBuffer"},a.prototype.isTiny3dMode=function(){return"tiny3d"===this._loaderOptions.compatibleMode},a.prototype.getTextureManager=function(){return this._textureManager},a.prototype.getItemDuration=function(){var t;return null!==(t=this._sceneOptions.effects.duration)&&void 0!==t?t:9999},a.prototype.getItemEndBehavior=function(){var t;return null!==(t=this._sceneOptions.effects.endBehavior)&&void 0!==t?t:e.spec.ItemEndBehavior.loop},a.prototype.getSkyboxType=function(){switch(this._sceneOptions.gltf.skyboxType){case"NFT":return t.PSkyboxType.NFT;case"FARM":return t.PSkyboxType.FARM}},a.prototype.isSkyboxVis=function(){return!0===this._sceneOptions.gltf.skyboxVis},a.prototype.ignoreSkybox=function(){return!0===this._sceneOptions.gltf.ignoreSkybox},a.prototype.isEnvironmentTest=function(){return"string"==typeof this._sceneOptions.gltf.remark&&this._sceneOptions.gltf.remark.includes("EnvironmentTest")},a}(),fa=function(){function t(t){this._owner=t,this._gltfImages=[],this._gltfTextures=[],this._textureMap=new Map}return t.prototype.initial=function(t,e){this._gltfImages=t,this._gltfTextures=e,this._textureMap.clear()},t.prototype.dispose=function(){this._textureMap.clear()},t.prototype.addTexture=function(t,e,a,n){var r=n?1e5*t+e:e;this._textureMap.set(r,a)},t.prototype.getTexture=function(t,e,a){var n=a?1e5*t+e:e;return this._textureMap.get(n)},t}(),pa=function(){function t(t,e,a){this.engine=t,this.gltfGeometry=e,this.hasSkinAnimation=a}return Object.defineProperty(t.prototype,"geometry",{get:function(){var t=this,a={};if(!this.hasPosition)throw new Error("Position attribute missing");var n=this.positionAttrib;(a.a_Position=this._getBufferAttrib(n),this.hasNormal)&&(void 0!==(n=this.normalAttrib)&&(a.a_Normal=this._getBufferAttrib(n)));this.hasTangent&&(void 0!==(n=this.tangentAttrib)&&(a.a_Tangent=this._getBufferAttrib(n)));if(this.texCoordList.forEach((function(e){var n=t.texCoordAttrib(e),r="a_UV".concat(e+1);a[r]=t._getBufferAttrib(n)})),this.hasSkinAnimation){var r=this.jointAttribute;void 0!==r&&(a.a_Joint1=this._getBufferAttrib(r));var o=this.weightAttribute;void 0!==o&&(a.a_Weight1=this._getBufferAttrib(o))}for(var i=0;i<8;i++){var s=this.getTargetPosition(i);void 0!==s&&(a["a_Target_Position".concat(i)]=this._getBufferAttrib(s));var c=this.getTargetNormal(i);void 0!==c&&(a["a_Target_Normal".concat(i)]=this._getBufferAttrib(c));var u=this.getTargetTangent(i);void 0!==u&&(a["a_Target_Tangent".concat(i)]=this._getBufferAttrib(u))}var d=this.indexArray;return void 0!==d?e.Geometry.create(this.engine,{attributes:a,indices:{data:d},drawStart:0,drawCount:d.length,mode:e.glContext.TRIANGLES}):e.Geometry.create(this.engine,{attributes:a,drawStart:0,drawCount:this.positionAttrib.array.length/3,mode:e.glContext.TRIANGLES})},enumerable:!1,configurable:!0}),t.prototype._getBufferAttrib=function(t){return{type:t.type,size:t.itemSize,data:t.array,normalize:t.normalized}},Object.defineProperty(t.prototype,"positionAttrib",{get:function(){return this.gltfGeometry.getPosition()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalAttrib",{get:function(){return this.gltfGeometry.getNormal()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tangentAttrib",{get:function(){return this.gltfGeometry.getTangent()},enumerable:!1,configurable:!0}),t.prototype.texCoordAttrib=function(t){return this.gltfGeometry.getTexCoord(t)},Object.defineProperty(t.prototype,"jointAttribute",{get:function(){return this.gltfGeometry.getJoints(0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"weightAttribute",{get:function(){return this.gltfGeometry.getWeights(0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPosition",{get:function(){return void 0!==this.positionAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasNormal",{get:function(){return void 0!==this.normalAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasTangent",{get:function(){return void 0!==this.tangentAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasTexCoord",{get:function(){return this.texCoordCount>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"texCoordCount",{get:function(){for(var t=0;t<10;t++)if(void 0===this.texCoordAttrib(t))return t;return 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasJointAttribute",{get:function(){return void 0!==this.jointAttribute},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasWeightAttribute",{get:function(){return void 0!==this.weightAttribute},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexArray",{get:function(){if(void 0!==this.gltfGeometry.indices)switch(this.gltfGeometry.indices.type){case WebGLRenderingContext.UNSIGNED_INT:case WebGLRenderingContext.UNSIGNED_SHORT:case WebGLRenderingContext.UNSIGNED_BYTE:return this.gltfGeometry.indices.array}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexCount",{get:function(){return void 0!==this.gltfGeometry.indices?this.gltfGeometry.indices.array.length:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"texCoordList",{get:function(){for(var t=[],e=0;e<10&&void 0!==this.texCoordAttrib(e);e++)t.push(e);return t},enumerable:!1,configurable:!0}),t.prototype.getTargetPosition=function(t){return this.gltfGeometry.getAttribute("POSITION".concat(t))},t.prototype.getTargetNormal=function(t){return this.gltfGeometry.getAttribute("NORMAL".concat(t))},t.prototype.getTargetTangent=function(t){return this.gltfGeometry.getAttribute("TANGENT".concat(t))},t}(),ma=function(){function t(t,e,a){this.gltfMaterial=t,this.textures=e,this.tiny3dMode=a}return Object.defineProperty(t.prototype,"material",{get:function(){var t,a,n,r=this.gltfMaterial,o=_a.isUnlitMaterial(r),i=e.spec.MaterialBlending.opaque;switch(r.alphaMode){case"OPAQUE":i=e.spec.MaterialBlending.opaque;break;case"MASK":i=e.spec.MaterialBlending.masked;break;case"BLEND":i=e.spec.MaterialBlending.translucent}var s=r.doubleSided?e.spec.SideMode.DOUBLE:e.spec.SideMode.FRONT,c=null!==(t=r.alphaCutOff)&&void 0!==t?t:.5,u=r.name;return o?{name:u,type:e.spec.MaterialType.unlit,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,depthMask:null===(a=r.extras)||void 0===a?void 0:a.depthMask,blending:i,alphaCutOff:c,side:s}:{name:u,type:e.spec.MaterialType.pbr,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,useSpecularAA:this.getSpecularAA(),metallicRoughnessTexture:this.metallicRoughnessTextureObj,metallicRoughnessTextureCoordinate:this.metallicRoughnessTextureCoord,metallicRoughnessTextureTransform:this.metallicRoughnessTextureTransfrom,metallicFactor:this.metalicFactor,roughnessFactor:this.roughnessFactor,normalTexture:this.normalTextureObj,normalTextureCoordinate:this.normalTextureCoord,normalTextureTransform:this.normalTextureTransfrom,normalTextureScale:this.normalTextureScale,occlusionTexture:this.occlusionTextureObj,occlusionTextureCoordinate:this.occlusionTextureCoord,occlusionTextureTransform:this.occlusionTextureTransfrom,occlusionTextureStrength:this.occlusionTextureStrength,emissiveTexture:this.emissiveTextureObj,emissiveTextureCoordinate:this.emissiveTextureCoord,emissiveTextureTransform:this.emissiveTextureTransfrom,emissiveFactor:this.emissiveFactor,emissiveIntensity:1,depthMask:null===(n=r.extras)||void 0===n?void 0:n.depthMask,blending:i,alphaCutOff:c,side:s,enableShadow:!1}},enumerable:!1,configurable:!0}),t.prototype.getTextureObject=function(t){if(!(t<0||t>=this.textures.length))return this.textures[t]},t.prototype.getTextureObj=function(t){return t?this.getTextureObject(t.index):void 0},t.prototype.getTextureCoord=function(t){return t?t.texCoord:void 0},t.prototype.getTextureTransform=function(t){var e,a=null===(e=null==t?void 0:t.extensions)||void 0===e?void 0:e.KHR_texture_transform;if(void 0!==a&&(void 0!==a.offset||void 0!==a.rotation||void 0!==a.scale))return{offset:a.offset,rotation:a.rotation,scale:a.scale}},Object.defineProperty(t.prototype,"baseColorTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"baseColorTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"baseColorTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metallicRoughnessTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metallicRoughnessTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metallicRoughnessTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"occlusionTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"occlusionTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"occlusionTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"emissiveTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"emissiveTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"emissiveTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasEmissive",{get:function(){var t=this.emissiveFactor;return t[0]+t[1]+t[2]>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"baseColorFactor",{get:function(){var t=this.gltfMaterial.baseColorFactor;return void 0===t||4!=t.length?[1,1,1,1]:[t[0],t[1],t[2],t[3]]},enumerable:!1,configurable:!0}),t.prototype.getSpecularAA=function(){var t;return null===(t=this.gltfMaterial.extras)||void 0===t?void 0:t.useSpecularAA},Object.defineProperty(t.prototype,"metalicFactor",{get:function(){var t;return null!==(t=this.gltfMaterial.metallicFactor)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughnessFactor",{get:function(){var t;return null!==(t=this.gltfMaterial.roughnessFactor)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalTextureScale",{get:function(){var t,e;return null!==(e=null===(t=this.gltfMaterial.normalTexture)||void 0===t?void 0:t.scale)&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"occlusionTextureStrength",{get:function(){var t,e;return null!==(e=null===(t=this.gltfMaterial.occlusionTexture)||void 0===t?void 0:t.strength)&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"emissiveFactor",{get:function(){var t=this.gltfMaterial.emissiveFactor;return void 0===t||4!=t.length?[0,0,0,1]:[t[0],t[1],t[2],1]},enumerable:!1,configurable:!0}),t}(),_a=function(){function t(){}return t.isUnlitMaterial=function(t){var e;return void 0!==(null===(e=t.extensions)||void 0===e?void 0:e.KHR_materials_unlit)},t.createBoxFromGLTFBound=function(t){var e=S.fromArray(t.box.min),a=S.fromArray(t.box.max);return new Ot(e,a)},t}();e.registerPlugin("tree",ca,oa,!0),e.registerPlugin("model",sa,ia);console.debug("[Galacean Effects Plugin Model] version: 1.0.0"),t.Box3=Ot,t.BoxMesh=Ge,t.CameraGestureHandlerImp=da,t.CheckerHelper=oe,t.CompositionCache=ze,t.CompositionHitTest=function(t,e,a){var n=t.hitTest(e,a,!0),r=t.getHitTestRay(e,a);if(n.length<=0)return[];var o=r.center,i=r.direction,s=n.map((function(t,e){for(var a=t.position,n=[0,0,0],r=0;r<3;r++)n[r]=(a[r]-o[r])/i[r];return[e,Math.max.apply(Math,u([],c(n),!1))]}));return s.sort((function(t,e){return(t[1]>=0?t[1]:t[1]+1e9)-(e[1]>=0?e[1]:e[1]+1e9)})),s.map((function(t){return n[t[0]]}))},t.Euler=Z,t.FBOOptions=je,t.Float16ArrayWrapper=ie,t.GeometryBoxProxy=ne,t.HitTestingProxy=re,t.HookOGLFunc=function(t){console.info("HookOGLFunc "+Object.getPrototypeOf(t));var e=0;for(var a in Object.getPrototypeOf(t))"getError"!==a&&"function"==typeof t[a]&&(++e,t[a+$e]=t[a],t[a]=aa(t,a));console.info("HookCount "+e),function(t){for(var e in Object.getPrototypeOf(t))"number"==typeof t[e]&&ta.set(t[e],e)}(t)},t.InterpolationSampler=d,t.LoaderHelper=la,t.LoaderImpl=ha,t.Matrix2=F,t.Matrix3=V,t.Matrix4=ct,t.MeshHelper=Kt,t.ModelPlugin=sa,t.ModelTreeItem=ra,t.ModelTreePlugin=ca,t.ModelTreeVFXItem=oa,t.ModelVFXItem=ia,t.PAnimTexture=pe,t.PAnimTrack=fe,t.PAnimation=me,t.PAnimationManager=_e,t.PAnimationSystem=ge,t.PCamera=De,t.PCameraManager=Ue,t.PCoordinate=Ft,t.PEntity=Dt,t.PGeometry=Je,t.PGlobalState=Rt,t.PLight=ke,t.PLightManager=Ve,t.PMaterialBase=Ie,t.PMaterialPBR=Pe,t.PMaterialSkyboxFilter=Fe,t.PMaterialUnlit=Ee,t.PMesh=Ye,t.PMorph=le,t.PObject=Bt,t.PPrimitive=Ze,t.PSceneManager=Ke,t.PShaderManager=Ae,t.PSkin=de,t.PSkybox=Le,t.PSkyboxCreator=Re,t.PTransform=Lt,t.PluginHelper=$t,t.Quaternion=J,t.RayBoxTesting=jt,t.RayIntersectsBoxWithRotation=Vt,t.RayTriangleTesting=Xt,t.Sphere=Nt,t.ToggleItemBounding=function(e,n){var r;null===(r=e.items)||void 0===r||r.forEach((function(e){if(e.type===a){var r=e;if(r.content.type===t.PObjectType.mesh){var o=r.content;r.id===n?o.visBoundingBox=!0:o.visBoundingBox=!1}}}))},t.TwoStatesSet=He,t.VFX_ITEM_TYPE_3D=a,t.Vector2=y,t.Vector3=S,t.Vector4=P,t.VertexAttribBuffer=ee,t.WebGLHelper=Qt,t.WebHelper=te,t.createAnimationSampler=m,t.createInternalMaterial=function(t){return{}},t.createPluginMaterial=Oe,t.getDefaultEffectsGLTFLoader=function(t,e){return ua||(ua=new ha),ua.initial(t,e),ua},t.getDiffuseOnlyShaderCode=function(t){return{vertexShaderCode:we({hasNormals:!0}),fragmentShaderCode:"\n #version 100\n precision highp float;\n varying vec3 v_Normal;\n void main(){\n vec3 lightDir = normalize(vec3(1, 1, 1));\n gl_FragColor = vec4(max(0.0, dot(v_Normal, lightDir)) * 0.8);\n }\n "}},t.getGaussianBlurShaderCodeV1=function(t){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform vec2 u_BlurScale;\n uniform sampler2D u_FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(-3.0) * u_BlurScale.xy)) * (1.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(-2.0) * u_BlurScale.xy)) * (6.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(-1.0) * u_BlurScale.xy)) * (15.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+0.0) * u_BlurScale.xy)) * (20.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+1.0) * u_BlurScale.xy)) * (15.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+2.0) * u_BlurScale.xy)) * (6.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+3.0) * u_BlurScale.xy)) * (1.0/64.0);\n gl_FragColor = color;\n }\n "}},t.getGaussianBlurShaderCodeV2=Ce,t.getKawaseBlurShaderCode=function(t){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform float u_Offset;\n uniform vec2 u_TextureSizeInv;\n uniform sampler2D u_TexturSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0.0);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2(-u_Offset-0.5,-u_Offset-0.5) * u_TextureSizeInv);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2(-u_Offset-0.5, u_Offset+0.5) * u_TextureSizeInv);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2( u_Offset+0.5,-u_Offset-0.5) * u_TextureSizeInv);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2( u_Offset+0.5, u_Offset+0.5) * u_TextureSizeInv);\n gl_FragColor = color * 0.25;\n }\n "}},t.getNormalVisShaderCode=Me,t.getPBRPassShaderCode=xe,t.getPMeshList=function(e){var n=[],r=e.getCompositions()[0];return null==r||r.items.forEach((function(e){if(e.type===a){var r=e;r.content&&r.content.type===t.PObjectType.mesh&&n.push(r.content)}})),n},t.getQuadFilterShaderCode=function(t){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform sampler2D u_ColorSampler;\n\n varying vec2 v_UVCoord1;\n void main(){\n gl_FragColor = texture2D(u_ColorSampler, v_UVCoord1);\n }\n "}},t.getRendererGPUInfo=function(t){var e=t.gpuCapability;return JSON.stringify(e,void 0,2)},t.getShadowPassShaderCode=be,t.getSimpleFilterShaderCode=Se,t.getSkyBoxShaderCode=Te,t.getTransparecyBaseShader=function(t){return t?we({hasNormals:!0}):"\n #version 100\n #extension GL_EXT_draw_buffers: require\n\n precision highp float;\n uniform vec4 u_BaseColorFactor;\n\n #ifdef HAS_UVS\n uniform sampler2D u_BaseColorSampler;\n varying vec2 v_UVCoord1;\n #endif\n\n varying vec3 v_Normal;\n\n float weight(float z, float a) {\n return clamp(pow(min(1.0, a * 10.0) + 0.01, 3.0) * 1e8 * pow(1.0 - z * 0.9, 3.0), 1e-2, 3e3);\n }\n\n void main() {\n vec4 color = u_BaseColorFactor;\n\n #ifdef HAS_UVS\n color *= texture2D(u_BaseColorSampler, v_UVCoord1);\n #endif\n\n color.rgb *= color.a * dot(normalize(v_Normal), normalize(vec3(0, 1, 3))) * 5.0;\n float w = weight(gl_FragCoord.z, color.a);\n gl_FragData[0] = vec4(color.rgb * w, color.a);\n gl_FragData[1] = vec4(color.a * w);\n }\n "},t.getTransparecyFilterShader=function(t){return t?"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ":"\n #version 100\n precision highp float;\n uniform sampler2D u_AccumColorSampler;\n uniform sampler2D u_AccumAlphaSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 accumColor = texture2D(u_AccumColorSampler, v_UVCoord1);\n vec4 accumAlpha = texture2D(u_AccumAlphaSampler, v_UVCoord1);\n float finalAlpha = 1.0 - accumColor.a;\n vec3 finalColor = accumColor.rgb / clamp(accumAlpha.r, 0.001, 50000.0);\n gl_FragColor = vec4(finalColor, finalAlpha);\n }\n "},t.setDefaultEffectsGLTFLoader=function(t){ua=t},t.version="1.0.0",Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
9
9
|
//# sourceMappingURL=index.min.js.map
|