@galacean/effects-plugin-model 1.6.0-beta.2 → 1.6.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/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: v1.6.0-beta.2
6
+ * Version: v1.6.0
7
7
  */
8
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ge=e.ge||{},e.ge.modelPlugin={}),e.ge)}(this,(function(e,t){"use strict";var n="PluginModel",o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var r=function(){return r=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};function a(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))}function s(e,t){var n,o,i,r,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,i,r=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=r.next()).done;)a.push(o.value)}catch(e){i={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return a}function l(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var u=function(){function e(e,t,n){this.time=e,this.data=t,this.componentCount=n,this.cachedIndex=0}return e.prototype.evaluate=function(e){var t=this.time,n=this.cachedIndex,o=t[n],i=t[n-1];e:{t:{var r=void 0;n:{o:if(!(e<o)){for(var a=n+2;;){if(void 0===o){if(e<i)break o;return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}if(n===a)break;if(i=o,e<(o=t[++n]))break t}r=t.length;break n}if(e>=i)break e;var s=t[1];e<s&&(n=2,i=s);for(a=n-2;;){if(void 0===i)return this.cachedIndex=0,this.copySampleValue(0);if(n===a)break;if(o=i,e>=(i=t[--n-1]))break t}r=n,n=0}for(;n<r;){var c=n+r>>>1;e<t[c]?r=c:n=c+1}if(o=t[n],void 0===(i=t[n-1]))return this.cachedIndex=0,this.copySampleValue(0);if(void 0===o)return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}this.cachedIndex=n,this.intervalChanged(n,i,o)}return this.interpolate(n,i,e,o)},e.prototype.dispose=function(){this.time=void 0,this.data=void 0},e.prototype.copySampleValue=function(e){for(var t=this.data,n=this.componentCount,o=e*n,i=new Float32Array(n),r=0;r!==n;++r)i[r]=t[o+r];return i},e}(),h=function(e){function t(t,n,o){return e.call(this,t,n,o)||this}return i(t,e),t.prototype.intervalChanged=function(e,t,n){},t.prototype.interpolate=function(e,t,n,o){for(var i,r=this.data,a=null!==(i=this.componentCount)&&void 0!==i?i:1,s=e*a,c=s-a,l=(n-t)/(o-t),u=1-l,h=new Float32Array(a),f=0;f!==a;++f)h[f]=r[c+f]*u+r[s+f]*l;return h},t}(u),f=function(e){function t(t,n,o){return e.call(this,t,n,o)||this}return i(t,e),t.prototype.intervalChanged=function(e,t,n){},t.prototype.interpolate=function(e,t,n,o){for(var i,r=this.data,a=null!==(i=this.componentCount)&&void 0!==i?i:1,s=(e-1)*a,c=new Float32Array(a),l=0;l!==a;++l)c[l]=r[s+l];return c},t}(u),d=function(){function e(){}return e.slerpFlat=function(e,t,n,o,i,r,a){var s=n[o+0],c=n[o+1],l=n[o+2],u=n[o+3],h=i[r+0],f=i[r+1],d=i[r+2],p=i[r+3];if(0===a)return e[t+0]=s,e[t+1]=c,e[t+2]=l,void(e[t+3]=u);if(1===a)return e[t+0]=h,e[t+1]=f,e[t+2]=d,void(e[t+3]=p);if(u!==p||s!==h||c!==f||l!==d){var m=1-a,g=s*h+c*f+l*d+u*p,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),T=Math.atan2(b,g*v);m=Math.sin(m*T)/b,a=Math.sin(a*T)/b}var _=a*v;if(s=s*m+h*_,c=c*m+f*_,l=l*m+d*_,u=u*m+p*_,m===1-a){var x=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=x,c*=x,l*=x,u*=x}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u},e}(),p=function(e){function t(t,n,o){return e.call(this,t,n,o)||this}return i(t,e),t.prototype.intervalChanged=function(e,t,n){},t.prototype.interpolate=function(e,t,n,o){for(var i,r=this.data,a=null!==(i=this.componentCount)&&void 0!==i?i:1,s=(n-t)/(o-t),c=e*a,l=new Float32Array(a),u=c+a;c!==u;c+=4)d.slerpFlat(l,0,r,c-a,r,c,s);return l},t}(u);function m(e,t,n,o,i){switch(e){case"LINEAR":return"rotation"===i?new p(t,n,o):new h(t,n,o);case"STEP":return new f(t,n,o);default:return new h(t,n,o)}}var g=t.math.Vector2,v=t.math.Vector3,y=t.math.Vector4,b=t.math.Matrix3,T=t.math.Matrix4,_=t.math.Euler,x=t.math.EulerOrder,S=t.math.Quaternion,C=t.math.Box3;t.math.Sphere,t.math.Ray;var M,A,I,E,P,w,O,L=t.math.DEG2RAD;e.PObjectType=void 0,(M=e.PObjectType||(e.PObjectType={}))[M.none=0]="none",M[M.mesh=1]="mesh",M[M.texture=2]="texture",M[M.material=3]="material",M[M.light=4]="light",M[M.camera=5]="camera",M[M.skybox=6]="skybox",M[M.skin=7]="skin",M[M.morph=8]="morph",M[M.skeleton=9]="skeleton",M[M.animation=10]="animation",M[M.animationManager=11]="animationManager",M[M.reference=12]="reference",e.PLightType=void 0,(A=e.PLightType||(e.PLightType={}))[A.directional=0]="directional",A[A.point=1]="point",A[A.spot=2]="spot",A[A.ambient=3]="ambient",e.PTextureType=void 0,(I=e.PTextureType||(e.PTextureType={}))[I.none=0]="none",I[I.t2d=1]="t2d",I[I.t3d=2]="t3d",I[I.cube=3]="cube",e.PMaterialType=void 0,(E=e.PMaterialType||(e.PMaterialType={}))[E.none=0]="none",E[E.unlit=1]="unlit",E[E.pbr=2]="pbr",E[E.normalVis=3]="normalVis",E[E.simpleFilter=4]="simpleFilter",E[E.shadowBase=5]="shadowBase",E[E.shadowFilter=6]="shadowFilter",E[E.skyboxFilter=7]="skyboxFilter",e.PBlendMode=void 0,(P=e.PBlendMode||(e.PBlendMode={}))[P.opaque=0]="opaque",P[P.masked=1]="masked",P[P.translucent=2]="translucent",P[P.additive=3]="additive",e.PFaceSideMode=void 0,(w=e.PFaceSideMode||(e.PFaceSideMode={}))[w.both=0]="both",w[w.front=1]="front",w[w.back=2]="back",e.PShadowType=void 0,(O=e.PShadowType||(e.PShadowType={}))[O.none=0]="none",O[O.standard=1]="standard",O[O.variance=2]="variance",O[O.expVariance=3]="expVariance";var N=function(){function e(){this.translation=new v(0,0,0),this.rotation=new S(0,0,0,1),this.scale=new v(1,1,1)}return e.prototype.fromMatrix4=function(e){return this.setMatrix(e),this},e.prototype.fromEffectsTransform=function(e){if(e instanceof t.Transform)this.setMatrix(e.getWorldMatrix());else{var n=new t.Transform(r(r({},e),{valid:!0}));n.setValid(!0),this.setMatrix(n.getWorldMatrix())}return this},e.prototype.toEffectsTransform=function(e){var t=this.getMatrix();return e.cloneFromMatrix(t),e},e.prototype.fromBaseTransform=function(e){return e.position?this.setTranslation(e.position):this.translation.set(0,0,0),e.rotation?this.setRotation(e.rotation):this.rotation.set(0,0,0,1),e.scale?this.setScale(e.scale):this.scale.set(1,1,1),this},e.prototype.getTranslation=function(){return this.translation},e.prototype.setTranslation=function(e){e instanceof v?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},e.prototype.getPosition=function(){return this.translation},e.prototype.setPosition=function(e){e instanceof v?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},e.prototype.getRotation=function(){return this.rotation},e.prototype.setRotation=function(e){e instanceof S?this.rotation.set(e.x,e.y,e.z,e.w):e instanceof _?this.rotation.setFromEuler(e):e instanceof v?this.rotation.setFromEuler(new _(e.x,e.y,e.z,x.ZYX)):4===e.length?this.rotation.set(e[0],e[1],e[2],e[3]):this.rotation.setFromEuler(new _(e[0],e[1],e[2],x.ZYX))},e.prototype.getScale=function(){return this.scale},e.prototype.setScale=function(e){e instanceof v?this.scale.set(e.x,e.y,e.z):this.scale.set(e[0],e[1],e[2])},e.prototype.getMatrix=function(){return(new T).compose(this.getTranslation(),this.getRotation(),this.getScale())},e.prototype.setMatrix=function(e){if(e instanceof T){var t=e.getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}else{t=T.fromArray(e).getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}},e}(),F=function(){function e(){this.origin=new v(0,0,0),this.xAxis=new v(1,0,0),this.yAxis=new v(0,1,0),this.zAxis=new v(0,0,1)}return e.prototype.fromPTransform=function(e,t){void 0===t&&(t=!1),this.origin.copyFrom(e.getPosition());var n=e.getRotation().toMatrix4(new T);return t&&n.invert(),this.fromRotationMatrix(n),this},e.prototype.fromRotationMatrix=function(e){var t=e.elements;this.xAxis.set(t[0],t[1],t[2]),this.yAxis.set(t[4],t[5],t[6]),this.zAxis.set(t[8],t[9],t[10])},e}(),R=function(){function e(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=t.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16}return e.getInstance=function(){return this.instance||(this.instance=new this)},e.prototype.reset=function(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=t.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16},e.prototype.hasRenderMode3D=function(){return this.renderMode3D!==t.spec.RenderMode3D.none},Object.defineProperty(e.prototype,"isEditorEnv",{get:function(){return this.runtimeEnv===t.PLAYER_OPTIONS_ENV_EDITOR},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDeviceEnv",{get:function(){return!this.isEditorEnv},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isTiny3dMode",{get:function(){return"tiny3d"===this.compatibleMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isOasisMode",{get:function(){return"oasis"===this.compatibleMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isGLTFMode",{get:function(){return!this.isTiny3dMode&&!this.isOasisMode},enumerable:!1,configurable:!0}),e}(),B=1,U=function(){function t(){this.name="Unnamed Object",this.type=e.PObjectType.none}return t.prototype.dispose=function(){},t.prototype.isNone=function(){return this.type===e.PObjectType.none},t.prototype.isValid=function(){return this.type!==e.PObjectType.none},t.prototype.genName=function(e){return"".concat(e,"_@").concat(B++)},t}(),D=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._visible=!1,t._transform=new N,t.deleted=!1,t}return i(t,e),t.prototype.tick=function(e){},t.prototype.onVisibleChanged=function(e){this.visible=e},t.prototype.addToRenderObjectSet=function(e){},t.prototype.updateUniformsForScene=function(e){},t.prototype.onEntityRemoved=function(){this.visible=!1,this.deleted=!0},Object.defineProperty(t.prototype,"visible",{get:function(){return this._visible&&this.isValid()},set:function(e){this._visible=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transform",{get:function(){return this._transform},set:function(e){e instanceof N?this._transform=e:(void 0!==e.position&&this._transform.setTranslation(e.position),void 0!==e.rotation&&this._transform.setRotation(e.rotation),void 0!==e.scale&&this._transform.setScale(e.scale))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"translation",{get:function(){return this._transform.getTranslation()},set:function(e){this._transform.setTranslation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._transform.getTranslation()},set:function(e){this._transform.setTranslation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._transform.getRotation()},set:function(e){this._transform.setRotation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scale",{get:function(){return this._transform.getScale()},set:function(e){this._transform.setScale(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._transform.getMatrix()},set:function(e){this._transform.setMatrix(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinate",{get:function(){var e=new F;return e.fromPTransform(this._transform),e},enumerable:!1,configurable:!0}),t}(U);var k={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,f32:Float32Array,i32:Int32Array,u32:Uint32Array};function V(e,n){if(2!=n.length||n[0]!==t.spec.ValueType.BINARY||!(n[1]instanceof Array))return n;var o=c(n[1],4),i=o[0],r=o[1],a=o[2],s=o[3];if(!s)return e[i].slice(r,a);var l=k[s]||Uint8Array;return new l(e[i],r,a/l.BYTES_PER_ELEMENT)}function G(e,t,n){var o=t,i=o.clone().invert(),r=e.clone().applyMatrix(i),a=v.fromArray(n.center),s=v.fromArray(n.size).multiply(.5),c=a.clone().subtract(s),l=a.clone().add(s),u=r.intersectBox({min:c,max:l},new v);return void 0!==u?[o.transformPoint(u)]:void 0}function j(e,t,n,o){var i=0,r=0,a=0,s=0,c=0,l=0,u=1/t.x,h=1/t.y,f=1/t.z;if(u>=0?(i=(n.x-e.x)*u,r=(o.x-e.x)*u):(i=(o.x-e.x)*u,r=(n.x-e.x)*u),h>=0?(a=(n.y-e.y)*h,s=(o.y-e.y)*h):(a=(o.y-e.y)*h,s=(n.y-e.y)*h),!(i>s||a>r||((a>i||i!=i)&&(i=a),(s<r||r!=r)&&(r=s),f>=0?(c=(n.z-e.z)*f,l=(o.z-e.z)*f):(c=(o.z-e.z)*f,l=(n.z-e.z)*f),i>l||c>r||((c>i||i!=i)&&(i=c),(l<r||r!=r)&&(r=l),r<0))))return i>=0?i:r}var z=new v,H=new v,W=new v,X=new v;function J(e,t,n,o,i,r){H.subtractVectors(o,n),W.subtractVectors(i,n),X.crossVectors(H,W);var a=t.dot(X),s=0;if(a>0){if(r)return;s=1}else{if(!(a<0))return;s=-1,a=-a}z.subtractVectors(e,n),W.crossVectors(z,W);var c=s*t.dot(W);if(!(c<0)){H.crossVectors(H,z);var l=s*t.dot(H);if(!(l<0||c+l>a)){var u=-s*z.dot(X);if(!(u<0))return u/a}}}var Y,q,K,Q=function(){function e(){}return e.createTexture2D=function(n,o,i,r,c){return a(this,void 0,void 0,(function(){var a,l,u,h;return s(this,(function(s){return void 0===o.imageData?(console.error("createTexture2D: Invalid image data from ".concat(o)),[2,t.Texture.create(n,{name:"createTexture2D",sourceType:t.TextureSourceType.data,data:{data:new Uint8Array([255,255,255,255]),width:1,height:1}})]):(a=new Blob([o.imageData],{type:o.mimeType}),l=window.URL||window.webkitURL,u=l.createObjectURL(a),(h=new Image).src=u,[2,new Promise((function(o,a){h.onload=function(){var a,s,f,d,p=null!==(a=i.minFilter)&&void 0!==a?a:t.glContext.LINEAR_MIPMAP_LINEAR,m=!1;c&&(p=t.glContext.LINEAR_MIPMAP_LINEAR,e.isPow2(h.width)&&e.isPow2(h.height)||(p=t.glContext.LINEAR),m=!r);var g=!1;p!=t.glContext.NEAREST_MIPMAP_NEAREST&&p!=t.glContext.LINEAR_MIPMAP_NEAREST&&p!=t.glContext.NEAREST_MIPMAP_LINEAR&&p!=t.glContext.LINEAR_MIPMAP_LINEAR||(g=!0);var v=t.Texture.create(n,{name:"createTexture2D",wrapS:null!==(s=i.wrapS)&&void 0!==s?s:t.glContext.REPEAT,wrapT:null!==(f=i.wrapT)&&void 0!==f?f:t.glContext.REPEAT,magFilter:null!==(d=i.magFilter)&&void 0!==d?d:t.glContext.LINEAR,minFilter:p,anisotropic:1,premultiplyAlpha:m,sourceType:t.TextureSourceType.image,image:h,generateMipmap:g});o(v),l.revokeObjectURL(u)},h.onerror=a}))])}))}))},e.createTextureList=function(e,t,n){return a(this,void 0,void 0,(function(){var o=this;return s(this,(function(i){switch(i.label){case 0:return[4,Promise.all(n.map((function(n){return o.createTexture2D(e,t[n.source],n)})))];case 1:return[2,i.sent()]}}))}))},e.getTextureCubeData=function(e){return a(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,ee.loadImageFromImageData(e[0])];case 1:return t=[n.sent()],[4,ee.loadImageFromImageData(e[1])];case 2:return t=t.concat([n.sent()]),[4,ee.loadImageFromImageData(e[2])];case 3:return t=t.concat([n.sent()]),[4,ee.loadImageFromImageData(e[3])];case 4:return t=t.concat([n.sent()]),[4,ee.loadImageFromImageData(e[4])];case 5:return t=t.concat([n.sent()]),[4,ee.loadImageFromImageData(e[5])];case 6:return[2,t.concat([n.sent()])]}}))}))},e.getTextureCubeMipmapData=function(e){return a(this,void 0,void 0,(function(){var t,n,o,i;return s(this,(function(r){switch(r.label){case 0:t=[],n=0,r.label=1;case 1:return n<e.length?(i=(o=t).push,[4,this.getTextureCubeData(e[n])]):[3,4];case 2:i.apply(o,[r.sent()]),r.label=3;case 3:return n++,[3,1];case 4:return[2,t]}}))}))},e.createTextureCubeFromURL=function(e,n){return a(this,void 0,void 0,(function(){var o;return s(this,(function(i){switch(i.label){case 0:return[4,t.getDefaultTextureFactory().loadSource({type:t.TextureSourceType.image,target:t.glContext.TEXTURE_CUBE_MAP,map:n},this.cubemapTexConfig)];case 1:return o=i.sent(),[2,t.Texture.create(e,o)]}}))}))},e.createTextureCubeMipmapFromURL=function(e,n){return a(this,void 0,void 0,(function(){var o;return s(this,(function(i){switch(i.label){case 0:return[4,t.getDefaultTextureFactory().loadSource({type:t.TextureSourceType.mipmaps,target:t.glContext.TEXTURE_CUBE_MAP,maps:n},this.cubemapMipTexConfig)];case 1:return o=i.sent(),[2,t.Texture.create(e,o)]}}))}))},e.createTextureCubeFromBuffer=function(n,o){return a(this,void 0,void 0,(function(){var i;return s(this,(function(a){switch(a.label){case 0:return[4,e.getTextureCubeData(o)];case 1:return i=a.sent(),[2,t.Texture.create(n,r({name:"createTextureCubeFromBuffer",sourceType:t.TextureSourceType.image,cube:i,target:t.glContext.TEXTURE_CUBE_MAP},this.cubemapTexConfig))]}}))}))},e.createTextureCubeMipmapFromBuffer=function(n,o,i){return a(this,void 0,void 0,(function(){var a,c,l,u,h;return s(this,(function(s){switch(s.label){case 0:return[4,e.getTextureCubeMipmapData(o)];case 1:for(a=s.sent(),c=0;Math.pow(2,c)<i;)++c;s.label=2;case 2:return a.length<=c?(l=Math.pow(2,c-a.length),u="https://gw.alipayobjects.com/zos/gltf-asset/67896749597915/img".concat(l,".png"),[4,t.loadImage(u)]):[3,4];case 3:return h=s.sent(),a.push([h,h,h,h,h,h]),[3,2];case 4:return[2,t.Texture.create(n,r({name:"createTextureCubeMipmapFromBuffer",sourceType:t.TextureSourceType.mipmaps,mipmaps:a,target:t.glContext.TEXTURE_CUBE_MAP},this.cubemapMipTexConfig))]}}))}))},e.getTexture=function(e,t){return e<0||e>=t.length?void 0:t[e]},e.createTextureFromImage=function(e,n){var o={name:"createTextureFromImage",image:n,sourceType:t.TextureSourceType.image,flipY:!1,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR,wrapT:t.glContext.REPEAT,wrapS:t.glContext.REPEAT};return t.Texture.create(e,o)},e.createRenderPass=function(e,n,o,i,r){var a=i instanceof t.Mesh?[i]:i;return new t.RenderPass(e,{name:n,priority:o,attachments:r.colorAttachments,depthStencilAttachment:r.depthAttachment,clearAction:{clearDepth:1,clearStencil:0,clearColor:[0,0,0,0],colorAction:t.TextureLoadAction.clear,depthAction:t.TextureLoadAction.clear},meshes:a,viewport:r.viewport})},e.deleteTexture=function(e){e.dispose()},e.deleteMesh=function(e){e.dispose({geometries:t.DestroyOptions.destroy,material:{textures:t.DestroyOptions.destroy}})},e.deleteGeometry=function(e){e.dispose()},e.deleteRenderPass=function(e){e.dispose({meshes:{geometries:t.DestroyOptions.destroy,material:{textures:t.DestroyOptions.destroy}},depthStencilAttachment:t.RenderPassDestroyAttachmentType.force,colorAttachment:t.RenderPassDestroyAttachmentType.force,semantics:t.DestroyOptions.destroy})},e.isTransparentMesh=function(e){return!0===e.material.blending},e.isSupportFloatTexture=function(e){return 0!==e.gpuCapability.detail.floatTexture},e.isSupportHalfFloatTexture=function(e){return 0!==e.gpuCapability.detail.halfFloatTexture},e.isPow2=function(e){return!(e&e-1||!e)},e.cubemapTexConfig={name:"cubemap texture",wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR},e.cubemapMipTexConfig={wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR_MIPMAP_LINEAR},e}(),Z=function(){function e(){}return e.createFilterMesh=function(n,o,i,r){var a=R.getInstance(),s=i.vertexShaderCode,c=i.fragmentShaderCode,l=t.Geometry.create(n,e.getPlaneGeometry()),u=t.Material.create(n,{shader:{vertex:s,fragment:c,shared:a.shaderShared},uniformSemantics:r});return i.setMaterialStates(u),t.Mesh.create(n,{name:o,worldMatrix:T.fromIdentity(),material:u,geometry:l})},e.getPlaneGeometry=function(){var n=e.getPlaneVertexArray();return{attributes:{a_Position:{type:t.glContext.FLOAT,size:3,data:n,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:0},a_UV1:{type:t.glContext.FLOAT,size:2,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:3*Float32Array.BYTES_PER_ELEMENT,dataSource:"a_Position"},a_Normal:{type:t.glContext.FLOAT,size:3,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:5*Float32Array.BYTES_PER_ELEMENT,dataSource:"a_Position"}},drawStart:0,drawCount:n.length/8}},e.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])},e}(),$=function(){function e(){}return e.createLightOptions=function(e){var t,n,o,i,r,a,s,c,l=null!==(t=e.color)&&void 0!==t?t:[255,255,255,255];return"point"===e.type?{color:l,intensity:null!==(n=e.intensity)&&void 0!==n?n:1,lightType:"point",range:null!==(o=e.range)&&void 0!==o?o:0}:"spot"===e.type?{color:l,intensity:null!==(i=e.intensity)&&void 0!==i?i:1,lightType:"spot",range:null!==(r=e.range)&&void 0!==r?r:0,innerConeAngle:null!==(a=e.innerConeAngle)&&void 0!==a?a:0,outerConeAngle:null!==(s=e.outerConeAngle)&&void 0!==s?s:Math.PI/4}:{color:l,intensity:null!==(c=e.intensity)&&void 0!==c?c:1,lightType:"directional"}},e.createCameraOptions=function(e){if(void 0!==e.perspective){var t=e.perspective;t.znear,t.zfar,t.yfov}},e.toPlayerColor3=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2])]},e.toPlayerColor4=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2]),this.scaleTo255(e[3])]},e.toPluginColor3=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2])]},e.toPluginColor4=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2]),this.scaleTo1(e[3])]},e.createUVTransform=function(e){if(void 0!==e&&(void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale)){var t=b.fromIdentity(),n=new b;if(void 0!==e.offset&&(n.setFromArray([1,0,0,0,1,0,e.offset[0],e.offset[1],1]),t.multiply(n)),void 0!==e.rotation){var o=Math.cos(e.rotation),i=Math.sin(e.rotation);n.setFromArray([o,i,0,-i,o,0,0,0,1]),t.multiply(n)}return void 0!==e.scale&&(n.setFromArray([e.scale[0],0,0,0,e.scale[1],0,0,0,1]),t.multiply(n)),t.transpose(),t}},e.clamp=function(e,t,n){return Math.max(Math.min(e,n),t)},e.scaleTo255=function(e){var t=Math.round(255*e);return Math.max(0,Math.min(t,255))},e.scaleTo1=function(e){var t=e/255;return Math.max(0,Math.min(t,1))},e.focusOnPoint=function(e,n,o){var i=v.fromArray(e),r=v.fromArray(o),a=(new v).copyFrom(i).subtract(r);T.fromRotationAxis(new v(0,1,0),n*L).transformPoint(a);var s=a.clone().add(r),c=(new T).lookAt(s,r,new v(0,1,0)).invert(),l=new t.Transform;return l.setValid(!0),l.cloneFromMatrix(c),l},e.preprocessEffectsScene=function(e,n,o,i){var r=this,a=n!==t.PLAYER_OPTIONS_ENV_EDITOR,s="tiny3d"===o,c=e.jsonScene;if(void 0===c||void 0===c.compositions)return{};var l=!1;if(a){var u=e.textureOptions;c.compositions.forEach((function(e){e.items.forEach((function(e){if("mesh"===e.type)e.content.options.primitives.forEach((function(e){var n=e.material;n.type===t.spec.MaterialType.pbr?(void 0!==n.baseColorTexture&&r.preprocessTextureOptions(n.baseColorTexture,u,!0,s),void 0!==n.metallicRoughnessTexture&&r.preprocessTextureOptions(n.metallicRoughnessTexture,u,!1,s),void 0!==n.normalTexture&&r.preprocessTextureOptions(n.normalTexture,u,!1,s),void 0!==n.occlusionTexture&&r.preprocessTextureOptions(n.occlusionTexture,u,!1,s),void 0!==n.emissiveTexture&&r.preprocessTextureOptions(n.emissiveTexture,u,!1,s)):void 0!==n.baseColorTexture&&r.preprocessTextureOptions(n.baseColorTexture,u,!0,s)}));else if("skybox"===e.type){l=!0;var n=e.content.options;r.preprocessTextureOptions(n.specularImage,u,!1,s),void 0!==n.diffuseImage&&r.preprocessTextureOptions(n.diffuseImage,u,!1,s)}}))}))}else c.compositions.forEach((function(e){e.items.forEach((function(e){"skybox"===e.type&&(l=!0)}))}));return i&&c.compositions.forEach((function(e){var n=0;e.items.forEach((function(e){"light"!==e.type&&"skybox"!==e.type||++n})),0==n&&(e.items.push({id:"dir-light1",duration:100,name:"dir-light1",type:t.spec.ItemType.light,transform:{rotation:[45,-45,0]},pluginName:"model",endBehavior:0,content:{options:{lightType:"directional",color:[255,255,255,255],intensity:1.5}}}),e.items.push({id:"dir-light2",duration:100,name:"dir-light2",type:t.spec.ItemType.light,transform:{rotation:[0,90,0]},pluginName:"model",endBehavior:0,content:{options:{lightType:"directional",color:[255,255,255,255],intensity:.2}}}))})),{loadSkybox:l}},e.preprocessTextureOptions=function(e,n,o,i){if(!(e<0||e>=n.length)){var r=n[e];i&&void 0!==r&&(void 0===r.target||r.target===t.glContext.TEXTURE_2D?(r.wrapS=t.glContext.REPEAT,r.wrapT=t.glContext.REPEAT,r.magFilter=t.glContext.LINEAR,r.minFilter=t.glContext.LINEAR_MIPMAP_LINEAR,r.generateMipmap=!0,o||(r.premultiplyAlpha=!0)):r.target===t.glContext.TEXTURE_CUBE_MAP&&(r.wrapS=t.glContext.CLAMP_TO_EDGE,r.wrapT=t.glContext.CLAMP_TO_EDGE,void 0!==r.mipmaps?(r.magFilter=t.glContext.LINEAR,r.minFilter=t.glContext.LINEAR_MIPMAP_LINEAR):(r.magFilter=t.glContext.LINEAR,r.minFilter=t.glContext.LINEAR)))}},e.setupItem3DOptions=function(e,n,o){var i=this;if(!(void 0===e||e.bins.length<=0)){var r=e.jsonScene,a=new Set;void 0===r.compositionId&&a.add(0),r.compositions.forEach((function(e,t){(e.id===r.compositionId||o.refCompositionProps.has(e.id))&&a.add(t)})),a.forEach((function(a){r.compositions[a].items.forEach((function(r,s){if("mesh"===r.type){var c=r,l=c.content.options.skin;if(c.content.options.primitives.forEach((function(r,c){if(!(r.geometry instanceof t.Geometry)){var l="Geom_C".concat(a,"_I").concat(s,"_P").concat(c),u=n.getOrCreateGeometry(l,r.geometry,e.bins),h=r;h.geometry=u;var f,d=r.material;if(d.type===t.spec.MaterialType.pbr)(f=h.material).baseColorTexture=i.getTextureObj(o.textures,d.baseColorTexture),f.metallicRoughnessTexture=i.getTextureObj(o.textures,d.metallicRoughnessTexture),f.normalTexture=i.getTextureObj(o.textures,d.normalTexture),f.occlusionTexture=i.getTextureObj(o.textures,d.occlusionTexture),f.emissiveTexture=i.getTextureObj(o.textures,d.emissiveTexture);else(f=h.material).baseColorTexture=i.getTextureObj(o.textures,d.baseColorTexture)}})),void 0!==l&&void 0!==l.inverseBindMatrices){var u=l,h=V(e.bins,l.inverseBindMatrices);h instanceof Float32Array?u.inverseBindMatrices=h:console.error("setupItem3DOptions: Invalid inverseBindMatrices type, ".concat(h))}}else if("tree"===r.type){var f=r,d=r.content.options.tree.animations,p=f.content.options.tree.animations;void 0!==d&&void 0!==p&&d.forEach((function(t,n){var o=p[n];t.tracks.forEach((function(t,n){var i=V(e.bins,t.input),r=V(e.bins,t.output),a=o.tracks[n];i instanceof Float32Array?a.input=i:console.error("setupItem3DOptions: Type of inputArray should be float32, ".concat(i)),r instanceof Float32Array?a.output=r:console.error("setupItem3DOptions: Type of outputArray should be float32, ".concat(r))}))}))}else if("skybox"===r.type){var m=r,g=r.content.options,v=m.content.options,y=i.getTextureObj(o.textures,g.specularImage);void 0===y&&console.error("setupItem3DOptions: skybox specualrImage is undefined, ".concat(re.stringify(g))),v.specularImage=y;var b=i.getTextureObj(o.textures,g.diffuseImage);void 0!==b&&(v.diffuseImage=b)}}))}))}},e.createGeometry=function(e,n,o){var i=function(e,t){var n,o,i=e.attributes,a=r({},e);return a.indices?(a.indices=r({},a.indices),a.indices.data&&(a.indices.data=V(t,null===(n=e.indices)||void 0===n?void 0:n.data))):a.index&&(a.indices=r({},a.index),a.indices.data&&(a.indices.data=V(t,null===(o=e.index)||void 0===o?void 0:o.data))),Object.keys(i).forEach((function(e){var n=i[e],o=n.data;a.attributes[e]=r({},n),o&&(a.attributes[e].data=V(t,o))})),a}(n,o),a={};for(var s in i.attributes){var c=i.attributes[s];a[this.getAttributeName(s)]=c}return i.attributes=a,t.Geometry.create(e,i)},e.getIndexArray=function(e,t){switch(e){case WebGLRenderingContext.UNSIGNED_INT:case WebGLRenderingContext.UNSIGNED_SHORT:case WebGLRenderingContext.UNSIGNED_BYTE:return t;default:console.error("Invalid index attribute type ".concat(e))}},e.getAttributeName=function(e){switch(e){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 e.startsWith("a_")||console.warn("Unknown attribute name: ".concat(e)),e},e.getTextureObj=function(e,t){return"number"!=typeof t?t:((t<0||t>=e.length)&&console.error("Invalid index for textures: ".concat(t,", ").concat(e.length)),e[t])},e}(),ee=function(){function e(){}return e.getImageFileName=function(e,t){var n=e.lastIndexOf("/"),o=e.lastIndexOf("."),i=e.substring(n+1,o);return t?i+t:i},e.getCurrnetTimeStr=function(){var e=new Date(Date.now()),t=e.toLocaleString("zh-CN"),n="".concat(e.getMilliseconds());return t.split(/[ /:]+/).join("")+n.padStart(3,"0")},e.saveFileForURL=function(e,t){var n=document.createElement("a");n.setAttribute("download",t),n.target="_blank",n.href=e,n.click()},e.createPlayer=function(e){void 0===e&&(e=!0);var n=document.createElement("canvas");return n.width=512,n.height=512,new t.Player({canvas:n,renderFramework:"webgl2",env:t.PLAYER_OPTIONS_ENV_EDITOR,willCaptureImage:!0,manualRender:e})},e.sleep=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},e.loadImageFromGLTFImage=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,t.loadImage(new Blob([e.imageData],{type:e.mimeType}))]}))}))},e.loadImageFromImageData=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,t.loadImage(new Blob([e.data],{type:e.mimeType}))]}))}))},e.getCanvasArrayBuffer=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t,n){e.toBlob((function(e){e?t(e.arrayBuffer()):n(Error("no canvas blob"))}),"image/png",1)}))]}))}))},e.getImageArrayBuffer=function(e){return a(this,void 0,void 0,(function(){var t;return s(this,(function(n){return(t=document.createElement("canvas")).width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0),[2,this.getCanvasArrayBuffer(t)]}))}))},e.getCanvasImageData=function(e){return e.getContext("2d").getImageData(0,0,e.width,e.height)},e.flipImageData=function(e){var t=document.createElement("canvas"),n=t.getContext("2d");return t.width=e.width,t.height=e.height,n.putImageData(e,0,0),n.globalCompositeOperation="copy",n.scale(1,-1),n.translate(0,-e.height),n.drawImage(t,0,0),n.setTransform(1,0,0,1,0,0),n.globalCompositeOperation="source-over",n.getImageData(0,0,t.width,t.height)},e.getImageData=function(e){var t=document.createElement("canvas");t.width=e.width,t.height=e.height;var n=t.getContext("2d");return n.drawImage(e,0,0),this.flipImageData(n.getImageData(0,0,t.width,t.height))},e.getWebGLCanvasImageBuffer=function(e){var t=e.getContext("webgl2"),n=new Uint8Array(e.width*e.height*4);return t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,n),n},e}(),te=function(){function e(){this.component=0,this.length=0,this.offset=0,this.stride=0,this.typeSize=0}return e.prototype.getBoundingBox=function(e){for(var t=this.offset,n=new v;t+this.component<=this.length;)2==this.component?n.set(this.data[t],this.data[t+1],0):n.set(this.data[t],this.data[t+1],this.data[t+2]),e.expandByPoint(n),t+=this.stride;return e},e}(),ne=function(){function e(){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 e.prototype.create=function(e,t){var n,o;switch(e.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=t,this.length=this.data.length,this.compCount=e.size,this.offset=null!==(n=e.offset)&&void 0!==n?n: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!==(o=e.stride)&&void 0!==o?o: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===e.normalize},e.prototype.getData=function(e){var t=this.offset;if(!((t+=e*this.stride)+this.compCount>this.length)){var n;if(n=2===this.compCount?[this.data[t],this.data[t+1],0,0]:3===this.compCount?[this.data[t],this.data[t+1],this.data[t+2],0]:[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]],this.compressed)for(var o=0;o<this.compCount;o++)n[o]*=this.compressScale,this.signed&&(n[o]=Math.max(n[o],-1));return n}},e.prototype.getLength=function(){return Math.round((this.length-this.offset)/this.stride)},e}(),oe=function(){function e(){this.drawStart=0,this.drawCount=0,this.bindMatrices=[]}return e.prototype.create=function(e,t){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var n=e.attributes;this.index=e.getIndexData();var o=n.a_Position,i=e.getAttributeData("a_Position");this.position=new ne,this.position.create(o,i);var r=n.a_Joint1,a=n.a_Weight1;if(void 0!==r&&void 0!==a){var s=e.getAttributeData("a_Joint1"),c=e.getAttributeData("a_Weight1");this.joint=new ne,this.joint.create(r,s),this.weight=new ne,this.weight.create(a,c)}this.bindMatrices=t},e.prototype.getBoundingBox=function(e){var t=this;e.makeEmpty();var n=new T,o=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0,i=new Set;if(void 0!==this.index)for(var r=0;r<this.drawCount;r++){var a=this.drawStart+r;a<this.index.length&&i.add(this.index[a])}else for(r=0;r<this.drawCount;r++)i.add(this.drawStart+r);return i.forEach((function(i){var r,a,s=t.position.getData(i);if(void 0!==s){var c=v.fromArray(s);if(o){var l=null===(r=t.joint)||void 0===r?void 0:r.getData(i),u=null===(a=t.weight)||void 0===a?void 0:a.getData(i);if(void 0!==l&&void 0!==u){n.setZero();for(var h=!1,f=0;f<4;f++)if(0!==u[f]){if(l[f]<0||l[f]>=t.bindMatrices.length){h=!0;break}var d=t.bindMatrices[l[f]];n.addScaledMatrix(d,u[f])}if(!h){var p=n.transformVector4(new y(c.x,c.y,c.z,1));Math.abs(p.w)>1e-4&&(p.multiply(1/p.w),c.set(p.x,p.y,p.z))}}}e.expandByPoint(c)}})),e},e}(),ie=function(){function e(){this.drawStart=0,this.drawCount=0,this.doubleSided=!1,this.bindMatrices=[],this.hasAnimation=!1,this.skinMatrix=new T}return e.prototype.create=function(e,t,n){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var o=e.attributes;this.index=e.getIndexData();var i=o.a_Position,r=e.getAttributeData("a_Position");this.position=new ne,this.position.create(i,r);var a=o.a_Joint1,s=o.a_Weight1;if(void 0!==a&&void 0!==s){var c=e.getAttributeData("a_Joint1"),l=e.getAttributeData("a_Weight1");this.joint=new ne,this.joint.create(a,c),this.weight=new ne,this.weight.create(s,l)}this.doubleSided=t,this.bindMatrices=n,this.hasAnimation=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0},e.prototype.getHitPoint=function(e,t){for(var n,o=new v,i=new v,r=new v,a=new y,s=new y,c=new y,l=!this.doubleSided,u=0;u+2<this.drawCount;u+=3){var h=this.drawStart+u,f=this.drawStart+u+1,d=this.drawStart+u+2;void 0!==this.index&&(h=this.index[h],f=this.index[f],d=this.index[d]);var p=this.getPosition(h,o,a),m=this.getPosition(f,i,s),g=this.getPosition(d,r,c);if(void 0!==p&&void 0!==m&&void 0!==g){var b=J(e,t,p,m,g,l);void 0!==b&&(void 0===n||n>b)&&(n=b)}}return n},e.prototype.getPosition=function(e,t,n){var o,i,r=this.position.getData(e);if(void 0!==r){if(this.hasAnimation){var a=null===(o=this.joint)||void 0===o?void 0:o.getData(e),s=null===(i=this.weight)||void 0===i?void 0:i.getData(e);if(void 0!==a&&void 0!==s){var c=this.skinMatrix;c.setZero();for(var l=0;l<4;l++)if(0!==s[l]){var u=this.bindMatrices[a[l]];c.addScaledMatrix(u,s[l])}n.set(r[0],r[1],r[2],1);var h=c.transformVector4(n),f=1/h.w;t.set(h.x*f,h.y*f,h.z*f)}}else t.set(r[0],r[1],r[2]);return t}},e}(),re=function(){function e(){}return e.checkNumber=function(e){return"number"==typeof e},e.checkNumberUndef=function(e){return void 0===e||this.checkNumber(e)},e.checkNumber01=function(e){return this.checkNumber(e)&&e>=0&&e<=1},e.checkNumber01Undef=function(e){return void 0===e||this.checkNumber01(e)},e.checkPositive=function(e){return this.checkNumber(e)&&e>0},e.checkNonnegative=function(e){return this.checkNumber(e)&&e>=0},e.checkNonnegativeUndef=function(e){return void 0===e||this.checkNonnegative(e)},e.checkBoolean=function(e){return"boolean"==typeof e},e.checkBooleanUndef=function(e){return void 0===e||this.checkBoolean(e)},e.checkString=function(e){return"string"==typeof e},e.checkStringUndef=function(e){return void 0===e||this.checkString(e)},e.checkFloat32Array=function(e){return e instanceof Float32Array},e.checkFloat32ArrayUndef=function(e){return void 0===e||this.checkFloat32Array(e)},e.checkParent=function(e){return void 0===e||!!this.checkNumber(e)&&e>=0},e.checkTexCoord=function(e){return void 0===e||!!this.checkNumber(e)&&(e>=0&&e<=1)},e.checkVec2=function(e){var t=this;return!!Array.isArray(e)&&(2==e.length&&e.every((function(e){return t.checkNumber(e)})))},e.checkVec2Undef=function(e){return void 0===e||this.checkVec2(e)},e.checkVec3=function(e){var t=this;return!!Array.isArray(e)&&(3==e.length&&e.every((function(e){return t.checkNumber(e)})))},e.checkNonnegative3=function(e){var t=this;return!!Array.isArray(e)&&(3==e.length&&e.every((function(e){return t.checkNonnegative(e)})))},e.checkVec4=function(e){var t=this;return!!Array.isArray(e)&&(4==e.length&&e.every((function(e){return t.checkNumber(e)})))},e.checkNonnegative4=function(e){var t=this;return!!Array.isArray(e)&&(4==e.length&&e.every((function(e){return t.checkNonnegative(e)})))},e.checkNumberArray=function(e){var t=this;return!!Array.isArray(e)&&e.every((function(e){return t.checkNumber(e)}))},e.checkTexture=function(e){return e instanceof t.Texture&&(e.isDestroyed&&console.error("Texture is destroyed, ".concat(e.name)),!e.isDestroyed)},e.checkTextureUndef=function(e){return void 0===e||this.checkTexture(e)},e.checkTexTransform=function(e){return!!this.checkVec2Undef(e.offset)&&(!!this.checkNumberUndef(e.rotation)&&(!!this.checkVec2Undef(e.scale)&&(void 0===e.scale||!(Math.abs(e.scale[0])<1e-5||Math.abs(e.scale[1])<1e-5))))},e.checkTexTransformUndef=function(e){return void 0===e||this.checkTexTransform(e)},e.checkMatBlending=function(e){return void 0===e||e===t.spec.MaterialBlending.opaque||e===t.spec.MaterialBlending.masked||e===t.spec.MaterialBlending.translucent||e===t.spec.MaterialBlending.additive},e.checkMatSide=function(e){return void 0===e||e===t.spec.SideMode.BACK||e===t.spec.SideMode.DOUBLE||e===t.spec.SideMode.FRONT},e.checkAnimPath=function(e){return"translation"===e||"rotation"===e||"scale"===e||"weights"===e},e.checkAnimInterp=function(e){return"LINEAR"===e||"STEP"===e||"CUBICSPLINE"===e},e.assertGeometry=function(e,n){e instanceof t.Geometry||console.error("Invalid geometry type ".concat(this.stringify(e))),!0===e.isDestroyed&&console.error("Geometry object is destroyed"),this.checkNonnegative(e.getDrawStart())||console.error("Invalid geometry draw start: ".concat(e.getDrawStart(),", ").concat(this.stringify(e)))},e.assertGeometryBuffer=function(e,t,n){var o=this.createAttributeArray(e,t);void 0!==o&&o.getLength()<n&&console.error("".concat(t," Length(").concat(o.getLength(),") is less than draw count(").concat(n,"), ").concat(this.stringify(e)))},e.createAttributeArray=function(e,t){var n=e.attributes;if(void 0!==n){var o=n[t];if(void 0!==o){var i=e.getAttributeData(t);if(void 0!==i){var r=new ne;return r.create(o,i),r}}}},e.assertModelSkinOptions=function(e){if(this.checkStringUndef(e.name)||console.error("Invalid skin name ".concat(e.name,", ").concat(this.stringify(e))),this.checkNumberArray(e.joints)||console.error("Invalid skin joints ".concat(e.joints,", ").concat(this.stringify(e))),this.checkNumberUndef(e.skeleton)||console.error("Invalid skin skeleton ".concat(e.skeleton,", ").concat(this.stringify(e))),this.checkFloat32ArrayUndef(e.inverseBindMatrices)||console.error("Invalid skin inverseBindMatrices ".concat(e.inverseBindMatrices,", ").concat(this.stringify(e))),void 0!==e.inverseBindMatrices){(e.inverseBindMatrices.length<=0||e.inverseBindMatrices.length%16!=0)&&console.error("Invalid skin inverseBindMatrices length ".concat(e.inverseBindMatrices,", ").concat(this.stringify(e))),16*e.joints.length!==e.inverseBindMatrices.length&&console.error("Mismatch: skin joints and inverseBindMatrices length, ".concat(e.joints,", ").concat(e.inverseBindMatrices,", ").concat(this.stringify(e)));for(var t=new T,n=0;n<e.inverseBindMatrices.length;n+=16){for(var o=0;o<16;o++)t.elements[o]=e.inverseBindMatrices[n+o];Math.abs(t.determinant())<1e-5&&console.error("Determinant of inverseBindMatrices is too small ".concat(t.determinant(),", index ").concat(n/16,", ").concat(this.stringify(e)))}}else e.joints.length<=0&&console.error("Invalid skin joints length ".concat(e.joints,", ").concat(this.stringify(e)))},e.assertMatOptions=function(e){e.type===t.spec.MaterialType.unlit?(this.checkString(e.name)||console.error("Invalid material name ".concat(e.name,", ").concat(this.stringify(e))),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor ".concat(e.baseColorFactor,", ").concat(this.stringify(e))),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture ".concat(e.baseColorTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform ".concat(e.baseColorTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate ".concat(e.baseColorTextureCoordinate,", ").concat(this.stringify(e))),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask ".concat(e.depthMask,", ").concat(this.stringify(e))),this.checkMatBlending(e.blending)||console.error("Invalid material blending ".concat(e.blending,", ").concat(this.stringify(e))),this.checkMatSide(e.side)||console.error("Invalid material side ".concat(e.side,", ").concat(this.stringify(e))),e.blending===t.spec.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, ".concat(this.stringify(e))),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff ".concat(e.alphaCutOff,", ").concat(this.stringify(e)))):e.type===t.spec.MaterialType.pbr?(this.checkString(e.name)||console.error("Invalid material name ".concat(e.name,", ").concat(this.stringify(e))),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor ".concat(e.baseColorFactor,", ").concat(this.stringify(e))),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture ".concat(e.baseColorTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform ".concat(e.baseColorTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate ".concat(e.baseColorTextureCoordinate,", ").concat(this.stringify(e))),this.checkBooleanUndef(e.useSpecularAA)||console.error("Invalid material useSpecularAA ".concat(e.useSpecularAA,", ").concat(this.stringify(e))),this.checkNumber01(e.metallicFactor)||console.error("Invalid material metallicFactor ".concat(e.metallicFactor,", ").concat(this.stringify(e))),this.checkNonnegative(e.roughnessFactor)||console.error("Invalid material roughnessFactor ".concat(e.roughnessFactor,", ").concat(this.stringify(e))),this.checkTextureUndef(e.metallicRoughnessTexture)||console.error("Invalid material metallicRoughnessTexture ".concat(e.metallicRoughnessTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.metallicRoughnessTextureTransform)||console.error("Invalid material metallicRoughnessTextureTransform ".concat(e.metallicRoughnessTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.metallicRoughnessTextureCoordinate)||console.error("Invalid material metallicRoughnessTextureCoordinate ".concat(e.metallicRoughnessTextureCoordinate,", ").concat(this.stringify(e))),this.checkTextureUndef(e.normalTexture)||console.error("Invalid material normalTexture ".concat(e.normalTexture,", ").concat(this.stringify(e))),this.checkNonnegativeUndef(e.normalTextureScale)||console.error("Invalid material normalTextureScale ".concat(e.normalTextureScale,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.normalTextureTransform)||console.error("Invalid material normalTextureTransform ".concat(e.normalTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.normalTextureCoordinate)||console.error("Invalid material normalTextureCoordinate ".concat(e.normalTextureCoordinate,", ").concat(this.stringify(e))),this.checkTextureUndef(e.occlusionTexture)||console.error("Invalid material occlusionTexture ".concat(e.occlusionTexture,", ").concat(this.stringify(e))),this.checkNumber01Undef(e.occlusionTextureStrength)||console.error("Invalid material occlusionTextureStrength ".concat(e.occlusionTextureStrength,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.occlusionTextureTransform)||console.error("Invalid material occlusionTextureTransform ".concat(e.occlusionTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.occlusionTextureCoordinate)||console.error("Invalid material occlusionTextureCoordinate ".concat(e.occlusionTextureCoordinate,", ").concat(this.stringify(e))),this.checkNonnegative4(e.emissiveFactor)||console.error("Invalid material emissiveFactor ".concat(e.emissiveFactor,", ").concat(this.stringify(e))),this.checkNonnegative(e.emissiveIntensity)||console.error("Invalid material emissiveIntensity ".concat(e.emissiveIntensity,", ").concat(this.stringify(e))),this.checkTextureUndef(e.emissiveTexture)||console.error("Invalid material emissiveTexture ".concat(e.emissiveTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.emissiveTextureTransform)||console.error("Invalid material emissiveTextureTransform ".concat(e.emissiveTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.emissiveTextureCoordinate)||console.error("Invalid material emissiveTextureCoordinate ".concat(e.emissiveTextureCoordinate,", ").concat(this.stringify(e))),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask ".concat(e.depthMask,", ").concat(this.stringify(e))),this.checkMatBlending(e.blending)||console.error("Invalid material blending ".concat(e.blending,", ").concat(this.stringify(e))),this.checkMatSide(e.side)||console.error("Invalid material side ".concat(e.side,", ").concat(this.stringify(e))),e.blending===t.spec.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, ".concat(this.stringify(e))),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff ".concat(e.alphaCutOff,", ").concat(this.stringify(e)))):console.error("Invalid material type ".concat(this.stringify(e)))},e.assertPrimOptions=function(e,t){return this.assertGeometry(e.geometry,t),this.assertMatOptions(e.material),!0},e.assertModelMeshOptions=function(e){this.checkParent(e.parent)||console.error("Invalid mesh parent ".concat(e.parent,", ").concat(this.stringify(e))),void 0!==e.skin&&this.assertModelSkinOptions(e.skin);for(var t=[],n=0;n<e.primitives.length;n++){var o=e.primitives[n];this.assertPrimOptions(o)||console.error("Invalid primitive ".concat(o,", ").concat(this.stringify(e)));var i=new he;i.create(o.geometry),t.push(i)}for(n=1;n<t.length;n++){var r=t[n-1],a=t[n];r.equals(a)||console.error("Morph states mismatch: ".concat(this.stringify(r),", ").concat(this.stringify(a),", ").concat(this.stringify(e)))}this.checkBooleanUndef(e.hide)||console.error("Invalid mesh hide ".concat(e.hide,", ").concat(this.stringify(e)))},e.assertModelCameraOptions=function(e){this.checkParent(e.parent)||console.error("Invalid camera parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNumberUndef(e.aspect)||console.error("Invalid camera aspect ".concat(e.aspect,", ").concat(this.stringify(e))),this.checkPositive(e.near)||console.error("Invalid camera near ".concat(e.near,", ").concat(this.stringify(e))),(!this.checkPositive(e.far)||e.far<=e.near)&&console.error("Invalid camera far ".concat(e.far,", ").concat(this.stringify(e))),this.checkPositive(e.fov)||console.error("Invalid camera fov ".concat(e.fov,", ").concat(this.stringify(e))),this.checkNumber01(e.clipMode)||console.error("Invalid camera clipMode ".concat(e.clipMode,", ").concat(this.stringify(e)))},e.assertModelLightOptions=function(e){"directional"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e)))):"point"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e))),this.checkNonnegative(e.range)||console.error("Invalid light range ".concat(e.range,", ").concat(this.stringify(e)))):"spot"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e))),this.checkNonnegative(e.range)||console.error("Invalid light range ".concat(e.range,", ").concat(this.stringify(e))),this.checkNonnegative(e.innerConeAngle)||console.error("Invalid light innerConeAngle ".concat(e.innerConeAngle,", ").concat(this.stringify(e))),this.checkNonnegative(e.outerConeAngle)||console.error("Invalid light outerConeAngle ".concat(e.outerConeAngle,", ").concat(this.stringify(e)))):"ambient"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e)))):console.error("Invalid light type ".concat(this.stringify(e)))},e.assertModelSkyboxOptions=function(e){var t=this;this.checkBoolean(e.renderable)||console.error("Invalid skybox renderable ".concat(e.renderable,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid skybox intensity ".concat(e.intensity,", ").concat(this.stringify(e))),this.checkNonnegative(e.reflectionsIntensity)||console.error("Invalid skybox reflectionsIntensity ".concat(e.reflectionsIntensity,", ").concat(this.stringify(e)));var n=e.irradianceCoeffs;void 0!==n?(Array.isArray(n)&&9==n.length||console.error("Invalid skybox irradianceCoeffs ".concat(n,", ").concat(this.stringify(e))),n.forEach((function(e){t.checkVec3(e)||console.error("Invalid skybox irradianceCoeffs ".concat(n,", ").concat(t.stringify(e)))}))):void 0!==e.diffuseImage?this.checkTexture(e.diffuseImage)||console.error("Invalid skybox diffuseImage ".concat(e.diffuseImage,", ").concat(this.stringify(e))):console.error("Invalid skybox, irradianceCoeffs or diffuseImage should give one, ".concat(this.stringify(e))),this.checkTexture(e.specularImage)||console.error("Invalid skybox specularImage ".concat(e.specularImage,", ").concat(this.stringify(e))),this.checkPositive(e.specularImageSize)||console.error("Invalid skybox specularImageSize ".concat(e.specularImageSize,", ").concat(this.stringify(e))),this.checkPositive(e.specularMipCount)||console.error("Invalid skybox specularMipCount ".concat(e.specularMipCount,", ").concat(this.stringify(e))),this.pow2(e.specularMipCount)>e.specularImageSize&&console.error("Invalid skybox specularMipCount or specularImageSize, ".concat(this.stringify(e)))},e.checkModelAnimTrackOptions=function(e){return this.checkNonnegative(e.node)?this.checkFloat32Array(e.input)?this.checkFloat32Array(e.output)?this.checkAnimPath(e.path)?!!this.checkAnimInterp(e.interpolation)||(console.error("Invalid track interpolation ".concat(e.interpolation,", ").concat(this.stringify(e))),!1):(console.error("Invalid track path ".concat(e.path,", ").concat(this.stringify(e))),!1):(console.error("Invalid track input ".concat(e.output,", ").concat(this.stringify(e))),!1):(console.error("Invalid track input ".concat(e.input,", ").concat(this.stringify(e))),!1):(console.error("Invalid track node ".concat(e.node,", ").concat(this.stringify(e))),!1)},e.assertModelAnimOptions=function(e){var t=this;this.checkStringUndef(e.name)||console.error("Invalid animation name ".concat(e.name,", ").concat(this.stringify(e))),Array.isArray(e.tracks)||console.error("Invalid animation tracks ".concat(e.tracks,", ").concat(this.stringify(e))),e.tracks.forEach((function(n){t.checkModelAnimTrackOptions(n)||console.error("Invalid animation track ".concat(n,", ").concat(t.stringify(e)))}))},e.assertTreeOptions=function(e){var t=this;this.checkNumberUndef(e.animation)||console.error("Invalid tree animation ".concat(e.animation,", ").concat(this.stringify(e))),void 0!==e.animations&&(Array.isArray(e.animations)||console.error("Invalid tree animations ".concat(e.animations,", ").concat(this.stringify(e))),e.animations.forEach((function(e){t.assertModelAnimOptions(e)})),void 0!==e.animation&&(e.animation<-1||e.animation>=e.animations.length)&&console.error("Invalid tree animations ".concat(e.animations,", ").concat(this.stringify(e))))},e.stringify=function(e){var n={};for(var o in e)"internal"!==o&&"function"!=typeof e[o]&&(e[o]instanceof t.Texture||e[o]instanceof t.Geometry?n[o]=e[o].name:e[o]instanceof t.Renderer||(n[o]=e[o]));return JSON.stringify(n)},e.pow2=function(e){for(var t=1;e-- >0;)t*=2;return t},e}(),ae=function(){function e(e){this.size=e,this.data=new Uint16Array(e)}return e.prototype.set=function(e,t){for(var n=0;n<e.length;n++)this.data[n+t]=se(e[n])},Object.defineProperty(e.prototype,"bytes",{get:function(){return 2*this.size},enumerable:!1,configurable:!0}),e}(),se=(Y=new Float32Array(1),q=new Int32Array(Y.buffer),function(e){Y[0]=e;var t=q[0],n=t>>16&32768,o=t>>12&2047,i=t>>23&255;return i<103?n:i>142?(n|=31744,n|=(255==i?0:1)&&8388607&t):i<113?n|=((o|=2048)>>114-i)+(o>>113-i&1):(n|=i-112<<10|o>>1,n+=1&o)});e.TextureDataMode=void 0,(K=e.TextureDataMode||(e.TextureDataMode={}))[K.none=0]="none",K[K.float=1]="float",K[K.half_float=2]="half_float";var ce,le,ue=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.skeleton=0,n.jointList=[],n.inverseBindMatrices=[],n.animationMatrices=[],n.textureDataMode=e.TextureDataMode.none,n}return i(n,t),n.prototype.create=function(t,n,o){var i,r;this.name=this.genName(null!==(i=t.name)&&void 0!==i?i:"Unnamed skin"),this.type=e.PObjectType.skin,this.parentItem=o,this.skeleton=null!==(r=t.skeleton)&&void 0!==r?r:-1,this.jointList=t.joints,this.animationMatrices=[],this.inverseBindMatrices=[],this.textureDataMode=this.getTextureDataMode(this.getJointCount(),n);var a=t.inverseBindMatrices;if(void 0!==a&&a.length>0){if(a.length%16!=0||a.length!==16*this.jointList.length)throw new Error("Invalid array length, invert bind matrices ".concat(a.length,", joint array ").concat(this.jointList.length));for(var s=a.length/16,c=0;c<s;c++){var l=T.fromArray(a,16*c);this.inverseBindMatrices.push(l)}}},n.prototype.updateSkinMatrices=function(){var e=this;if(this.animationMatrices=[],void 0!==this.parentItem)for(var t=this.parentItem.content,n=0;n<this.jointList.length;n++){var o=this.jointList[n],i=t.getNodeById(o);if(void 0===i){console.error("Can't find joint ".concat(o," in node tree ").concat(this.parentItem,"."));break}var r=i.transform.getWorldMatrix();this.animationMatrices.push(r.clone())}this.animationMatrices.length===this.inverseBindMatrices.length?this.animationMatrices.forEach((function(t,n){t.multiply(e.inverseBindMatrices[n])})):(this.animationMatrices=this.inverseBindMatrices,console.error("Some error occured, replace skin animation matrices by invert bind matrices"))},n.prototype.computeMeshAnimMatrices=function(e,t,n){var o=e.clone().invert(),i=new T;this.animationMatrices.forEach((function(e,r){var a=i.multiplyMatrices(o,e);a.elements.forEach((function(e,n){return t[16*r+n]=e})),a.clone().invert().transpose().elements.forEach((function(e,t){return n[16*r+t]=e}))}))},n.prototype.updateParentItem=function(e){this.parentItem=e},n.prototype.getJointCount=function(){return this.jointList.length},n.prototype.isTextureDataMode=function(){return this.textureDataMode!==e.TextureDataMode.none},n.prototype.dispose=function(){this.parentItem=void 0,this.jointList=[],this.inverseBindMatrices=[],this.animationMatrices=[]},n.prototype.getTextureDataMode=function(t,n){var o=n.gpuCapability.detail,i=o.maxVertexUniforms-25;if(t>Math.floor(i/8)){if(o.floatTexture)return e.TextureDataMode.float;if(o.halfFloatTexture)return e.TextureDataMode.half_float;throw new Error("Too many joint count ".concat(t,", half float texture not support"))}return e.TextureDataMode.none},n}(U),he=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.morphWeightsLength=0,e.hasPositionMorph=!1,e.hasNormalMorph=!1,e.hasTangentMorph=!1,e}return i(n,t),n.prototype.create=function(t){var o=this;this.name=this.genName("Morph target"),this.type=e.PObjectType.morph;var i=this.getAttributeMorphCount(n.positionNameList,t),r=this.getAttributeMorphCount(n.normalNameList,t),a=this.getAttributeMorphCount(n.tangentNameList,t),s=[i,r,a];return this.morphWeightsLength=0,s.forEach((function(e){e>0&&(0===o.morphWeightsLength?o.morphWeightsLength=e:o.morphWeightsLength=Math.min(o.morphWeightsLength,e))})),this.morphWeightsLength>0&&(this.morphWeightsArray=new Float32Array(this.morphWeightsLength),this.hasPositionMorph=i==this.morphWeightsLength,this.hasNormalMorph=r==this.morphWeightsLength,this.hasTangentMorph=a==this.morphWeightsLength),i>0&&i!=this.morphWeightsLength?(console.error("Position morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(i)),!1):r>0&&r!=this.morphWeightsLength?(console.error("Normal morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(r)),!1):a>0&&a!=this.morphWeightsLength?(console.error("Tangent morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(a)),!1):!(this.morphWeightsLength>5)||(console.error("Tangent morph count should not greater than 5, current ".concat(this.morphWeightsLength)),!1)},n.prototype.dispose=function(){this.morphWeightsArray=void 0},n.prototype.initWeights=function(e){if(void 0!==this.morphWeightsArray){var t=this.morphWeightsArray;e.forEach((function(e,n){n<t.length&&(t[n]=e)}))}},n.prototype.hasMorph=function(){return this.morphWeightsLength>0&&(this.hasPositionMorph||this.hasNormalMorph||this.hasTangentMorph)},n.prototype.equals=function(e){return this.morphWeightsLength===e.morphWeightsLength&&this.hasPositionMorph===e.hasPositionMorph&&this.hasNormalMorph===e.hasNormalMorph&&this.hasTangentMorph===e.hasTangentMorph},n.prototype.getMorphWeightsArray=function(){return this.morphWeightsArray},n.prototype.getAttributeMorphCount=function(e,t){for(var n=0;n<e.length;n++){var o=e[n];if(void 0===t.getAttributeData(o))return n}return e.length},n.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"],n.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"],n.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"],n}(U);e.PAnimInterpType=void 0,(ce=e.PAnimInterpType||(e.PAnimInterpType={}))[ce.linear=0]="linear",ce[ce.step=1]="step",ce[ce.cubicSpline=2]="cubicSpline",e.PAnimPathType=void 0,(le=e.PAnimPathType||(e.PAnimPathType={}))[le.translation=0]="translation",le[le.rotation=1]="rotation",le[le.scale=2]="scale",le[le.weights=3]="weights";var fe,de=function(){function t(t){this.path=e.PAnimPathType.translation,this.interp=e.PAnimInterpType.linear;var n=t.node,o=t.input,i=t.output,r=t.path,a=t.interpolation;if(this.node=n,this.timeArray=o,this.dataArray=i,"translation"===r?(this.path=e.PAnimPathType.translation,this.component=3):"rotation"===r?(this.path=e.PAnimPathType.rotation,this.component=4):"scale"===r?(this.path=e.PAnimPathType.scale,this.component=3):"weights"===r?(this.path=e.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(r)),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"===a?e.PAnimInterpType.linear:"STEP"===a?e.PAnimInterpType.step:e.PAnimInterpType.cubicSpline,this.sampler=m(this.getInterpInfo(),this.timeArray,this.dataArray,this.component,this.getPathInfo())}return t.prototype.dispose=function(){var e;this.timeArray=void 0,this.dataArray=void 0,null===(e=this.sampler)||void 0===e||e.dispose(),this.sampler=void 0},t.prototype.tick=function(t,n,o){var i=n.content.getNodeById(this.node);if(void 0!==this.sampler&&void 0!==i){var r=this.sampler.evaluate(t);switch(this.path){case e.PAnimPathType.translation:i.transform.setPosition(r[0],r[1],r[2]);break;case e.PAnimPathType.rotation:i.transform.setQuaternion(r[0],r[1],r[2],r[3]);break;case e.PAnimPathType.scale:i.transform.setScale(r[0],r[1],r[2]);break;case e.PAnimPathType.weights:var a=this.genParentId(n.id,this.node),s=null==o?void 0:o.queryMesh(a);void 0!==s&&s.updateMorphWeights(r)}}else void 0!==this.sampler&&console.error("AnimTrack: error",this.sampler,i)},t.prototype.getEndTime=function(){var e=this.timeArray.length-1;return this.timeArray[e]},t.prototype.genParentId=function(e,t){return"".concat(e,"^").concat(t)},t.prototype.getPathInfo=function(){return this.path===e.PAnimPathType.scale?"scale":this.path===e.PAnimPathType.rotation?"rotation":"translation"},t.prototype.getInterpInfo=function(){return this.interp===e.PAnimInterpType.cubicSpline?"CUBICSPLINE":this.interp===e.PAnimInterpType.step?"STEP":"LINEAR"},t}(),pe=function(){function e(e){this.engine=e,this.isHalfFloat=!0,this.width=0,this.height=0}return e.prototype.create=function(e,n,o){var i,r;this.width=4,this.height=e,this.isHalfFloat=n,this.isHalfFloat&&(this.buffer=new ae(4*this.getSize()));var a=null!==(r=null===(i=this.buffer)||void 0===i?void 0:i.data)&&void 0!==r?r:new Float32Array(4*this.getSize()),s=this.isHalfFloat?t.glContext.HALF_FLOAT:t.glContext.FLOAT;this.texture=t.Texture.create(this.engine,{name:o,data:{width:this.width,height:this.height,data:a},target:t.glContext.TEXTURE_2D,format:t.glContext.RGBA,type:s,wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,minFilter:t.glContext.NEAREST,magFilter:t.glContext.NEAREST})},e.prototype.update=function(e){var n,o;void 0!==this.buffer&&this.buffer.set(e,0),void 0!==this.texture&&this.texture.updateSource({sourceType:t.TextureSourceType.data,data:{width:this.width,height:this.height,data:null!==(o=null===(n=this.buffer)||void 0===n?void 0:n.data)&&void 0!==o?o:e},target:t.glContext.TEXTURE_2D})},e.prototype.dispose=function(){var e;this.engine=null,this.buffer=void 0,null===(e=this.texture)||void 0===e||e.dispose()},e.prototype.getSize=function(){return this.width*this.height},e.prototype.getTexture=function(){return this.texture},e}(),me=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.time=0,e.duration=0,e.tracks=[],e}return i(n,t),n.prototype.create=function(t){var n,o=this;this.name=this.genName(null!==(n=t.name)&&void 0!==n?n:"Unnamed animation"),this.type=e.PObjectType.animation,this.time=0,this.duration=0,this.tracks=[],t.tracks.forEach((function(e){var t=new de(e);o.tracks.push(t),o.duration=Math.max(o.duration,t.getEndTime())}))},n.prototype.tick=function(e,t,n){this.time=e;var o=this.time%this.duration;this.tracks.forEach((function(e){e.tick(o,t,n)}))},n.prototype.dispose=function(){this.tracks.forEach((function(e){e.dispose()})),this.tracks=[]},n}(U),ge=function(t){function n(n,o){var i,r,a,s=t.call(this)||this;s.animation=0,s.speed=0,s.delay=0,s.time=0,s.animations=[],s.name=s.genName(null!==(i=o.name)&&void 0!==i?i:"Unnamed tree"),s.type=e.PObjectType.animationManager,s.ownerItem=o,s.animation=null!==(r=n.animation)&&void 0!==r?r:-1,s.speed=1,s.delay=null!==(a=o.delay)&&void 0!==a?a:0,s.animations=[],void 0!==n.animations&&n.animations.forEach((function(e){var t=s.createAnimation(e);s.animations.push(t)}));var c=o.composition;return null!=c&&(s.sceneManager=c.loaderData.sceneManager),s}return i(n,t),n.prototype.createAnimation=function(e){var t=new me;return t.create(e),t},n.prototype.tick=function(e){var t=this,n=e*this.speed*.001;this.time+=n;var o=this.time-this.delay;o>=0&&(this.animation>=0&&this.animation<this.animations.length?this.animations[this.animation].tick(o,this.ownerItem,this.sceneManager):-88888888==this.animation&&this.animations.forEach((function(e){e.tick(o,t.ownerItem,t.sceneManager)})))},n.prototype.dispose=function(){this.ownerItem=null,this.animations.forEach((function(e){e.dispose()})),this.animations=[],this.sceneManager=null},n.prototype.getTreeItem=function(){return this.ownerItem},n}(U),ve=function(){function e(e){this.engine=e,this.managers=[]}return e.prototype.create=function(e){var t=this;this.managers=[],e.forEach((function(e){var n=new ge(e.options,e);t.managers.push(n)}))},e.prototype.insert=function(e){this.managers.push(e)},e.prototype.delete=function(e){var t=-1;this.managers.forEach((function(n,o){n===e&&(t=o)})),t>=0&&this.managers.splice(t,1)},e.prototype.dispose=function(){this.managers.forEach((function(e){e.dispose()})),this.managers=[]},e}(),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;\n#ifdef HAS_UV_SET2\nfsIn vec2 v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_NormalUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_EmissiveUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_OcclusionUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_BaseColorUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_MetallicRoughnessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_SpecularGlossinessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_DiffuseUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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(e){e.build=function(e,t,n){for(var o;null!==(o=/#include <(.+)>/gm.exec(e));)e=e.replace(o[0],ye[o[1]]);return e=e.replace(/#define FEATURES/,t.map((function(e){return"#define ".concat(e)})).join("\n")),n?"#version 300 es\n"+e:"#version 100\n"+e}}(fe||(fe={}));var be=function(){function t(){}return t.getVertexShaderCode=function(t){var n=t.isWebGL2,o=t.featureList,i=t.material.materialType;switch(i){case e.PMaterialType.unlit:case e.PMaterialType.pbr:case e.PMaterialType.shadowBase:return fe.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;\n#ifdef HAS_UV_SET2\nvsOut vec2 v_UVCoord2;\n#endif\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);\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}",o,n);case e.PMaterialType.skyboxFilter:return fe.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);}",o,n);default:throw new Error("Invalid material type ".concat(i," for getVertexShaderString!"))}},t.getFragmentShaderCode=function(t){var n=t.isWebGL2,o=t.featureList,i=t.material.materialType;switch(i){case e.PMaterialType.unlit:case e.PMaterialType.pbr:return fe.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}",o,n);case e.PMaterialType.shadowBase:return fe.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}",o,n);case e.PMaterialType.skyboxFilter:return fe.build("\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\nprecision highp float;\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);}",o,n);default:throw new Error("Invalid material type ".concat(i," for getFragmentShaderString!"))}},t.environment="webgl1",t}();function Te(e){return{vertexShaderCode:be.getVertexShaderCode(e),fragmentShaderCode:be.getFragmentShaderCode(e)}}function _e(e){return{vertexShaderCode:be.getVertexShaderCode(e),fragmentShaderCode:be.getFragmentShaderCode(e)}}function xe(e){return{vertexShaderCode:be.getVertexShaderCode(e),fragmentShaderCode:be.getFragmentShaderCode(e)}}function Se(e){return{vertexShaderCode:Ae({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 Ce(e){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 Me(e){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 Ae(e){void 0===e&&(e={});var t=["#version 100"];return e.hasUVs&&t.push("#define HAS_UVS 1"),e.hasNormals&&t.push("#define HAS_NORMALS 1"),t.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 "),t.join("\n")}var Ie=function(){function t(){this.funcMap=new Map,this.funcMap.set(e.PMaterialType.unlit,Te),this.funcMap.set(e.PMaterialType.pbr,Te),this.funcMap.set(e.PMaterialType.shadowBase,_e),this.funcMap.set(e.PMaterialType.shadowFilter,Me),this.funcMap.set(e.PMaterialType.normalVis,Se),this.funcMap.set(e.PMaterialType.simpleFilter,Ce),this.funcMap.set(e.PMaterialType.skyboxFilter,xe)}return t.getInstance=function(){return this._instance||(this._instance=new this)},t.prototype.genShaderCode=function(e){var t=e.material.materialType,n=this.funcMap.get(t);if(void 0!==n)return n(e);throw new Error("Invalid material type ".concat(t,", shader content ").concat(e))},t}(),Ee=function(n){function o(){var t=null!==n&&n.apply(this,arguments)||this;return t.materialType=e.PMaterialType.none,t.vertexShaderCode="",t.fragmentShaderCode="",t.depthMask=!0,t.depthTestHint=!0,t.blendMode=e.PBlendMode.opaque,t.alphaCutOff=.5,t.faceSideMode=e.PFaceSideMode.front,t}return i(o,n),o.prototype.getShaderFeatures=function(){var t=[];return this.isOpaque()?t.push("ALPHAMODE_OPAQUE 1"):this.isMasked()&&t.push("ALPHAMODE_MASK 1"),this.faceSideMode===e.PFaceSideMode.both&&t.push("DOUBLE_SIDED 1"),t},o.prototype.updateUniforms=function(e){if(this.isMasked()&&e.setFloat("u_AlphaCutoff",this.alphaCutOff),R.getInstance().renderMode3D===t.spec.RenderMode3D.uv){var n=R.getInstance().renderMode3DUVGridSize;e.setFloat("u_DebugUVGridSize",n)}},o.prototype.build=function(t){var n=this.getShaderFeatures();void 0!==t&&n.push.apply(n,l([],c(t),!1));var o=R.getInstance().isWebGL2;(o&&n.push("WEBGL2"),this.materialType!==e.PMaterialType.shadowBase)&&(R.getInstance().isEditorEnv&&n.push("EDITOR_TRANSFORM"));var i=Ie.getInstance().genShaderCode({material:this,isWebGL2:o,featureList:n});this.vertexShaderCode=i.vertexShaderCode,this.fragmentShaderCode=i.fragmentShaderCode},o.prototype.getBlendMode=function(n){return n===t.spec.MaterialBlending.masked?e.PBlendMode.masked:n===t.spec.MaterialBlending.translucent?e.PBlendMode.translucent:n===t.spec.MaterialBlending.additive?e.PBlendMode.additive:e.PBlendMode.opaque},o.prototype.getFaceSideMode=function(n){return n===t.spec.SideMode.DOUBLE?e.PFaceSideMode.both:n===t.spec.SideMode.BACK?e.PFaceSideMode.back:e.PFaceSideMode.front},o.prototype.setMaterialStates=function(n){this.blendMode===e.PBlendMode.translucent||this.blendMode===e.PBlendMode.additive?(n.blending=!0,n.depthTest=!0,n.blendEquation=[t.glContext.FUNC_ADD,t.glContext.FUNC_ADD],this.blendMode===e.PBlendMode.translucent?n.blendFunction=[t.glContext.ONE,t.glContext.ONE_MINUS_SRC_ALPHA,t.glContext.ONE,t.glContext.ONE_MINUS_SRC_ALPHA]:n.blendFunction=[t.glContext.ONE,t.glContext.ONE,t.glContext.ONE,t.glContext.ONE],n.depthMask=this.depthMask):R.getInstance().isTiny3dMode?(n.blending=!1,n.depthTest=!0,n.depthMask=!0):(n.blending=!1,n.depthTest=this.depthTestHint,n.depthMask=this.depthMask),this.setFaceSideStates(n)},o.prototype.setFaceSideStates=function(e){this.isBothFace()?e.culling=!1:this.isBackFace()?(e.cullFace=t.glContext.FRONT,e.frontFace=t.glContext.CCW,e.culling=!0):(e.cullFace=t.glContext.BACK,e.frontFace=t.glContext.CCW,e.culling=!0)},o.prototype.dispose=function(){this.vertexShaderCode="",this.fragmentShaderCode=""},o.prototype.isValid=function(){return this.materialType!==e.PMaterialType.none&&n.prototype.isValid.call(this)},o.prototype.isOpaque=function(){return this.blendMode===e.PBlendMode.opaque},o.prototype.isMasked=function(){return this.blendMode===e.PBlendMode.masked},o.prototype.isTranslucent=function(){return this.blendMode===e.PBlendMode.translucent},o.prototype.isAdditive=function(){return this.blendMode===e.PBlendMode.additive},o.prototype.requireBlend=function(){return this.blendMode===e.PBlendMode.translucent||this.blendMode===e.PBlendMode.additive},o.prototype.isFrontFace=function(){return this.faceSideMode===e.PFaceSideMode.front},o.prototype.isBackFace=function(){return this.faceSideMode===e.PFaceSideMode.back},o.prototype.isBothFace=function(){return this.faceSideMode===e.PFaceSideMode.both},o}(U),Pe=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.baseColorFactor=new y(1,1,1,1),e}return i(n,t),n.prototype.create=function(t){var n;this.name=t.name,this.type=e.PObjectType.material,this.materialType=e.PMaterialType.unlit,t.baseColorTexture&&(this.baseColorTexture=t.baseColorTexture),this.setBaseColorFactor($.toPluginColor4(t.baseColorFactor)),!1===t.depthMask?this.depthMask=!1:this.depthMask=!0,this.blendMode=this.getBlendMode(t.blending),this.alphaCutOff=null!==(n=t.alphaCutOff)&&void 0!==n?n:0,this.faceSideMode=this.getFaceSideMode(t.side)},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.baseColorTexture=void 0},n.prototype.getShaderFeatures=function(){var e=t.prototype.getShaderFeatures.call(this);return e.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&e.push("HAS_BASE_COLOR_MAP 1"),e.push("MATERIAL_UNLIT 1"),e},n.prototype.updateUniforms=function(e){t.prototype.updateUniforms.call(this,e);var n=(new b).identity();e.setVector4("u_BaseColorFactor",this.baseColorFactor),this.hasBaseColorTexture()&&(e.setTexture("u_BaseColorSampler",this.getBaseColorTexture()),e.setInt("u_BaseColorUVSet",0),e.setMatrix3("u_BaseColorUVTransform",n)),e.setFloat("u_MetallicFactor",0),e.setFloat("u_RoughnessFactor",0),e.setFloat("u_Exposure",1)},n.prototype.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},n.prototype.getBaseColorTexture=function(){return this.baseColorTexture},n.prototype.setBaseColorTexture=function(e){this.baseColorTexture=e},n.prototype.getBaseColorFactor=function(){return this.baseColorFactor},n.prototype.setBaseColorFactor=function(e){e instanceof y?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},n}(Ee),we=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.baseColorFactor=new y(1,1,1,1),e.useSpecularAA=!1,e.metallicFactor=0,e.roughnessFactor=1,e.normalTextureScale=1,e.occlusionTextureStrength=1,e.emissiveFactor=new v(0,0,0),e.emissiveIntensity=1,e.enableShadow=!1,e}return i(n,t),n.prototype.create=function(t){var n,o,i,r,a;this.name=t.name,this.type=e.PObjectType.material,this.materialType=e.PMaterialType.pbr,t.baseColorTexture&&(this.baseColorTexture=t.baseColorTexture),t.baseColorTextureTransform&&(this.baseColorTextureTrans=$.createUVTransform(t.baseColorTextureTransform)),this.setBaseColorFactor($.toPluginColor4(t.baseColorFactor)),t.metallicRoughnessTexture&&(this.metallicRoughnessTexture=t.metallicRoughnessTexture),t.metallicRoughnessTextureTransform&&(this.metallicRoughnessTextureTrans=$.createUVTransform(t.metallicRoughnessTextureTransform)),this.useSpecularAA=null!==(n=t.useSpecularAA)&&void 0!==n&&n,this.metallicFactor=t.metallicFactor,this.roughnessFactor=$.clamp(t.roughnessFactor,0,1),t.normalTexture&&(this.normalTexture=t.normalTexture),t.normalTextureTransform&&(this.normalTextureTrans=$.createUVTransform(t.normalTextureTransform)),this.normalTextureScale=null!==(o=t.normalTextureScale)&&void 0!==o?o:1,t.occlusionTexture&&(this.occlusionTexture=t.occlusionTexture),t.occlusionTextureTransform&&(this.occlusionTextureTrans=$.createUVTransform(t.occlusionTextureTransform)),this.occlusionTextureStrength=null!==(i=t.occlusionTextureStrength)&&void 0!==i?i:1,t.emissiveTexture&&(this.emissiveTexture=t.emissiveTexture),t.emissiveTextureTransform&&(this.emissiveTextureTrans=$.createUVTransform(t.emissiveTextureTransform));var s=$.toPluginColor4(t.emissiveFactor);this.emissiveFactor=v.fromArray(s),this.emissiveIntensity=t.emissiveIntensity,this.enableShadow=null!==(r=t.enableShadow)&&void 0!==r&&r,!1===t.depthMask?this.depthMask=!1:this.depthMask=!0,this.blendMode=this.getBlendMode(t.blending),this.alphaCutOff=null!==(a=t.alphaCutOff)&&void 0!==a?a:0,this.faceSideMode=this.getFaceSideMode(t.side)},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.baseColorTexture=void 0,this.metallicRoughnessTexture=void 0,this.normalTexture=void 0,this.occlusionTexture=void 0,this.emissiveTexture=void 0},n.prototype.getShaderFeatures=function(){var e=t.prototype.getShaderFeatures.call(this);return e.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&(e.push("HAS_BASE_COLOR_MAP 1"),void 0!==this.baseColorTextureTrans&&e.push("HAS_BASECOLOR_UV_TRANSFORM 1")),this.hasMetallicRoughnessTexture()&&(e.push("HAS_METALLIC_ROUGHNESS_MAP 1"),void 0!==this.metallicRoughnessTextureTrans&&e.push("HAS_METALLICROUGHNESS_UV_TRANSFORM 1")),this.useSpecularAA&&e.push("USE_SPECULAR_AA 1"),this.hasNormalTexture()&&(e.push("HAS_NORMAL_MAP 1"),void 0!==this.normalTextureTrans&&e.push("HAS_NORMAL_UV_TRANSFORM 1")),this.hasOcclusionTexture()&&(e.push("HAS_OCCLUSION_MAP 1"),void 0!==this.occlusionTextureTrans&&e.push("HAS_OCCLUSION_UV_TRANSFORM 1")),this.hasEmissiveTexture()?(e.push("HAS_EMISSIVE_MAP 1"),void 0!==this.emissiveTextureTrans&&e.push("HAS_EMISSIVE_UV_TRANSFORM 1")):this.hasEmissiveFactor()&&e.push("HAS_EMISSIVE 1"),e},n.prototype.updateUniforms=function(e){t.prototype.updateUniforms.call(this,e);var n=(new b).identity();if(e.setVector4("u_BaseColorFactor",this.baseColorFactor),void 0!==this.baseColorTexture&&(e.setTexture("u_BaseColorSampler",this.baseColorTexture),e.setInt("u_BaseColorUVSet",0),void 0!==this.baseColorTextureTrans?e.setMatrix3("u_BaseColorUVTransform",this.baseColorTextureTrans):e.setMatrix3("u_BaseColorUVTransform",n)),e.setFloat("u_MetallicFactor",this.metallicFactor),e.setFloat("u_RoughnessFactor",this.roughnessFactor),void 0!==this.metallicRoughnessTexture&&(e.setTexture("u_MetallicRoughnessSampler",this.metallicRoughnessTexture),e.setInt("u_MetallicRoughnessUVSet",0),void 0!==this.metallicRoughnessTextureTrans?e.setMatrix3("u_MetallicRoughnessUVTransform",this.metallicRoughnessTextureTrans):e.setMatrix3("u_MetallicRoughnessUVTransform",n)),void 0!==this.normalTexture&&(e.setTexture("u_NormalSampler",this.normalTexture),e.setFloat("u_NormalScale",this.normalTextureScale),e.setInt("u_NormalUVSet",0),void 0!==this.normalTextureTrans?e.setMatrix3("u_NormalUVTransform",this.normalTextureTrans):e.setMatrix3("u_NormalUVTransform",n)),void 0!==this.occlusionTexture&&(e.setTexture("u_OcclusionSampler",this.occlusionTexture),e.setFloat("u_OcclusionStrength",this.occlusionTextureStrength),e.setInt("u_OcclusionUVSet",0),void 0!==this.occlusionTextureTrans?e.setMatrix3("u_OcclusionUVTransform",this.occlusionTextureTrans):e.setMatrix3("u_OcclusionUVTransform",n)),void 0!==this.emissiveTexture){var o=this.getEmissiveFactor();e.setTexture("u_EmissiveSampler",this.emissiveTexture),e.setVector3("u_EmissiveFactor",o),e.setInt("u_EmissiveUVSet",0),void 0!==this.emissiveTextureTrans?e.setMatrix3("u_EmissiveUVTransform",this.emissiveTextureTrans):e.setMatrix3("u_EmissiveUVTransform",n)}else if(this.hasEmissiveFactor()){o=this.getEmissiveFactor();e.setVector3("u_EmissiveFactor",o)}e.setFloat("u_Exposure",3)},n.prototype.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},n.prototype.hasBaseColorTextureTrans=function(){return void 0!==this.baseColorTextureTrans},n.prototype.setBaseColorTexture=function(e){this.baseColorTexture=e},n.prototype.getBaseColorFactor=function(){return this.baseColorFactor},n.prototype.setBaseColorFactor=function(e){e instanceof y?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},n.prototype.hasMetallicRoughnessTexture=function(){return void 0!==this.metallicRoughnessTexture},n.prototype.hasMetallicRoughnessTextureTrans=function(){return void 0!==this.metallicRoughnessTextureTrans},n.prototype.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture},n.prototype.setMetallicRoughnessTexture=function(e){this.metallicRoughnessTexture=e},n.prototype.hasNormalTexture=function(){return void 0!==this.normalTexture},n.prototype.hasNormalTextureTrans=function(){return void 0!==this.normalTextureTrans},n.prototype.getNormalTexture=function(){return this.normalTexture},n.prototype.setNormalTexture=function(e){this.normalTexture=e},n.prototype.hasOcclusionTexture=function(){return void 0!==this.occlusionTexture},n.prototype.hasOcclusionTextureTrans=function(){return void 0!==this.occlusionTextureTrans},n.prototype.getOcclusionTexture=function(){return this.occlusionTexture},n.prototype.setOcclusionTexture=function(e){this.occlusionTexture=e},n.prototype.hasEmissiveTexture=function(){return void 0!==this.emissiveTexture},n.prototype.hasEmissiveTextureTrans=function(){return void 0!==this.emissiveTextureTrans},n.prototype.getEmissiveTexture=function(){return this.emissiveTexture},n.prototype.setEmissiveTexture=function(e){this.emissiveTexture=e},n.prototype.hasEmissiveFactor=function(){return this.emissiveFactor.sum()*this.emissiveIntensity>0},n.prototype.getEmissiveFactor=function(){return this.emissiveFactor.clone().multiply(this.emissiveIntensity)},n.prototype.setEmissiveFactor=function(e){e instanceof v?this.emissiveFactor.set(e.x,e.y,e.z):this.emissiveFactor.set(e[0],e[1],e[2])},n}(Ee);function Oe(e){if(e.type===t.spec.MaterialType.pbr){var n=new we;return n.create(e),n}var o=new Pe;return o.create(e),o}var Le,Ne=function(t){function n(n,o){var i=t.call(this)||this;i.renderable=!0,i.intensity=1,i.reflectionsIntensity=1,i.specularImageSize=0,i.specularMipCount=0,i.priority=0,i.isBuilt=!1,i.name=n.name,i.type=e.PObjectType.skybox,i.visible=!1,i.ownerItem=o;var r=n.content.options;return i.renderable=r.renderable,i.intensity=r.intensity,i.reflectionsIntensity=r.reflectionsIntensity,i.irradianceCoeffs=r.irradianceCoeffs,i.diffuseImage=r.diffuseImage,i.specularImage=r.specularImage,i.specularImageSize=r.specularImageSize,i.specularMipCount=r.specularMipCount,i.priority=(null==o?void 0:o.listIndex)||0,i}return i(n,t),n.prototype.setup=function(e){this.brdfLUT=e},n.prototype.build=function(e){this.isBuilt||(this.isBuilt=!0,this.skyboxMaterial=new Fe,this.skyboxMaterial.create(this),this.skyboxMaterial.build(),this.skyboxMesh=e.getFilterMesh("SkyboxFilterPlane",this.skyboxMaterial,{}),this.skyboxMesh.priority=this.priority,this.skyboxMaterial.updateUniforms(this.skyboxMesh.material))},n.prototype.dispose=function(){var e;this.diffuseImage=void 0,this.specularImage=void 0,this.brdfLUT=void 0,this.skyboxMesh=void 0,null===(e=this.skyboxMaterial)||void 0===e||e.dispose(),this.skyboxMaterial=void 0},n.prototype.addToRenderObjectSet=function(e){this.visible&&this.renderable&&void 0!==this.skyboxMesh&&e.add(this.skyboxMesh)},n.prototype.updateUniformsForScene=function(e){if(this.visible&&this.renderable&&void 0!==this.skyboxMesh&&void 0!==this.skyboxMaterial){var t=e.camera,n=e.viewMatrix,o=t.getNewProjectionMatrix(t.fovy).multiply(n).invert(),i=this.skyboxMesh.material;this.skyboxMaterial.updateUniforms(i),i.setMatrix("u_InvViewProjectionMatrix",o)}},Object.defineProperty(n.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(n.prototype,"currentIntensity",{get:function(){return this.visible?this.intensity:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentReflectionsIntensity",{get:function(){return this.visible?this.reflectionsIntensity:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasDiffuseImage",{get:function(){return void 0!==this.diffuseImage},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasIrradianceCoeffs",{get:function(){return void 0!==this.irradianceCoeffs},enumerable:!1,configurable:!0}),n}(D),Fe=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.intensity=1,e.reflectionsIntensity=1,e.specularMipCount=0,e}return i(n,t),n.prototype.create=function(t){this.type=e.PObjectType.material,this.materialType=e.PMaterialType.skyboxFilter,this.depthTestHint=!1,this.name=t.name,this.intensity=t.intensity,this.reflectionsIntensity=t.reflectionsIntensity,this.brdfLUT=t.brdfLUT,this.irradianceCoeffs=t.irradianceCoeffs,this.diffuseImage=t.diffuseImage,this.specularImage=t.specularImage,this.specularMipCount=t.specularMipCount},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.brdfLUT=void 0,this.irradianceCoeffs=void 0,this.diffuseImage=void 0,this.specularImage=void 0},n.prototype.getShaderFeatures=function(){var e=[];return e.push("USE_IBL 1"),e.push("USE_TEX_LOD 1"),void 0===this.diffuseImage&&e.push("IRRADIANCE_COEFFICIENTS 1"),e},n.prototype.updateUniforms=function(e){if(void 0===this.brdfLUT)throw new Error("Setup brdfLUT for skybox at first.");if(e.setVector2("u_IblIntensity",new g(2,2)),e.setTexture("u_brdfLUT",this.brdfLUT),void 0!==this.diffuseImage)e.setTexture("u_DiffuseEnvSampler",this.diffuseImage);else{var t=this.irradianceCoeffs;if(void 0===t||9!=t.length)throw new Error("Invalid skybox irradiance coeffs ".concat(t));["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(n,o){e.setVector3("u_shCoefficients.".concat(n),v.fromArray(t[o]))}))}e.setInt("u_MipCount",this.specularMipCount),e.setTexture("u_SpecularEnvSampler",this.specularImage)},n.prototype.setMaterialStates=function(e){e.depthTest=!0,e.depthMask=!1,this.setFaceSideStates(e)},n}(Ee);e.PSkyboxType=void 0,(Le=e.PSkyboxType||(e.PSkyboxType={}))[Le.NFT=0]="NFT",Le[Le.FARM=1]="FARM";var Re=function(){function n(){}return n.getBrdfLutTextureOptions=function(){return a(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return"https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png",[4,t.loadImage("https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png")];case 1:return e=n.sent(),[2,{name:"brdfLut",wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR,anisotropic:1,sourceType:t.TextureSourceType.image,image:e,generateMipmap:!1,flipY:!1,premultiplyAlpha:!1}]}}))}))},n.createBrdfLutTexture=function(e){return a(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:return[4,this.getBrdfLutTextureOptions()];case 1:return n=o.sent(),[2,t.Texture.create(e,n)]}}))}))},n.createSkyboxOptions=function(e,t){return a(this,void 0,void 0,(function(){var n,o,i,r,a,c,l,u;return s(this,(function(s){switch(s.label){case 0:return[4,this.createSpecularCubeMap(e,t)];case 1:return n=s.sent(),[4,this.createDiffuseCubeMap(e,t)];case 2:return o=s.sent(),i=t.renderable,r=t.intensity,a=t.reflectionsIntensity,c=t.irradianceCoeffs,l=t.specularImageSize,u=t.specularMipCount,[2,{renderable:i,intensity:r,reflectionsIntensity:a,irradianceCoeffs:c,diffuseImage:o,specularImage:n,specularImageSize:l,specularMipCount:u}]}}))}))},n.createSpecularCubeMap=function(e,n){return a(this,void 0,void 0,(function(){return s(this,(function(o){return t.glContext.CLAMP_TO_EDGE,t.glContext.CLAMP_TO_EDGE,t.glContext.LINEAR,t.glContext.LINEAR_MIPMAP_LINEAR,"url"===n.type?[2,Q.createTextureCubeMipmapFromURL(e,n.specularImage)]:[2,Q.createTextureCubeMipmapFromBuffer(e,n.specularImage,n.specularImageSize)]}))}))},n.createDiffuseCubeMap=function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){return void 0===t.diffuseImage?[2]:"url"===t.type?[2,Q.createTextureCubeFromURL(e,t.diffuseImage)]:[2,Q.createTextureCubeFromBuffer(e,t.diffuseImage)]}))}))},n.getSkyboxParams=function(t){void 0===t&&(t=e.PSkyboxType.NFT);var n=this.getSpecularImageList(t);return{type:"url",renderable:!0,intensity:1.8,reflectionsIntensity:1.8,irradianceCoeffs:this.getIrradianceCoeffs(t),diffuseImage:this.getDiffuseImageList(t,n),specularImage:n,specularImageSize:Math.pow(2,n.length-1),specularMipCount:n.length-1}},n.prototype.checkCubeMapImage=function(e){return a(this,void 0,void 0,(function(){var n,o,i,r;return s(this,(function(a){switch(a.label){case 0:o=[],i=0,a.label=1;case 1:return i<e.length?[4,t.loadImage(e[i])]:[3,4];case 2:if(r=a.sent(),i>0)if(i%6==0){if(2*r.width!==n.width||2*r.height!==n.height)throw new Error("Invalid cube map list1: index ".concat(i,", image0 ").concat(n,", image1 ").concat(r))}else if(r.width!==n.width||r.height!==n.height)throw new Error("Invalid cube map list2: index ".concat(i,", image0 ").concat(n,", image1 ").concat(r));i%6==0&&o.push([]),o[o.length-1].push(r),n=r,a.label=3;case 3:return i++,[3,1];case 4:return[2]}}))}))},n.getIrradianceCoeffs=function(t){var n=[];switch(t){case e.PSkyboxType.NFT:return;case e.PSkyboxType.FARM:n=[.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:n=[.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 o=[],i=0;i<n.length;i+=3)o.push([n[i],n[i+1],n[i+2]]);return o},n.getDiffuseImageList=function(t,n){if(t==e.PSkyboxType.NFT)return n[n.length-1]},n.getSpecularImageList=function(t){var n=[];if(t===e.PSkyboxType.FARM)n.push.apply(n,l([],c(this.getSpecularImageListAntFarm()),!1));else n.push.apply(n,l([],c(this.getSpecularImageListNFT()),!1));var o=[];return n.forEach((function(e,t){t%6==0&&o.push([]),o[o.length-1].push(e)})),o},n.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"]},n.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"]},n}(),Be=function(){function e(e){this.engine=e,this.loadSkybox=!1,this.meshCache=new Map,this.textureCache=new Map,this.geometryCache=new Map,this.renderPassCache=new Map}return e.loadStaticResources=function(){return a(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return void 0!==this.brdfLutTexOptions?[2]:(e=this,[4,Re.getBrdfLutTextureOptions()]);case 1:return e.brdfLutTexOptions=t.sent(),[2]}}))}))},e.genSkyboxOptions=function(t,n){return a(this,void 0,void 0,(function(){var o,i;return s(this,(function(r){switch(r.label){case 0:return void 0===(o=n)&&(o=Re.getSkyboxParams()),i=e,[4,Re.createSkyboxOptions(t,o)];case 1:return i.skyboxOptions=r.sent(),[2,e.skyboxOptions]}}))}))},e.prototype.setup=function(n){if(this.loadSkybox=n,void 0===this.brdfLutTexture||this.brdfLutTexture.isDestroyed){if(void 0===e.brdfLutTexOptions)throw new Error("Please load brdfLutTexOptions at first");var o="brdfLutTexture";this.brdfLutTexture=t.Texture.create(this.engine,e.brdfLutTexOptions),this.deleteTexture(o),this.setTexture(o,this.brdfLutTexture)}},e.prototype.getTexture=function(e){return this.textureCache.get(e)},e.prototype.setTexture=function(e,t){this.textureCache.set(e,t)},e.prototype.getOrCreateTexture=function(e,n){var o=this.textureCache.get(e);if(void 0!==o)return o;var i=t.Texture.create(this.engine,n);return this.textureCache.set(e,i),i},e.prototype.deleteTexture=function(e){var t=this.textureCache.get(e);return void 0!==t&&t.dispose(),this.textureCache.delete(e)},e.prototype.getOrCreateGeometry=function(e,t,n){var o=this.geometryCache.get(e);if(void 0!==o)return o;var i=$.createGeometry(this.engine,t,n);return this.geometryCache.set(e,i),i},e.prototype.getFilterMesh=function(e,t,n){var o=this.meshCache.get(e);if(void 0!==o)return o;var i=Z.createFilterMesh(this.engine,e,t,n);return this.meshCache.set(e,i),i},e.prototype.getShadowBasePass=function(e,t,n,o){return this.getRenderPass(e,t,n,o)},e.prototype.getShadowFilterPass=function(e,t,n,o){return this.getRenderPass(e,t,n,o)},e.prototype.getRenderPass=function(e,t,n,o){var i=this.renderPassCache.get(e);if(void 0!==i)return i.setMeshes([]),n.forEach((function(e){i.addMesh(e)})),i;var r=this.engine.renderer,a=Q.createRenderPass(r,e,t,n,o);return this.renderPassCache.set(e,a),a},e.prototype.dispose=function(){this.engine=null,this.brdfLutTexture=void 0,this.meshCache.forEach((function(e){Q.deleteMesh(e)})),this.meshCache.clear(),this.textureCache.forEach((function(e){Q.deleteTexture(e)})),this.textureCache.clear(),this.geometryCache.forEach((function(e){Q.deleteGeometry(e)})),this.geometryCache.clear(),this.renderPassCache.forEach((function(e){Q.deleteRenderPass(e)})),this.renderPassCache.clear()},e.prototype.getRenderPasses=function(){var e=[];return this.renderPassCache.forEach((function(t){e.push(t)})),e},e.prototype.getBrdfLutTexture=function(){return this.brdfLutTexture},e.prototype.getSkyboxOptions=function(){return e.skyboxOptions},e}(),Ue=Math.PI/180,De=function(n){function o(o,i,r,a){var s,c=n.call(this)||this;c.width=512,c.height=512,c.nearPlane=.001,c.farPlane=1e3,c.fovy=45,c.aspect=1,c.clipMode=t.spec.CameraClipMode.landscape,c.projectionMatrix=new T,c.viewMatrix=new T,c.name=o.name,c.type=e.PObjectType.camera,c.visible=!1,c.ownerItem=a,c.width=i,c.height=r;var l=o.content.options;return c.nearPlane=l.near,c.farPlane=l.far,c.fovy=l.fov,c.aspect=null!==(s=l.aspect)&&void 0!==s?s:c.width/c.height,c.clipMode=l.clipMode,c.update(),c}return i(o,n),o.prototype.update=function(){void 0!==this.ownerItem&&this.transform.fromEffectsTransform(this.ownerItem.transform);var e=this.clipMode===t.spec.CameraClipMode.portrait;this.projectionMatrix.perspective(this.fovy*Ue,this.aspect,this.nearPlane,this.farPlane,e),this.viewMatrix=this.matrix.invert()},o.prototype.getNewProjectionMatrix=function(e){var n=this.clipMode===t.spec.CameraClipMode.portrait;return(new T).perspective(Math.min(1.25*e,140)*Ue,this.aspect,this.nearPlane,this.farPlane,n)},o.prototype.computeViewAABB=function(e){var t=Math.tan(this.fovy*Ue*.5),n=this.aspect,o=0,i=0,r=0,a=0;this.isReversed()?(o=(r=this.farPlane*t)/n,i=(a=this.nearPlane*t)/n):(r=n*(o=this.farPlane*t),a=n*(i=this.nearPlane*t)),e.makeEmpty();var s=this.matrix;return e.expandByPoint(s.transformPoint(new v(r,o,-this.farPlane))),e.expandByPoint(s.transformPoint(new v(r,-o,-this.farPlane))),e.expandByPoint(s.transformPoint(new v(-r,o,-this.farPlane))),e.expandByPoint(s.transformPoint(new v(-r,-o,-this.farPlane))),e.expandByPoint(s.transformPoint(new v(a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new v(a,-i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new v(-a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new v(-a,-i,-this.nearPlane))),e},o.prototype.getSize=function(){return new g(this.width,this.height)},o.prototype.isReversed=function(){return this.clipMode===t.spec.CameraClipMode.portrait},o.prototype.getEye=function(){return this.translation},o.prototype.setEye=function(e){this.translation=e},o}(D),ke=function(){function e(){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:t.spec.CameraClipMode.portrait}},endBehavior:t.spec.END_BEHAVIOR_FORWARD},512,512)}return e.prototype.initial=function(e,t){this.winWidth=e,this.winHeight=t;var n=this.defaultCamera;n.width=e,n.height=t,n.aspect=e/t,n.update()},e.prototype.insert=function(e,t){var n=new De(e,this.winWidth,this.winHeight,t);return this.cameraList.push(n),n},e.prototype.insertCamera=function(e){this.cameraList.push(e)},e.prototype.remove=function(e){if(e instanceof De){var t=this.cameraList.findIndex((function(t){return t===e}));-1!==t&&this.cameraList.splice(t,1)}else e>=0&&e<this.cameraList.length&&this.cameraList.splice(e,1)},e.prototype.dispose=function(){this.cameraList=[]},e.prototype.updateDefaultCamera=function(e,t,n,o,i,r,a){this.defaultCamera.fovy=e,this.defaultCamera.nearPlane=t,this.defaultCamera.farPlane=n,this.defaultCamera.position=o,this.defaultCamera.rotation=i,this.defaultCamera.aspect=r,this.defaultCamera.clipMode=a,this.defaultCamera.update()},e.prototype.getCameraList=function(){return this.cameraList},e.prototype.getDefaultCamera=function(){return this.defaultCamera},e.prototype.getCameraCount=function(){return this.cameraList.length},e.prototype.getActiveCamera=function(){return this.defaultCamera},e.prototype.getAspect=function(){return this.winWidth/this.winHeight},e}(),Ve=function(t){function n(n,o){var i=t.call(this)||this;i.direction=new v(0,0,1),i.range=0,i.color=new v(1,1,1),i.intensity=0,i.outerConeAngle=0,i.innerConeAngle=0,i.lightType=e.PLightType.ambient,i.padding=new g(0,0),i.name=n.name,i.type=e.PObjectType.light,i.visible=!1,i.ownerItem=o,void 0!==o&&i.transform.fromEffectsTransform(o.transform),i.direction=new v(0,0,-1),i.range=0,i.outerConeAngle=0,i.innerConeAngle=0;var r=n.content.options,a=$.toPluginColor4(r.color);return i.color=new v(a[0],a[1],a[2]),i.intensity=r.intensity,"point"===r.lightType?(i.lightType=e.PLightType.point,i.range=r.range):"spot"===r.lightType?(i.lightType=e.PLightType.spot,i.range=r.range,i.outerConeAngle=r.outerConeAngle,i.innerConeAngle=r.innerConeAngle):"directional"===r.lightType?i.lightType=e.PLightType.directional:i.lightType=e.PLightType.ambient,i}return i(n,t),n.prototype.tick=function(e){void 0!==this.ownerItem&&this.transform.fromEffectsTransform(this.ownerItem.transform)},n.prototype.isDirectional=function(){return this.lightType===e.PLightType.directional},n.prototype.isPoint=function(){return this.lightType===e.PLightType.point},n.prototype.isSpot=function(){return this.lightType===e.PLightType.spot},n.prototype.isAmbient=function(){return this.lightType===e.PLightType.ambient},Object.defineProperty(n.prototype,"position",{get:function(){return this.translation},enumerable:!1,configurable:!0}),n.prototype.getWorldPosition=function(){return this.translation},n.prototype.getWorldDirection=function(){return this.matrix.transformNormal(this.direction,new v)},n}(D),Ge=function(){function e(){this.lightList=[]}return e.prototype.tick=function(e){this.lightList.forEach((function(t){t.tick(e)}))},e.prototype.insertItem=function(e,t){var n=new Ve(e,t);return this.lightList.push(n),n},e.prototype.insertLight=function(e){return this.lightList.push(e),e},e.prototype.remove=function(e){var t=this.lightList.findIndex((function(t){return t===e}));-1!==t&&this.lightList.splice(t,1)},e.prototype.dispose=function(){this.lightList=[]},Object.defineProperty(e.prototype,"lightCount",{get:function(){return this.lightList.length},enumerable:!1,configurable:!0}),e}(),je=function(){function e(e){var t,n;this.resolution=null!==(t=e.resolution)&&void 0!==t?t:new g(512,512),this.colorAttachments=null!==(n=e.colorAttachments)&&void 0!==n?n:[],this.depthAttachment=e.depthAttachment}return e.prototype.addDepthAttachment=function(e){var n;this.depthAttachment={storageType:null!==(n=e.storageType)&&void 0!==n?n:t.RenderPassAttachmentStorageType.depth_16_texture}},e.prototype.addDefaultDepthAttachment=function(){this.depthAttachment={storageType:t.RenderPassAttachmentStorageType.depth_16_texture}},e.prototype.deleteDepthAttachment=function(){this.depthAttachment=void 0},e.prototype.addColorAttachment=function(e){var n,o,i,r;this.colorAttachments.push({texture:{format:null!==(n=e.format)&&void 0!==n?n:t.glContext.RGBA,type:null!==(o=e.type)&&void 0!==o?o:t.glContext.HALF_FLOAT,minFilter:null!==(i=e.filter)&&void 0!==i?i:t.glContext.LINEAR,magFilter:null!==(r=e.filter)&&void 0!==r?r:t.glContext.LINEAR}})},e.prototype.deleteColorAttachment=function(e){e>=0&&e<this.colorAttachments.length&&this.colorAttachments.splice(e,1)},Object.defineProperty(e.prototype,"viewport",{get:function(){return[0,0,this.resolution.x,this.resolution.y]},enumerable:!1,configurable:!0}),e}(),ze=function(){function e(e,n){var o=t.Material.create(e,{shader:{vertex:this.vertexShader,fragment:this.fragmentShader,shared:!0}});o.depthTest=!0,o.depthMask=!0,this.mesh=t.Mesh.create(e,{name:"boxMesh",material:o,geometry:t.Geometry.create(e,this.geometry),priority:n})}return e.prototype.update=function(e,t,n,o){var i=this.mesh.material;i.setMatrix("u_ModelMatrix",e),i.setMatrix("u_ViewProjectionMatrix",t);for(var r=0;r<n.length;r+=3)i.setVector3("u_PositionList[".concat(r/3,"]"),v.fromArray(n,r));i.setVector3("u_LineColor",o)},e.prototype.dispose=function(){this.mesh.dispose(),this.mesh=void 0},Object.defineProperty(e.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(e.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(e.prototype,"geometry",{get:function(){var e=new Float32Array([0,1,2,3,4,5,6,7]),n=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:t.glContext.FLOAT,size:1,data:e,stride:Float32Array.BYTES_PER_ELEMENT,offset:0}},mode:t.glContext.LINES,indices:{data:n},drawStart:0,drawCount:24}},enumerable:!1,configurable:!0}),e}(),He=function(){function e(){this.now=new Set,this.last=new Set}return e.prototype.clear=function(){this.now.clear(),this.last.clear()},e.prototype.forward=function(){var e=this.last;this.last=this.now,this.now=e,this.now.clear()},e.prototype.forAddedItem=function(e){var t=this;this.now.forEach((function(n){t.last.has(n)||e(n)}))},e.prototype.forRemovedItem=function(e){var t=this;this.last.forEach((function(n){t.now.has(n)||e(n)}))},e}();!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}i(n,t),n.prototype.create=function(t){this.type=e.PObjectType.material,this.materialType=e.PMaterialType.shadowBase,this.name=t.name,this.shadowType=t.shadowType},n.prototype.getShaderFeatures=function(){return[]},n.prototype.updateUniforms=function(e){}}(Ee);var We=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n.prototype.create=function(t){this.type=e.PObjectType.material,this.materialType=e.PMaterialType.shadowBase,this.name=t.name,this.shadowType=t.shadowType},n.prototype.getShaderFeatures=function(){return[]},n.prototype.updateUniforms=function(e){},n}(Ee),Xe=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n.prototype.create=function(t){this.type=e.PObjectType.material,this.materialType=e.PMaterialType.shadowFilter,this.depthTestHint=!1,this.name=t.name,this.blurScale=t.blurScale},n.prototype.getShaderFeatures=function(){return[]},n.prototype.updateUniforms=function(e){e.setVector2("u_BlurScale",this.blurScale)},n}(Ee),Je=function(){function n(){this.enable=!1,this.quality="medium",this.softness=1.5,this.width=1024,this.height=1024,this.type=t.glContext.HALF_FLOAT,this.format=t.glContext.RGBA,this.filter=t.glContext.LINEAR,this.baseFBOOpts=this.getBaseFBOOptions(),this.filterFBOOpts=this.getFilterFBOOptions(),this.runtimeEnable=!1,this.meshList=[],this.primitiveList=[],this.viewAABB=new C,this.sceneAABB=new C,this.shadowAABB=new C,this.lightView=new T,this.lightProjection=new T,this.lightViewProjection=new T,this.xFilterMaterial=new Xe,this.yFilterMaterial=new Xe,this.meshCacheSet=new He,this.renderPassCacheSet=new He}return n.prototype.initial=function(e,t){var n,o,i,r=this;this.runtimeEnable=!1,this.meshList=[],this.primitiveList=[],this.shadowLight=void 0,this.meshCacheSet.clear(),this.renderPassCacheSet.clear(),this.sceneManager=e,this.renderer=e.getRenderer(),this.engine=this.renderer.engine,this.enable=null===(o=null==t?void 0:t.enable)||void 0===o||o,this.quality=null!==(i=null==t?void 0:t.quality)&&void 0!==i?i:"medium",this.softness=this.getSoftness(t),n=c(this.getTextureSize(t),2),this.width=n[0],this.height=n[1],this.type=this.getTextureType(t),this.format=this.getTextureFormat(t),this.filter=this.getTextureFilter(t),this.enable&&this.isSupportTextureOptions()&&(this.shadowLight=this.getShadowLight(e),void 0!==this.shadowLight&&(e.meshList.forEach((function(e){var t=0;e.primitives.forEach((function(e){e.isEnableShadow()&&(t+=1)})),t>0&&r.meshList.push(e)})),this.meshList.length<=0||(this.runtimeEnable=!0,this.xFilterMaterial.create({name:"ShadowXFilterPass",blurScale:new g(this.softness/this.width,0)}),this.yFilterMaterial.create({name:"ShadowYFilterPass",blurScale:new g(0,this.softness/this.height)}),this.xFilterMaterial.build([]),this.yFilterMaterial.build([]))))},n.prototype.build=function(){if(this.isEnable()){var e=this.sceneManager.getSceneCache();this.basePass=e.getShadowBasePass(this.basePassName,900,[],this.baseFBOOpts);var t=e.getFilterMesh(this.xFilterMeshName,this.xFilterMaterial,{u_FilterSampler:"Shadow0Color"}),n=e.getFilterMesh(this.yFilterMeshName,this.yFilterMaterial,{u_FilterSampler:"Shadow1Color"});this.xFilterMaterial.updateUniforms(t.material),this.yFilterMaterial.updateUniforms(n.material),this.xFilterPass=e.getShadowFilterPass(this.xFilterPassName,901,[t],this.filterFBOOpts),this.yFilterPass=e.getShadowFilterPass(this.yFilterPassName,902,[n],this.filterFBOOpts)}},n.prototype.tick=function(e){this.isEnable()&&(this.primitiveList=this.getCurrentPrimitiveList(),this.primitiveList.length<=0||(this.updateAABBInfo(),this.updateLightViewProjection(),this.updateShadowUniforms(),e.shadowMapSizeInv=new g(1/this.width,1/this.height),e.lightViewMatrix=this.lightView,e.lightProjectionMatrix=this.lightProjection,e.lightViewProjectionMatrix=this.lightViewProjection))},n.prototype.updateAABBInfo=function(){var e=this;this.sceneAABB.makeEmpty(),this.primitiveList.forEach((function(t){var n=t.getWorldBoundingBox();e.sceneAABB.expandByBox(n)})),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)},n.prototype.updateLightViewProjection=function(){void 0!==this.shadowLight&&(this.shadowLight.lightType===e.PLightType.directional?this.updateDirectionalLightViewProjection(this.shadowLight):this.shadowLight.lightType===e.PLightType.spot?this.updateSpotLightViewProjection(this.shadowLight):console.warn("Invalid light type for casting shadow: ".concat(this.shadowLight)))},n.prototype.updateDirectionalLightViewProjection=function(e){if(e.isDirectional()){var t=this.shadowAABB,n=t.getCenter(new v),o=e.getWorldDirection(),i=n.clone().add(o),r=Ye(o,new v),a=(new T).lookAt(n,i,r),s=t.clone().applyMatrix4(a),c=s.getCenter(new v),l=s.getSize(new v).multiply(.5);l.x=Math.max(l.x,l.y),l.y=Math.max(l.x,l.y);var u=l.clone().multiply(-1.001).add(c),h=l.clone().multiply(1.001).add(c),f=(new T).orthographic(u.x,h.x,u.y,h.y,u.z,h.z);return this.lightView.copyFrom(a),this.lightProjection.copyFrom(f),this.lightViewProjection.multiplyMatrices(f,a)}this.lightViewProjection.identity()},n.prototype.updateSpotLightViewProjection=function(e){if(e.isSpot()){var t=e.getWorldPosition(),n=e.direction.clone(),o=n.clone().multiply(10),i=t.clone().add(o),r=Ye(n,new v),a=T.fromLookAt(t,i,r),s=this.shadowAABB.clone().applyMatrix4(a),c=[new v(s.min.x,s.min.y,s.min.z),new v(s.min.x,s.min.y,s.max.z),new v(s.min.x,s.max.y,s.min.z),new v(s.min.x,s.max.y,s.max.z),new v(s.max.x,s.min.y,s.min.z),new v(s.max.x,s.min.y,s.max.z),new v(s.max.x,s.max.y,s.min.z),new v(s.max.x,s.max.y,s.max.z)],l=1,u=1e4,h=-1e4;c.map((function(e){if(e.z<=0){var t=new v(0,e.y,e.z).normalize();l=Math.min(l,-t.z),u=Math.min(u,-e.z),h=Math.max(h,-e.z)}}));var f=Math.acos(l),d=2*Math.min(f,e.outerConeAngle),p=T.fromPerspective(d,1,u,h,!1);return this.lightViewProjection.multiplyMatrices(p,a)}this.lightViewProjection.identity()},n.prototype.getShadowOptions=function(){return{viewProjectionMatrix:this.lightViewProjection,softness:this.softness}},n.prototype.updateShadowUniforms=function(){var e=this.getShadowOptions();this.primitiveList.forEach((function(t){t.updateUniformForShadow(e)}))},n.prototype.getShadowLight=function(t){for(var n=t.lightManager.lightList,o=0;o<n.length;o++){var i=n[o];if(i.lightType===e.PLightType.directional||i.lightType===e.PLightType.spot)return i}},n.prototype.getShadowPrimitiveCount=function(e){var t=0;return e.meshList.forEach((function(e){e.primitives.forEach((function(e){e.isEnableShadow()&&(t+=1)}))})),t},n.prototype.updateRenderPass=function(e){var t=this;if(void 0!==this.basePass){var n=this.basePass;this.meshCacheSet.forward(),this.primitiveList.forEach((function(e){e.isEnableShadow()&&void 0!==e.shadowMesh&&t.meshCacheSet.now.add(e.shadowMesh)})),this.meshCacheSet.forRemovedItem((function(e){n.removeMesh(e)})),this.meshCacheSet.forAddedItem((function(e){n.addMesh(e)}))}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 o=!1;this.renderPassCacheSet.forRemovedItem((function(t){e.removeRenderPass(t),o=!0}));var i=!1;this.renderPassCacheSet.forAddedItem((function(t){e.addRenderPass(t),i=!0})),i?this.updateFrameSemantics(e.semantics,!0):o&&this.updateFrameSemantics(e.semantics,!1)},n.prototype.updateFrameSemantics=function(e,t){var n=this;t?(void 0!==this.basePass&&e.setSemantic("Shadow0Color",(function(){return n.basePass.attachments[0].texture})),void 0!==this.xFilterPass&&e.setSemantic("Shadow1Color",(function(){return n.xFilterPass.attachments[0].texture})),void 0!==this.yFilterPass&&e.setSemantic("ShadowNColor",(function(){return n.yFilterPass.attachments[0].texture}))):(e.setSemantic("Shadow0Color",void 0),e.setSemantic("Shadow1Color",void 0),e.setSemantic("ShadowNColor",void 0))},n.prototype.isEnable=function(){return this.enable&&this.runtimeEnable},n.prototype.hasRenderObject=function(){return this.isEnable()&&this.primitiveList.length>0},n.prototype.getCurrentPrimitiveList=function(){var e=[];return this.meshList.forEach((function(t){t.visible&&t.primitives.forEach((function(t){t.isEnableShadow()&&void 0!==t.shadowMesh&&e.push(t)}))})),e},n.prototype.isSupportTextureOptions=function(){return this.type===t.glContext.FLOAT?Q.isSupportFloatTexture(this.engine):this.type!==t.glContext.HALF_FLOAT||Q.isSupportHalfFloatTexture(this.engine)},n.prototype.getBaseFBOOptions=function(){var e=new g(this.width,this.height),n={texture:{format:this.format,type:this.type,minFilter:this.filter,magFilter:this.filter}},o={storageType:t.RenderPassAttachmentStorageType.depth_16_opaque};return new je({resolution:e,colorAttachments:[n],depthAttachment:o})},n.prototype.getFilterFBOOptions=function(){var e=new g(this.width,this.height),t={texture:{format:this.format,type:this.type,minFilter:this.filter,magFilter:this.filter}};return new je({resolution:e,colorAttachments:[t]})},n.prototype.getSoftness=function(e){var n,o=null!==(n=null==e?void 0:e.softness)&&void 0!==n?n:1.5;return o>=0&&o<=2?o:(console.error("Invalid softness value from shadow init options, ".concat(o)),t.math.clamp(o,0,2))},n.prototype.getTextureSize=function(e){var t,n,o=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:1024,i=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:1024;return o===i&&o>0&&o<=4096?[o,i]:(console.error("Invalid texture size from shadow init options, ".concat(o,"x").concat(i)),[1024,1024])},n.prototype.getTextureType=function(e){var n,o=null!==(n=null==e?void 0:e.type)&&void 0!==n?n:t.glContext.HALF_FLOAT;return o===t.glContext.UNSIGNED_BYTE||o===t.glContext.HALF_FLOAT||o===t.glContext.FLOAT?o:(console.error("Invalid texture type from shadow init options, ".concat(o)),t.glContext.HALF_FLOAT)},n.prototype.getTextureFormat=function(e){var n,o=null!==(n=null==e?void 0:e.format)&&void 0!==n?n:t.glContext.RGBA;return o===t.glContext.RGBA?o:(console.error("Invalid texture format from shadow init options, ".concat(o)),t.glContext.RGBA)},n.prototype.getTextureFilter=function(e){var n,o=null!==(n=null==e?void 0:e.filter)&&void 0!==n?n:t.glContext.LINEAR;return o===t.glContext.NEAREST||o===t.glContext.LINEAR?o:(console.error("Invalid texture filter from shadow init options, ".concat(o)),t.glContext.LINEAR)},Object.defineProperty(n.prototype,"mainPassUniformSemantics",{get:function(){return{u_ShadowSampler:"ShadowNColor"}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"basePassName",{get:function(){return this.sceneManager.compName+"_ShadowBasePass"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"xFilterPassName",{get:function(){return this.sceneManager.compName+"_ShadowXFilterPass"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"yFilterPassName",{get:function(){return this.sceneManager.compName+"_ShadowYFilterPass"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"xFilterMeshName",{get:function(){return this.sceneManager.compName+"_ShadowXFilterMesh"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"yFilterMeshName",{get:function(){return this.sceneManager.compName+"_ShadowYFilterMesh"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shadowPassList",{get:function(){var e=[];return void 0!==this.basePass&&e.push(this.basePass),void 0!==this.xFilterPass&&e.push(this.xFilterPass),void 0!==this.yFilterPass&&e.push(this.yFilterPass),e},enumerable:!1,configurable:!0}),n}();function Ye(e,t){var n,o=e.clone().normalize(),i=o.clone().abs();return 1!==((n=i).x<n.y?n.x<n.z?0:2:n.y<n.z?1:2)?t.set(0,1,0):(t.set(o.z,0,-o.x),t.normalize()),t}var qe=function(n){function o(t,o,i,r){var a=n.call(this)||this;a.engine=t,a.parentIndex=-1,a.primitives=[],a.hide=!0,a.priority=0,a.boundingBox=new C,a.visBoundingBox=!1,a.isBuilt=!1,a.isDisposed=!1;var s=new Ze(o,r);return a.name=s.getName(),a.type=e.PObjectType.mesh,a.visible=!1,a.ownerItem=i,a.parentIndex=s.getParentIndex(),a.parentItem=s.parentItem,a.parentItemId=s.getParentId(),a.skin=s.getSkinObj(t),a.morph=s.getMorphObj(),a.hide=s.isHide(),a.priority=(null==i?void 0:i.listIndex)||0,a.primitives=[],s.getPrimitives().forEach((function(e){var t=new Ke(a.engine);t.create(e,a),a.primitives.push(t)})),a.primitives.length<=0&&console.warn("No primitive inside mesh item ".concat(s.getName())),a.boundingBox=a.getItemBoundingBox(o.content.interaction),R.getInstance().visBoundingBox&&(a.boundingBoxMesh=new ze(a.engine,a.priority)),a}return i(o,n),o.prototype.build=function(e,t,n){this.isBuilt||(this.isBuilt=!0,this.primitives.forEach((function(o){o.build(e,t,n)})))},o.prototype.tick=function(e){this.visible&&(void 0!==this.ownerItem&&this.transform.setMatrix(this.ownerItem.transform.getWorldMatrix()),void 0!==this.skin&&this.skin.updateSkinMatrices())},o.prototype.addToRenderObjectSet=function(e){this.visible&&(this.primitives.forEach((function(t){e.add(t.effectsMesh)})),this.visBoundingBox&&void 0!==this.boundingBoxMesh&&e.add(this.boundingBoxMesh.mesh))},o.prototype.dispose=function(){var e,t,n;this.isDisposed||(this.isDisposed=!0,this.engine=null,this.parentItem=void 0,null===(e=this.skin)||void 0===e||e.dispose(),this.skin=void 0,null===(t=this.morph)||void 0===t||t.dispose(),this.morph=void 0,this.primitives.forEach((function(e){e.dispose()})),this.primitives=[],null===(n=this.boundingBoxMesh)||void 0===n||n.dispose(),this.boundingBoxMesh=void 0)},o.prototype.updateMorphWeights=function(e){if(void 0!==this.morph&&this.morph.hasMorph()){var t=this.morph.morphWeightsArray;if(void 0!==t){if(t.length!=e.length)throw new Error("weight array length mismatch");for(var n=0;n<t.length;n++)t[n]=e[n]}}},o.prototype.updateParentItem=function(e){this.parentItem=e,void 0!==this.skin&&this.skin.updateParentItem(e)},o.prototype.updateUniformsForScene=function(e){var t=this.matrix,n=t.clone().invert().transpose();if(this.primitives.forEach((function(o){o.updateUniformsForScene(t,n,e)})),0===e.deltaSeconds&&void 0!==this.boundingBoxMesh){this.computeBoundingBox(t);var o=new v(1,1,1),i=this.boundingBox.min,r=this.boundingBox.max,a=new Float32Array([i.x,i.y,i.z,r.x,i.y,i.z,r.x,r.y,i.z,i.x,r.y,i.z,i.x,i.y,r.z,r.x,i.y,r.z,r.x,r.y,r.z,i.x,r.y,r.z]);this.boundingBoxMesh.update(t,e.viewProjectionMatrix,a,o)}},o.prototype.updateUniformForShadow=function(e){this.primitives.forEach((function(t){t.updateUniformForShadow(e)}))},o.prototype.hitTesting=function(e,t){var n,o=this.matrix,i=o.clone().invert(),r=i.transformPoint(e,new v),a=i.transformNormal(t,new v),s=this.boundingBox,c=j(r,a,s.min,s.max);return void 0===c?[]:(R.getInstance().isEditorEnv?this.primitives.forEach((function(e){var t=e.hitTesting(r,a,o,i);void 0!==t&&(void 0===n||n>t)&&(n=t)})):n=c,void 0===n?[]:(a.multiply(n),r.add(a),o.transformPoint(r),[r]))},o.prototype.computeBoundingBox=function(e){var t=this.boundingBox.makeEmpty(),n=e.clone().invert();return this.primitives.forEach((function(e){var o=e.computeBoundingBox(n);t.union(o)})),t},o.prototype.getItemBoundingBox=function(e){var n,o,i,r;if(void 0===e)return new C;if(e.type===t.spec.ModelBoundingType.box){var a=null!==(n=e.center)&&void 0!==n?n:[0,0,0],s=null!==(o=e.size)&&void 0!==o?o:[0,0,0],c=v.fromArray(a),l=v.fromArray(s).multiply(.5),u=c.clone().subtract(l),h=c.clone().add(l);return new C(u,h)}a=null!==(i=e.center)&&void 0!==i?i:[0,0,0];var f=.5*(null!==(r=e.radius)&&void 0!==r?r:0);u=(c=v.fromArray(a)).clone().subtract(f),h=c.clone().add(f);return new C(u,h)},o.prototype.getParentId=function(){return this.parentItemId},Object.defineProperty(o.prototype,"hasSkin",{get:function(){return void 0!==this.skin},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"mriMeshs",{get:function(){return this.primitives.map((function(e){return e.effectsMesh}))},enumerable:!1,configurable:!0}),o}(D),Ke=function(){function n(t){this.engine=t,this.name="",this.effectsPriority=0,this.boundingBox=new C,this.isCompressed=!1,this.shadowType=e.PShadowType.none}return n.prototype.create=function(t,n){if(this.parent=n,this.skin=n.skin,this.morph=n.morph,this.setGeometry(t.geometry),this.setMaterial(t.material),this.name=n.name,this.effectsPriority=n.priority,this.geometry.setHide(n.hide),void 0!==this.skin){var o=this.skin.getJointCount();if(this.jointMatrixList=new Float32Array(16*o),this.jointNormalMatList=new Float32Array(16*o),this.skin.isTextureDataMode()){var i=this.skin.textureDataMode===e.TextureDataMode.half_float;this.jointMatrixTexture=new pe(this.engine),this.jointNormalMatTexture=new pe(this.engine),this.jointMatrixTexture.create(o,i,"jointMatrixTexture"),this.jointNormalMatTexture.create(o,i,"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=e.PShadowType.none,this.material instanceof we&&this.material.enableShadow&&(this.shadowType=e.PShadowType.expVariance)},n.prototype.build=function(e,n,o){var i=R.getInstance(),r=this.getFeatureList(e,!0,o);this.material.build(r);var a=this.isEnableShadow()?n:{};a.u_ViewProjectionMatrix="VIEWPROJECTION",a.u_ModelMatrix="MODEL",a.uEditorTransform="EDITOR_TRANSFORM";var s=t.Material.create(this.engine,{shader:{vertex:this.material.vertexShaderCode,fragment:this.material.fragmentShaderCode,shared:i.shaderShared},uniformSemantics:a});this.material.setMaterialStates(s);var c=t.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 l=this.getFeatureList(e,!1,o);this.shadowMaterial.build(l);var u=this.shadowMaterial.vertexShaderCode,h=this.shadowMaterial.fragmentShaderCode,f=t.Material.create(this.engine,{shader:{vertex:u,fragment:h,shared:i.shaderShared}});this.shadowMaterial.setMaterialStates(f);var d=t.Mesh.create(this.engine,{name:this.name+"_shadow",material:f,geometry:this.getEffectsGeometry(),priority:this.effectsPriority});void 0!==this.shadowMesh&&this.shadowMesh.dispose(),this.shadowMesh=d}},n.prototype.getFeatureList=function(t,n,o){var i=[];if(this.geometry.hasNormals()&&i.push("HAS_NORMALS 1"),this.geometry.hasTangents()&&i.push("HAS_TANGENTS 1"),this.geometry.hasUVCoords(1)&&i.push("HAS_UV_SET1 1"),this.geometry.hasUVCoords(2)&&i.push("HAS_UV_SET2 1"),void 0!==this.morph&&this.morph.hasMorph()){i.push("USE_MORPHING"),i.push("WEIGHT_COUNT ".concat(this.morph.morphWeightsLength));for(var r=0;r<this.morph.morphWeightsLength;r++)this.morph.hasPositionMorph&&i.push("HAS_TARGET_POSITION".concat(r)),this.morph.hasNormalMorph&&i.push("HAS_TARGET_NORMAL".concat(r)),this.morph.hasTangentMorph&&i.push("HAS_TARGET_TANGENT".concat(r))}void 0!==this.skin&&(i.push("USE_SKINNING 1"),i.push("JOINT_COUNT ".concat(this.skin.getJointCount())),i.push("HAS_JOINT_SET1 1"),i.push("HAS_WEIGHT_SET1 1"),this.skin.textureDataMode&&i.push("USE_SKINNING_TEXTURE 1")),this.isEnableShadow()&&(this.shadowType===e.PShadowType.standard?i.push("SHADOWMAP_STANDARD 1"):this.shadowType===e.PShadowType.variance?i.push("SHADOWMAP_VSM 1"):(i.push("SHADOWMAP_EVSM 1"),i.push("SHADOWMAP_EVSM_PCF 1")),n&&i.push("USE_SHADOW_MAPPING 1")),this.material.materialType!==e.PMaterialType.unlit&&(t>0&&this.geometry.hasNormals()&&(i.push("USE_PUNCTUAL 1"),i.push("LIGHT_COUNT ".concat(t))),void 0!==o&&o.available&&(i.push("USE_IBL 1"),i.push("USE_TEX_LOD 1"),o.hasDiffuseImage||i.push("IRRADIANCE_COEFFICIENTS 1")));var a=R.getInstance().renderMode3D,s=this.getRenderMode3DDefine(a);return void 0!==s&&(i.push("DEBUG_OUTPUT 1"),i.push("".concat(s," 1"))),i},n.prototype.addToRenderObjectSet=function(e){e.add(this.effectsMesh)},n.prototype.dispose=function(){var e,n,o,i,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===(e=this.jointMatrixTexture)||void 0===e||e.dispose(),this.jointMatrixTexture=void 0,null===(n=this.jointNormalMatTexture)||void 0===n||n.dispose(),this.jointNormalMatTexture=void 0,null===(o=this.effectsMesh)||void 0===o||o.dispose({geometries:t.DestroyOptions.keep,material:t.DestroyOptions.keep}),this.effectsMesh=void 0,null===(i=this.shadowMesh)||void 0===i||i.dispose({geometries:t.DestroyOptions.keep,material:t.DestroyOptions.keep}),this.shadowMesh=void 0,null===(r=this.shadowMaterial)||void 0===r||r.dispose(),this.shadowMaterial=void 0},n.prototype.updateUniformsForScene=function(e,t,n){this.updateUniformsByAnimation(e,t),this.updateUniformsByScene(n),this.material.updateUniforms(this.getModelMaterial())},n.prototype.updateUniformForShadow=function(e){var t=this.getShadowModelMaterial();void 0!==t&&(t.setMatrix("u_ViewProjectionMatrix",e.viewProjectionMatrix),void 0!==this.shadowMaterial&&this.shadowMaterial.updateUniforms(t))},n.prototype.hitTesting=function(t,n,o,i){var r=this.boundingBox,a=j(t,n,r.min,r.max),s=[];if(void 0!==a){if(void 0!==this.skin)this.skin.animationMatrices.forEach((function(e){s.push((new T).multiplyMatrices(i,e))}));var c=new ie,l=this.material.faceSideMode===e.PFaceSideMode.both;return c.create(this.geometry.geometry,l,s),c.getHitPoint(t,n)}},n.prototype.computeBoundingBox=function(e){if(void 0===this.skin&&!this.boundingBox.isEmpty())return this.boundingBox;var t=[];void 0!==this.skin&&this.skin.animationMatrices.forEach((function(n){t.push((new T).multiplyMatrices(e,n))}));var n=new oe;return n.create(this.geometry.geometry,t),n.getBoundingBox(this.boundingBox)},n.prototype.getRenderMode3DDefine=function(e){switch(e){case t.spec.RenderMode3D.uv:return"DEBUG_UV";case t.spec.RenderMode3D.normal:return"DEBUG_NORMAL";case t.spec.RenderMode3D.basecolor:return"DEBUG_BASECOLOR";case t.spec.RenderMode3D.alpha:return"DEBUG_ALPHA";case t.spec.RenderMode3D.metallic:return"DEBUG_METALLIC";case t.spec.RenderMode3D.roughness:return"DEBUG_ROUGHNESS";case t.spec.RenderMode3D.ao:return"DEBUG_OCCLUSION";case t.spec.RenderMode3D.emissive:return"DEBUG_EMISSIVE"}},n.prototype.updateUniformsByAnimation=function(e,t){var n=this.getModelMaterial(),o=this.getShadowModelMaterial();n.setMatrix("u_ModelMatrix",e),n.setMatrix("u_NormalMatrix",t),void 0!==o&&(o.setMatrix("u_ModelMatrix",e),o.setMatrix("u_NormalMatrix",t));var i=this.skin;if(void 0!==i){var r=this.jointMatrixList,a=this.jointNormalMatList;if(i.computeMeshAnimMatrices(e,r,a),i.textureDataMode){var s=this.jointMatrixTexture,c=this.jointNormalMatTexture;s.update(r),c.update(a),n.setTexture("u_jointMatrixSampler",s.getTexture()),n.setTexture("u_jointNormalMatrixSampler",c.getTexture())}else{var l=[],u=[];r.forEach((function(e){return l.push(e)})),a.forEach((function(e){return u.push(e)})),n.setMatrixNumberArray("u_jointMatrix",l),n.setMatrixNumberArray("u_jointNormalMatrix",u),void 0!==o&&(o.setMatrixNumberArray("u_jointMatrix",l),o.setMatrixNumberArray("u_jointNormalMatrix",u))}}var h=this.morph;if(void 0!==h&&h.hasMorph()){var f=h.morphWeightsArray,d=[];f.forEach((function(e){return d.push(e)})),n.setFloats("u_morphWeights",d),void 0!==o&&o.setFloats("u_morphWeights",d)}},n.prototype.updateUniformsByScene=function(e){var t,n=this.getModelMaterial();if(n.setMatrix("u_ViewProjectionMatrix",e.viewProjectionMatrix),n.setVector3("u_Camera",e.cameraPosition),this.isEnableShadow(),!this.isUnlitMaterial()){for(var o=e.maxLightCount,i=e.lightList,r=0;r<o;r++)if(r<i.length){var a=i[r],s=a.visible?a.intensity:0;n.setVector3("u_Lights[".concat(r,"].direction"),a.getWorldDirection()),n.setFloat("u_Lights[".concat(r,"].range"),a.range),n.setVector3("u_Lights[".concat(r,"].color"),a.color),n.setFloat("u_Lights[".concat(r,"].intensity"),s),n.setVector3("u_Lights[".concat(r,"].position"),a.getWorldPosition()),n.setFloat("u_Lights[".concat(r,"].innerConeCos"),Math.cos(a.innerConeAngle)),n.setFloat("u_Lights[".concat(r,"].outerConeCos"),Math.cos(a.outerConeAngle)),n.setInt("u_Lights[".concat(r,"].type"),a.lightType),n.setVector2("u_Lights[".concat(r,"].padding"),a.padding)}else n.setVector3("u_Lights[".concat(r,"].direction"),v.ZERO),n.setFloat("u_Lights[".concat(r,"].range"),0),n.setVector3("u_Lights[".concat(r,"].color"),v.ZERO),n.setFloat("u_Lights[".concat(r,"].intensity"),0),n.setVector3("u_Lights[".concat(r,"].position"),v.ZERO),n.setFloat("u_Lights[".concat(r,"].innerConeCos"),0),n.setFloat("u_Lights[".concat(r,"].outerConeCos"),0),n.setInt("u_Lights[".concat(r,"].type"),99999),n.setVector2("u_Lights[".concat(r,"].padding"),g.ZERO);var c=e.skybox;if(void 0!==c&&c.available){if(n.setVector2("u_IblIntensity",new g(c.currentIntensity,c.currentReflectionsIntensity)),n.setTexture("u_brdfLUT",c.brdfLUT),void 0!==c.diffuseImage)n.setTexture("u_DiffuseEnvSampler",c.diffuseImage);else{var l=c.irradianceCoeffs;["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(e,t){n.setVector3("u_shCoefficients.".concat(e),v.fromArray(l[t]))}))}n.setInt("u_MipCount",null!==(t=c.specularMipCount)&&void 0!==t?t:1),n.setTexture("u_SpecularEnvSampler",c.specularImage)}}},n.prototype.hasSkin=function(){return void 0!==this.skin},n.prototype.getEffectsGeometry=function(){return this.geometry.geometry},n.prototype.setGeometry=function(e){this.geometry=e instanceof Qe?e:new Qe(e)},n.prototype.setMaterial=function(e){this.material=e instanceof Pe||e instanceof we?e:Oe(e)},n.prototype.getModelMaterial=function(){return this.effectsMesh.material},n.prototype.getShadowModelMaterial=function(){var e;return null===(e=this.shadowMesh)||void 0===e?void 0:e.material},n.prototype.isEnableShadow=function(){return this.shadowType!==e.PShadowType.none&&this.material.materialType!==e.PMaterialType.unlit},n.prototype.isUnlitMaterial=function(){return this.material.materialType===e.PMaterialType.unlit},n.prototype.hasMorph=function(){return void 0!==this.morph&&this.morph.hasMorph()},n.prototype.getWorldBoundingBox=function(){if(void 0===this.parent)return this.boundingBox.isEmpty()&&this.computeBoundingBox(T.fromIdentity()),this.boundingBox;var e=this.parent.matrix;return this.boundingBox.isEmpty()&&this.computeBoundingBox(e.clone().invert()),this.boundingBox.clone().applyMatrix4(e)},n}(),Qe=function(){function e(e){this.geometry=e,this.attributeNames=e.getAttributeNames()}return e.prototype.dispose=function(){this.geometry=void 0,this.attributeNames=[]},e.prototype.hasAttribute=function(e){return-1!==this.attributeNames.findIndex((function(t){return t===e}))},e.prototype.setHide=function(e){var t=this.geometry;if(0===t.getDrawCount()){var n=t.getIndexData();void 0!==n&&t.setDrawCount(n.length)}e?t.getDrawCount()>=0&&t.setDrawCount(-t.getDrawCount()):t.getDrawCount()<0&&t.setDrawCount(-t.getDrawCount())},e.prototype.isCompressed=function(){this.geometry.getAttributeData("a_Position");return!1},e.prototype.hasPositions=function(){return this.hasAttribute("a_Position")},e.prototype.hasNormals=function(){return this.hasAttribute("a_Normal")},e.prototype.hasTangents=function(){return this.hasAttribute("a_Tangent")},e.prototype.hasUVCoords=function(e){return this.hasAttribute("a_UV".concat(e))},e.prototype.hasColors=function(){return this.hasAttribute("a_Color")},e.prototype.hasJoints=function(){return this.hasAttribute("a_Joint1")},e.prototype.hasWeights=function(){return this.hasAttribute("a_Weight1")},e}(),Ze=function(){function e(e,t){this.item=e,this.parentItem=t,this.options=e.content.options;var n=!0,o=new he,i=e.content.options;i.primitives.forEach((function(e,t){if(0===t)o.create(e.geometry);else{var i=new he;i.create(e.geometry)?o.equals(i)||(n=!1,console.error("Morpth target mismatch between primtives: ".concat(JSON.stringify(o),", ").concat(JSON.stringify(i)))):n=!1}})),n?(void 0!==i.weights&&o.initWeights(i.weights),this.morphObj=o):this.morphObj=new he}return e.prototype.hasMorphTarget=function(){return this.morphObj.hasMorph()},e.prototype.getMorphObj=function(){if(this.hasMorphTarget())return this.morphObj},e.prototype.getParentId=function(){return this.item.parentId},e.prototype.getName=function(){return this.item.name},e.prototype.isHide=function(){return!0===this.options.hide},e.prototype.getParentNode=function(){var e=this.getParentIndex();if(void 0!==this.parentItem&&e>=0)return this.parentItem.content.getNodeById(e)},e.prototype.getParentIndex=function(){var e;return null!==(e=this.options.parent)&&void 0!==e?e:-1},e.prototype.getPrimitives=function(){return this.options.primitives},e.prototype.getPrimitiveCount=function(){return this.options.primitives.length},e.prototype.hasSkin=function(){return void 0!==this.options.skin},e.prototype.getSkinOpts=function(){return this.options.skin},e.prototype.getSkinObj=function(e){var t=this.getSkinOpts();if(void 0!==t){var n=new ue;return n.create(t,e,this.parentItem),n}},e}(),$e=function(){function n(e){this.maxLightCount=16,this.renderSkybox=!1,this.compName="SceneManger",this.itemList=[],this.meshList=[],this.engine=e,this.lightManager=new Ge,this.cameraManager=new ke,this.shadowManager=new Je,this.parentId2Mesh=new Map,this.enableDynamicSort=!1,this.tickCount=0,this.lastTickSecond=-1,this.sceneAABBCache=new C,this.renderedMeshSet=new He,this.allRenderedMeshSet=new Set}return n.prototype.initial=function(e){this.clean(),this.compName=e.componentName,this.renderer=e.renderer,this.engine=e.renderer.engine,this.sceneCache=e.sceneCache,this.enableDynamicSort=!0===e.enableDynamicSort,this.renderSkybox=e.renderSkybox,this.maxLightCount=e.lightItemCount,this.cameraManager.initial(this.renderer.getWidth(),this.renderer.getHeight()),this.brdfLUT=this.sceneCache.getBrdfLutTexture(),this.initGlobalState(e),this.maxLightCount>8&&console.warn("Too many light items: ".concat(this.maxLightCount," light(s)"))},n.prototype.initGlobalState=function(e){var n,o,i,r,a,s=this.engine.gpuCapability,c=R.getInstance();c.reset(),c.isWebGL2=2===s.level,c.runtimeEnv=null!==(n=e.runtimeEnv)&&void 0!==n?n:t.PLAYER_OPTIONS_ENV_EDITOR,c.compatibleMode=null!==(o=e.compatibleMode)&&void 0!==o?o:"gltf",c.visBoundingBox=null!==(i=e.visBoundingBox)&&void 0!==i&&i,c.renderMode3D=null!==(r=e.renderMode3D)&&void 0!==r?r:t.spec.RenderMode3D.none,c.renderMode3DUVGridSize=null!==(a=e.renderMode3DUVGridSize)&&void 0!==a?a:1/16},n.prototype.clean=function(){this.dispose(),this.compName="",this.renderer=void 0,this.sceneCache=void 0,this.itemList=[],this.meshList=[],this.lightManager=new Ge,this.cameraManager=new ke,this.shadowManager=new Je,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},n.prototype.dispose=function(){var e;this.itemList.forEach((function(e){return e.dispose()})),this.itemList=[],this.meshList.forEach((function(e){return e.dispose()})),this.meshList=[],this.lightManager.dispose(),this.cameraManager.dispose(),this.brdfLUT=void 0,null===(e=this.skybox)||void 0===e||e.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()},n.prototype.addItem=function(e){var n=e.content;if(n instanceof qe){var o=n;void 0!==o.parentItemId&&this.parentId2Mesh.set(o.parentItemId,o),t.addItem(this.meshList,o),this.buildItem(n)}else if(n instanceof Ne){var i=n;i.setup(this.brdfLUT),this.renderSkybox||(i.renderable=!1),this.skybox=i,this.buildItem(n)}else n instanceof Ve?this.lightManager.insertLight(n):this.cameraManager.insertCamera(n);t.addItem(this.itemList,n)},n.prototype.removeItem=function(e){var n=e.content;if(n instanceof qe){var o=n;void 0!==o.parentItemId&&this.parentId2Mesh.delete(o.parentItemId),t.removeItem(this.meshList,o)}else n instanceof Ne?this.skybox=void 0:n instanceof Ve?this.lightManager.remove(n):this.cameraManager.remove(n);t.removeItem(this.itemList,n)},n.prototype.updateDefaultCamera=function(e){var n=new t.Transform(r(r({},e),{valid:!0})),o=(new N).fromEffectsTransform(n);this.cameraManager.updateDefaultCamera(e.fov,e.near,e.far,o.getPosition(),o.getRotation(),e.aspect,e.clipMode)},n.prototype.buildItem=function(e){e instanceof qe?e.build(this.maxLightCount,{},this.skybox):e instanceof Ne&&e.build(this.getSceneCache())},n.prototype.build=function(){var e=this;this.meshList.forEach((function(t){t.build(e.maxLightCount,{},e.skybox)})),void 0!==this.skybox&&this.skybox.build(this.getSceneCache())},n.prototype.tick=function(e){var t=this,n=e,o=this.activeCamera,i=o.viewMatrix,r=o.projectionMatrix,a=r.clone().multiply(i),s={deltaSeconds:n,camera:o,cameraPosition:o.getEye(),viewMatrix:i,projectionMatrix:r,viewProjectionMatrix:a,winSize:o.getSize(),sceneRadius:1,lightList:this.lightManager.lightList,maxLightCount:this.maxLightCount,skybox:this.skybox};this.build(),this.lightManager.tick(n),this.renderedMeshSet.forward(),this.itemList.forEach((function(e){e.tick(n),e.updateUniformsForScene(s),e.addToRenderObjectSet(t.renderedMeshSet.now)})),this.enableDynamicSort&&this.dynamicSortMeshes(s),this.tickCount+=1,this.lastTickSecond+=n},n.prototype.updateDefaultRenderPass=function(e){var t=this;this.enableDynamicSort?(this.renderedMeshSet.last.forEach((function(t){e.removeMeshFromDefaultRenderPass(t)})),this.renderedMeshSet.now.forEach((function(n){e.addMeshToDefaultRenderPass(n),t.allRenderedMeshSet.add(n)}))):(this.renderedMeshSet.forRemovedItem((function(t){e.removeMeshFromDefaultRenderPass(t)})),this.renderedMeshSet.forAddedItem((function(n){e.addMeshToDefaultRenderPass(n),t.allRenderedMeshSet.add(n)})))},n.prototype.dynamicSortMeshes=function(e){var t=[],n=[];this.renderedMeshSet.now.forEach((function(e){t.push(e),n.push(e.priority)})),n.sort((function(e,t){return e-t}));var o=e.viewMatrix;t.sort((function(e,t){var n=Q.isTransparentMesh(e),i=Q.isTransparentMesh(t);if(n&&i){var r=v.fromArray(e.worldMatrix.elements,12),a=v.fromArray(t.worldMatrix.elements,12),s=o.transformPoint(r),c=o.transformPoint(a);return s.z-c.z}return n?1:i?-1:0}));for(var i=0;i<t.length;i++){var r=t[i],a=n[i];r.priority=a}},n.prototype.queryMesh=function(e){var t=this.parentId2Mesh.get(e);if(void 0!==t&&t.visible)return t},n.prototype.removeAllMeshesFromDefaultPass=function(e){this.renderedMeshSet.now.forEach((function(t){e.removeMeshFromDefaultRenderPass(t)}))},n.prototype.getSceneAABB=function(t){var n=null!=t?t:new C;return this.itemList.forEach((function(t){if(t.type===e.PObjectType.mesh){var o=t;if(o.ownerItem){var i=o.ownerItem.getWorldTransform().getWorldMatrix(),r=o.computeBoundingBox(i);r.applyMatrix4(i),n.union(r)}else n.union(o.computeBoundingBox(T.fromIdentity()))}})),n},n.prototype.printDebugInfo=function(){console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),this.meshList.forEach((function(e,t){console.info("Mesh: ",t,e)})),this.cameraManager.getCameraList().forEach((function(e,t){console.info("Camera: ",t,e)})),console.info("Default Camera: ",this.cameraManager.getDefaultCamera()),this.lightManager.lightList.forEach((function(e,t){console.info("Light: ",t,e)})),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")},n.prototype.getRenderer=function(){return this.renderer},n.prototype.getSceneCache=function(){return this.sceneCache},Object.defineProperty(n.prototype,"activeCamera",{get:function(){return this.cameraManager.getActiveCamera()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lightCount",{get:function(){return this.lightManager.lightCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shaderLightCount",{get:function(){return Math.min(10,this.lightManager.lightCount)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enableShadowPass",{get:function(){return this.shadowManager.isEnable()},enumerable:!1,configurable:!0}),n}(),et="_Native",tt=new Map;function nt(e,t){for(var n,o="".concat(e),i=[],r=0;r<t.length;r++)"number"==typeof t[r]&&tt.has(t[r])?i.push(tt.get(t[r])+"(".concat(t[r],")")):i.push(null===(n=t[r])||void 0===n?void 0:n.toString());return o+(i.length>0?"("+i.join(", ")+")":"()")}function ot(e,t){return function(){var n=e[t+et].apply(this,arguments),o=e.getError();return o>0?(console.info("OpenGLError: "+function(e){var t,n=new Map;return n.set(WebGLRenderingContext.NO_ERROR,"NO_ERROR"),n.set(WebGLRenderingContext.INVALID_ENUM,"INVALID_ENUM"),n.set(WebGLRenderingContext.INVALID_VALUE,"INVALID_VALUE"),n.set(WebGLRenderingContext.INVALID_OPERATION,"INVALID_OPERATION"),n.set(WebGLRenderingContext.INVALID_FRAMEBUFFER_OPERATION,"INVALID_FRAMEBUFFER_OPERATION"),n.set(WebGLRenderingContext.OUT_OF_MEMORY,"OUT_OF_MEMORY"),n.set(WebGLRenderingContext.CONTEXT_LOST_WEBGL,"CONTEXT_LOST_WEBGL"),(null!==(t=n.get(e))&&void 0!==t?t:"UNKNOWN_ERROR")+"(".concat(e,")")}(o)+" ===> "+nt(t,arguments)),console.trace()):console.info(nt(t,arguments)),n}}var it,rt=function(){function e(e,t){this.baseTransform=t.transform,this.animationManager=new ge(e,t),this.build(e)}return e.prototype.tick=function(e){this.animationManager.tick(e)},e.prototype.getNodes=function(){return this.nodes},e.prototype.getNodeById=function(e){var t=this.cacheMap;if(!t[e]){var n="^".concat(e);t[e]=this.allNodes.find((function(e){return e.id===n}))}return t[e]},e.prototype.getNodeByName=function(e){var t=this.cacheMap;return t[e]||(t[e]=this.allNodes.find((function(t){return t.name===e}))),t[e]},e.prototype.getNodeTransform=function(e){var t=this.getNodeById(e);return t?t.transform:this.baseTransform},e.prototype.dispose=function(){var e;this.allNodes=[],this.nodes=[],this.cacheMap={},this.baseTransform=null,null===(e=this.animationManager)||void 0===e||e.dispose(),this.animationManager=null},e.prototype.build=function(e){var n=this,o=this.baseTransform,i=e.nodes.map((function(e,i){return{name:e.name||e.id||i+"",transform:new t.Transform(r(r({},e.transform),{valid:!0}),o),id:"^".concat(e.id||i),children:[],tree:n}}));this.cacheMap={},i.forEach((function(t,n){var r=e.nodes[n].children;t.transform.name=t.name,t.transform.setValid(!0),r&&r.forEach((function(e){var n=i[e];n&&n!==t&&(n.transform.parentTransform!==o&&console.error("Node parent has been set."),n.transform.parentTransform=t.transform,t.children.push(n))}))})),this.allNodes=i,this.nodes=e.children.map((function(e){return i[e]}))},e}(),at=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return i(n,e),Object.defineProperty(n.prototype,"type",{get:function(){return t.spec.ItemType.tree},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(e){this.options=e.content.options.tree,this.timeline=new t.TimelineComponent(e.content,this),this.timeline.getRenderData(0,!0)},n.prototype.onLifetimeBegin=function(){this.content.baseTransform.setValid(!0)},n.prototype.onItemRemoved=function(e,t){void 0!==this.content&&this.content.dispose()},n.prototype.onItemUpdate=function(e,t){var n,o=.001*(this.timeInms-this.delayInms);null===(n=this.timeline)||void 0===n||n.getRenderData(o,!0),this.content.tick(e)},n.prototype.doCreateContent=function(){return new rt(this.options,this)},n.prototype.getNodeTransform=function(e){if(void 0===this.content)return this.transform;var t=this.id+"^";if(0===e.indexOf(t)){var n=e.substring(t.length);return this.content.getNodeTransform(n)}return this.transform},n}(t.VFXItem),st=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return i(o,e),Object.defineProperty(o.prototype,"type",{get:function(){return n},set:function(e){},enumerable:!1,configurable:!0}),o.prototype.onConstructed=function(e){var n;this.options=e,this.duration=e.duration,this.delay=null!==(n=e.delay)&&void 0!==n?n:0;var o=e.content.interaction;this.bounding=o&&JSON.parse(JSON.stringify(o)),(t.Item.is(e,t.spec.ItemType.camera)||t.Item.is(e,t.spec.ItemType.light))&&(this.timeline=new t.TimelineComponent(e.content,this),this.timeline.getRenderData(0,!0)),t.Item.is(e,t.spec.ItemType.skybox)&&this.overwriteSkyboxFromCache(e.content.options)},o.prototype.handleVisibleChanged=function(e){void 0!==this.content&&this.content.onVisibleChanged(e)},o.prototype.doCreateContent=function(e){var t,n;switch(null===(t=this.options)||void 0===t?void 0:t.type){case"mesh":var o=this.options.content.options;re.assertModelMeshOptions(o);var i=null===(n=this.composition)||void 0===n?void 0:n.getEngine();return new qe(i,this.options,this);case"camera":var r=this.options.content.options;re.assertModelCameraOptions(r);var a=e.width,s=e.height;return new De(this.options,a,s,this);case"light":var c=this.options.content.options;return re.assertModelLightOptions(c),new Ve(this.options,this);case"skybox":var l=this.options.content.options;return re.assertModelSkyboxOptions(l),new Ne(this.options,this);default:throw new Error("Invalid model item type, options: ".concat(this.options))}},o.prototype.overwriteSkyboxFromCache=function(e){var t,n=(null===(t=this.composition)||void 0===t?void 0:t.loaderData.cache).getSkyboxOptions();void 0!==n&&(void 0===e.specularImage||void 0===e.diffuseImage&&void 0===e.irradianceCoeffs)&&(e.diffuseImage=n.diffuseImage,e.irradianceCoeffs=n.irradianceCoeffs,e.specularImage=n.specularImage,e.specularImageSize=n.specularImageSize,e.specularMipCount=n.specularMipCount)},o.prototype.computeBoundingBox=function(){var e;if(void 0!==this._content&&this._content instanceof qe){var n=this.transform.getWorldMatrix(),o=this._content.computeBoundingBox(n),i=o.getCenter(new v),r=o.getSize(new v);return this.bounding={behavior:null===(e=this.bounding)||void 0===e?void 0:e.behavior,type:t.spec.ModelBoundingType.box,center:[i.x,i.y,i.z],size:[r.x,r.y,r.z]},this.bounding}},o.prototype.updateTransform=function(){var e=this._content;if(void 0!==e){var t=this.transform.getWorldMatrix();e.matrix=t,e instanceof De&&this.composition&&(this.composition.camera.position=this.transform.position.clone(),this.composition.camera.setQuat(this.transform.quat),this.composition.camera.near=e.nearPlane,this.composition.camera.far=e.farPlane,this.composition.camera.fov=e.fovy)}},o.prototype.setTransform=function(e,t){var n,o;void 0!==e&&(this.transform.setPosition(e.x,e.y,e.z),null===(n=this.timeline)||void 0===n||n.updatePosition(e.x,e.y,e.z)),void 0!==t&&(this.transform.setRotation(t.x,t.y,t.z),null===(o=this.timeline)||void 0===o||o.updateRotation(t.x,t.y,t.z)),this.updateTransform()},o.prototype.onLifetimeBegin=function(e,t){void 0!==this.content&&(this.content instanceof qe&&this.parent instanceof at&&this.content.updateParentItem(this.parent),this.content.onVisibleChanged(!0))},o.prototype.onItemUpdate=function(e,t){var n,o=.001*(this.timeInms-this.delayInms);null===(n=this.timeline)||void 0===n||n.getRenderData(o,!0),this.updateTransform()},o.prototype.onItemRemoved=function(e,t){void 0!==this.content&&(this.content.onEntityRemoved(),this.content.dispose())},o.prototype.onEnd=function(){this.endBehavior===t.spec.END_BEHAVIOR_DESTROY&&this.content&&this.content.onVisibleChanged(!1)},o.prototype.getHitTestParams=function(e){this.computeBoundingBox();var n=this.bounding;if(n&&(e||Number.isInteger(n.behavior))){var o=n.type;if(o===t.spec.ModelBoundingType.box){if(this.content instanceof qe){var i=this.content;return{behavior:n.behavior,type:t.HitTestType.custom,collect:function(e,t){return i.hitTesting(e.origin,e.direction)}}}var r=this.transform.getWorldMatrix();return{behavior:n.behavior,type:t.HitTestType.custom,collect:function(e,t){return G(e,r,n)}}}if(o===t.spec.ModelBoundingType.sphere){var a=new v;this.transform.assignWorldTRS(a);var s=new v;return n.center&&s.setFromArray(n.center),s.add(a),{type:o,behavior:n.behavior,radius:n.radius||0,center:s}}}},o}(t.VFXItem),ct=function(o){function r(){var e=null!==o&&o.apply(this,arguments)||this;return e.name="model",e.deltaTime=0,e.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,e.compatibleMode="gltf",e.renderSkybox=!0,e.visBoundingBox=!1,e.autoAdjustScene=!1,e.enableDynamicSort=!1,e.renderMode3D=t.spec.RenderMode3D.none,e.renderMode3DUVGridSize=1/16,e}return i(r,o),r.prepareResource=function(e,t){var n,o,i;return a(this,void 0,void 0,(function(){var r,a,c,l,u;return s(this,(function(s){switch(s.label){case 0:return r=null!==(n=t.env)&&void 0!==n?n:"",a="gltf",c=!1,void 0!==t.pluginData&&(l=["compatibleMode","renderSkybox","visBoundingBox","autoAdjustScene","enableDynamicSort","renderMode3D","renderMode3DUVGridSize"],u=t.pluginData,l.forEach((function(t){return e.storage[t]=u[t]})),e.storage.runtimeEnv=r,a=null!==(o=t.pluginData.compatibleMode)&&void 0!==o?o:a,c=null!==(i=t.pluginData.autoAdjustScene)&&void 0!==i?i:c),$.preprocessEffectsScene(e,r,a,c),[4,Be.loadStaticResources()];case 1:return s.sent(),[2]}}))}))},r.prototype.onCompositionConstructed=function(e,t){var n,o,i,r,a,s,c,l;this.runtimeEnv=null!==(n=t.storage.runtimeEnv)&&void 0!==n?n:this.runtimeEnv,this.compatibleMode=null!==(o=t.storage.compatibleMode)&&void 0!==o?o:this.compatibleMode,this.renderSkybox=null!==(i=t.storage.renderSkybox)&&void 0!==i?i:this.renderSkybox,this.visBoundingBox=null!==(r=t.storage.visBoundingBox)&&void 0!==r?r:this.visBoundingBox,this.autoAdjustScene=null!==(a=t.storage.autoAdjustScene)&&void 0!==a?a:this.autoAdjustScene,this.enableDynamicSort=null!==(s=t.storage.enableDynamicSort)&&void 0!==s?s:this.enableDynamicSort,this.renderMode3D=null!==(c=t.storage.renderMode3D)&&void 0!==c?c:this.renderMode3D,this.renderMode3DUVGridSize=null!==(l=t.storage.renderMode3DUVGridSize)&&void 0!==l?l:this.renderMode3DUVGridSize;var u=e.renderer.engine;e.loaderData.sceneManager=new $e(u);var h=new Be(u);h.setup(!1),e.loaderData.cache=h,$.setupItem3DOptions(t,h,e)},r.prototype.onCompositionWillReset=function(e,t){this.getCache(e).getRenderPasses().forEach((function(e){t.removeRenderPass(e)})),this.getSceneManager(e).removeAllMeshesFromDefaultPass(t)},r.prototype.onCompositionReset=function(e,t){var n=this.getSceneManager(e),o=this.getCache(e),i=this.getLightItemCount(e);n.initial({componentName:"".concat(e.id),renderer:e.renderer,sceneCache:o,runtimeEnv:this.runtimeEnv,compatibleMode:this.compatibleMode,visBoundingBox:this.visBoundingBox,enableDynamicSort:this.enableDynamicSort,renderMode3D:this.renderMode3D,renderMode3DUVGridSize:this.renderMode3DUVGridSize,renderSkybox:this.renderSkybox,lightItemCount:i}),this.updateSceneCamera(e,n)},r.prototype.onCompositionDestroyed=function(e){this.disposeSceneManager(e),this.disposeCache(e)},r.prototype.onCompositionUpdate=function(e,t){this.deltaTime=t},r.prototype.onCompositionItemLifeBegin=function(e,t){t.type===n&&this.getSceneManager(e).addItem(t)},r.prototype.onCompositionItemRemoved=function(e,t){t.type===n&&this.getSceneManager(e).removeItem(t)},r.prototype.prepareRenderFrame=function(e,t){var o,i,r,a=this.getSceneManager(e);if(this.autoAdjustScene&&1==a.tickCount){var s=e.camera,c=(new N).fromMatrix4(s.getViewMatrix()),l=(new F).fromPTransform(c).zAxis.clone(),u=null!==(o=s.fov)&&void 0!==o?o:45,h=null!==(i=s.aspect)&&void 0!==i?i:1,f=a.getSceneAABB(),d=f.clone().applyMatrix4(c.getMatrix()).getSize(new v).multiply(.5),p=d.x,m=d.y,g=m*Math.max(p/m/h,1),y=f.getCenter(new v),b=g/Math.tan(.5*u*L),T=y.clone().add(l.clone().multiply(b+d.z));e.camera.position=T,null===(r=e.items)||void 0===r||r.forEach((function(e){if(e.type===n){var t=e;if(t.content instanceof De){var o=t.transform.parentTransform.getWorldMatrix().invert().transformPoint(T);t.setTransform(o),console.info("Scene AABB [".concat(f.min.toArray(),"], [").concat(f.max.toArray(),"]")),console.info("Update camera position [".concat(o.toArray(),"]"))}}}))}return this.updateSceneCamera(e,a),a.tick(this.deltaTime),a.updateDefaultRenderPass(t),!0},r.prototype.postProcessFrame=function(e,t){this.getSceneManager(e).shadowManager.updateRenderPass(t)},r.prototype.getLightItemCount=function(t){var n=0;return t.items.forEach((function(t){var o,i;t instanceof st&&((null===(o=t.content)||void 0===o?void 0:o.type)!==e.PObjectType.light&&"light"!==(null===(i=t.options)||void 0===i?void 0:i.type)||n++)})),n},r.prototype.updateSceneCamera=function(e,t){t.updateDefaultCamera(e.camera.getOptions())},r.prototype.getSceneManager=function(e){return e.loaderData.sceneManager},r.prototype.getCache=function(e){return e.loaderData.cache},r.prototype.disposeCache=function(e){var t=e.loaderData;t.cache.dispose(),delete t.cache},r.prototype.disposeSceneManager=function(e){var t=e.loaderData;t.sceneManager.dispose(),delete t.sceneManager},r}(t.AbstractPlugin),lt=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="tree",t.order=2,t}return i(n,e),n.prototype.onCompositionConstructed=function(e,t){var n=e.getEngine(),o=new ve(n);e.loaderData.animSystem=o},n.prototype.onCompositionWillReset=function(e,t){var n=this.getAnimationSystem(e);void 0!==n&&n.dispose()},n.prototype.onCompositionDestroyed=function(e){var t=this.getAnimationSystem(e);void 0!==t&&t.dispose(),delete e.loaderData.animSystem},n.prototype.onCompositionItemLifeBegin=function(e,n){if(n.type===t.spec.ItemType.tree){var o=this.getAnimationSystem(e),i=n.content;null==o||o.insert(i.animationManager)}},n.prototype.onCompositionItemRemoved=function(e,n){if(n.type===t.spec.ItemType.tree){var o=this.getAnimationSystem(e),i=n.content;null==o||o.delete(i.animationManager)}},n.prototype.getAnimationSystem=function(e){var t=e.loaderData.animSystem;if(void 0!==t)return t},n}(t.AbstractPlugin);e.CameraGestureType=void 0,(it=e.CameraGestureType||(e.CameraGestureType={}))[it.none=0]="none",it[it.translate=1]="translate",it[it.rotate_focus=2]="rotate_focus",it[it.rotate_self=3]="rotate_self",it[it.scale=4]="scale";var ut,ht=function(){function n(t){this.composition=t,this.cameraTransform=new N,this.cameraCoordiante=new F,this.startParams={type:e.CameraGestureType.none,mouseEvent:!1,clientX:0,clientY:0,clientWidth:512,clientHeight:512,target:""}}return n.prototype.getItem=function(){var e,t=this;return null===(e=this.composition.items)||void 0===e?void 0:e.find((function(e){return e.id===t.getCurrentTarget()}))},n.prototype.getCurrentTarget=function(){return this.startParams.target},n.prototype.getCurrentType=function(){return this.startParams.type},n.prototype.onKeyEvent=function(n){var o,i,a,s;this.startParams.target!==n.cameraID&&(this.startParams.target=n.cameraID,this.startParams.type=e.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 l=this.composition.camera,u=new t.Transform(r(r({},l.getOptions()),{valid:!0})),h=(new N).fromEffectsTransform(u),f=(new F).fromPTransform(h),d=null!==(o=n.xAxis)&&void 0!==o?o:0,p=null!==(i=n.yAxis)&&void 0!==i?i:0,m=null!==(a=n.zAxis)&&void 0!==a?a:0,g=f.xAxis.clone().multiply(d);if(g.add(f.yAxis.clone().multiply(p)),g.add(f.zAxis.clone().multiply(m)),g.lengthSquared()<1e-5)return l.getOptions();g.normalize();var v=null!==(s=n.speed)&&void 0!==s?s:.1,y=h.getPosition();return y.add(g.clone().multiply(v)),c.transform.setPosition(y.x,y.y,y.z),c.updateTransform(),this.startParams.type===e.CameraGestureType.rotate_self&&(this.cameraTransform.setPosition(y),this.cameraCoordiante.origin=y),l.getOptions()},n.prototype.onXYMoveBegin=function(t,n,o,i,r){var a={type:e.CameraGestureType.translate,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,target:r};return this.startGesture(a)},n.prototype.onXYMoving=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.translate,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=o?o:.015};return this.moveGesture(r)},n.prototype.onXYMoveEnd=function(){this.endGesture()},n.prototype.onZMoveBegin=function(t,n,o,i,r){var a={type:e.CameraGestureType.scale,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,target:r};return this.startGesture(a)},n.prototype.onZMoving=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.scale,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=o?o:.015};return this.moveGesture(r)},n.prototype.onZMoveEnd=function(){this.endGesture()},n.prototype.onRotateBegin=function(t,n,o,i,r){var a={type:e.CameraGestureType.rotate_self,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,target:r};return this.startGesture(a)},n.prototype.onRotating=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.rotate_self,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=o?o:1.5};return this.moveGesture(r)},n.prototype.onRotateEnd=function(){this.endGesture()},n.prototype.onRotatePointBegin=function(t,n,o,i,r,a){var s={type:e.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,focusPoint:r,target:a};return this.startGesture(s)},n.prototype.onRotatingPoint=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,focusPoint:i.focusPoint,target:i.target,speed:null!=o?o:8};return this.moveGesture(r)},n.prototype.onRotatePointEnd=function(){this.endGesture()},n.prototype.moveTo=function(t,n){var o;this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var i=this.getItem();void 0!==i?((o=i.transform).setPosition.apply(o,l([],c(n),!1)),i.updateTransform()):console.warn("can't find camera item")},n.prototype.rotateTo=function(t,n){var o;this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var i=this.getItem();void 0!==i?((o=i.transform).setQuaternion.apply(o,l([],c(n),!1)),i.updateTransform()):console.warn("can't find camera item")},n.prototype.onFocusPoint=function(t,n,o){this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var i=this.getItem();if(void 0!==i){var r=null!=o?o:5,a=v.fromArray(n),s=(new N).fromEffectsTransform(i.transform),c=(new F).fromPTransform(s),l=v.fromArray(c.zAxis.toArray()).multiply(1).clone().multiply(r),u=a.clone().add(l);i.transform.setPosition(u.x,u.y,u.z),i.updateTransform(),this.startParams.target=""}else console.warn("can't find camera item")},n.prototype.getCameraTransform=function(){var e=this.composition.camera,n=new t.Transform(e.getOptions());return n.setValid(!0),n},n.prototype.initKeyEvent=function(t,n){this.startParams.target=t,this.startParams.speed=n,this.startParams.type=e.CameraGestureType.translate,this.updateCameraTransform(this.composition.camera.getOptions())},n.prototype.startGesture=function(e){return this.startParams=e,this.updateCameraTransform(this.composition.camera.getOptions()),this.getItem()||console.warn("invalid target"),this.composition.camera.getOptions()},n.prototype.moveGesture=function(t){var n;if(this.getCurrentType()===t.type){var o=this.getItem();if(void 0===o)return console.warn("can't find camera item"),this.composition.camera.getOptions();var i=null!==(n=t.speed)&&void 0!==n?n:1.015,r=this.cameraCoordiante.xAxis,a=this.cameraCoordiante.yAxis,s=this.cameraCoordiante.zAxis,c=t.clientX-this.startParams.clientX,l=t.clientY-this.startParams.clientY;if(t.type===e.CameraGestureType.translate)(u=this.cameraTransform.getPosition().clone()).add(r.clone().multiply(-c*i)),u.add(a.clone().multiply(l*i)),o.transform.setPosition(u.x,u.y,u.z),o.setTransform(o.transform.position,o.transform.rotation);else if(t.type===e.CameraGestureType.scale){var u;(u=this.cameraTransform.getPosition().clone()).add(s.clone().multiply(l*i)),o.transform.setPosition(u.x,u.y,u.z),o.setTransform(o.transform.position,o.transform.rotation)}else if(t.type===e.CameraGestureType.rotate_self){var h=c/t.clientWidth,f=l/t.clientHeight,d=h*Math.PI*i*.5,p=f*Math.PI*i*.5,m=S.fromAxisAngle(v.Y,-d),g=S.fromAxisAngle(r,-p);m.multiply(g),m.multiply(this.cameraTransform.getRotation()),o.transform.setQuaternion(m.x,m.y,m.z,m.w),o.setTransform(o.transform.position,o.transform.rotation)}else if(t.type===e.CameraGestureType.rotate_focus){h=c/t.clientWidth,f=l/t.clientHeight,d=h*Math.PI*i,p=f*Math.PI*i,m=S.fromAxisAngle(v.Y,-d),g=S.fromAxisAngle(r,-p);m.multiply(g);var y=m.toMatrix4(new T),b=v.fromArray(t.focusPoint),_=this.cameraCoordiante.origin.clone().subtract(b);y.transformPoint(_);var x=_.add(b);m.multiply(this.cameraTransform.getRotation()),o.transform.setPosition(x.x,x.y,x.z),o.transform.setQuaternion(m.x,m.y,m.z,m.w),o.setTransform(x,o.transform.rotation)}else console.warn("not implement")}else console.warn("invalid move type");return this.composition.camera.getOptions()},n.prototype.endGesture=function(){this.startParams.type=e.CameraGestureType.none,this.startParams.mouseEvent=!1,this.startParams.target=""},n.prototype.updateCameraTransform=function(e){var n=new t.Transform(e);n.setValid(!0),this.cameraTransform.fromEffectsTransform(n),this.cameraCoordiante.fromPTransform(this.cameraTransform)},n}(),ft=function(){function e(){}return e.getTransformFromMat4=function(e){var t=e.getTransform(),n=t.rotation.toEuler(new _);return{position:t.translation.toArray(),rotation:n.toArray(),scale:t.scale.toArray()}},e.getEffectsTransformFromMat4=function(e){var n=new t.Transform({valid:!0});return n.cloneFromMatrix(e),{position:n.position.toArray(),rotation:n.rotation.toArray(),scale:n.scale.toArray()}},e.getTransformFromTranslation=function(e){return{position:e.toArray()}},e.getTransformFromDirection=function(t){var n=v.fromArray([1,0,0]),o=t.clone().normalize(),i=n.clone().cross(o);if(i.length()<.01)return{};i.normalize();var r=o.dot(n),a=Math.acos(r),s=T.fromRotationAxis(i,a);return e.getTransformFromMat4(s)},e.getEffectsTransformFromDirection=function(t){var n=v.fromArray([0,0,1]),o=t.clone().normalize(),i=n.clone().cross(o);if(i.length()<.01)return{};i.normalize();var r=o.dot(n),a=Math.acos(r),s=T.fromRotationAxis(i,a);return e.getEffectsTransformFromMat4(s)},e.getTransformFromTransDir=function(t,n){var o=e.getTransformFromDirection(n);return o.position=t.toArray(),o},e.getEffectsTransformFromTransDir=function(t,n){var o=e.getEffectsTransformFromDirection(n);return o.position=t.toArray(),o},e.getEulerFromQuat=function(e){var t=new _,n=new S(e.x,e.y,e.z,e.w);return t.order=x.ZYX,t.setFromQuaternion(n),[t.x,t.y,t.z]},e.getQuatFromEuler=function(e){var t=new S;return t.setFromEuler(e),[t.x,t.y,t.z,t.w]},e.toPlayerColor3=function(t){return[e.scaleTo255(t[0]),e.scaleTo255(t[1]),e.scaleTo255(t[2])]},e.toPlayerColor4=function(t){return[e.scaleTo255(t[0]),e.scaleTo255(t[1]),e.scaleTo255(t[2]),e.scaleTo255(t[3])]},e.scaleTo255=function(e){var t=255*e;return Math.max(0,Math.min(t,255))},e.scaleTo1=function(e){var t=e/255;return Math.max(0,Math.min(t,1))},e}();var dt=function(){function n(){}return n.prototype.initial=function(e,t){this.engine=e,this._loaderOptions=null!=t?t:{}},n.prototype.processLight=function(e,t){var n=this;e.forEach((function(e){void 0===e.color?e.color=t?[255,255,255,255]:[1,1,1,1]:(e.color[0]=n.scaleColorVal(e.color[0],t),e.color[1]=n.scaleColorVal(e.color[1],t),e.color[2]=n.scaleColorVal(e.color[2],t),e.color[3]=n.scaleColorVal(e.color[3],t))}))},n.prototype.processCamera=function(e,t){var n=t?180/Math.PI:Math.PI/180;e.forEach((function(e){void 0!==e.perspective&&(e.perspective.yfov*=n)}))},n.prototype.processMaterial=function(e,t){var n=this;e.forEach((function(e){void 0===e.baseColorFactor?e.baseColorFactor=t?[255,255,255,255]:[1,1,1,1]:(e.baseColorFactor[0]=n.scaleColorVal(e.baseColorFactor[0],t),e.baseColorFactor[1]=n.scaleColorVal(e.baseColorFactor[1],t),e.baseColorFactor[2]=n.scaleColorVal(e.baseColorFactor[2],t),e.baseColorFactor[3]=n.scaleColorVal(e.baseColorFactor[3],t)),void 0===e.emissiveFactor?e.emissiveFactor=t?[255,255,255,255]:[1,1,1,1]:(e.emissiveFactor[0]=n.scaleColorVal(e.emissiveFactor[0],t),e.emissiveFactor[1]=n.scaleColorVal(e.emissiveFactor[1],t),e.emissiveFactor[2]=n.scaleColorVal(e.emissiveFactor[2],t),e.emissiveFactor[3]=n.scaleColorVal(e.emissiveFactor[3],t)),t&&void 0!==e.occlusionTexture&&void 0===e.occlusionTexture.strength&&(e.occlusionTexture.strength=n.isTiny3dMode()?0:1)}))},n.prototype.createTreeOptions=function(e){return{nodes:e.nodes.map((function(e,t){var n,o,i,r=e.children.map((function(e){if(void 0===e.nodeIndex)throw new Error("Undefined nodeIndex for child ".concat(e));return e.nodeIndex}));if(void 0!==e.matrix){if(16!==e.matrix.length)throw new Error("Invalid matrix length ".concat(e.matrix.length," for node ").concat(e));var a=T.fromArray(e.matrix).getTransform();n=a.translation.toArray(),o=a.rotation.toArray(),i=a.scale.toArray()}else void 0!==e.translation&&(n=e.translation),void 0!==e.rotation&&(o=e.rotation),void 0!==e.scale&&(i=e.scale);return e.nodeIndex=t,{name:e.name,transform:{position:n,quat:o,scale:i},children:r,id:"".concat(e.nodeIndex)}})),children:e.rootNodes.map((function(e){if(void 0===e.nodeIndex)throw new Error("Undefined nodeIndex for root ".concat(e));return e.nodeIndex})),animation:-1,animations:[]}},n.prototype.createAnimations=function(e){return e.map((function(e){var t=e.channels.map((function(e){return{input:e.input.array,output:e.output.array,node:e.target.node,path:e.target.path,interpolation:e.interpolation}}));return{name:e.name,tracks:t}}))},n.prototype.createGeometry=function(e,t){return new mt(this.engine,e,t).geometry},n.prototype.createMaterial=function(e){return new gt(e,[],this.isTiny3dMode()).material},n.prototype.createTexture2D=function(e,t,n){return Q.createTexture2D(this.engine,e,t,n,this.isTiny3dMode())},n.prototype.createTextureCube=function(e,t){var n=this;if(0==e.length)throw new Error("createTextureCube: Invalid cubeImages length ".concat(e));var o=[];return e.forEach((function(e){var t;if(6!=e.length)throw new Error("createTextureCube: cubeimage count should always be 6, ".concat(e));var i=[];e.forEach((function(e){if(void 0===e.imageData)throw new Error("createTextureCube: Invalid image data from ".concat(e));i.push({type:"buffer",data:e.imageData,mimeType:e.mimeType})})),n.isTiny3dMode()&&(t=c([i[5],i[4]],2),i[4]=t[0],i[5]=t[1]),o.push(i)})),1==o.length?Q.createTextureCubeFromBuffer(this.engine,o[0]):Q.createTextureCubeMipmapFromBuffer(this.engine,o,null!=t?t:Math.pow(2,o.length-1))},n.prototype.createSkybox=function(e){var t,n,o=this,i=null!==(t=e.reflectionsIntensity)&&void 0!==t?t:e.intensity,r=e.irradianceCoefficients,a=e.specularImages.map((function(e){var t,n=e.map((function(e){return{type:"buffer",data:e.imageData,mimeType:e.mimeType}}));return o.isTiny3dMode()&&(t=c([n[5],n[4]],2),n[4]=t[0],n[5]=t[1]),n})),s=a.length-1,l=null!==(n=e.specularImageSize)&&void 0!==n?n:Math.pow(2,s),u={type:"buffer",renderable:this.isSkyboxVis(),intensity:e.intensity,reflectionsIntensity:i,irradianceCoeffs:r,specularImage:a,specularMipCount:s,specularImageSize:l};return Re.createSkyboxOptions(this.engine,u)},n.prototype.createDefaultSkybox=function(t){if("NFT"!==t&&"FARM"!==t)throw new Error("Invalid skybox type name ".concat(t));var n="NFT"===t?e.PSkyboxType.NFT:e.PSkyboxType.FARM,o=Re.getSkyboxParams(n);return Re.createSkyboxOptions(this.engine,o)},n.prototype.scaleColorVal=function(e,t){return t?ft.scaleTo255(e):ft.scaleTo1(e)},n.prototype.scaleColorVec=function(e,t){var n=this;return e.map((function(e){return n.scaleColorVal(e,t)}))},n.prototype.loadScene=function(e){var n;return a(this,void 0,void 0,(function(){var o,i,r,a,c,l=this;return s(this,(function(s){switch(s.label){case 0:if(this._clear(),this._sceneOptions=e,this.engine=null===(n=e.effects.renderer)||void 0===n?void 0:n.engine,this._loaderOptions={compatibleMode:e.gltf.compatibleMode},"string"==typeof(o=e.gltf.resource)||o instanceof Uint8Array)throw new Error("Please load resource by GLTFTools at first");return this._gltfScene=o.scenes[0],this._gltfSkins=this._gltfScene.skins,this._gltfMeshs=o.meshes,this._gltfLights=this._gltfScene.lights,this._gltfCameras=this._gltfScene.cameras,this._gltfImages=o.images,this._gltfTextures=o.textures,this._gltfMaterials=o.materials,this._gltfAnimations=o.animations,this._gltfImageBasedLights=o.imageBasedLights,[4,this._preprocess()];case 1:return s.sent(),r="sceneTree",(i=[]).push(this._createItemTree(r,this._gltfScene)),void 0!==(a=this._createItemSkybox())&&i.push(a),this._gltfScene.nodes.forEach((function(e){if(void 0!==e.mesh){var t=l._createItemMesh(e,r);void 0!==t&&i.push(t)}if(void 0!==e.light){var n=l._createItemLight(e,r);void 0!==n&&i.push(n)}if(void 0!==e.camera){var o=l._createItemCamera(e,r);void 0!==o&&i.push(o)}})),c=new C,this._gltfScene.rootNodes.forEach((function(e){var n=new t.Transform({valid:!0});l._computeSceneAABB(e,n,c)})),[2,{source:this.getRemarkString(),items:i,sceneAABB:{min:c.min.toArray(),max:c.max.toArray()}}]}}))}))},n.prototype._preprocess=function(){return a(this,void 0,void 0,(function(){var t,n,o,i,r,a,l,u=this;return s(this,(function(s){switch(s.label){case 0:this.getTextureManager().initial(this._gltfImages,this._gltfTextures),t=0,s.label=1;case 1:return t<this._gltfMaterials.length?(n=this._gltfMaterials[t],[4,this.tryAddTexture2D(t,n.baseColorTexture,!0)]):[3,8];case 2:return s.sent(),vt.isUnlitMaterial(n)?[3,7]:[4,this.tryAddTexture2D(t,n.metallicRoughnessTexture,!1)];case 3:return s.sent(),[4,this.tryAddTexture2D(t,n.normalTexture,!1)];case 4:return s.sent(),[4,this.tryAddTexture2D(t,n.emissiveTexture,!1)];case 5:return s.sent(),[4,this.tryAddTexture2D(t,n.occlusionTexture,!1)];case 6:s.sent(),s.label=7;case 7:return t++,[3,1];case 8:return this._gltfImageBasedLights.length>0&&!this.ignoreSkybox()?(o=this._gltfImageBasedLights[0],this.isEnvironmentTest()&&o.specularImages.forEach((function(e){var t,n;u.isTiny3dMode()&&(t=c([e[5],e[4]],2),e[4]=t[0],e[5]=t[1]),n=c([e[3],e[2]],2),e[2]=n[0],e[3]=n[1]})),i=this,[4,this.createSkybox(o)]):[3,10];case 9:return i._skyboxOptions=s.sent(),[3,12];case 10:return void 0===(r=this.getSkyboxType())?[3,12]:(a=r===e.PSkyboxType.FARM?"FARM":"NFT",l=this,[4,this.createDefaultSkybox(a)]);case 11:l._skyboxOptions=s.sent(),s.label=12;case 12:return this._skyboxOptions&&(this._skyboxOptions.renderable=this.isSkyboxVis()),this._gltfData2PlayerData(this._gltfScene,this._gltfMaterials),[2]}}))}))},n.prototype.tryAddTexture2D=function(e,t,n){var o=this;if(void 0!==t&&void 0===this.getTexture2D(e,t,n,!0)){var i=t.index,r=this._gltfTextures[i],a=this._gltfImages[r.source];return Q.createTexture2D(this.engine,a,r,n,this.isTiny3dMode()).then((function(t){o.getTextureManager().addTexture(e,i,t,n)}))}},n.prototype.getTexture2D=function(e,t,n,o){if(void 0!==t){var i=t.index,r=this.getTextureManager().getTexture(e,i,n);return void 0===r&&!0!==o&&console.warn("Can't find texture for mat ".concat(e,", tex ").concat(JSON.stringify(t),", basecolor ").concat(n)),r}},n.prototype._gltfData2PlayerData=function(e,t){this.processCamera(e.cameras,!0),this.processLight(e.lights,!0),this.processMaterial(t,!0)},n.prototype._createItemTree=function(e,n){var o=this.createTreeOptions(n),i=this.createAnimations(this._gltfAnimations);return o.animations=i,o.animation=this.getPlayAnimationIndex(o),{id:e,name:n.name,duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:t.spec.ItemType.tree,content:{options:{tree:o}}}},n.prototype._createItemMesh=function(e,n){var o,i,r=this,a=e.mesh;if(void 0===a)throw new Error("Invalid mesh index in node ".concat(e));if(void 0!==e.skin){var s=this._gltfSkins[e.skin];i={name:s.name,joints:s.jointIndexList,skeleton:s.skeleton,inverseBindMatrices:s.inverseBindMatrices}}var c=this._gltfMeshs[a],l=c.primitives.map((function(e){var n=e.material,o=r._gltfMaterials[n],a=r.createGeometry(e,void 0!==i),s=r.createMaterial(o);return s.baseColorTexture=r.getTexture2D(n,o.baseColorTexture,!0),s.type===t.spec.MaterialType.pbr&&(s.metallicRoughnessTexture=r.getTexture2D(n,o.metallicRoughnessTexture,!1),s.normalTexture=r.getTexture2D(n,o.normalTexture,!1),s.emissiveTexture=r.getTexture2D(n,o.emissiveTexture,!1),s.occlusionTexture=r.getTexture2D(n,o.occlusionTexture,!1)),{geometry:a,material:s}})),u={parent:e.nodeIndex,skin:i,primitives:l,weights:c.weights},h=vt.createBoxFromGLTFBound(c.bounds),f=h.getSize(new v),d=h.getCenter(new v),p={behavior:t.spec.InteractBehavior.NOTIFY,type:t.spec.ModelBoundingType.box,size:[f.x,f.y,f.z],center:[d.x,d.y,d.z]};return{id:"mesh_ni".concat(null!==(o=e.nodeIndex)&&void 0!==o?o:0,"_mi").concat(a),parentId:"".concat(n,"^").concat(e.nodeIndex),name:c.name,duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:t.spec.ItemType.mesh,pluginName:"model",content:{options:u,interaction:p}}},n.prototype._createItemLight=function(e,n){var o,i,r=e.light;if(void 0!==r){var a=this._gltfLights[r],s=this.createLightOptions(a);return{id:"light_ni".concat(null!==(o=e.nodeIndex)&&void 0!==o?o:0,"_li").concat(r),parentId:"".concat(n,"^").concat(e.nodeIndex),name:null!==(i=a.name)&&void 0!==i?i:"light",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:t.spec.ItemType.light,pluginName:"model",content:{options:s}}}},n.prototype._createItemCamera=function(e,t){var n,o,i=e.camera;if(void 0!==i){var r=this._gltfCameras[i],a=this.createCameraOptions(r);if(void 0!==a)return{id:"camera_ni".concat(null!==(n=e.nodeIndex)&&void 0!==n?n:0,"_ci").concat(i),parentId:"".concat(t,"^").concat(e.nodeIndex),name:null!==(o=r.name)&&void 0!==o?o:"camera",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:"camera",pluginName:"model",content:{options:a}}}},n.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}}},n.prototype._computeSceneAABB=function(e,n,o){var i=this,r={};if(e.matrix){var a=T.fromArray(e.matrix).getTransform();r.position=a.translation.toArray(),r.quat=a.rotation.toArray(),r.scale=a.scale.toArray()}else e.translation&&(r.position=e.translation),e.rotation&&(r.quat=e.rotation),e.scale&&(r.scale=e.scale);var s=new t.Transform(r,n);if(s.setValid(!0),void 0!==e.mesh){var c=this._gltfMeshs[e.mesh],l=vt.createBoxFromGLTFBound(c.bounds);l.applyMatrix4(s.getWorldMatrix()),o.union(l)}e.children.forEach((function(e){i._computeSceneAABB(e,s,o)}))},n.prototype.createLightOptions=function(e){return $.createLightOptions(e)},n.prototype.createCameraOptions=function(e){return $.createCameraOptions(e)},n.prototype._clear=function(){this._textureManager&&(this._textureManager.dispose(),this._textureManager=void 0),this._textureManager=new pt(this)},n.prototype.getPlayAnimationIndex=function(e){var t=e.animations;if(void 0===t||t.length<=0)return-1;if(this.isPlayAllAnimation())return-88888888;var n=this._sceneOptions.effects.playAnimation;if(void 0===n)return-1;if("number"==typeof n)return n>=0&&n<t.length?n:-1;var o=-1;return t.forEach((function(e,t){e.name===n&&(o=t)})),o},n.prototype.isPlayAnimation=function(){return void 0!==this._sceneOptions.effects.playAnimation},n.prototype.isPlayAllAnimation=function(){return!0===this._sceneOptions.effects.playAllAnimation},n.prototype.getRemarkString=function(){var e=this._sceneOptions.gltf.remark;return void 0===e?"Unknown":"string"==typeof e?e:"BinaryBuffer"},n.prototype.isTiny3dMode=function(){return"tiny3d"===this._loaderOptions.compatibleMode},n.prototype.getTextureManager=function(){return this._textureManager},n.prototype.getItemDuration=function(){var e;return null!==(e=this._sceneOptions.effects.duration)&&void 0!==e?e:9999},n.prototype.getItemEndBehavior=function(){var e;return null!==(e=this._sceneOptions.effects.endBehavior)&&void 0!==e?e:t.spec.ItemEndBehavior.loop},n.prototype.getSkyboxType=function(){switch(this._sceneOptions.gltf.skyboxType){case"NFT":return e.PSkyboxType.NFT;case"FARM":return e.PSkyboxType.FARM}},n.prototype.isSkyboxVis=function(){return!0===this._sceneOptions.gltf.skyboxVis},n.prototype.ignoreSkybox=function(){return!0===this._sceneOptions.gltf.ignoreSkybox},n.prototype.isEnvironmentTest=function(){return"string"==typeof this._sceneOptions.gltf.remark&&this._sceneOptions.gltf.remark.includes("EnvironmentTest")},n}(),pt=function(){function e(e){this._owner=e,this._gltfImages=[],this._gltfTextures=[],this._textureMap=new Map}return e.prototype.initial=function(e,t){this._gltfImages=e,this._gltfTextures=t,this._textureMap.clear()},e.prototype.dispose=function(){this._textureMap.clear()},e.prototype.addTexture=function(e,t,n,o){var i=o?1e5*(e+1)+t:t;this._textureMap.set(i,n)},e.prototype.getTexture=function(e,t,n){var o=n?1e5*(e+1)+t:t;return this._textureMap.get(o)},e}(),mt=function(){function e(e,t,n){this.engine=e,this.gltfGeometry=t,this.hasSkinAnimation=n}return Object.defineProperty(e.prototype,"geometry",{get:function(){var e=this,n={};if(!this.hasPosition)throw new Error("Position attribute missing");var o=this.positionAttrib;(n.a_Position=this._getBufferAttrib(o),this.hasNormal)&&(void 0!==(o=this.normalAttrib)&&(n.a_Normal=this._getBufferAttrib(o)));this.hasTangent&&(void 0!==(o=this.tangentAttrib)&&(n.a_Tangent=this._getBufferAttrib(o)));if(this.texCoordList.forEach((function(t){var o=e.texCoordAttrib(t),i="a_UV".concat(t+1);n[i]=e._getBufferAttrib(o)})),this.hasSkinAnimation){var i=this.jointAttribute;void 0!==i&&(n.a_Joint1=this._getBufferAttrib(i));var r=this.weightAttribute;void 0!==r&&(n.a_Weight1=this._getBufferAttrib(r))}for(var a=0;a<8;a++){var s=this.getTargetPosition(a);void 0!==s&&(n["a_Target_Position".concat(a)]=this._getBufferAttrib(s));var c=this.getTargetNormal(a);void 0!==c&&(n["a_Target_Normal".concat(a)]=this._getBufferAttrib(c));var l=this.getTargetTangent(a);void 0!==l&&(n["a_Target_Tangent".concat(a)]=this._getBufferAttrib(l))}var u=this.indexArray;return void 0!==u?t.Geometry.create(this.engine,{attributes:n,indices:{data:u},drawStart:0,drawCount:u.length,mode:t.glContext.TRIANGLES}):t.Geometry.create(this.engine,{attributes:n,drawStart:0,drawCount:this.positionAttrib.array.length/3,mode:t.glContext.TRIANGLES})},enumerable:!1,configurable:!0}),e.prototype._getBufferAttrib=function(e){return{type:e.type,size:e.itemSize,data:e.array,normalize:e.normalized}},Object.defineProperty(e.prototype,"positionAttrib",{get:function(){return this.gltfGeometry.getPosition()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalAttrib",{get:function(){return this.gltfGeometry.getNormal()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tangentAttrib",{get:function(){return this.gltfGeometry.getTangent()},enumerable:!1,configurable:!0}),e.prototype.texCoordAttrib=function(e){return this.gltfGeometry.getTexCoord(e)},Object.defineProperty(e.prototype,"jointAttribute",{get:function(){return this.gltfGeometry.getJoints(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"weightAttribute",{get:function(){return this.gltfGeometry.getWeights(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPosition",{get:function(){return void 0!==this.positionAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNormal",{get:function(){return void 0!==this.normalAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasTangent",{get:function(){return void 0!==this.tangentAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasTexCoord",{get:function(){return this.texCoordCount>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texCoordCount",{get:function(){for(var e=0;e<10;e++)if(void 0===this.texCoordAttrib(e))return e;return 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasJointAttribute",{get:function(){return void 0!==this.jointAttribute},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasWeightAttribute",{get:function(){return void 0!==this.weightAttribute},enumerable:!1,configurable:!0}),Object.defineProperty(e.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(e.prototype,"indexCount",{get:function(){return void 0!==this.gltfGeometry.indices?this.gltfGeometry.indices.array.length:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texCoordList",{get:function(){for(var e=[],t=0;t<10&&void 0!==this.texCoordAttrib(t);t++)e.push(t);return e},enumerable:!1,configurable:!0}),e.prototype.getTargetPosition=function(e){return this.gltfGeometry.getAttribute("POSITION".concat(e))},e.prototype.getTargetNormal=function(e){return this.gltfGeometry.getAttribute("NORMAL".concat(e))},e.prototype.getTargetTangent=function(e){return this.gltfGeometry.getAttribute("TANGENT".concat(e))},e}(),gt=function(){function e(e,t,n){this.gltfMaterial=e,this.textures=t,this.tiny3dMode=n}return Object.defineProperty(e.prototype,"material",{get:function(){var e,n,o,i=this.gltfMaterial,r=vt.isUnlitMaterial(i),a=t.spec.MaterialBlending.opaque;switch(i.alphaMode){case"OPAQUE":a=t.spec.MaterialBlending.opaque;break;case"MASK":a=t.spec.MaterialBlending.masked;break;case"BLEND":a=t.spec.MaterialBlending.translucent}var s=i.doubleSided?t.spec.SideMode.DOUBLE:t.spec.SideMode.FRONT,c=null!==(e=i.alphaCutOff)&&void 0!==e?e:.5,l=i.name;return r?{name:l,type:t.spec.MaterialType.unlit,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,depthMask:null===(n=i.extras)||void 0===n?void 0:n.depthMask,blending:a,alphaCutOff:c,side:s}:{name:l,type:t.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===(o=i.extras)||void 0===o?void 0:o.depthMask,blending:a,alphaCutOff:c,side:s,enableShadow:!1}},enumerable:!1,configurable:!0}),e.prototype.getTextureObject=function(e){if(!(e<0||e>=this.textures.length))return this.textures[e]},e.prototype.getTextureObj=function(e){return e?this.getTextureObject(e.index):void 0},e.prototype.getTextureCoord=function(e){return e?e.texCoord:void 0},e.prototype.getTextureTransform=function(e){var t,n=null===(t=null==e?void 0:e.extensions)||void 0===t?void 0:t.KHR_texture_transform;if(void 0!==n&&(void 0!==n.offset||void 0!==n.rotation||void 0!==n.scale))return{offset:n.offset,rotation:n.rotation,scale:n.scale}},Object.defineProperty(e.prototype,"baseColorTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metallicRoughnessTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metallicRoughnessTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metallicRoughnessTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasEmissive",{get:function(){var e=this.emissiveFactor;return e[0]+e[1]+e[2]>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorFactor",{get:function(){var e=this.gltfMaterial.baseColorFactor;return void 0===e||4!=e.length?[1,1,1,1]:[e[0],e[1],e[2],e[3]]},enumerable:!1,configurable:!0}),e.prototype.getSpecularAA=function(){var e;return null===(e=this.gltfMaterial.extras)||void 0===e?void 0:e.useSpecularAA},Object.defineProperty(e.prototype,"metalicFactor",{get:function(){var e;return null!==(e=this.gltfMaterial.metallicFactor)&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"roughnessFactor",{get:function(){var e;return null!==(e=this.gltfMaterial.roughnessFactor)&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureScale",{get:function(){var e,t;return null!==(t=null===(e=this.gltfMaterial.normalTexture)||void 0===e?void 0:e.scale)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureStrength",{get:function(){var e,t;return null!==(t=null===(e=this.gltfMaterial.occlusionTexture)||void 0===e?void 0:e.strength)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveFactor",{get:function(){var e=this.gltfMaterial.emissiveFactor;return void 0===e||4!=e.length?[0,0,0,1]:[e[0],e[1],e[2],1]},enumerable:!1,configurable:!0}),e}(),vt=function(){function e(){}return e.isUnlitMaterial=function(e){var t;return void 0!==(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_unlit)},e.createBoxFromGLTFBound=function(e){var t=v.fromArray(e.box.min),n=v.fromArray(e.box.max);return new C(t,n)},e}();t.registerPlugin("tree",lt,at,!0),t.registerPlugin("model",ct,st);var yt="1.6.0-beta.2";t.logger.info("plugin model version: "+yt),e.BoxMesh=ze,e.CameraGestureHandlerImp=ht,e.CheckerHelper=re,e.CompositionCache=Be,e.CompositionHitTest=function(e,t,n){var o=e.hitTest(t,n,!0),i=e.getHitTestRay(t,n);if(o.length<=0)return[];var r=i.origin,a=i.direction,s=o.map((function(e,t){for(var n=e.position,o=[0,0,0],i=0;i<3;i++)o[i]=(n.getElement(i)-r.getElement(i))/a.getElement(i);return[t,Math.max.apply(Math,l([],c(o),!1))]}));return s.sort((function(e,t){return(e[1]>=0?e[1]:e[1]+1e9)-(t[1]>=0?t[1]:t[1]+1e9)})),s.map((function(e){return o[e[0]]}))},e.FBOOptions=je,e.Float16ArrayWrapper=ae,e.GeometryBoxProxy=oe,e.HitTestingProxy=ie,e.HookOGLFunc=function(e){console.info("HookOGLFunc "+Object.getPrototypeOf(e));var t=0;for(var n in Object.getPrototypeOf(e))"getError"!==n&&"function"==typeof e[n]&&(++t,e[n+et]=e[n],e[n]=ot(e,n));console.info("HookCount "+t),function(e){for(var t in Object.getPrototypeOf(e))"number"==typeof e[t]&&tt.set(e[t],t)}(e)},e.InterpolationSampler=u,e.LoaderHelper=ft,e.LoaderImpl=dt,e.MeshHelper=Z,e.ModelPlugin=ct,e.ModelTreeItem=rt,e.ModelTreePlugin=lt,e.ModelTreeVFXItem=at,e.ModelVFXItem=st,e.PAnimTexture=pe,e.PAnimTrack=de,e.PAnimation=me,e.PAnimationManager=ge,e.PAnimationSystem=ve,e.PCamera=De,e.PCameraManager=ke,e.PCoordinate=F,e.PEntity=D,e.PGeometry=Qe,e.PGlobalState=R,e.PLight=Ve,e.PLightManager=Ge,e.PMaterialBase=Ee,e.PMaterialPBR=we,e.PMaterialSkyboxFilter=Fe,e.PMaterialUnlit=Pe,e.PMesh=qe,e.PMorph=he,e.PObject=U,e.PPrimitive=Ke,e.PSceneManager=$e,e.PShaderManager=Ie,e.PSkin=ue,e.PSkybox=Ne,e.PSkyboxCreator=Re,e.PTransform=N,e.PluginHelper=$,e.RayBoxTesting=j,e.RayIntersectsBoxWithRotation=G,e.RayTriangleTesting=J,e.ToggleItemBounding=function(t,o){var i;null===(i=t.items)||void 0===i||i.forEach((function(t){if(t.type===n){var i=t;if(i.content.type===e.PObjectType.mesh){var r=i.content;i.id===o?r.visBoundingBox=!0:r.visBoundingBox=!1}}}))},e.TwoStatesSet=He,e.VFX_ITEM_TYPE_3D=n,e.VertexAttribBuffer=te,e.WebGLHelper=Q,e.WebHelper=ee,e.createAnimationSampler=m,e.createInternalMaterial=function(e){return{}},e.createPluginMaterial=Oe,e.getDefaultEffectsGLTFLoader=function(e,t){return ut||(ut=new dt),ut.initial(e,t),ut},e.getDiffuseOnlyShaderCode=function(e){return{vertexShaderCode:Ae({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 "}},e.getGaussianBlurShaderCodeV1=function(e){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 "}},e.getGaussianBlurShaderCodeV2=Me,e.getKawaseBlurShaderCode=function(e){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 "}},e.getNormalVisShaderCode=Se,e.getPBRPassShaderCode=Te,e.getPMeshList=function(t){var o=[],i=t.getCompositions()[0];return null==i||i.items.forEach((function(t){if(t.type===n){var i=t;i.content&&i.content.type===e.PObjectType.mesh&&o.push(i.content)}})),o},e.getQuadFilterShaderCode=function(e){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 "}},e.getRendererGPUInfo=function(e){var t=e.gpuCapability;return JSON.stringify(t,void 0,2)},e.getShadowPassShaderCode=_e,e.getSimpleFilterShaderCode=Ce,e.getSkyBoxShaderCode=xe,e.getTransparecyBaseShader=function(e){return e?Ae({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 "},e.getTransparecyFilterShader=function(e){return e?"\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 "},e.setDefaultEffectsGLTFLoader=function(e){ut=e},e.version=yt,Object.defineProperty(e,"__esModule",{value:!0})}));
8
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ge=e.ge||{},e.ge.modelPlugin={}),e.ge)}(this,(function(e,t){"use strict";var n="PluginModel",o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var r=function(){return r=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};function a(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))}function s(e,t){var n,o,i,r,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,i,r=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=r.next()).done;)a.push(o.value)}catch(e){i={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return a}function l(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var u=function(){function e(e,t,n){this.time=e,this.data=t,this.componentCount=n,this.cachedIndex=0}return e.prototype.evaluate=function(e){var t=this.time,n=this.cachedIndex,o=t[n],i=t[n-1];e:{t:{var r=void 0;n:{o:if(!(e<o)){for(var a=n+2;;){if(void 0===o){if(e<i)break o;return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}if(n===a)break;if(i=o,e<(o=t[++n]))break t}r=t.length;break n}if(e>=i)break e;var s=t[1];e<s&&(n=2,i=s);for(a=n-2;;){if(void 0===i)return this.cachedIndex=0,this.copySampleValue(0);if(n===a)break;if(o=i,e>=(i=t[--n-1]))break t}r=n,n=0}for(;n<r;){var c=n+r>>>1;e<t[c]?r=c:n=c+1}if(o=t[n],void 0===(i=t[n-1]))return this.cachedIndex=0,this.copySampleValue(0);if(void 0===o)return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}this.cachedIndex=n,this.intervalChanged(n,i,o)}return this.interpolate(n,i,e,o)},e.prototype.dispose=function(){this.time=void 0,this.data=void 0},e.prototype.copySampleValue=function(e){for(var t=this.data,n=this.componentCount,o=e*n,i=new Float32Array(n),r=0;r!==n;++r)i[r]=t[o+r];return i},e}(),h=function(e){function t(t,n,o){return e.call(this,t,n,o)||this}return i(t,e),t.prototype.intervalChanged=function(e,t,n){},t.prototype.interpolate=function(e,t,n,o){for(var i,r=this.data,a=null!==(i=this.componentCount)&&void 0!==i?i:1,s=e*a,c=s-a,l=(n-t)/(o-t),u=1-l,h=new Float32Array(a),f=0;f!==a;++f)h[f]=r[c+f]*u+r[s+f]*l;return h},t}(u),f=function(e){function t(t,n,o){return e.call(this,t,n,o)||this}return i(t,e),t.prototype.intervalChanged=function(e,t,n){},t.prototype.interpolate=function(e,t,n,o){for(var i,r=this.data,a=null!==(i=this.componentCount)&&void 0!==i?i:1,s=(e-1)*a,c=new Float32Array(a),l=0;l!==a;++l)c[l]=r[s+l];return c},t}(u),d=function(){function e(){}return e.slerpFlat=function(e,t,n,o,i,r,a){var s=n[o+0],c=n[o+1],l=n[o+2],u=n[o+3],h=i[r+0],f=i[r+1],d=i[r+2],p=i[r+3];if(0===a)return e[t+0]=s,e[t+1]=c,e[t+2]=l,void(e[t+3]=u);if(1===a)return e[t+0]=h,e[t+1]=f,e[t+2]=d,void(e[t+3]=p);if(u!==p||s!==h||c!==f||l!==d){var m=1-a,g=s*h+c*f+l*d+u*p,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),T=Math.atan2(b,g*v);m=Math.sin(m*T)/b,a=Math.sin(a*T)/b}var _=a*v;if(s=s*m+h*_,c=c*m+f*_,l=l*m+d*_,u=u*m+p*_,m===1-a){var x=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=x,c*=x,l*=x,u*=x}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u},e}(),p=function(e){function t(t,n,o){return e.call(this,t,n,o)||this}return i(t,e),t.prototype.intervalChanged=function(e,t,n){},t.prototype.interpolate=function(e,t,n,o){for(var i,r=this.data,a=null!==(i=this.componentCount)&&void 0!==i?i:1,s=(n-t)/(o-t),c=e*a,l=new Float32Array(a),u=c+a;c!==u;c+=4)d.slerpFlat(l,0,r,c-a,r,c,s);return l},t}(u);function m(e,t,n,o,i){switch(e){case"LINEAR":return"rotation"===i?new p(t,n,o):new h(t,n,o);case"STEP":return new f(t,n,o);default:return new h(t,n,o)}}var g=t.math.Vector2,v=t.math.Vector3,y=t.math.Vector4,b=t.math.Matrix3,T=t.math.Matrix4,_=t.math.Euler,x=t.math.EulerOrder,S=t.math.Quaternion,M=t.math.Box3;t.math.Sphere,t.math.Ray;var C,A,I,E,P,w,O,L=t.math.DEG2RAD;e.PObjectType=void 0,(C=e.PObjectType||(e.PObjectType={}))[C.none=0]="none",C[C.mesh=1]="mesh",C[C.texture=2]="texture",C[C.material=3]="material",C[C.light=4]="light",C[C.camera=5]="camera",C[C.skybox=6]="skybox",C[C.skin=7]="skin",C[C.morph=8]="morph",C[C.skeleton=9]="skeleton",C[C.animation=10]="animation",C[C.animationManager=11]="animationManager",C[C.reference=12]="reference",e.PLightType=void 0,(A=e.PLightType||(e.PLightType={}))[A.directional=0]="directional",A[A.point=1]="point",A[A.spot=2]="spot",A[A.ambient=3]="ambient",e.PTextureType=void 0,(I=e.PTextureType||(e.PTextureType={}))[I.none=0]="none",I[I.t2d=1]="t2d",I[I.t3d=2]="t3d",I[I.cube=3]="cube",e.PMaterialType=void 0,(E=e.PMaterialType||(e.PMaterialType={}))[E.none=0]="none",E[E.unlit=1]="unlit",E[E.pbr=2]="pbr",E[E.normalVis=3]="normalVis",E[E.simpleFilter=4]="simpleFilter",E[E.shadowBase=5]="shadowBase",E[E.shadowFilter=6]="shadowFilter",E[E.skyboxFilter=7]="skyboxFilter",e.PBlendMode=void 0,(P=e.PBlendMode||(e.PBlendMode={}))[P.opaque=0]="opaque",P[P.masked=1]="masked",P[P.translucent=2]="translucent",P[P.additive=3]="additive",e.PFaceSideMode=void 0,(w=e.PFaceSideMode||(e.PFaceSideMode={}))[w.both=0]="both",w[w.front=1]="front",w[w.back=2]="back",e.PShadowType=void 0,(O=e.PShadowType||(e.PShadowType={}))[O.none=0]="none",O[O.standard=1]="standard",O[O.variance=2]="variance",O[O.expVariance=3]="expVariance";var N=function(){function e(){this.translation=new v(0,0,0),this.rotation=new S(0,0,0,1),this.scale=new v(1,1,1)}return e.prototype.fromMatrix4=function(e){return this.setMatrix(e),this},e.prototype.fromEffectsTransform=function(e){if(e instanceof t.Transform)this.setMatrix(e.getWorldMatrix());else{var n=new t.Transform(r(r({},e),{valid:!0}));n.setValid(!0),this.setMatrix(n.getWorldMatrix())}return this},e.prototype.toEffectsTransform=function(e){var t=this.getMatrix();return e.cloneFromMatrix(t),e},e.prototype.fromBaseTransform=function(e){return e.position?this.setTranslation(e.position):this.translation.set(0,0,0),e.rotation?this.setRotation(e.rotation):this.rotation.set(0,0,0,1),e.scale?this.setScale(e.scale):this.scale.set(1,1,1),this},e.prototype.getTranslation=function(){return this.translation},e.prototype.setTranslation=function(e){e instanceof v?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},e.prototype.getPosition=function(){return this.translation},e.prototype.setPosition=function(e){e instanceof v?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},e.prototype.getRotation=function(){return this.rotation},e.prototype.setRotation=function(e){e instanceof S?this.rotation.set(e.x,e.y,e.z,e.w):e instanceof _?this.rotation.setFromEuler(e):e instanceof v?this.rotation.setFromEuler(new _(e.x,e.y,e.z,x.ZYX)):4===e.length?this.rotation.set(e[0],e[1],e[2],e[3]):this.rotation.setFromEuler(new _(e[0],e[1],e[2],x.ZYX))},e.prototype.getScale=function(){return this.scale},e.prototype.setScale=function(e){e instanceof v?this.scale.set(e.x,e.y,e.z):this.scale.set(e[0],e[1],e[2])},e.prototype.getMatrix=function(){return(new T).compose(this.getTranslation(),this.getRotation(),this.getScale())},e.prototype.setMatrix=function(e){if(e instanceof T){var t=e.getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}else{t=T.fromArray(e).getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}},e}(),F=function(){function e(){this.origin=new v(0,0,0),this.xAxis=new v(1,0,0),this.yAxis=new v(0,1,0),this.zAxis=new v(0,0,1)}return e.prototype.fromPTransform=function(e,t){void 0===t&&(t=!1),this.origin.copyFrom(e.getPosition());var n=e.getRotation().toMatrix4(new T);return t&&n.invert(),this.fromRotationMatrix(n),this},e.prototype.fromRotationMatrix=function(e){var t=e.elements;this.xAxis.set(t[0],t[1],t[2]),this.yAxis.set(t[4],t[5],t[6]),this.zAxis.set(t[8],t[9],t[10])},e}(),R=function(){function e(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=t.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16}return e.getInstance=function(){return this.instance||(this.instance=new this)},e.prototype.reset=function(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=t.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16},e.prototype.hasRenderMode3D=function(){return this.renderMode3D!==t.spec.RenderMode3D.none},Object.defineProperty(e.prototype,"isEditorEnv",{get:function(){return this.runtimeEnv===t.PLAYER_OPTIONS_ENV_EDITOR},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDeviceEnv",{get:function(){return!this.isEditorEnv},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isTiny3dMode",{get:function(){return"tiny3d"===this.compatibleMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isOasisMode",{get:function(){return"oasis"===this.compatibleMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isGLTFMode",{get:function(){return!this.isTiny3dMode&&!this.isOasisMode},enumerable:!1,configurable:!0}),e}(),B=1,U=function(){function t(){this.name="Unnamed Object",this.type=e.PObjectType.none}return t.prototype.dispose=function(){},t.prototype.isNone=function(){return this.type===e.PObjectType.none},t.prototype.isValid=function(){return this.type!==e.PObjectType.none},t.prototype.genName=function(e){return"".concat(e,"_@").concat(B++)},t}(),D=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._visible=!1,t._transform=new N,t.deleted=!1,t}return i(t,e),t.prototype.tick=function(e){},t.prototype.onVisibleChanged=function(e){this.visible=e},t.prototype.addToRenderObjectSet=function(e){},t.prototype.updateUniformsForScene=function(e){},t.prototype.onEntityRemoved=function(){this.visible=!1,this.deleted=!0},Object.defineProperty(t.prototype,"visible",{get:function(){return this._visible&&this.isValid()},set:function(e){this._visible=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transform",{get:function(){return this._transform},set:function(e){e instanceof N?this._transform=e:(void 0!==e.position&&this._transform.setTranslation(e.position),void 0!==e.rotation&&this._transform.setRotation(e.rotation),void 0!==e.scale&&this._transform.setScale(e.scale))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"translation",{get:function(){return this._transform.getTranslation()},set:function(e){this._transform.setTranslation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._transform.getTranslation()},set:function(e){this._transform.setTranslation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._transform.getRotation()},set:function(e){this._transform.setRotation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scale",{get:function(){return this._transform.getScale()},set:function(e){this._transform.setScale(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._transform.getMatrix()},set:function(e){this._transform.setMatrix(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinate",{get:function(){var e=new F;return e.fromPTransform(this._transform),e},enumerable:!1,configurable:!0}),t}(U);var k={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,f32:Float32Array,i32:Int32Array,u32:Uint32Array};function V(e,n){if(2!=n.length||n[0]!==t.spec.ValueType.BINARY||!(n[1]instanceof Array))return n;var o=c(n[1],4),i=o[0],r=o[1],a=o[2],s=o[3];if(!s)return e[i].slice(r,a);var l=k[s]||Uint8Array;return new l(e[i],r,a/l.BYTES_PER_ELEMENT)}function G(e,t,n){var o=t,i=o.clone().invert(),r=e.clone().applyMatrix(i),a=v.fromArray(n.center),s=v.fromArray(n.size).multiply(.5),c=a.clone().subtract(s),l=a.clone().add(s),u=r.intersectBox({min:c,max:l},new v);return void 0!==u?[o.transformPoint(u)]:void 0}function j(e,t,n,o){var i=0,r=0,a=0,s=0,c=0,l=0,u=1/t.x,h=1/t.y,f=1/t.z;if(u>=0?(i=(n.x-e.x)*u,r=(o.x-e.x)*u):(i=(o.x-e.x)*u,r=(n.x-e.x)*u),h>=0?(a=(n.y-e.y)*h,s=(o.y-e.y)*h):(a=(o.y-e.y)*h,s=(n.y-e.y)*h),!(i>s||a>r||((a>i||i!=i)&&(i=a),(s<r||r!=r)&&(r=s),f>=0?(c=(n.z-e.z)*f,l=(o.z-e.z)*f):(c=(o.z-e.z)*f,l=(n.z-e.z)*f),i>l||c>r||((c>i||i!=i)&&(i=c),(l<r||r!=r)&&(r=l),r<0))))return i>=0?i:r}var z=new v,H=new v,W=new v,X=new v;function J(e,t,n,o,i,r){H.subtractVectors(o,n),W.subtractVectors(i,n),X.crossVectors(H,W);var a=t.dot(X),s=0;if(a>0){if(r)return;s=1}else{if(!(a<0))return;s=-1,a=-a}z.subtractVectors(e,n),W.crossVectors(z,W);var c=s*t.dot(W);if(!(c<0)){H.crossVectors(H,z);var l=s*t.dot(H);if(!(l<0||c+l>a)){var u=-s*z.dot(X);if(!(u<0))return u/a}}}var Y,q,K,Q=function(){function e(){}return e.createTexture2D=function(n,o,i,r,c){return a(this,void 0,void 0,(function(){var a,l,u,h;return s(this,(function(s){return void 0===o.imageData?(console.error("createTexture2D: Invalid image data from ".concat(o)),[2,t.Texture.create(n,{name:"createTexture2D",sourceType:t.TextureSourceType.data,data:{data:new Uint8Array([255,255,255,255]),width:1,height:1}})]):(a=new Blob([o.imageData],{type:o.mimeType}),l=window.URL||window.webkitURL,u=l.createObjectURL(a),(h=new Image).src=u,[2,new Promise((function(o,a){h.onload=function(){var a,s,f,d,p=null!==(a=i.minFilter)&&void 0!==a?a:t.glContext.LINEAR_MIPMAP_LINEAR,m=!1;c&&(p=t.glContext.LINEAR_MIPMAP_LINEAR,e.isPow2(h.width)&&e.isPow2(h.height)||(p=t.glContext.LINEAR),m=!r);var g=!1;p!=t.glContext.NEAREST_MIPMAP_NEAREST&&p!=t.glContext.LINEAR_MIPMAP_NEAREST&&p!=t.glContext.NEAREST_MIPMAP_LINEAR&&p!=t.glContext.LINEAR_MIPMAP_LINEAR||(g=!0);var v=t.Texture.create(n,{name:"createTexture2D",wrapS:null!==(s=i.wrapS)&&void 0!==s?s:t.glContext.REPEAT,wrapT:null!==(f=i.wrapT)&&void 0!==f?f:t.glContext.REPEAT,magFilter:null!==(d=i.magFilter)&&void 0!==d?d:t.glContext.LINEAR,minFilter:p,anisotropic:1,premultiplyAlpha:m,sourceType:t.TextureSourceType.image,image:h,generateMipmap:g});o(v),l.revokeObjectURL(u)},h.onerror=a}))])}))}))},e.createTextureList=function(e,t,n){return a(this,void 0,void 0,(function(){var o=this;return s(this,(function(i){switch(i.label){case 0:return[4,Promise.all(n.map((function(n){return o.createTexture2D(e,t[n.source],n)})))];case 1:return[2,i.sent()]}}))}))},e.getTextureCubeData=function(e){return a(this,void 0,void 0,(function(){var t;return s(this,(function(n){switch(n.label){case 0:return[4,ee.loadImageFromImageData(e[0])];case 1:return t=[n.sent()],[4,ee.loadImageFromImageData(e[1])];case 2:return t=t.concat([n.sent()]),[4,ee.loadImageFromImageData(e[2])];case 3:return t=t.concat([n.sent()]),[4,ee.loadImageFromImageData(e[3])];case 4:return t=t.concat([n.sent()]),[4,ee.loadImageFromImageData(e[4])];case 5:return t=t.concat([n.sent()]),[4,ee.loadImageFromImageData(e[5])];case 6:return[2,t.concat([n.sent()])]}}))}))},e.getTextureCubeMipmapData=function(e){return a(this,void 0,void 0,(function(){var t,n,o,i;return s(this,(function(r){switch(r.label){case 0:t=[],n=0,r.label=1;case 1:return n<e.length?(i=(o=t).push,[4,this.getTextureCubeData(e[n])]):[3,4];case 2:i.apply(o,[r.sent()]),r.label=3;case 3:return n++,[3,1];case 4:return[2,t]}}))}))},e.createTextureCubeFromURL=function(e,n){return a(this,void 0,void 0,(function(){var o;return s(this,(function(i){switch(i.label){case 0:return[4,t.getDefaultTextureFactory().loadSource({type:t.TextureSourceType.image,target:t.glContext.TEXTURE_CUBE_MAP,map:n},this.cubemapTexConfig)];case 1:return o=i.sent(),[2,t.Texture.create(e,o)]}}))}))},e.createTextureCubeMipmapFromURL=function(e,n){return a(this,void 0,void 0,(function(){var o;return s(this,(function(i){switch(i.label){case 0:return[4,t.getDefaultTextureFactory().loadSource({type:t.TextureSourceType.mipmaps,target:t.glContext.TEXTURE_CUBE_MAP,maps:n},this.cubemapMipTexConfig)];case 1:return o=i.sent(),[2,t.Texture.create(e,o)]}}))}))},e.createTextureCubeFromBuffer=function(n,o){return a(this,void 0,void 0,(function(){var i;return s(this,(function(a){switch(a.label){case 0:return[4,e.getTextureCubeData(o)];case 1:return i=a.sent(),[2,t.Texture.create(n,r({name:"createTextureCubeFromBuffer",sourceType:t.TextureSourceType.image,cube:i,target:t.glContext.TEXTURE_CUBE_MAP},this.cubemapTexConfig))]}}))}))},e.createTextureCubeMipmapFromBuffer=function(n,o,i){return a(this,void 0,void 0,(function(){var a,c,l,u,h;return s(this,(function(s){switch(s.label){case 0:return[4,e.getTextureCubeMipmapData(o)];case 1:for(a=s.sent(),c=0;Math.pow(2,c)<i;)++c;s.label=2;case 2:return a.length<=c?(l=Math.pow(2,c-a.length),u="https://gw.alipayobjects.com/zos/gltf-asset/67896749597915/img".concat(l,".png"),[4,t.loadImage(u)]):[3,4];case 3:return h=s.sent(),a.push([h,h,h,h,h,h]),[3,2];case 4:return[2,t.Texture.create(n,r({name:"createTextureCubeMipmapFromBuffer",sourceType:t.TextureSourceType.mipmaps,mipmaps:a,target:t.glContext.TEXTURE_CUBE_MAP},this.cubemapMipTexConfig))]}}))}))},e.getTexture=function(e,t){return e<0||e>=t.length?void 0:t[e]},e.createTextureFromImage=function(e,n){var o={name:"createTextureFromImage",image:n,sourceType:t.TextureSourceType.image,flipY:!1,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR,wrapT:t.glContext.REPEAT,wrapS:t.glContext.REPEAT};return t.Texture.create(e,o)},e.createRenderPass=function(e,n,o,i,r){var a=i instanceof t.Mesh?[i]:i;return new t.RenderPass(e,{name:n,priority:o,attachments:r.colorAttachments,depthStencilAttachment:r.depthAttachment,clearAction:{clearDepth:1,clearStencil:0,clearColor:[0,0,0,0],colorAction:t.TextureLoadAction.clear,depthAction:t.TextureLoadAction.clear},meshes:a,viewport:r.viewport})},e.deleteTexture=function(e){e.dispose()},e.deleteMesh=function(e){e.dispose({geometries:t.DestroyOptions.destroy,material:{textures:t.DestroyOptions.destroy}})},e.deleteGeometry=function(e){e.dispose()},e.deleteRenderPass=function(e){e.dispose({meshes:{geometries:t.DestroyOptions.destroy,material:{textures:t.DestroyOptions.destroy}},depthStencilAttachment:t.RenderPassDestroyAttachmentType.force,colorAttachment:t.RenderPassDestroyAttachmentType.force,semantics:t.DestroyOptions.destroy})},e.isTransparentMesh=function(e){return!0===e.material.blending},e.isSupportFloatTexture=function(e){return 0!==e.gpuCapability.detail.floatTexture},e.isSupportHalfFloatTexture=function(e){return 0!==e.gpuCapability.detail.halfFloatTexture},e.isPow2=function(e){return!(e&e-1||!e)},e.cubemapTexConfig={name:"cubemap texture",wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR},e.cubemapMipTexConfig={wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR_MIPMAP_LINEAR},e}(),Z=function(){function e(){}return e.createFilterMesh=function(n,o,i,r){var a=R.getInstance(),s=i.vertexShaderCode,c=i.fragmentShaderCode,l=t.Geometry.create(n,e.getPlaneGeometry()),u=t.Material.create(n,{shader:{vertex:s,fragment:c,shared:a.shaderShared},uniformSemantics:r});return i.setMaterialStates(u),t.Mesh.create(n,{name:o,worldMatrix:T.fromIdentity(),material:u,geometry:l})},e.getPlaneGeometry=function(){var n=e.getPlaneVertexArray();return{attributes:{a_Position:{type:t.glContext.FLOAT,size:3,data:n,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:0},a_UV1:{type:t.glContext.FLOAT,size:2,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:3*Float32Array.BYTES_PER_ELEMENT,dataSource:"a_Position"},a_Normal:{type:t.glContext.FLOAT,size:3,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:5*Float32Array.BYTES_PER_ELEMENT,dataSource:"a_Position"}},drawStart:0,drawCount:n.length/8}},e.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])},e}(),$=function(){function e(){}return e.createLightOptions=function(e){var t,n,o,i,r,a,s,c,l=null!==(t=e.color)&&void 0!==t?t:[255,255,255,255];return"point"===e.type?{color:l,intensity:null!==(n=e.intensity)&&void 0!==n?n:1,lightType:"point",range:null!==(o=e.range)&&void 0!==o?o:0}:"spot"===e.type?{color:l,intensity:null!==(i=e.intensity)&&void 0!==i?i:1,lightType:"spot",range:null!==(r=e.range)&&void 0!==r?r:0,innerConeAngle:null!==(a=e.innerConeAngle)&&void 0!==a?a:0,outerConeAngle:null!==(s=e.outerConeAngle)&&void 0!==s?s:Math.PI/4}:{color:l,intensity:null!==(c=e.intensity)&&void 0!==c?c:1,lightType:"directional"}},e.createCameraOptions=function(e){if(void 0!==e.perspective){var t=e.perspective;t.znear,t.zfar,t.yfov}},e.toPlayerColor3=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2])]},e.toPlayerColor4=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2]),this.scaleTo255(e[3])]},e.toPluginColor3=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2])]},e.toPluginColor4=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2]),this.scaleTo1(e[3])]},e.createUVTransform=function(e){if(void 0!==e&&(void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale)){var t=b.fromIdentity(),n=new b;if(void 0!==e.offset&&(n.setFromArray([1,0,0,0,1,0,e.offset[0],e.offset[1],1]),t.multiply(n)),void 0!==e.rotation){var o=Math.cos(e.rotation),i=Math.sin(e.rotation);n.setFromArray([o,i,0,-i,o,0,0,0,1]),t.multiply(n)}return void 0!==e.scale&&(n.setFromArray([e.scale[0],0,0,0,e.scale[1],0,0,0,1]),t.multiply(n)),t.transpose(),t}},e.clamp=function(e,t,n){return Math.max(Math.min(e,n),t)},e.scaleTo255=function(e){var t=Math.round(255*e);return Math.max(0,Math.min(t,255))},e.scaleTo1=function(e){var t=e/255;return Math.max(0,Math.min(t,1))},e.focusOnPoint=function(e,n,o){var i=v.fromArray(e),r=v.fromArray(o),a=(new v).copyFrom(i).subtract(r);T.fromRotationAxis(new v(0,1,0),n*L).transformPoint(a);var s=a.clone().add(r),c=(new T).lookAt(s,r,new v(0,1,0)).invert(),l=new t.Transform;return l.setValid(!0),l.cloneFromMatrix(c),l},e.preprocessEffectsScene=function(e,n,o,i){var r=this,a=n!==t.PLAYER_OPTIONS_ENV_EDITOR,s="tiny3d"===o,c=e.jsonScene;if(void 0===c||void 0===c.compositions)return{};var l=!1;if(a){var u=e.textureOptions;c.compositions.forEach((function(e){e.items.forEach((function(e){if("mesh"===e.type)e.content.options.primitives.forEach((function(e){var n=e.material;n.type===t.spec.MaterialType.pbr?(void 0!==n.baseColorTexture&&r.preprocessTextureOptions(n.baseColorTexture,u,!0,s),void 0!==n.metallicRoughnessTexture&&r.preprocessTextureOptions(n.metallicRoughnessTexture,u,!1,s),void 0!==n.normalTexture&&r.preprocessTextureOptions(n.normalTexture,u,!1,s),void 0!==n.occlusionTexture&&r.preprocessTextureOptions(n.occlusionTexture,u,!1,s),void 0!==n.emissiveTexture&&r.preprocessTextureOptions(n.emissiveTexture,u,!1,s)):void 0!==n.baseColorTexture&&r.preprocessTextureOptions(n.baseColorTexture,u,!0,s)}));else if("skybox"===e.type){l=!0;var n=e.content.options;r.preprocessTextureOptions(n.specularImage,u,!1,s),void 0!==n.diffuseImage&&r.preprocessTextureOptions(n.diffuseImage,u,!1,s)}}))}))}else c.compositions.forEach((function(e){e.items.forEach((function(e){"skybox"===e.type&&(l=!0)}))}));return i&&c.compositions.forEach((function(e){var n=0;e.items.forEach((function(e){"light"!==e.type&&"skybox"!==e.type||++n})),0==n&&(e.items.push({id:"dir-light1",duration:100,name:"dir-light1",type:t.spec.ItemType.light,transform:{rotation:[45,-45,0]},pluginName:"model",endBehavior:0,content:{options:{lightType:"directional",color:[255,255,255,255],intensity:1.5}}}),e.items.push({id:"dir-light2",duration:100,name:"dir-light2",type:t.spec.ItemType.light,transform:{rotation:[0,90,0]},pluginName:"model",endBehavior:0,content:{options:{lightType:"directional",color:[255,255,255,255],intensity:.2}}}))})),{loadSkybox:l}},e.preprocessTextureOptions=function(e,n,o,i){if(!(e<0||e>=n.length)){var r=n[e];i&&void 0!==r&&(void 0===r.target||r.target===t.glContext.TEXTURE_2D?(r.wrapS=t.glContext.REPEAT,r.wrapT=t.glContext.REPEAT,r.magFilter=t.glContext.LINEAR,r.minFilter=t.glContext.LINEAR_MIPMAP_LINEAR,r.generateMipmap=!0,o||(r.premultiplyAlpha=!0)):r.target===t.glContext.TEXTURE_CUBE_MAP&&(r.wrapS=t.glContext.CLAMP_TO_EDGE,r.wrapT=t.glContext.CLAMP_TO_EDGE,void 0!==r.mipmaps?(r.magFilter=t.glContext.LINEAR,r.minFilter=t.glContext.LINEAR_MIPMAP_LINEAR):(r.magFilter=t.glContext.LINEAR,r.minFilter=t.glContext.LINEAR)))}},e.setupItem3DOptions=function(e,n,o){var i=this;if(!(void 0===e||e.bins.length<=0)){var r=e.jsonScene,a=new Set;void 0===r.compositionId&&a.add(0),r.compositions.forEach((function(e,t){(e.id===r.compositionId||o.refCompositionProps.has(e.id))&&a.add(t)})),a.forEach((function(a){r.compositions[a].items.forEach((function(r,s){if("mesh"===r.type){var c=r,l=c.content.options.skin;if(c.content.options.primitives.forEach((function(r,c){if(!(r.geometry instanceof t.Geometry)){var l="Geom_C".concat(a,"_I").concat(s,"_P").concat(c),u=n.getOrCreateGeometry(l,r.geometry,e.bins),h=r;h.geometry=u;var f,d=r.material;if(d.type===t.spec.MaterialType.pbr)(f=h.material).baseColorTexture=i.getTextureObj(o.textures,d.baseColorTexture),f.metallicRoughnessTexture=i.getTextureObj(o.textures,d.metallicRoughnessTexture),f.normalTexture=i.getTextureObj(o.textures,d.normalTexture),f.occlusionTexture=i.getTextureObj(o.textures,d.occlusionTexture),f.emissiveTexture=i.getTextureObj(o.textures,d.emissiveTexture);else(f=h.material).baseColorTexture=i.getTextureObj(o.textures,d.baseColorTexture)}})),void 0!==l&&void 0!==l.inverseBindMatrices){var u=l,h=V(e.bins,l.inverseBindMatrices);h instanceof Float32Array?u.inverseBindMatrices=h:console.error("setupItem3DOptions: Invalid inverseBindMatrices type, ".concat(h))}}else if("tree"===r.type){var f=r,d=r.content.options.tree.animations,p=f.content.options.tree.animations;void 0!==d&&void 0!==p&&d.forEach((function(t,n){var o=p[n];t.tracks.forEach((function(t,n){var i=V(e.bins,t.input),r=V(e.bins,t.output),a=o.tracks[n];i instanceof Float32Array?a.input=i:console.error("setupItem3DOptions: Type of inputArray should be float32, ".concat(i)),r instanceof Float32Array?a.output=r:console.error("setupItem3DOptions: Type of outputArray should be float32, ".concat(r))}))}))}else if("skybox"===r.type){var m=r,g=r.content.options,v=m.content.options,y=i.getTextureObj(o.textures,g.specularImage);void 0===y&&console.error("setupItem3DOptions: skybox specualrImage is undefined, ".concat(re.stringify(g))),v.specularImage=y;var b=i.getTextureObj(o.textures,g.diffuseImage);void 0!==b&&(v.diffuseImage=b)}}))}))}},e.createGeometry=function(e,n,o){var i=function(e,t){var n,o,i=e.attributes,a=r({},e);return a.indices?(a.indices=r({},a.indices),a.indices.data&&(a.indices.data=V(t,null===(n=e.indices)||void 0===n?void 0:n.data))):a.index&&(a.indices=r({},a.index),a.indices.data&&(a.indices.data=V(t,null===(o=e.index)||void 0===o?void 0:o.data))),Object.keys(i).forEach((function(e){var n=i[e],o=n.data;a.attributes[e]=r({},n),o&&(a.attributes[e].data=V(t,o))})),a}(n,o),a={};for(var s in i.attributes){var c=i.attributes[s];a[this.getAttributeName(s)]=c}return i.attributes=a,t.Geometry.create(e,i)},e.getIndexArray=function(e,t){switch(e){case WebGLRenderingContext.UNSIGNED_INT:case WebGLRenderingContext.UNSIGNED_SHORT:case WebGLRenderingContext.UNSIGNED_BYTE:return t;default:console.error("Invalid index attribute type ".concat(e))}},e.getAttributeName=function(e){switch(e){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 e.startsWith("a_")||console.warn("Unknown attribute name: ".concat(e)),e},e.getTextureObj=function(e,t){return"number"!=typeof t?t:((t<0||t>=e.length)&&console.error("Invalid index for textures: ".concat(t,", ").concat(e.length)),e[t])},e}(),ee=function(){function e(){}return e.getImageFileName=function(e,t){var n=e.lastIndexOf("/"),o=e.lastIndexOf("."),i=e.substring(n+1,o);return t?i+t:i},e.getCurrnetTimeStr=function(){var e=new Date(Date.now()),t=e.toLocaleString("zh-CN"),n="".concat(e.getMilliseconds());return t.split(/[ /:]+/).join("")+n.padStart(3,"0")},e.saveFileForURL=function(e,t){var n=document.createElement("a");n.setAttribute("download",t),n.target="_blank",n.href=e,n.click()},e.createPlayer=function(e){void 0===e&&(e=!0);var n=document.createElement("canvas");return n.width=512,n.height=512,new t.Player({canvas:n,renderFramework:"webgl2",env:t.PLAYER_OPTIONS_ENV_EDITOR,willCaptureImage:!0,manualRender:e})},e.sleep=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},e.loadImageFromGLTFImage=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,t.loadImage(new Blob([e.imageData],{type:e.mimeType}))]}))}))},e.loadImageFromImageData=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(n){return[2,t.loadImage(new Blob([e.data],{type:e.mimeType}))]}))}))},e.getCanvasArrayBuffer=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(t){return[2,new Promise((function(t,n){e.toBlob((function(e){e?t(e.arrayBuffer()):n(Error("no canvas blob"))}),"image/png",1)}))]}))}))},e.getImageArrayBuffer=function(e){return a(this,void 0,void 0,(function(){var t;return s(this,(function(n){return(t=document.createElement("canvas")).width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0),[2,this.getCanvasArrayBuffer(t)]}))}))},e.getCanvasImageData=function(e){return e.getContext("2d").getImageData(0,0,e.width,e.height)},e.flipImageData=function(e){var t=document.createElement("canvas"),n=t.getContext("2d");return t.width=e.width,t.height=e.height,n.putImageData(e,0,0),n.globalCompositeOperation="copy",n.scale(1,-1),n.translate(0,-e.height),n.drawImage(t,0,0),n.setTransform(1,0,0,1,0,0),n.globalCompositeOperation="source-over",n.getImageData(0,0,t.width,t.height)},e.getImageData=function(e){var t=document.createElement("canvas");t.width=e.width,t.height=e.height;var n=t.getContext("2d");return n.drawImage(e,0,0),this.flipImageData(n.getImageData(0,0,t.width,t.height))},e.getWebGLCanvasImageBuffer=function(e){var t=e.getContext("webgl2"),n=new Uint8Array(e.width*e.height*4);return t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,n),n},e}(),te=function(){function e(){this.component=0,this.length=0,this.offset=0,this.stride=0,this.typeSize=0}return e.prototype.getBoundingBox=function(e){for(var t=this.offset,n=new v;t+this.component<=this.length;)2==this.component?n.set(this.data[t],this.data[t+1],0):n.set(this.data[t],this.data[t+1],this.data[t+2]),e.expandByPoint(n),t+=this.stride;return e},e}(),ne=function(){function e(){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 e.prototype.create=function(e,t){var n,o;switch(e.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=t,this.length=this.data.length,this.compCount=e.size,this.offset=null!==(n=e.offset)&&void 0!==n?n: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!==(o=e.stride)&&void 0!==o?o: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===e.normalize},e.prototype.getData=function(e){var t=this.offset;if(!((t+=e*this.stride)+this.compCount>this.length)){var n;if(n=2===this.compCount?[this.data[t],this.data[t+1],0,0]:3===this.compCount?[this.data[t],this.data[t+1],this.data[t+2],0]:[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]],this.compressed)for(var o=0;o<this.compCount;o++)n[o]*=this.compressScale,this.signed&&(n[o]=Math.max(n[o],-1));return n}},e.prototype.getLength=function(){return Math.round((this.length-this.offset)/this.stride)},e}(),oe=function(){function e(){this.drawStart=0,this.drawCount=0,this.bindMatrices=[]}return e.prototype.create=function(e,t){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var n=e.attributes;this.index=e.getIndexData();var o=n.a_Position,i=e.getAttributeData("a_Position");this.position=new ne,this.position.create(o,i);var r=n.a_Joint1,a=n.a_Weight1;if(void 0!==r&&void 0!==a){var s=e.getAttributeData("a_Joint1"),c=e.getAttributeData("a_Weight1");this.joint=new ne,this.joint.create(r,s),this.weight=new ne,this.weight.create(a,c)}this.bindMatrices=t},e.prototype.getBoundingBox=function(e){var t=this;e.makeEmpty();var n=new T,o=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0,i=new Set;if(void 0!==this.index)for(var r=0;r<this.drawCount;r++){var a=this.drawStart+r;a<this.index.length&&i.add(this.index[a])}else for(r=0;r<this.drawCount;r++)i.add(this.drawStart+r);return i.forEach((function(i){var r,a,s=t.position.getData(i);if(void 0!==s){var c=v.fromArray(s);if(o){var l=null===(r=t.joint)||void 0===r?void 0:r.getData(i),u=null===(a=t.weight)||void 0===a?void 0:a.getData(i);if(void 0!==l&&void 0!==u){n.setZero();for(var h=!1,f=0;f<4;f++)if(0!==u[f]){if(l[f]<0||l[f]>=t.bindMatrices.length){h=!0;break}var d=t.bindMatrices[l[f]];n.addScaledMatrix(d,u[f])}if(!h){var p=n.transformVector4(new y(c.x,c.y,c.z,1));Math.abs(p.w)>1e-4&&(p.multiply(1/p.w),c.set(p.x,p.y,p.z))}}}e.expandByPoint(c)}})),e},e}(),ie=function(){function e(){this.drawStart=0,this.drawCount=0,this.doubleSided=!1,this.bindMatrices=[],this.hasAnimation=!1,this.skinMatrix=new T}return e.prototype.create=function(e,t,n){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var o=e.attributes;this.index=e.getIndexData();var i=o.a_Position,r=e.getAttributeData("a_Position");this.position=new ne,this.position.create(i,r);var a=o.a_Joint1,s=o.a_Weight1;if(void 0!==a&&void 0!==s){var c=e.getAttributeData("a_Joint1"),l=e.getAttributeData("a_Weight1");this.joint=new ne,this.joint.create(a,c),this.weight=new ne,this.weight.create(s,l)}this.doubleSided=t,this.bindMatrices=n,this.hasAnimation=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0},e.prototype.getHitPoint=function(e,t){for(var n,o=new v,i=new v,r=new v,a=new y,s=new y,c=new y,l=!this.doubleSided,u=0;u+2<this.drawCount;u+=3){var h=this.drawStart+u,f=this.drawStart+u+1,d=this.drawStart+u+2;void 0!==this.index&&(h=this.index[h],f=this.index[f],d=this.index[d]);var p=this.getPosition(h,o,a),m=this.getPosition(f,i,s),g=this.getPosition(d,r,c);if(void 0!==p&&void 0!==m&&void 0!==g){var b=J(e,t,p,m,g,l);void 0!==b&&(void 0===n||n>b)&&(n=b)}}return n},e.prototype.getPosition=function(e,t,n){var o,i,r=this.position.getData(e);if(void 0!==r){if(this.hasAnimation){var a=null===(o=this.joint)||void 0===o?void 0:o.getData(e),s=null===(i=this.weight)||void 0===i?void 0:i.getData(e);if(void 0!==a&&void 0!==s){var c=this.skinMatrix;c.setZero();for(var l=0;l<4;l++)if(0!==s[l]){var u=this.bindMatrices[a[l]];c.addScaledMatrix(u,s[l])}n.set(r[0],r[1],r[2],1);var h=c.transformVector4(n),f=1/h.w;t.set(h.x*f,h.y*f,h.z*f)}}else t.set(r[0],r[1],r[2]);return t}},e}(),re=function(){function e(){}return e.checkNumber=function(e){return"number"==typeof e},e.checkNumberUndef=function(e){return void 0===e||this.checkNumber(e)},e.checkNumber01=function(e){return this.checkNumber(e)&&e>=0&&e<=1},e.checkNumber01Undef=function(e){return void 0===e||this.checkNumber01(e)},e.checkPositive=function(e){return this.checkNumber(e)&&e>0},e.checkNonnegative=function(e){return this.checkNumber(e)&&e>=0},e.checkNonnegativeUndef=function(e){return void 0===e||this.checkNonnegative(e)},e.checkBoolean=function(e){return"boolean"==typeof e},e.checkBooleanUndef=function(e){return void 0===e||this.checkBoolean(e)},e.checkString=function(e){return"string"==typeof e},e.checkStringUndef=function(e){return void 0===e||this.checkString(e)},e.checkFloat32Array=function(e){return e instanceof Float32Array},e.checkFloat32ArrayUndef=function(e){return void 0===e||this.checkFloat32Array(e)},e.checkParent=function(e){return void 0===e||!!this.checkNumber(e)&&e>=0},e.checkTexCoord=function(e){return void 0===e||!!this.checkNumber(e)&&(e>=0&&e<=1)},e.checkVec2=function(e){var t=this;return!!Array.isArray(e)&&(2==e.length&&e.every((function(e){return t.checkNumber(e)})))},e.checkVec2Undef=function(e){return void 0===e||this.checkVec2(e)},e.checkVec3=function(e){var t=this;return!!Array.isArray(e)&&(3==e.length&&e.every((function(e){return t.checkNumber(e)})))},e.checkNonnegative3=function(e){var t=this;return!!Array.isArray(e)&&(3==e.length&&e.every((function(e){return t.checkNonnegative(e)})))},e.checkVec4=function(e){var t=this;return!!Array.isArray(e)&&(4==e.length&&e.every((function(e){return t.checkNumber(e)})))},e.checkNonnegative4=function(e){var t=this;return!!Array.isArray(e)&&(4==e.length&&e.every((function(e){return t.checkNonnegative(e)})))},e.checkNumberArray=function(e){var t=this;return!!Array.isArray(e)&&e.every((function(e){return t.checkNumber(e)}))},e.checkTexture=function(e){return e instanceof t.Texture&&(e.isDestroyed&&console.error("Texture is destroyed, ".concat(e.name)),!e.isDestroyed)},e.checkTextureUndef=function(e){return void 0===e||this.checkTexture(e)},e.checkTexTransform=function(e){return!!this.checkVec2Undef(e.offset)&&(!!this.checkNumberUndef(e.rotation)&&(!!this.checkVec2Undef(e.scale)&&(void 0===e.scale||!(Math.abs(e.scale[0])<1e-5||Math.abs(e.scale[1])<1e-5))))},e.checkTexTransformUndef=function(e){return void 0===e||this.checkTexTransform(e)},e.checkMatBlending=function(e){return void 0===e||e===t.spec.MaterialBlending.opaque||e===t.spec.MaterialBlending.masked||e===t.spec.MaterialBlending.translucent||e===t.spec.MaterialBlending.additive},e.checkMatSide=function(e){return void 0===e||e===t.spec.SideMode.BACK||e===t.spec.SideMode.DOUBLE||e===t.spec.SideMode.FRONT},e.checkAnimPath=function(e){return"translation"===e||"rotation"===e||"scale"===e||"weights"===e},e.checkAnimInterp=function(e){return"LINEAR"===e||"STEP"===e||"CUBICSPLINE"===e},e.assertGeometry=function(e,n){e instanceof t.Geometry||console.error("Invalid geometry type ".concat(this.stringify(e))),!0===e.isDestroyed&&console.error("Geometry object is destroyed"),this.checkNonnegative(e.getDrawStart())||console.error("Invalid geometry draw start: ".concat(e.getDrawStart(),", ").concat(this.stringify(e)))},e.assertGeometryBuffer=function(e,t,n){var o=this.createAttributeArray(e,t);void 0!==o&&o.getLength()<n&&console.error("".concat(t," Length(").concat(o.getLength(),") is less than draw count(").concat(n,"), ").concat(this.stringify(e)))},e.createAttributeArray=function(e,t){var n=e.attributes;if(void 0!==n){var o=n[t];if(void 0!==o){var i=e.getAttributeData(t);if(void 0!==i){var r=new ne;return r.create(o,i),r}}}},e.assertModelSkinOptions=function(e){if(this.checkStringUndef(e.name)||console.error("Invalid skin name ".concat(e.name,", ").concat(this.stringify(e))),this.checkNumberArray(e.joints)||console.error("Invalid skin joints ".concat(e.joints,", ").concat(this.stringify(e))),this.checkNumberUndef(e.skeleton)||console.error("Invalid skin skeleton ".concat(e.skeleton,", ").concat(this.stringify(e))),this.checkFloat32ArrayUndef(e.inverseBindMatrices)||console.error("Invalid skin inverseBindMatrices ".concat(e.inverseBindMatrices,", ").concat(this.stringify(e))),void 0!==e.inverseBindMatrices){(e.inverseBindMatrices.length<=0||e.inverseBindMatrices.length%16!=0)&&console.error("Invalid skin inverseBindMatrices length ".concat(e.inverseBindMatrices,", ").concat(this.stringify(e))),16*e.joints.length!==e.inverseBindMatrices.length&&console.error("Mismatch: skin joints and inverseBindMatrices length, ".concat(e.joints,", ").concat(e.inverseBindMatrices,", ").concat(this.stringify(e)));for(var t=new T,n=0;n<e.inverseBindMatrices.length;n+=16){for(var o=0;o<16;o++)t.elements[o]=e.inverseBindMatrices[n+o];Math.abs(t.determinant())<1e-5&&console.error("Determinant of inverseBindMatrices is too small ".concat(t.determinant(),", index ").concat(n/16,", ").concat(this.stringify(e)))}}else e.joints.length<=0&&console.error("Invalid skin joints length ".concat(e.joints,", ").concat(this.stringify(e)))},e.assertMatOptions=function(e){e.type===t.spec.MaterialType.unlit?(this.checkString(e.name)||console.error("Invalid material name ".concat(e.name,", ").concat(this.stringify(e))),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor ".concat(e.baseColorFactor,", ").concat(this.stringify(e))),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture ".concat(e.baseColorTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform ".concat(e.baseColorTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate ".concat(e.baseColorTextureCoordinate,", ").concat(this.stringify(e))),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask ".concat(e.depthMask,", ").concat(this.stringify(e))),this.checkMatBlending(e.blending)||console.error("Invalid material blending ".concat(e.blending,", ").concat(this.stringify(e))),this.checkMatSide(e.side)||console.error("Invalid material side ".concat(e.side,", ").concat(this.stringify(e))),e.blending===t.spec.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, ".concat(this.stringify(e))),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff ".concat(e.alphaCutOff,", ").concat(this.stringify(e)))):e.type===t.spec.MaterialType.pbr?(this.checkString(e.name)||console.error("Invalid material name ".concat(e.name,", ").concat(this.stringify(e))),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor ".concat(e.baseColorFactor,", ").concat(this.stringify(e))),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture ".concat(e.baseColorTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform ".concat(e.baseColorTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate ".concat(e.baseColorTextureCoordinate,", ").concat(this.stringify(e))),this.checkBooleanUndef(e.useSpecularAA)||console.error("Invalid material useSpecularAA ".concat(e.useSpecularAA,", ").concat(this.stringify(e))),this.checkNumber01(e.metallicFactor)||console.error("Invalid material metallicFactor ".concat(e.metallicFactor,", ").concat(this.stringify(e))),this.checkNonnegative(e.roughnessFactor)||console.error("Invalid material roughnessFactor ".concat(e.roughnessFactor,", ").concat(this.stringify(e))),this.checkTextureUndef(e.metallicRoughnessTexture)||console.error("Invalid material metallicRoughnessTexture ".concat(e.metallicRoughnessTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.metallicRoughnessTextureTransform)||console.error("Invalid material metallicRoughnessTextureTransform ".concat(e.metallicRoughnessTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.metallicRoughnessTextureCoordinate)||console.error("Invalid material metallicRoughnessTextureCoordinate ".concat(e.metallicRoughnessTextureCoordinate,", ").concat(this.stringify(e))),this.checkTextureUndef(e.normalTexture)||console.error("Invalid material normalTexture ".concat(e.normalTexture,", ").concat(this.stringify(e))),this.checkNonnegativeUndef(e.normalTextureScale)||console.error("Invalid material normalTextureScale ".concat(e.normalTextureScale,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.normalTextureTransform)||console.error("Invalid material normalTextureTransform ".concat(e.normalTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.normalTextureCoordinate)||console.error("Invalid material normalTextureCoordinate ".concat(e.normalTextureCoordinate,", ").concat(this.stringify(e))),this.checkTextureUndef(e.occlusionTexture)||console.error("Invalid material occlusionTexture ".concat(e.occlusionTexture,", ").concat(this.stringify(e))),this.checkNumber01Undef(e.occlusionTextureStrength)||console.error("Invalid material occlusionTextureStrength ".concat(e.occlusionTextureStrength,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.occlusionTextureTransform)||console.error("Invalid material occlusionTextureTransform ".concat(e.occlusionTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.occlusionTextureCoordinate)||console.error("Invalid material occlusionTextureCoordinate ".concat(e.occlusionTextureCoordinate,", ").concat(this.stringify(e))),this.checkNonnegative4(e.emissiveFactor)||console.error("Invalid material emissiveFactor ".concat(e.emissiveFactor,", ").concat(this.stringify(e))),this.checkNonnegative(e.emissiveIntensity)||console.error("Invalid material emissiveIntensity ".concat(e.emissiveIntensity,", ").concat(this.stringify(e))),this.checkTextureUndef(e.emissiveTexture)||console.error("Invalid material emissiveTexture ".concat(e.emissiveTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.emissiveTextureTransform)||console.error("Invalid material emissiveTextureTransform ".concat(e.emissiveTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.emissiveTextureCoordinate)||console.error("Invalid material emissiveTextureCoordinate ".concat(e.emissiveTextureCoordinate,", ").concat(this.stringify(e))),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask ".concat(e.depthMask,", ").concat(this.stringify(e))),this.checkMatBlending(e.blending)||console.error("Invalid material blending ".concat(e.blending,", ").concat(this.stringify(e))),this.checkMatSide(e.side)||console.error("Invalid material side ".concat(e.side,", ").concat(this.stringify(e))),e.blending===t.spec.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, ".concat(this.stringify(e))),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff ".concat(e.alphaCutOff,", ").concat(this.stringify(e)))):console.error("Invalid material type ".concat(this.stringify(e)))},e.assertPrimOptions=function(e,t){return this.assertGeometry(e.geometry,t),this.assertMatOptions(e.material),!0},e.assertModelMeshOptions=function(e){this.checkParent(e.parent)||console.error("Invalid mesh parent ".concat(e.parent,", ").concat(this.stringify(e))),void 0!==e.skin&&this.assertModelSkinOptions(e.skin);for(var t=[],n=0;n<e.primitives.length;n++){var o=e.primitives[n];this.assertPrimOptions(o)||console.error("Invalid primitive ".concat(o,", ").concat(this.stringify(e)));var i=new he;i.create(o.geometry),t.push(i)}for(n=1;n<t.length;n++){var r=t[n-1],a=t[n];r.equals(a)||console.error("Morph states mismatch: ".concat(this.stringify(r),", ").concat(this.stringify(a),", ").concat(this.stringify(e)))}this.checkBooleanUndef(e.hide)||console.error("Invalid mesh hide ".concat(e.hide,", ").concat(this.stringify(e)))},e.assertModelCameraOptions=function(e){this.checkParent(e.parent)||console.error("Invalid camera parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNumberUndef(e.aspect)||console.error("Invalid camera aspect ".concat(e.aspect,", ").concat(this.stringify(e))),this.checkPositive(e.near)||console.error("Invalid camera near ".concat(e.near,", ").concat(this.stringify(e))),(!this.checkPositive(e.far)||e.far<=e.near)&&console.error("Invalid camera far ".concat(e.far,", ").concat(this.stringify(e))),this.checkPositive(e.fov)||console.error("Invalid camera fov ".concat(e.fov,", ").concat(this.stringify(e))),this.checkNumber01(e.clipMode)||console.error("Invalid camera clipMode ".concat(e.clipMode,", ").concat(this.stringify(e)))},e.assertModelLightOptions=function(e){"directional"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e)))):"point"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e))),this.checkNonnegative(e.range)||console.error("Invalid light range ".concat(e.range,", ").concat(this.stringify(e)))):"spot"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e))),this.checkNonnegative(e.range)||console.error("Invalid light range ".concat(e.range,", ").concat(this.stringify(e))),this.checkNonnegative(e.innerConeAngle)||console.error("Invalid light innerConeAngle ".concat(e.innerConeAngle,", ").concat(this.stringify(e))),this.checkNonnegative(e.outerConeAngle)||console.error("Invalid light outerConeAngle ".concat(e.outerConeAngle,", ").concat(this.stringify(e)))):"ambient"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e)))):console.error("Invalid light type ".concat(this.stringify(e)))},e.assertModelSkyboxOptions=function(e){var t=this;this.checkBoolean(e.renderable)||console.error("Invalid skybox renderable ".concat(e.renderable,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid skybox intensity ".concat(e.intensity,", ").concat(this.stringify(e))),this.checkNonnegative(e.reflectionsIntensity)||console.error("Invalid skybox reflectionsIntensity ".concat(e.reflectionsIntensity,", ").concat(this.stringify(e)));var n=e.irradianceCoeffs;void 0!==n?(Array.isArray(n)&&9==n.length||console.error("Invalid skybox irradianceCoeffs ".concat(n,", ").concat(this.stringify(e))),n.forEach((function(e){t.checkVec3(e)||console.error("Invalid skybox irradianceCoeffs ".concat(n,", ").concat(t.stringify(e)))}))):void 0!==e.diffuseImage?this.checkTexture(e.diffuseImage)||console.error("Invalid skybox diffuseImage ".concat(e.diffuseImage,", ").concat(this.stringify(e))):console.error("Invalid skybox, irradianceCoeffs or diffuseImage should give one, ".concat(this.stringify(e))),this.checkTexture(e.specularImage)||console.error("Invalid skybox specularImage ".concat(e.specularImage,", ").concat(this.stringify(e))),this.checkPositive(e.specularImageSize)||console.error("Invalid skybox specularImageSize ".concat(e.specularImageSize,", ").concat(this.stringify(e))),this.checkPositive(e.specularMipCount)||console.error("Invalid skybox specularMipCount ".concat(e.specularMipCount,", ").concat(this.stringify(e))),this.pow2(e.specularMipCount)>e.specularImageSize&&console.error("Invalid skybox specularMipCount or specularImageSize, ".concat(this.stringify(e)))},e.checkModelAnimTrackOptions=function(e){return this.checkNonnegative(e.node)?this.checkFloat32Array(e.input)?this.checkFloat32Array(e.output)?this.checkAnimPath(e.path)?!!this.checkAnimInterp(e.interpolation)||(console.error("Invalid track interpolation ".concat(e.interpolation,", ").concat(this.stringify(e))),!1):(console.error("Invalid track path ".concat(e.path,", ").concat(this.stringify(e))),!1):(console.error("Invalid track input ".concat(e.output,", ").concat(this.stringify(e))),!1):(console.error("Invalid track input ".concat(e.input,", ").concat(this.stringify(e))),!1):(console.error("Invalid track node ".concat(e.node,", ").concat(this.stringify(e))),!1)},e.assertModelAnimOptions=function(e){var t=this;this.checkStringUndef(e.name)||console.error("Invalid animation name ".concat(e.name,", ").concat(this.stringify(e))),Array.isArray(e.tracks)||console.error("Invalid animation tracks ".concat(e.tracks,", ").concat(this.stringify(e))),e.tracks.forEach((function(n){t.checkModelAnimTrackOptions(n)||console.error("Invalid animation track ".concat(n,", ").concat(t.stringify(e)))}))},e.assertTreeOptions=function(e){var t=this;this.checkNumberUndef(e.animation)||console.error("Invalid tree animation ".concat(e.animation,", ").concat(this.stringify(e))),void 0!==e.animations&&(Array.isArray(e.animations)||console.error("Invalid tree animations ".concat(e.animations,", ").concat(this.stringify(e))),e.animations.forEach((function(e){t.assertModelAnimOptions(e)})),void 0!==e.animation&&(e.animation<-1||e.animation>=e.animations.length)&&console.error("Invalid tree animations ".concat(e.animations,", ").concat(this.stringify(e))))},e.stringify=function(e){var n={};for(var o in e)"internal"!==o&&"function"!=typeof e[o]&&(e[o]instanceof t.Texture||e[o]instanceof t.Geometry?n[o]=e[o].name:e[o]instanceof t.Renderer||(n[o]=e[o]));return JSON.stringify(n)},e.pow2=function(e){for(var t=1;e-- >0;)t*=2;return t},e}(),ae=function(){function e(e){this.size=e,this.data=new Uint16Array(e)}return e.prototype.set=function(e,t){for(var n=0;n<e.length;n++)this.data[n+t]=se(e[n])},Object.defineProperty(e.prototype,"bytes",{get:function(){return 2*this.size},enumerable:!1,configurable:!0}),e}(),se=(Y=new Float32Array(1),q=new Int32Array(Y.buffer),function(e){Y[0]=e;var t=q[0],n=t>>16&32768,o=t>>12&2047,i=t>>23&255;return i<103?n:i>142?(n|=31744,n|=(255==i?0:1)&&8388607&t):i<113?n|=((o|=2048)>>114-i)+(o>>113-i&1):(n|=i-112<<10|o>>1,n+=1&o)});e.TextureDataMode=void 0,(K=e.TextureDataMode||(e.TextureDataMode={}))[K.none=0]="none",K[K.float=1]="float",K[K.half_float=2]="half_float";var ce,le,ue=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.skeleton=0,n.jointList=[],n.inverseBindMatrices=[],n.animationMatrices=[],n.textureDataMode=e.TextureDataMode.none,n}return i(n,t),n.prototype.create=function(t,n,o){var i,r;this.name=this.genName(null!==(i=t.name)&&void 0!==i?i:"Unnamed skin"),this.type=e.PObjectType.skin,this.parentItem=o,this.skeleton=null!==(r=t.skeleton)&&void 0!==r?r:-1,this.jointList=t.joints,this.animationMatrices=[],this.inverseBindMatrices=[],this.textureDataMode=this.getTextureDataMode(this.getJointCount(),n);var a=t.inverseBindMatrices;if(void 0!==a&&a.length>0){if(a.length%16!=0||a.length!==16*this.jointList.length)throw new Error("Invalid array length, invert bind matrices ".concat(a.length,", joint array ").concat(this.jointList.length));for(var s=a.length/16,c=0;c<s;c++){var l=T.fromArray(a,16*c);this.inverseBindMatrices.push(l)}}},n.prototype.updateSkinMatrices=function(){var e=this;if(this.animationMatrices=[],void 0!==this.parentItem)for(var t=this.parentItem.content,n=0;n<this.jointList.length;n++){var o=this.jointList[n],i=t.getNodeById(o);if(void 0===i){console.error("Can't find joint ".concat(o," in node tree ").concat(this.parentItem,"."));break}var r=i.transform.getWorldMatrix();this.animationMatrices.push(r.clone())}this.animationMatrices.length===this.inverseBindMatrices.length?this.animationMatrices.forEach((function(t,n){t.multiply(e.inverseBindMatrices[n])})):(this.animationMatrices=this.inverseBindMatrices,console.error("Some error occured, replace skin animation matrices by invert bind matrices"))},n.prototype.computeMeshAnimMatrices=function(e,t,n){var o=e.clone().invert(),i=new T;this.animationMatrices.forEach((function(e,r){var a=i.multiplyMatrices(o,e);a.elements.forEach((function(e,n){return t[16*r+n]=e})),a.clone().invert().transpose().elements.forEach((function(e,t){return n[16*r+t]=e}))}))},n.prototype.updateParentItem=function(e){this.parentItem=e},n.prototype.getJointCount=function(){return this.jointList.length},n.prototype.isTextureDataMode=function(){return this.textureDataMode!==e.TextureDataMode.none},n.prototype.dispose=function(){this.parentItem=void 0,this.jointList=[],this.inverseBindMatrices=[],this.animationMatrices=[]},n.prototype.getTextureDataMode=function(t,n){var o=n.gpuCapability.detail,i=o.maxVertexUniforms-25;if(t>Math.floor(i/8)){if(o.floatTexture)return e.TextureDataMode.float;if(o.halfFloatTexture)return e.TextureDataMode.half_float;throw new Error("Too many joint count ".concat(t,", half float texture not support"))}return e.TextureDataMode.none},n}(U),he=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.morphWeightsLength=0,e.hasPositionMorph=!1,e.hasNormalMorph=!1,e.hasTangentMorph=!1,e}return i(n,t),n.prototype.create=function(t){var o=this;this.name=this.genName("Morph target"),this.type=e.PObjectType.morph;var i=this.getAttributeMorphCount(n.positionNameList,t),r=this.getAttributeMorphCount(n.normalNameList,t),a=this.getAttributeMorphCount(n.tangentNameList,t),s=[i,r,a];return this.morphWeightsLength=0,s.forEach((function(e){e>0&&(0===o.morphWeightsLength?o.morphWeightsLength=e:o.morphWeightsLength=Math.min(o.morphWeightsLength,e))})),this.morphWeightsLength>0&&(this.morphWeightsArray=new Float32Array(this.morphWeightsLength),this.hasPositionMorph=i==this.morphWeightsLength,this.hasNormalMorph=r==this.morphWeightsLength,this.hasTangentMorph=a==this.morphWeightsLength),i>0&&i!=this.morphWeightsLength?(console.error("Position morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(i)),!1):r>0&&r!=this.morphWeightsLength?(console.error("Normal morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(r)),!1):a>0&&a!=this.morphWeightsLength?(console.error("Tangent morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(a)),!1):!(this.morphWeightsLength>5)||(console.error("Tangent morph count should not greater than 5, current ".concat(this.morphWeightsLength)),!1)},n.prototype.dispose=function(){this.morphWeightsArray=void 0},n.prototype.initWeights=function(e){if(void 0!==this.morphWeightsArray){var t=this.morphWeightsArray;e.forEach((function(e,n){n<t.length&&(t[n]=e)}))}},n.prototype.hasMorph=function(){return this.morphWeightsLength>0&&(this.hasPositionMorph||this.hasNormalMorph||this.hasTangentMorph)},n.prototype.equals=function(e){return this.morphWeightsLength===e.morphWeightsLength&&this.hasPositionMorph===e.hasPositionMorph&&this.hasNormalMorph===e.hasNormalMorph&&this.hasTangentMorph===e.hasTangentMorph},n.prototype.getMorphWeightsArray=function(){return this.morphWeightsArray},n.prototype.getAttributeMorphCount=function(e,t){for(var n=0;n<e.length;n++){var o=e[n];if(void 0===t.getAttributeData(o))return n}return e.length},n.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"],n.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"],n.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"],n}(U);e.PAnimInterpType=void 0,(ce=e.PAnimInterpType||(e.PAnimInterpType={}))[ce.linear=0]="linear",ce[ce.step=1]="step",ce[ce.cubicSpline=2]="cubicSpline",e.PAnimPathType=void 0,(le=e.PAnimPathType||(e.PAnimPathType={}))[le.translation=0]="translation",le[le.rotation=1]="rotation",le[le.scale=2]="scale",le[le.weights=3]="weights";var fe,de=function(){function t(t){this.path=e.PAnimPathType.translation,this.interp=e.PAnimInterpType.linear;var n=t.node,o=t.input,i=t.output,r=t.path,a=t.interpolation;if(this.node=n,this.timeArray=o,this.dataArray=i,"translation"===r?(this.path=e.PAnimPathType.translation,this.component=3):"rotation"===r?(this.path=e.PAnimPathType.rotation,this.component=4):"scale"===r?(this.path=e.PAnimPathType.scale,this.component=3):"weights"===r?(this.path=e.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(r)),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"===a?e.PAnimInterpType.linear:"STEP"===a?e.PAnimInterpType.step:e.PAnimInterpType.cubicSpline,this.sampler=m(this.getInterpInfo(),this.timeArray,this.dataArray,this.component,this.getPathInfo())}return t.prototype.dispose=function(){var e;this.timeArray=void 0,this.dataArray=void 0,null===(e=this.sampler)||void 0===e||e.dispose(),this.sampler=void 0},t.prototype.tick=function(t,n,o){var i=n.content.getNodeById(this.node);if(void 0!==this.sampler&&void 0!==i){var r=this.sampler.evaluate(t);switch(this.path){case e.PAnimPathType.translation:i.transform.setPosition(r[0],r[1],r[2]);break;case e.PAnimPathType.rotation:i.transform.setQuaternion(r[0],r[1],r[2],r[3]);break;case e.PAnimPathType.scale:i.transform.setScale(r[0],r[1],r[2]);break;case e.PAnimPathType.weights:var a=this.genParentId(n.id,this.node),s=null==o?void 0:o.queryMesh(a);void 0!==s&&s.updateMorphWeights(r)}}else void 0!==this.sampler&&console.error("AnimTrack: error",this.sampler,i)},t.prototype.getEndTime=function(){var e=this.timeArray.length-1;return this.timeArray[e]},t.prototype.genParentId=function(e,t){return"".concat(e,"^").concat(t)},t.prototype.getPathInfo=function(){return this.path===e.PAnimPathType.scale?"scale":this.path===e.PAnimPathType.rotation?"rotation":"translation"},t.prototype.getInterpInfo=function(){return this.interp===e.PAnimInterpType.cubicSpline?"CUBICSPLINE":this.interp===e.PAnimInterpType.step?"STEP":"LINEAR"},t}(),pe=function(){function e(e){this.engine=e,this.isHalfFloat=!0,this.width=0,this.height=0}return e.prototype.create=function(e,n,o){var i,r;this.width=4,this.height=e,this.isHalfFloat=n,this.isHalfFloat&&(this.buffer=new ae(4*this.getSize()));var a=null!==(r=null===(i=this.buffer)||void 0===i?void 0:i.data)&&void 0!==r?r:new Float32Array(4*this.getSize()),s=this.isHalfFloat?t.glContext.HALF_FLOAT:t.glContext.FLOAT;this.texture=t.Texture.create(this.engine,{name:o,data:{width:this.width,height:this.height,data:a},target:t.glContext.TEXTURE_2D,format:t.glContext.RGBA,type:s,wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,minFilter:t.glContext.NEAREST,magFilter:t.glContext.NEAREST})},e.prototype.update=function(e){var n,o;void 0!==this.buffer&&this.buffer.set(e,0),void 0!==this.texture&&this.texture.updateSource({sourceType:t.TextureSourceType.data,data:{width:this.width,height:this.height,data:null!==(o=null===(n=this.buffer)||void 0===n?void 0:n.data)&&void 0!==o?o:e},target:t.glContext.TEXTURE_2D})},e.prototype.dispose=function(){var e;this.engine=null,this.buffer=void 0,null===(e=this.texture)||void 0===e||e.dispose()},e.prototype.getSize=function(){return this.width*this.height},e.prototype.getTexture=function(){return this.texture},e}(),me=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.time=0,e.duration=0,e.tracks=[],e}return i(n,t),n.prototype.create=function(t){var n,o=this;this.name=this.genName(null!==(n=t.name)&&void 0!==n?n:"Unnamed animation"),this.type=e.PObjectType.animation,this.time=0,this.duration=0,this.tracks=[],t.tracks.forEach((function(e){var t=new de(e);o.tracks.push(t),o.duration=Math.max(o.duration,t.getEndTime())}))},n.prototype.tick=function(e,t,n){this.time=e;var o=this.time%this.duration;this.tracks.forEach((function(e){e.tick(o,t,n)}))},n.prototype.dispose=function(){this.tracks.forEach((function(e){e.dispose()})),this.tracks=[]},n}(U),ge=function(t){function n(n,o){var i,r,a,s=t.call(this)||this;s.animation=0,s.speed=0,s.delay=0,s.time=0,s.animations=[],s.name=s.genName(null!==(i=o.name)&&void 0!==i?i:"Unnamed tree"),s.type=e.PObjectType.animationManager,s.ownerItem=o,s.animation=null!==(r=n.animation)&&void 0!==r?r:-1,s.speed=1,s.delay=null!==(a=o.delay)&&void 0!==a?a:0,s.animations=[],void 0!==n.animations&&n.animations.forEach((function(e){var t=s.createAnimation(e);s.animations.push(t)}));var c=o.composition;return null!=c&&(s.sceneManager=c.loaderData.sceneManager),s}return i(n,t),n.prototype.createAnimation=function(e){var t=new me;return t.create(e),t},n.prototype.tick=function(e){var t=this,n=e*this.speed*.001;this.time+=n;var o=this.time-this.delay;o>=0&&(this.animation>=0&&this.animation<this.animations.length?this.animations[this.animation].tick(o,this.ownerItem,this.sceneManager):-88888888==this.animation&&this.animations.forEach((function(e){e.tick(o,t.ownerItem,t.sceneManager)})))},n.prototype.dispose=function(){this.ownerItem=null,this.animations.forEach((function(e){e.dispose()})),this.animations=[],this.sceneManager=null},n.prototype.getTreeItem=function(){return this.ownerItem},n}(U),ve=function(){function e(e){this.engine=e,this.managers=[]}return e.prototype.create=function(e){var t=this;this.managers=[],e.forEach((function(e){var n=new ge(e.options,e);t.managers.push(n)}))},e.prototype.insert=function(e){this.managers.push(e)},e.prototype.delete=function(e){var t=-1;this.managers.forEach((function(n,o){n===e&&(t=o)})),t>=0&&this.managers.splice(t,1)},e.prototype.dispose=function(){this.managers.forEach((function(e){e.dispose()})),this.managers=[]},e}(),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;\n#ifdef HAS_UV_SET2\nfsIn vec2 v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_NormalUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_EmissiveUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_OcclusionUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_BaseColorUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_MetallicRoughnessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_SpecularGlossinessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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\n#ifdef HAS_UV_SET2\nuv.xy=u_DiffuseUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\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(e){e.build=function(e,t,n){for(var o;null!==(o=/#include <(.+)>/gm.exec(e));)e=e.replace(o[0],ye[o[1]]);return e=e.replace(/#define FEATURES/,t.map((function(e){return"#define ".concat(e)})).join("\n")),n?"#version 300 es\n"+e:"#version 100\n"+e}}(fe||(fe={}));var be=function(){function t(){}return t.getVertexShaderCode=function(t){var n=t.isWebGL2,o=t.featureList,i=t.material.materialType;switch(i){case e.PMaterialType.unlit:case e.PMaterialType.pbr:case e.PMaterialType.shadowBase:return fe.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;\n#ifdef HAS_UV_SET2\nvsOut vec2 v_UVCoord2;\n#endif\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);\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}",o,n);case e.PMaterialType.skyboxFilter:return fe.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);}",o,n);default:throw new Error("Invalid material type ".concat(i," for getVertexShaderString!"))}},t.getFragmentShaderCode=function(t){var n=t.isWebGL2,o=t.featureList,i=t.material.materialType;switch(i){case e.PMaterialType.unlit:case e.PMaterialType.pbr:return fe.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}",o,n);case e.PMaterialType.shadowBase:return fe.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}",o,n);case e.PMaterialType.skyboxFilter:return fe.build("\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\nprecision highp float;\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);}",o,n);default:throw new Error("Invalid material type ".concat(i," for getFragmentShaderString!"))}},t.environment="webgl1",t}();function Te(e){return{vertexShaderCode:be.getVertexShaderCode(e),fragmentShaderCode:be.getFragmentShaderCode(e)}}function _e(e){return{vertexShaderCode:be.getVertexShaderCode(e),fragmentShaderCode:be.getFragmentShaderCode(e)}}function xe(e){return{vertexShaderCode:be.getVertexShaderCode(e),fragmentShaderCode:be.getFragmentShaderCode(e)}}function Se(e){return{vertexShaderCode:Ae({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 Me(e){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(e){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 Ae(e){void 0===e&&(e={});var t=["#version 100"];return e.hasUVs&&t.push("#define HAS_UVS 1"),e.hasNormals&&t.push("#define HAS_NORMALS 1"),t.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 "),t.join("\n")}var Ie=function(){function t(){this.funcMap=new Map,this.funcMap.set(e.PMaterialType.unlit,Te),this.funcMap.set(e.PMaterialType.pbr,Te),this.funcMap.set(e.PMaterialType.shadowBase,_e),this.funcMap.set(e.PMaterialType.shadowFilter,Ce),this.funcMap.set(e.PMaterialType.normalVis,Se),this.funcMap.set(e.PMaterialType.simpleFilter,Me),this.funcMap.set(e.PMaterialType.skyboxFilter,xe)}return t.getInstance=function(){return this._instance||(this._instance=new this)},t.prototype.genShaderCode=function(e){var t=e.material.materialType,n=this.funcMap.get(t);if(void 0!==n)return n(e);throw new Error("Invalid material type ".concat(t,", shader content ").concat(e))},t}(),Ee=function(n){function o(){var t=null!==n&&n.apply(this,arguments)||this;return t.materialType=e.PMaterialType.none,t.vertexShaderCode="",t.fragmentShaderCode="",t.depthMask=!0,t.depthTestHint=!0,t.blendMode=e.PBlendMode.opaque,t.alphaCutOff=.5,t.faceSideMode=e.PFaceSideMode.front,t}return i(o,n),o.prototype.getShaderFeatures=function(){var t=[];return this.isOpaque()?t.push("ALPHAMODE_OPAQUE 1"):this.isMasked()&&t.push("ALPHAMODE_MASK 1"),this.faceSideMode===e.PFaceSideMode.both&&t.push("DOUBLE_SIDED 1"),t},o.prototype.updateUniforms=function(e){if(this.isMasked()&&e.setFloat("u_AlphaCutoff",this.alphaCutOff),R.getInstance().renderMode3D===t.spec.RenderMode3D.uv){var n=R.getInstance().renderMode3DUVGridSize;e.setFloat("u_DebugUVGridSize",n)}},o.prototype.build=function(t){var n=this.getShaderFeatures();void 0!==t&&n.push.apply(n,l([],c(t),!1));var o=R.getInstance().isWebGL2;(o&&n.push("WEBGL2"),this.materialType!==e.PMaterialType.shadowBase)&&(R.getInstance().isEditorEnv&&n.push("EDITOR_TRANSFORM"));var i=Ie.getInstance().genShaderCode({material:this,isWebGL2:o,featureList:n});this.vertexShaderCode=i.vertexShaderCode,this.fragmentShaderCode=i.fragmentShaderCode},o.prototype.getBlendMode=function(n){return n===t.spec.MaterialBlending.masked?e.PBlendMode.masked:n===t.spec.MaterialBlending.translucent?e.PBlendMode.translucent:n===t.spec.MaterialBlending.additive?e.PBlendMode.additive:e.PBlendMode.opaque},o.prototype.getFaceSideMode=function(n){return n===t.spec.SideMode.DOUBLE?e.PFaceSideMode.both:n===t.spec.SideMode.BACK?e.PFaceSideMode.back:e.PFaceSideMode.front},o.prototype.setMaterialStates=function(n){this.blendMode===e.PBlendMode.translucent||this.blendMode===e.PBlendMode.additive?(n.blending=!0,n.depthTest=!0,n.blendEquation=[t.glContext.FUNC_ADD,t.glContext.FUNC_ADD],this.blendMode===e.PBlendMode.translucent?n.blendFunction=[t.glContext.ONE,t.glContext.ONE_MINUS_SRC_ALPHA,t.glContext.ONE,t.glContext.ONE_MINUS_SRC_ALPHA]:n.blendFunction=[t.glContext.ONE,t.glContext.ONE,t.glContext.ONE,t.glContext.ONE],n.depthMask=this.depthMask):R.getInstance().isTiny3dMode?(n.blending=!1,n.depthTest=!0,n.depthMask=!0):(n.blending=!1,n.depthTest=this.depthTestHint,n.depthMask=this.depthMask),this.setFaceSideStates(n)},o.prototype.setFaceSideStates=function(e){this.isBothFace()?e.culling=!1:this.isBackFace()?(e.cullFace=t.glContext.FRONT,e.frontFace=t.glContext.CCW,e.culling=!0):(e.cullFace=t.glContext.BACK,e.frontFace=t.glContext.CCW,e.culling=!0)},o.prototype.dispose=function(){this.vertexShaderCode="",this.fragmentShaderCode=""},o.prototype.isValid=function(){return this.materialType!==e.PMaterialType.none&&n.prototype.isValid.call(this)},o.prototype.isOpaque=function(){return this.blendMode===e.PBlendMode.opaque},o.prototype.isMasked=function(){return this.blendMode===e.PBlendMode.masked},o.prototype.isTranslucent=function(){return this.blendMode===e.PBlendMode.translucent},o.prototype.isAdditive=function(){return this.blendMode===e.PBlendMode.additive},o.prototype.requireBlend=function(){return this.blendMode===e.PBlendMode.translucent||this.blendMode===e.PBlendMode.additive},o.prototype.isFrontFace=function(){return this.faceSideMode===e.PFaceSideMode.front},o.prototype.isBackFace=function(){return this.faceSideMode===e.PFaceSideMode.back},o.prototype.isBothFace=function(){return this.faceSideMode===e.PFaceSideMode.both},o}(U),Pe=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.baseColorFactor=new y(1,1,1,1),e}return i(n,t),n.prototype.create=function(t){var n;this.name=t.name,this.type=e.PObjectType.material,this.materialType=e.PMaterialType.unlit,t.baseColorTexture&&(this.baseColorTexture=t.baseColorTexture),this.setBaseColorFactor($.toPluginColor4(t.baseColorFactor)),!1===t.depthMask?this.depthMask=!1:this.depthMask=!0,this.blendMode=this.getBlendMode(t.blending),this.alphaCutOff=null!==(n=t.alphaCutOff)&&void 0!==n?n:0,this.faceSideMode=this.getFaceSideMode(t.side)},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.baseColorTexture=void 0},n.prototype.getShaderFeatures=function(){var e=t.prototype.getShaderFeatures.call(this);return e.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&e.push("HAS_BASE_COLOR_MAP 1"),e.push("MATERIAL_UNLIT 1"),e},n.prototype.updateUniforms=function(e){t.prototype.updateUniforms.call(this,e);var n=(new b).identity();e.setVector4("u_BaseColorFactor",this.baseColorFactor),this.hasBaseColorTexture()&&(e.setTexture("u_BaseColorSampler",this.getBaseColorTexture()),e.setInt("u_BaseColorUVSet",0),e.setMatrix3("u_BaseColorUVTransform",n)),e.setFloat("u_MetallicFactor",0),e.setFloat("u_RoughnessFactor",0),e.setFloat("u_Exposure",1)},n.prototype.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},n.prototype.getBaseColorTexture=function(){return this.baseColorTexture},n.prototype.setBaseColorTexture=function(e){this.baseColorTexture=e},n.prototype.getBaseColorFactor=function(){return this.baseColorFactor},n.prototype.setBaseColorFactor=function(e){e instanceof y?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},n}(Ee),we=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.baseColorFactor=new y(1,1,1,1),e.useSpecularAA=!1,e.metallicFactor=0,e.roughnessFactor=1,e.normalTextureScale=1,e.occlusionTextureStrength=1,e.emissiveFactor=new v(0,0,0),e.emissiveIntensity=1,e.enableShadow=!1,e}return i(n,t),n.prototype.create=function(t){var n,o,i,r,a;this.name=t.name,this.type=e.PObjectType.material,this.materialType=e.PMaterialType.pbr,t.baseColorTexture&&(this.baseColorTexture=t.baseColorTexture),t.baseColorTextureTransform&&(this.baseColorTextureTrans=$.createUVTransform(t.baseColorTextureTransform)),this.setBaseColorFactor($.toPluginColor4(t.baseColorFactor)),t.metallicRoughnessTexture&&(this.metallicRoughnessTexture=t.metallicRoughnessTexture),t.metallicRoughnessTextureTransform&&(this.metallicRoughnessTextureTrans=$.createUVTransform(t.metallicRoughnessTextureTransform)),this.useSpecularAA=null!==(n=t.useSpecularAA)&&void 0!==n&&n,this.metallicFactor=t.metallicFactor,this.roughnessFactor=$.clamp(t.roughnessFactor,0,1),t.normalTexture&&(this.normalTexture=t.normalTexture),t.normalTextureTransform&&(this.normalTextureTrans=$.createUVTransform(t.normalTextureTransform)),this.normalTextureScale=null!==(o=t.normalTextureScale)&&void 0!==o?o:1,t.occlusionTexture&&(this.occlusionTexture=t.occlusionTexture),t.occlusionTextureTransform&&(this.occlusionTextureTrans=$.createUVTransform(t.occlusionTextureTransform)),this.occlusionTextureStrength=null!==(i=t.occlusionTextureStrength)&&void 0!==i?i:1,t.emissiveTexture&&(this.emissiveTexture=t.emissiveTexture),t.emissiveTextureTransform&&(this.emissiveTextureTrans=$.createUVTransform(t.emissiveTextureTransform));var s=$.toPluginColor4(t.emissiveFactor);this.emissiveFactor=v.fromArray(s),this.emissiveIntensity=t.emissiveIntensity,this.enableShadow=null!==(r=t.enableShadow)&&void 0!==r&&r,!1===t.depthMask?this.depthMask=!1:this.depthMask=!0,this.blendMode=this.getBlendMode(t.blending),this.alphaCutOff=null!==(a=t.alphaCutOff)&&void 0!==a?a:0,this.faceSideMode=this.getFaceSideMode(t.side)},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.baseColorTexture=void 0,this.metallicRoughnessTexture=void 0,this.normalTexture=void 0,this.occlusionTexture=void 0,this.emissiveTexture=void 0},n.prototype.getShaderFeatures=function(){var e=t.prototype.getShaderFeatures.call(this);return e.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&(e.push("HAS_BASE_COLOR_MAP 1"),void 0!==this.baseColorTextureTrans&&e.push("HAS_BASECOLOR_UV_TRANSFORM 1")),this.hasMetallicRoughnessTexture()&&(e.push("HAS_METALLIC_ROUGHNESS_MAP 1"),void 0!==this.metallicRoughnessTextureTrans&&e.push("HAS_METALLICROUGHNESS_UV_TRANSFORM 1")),this.useSpecularAA&&e.push("USE_SPECULAR_AA 1"),this.hasNormalTexture()&&(e.push("HAS_NORMAL_MAP 1"),void 0!==this.normalTextureTrans&&e.push("HAS_NORMAL_UV_TRANSFORM 1")),this.hasOcclusionTexture()&&(e.push("HAS_OCCLUSION_MAP 1"),void 0!==this.occlusionTextureTrans&&e.push("HAS_OCCLUSION_UV_TRANSFORM 1")),this.hasEmissiveTexture()?(e.push("HAS_EMISSIVE_MAP 1"),void 0!==this.emissiveTextureTrans&&e.push("HAS_EMISSIVE_UV_TRANSFORM 1")):this.hasEmissiveFactor()&&e.push("HAS_EMISSIVE 1"),e},n.prototype.updateUniforms=function(e){t.prototype.updateUniforms.call(this,e);var n=(new b).identity();if(e.setVector4("u_BaseColorFactor",this.baseColorFactor),void 0!==this.baseColorTexture&&(e.setTexture("u_BaseColorSampler",this.baseColorTexture),e.setInt("u_BaseColorUVSet",0),void 0!==this.baseColorTextureTrans?e.setMatrix3("u_BaseColorUVTransform",this.baseColorTextureTrans):e.setMatrix3("u_BaseColorUVTransform",n)),e.setFloat("u_MetallicFactor",this.metallicFactor),e.setFloat("u_RoughnessFactor",this.roughnessFactor),void 0!==this.metallicRoughnessTexture&&(e.setTexture("u_MetallicRoughnessSampler",this.metallicRoughnessTexture),e.setInt("u_MetallicRoughnessUVSet",0),void 0!==this.metallicRoughnessTextureTrans?e.setMatrix3("u_MetallicRoughnessUVTransform",this.metallicRoughnessTextureTrans):e.setMatrix3("u_MetallicRoughnessUVTransform",n)),void 0!==this.normalTexture&&(e.setTexture("u_NormalSampler",this.normalTexture),e.setFloat("u_NormalScale",this.normalTextureScale),e.setInt("u_NormalUVSet",0),void 0!==this.normalTextureTrans?e.setMatrix3("u_NormalUVTransform",this.normalTextureTrans):e.setMatrix3("u_NormalUVTransform",n)),void 0!==this.occlusionTexture&&(e.setTexture("u_OcclusionSampler",this.occlusionTexture),e.setFloat("u_OcclusionStrength",this.occlusionTextureStrength),e.setInt("u_OcclusionUVSet",0),void 0!==this.occlusionTextureTrans?e.setMatrix3("u_OcclusionUVTransform",this.occlusionTextureTrans):e.setMatrix3("u_OcclusionUVTransform",n)),void 0!==this.emissiveTexture){var o=this.getEmissiveFactor();e.setTexture("u_EmissiveSampler",this.emissiveTexture),e.setVector3("u_EmissiveFactor",o),e.setInt("u_EmissiveUVSet",0),void 0!==this.emissiveTextureTrans?e.setMatrix3("u_EmissiveUVTransform",this.emissiveTextureTrans):e.setMatrix3("u_EmissiveUVTransform",n)}else if(this.hasEmissiveFactor()){o=this.getEmissiveFactor();e.setVector3("u_EmissiveFactor",o)}e.setFloat("u_Exposure",3)},n.prototype.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},n.prototype.hasBaseColorTextureTrans=function(){return void 0!==this.baseColorTextureTrans},n.prototype.setBaseColorTexture=function(e){this.baseColorTexture=e},n.prototype.getBaseColorFactor=function(){return this.baseColorFactor},n.prototype.setBaseColorFactor=function(e){e instanceof y?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},n.prototype.hasMetallicRoughnessTexture=function(){return void 0!==this.metallicRoughnessTexture},n.prototype.hasMetallicRoughnessTextureTrans=function(){return void 0!==this.metallicRoughnessTextureTrans},n.prototype.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture},n.prototype.setMetallicRoughnessTexture=function(e){this.metallicRoughnessTexture=e},n.prototype.hasNormalTexture=function(){return void 0!==this.normalTexture},n.prototype.hasNormalTextureTrans=function(){return void 0!==this.normalTextureTrans},n.prototype.getNormalTexture=function(){return this.normalTexture},n.prototype.setNormalTexture=function(e){this.normalTexture=e},n.prototype.hasOcclusionTexture=function(){return void 0!==this.occlusionTexture},n.prototype.hasOcclusionTextureTrans=function(){return void 0!==this.occlusionTextureTrans},n.prototype.getOcclusionTexture=function(){return this.occlusionTexture},n.prototype.setOcclusionTexture=function(e){this.occlusionTexture=e},n.prototype.hasEmissiveTexture=function(){return void 0!==this.emissiveTexture},n.prototype.hasEmissiveTextureTrans=function(){return void 0!==this.emissiveTextureTrans},n.prototype.getEmissiveTexture=function(){return this.emissiveTexture},n.prototype.setEmissiveTexture=function(e){this.emissiveTexture=e},n.prototype.hasEmissiveFactor=function(){return this.emissiveFactor.sum()*this.emissiveIntensity>0},n.prototype.getEmissiveFactor=function(){return this.emissiveFactor.clone().multiply(this.emissiveIntensity)},n.prototype.setEmissiveFactor=function(e){e instanceof v?this.emissiveFactor.set(e.x,e.y,e.z):this.emissiveFactor.set(e[0],e[1],e[2])},n}(Ee);function Oe(e){if(e.type===t.spec.MaterialType.pbr){var n=new we;return n.create(e),n}var o=new Pe;return o.create(e),o}var Le,Ne=function(t){function n(n,o){var i=t.call(this)||this;i.renderable=!0,i.intensity=1,i.reflectionsIntensity=1,i.specularImageSize=0,i.specularMipCount=0,i.priority=0,i.isBuilt=!1,i.name=n.name,i.type=e.PObjectType.skybox,i.visible=!1,i.ownerItem=o;var r=n.content.options;return i.renderable=r.renderable,i.intensity=r.intensity,i.reflectionsIntensity=r.reflectionsIntensity,i.irradianceCoeffs=r.irradianceCoeffs,i.diffuseImage=r.diffuseImage,i.specularImage=r.specularImage,i.specularImageSize=r.specularImageSize,i.specularMipCount=r.specularMipCount,i.priority=(null==o?void 0:o.listIndex)||0,i}return i(n,t),n.prototype.setup=function(e){this.brdfLUT=e},n.prototype.build=function(e){this.isBuilt||(this.isBuilt=!0,this.skyboxMaterial=new Fe,this.skyboxMaterial.create(this),this.skyboxMaterial.build(),this.skyboxMesh=e.getFilterMesh("SkyboxFilterPlane",this.skyboxMaterial,{}),this.skyboxMesh.priority=this.priority,this.skyboxMaterial.updateUniforms(this.skyboxMesh.material))},n.prototype.dispose=function(){var e;this.diffuseImage=void 0,this.specularImage=void 0,this.brdfLUT=void 0,this.skyboxMesh=void 0,null===(e=this.skyboxMaterial)||void 0===e||e.dispose(),this.skyboxMaterial=void 0},n.prototype.addToRenderObjectSet=function(e){this.visible&&this.renderable&&void 0!==this.skyboxMesh&&e.add(this.skyboxMesh)},n.prototype.updateUniformsForScene=function(e){if(this.visible&&this.renderable&&void 0!==this.skyboxMesh&&void 0!==this.skyboxMaterial){var t=e.camera,n=e.viewMatrix,o=t.getNewProjectionMatrix(t.fovy).multiply(n).invert(),i=this.skyboxMesh.material;this.skyboxMaterial.updateUniforms(i),i.setMatrix("u_InvViewProjectionMatrix",o)}},Object.defineProperty(n.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(n.prototype,"currentIntensity",{get:function(){return this.visible?this.intensity:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentReflectionsIntensity",{get:function(){return this.visible?this.reflectionsIntensity:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasDiffuseImage",{get:function(){return void 0!==this.diffuseImage},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasIrradianceCoeffs",{get:function(){return void 0!==this.irradianceCoeffs},enumerable:!1,configurable:!0}),n}(D),Fe=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.intensity=1,e.reflectionsIntensity=1,e.specularMipCount=0,e}return i(n,t),n.prototype.create=function(t){this.type=e.PObjectType.material,this.materialType=e.PMaterialType.skyboxFilter,this.depthTestHint=!1,this.name=t.name,this.intensity=t.intensity,this.reflectionsIntensity=t.reflectionsIntensity,this.brdfLUT=t.brdfLUT,this.irradianceCoeffs=t.irradianceCoeffs,this.diffuseImage=t.diffuseImage,this.specularImage=t.specularImage,this.specularMipCount=t.specularMipCount},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.brdfLUT=void 0,this.irradianceCoeffs=void 0,this.diffuseImage=void 0,this.specularImage=void 0},n.prototype.getShaderFeatures=function(){var e=[];return e.push("USE_IBL 1"),e.push("USE_TEX_LOD 1"),void 0===this.diffuseImage&&e.push("IRRADIANCE_COEFFICIENTS 1"),e},n.prototype.updateUniforms=function(e){if(void 0===this.brdfLUT)throw new Error("Setup brdfLUT for skybox at first.");if(e.setVector2("u_IblIntensity",new g(2,2)),e.setTexture("u_brdfLUT",this.brdfLUT),void 0!==this.diffuseImage)e.setTexture("u_DiffuseEnvSampler",this.diffuseImage);else{var t=this.irradianceCoeffs;if(void 0===t||9!=t.length)throw new Error("Invalid skybox irradiance coeffs ".concat(t));["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(n,o){e.setVector3("u_shCoefficients.".concat(n),v.fromArray(t[o]))}))}e.setInt("u_MipCount",this.specularMipCount),e.setTexture("u_SpecularEnvSampler",this.specularImage)},n.prototype.setMaterialStates=function(e){e.depthTest=!0,e.depthMask=!1,this.setFaceSideStates(e)},n}(Ee);e.PSkyboxType=void 0,(Le=e.PSkyboxType||(e.PSkyboxType={}))[Le.NFT=0]="NFT",Le[Le.FARM=1]="FARM";var Re=function(){function n(){}return n.getBrdfLutTextureOptions=function(){return a(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return"https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png",[4,t.loadImage("https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png")];case 1:return e=n.sent(),[2,{name:"brdfLut",wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR,anisotropic:1,sourceType:t.TextureSourceType.image,image:e,generateMipmap:!1,flipY:!1,premultiplyAlpha:!1}]}}))}))},n.createBrdfLutTexture=function(e){return a(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:return[4,this.getBrdfLutTextureOptions()];case 1:return n=o.sent(),[2,t.Texture.create(e,n)]}}))}))},n.createSkyboxOptions=function(e,t){return a(this,void 0,void 0,(function(){var n,o,i,r,a,c,l,u;return s(this,(function(s){switch(s.label){case 0:return[4,this.createSpecularCubeMap(e,t)];case 1:return n=s.sent(),[4,this.createDiffuseCubeMap(e,t)];case 2:return o=s.sent(),i=t.renderable,r=t.intensity,a=t.reflectionsIntensity,c=t.irradianceCoeffs,l=t.specularImageSize,u=t.specularMipCount,[2,{renderable:i,intensity:r,reflectionsIntensity:a,irradianceCoeffs:c,diffuseImage:o,specularImage:n,specularImageSize:l,specularMipCount:u}]}}))}))},n.createSpecularCubeMap=function(e,n){return a(this,void 0,void 0,(function(){return s(this,(function(o){return t.glContext.CLAMP_TO_EDGE,t.glContext.CLAMP_TO_EDGE,t.glContext.LINEAR,t.glContext.LINEAR_MIPMAP_LINEAR,"url"===n.type?[2,Q.createTextureCubeMipmapFromURL(e,n.specularImage)]:[2,Q.createTextureCubeMipmapFromBuffer(e,n.specularImage,n.specularImageSize)]}))}))},n.createDiffuseCubeMap=function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){return void 0===t.diffuseImage?[2]:"url"===t.type?[2,Q.createTextureCubeFromURL(e,t.diffuseImage)]:[2,Q.createTextureCubeFromBuffer(e,t.diffuseImage)]}))}))},n.getSkyboxParams=function(t){void 0===t&&(t=e.PSkyboxType.NFT);var n=this.getSpecularImageList(t);return{type:"url",renderable:!0,intensity:1.8,reflectionsIntensity:1.8,irradianceCoeffs:this.getIrradianceCoeffs(t),diffuseImage:this.getDiffuseImageList(t,n),specularImage:n,specularImageSize:Math.pow(2,n.length-1),specularMipCount:n.length-1}},n.prototype.checkCubeMapImage=function(e){return a(this,void 0,void 0,(function(){var n,o,i,r;return s(this,(function(a){switch(a.label){case 0:o=[],i=0,a.label=1;case 1:return i<e.length?[4,t.loadImage(e[i])]:[3,4];case 2:if(r=a.sent(),i>0)if(i%6==0){if(2*r.width!==n.width||2*r.height!==n.height)throw new Error("Invalid cube map list1: index ".concat(i,", image0 ").concat(n,", image1 ").concat(r))}else if(r.width!==n.width||r.height!==n.height)throw new Error("Invalid cube map list2: index ".concat(i,", image0 ").concat(n,", image1 ").concat(r));i%6==0&&o.push([]),o[o.length-1].push(r),n=r,a.label=3;case 3:return i++,[3,1];case 4:return[2]}}))}))},n.getIrradianceCoeffs=function(t){var n=[];switch(t){case e.PSkyboxType.NFT:return;case e.PSkyboxType.FARM:n=[.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:n=[.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 o=[],i=0;i<n.length;i+=3)o.push([n[i],n[i+1],n[i+2]]);return o},n.getDiffuseImageList=function(t,n){if(t==e.PSkyboxType.NFT)return n[n.length-1]},n.getSpecularImageList=function(t){var n=[];if(t===e.PSkyboxType.FARM)n.push.apply(n,l([],c(this.getSpecularImageListAntFarm()),!1));else n.push.apply(n,l([],c(this.getSpecularImageListNFT()),!1));var o=[];return n.forEach((function(e,t){t%6==0&&o.push([]),o[o.length-1].push(e)})),o},n.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"]},n.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"]},n}(),Be=function(){function e(e){this.engine=e,this.loadSkybox=!1,this.meshCache=new Map,this.textureCache=new Map,this.geometryCache=new Map,this.renderPassCache=new Map}return e.loadStaticResources=function(){return a(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return void 0!==this.brdfLutTexOptions?[2]:(e=this,[4,Re.getBrdfLutTextureOptions()]);case 1:return e.brdfLutTexOptions=t.sent(),[2]}}))}))},e.genSkyboxOptions=function(t,n){return a(this,void 0,void 0,(function(){var o,i;return s(this,(function(r){switch(r.label){case 0:return void 0===(o=n)&&(o=Re.getSkyboxParams()),i=e,[4,Re.createSkyboxOptions(t,o)];case 1:return i.skyboxOptions=r.sent(),[2,e.skyboxOptions]}}))}))},e.prototype.setup=function(n){if(this.loadSkybox=n,void 0===this.brdfLutTexture||this.brdfLutTexture.isDestroyed){if(void 0===e.brdfLutTexOptions)throw new Error("Please load brdfLutTexOptions at first");var o="brdfLutTexture";this.brdfLutTexture=t.Texture.create(this.engine,e.brdfLutTexOptions),this.deleteTexture(o),this.setTexture(o,this.brdfLutTexture)}},e.prototype.getTexture=function(e){return this.textureCache.get(e)},e.prototype.setTexture=function(e,t){this.textureCache.set(e,t)},e.prototype.getOrCreateTexture=function(e,n){var o=this.textureCache.get(e);if(void 0!==o)return o;var i=t.Texture.create(this.engine,n);return this.textureCache.set(e,i),i},e.prototype.deleteTexture=function(e){var t=this.textureCache.get(e);return void 0!==t&&t.dispose(),this.textureCache.delete(e)},e.prototype.getOrCreateGeometry=function(e,t,n){var o=this.geometryCache.get(e);if(void 0!==o)return o;var i=$.createGeometry(this.engine,t,n);return this.geometryCache.set(e,i),i},e.prototype.getFilterMesh=function(e,t,n){var o=this.meshCache.get(e);if(void 0!==o)return o;var i=Z.createFilterMesh(this.engine,e,t,n);return this.meshCache.set(e,i),i},e.prototype.getShadowBasePass=function(e,t,n,o){return this.getRenderPass(e,t,n,o)},e.prototype.getShadowFilterPass=function(e,t,n,o){return this.getRenderPass(e,t,n,o)},e.prototype.getRenderPass=function(e,t,n,o){var i=this.renderPassCache.get(e);if(void 0!==i)return i.setMeshes([]),n.forEach((function(e){i.addMesh(e)})),i;var r=this.engine.renderer,a=Q.createRenderPass(r,e,t,n,o);return this.renderPassCache.set(e,a),a},e.prototype.dispose=function(){this.engine=null,this.brdfLutTexture=void 0,this.meshCache.forEach((function(e){Q.deleteMesh(e)})),this.meshCache.clear(),this.textureCache.forEach((function(e){Q.deleteTexture(e)})),this.textureCache.clear(),this.geometryCache.forEach((function(e){Q.deleteGeometry(e)})),this.geometryCache.clear(),this.renderPassCache.forEach((function(e){Q.deleteRenderPass(e)})),this.renderPassCache.clear()},e.prototype.getRenderPasses=function(){var e=[];return this.renderPassCache.forEach((function(t){e.push(t)})),e},e.prototype.getBrdfLutTexture=function(){return this.brdfLutTexture},e.prototype.getSkyboxOptions=function(){return e.skyboxOptions},e}(),Ue=Math.PI/180,De=function(n){function o(o,i,r,a){var s,c=n.call(this)||this;c.width=512,c.height=512,c.nearPlane=.001,c.farPlane=1e3,c.fovy=45,c.aspect=1,c.clipMode=t.spec.CameraClipMode.landscape,c.projectionMatrix=new T,c.viewMatrix=new T,c.name=o.name,c.type=e.PObjectType.camera,c.visible=!1,c.ownerItem=a,c.width=i,c.height=r;var l=o.content.options;return c.nearPlane=l.near,c.farPlane=l.far,c.fovy=l.fov,c.aspect=null!==(s=l.aspect)&&void 0!==s?s:c.width/c.height,c.clipMode=l.clipMode,c.update(),c}return i(o,n),o.prototype.update=function(){void 0!==this.ownerItem&&this.transform.fromEffectsTransform(this.ownerItem.transform);var e=this.clipMode===t.spec.CameraClipMode.portrait;this.projectionMatrix.perspective(this.fovy*Ue,this.aspect,this.nearPlane,this.farPlane,e),this.viewMatrix=this.matrix.invert()},o.prototype.getNewProjectionMatrix=function(e){var n=this.clipMode===t.spec.CameraClipMode.portrait;return(new T).perspective(Math.min(1.25*e,140)*Ue,this.aspect,this.nearPlane,this.farPlane,n)},o.prototype.computeViewAABB=function(e){var t=Math.tan(this.fovy*Ue*.5),n=this.aspect,o=0,i=0,r=0,a=0;this.isReversed()?(o=(r=this.farPlane*t)/n,i=(a=this.nearPlane*t)/n):(r=n*(o=this.farPlane*t),a=n*(i=this.nearPlane*t)),e.makeEmpty();var s=this.matrix;return e.expandByPoint(s.transformPoint(new v(r,o,-this.farPlane))),e.expandByPoint(s.transformPoint(new v(r,-o,-this.farPlane))),e.expandByPoint(s.transformPoint(new v(-r,o,-this.farPlane))),e.expandByPoint(s.transformPoint(new v(-r,-o,-this.farPlane))),e.expandByPoint(s.transformPoint(new v(a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new v(a,-i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new v(-a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new v(-a,-i,-this.nearPlane))),e},o.prototype.getSize=function(){return new g(this.width,this.height)},o.prototype.isReversed=function(){return this.clipMode===t.spec.CameraClipMode.portrait},o.prototype.getEye=function(){return this.translation},o.prototype.setEye=function(e){this.translation=e},o}(D),ke=function(){function e(){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:t.spec.CameraClipMode.portrait}},endBehavior:t.spec.END_BEHAVIOR_FORWARD},512,512)}return e.prototype.initial=function(e,t){this.winWidth=e,this.winHeight=t;var n=this.defaultCamera;n.width=e,n.height=t,n.aspect=e/t,n.update()},e.prototype.insert=function(e,t){var n=new De(e,this.winWidth,this.winHeight,t);return this.cameraList.push(n),n},e.prototype.insertCamera=function(e){this.cameraList.push(e)},e.prototype.remove=function(e){if(e instanceof De){var t=this.cameraList.findIndex((function(t){return t===e}));-1!==t&&this.cameraList.splice(t,1)}else e>=0&&e<this.cameraList.length&&this.cameraList.splice(e,1)},e.prototype.dispose=function(){this.cameraList=[]},e.prototype.updateDefaultCamera=function(e,t,n,o,i,r,a){this.defaultCamera.fovy=e,this.defaultCamera.nearPlane=t,this.defaultCamera.farPlane=n,this.defaultCamera.position=o,this.defaultCamera.rotation=i,this.defaultCamera.aspect=r,this.defaultCamera.clipMode=a,this.defaultCamera.update()},e.prototype.getCameraList=function(){return this.cameraList},e.prototype.getDefaultCamera=function(){return this.defaultCamera},e.prototype.getCameraCount=function(){return this.cameraList.length},e.prototype.getActiveCamera=function(){return this.defaultCamera},e.prototype.getAspect=function(){return this.winWidth/this.winHeight},e}(),Ve=function(t){function n(n,o){var i=t.call(this)||this;i.direction=new v(0,0,1),i.range=0,i.color=new v(1,1,1),i.intensity=0,i.outerConeAngle=0,i.innerConeAngle=0,i.lightType=e.PLightType.ambient,i.padding=new g(0,0),i.name=n.name,i.type=e.PObjectType.light,i.visible=!1,i.ownerItem=o,void 0!==o&&i.transform.fromEffectsTransform(o.transform),i.direction=new v(0,0,-1),i.range=0,i.outerConeAngle=0,i.innerConeAngle=0;var r=n.content.options,a=$.toPluginColor4(r.color);return i.color=new v(a[0],a[1],a[2]),i.intensity=r.intensity,"point"===r.lightType?(i.lightType=e.PLightType.point,i.range=r.range):"spot"===r.lightType?(i.lightType=e.PLightType.spot,i.range=r.range,i.outerConeAngle=r.outerConeAngle,i.innerConeAngle=r.innerConeAngle):"directional"===r.lightType?i.lightType=e.PLightType.directional:i.lightType=e.PLightType.ambient,i}return i(n,t),n.prototype.tick=function(e){void 0!==this.ownerItem&&this.transform.fromEffectsTransform(this.ownerItem.transform)},n.prototype.isDirectional=function(){return this.lightType===e.PLightType.directional},n.prototype.isPoint=function(){return this.lightType===e.PLightType.point},n.prototype.isSpot=function(){return this.lightType===e.PLightType.spot},n.prototype.isAmbient=function(){return this.lightType===e.PLightType.ambient},Object.defineProperty(n.prototype,"position",{get:function(){return this.translation},enumerable:!1,configurable:!0}),n.prototype.getWorldPosition=function(){return this.translation},n.prototype.getWorldDirection=function(){return this.matrix.transformNormal(this.direction,new v)},n}(D),Ge=function(){function e(){this.lightList=[]}return e.prototype.tick=function(e){this.lightList.forEach((function(t){t.tick(e)}))},e.prototype.insertItem=function(e,t){var n=new Ve(e,t);return this.lightList.push(n),n},e.prototype.insertLight=function(e){return this.lightList.push(e),e},e.prototype.remove=function(e){var t=this.lightList.findIndex((function(t){return t===e}));-1!==t&&this.lightList.splice(t,1)},e.prototype.dispose=function(){this.lightList=[]},Object.defineProperty(e.prototype,"lightCount",{get:function(){return this.lightList.length},enumerable:!1,configurable:!0}),e}(),je=function(){function e(e){var t,n;this.resolution=null!==(t=e.resolution)&&void 0!==t?t:new g(512,512),this.colorAttachments=null!==(n=e.colorAttachments)&&void 0!==n?n:[],this.depthAttachment=e.depthAttachment}return e.prototype.addDepthAttachment=function(e){var n;this.depthAttachment={storageType:null!==(n=e.storageType)&&void 0!==n?n:t.RenderPassAttachmentStorageType.depth_16_texture}},e.prototype.addDefaultDepthAttachment=function(){this.depthAttachment={storageType:t.RenderPassAttachmentStorageType.depth_16_texture}},e.prototype.deleteDepthAttachment=function(){this.depthAttachment=void 0},e.prototype.addColorAttachment=function(e){var n,o,i,r;this.colorAttachments.push({texture:{format:null!==(n=e.format)&&void 0!==n?n:t.glContext.RGBA,type:null!==(o=e.type)&&void 0!==o?o:t.glContext.HALF_FLOAT,minFilter:null!==(i=e.filter)&&void 0!==i?i:t.glContext.LINEAR,magFilter:null!==(r=e.filter)&&void 0!==r?r:t.glContext.LINEAR}})},e.prototype.deleteColorAttachment=function(e){e>=0&&e<this.colorAttachments.length&&this.colorAttachments.splice(e,1)},Object.defineProperty(e.prototype,"viewport",{get:function(){return[0,0,this.resolution.x,this.resolution.y]},enumerable:!1,configurable:!0}),e}(),ze=function(){function e(e,n){var o=t.Material.create(e,{shader:{vertex:this.vertexShader,fragment:this.fragmentShader,shared:!0}});o.depthTest=!0,o.depthMask=!0,this.mesh=t.Mesh.create(e,{name:"boxMesh",material:o,geometry:t.Geometry.create(e,this.geometry),priority:n})}return e.prototype.update=function(e,t,n,o){var i=this.mesh.material;i.setMatrix("u_ModelMatrix",e),i.setMatrix("u_ViewProjectionMatrix",t);for(var r=0;r<n.length;r+=3)i.setVector3("u_PositionList[".concat(r/3,"]"),v.fromArray(n,r));i.setVector3("u_LineColor",o)},e.prototype.dispose=function(){this.mesh.dispose(),this.mesh=void 0},Object.defineProperty(e.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(e.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(e.prototype,"geometry",{get:function(){var e=new Float32Array([0,1,2,3,4,5,6,7]),n=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:t.glContext.FLOAT,size:1,data:e,stride:Float32Array.BYTES_PER_ELEMENT,offset:0}},mode:t.glContext.LINES,indices:{data:n},drawStart:0,drawCount:24}},enumerable:!1,configurable:!0}),e}(),He=function(){function e(){this.now=new Set,this.last=new Set}return e.prototype.clear=function(){this.now.clear(),this.last.clear()},e.prototype.forward=function(){var e=this.last;this.last=this.now,this.now=e,this.now.clear()},e.prototype.forAddedItem=function(e){var t=this;this.now.forEach((function(n){t.last.has(n)||e(n)}))},e.prototype.forRemovedItem=function(e){var t=this;this.last.forEach((function(n){t.now.has(n)||e(n)}))},e}();!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}i(n,t),n.prototype.create=function(t){this.type=e.PObjectType.material,this.materialType=e.PMaterialType.shadowBase,this.name=t.name,this.shadowType=t.shadowType},n.prototype.getShaderFeatures=function(){return[]},n.prototype.updateUniforms=function(e){}}(Ee);var We=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n.prototype.create=function(t){this.type=e.PObjectType.material,this.materialType=e.PMaterialType.shadowBase,this.name=t.name,this.shadowType=t.shadowType},n.prototype.getShaderFeatures=function(){return[]},n.prototype.updateUniforms=function(e){},n}(Ee),Xe=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n.prototype.create=function(t){this.type=e.PObjectType.material,this.materialType=e.PMaterialType.shadowFilter,this.depthTestHint=!1,this.name=t.name,this.blurScale=t.blurScale},n.prototype.getShaderFeatures=function(){return[]},n.prototype.updateUniforms=function(e){e.setVector2("u_BlurScale",this.blurScale)},n}(Ee),Je=function(){function n(){this.enable=!1,this.quality="medium",this.softness=1.5,this.width=1024,this.height=1024,this.type=t.glContext.HALF_FLOAT,this.format=t.glContext.RGBA,this.filter=t.glContext.LINEAR,this.baseFBOOpts=this.getBaseFBOOptions(),this.filterFBOOpts=this.getFilterFBOOptions(),this.runtimeEnable=!1,this.meshList=[],this.primitiveList=[],this.viewAABB=new M,this.sceneAABB=new M,this.shadowAABB=new M,this.lightView=new T,this.lightProjection=new T,this.lightViewProjection=new T,this.xFilterMaterial=new Xe,this.yFilterMaterial=new Xe,this.meshCacheSet=new He,this.renderPassCacheSet=new He}return n.prototype.initial=function(e,t){var n,o,i,r=this;this.runtimeEnable=!1,this.meshList=[],this.primitiveList=[],this.shadowLight=void 0,this.meshCacheSet.clear(),this.renderPassCacheSet.clear(),this.sceneManager=e,this.renderer=e.getRenderer(),this.engine=this.renderer.engine,this.enable=null===(o=null==t?void 0:t.enable)||void 0===o||o,this.quality=null!==(i=null==t?void 0:t.quality)&&void 0!==i?i:"medium",this.softness=this.getSoftness(t),n=c(this.getTextureSize(t),2),this.width=n[0],this.height=n[1],this.type=this.getTextureType(t),this.format=this.getTextureFormat(t),this.filter=this.getTextureFilter(t),this.enable&&this.isSupportTextureOptions()&&(this.shadowLight=this.getShadowLight(e),void 0!==this.shadowLight&&(e.meshList.forEach((function(e){var t=0;e.primitives.forEach((function(e){e.isEnableShadow()&&(t+=1)})),t>0&&r.meshList.push(e)})),this.meshList.length<=0||(this.runtimeEnable=!0,this.xFilterMaterial.create({name:"ShadowXFilterPass",blurScale:new g(this.softness/this.width,0)}),this.yFilterMaterial.create({name:"ShadowYFilterPass",blurScale:new g(0,this.softness/this.height)}),this.xFilterMaterial.build([]),this.yFilterMaterial.build([]))))},n.prototype.build=function(){if(this.isEnable()){var e=this.sceneManager.getSceneCache();this.basePass=e.getShadowBasePass(this.basePassName,900,[],this.baseFBOOpts);var t=e.getFilterMesh(this.xFilterMeshName,this.xFilterMaterial,{u_FilterSampler:"Shadow0Color"}),n=e.getFilterMesh(this.yFilterMeshName,this.yFilterMaterial,{u_FilterSampler:"Shadow1Color"});this.xFilterMaterial.updateUniforms(t.material),this.yFilterMaterial.updateUniforms(n.material),this.xFilterPass=e.getShadowFilterPass(this.xFilterPassName,901,[t],this.filterFBOOpts),this.yFilterPass=e.getShadowFilterPass(this.yFilterPassName,902,[n],this.filterFBOOpts)}},n.prototype.tick=function(e){this.isEnable()&&(this.primitiveList=this.getCurrentPrimitiveList(),this.primitiveList.length<=0||(this.updateAABBInfo(),this.updateLightViewProjection(),this.updateShadowUniforms(),e.shadowMapSizeInv=new g(1/this.width,1/this.height),e.lightViewMatrix=this.lightView,e.lightProjectionMatrix=this.lightProjection,e.lightViewProjectionMatrix=this.lightViewProjection))},n.prototype.updateAABBInfo=function(){var e=this;this.sceneAABB.makeEmpty(),this.primitiveList.forEach((function(t){var n=t.getWorldBoundingBox();e.sceneAABB.expandByBox(n)})),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)},n.prototype.updateLightViewProjection=function(){void 0!==this.shadowLight&&(this.shadowLight.lightType===e.PLightType.directional?this.updateDirectionalLightViewProjection(this.shadowLight):this.shadowLight.lightType===e.PLightType.spot?this.updateSpotLightViewProjection(this.shadowLight):console.warn("Invalid light type for casting shadow: ".concat(this.shadowLight)))},n.prototype.updateDirectionalLightViewProjection=function(e){if(e.isDirectional()){var t=this.shadowAABB,n=t.getCenter(new v),o=e.getWorldDirection(),i=n.clone().add(o),r=Ye(o,new v),a=(new T).lookAt(n,i,r),s=t.clone().applyMatrix4(a),c=s.getCenter(new v),l=s.getSize(new v).multiply(.5);l.x=Math.max(l.x,l.y),l.y=Math.max(l.x,l.y);var u=l.clone().multiply(-1.001).add(c),h=l.clone().multiply(1.001).add(c),f=(new T).orthographic(u.x,h.x,u.y,h.y,u.z,h.z);return this.lightView.copyFrom(a),this.lightProjection.copyFrom(f),this.lightViewProjection.multiplyMatrices(f,a)}this.lightViewProjection.identity()},n.prototype.updateSpotLightViewProjection=function(e){if(e.isSpot()){var t=e.getWorldPosition(),n=e.direction.clone(),o=n.clone().multiply(10),i=t.clone().add(o),r=Ye(n,new v),a=T.fromLookAt(t,i,r),s=this.shadowAABB.clone().applyMatrix4(a),c=[new v(s.min.x,s.min.y,s.min.z),new v(s.min.x,s.min.y,s.max.z),new v(s.min.x,s.max.y,s.min.z),new v(s.min.x,s.max.y,s.max.z),new v(s.max.x,s.min.y,s.min.z),new v(s.max.x,s.min.y,s.max.z),new v(s.max.x,s.max.y,s.min.z),new v(s.max.x,s.max.y,s.max.z)],l=1,u=1e4,h=-1e4;c.map((function(e){if(e.z<=0){var t=new v(0,e.y,e.z).normalize();l=Math.min(l,-t.z),u=Math.min(u,-e.z),h=Math.max(h,-e.z)}}));var f=Math.acos(l),d=2*Math.min(f,e.outerConeAngle),p=T.fromPerspective(d,1,u,h,!1);return this.lightViewProjection.multiplyMatrices(p,a)}this.lightViewProjection.identity()},n.prototype.getShadowOptions=function(){return{viewProjectionMatrix:this.lightViewProjection,softness:this.softness}},n.prototype.updateShadowUniforms=function(){var e=this.getShadowOptions();this.primitiveList.forEach((function(t){t.updateUniformForShadow(e)}))},n.prototype.getShadowLight=function(t){for(var n=t.lightManager.lightList,o=0;o<n.length;o++){var i=n[o];if(i.lightType===e.PLightType.directional||i.lightType===e.PLightType.spot)return i}},n.prototype.getShadowPrimitiveCount=function(e){var t=0;return e.meshList.forEach((function(e){e.primitives.forEach((function(e){e.isEnableShadow()&&(t+=1)}))})),t},n.prototype.updateRenderPass=function(e){var t=this;if(void 0!==this.basePass){var n=this.basePass;this.meshCacheSet.forward(),this.primitiveList.forEach((function(e){e.isEnableShadow()&&void 0!==e.shadowMesh&&t.meshCacheSet.now.add(e.shadowMesh)})),this.meshCacheSet.forRemovedItem((function(e){n.removeMesh(e)})),this.meshCacheSet.forAddedItem((function(e){n.addMesh(e)}))}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 o=!1;this.renderPassCacheSet.forRemovedItem((function(t){e.removeRenderPass(t),o=!0}));var i=!1;this.renderPassCacheSet.forAddedItem((function(t){e.addRenderPass(t),i=!0})),i?this.updateFrameSemantics(e.semantics,!0):o&&this.updateFrameSemantics(e.semantics,!1)},n.prototype.updateFrameSemantics=function(e,t){var n=this;t?(void 0!==this.basePass&&e.setSemantic("Shadow0Color",(function(){return n.basePass.attachments[0].texture})),void 0!==this.xFilterPass&&e.setSemantic("Shadow1Color",(function(){return n.xFilterPass.attachments[0].texture})),void 0!==this.yFilterPass&&e.setSemantic("ShadowNColor",(function(){return n.yFilterPass.attachments[0].texture}))):(e.setSemantic("Shadow0Color",void 0),e.setSemantic("Shadow1Color",void 0),e.setSemantic("ShadowNColor",void 0))},n.prototype.isEnable=function(){return this.enable&&this.runtimeEnable},n.prototype.hasRenderObject=function(){return this.isEnable()&&this.primitiveList.length>0},n.prototype.getCurrentPrimitiveList=function(){var e=[];return this.meshList.forEach((function(t){t.visible&&t.primitives.forEach((function(t){t.isEnableShadow()&&void 0!==t.shadowMesh&&e.push(t)}))})),e},n.prototype.isSupportTextureOptions=function(){return this.type===t.glContext.FLOAT?Q.isSupportFloatTexture(this.engine):this.type!==t.glContext.HALF_FLOAT||Q.isSupportHalfFloatTexture(this.engine)},n.prototype.getBaseFBOOptions=function(){var e=new g(this.width,this.height),n={texture:{format:this.format,type:this.type,minFilter:this.filter,magFilter:this.filter}},o={storageType:t.RenderPassAttachmentStorageType.depth_16_opaque};return new je({resolution:e,colorAttachments:[n],depthAttachment:o})},n.prototype.getFilterFBOOptions=function(){var e=new g(this.width,this.height),t={texture:{format:this.format,type:this.type,minFilter:this.filter,magFilter:this.filter}};return new je({resolution:e,colorAttachments:[t]})},n.prototype.getSoftness=function(e){var n,o=null!==(n=null==e?void 0:e.softness)&&void 0!==n?n:1.5;return o>=0&&o<=2?o:(console.error("Invalid softness value from shadow init options, ".concat(o)),t.math.clamp(o,0,2))},n.prototype.getTextureSize=function(e){var t,n,o=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:1024,i=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:1024;return o===i&&o>0&&o<=4096?[o,i]:(console.error("Invalid texture size from shadow init options, ".concat(o,"x").concat(i)),[1024,1024])},n.prototype.getTextureType=function(e){var n,o=null!==(n=null==e?void 0:e.type)&&void 0!==n?n:t.glContext.HALF_FLOAT;return o===t.glContext.UNSIGNED_BYTE||o===t.glContext.HALF_FLOAT||o===t.glContext.FLOAT?o:(console.error("Invalid texture type from shadow init options, ".concat(o)),t.glContext.HALF_FLOAT)},n.prototype.getTextureFormat=function(e){var n,o=null!==(n=null==e?void 0:e.format)&&void 0!==n?n:t.glContext.RGBA;return o===t.glContext.RGBA?o:(console.error("Invalid texture format from shadow init options, ".concat(o)),t.glContext.RGBA)},n.prototype.getTextureFilter=function(e){var n,o=null!==(n=null==e?void 0:e.filter)&&void 0!==n?n:t.glContext.LINEAR;return o===t.glContext.NEAREST||o===t.glContext.LINEAR?o:(console.error("Invalid texture filter from shadow init options, ".concat(o)),t.glContext.LINEAR)},Object.defineProperty(n.prototype,"mainPassUniformSemantics",{get:function(){return{u_ShadowSampler:"ShadowNColor"}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"basePassName",{get:function(){return this.sceneManager.compName+"_ShadowBasePass"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"xFilterPassName",{get:function(){return this.sceneManager.compName+"_ShadowXFilterPass"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"yFilterPassName",{get:function(){return this.sceneManager.compName+"_ShadowYFilterPass"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"xFilterMeshName",{get:function(){return this.sceneManager.compName+"_ShadowXFilterMesh"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"yFilterMeshName",{get:function(){return this.sceneManager.compName+"_ShadowYFilterMesh"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shadowPassList",{get:function(){var e=[];return void 0!==this.basePass&&e.push(this.basePass),void 0!==this.xFilterPass&&e.push(this.xFilterPass),void 0!==this.yFilterPass&&e.push(this.yFilterPass),e},enumerable:!1,configurable:!0}),n}();function Ye(e,t){var n,o=e.clone().normalize(),i=o.clone().abs();return 1!==((n=i).x<n.y?n.x<n.z?0:2:n.y<n.z?1:2)?t.set(0,1,0):(t.set(o.z,0,-o.x),t.normalize()),t}var qe=function(n){function o(t,o,i,r){var a=n.call(this)||this;a.engine=t,a.parentIndex=-1,a.primitives=[],a.hide=!0,a.priority=0,a.boundingBox=new M,a.visBoundingBox=!1,a.isBuilt=!1,a.isDisposed=!1;var s=new Ze(o,r);return a.name=s.getName(),a.type=e.PObjectType.mesh,a.visible=!1,a.ownerItem=i,a.parentIndex=s.getParentIndex(),a.parentItem=s.parentItem,a.parentItemId=s.getParentId(),a.skin=s.getSkinObj(t),a.morph=s.getMorphObj(),a.hide=s.isHide(),a.priority=(null==i?void 0:i.listIndex)||0,a.primitives=[],s.getPrimitives().forEach((function(e){var t=new Ke(a.engine);t.create(e,a),a.primitives.push(t)})),a.primitives.length<=0&&console.warn("No primitive inside mesh item ".concat(s.getName())),a.boundingBox=a.getItemBoundingBox(o.content.interaction),R.getInstance().visBoundingBox&&(a.boundingBoxMesh=new ze(a.engine,a.priority)),a}return i(o,n),o.prototype.build=function(e,t,n){this.isBuilt||(this.isBuilt=!0,this.primitives.forEach((function(o){o.build(e,t,n)})))},o.prototype.tick=function(e){this.visible&&(void 0!==this.ownerItem&&this.transform.setMatrix(this.ownerItem.transform.getWorldMatrix()),void 0!==this.skin&&this.skin.updateSkinMatrices())},o.prototype.addToRenderObjectSet=function(e){var t=this;this.visible&&(this.primitives.forEach((function(n){n.effectsMesh.worldMatrix=t.transform.getMatrix(),e.add(n.effectsMesh)})),this.visBoundingBox&&void 0!==this.boundingBoxMesh&&e.add(this.boundingBoxMesh.mesh))},o.prototype.dispose=function(){var e,t,n;this.isDisposed||(this.isDisposed=!0,this.engine=null,this.parentItem=void 0,null===(e=this.skin)||void 0===e||e.dispose(),this.skin=void 0,null===(t=this.morph)||void 0===t||t.dispose(),this.morph=void 0,this.primitives.forEach((function(e){e.dispose()})),this.primitives=[],null===(n=this.boundingBoxMesh)||void 0===n||n.dispose(),this.boundingBoxMesh=void 0)},o.prototype.updateMorphWeights=function(e){if(void 0!==this.morph&&this.morph.hasMorph()){var t=this.morph.morphWeightsArray;if(void 0!==t){if(t.length!=e.length)throw new Error("weight array length mismatch");for(var n=0;n<t.length;n++)t[n]=e[n]}}},o.prototype.updateParentItem=function(e){this.parentItem=e,void 0!==this.skin&&this.skin.updateParentItem(e)},o.prototype.updateUniformsForScene=function(e){var t=this.matrix,n=t.clone().invert().transpose();if(this.primitives.forEach((function(o){o.updateUniformsForScene(t,n,e)})),0===e.deltaSeconds&&void 0!==this.boundingBoxMesh){this.computeBoundingBox(t);var o=new v(1,1,1),i=this.boundingBox.min,r=this.boundingBox.max,a=new Float32Array([i.x,i.y,i.z,r.x,i.y,i.z,r.x,r.y,i.z,i.x,r.y,i.z,i.x,i.y,r.z,r.x,i.y,r.z,r.x,r.y,r.z,i.x,r.y,r.z]);this.boundingBoxMesh.update(t,e.viewProjectionMatrix,a,o)}},o.prototype.updateUniformForShadow=function(e){this.primitives.forEach((function(t){t.updateUniformForShadow(e)}))},o.prototype.hitTesting=function(e,t){var n,o=this.matrix,i=o.clone().invert(),r=i.transformPoint(e,new v),a=i.transformNormal(t,new v),s=this.boundingBox,c=j(r,a,s.min,s.max);return void 0===c?[]:(R.getInstance().isEditorEnv?this.primitives.forEach((function(e){var t=e.hitTesting(r,a,o,i);void 0!==t&&(void 0===n||n>t)&&(n=t)})):n=c,void 0===n?[]:(a.multiply(n),r.add(a),o.transformPoint(r),[r]))},o.prototype.computeBoundingBox=function(e){var t=this.boundingBox.makeEmpty(),n=e.clone().invert();return this.primitives.forEach((function(e){var o=e.computeBoundingBox(n);t.union(o)})),t},o.prototype.getItemBoundingBox=function(e){var n,o,i,r;if(void 0===e)return new M;if(e.type===t.spec.ModelBoundingType.box){var a=null!==(n=e.center)&&void 0!==n?n:[0,0,0],s=null!==(o=e.size)&&void 0!==o?o:[0,0,0],c=v.fromArray(a),l=v.fromArray(s).multiply(.5),u=c.clone().subtract(l),h=c.clone().add(l);return new M(u,h)}a=null!==(i=e.center)&&void 0!==i?i:[0,0,0];var f=.5*(null!==(r=e.radius)&&void 0!==r?r:0);u=(c=v.fromArray(a)).clone().subtract(f),h=c.clone().add(f);return new M(u,h)},o.prototype.getParentId=function(){return this.parentItemId},Object.defineProperty(o.prototype,"hasSkin",{get:function(){return void 0!==this.skin},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"mriMeshs",{get:function(){return this.primitives.map((function(e){return e.effectsMesh}))},enumerable:!1,configurable:!0}),o}(D),Ke=function(){function n(t){this.engine=t,this.name="",this.effectsPriority=0,this.boundingBox=new M,this.isCompressed=!1,this.shadowType=e.PShadowType.none}return n.prototype.create=function(t,n){if(this.parent=n,this.skin=n.skin,this.morph=n.morph,this.setGeometry(t.geometry),this.setMaterial(t.material),this.name=n.name,this.effectsPriority=n.priority,this.geometry.setHide(n.hide),void 0!==this.skin){var o=this.skin.getJointCount();if(this.jointMatrixList=new Float32Array(16*o),this.jointNormalMatList=new Float32Array(16*o),this.skin.isTextureDataMode()){var i=this.skin.textureDataMode===e.TextureDataMode.half_float;this.jointMatrixTexture=new pe(this.engine),this.jointNormalMatTexture=new pe(this.engine),this.jointMatrixTexture.create(o,i,"jointMatrixTexture"),this.jointNormalMatTexture.create(o,i,"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=e.PShadowType.none,this.material instanceof we&&this.material.enableShadow&&(this.shadowType=e.PShadowType.expVariance)},n.prototype.build=function(e,n,o){var i=R.getInstance(),r=this.getFeatureList(e,!0,o);this.material.build(r);var a=this.isEnableShadow()?n:{};a.u_ViewProjectionMatrix="VIEWPROJECTION",a.u_ModelMatrix="MODEL",a.uEditorTransform="EDITOR_TRANSFORM";var s=t.Material.create(this.engine,{shader:{vertex:this.material.vertexShaderCode,fragment:this.material.fragmentShaderCode,shared:i.shaderShared},uniformSemantics:a});this.material.setMaterialStates(s);var c=t.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 l=this.getFeatureList(e,!1,o);this.shadowMaterial.build(l);var u=this.shadowMaterial.vertexShaderCode,h=this.shadowMaterial.fragmentShaderCode,f=t.Material.create(this.engine,{shader:{vertex:u,fragment:h,shared:i.shaderShared}});this.shadowMaterial.setMaterialStates(f);var d=t.Mesh.create(this.engine,{name:this.name+"_shadow",material:f,geometry:this.getEffectsGeometry(),priority:this.effectsPriority});void 0!==this.shadowMesh&&this.shadowMesh.dispose(),this.shadowMesh=d}},n.prototype.getFeatureList=function(t,n,o){var i=[];if(this.geometry.hasNormals()&&i.push("HAS_NORMALS 1"),this.geometry.hasTangents()&&i.push("HAS_TANGENTS 1"),this.geometry.hasUVCoords(1)&&i.push("HAS_UV_SET1 1"),this.geometry.hasUVCoords(2)&&i.push("HAS_UV_SET2 1"),void 0!==this.morph&&this.morph.hasMorph()){i.push("USE_MORPHING"),i.push("WEIGHT_COUNT ".concat(this.morph.morphWeightsLength));for(var r=0;r<this.morph.morphWeightsLength;r++)this.morph.hasPositionMorph&&i.push("HAS_TARGET_POSITION".concat(r)),this.morph.hasNormalMorph&&i.push("HAS_TARGET_NORMAL".concat(r)),this.morph.hasTangentMorph&&i.push("HAS_TARGET_TANGENT".concat(r))}void 0!==this.skin&&(i.push("USE_SKINNING 1"),i.push("JOINT_COUNT ".concat(this.skin.getJointCount())),i.push("HAS_JOINT_SET1 1"),i.push("HAS_WEIGHT_SET1 1"),this.skin.textureDataMode&&i.push("USE_SKINNING_TEXTURE 1")),this.isEnableShadow()&&(this.shadowType===e.PShadowType.standard?i.push("SHADOWMAP_STANDARD 1"):this.shadowType===e.PShadowType.variance?i.push("SHADOWMAP_VSM 1"):(i.push("SHADOWMAP_EVSM 1"),i.push("SHADOWMAP_EVSM_PCF 1")),n&&i.push("USE_SHADOW_MAPPING 1")),this.material.materialType!==e.PMaterialType.unlit&&(t>0&&this.geometry.hasNormals()&&(i.push("USE_PUNCTUAL 1"),i.push("LIGHT_COUNT ".concat(t))),void 0!==o&&o.available&&(i.push("USE_IBL 1"),i.push("USE_TEX_LOD 1"),o.hasDiffuseImage||i.push("IRRADIANCE_COEFFICIENTS 1")));var a=R.getInstance().renderMode3D,s=this.getRenderMode3DDefine(a);return void 0!==s&&(i.push("DEBUG_OUTPUT 1"),i.push("".concat(s," 1"))),i},n.prototype.addToRenderObjectSet=function(e){e.add(this.effectsMesh)},n.prototype.dispose=function(){var e,n,o,i,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===(e=this.jointMatrixTexture)||void 0===e||e.dispose(),this.jointMatrixTexture=void 0,null===(n=this.jointNormalMatTexture)||void 0===n||n.dispose(),this.jointNormalMatTexture=void 0,null===(o=this.effectsMesh)||void 0===o||o.dispose({geometries:t.DestroyOptions.keep,material:t.DestroyOptions.keep}),this.effectsMesh=void 0,null===(i=this.shadowMesh)||void 0===i||i.dispose({geometries:t.DestroyOptions.keep,material:t.DestroyOptions.keep}),this.shadowMesh=void 0,null===(r=this.shadowMaterial)||void 0===r||r.dispose(),this.shadowMaterial=void 0},n.prototype.updateUniformsForScene=function(e,t,n){this.updateUniformsByAnimation(e,t),this.updateUniformsByScene(n),this.material.updateUniforms(this.getModelMaterial())},n.prototype.updateUniformForShadow=function(e){var t=this.getShadowModelMaterial();void 0!==t&&(t.setMatrix("u_ViewProjectionMatrix",e.viewProjectionMatrix),void 0!==this.shadowMaterial&&this.shadowMaterial.updateUniforms(t))},n.prototype.hitTesting=function(t,n,o,i){var r=this.boundingBox,a=j(t,n,r.min,r.max),s=[];if(void 0!==a){if(void 0!==this.skin)this.skin.animationMatrices.forEach((function(e){s.push((new T).multiplyMatrices(i,e))}));var c=new ie,l=this.material.faceSideMode===e.PFaceSideMode.both;return c.create(this.geometry.geometry,l,s),c.getHitPoint(t,n)}},n.prototype.computeBoundingBox=function(e){if(void 0===this.skin&&!this.boundingBox.isEmpty())return this.boundingBox;var t=[];void 0!==this.skin&&this.skin.animationMatrices.forEach((function(n){t.push((new T).multiplyMatrices(e,n))}));var n=new oe;return n.create(this.geometry.geometry,t),n.getBoundingBox(this.boundingBox)},n.prototype.getRenderMode3DDefine=function(e){switch(e){case t.spec.RenderMode3D.uv:return"DEBUG_UV";case t.spec.RenderMode3D.normal:return"DEBUG_NORMAL";case t.spec.RenderMode3D.basecolor:return"DEBUG_BASECOLOR";case t.spec.RenderMode3D.alpha:return"DEBUG_ALPHA";case t.spec.RenderMode3D.metallic:return"DEBUG_METALLIC";case t.spec.RenderMode3D.roughness:return"DEBUG_ROUGHNESS";case t.spec.RenderMode3D.ao:return"DEBUG_OCCLUSION";case t.spec.RenderMode3D.emissive:return"DEBUG_EMISSIVE"}},n.prototype.updateUniformsByAnimation=function(e,t){var n=this.getModelMaterial(),o=this.getShadowModelMaterial();n.setMatrix("u_ModelMatrix",e),n.setMatrix("u_NormalMatrix",t),void 0!==o&&(o.setMatrix("u_ModelMatrix",e),o.setMatrix("u_NormalMatrix",t));var i=this.skin;if(void 0!==i){var r=this.jointMatrixList,a=this.jointNormalMatList;if(i.computeMeshAnimMatrices(e,r,a),i.textureDataMode){var s=this.jointMatrixTexture,c=this.jointNormalMatTexture;s.update(r),c.update(a),n.setTexture("u_jointMatrixSampler",s.getTexture()),n.setTexture("u_jointNormalMatrixSampler",c.getTexture())}else{var l=[],u=[];r.forEach((function(e){return l.push(e)})),a.forEach((function(e){return u.push(e)})),n.setMatrixNumberArray("u_jointMatrix",l),n.setMatrixNumberArray("u_jointNormalMatrix",u),void 0!==o&&(o.setMatrixNumberArray("u_jointMatrix",l),o.setMatrixNumberArray("u_jointNormalMatrix",u))}}var h=this.morph;if(void 0!==h&&h.hasMorph()){var f=h.morphWeightsArray,d=[];f.forEach((function(e){return d.push(e)})),n.setFloats("u_morphWeights",d),void 0!==o&&o.setFloats("u_morphWeights",d)}},n.prototype.updateUniformsByScene=function(e){var t,n=this.getModelMaterial();if(n.setMatrix("u_ViewProjectionMatrix",e.viewProjectionMatrix),n.setVector3("u_Camera",e.cameraPosition),this.isEnableShadow(),!this.isUnlitMaterial()){for(var o=e.maxLightCount,i=e.lightList,r=0;r<o;r++)if(r<i.length){var a=i[r],s=a.visible?a.intensity:0;n.setVector3("u_Lights[".concat(r,"].direction"),a.getWorldDirection()),n.setFloat("u_Lights[".concat(r,"].range"),a.range),n.setVector3("u_Lights[".concat(r,"].color"),a.color),n.setFloat("u_Lights[".concat(r,"].intensity"),s),n.setVector3("u_Lights[".concat(r,"].position"),a.getWorldPosition()),n.setFloat("u_Lights[".concat(r,"].innerConeCos"),Math.cos(a.innerConeAngle)),n.setFloat("u_Lights[".concat(r,"].outerConeCos"),Math.cos(a.outerConeAngle)),n.setInt("u_Lights[".concat(r,"].type"),a.lightType),n.setVector2("u_Lights[".concat(r,"].padding"),a.padding)}else n.setVector3("u_Lights[".concat(r,"].direction"),v.ZERO),n.setFloat("u_Lights[".concat(r,"].range"),0),n.setVector3("u_Lights[".concat(r,"].color"),v.ZERO),n.setFloat("u_Lights[".concat(r,"].intensity"),0),n.setVector3("u_Lights[".concat(r,"].position"),v.ZERO),n.setFloat("u_Lights[".concat(r,"].innerConeCos"),0),n.setFloat("u_Lights[".concat(r,"].outerConeCos"),0),n.setInt("u_Lights[".concat(r,"].type"),99999),n.setVector2("u_Lights[".concat(r,"].padding"),g.ZERO);var c=e.skybox;if(void 0!==c&&c.available){if(n.setVector2("u_IblIntensity",new g(c.currentIntensity,c.currentReflectionsIntensity)),n.setTexture("u_brdfLUT",c.brdfLUT),void 0!==c.diffuseImage)n.setTexture("u_DiffuseEnvSampler",c.diffuseImage);else{var l=c.irradianceCoeffs;["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(e,t){n.setVector3("u_shCoefficients.".concat(e),v.fromArray(l[t]))}))}n.setInt("u_MipCount",null!==(t=c.specularMipCount)&&void 0!==t?t:1),n.setTexture("u_SpecularEnvSampler",c.specularImage)}}},n.prototype.hasSkin=function(){return void 0!==this.skin},n.prototype.getEffectsGeometry=function(){return this.geometry.geometry},n.prototype.setGeometry=function(e){this.geometry=e instanceof Qe?e:new Qe(e)},n.prototype.setMaterial=function(e){this.material=e instanceof Pe||e instanceof we?e:Oe(e)},n.prototype.getModelMaterial=function(){return this.effectsMesh.material},n.prototype.getShadowModelMaterial=function(){var e;return null===(e=this.shadowMesh)||void 0===e?void 0:e.material},n.prototype.isEnableShadow=function(){return this.shadowType!==e.PShadowType.none&&this.material.materialType!==e.PMaterialType.unlit},n.prototype.isUnlitMaterial=function(){return this.material.materialType===e.PMaterialType.unlit},n.prototype.hasMorph=function(){return void 0!==this.morph&&this.morph.hasMorph()},n.prototype.getWorldBoundingBox=function(){if(void 0===this.parent)return this.boundingBox.isEmpty()&&this.computeBoundingBox(T.fromIdentity()),this.boundingBox;var e=this.parent.matrix;return this.boundingBox.isEmpty()&&this.computeBoundingBox(e.clone().invert()),this.boundingBox.clone().applyMatrix4(e)},n}(),Qe=function(){function e(e){this.geometry=e,this.attributeNames=e.getAttributeNames()}return e.prototype.dispose=function(){this.geometry=void 0,this.attributeNames=[]},e.prototype.hasAttribute=function(e){return-1!==this.attributeNames.findIndex((function(t){return t===e}))},e.prototype.setHide=function(e){var t=this.geometry;if(0===t.getDrawCount()){var n=t.getIndexData();void 0!==n&&t.setDrawCount(n.length)}e?t.getDrawCount()>=0&&t.setDrawCount(-t.getDrawCount()):t.getDrawCount()<0&&t.setDrawCount(-t.getDrawCount())},e.prototype.isCompressed=function(){this.geometry.getAttributeData("a_Position");return!1},e.prototype.hasPositions=function(){return this.hasAttribute("a_Position")},e.prototype.hasNormals=function(){return this.hasAttribute("a_Normal")},e.prototype.hasTangents=function(){return this.hasAttribute("a_Tangent")},e.prototype.hasUVCoords=function(e){return this.hasAttribute("a_UV".concat(e))},e.prototype.hasColors=function(){return this.hasAttribute("a_Color")},e.prototype.hasJoints=function(){return this.hasAttribute("a_Joint1")},e.prototype.hasWeights=function(){return this.hasAttribute("a_Weight1")},e}(),Ze=function(){function e(e,t){this.item=e,this.parentItem=t,this.options=e.content.options;var n=!0,o=new he,i=e.content.options;i.primitives.forEach((function(e,t){if(0===t)o.create(e.geometry);else{var i=new he;i.create(e.geometry)?o.equals(i)||(n=!1,console.error("Morpth target mismatch between primtives: ".concat(JSON.stringify(o),", ").concat(JSON.stringify(i)))):n=!1}})),n?(void 0!==i.weights&&o.initWeights(i.weights),this.morphObj=o):this.morphObj=new he}return e.prototype.hasMorphTarget=function(){return this.morphObj.hasMorph()},e.prototype.getMorphObj=function(){if(this.hasMorphTarget())return this.morphObj},e.prototype.getParentId=function(){return this.item.parentId},e.prototype.getName=function(){return this.item.name},e.prototype.isHide=function(){return!0===this.options.hide},e.prototype.getParentNode=function(){var e=this.getParentIndex();if(void 0!==this.parentItem&&e>=0)return this.parentItem.content.getNodeById(e)},e.prototype.getParentIndex=function(){var e;return null!==(e=this.options.parent)&&void 0!==e?e:-1},e.prototype.getPrimitives=function(){return this.options.primitives},e.prototype.getPrimitiveCount=function(){return this.options.primitives.length},e.prototype.hasSkin=function(){return void 0!==this.options.skin},e.prototype.getSkinOpts=function(){return this.options.skin},e.prototype.getSkinObj=function(e){var t=this.getSkinOpts();if(void 0!==t){var n=new ue;return n.create(t,e,this.parentItem),n}},e}(),$e=function(){function n(e){this.maxLightCount=16,this.renderSkybox=!1,this.compName="SceneManger",this.itemList=[],this.meshList=[],this.engine=e,this.lightManager=new Ge,this.cameraManager=new ke,this.shadowManager=new Je,this.parentId2Mesh=new Map,this.enableDynamicSort=!1,this.tickCount=0,this.lastTickSecond=-1,this.sceneAABBCache=new M,this.renderedMeshSet=new He,this.allRenderedMeshSet=new Set}return n.prototype.initial=function(e){this.clean(),this.compName=e.componentName,this.renderer=e.renderer,this.engine=e.renderer.engine,this.sceneCache=e.sceneCache,this.enableDynamicSort=!0===e.enableDynamicSort,this.renderSkybox=e.renderSkybox,this.maxLightCount=e.lightItemCount,this.cameraManager.initial(this.renderer.getWidth(),this.renderer.getHeight()),this.brdfLUT=this.sceneCache.getBrdfLutTexture(),this.initGlobalState(e),this.maxLightCount>8&&console.warn("Too many light items: ".concat(this.maxLightCount," light(s)"))},n.prototype.initGlobalState=function(e){var n,o,i,r,a,s=this.engine.gpuCapability,c=R.getInstance();c.reset(),c.isWebGL2=2===s.level,c.runtimeEnv=null!==(n=e.runtimeEnv)&&void 0!==n?n:t.PLAYER_OPTIONS_ENV_EDITOR,c.compatibleMode=null!==(o=e.compatibleMode)&&void 0!==o?o:"gltf",c.visBoundingBox=null!==(i=e.visBoundingBox)&&void 0!==i&&i,c.renderMode3D=null!==(r=e.renderMode3D)&&void 0!==r?r:t.spec.RenderMode3D.none,c.renderMode3DUVGridSize=null!==(a=e.renderMode3DUVGridSize)&&void 0!==a?a:1/16},n.prototype.clean=function(){this.dispose(),this.compName="",this.renderer=void 0,this.sceneCache=void 0,this.itemList=[],this.meshList=[],this.lightManager=new Ge,this.cameraManager=new ke,this.shadowManager=new Je,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},n.prototype.dispose=function(){var e;this.itemList.forEach((function(e){return e.dispose()})),this.itemList=[],this.meshList.forEach((function(e){return e.dispose()})),this.meshList=[],this.lightManager.dispose(),this.cameraManager.dispose(),this.brdfLUT=void 0,null===(e=this.skybox)||void 0===e||e.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()},n.prototype.addItem=function(e){var n=e.content;if(n instanceof qe){var o=n;void 0!==o.parentItemId&&this.parentId2Mesh.set(o.parentItemId,o),t.addItem(this.meshList,o),this.buildItem(n)}else if(n instanceof Ne){var i=n;i.setup(this.brdfLUT),this.renderSkybox||(i.renderable=!1),this.skybox=i,this.buildItem(n)}else n instanceof Ve?this.lightManager.insertLight(n):this.cameraManager.insertCamera(n);t.addItem(this.itemList,n)},n.prototype.removeItem=function(e){var n=e.content;if(n instanceof qe){var o=n;void 0!==o.parentItemId&&this.parentId2Mesh.delete(o.parentItemId),t.removeItem(this.meshList,o)}else n instanceof Ne?this.skybox=void 0:n instanceof Ve?this.lightManager.remove(n):this.cameraManager.remove(n);t.removeItem(this.itemList,n)},n.prototype.updateDefaultCamera=function(e){var n=new t.Transform(r(r({},e),{valid:!0})),o=(new N).fromEffectsTransform(n);this.cameraManager.updateDefaultCamera(e.fov,e.near,e.far,o.getPosition(),o.getRotation(),e.aspect,e.clipMode)},n.prototype.buildItem=function(e){e instanceof qe?e.build(this.maxLightCount,{},this.skybox):e instanceof Ne&&e.build(this.getSceneCache())},n.prototype.build=function(){var e=this;this.meshList.forEach((function(t){t.build(e.maxLightCount,{},e.skybox)})),void 0!==this.skybox&&this.skybox.build(this.getSceneCache())},n.prototype.tick=function(e){var t=this,n=e,o=this.activeCamera,i=o.viewMatrix,r=o.projectionMatrix,a=r.clone().multiply(i),s={deltaSeconds:n,camera:o,cameraPosition:o.getEye(),viewMatrix:i,projectionMatrix:r,viewProjectionMatrix:a,winSize:o.getSize(),sceneRadius:1,lightList:this.lightManager.lightList,maxLightCount:this.maxLightCount,skybox:this.skybox};this.build(),this.lightManager.tick(n),this.renderedMeshSet.forward(),this.itemList.forEach((function(e){e.tick(n),e.updateUniformsForScene(s),e.addToRenderObjectSet(t.renderedMeshSet.now)})),this.enableDynamicSort&&this.dynamicSortMeshes(s),this.tickCount+=1,this.lastTickSecond+=n},n.prototype.updateDefaultRenderPass=function(e){var t=this;this.enableDynamicSort?(this.renderedMeshSet.last.forEach((function(t){e.removeMeshFromDefaultRenderPass(t)})),this.renderedMeshSet.now.forEach((function(n){e.addMeshToDefaultRenderPass(n),t.allRenderedMeshSet.add(n)}))):(this.renderedMeshSet.forRemovedItem((function(t){e.removeMeshFromDefaultRenderPass(t)})),this.renderedMeshSet.forAddedItem((function(n){e.addMeshToDefaultRenderPass(n),t.allRenderedMeshSet.add(n)})))},n.prototype.dynamicSortMeshes=function(e){var t=[],n=[];this.renderedMeshSet.now.forEach((function(e){t.push(e),n.push(e.priority)})),n.sort((function(e,t){return e-t}));var o=e.viewMatrix;t.sort((function(e,t){var n=Q.isTransparentMesh(e),i=Q.isTransparentMesh(t);if(n&&i){var r=v.fromArray(e.worldMatrix.elements,12),a=v.fromArray(t.worldMatrix.elements,12),s=o.transformPoint(r),c=o.transformPoint(a);return s.z-c.z}return n?1:i?-1:0}));for(var i=-99999,r=0;r<t.length;r++){var a=t[r],s=n[r];i<s?(i=s,a.priority=s):(i+=.1,a.priority=i)}},n.prototype.queryMesh=function(e){var t=this.parentId2Mesh.get(e);if(void 0!==t&&t.visible)return t},n.prototype.removeAllMeshesFromDefaultPass=function(e){this.renderedMeshSet.now.forEach((function(t){e.removeMeshFromDefaultRenderPass(t)}))},n.prototype.getSceneAABB=function(t){var n=null!=t?t:new M;return this.itemList.forEach((function(t){if(t.type===e.PObjectType.mesh){var o=t;if(o.ownerItem){var i=o.ownerItem.getWorldTransform().getWorldMatrix(),r=o.computeBoundingBox(i);r.applyMatrix4(i),n.union(r)}else n.union(o.computeBoundingBox(T.fromIdentity()))}})),n},n.prototype.printDebugInfo=function(){console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),this.meshList.forEach((function(e,t){console.info("Mesh: ",t,e)})),this.cameraManager.getCameraList().forEach((function(e,t){console.info("Camera: ",t,e)})),console.info("Default Camera: ",this.cameraManager.getDefaultCamera()),this.lightManager.lightList.forEach((function(e,t){console.info("Light: ",t,e)})),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")},n.prototype.getRenderer=function(){return this.renderer},n.prototype.getSceneCache=function(){return this.sceneCache},Object.defineProperty(n.prototype,"activeCamera",{get:function(){return this.cameraManager.getActiveCamera()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lightCount",{get:function(){return this.lightManager.lightCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shaderLightCount",{get:function(){return Math.min(10,this.lightManager.lightCount)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"enableShadowPass",{get:function(){return this.shadowManager.isEnable()},enumerable:!1,configurable:!0}),n}(),et="_Native",tt=new Map;function nt(e,t){for(var n,o="".concat(e),i=[],r=0;r<t.length;r++)"number"==typeof t[r]&&tt.has(t[r])?i.push(tt.get(t[r])+"(".concat(t[r],")")):i.push(null===(n=t[r])||void 0===n?void 0:n.toString());return o+(i.length>0?"("+i.join(", ")+")":"()")}function ot(e,t){return function(){var n=e[t+et].apply(this,arguments),o=e.getError();return o>0?(console.info("OpenGLError: "+function(e){var t,n=new Map;return n.set(WebGLRenderingContext.NO_ERROR,"NO_ERROR"),n.set(WebGLRenderingContext.INVALID_ENUM,"INVALID_ENUM"),n.set(WebGLRenderingContext.INVALID_VALUE,"INVALID_VALUE"),n.set(WebGLRenderingContext.INVALID_OPERATION,"INVALID_OPERATION"),n.set(WebGLRenderingContext.INVALID_FRAMEBUFFER_OPERATION,"INVALID_FRAMEBUFFER_OPERATION"),n.set(WebGLRenderingContext.OUT_OF_MEMORY,"OUT_OF_MEMORY"),n.set(WebGLRenderingContext.CONTEXT_LOST_WEBGL,"CONTEXT_LOST_WEBGL"),(null!==(t=n.get(e))&&void 0!==t?t:"UNKNOWN_ERROR")+"(".concat(e,")")}(o)+" ===> "+nt(t,arguments)),console.trace()):console.info(nt(t,arguments)),n}}var it,rt=function(){function e(e,t){this.baseTransform=t.transform,this.animationManager=new ge(e,t),this.build(e)}return e.prototype.tick=function(e){this.animationManager.tick(e)},e.prototype.getNodes=function(){return this.nodes},e.prototype.getNodeById=function(e){var t=this.cacheMap;if(!t[e]){var n="^".concat(e);t[e]=this.allNodes.find((function(e){return e.id===n}))}return t[e]},e.prototype.getNodeByName=function(e){var t=this.cacheMap;return t[e]||(t[e]=this.allNodes.find((function(t){return t.name===e}))),t[e]},e.prototype.getNodeTransform=function(e){var t=this.getNodeById(e);return t?t.transform:this.baseTransform},e.prototype.dispose=function(){var e;this.allNodes=[],this.nodes=[],this.cacheMap={},this.baseTransform=null,null===(e=this.animationManager)||void 0===e||e.dispose(),this.animationManager=null},e.prototype.build=function(e){var n=this,o=this.baseTransform,i=e.nodes.map((function(e,i){return{name:e.name||e.id||i+"",transform:new t.Transform(r(r({},e.transform),{valid:!0}),o),id:"^".concat(e.id||i),children:[],tree:n}}));this.cacheMap={},i.forEach((function(t,n){var r=e.nodes[n].children;t.transform.name=t.name,t.transform.setValid(!0),r&&r.forEach((function(e){var n=i[e];n&&n!==t&&(n.transform.parentTransform!==o&&console.error("Node parent has been set."),n.transform.parentTransform=t.transform,t.children.push(n))}))})),this.allNodes=i,this.nodes=e.children.map((function(e){return i[e]}))},e}(),at=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return i(n,e),Object.defineProperty(n.prototype,"type",{get:function(){return t.spec.ItemType.tree},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(e){this.options=e.content.options.tree,this.timeline=new t.TimelineComponent(e.content,this),this.timeline.getRenderData(0,!0)},n.prototype.onLifetimeBegin=function(){this.content.baseTransform.setValid(!0)},n.prototype.onItemRemoved=function(e,t){void 0!==this.content&&this.content.dispose()},n.prototype.onItemUpdate=function(e,t){var n,o=.001*(this.timeInms-this.delayInms);null===(n=this.timeline)||void 0===n||n.getRenderData(o,!0),this.content.tick(e)},n.prototype.doCreateContent=function(){return new rt(this.options,this)},n.prototype.getNodeTransform=function(e){if(void 0===this.content)return this.transform;var t=this.id+"^";if(0===e.indexOf(t)){var n=e.substring(t.length);return this.content.getNodeTransform(n)}return this.transform},n}(t.VFXItem),st=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return i(o,e),Object.defineProperty(o.prototype,"type",{get:function(){return n},set:function(e){},enumerable:!1,configurable:!0}),o.prototype.onConstructed=function(e){var n;this.options=e,this.duration=e.duration,this.delay=null!==(n=e.delay)&&void 0!==n?n:0;var o=e.content.interaction;this.bounding=o&&JSON.parse(JSON.stringify(o)),(t.Item.is(e,t.spec.ItemType.camera)||t.Item.is(e,t.spec.ItemType.light))&&(this.timeline=new t.TimelineComponent(e.content,this),this.timeline.getRenderData(0,!0)),t.Item.is(e,t.spec.ItemType.skybox)&&this.overwriteSkyboxFromCache(e.content.options)},o.prototype.handleVisibleChanged=function(e){void 0!==this.content&&this.content.onVisibleChanged(e)},o.prototype.doCreateContent=function(e){var t,n;switch(null===(t=this.options)||void 0===t?void 0:t.type){case"mesh":var o=this.options.content.options;re.assertModelMeshOptions(o);var i=null===(n=this.composition)||void 0===n?void 0:n.getEngine();return new qe(i,this.options,this);case"camera":var r=this.options.content.options;re.assertModelCameraOptions(r);var a=e.width,s=e.height;return new De(this.options,a,s,this);case"light":var c=this.options.content.options;return re.assertModelLightOptions(c),new Ve(this.options,this);case"skybox":var l=this.options.content.options;return re.assertModelSkyboxOptions(l),new Ne(this.options,this);default:throw new Error("Invalid model item type, options: ".concat(this.options))}},o.prototype.overwriteSkyboxFromCache=function(e){var t,n=(null===(t=this.composition)||void 0===t?void 0:t.loaderData.cache).getSkyboxOptions();void 0!==n&&(void 0===e.specularImage||void 0===e.diffuseImage&&void 0===e.irradianceCoeffs)&&(e.diffuseImage=n.diffuseImage,e.irradianceCoeffs=n.irradianceCoeffs,e.specularImage=n.specularImage,e.specularImageSize=n.specularImageSize,e.specularMipCount=n.specularMipCount)},o.prototype.computeBoundingBox=function(){var e;if(void 0!==this._content&&this._content instanceof qe){var n=this.transform.getWorldMatrix(),o=this._content.computeBoundingBox(n),i=o.getCenter(new v),r=o.getSize(new v);return this.bounding={behavior:null===(e=this.bounding)||void 0===e?void 0:e.behavior,type:t.spec.ModelBoundingType.box,center:[i.x,i.y,i.z],size:[r.x,r.y,r.z]},this.bounding}},o.prototype.updateTransform=function(){var e=this._content;if(void 0!==e){var t=this.transform.getWorldMatrix();e.matrix=t,e instanceof De&&this.composition&&(this.composition.camera.position=this.transform.position.clone(),this.composition.camera.setQuat(this.transform.quat),this.composition.camera.near=e.nearPlane,this.composition.camera.far=e.farPlane,this.composition.camera.fov=e.fovy)}},o.prototype.setTransform=function(e,t){var n,o;void 0!==e&&(this.transform.setPosition(e.x,e.y,e.z),null===(n=this.timeline)||void 0===n||n.updatePosition(e.x,e.y,e.z)),void 0!==t&&(this.transform.setRotation(t.x,t.y,t.z),null===(o=this.timeline)||void 0===o||o.updateRotation(t.x,t.y,t.z)),this.updateTransform()},o.prototype.onLifetimeBegin=function(e,t){void 0!==this.content&&(this.content instanceof qe&&this.parent instanceof at&&this.content.updateParentItem(this.parent),this.content.onVisibleChanged(!0))},o.prototype.onItemUpdate=function(e,t){var n,o=.001*(this.timeInms-this.delayInms);null===(n=this.timeline)||void 0===n||n.getRenderData(o,!0),this.updateTransform()},o.prototype.onItemRemoved=function(e,t){void 0!==this.content&&(this.content.onEntityRemoved(),this.content.dispose())},o.prototype.onEnd=function(){this.endBehavior===t.spec.END_BEHAVIOR_DESTROY&&this.content&&this.content.onVisibleChanged(!1)},o.prototype.getHitTestParams=function(e){this.computeBoundingBox();var n=this.bounding;if(n&&(e||Number.isInteger(n.behavior))){var o=n.type;if(o===t.spec.ModelBoundingType.box){if(this.content instanceof qe){var i=this.content;return{behavior:n.behavior,type:t.HitTestType.custom,collect:function(e,t){return i.hitTesting(e.origin,e.direction)}}}var r=this.transform.getWorldMatrix();return{behavior:n.behavior,type:t.HitTestType.custom,collect:function(e,t){return G(e,r,n)}}}if(o===t.spec.ModelBoundingType.sphere){var a=new v;this.transform.assignWorldTRS(a);var s=new v;return n.center&&s.setFromArray(n.center),s.add(a),{type:o,behavior:n.behavior,radius:n.radius||0,center:s}}}},o}(t.VFXItem),ct=function(o){function r(){var e=null!==o&&o.apply(this,arguments)||this;return e.name="model",e.deltaTime=0,e.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,e.compatibleMode="gltf",e.renderSkybox=!0,e.visBoundingBox=!1,e.autoAdjustScene=!1,e.enableDynamicSort=!1,e.renderMode3D=t.spec.RenderMode3D.none,e.renderMode3DUVGridSize=1/16,e}return i(r,o),r.prepareResource=function(e,t){var n,o,i;return a(this,void 0,void 0,(function(){var r,a,c,l,u;return s(this,(function(s){switch(s.label){case 0:return r=null!==(n=t.env)&&void 0!==n?n:"",a="gltf",c=!1,void 0!==t.pluginData&&(l=["compatibleMode","renderSkybox","visBoundingBox","autoAdjustScene","enableDynamicSort","renderMode3D","renderMode3DUVGridSize"],u=t.pluginData,l.forEach((function(t){return e.storage[t]=u[t]})),e.storage.runtimeEnv=r,a=null!==(o=t.pluginData.compatibleMode)&&void 0!==o?o:a,c=null!==(i=t.pluginData.autoAdjustScene)&&void 0!==i?i:c),$.preprocessEffectsScene(e,r,a,c),[4,Be.loadStaticResources()];case 1:return s.sent(),[2]}}))}))},r.prototype.onCompositionConstructed=function(e,t){var n,o,i,r,a,s,c,l;this.runtimeEnv=null!==(n=t.storage.runtimeEnv)&&void 0!==n?n:this.runtimeEnv,this.compatibleMode=null!==(o=t.storage.compatibleMode)&&void 0!==o?o:this.compatibleMode,this.renderSkybox=null!==(i=t.storage.renderSkybox)&&void 0!==i?i:this.renderSkybox,this.visBoundingBox=null!==(r=t.storage.visBoundingBox)&&void 0!==r?r:this.visBoundingBox,this.autoAdjustScene=null!==(a=t.storage.autoAdjustScene)&&void 0!==a?a:this.autoAdjustScene,this.enableDynamicSort=null!==(s=t.storage.enableDynamicSort)&&void 0!==s?s:this.enableDynamicSort,this.renderMode3D=null!==(c=t.storage.renderMode3D)&&void 0!==c?c:this.renderMode3D,this.renderMode3DUVGridSize=null!==(l=t.storage.renderMode3DUVGridSize)&&void 0!==l?l:this.renderMode3DUVGridSize;var u=e.renderer.engine;e.loaderData.sceneManager=new $e(u);var h=new Be(u);h.setup(!1),e.loaderData.cache=h,$.setupItem3DOptions(t,h,e)},r.prototype.onCompositionWillReset=function(e,t){this.getCache(e).getRenderPasses().forEach((function(e){t.removeRenderPass(e)})),this.getSceneManager(e).removeAllMeshesFromDefaultPass(t)},r.prototype.onCompositionReset=function(e,t){var n=this.getSceneManager(e),o=this.getCache(e),i=this.getLightItemCount(e);n.initial({componentName:"".concat(e.id),renderer:e.renderer,sceneCache:o,runtimeEnv:this.runtimeEnv,compatibleMode:this.compatibleMode,visBoundingBox:this.visBoundingBox,enableDynamicSort:this.enableDynamicSort,renderMode3D:this.renderMode3D,renderMode3DUVGridSize:this.renderMode3DUVGridSize,renderSkybox:this.renderSkybox,lightItemCount:i}),this.updateSceneCamera(e,n)},r.prototype.onCompositionDestroyed=function(e){this.disposeSceneManager(e),this.disposeCache(e)},r.prototype.onCompositionUpdate=function(e,t){this.deltaTime=t},r.prototype.onCompositionItemLifeBegin=function(e,t){t.type===n&&this.getSceneManager(e).addItem(t)},r.prototype.onCompositionItemRemoved=function(e,t){t.type===n&&this.getSceneManager(e).removeItem(t)},r.prototype.prepareRenderFrame=function(e,t){var o,i,r,a=this.getSceneManager(e);if(this.autoAdjustScene&&1==a.tickCount){var s=e.camera,c=(new N).fromMatrix4(s.getViewMatrix()),l=(new F).fromPTransform(c).zAxis.clone(),u=null!==(o=s.fov)&&void 0!==o?o:45,h=null!==(i=s.aspect)&&void 0!==i?i:1,f=a.getSceneAABB(),d=f.clone().applyMatrix4(c.getMatrix()).getSize(new v).multiply(.5),p=d.x,m=d.y,g=m*Math.max(p/m/h,1),y=f.getCenter(new v),b=g/Math.tan(.5*u*L),T=y.clone().add(l.clone().multiply(b+d.z));e.camera.position=T,null===(r=e.items)||void 0===r||r.forEach((function(e){if(e.type===n){var t=e;if(t.content instanceof De){var o=t.transform.parentTransform.getWorldMatrix().invert().transformPoint(T);t.setTransform(o),console.info("Scene AABB [".concat(f.min.toArray(),"], [").concat(f.max.toArray(),"]")),console.info("Update camera position [".concat(o.toArray(),"]"))}}}))}return this.updateSceneCamera(e,a),a.tick(this.deltaTime),a.updateDefaultRenderPass(t),!0},r.prototype.postProcessFrame=function(e,t){this.getSceneManager(e).shadowManager.updateRenderPass(t)},r.prototype.getLightItemCount=function(t){var n=0;return t.items.forEach((function(t){var o,i;t instanceof st&&((null===(o=t.content)||void 0===o?void 0:o.type)!==e.PObjectType.light&&"light"!==(null===(i=t.options)||void 0===i?void 0:i.type)||n++)})),n},r.prototype.updateSceneCamera=function(e,t){t.updateDefaultCamera(e.camera.getOptions())},r.prototype.getSceneManager=function(e){return e.loaderData.sceneManager},r.prototype.getCache=function(e){return e.loaderData.cache},r.prototype.disposeCache=function(e){var t=e.loaderData;t.cache.dispose(),delete t.cache},r.prototype.disposeSceneManager=function(e){var t=e.loaderData;t.sceneManager.dispose(),delete t.sceneManager},r}(t.AbstractPlugin),lt=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="tree",t.order=2,t}return i(n,e),n.prototype.onCompositionConstructed=function(e,t){var n=e.getEngine(),o=new ve(n);e.loaderData.animSystem=o},n.prototype.onCompositionWillReset=function(e,t){var n=this.getAnimationSystem(e);void 0!==n&&n.dispose()},n.prototype.onCompositionDestroyed=function(e){var t=this.getAnimationSystem(e);void 0!==t&&t.dispose(),delete e.loaderData.animSystem},n.prototype.onCompositionItemLifeBegin=function(e,n){if(n.type===t.spec.ItemType.tree){var o=this.getAnimationSystem(e),i=n.content;null==o||o.insert(i.animationManager)}},n.prototype.onCompositionItemRemoved=function(e,n){if(n.type===t.spec.ItemType.tree){var o=this.getAnimationSystem(e),i=n.content;null==o||o.delete(i.animationManager)}},n.prototype.getAnimationSystem=function(e){var t=e.loaderData.animSystem;if(void 0!==t)return t},n}(t.AbstractPlugin);e.CameraGestureType=void 0,(it=e.CameraGestureType||(e.CameraGestureType={}))[it.none=0]="none",it[it.translate=1]="translate",it[it.rotate_focus=2]="rotate_focus",it[it.rotate_self=3]="rotate_self",it[it.scale=4]="scale";var ut,ht=function(){function n(t){this.composition=t,this.cameraTransform=new N,this.cameraCoordiante=new F,this.startParams={type:e.CameraGestureType.none,mouseEvent:!1,clientX:0,clientY:0,clientWidth:512,clientHeight:512,target:""}}return n.prototype.getItem=function(){var e,t=this;return null===(e=this.composition.items)||void 0===e?void 0:e.find((function(e){return e.id===t.getCurrentTarget()}))},n.prototype.getCurrentTarget=function(){return this.startParams.target},n.prototype.getCurrentType=function(){return this.startParams.type},n.prototype.onKeyEvent=function(n){var o,i,a,s;this.startParams.target!==n.cameraID&&(this.startParams.target=n.cameraID,this.startParams.type=e.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 l=this.composition.camera,u=new t.Transform(r(r({},l.getOptions()),{valid:!0})),h=(new N).fromEffectsTransform(u),f=(new F).fromPTransform(h),d=null!==(o=n.xAxis)&&void 0!==o?o:0,p=null!==(i=n.yAxis)&&void 0!==i?i:0,m=null!==(a=n.zAxis)&&void 0!==a?a:0,g=f.xAxis.clone().multiply(d);if(g.add(f.yAxis.clone().multiply(p)),g.add(f.zAxis.clone().multiply(m)),g.lengthSquared()<1e-5)return l.getOptions();g.normalize();var v=null!==(s=n.speed)&&void 0!==s?s:.1,y=h.getPosition();return y.add(g.clone().multiply(v)),c.transform.setPosition(y.x,y.y,y.z),c.updateTransform(),this.startParams.type===e.CameraGestureType.rotate_self&&(this.cameraTransform.setPosition(y),this.cameraCoordiante.origin=y),l.getOptions()},n.prototype.onXYMoveBegin=function(t,n,o,i,r){var a={type:e.CameraGestureType.translate,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,target:r};return this.startGesture(a)},n.prototype.onXYMoving=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.translate,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=o?o:.015};return this.moveGesture(r)},n.prototype.onXYMoveEnd=function(){this.endGesture()},n.prototype.onZMoveBegin=function(t,n,o,i,r){var a={type:e.CameraGestureType.scale,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,target:r};return this.startGesture(a)},n.prototype.onZMoving=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.scale,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=o?o:.015};return this.moveGesture(r)},n.prototype.onZMoveEnd=function(){this.endGesture()},n.prototype.onRotateBegin=function(t,n,o,i,r){var a={type:e.CameraGestureType.rotate_self,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,target:r};return this.startGesture(a)},n.prototype.onRotating=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.rotate_self,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=o?o:1.5};return this.moveGesture(r)},n.prototype.onRotateEnd=function(){this.endGesture()},n.prototype.onRotatePointBegin=function(t,n,o,i,r,a){var s={type:e.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,focusPoint:r,target:a};return this.startGesture(s)},n.prototype.onRotatingPoint=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,focusPoint:i.focusPoint,target:i.target,speed:null!=o?o:8};return this.moveGesture(r)},n.prototype.onRotatePointEnd=function(){this.endGesture()},n.prototype.moveTo=function(t,n){var o;this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var i=this.getItem();void 0!==i?((o=i.transform).setPosition.apply(o,l([],c(n),!1)),i.updateTransform()):console.warn("can't find camera item")},n.prototype.rotateTo=function(t,n){var o;this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var i=this.getItem();void 0!==i?((o=i.transform).setQuaternion.apply(o,l([],c(n),!1)),i.updateTransform()):console.warn("can't find camera item")},n.prototype.onFocusPoint=function(t,n,o){this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var i=this.getItem();if(void 0!==i){var r=null!=o?o:5,a=v.fromArray(n),s=(new N).fromEffectsTransform(i.transform),c=(new F).fromPTransform(s),l=v.fromArray(c.zAxis.toArray()).multiply(1).clone().multiply(r),u=a.clone().add(l);i.transform.setPosition(u.x,u.y,u.z),i.updateTransform(),this.startParams.target=""}else console.warn("can't find camera item")},n.prototype.getCameraTransform=function(){var e=this.composition.camera,n=new t.Transform(e.getOptions());return n.setValid(!0),n},n.prototype.initKeyEvent=function(t,n){this.startParams.target=t,this.startParams.speed=n,this.startParams.type=e.CameraGestureType.translate,this.updateCameraTransform(this.composition.camera.getOptions())},n.prototype.startGesture=function(e){return this.startParams=e,this.updateCameraTransform(this.composition.camera.getOptions()),this.getItem()||console.warn("invalid target"),this.composition.camera.getOptions()},n.prototype.moveGesture=function(t){var n;if(this.getCurrentType()===t.type){var o=this.getItem();if(void 0===o)return console.warn("can't find camera item"),this.composition.camera.getOptions();var i=null!==(n=t.speed)&&void 0!==n?n:1.015,r=this.cameraCoordiante.xAxis,a=this.cameraCoordiante.yAxis,s=this.cameraCoordiante.zAxis,c=t.clientX-this.startParams.clientX,l=t.clientY-this.startParams.clientY;if(t.type===e.CameraGestureType.translate)(u=this.cameraTransform.getPosition().clone()).add(r.clone().multiply(-c*i)),u.add(a.clone().multiply(l*i)),o.transform.setPosition(u.x,u.y,u.z),o.setTransform(o.transform.position,o.transform.rotation);else if(t.type===e.CameraGestureType.scale){var u;(u=this.cameraTransform.getPosition().clone()).add(s.clone().multiply(l*i)),o.transform.setPosition(u.x,u.y,u.z),o.setTransform(o.transform.position,o.transform.rotation)}else if(t.type===e.CameraGestureType.rotate_self){var h=c/t.clientWidth,f=l/t.clientHeight,d=h*Math.PI*i*.5,p=f*Math.PI*i*.5,m=S.fromAxisAngle(v.Y,-d),g=S.fromAxisAngle(r,-p);m.multiply(g),m.multiply(this.cameraTransform.getRotation()),o.transform.setQuaternion(m.x,m.y,m.z,m.w),o.setTransform(o.transform.position,o.transform.rotation)}else if(t.type===e.CameraGestureType.rotate_focus){h=c/t.clientWidth,f=l/t.clientHeight,d=h*Math.PI*i,p=f*Math.PI*i,m=S.fromAxisAngle(v.Y,-d),g=S.fromAxisAngle(r,-p);m.multiply(g);var y=m.toMatrix4(new T),b=v.fromArray(t.focusPoint),_=this.cameraCoordiante.origin.clone().subtract(b);y.transformPoint(_);var x=_.add(b);m.multiply(this.cameraTransform.getRotation()),o.transform.setPosition(x.x,x.y,x.z),o.transform.setQuaternion(m.x,m.y,m.z,m.w),o.setTransform(x,o.transform.rotation)}else console.warn("not implement")}else console.warn("invalid move type");return this.composition.camera.getOptions()},n.prototype.endGesture=function(){this.startParams.type=e.CameraGestureType.none,this.startParams.mouseEvent=!1,this.startParams.target=""},n.prototype.updateCameraTransform=function(e){var n=new t.Transform(e);n.setValid(!0),this.cameraTransform.fromEffectsTransform(n),this.cameraCoordiante.fromPTransform(this.cameraTransform)},n}(),ft=function(){function e(){}return e.getTransformFromMat4=function(e){var t=e.getTransform(),n=t.rotation.toEuler(new _);return{position:t.translation.toArray(),rotation:n.toArray(),scale:t.scale.toArray()}},e.getEffectsTransformFromMat4=function(e){var n=new t.Transform({valid:!0});return n.cloneFromMatrix(e),{position:n.position.toArray(),rotation:n.rotation.toArray(),scale:n.scale.toArray()}},e.getTransformFromTranslation=function(e){return{position:e.toArray()}},e.getTransformFromDirection=function(t){var n=v.fromArray([1,0,0]),o=t.clone().normalize(),i=n.clone().cross(o);if(i.length()<.01)return{};i.normalize();var r=o.dot(n),a=Math.acos(r),s=T.fromRotationAxis(i,a);return e.getTransformFromMat4(s)},e.getEffectsTransformFromDirection=function(t){var n=v.fromArray([0,0,1]),o=t.clone().normalize(),i=n.clone().cross(o);if(i.length()<.01)return{};i.normalize();var r=o.dot(n),a=Math.acos(r),s=T.fromRotationAxis(i,a);return e.getEffectsTransformFromMat4(s)},e.getTransformFromTransDir=function(t,n){var o=e.getTransformFromDirection(n);return o.position=t.toArray(),o},e.getEffectsTransformFromTransDir=function(t,n){var o=e.getEffectsTransformFromDirection(n);return o.position=t.toArray(),o},e.getEulerFromQuat=function(e){var t=new _,n=new S(e.x,e.y,e.z,e.w);return t.order=x.ZYX,t.setFromQuaternion(n),[t.x,t.y,t.z]},e.getQuatFromEuler=function(e){var t=new S;return t.setFromEuler(e),[t.x,t.y,t.z,t.w]},e.toPlayerColor3=function(t){return[e.scaleTo255(t[0]),e.scaleTo255(t[1]),e.scaleTo255(t[2])]},e.toPlayerColor4=function(t){return[e.scaleTo255(t[0]),e.scaleTo255(t[1]),e.scaleTo255(t[2]),e.scaleTo255(t[3])]},e.scaleTo255=function(e){var t=255*e;return Math.max(0,Math.min(t,255))},e.scaleTo1=function(e){var t=e/255;return Math.max(0,Math.min(t,1))},e}();var dt=function(){function n(){}return n.prototype.initial=function(e,t){this.engine=e,this._loaderOptions=null!=t?t:{}},n.prototype.processLight=function(e,t){var n=this;e.forEach((function(e){void 0===e.color?e.color=t?[255,255,255,255]:[1,1,1,1]:(e.color[0]=n.scaleColorVal(e.color[0],t),e.color[1]=n.scaleColorVal(e.color[1],t),e.color[2]=n.scaleColorVal(e.color[2],t),e.color[3]=n.scaleColorVal(e.color[3],t))}))},n.prototype.processCamera=function(e,t){var n=t?180/Math.PI:Math.PI/180;e.forEach((function(e){void 0!==e.perspective&&(e.perspective.yfov*=n)}))},n.prototype.processMaterial=function(e,t){var n=this;e.forEach((function(e){void 0===e.baseColorFactor?e.baseColorFactor=t?[255,255,255,255]:[1,1,1,1]:(e.baseColorFactor[0]=n.scaleColorVal(e.baseColorFactor[0],t),e.baseColorFactor[1]=n.scaleColorVal(e.baseColorFactor[1],t),e.baseColorFactor[2]=n.scaleColorVal(e.baseColorFactor[2],t),e.baseColorFactor[3]=n.scaleColorVal(e.baseColorFactor[3],t)),void 0===e.emissiveFactor?e.emissiveFactor=t?[255,255,255,255]:[1,1,1,1]:(e.emissiveFactor[0]=n.scaleColorVal(e.emissiveFactor[0],t),e.emissiveFactor[1]=n.scaleColorVal(e.emissiveFactor[1],t),e.emissiveFactor[2]=n.scaleColorVal(e.emissiveFactor[2],t),e.emissiveFactor[3]=n.scaleColorVal(e.emissiveFactor[3],t)),t&&void 0!==e.occlusionTexture&&void 0===e.occlusionTexture.strength&&(e.occlusionTexture.strength=n.isTiny3dMode()?0:1)}))},n.prototype.createTreeOptions=function(e){return{nodes:e.nodes.map((function(e,t){var n,o,i,r=e.children.map((function(e){if(void 0===e.nodeIndex)throw new Error("Undefined nodeIndex for child ".concat(e));return e.nodeIndex}));if(void 0!==e.matrix){if(16!==e.matrix.length)throw new Error("Invalid matrix length ".concat(e.matrix.length," for node ").concat(e));var a=T.fromArray(e.matrix).getTransform();n=a.translation.toArray(),o=a.rotation.toArray(),i=a.scale.toArray()}else void 0!==e.translation&&(n=e.translation),void 0!==e.rotation&&(o=e.rotation),void 0!==e.scale&&(i=e.scale);return e.nodeIndex=t,{name:e.name,transform:{position:n,quat:o,scale:i},children:r,id:"".concat(e.nodeIndex)}})),children:e.rootNodes.map((function(e){if(void 0===e.nodeIndex)throw new Error("Undefined nodeIndex for root ".concat(e));return e.nodeIndex})),animation:-1,animations:[]}},n.prototype.createAnimations=function(e){return e.map((function(e){var t=e.channels.map((function(e){return{input:e.input.array,output:e.output.array,node:e.target.node,path:e.target.path,interpolation:e.interpolation}}));return{name:e.name,tracks:t}}))},n.prototype.createGeometry=function(e,t){return new mt(this.engine,e,t).geometry},n.prototype.createMaterial=function(e){return new gt(e,[],this.isTiny3dMode()).material},n.prototype.createTexture2D=function(e,t,n){return Q.createTexture2D(this.engine,e,t,n,this.isTiny3dMode())},n.prototype.createTextureCube=function(e,t){var n=this;if(0==e.length)throw new Error("createTextureCube: Invalid cubeImages length ".concat(e));var o=[];return e.forEach((function(e){var t;if(6!=e.length)throw new Error("createTextureCube: cubeimage count should always be 6, ".concat(e));var i=[];e.forEach((function(e){if(void 0===e.imageData)throw new Error("createTextureCube: Invalid image data from ".concat(e));i.push({type:"buffer",data:e.imageData,mimeType:e.mimeType})})),n.isTiny3dMode()&&(t=c([i[5],i[4]],2),i[4]=t[0],i[5]=t[1]),o.push(i)})),1==o.length?Q.createTextureCubeFromBuffer(this.engine,o[0]):Q.createTextureCubeMipmapFromBuffer(this.engine,o,null!=t?t:Math.pow(2,o.length-1))},n.prototype.createSkybox=function(e){var t,n,o=this,i=null!==(t=e.reflectionsIntensity)&&void 0!==t?t:e.intensity,r=e.irradianceCoefficients,a=e.specularImages.map((function(e){var t,n=e.map((function(e){return{type:"buffer",data:e.imageData,mimeType:e.mimeType}}));return o.isTiny3dMode()&&(t=c([n[5],n[4]],2),n[4]=t[0],n[5]=t[1]),n})),s=a.length-1,l=null!==(n=e.specularImageSize)&&void 0!==n?n:Math.pow(2,s),u={type:"buffer",renderable:this.isSkyboxVis(),intensity:e.intensity,reflectionsIntensity:i,irradianceCoeffs:r,specularImage:a,specularMipCount:s,specularImageSize:l};return Re.createSkyboxOptions(this.engine,u)},n.prototype.createDefaultSkybox=function(t){if("NFT"!==t&&"FARM"!==t)throw new Error("Invalid skybox type name ".concat(t));var n="NFT"===t?e.PSkyboxType.NFT:e.PSkyboxType.FARM,o=Re.getSkyboxParams(n);return Re.createSkyboxOptions(this.engine,o)},n.prototype.scaleColorVal=function(e,t){return t?ft.scaleTo255(e):ft.scaleTo1(e)},n.prototype.scaleColorVec=function(e,t){var n=this;return e.map((function(e){return n.scaleColorVal(e,t)}))},n.prototype.loadScene=function(e){var n;return a(this,void 0,void 0,(function(){var o,i,r,a,c,l=this;return s(this,(function(s){switch(s.label){case 0:if(this._clear(),this._sceneOptions=e,this.engine=null===(n=e.effects.renderer)||void 0===n?void 0:n.engine,this._loaderOptions={compatibleMode:e.gltf.compatibleMode},"string"==typeof(o=e.gltf.resource)||o instanceof Uint8Array)throw new Error("Please load resource by GLTFTools at first");return this._gltfScene=o.scenes[0],this._gltfSkins=this._gltfScene.skins,this._gltfMeshs=o.meshes,this._gltfLights=this._gltfScene.lights,this._gltfCameras=this._gltfScene.cameras,this._gltfImages=o.images,this._gltfTextures=o.textures,this._gltfMaterials=o.materials,this._gltfAnimations=o.animations,this._gltfImageBasedLights=o.imageBasedLights,[4,this._preprocess()];case 1:return s.sent(),r="sceneTree",(i=[]).push(this._createItemTree(r,this._gltfScene)),void 0!==(a=this._createItemSkybox())&&i.push(a),this._gltfScene.nodes.forEach((function(e){if(void 0!==e.mesh){var t=l._createItemMesh(e,r);void 0!==t&&i.push(t)}if(void 0!==e.light){var n=l._createItemLight(e,r);void 0!==n&&i.push(n)}if(void 0!==e.camera){var o=l._createItemCamera(e,r);void 0!==o&&i.push(o)}})),c=new M,this._gltfScene.rootNodes.forEach((function(e){var n=new t.Transform({valid:!0});l._computeSceneAABB(e,n,c)})),[2,{source:this.getRemarkString(),items:i,sceneAABB:{min:c.min.toArray(),max:c.max.toArray()}}]}}))}))},n.prototype._preprocess=function(){return a(this,void 0,void 0,(function(){var t,n,o,i,r,a,l,u=this;return s(this,(function(s){switch(s.label){case 0:this.getTextureManager().initial(this._gltfImages,this._gltfTextures),t=0,s.label=1;case 1:return t<this._gltfMaterials.length?(n=this._gltfMaterials[t],[4,this.tryAddTexture2D(t,n.baseColorTexture,!0)]):[3,8];case 2:return s.sent(),vt.isUnlitMaterial(n)?[3,7]:[4,this.tryAddTexture2D(t,n.metallicRoughnessTexture,!1)];case 3:return s.sent(),[4,this.tryAddTexture2D(t,n.normalTexture,!1)];case 4:return s.sent(),[4,this.tryAddTexture2D(t,n.emissiveTexture,!1)];case 5:return s.sent(),[4,this.tryAddTexture2D(t,n.occlusionTexture,!1)];case 6:s.sent(),s.label=7;case 7:return t++,[3,1];case 8:return this._gltfImageBasedLights.length>0&&!this.ignoreSkybox()?(o=this._gltfImageBasedLights[0],this.isEnvironmentTest()&&o.specularImages.forEach((function(e){var t,n;u.isTiny3dMode()&&(t=c([e[5],e[4]],2),e[4]=t[0],e[5]=t[1]),n=c([e[3],e[2]],2),e[2]=n[0],e[3]=n[1]})),i=this,[4,this.createSkybox(o)]):[3,10];case 9:return i._skyboxOptions=s.sent(),[3,12];case 10:return void 0===(r=this.getSkyboxType())?[3,12]:(a=r===e.PSkyboxType.FARM?"FARM":"NFT",l=this,[4,this.createDefaultSkybox(a)]);case 11:l._skyboxOptions=s.sent(),s.label=12;case 12:return this._skyboxOptions&&(this._skyboxOptions.renderable=this.isSkyboxVis()),this._gltfData2PlayerData(this._gltfScene,this._gltfMaterials),[2]}}))}))},n.prototype.tryAddTexture2D=function(e,t,n){var o=this;if(void 0!==t&&void 0===this.getTexture2D(e,t,n,!0)){var i=t.index,r=this._gltfTextures[i],a=this._gltfImages[r.source];return Q.createTexture2D(this.engine,a,r,n,this.isTiny3dMode()).then((function(t){o.getTextureManager().addTexture(e,i,t,n)}))}},n.prototype.getTexture2D=function(e,t,n,o){if(void 0!==t){var i=t.index,r=this.getTextureManager().getTexture(e,i,n);return void 0===r&&!0!==o&&console.warn("Can't find texture for mat ".concat(e,", tex ").concat(JSON.stringify(t),", basecolor ").concat(n)),r}},n.prototype._gltfData2PlayerData=function(e,t){this.processCamera(e.cameras,!0),this.processLight(e.lights,!0),this.processMaterial(t,!0)},n.prototype._createItemTree=function(e,n){var o=this.createTreeOptions(n),i=this.createAnimations(this._gltfAnimations);return o.animations=i,o.animation=this.getPlayAnimationIndex(o),{id:e,name:n.name,duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:t.spec.ItemType.tree,content:{options:{tree:o}}}},n.prototype._createItemMesh=function(e,n){var o,i,r=this,a=e.mesh;if(void 0===a)throw new Error("Invalid mesh index in node ".concat(e));if(void 0!==e.skin){var s=this._gltfSkins[e.skin];i={name:s.name,joints:s.jointIndexList,skeleton:s.skeleton,inverseBindMatrices:s.inverseBindMatrices}}var c=this._gltfMeshs[a],l=c.primitives.map((function(e){var n=e.material,o=r._gltfMaterials[n],a=r.createGeometry(e,void 0!==i),s=r.createMaterial(o);return s.baseColorTexture=r.getTexture2D(n,o.baseColorTexture,!0),s.type===t.spec.MaterialType.pbr&&(s.metallicRoughnessTexture=r.getTexture2D(n,o.metallicRoughnessTexture,!1),s.normalTexture=r.getTexture2D(n,o.normalTexture,!1),s.emissiveTexture=r.getTexture2D(n,o.emissiveTexture,!1),s.occlusionTexture=r.getTexture2D(n,o.occlusionTexture,!1)),{geometry:a,material:s}})),u={parent:e.nodeIndex,skin:i,primitives:l,weights:c.weights},h=vt.createBoxFromGLTFBound(c.bounds),f=h.getSize(new v),d=h.getCenter(new v),p={behavior:t.spec.InteractBehavior.NOTIFY,type:t.spec.ModelBoundingType.box,size:[f.x,f.y,f.z],center:[d.x,d.y,d.z]};return{id:"mesh_ni".concat(null!==(o=e.nodeIndex)&&void 0!==o?o:0,"_mi").concat(a),parentId:"".concat(n,"^").concat(e.nodeIndex),name:c.name,duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:t.spec.ItemType.mesh,pluginName:"model",content:{options:u,interaction:p}}},n.prototype._createItemLight=function(e,n){var o,i,r=e.light;if(void 0!==r){var a=this._gltfLights[r],s=this.createLightOptions(a);return{id:"light_ni".concat(null!==(o=e.nodeIndex)&&void 0!==o?o:0,"_li").concat(r),parentId:"".concat(n,"^").concat(e.nodeIndex),name:null!==(i=a.name)&&void 0!==i?i:"light",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:t.spec.ItemType.light,pluginName:"model",content:{options:s}}}},n.prototype._createItemCamera=function(e,t){var n,o,i=e.camera;if(void 0!==i){var r=this._gltfCameras[i],a=this.createCameraOptions(r);if(void 0!==a)return{id:"camera_ni".concat(null!==(n=e.nodeIndex)&&void 0!==n?n:0,"_ci").concat(i),parentId:"".concat(t,"^").concat(e.nodeIndex),name:null!==(o=r.name)&&void 0!==o?o:"camera",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:"camera",pluginName:"model",content:{options:a}}}},n.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}}},n.prototype._computeSceneAABB=function(e,n,o){var i=this,r={};if(e.matrix){var a=T.fromArray(e.matrix).getTransform();r.position=a.translation.toArray(),r.quat=a.rotation.toArray(),r.scale=a.scale.toArray()}else e.translation&&(r.position=e.translation),e.rotation&&(r.quat=e.rotation),e.scale&&(r.scale=e.scale);var s=new t.Transform(r,n);if(s.setValid(!0),void 0!==e.mesh){var c=this._gltfMeshs[e.mesh],l=vt.createBoxFromGLTFBound(c.bounds);l.applyMatrix4(s.getWorldMatrix()),o.union(l)}e.children.forEach((function(e){i._computeSceneAABB(e,s,o)}))},n.prototype.createLightOptions=function(e){return $.createLightOptions(e)},n.prototype.createCameraOptions=function(e){return $.createCameraOptions(e)},n.prototype._clear=function(){this._textureManager&&(this._textureManager.dispose(),this._textureManager=void 0),this._textureManager=new pt(this)},n.prototype.getPlayAnimationIndex=function(e){var t=e.animations;if(void 0===t||t.length<=0)return-1;if(this.isPlayAllAnimation())return-88888888;var n=this._sceneOptions.effects.playAnimation;if(void 0===n)return-1;if("number"==typeof n)return n>=0&&n<t.length?n:-1;var o=-1;return t.forEach((function(e,t){e.name===n&&(o=t)})),o},n.prototype.isPlayAnimation=function(){return void 0!==this._sceneOptions.effects.playAnimation},n.prototype.isPlayAllAnimation=function(){return!0===this._sceneOptions.effects.playAllAnimation},n.prototype.getRemarkString=function(){var e=this._sceneOptions.gltf.remark;return void 0===e?"Unknown":"string"==typeof e?e:"BinaryBuffer"},n.prototype.isTiny3dMode=function(){return"tiny3d"===this._loaderOptions.compatibleMode},n.prototype.getTextureManager=function(){return this._textureManager},n.prototype.getItemDuration=function(){var e;return null!==(e=this._sceneOptions.effects.duration)&&void 0!==e?e:9999},n.prototype.getItemEndBehavior=function(){var e;return null!==(e=this._sceneOptions.effects.endBehavior)&&void 0!==e?e:t.spec.ItemEndBehavior.loop},n.prototype.getSkyboxType=function(){switch(this._sceneOptions.gltf.skyboxType){case"NFT":return e.PSkyboxType.NFT;case"FARM":return e.PSkyboxType.FARM}},n.prototype.isSkyboxVis=function(){return!0===this._sceneOptions.gltf.skyboxVis},n.prototype.ignoreSkybox=function(){return!0===this._sceneOptions.gltf.ignoreSkybox},n.prototype.isEnvironmentTest=function(){return"string"==typeof this._sceneOptions.gltf.remark&&this._sceneOptions.gltf.remark.includes("EnvironmentTest")},n}(),pt=function(){function e(e){this._owner=e,this._gltfImages=[],this._gltfTextures=[],this._textureMap=new Map}return e.prototype.initial=function(e,t){this._gltfImages=e,this._gltfTextures=t,this._textureMap.clear()},e.prototype.dispose=function(){this._textureMap.clear()},e.prototype.addTexture=function(e,t,n,o){var i=o?1e5*(e+1)+t:t;this._textureMap.set(i,n)},e.prototype.getTexture=function(e,t,n){var o=n?1e5*(e+1)+t:t;return this._textureMap.get(o)},e}(),mt=function(){function e(e,t,n){this.engine=e,this.gltfGeometry=t,this.hasSkinAnimation=n}return Object.defineProperty(e.prototype,"geometry",{get:function(){var e=this,n={};if(!this.hasPosition)throw new Error("Position attribute missing");var o=this.positionAttrib;(n.a_Position=this._getBufferAttrib(o),this.hasNormal)&&(void 0!==(o=this.normalAttrib)&&(n.a_Normal=this._getBufferAttrib(o)));this.hasTangent&&(void 0!==(o=this.tangentAttrib)&&(n.a_Tangent=this._getBufferAttrib(o)));if(this.texCoordList.forEach((function(t){var o=e.texCoordAttrib(t),i="a_UV".concat(t+1);n[i]=e._getBufferAttrib(o)})),this.hasSkinAnimation){var i=this.jointAttribute;void 0!==i&&(n.a_Joint1=this._getBufferAttrib(i));var r=this.weightAttribute;void 0!==r&&(n.a_Weight1=this._getBufferAttrib(r))}for(var a=0;a<8;a++){var s=this.getTargetPosition(a);void 0!==s&&(n["a_Target_Position".concat(a)]=this._getBufferAttrib(s));var c=this.getTargetNormal(a);void 0!==c&&(n["a_Target_Normal".concat(a)]=this._getBufferAttrib(c));var l=this.getTargetTangent(a);void 0!==l&&(n["a_Target_Tangent".concat(a)]=this._getBufferAttrib(l))}var u=this.indexArray;return void 0!==u?t.Geometry.create(this.engine,{attributes:n,indices:{data:u},drawStart:0,drawCount:u.length,mode:t.glContext.TRIANGLES}):t.Geometry.create(this.engine,{attributes:n,drawStart:0,drawCount:this.positionAttrib.array.length/3,mode:t.glContext.TRIANGLES})},enumerable:!1,configurable:!0}),e.prototype._getBufferAttrib=function(e){return{type:e.type,size:e.itemSize,data:e.array,normalize:e.normalized}},Object.defineProperty(e.prototype,"positionAttrib",{get:function(){return this.gltfGeometry.getPosition()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalAttrib",{get:function(){return this.gltfGeometry.getNormal()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tangentAttrib",{get:function(){return this.gltfGeometry.getTangent()},enumerable:!1,configurable:!0}),e.prototype.texCoordAttrib=function(e){return this.gltfGeometry.getTexCoord(e)},Object.defineProperty(e.prototype,"jointAttribute",{get:function(){return this.gltfGeometry.getJoints(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"weightAttribute",{get:function(){return this.gltfGeometry.getWeights(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPosition",{get:function(){return void 0!==this.positionAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNormal",{get:function(){return void 0!==this.normalAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasTangent",{get:function(){return void 0!==this.tangentAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasTexCoord",{get:function(){return this.texCoordCount>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texCoordCount",{get:function(){for(var e=0;e<10;e++)if(void 0===this.texCoordAttrib(e))return e;return 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasJointAttribute",{get:function(){return void 0!==this.jointAttribute},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasWeightAttribute",{get:function(){return void 0!==this.weightAttribute},enumerable:!1,configurable:!0}),Object.defineProperty(e.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(e.prototype,"indexCount",{get:function(){return void 0!==this.gltfGeometry.indices?this.gltfGeometry.indices.array.length:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texCoordList",{get:function(){for(var e=[],t=0;t<10&&void 0!==this.texCoordAttrib(t);t++)e.push(t);return e},enumerable:!1,configurable:!0}),e.prototype.getTargetPosition=function(e){return this.gltfGeometry.getAttribute("POSITION".concat(e))},e.prototype.getTargetNormal=function(e){return this.gltfGeometry.getAttribute("NORMAL".concat(e))},e.prototype.getTargetTangent=function(e){return this.gltfGeometry.getAttribute("TANGENT".concat(e))},e}(),gt=function(){function e(e,t,n){this.gltfMaterial=e,this.textures=t,this.tiny3dMode=n}return Object.defineProperty(e.prototype,"material",{get:function(){var e,n,o,i=this.gltfMaterial,r=vt.isUnlitMaterial(i),a=t.spec.MaterialBlending.opaque;switch(i.alphaMode){case"OPAQUE":a=t.spec.MaterialBlending.opaque;break;case"MASK":a=t.spec.MaterialBlending.masked;break;case"BLEND":a=t.spec.MaterialBlending.translucent}var s=i.doubleSided?t.spec.SideMode.DOUBLE:t.spec.SideMode.FRONT,c=null!==(e=i.alphaCutOff)&&void 0!==e?e:.5,l=i.name;return r?{name:l,type:t.spec.MaterialType.unlit,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,depthMask:null===(n=i.extras)||void 0===n?void 0:n.depthMask,blending:a,alphaCutOff:c,side:s}:{name:l,type:t.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===(o=i.extras)||void 0===o?void 0:o.depthMask,blending:a,alphaCutOff:c,side:s,enableShadow:!1}},enumerable:!1,configurable:!0}),e.prototype.getTextureObject=function(e){if(!(e<0||e>=this.textures.length))return this.textures[e]},e.prototype.getTextureObj=function(e){return e?this.getTextureObject(e.index):void 0},e.prototype.getTextureCoord=function(e){return e?e.texCoord:void 0},e.prototype.getTextureTransform=function(e){var t,n=null===(t=null==e?void 0:e.extensions)||void 0===t?void 0:t.KHR_texture_transform;if(void 0!==n&&(void 0!==n.offset||void 0!==n.rotation||void 0!==n.scale))return{offset:n.offset,rotation:n.rotation,scale:n.scale}},Object.defineProperty(e.prototype,"baseColorTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metallicRoughnessTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metallicRoughnessTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metallicRoughnessTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasEmissive",{get:function(){var e=this.emissiveFactor;return e[0]+e[1]+e[2]>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorFactor",{get:function(){var e=this.gltfMaterial.baseColorFactor;return void 0===e||4!=e.length?[1,1,1,1]:[e[0],e[1],e[2],e[3]]},enumerable:!1,configurable:!0}),e.prototype.getSpecularAA=function(){var e;return null===(e=this.gltfMaterial.extras)||void 0===e?void 0:e.useSpecularAA},Object.defineProperty(e.prototype,"metalicFactor",{get:function(){var e;return null!==(e=this.gltfMaterial.metallicFactor)&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"roughnessFactor",{get:function(){var e;return null!==(e=this.gltfMaterial.roughnessFactor)&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureScale",{get:function(){var e,t;return null!==(t=null===(e=this.gltfMaterial.normalTexture)||void 0===e?void 0:e.scale)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureStrength",{get:function(){var e,t;return null!==(t=null===(e=this.gltfMaterial.occlusionTexture)||void 0===e?void 0:e.strength)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveFactor",{get:function(){var e=this.gltfMaterial.emissiveFactor;return void 0===e||4!=e.length?[0,0,0,1]:[e[0],e[1],e[2],1]},enumerable:!1,configurable:!0}),e}(),vt=function(){function e(){}return e.isUnlitMaterial=function(e){var t;return void 0!==(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_unlit)},e.createBoxFromGLTFBound=function(e){var t=v.fromArray(e.box.min),n=v.fromArray(e.box.max);return new M(t,n)},e}();t.registerPlugin("tree",lt,at,!0),t.registerPlugin("model",ct,st);var yt="1.6.0";t.logger.info("plugin model version: "+yt),e.BoxMesh=ze,e.CameraGestureHandlerImp=ht,e.CheckerHelper=re,e.CompositionCache=Be,e.CompositionHitTest=function(e,t,n){var o=e.hitTest(t,n,!0),i=e.getHitTestRay(t,n);if(o.length<=0)return[];var r=i.origin,a=i.direction,s=o.map((function(e,t){for(var n=e.position,o=[0,0,0],i=0;i<3;i++)o[i]=(n.getElement(i)-r.getElement(i))/a.getElement(i);return[t,Math.max.apply(Math,l([],c(o),!1))]}));return s.sort((function(e,t){return(e[1]>=0?e[1]:e[1]+1e9)-(t[1]>=0?t[1]:t[1]+1e9)})),s.map((function(e){return o[e[0]]}))},e.FBOOptions=je,e.Float16ArrayWrapper=ae,e.GeometryBoxProxy=oe,e.HitTestingProxy=ie,e.HookOGLFunc=function(e){console.info("HookOGLFunc "+Object.getPrototypeOf(e));var t=0;for(var n in Object.getPrototypeOf(e))"getError"!==n&&"function"==typeof e[n]&&(++t,e[n+et]=e[n],e[n]=ot(e,n));console.info("HookCount "+t),function(e){for(var t in Object.getPrototypeOf(e))"number"==typeof e[t]&&tt.set(e[t],t)}(e)},e.InterpolationSampler=u,e.LoaderHelper=ft,e.LoaderImpl=dt,e.MeshHelper=Z,e.ModelPlugin=ct,e.ModelTreeItem=rt,e.ModelTreePlugin=lt,e.ModelTreeVFXItem=at,e.ModelVFXItem=st,e.PAnimTexture=pe,e.PAnimTrack=de,e.PAnimation=me,e.PAnimationManager=ge,e.PAnimationSystem=ve,e.PCamera=De,e.PCameraManager=ke,e.PCoordinate=F,e.PEntity=D,e.PGeometry=Qe,e.PGlobalState=R,e.PLight=Ve,e.PLightManager=Ge,e.PMaterialBase=Ee,e.PMaterialPBR=we,e.PMaterialSkyboxFilter=Fe,e.PMaterialUnlit=Pe,e.PMesh=qe,e.PMorph=he,e.PObject=U,e.PPrimitive=Ke,e.PSceneManager=$e,e.PShaderManager=Ie,e.PSkin=ue,e.PSkybox=Ne,e.PSkyboxCreator=Re,e.PTransform=N,e.PluginHelper=$,e.RayBoxTesting=j,e.RayIntersectsBoxWithRotation=G,e.RayTriangleTesting=J,e.ToggleItemBounding=function(t,o){var i;null===(i=t.items)||void 0===i||i.forEach((function(t){if(t.type===n){var i=t;if(i.content.type===e.PObjectType.mesh){var r=i.content;i.id===o?r.visBoundingBox=!0:r.visBoundingBox=!1}}}))},e.TwoStatesSet=He,e.VFX_ITEM_TYPE_3D=n,e.VertexAttribBuffer=te,e.WebGLHelper=Q,e.WebHelper=ee,e.createAnimationSampler=m,e.createInternalMaterial=function(e){return{}},e.createPluginMaterial=Oe,e.getDefaultEffectsGLTFLoader=function(e,t){return ut||(ut=new dt),ut.initial(e,t),ut},e.getDiffuseOnlyShaderCode=function(e){return{vertexShaderCode:Ae({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 "}},e.getGaussianBlurShaderCodeV1=function(e){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 "}},e.getGaussianBlurShaderCodeV2=Ce,e.getKawaseBlurShaderCode=function(e){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 "}},e.getNormalVisShaderCode=Se,e.getPBRPassShaderCode=Te,e.getPMeshList=function(t){var o=[],i=t.getCompositions()[0];return null==i||i.items.forEach((function(t){if(t.type===n){var i=t;i.content&&i.content.type===e.PObjectType.mesh&&o.push(i.content)}})),o},e.getQuadFilterShaderCode=function(e){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 "}},e.getRendererGPUInfo=function(e){var t=e.gpuCapability;return JSON.stringify(t,void 0,2)},e.getShadowPassShaderCode=_e,e.getSimpleFilterShaderCode=Me,e.getSkyBoxShaderCode=xe,e.getTransparecyBaseShader=function(e){return e?Ae({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 "},e.getTransparecyFilterShader=function(e){return e?"\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 "},e.setDefaultEffectsGLTFLoader=function(e){ut=e},e.version=yt,Object.defineProperty(e,"__esModule",{value:!0})}));
9
9
  //# sourceMappingURL=index.min.js.map