@galacean/effects-plugin-model 2.7.4 → 2.8.0-alpha.1
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/alipay.js +1 -1
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +1 -1
- package/dist/alipay.mjs.map +1 -1
- package/dist/douyin.js +1 -1
- package/dist/douyin.js.map +1 -1
- package/dist/douyin.mjs +1 -1
- package/dist/douyin.mjs.map +1 -1
- package/dist/index.js +3 -68
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +4 -69
- package/dist/index.mjs.map +1 -1
- package/dist/loader.mjs +4 -69
- package/dist/loader.mjs.map +1 -1
- package/dist/runtime/cache.d.ts +0 -12
- package/dist/utility/plugin-helper.d.ts +2 -13
- package/dist/weapp.js +1 -1
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +1 -1
- package/dist/weapp.mjs.map +1 -1
- package/package.json +4 -4
package/dist/douyin.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as e from"@galacean/effects/douyin";import{math as t,spec as n,Transform as i,PLAYER_OPTIONS_ENV_EDITOR as r,RenderPassAttachmentStorageType as o,glContext as a,Material as s,Mesh as l,Geometry as c,ShaderFactory as u,effectsClass as h,RendererComponent as f,Behaviour as d,HitTestType as m,AnimationClip as g,TextureSourceType as p,Texture as v,RenderPass as y,TextureLoadAction as T,DestroyOptions as _,RenderPassDestroyAttachmentType as b,GLSLVersion as C,Player as S,Renderer as x,getDefaultTextureFactory as A,loadImage as M,generateGUID as I,addItem as E,removeItem as w,VFXItem as N,AbstractPlugin as L,glType2VertexFormatType as R,Downloader as O,getStandardJSON as F,isObject as P,registerPlugin as U,logger as D}from"@galacean/effects/douyin";var B="PluginModel";function k(e,t,n,i,r,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(i,r)}function V(e){return function(){var t=this,n=arguments;return new Promise((function(i,r){var o=e.apply(t,n);function a(e){k(o,i,r,a,s,"next",e)}function s(e){k(o,i,r,a,s,"throw",e)}a(void 0)}))}}function G(e,t){return G=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},G(e,t)}function z(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&G(e,t)}function H(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):H(e,t)}function j(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function W(e,t){var n,i,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}"function"==typeof SuppressedError&&SuppressedError;var J=function(){function e(e,t,n){this.time=e,this.data=t,this.componentCount=n,this.cachedIndex=0}var t=e.prototype;return t.evaluate=function(e){var t=this.time,n=this.cachedIndex,i=t[n],r=t[n-1];e:{t:{var o;n:{i:if(!(e<i)){for(var a=n+2;;){if(void 0===i){if(e<r)break i;return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}if(n===a)break;if(r=i,e<(i=t[++n]))break t}o=t.length;break n}if(e>=r)break e;var s=t[1];e<s&&(n=2,r=s);for(var l=n-2;;){if(void 0===r)return this.cachedIndex=0,this.copySampleValue(0);if(n===l)break;if(i=r,e>=(r=t[--n-1]))break t}o=n,n=0}for(;n<o;){var c=n+o>>>1;e<t[c]?o=c:n=c+1}if(i=t[n],void 0===(r=t[n-1]))return this.cachedIndex=0,this.copySampleValue(0);if(void 0===i)return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}this.cachedIndex=n,this.intervalChanged(n,r,i)}return this.interpolate(n,r,e,i)},t.dispose=function(){this.time=void 0,this.data=void 0},t.copySampleValue=function(e){for(var t=this.data,n=this.componentCount,i=e*n,r=new Float32Array(n),o=0;o!==n;++o)r[o]=t[i+o];return r},e}(),X=function(e){function t(t,n,i){return e.call(this,t,n,i)}z(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,i){for(var r,o=this.data,a=null!=(r=this.componentCount)?r:1,s=e*a,l=s-a,c=(n-t)/(i-t),u=1-c,h=new Float32Array(a),f=0;f!==a;++f)h[f]=o[l+f]*u+o[s+f]*c;return h},t}(J),q=function(e){function t(t,n,i){return e.call(this,t,n,i)}z(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,i){for(var r,o=this.data,a=null!=(r=this.componentCount)?r:1,s=(e-1)*a,l=new Float32Array(a),c=0;c!==a;++c)l[c]=o[s+c];return l},t}(J),Z=function(){function e(){}return e.slerpFlat=function(e,t,n,i,r,o,a){var s=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3],h=r[o+0],f=r[o+1],d=r[o+2],m=r[o+3];if(0===a)return e[t+0]=s,e[t+1]=l,e[t+2]=c,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]=m);if(u!==m||s!==h||l!==f||c!==d){var g=1-a,p=s*h+l*f+c*d+u*m,v=p>=0?1:-1,y=1-p*p;if(y>Number.EPSILON){var T=Math.sqrt(y),_=Math.atan2(T,p*v);g=Math.sin(g*_)/T,a=Math.sin(a*_)/T}var b=a*v;if(s=s*g+h*b,l=l*g+f*b,c=c*g+d*b,u=u*g+m*b,g===1-a){var C=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=C,l*=C,c*=C,u*=C}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u},e}(),Y=function(e){function t(t,n,i){return e.call(this,t,n,i)}z(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,i){for(var r,o=this.data,a=null!=(r=this.componentCount)?r:1,s=(n-t)/(i-t),l=e*a,c=new Float32Array(a),u=l+a;l!==u;l+=4)Z.slerpFlat(c,0,o,l-a,o,l,s);return c},t}(J);function K(e,t,n,i,r){switch(e){case"LINEAR":return"rotation"===r?new Y(t,n,i):new X(t,n,i);case"STEP":return new q(t,n,i);default:return new X(t,n,i)}}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function $(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Q(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var ee,te,ne,ie,re,oe,ae,se=t.Vector2,le=t.Vector3,ce=t.Vector4,ue=t.Matrix3,he=t.Matrix4,fe=t.Color,de=t.Euler,me=t.EulerOrder,ge=t.Quaternion,pe=t.Box3,ve=t.Sphere,ye=t.Ray,Te=t.DEG2RAD;function _e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function be(e,t,n){return t&&_e(e.prototype,t),n&&_e(e,n),e}function Ce(){return Ce=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Ce.apply(this,arguments)}!function(e){e[e.none=0]="none",e[e.mesh=1]="mesh",e[e.texture=2]="texture",e[e.material=3]="material",e[e.light=4]="light",e[e.camera=5]="camera",e[e.skybox=6]="skybox",e[e.skin=7]="skin",e[e.morph=8]="morph",e[e.skeleton=9]="skeleton",e[e.animation=10]="animation",e[e.animationManager=11]="animationManager",e[e.reference=12]="reference"}(ee||(ee={})),function(e){e[e.directional=0]="directional",e[e.point=1]="point",e[e.spot=2]="spot",e[e.ambient=3]="ambient"}(te||(te={})),function(e){e[e.none=0]="none",e[e.t2d=1]="t2d",e[e.t3d=2]="t3d",e[e.cube=3]="cube"}(ne||(ne={})),function(e){e[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"}(ie||(ie={})),function(e){e[e.opaque=0]="opaque",e[e.masked=1]="masked",e[e.translucent=2]="translucent",e[e.additive=3]="additive"}(re||(re={})),function(e){e[e.both=0]="both",e[e.front=1]="front",e[e.back=2]="back"}(oe||(oe={})),function(e){e[e.none=0]="none",e[e.standard=1]="standard",e[e.variance=2]="variance",e[e.expVariance=3]="expVariance"}(ae||(ae={}));var Se=n.BuiltinObjectGUID.PBRShader,xe=n.BuiltinObjectGUID.UnlitShader,Ae=function(){function e(){this.translation=new le(0,0,0),this.rotation=new ge(0,0,0,1),this.scale=new le(1,1,1)}var t=e.prototype;return t.fromMatrix4=function(e){return this.setMatrix(e),this},t.fromEffectsTransform=function(e){if(H(e,i))this.setMatrix(e.getWorldMatrix());else{var t=new i(Ce({},e,{valid:!0}));t.setValid(!0),this.setMatrix(t.getWorldMatrix())}return this},t.toEffectsTransform=function(e){var t=this.getMatrix();return e.cloneFromMatrix(t),e},t.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},t.getTranslation=function(){return this.translation},t.setTranslation=function(e){H(e,le)?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},t.getPosition=function(){return this.translation},t.setPosition=function(e){H(e,le)?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},t.getRotation=function(){return this.rotation},t.setRotation=function(e){H(e,ge)?this.rotation.set(e.x,e.y,e.z,e.w):H(e,de)?this.rotation.setFromEuler(e):H(e,le)?this.rotation.setFromEuler(new de(e.x,e.y,e.z,me.ZYX)):4===e.length?this.rotation.set(e[0],e[1],e[2],e[3]):this.rotation.setFromEuler(new de(e[0],e[1],e[2],me.ZYX))},t.getScale=function(){return this.scale},t.setScale=function(e){H(e,le)?this.scale.set(e.x,e.y,e.z):this.scale.set(e[0],e[1],e[2])},t.getMatrix=function(){return(new he).compose(this.getTranslation(),this.getRotation(),this.getScale())},t.setMatrix=function(e){if(H(e,he)){var t=e.getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}else{var n=he.fromArray(e).getTransform();this.setTranslation(n.translation),this.setRotation(n.rotation),this.setScale(n.scale)}},e}(),Me=function(){function e(){this.origin=new le(0,0,0),this.xAxis=new le(1,0,0),this.yAxis=new le(0,1,0),this.zAxis=new le(0,0,1)}var t=e.prototype;return t.fromPTransform=function(e,t){void 0===t&&(t=!1),this.origin.copyFrom(e.getPosition());var n=e.getRotation().toMatrix4(new he);return t&&n.invert(),this.fromRotationMatrix(n),this},t.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}(),Ie=function(){function e(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=r,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=n.RenderMode3D.none,this.renderMode3DUVGridSize=1/16}var t=e.prototype;return t.reset=function(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=r,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=n.RenderMode3D.none,this.renderMode3DUVGridSize=1/16},t.hasRenderMode3D=function(){return this.renderMode3D!==n.RenderMode3D.none},e.getInstance=function(){return this.instance||(this.instance=new this)},be(e,[{key:"isEditorEnv",get:function(){return this.runtimeEnv===r}},{key:"isDeviceEnv",get:function(){return!this.isEditorEnv}},{key:"isTiny3dMode",get:function(){return"tiny3d"===this.compatibleMode}},{key:"isGLTFMode",get:function(){return!this.isTiny3dMode}}]),e}(),Ee=1,we=function(){function e(){this.name="Unnamed Object",this.type=ee.none}var t=e.prototype;return t.dispose=function(){},t.isNone=function(){return this.type===ee.none},t.isValid=function(){return this.type!==ee.none},t.genName=function(e){return e+"_@"+Ee++},e}(),Ne=function(e){function t(){var t;return(t=e.apply(this,arguments)||this)._visible=!1,t._transform=new Ae,t.deleted=!1,t}z(t,e);var n=t.prototype;return n.update=function(){},n.render=function(e,t){},n.onVisibleChanged=function(e){this.visible=e},n.dispose=function(){e.prototype.dispose.call(this),this.visible=!1,this.deleted=!0},be(t,[{key:"visible",get:function(){return this._visible&&this.isValid()},set:function(e){this._visible=e}},{key:"transform",get:function(){return this._transform},set:function(e){H(e,Ae)?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))}},{key:"translation",get:function(){return this._transform.getTranslation()},set:function(e){this._transform.setTranslation(e)}},{key:"position",get:function(){return this._transform.getTranslation()},set:function(e){this._transform.setTranslation(e)}},{key:"rotation",get:function(){return this._transform.getRotation()},set:function(e){this._transform.setRotation(e)}},{key:"scale",get:function(){return this._transform.getScale()},set:function(e){this._transform.setScale(e)}},{key:"matrix",get:function(){return this._transform.getMatrix()},set:function(e){this._transform.setMatrix(e)}},{key:"coordinate",get:function(){var e=new Me;return e.fromPTransform(this._transform),e}}]),t}(we);function Le(e,t){var n,i=e.attributes,r=Ce({},e);if(r.indices)r.indices=Ce({},r.indices),r.indices.data&&(r.indices.data=Oe(t,null==(n=e.indices)?void 0:n.data));else if(r.index){var o;if(r.indices=Ce({},r.index),r.indices.data)r.indices.data=Oe(t,null==(o=e.index)?void 0:o.data)}return Object.keys(i).forEach((function(e){var n=i[e],o=n.data;r.attributes[e]=Ce({},n),o&&(r.attributes[e].data=Oe(t,o))})),r}var Re={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,f32:Float32Array,i32:Int32Array,u32:Uint32Array};function Oe(e,t){if(2!=t.length||t[0]!==n.ValueType.BINARY||!H(t[1],Array))return t;var i=t[1],r=i[0],o=i[1],a=i[2],s=i[3];if(!s)return e[r].slice(o,a);var l=Re[s]||Uint8Array;return new l(e[r],o,a/l.BYTES_PER_ELEMENT)}var Fe="_Native",Pe=new Map;function Ue(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+Fe]=e[n],e[n]=Be(e,n));console.info("HookCount "+t),function(e){for(var t in Object.getPrototypeOf(e))"number"==typeof e[t]&&Pe.set(e[t],t)}(e)}function De(e,t){for(var n=""+e,i=[],r=0;r<t.length;r++){var o;"number"==typeof t[r]&&Pe.has(t[r])?i.push(Pe.get(t[r])+"("+t[r]+")"):i.push(null==(o=t[r])?void 0:o.toString())}return n+(i.length>0?"("+i.join(", ")+")":"()")}function Be(e,t){return function(){var n=e[t+Fe].apply(this,arguments),i=e.getError();return i>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))?t:"UNKNOWN_ERROR")+"("+e+")"}(i)+" ===> "+De(t,arguments)),console.trace()):console.info(De(t,arguments)),n}}function ke(e){var t=e.gpuCapability;return JSON.stringify(t,void 0,2)}function Ve(e){var t=[],n=e.getCompositions()[0];return null==n||n.items.forEach((function(e){if(e.type===B){var n=e.getComponent(ft);(null==n?void 0:n.content.type)===ee.mesh&&t.push(n.content)}})),t}var Ge,ze=function(){function e(e){var t,n;this.resolution=null!=(t=e.resolution)?t:new se(512,512),this.colorAttachments=null!=(n=e.colorAttachments)?n:[],this.depthAttachment=e.depthAttachment}var t=e.prototype;return t.addDepthAttachment=function(e){var t;this.depthAttachment={storageType:null!=(t=e.storageType)?t:o.depth_16_texture}},t.addDefaultDepthAttachment=function(){this.depthAttachment={storageType:o.depth_16_texture}},t.deleteDepthAttachment=function(){this.depthAttachment=void 0},t.addColorAttachment=function(e){var t,n,i,r;this.colorAttachments.push({texture:{format:null!=(t=e.format)?t:a.RGBA,type:null!=(n=e.type)?n:a.HALF_FLOAT,minFilter:null!=(i=e.filter)?i:a.LINEAR,magFilter:null!=(r=e.filter)?r:a.LINEAR}})},t.deleteColorAttachment=function(e){e>=0&&e<this.colorAttachments.length&&this.colorAttachments.splice(e,1)},be(e,[{key:"viewport",get:function(){return[0,0,this.resolution.x,this.resolution.y]}}]),e}(),He=function(){function e(e,t){var n=s.create(e,{shader:{vertex:this.vertexShader,fragment:this.fragmentShader,shared:!0}});n.depthTest=!0,n.depthMask=!0,this.mesh=l.create(e,{name:"boxMesh",material:n,geometry:c.create(e,this.geometry),priority:t})}var t=e.prototype;return t.update=function(e,t,n,i){var r=this.mesh.material;r.setMatrix("effects_ObjectToWorld",e);for(var o=0;o<n.length;o+=3)r.setVector3("_PositionList["+o/3+"]",le.fromArray(n,o));r.setVector3("_LineColor",i)},t.dispose=function(){this.mesh.dispose(),this.mesh=void 0},be(e,[{key:"vertexShader",get:function(){return"\n precision highp float;\n\n uniform mat4 effects_ObjectToWorld;\n uniform mat4 effects_MatrixVP;\n uniform vec3 _PositionList[8];\n attribute vec3 aPos;\n void main(){\n int index = int(aPos.x + 0.5);\n vec4 pos = effects_ObjectToWorld * vec4(_PositionList[index], 1);\n gl_Position = effects_MatrixVP * pos;\n }\n "}},{key:"fragmentShader",get:function(){return"\n precision highp float;\n\n uniform vec3 _LineColor;\n void main(){\n gl_FragColor = vec4(_LineColor, 1);\n }\n "}},{key:"geometry",get:function(){var e=new Float32Array([0,1,2,3,4,5,6,7]),t=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:{aPos:{type:a.FLOAT,size:1,data:e,stride:Float32Array.BYTES_PER_ELEMENT,offset:0}},mode:a.LINES,indices:{data:t},drawStart:0,drawCount:24}}}]),e}(),je="precision highp float;\n#define FEATURES\n#include <animation.vert.glsl>\nattribute vec4 aPos;varying vec3 v_Position;\n#ifdef HAS_NORMALS\nattribute vec4 aNormal;\n#endif\n#ifdef HAS_TANGENTS\nattribute vec4 aTangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 v_TBN;\n#else\nvarying vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nattribute vec2 aUV;\n#endif\n#ifdef HAS_UV_SET2\nattribute vec2 aUV2;\n#endif\nvarying vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nvarying vec2 v_UVCoord2;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nattribute vec3 aColor;varying vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nattribute vec4 aColor;varying vec4 v_Color;\n#endif\nuniform mat4 effects_MatrixVP;uniform mat4 effects_ObjectToWorld;uniform mat4 _NormalMatrix;\n#ifdef USE_SHADOW_MAPPING\nuniform mat4 _LightViewProjectionMatrix;uniform float _DeltaSceneSize;varying vec4 v_PositionLightSpace;varying vec4 v_dPositionLightSpace;\n#endif\nvec4 getPosition(){vec4 pos=vec4(aPos.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=aNormal;\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=aTangent;\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=effects_ObjectToWorld*getPosition();v_Position=vec3(pos.xyz)/pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec4 tangent=getTangent();vec3 normalW=normalize(vec3(_NormalMatrix*vec4(getNormal().xyz,0.0)));vec3 tangentW=normalize(vec3(effects_ObjectToWorld*vec4(tangent.xyz,0.0)));vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\n#else\nv_Normal=normalize(vec3(_NormalMatrix*vec4(getNormal().xyz,0.0)));\n#endif\n#endif\nv_UVCoord1=vec2(0.0,0.0);\n#ifdef HAS_UV_SET1\nv_UVCoord1=aUV;\n#endif\n#ifdef HAS_UV_SET2\nv_UVCoord2=aUV2;\n#endif\n#if defined(HAS_VERTEX_COLOR_VEC3) || defined(HAS_VERTEX_COLOR_VEC4)\nv_Color=aColor;\n#endif\n#ifdef USE_SHADOW_MAPPING\nv_PositionLightSpace=_LightViewProjectionMatrix*pos;vec3 dpos=vec3(_DeltaSceneSize);v_dPositionLightSpace=_LightViewProjectionMatrix*(pos+vec4(dpos,0));\n#endif\ngl_Position=effects_MatrixVP*pos;}",We="\n#define FEATURES\n#extension GL_OES_standard_derivatives : enable\n#if 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#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include <extensions.frag.glsl>\n#include <tone-mapping.frag.glsl>\n#include <textures.vert.glsl>\n#include <functions.frag.glsl>\n#include <shadow-common.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 _Lights[LIGHT_COUNT];\n#endif\n#if defined(MATERIAL_SPECULARGLOSSINESS) || defined(MATERIAL_METALLICROUGHNESS)\nuniform float _MetallicFactor;uniform float _RoughnessFactor;uniform vec4 _BaseColorFactor;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\nuniform vec3 _SpecularFactor;uniform vec4 _DiffuseFactor;uniform float _GlossinessFactor;\n#endif\n#ifdef ALPHAMODE_MASK\nuniform float _AlphaCutoff;\n#endif\n#ifdef ADD_FOG\nuniform vec4 _FogColor;\n#ifdef LINEAR_FOG\nuniform float _FogNear;uniform float _FogFar;\n#endif\n#ifdef EXP_FOG\nuniform float _FogDensity;\n#endif\n#endif\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\nuniform vec3 _Camera;uniform int _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=_Camera-v_Position;float fogAmount=0.0;\n#ifdef LINEAR_FOG\nfogAmount=smoothstep(_FogNear,_FogFar,distance[2]);\n#endif\n#ifdef EXP_FOG\n#define LOG2 1.442695\nfogAmount=1.-exp2(-_FogDensity*_FogDensity*distance[2]*distance[2]*LOG2);fogAmount=clamp(fogAmount,0.,1.);\n#endif\nvec3 mixColor=baseColor.rgb+(vec3(_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(_MipCount),0.0,float(_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(_brdfLUT,brdfSamplePoint).rg;vec4 diffuseColor=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,_shCoefficients);diffuseColor=vec4(irradiance,1.0);\n#else\ndiffuseColor=textureCube(_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(_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*_IblIntensity[0]+specular*_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 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\ngl_FragColor=uPreviewColor;return;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nvec4 sgSample=SRGBtoLINEAR(texture2D(_SpecularGlossinessSampler,getSpecularGlossinessUV()));perceptualRoughness=(1.0-sgSample.a*_GlossinessFactor);f0=sgSample.rgb*_SpecularFactor;\n#else\nf0=_SpecularFactor;perceptualRoughness=1.0-_GlossinessFactor;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nbaseColor=SRGBtoLINEAR(texture2D(_DiffuseSampler,getDiffuseUV()))*_DiffuseFactor;\n#else\nbaseColor=SRGBtoLINEAR(_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(_MetallicRoughnessSampler,getMetallicRoughnessUV());perceptualRoughness=mrSample.g*_RoughnessFactor;metallic=mrSample.b*_MetallicFactor;\n#else\nmetallic=_MetallicFactor;perceptualRoughness=_RoughnessFactor;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nbaseColor=SRGBtoLINEAR(texture2D(_BaseColorSampler,getBaseColorUV()))*_BaseColorFactor;\n#else\nbaseColor=SRGBtoLINEAR(_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<_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\ngl_FragColor=fragColorUnlit;\n#else\n#ifdef DEBUG_UV\ngl_FragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),getNormal()));\n#endif\n#ifdef DEBUG_METALLIC\ngl_FragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\ngl_FragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\ngl_FragColor.rgb=getNormal()*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\ngl_FragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\ngl_FragColor.rgb=vec3(1.0);\n#endif\n#ifdef DEBUG_EMISSIVE\ngl_FragColor.rgb=vec3(0.0);\n#endif\n#ifdef DEBUG_ALPHA\ngl_FragColor.rgb=vec3(baseColor.a);\n#endif\ngl_FragColor.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(_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=_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(_OcclusionSampler,getOcclusionUV()).r;color=mix(color,color*ao,_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+=_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb*_EmissiveIntensity;color+=emissive;\n#endif\nvec4 fragColorOut=vec4(color,baseColor.a);\n#endif\ngl_FragColor=fragColorOut;\n#else\n#ifdef DEBUG_UV\ngl_FragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),normal));\n#endif\n#ifdef DEBUG_METALLIC\ngl_FragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\ngl_FragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\ngl_FragColor.rgb=normal*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\ngl_FragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\n#ifdef HAS_OCCLUSION_MAP\ngl_FragColor.rgb=vec3(mix(1.0,ao,_OcclusionStrength));\n#else\ngl_FragColor.rgb=vec3(1.0);\n#endif\n#endif\n#ifdef DEBUG_EMISSIVE\n#ifdef HAS_EMISSIVE\nemissive=_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\ngl_FragColor.rgb=LINEARtoSRGB(emissive);\n#endif\n#ifdef DEBUG_F0\ngl_FragColor.rgb=vec3(f0);\n#endif\n#ifdef DEBUG_ALPHA\ngl_FragColor.rgb=vec3(baseColor.a);\n#endif\n#ifdef DEBUG_DIFFUSE\nvec3 debugDiffuse=vec3(0.0);\n#ifdef USE_PUNCTUAL\nMaterialInfo diffuseMaterialInfo=MaterialInfo(1.0,f0,1.0,vec3(0.35),f0,f0);for(int i=0;i<LIGHT_COUNT;++i){Light light=_Lights[i];if(light.type==LightType_Directional){debugDiffuse+=applyDirectionalLight(light,diffuseMaterialInfo,normal,view,shadow);}else if(light.type==LightType_Point){debugDiffuse+=applyPointLight(light,diffuseMaterialInfo,normal,view);}else if(light.type==LightType_Spot){debugDiffuse+=applySpotLight(light,diffuseMaterialInfo,normal,view,shadow);}else if(light.type==LightType_Ambient){debugDiffuse+=applyAmbientLight(light,diffuseMaterialInfo);}}\n#ifdef USE_IBL\ndebugDiffuse+=getIBLContribution(diffuseMaterialInfo,normal,view);\n#endif\n#endif\ngl_FragColor.rgb=toneMap(debugDiffuse);\n#endif\ngl_FragColor.a=1.0;\n#endif\n}",Je="#define FEATURES\n#include <shadow-common.vert.glsl>\n#if defined(SHADOWMAP_VSM)\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\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)\ngl_FragColor=CalcMomentVSM(gl_FragCoord.z);\n#else\ngl_FragColor=CalcMomentEVSM(gl_FragCoord.z);\n#endif\n}",Xe="precision highp float;\n#define FEATURES\nattribute vec3 aPos;varying vec3 v_CameraDir;uniform mat4 _InvViewProjectionMatrix;void main(){vec4 dir=_InvViewProjectionMatrix*vec4(aPos.xy,1,1);v_CameraDir=normalize(dir.xyz/dir.w);gl_Position=vec4(aPos.xy,0.99999,1);}",qe="\n#define FEATURES\n#if defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#extension GL_OES_standard_derivatives : enable\nprecision highp float;\n#include <extensions.frag.glsl>\nuniform sampler2D _brdfLUT;uniform vec2 _IblIntensity;uniform int _MipCount;uniform samplerCube _DiffuseEnvSampler;uniform samplerCube _SpecularEnvSampler;varying vec3 v_CameraDir;\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients _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(_MipCount),0.0,float(_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(_brdfLUT,brdfSamplePoint).rg;vec4 diffuseSample=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,_shCoefficients);diffuseSample=vec4(irradiance,1.0);\n#else\ndiffuseSample=textureCube(_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(_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*_IblIntensity[0]+specular*_IblIntensity[1];}void main(){vec3 dir=normalize(v_CameraDir);gl_FragColor=vec4(getIBLContribution(dir,dir),1.0);}";!function(e){e.build=function(e,t){return e=e.replace(/#define FEATURES/,t.map((function(e){return"#define "+e})).join("\n"))}}(Ge||(Ge={})),u.registerInclude("animation.vert.glsl","#ifdef HAS_TARGET_POSITION0\nattribute vec3 aTargetPosition0;\n#endif\n#ifdef HAS_TARGET_POSITION1\nattribute vec3 aTargetPosition1;\n#endif\n#ifdef HAS_TARGET_POSITION2\nattribute vec3 aTargetPosition2;\n#endif\n#ifdef HAS_TARGET_POSITION3\nattribute vec3 aTargetPosition3;\n#endif\n#ifdef HAS_TARGET_POSITION4\nattribute vec3 aTargetPosition4;\n#endif\n#ifdef HAS_TARGET_POSITION5\nattribute vec3 aTargetPosition5;\n#endif\n#ifdef HAS_TARGET_POSITION6\nattribute vec3 aTargetPosition6;\n#endif\n#ifdef HAS_TARGET_POSITION7\nattribute vec3 aTargetPosition7;\n#endif\n#ifdef HAS_TARGET_NORMAL0\nattribute vec3 aTargetNormal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nattribute vec3 aTargetNormal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nattribute vec3 aTargetNormal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nattribute vec3 aTargetNormal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nattribute vec3 aTargetNormal4;\n#endif\n#ifdef HAS_TARGET_TANGENT0\nattribute vec3 aTargetTangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\nattribute vec3 aTargetTangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\nattribute vec3 aTargetTangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\nattribute vec3 aTargetTangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\nattribute vec3 aTargetTangent4;\n#endif\n#ifdef USE_MORPHING\nuniform float _morphWeights[WEIGHT_COUNT];\n#endif\n#ifdef HAS_JOINT_SET1\nattribute vec4 aJoints;\n#endif\n#ifdef HAS_JOINT_SET2\nattribute vec4 aJoint2;\n#endif\n#ifdef HAS_WEIGHT_SET1\nattribute vec4 aWeights;\n#endif\n#ifdef HAS_WEIGHT_SET2\nattribute vec4 aWeight2;\n#endif\n#ifdef USE_SKINNING\n#ifdef USE_SKINNING_TEXTURE\nuniform sampler2D _jointMatrixSampler;uniform sampler2D _jointNormalMatrixSampler;\n#else\nuniform mat4 _jointMatrix[JOINT_COUNT];uniform mat4 _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(_jointMatrixSampler,vec2(ROW0_U,v)),texture2D(_jointMatrixSampler,vec2(ROW1_U,v)),texture2D(_jointMatrixSampler,vec2(ROW2_U,v)),texture2D(_jointMatrixSampler,vec2(ROW3_U,v)));\n#else\nreturn _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(_jointNormalMatrixSampler,vec2(ROW0_U,v)),texture2D(_jointNormalMatrixSampler,vec2(ROW1_U,v)),texture2D(_jointNormalMatrixSampler,vec2(ROW2_U,v)),texture2D(_jointNormalMatrixSampler,vec2(ROW3_U,v)));\n#else\nreturn _jointNormalMatrix[int(boneNdx)];\n#endif\n}mat4 getSkinningMatrix(){mat4 skin=mat4(0);\n#if defined(HAS_WEIGHT_SET1) && defined(HAS_JOINT_SET1)\nskin+=aWeights.x*getJointMatrix(aJoints.x)+aWeights.y*getJointMatrix(aJoints.y)+aWeights.z*getJointMatrix(aJoints.z)+aWeights.w*getJointMatrix(aJoints.w);\n#endif\nreturn skin;}mat4 getSkinningNormalMatrix(){mat4 skin=mat4(0);\n#if defined(HAS_WEIGHT_SET1) && defined(HAS_JOINT_SET1)\nskin+=aWeights.x*getJointNormalMatrix(aJoints.x)+aWeights.y*getJointNormalMatrix(aJoints.y)+aWeights.z*getJointNormalMatrix(aJoints.z)+aWeights.w*getJointNormalMatrix(aJoints.w);\n#endif\nreturn skin;}\n#endif\n#ifdef USE_MORPHING\nvec4 getTargetPosition(){vec4 pos=vec4(0);\n#ifdef HAS_TARGET_POSITION0\npos.xyz+=_morphWeights[0]*aTargetPosition0;\n#endif\n#ifdef HAS_TARGET_POSITION1\npos.xyz+=_morphWeights[1]*aTargetPosition1;\n#endif\n#ifdef HAS_TARGET_POSITION2\npos.xyz+=_morphWeights[2]*aTargetPosition2;\n#endif\n#ifdef HAS_TARGET_POSITION3\npos.xyz+=_morphWeights[3]*aTargetPosition3;\n#endif\n#ifdef HAS_TARGET_POSITION4\npos.xyz+=_morphWeights[4]*aTargetPosition4;\n#endif\nreturn pos;}vec4 getTargetNormal(){vec4 normal=vec4(0);\n#ifdef HAS_TARGET_NORMAL0\nnormal.xyz+=_morphWeights[0]*aTargetNormal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nnormal.xyz+=_morphWeights[1]*aTargetNormal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nnormal.xyz+=_morphWeights[2]*aTargetNormal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nnormal.xyz+=_morphWeights[3]*aTargetNormal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nnormal.xyz+=_morphWeights[4]*aTargetNormal4;\n#endif\nreturn normal;}vec4 getTargetTangent(){vec4 tangent=vec4(0);\n#ifdef HAS_TARGET_TANGENT0\ntangent.xyz+=_morphWeights[0]*aTargetTangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\ntangent.xyz+=_morphWeights[1]*aTargetTangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\ntangent.xyz+=_morphWeights[2]*aTargetTangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\ntangent.xyz+=_morphWeights[3]*aTargetTangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\ntangent.xyz+=_morphWeights[4]*aTargetTangent4;\n#endif\nreturn tangent;}\n#endif\n"),u.registerInclude("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"),u.registerInclude("tone-mapping.frag.glsl","uniform float _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*=_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);}"),u.registerInclude("textures.vert.glsl","varying vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nvarying vec2 v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D _NormalSampler;uniform float _NormalScale;uniform int _NormalUVSet;uniform mat3 _NormalUVTransform;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D _EmissiveSampler;uniform int _EmissiveUVSet;uniform vec4 _EmissiveFactor;uniform float _EmissiveIntensity;uniform mat3 _EmissiveUVTransform;\n#endif\n#ifdef HAS_EMISSIVE\nuniform vec4 _EmissiveFactor;uniform float _EmissiveIntensity;\n#endif\n#ifdef HAS_OCCLUSION_MAP\nuniform sampler2D _OcclusionSampler;uniform int _OcclusionUVSet;uniform float _OcclusionStrength;uniform mat3 _OcclusionUVTransform;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nuniform sampler2D _BaseColorSampler;uniform int _BaseColorUVSet;uniform mat3 _BaseColorUVTransform;\n#endif\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nuniform sampler2D _MetallicRoughnessSampler;uniform int _MetallicRoughnessUVSet;uniform mat3 _MetallicRoughnessUVTransform;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D _DiffuseSampler;uniform int _DiffuseUVSet;uniform mat3 _DiffuseUVTransform;\n#endif\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nuniform sampler2D _SpecularGlossinessSampler;uniform int _SpecularGlossinessUVSet;uniform mat3 _SpecularGlossinessUVTransform;\n#endif\n#ifdef USE_IBL\nuniform samplerCube _DiffuseEnvSampler;uniform samplerCube _SpecularEnvSampler;uniform sampler2D _brdfLUT;uniform vec2 _IblIntensity;\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients _shCoefficients;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform sampler2D _ShadowSampler;\n#endif\nvec2 getNormalUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_NORMAL_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_NormalUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_UV_TRANSFORM\nuv*=_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=_EmissiveUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_EMISSIVE_UV_TRANSFORM\nuv*=_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=_OcclusionUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_OCCLUSION_UV_TRANSFORM\nuv*=_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=_BaseColorUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_BASECOLOR_UV_TRANSFORM\nuv*=_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=_MetallicRoughnessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_METALLICROUGHNESS_UV_TRANSFORM\nuv*=_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=_SpecularGlossinessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_UV_TRANSFORM\nuv*=_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=_DiffuseUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_DIFFUSE_UV_TRANSFORM\nuv*=_DiffuseUVTransform;\n#endif\n#endif\nreturn uv.xy;}"),u.registerInclude("functions.frag.glsl","const float M_PI=3.141592653589793;const float c_MinReflectance=0.04;varying vec3 v_Position;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 v_TBN;\n#else\nvarying vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nvarying vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nvarying 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(_NormalSampler,UV).rgb;n=normalize(tbn*((2.0*n-1.0)*vec3(_NormalScale,_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 _DebugUVGridSize;float getDebugUVColor(vec2 uv,vec3 n){float s=dot(abs(n),vec3(1,1,1))*0.6;uv=uv/(_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"),u.registerInclude("shadow.frag.glsl","#ifdef USE_SHADOW_MAPPING\nuniform vec2 _ShadowMapSizeInv;varying vec4 v_PositionLightSpace;varying 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(_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(_ShadowSampler,coords.xy).xy;return chebyshev(moments,coords.z,0.00002);}float computeEVSMShadow(vec2 coords,float pos,float neg){vec4 moments=texture2D(_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),_ShadowMapSizeInv);if(max(dCoords.x,dCoords.y)>=min(_ShadowMapSizeInv.x,_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"),u.registerInclude("shadow-common.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");var Ze=function(){function e(){}return e.getVertexShaderCode=function(e){var t=e.featureList,n=e.material.materialType;switch(n){case ie.unlit:case ie.pbr:case ie.shadowBase:return Ge.build(je,t);case ie.skyboxFilter:return Ge.build(Xe,t);default:throw new Error("Invalid material type "+n+" for getVertexShaderString!")}},e.getFragmentShaderCode=function(e){var t=e.featureList,n=e.material.materialType;switch(n){case ie.unlit:case ie.pbr:return Ge.build(We,t);case ie.shadowBase:return Ge.build(Je,t);case ie.skyboxFilter:return Ge.build(qe,t);default:throw new Error("Invalid material type "+n+" for getFragmentShaderString!")}},e.genVertexShaderCode=function(e){switch(e){case ie.unlit:case ie.pbr:case ie.shadowBase:return je;case ie.skyboxFilter:return Xe;default:throw new Error("Invalid material type "+e+" for genVertexShaderCode!")}},e.genFragmentShaderCode=function(e){switch(e){case ie.unlit:case ie.pbr:return We;case ie.shadowBase:return Je;case ie.skyboxFilter:return qe;default:throw new Error("Invalid material type "+e+" for genFragmentShaderCode!")}},e}();function Ye(){return{vertexShaderCode:Ze.genVertexShaderCode(ie.pbr),fragmentShaderCode:Ze.genFragmentShaderCode(ie.pbr)}}function Ke(){return{vertexShaderCode:Ze.genVertexShaderCode(ie.unlit),fragmentShaderCode:Ze.genFragmentShaderCode(ie.unlit)}}function Qe(e){return{vertexShaderCode:Ze.getVertexShaderCode(e),fragmentShaderCode:Ze.getFragmentShaderCode(e)}}function $e(e){return{vertexShaderCode:Ze.getVertexShaderCode(e),fragmentShaderCode:Ze.getFragmentShaderCode(e)}}function et(e){return{vertexShaderCode:Ze.getVertexShaderCode(e),fragmentShaderCode:Ze.getFragmentShaderCode(e)}}function tt(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform sampler2D _ColorSampler;\n\n varying vec2 v_UVCoord1;\n void main(){\n gl_FragColor = texture2D(_ColorSampler, v_UVCoord1);\n }\n "}}function nt(e){return{vertexShaderCode:ut({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 it(e){return{vertexShaderCode:ut({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 "}}function rt(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform float _Offset;\n uniform vec2 _TextureSizeInv;\n uniform sampler2D _TexturSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0.0);\n color += texture2D(_TexturSampler, v_UVCoord1 + vec2(-_Offset-0.5,-_Offset-0.5) * _TextureSizeInv);\n color += texture2D(_TexturSampler, v_UVCoord1 + vec2(-_Offset-0.5, _Offset+0.5) * _TextureSizeInv);\n color += texture2D(_TexturSampler, v_UVCoord1 + vec2( _Offset+0.5,-_Offset-0.5) * _TextureSizeInv);\n color += texture2D(_TexturSampler, v_UVCoord1 + vec2( _Offset+0.5, _Offset+0.5) * _TextureSizeInv);\n gl_FragColor = color * 0.25;\n }\n "}}function ot(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform sampler2D _FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n gl_FragColor = texture2D(_FilterSampler, v_UVCoord1) * vec4(0.5);\n }\n "}}function at(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform vec2 _BlurScale;\n uniform sampler2D _FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0);\n vec2 offset0 = vec2(0.53805) * _BlurScale.xy;\n vec2 offset1 = vec2(2.06278) * _BlurScale.xy;\n color += (texture2D(_FilterSampler, v_UVCoord1 + offset0) + texture2D(_FilterSampler, v_UVCoord1 - offset0)) * 0.44908;\n color += (texture2D(_FilterSampler, v_UVCoord1 + offset1) + texture2D(_FilterSampler, v_UVCoord1 - offset1)) * 0.05092;\n gl_FragColor = color;\n }\n "}}function st(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform vec2 _BlurScale;\n uniform sampler2D _FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(-3.0) * _BlurScale.xy)) * (1.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(-2.0) * _BlurScale.xy)) * (6.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(-1.0) * _BlurScale.xy)) * (15.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(+0.0) * _BlurScale.xy)) * (20.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(+1.0) * _BlurScale.xy)) * (15.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(+2.0) * _BlurScale.xy)) * (6.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(+3.0) * _BlurScale.xy)) * (1.0/64.0);\n gl_FragColor = color;\n }\n "}}function lt(e){return e?ut({hasNormals:!0}):"\n #version 100\n #extension GL_EXT_draw_buffers: require\n\n precision highp float;\n uniform vec4 _BaseColorFactor;\n\n #ifdef HAS_UVS\n uniform sampler2D _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 = _BaseColorFactor;\n\n #ifdef HAS_UVS\n color *= texture2D(_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 "}function ct(e){return e?"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ":"\n #version 100\n precision highp float;\n uniform sampler2D _AccumColorSampler;\n uniform sampler2D _AccumAlphaSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 accumColor = texture2D(_AccumColorSampler, v_UVCoord1);\n vec4 accumAlpha = texture2D(_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 "}function ut(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 effects_ObjectToWorld;\n uniform mat4 effects_MatrixVP;\n attribute vec3 aPos;\n varying vec3 v_Position;\n\n #ifdef HAS_UVS\n attribute vec2 aUV;\n varying vec2 v_UVCoord1;\n #endif\n\n #ifdef HAS_NORMALS\n uniform mat4 _NormalMatrix;\n attribute vec3 aNormal;\n varying vec3 v_Normal;\n #endif\n\n void main(){\n vec4 pos = effects_ObjectToWorld * vec4(aPos, 1);\n v_Position = pos.xyz / pos.w;\n\n #ifdef HAS_UVS\n v_UVCoord1 = aUV;\n #endif\n\n #ifdef HAS_NORMALS\n v_Normal = normalize(vec3(effects_ObjectToWorld * vec4(aNormal, 0)));\n #endif\n\n gl_Position = effects_MatrixVP * pos;\n }\n "),t.join("\n")}Ze.environment="webgl1";var ht=function(){function e(){this.now=new Set,this.last=new Set}var t=e.prototype;return t.clear=function(){this.now.clear(),this.last.clear()},t.forward=function(){var e=this.last;this.last=this.now,this.now=e,this.now.clear()},t.forAddedItem=function(e){var t=this;this.now.forEach((function(n){t.last.has(n)||e(n)}))},t.forRemovedItem=function(e){var t=this;this.last.forEach((function(n){t.now.has(n)||e(n)}))},t.forNowItem=function(e){this.now.forEach((function(t){e(t)}))},e}(),ft=function(e){function t(t,i){var r;return(r=e.call(this,t)||this).morphWeights=[],r.getHitTestParams=function(e){r.computeBoundingBox();var t=r.bounding;if(t&&(e||Number.isInteger(t.behavior))){var i=t.type;if(i===n.ModelBoundingType.box){if(H(r.content,cn)){var o=r.content;return{behavior:t.behavior,type:m.custom,collect:function(e,t){return o.hitTesting(e.origin,e.direction)}}}var a=r.transform.getWorldMatrix();return{behavior:t.behavior,type:m.custom,collect:function(e,n){return Tt(e,a,t)}}}if(i===n.ModelBoundingType.sphere){var s=new le;r.transform.assignWorldTRS(s);var l=new le;return t.center&&l.setFromArray(t.center),l.add(s),{type:i,behavior:t.behavior,radius:t.radius||0,center:l}}}},i&&r.fromData(i),r}z(t,e);var i=t.prototype;return i.onStart=function(){var e;this.sceneManager=pn(this),this.createContent(),this.item.type=B,this.priority=this.item.renderOrder,null==(e=this.sceneManager)||e.addItem(this.content),this.item.parentId&&this.item.parent&&this.content.updateParentInfo(this.item.parentId,this.item.parent),this.setVisible(!0),this.item.getHitTestParams=this.getHitTestParams},i.onUpdate=function(e){this.sceneManager&&this.content.build(this.sceneManager),this.content.update()},i.onLateUpdate=function(e){this.content.lateUpdate()},i.render=function(e){this.getVisible()&&this.sceneManager&&this.content.render(this.sceneManager,e)},i.onDestroy=function(){var e;null==(e=this.sceneManager)||e.removeItem(this.content),this.sceneManager=void 0,this.content.dispose()},i.fromData=function(t){if(e.prototype.fromData.call(this,t),this.data=Ce({},t,{materials:[]}),this.data.rootBone=t.rootBone?this.engine.findObject(t.rootBone):void 0,this.data.geometry=this.engine.findObject(t.geometry),t.materials)for(var n=0;n<t.materials.length;n++)this.data.materials[n]=this.engine.findObject(t.materials[n])},i.createContent=function(){if(this.data){var e=this.data.interaction;this.bounding=e&&JSON.parse(JSON.stringify(e)),this.content=new cn(this.engine,this.item.name,this.data,this,this.item.parentId)}},i.setVisible=function(e){var t;null==(t=this.content)||t.onVisibleChanged(e)},i.getVisible=function(){var e,t;return null!=(t=null==(e=this.content)?void 0:e.visible)&&t},i.computeBoundingBox=function(){if(this.content&&H(this.content,cn)){var e,t=this.transform.getWorldMatrix(),i=this.content.computeBoundingBox(t),r=i.getCenter(new le),o=i.getSize(new le);return this.bounding={behavior:null==(e=this.bounding)?void 0:e.behavior,type:n.ModelBoundingType.box,center:[r.x,r.y,r.z],size:[o.x,o.y,o.z]},this.bounding}},t}(f);ft=j([h(n.DataType.MeshComponent)],ft);var dt=function(e){function t(t,n){var i;return i=e.call(this,t)||this,n&&i.fromData(n),i}z(t,e);var n=t.prototype;return n.onStart=function(){var e;this.createContent(),this.item.type=B,this.priority=this.item.renderOrder,this.sceneManager=pn(this),null==(e=this.sceneManager)||e.addItem(this.content),this.setVisible(!0)},n.render=function(e){this.getVisible()&&this.sceneManager&&this.content.render(this.sceneManager,e)},n.onDestroy=function(){var e;null==(e=this.sceneManager)||e.removeItem(this.content),this.sceneManager=void 0,this.content.dispose()},n.fromData=function(t){e.prototype.fromData.call(this,t),t.diffuseImage=t.diffuseImage?this.engine.findObject(t.diffuseImage):void 0,t.specularImage=this.engine.findObject(t.specularImage),this.data=t},n.createContent=function(){if(this.data){var e=this.data;this.content=new $t(this.item.name,e,this)}},n.setVisible=function(e){var t;null==(t=this.content)||t.onVisibleChanged(e)},n.getVisible=function(){var e,t;return null!=(t=null==(e=this.content)?void 0:e.visible)&&t},t}(f);dt=j([h(n.DataType.SkyboxComponent)],dt);var mt=function(e){function t(t,n){var i;return i=e.call(this,t)||this,n&&i.fromData(n),i}z(t,e);var n=t.prototype;return n.onStart=function(){this.createContent(),this.item.type=B;var e=pn(this);null==e||e.addItem(this.content),this.setVisible(!0)},n.onUpdate=function(e){this.content.update()},n.onDestroy=function(){this.content.dispose()},n.fromData=function(t){e.prototype.fromData.call(this,t),this.data=t},n.createContent=function(){if(this.data){var e=this.data;this.content=new sn(this.item.name,e,this)}},n.setVisible=function(e){var t;null==(t=this.content)||t.onVisibleChanged(e)},n.getVisible=function(){var e,t;return null!=(t=null==(e=this.content)?void 0:e.visible)&&t},t}(d);mt=j([h(n.DataType.LightComponent)],mt);var gt=function(e){function t(t,n){var i;return i=e.call(this,t)||this,n&&i.fromData(n),i}z(t,e);var n=t.prototype;return n.onStart=function(){this.createContent(),this.item.type=B;var e=pn(this);null==e||e.addItem(this.content),this.updateMainCamera()},n.onUpdate=function(e){this.content.update(),this.updateMainCamera()},n.onDestroy=function(){var e;null==(e=this.content)||e.dispose()},n.fromData=function(t){e.prototype.fromData.call(this,t),this.data=t},n.createContent=function(){if(this.data){var e=this.data,t=this.engine.renderer.getWidth(),n=this.engine.renderer.getHeight();this.content=new on(this.item.name,t,n,e,this)}},n.updateMainCamera=function(){this.content.matrix=this.transform.getWorldMatrix();var e=this.item.composition;e&&(e.camera.near=this.content.nearPlane,e.camera.far=this.content.farPlane,e.camera.fov=this.content.fov,e.camera.setTransform(this.transform))},n.setTransform=function(e,t){e&&this.transform.setPosition(e.x,e.y,e.z),t&&this.transform.setRotation(t.x,t.y,t.z),this.updateMainCamera()},t}(d);gt=j([h(n.DataType.CameraComponent)],gt);var pt=function(e){function t(t){var n;return(n=e.call(this,t)||this).elapsedTime=0,n.animation=-1,n.clips=[],n}z(t,e);var n=t.prototype;return n.onStart=function(){this.elapsedTime=0,this.item.type=B},n.onUpdate=function(e){this.elapsedTime+=.001*e,this.animation>=0&&this.animation<this.clips.length&&this.clips[this.animation].sampleAnimation(this.item,this.elapsedTime)},n.onDestroy=function(){},n.fromData=function(t){var n,i,r=this;e.prototype.fromData.call(this,t),this.data=t,this.name=null!=(n=t.name)?n:"<empty>",this.animation=null!=(i=t.animation)?i:-1,this.clips=[],t.animationClips.forEach((function(e){var t=new vt(r.engine),n=r.engine.findObject(e);t.setFromAnimationClip(n),r.clips.push(t)}))},t}(d);pt=j([h(n.DataType.AnimationComponent)],pt);var vt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).path2Node={},t}z(t,e);var n=t.prototype;return n.sampleAnimation=function(e,t){for(var n,i=this.duration,r=Math.max(0,t)%i,o=$(this.positionCurves);!(n=o()).done;){var a=n.value,s=a.keyFrames.getValue(r%this.duration),l=this.getTargetItem(e,a.path);null==l||l.transform.setPosition(s.x,s.y,s.z)}for(var c,u=$(this.rotationCurves);!(c=u()).done;){var h=c.value,f=h.keyFrames.getValue(r%this.duration),d=this.getTargetItem(e,h.path);null==d||d.transform.setQuaternion(f.x,f.y,f.z,f.w)}for(var m,g=$(this.scaleCurves);!(m=g()).done;){var p=m.value,v=p.keyFrames.getValue(r%this.duration),y=this.getTargetItem(e,p.path);null==y||y.transform.setScale(v.x,v.y,v.z)}for(var T,_=$(this.floatCurves);!(T=_()).done;){var b=T.value,C=b.keyFrames.getValue(r%this.duration),S=this.getTargetItem(e,b.path);if("ModelMeshComponent"===b.className){var x=null==S?void 0:S.getComponent(ft);if(x)yt(x,b.property.split("."),C);else console.error("Can't find mesh component.")}else console.warn("Ignore curve: className "+b.className+".")}},n.setFromAnimationClip=function(e){this.duration=e.duration,this.positionCurves=e.positionCurves.slice(),this.rotationCurves=e.rotationCurves.slice(),this.scaleCurves=e.scaleCurves.slice(),this.floatCurves=e.floatCurves.slice()},n.getTargetItem=function(e,t){if(this.path2Node[t])return this.path2Node[t];for(var n,i=e,r=$(t.split("/"));!(n=r()).done;){for(var o,a=n.value,s=!1,l=$(i.children);!(o=l()).done;){var c=o.value;if(c.name===a){i=c,s=!0;break}}if(!s)throw new Error("Can't find path in tree "+e.id+", "+t+".")}return this.path2Node[t]=i,i},t}(g);function yt(e,t,n){for(var i=t.length,r=e,o=0;o<i-1;o++){var a=t[o];if(!(a in r)||"object"!=typeof r[a])return void console.error("Invalid properties "+t+".");r=r[a]}r[t[i-1]]=n}function Tt(e,t,n){var i=t,r=i.clone().invert(),o=e.clone().applyMatrix(r),a=le.fromArray(n.center),s=le.fromArray(n.size).multiply(.5),l=a.clone().subtract(s),c=a.clone().add(s),u=o.intersectBox({min:l,max:c},new le);return void 0!==u?[i.transformPoint(u)]:void 0}function _t(e,t,n,i){var r=0,o=0,a=0,s=0,l=0,c=0,u=1/t.x,h=1/t.y,f=1/t.z;if(u>=0?(r=(n.x-e.x)*u,o=(i.x-e.x)*u):(r=(i.x-e.x)*u,o=(n.x-e.x)*u),h>=0?(a=(n.y-e.y)*h,s=(i.y-e.y)*h):(a=(i.y-e.y)*h,s=(n.y-e.y)*h),!(r>s||a>o||((a>r||r!=r)&&(r=a),(s<o||o!=o)&&(o=s),f>=0?(l=(n.z-e.z)*f,c=(i.z-e.z)*f):(l=(i.z-e.z)*f,c=(n.z-e.z)*f),r>c||l>o||((l>r||r!=r)&&(r=l),(c<o||o!=o)&&(o=c),o<0))))return r>=0?r:o}var bt=new le,Ct=new le,St=new le,xt=new le;function At(e,t,n,i,r,o){Ct.subtractVectors(i,n),St.subtractVectors(r,n),xt.crossVectors(Ct,St);var a=t.dot(xt),s=0;if(a>0){if(o)return;s=1}else{if(!(a<0))return;s=-1,a=-a}bt.subtractVectors(e,n),St.crossVectors(bt,St);var l=s*t.dot(St);if(!(l<0)){Ct.crossVectors(Ct,bt);var c=s*t.dot(Ct);if(!(c<0||l+c>a)){var u=-s*bt.dot(xt);if(!(u<0))return u/a}}}function Mt(e,t,n){var i=e.hitTest(t,n,!0),r=e.getHitTestRay(t,n);if(i.length<=0)return[];var o=r.origin,a=r.direction,s=i.map((function(e,t){for(var n,i=e.position,r=[0,0,0],s=0;s<3;s++)r[s]=(i.getElement(s)-o.getElement(s))/a.getElement(s);return[t,(n=Math).max.apply(n,[].concat(r))]}));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 i[e[0]]}))}function It(e,t){var n;null==(n=e.items)||n.forEach((function(e){if(e.type===B){var n=e.getComponent(ft);if(n){var i=n.content;e.id===t?i.visBoundingBox=!0:i.visBoundingBox=!1}}}))}var Et=function(){function e(){}return e.createTexture2D=function(t,n,i,r,o){return V((function(){var s,l,c,u;return W(this,(function(h){return void 0===n.imageData?(console.error("createTexture2D: Invalid image data from "+n+"."),[2,v.create(t,{name:"createTexture2D",sourceType:p.data,data:{data:new Uint8Array([255,255,255,255]),width:1,height:1}})]):(s=new Blob([n.imageData],{type:n.mimeType}),l=window.URL||window.webkitURL,c=l.createObjectURL(s),(u=new Image).src=c,[2,new Promise((function(n,s){u.onload=function(){var s,h=null!=(s=i.minFilter)?s:a.LINEAR_MIPMAP_LINEAR,f=!1;o&&(h=a.LINEAR_MIPMAP_LINEAR,e.isPow2(u.width)&&e.isPow2(u.height)||(h=a.LINEAR),f=!r);var d,m,g,y=!1;h!=a.NEAREST_MIPMAP_NEAREST&&h!=a.LINEAR_MIPMAP_NEAREST&&h!=a.NEAREST_MIPMAP_LINEAR&&h!=a.LINEAR_MIPMAP_LINEAR||(y=!0);var T=v.create(t,{name:"createTexture2D",wrapS:null!=(d=i.wrapS)?d:a.REPEAT,wrapT:null!=(m=i.wrapT)?m:a.REPEAT,magFilter:null!=(g=i.magFilter)?g:a.LINEAR,minFilter:h,anisotropic:1,premultiplyAlpha:f,sourceType:p.image,image:u,generateMipmap:y});n(T),l.revokeObjectURL(c)},u.onerror=s}))])}))}))()},e.createTextureList=function(e,t,n){var i=this;return V((function(){return W(this,(function(r){switch(r.label){case 0:return[4,Promise.all(n.map((function(n){return i.createTexture2D(e,t[n.source],n)})))];case 1:return[2,r.sent()]}}))}))()},e.getTextureCubeData=function(e){return V((function(){var t;return W(this,(function(n){switch(n.label){case 0:return[4,Ft.loadImageFromImageData(e[0])];case 1:return t=[n.sent()],[4,Ft.loadImageFromImageData(e[1])];case 2:return t=t.concat([n.sent()]),[4,Ft.loadImageFromImageData(e[2])];case 3:return t=t.concat([n.sent()]),[4,Ft.loadImageFromImageData(e[3])];case 4:return t=t.concat([n.sent()]),[4,Ft.loadImageFromImageData(e[4])];case 5:return t=t.concat([n.sent()]),[4,Ft.loadImageFromImageData(e[5])];case 6:return[2,t.concat([n.sent()])]}}))}))()},e.getTextureCubeMipmapData=function(e){var t=this;return V((function(){var n,i,r;return W(this,(function(o){switch(o.label){case 0:n=[],i=0,o.label=1;case 1:return i<e.length?(r=n.push,[4,t.getTextureCubeData(e[i])]):[3,4];case 2:r.apply(n,[o.sent()]),o.label=3;case 3:return i++,[3,1];case 4:return[2,n]}}))}))()},e.createTextureCubeFromURL=function(e,t){var n=this;return V((function(){var i;return W(this,(function(r){switch(r.label){case 0:return[4,A().loadSource({type:p.image,target:a.TEXTURE_CUBE_MAP,map:t},n.cubemapTexConfig)];case 1:return i=r.sent(),[2,v.create(e,i)]}}))}))()},e.createTextureCubeMipmapFromURL=function(e,t){var n=this;return V((function(){var i;return W(this,(function(r){switch(r.label){case 0:return[4,A().loadSource({type:p.mipmaps,target:a.TEXTURE_CUBE_MAP,maps:t},n.cubemapMipTexConfig)];case 1:return i=r.sent(),[2,v.create(e,i)]}}))}))()},e.createTextureCubeFromBuffer=function(t,n){var i=this;return V((function(){var r;return W(this,(function(o){switch(o.label){case 0:return[4,e.getTextureCubeData(n)];case 1:return r=o.sent(),[2,v.create(t,Ce({name:"createTextureCubeFromBuffer",sourceType:p.image,cube:r,target:a.TEXTURE_CUBE_MAP},i.cubemapTexConfig))]}}))}))()},e.createTextureCubeMipmapFromBuffer=function(t,n,i){var r=this;return V((function(){var o,s,l,c;return W(this,(function(u){switch(u.label){case 0:return[4,e.getTextureCubeMipmapData(n)];case 1:for(o=u.sent(),s=0;Math.pow(2,s)<i;)++s;u.label=2;case 2:return o.length<=s?(l=Math.pow(2,s-o.length),[4,M("https://gw.alipayobjects.com/zos/gltf-asset/67896749597915/img"+l+".png")]):[3,4];case 3:return c=u.sent(),o.push([c,c,c,c,c,c]),[3,2];case 4:return[2,v.create(t,Ce({name:"createTextureCubeMipmapFromBuffer",sourceType:p.mipmaps,mipmaps:o,target:a.TEXTURE_CUBE_MAP},r.cubemapMipTexConfig))]}}))}))()},e.getTexture=function(e,t){return e<0||e>=t.length?null:t[e]},e.createTextureFromImage=function(e,t){var n={name:"createTextureFromImage",image:t,sourceType:p.image,flipY:!1,magFilter:a.LINEAR,minFilter:a.LINEAR,wrapT:a.REPEAT,wrapS:a.REPEAT};return v.create(e,n)},e.createRenderPass=function(e,t,n,i,r){var o=H(i,l)?[i]:i;return new y(e,{name:t,priority:n,attachments:r.colorAttachments,depthStencilAttachment:r.depthAttachment,clearAction:{clearDepth:1,clearStencil:0,clearColor:[0,0,0,0],colorAction:T.clear,depthAction:T.clear},meshes:o,viewport:r.viewport})},e.deleteTexture=function(e){e.dispose()},e.deleteMesh=function(e){e.dispose({geometries:_.destroy})},e.deleteGeometry=function(e){e.dispose()},e.deleteRenderPass=function(e){e.dispose({meshes:{geometries:_.destroy},depthStencilAttachment:b.force,colorAttachment:b.force,semantics:_.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}();Et.cubemapTexConfig={name:"cubemap texture",wrapS:a.CLAMP_TO_EDGE,wrapT:a.CLAMP_TO_EDGE,magFilter:a.LINEAR,minFilter:a.LINEAR},Et.cubemapMipTexConfig={wrapS:a.CLAMP_TO_EDGE,wrapT:a.CLAMP_TO_EDGE,magFilter:a.LINEAR,minFilter:a.LINEAR_MIPMAP_LINEAR};var wt,Nt,Lt,Rt=function(){function e(){}return e.createFilterMesh=function(t,n,i){var r=Ie.getInstance(),o=i.vertexShaderCode,a=i.fragmentShaderCode,u=c.create(t,e.getPlaneGeometry()),h=2===t.gpuCapability.level,f=s.create(t,{shader:{vertex:o,fragment:a,shared:r.shaderShared,glslVersion:h?C.GLSL3:C.GLSL1}});return i.setMaterialStates(f),l.create(t,{name:n,worldMatrix:he.fromIdentity(),material:f,geometry:u})},e.getPlaneGeometry=function(){var t=e.getPlaneVertexArray();return{attributes:{aPos:{type:a.FLOAT,size:3,data:t,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:0},aUV:{type:a.FLOAT,size:2,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:3*Float32Array.BYTES_PER_ELEMENT,dataSource:"aPos"},aNormal:{type:a.FLOAT,size:3,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:5*Float32Array.BYTES_PER_ELEMENT,dataSource:"aPos"}},drawStart:0,drawCount:t.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}(),Ot=function(){function e(){}return e.createLightOptions=function(e){var t,n,i,r,o,a,s,l,c=null!=(t=e.color)?t:[255,255,255,255];return"point"===e.type?{color:c,intensity:null!=(n=e.intensity)?n:1,lightType:"point",range:null!=(i=e.range)?i:0}:"spot"===e.type?{color:c,intensity:null!=(r=e.intensity)?r:1,lightType:"spot",range:null!=(o=e.range)?o:0,innerConeAngle:null!=(a=e.innerConeAngle)?a:0,outerConeAngle:null!=(s=e.outerConeAngle)?s:Math.PI/4}:{color:c,intensity:null!=(l=e.intensity)?l:1,lightType:"directional"}},e.createCameraOptions=function(e){if(void 0!==e.perspective){var t,n=e.perspective;return{near:n.znear,far:null!=(t=n.zfar)?t:1e3,fov:n.yfov,clipMode:0}}},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,t,n){var i=e.getVector4(t),r=e.getFloat(n),o=ue.fromIdentity();i&&o.setFromArray([1,0,0,0,1,0,i.z,i.w,1]);var a=new ue;if(r){var s=Math.cos(r),l=Math.sin(r);a.setFromArray([s,l,0,-l,s,0,0,0,1]),o.multiply(a)}return i&&(a.setFromArray([i.x,0,0,0,i.y,0,0,0,1]),o.multiply(a)),o.transpose(),o},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,t,n){var r=le.fromArray(e),o=le.fromArray(n),a=(new le).copyFrom(r).subtract(o);he.fromRotationAxis(new le(0,1,0),t*Te).transformPoint(a);var s=a.clone().add(o),l=(new he).lookAt(s,o,new le(0,1,0)).invert(),c=new i;return c.setValid(!0),c.cloneFromMatrix(l),c},e.preprocessScene=function(e,t,i){var o=this,a=t!==r,s="tiny3d"===i,l=e.jsonScene;if(!(l&&l.textures&&l.materials))return{};var c={};e.textureOptions.forEach((function(e){var t=e.id;t&&(c[t]=e)}));var u=!1;return a&&(l.materials.forEach((function(e){o.preprocessTextureOptions(c,e.textures._BaseColorSampler,!0,s),o.preprocessTextureOptions(c,e.textures._MetallicRoughnessSampler,!1,s),o.preprocessTextureOptions(c,e.textures._NormalSampler,!1,s),o.preprocessTextureOptions(c,e.textures._OcclusionSampler,!1,s),o.preprocessTextureOptions(c,e.textures._EmissiveSampler,!1,s)})),l.components.forEach((function(e){if(e.dataType===n.DataType.SkyboxComponent){u=!0;var t=e;t.diffuseImage&&o.preprocessTextureOptions(c,t.diffuseImage,!1,s),t.specularImage&&o.preprocessTextureOptions(c,t.specularImage,!1,s)}}))),{loadSkybox:u}},e.preprocessTextureOptions=function(e,t,n,i){var r;if(i&&t&&(r="texture"in t?t.texture.id:t.id)){var o=e[r];if(o)if(void 0===o.target||o.target===a.TEXTURE_2D){o.wrapS=a.REPEAT,o.wrapT=a.REPEAT,o.magFilter=a.LINEAR,o.minFilter=a.LINEAR_MIPMAP_LINEAR,n||(o.premultiplyAlpha=!0);var s=o;s.generateMipmap=!0;var l=s.image;l&&l.width&&l.height&&(Et.isPow2(l.width)&&Et.isPow2(l.height)||(o.minFilter=a.LINEAR))}else o.target===a.TEXTURE_CUBE_MAP&&(o.wrapS=a.CLAMP_TO_EDGE,o.wrapT=a.CLAMP_TO_EDGE,void 0!==o.mipmaps?1===o.mipmaps.length?(o.magFilter=a.LINEAR,o.minFilter=a.LINEAR):(o.magFilter=a.LINEAR,o.minFilter=a.LINEAR_MIPMAP_LINEAR):(o.magFilter=a.LINEAR,o.minFilter=a.LINEAR))}},e.createGeometry=function(e,t,n){var i=Le(t,n),r={};for(var o in i.attributes){var a=i.attributes[o];r[this.getAttributeName(o)]=a}return i.attributes=r,c.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 "+e+".")}},e.getAttributeName=function(e){switch(e){case"POSITION":return"aPos";case"NORMAL":return"aNormal";case"TANGENT":return"aTangent";case"TEXCOORD_0":return"aUV";case"TEXCOORD_1":return"aUV2";case"JOINTS_0":return"aJoints";case"WEIGHTS_0":return"aWeights"}return e.startsWith("a")||console.warn("Unknown attribute name: "+e+"."),e},e.getTextureObj=function(e,t){return"number"!=typeof t?null:((t<0||t>=e.length)&&console.error("Invalid index for textures: "+t+", "+e.length+"."),e[t])},e}(),Ft=function(){function e(){}return e.getImageFileName=function(e,t){var n=e.lastIndexOf("/"),i=e.lastIndexOf("."),r=e.substring(n+1,i);return t?r+t:r},e.getCurrnetTimeStr=function(){var e=new Date(Date.now()),t=e.toLocaleString("zh-CN"),n=""+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 t=document.createElement("canvas");return t.width=512,t.height=512,new S({canvas:t,renderFramework:"webgl2",env:r,renderOptions:{willCaptureImage:!0},manualRender:e})},e.sleep=function(e){return V((function(){return W(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))()},e.loadImageFromGLTFImage=function(e){return V((function(){return W(this,(function(t){return[2,M(new Blob([e.imageData],{type:e.mimeType}))]}))}))()},e.loadImageFromImageData=function(e){return V((function(){return W(this,(function(t){return[2,M(new Blob([e.data],{type:e.mimeType}))]}))}))()},e.getCanvasArrayBuffer=function(e){return V((function(){return W(this,(function(t){return[2,new Promise((function(t,n){e.toBlob((function(e){e?t(e.arrayBuffer()):n(new Error("No canvas blob."))}),"image/png",1)}))]}))}))()},e.getImageArrayBuffer=function(e){var t=this;return V((function(){var n;return W(this,(function(i){return(n=document.createElement("canvas")).width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0),[2,t.getCanvasArrayBuffer(n)]}))}))()},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}(),Pt=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 le;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}(),Ut=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}var t=e.prototype;return t.create=function(e,t){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}var n,i;this.data=t,this.length=this.data.length,this.compCount=e.size,this.offset=null!=(n=e.offset)?n:0,this.offset>0&&(this.offset%this.typeSize!=0&&console.error("Invalid offset "+this.offset+", type size "+this.typeSize+"."),this.offset=this.offset/this.typeSize),this.stride=null!=(i=e.stride)?i:0,this.stride>0?(this.stride%this.typeSize!=0&&console.error("Invalid stride "+this.stride+", type size "+this.typeSize+"."),this.stride=this.stride/this.typeSize):this.stride=this.compCount,this.compressed=!0===e.normalize},t.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 i=0;i<this.compCount;i++)n[i]*=this.compressScale,this.signed&&(n[i]=Math.max(n[i],-1));return n}},t.getLength=function(){return Math.round((this.length-this.offset)/this.stride)},e}(),Dt=function(){function e(){this.drawStart=0,this.drawCount=0,this.bindMatrices=[]}var t=e.prototype;return t.create=function(e,t){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var n=e.attributes;this.index=e.getIndexData();var i=n.aPos,r=e.getAttributeData("aPos");this.position=new Ut,this.position.create(i,r);var o=n.aJoints,a=n.aWeights;if(void 0!==o&&void 0!==a){var s=e.getAttributeData("aJoints"),l=e.getAttributeData("aWeights");this.joint=new Ut,this.joint.create(o,s),this.weight=new Ut,this.weight.create(a,l)}this.bindMatrices=t},t.getBoundingBox=function(e){var t=this;e.makeEmpty();var n=new he,i=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0,r=new Set;if(void 0!==this.index)for(var o=0;o<this.drawCount;o++){var a=this.drawStart+o;a<this.index.length&&r.add(this.index[a])}else for(var s=0;s<this.drawCount;s++)r.add(this.drawStart+s);return r.forEach((function(r){var o=t.position.getData(r);if(void 0!==o){var a=le.fromArray(o);if(i){var s,l,c=null==(s=t.joint)?void 0:s.getData(r),u=null==(l=t.weight)?void 0:l.getData(r);if(void 0!==c&&void 0!==u){n.setZero();for(var h=!1,f=0;f<4;f++)if(0!==u[f]){if(c[f]<0||c[f]>=t.bindMatrices.length){h=!0;break}var d=t.bindMatrices[c[f]];n.addScaledMatrix(d,u[f])}if(!h){var m=n.transformVector4(new ce(a.x,a.y,a.z,1));Math.abs(m.w)>1e-4&&(m.multiply(1/m.w),a.set(m.x,m.y,m.z))}}}e.expandByPoint(a)}})),e},e}(),Bt=function(){function e(){this.drawStart=0,this.drawCount=0,this.doubleSided=!1,this.bindMatrices=[],this.hasAnimation=!1,this.skinMatrix=new he}var t=e.prototype;return t.create=function(e,t,n){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var i=e.attributes;this.index=e.getIndexData();var r=i.aPos,o=e.getAttributeData("aPos");this.position=new Ut,this.position.create(r,o);var a=i.aJoints,s=i.aWeights;if(void 0!==a&&void 0!==s){var l=e.getAttributeData("aJoints"),c=e.getAttributeData("aWeights");this.joint=new Ut,this.joint.create(a,l),this.weight=new Ut,this.weight.create(s,c)}this.doubleSided=t,this.bindMatrices=n,this.hasAnimation=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0},t.getHitPoint=function(e,t){for(var n,i=new le,r=new le,o=new le,a=new ce,s=new ce,l=new ce,c=!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 m=this.getPosition(h,i,a),g=this.getPosition(f,r,s),p=this.getPosition(d,o,l);if(m&&g&&p){var v=At(e,t,m,g,p,c);void 0!==v&&(void 0===n||n>v)&&(n=v)}}return n},t.getPosition=function(e,t,n){var i=this.position.getData(e);if(void 0===i)return null;if(this.hasAnimation){var r,o,a=null==(r=this.joint)?void 0:r.getData(e),s=null==(o=this.weight)?void 0:o.getData(e);if(void 0!==a&&void 0!==s){var l=this.skinMatrix;l.setZero();for(var c=0;c<4;c++)if(0!==s[c]){var u=this.bindMatrices[a[c]];l.addScaledMatrix(u,s[c])}n.set(i[0],i[1],i[2],1);var h=l.transformVector4(n),f=1/h.w;t.set(h.x*f,h.y*f,h.z*f)}}else t.set(i[0],i[1],i[2]);return t},e}(),kt=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 H(e,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!!H(e,v)&&(e.isDestroyed&&console.error("Texture is destroyed, "+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===n.MaterialBlending.opaque||e===n.MaterialBlending.masked||e===n.MaterialBlending.translucent||e===n.MaterialBlending.additive},e.checkMatSide=function(e){return void 0===e||e===n.SideMode.BACK||e===n.SideMode.DOUBLE||e===n.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,t){H(e,c)||console.error("Invalid geometry type "+this.stringify(e)+"."),!0===e.isDestroyed&&console.error("Geometry object is destroyed."),this.checkNonnegative(e.getDrawStart())||console.error("Invalid geometry draw start: "+e.getDrawStart()+", "+this.stringify(e)+".")},e.assertGeometryBuffer=function(e,t,n){var i=this.createAttributeArray(e,t);void 0!==i&&i.getLength()<n&&console.error(t+" Length("+i.getLength()+") is less than draw count("+n+"), "+this.stringify(e)+".")},e.createAttributeArray=function(e,t){var n=e.attributes;if(void 0!==n){var i=n[t];if(void 0!==i){var r=e.getAttributeData(t);if(void 0!==r){var o=new Ut;return o.create(i,r),o}}}},e.assertModelSkinOptions=function(e){if(this.checkStringUndef(e.name)||console.error("Invalid skin name "+e.name+", "+this.stringify(e)+"."),this.checkNumberArray(e.joints)||console.error("Invalid skin joints "+e.joints+", "+this.stringify(e)+"."),this.checkNumberUndef(e.skeleton)||console.error("Invalid skin skeleton "+e.skeleton+", "+this.stringify(e)+"."),this.checkFloat32ArrayUndef(e.inverseBindMatrices)||console.error("Invalid skin inverseBindMatrices "+e.inverseBindMatrices+", "+this.stringify(e)+"."),void 0!==e.inverseBindMatrices){(e.inverseBindMatrices.length<=0||e.inverseBindMatrices.length%16!=0)&&console.error("Invalid skin inverseBindMatrices length "+e.inverseBindMatrices+", "+this.stringify(e)+"."),16*e.joints.length!==e.inverseBindMatrices.length&&console.error("Mismatch: skin joints and inverseBindMatrices length, "+e.joints+", "+e.inverseBindMatrices+", "+this.stringify(e)+".");for(var t=new he,n=0;n<e.inverseBindMatrices.length;n+=16){for(var i=0;i<16;i++)t.elements[i]=e.inverseBindMatrices[n+i];Math.abs(t.determinant())<1e-5&&console.error("Determinant of inverseBindMatrices is too small "+t.determinant()+", index "+n/16+", "+this.stringify(e)+".")}}else e.joints.length<=0&&console.error("Invalid skin joints length "+e.joints+", "+this.stringify(e)+".")},e.assertMatOptions=function(e){e.type===n.MaterialType.unlit?(this.checkString(e.name)||console.error("Invalid material name "+e.name+", "+this.stringify(e)+"."),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor "+e.baseColorFactor+", "+this.stringify(e)+"."),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture "+e.baseColorTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform "+e.baseColorTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate "+e.baseColorTextureCoordinate+", "+this.stringify(e)+"."),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask "+e.depthMask+", "+this.stringify(e)+"."),this.checkMatBlending(e.blending)||console.error("Invalid material blending "+e.blending+", "+this.stringify(e)+"."),this.checkMatSide(e.side)||console.error("Invalid material side "+e.side+", "+this.stringify(e)+"."),e.blending===n.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, "+this.stringify(e)+"."),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff "+e.alphaCutOff+", "+this.stringify(e)+".")):e.type===n.MaterialType.pbr?(this.checkString(e.name)||console.error("Invalid material name "+e.name+", "+this.stringify(e)+"."),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor "+e.baseColorFactor+", "+this.stringify(e)+"."),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture "+e.baseColorTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform "+e.baseColorTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate "+e.baseColorTextureCoordinate+", "+this.stringify(e)+"."),this.checkBooleanUndef(e.useSpecularAA)||console.error("Invalid material useSpecularAA "+e.useSpecularAA+", "+this.stringify(e)+"."),this.checkNumber01(e.metallicFactor)||console.error("Invalid material metallicFactor "+e.metallicFactor+", "+this.stringify(e)+"."),this.checkNonnegative(e.roughnessFactor)||console.error("Invalid material roughnessFactor "+e.roughnessFactor+", "+this.stringify(e)+"."),this.checkTextureUndef(e.metallicRoughnessTexture)||console.error("Invalid material metallicRoughnessTexture "+e.metallicRoughnessTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.metallicRoughnessTextureTransform)||console.error("Invalid material metallicRoughnessTextureTransform "+e.metallicRoughnessTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.metallicRoughnessTextureCoordinate)||console.error("Invalid material metallicRoughnessTextureCoordinate "+e.metallicRoughnessTextureCoordinate+", "+this.stringify(e)+"."),this.checkTextureUndef(e.normalTexture)||console.error("Invalid material normalTexture "+e.normalTexture+", "+this.stringify(e)+"."),this.checkNonnegativeUndef(e.normalTextureScale)||console.error("Invalid material normalTextureScale "+e.normalTextureScale+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.normalTextureTransform)||console.error("Invalid material normalTextureTransform "+e.normalTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.normalTextureCoordinate)||console.error("Invalid material normalTextureCoordinate "+e.normalTextureCoordinate+", "+this.stringify(e)+"."),this.checkTextureUndef(e.occlusionTexture)||console.error("Invalid material occlusionTexture "+e.occlusionTexture+", "+this.stringify(e)+"."),this.checkNumber01Undef(e.occlusionTextureStrength)||console.error("Invalid material occlusionTextureStrength "+e.occlusionTextureStrength+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.occlusionTextureTransform)||console.error("Invalid material occlusionTextureTransform "+e.occlusionTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.occlusionTextureCoordinate)||console.error("Invalid material occlusionTextureCoordinate "+e.occlusionTextureCoordinate+", "+this.stringify(e)+"."),this.checkNonnegative4(e.emissiveFactor)||console.error("Invalid material emissiveFactor "+e.emissiveFactor+", "+this.stringify(e)+"."),this.checkNonnegative(e.emissiveIntensity)||console.error("Invalid material emissiveIntensity "+e.emissiveIntensity+", "+this.stringify(e)+"."),this.checkTextureUndef(e.emissiveTexture)||console.error("Invalid material emissiveTexture "+e.emissiveTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.emissiveTextureTransform)||console.error("Invalid material emissiveTextureTransform "+e.emissiveTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.emissiveTextureCoordinate)||console.error("Invalid material emissiveTextureCoordinate "+e.emissiveTextureCoordinate+", "+this.stringify(e)+"."),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask "+e.depthMask+", "+this.stringify(e)+"."),this.checkMatBlending(e.blending)||console.error("Invalid material blending "+e.blending+", "+this.stringify(e)+"."),this.checkMatSide(e.side)||console.error("Invalid material side "+e.side+", "+this.stringify(e)+"."),e.blending===n.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, "+this.stringify(e)+"."),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff "+e.alphaCutOff+", "+this.stringify(e)+".")):console.error("Invalid material type "+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 "+e.parent+", "+this.stringify(e)+"."),void 0!==e.skin&&this.assertModelSkinOptions(e.skin);for(var t=[],n=0;n<e.primitives.length;n++){var i=e.primitives[n];this.assertPrimOptions(i)||console.error("Invalid primitive "+i+", "+this.stringify(e)+".");var r=new Wt;r.create(i.geometry),t.push(r)}for(var o=1;o<t.length;o++){var a=t[o-1],s=t[o];a.equals(s)||console.error("Morph states mismatch: "+this.stringify(a)+", "+this.stringify(s)+", "+this.stringify(e)+".")}this.checkBooleanUndef(e.hide)||console.error("Invalid mesh hide "+e.hide+", "+this.stringify(e)+".")},e.assertModelCameraOptions=function(e){this.checkParent(e.parent)||console.error("Invalid camera parent "+e.parent+", "+this.stringify(e)+"."),this.checkNumberUndef(e.aspect)||console.error("Invalid camera aspect "+e.aspect+", "+this.stringify(e)+"."),this.checkPositive(e.near)||console.error("Invalid camera near "+e.near+", "+this.stringify(e)+"."),(!this.checkPositive(e.far)||e.far<=e.near)&&console.error("Invalid camera far "+e.far+", "+this.stringify(e)+"."),this.checkPositive(e.fov)||console.error("Invalid camera fov "+e.fov+", "+this.stringify(e)+"."),this.checkNumber01(e.clipMode)||console.error("Invalid camera clipMode "+e.clipMode+", "+this.stringify(e)+".")},e.assertModelLightOptions=function(e){"directional"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+".")):"point"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+"."),this.checkNonnegative(e.range)||console.error("Invalid light range "+e.range+", "+this.stringify(e)+".")):"spot"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+"."),this.checkNonnegative(e.range)||console.error("Invalid light range "+e.range+", "+this.stringify(e)+"."),this.checkNonnegative(e.innerConeAngle)||console.error("Invalid light innerConeAngle "+e.innerConeAngle+", "+this.stringify(e)+"."),this.checkNonnegative(e.outerConeAngle)||console.error("Invalid light outerConeAngle "+e.outerConeAngle+", "+this.stringify(e)+".")):"ambient"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+".")):console.error("Invalid light type "+this.stringify(e)+".")},e.assertModelSkyboxOptions=function(e){var t=this;this.checkBoolean(e.renderable)||console.error("Invalid skybox renderable "+e.renderable+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid skybox intensity "+e.intensity+", "+this.stringify(e)+"."),this.checkNonnegative(e.reflectionsIntensity)||console.error("Invalid skybox reflectionsIntensity "+e.reflectionsIntensity+", "+this.stringify(e)+".");var n=e.irradianceCoeffs;void 0!==n?(Array.isArray(n)&&9==n.length||console.error("Invalid skybox irradianceCoeffs "+n+", "+this.stringify(e)+"."),n.forEach((function(e){t.checkVec3(e)||console.error("Invalid skybox irradianceCoeffs "+n+", "+t.stringify(e)+".")}))):void 0!==e.diffuseImage?this.checkTexture(e.diffuseImage)||console.error("Invalid skybox diffuseImage "+e.diffuseImage+", "+this.stringify(e)+"."):console.error("Invalid skybox, irradianceCoeffs or diffuseImage should give one, "+this.stringify(e)+"."),this.checkTexture(e.specularImage)||console.error("Invalid skybox specularImage "+e.specularImage+", "+this.stringify(e)+"."),this.checkPositive(e.specularImageSize)||console.error("Invalid skybox specularImageSize "+e.specularImageSize+", "+this.stringify(e)+"."),this.checkPositive(e.specularMipCount)||console.error("Invalid skybox specularMipCount "+e.specularMipCount+", "+this.stringify(e)+"."),this.pow2(e.specularMipCount)>e.specularImageSize&&console.error("Invalid skybox specularMipCount or specularImageSize, "+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 "+e.interpolation+", "+this.stringify(e)),!1):(console.error("Invalid track path "+e.path+", "+this.stringify(e)),!1):(console.error("Invalid track input "+e.output+", "+this.stringify(e)),!1):(console.error("Invalid track input "+e.input+", "+this.stringify(e)),!1):(console.error("Invalid track node "+e.node+", "+this.stringify(e)),!1)},e.assertModelAnimOptions=function(e){var t=this;this.checkStringUndef(e.name)||console.error("Invalid animation name "+e.name+", "+this.stringify(e)+"."),Array.isArray(e.tracks)||console.error("Invalid animation tracks "+e.tracks+", "+this.stringify(e)+"."),e.tracks.forEach((function(n){t.checkModelAnimTrackOptions(n)||console.error("Invalid animation track "+n+", "+t.stringify(e)+".")}))},e.assertTreeOptions=function(e){var t=this;this.checkNumberUndef(e.animation)||console.error("Invalid tree animation "+e.animation+", "+this.stringify(e)+"."),void 0!==e.animations&&(Array.isArray(e.animations)||console.error("Invalid tree animations "+e.animations+", "+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 "+e.animations+", "+this.stringify(e)+"."))},e.stringify=function(e){var t={};for(var n in e)"internal"!==n&&"function"!=typeof e[n]&&(H(e[n],v)||H(e[n],c)?t[n]=e[n].name:H(e[n],x)||(t[n]=e[n]));return JSON.stringify(t)},e.pow2=function(e){for(var t=1;e-- >0;)t*=2;return t},e}(),Vt=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]=Gt(e[n])},be(e,[{key:"bytes",get:function(){return 2*this.size}}]),e}(),Gt=(wt=new Float32Array(1),Nt=new Int32Array(wt.buffer),function(e){wt[0]=e;var t=Nt[0],n=t>>16&32768,i=t>>12&2047,r=t>>23&255;return r<103?n:r>142?(n|=31744,n|=(255==r?0:1)&&8388607&t):r<113?n|=((i|=2048)>>114-r)+(i>>113-r&1):(n|=r-112<<10|i>>1,n+=1&i)});!function(e){e[e.none=0]="none",e[e.float=1]="float",e[e.half_float=2]="half_float"}(Lt||(Lt={}));var zt,Ht,jt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).skeleton=0,t.jointItem=[],t.inverseBindMatrices=[],t.animationMatrices=[],t.textureDataMode=0,t.maxJointCount=0,t}z(t,e);var n=t.prototype;return n.create=function(e,t,n,i){var r;this.name=null!=(r=e.rootBoneName)?r:"Unnamed skin",this.type=ee.skin,this.rootBoneItem=n,this.skeleton=-1,this.jointItem=this.getJointItems(e,n),this.maxJointCount=Math.max(i,this.jointItem.length),this.animationMatrices=[],this.inverseBindMatrices=[],this.textureDataMode=this.getTextureDataMode(this.maxJointCount,t);var o=e.inverseBindMatrices;if(void 0!==o&&o.length>0){if(o.length%16!=0||o.length!==16*this.jointItem.length)throw new Error("Invalid array length, invert bind matrices "+o.length+", joint array "+this.jointItem.length+".");for(var a=o.length/16,s=0;s<a;s++){var l=he.fromArray(o,16*s);this.inverseBindMatrices.push(l)}}},n.updateSkinMatrices=function(){var e=this;this.animationMatrices=[];for(var t=0;t<this.jointItem.length;t++){var n=this.jointItem[t].transform.getWorldMatrix();this.animationMatrices.push(n.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.computeMeshAnimMatrices=function(e,t,n){var i=e.clone().invert(),r=new he;this.animationMatrices.forEach((function(e,o){var a=r.multiplyMatrices(i,e);a.elements.forEach((function(e,n){return t[16*o+n]=e})),a.clone().invert().transpose().elements.forEach((function(e,t){return n[16*o+t]=e}))}))},n.updateParentItem=function(e){this.rootBoneItem=e},n.getJointCount=function(){return this.jointItem.length},n.isTextureDataMode=function(){return 0!==this.textureDataMode},n.dispose=function(){this.rootBoneItem=void 0,this.jointItem=[],this.inverseBindMatrices=[],this.animationMatrices=[]},n.getTextureDataMode=function(e,t){var n=t.gpuCapability.detail,i=n.maxVertexUniforms-25;if(e>Math.floor(i/8)){if(n.floatTexture)return 1;if(n.halfFloatTexture)return 2;throw new Error("Too many joint count "+e+", half float texture not support.")}return 0},n.getJointItems=function(e,t){var n,i=this.genNodeName(t),r=[];return null==(n=e.boneNames)||n.forEach((function(e){var t=i[e];if(!t)throw new Error("Can't find node of bone name "+e+".");r.push(t)})),r},n.genNodeName=function(e){var t={},n=[];t[""]=e;for(var i,r=$(e.children);!(i=r()).done;){var o=i.value;this.genNodeNameDFS(o,n,t)}return t},n.genNodeNameDFS=function(e,t,n){t.push(e.name),n[t.join("/")]=e;for(var i,r=$(e.children);!(i=r()).done;){var o=i.value;this.genNodeNameDFS(o,t,n)}t.pop()},t}(we),Wt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).morphWeightsLength=0,t.morphWeightsArray=[],t.hasPositionMorph=!1,t.hasNormalMorph=!1,t.hasTangentMorph=!1,t}z(t,e);var n=t.prototype;return n.create=function(e){var n=this;this.name=this.genName("Morph target"),this.type=ee.morph;var i=this.getAttributeMorphCount(t.positionNameList,e),r=this.getAttributeMorphCount(t.normalNameList,e),o=this.getAttributeMorphCount(t.tangentNameList,e),a=[i,r,o];return this.morphWeightsLength=0,a.forEach((function(e){e>0&&(0===n.morphWeightsLength?n.morphWeightsLength=e:n.morphWeightsLength=Math.min(n.morphWeightsLength,e))})),this.morphWeightsLength>0&&(this.morphWeightsArray=Array(this.morphWeightsLength).fill(0),this.hasPositionMorph=i==this.morphWeightsLength,this.hasNormalMorph=r==this.morphWeightsLength,this.hasTangentMorph=o==this.morphWeightsLength),i>0&&i!=this.morphWeightsLength?(console.error("Position morph count mismatch: "+this.morphWeightsLength+", "+i+"."),!1):r>0&&r!=this.morphWeightsLength?(console.error("Normal morph count mismatch: "+this.morphWeightsLength+", "+r+"."),!1):o>0&&o!=this.morphWeightsLength?(console.error("Tangent morph count mismatch: "+this.morphWeightsLength+", "+o+"."),!1):!(this.morphWeightsLength>5)||(console.error("Tangent morph count should not greater than 5, current "+this.morphWeightsLength+"."),!1)},n.initWeights=function(e){if(0!==this.morphWeightsArray.length){var t=this.morphWeightsArray;e.forEach((function(e,n){n<t.length&&(t[n]=e)}))}},n.updateWeights=function(e){var t=this;e.length==this.morphWeightsArray.length?e.forEach((function(e,n){return t.morphWeightsArray[n]=e})):console.error("Length of morph weights mismatch: input "+e.length+", internel "+this.morphWeightsArray.length+".")},n.hasMorph=function(){return this.morphWeightsLength>0&&(this.hasPositionMorph||this.hasNormalMorph||this.hasTangentMorph)},n.equals=function(e){return this.morphWeightsLength===e.morphWeightsLength&&this.hasPositionMorph===e.hasPositionMorph&&this.hasNormalMorph===e.hasNormalMorph&&this.hasTangentMorph===e.hasTangentMorph},n.getMorphWeightsArray=function(){return this.morphWeightsArray},n.getAttributeMorphCount=function(e,t){for(var n=0;n<e.length;n++){var i=e[n];if(void 0===t.getAttributeData(i))return n}return e.length},t}(we);Wt.positionNameList=["aTargetPosition0","aTargetPosition1","aTargetPosition2","aTargetPosition3","aTargetPosition4","aTargetPosition5","aTargetPosition6","aTargetPosition7"],Wt.normalNameList=["aTargetNormal0","aTargetNormal1","aTargetNormal2","aTargetNormal3","aTargetNormal4","aTargetNormal5","aTargetNormal6","aTargetNormal7"],Wt.tangentNameList=["aTargetTangent0","aTargetTangent1","aTargetTangent2","aTargetTangent3","aTargetTangent4","aTargetTangent5","aTargetTangent6","aTargetTangent7"],function(e){e[e.linear=0]="linear",e[e.step=1]="step",e[e.cubicSpline=2]="cubicSpline"}(zt||(zt={})),function(e){e[e.translation=0]="translation",e[e.rotation=1]="rotation",e[e.scale=2]="scale",e[e.weights=3]="weights"}(Ht||(Ht={}));var Jt=function(){function e(e){this.engine=e,this.isHalfFloat=!0,this.width=0,this.height=0}var t=e.prototype;return t.create=function(e,t,n){var i,r;this.width=4,this.height=e,this.isHalfFloat=t,this.isHalfFloat&&(this.buffer=new Vt(4*this.getSize()));var o=null!=(r=null==(i=this.buffer)?void 0:i.data)?r:new Float32Array(4*this.getSize()),s=this.isHalfFloat?a.HALF_FLOAT:a.FLOAT;this.texture=v.create(this.engine,{name:n,data:{width:this.width,height:this.height,data:o},target:a.TEXTURE_2D,format:a.RGBA,type:s,wrapS:a.CLAMP_TO_EDGE,wrapT:a.CLAMP_TO_EDGE,minFilter:a.NEAREST,magFilter:a.NEAREST})},t.update=function(e){var t,n;(void 0!==this.buffer&&this.buffer.set(e,0),void 0!==this.texture)&&this.texture.updateSource({sourceType:p.data,data:{width:this.width,height:this.height,data:null!=(n=null==(t=this.buffer)?void 0:t.data)?n:e},target:a.TEXTURE_2D})},t.dispose=function(){var e;this.engine=null,this.buffer=void 0,null==(e=this.texture)||e.dispose()},t.getSize=function(){return this.width*this.height},t.getTexture=function(){return this.texture},e}(),Xt=function(){function e(){this.funcMap=new Map,this.funcMap.set(ie.unlit,Qe),this.funcMap.set(ie.pbr,Qe),this.funcMap.set(ie.shadowBase,$e),this.funcMap.set(ie.shadowFilter,at),this.funcMap.set(ie.normalVis,nt),this.funcMap.set(ie.simpleFilter,ot),this.funcMap.set(ie.skyboxFilter,et)}return e.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 "+t+", shader content "+e+".")},e.getInstance=function(){return this._instance||(this._instance=new this)},e}(),qt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).materialType=ie.none,t.vertexShaderCode="",t.fragmentShaderCode="",t.ZWrite=!0,t.ZTest=!0,t.renderType=n.RenderType.Opaque,t.alphaClip=!1,t.alphaCutoff=.5,t.renderFace=n.RenderFace.Front,t}z(t,e);var i=t.prototype;return i.getShaderFeatures=function(){var e=[];return this.isAlphaClip()?e.push("ALPHAMODE_MASK 1"):this.isOpaque()&&e.push("ALPHAMODE_OPAQUE 1"),this.renderFace===n.RenderFace.Both&&e.push("DOUBLE_SIDED 1"),e},i.getShaderMacros=function(){var e=[];return this.isAlphaClip()?e.push({name:"ALPHAMODE_MASK"}):this.isOpaque()&&e.push({name:"ALPHAMODE_OPAQUE"}),this.renderFace===n.RenderFace.Both&&e.push({name:"DOUBLE_SIDED"}),e},i.updateUniforms=function(e){if(Ie.getInstance().renderMode3D===n.RenderMode3D.uv){var t=Ie.getInstance().renderMode3DUVGridSize;e.setFloat("_DebugUVGridSize",t)}},i.build=function(e){var t=this.getFeatureList(e),n=Ie.getInstance().isWebGL2,i=Xt.getInstance().genShaderCode({material:this,isWebGL2:n,featureList:t});this.vertexShaderCode=i.vertexShaderCode,this.fragmentShaderCode=i.fragmentShaderCode},i.getFeatureList=function(e){var t,n=this.getShaderFeatures();void 0!==e&&(t=n).push.apply(t,[].concat(e));this.materialType!==ie.shadowBase&&(Ie.getInstance().isEditorEnv&&n.push("EDITOR_TRANSFORM"));return n},i.getMacroList=function(e){var t,n=this.getShaderMacros();void 0!==e&&(t=n).push.apply(t,[].concat(e));this.materialType!==ie.shadowBase&&(Ie.getInstance().isEditorEnv&&n.push({name:"EDITOR_TRANSFORM"}));return n},i.setMaterialStates=function(e){this.renderType===n.RenderType.Transparent?(e.blending=!0,e.depthTest=this.ZTest,e.depthMask=this.ZWrite,e.blendEquation=[a.FUNC_ADD,a.FUNC_ADD],e.blendFunction=[a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA]):Ie.getInstance().isTiny3dMode?(e.blending=!1,e.depthTest=!0,e.depthMask=!0):(e.blending=!1,e.depthTest=this.ZTest,e.depthMask=this.ZWrite),this.setFaceSideStates(e)},i.setFaceSideStates=function(e){this.isBothSide()?e.culling=!1:this.isBackSide()?(e.cullFace=a.FRONT,e.frontFace=a.CCW,e.culling=!0):(e.cullFace=a.BACK,e.frontFace=a.CCW,e.culling=!0)},i.dispose=function(){this.vertexShaderCode="",this.fragmentShaderCode=""},i.isValid=function(){return this.materialType!==ie.none&&e.prototype.isValid.call(this)},i.isOpaque=function(){return this.renderType===n.RenderType.Opaque},i.isAlphaClip=function(){return this.alphaClip},i.isTransparent=function(){return this.renderType===n.RenderType.Transparent},i.isFrontSide=function(){return this.renderFace===n.RenderFace.Front},i.isBackSide=function(){return this.renderFace===n.RenderFace.Back},i.isBothSide=function(){return this.renderFace===n.RenderFace.Both},t}(we),Zt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).baseColorFactor=new fe(1,1,1,1),t}z(t,e);var i=t.prototype;return i.create=function(e){var t,i,r,o,a;this.effectMaterial=e,this.name=e.name,this.type=ee.material,this.materialType=ie.unlit,this.baseColorTexture=null!=(t=e.getTexture("_BaseColorSampler"))?t:void 0,this.baseColorTextureTrans=Ot.createUVTransform(e,"_BaseColorSampler_ST","_BaseColorRotation"),this.baseColorFactor=null!=(i=e.getColor("_BaseColorFactor"))?i:new fe(1,1,1,1),this.ZWrite=0!==e.getFloat("ZWrite"),this.ZTest=0!==e.getFloat("ZTest"),this.renderType=null!=(r=e.stringTags.RenderType)?r:n.RenderType.Opaque,this.alphaClip=1===e.getFloat("AlphaClip"),this.alphaCutoff=null!=(o=e.getFloat("_AlphaCutoff"))?o:0,this.renderFace=null!=(a=e.stringTags.RenderFace)?a:n.RenderFace.Front},i.dispose=function(){e.prototype.dispose.call(this),this.baseColorTexture=void 0},i.getShaderFeatures=function(){var t=e.prototype.getShaderFeatures.call(this);return t.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&t.push("HAS_BASE_COLOR_MAP 1"),t.push("MATERIAL_UNLIT 1"),t},i.getShaderMacros=function(){var t=e.prototype.getShaderMacros.call(this);return t.push({name:"MATERIAL_METALLICROUGHNESS"}),this.hasBaseColorTexture()&&t.push({name:"HAS_BASE_COLOR_MAP"}),t.push({name:"MATERIAL_UNLIT"}),t},i.updateUniforms=function(t){e.prototype.updateUniforms.call(this,t),void 0!==this.baseColorTexture&&(t.setInt("_BaseColorUVSet",0),t.setMatrix3("_BaseColorUVTransform",this.baseColorTextureTrans)),t.setFloat("_MetallicFactor",0),t.setFloat("_RoughnessFactor",0),t.setFloat("_Exposure",1)},i.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},i.getBaseColorTexture=function(){return this.baseColorTexture},i.setBaseColorTexture=function(e){this.baseColorTexture=e},i.getBaseColorFactor=function(){return this.baseColorFactor},i.setBaseColorFactor=function(e){H(e,fe)?this.baseColorFactor.set(e.r,e.g,e.b,e.a):H(e,ce)?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},t}(qt),Yt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).baseColorFactor=new fe(1,1,1,1),t.useSpecularAA=!1,t.metallicFactor=0,t.roughnessFactor=1,t.normalTextureScale=1,t.occlusionTextureStrength=1,t.emissiveFactor=new fe(0,0,0,0),t.emissiveIntensity=1,t}z(t,e);var i=t.prototype;return i.create=function(e){var t,i,r,o,a,s,l,c,u,h,f,d,m,g,p;this.effectMaterial=e,this.name=e.name,this.type=ee.material,this.materialType=ie.pbr,this.baseColorTexture=null!=(t=e.getTexture("_BaseColorSampler"))?t:void 0,this.baseColorTextureTrans=Ot.createUVTransform(e,"_BaseColorSampler_ST","_BaseColorRotation"),this.baseColorFactor=null!=(i=e.getColor("_BaseColorFactor"))?i:new fe(1,1,1,1),this.metallicRoughnessTexture=null!=(r=e.getTexture("_MetallicRoughnessSampler"))?r:void 0,this.metallicRoughnessTextureTrans=Ot.createUVTransform(e,"_MetallicRoughnessSampler_ST","_MetallicRoughnessRotation"),this.useSpecularAA=1===e.getFloat("_SpecularAA"),this.metallicFactor=null!=(o=e.getFloat("_MetallicFactor"))?o:1,this.roughnessFactor=null!=(a=e.getFloat("_RoughnessFactor"))?a:0,this.normalTexture=null!=(s=e.getTexture("_NormalSampler"))?s:void 0,this.normalTextureTrans=Ot.createUVTransform(e,"_NormalSampler_ST","_NormalRotation"),this.normalTextureScale=null!=(l=e.getFloat("_NormalScale"))?l:1,this.occlusionTexture=null!=(c=e.getTexture("_OcclusionSampler"))?c:void 0,this.occlusionTextureTrans=Ot.createUVTransform(e,"_OcclusionSampler_ST","_OcclusionRotation"),this.occlusionTextureStrength=null!=(u=e.getFloat("_OcclusionStrength"))?u:1,this.emissiveTexture=null!=(h=e.getTexture("_EmissiveSampler"))?h:void 0,this.emissiveTextureTrans=Ot.createUVTransform(e,"_EmissiveSampler_ST","_EmissiveRotation"),this.emissiveFactor=null!=(f=e.getColor("_EmissiveFactor"))?f:new fe(0,0,0,1),this.emissiveIntensity=null!=(d=e.getFloat("_EmissiveIntensity"))?d:1,this.ZWrite=0!==e.getFloat("ZWrite"),this.ZTest=0!==e.getFloat("ZTest"),this.renderType=null!=(m=e.stringTags.RenderType)?m:n.RenderType.Opaque,this.alphaClip=1===e.getFloat("AlphaClip"),this.alphaCutoff=null!=(g=e.getFloat("_AlphaCutoff"))?g:0,this.renderFace=null!=(p=e.stringTags.RenderFace)?p:n.RenderFace.Front},i.dispose=function(){e.prototype.dispose.call(this),this.baseColorTexture=void 0,this.metallicRoughnessTexture=void 0,this.normalTexture=void 0,this.occlusionTexture=void 0,this.emissiveTexture=void 0},i.getShaderFeatures=function(){var t=e.prototype.getShaderFeatures.call(this);return t.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&(t.push("HAS_BASE_COLOR_MAP 1"),void 0!==this.baseColorTextureTrans&&t.push("HAS_BASECOLOR_UV_TRANSFORM 1")),this.hasMetallicRoughnessTexture()&&(t.push("HAS_METALLIC_ROUGHNESS_MAP 1"),void 0!==this.metallicRoughnessTextureTrans&&t.push("HAS_METALLICROUGHNESS_UV_TRANSFORM 1")),this.useSpecularAA&&t.push("USE_SPECULAR_AA 1"),this.hasNormalTexture()&&(t.push("HAS_NORMAL_MAP 1"),void 0!==this.normalTextureTrans&&t.push("HAS_NORMAL_UV_TRANSFORM 1")),this.hasOcclusionTexture()&&(t.push("HAS_OCCLUSION_MAP 1"),void 0!==this.occlusionTextureTrans&&t.push("HAS_OCCLUSION_UV_TRANSFORM 1")),this.hasEmissiveTexture()?(t.push("HAS_EMISSIVE_MAP 1"),void 0!==this.emissiveTextureTrans&&t.push("HAS_EMISSIVE_UV_TRANSFORM 1")):this.hasEmissiveValue()&&t.push("HAS_EMISSIVE 1"),t},i.getShaderMacros=function(){var t=e.prototype.getShaderMacros.call(this);return t.push({name:"MATERIAL_METALLICROUGHNESS"}),this.hasBaseColorTexture()&&(t.push({name:"HAS_BASE_COLOR_MAP"}),void 0!==this.baseColorTextureTrans&&t.push({name:"HAS_BASECOLOR_UV_TRANSFORM"})),this.hasMetallicRoughnessTexture()&&(t.push({name:"HAS_METALLIC_ROUGHNESS_MAP"}),void 0!==this.metallicRoughnessTextureTrans&&t.push({name:"HAS_METALLICROUGHNESS_UV_TRANSFORM"})),this.useSpecularAA&&t.push({name:"USE_SPECULAR_AA"}),this.hasNormalTexture()&&(t.push({name:"HAS_NORMAL_MAP"}),void 0!==this.normalTextureTrans&&t.push({name:"HAS_NORMAL_UV_TRANSFORM"})),this.hasOcclusionTexture()&&(t.push({name:"HAS_OCCLUSION_MAP"}),void 0!==this.occlusionTextureTrans&&t.push({name:"HAS_OCCLUSION_UV_TRANSFORM"})),this.hasEmissiveTexture()?(t.push({name:"HAS_EMISSIVE_MAP"}),void 0!==this.emissiveTextureTrans&&t.push({name:"HAS_EMISSIVE_UV_TRANSFORM"})):this.hasEmissiveValue()&&t.push({name:"HAS_EMISSIVE"}),t},i.updateUniforms=function(t){e.prototype.updateUniforms.call(this,t),void 0!==this.baseColorTexture&&(t.setInt("_BaseColorUVSet",0),t.setMatrix3("_BaseColorUVTransform",this.baseColorTextureTrans)),void 0!==this.metallicRoughnessTexture&&(t.setInt("_MetallicRoughnessUVSet",0),t.setMatrix3("_MetallicRoughnessUVTransform",this.metallicRoughnessTextureTrans)),void 0!==this.normalTexture&&(t.setInt("_NormalUVSet",0),t.setMatrix3("_NormalUVTransform",this.normalTextureTrans)),void 0!==this.occlusionTexture&&(t.setInt("_OcclusionUVSet",0),t.setMatrix3("_OcclusionUVTransform",this.occlusionTextureTrans)),void 0!==this.emissiveTexture&&(t.setInt("_EmissiveUVSet",0),t.setMatrix3("_EmissiveUVTransform",this.emissiveTextureTrans)),t.setFloat("_Exposure",3)},i.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},i.setBaseColorTexture=function(e){this.baseColorTexture=e},i.getBaseColorFactor=function(){return this.baseColorFactor},i.setBaseColorFactor=function(e){H(e,fe)?this.baseColorFactor.set(e.r,e.g,e.b,e.a):H(e,ce)?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},i.hasMetallicRoughnessTexture=function(){return void 0!==this.metallicRoughnessTexture},i.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture},i.setMetallicRoughnessTexture=function(e){this.metallicRoughnessTexture=e},i.hasNormalTexture=function(){return void 0!==this.normalTexture},i.getNormalTexture=function(){return this.normalTexture},i.setNormalTexture=function(e){this.normalTexture=e},i.hasOcclusionTexture=function(){return void 0!==this.occlusionTexture},i.getOcclusionTexture=function(){return this.occlusionTexture},i.setOcclusionTexture=function(e){this.occlusionTexture=e},i.hasEmissiveTexture=function(){return void 0!==this.emissiveTexture},i.getEmissiveTexture=function(){return this.emissiveTexture},i.setEmissiveTexture=function(e){this.emissiveTexture=e},i.hasEmissiveValue=function(){return this.emissiveFactor.luminance()*this.emissiveIntensity>0},i.getEmissiveFactor=function(){return this.emissiveFactor},i.setEmissiveFactor=function(e){H(e,fe)?this.emissiveFactor.set(e.r,e.g,e.b,e.a):H(e,le)?this.emissiveFactor.set(e.x,e.y,e.z,0):this.emissiveFactor.set(e[0],e[1],e[2],0)},i.getEmissiveIntensity=function(){return this.emissiveIntensity},i.setEmissiveIntensity=function(e){this.emissiveIntensity=e},t}(qt);function Kt(e){if(e.shader.getInstanceId()===Se){var t=new Yt;return t.create(e),t}var n=new Zt;return n.create(e),n}var Qt,$t=function(e){function t(t,n,i){var r,o;(r=e.call(this)||this).renderable=!0,r.intensity=1,r.reflectionsIntensity=1,r.specularImageSize=0,r.specularMipCount=0,r.priority=0,r.isBuilt=!1,r.name=t,r.type=ee.skybox,r.visible=!1,r.owner=i;var a=n.irradianceCoeffs;if(r.renderable=n.renderable,r.intensity=n.intensity,r.reflectionsIntensity=n.reflectionsIntensity,a){r.irradianceCoeffs=[];for(var s=0;s<a.length;s+=3)r.irradianceCoeffs.push([a[s],a[s+1],a[s+2]])}else r.irradianceCoeffs=[];return r.diffuseImage=n.diffuseImage,r.specularImage=n.specularImage,r.specularImageSize=n.specularImageSize,r.specularMipCount=n.specularMipCount,r.priority=(null==i||null==(o=i.item)?void 0:o.renderOrder)||0,r}z(t,e);var n=t.prototype;return n.setup=function(e){this.brdfLUT=e},n.build=function(e){if(!this.isBuilt){this.isBuilt=!0,this.skyboxMaterial=new en,this.skyboxMaterial.create(this),this.skyboxMaterial.build();var t=e.getSceneCache();this.skyboxMesh=t.getFilterMesh("SkyboxFilterPlane",this.skyboxMaterial),this.skyboxMesh.priority=this.priority,this.skyboxMaterial.updateUniforms(this.skyboxMesh.material)}},n.render=function(e,t){if(this.updateMaterial(e),this.visible&&this.renderable&&void 0!==this.skyboxMesh){var n=this.skyboxMesh;t.drawGeometry(n.geometry,he.IDENTITY,n.material)}},n.dispose=function(){var t;e.prototype.dispose.call(this),this.owner=void 0,this.diffuseImage=void 0,this.specularImage=void 0,this.brdfLUT=void 0,this.skyboxMesh=void 0,null==(t=this.skyboxMaterial)||t.dispose(),this.skyboxMaterial=void 0},n.updateMaterial=function(e){if(this.build(e),this.visible&&this.renderable&&void 0!==this.skyboxMesh&&void 0!==this.skyboxMaterial){var t=e.sceneStates,n=t.camera,i=t.viewMatrix,r=n.getNewProjectionMatrix(n.fov).multiply(i).invert(),o=this.skyboxMesh.material;this.skyboxMaterial.updateUniforms(o),o.setMatrix("_InvViewProjectionMatrix",r)}},be(t,[{key:"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)))}},{key:"currentIntensity",get:function(){return this.visible?this.intensity:0}},{key:"currentReflectionsIntensity",get:function(){return this.visible?this.reflectionsIntensity:0}},{key:"hasDiffuseImage",get:function(){return void 0!==this.diffuseImage}},{key:"hasIrradianceCoeffs",get:function(){return void 0!==this.irradianceCoeffs}}]),t}(Ne),en=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).intensity=1,t.reflectionsIntensity=1,t.specularMipCount=0,t}z(t,e);var n=t.prototype;return n.create=function(e){this.type=ee.material,this.materialType=ie.skyboxFilter,this.ZTest=!1,this.name=e.name,this.intensity=e.intensity,this.reflectionsIntensity=e.reflectionsIntensity,this.brdfLUT=e.brdfLUT,this.irradianceCoeffs=e.irradianceCoeffs,this.diffuseImage=e.diffuseImage,this.specularImage=e.specularImage,this.specularMipCount=e.specularMipCount},n.dispose=function(){e.prototype.dispose.call(this),this.brdfLUT=void 0,this.irradianceCoeffs=void 0,this.diffuseImage=void 0,this.specularImage=void 0},n.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.updateUniforms=function(e){if(void 0===this.brdfLUT)throw new Error("Setup brdfLUT for skybox at first.");if(e.setVector2("_IblIntensity",new se(2,2)),e.setTexture("_brdfLUT",this.brdfLUT),void 0!==this.diffuseImage)e.setTexture("_DiffuseEnvSampler",this.diffuseImage);else{var t=this.irradianceCoeffs;if(void 0===t||9!=t.length)throw new Error("Invalid skybox irradiance coeffs "+t+".");["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(n,i){e.setVector3("_shCoefficients."+n,le.fromArray(t[i]))}))}e.setInt("_MipCount",this.specularMipCount-1),e.setTexture("_SpecularEnvSampler",this.specularImage)},n.setMaterialStates=function(e){e.depthTest=!0,e.depthMask=!1,this.setFaceSideStates(e)},t}(qt);!function(e){e[e.NFT=0]="NFT",e[e.FARM=1]="FARM"}(Qt||(Qt={}));var tn=function(){function e(){}return e.prototype.checkCubeMapImage=function(e){return V((function(){var t,n,i,r;return W(this,(function(o){switch(o.label){case 0:n=[],i=0,o.label=1;case 1:return i<e.length?[4,M(e[i])]:[3,4];case 2:if(r=o.sent(),i>0)if(i%6==0){if(2*r.width!==t.width||2*r.height!==t.height)throw new Error("Invalid cube map list1: index "+i+", image0 "+t+", image1 "+r+".")}else if(r.width!==t.width||r.height!==t.height)throw new Error("Invalid cube map list2: index "+i+", image0 "+t+", image1 "+r+".");i%6==0&&n.push([]),n[n.length-1].push(r),t=r,o.label=3;case 3:return i++,[3,1];case 4:return[2]}}))}))()},e.getBrdfLutTextureOptions=function(){return V((function(){var e;return W(this,(function(t){switch(t.label){case 0:return"https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png",[4,M("https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png")];case 1:return e=t.sent(),[2,{name:"brdfLut",wrapS:a.CLAMP_TO_EDGE,wrapT:a.CLAMP_TO_EDGE,magFilter:a.LINEAR,minFilter:a.LINEAR,anisotropic:1,sourceType:p.image,image:e,generateMipmap:!1,flipY:!1,premultiplyAlpha:!1}]}}))}))()},e.createBrdfLutTexture=function(e){var t=this;return V((function(){var n;return W(this,(function(i){switch(i.label){case 0:return[4,t.getBrdfLutTextureOptions()];case 1:return n=i.sent(),[2,v.create(e,n)]}}))}))()},e.createSkyboxOptions=function(e,t){var n=this;return V((function(){var i,r,o,a,s,l,c,u;return W(this,(function(h){switch(h.label){case 0:return[4,n.createSpecularCubeMap(e,t)];case 1:return i=h.sent(),[4,n.createDiffuseCubeMap(e,t)];case 2:return r=h.sent(),o=t.renderable,a=t.intensity,s=t.reflectionsIntensity,l=t.irradianceCoeffs,c=t.specularImageSize,u=t.specularMipCount,[2,{renderable:o,intensity:a,reflectionsIntensity:s,irradianceCoeffs:l,diffuseImage:r,specularImage:i,specularImageSize:c,specularMipCount:u}]}}))}))()},e.createSkyboxComponentData=function(t){var i,r,o,a=e.getSpecularCubeMapData(t),s=e.getDiffuseCubeMapData(t),l=t.renderable,c=t.intensity,u=t.reflectionsIntensity,h=t.irradianceCoeffs,f=t.specularImageSize,d=t.specularMipCount,m=[],g=[];s&&((o=m).push.apply(o,[].concat(s.images)),g.push(s.textureOptions),r={id:s.textureOptions.id});(i=m).push.apply(i,[].concat(a.images)),g.push(a.textureOptions);var p={id:a.textureOptions.id};return{imageList:m,textureOptionsList:g,component:{id:I(),dataType:n.DataType.SkyboxComponent,item:{id:I()},renderable:l,intensity:c,reflectionsIntensity:u,irradianceCoeffs:h,diffuseImage:r,specularImage:p,specularImageSize:f,specularMipCount:d}}},e.createSpecularCubeMap=function(e,t){return V((function(){return W(this,(function(n){return"url"===t.type?[2,Et.createTextureCubeMipmapFromURL(e,t.specularImage)]:[2,Et.createTextureCubeMipmapFromBuffer(e,t.specularImage,t.specularImageSize)]}))}))()},e.getSpecularCubeMapData=function(e){var t=[],i=[];e.specularImage.forEach((function(e){var n=[];e.forEach((function(e){var i=I();t.push({id:i,url:e}),n.push({id:i})})),i.push(n)}));var r=Ce({id:I(),dataType:n.DataType.Texture,sourceType:p.mipmaps,target:a.TEXTURE_CUBE_MAP,mipmaps:i},Et.cubemapMipTexConfig);return{images:t,textureOptions:r}},e.createDiffuseCubeMap=function(e,t){return V((function(){return W(this,(function(n){return void 0===t.diffuseImage?[2,null]:"url"===t.type?[2,Et.createTextureCubeFromURL(e,t.diffuseImage)]:[2,Et.createTextureCubeFromBuffer(e,t.diffuseImage)]}))}))()},e.getDiffuseCubeMapData=function(e){if(void 0!==e.diffuseImage){var t=[],i=[];e.diffuseImage.forEach((function(e){var n=I();t.push({id:n,url:e}),i.push({id:n})}));var r=Ce({id:I(),dataType:n.DataType.Texture,sourceType:p.mipmaps,target:a.TEXTURE_CUBE_MAP,mipmaps:[i]},Et.cubemapTexConfig);return{images:t,textureOptions:r}}},e.getSkyboxParams=function(e){void 0===e&&(e=0);var t=this.getSpecularImageList(e);return{type:"url",renderable:!0,intensity:1.8,reflectionsIntensity:1.8,irradianceCoeffs:this.getIrradianceCoeffs(e),diffuseImage:this.getDiffuseImageList(e,t),specularImage:t,specularImageSize:Math.pow(2,t.length-1),specularMipCount:t.length}},e.getIrradianceCoeffs=function(e){var t=[];switch(e){case 0:return;case 1:t=[.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:t=[.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]}return t},e.getDiffuseImageList=function(e,t){if(0==e)return t[t.length-1]},e.getSpecularImageList=function(e){var t,n,i=[];1===e?(t=i).push.apply(t,[].concat(this.getSpecularImageListAntFarm())):(n=i).push.apply(n,[].concat(this.getSpecularImageListNFT()));var r=[];return i.forEach((function(e,t){t%6==0&&r.push([]),r[r.length-1].push(e)})),r},e.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"]},e.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"]},e}(),nn=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}var t=e.prototype;return t.setup=function(t){if(this.loadSkybox=t,void 0===this.brdfLutTexture||this.brdfLutTexture.isDestroyed){if(void 0===e.brdfLutTexOptions)throw new Error("Please load brdfLutTexOptions at first.");var n="brdfLutTexture";this.brdfLutTexture=v.create(this.engine,e.brdfLutTexOptions),this.deleteTexture(n),this.setTexture(n,this.brdfLutTexture)}},t.getTexture=function(e){return this.textureCache.get(e)},t.setTexture=function(e,t){this.textureCache.set(e,t)},t.getOrCreateTexture=function(e,t){var n=this.textureCache.get(e);if(void 0!==n)return n;var i=v.create(this.engine,t);return this.textureCache.set(e,i),i},t.deleteTexture=function(e){var t=this.textureCache.get(e);return void 0!==t&&t.dispose(),this.textureCache.delete(e)},t.getOrCreateGeometry=function(e,t,n){var i=this.geometryCache.get(e);if(void 0!==i)return i;var r=Ot.createGeometry(this.engine,t,n);return this.geometryCache.set(e,r),r},t.getFilterMesh=function(e,t){var n=this.meshCache.get(e);if(void 0!==n)return n;var i=Rt.createFilterMesh(this.engine,e,t);return this.meshCache.set(e,i),i},t.getShadowBasePass=function(e,t,n,i){return this.getRenderPass(e,t,n,i)},t.getShadowFilterPass=function(e,t,n,i){return this.getRenderPass(e,t,n,i)},t.getRenderPass=function(e,t,n,i){var r=this.renderPassCache.get(e);if(void 0!==r)return r.setMeshes([]),n.forEach((function(e){r.addMesh(e)})),r;var o=this.engine.renderer,a=Et.createRenderPass(o,e,t,n,i);return this.renderPassCache.set(e,a),a},t.dispose=function(){this.engine=null,this.brdfLutTexture=void 0,this.meshCache.forEach((function(e){Et.deleteMesh(e)})),this.meshCache.clear(),this.textureCache.forEach((function(e){Et.deleteTexture(e)})),this.textureCache.clear(),this.geometryCache.forEach((function(e){Et.deleteGeometry(e)})),this.geometryCache.clear(),this.renderPassCache.forEach((function(e){Et.deleteRenderPass(e)})),this.renderPassCache.clear()},t.getRenderPasses=function(){var e=[];return this.renderPassCache.forEach((function(t){e.push(t)})),e},t.getBrdfLutTexture=function(){return this.brdfLutTexture},t.getSkyboxOptions=function(){return e.skyboxOptions},e.loadStaticResources=function(){var e=this;return V((function(){return W(this,(function(t){switch(t.label){case 0:return void 0!==e.brdfLutTexOptions?[2]:[4,tn.getBrdfLutTextureOptions()];case 1:return e.brdfLutTexOptions=t.sent(),[2]}}))}))()},e.genSkyboxOptions=function(t,n){return V((function(){var i;return W(this,(function(r){switch(r.label){case 0:return void 0===(i=n)&&(i=tn.getSkyboxParams()),[4,tn.createSkyboxOptions(t,i)];case 1:return e.skyboxOptions=r.sent(),[2,e.skyboxOptions]}}))}))()},e}(),rn=Math.PI/180,on=function(e){function t(t,i,r,o,a){var s,l,c,u,h,f;return(s=e.call(this)||this).width=512,s.height=512,s.nearPlane=.001,s.farPlane=1e3,s.fov=45,s.viewportMatrix=he.fromIdentity(),s.aspect=1,s.clipMode=n.CameraClipMode.landscape,s.projectionMatrix=new he,s.viewMatrix=new he,s.type=ee.camera,s.visible=!1,s.owner=a,s.name=t,s.width=i,s.height=r,s.nearPlane=null!=(l=o.near)?l:.001,s.farPlane=null!=(c=o.far)?c:1e3,s.fov=null!=(u=o.fov)?u:45,s.aspect=null!=(h=o.aspect)?h:s.width/s.height,s.clipMode=null!=(f=o.clipMode)?f:n.CameraClipMode.landscape,s.update(),s}z(t,e);var i=t.prototype;return i.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform);var e=this.clipMode===n.CameraClipMode.portrait;this.projectionMatrix.perspective(this.fov*rn,this.aspect,this.nearPlane,this.farPlane,e),this.projectionMatrix.premultiply(this.viewportMatrix),this.viewMatrix=this.matrix.invert()},i.getNewProjectionMatrix=function(e){var t=this.clipMode===n.CameraClipMode.portrait;return(new he).perspective(Math.min(1.25*e,140)*rn,this.aspect,this.nearPlane,this.farPlane,t).premultiply(this.viewportMatrix)},i.computeViewAABB=function(e){var t=Math.tan(this.fov*rn*.5),n=this.aspect,i=0,r=0,o=0,a=0;this.isReversed()?(i=(o=this.farPlane*t)/n,r=(a=this.nearPlane*t)/n):(o=n*(i=this.farPlane*t),a=n*(r=this.nearPlane*t)),e.makeEmpty();var s=this.matrix;return e.expandByPoint(s.transformPoint(new le(o,i,-this.farPlane))),e.expandByPoint(s.transformPoint(new le(o,-i,-this.farPlane))),e.expandByPoint(s.transformPoint(new le(-o,i,-this.farPlane))),e.expandByPoint(s.transformPoint(new le(-o,-i,-this.farPlane))),e.expandByPoint(s.transformPoint(new le(a,r,-this.nearPlane))),e.expandByPoint(s.transformPoint(new le(a,-r,-this.nearPlane))),e.expandByPoint(s.transformPoint(new le(-a,r,-this.nearPlane))),e.expandByPoint(s.transformPoint(new le(-a,-r,-this.nearPlane))),e},i.getSize=function(){return new se(this.width,this.height)},i.isReversed=function(){return this.clipMode===n.CameraClipMode.portrait},i.getEye=function(){return this.translation},i.setEye=function(e){this.translation=e},t}(Ne),an=function(){function e(){this.winWidth=512,this.winHeight=512,this.cameraList=[],this.defaultCamera=new on("camera",512,512,{id:"0",dataType:"camera",fov:60,far:1e3,near:.001,clipMode:n.CameraClipMode.portrait,item:{id:"0"}})}var t=e.prototype;return t.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()},t.insert=function(e,t,n){var i=new on(e,this.winWidth,this.winHeight,t,n);return this.cameraList.push(i),i},t.insertCamera=function(e){this.cameraList.push(e)},t.remove=function(e){if(H(e,on)){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)},t.dispose=function(){this.cameraList=[]},t.updateDefaultCamera=function(e,t,n,i,r,o,a,s){this.defaultCamera.fov=e,this.defaultCamera.viewportMatrix=t.clone(),this.defaultCamera.aspect=n,this.defaultCamera.nearPlane=i,this.defaultCamera.farPlane=r,this.defaultCamera.position=o,this.defaultCamera.rotation=a,this.defaultCamera.aspect=n,this.defaultCamera.clipMode=s,this.defaultCamera.update()},t.getCameraList=function(){return this.cameraList},t.getDefaultCamera=function(){return this.defaultCamera},t.getCameraCount=function(){return this.cameraList.length},t.getActiveCamera=function(){return this.defaultCamera},t.getAspect=function(){return this.winWidth/this.winHeight},e}(),sn=function(e){function t(t,i,r){var o;(o=e.call(this)||this).direction=new le(0,0,1),o.range=0,o.color=new le(1,1,1),o.intensity=0,o.outerConeAngle=0,o.innerConeAngle=0,o.lightType=te.ambient,o.padding=new se(0,0),o.followCamera=!1,o.name=t,o.type=ee.light,o.visible=!1,o.owner=r,o.direction=new le(0,0,-1),o.range=0,o.outerConeAngle=0,o.innerConeAngle=0;var a,s,l=i.color;if(o.color=new le(l.r,l.g,l.b),o.intensity=i.intensity,o.followCamera=null!=(a=i.followCamera)&&a,i.lightType===n.LightType.point)o.lightType=te.point,o.range=null!=(s=i.range)?s:-1;else if(i.lightType===n.LightType.spot){var c,u,h;o.lightType=te.spot,o.range=null!=(c=i.range)?c:-1,o.outerConeAngle=null!=(u=i.outerConeAngle)?u:Math.PI,o.innerConeAngle=null!=(h=i.innerConeAngle)?h:0}else i.lightType===n.LightType.directional?o.lightType=te.directional:o.lightType=te.ambient;return o.update(),o}z(t,e);var i=t.prototype;return i.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform)},i.isDirectional=function(){return this.lightType===te.directional},i.isPoint=function(){return this.lightType===te.point},i.isSpot=function(){return this.lightType===te.spot},i.isAmbient=function(){return this.lightType===te.ambient},i.getWorldPosition=function(){return this.translation},i.getWorldDirection=function(){return this.matrix.transformNormal(this.direction,new le)},be(t,[{key:"position",get:function(){return this.translation}}]),t}(Ne),ln=function(){function e(){this.lightList=[]}var t=e.prototype;return t.insertItem=function(e,t,n){var i=new sn(e,t,n);return this.lightList.push(i),i},t.insertLight=function(e){return this.lightList.push(e),e},t.remove=function(e){var t=this.lightList.findIndex((function(t){return t===e}));-1!==t&&this.lightList.splice(t,1)},t.dispose=function(){this.lightList=[]},be(e,[{key:"lightCount",get:function(){return this.lightList.length}}]),e}();var cn=function(e){function t(t,n,i,r,o,a){var s,l;(s=e.call(this)||this).engine=t,s.parentIndex=-1,s.subMeshes=[],s.hide=!0,s.priority=0,s.boundingBox=new pe,s.visBoundingBox=!1,s.isBuilt=!1,s.isDisposed=!1;var c=new fn(i,r,a);s.name=n,s.type=ee.mesh,s.visible=!1,s.owner=r,s.parentIndex=c.getParentIndex(),s.parentItem=c.parentItem,s.parentItemId=o,s.rootBoneItem=i.rootBone,s.skin=c.getSkinObj(t),s.morph=c.getMorphObj(),s.hide=c.isHide(),s.priority=(null==r||null==(l=r.item)?void 0:l.renderOrder)||0,s.subMeshes=[];var u,h=c.getGeometry();return(null!=(u=null==r?void 0:r.materials)?u:[]).forEach((function(e){var t=new un(s.engine);t.create(h,e,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(s)),s.subMeshes.push(t)})),s.subMeshes.length<=0&&console.warn("No primitive inside mesh item "+n+"."),s.boundingBox=s.getItemBoundingBox(i.interaction),s}z(t,e);var i=t.prototype;return i.build=function(e){this.isBuilt||(this.isBuilt=!0,this.subMeshes.forEach((function(t){t.build(e.maxLightCount,e.skybox)})),Ie.getInstance().visBoundingBox&&(this.boundingBoxMesh=new He(this.engine,this.priority)))},i.update=function(){void 0!==this.owner&&(this.transform.fromEffectsTransform(this.owner.transform),this.morph&&this.morph.hasMorph()&&this.owner.morphWeights.length>0&&this.morph.updateWeights(this.owner.morphWeights))},i.lateUpdate=function(){var e;null==(e=this.skin)||e.updateSkinMatrices()},i.render=function(e,t){var n=this;if(this.updateMaterial(e),this.subMeshes.forEach((function(e,i){t.drawGeometry(e.getEffectsGeometry(),n.matrix,e.getEffectsMaterial(),i)})),this.visBoundingBox&&void 0!==this.boundingBoxMesh){var i=this.boundingBoxMesh.mesh;t.drawGeometry(i.geometry,he.IDENTITY,i.material)}},i.dispose=function(){var t,n,i;this.isDisposed||(e.prototype.dispose.call(this),this.owner=void 0,this.isDisposed=!0,this.engine=null,this.parentItem=void 0,null==(t=this.skin)||t.dispose(),this.skin=void 0,null==(n=this.morph)||n.dispose(),this.morph=void 0,this.subMeshes.forEach((function(e){e.dispose()})),this.subMeshes=[],null==(i=this.boundingBoxMesh)||i.dispose(),this.boundingBoxMesh=void 0)},i.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]}}},i.updateParentInfo=function(e,t){this.parentItemId=e,this.parentItem=t,void 0!==this.skin&&this.skin.updateParentItem(t)},i.updateMaterial=function(e){var t=this.matrix,n=t.clone().invert().transpose(),i=e.sceneStates;if(this.subMeshes.forEach((function(e){e.updateMaterial(t,n,i)})),void 0!==this.boundingBoxMesh){this.computeBoundingBox(t);var r=new le(1,1,1),o=this.boundingBox.min,a=this.boundingBox.max,s=new Float32Array([o.x,o.y,o.z,a.x,o.y,o.z,a.x,a.y,o.z,o.x,a.y,o.z,o.x,o.y,a.z,a.x,o.y,a.z,a.x,a.y,a.z,o.x,a.y,a.z]);this.boundingBoxMesh.update(t,i.viewProjectionMatrix,s,r)}},i.hitTesting=function(e,t){var n,i=this.matrix,r=i.clone().invert(),o=r.transformPoint(e,new le),a=r.transformNormal(t,new le),s=this.boundingBox,l=_t(o,a,s.min,s.max);return void 0===l?[]:(Ie.getInstance().isEditorEnv?this.subMeshes.forEach((function(e){var t=e.hitTesting(o,a,i,r);void 0!==t&&(void 0===n||n>t)&&(n=t)})):n=l,void 0===n?[]:(a.multiply(n),o.add(a),i.transformPoint(o),[o]))},i.computeBoundingBox=function(e){var t=this.boundingBox.makeEmpty(),n=e.clone().invert();return this.subMeshes.forEach((function(e){var i=e.computeBoundingBox(n);t.union(i)})),t},i.getItemBoundingBox=function(e){if(void 0===e)return new pe;if(e.type===n.ModelBoundingType.box){var t,i,r=null!=(t=e.center)?t:[0,0,0],o=null!=(i=e.size)?i:[0,0,0],a=le.fromArray(r),s=le.fromArray(o).multiply(.5),l=a.clone().subtract(s),c=a.clone().add(s);return new pe(l,c)}var u,h,f=null!=(u=e.center)?u:[0,0,0],d=.5*(null!=(h=e.radius)?h:0),m=le.fromArray(f),g=m.clone().subtract(d),p=m.clone().add(d);return new pe(g,p)},i.getParentId=function(){return this.parentItemId},be(t,[{key:"hasSkin",get:function(){return void 0!==this.skin}}]),t}(Ne),un=function(){function e(e){this.engine=e,this.name="",this.effectsPriority=0,this.boundingBox=new pe,this.isCompressed=!1}var t=e.prototype;return t.create=function(e,t,n){if(this.parent=n,this.skin=n.skin,this.morph=n.morph,this.setGeometry(e),this.setMaterial(t),this.name=n.name,this.effectsPriority=n.priority,this.geometry.setHide(n.hide),void 0!==this.skin){var i=this.skin.maxJointCount;if(this.jointMatrixList=new Float32Array(16*i),this.jointNormalMatList=new Float32Array(16*i),this.skin.isTextureDataMode()){var r=this.skin.textureDataMode===Lt.half_float;this.jointMatrixTexture=new Jt(this.engine),this.jointNormalMatTexture=new Jt(this.engine),this.jointMatrixTexture.create(i,r,"jointMatrixTexture"),this.jointNormalMatTexture.create(i,r,"jointNormalMatTexture")}}else(this.geometry.hasWeights()||this.geometry.hasJoints())&&console.warn("Geometry has weight and/or joint array, but the skin is missing.");this.isCompressed=this.geometry.isCompressed()},t.build=function(e,t){var n,i=Ie.getInstance(),r=this.getMacroList(e,!0,t),o=this.material.getMacroList(r),a=Ie.getInstance().isWebGL2;this.material.effectMaterial?(n=this.material.effectMaterial,o.forEach((function(e){var t=e.name,i=e.value;n.enableMacro(t,i)})),this.material.setMaterialStates(n)):(n=s.create(this.engine,{shader:{vertex:this.material.vertexShaderCode,fragment:this.material.fragmentShaderCode,shared:i.shaderShared,glslVersion:a?C.GLSL3:C.GLSL1}}),this.material.setMaterialStates(n))},t.getFeatureList=function(e,t,n){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 "+this.morph.morphWeightsLength);for(var r=0;r<this.morph.morphWeightsLength;r++)this.morph.hasPositionMorph&&i.push("HAS_TARGET_POSITION"+r),this.morph.hasNormalMorph&&i.push("HAS_TARGET_NORMAL"+r),this.morph.hasTangentMorph&&i.push("HAS_TARGET_TANGENT"+r)}void 0!==this.skin&&(i.push("USE_SKINNING 1"),i.push("JOINT_COUNT "+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.material.materialType!==ie.unlit&&(e>0&&this.geometry.hasNormals()&&(i.push("USE_PUNCTUAL 1"),i.push("LIGHT_COUNT "+e)),void 0!==n&&n.available&&(i.push("USE_IBL 1"),i.push("USE_TEX_LOD 1"),n.hasDiffuseImage||i.push("IRRADIANCE_COEFFICIENTS 1")));var o=Ie.getInstance().renderMode3D,a=this.getRenderMode3DDefine(o);return void 0!==a&&(i.push("DEBUG_OUTPUT 1"),i.push(a+" 1")),i},t.getMacroList=function(e,t,n){var i=[];if(this.geometry.hasNormals()&&i.push({name:"HAS_NORMALS"}),this.geometry.hasTangents()&&i.push({name:"HAS_TANGENTS"}),this.geometry.hasUVCoords(1)&&i.push({name:"HAS_UV_SET1"}),this.geometry.hasUVCoords(2)&&i.push({name:"HAS_UV_SET2"}),void 0!==this.morph&&this.morph.hasMorph()){i.push({name:"USE_MORPHING"}),i.push({name:"WEIGHT_COUNT",value:this.morph.morphWeightsLength});for(var r=0;r<this.morph.morphWeightsLength;r++)this.morph.hasPositionMorph&&i.push({name:"HAS_TARGET_POSITION"+r}),this.morph.hasNormalMorph&&i.push({name:"HAS_TARGET_NORMAL"+r}),this.morph.hasTangentMorph&&i.push({name:"HAS_TARGET_TANGENT"+r})}void 0!==this.skin&&(i.push({name:"USE_SKINNING"}),i.push({name:"JOINT_COUNT",value:this.skin.maxJointCount}),i.push({name:"HAS_JOINT_SET1"}),i.push({name:"HAS_WEIGHT_SET1"}),this.skin.textureDataMode&&i.push({name:"USE_SKINNING_TEXTURE"})),this.material.materialType!==ie.unlit&&(e>0&&this.geometry.hasNormals()&&(i.push({name:"USE_PUNCTUAL"}),i.push({name:"LIGHT_COUNT",value:e})),void 0!==n&&n.available&&(i.push({name:"USE_IBL"}),i.push({name:"USE_TEX_LOD"}),n.hasDiffuseImage||i.push({name:"IRRADIANCE_COEFFICIENTS"})));var o=Ie.getInstance().renderMode3D,a=this.getRenderMode3DDefine(o);return void 0!==a&&(i.push({name:"DEBUG_OUTPUT"}),i.push({name:a})),i},t.dispose=function(){var e,t;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)||e.dispose(),this.jointMatrixTexture=void 0,null==(t=this.jointNormalMatTexture)||t.dispose(),this.jointNormalMatTexture=void 0},t.updateMaterial=function(e,t,n){this.updateUniformsByAnimation(e,t),this.updateUniformsByScene(n),this.material.updateUniforms(this.getEffectsMaterial())},t.hitTesting=function(e,t,n,i){var r=this.boundingBox,o=_t(e,t,r.min,r.max),a=[];if(void 0!==o){if(void 0!==this.skin)this.skin.animationMatrices.forEach((function(e){a.push((new he).multiplyMatrices(i,e))}));var s=new Bt,l=this.material.isBothSide();return s.create(this.geometry.geometry,l,a),s.getHitPoint(e,t)}},t.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 he).multiplyMatrices(e,n))}));var n=new Dt;return n.create(this.geometry.geometry,t),n.getBoundingBox(this.boundingBox)},t.getRenderMode3DDefine=function(e){switch(e){case n.RenderMode3D.uv:return"DEBUG_UV";case n.RenderMode3D.normal:return"DEBUG_NORMAL";case n.RenderMode3D.basecolor:return"DEBUG_BASECOLOR";case n.RenderMode3D.alpha:return"DEBUG_ALPHA";case n.RenderMode3D.metallic:return"DEBUG_METALLIC";case n.RenderMode3D.roughness:return"DEBUG_ROUGHNESS";case n.RenderMode3D.ao:return"DEBUG_OCCLUSION";case n.RenderMode3D.emissive:return"DEBUG_EMISSIVE";case n.RenderMode3D.diffuse:return"DEBUG_DIFFUSE"}},t.updateUniformsByAnimation=function(e,t){var n=this.getEffectsMaterial();n.setMatrix("_NormalMatrix",t);var i=this.skin;if(void 0!==i){var r=this.jointMatrixList,o=this.jointNormalMatList;if(i.computeMeshAnimMatrices(e,r,o),i.textureDataMode){var a=this.jointMatrixTexture,s=this.jointNormalMatTexture;a.update(r),s.update(o),n.setTexture("_jointMatrixSampler",a.getTexture()),n.setTexture("_jointNormalMatrixSampler",s.getTexture())}else{var l=[],c=[];r.forEach((function(e){return l.push(e)})),o.forEach((function(e){return c.push(e)})),n.setMatrixNumberArray("_jointMatrix",l),n.setMatrixNumberArray("_jointNormalMatrix",c)}}var u=this.morph;if(void 0!==u&&u.hasMorph()){var h=u.morphWeightsArray.slice();n.setFloats("_morphWeights",h)}},t.updateUniformsByScene=function(e){var t=this.getEffectsMaterial();if(t.setVector3("_Camera",e.cameraPosition),!this.isUnlitMaterial()){for(var n=e.maxLightCount,i=e.lightList,r=e.inverseViewMatrix,o=0;o<n;o++)if(o<i.length){var a=i[o],s=a.visible?a.intensity:0;if(a.followCamera){var l=r.transformNormal(a.getWorldDirection(),new le),c=r.transformPoint(a.getWorldPosition(),new le);t.setVector3("_Lights["+o+"].direction",l),t.setVector3("_Lights["+o+"].position",c)}else t.setVector3("_Lights["+o+"].direction",a.getWorldDirection()),t.setVector3("_Lights["+o+"].position",a.getWorldPosition());t.setFloat("_Lights["+o+"].range",a.range),t.setVector3("_Lights["+o+"].color",a.color),t.setFloat("_Lights["+o+"].intensity",s),t.setFloat("_Lights["+o+"].innerConeCos",Math.cos(a.innerConeAngle)),t.setFloat("_Lights["+o+"].outerConeCos",Math.cos(a.outerConeAngle)),t.setInt("_Lights["+o+"].type",a.lightType),t.setVector2("_Lights["+o+"].padding",a.padding)}else t.setVector3("_Lights["+o+"].direction",le.ZERO),t.setFloat("_Lights["+o+"].range",0),t.setVector3("_Lights["+o+"].color",le.ZERO),t.setFloat("_Lights["+o+"].intensity",0),t.setVector3("_Lights["+o+"].position",le.ZERO),t.setFloat("_Lights["+o+"].innerConeCos",0),t.setFloat("_Lights["+o+"].outerConeCos",0),t.setInt("_Lights["+o+"].type",99999),t.setVector2("_Lights["+o+"].padding",se.ZERO);var u=e.skybox;if(void 0!==u&&u.available){if(t.setVector2("_IblIntensity",new se(u.currentIntensity,u.currentReflectionsIntensity)),t.setTexture("_brdfLUT",u.brdfLUT),void 0!==u.diffuseImage)t.setTexture("_DiffuseEnvSampler",u.diffuseImage);else{var h=u.irradianceCoeffs;["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(e,n){t.setVector3("_shCoefficients."+e,le.fromArray(h[n]))}))}t.setInt("_MipCount",u.specularMipCount-1),t.setTexture("_SpecularEnvSampler",u.specularImage)}}},t.hasSkin=function(){return void 0!==this.skin},t.getEffectsGeometry=function(){return this.geometry.geometry},t.setGeometry=function(e){H(e,hn)?this.geometry=e:this.geometry=new hn(e)},t.setMaterial=function(e){H(e,Zt)||H(e,Yt)?this.material=e:this.material=Kt(e)},t.getEffectsMaterial=function(){return this.material.effectMaterial},t.isUnlitMaterial=function(){return this.material.materialType===ie.unlit},t.hasMorph=function(){return void 0!==this.morph&&this.morph.hasMorph()},t.getWorldBoundingBox=function(){if(void 0===this.parent)return this.boundingBox.isEmpty()&&this.computeBoundingBox(he.fromIdentity()),this.boundingBox;var e=this.parent.matrix;return this.boundingBox.isEmpty()&&this.computeBoundingBox(e.clone().invert()),this.boundingBox.clone().applyMatrix4(e)},e}(),hn=function(){function e(e){this.geometry=e,this.attributeNames=e.getAttributeNames()}var t=e.prototype;return t.dispose=function(){this.geometry=void 0,this.attributeNames=[]},t.hasAttribute=function(e){return-1!==this.attributeNames.findIndex((function(t){return t===e}))},t.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())},t.isCompressed=function(){this.geometry.getAttributeData("aPos");return!1},t.hasPositions=function(){return this.hasAttribute("aPos")},t.hasNormals=function(){return this.hasAttribute("aNormal")},t.hasTangents=function(){return this.hasAttribute("aTangent")},t.hasUVCoords=function(e){return 1===e?this.hasAttribute("aUV"):this.hasAttribute("aUV"+e)},t.hasColors=function(){return this.hasAttribute("aColor")},t.hasJoints=function(){return this.hasAttribute("aJoints")},t.hasWeights=function(){return this.hasAttribute("aWeights")},e}(),fn=function(){function e(e,t,n){this.itemData=e,this.parentComponent=t,this.parentItem=n,this.data=e,this.geometry=e.geometry,this.rootBoneItem=e.rootBone;var i=new Wt;if(i.create(this.geometry)){var r,o;if(null==(r=e.morph)?void 0:r.weights)i.initWeights(null==(o=e.morph)?void 0:o.weights);this.morphObj=i}}var t=e.prototype;return t.hasMorphTarget=function(){return this.morphObj.hasMorph()},t.getMorphObj=function(){if(this.hasMorphTarget())return this.morphObj},t.isHide=function(){return!0===this.data.hide},t.getParentIndex=function(){return-1},t.getGeometry=function(){return this.data.geometry},t.getMaterials=function(){return this.data.materials},t.getMaterialCount=function(){return this.data.materials.length},t.hasSkin=function(){var e=this.geometry.getSkinProps();return!!(e.rootBoneName&&e.boneNames&&e.inverseBindMatrices&&this.rootBoneItem)},t.getSkinOpts=function(){return this.geometry.getSkinProps()},t.getSkinObj=function(e){var t=this.getSkinOpts();if(t.rootBoneName&&t.boneNames&&t.inverseBindMatrices&&this.rootBoneItem){var n,i,r=new jt,o=null!=(i=null==(n=this.parentComponent.sceneManager)?void 0:n.maxJointCount)?i:0;return r.create(t,e,this.rootBoneItem,o),r}},e}(),dn=function(){function e(e){this.maxLightCount=16,this.maxJointCount=0,this.renderSkybox=!1,this.compName="SceneManger",this.itemList=[],this.meshList=[],this.engine=e,this.lightManager=new ln,this.cameraManager=new an,this.parentId2Mesh=new Map,this.enableDynamicSort=!1,this.tickCount=0,this.lastTickSecond=-1,this.sceneAABBCache=new pe,this.renderedMeshSet=new ht}var t=e.prototype;return t.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.maxJointCount=e.maxJointCount,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: "+this.maxLightCount+" light(s).")},t.initGlobalState=function(e){var t,i,o,a,s,l=this.engine.gpuCapability,c=Ie.getInstance();c.reset(),c.isWebGL2=2===l.level,c.runtimeEnv=null!=(t=e.runtimeEnv)?t:r,c.compatibleMode=null!=(i=e.compatibleMode)?i:"gltf",c.visBoundingBox=null!=(o=e.visBoundingBox)&&o,c.renderMode3D=null!=(a=e.renderMode3D)?a:n.RenderMode3D.none,c.renderMode3DUVGridSize=null!=(s=e.renderMode3DUVGridSize)?s:1/16},t.clean=function(){this.dispose(),this.compName="",this.renderer=void 0,this.sceneCache=void 0,this.itemList=[],this.meshList=[],this.lightManager=new ln,this.cameraManager=new an,this.parentId2Mesh=new Map,this.brdfLUT=void 0,this.skybox=void 0,this.lastTickSecond=-1,this.tickCount=0,this.renderedMeshSet=new ht},t.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)||e.dispose(),this.skybox=void 0,this.renderedMeshSet.clear(),this.renderer=void 0,this.sceneCache=void 0,this.engine=void 0,this.parentId2Mesh.clear()},t.addItem=function(e){if(H(e,cn)){var t=e;void 0!==t.parentItemId&&this.parentId2Mesh.set(t.parentItemId,t),E(this.meshList,t)}else if(H(e,$t)){var n=e;n.setup(this.brdfLUT),this.renderSkybox||(n.renderable=!1),this.skybox=n}else H(e,sn)?this.lightManager.insertLight(e):this.cameraManager.insertCamera(e);E(this.itemList,e)},t.removeItem=function(e){if(H(e,cn)){var t=e;void 0!==t.parentItemId&&this.parentId2Mesh.delete(t.parentItemId),w(this.meshList,t)}else H(e,$t)?this.skybox=void 0:H(e,sn)?this.lightManager.remove(e):this.cameraManager.remove(e);w(this.itemList,e)},t.updateDefaultCamera=function(e,t){var n=new i(Ce({},e,{valid:!0})),r=(new Ae).fromEffectsTransform(n);this.cameraManager.updateDefaultCamera(e.fov,t,e.aspect,e.near,e.far,r.getPosition(),r.getRotation(),e.clipMode)},t.tick=function(e){var t=e,n=this.activeCamera,i=n.viewMatrix,r=n.projectionMatrix,o=r.clone().multiply(i);this.sceneStates={deltaSeconds:t,camera:n,cameraPosition:n.getEye(),viewMatrix:i,inverseViewMatrix:i.clone().invert(),projectionMatrix:r,viewProjectionMatrix:o,winSize:n.getSize(),sceneRadius:1,lightList:this.lightManager.lightList,maxLightCount:this.maxLightCount,maxJointCount:this.maxJointCount,skybox:this.skybox},this.enableDynamicSort&&this.dynamicSortMeshes(this.sceneStates),this.tickCount+=1,this.lastTickSecond+=t},t.dynamicSortMeshes=function(e){var t=[],n=[];this.meshList.forEach((function(e){if(e.owner&&e.owner.enabled){var i=e.owner;t.push(i),n.push(i.priority)}})),n.sort((function(e,t){return e-t}));var i=e.viewMatrix;t.sort((function(e,t){var n=Et.isTransparentMesh(e),r=Et.isTransparentMesh(t);if(n&&r){var o=e.transform.getWorldPosition(),a=t.transform.getWorldPosition(),s=i.transformPoint(o),l=i.transformPoint(a);return s.z===l.z?e.priority-t.priority:s.z-l.z}return n?1:r?-1:e.priority-t.priority}));for(var r=-99999,o=0;o<t.length;o++){var a=t[o],s=n[o];r<s?(r=s,a.priority=s):(r+=.1,a.priority=r)}},t.queryMesh=function(e){var t=this.parentId2Mesh.get(e);if(void 0!==t&&t.visible)return t},t.getSceneAABB=function(e){var t=null!=e?e:new pe;return this.itemList.forEach((function(e){if(e.type===ee.mesh){var n=e;if(n.owner){var i=n.owner.item.getWorldTransform().getWorldMatrix(),r=n.computeBoundingBox(i);r.applyMatrix4(i),t.union(r)}else t.union(n.computeBoundingBox(he.fromIdentity()))}})),t},t.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("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")},t.getRenderer=function(){return this.renderer},t.getSceneCache=function(){return this.sceneCache},be(e,[{key:"activeCamera",get:function(){return this.cameraManager.getActiveCamera()}},{key:"lightCount",get:function(){return this.lightManager.lightCount}},{key:"shaderLightCount",get:function(){return Math.min(10,this.lightManager.lightCount)}}]),e}(),mn=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).name="model",t}z(t,e);var i=t.prototype;return i.precompile=function(e,t){var i=2===t.engine.gpuCapability.level,r=Ye(),o=Ke(),a={id:Se,name:"PBR Shader",dataType:n.DataType.Shader,fragment:r.fragmentShaderCode,vertex:r.vertexShaderCode,glslVersion:i?C.GLSL3:C.GLSL1},s={id:xe,name:"Unlit Shader",dataType:n.DataType.Shader,fragment:o.fragmentShaderCode,vertex:o.vertexShaderCode,glslVersion:i?C.GLSL3:C.GLSL1};return t.engine.addEffectsObjectData(a),t.engine.addEffectsObjectData(s),Promise.resolve()},i.onCompositionConstructed=function(e,t){this.sceneParams=t.storage;var n=e.renderer.engine;this.cache=new nn(n),this.cache.setup(!1)},i.onCompositionReset=function(e,t){var i={id:"ModelPluginItem",name:"ModelPluginItem",duration:9999999,endBehavior:n.END_BEHAVIOR_FORWARD},r=new N(e.getEngine(),i);e.addItem(r);var o=r.addComponent(gn);o.fromData({cache:this.cache}),o.initial(this.sceneParams)},i.onCompositionDestroyed=function(e){this.cache.dispose(),this.cache=null,this.sceneParams=null},t.prepareResource=function(e,t){return V((function(){var n,i,r,o,a,s,l;return W(this,(function(c){switch(c.label){case 0:return void 0!==t.pluginData&&(i=["compatibleMode","renderSkybox","visBoundingBox","autoAdjustScene","enableDynamicSort","renderMode3D","renderMode3DUVGridSize"],r=t.pluginData,i.forEach((function(t){return e.storage[t]=r[t]}))),a=null!=(o=t.env)?o:"",e.storage.runtimeEnv=a,l=null!=(s=null==(n=t.pluginData)?void 0:n.compatibleMode)?s:"gltf",Ot.preprocessScene(e,a,l),[4,nn.loadStaticResources()];case 1:return c.sent(),[2]}}))}))()},t}(L),gn=function(e){function t(t,i){var o;return(o=e.call(this,t)||this).runtimeEnv=r,o.compatibleMode="gltf",o.renderSkybox=!0,o.visBoundingBox=!1,o.autoAdjustScene=!1,o.enableDynamicSort=!1,o.renderMode3D=n.RenderMode3D.none,o.renderMode3DUVGridSize=1/16,i&&o.fromData(i),o}z(t,e);var i=t.prototype;return i.onLateUpdate=function(e){var t=this.item.composition;if(this.autoAdjustScene&&1==this.scene.tickCount){var n,i,r,o=t.camera,a=(new Ae).fromMatrix4(o.getViewMatrix()),s=(new Me).fromPTransform(a).zAxis.clone(),l=null!=(i=o.fov)?i:45,c=null!=(r=o.aspect)?r:1,u=this.scene.getSceneAABB(),h=u.clone().applyMatrix4(a.getMatrix()).getSize(new le).multiply(.5),f=h.x,d=h.y,m=d*Math.max(f/d/c,1),g=u.getCenter(new le),p=m/Math.tan(.5*l*Te),v=g.clone().add(s.clone().multiply(p+h.z));t.camera.position=v,null==(n=t.items)||n.forEach((function(e){if(e.type===B){var t=e.getComponent(gt);if(null==t?void 0:t.content){var n,i=((null==(n=e.transform.parentTransform)?void 0:n.getWorldMatrix())||he.IDENTITY.clone()).invert().transformPoint(v);t.setTransform(i),console.info("Scene AABB ["+u.min.toArray()+"], ["+u.max.toArray()+"]."),console.info("Update camera position ["+i.toArray()+"].")}}}))}this.updateSceneCamera(t),this.scene.tick(e)},i.onDestroy=function(){this.scene.dispose(),this.scene=null,this.cache=null},i.fromData=function(t){e.prototype.fromData.call(this,t);var n=t;this.cache=n.cache,this.scene=new dn(this.engine)},i.initial=function(e){var t,n,i,r,o,a,s,l,c;this.runtimeEnv=null!=(n=e.runtimeEnv)?n:this.runtimeEnv,this.compatibleMode=null!=(i=e.compatibleMode)?i:this.compatibleMode,this.renderSkybox=null!=(r=e.renderSkybox)?r:this.renderSkybox,this.visBoundingBox=null!=(o=e.visBoundingBox)?o:this.visBoundingBox,this.autoAdjustScene=null!=(a=e.autoAdjustScene)?a:this.autoAdjustScene,this.enableDynamicSort=null!=(s=e.enableDynamicSort)?s:this.enableDynamicSort,this.renderMode3D=null!=(l=e.renderMode3D)?l:this.renderMode3D,this.renderMode3DUVGridSize=null!=(c=e.renderMode3DUVGridSize)?c:this.renderMode3DUVGridSize;var u,h=this.item.composition;this.scene.initial({componentName:""+h.id,renderer:this.engine.renderer,sceneCache:this.cache,runtimeEnv:this.runtimeEnv,compatibleMode:this.compatibleMode,visBoundingBox:this.visBoundingBox,enableDynamicSort:this.enableDynamicSort,renderMode3D:this.renderMode3D,renderMode3DUVGridSize:this.renderMode3DUVGridSize,renderSkybox:this.renderSkybox,lightItemCount:this.getLightItemCount(),maxJointCount:this.getMaxJointCount(null!=(u=null==(t=this.item.composition)?void 0:t.items)?u:[])}),this.updateSceneCamera(h)},i.updateSceneCamera=function(e){this.scene.updateDefaultCamera(e.camera.getOptions(),e.camera.getViewportMatrix())},i.getLightItemCount=function(){var e,t,n=0;return(null!=(t=null==(e=this.item.composition)?void 0:e.items)?t:[]).forEach((function(e){e.getComponent(mt)&&n++})),n},i.getMaxJointCount=function(e){var t=this,n=0;return e.forEach((function(e){var i=e.getComponent(ft);if(i&&i.data){var r=i.data.geometry;if(H(r,c)){var o=r.getSkinProps();o.boneNames&&(n=Math.max(o.boneNames.length,n))}}0!==e.children.length&&(n=Math.max(t.getMaxJointCount(e.children),n))})),n},t}(d);function pn(e){var t,n=null==e||null==(t=e.item)?void 0:t.composition,i=null==n?void 0:n.getItemByName("ModelPluginItem"),r=null==i?void 0:i.getComponent(gn);return null==r?void 0:r.scene}gn=j([h(n.DataType.ModelPluginComponent)],gn);var vn,yn=function(e){function t(t,n){var i;return i=e.call(this,t)||this,n&&i.fromData(n),i}return z(t,e),t.prototype.fromData=function(t){e.prototype.fromData.call(this,t),this.options=t},t}(d);yn=j([h(n.DataType.TreeComponent)],yn),function(e){e[e.none=0]="none",e[e.translate=1]="translate",e[e.rotate_focus=2]="rotate_focus",e[e.rotate_self=3]="rotate_self",e[e.scale=4]="scale"}(vn||(vn={}));var Tn=function(){function e(e){this.composition=e,this.cameraTransform=new Ae,this.cameraCoordiante=new Me,this.startParams={type:vn.none,mouseEvent:!1,clientX:0,clientY:0,clientWidth:512,clientHeight:512,target:""}}var t=e.prototype;return t.updateComposition=function(e){this.composition=e},t.getItem=function(){var e,t=this;return null==(e=this.composition.items)?void 0:e.find((function(e){return e.name===t.getCurrentTarget()}))},t.getCurrentTarget=function(){return this.startParams.target},t.getCurrentType=function(){return this.startParams.type},t.onKeyEvent=function(e){this.startParams.target!==e.cameraID&&(this.startParams.target=e.cameraID,this.startParams.type=vn.translate);var t=this.getItem();if(void 0===t)return console.warn("[CameraGestureHandlerImp] Unable to locate camera item with ID: "+this.startParams.target+"."),this.composition.camera.getOptions();var n,r,o,a,s=this.composition.camera,l=new i(Ce({},s.getOptions(),{valid:!0})),c=(new Ae).fromEffectsTransform(l),u=(new Me).fromPTransform(c),h=null!=(n=e.xAxis)?n:0,f=null!=(r=e.yAxis)?r:0,d=null!=(o=e.zAxis)?o:0,m=u.xAxis.clone().multiply(h);if(m.add(u.yAxis.clone().multiply(f)),m.add(u.zAxis.clone().multiply(d)),m.lengthSquared()<1e-5)return s.getOptions();m.normalize();var g=null!=(a=e.speed)?a:.1,p=c.getPosition();return p.add(m.clone().multiply(g)),this.setTransform(t,p),this.startParams.type===vn.rotate_self&&(this.cameraTransform.setPosition(p),this.cameraCoordiante.origin=p),s.getOptions()},t.onXYMoveBegin=function(e,t,n,i,r){var o={type:vn.translate,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:i,target:r};return this.startGesture(o)},t.onXYMoving=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:vn.translate,mouseEvent:!0,clientX:e,clientY:t,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=n?n:.015};return this.moveGesture(r)},t.onXYMoveEnd=function(){this.endGesture()},t.onZMoveBegin=function(e,t,n,i,r){var o={type:vn.scale,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:i,target:r};return this.startGesture(o)},t.onZMoving=function(e,t,n){if(void 0===n&&(n=.015),!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:vn.scale,mouseEvent:!0,clientX:e,clientY:t,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:n};return this.moveGesture(r)},t.onZMoveEnd=function(){this.endGesture()},t.onRotateBegin=function(e,t,n,i,r){var o={type:vn.rotate_self,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:i,target:r};return this.startGesture(o)},t.onRotating=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:vn.rotate_self,mouseEvent:!0,clientX:e,clientY:t,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=n?n:1.5};return this.moveGesture(r)},t.onRotateEnd=function(){this.endGesture()},t.onRotatePointBegin=function(e,t,n,i,r,o){var a={type:vn.rotate_focus,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:i,focusPoint:r,target:o};return this.startGesture(a)},t.onRotatingPoint=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:vn.rotate_focus,mouseEvent:!0,clientX:e,clientY:t,clientWidth:i.clientWidth,clientHeight:i.clientHeight,focusPoint:i.focusPoint,target:i.target,speed:null!=n?n:8};return this.moveGesture(r)},t.onRotatePointEnd=function(){this.endGesture()},t.moveTo=function(e,t){this.startParams.target=e,this.startParams.type=vn.none;var n=this.getItem();void 0!==n?this.setPosition(n,t):console.warn("[CameraGestureHandlerImp] Can't find camera item.")},t.rotateTo=function(e,t){this.startParams.target=e,this.startParams.type=vn.none;var n=this.getItem();void 0!==n?this.setQuaternion(n,t):console.warn("[CameraGestureHandlerImp] Can't find camera item.")},t.onFocusPoint=function(e,t,n){this.startParams.target=e,this.startParams.type=vn.none;var i=this.getItem();if(void 0!==i){var r=null!=n?n:5,o=le.fromArray(t),a=(new Ae).fromEffectsTransform(i.transform),s=(new Me).fromPTransform(a),l=le.fromArray(s.zAxis.toArray()).multiply(1).clone().multiply(r),c=o.clone().add(l);this.setTransform(i,c),this.startParams.target=""}else console.warn("[CameraGestureHandlerImp] Can't find camera item.")},t.getCameraTransform=function(){var e=this.composition.camera,t=new i(e.getOptions());return t.setValid(!0),t},t.startGesture=function(e){return this.startParams=e,this.updateCameraTransform(this.composition.camera.getOptions()),this.getItem()||console.warn("[CameraGestureHandlerImp] Invalid target specified in startGesture."),this.composition.camera.getOptions()},t.moveGesture=function(e){if(this.getCurrentType()===e.type){var t,n=this.getItem();if(void 0===n)return console.warn("[CameraGestureHandlerImp] Can't find camera item."),this.composition.camera.getOptions();var i=null!=(t=e.speed)?t:1.015,r=this.cameraCoordiante.xAxis,o=this.cameraCoordiante.yAxis,a=this.cameraCoordiante.zAxis,s=e.clientX-this.startParams.clientX,l=e.clientY-this.startParams.clientY;if(e.type===vn.translate){var c=this.cameraTransform.getPosition().clone();c.add(r.clone().multiply(-s*i)),c.add(o.clone().multiply(l*i)),n.transform.setPosition(c.x,c.y,c.z),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===vn.scale){var u=this.cameraTransform.getPosition().clone();u.add(a.clone().multiply(l*i)),n.transform.setPosition(u.x,u.y,u.z),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===vn.rotate_self){var h=s/e.clientWidth,f=l/e.clientHeight,d=h*Math.PI*i*.5,m=f*Math.PI*i*.5,g=ge.fromAxisAngle(le.Y,-d),p=ge.fromAxisAngle(r,-m);g.multiply(p),g.multiply(this.cameraTransform.getRotation()),n.transform.setQuaternion(g.x,g.y,g.z,g.w),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===vn.rotate_focus){var v=s/e.clientWidth,y=l/e.clientHeight,T=v*Math.PI*i,_=y*Math.PI*i,b=ge.fromAxisAngle(le.Y,-T),C=ge.fromAxisAngle(r,-_);b.multiply(C);var S=b.toMatrix4(new he),x=le.fromArray(e.focusPoint),A=this.cameraCoordiante.origin.clone().subtract(x);S.transformPoint(A);var M=A.add(x);b.multiply(this.cameraTransform.getRotation()),n.transform.setPosition(M.x,M.y,M.z),n.transform.setQuaternion(b.x,b.y,b.z,b.w),this.setTransform(n,M,n.transform.rotation)}else console.warn("[CameraGestureHandlerImp] Movement type not implemented.")}else console.warn("[CameraGestureHandlerImp] Invalid move type specified: "+e.type);return this.composition.camera.getOptions()},t.setTransform=function(e,t,n){var i=e.getComponent(gt);void 0!==i&&i.setTransform(t,n)},t.setPosition=function(e,t){var n;(n=e.transform).setPosition.apply(n,[].concat(t));var i=e.getComponent(gt);void 0!==i&&i.updateMainCamera()},t.setQuaternion=function(e,t){var n;(n=e.transform).setQuaternion.apply(n,[].concat(t));var i=e.getComponent(gt);void 0!==i&&i.updateMainCamera()},t.endGesture=function(){this.startParams.type=vn.none,this.startParams.mouseEvent=!1,this.startParams.target=""},t.updateCameraTransform=function(e){var t=new i(e);t.setValid(!0),this.cameraTransform.fromEffectsTransform(t),this.cameraCoordiante.fromPTransform(this.cameraTransform)},e}(),_n=function(){function e(){}return e.getTransformFromMat4=function(e){var t=e.getTransform(),n=t.rotation.toEuler(new de);return{position:t.translation.toArray(),rotation:n.toArray(),scale:t.scale.toArray()}},e.getEffectsTransformFromMat4=function(e){var t=new i({valid:!0});return t.cloneFromMatrix(e),{position:t.position.toArray(),rotation:t.rotation.toArray(),scale:t.scale.toArray()}},e.getTransformFromTranslation=function(e){return{position:e.toArray()}},e.getTransformFromDirection=function(t){var n=le.fromArray([1,0,0]),i=t.clone().normalize(),r=n.clone().cross(i);if(r.length()<.01)return{};r.normalize();var o=i.dot(n),a=Math.acos(o),s=he.fromRotationAxis(r,a);return e.getTransformFromMat4(s)},e.getEffectsTransformFromDirection=function(t){var n=le.fromArray([0,0,1]),i=t.clone().normalize(),r=n.clone().cross(i);if(r.length()<.01)return{};r.normalize();var o=i.dot(n),a=Math.acos(o),s=he.fromRotationAxis(r,a);return e.getEffectsTransformFromMat4(s)},e.getTransformFromTransDir=function(t,n){var i=e.getTransformFromDirection(n);return i.position=t.toArray(),i},e.getEffectsTransformFromTransDir=function(t,n){var i=e.getEffectsTransformFromDirection(n);return i.position=t.toArray(),i},e.getEulerFromQuat=function(e){var t=new de,n=new ge(e.x,e.y,e.z,e.w);return t.order=me.ZYX,t.setFromQuaternion(n),[t.x,t.y,t.z]},e.getQuatFromEuler=function(e){var t=new ge;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}(),bn=function(){function e(e,t){void 0===t&&(t=!0),this.renderer=e,this.keepIBLData=t,this.treeInfo=new Cn,this.engine=e.engine,this.downloader=new O}var t=e.prototype;return t.processScene=function(e){var t=this;return V((function(){var i,r,o,a,s,l,c,u,h,f,d,m;return W(this,(function(g){switch(g.label){case 0:return P(e)?(r=e,[3,3]):[3,1];case 1:return[4,t.loadJSON(e)];case 2:r=g.sent(),g.label=3;case 3:if((i=r).textures||(i.textures=[]),i.textures.forEach((function(e){void 0===e.source&&(e.source=0)})),o=F(i),s=null!=(a=o.bins)?a:[],l=[],c=i.version.split("."),Number(c[0])>=3)return[2,o];if(!o.bins)return[3,7];u=$(o.bins),g.label=4;case 4:return(h=u()).done?[3,7]:(f=h.value,d=l.push,[4,t.loadBins(f.url)]);case 5:d.apply(l,[g.sent()]),g.label=6;case 6:return[3,4];case 7:return o.bins=l,m=Ce({},o,{version:n.JSONSceneVersion["3_0"],playerVersion:{web:"3.0",native:"3.0"},type:"ge",compositions:[],images:[],textures:[],items:[],components:[],materials:[],shaders:[]}),t.setImage(m,o),[4,t.setTexture(m,o)];case 8:return g.sent(),t.setComponent(m,o),t.setItem(m,o),t.setComposition(m,o),m.bins=s,[2,m]}}))}))()},t.setImage=function(e,t){var n=[];t.images.forEach((function(e){n.push(e)})),e.images=n},t.setTexture=function(e,t){var n=this;return V((function(){var i,r,o,a,s,l,c,u,h,f,d,m;return W(this,(function(g){switch(g.label){case 0:if(i=[],r=t.bins,!t.textures)return[3,7];o=$(t.textures),g.label=1;case 1:return(a=o()).done?[3,7]:34067!==(s=a.value).target?[3,5]:n.keepIBLData?(i.push(s),[3,4]):[3,2];case 2:return l=s.mipmaps,c=s.target,u=l.map((function(e){return Promise.all(e.map((function(e){return n.loadMipmapImage(e,r)})))})),[4,Promise.all(u)];case 3:h=g.sent(),f=h.map((function(t){return t.map((function(t){var n=I(),i={url:t,id:n};return e.images.push(i),{id:n}}))})),d=Ce({keepImageSource:!1},s,{mipmaps:f,sourceFrom:{target:c,type:p.mipmaps,mipmaps:l.map((function(e){return e.map((function(e){return[e[1][1],e[1][2]]}))}))}}),i.push(d),g.label=4;case 4:return[3,6];case 5:"number"==typeof(m=s.source)&&(s.source={id:e.images[m].id}),i.push(s),g.label=6;case 6:return[3,1];case 7:return e.textures=i,[2]}}))}))()},t.setComponent=function(e,t){for(var i,r=e.components,o=$(t.components);!(i=o()).done;){var a=i.value;if(a.dataType===n.DataType.SkyboxComponent)r.push(this.createSkyboxComponent(a,e));else if(a.dataType===n.DataType.LightComponent)r.push(this.createLightComponent(a,e));else if(a.dataType===n.DataType.CameraComponent)r.push(a),console.warn("Camera component found: "+a+".");else if(a.dataType===n.DataType.TreeComponent){var s=a;this.createItemsFromTreeComponent(a,e,t),s.options.tree.animation=void 0,s.options.tree.animations=void 0}else a.dataType!==n.DataType.MeshComponent&&r.push(a)}for(var l,c=$(t.components);!(l=c()).done;){var u=l.value;u.dataType===n.DataType.MeshComponent&&r.push(this.createMeshComponent(u,e,t))}},t.setItem=function(e,t){},t.setComposition=function(e,t){var n;e.items=t.items,(n=e.items).push.apply(n,[].concat(this.treeInfo.getAllTreeNodeList())),e.compositionId=t.compositionId,e.compositions=t.compositions,e.items.forEach((function(e){"root"===e.type&&(e.type="ECS")})),e.compositions[0].items=e.items.map((function(e){return{id:e.id}}))},t.loadJSON=function(e){var t=this;return V((function(){return W(this,(function(n){return[2,new Promise((function(n,i){t.downloader.downloadJSON(e,n,(function(t,n){i(new Error("Failed to load JSON from URL '"+e+"': status "+t+" - "+n+". Please check the URL or network settings."))}))}))]}))}))()},t.loadBins=function(e){var t=this;return V((function(){return W(this,(function(n){return[2,new Promise((function(n,i){t.downloader.downloadBinary(e,n,(function(t,n){i("Couldn't load bins "+JSON.stringify(e)+": status "+t+", "+n)}))}))]}))}))()},t.loadMipmapImage=function(e,t){return V((function(){var n,i,r,o,a;return W(this,(function(s){if(n=e[1],i=n[0],r=n[1],o=n[2],!(a=t[i]))throw new Error("Invalid bin pointer: "+JSON.stringify(e)+".");return[2,URL.createObjectURL(new Blob([new Uint8Array(a,r,o)]))]}))}))()},t.createSkyboxComponent=function(e,t){var n,i,r,o=e.options;o.irradianceCoeffs&&(n=[],o.irradianceCoeffs.forEach((function(e){return(i=n).push.apply(i,[].concat(e))})));return o.diffuseImage&&(r={id:t.textures[o.diffuseImage].id}),{id:e.id,dataType:e.dataType,item:e.item,renderable:o.renderable,intensity:o.intensity,reflectionsIntensity:o.reflectionsIntensity,irradianceCoeffs:n,diffuseImage:r,specularImage:{id:t.textures[o.specularImage].id},specularImageSize:o.specularImageSize,specularMipCount:o.specularMipCount+1}},t.createMeshComponent=function(e,t,n){var i,r=this,o=e.options,a=[],s=[];o.primitives.forEach((function(e){var t,i=Le(e.geometry,n.bins),o=r.getMaterialData(e.material,n);if(H(null==(t=i.indices)?void 0:t.data,Uint8Array)){for(var l=i.indices.data,c=new Uint16Array(l.length),u=0;u<l.length;u++)c[u]=l[u];i.indices.data=c}a.push(i),s.push(o)}));var l=xn(a);if(!l)throw new Error("No primitives available to process.");t.geometries.push(l),(i=t.materials).push.apply(i,[].concat(s));var c={id:e.id,dataType:e.dataType,item:e.item,geometry:{id:l.id},materials:s.map((function(e){return{id:e.id}}))};if(o.skin){for(var u,h=e.item.id,f=$(n.items);!(u=f()).done;){var d=u.value;d.id===e.item.id&&(h=d.parentId)}if(h===e.item.id)throw new Error("Can't item "+e.item+".");var m=this.treeInfo.getTreeItemByNodeId(h),g=this.treeInfo.getTreeNodeListByNodeId(h);if(!m||!g)throw new Error("Failed to retrieve tree node list for item with ID "+e.item.id+". Ensure the item exists and has a valid tree structure.");var p=this.setupBoneData(l,o.skin,n,m,g);c.rootBone={id:p.id}}return void 0!==o.weights&&(c.morph={weights:o.weights}),c},t.createItemsFromTreeComponent=function(e,t,i){var r=this,o=i.items[0];i.items.forEach((function(t){t.id===e.item.id&&(o=t)}));var a=e.options.tree,s=[];a.nodes.forEach((function(e,i){var a,l={id:I(),parentId:o.id,name:null!=(a=e.name)?a:"node"+i,duration:o.duration,type:"ECS",dataType:n.DataType.VFXItemData,visible:o.visible,endBehavior:o.endBehavior,delay:o.delay,content:{},renderLevel:o.renderLevel,pn:o.pn,pluginName:o.pluginName,transform:r.getTransformData(e.transform),components:[]};s.push(l),t.items.push(l)})),a.nodes.forEach((function(e,t){var n,i=s[t];null==(n=e.children)||n.forEach((function(e){s[e].parentId=i.id}))})),i.items.forEach((function(e){if(e.parentId){var t=e.parentId.indexOf("^");if(t>=0){var n=e.parentId.substring(0,t),i=+e.parentId.substring(t+1);n===o.id&&(e.parentId=s[i].id)}}})),this.treeInfo.add(o,s),this.createAnimationComponent(a,o,t,i)},t.createLightComponent=function(e,t){var n=e.options,i={id:e.id,dataType:e.dataType,item:e.item,lightType:n.lightType,color:{r:n.color[0]/255,g:n.color[1]/255,b:n.color[2]/255,a:n.color[3]/255},intensity:n.intensity};return"point"===n.lightType?i.range=n.range:"spot"===n.lightType&&(i.range=n.range,i.innerConeAngle=n.innerConeAngle,i.outerConeAngle=n.outerConeAngle),i},t.createAnimationComponent=function(e,t,i,r){var o=this,a=e.animation,s=e.animations,l={id:I(),dataType:n.DataType.AnimationComponent,item:{id:t.id},animation:a,animationClips:[]};if(s&&s.length){var c=r.bins;s.forEach((function(e){var a={id:I(),name:e.name,dataType:n.DataType.AnimationClip,positionCurves:[],rotationCurves:[],scaleCurves:[],floatCurves:[]},s=0;e.tracks.forEach((function(e){var t=Oe(c,e.input);s=Math.max(s,t[t.length-1])})),e.tracks.forEach((function(e){var i=Oe(c,e.input),s=Oe(c,e.output);if(!H(i,Float32Array))throw new Error("Type of inputArray should be float32, "+i+".");if(!H(s,Float32Array))throw new Error("Type of outputArray should be float32, "+s+".");if("LINEAR"!==e.interpolation)throw new Error("Invalid interpolation type "+e.interpolation+".");if("rotation"===e.path){for(var l,u=[],h=[],f=[],d=0;d<i.length;d++){if(u.push([s[4*d],s[4*d+1],s[4*d+2],s[4*d+3]]),d>0){var m=ge.fromArray(u[d-1]),g=ge.fromArray(u[d]),p=new ge,v=new ge;p.slerpQuaternions(m,g,1/3),v.slerpQuaternions(m,g,2/3),h.push(p.toArray()),h.push(v.toArray())}f.push([n.BezierKeyframeType.LINE,[i[d],d]])}var y=o.treeInfo.getTreeNode(t.id,e.node),T=o.treeInfo.getNodePath(y.id),_=[n.ValueType.BEZIER_CURVE_QUAT,[f,u,h]];null==(l=a.rotationCurves)||l.push({path:T,keyFrames:_})}else if("weights"===e.path){var b=o.treeInfo.getTreeNode(t.id,e.node),C=o.treeInfo.getNodePath(b.id);if(0===b.components.length)for(var S=0;S<r.items.length;S++){var x=r.items[S];if(x.parentId===b.id){C+="/"+x.name;break}}for(var A=s.length/i.length,M=0;M<A;M++){for(var I,E=[],w=0;w<i.length;w++)E.push([n.BezierKeyframeType.LINE,[i[w],s[w*A+M]]]);var N=[n.ValueType.BEZIER_CURVE,E];null==(I=a.floatCurves)||I.push({path:C,className:"ModelMeshComponent",property:"morphWeights."+M,keyFrames:N})}}else{for(var L=[],R=[],O=[],F=0;F<i.length;F++){if(L.push([s[3*F],s[3*F+1],s[3*F+2]]),F>0){var P=le.fromArray(L[F-1]),U=le.fromArray(L[F]),D=(new le).lerpVectors(P,U,1/3),B=(new le).lerpVectors(P,U,2/3);R.push(D.toArray()),R.push(B.toArray())}O.push([n.BezierKeyframeType.LINE,[i[F],F]])}var k,V,G=o.treeInfo.getTreeNode(t.id,e.node),z=o.treeInfo.getNodePath(G.id),j=[n.ValueType.BEZIER_CURVE_PATH,[O,L,R]];if("translation"===e.path)null==(k=a.positionCurves)||k.push({path:z,keyFrames:j});else null==(V=a.scaleCurves)||V.push({path:z,keyFrames:j})}})),i.animations.push(a),l.animationClips.push({id:a.id})}))}t.components=[],t.components.push({id:l.id}),i.components.push(l)},t.getMaterialData=function(e,t){if(e.type===n.MaterialType.unlit){var i={};void 0!==e.alphaCutOff&&(i._AlphaCutoff=e.alphaCutOff);var r={_BaseColorFactor:new fe(e.baseColorFactor[0],e.baseColorFactor[1],e.baseColorFactor[2],e.baseColorFactor[3]).divide(255)},o={};e.baseColorTexture&&(o._BaseColorSampler=this.getTextureData(t,i,e.baseColorTexture,e.baseColorTextureTransform));var a={id:I(),name:e.name,dataType:n.DataType.Material,shader:{id:xe},stringTags:{},macros:[],ints:{},floats:i,vector4s:{},colors:r,textures:o};return this.setupMaterial(e,a),a}var s={_MetallicFactor:e.metallicFactor,_RoughnessFactor:e.roughnessFactor};void 0!==e.useSpecularAA&&(s._SpecularAA=e.useSpecularAA?1:0),void 0!==e.normalTextureScale&&(s._NormalScale=e.normalTextureScale),void 0!==e.occlusionTextureStrength&&(s._OcclusionStrength=e.occlusionTextureStrength),void 0!==e.emissiveIntensity&&(s._EmissiveIntensity=e.emissiveIntensity),void 0!==e.alphaCutOff&&(s._AlphaCutoff=e.alphaCutOff);var l={_BaseColorFactor:new fe(e.baseColorFactor[0],e.baseColorFactor[1],e.baseColorFactor[2],e.baseColorFactor[3]).divide(255),_EmissiveFactor:new fe(e.emissiveFactor[0],e.emissiveFactor[1],e.emissiveFactor[2],e.emissiveFactor[3]).divide(255)},c={};e.baseColorTexture&&(c._BaseColorSampler=this.getTextureData(t,s,e.baseColorTexture,e.baseColorTextureTransform)),e.metallicRoughnessTexture&&(c._MetallicRoughnessSampler=this.getTextureData(t,s,e.metallicRoughnessTexture,e.metallicRoughnessTextureTransform)),e.normalTexture&&(c._NormalSampler=this.getTextureData(t,s,e.normalTexture,e.normalTextureTransform)),e.occlusionTexture&&(c._OcclusionSampler=this.getTextureData(t,s,e.occlusionTexture,e.occlusionTextureTransform)),e.emissiveTexture&&(c._EmissiveSampler=this.getTextureData(t,s,e.emissiveTexture,e.emissiveTextureTransform));var u={id:I(),name:e.name,dataType:n.DataType.Material,shader:{id:Se},stringTags:{},macros:[],ints:{},floats:s,vector4s:{},colors:l,textures:c};return this.setupMaterial(e,u),u},t.setupMaterial=function(e,t){var i;(e.blending===n.MaterialBlending.translucent?t.stringTags.RenderType=n.RenderType.Transparent:t.stringTags.RenderType=n.RenderType.Opaque,e.blending===n.MaterialBlending.masked)?(t.floats.AlphaClip=1,t.floats._AlphaCutoff=null!=(i=e.alphaCutOff)?i:0):t.floats.AlphaClip=0;switch(e.side){case n.SideMode.BACK:t.stringTags.RenderFace=n.RenderFace.Back;break;case n.SideMode.DOUBLE:t.stringTags.RenderFace=n.RenderFace.Both;break;default:t.stringTags.RenderFace=n.RenderFace.Front}e.type===n.MaterialType.pbr&&(t.floats._SpecularAA=e.useSpecularAA?1:0),t.floats.ZWrite=!1!==e.depthMask?1:0,t.floats.ZTest=1},t.getTextureData=function(e,t,n,i){var r,o={texture:{id:null!=(r=e.textures[n].id)?r:"0"}};return i&&(i.scale&&(o.scale={x:i.scale[0],y:i.scale[1]}),i.offset&&(o.offset={x:i.offset[0],y:i.offset[1]}),i.rotation&&(t._BaseColorRotation=i.rotation)),o},t.getTransformData=function(e){var t={position:{x:0,y:0,z:0},eulerHint:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}};return(null==e?void 0:e.position)&&(t.position.x=e.position[0],t.position.y=e.position[1],t.position.z=e.position[2]),(null==e?void 0:e.quat)?(t.quat={},t.quat.x=e.quat[0],t.quat.y=e.quat[1],t.quat.z=e.quat[2],t.quat.w=e.quat[3]):(null==e?void 0:e.rotation)&&(t.eulerHint.x=e.rotation[0],t.eulerHint.y=e.rotation[1],t.eulerHint.z=e.rotation[2]),(null==e?void 0:e.scale)&&(t.scale.x=e.scale[0],t.scale.y=e.scale[1],t.scale.z=e.scale[2]),t},t.setupBoneData=function(e,t,n,i,r){var o=n.bins,a=t.joints,s=t.skeleton,l=t.inverseBindMatrices;if(!l)throw new Error("'inverseBindMatrices' is undefined for the skin configuration: "+JSON.stringify(t)+". Ensure 'inverseBindMatrices' is properly defined in your skin data.");var c=Oe(o,l);e.inverseBindMatrices=Array.from(c);var u={},h=i;void 0!==s?h=r[s]:console.warn("Root bone is missing for the skeleton. Defaulting to the primary tree item as the root bone."),a.forEach((function(e){var t=r[e];t!==h&&t.parentId===h.parentId&&(console.error("Invalid node detected for 'rootBoneItem'. Adjusting 'rootBoneItem' to the primary tree item. Please verify the tree structure."),h=i)})),r.forEach((function(e){u[e.id]=e})),e.rootBoneName=h.name;var f=[];return a.forEach((function(e){for(var t=r[e],n=[];t&&t!=h&&(n.push(t.name),t.parentId);)t=u[t.parentId];f.push(n.reverse().join("/"))})),e.boneNames=f,h},e}(),Cn=function(){function e(){this.tree2NodeList={},this.nodeList2Tree={},this.nodeId2Node={},this.node2Path={}}var t=e.prototype;return t.add=function(e,t){var n=this;if(this.tree2NodeList[e.id])throw new Error("Duplicate treeItem ID detected: "+e.id+". Ensure each tree item has a unique ID.");this.tree2NodeList[e.id]=t,t.forEach((function(t){if(n.nodeList2Tree[t.id])throw new Error("Duplicate tree node ID found: "+t.id+". Each node in the tree must have a unique ID.");n.nodeList2Tree[t.id]=e,n.nodeId2Node[t.id]=t})),t.forEach((function(e){n.setNodePath(e)}))},t.setNodePath=function(e){e.parentId?this.node2Path[e.parentId]?this.node2Path[e.id]=this.node2Path[e.parentId]+"/"+e.name:this.nodeId2Node[e.parentId]?(this.setNodePath(this.nodeId2Node[e.parentId]),this.node2Path[e.id]=this.node2Path[e.parentId]+"/"+e.name):this.node2Path[e.id]=e.name:this.node2Path[e.id]=e.name},t.getTreeNodeListByTreeId=function(e){return this.tree2NodeList[e]},t.getTreeNodeListByNodeId=function(e){var t=this.nodeList2Tree[e];if(!t)throw new Error("Invalid id "+e+".");return this.getTreeNodeListByTreeId(t.id)},t.getTreeItemByNodeId=function(e){return this.nodeList2Tree[e]},t.getTreeNode=function(e,t){return this.getTreeNodeListByTreeId(e)[t]},t.getAllTreeNodeList=function(){var e=this,t=[];return Object.keys(this.tree2NodeList).forEach((function(n){var i;(i=t).push.apply(i,[].concat(e.tree2NodeList[n]))})),t},t.getNodePath=function(e){return this.node2Path[e]},e}();function Sn(e){var t,i=0,r=n.VertexFormatType.Float32,o=!1,s=n.VertexFormatType.Float32,l=!1,c=n.VertexFormatType.Float32,u=!1,h={vertices:new Float32Array,uvs:new Float32Array,normals:new Float32Array,indices:new Float32Array,name:null!=(t=e.name)?t:"<empty>"};for(var f in e.attributes){var d,m,g=e.attributes[f];if("aPosition"===f)i=g.data.length/g.size,h.vertices=g.data,o=null!=(d=g.normalize)&&d,r=R(null!=(m=g.type)?m:a.FLOAT);else if("aNormal"===f){var p,v;h.normals=g.data,u=null!=(p=g.normalize)&&p,c=R(null!=(v=g.type)?v:a.FLOAT)}else if("aUV1"===f){var y,T;h.uvs=g.data,l=null!=(y=g.normalize)&&y,s=R(null!=(T=g.type)?T:a.FLOAT)}}var _=An(r,3,i),b=An(s,2,i),C=An(c,3,i);if(e.indices)h.indices=e.indices.data;else if(i<=65535){for(var S=new Uint16Array(i),x=0;x<i;x++)S[x]=x;h.indices=S}else{for(var A=new Uint32Array(i),M=0;M<i;M++)A[M]=M;h.indices=A}var E=n.IndexFormatType.UInt16;return 4===h.indices.BYTES_PER_ELEMENT&&(E=n.IndexFormatType.UInt32),{id:I(),dataType:n.DataType.Geometry,vertexData:{vertexCount:i,channels:[{semantic:n.VertexBufferSemantic.Position,offset:0,format:r,dimension:3,normalize:o},{semantic:n.VertexBufferSemantic.Uv,offset:_,format:s,dimension:2,normalize:l},{semantic:n.VertexBufferSemantic.Normal,offset:_+b,format:c,dimension:3,normalize:u}]},subMeshes:[],mode:n.GeometryType.TRIANGLES,indexFormat:E,indexOffset:_+b+C,buffer:Mn(h)}}function xn(e){var t=function(t){var n,o,a,s=function(e){if(e.drawCount)return e.drawCount;if(e.indices)return e.indices.data.length;var t=0;return e.attributes.forEach((function(e){t=e.data.length/e.size})),t}(e[t]),l=i+(null!=(o=e[t].drawStart)?o:0),c=null!=(a=null==(n=e[0].indices)?void 0:n.data.BYTES_PER_ELEMENT)?a:1;if(r.push({offset:l*c,indexCount:s,vertexCount:s}),t){var u=e[0],h=e[t],f=!0;if(Object.keys(u.attributes).forEach((function(e){var t=u.attributes[e].data,n=h.attributes[e].data;t.length===n.length&&t[0]===n[0]||(f=!1)})),f)u.indices&&h.indices&&(u.indices.data=In(u.indices.data,h.indices.data));else{if(u.indices&&h.indices){var d=function(e){var t=0;return Object.keys(e.attributes).forEach((function(n){var i=e.attributes[n];t=i.data.length/i.size})),t}(u);u.indices.data=In(u.indices.data,h.indices.data,d)}Object.keys(u.attributes).forEach((function(e){var t=u.attributes[e],n=t.data,i=h.attributes[e].data;t.data=In(n,i)}))}}i=l+s};if(!(e.length<=0)){for(var i=0,r=[],o=0;o<e.length;o++)t(o);return function(e,t){var i=0;for(var r in e.attributes){i+=e.attributes[r].data.byteLength}e.indices&&(i+=e.indices.data.byteLength);var o=0,s=0,l=new Uint8Array(i),c=[];for(var u in e.attributes){var h,f,d=e.attributes[u],m=null!=(h=wn[u])?h:u;o=d.data.length/d.size;var g={semantic:m,offset:s,format:R(null!=(f=d.type)?f:a.FLOAT),dimension:d.size,normalize:d.normalize};c.push(g);var p=d.data,v=new Uint8Array(p.buffer,p.byteOffset,p.byteLength);l.set(v,s),s+=v.byteLength}var y={id:I(),dataType:n.DataType.Geometry,vertexData:{vertexCount:o,channels:c},subMeshes:t,mode:n.GeometryType.TRIANGLES,indexFormat:n.IndexFormatType.None,indexOffset:0,buffer:""};if(e.indices){var T=e.indices.data,_=new Uint8Array(T.buffer,T.byteOffset,T.byteLength);l.set(_,s),y.indexOffset=s,H(T,Uint32Array)?y.indexFormat=n.IndexFormatType.UInt32:y.indexFormat=n.IndexFormatType.UInt16}return y.buffer=function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}(l),y}(e[0],r)}}function An(e,t,i){switch(e){case n.VertexFormatType.Int8:case n.VertexFormatType.UInt8:return t*i;case n.VertexFormatType.Int16:case n.VertexFormatType.UInt16:return t*i*2;default:return t*i*4}}function Mn(e){var t=new Uint8Array(e.vertices.buffer,e.vertices.byteOffset,e.vertices.byteLength),n=new Uint8Array(e.uvs.buffer,e.uvs.byteOffset,e.uvs.byteLength),i=new Uint8Array(e.normals.buffer,e.normals.byteOffset,e.normals.byteLength),r=new Uint8Array(e.indices.buffer,e.indices.byteOffset,e.indices.byteLength),o=t.byteLength+n.byteLength+i.byteLength+r.byteLength,a=new ArrayBuffer(o),s=new Uint8Array(a,0,t.byteLength);s.set(t),(s=new Uint8Array(a,t.byteLength,n.byteLength)).set(n),(s=new Uint8Array(a,t.byteLength+n.byteLength,i.byteLength)).set(i),new Uint8Array(a,t.byteLength+n.byteLength+i.byteLength,r.byteLength).set(r);for(var l=new Uint8Array(a),c="",u=0;u<l.length;u++)c+=String.fromCharCode(l[u]);return btoa(c)}function In(e,t,n){if(H(e,Float32Array)){var i=new Float32Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}if(H(e,Int32Array)){var r=new Int32Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}if(H(e,Uint32Array)){var o=new Uint32Array(e.length+t.length);if(o.set(e),o.set(t,e.length),n)for(var a=0;a<t.length;a++)o[e.length+a]+=n;return o}if(H(e,Int16Array)){var s=new Int16Array(e.length+t.length);return s.set(e),s.set(t,e.length),s}if(H(e,Uint16Array)){var l=new Uint16Array(e.length+t.length);if(l.set(e),l.set(t,e.length),n)for(var c=0;c<t.length;c++)l[e.length+c]+=n;return l}if(H(e,Int8Array)){var u=new Int8Array(e.length+t.length);return u.set(e),u.set(t,e.length),u}var h=new Uint8Array(e.length+t.length);return h.set(e),h.set(t,e.length),h}var En,wn={aPos:"POSITION",aUV:"TEXCOORD0",aUV2:"TEXCOORD1",aNormal:"NORMAL",aTangent:"TANGENT",aColor:"COLOR",aJoints:"JOINTS",aWeights:"WEIGHTS",a_Position:"POSITION",a_UV:"TEXCOORD0",a_UV1:"TEXCOORD0",a_UV2:"TEXCOORD1",a_Normal:"NORMAL",a_Tangent:"TANGENT",a_Color:"COLOR",a_Joints:"JOINTS",a_Joint1:"JOINTS",a_Weights:"WEIGHTS",a_Weight1:"WEIGHTS",a_Target_Position0:"POSITION_BS0",a_Target_Position1:"POSITION_BS1",a_Target_Position2:"POSITION_BS2",a_Target_Position3:"POSITION_BS3",a_Target_Position4:"POSITION_BS4",a_Target_Position5:"POSITION_BS5",a_Target_Position6:"POSITION_BS6",a_Target_Position7:"POSITION_BS7",a_Target_Normal0:"NORMAL_BS0",a_Target_Normal1:"NORMAL_BS1",a_Target_Normal2:"NORMAL_BS2",a_Target_Normal3:"NORMAL_BS3",a_Target_Tangent0:"TANGENT_BS0",a_Target_Tangent1:"TANGENT_BS1",a_Target_Tangent2:"TANGENT_BS2",a_Target_Tangent3:"TANGENT_BS3"};function Nn(e,t){return En||(En=new Rn),En.initial(e,t),En}function Ln(e){En=e}var Rn=function(){function e(e){this.gltfMeshs=[],this.gltfTextures=[],this.gltfMaterials=[],this.gltfAnimations=[],this.gltfImageBasedLights=[],this.timelineAssetId="",this.images=[],this.imageElements=[],this.textures=[],this.items=[],this.components=[],this.materials=[],this.shaders=[],this.geometries=[],this.animations=[],this.sceneAABB=new pe,e?this.composition=e:(this.timelineAssetId=I(),this.composition={id:"1",name:"test1",duration:99999,endBehavior:n.EndBehavior.restart,camera:{fov:45,far:2e3,near:.001,position:[0,0,8],rotation:[0,0,0],clipMode:n.CameraClipMode.portrait},items:[],timelineAsset:{id:this.timelineAssetId},sceneBindings:[]})}var t=e.prototype;return t.loadScene=function(e){var t=this;return V((function(){var n,i,r,o,a,s,l,c,u;return W(this,(function(h){switch(h.label){case 0:if(t.clear(),t.sceneOptions=e,t.loaderOptions={compatibleMode:e.gltf.compatibleMode},"string"==typeof(a=e.gltf.resource)||H(a,Uint8Array))throw new Error("Please load the resource using GLTFTools first.");return t.images=a.images.map((function(e){var t,n=new Blob([e.imageData.buffer],{type:null!=(t=e.mimeType)?t:"image/png"});return{id:e.id,url:URL.createObjectURL(n)}})),[4,Promise.all(t.images.map(V((function(e){return W(this,(function(t){return[2,M(e.url)]}))}))))];case 1:if(t.imageElements=h.sent(),t.processGLTFResource(a,t.imageElements),t.gltfMeshs=a.meshes,t.gltfTextures=a.textures,t.gltfMaterials=a.materials,t.gltfAnimations=a.animations,t.gltfImageBasedLights=a.imageBasedLights,t.textures=t.gltfTextures.map((function(e){var n=e.textureOptions,i=n.source;return"number"==typeof i&&(n.source={id:t.images[i].id}),n})),t.materials=t.gltfMaterials.map((function(e){return e.materialData})),a.meshes.forEach((function(e){t.geometries.push(e.geometryData)})),(s=a.scenes[0]).meshesComponentData.forEach((function(e){return t.checkMeshComponentData(e,a)})),(n=t.components).push.apply(n,[].concat(s.camerasComponentData)),(i=t.components).push.apply(i,[].concat(s.lightsComponentData)),(r=t.components).push.apply(r,[].concat(s.meshesComponentData)),1===s.animationsComponentData.length)l=s.animationsComponentData[0],e.effects.playAllAnimation||void 0===e.effects.playAnimation||(c=l.animationClips,(u=e.effects.playAnimation)>=0&&u<c.length?l.animationClips=[c[u]]:l.animationClips=[]),t.components.push(l);else if(s.animationsComponentData.length>1)throw new Error("Find many animation component data "+s.animationsComponentData.length);return t.animations=[],t.gltfAnimations.forEach((function(e){t.animations.push(e.animationClipData)})),t.items=[],[4,t.tryAddSkybox({skyboxType:e.gltf.skyboxType,renderable:e.gltf.skyboxVis})];case 2:return h.sent(),(o=t.items).push.apply(o,[].concat(a.scenes[0].vfxItemData)),t.items.forEach((function(e){"root"===e.type&&(e.type="ECS")})),[2,t.getLoadResult()]}}))}))()},t.processGLTFResource=function(e,t){var n=function(){var e=f.value;if(h.has(e)){var t=o.find((function(t){return t.textureOptions.id===e}));if(t){var n=I(),i=t.clone();i.textureOptions.id=n,o.push(i),r[n]=i.textureOptions,m[e]=n,d+=1}}},i=this,r={},o=e.textures,s=e.materials,l=e.scenes,c=e.imageBasedLights;o.forEach((function(e){var t=e.textureOptions,n=t.id;n?(r[n]&&console.error("Duplicate GUID found: "+n+", old "+r[n]+", new "+t+"."),r[n]=t):console.error("No GUID in texture Data: "+t+".")}));var u=new Set,h=new Set;s.forEach((function(e){var t,n,i=e.materialData,r=null==(t=i.textures._BaseColorSampler)?void 0:t.texture,o=null==(n=i.textures._EmissiveSampler)?void 0:n.texture;r&&u.add(r.id),o&&h.add(o.id)}));for(var f,d=0,m={},g=$(u);!(f=g()).done;)n();d>0&&console.warn("Add base color texture "+d),s.forEach((function(e){var n,o,a=e.materialData;if(i.processMaterialData(a),(null==(n=a.shader)?void 0:n.id)===xe)i.processMaterialTexture(a,"_BaseColorSampler",!0,r,t);else if((null==(o=a.shader)?void 0:o.id)===Se){var s,l=null==(s=a.textures._EmissiveSampler)?void 0:s.texture;l&&m[l.id]&&(l.id=m[l.id]),i.processMaterialTexture(a,"_BaseColorSampler",!0,r,t),i.processMaterialTexture(a,"_MetallicRoughnessSampler",!1,r,t),i.processMaterialTexture(a,"_NormalSampler",!1,r,t),i.processMaterialTexture(a,"_OcclusionSampler",!1,r,t),i.processMaterialTexture(a,"_EmissiveSampler",!1,r,t)}}));var p=l[0];p.camerasComponentData.forEach((function(e){return i.processCameraComponentData(e)})),p.lightsComponentData.forEach((function(e){return i.processLightComponentData(e)}));var v=[];c.forEach((function(e){var t=e.imageBaseLightData;if(void 0===t.reflectionsIntensity&&(t.reflectionsIntensity=t.intensity),t.diffuseImage){var n=r[t.diffuseImage.id];E(v,n)}if(t.specularImage){var i=r[t.specularImage.id];E(v,i)}})),v.forEach((function(e){if(e.target===a.TEXTURE_CUBE_MAP){var t=e;t.mipmaps.forEach((function(e){var t;t=[e[5],e[4]],e[4]=t[0],e[5]=t[1]})),1===t.mipmaps.length?(t.minFilter=a.LINEAR,t.magFilter=a.LINEAR):(t.minFilter=a.LINEAR_MIPMAP_LINEAR,t.magFilter=a.LINEAR)}}))},t.processComponentData=function(e){var t=this;e.forEach((function(e){e.dataType===n.DataType.LightComponent?t.processLightComponentData(e):e.dataType===n.DataType.CameraComponent?t.processCameraComponentData(e):e.dataType===n.DataType.SkyboxComponent&&t.processSkyboxComponentData(e)}))},t.processLightComponentData=function(e){e.color||(e.color={r:1,g:1,b:1,a:1}),e.intensity||(e.intensity=1),e.lightType===n.LightType.point?e.range||(e.range=0):e.lightType===n.LightType.spot&&(e.range||(e.range=0),e.innerConeAngle||(e.innerConeAngle=0),e.outerConeAngle||(e.outerConeAngle=Math.PI/4))},t.processCameraComponentData=function(e){e.type===n.CameraType.perspective&&e.fov&&(e.fov*=Math.PI/180)},t.processSkyboxComponentData=function(e){void 0===e.intensity&&(e.intensity=1),void 0===e.reflectionsIntensity&&(e.reflectionsIntensity=1)},t.processMaterialData=function(e){var t,i;(null==(t=e.shader)?void 0:t.id)===xe?(e.colors._BaseColorFactor||(e.colors._BaseColorFactor={r:1,g:1,b:1,a:1}),void 0===e.floats._AlphaCutoff&&(e.floats._AlphaCutoff=0),void 0===e.floats.ZWrite&&(e.floats.ZWrite=1),void 0===e.floats.ZTest&&(e.floats.ZTest=1),e.stringTags.RenderType||(e.stringTags.RenderType=n.RenderType.Opaque),e.stringTags.RenderFace||(e.stringTags.RenderFace=n.RenderFace.Front)):(null==(i=e.shader)?void 0:i.id)===Se?(e.colors._BaseColorFactor||(e.colors._BaseColorFactor={r:1,g:1,b:1,a:1}),void 0===e.floats._SpecularAA&&(e.floats._SpecularAA=0),void 0===e.floats._MetallicFactor&&(e.floats._MetallicFactor=1),void 0===e.floats._RoughnessFactor&&(e.floats._RoughnessFactor=0),void 0===e.floats._NormalScale&&(e.floats._NormalScale=1),void 0===e.floats._OcclusionStrength&&(e.floats._OcclusionStrength=this.isTiny3dMode()?0:1),e.colors._EmissiveFactor||(e.colors._EmissiveFactor={r:0,g:0,b:0,a:1}),void 0===e.floats._EmissiveIntensity&&(e.floats._EmissiveIntensity=1),void 0===e.floats._AlphaCutoff&&(e.floats._AlphaCutoff=0),void 0===e.floats.ZWrite&&(e.floats.ZWrite=1),void 0===e.floats.ZTest&&(e.floats.ZTest=1),e.stringTags.RenderType||(e.stringTags.RenderType=n.RenderType.Opaque),e.stringTags.RenderFace||(e.stringTags.RenderFace=n.RenderFace.Front)):console.error("Encountered unknown shader ID in material with ID: "+e.id+".")},t.processTextureOptions=function(e,t,n){var i,r=!1,o=null!=(i=e.minFilter)?i:a.LINEAR_MIPMAP_LINEAR;this.isTiny3dMode()&&(o=a.LINEAR_MIPMAP_LINEAR,n&&(Et.isPow2(n.width)&&Et.isPow2(n.height)||(o=a.LINEAR)),r=!t);var s,l,c,u=o==a.NEAREST_MIPMAP_NEAREST||o==a.LINEAR_MIPMAP_NEAREST||o==a.NEAREST_MIPMAP_LINEAR||o==a.LINEAR_MIPMAP_LINEAR;e.wrapS=null!=(s=e.wrapS)?s:a.REPEAT,e.wrapT=null!=(l=e.wrapT)?l:a.REPEAT,e.magFilter=null!=(c=e.magFilter)?c:a.LINEAR,e.minFilter=o,e.anisotropic=1,e.premultiplyAlpha=r,e.generateMipmap=u},t.initial=function(e,t){this.engine=e,this.loaderOptions=null!=t?t:{}},t.checkMeshComponentData=function(e,t){if(e.materials.length<=0)throw new Error("Submesh array is empty for mesh with ID: "+e.id+".");var n;if(t.meshes.forEach((function(t){t.geometryData.id===e.geometry.id&&(n=t.geometryData)})),void 0===n)throw new Error("Unable to find geometry data for mesh with ID: "+e.geometry.id+".");if(n.subMeshes.length!==e.materials.length)throw new Error("Mismatch between submeshes count ("+n.subMeshes.length+") and materials count ("+e.materials.length+").")},t.processMaterialTexture=function(e,t,n,i,r){var o=e.textures[t];if(o){var a,s=i[o.texture.id];if("number"!=typeof s.source)throw new Error("Invalid texture option source data, "+s.source);a=r[s.source],s&&this.processTextureOptions(s,n,a)}},t.getLoadResult=function(){var e=[];this.items.forEach((function(t){return e.push({id:t.id})})),this.composition.items=e;var t={version:n.JSONSceneVersion["3_0"],playerVersion:{web:"2.0",native:"2.0"},type:"ge",compositionId:this.composition.id,compositions:[this.composition],images:this.images,plugins:["model"],textures:this.textures,items:this.items,components:this.components,materials:this.materials,shaders:this.shaders,geometries:this.geometries,animations:this.animations,miscs:[{id:this.timelineAssetId,dataType:n.DataType.TimelineAsset}]},i=this.computeSceneAABB();return{source:this.getRemarkString(),jsonScene:t,sceneAABB:{min:i.min.toArray(),max:i.max.toArray()}}},t.addLight=function(e){var t=I(),i={id:I(),item:{id:t},dataType:n.DataType.LightComponent,lightType:e.lightType,color:e.color,intensity:e.intensity,range:e.range,innerConeAngle:e.innerConeAngle,outerConeAngle:e.outerConeAngle,followCamera:e.followCamera},r={id:t,name:e.name,duration:e.duration,type:n.ItemType.light,pn:0,visible:!0,endBehavior:e.endBehavior,transform:{position:{x:e.position[0],y:e.position[1],z:e.position[2]},eulerHint:{x:e.rotation[0],y:e.rotation[1],z:e.rotation[2]},scale:{x:e.scale[0],y:e.scale[1],z:e.scale[2]}},components:[{id:i.id}],content:{},dataType:n.DataType.VFXItemData};this.items.push(r),this.components.push(i)},t.addCamera=function(e){var t=I(),i={id:I(),item:{id:t},dataType:n.DataType.CameraComponent,fov:e.fov,near:e.near,far:e.far,clipMode:e.clipMode},r={id:t,name:e.name,duration:e.duration,type:"camera",pn:0,visible:!0,endBehavior:e.endBehavior,transform:{position:{x:e.position[0],y:e.position[1],z:e.position[2]},eulerHint:{x:e.rotation[0],y:e.rotation[1],z:e.rotation[2]},scale:{x:1,y:1,z:1}},components:[{id:i.id}],content:{},dataType:n.DataType.VFXItemData};this.items.push(r),this.components.push(i)},t.addSkybox=function(e){var t,i,r,o=I(),a=tn.createSkyboxComponentData(e),s=a.imageList,l=a.textureOptionsList,c=a.component;c.item.id=o,void 0!==e.intensity&&(c.intensity=e.intensity),void 0!==e.reflectionsIntensity&&(c.reflectionsIntensity=e.reflectionsIntensity),c.renderable=null!=(r=e.renderable)&&r;var u={id:o,name:"Skybox-Customize",duration:999,type:n.ItemType.skybox,pn:0,visible:!0,endBehavior:n.EndBehavior.freeze,transform:{position:{x:0,y:0,z:0},eulerHint:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},components:[{id:c.id}],content:{},dataType:n.DataType.VFXItemData};(t=this.images).push.apply(t,[].concat(s)),(i=this.textures).push.apply(i,[].concat(l)),this.items.push(u),this.components.push(c)},t.tryAddSkybox=function(e){var t=this;return V((function(){var i,r,o,a,s,l,c,u,h,f,d;return W(this,(function(m){return t.gltfImageBasedLights.length>0&&!t.ignoreSkybox()?(i=t.gltfImageBasedLights[0],t.components.push(i.imageBaseLightData)):void 0!==e.skyboxType&&(a=I(),s=t.createSkyboxComponentData(e.skyboxType),l=s.imageList,c=s.textureOptionsList,(u=s.component).item.id=a,void 0!==e.intensity&&(u.intensity=e.intensity),void 0!==e.reflectionsIntensity&&(u.reflectionsIntensity=e.reflectionsIntensity),u.renderable=null!=(h=e.renderable)&&h,d={id:a,name:"Skybox-"+e.skyboxType,duration:null!=(f=e.duration)?f:999,type:n.ItemType.skybox,pn:0,visible:!0,endBehavior:n.EndBehavior.freeze,transform:{position:{x:0,y:0,z:0},eulerHint:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},components:[{id:u.id}],content:{},dataType:n.DataType.VFXItemData},(r=t.images).push.apply(r,[].concat(l)),(o=t.textures).push.apply(o,[].concat(c)),t.items.push(d),t.components.push(u)),[2]}))}))()},t.createSkyboxComponentData=function(e){if("NFT"!==e&&"FARM"!==e)throw new Error("Invalid skybox type specified: '"+e+"'. Valid types are: 'NFT', 'FARM'.");var t="NFT"===e?Qt.NFT:Qt.FARM,n=tn.getSkyboxParams(t);return tn.createSkyboxComponentData(n)},t.dispose=function(){this.clear(),this.engine=null},t.clear=function(){this.gltfMeshs=[],this.gltfTextures=[],this.gltfMaterials=[],this.gltfAnimations=[],this.gltfImageBasedLights=[],this.images=[],this.imageElements=[],this.textures=[],this.items=[],this.components=[],this.materials=[],this.shaders=[],this.geometries=[],this.animations=[]},t.computeSceneAABB=function(){var e={};this.gltfMeshs.forEach((function(t){var n=t.geometryData.id;e[n]=t}));var t={};this.components.forEach((function(i){if(i.dataType===n.DataType.MeshComponent){var r=i;t[i.id]=e[r.geometry.id]}}));var r=new pe,o={};return this.items.forEach((function(e){var n,a,s=null!=(n=e.parentId)?n:"",l=null!=(a=o[s])?a:new i,c={};e.transform&&(c.position=(new le).copyFrom(e.transform.position),c.rotation=de.fromVector3(e.transform.eulerHint),c.scale=(new le).copyFrom(e.transform.scale));var u=new i(c,l);o[e.id]=u,e.components.forEach((function(e){var n=t[e.id];if(n&&n.bounds){var i=le.fromArray(n.bounds.box.min),o=le.fromArray(n.bounds.box.max);r.union(new pe(i,o))}}))})),r},t.isPlayAnimation=function(){return void 0!==this.sceneOptions.effects.playAnimation},t.isPlayAllAnimation=function(){return!0===this.sceneOptions.effects.playAllAnimation},t.getRemarkString=function(){var e=this.sceneOptions.gltf.remark;return void 0===e?"Unknown":"string"==typeof e?e:"BinaryBuffer"},t.getCompositionDuration=function(){return this.composition.duration},t.isTiny3dMode=function(){return"tiny3d"===this.loaderOptions.compatibleMode},t.getItemDuration=function(){var e;return null!=(e=this.sceneOptions.effects.duration)?e:9999},t.getEndBehavior=function(){var e;return null!=(e=this.sceneOptions.effects.endBehavior)?e:n.EndBehavior.restart},t.getSkyboxType=function(){switch(this.sceneOptions.gltf.skyboxType){case"NFT":return Qt.NFT;case"FARM":return Qt.FARM}},t.isSkyboxVis=function(){return!0===this.sceneOptions.gltf.skyboxVis},t.ignoreSkybox=function(){return!0===this.sceneOptions.gltf.ignoreSkybox},t.isEnvironmentTest=function(){return"string"==typeof this.sceneOptions.gltf.remark&&this.sceneOptions.gltf.remark.includes("EnvironmentTest")},t.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))}))},t.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)}))},t.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)}))},t.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}}))},t.createGeometry=function(e,t){return new Dn(this.engine,e,t).geometry},t.createMaterial=function(e){return new Bn(e,[],this.isTiny3dMode()).material},t.createTexture2D=function(e,t,n){return Et.createTexture2D(this.engine,e,t,n,this.isTiny3dMode())},t.createTextureCube=function(e,t){var n=this;if(0==e.length)throw new Error("createTextureCube: Invalid cubeImages length "+e);var i=[];return e.forEach((function(e){if(6!=e.length)throw new Error("createTextureCube: cubeimage count should always be 6, "+e);var t,r=[];(e.forEach((function(e){if(void 0===e.imageData)throw new Error("createTextureCube: Invalid image data from "+e);r.push({type:"buffer",data:e.imageData,mimeType:e.mimeType})})),n.isTiny3dMode())&&(t=[r[5],r[4]],r[4]=t[0],r[5]=t[1]);i.push(r)})),1==i.length?Et.createTextureCubeFromBuffer(this.engine,i[0]):Et.createTextureCubeMipmapFromBuffer(this.engine,i,null!=t?t:Math.pow(2,i.length-1))},t.createSkybox=function(e){var t,n,i=this,r=null!=(t=e.reflectionsIntensity)?t:e.intensity,o=e.irradianceCoefficients,a=e.specularImages.map((function(e){var t,n=e.map((function(e){return{type:"buffer",data:e.imageData,mimeType:e.mimeType}}));i.isTiny3dMode()&&(t=[n[5],n[4]],n[4]=t[0],n[5]=t[1]);return n})),s=a.length-1,l=null!=(n=e.specularImageSize)?n:Math.pow(2,s),c=[];o.forEach((function(e){var t;(t=c).push.apply(t,[].concat(e))}));var u={type:"buffer",renderable:this.isSkyboxVis(),intensity:e.intensity,reflectionsIntensity:r,irradianceCoeffs:c,specularImage:a,specularMipCount:s,specularImageSize:l};return tn.createSkyboxOptions(this.engine,u)},t.createDefaultSkybox=function(e){if("NFT"!==e&&"FARM"!==e)throw new Error("Invalid skybox type name "+e);var t="NFT"===e?Qt.NFT:Qt.FARM,n=tn.getSkyboxParams(t);return tn.createSkyboxOptions(this.engine,n)},t.scaleColorVal=function(e,t){return t?_n.scaleTo255(e):_n.scaleTo1(e)},t.scaleColorVec=function(e,t){var n=this;return e.map((function(e){return n.scaleColorVal(e,t)}))},e}();function On(){return'\n _BaseColorSampler ("基础贴图", 2D) = "" {}\n _BaseColorFactor ("基础颜色", Color) = (1, 1, 1, 1)\n _MetallicRoughnessSampler ("金属贴图", 2D) = "" {}\n _MetallicFactor ("金属度", Range(0, 1)) = 1\n _RoughnessFactor ("粗糙度", Range(0, 1)) = 1\n [Toggle] _SpecularAA ("高光抗锯齿", Float) = 0\n _NormalSampler ("法线贴图", 2D) = "" {}\n _NormalScale ("法线贴图强度", Range(0, 2)) = 1\n _OcclusionSampler ("AO贴图", 2D) = "" {}\n _OcclusionStrength ("AO贴图强度", Range(0, 1)) = 1\n _EmissiveSampler ("自发光贴图", 2D) = "" {}\n _EmissiveIntensity ("自发光贴图强度", Float) = 1\n _EmissiveFactor ("自发光颜色", Color) = (0, 0, 0, 1)\n _AlphaCutoff ("Alpha裁剪值", Range(0, 1)) = 0.5\n '}function Fn(){return'\n _BaseColorSampler ("基础贴图", 2D) = "" {}\n _BaseColorFactor ("基础颜色", Color) = (1, 1, 1, 1)\n _AlphaCutoff ("Alpha裁剪值", Range(0, 1)) = 0.5\n '}function Pn(){return{id:"00000000000000000000000000000000",name:"PBR Material",dataType:n.DataType.Material,stringTags:{RenderType:n.RenderType.Opaque,RenderFace:"Front"},macros:[],shader:{id:"pbr00000000000000000000000000000"},ints:{},floats:{ZWrite:1,ZTest:1,_SpecularAA:0,_MetallicFactor:1,_RoughnessFactor:0,_NormalScale:1,_OcclusionStrength:1,_EmissiveIntensity:1,_AlphaCutoff:.5},vector4s:{},colors:{_BaseColorFactor:{r:1,g:1,b:1,a:1},_EmissiveFactor:{r:0,g:0,b:0,a:1}},textures:{}}}function Un(){return{id:"00000000000000000000000000000000",name:"Unlit Material",dataType:n.DataType.Material,stringTags:{ZWrite:"true",ZTest:"true",RenderType:n.RenderType.Opaque,Cull:"Front"},macros:[],shader:{id:n.BuiltinObjectGUID.UnlitShader},ints:{},floats:{_AlphaCutoff:.5},vector4s:{},colors:{_BaseColorFactor:{r:1,g:1,b:1,a:1}},textures:{}}}var Dn=function(){function e(e,t,n){this.engine=e,this.gltfGeometry=t,this.hasSkinAnimation=n}var t=e.prototype;return t._getBufferAttrib=function(e){return{type:e.type,size:e.itemSize,data:e.array,normalize:e.normalized}},t.texCoordAttrib=function(e){return this.gltfGeometry.getTexCoord(e)},t.getTargetPosition=function(e){return this.gltfGeometry.getAttribute("POSITION"+e)},t.getTargetNormal=function(e){return this.gltfGeometry.getAttribute("NORMAL"+e)},t.getTargetTangent=function(e){return this.gltfGeometry.getAttribute("TANGENT"+e)},be(e,[{key:"geometry",get:function(){var e=this,t={};if(!this.hasPosition)throw new Error("Position attribute missing");var n=this.positionAttrib;if(t.a_Position=this._getBufferAttrib(n),this.hasNormal){var i=this.normalAttrib;void 0!==i&&(t.a_Normal=this._getBufferAttrib(i))}if(this.hasTangent){var r=this.tangentAttrib;void 0!==r&&(t.a_Tangent=this._getBufferAttrib(r))}if(this.texCoordList.forEach((function(n){var i=e.texCoordAttrib(n);t["a_UV"+(n+1)]=e._getBufferAttrib(i)})),this.hasSkinAnimation){var o=this.jointAttribute;void 0!==o&&(t.a_Joint1=this._getBufferAttrib(o));var s=this.weightAttribute;void 0!==s&&(t.a_Weight1=this._getBufferAttrib(s))}for(var l=0;l<8;l++){var u=this.getTargetPosition(l);void 0!==u&&(t["a_Target_Position"+l]=this._getBufferAttrib(u));var h=this.getTargetNormal(l);void 0!==h&&(t["a_Target_Normal"+l]=this._getBufferAttrib(h));var f=this.getTargetTangent(l);void 0!==f&&(t["a_Target_Tangent"+l]=this._getBufferAttrib(f))}var d=this.indexArray;return void 0!==d?c.create(this.engine,{attributes:t,indices:{data:d},drawStart:0,drawCount:d.length,mode:a.TRIANGLES}):c.create(this.engine,{attributes:t,drawStart:0,drawCount:this.positionAttrib.array.length/3,mode:a.TRIANGLES})}},{key:"positionAttrib",get:function(){return this.gltfGeometry.getPosition()}},{key:"normalAttrib",get:function(){return this.gltfGeometry.getNormal()}},{key:"tangentAttrib",get:function(){return this.gltfGeometry.getTangent()}},{key:"jointAttribute",get:function(){return this.gltfGeometry.getJoints(0)}},{key:"weightAttribute",get:function(){return this.gltfGeometry.getWeights(0)}},{key:"hasPosition",get:function(){return void 0!==this.positionAttrib}},{key:"hasNormal",get:function(){return void 0!==this.normalAttrib}},{key:"hasTangent",get:function(){return void 0!==this.tangentAttrib}},{key:"hasTexCoord",get:function(){return this.texCoordCount>0}},{key:"texCoordCount",get:function(){for(var e=0;e<10;e++)if(void 0===this.texCoordAttrib(e))return e;return 0}},{key:"hasJointAttribute",get:function(){return void 0!==this.jointAttribute}},{key:"hasWeightAttribute",get:function(){return void 0!==this.weightAttribute}},{key:"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}}},{key:"indexCount",get:function(){return void 0!==this.gltfGeometry.indices?this.gltfGeometry.indices.array.length:0}},{key:"texCoordList",get:function(){for(var e=[],t=0;t<10&&void 0!==this.texCoordAttrib(t);t++)e.push(t);return e}}]),e}(),Bn=function(){function e(e,t,n){this.gltfMaterial=e,this.textures=t,this.tiny3dMode=n}var t=e.prototype;return t.getTextureObject=function(e){if(!(e<0||e>=this.textures.length))return this.textures[e]},t.getTextureObj=function(e){return e?this.getTextureObject(e.index):void 0},t.getTextureCoord=function(e){return e?e.texCoord:void 0},t.getTextureTransform=function(e){var t,n=null==e||null==(t=e.extensions)?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}},t.getSpecularAA=function(){var e;return null==(e=this.gltfMaterial.extras)?void 0:e.useSpecularAA},be(e,[{key:"material",get:function(){var e=this.gltfMaterial,t=kn.isUnlitMaterial(e),i=n.MaterialBlending.opaque;switch(e.alphaMode){case"OPAQUE":i=n.MaterialBlending.opaque;break;case"MASK":i=n.MaterialBlending.masked;break;case"BLEND":i=n.MaterialBlending.translucent}var r,o,a,s=e.doubleSided?n.SideMode.DOUBLE:n.SideMode.FRONT,l=null!=(r=e.alphaCutOff)?r:.5,c=e.name;return t?{name:c,type:n.MaterialType.unlit,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,depthMask:null==(o=e.extras)?void 0:o.depthMask,blending:i,alphaCutOff:l,side:s}:{name:c,type:n.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==(a=e.extras)?void 0:a.depthMask,blending:i,alphaCutOff:l,side:s,enableShadow:!1}}},{key:"baseColorTextureObj",get:function(){return this.getTextureObj(this.gltfMaterial.baseColorTexture)}},{key:"baseColorTextureCoord",get:function(){return this.getTextureCoord(this.gltfMaterial.baseColorTexture)}},{key:"baseColorTextureTransfrom",get:function(){return this.getTextureTransform(this.gltfMaterial.baseColorTexture)}},{key:"metallicRoughnessTextureObj",get:function(){return this.getTextureObj(this.gltfMaterial.metallicRoughnessTexture)}},{key:"metallicRoughnessTextureCoord",get:function(){return this.getTextureCoord(this.gltfMaterial.metallicRoughnessTexture)}},{key:"metallicRoughnessTextureTransfrom",get:function(){return this.getTextureTransform(this.gltfMaterial.metallicRoughnessTexture)}},{key:"normalTextureObj",get:function(){return this.getTextureObj(this.gltfMaterial.normalTexture)}},{key:"normalTextureCoord",get:function(){return this.getTextureCoord(this.gltfMaterial.normalTexture)}},{key:"normalTextureTransfrom",get:function(){return this.getTextureTransform(this.gltfMaterial.normalTexture)}},{key:"occlusionTextureObj",get:function(){return this.getTextureObj(this.gltfMaterial.occlusionTexture)}},{key:"occlusionTextureCoord",get:function(){return this.getTextureCoord(this.gltfMaterial.occlusionTexture)}},{key:"occlusionTextureTransfrom",get:function(){return this.getTextureTransform(this.gltfMaterial.occlusionTexture)}},{key:"emissiveTextureObj",get:function(){return this.getTextureObj(this.gltfMaterial.emissiveTexture)}},{key:"emissiveTextureCoord",get:function(){return this.getTextureCoord(this.gltfMaterial.emissiveTexture)}},{key:"emissiveTextureTransfrom",get:function(){return this.getTextureTransform(this.gltfMaterial.emissiveTexture)}},{key:"hasEmissive",get:function(){var e=this.emissiveFactor;return e[0]+e[1]+e[2]>0}},{key:"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]]}},{key:"metalicFactor",get:function(){var e;return null!=(e=this.gltfMaterial.metallicFactor)?e:1}},{key:"roughnessFactor",get:function(){var e;return null!=(e=this.gltfMaterial.roughnessFactor)?e:1}},{key:"normalTextureScale",get:function(){var e,t;return null!=(t=null==(e=this.gltfMaterial.normalTexture)?void 0:e.scale)?t:1}},{key:"occlusionTextureStrength",get:function(){var e,t;return null!=(t=null==(e=this.gltfMaterial.occlusionTexture)?void 0:e.strength)?t:1}},{key:"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]}}]),e}(),kn=function(){function e(){}return e.isUnlitMaterial=function(e){var t;return void 0!==(null==(t=e.extensions)?void 0:t.KHR_materials_unlit)},e.createBoxFromGLTFBound=function(e){var t=le.fromArray(e.box.min),n=le.fromArray(e.box.max);return new pe(t,n)},e}();U("model",mn,N);var Vn="2.7.4";D.info("Plugin model version: 2.7.4."),Vn!==e.version&&console.error("注意:请统一 Model 插件与 Player 版本,不统一的版本混用会有不可预知的后果!","\nAttention: Please ensure the Model plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");export{pt as AnimationComponent,pe as Box3,He as BoxMesh,Tn as CameraGestureHandlerImp,vn as CameraGestureType,kt as CheckerHelper,fe as Color,nn as CompositionCache,Mt as CompositionHitTest,Te as DEG2RAD,de as Euler,me as EulerOrder,ze as FBOOptions,Vt as Float16ArrayWrapper,Dt as GeometryBoxProxy,Bt as HitTestingProxy,Ue as HookOGLFunc,J as InterpolationSampler,bn as JSONConverter,_n as LoaderHelper,Rn as LoaderImpl,ue as Matrix3,he as Matrix4,Rt as MeshHelper,gt as ModelCameraComponent,mt as ModelLightComponent,ft as ModelMeshComponent,mn as ModelPlugin,gn as ModelPluginComponent,dt as ModelSkyboxComponent,yn as ModelTreeComponent,zt as PAnimInterpType,Ht as PAnimPathType,Jt as PAnimTexture,Se as PBRShaderGUID,re as PBlendMode,on as PCamera,an as PCameraManager,Me as PCoordinate,Ne as PEntity,oe as PFaceSideMode,hn as PGeometry,Ie as PGlobalState,sn as PLight,ln as PLightManager,te as PLightType,qt as PMaterialBase,Yt as PMaterialPBR,en as PMaterialSkyboxFilter,ie as PMaterialType,Zt as PMaterialUnlit,cn as PMesh,Wt as PMorph,we as PObject,ee as PObjectType,dn as PSceneManager,Xt as PShaderManager,ae as PShadowType,jt as PSkin,$t as PSkybox,tn as PSkyboxCreator,Qt as PSkyboxType,un as PSubMesh,ne as PTextureType,Ae as PTransform,Ot as PluginHelper,ge as Quaternion,ye as Ray,_t as RayBoxTesting,Tt as RayIntersectsBoxWithRotation,At as RayTriangleTesting,ve as Sphere,Lt as TextureDataMode,It as ToggleItemBounding,ht as TwoStatesSet,xe as UnlitShaderGUID,B as VFX_ITEM_TYPE_3D,se as Vector2,le as Vector3,ce as Vector4,Pt as VertexAttribBuffer,Et as WebGLHelper,Ft as WebHelper,K as createAnimationSampler,Kt as createPluginMaterial,Ye as fetchPBRShaderCode,Ke as fetchUnlitShaderCode,Nn as getDefaultEffectsGLTFLoader,Pn as getDefaultPBRMaterialData,Un as getDefaultUnlitMaterialData,it as getDiffuseOnlyShaderCode,st as getGaussianBlurShaderCodeV1,at as getGaussianBlurShaderCodeV2,Sn as getGeometryDataFromOptions,xn as getGeometryDataFromPropsList,rt as getKawaseBlurShaderCode,nt as getNormalVisShaderCode,Qe as getPBRPassShaderCode,On as getPBRShaderProperties,Ve as getPMeshList,tt as getQuadFilterShaderCode,ke as getRendererGPUInfo,pn as getSceneManager,$e as getShadowPassShaderCode,ot as getSimpleFilterShaderCode,et as getSkyBoxShaderCode,lt as getTransparecyBaseShader,ct as getTransparecyFilterShader,Fn as getUnlitShaderProperties,Ln as setDefaultEffectsGLTFLoader,Vn as version};
|
|
1
|
+
import*as e from"@galacean/effects/douyin";import{math as t,spec as n,Transform as i,PLAYER_OPTIONS_ENV_EDITOR as r,RenderPassAttachmentStorageType as o,glContext as a,Material as s,Mesh as l,Geometry as c,ShaderFactory as u,effectsClass as h,RendererComponent as f,Behaviour as d,HitTestType as m,AnimationClip as g,TextureSourceType as p,Texture as v,DestroyOptions as y,RenderPassDestroyAttachmentType as T,GLSLVersion as _,Player as b,Renderer as C,getDefaultTextureFactory as x,loadImage as S,generateGUID as A,addItem as M,removeItem as I,VFXItem as E,AbstractPlugin as w,glType2VertexFormatType as N,Downloader as L,getStandardJSON as R,isObject as O,registerPlugin as F,logger as U}from"@galacean/effects/douyin";var D="PluginModel";function P(e,t,n,i,r,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(i,r)}function B(e){return function(){var t=this,n=arguments;return new Promise((function(i,r){var o=e.apply(t,n);function a(e){P(o,i,r,a,s,"next",e)}function s(e){P(o,i,r,a,s,"throw",e)}a(void 0)}))}}function k(e,t){return k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},k(e,t)}function V(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&k(e,t)}function G(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):G(e,t)}function z(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function H(e,t){var n,i,r,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}"function"==typeof SuppressedError&&SuppressedError;var j=function(){function e(e,t,n){this.time=e,this.data=t,this.componentCount=n,this.cachedIndex=0}var t=e.prototype;return t.evaluate=function(e){var t=this.time,n=this.cachedIndex,i=t[n],r=t[n-1];e:{t:{var o;n:{i:if(!(e<i)){for(var a=n+2;;){if(void 0===i){if(e<r)break i;return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}if(n===a)break;if(r=i,e<(i=t[++n]))break t}o=t.length;break n}if(e>=r)break e;var s=t[1];e<s&&(n=2,r=s);for(var l=n-2;;){if(void 0===r)return this.cachedIndex=0,this.copySampleValue(0);if(n===l)break;if(i=r,e>=(r=t[--n-1]))break t}o=n,n=0}for(;n<o;){var c=n+o>>>1;e<t[c]?o=c:n=c+1}if(i=t[n],void 0===(r=t[n-1]))return this.cachedIndex=0,this.copySampleValue(0);if(void 0===i)return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}this.cachedIndex=n,this.intervalChanged(n,r,i)}return this.interpolate(n,r,e,i)},t.dispose=function(){this.time=void 0,this.data=void 0},t.copySampleValue=function(e){for(var t=this.data,n=this.componentCount,i=e*n,r=new Float32Array(n),o=0;o!==n;++o)r[o]=t[i+o];return r},e}(),W=function(e){function t(t,n,i){return e.call(this,t,n,i)}V(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,i){for(var r,o=this.data,a=null!=(r=this.componentCount)?r:1,s=e*a,l=s-a,c=(n-t)/(i-t),u=1-c,h=new Float32Array(a),f=0;f!==a;++f)h[f]=o[l+f]*u+o[s+f]*c;return h},t}(j),J=function(e){function t(t,n,i){return e.call(this,t,n,i)}V(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,i){for(var r,o=this.data,a=null!=(r=this.componentCount)?r:1,s=(e-1)*a,l=new Float32Array(a),c=0;c!==a;++c)l[c]=o[s+c];return l},t}(j),X=function(){function e(){}return e.slerpFlat=function(e,t,n,i,r,o,a){var s=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3],h=r[o+0],f=r[o+1],d=r[o+2],m=r[o+3];if(0===a)return e[t+0]=s,e[t+1]=l,e[t+2]=c,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]=m);if(u!==m||s!==h||l!==f||c!==d){var g=1-a,p=s*h+l*f+c*d+u*m,v=p>=0?1:-1,y=1-p*p;if(y>Number.EPSILON){var T=Math.sqrt(y),_=Math.atan2(T,p*v);g=Math.sin(g*_)/T,a=Math.sin(a*_)/T}var b=a*v;if(s=s*g+h*b,l=l*g+f*b,c=c*g+d*b,u=u*g+m*b,g===1-a){var C=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=C,l*=C,c*=C,u*=C}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u},e}(),q=function(e){function t(t,n,i){return e.call(this,t,n,i)}V(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,i){for(var r,o=this.data,a=null!=(r=this.componentCount)?r:1,s=(n-t)/(i-t),l=e*a,c=new Float32Array(a),u=l+a;l!==u;l+=4)X.slerpFlat(c,0,o,l-a,o,l,s);return c},t}(j);function Z(e,t,n,i,r){switch(e){case"LINEAR":return"rotation"===r?new q(t,n,i):new W(t,n,i);case"STEP":return new J(t,n,i);default:return new W(t,n,i)}}function Y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function K(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Y(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var Q,$,ee,te,ne,ie,re,oe=t.Vector2,ae=t.Vector3,se=t.Vector4,le=t.Matrix3,ce=t.Matrix4,ue=t.Color,he=t.Euler,fe=t.EulerOrder,de=t.Quaternion,me=t.Box3,ge=t.Sphere,pe=t.Ray,ve=t.DEG2RAD;function ye(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Te(e,t,n){return t&&ye(e.prototype,t),n&&ye(e,n),e}function _e(){return _e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},_e.apply(this,arguments)}!function(e){e[e.none=0]="none",e[e.mesh=1]="mesh",e[e.texture=2]="texture",e[e.material=3]="material",e[e.light=4]="light",e[e.camera=5]="camera",e[e.skybox=6]="skybox",e[e.skin=7]="skin",e[e.morph=8]="morph",e[e.skeleton=9]="skeleton",e[e.animation=10]="animation",e[e.animationManager=11]="animationManager",e[e.reference=12]="reference"}(Q||(Q={})),function(e){e[e.directional=0]="directional",e[e.point=1]="point",e[e.spot=2]="spot",e[e.ambient=3]="ambient"}($||($={})),function(e){e[e.none=0]="none",e[e.t2d=1]="t2d",e[e.t3d=2]="t3d",e[e.cube=3]="cube"}(ee||(ee={})),function(e){e[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"}(te||(te={})),function(e){e[e.opaque=0]="opaque",e[e.masked=1]="masked",e[e.translucent=2]="translucent",e[e.additive=3]="additive"}(ne||(ne={})),function(e){e[e.both=0]="both",e[e.front=1]="front",e[e.back=2]="back"}(ie||(ie={})),function(e){e[e.none=0]="none",e[e.standard=1]="standard",e[e.variance=2]="variance",e[e.expVariance=3]="expVariance"}(re||(re={}));var be=n.BuiltinObjectGUID.PBRShader,Ce=n.BuiltinObjectGUID.UnlitShader,xe=function(){function e(){this.translation=new ae(0,0,0),this.rotation=new de(0,0,0,1),this.scale=new ae(1,1,1)}var t=e.prototype;return t.fromMatrix4=function(e){return this.setMatrix(e),this},t.fromEffectsTransform=function(e){if(G(e,i))this.setMatrix(e.getWorldMatrix());else{var t=new i(_e({},e,{valid:!0}));t.setValid(!0),this.setMatrix(t.getWorldMatrix())}return this},t.toEffectsTransform=function(e){var t=this.getMatrix();return e.cloneFromMatrix(t),e},t.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},t.getTranslation=function(){return this.translation},t.setTranslation=function(e){G(e,ae)?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},t.getPosition=function(){return this.translation},t.setPosition=function(e){G(e,ae)?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},t.getRotation=function(){return this.rotation},t.setRotation=function(e){G(e,de)?this.rotation.set(e.x,e.y,e.z,e.w):G(e,he)?this.rotation.setFromEuler(e):G(e,ae)?this.rotation.setFromEuler(new he(e.x,e.y,e.z,fe.ZYX)):4===e.length?this.rotation.set(e[0],e[1],e[2],e[3]):this.rotation.setFromEuler(new he(e[0],e[1],e[2],fe.ZYX))},t.getScale=function(){return this.scale},t.setScale=function(e){G(e,ae)?this.scale.set(e.x,e.y,e.z):this.scale.set(e[0],e[1],e[2])},t.getMatrix=function(){return(new ce).compose(this.getTranslation(),this.getRotation(),this.getScale())},t.setMatrix=function(e){if(G(e,ce)){var t=e.getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}else{var n=ce.fromArray(e).getTransform();this.setTranslation(n.translation),this.setRotation(n.rotation),this.setScale(n.scale)}},e}(),Se=function(){function e(){this.origin=new ae(0,0,0),this.xAxis=new ae(1,0,0),this.yAxis=new ae(0,1,0),this.zAxis=new ae(0,0,1)}var t=e.prototype;return t.fromPTransform=function(e,t){void 0===t&&(t=!1),this.origin.copyFrom(e.getPosition());var n=e.getRotation().toMatrix4(new ce);return t&&n.invert(),this.fromRotationMatrix(n),this},t.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}(),Ae=function(){function e(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=r,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=n.RenderMode3D.none,this.renderMode3DUVGridSize=1/16}var t=e.prototype;return t.reset=function(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=r,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=n.RenderMode3D.none,this.renderMode3DUVGridSize=1/16},t.hasRenderMode3D=function(){return this.renderMode3D!==n.RenderMode3D.none},e.getInstance=function(){return this.instance||(this.instance=new this)},Te(e,[{key:"isEditorEnv",get:function(){return this.runtimeEnv===r}},{key:"isDeviceEnv",get:function(){return!this.isEditorEnv}},{key:"isTiny3dMode",get:function(){return"tiny3d"===this.compatibleMode}},{key:"isGLTFMode",get:function(){return!this.isTiny3dMode}}]),e}(),Me=1,Ie=function(){function e(){this.name="Unnamed Object",this.type=Q.none}var t=e.prototype;return t.dispose=function(){},t.isNone=function(){return this.type===Q.none},t.isValid=function(){return this.type!==Q.none},t.genName=function(e){return e+"_@"+Me++},e}(),Ee=function(e){function t(){var t;return(t=e.apply(this,arguments)||this)._visible=!1,t._transform=new xe,t.deleted=!1,t}V(t,e);var n=t.prototype;return n.update=function(){},n.render=function(e,t){},n.onVisibleChanged=function(e){this.visible=e},n.dispose=function(){e.prototype.dispose.call(this),this.visible=!1,this.deleted=!0},Te(t,[{key:"visible",get:function(){return this._visible&&this.isValid()},set:function(e){this._visible=e}},{key:"transform",get:function(){return this._transform},set:function(e){G(e,xe)?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))}},{key:"translation",get:function(){return this._transform.getTranslation()},set:function(e){this._transform.setTranslation(e)}},{key:"position",get:function(){return this._transform.getTranslation()},set:function(e){this._transform.setTranslation(e)}},{key:"rotation",get:function(){return this._transform.getRotation()},set:function(e){this._transform.setRotation(e)}},{key:"scale",get:function(){return this._transform.getScale()},set:function(e){this._transform.setScale(e)}},{key:"matrix",get:function(){return this._transform.getMatrix()},set:function(e){this._transform.setMatrix(e)}},{key:"coordinate",get:function(){var e=new Se;return e.fromPTransform(this._transform),e}}]),t}(Ie);function we(e,t){var n,i=e.attributes,r=_e({},e);if(r.indices)r.indices=_e({},r.indices),r.indices.data&&(r.indices.data=Le(t,null==(n=e.indices)?void 0:n.data));else if(r.index){var o;if(r.indices=_e({},r.index),r.indices.data)r.indices.data=Le(t,null==(o=e.index)?void 0:o.data)}return Object.keys(i).forEach((function(e){var n=i[e],o=n.data;r.attributes[e]=_e({},n),o&&(r.attributes[e].data=Le(t,o))})),r}var Ne={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,f32:Float32Array,i32:Int32Array,u32:Uint32Array};function Le(e,t){if(2!=t.length||t[0]!==n.ValueType.BINARY||!G(t[1],Array))return t;var i=t[1],r=i[0],o=i[1],a=i[2],s=i[3];if(!s)return e[r].slice(o,a);var l=Ne[s]||Uint8Array;return new l(e[r],o,a/l.BYTES_PER_ELEMENT)}var Re="_Native",Oe=new Map;function Fe(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+Re]=e[n],e[n]=De(e,n));console.info("HookCount "+t),function(e){for(var t in Object.getPrototypeOf(e))"number"==typeof e[t]&&Oe.set(e[t],t)}(e)}function Ue(e,t){for(var n=""+e,i=[],r=0;r<t.length;r++){var o;"number"==typeof t[r]&&Oe.has(t[r])?i.push(Oe.get(t[r])+"("+t[r]+")"):i.push(null==(o=t[r])?void 0:o.toString())}return n+(i.length>0?"("+i.join(", ")+")":"()")}function De(e,t){return function(){var n=e[t+Re].apply(this,arguments),i=e.getError();return i>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))?t:"UNKNOWN_ERROR")+"("+e+")"}(i)+" ===> "+Ue(t,arguments)),console.trace()):console.info(Ue(t,arguments)),n}}function Pe(e){var t=e.gpuCapability;return JSON.stringify(t,void 0,2)}function Be(e){var t=[],n=e.getCompositions()[0];return null==n||n.items.forEach((function(e){if(e.type===D){var n=e.getComponent(ut);(null==n?void 0:n.content.type)===Q.mesh&&t.push(n.content)}})),t}var ke,Ve=function(){function e(e){var t,n;this.resolution=null!=(t=e.resolution)?t:new oe(512,512),this.colorAttachments=null!=(n=e.colorAttachments)?n:[],this.depthAttachment=e.depthAttachment}var t=e.prototype;return t.addDepthAttachment=function(e){var t;this.depthAttachment={storageType:null!=(t=e.storageType)?t:o.depth_16_texture}},t.addDefaultDepthAttachment=function(){this.depthAttachment={storageType:o.depth_16_texture}},t.deleteDepthAttachment=function(){this.depthAttachment=void 0},t.addColorAttachment=function(e){var t,n,i,r;this.colorAttachments.push({texture:{format:null!=(t=e.format)?t:a.RGBA,type:null!=(n=e.type)?n:a.HALF_FLOAT,minFilter:null!=(i=e.filter)?i:a.LINEAR,magFilter:null!=(r=e.filter)?r:a.LINEAR}})},t.deleteColorAttachment=function(e){e>=0&&e<this.colorAttachments.length&&this.colorAttachments.splice(e,1)},Te(e,[{key:"viewport",get:function(){return[0,0,this.resolution.x,this.resolution.y]}}]),e}(),Ge=function(){function e(e,t){var n=s.create(e,{shader:{vertex:this.vertexShader,fragment:this.fragmentShader,shared:!0}});n.depthTest=!0,n.depthMask=!0,this.mesh=l.create(e,{name:"boxMesh",material:n,geometry:c.create(e,this.geometry),priority:t})}var t=e.prototype;return t.update=function(e,t,n,i){var r=this.mesh.material;r.setMatrix("effects_ObjectToWorld",e);for(var o=0;o<n.length;o+=3)r.setVector3("_PositionList["+o/3+"]",ae.fromArray(n,o));r.setVector3("_LineColor",i)},t.dispose=function(){this.mesh.dispose(),this.mesh=void 0},Te(e,[{key:"vertexShader",get:function(){return"\n precision highp float;\n\n uniform mat4 effects_ObjectToWorld;\n uniform mat4 effects_MatrixVP;\n uniform vec3 _PositionList[8];\n attribute vec3 aPos;\n void main(){\n int index = int(aPos.x + 0.5);\n vec4 pos = effects_ObjectToWorld * vec4(_PositionList[index], 1);\n gl_Position = effects_MatrixVP * pos;\n }\n "}},{key:"fragmentShader",get:function(){return"\n precision highp float;\n\n uniform vec3 _LineColor;\n void main(){\n gl_FragColor = vec4(_LineColor, 1);\n }\n "}},{key:"geometry",get:function(){var e=new Float32Array([0,1,2,3,4,5,6,7]),t=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:{aPos:{type:a.FLOAT,size:1,data:e,stride:Float32Array.BYTES_PER_ELEMENT,offset:0}},mode:a.LINES,indices:{data:t},drawStart:0,drawCount:24}}}]),e}(),ze="precision highp float;\n#define FEATURES\n#include <animation.vert.glsl>\nattribute vec4 aPos;varying vec3 v_Position;\n#ifdef HAS_NORMALS\nattribute vec4 aNormal;\n#endif\n#ifdef HAS_TANGENTS\nattribute vec4 aTangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 v_TBN;\n#else\nvarying vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nattribute vec2 aUV;\n#endif\n#ifdef HAS_UV_SET2\nattribute vec2 aUV2;\n#endif\nvarying vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nvarying vec2 v_UVCoord2;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nattribute vec3 aColor;varying vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nattribute vec4 aColor;varying vec4 v_Color;\n#endif\nuniform mat4 effects_MatrixVP;uniform mat4 effects_ObjectToWorld;uniform mat4 _NormalMatrix;\n#ifdef USE_SHADOW_MAPPING\nuniform mat4 _LightViewProjectionMatrix;uniform float _DeltaSceneSize;varying vec4 v_PositionLightSpace;varying vec4 v_dPositionLightSpace;\n#endif\nvec4 getPosition(){vec4 pos=vec4(aPos.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=aNormal;\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=aTangent;\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=effects_ObjectToWorld*getPosition();v_Position=vec3(pos.xyz)/pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec4 tangent=getTangent();vec3 normalW=normalize(vec3(_NormalMatrix*vec4(getNormal().xyz,0.0)));vec3 tangentW=normalize(vec3(effects_ObjectToWorld*vec4(tangent.xyz,0.0)));vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\n#else\nv_Normal=normalize(vec3(_NormalMatrix*vec4(getNormal().xyz,0.0)));\n#endif\n#endif\nv_UVCoord1=vec2(0.0,0.0);\n#ifdef HAS_UV_SET1\nv_UVCoord1=aUV;\n#endif\n#ifdef HAS_UV_SET2\nv_UVCoord2=aUV2;\n#endif\n#if defined(HAS_VERTEX_COLOR_VEC3) || defined(HAS_VERTEX_COLOR_VEC4)\nv_Color=aColor;\n#endif\n#ifdef USE_SHADOW_MAPPING\nv_PositionLightSpace=_LightViewProjectionMatrix*pos;vec3 dpos=vec3(_DeltaSceneSize);v_dPositionLightSpace=_LightViewProjectionMatrix*(pos+vec4(dpos,0));\n#endif\ngl_Position=effects_MatrixVP*pos;}",He="\n#define FEATURES\n#extension GL_OES_standard_derivatives : enable\n#if 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#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#include <extensions.frag.glsl>\n#include <tone-mapping.frag.glsl>\n#include <textures.vert.glsl>\n#include <functions.frag.glsl>\n#include <shadow-common.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 _Lights[LIGHT_COUNT];\n#endif\n#if defined(MATERIAL_SPECULARGLOSSINESS) || defined(MATERIAL_METALLICROUGHNESS)\nuniform float _MetallicFactor;uniform float _RoughnessFactor;uniform vec4 _BaseColorFactor;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\nuniform vec3 _SpecularFactor;uniform vec4 _DiffuseFactor;uniform float _GlossinessFactor;\n#endif\n#ifdef ALPHAMODE_MASK\nuniform float _AlphaCutoff;\n#endif\n#ifdef ADD_FOG\nuniform vec4 _FogColor;\n#ifdef LINEAR_FOG\nuniform float _FogNear;uniform float _FogFar;\n#endif\n#ifdef EXP_FOG\nuniform float _FogDensity;\n#endif\n#endif\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\nuniform vec3 _Camera;uniform int _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=_Camera-v_Position;float fogAmount=0.0;\n#ifdef LINEAR_FOG\nfogAmount=smoothstep(_FogNear,_FogFar,distance[2]);\n#endif\n#ifdef EXP_FOG\n#define LOG2 1.442695\nfogAmount=1.-exp2(-_FogDensity*_FogDensity*distance[2]*distance[2]*LOG2);fogAmount=clamp(fogAmount,0.,1.);\n#endif\nvec3 mixColor=baseColor.rgb+(vec3(_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(_MipCount),0.0,float(_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(_brdfLUT,brdfSamplePoint).rg;vec4 diffuseColor=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,_shCoefficients);diffuseColor=vec4(irradiance,1.0);\n#else\ndiffuseColor=textureCube(_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(_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*_IblIntensity[0]+specular*_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 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\ngl_FragColor=uPreviewColor;return;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nvec4 sgSample=SRGBtoLINEAR(texture2D(_SpecularGlossinessSampler,getSpecularGlossinessUV()));perceptualRoughness=(1.0-sgSample.a*_GlossinessFactor);f0=sgSample.rgb*_SpecularFactor;\n#else\nf0=_SpecularFactor;perceptualRoughness=1.0-_GlossinessFactor;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nbaseColor=SRGBtoLINEAR(texture2D(_DiffuseSampler,getDiffuseUV()))*_DiffuseFactor;\n#else\nbaseColor=SRGBtoLINEAR(_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(_MetallicRoughnessSampler,getMetallicRoughnessUV());perceptualRoughness=mrSample.g*_RoughnessFactor;metallic=mrSample.b*_MetallicFactor;\n#else\nmetallic=_MetallicFactor;perceptualRoughness=_RoughnessFactor;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nbaseColor=SRGBtoLINEAR(texture2D(_BaseColorSampler,getBaseColorUV()))*_BaseColorFactor;\n#else\nbaseColor=SRGBtoLINEAR(_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<_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\ngl_FragColor=fragColorUnlit;\n#else\n#ifdef DEBUG_UV\ngl_FragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),getNormal()));\n#endif\n#ifdef DEBUG_METALLIC\ngl_FragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\ngl_FragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\ngl_FragColor.rgb=getNormal()*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\ngl_FragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\ngl_FragColor.rgb=vec3(1.0);\n#endif\n#ifdef DEBUG_EMISSIVE\ngl_FragColor.rgb=vec3(0.0);\n#endif\n#ifdef DEBUG_ALPHA\ngl_FragColor.rgb=vec3(baseColor.a);\n#endif\ngl_FragColor.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(_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=_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(_OcclusionSampler,getOcclusionUV()).r;color=mix(color,color*ao,_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+=_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb*_EmissiveIntensity;color+=emissive;\n#endif\nvec4 fragColorOut=vec4(color,baseColor.a);\n#endif\ngl_FragColor=fragColorOut;\n#else\n#ifdef DEBUG_UV\ngl_FragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),normal));\n#endif\n#ifdef DEBUG_METALLIC\ngl_FragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\ngl_FragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\ngl_FragColor.rgb=normal*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\ngl_FragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\n#ifdef HAS_OCCLUSION_MAP\ngl_FragColor.rgb=vec3(mix(1.0,ao,_OcclusionStrength));\n#else\ngl_FragColor.rgb=vec3(1.0);\n#endif\n#endif\n#ifdef DEBUG_EMISSIVE\n#ifdef HAS_EMISSIVE\nemissive=_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\ngl_FragColor.rgb=LINEARtoSRGB(emissive);\n#endif\n#ifdef DEBUG_F0\ngl_FragColor.rgb=vec3(f0);\n#endif\n#ifdef DEBUG_ALPHA\ngl_FragColor.rgb=vec3(baseColor.a);\n#endif\n#ifdef DEBUG_DIFFUSE\nvec3 debugDiffuse=vec3(0.0);\n#ifdef USE_PUNCTUAL\nMaterialInfo diffuseMaterialInfo=MaterialInfo(1.0,f0,1.0,vec3(0.35),f0,f0);for(int i=0;i<LIGHT_COUNT;++i){Light light=_Lights[i];if(light.type==LightType_Directional){debugDiffuse+=applyDirectionalLight(light,diffuseMaterialInfo,normal,view,shadow);}else if(light.type==LightType_Point){debugDiffuse+=applyPointLight(light,diffuseMaterialInfo,normal,view);}else if(light.type==LightType_Spot){debugDiffuse+=applySpotLight(light,diffuseMaterialInfo,normal,view,shadow);}else if(light.type==LightType_Ambient){debugDiffuse+=applyAmbientLight(light,diffuseMaterialInfo);}}\n#ifdef USE_IBL\ndebugDiffuse+=getIBLContribution(diffuseMaterialInfo,normal,view);\n#endif\n#endif\ngl_FragColor.rgb=toneMap(debugDiffuse);\n#endif\ngl_FragColor.a=1.0;\n#endif\n}",je="#define FEATURES\n#include <shadow-common.vert.glsl>\n#if defined(SHADOWMAP_VSM)\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\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)\ngl_FragColor=CalcMomentVSM(gl_FragCoord.z);\n#else\ngl_FragColor=CalcMomentEVSM(gl_FragCoord.z);\n#endif\n}",We="precision highp float;\n#define FEATURES\nattribute vec3 aPos;varying vec3 v_CameraDir;uniform mat4 _InvViewProjectionMatrix;void main(){vec4 dir=_InvViewProjectionMatrix*vec4(aPos.xy,1,1);v_CameraDir=normalize(dir.xyz/dir.w);gl_Position=vec4(aPos.xy,0.99999,1);}",Je="\n#define FEATURES\n#if defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#extension GL_OES_standard_derivatives : enable\nprecision highp float;\n#include <extensions.frag.glsl>\nuniform sampler2D _brdfLUT;uniform vec2 _IblIntensity;uniform int _MipCount;uniform samplerCube _DiffuseEnvSampler;uniform samplerCube _SpecularEnvSampler;varying vec3 v_CameraDir;\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients _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(_MipCount),0.0,float(_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(_brdfLUT,brdfSamplePoint).rg;vec4 diffuseSample=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,_shCoefficients);diffuseSample=vec4(irradiance,1.0);\n#else\ndiffuseSample=textureCube(_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(_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*_IblIntensity[0]+specular*_IblIntensity[1];}void main(){vec3 dir=normalize(v_CameraDir);gl_FragColor=vec4(getIBLContribution(dir,dir),1.0);}";!function(e){e.build=function(e,t){return e=e.replace(/#define FEATURES/,t.map((function(e){return"#define "+e})).join("\n"))}}(ke||(ke={})),u.registerInclude("animation.vert.glsl","#ifdef HAS_TARGET_POSITION0\nattribute vec3 aTargetPosition0;\n#endif\n#ifdef HAS_TARGET_POSITION1\nattribute vec3 aTargetPosition1;\n#endif\n#ifdef HAS_TARGET_POSITION2\nattribute vec3 aTargetPosition2;\n#endif\n#ifdef HAS_TARGET_POSITION3\nattribute vec3 aTargetPosition3;\n#endif\n#ifdef HAS_TARGET_POSITION4\nattribute vec3 aTargetPosition4;\n#endif\n#ifdef HAS_TARGET_POSITION5\nattribute vec3 aTargetPosition5;\n#endif\n#ifdef HAS_TARGET_POSITION6\nattribute vec3 aTargetPosition6;\n#endif\n#ifdef HAS_TARGET_POSITION7\nattribute vec3 aTargetPosition7;\n#endif\n#ifdef HAS_TARGET_NORMAL0\nattribute vec3 aTargetNormal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nattribute vec3 aTargetNormal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nattribute vec3 aTargetNormal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nattribute vec3 aTargetNormal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nattribute vec3 aTargetNormal4;\n#endif\n#ifdef HAS_TARGET_TANGENT0\nattribute vec3 aTargetTangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\nattribute vec3 aTargetTangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\nattribute vec3 aTargetTangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\nattribute vec3 aTargetTangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\nattribute vec3 aTargetTangent4;\n#endif\n#ifdef USE_MORPHING\nuniform float _morphWeights[WEIGHT_COUNT];\n#endif\n#ifdef HAS_JOINT_SET1\nattribute vec4 aJoints;\n#endif\n#ifdef HAS_JOINT_SET2\nattribute vec4 aJoint2;\n#endif\n#ifdef HAS_WEIGHT_SET1\nattribute vec4 aWeights;\n#endif\n#ifdef HAS_WEIGHT_SET2\nattribute vec4 aWeight2;\n#endif\n#ifdef USE_SKINNING\n#ifdef USE_SKINNING_TEXTURE\nuniform sampler2D _jointMatrixSampler;uniform sampler2D _jointNormalMatrixSampler;\n#else\nuniform mat4 _jointMatrix[JOINT_COUNT];uniform mat4 _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(_jointMatrixSampler,vec2(ROW0_U,v)),texture2D(_jointMatrixSampler,vec2(ROW1_U,v)),texture2D(_jointMatrixSampler,vec2(ROW2_U,v)),texture2D(_jointMatrixSampler,vec2(ROW3_U,v)));\n#else\nreturn _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(_jointNormalMatrixSampler,vec2(ROW0_U,v)),texture2D(_jointNormalMatrixSampler,vec2(ROW1_U,v)),texture2D(_jointNormalMatrixSampler,vec2(ROW2_U,v)),texture2D(_jointNormalMatrixSampler,vec2(ROW3_U,v)));\n#else\nreturn _jointNormalMatrix[int(boneNdx)];\n#endif\n}mat4 getSkinningMatrix(){mat4 skin=mat4(0);\n#if defined(HAS_WEIGHT_SET1) && defined(HAS_JOINT_SET1)\nskin+=aWeights.x*getJointMatrix(aJoints.x)+aWeights.y*getJointMatrix(aJoints.y)+aWeights.z*getJointMatrix(aJoints.z)+aWeights.w*getJointMatrix(aJoints.w);\n#endif\nreturn skin;}mat4 getSkinningNormalMatrix(){mat4 skin=mat4(0);\n#if defined(HAS_WEIGHT_SET1) && defined(HAS_JOINT_SET1)\nskin+=aWeights.x*getJointNormalMatrix(aJoints.x)+aWeights.y*getJointNormalMatrix(aJoints.y)+aWeights.z*getJointNormalMatrix(aJoints.z)+aWeights.w*getJointNormalMatrix(aJoints.w);\n#endif\nreturn skin;}\n#endif\n#ifdef USE_MORPHING\nvec4 getTargetPosition(){vec4 pos=vec4(0);\n#ifdef HAS_TARGET_POSITION0\npos.xyz+=_morphWeights[0]*aTargetPosition0;\n#endif\n#ifdef HAS_TARGET_POSITION1\npos.xyz+=_morphWeights[1]*aTargetPosition1;\n#endif\n#ifdef HAS_TARGET_POSITION2\npos.xyz+=_morphWeights[2]*aTargetPosition2;\n#endif\n#ifdef HAS_TARGET_POSITION3\npos.xyz+=_morphWeights[3]*aTargetPosition3;\n#endif\n#ifdef HAS_TARGET_POSITION4\npos.xyz+=_morphWeights[4]*aTargetPosition4;\n#endif\nreturn pos;}vec4 getTargetNormal(){vec4 normal=vec4(0);\n#ifdef HAS_TARGET_NORMAL0\nnormal.xyz+=_morphWeights[0]*aTargetNormal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nnormal.xyz+=_morphWeights[1]*aTargetNormal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nnormal.xyz+=_morphWeights[2]*aTargetNormal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nnormal.xyz+=_morphWeights[3]*aTargetNormal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nnormal.xyz+=_morphWeights[4]*aTargetNormal4;\n#endif\nreturn normal;}vec4 getTargetTangent(){vec4 tangent=vec4(0);\n#ifdef HAS_TARGET_TANGENT0\ntangent.xyz+=_morphWeights[0]*aTargetTangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\ntangent.xyz+=_morphWeights[1]*aTargetTangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\ntangent.xyz+=_morphWeights[2]*aTargetTangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\ntangent.xyz+=_morphWeights[3]*aTargetTangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\ntangent.xyz+=_morphWeights[4]*aTargetTangent4;\n#endif\nreturn tangent;}\n#endif\n"),u.registerInclude("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"),u.registerInclude("tone-mapping.frag.glsl","uniform float _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*=_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);}"),u.registerInclude("textures.vert.glsl","varying vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nvarying vec2 v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D _NormalSampler;uniform float _NormalScale;uniform int _NormalUVSet;uniform mat3 _NormalUVTransform;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D _EmissiveSampler;uniform int _EmissiveUVSet;uniform vec4 _EmissiveFactor;uniform float _EmissiveIntensity;uniform mat3 _EmissiveUVTransform;\n#endif\n#ifdef HAS_EMISSIVE\nuniform vec4 _EmissiveFactor;uniform float _EmissiveIntensity;\n#endif\n#ifdef HAS_OCCLUSION_MAP\nuniform sampler2D _OcclusionSampler;uniform int _OcclusionUVSet;uniform float _OcclusionStrength;uniform mat3 _OcclusionUVTransform;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nuniform sampler2D _BaseColorSampler;uniform int _BaseColorUVSet;uniform mat3 _BaseColorUVTransform;\n#endif\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nuniform sampler2D _MetallicRoughnessSampler;uniform int _MetallicRoughnessUVSet;uniform mat3 _MetallicRoughnessUVTransform;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D _DiffuseSampler;uniform int _DiffuseUVSet;uniform mat3 _DiffuseUVTransform;\n#endif\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nuniform sampler2D _SpecularGlossinessSampler;uniform int _SpecularGlossinessUVSet;uniform mat3 _SpecularGlossinessUVTransform;\n#endif\n#ifdef USE_IBL\nuniform samplerCube _DiffuseEnvSampler;uniform samplerCube _SpecularEnvSampler;uniform sampler2D _brdfLUT;uniform vec2 _IblIntensity;\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients _shCoefficients;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform sampler2D _ShadowSampler;\n#endif\nvec2 getNormalUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_NORMAL_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_NormalUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_UV_TRANSFORM\nuv*=_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=_EmissiveUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_EMISSIVE_UV_TRANSFORM\nuv*=_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=_OcclusionUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_OCCLUSION_UV_TRANSFORM\nuv*=_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=_BaseColorUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_BASECOLOR_UV_TRANSFORM\nuv*=_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=_MetallicRoughnessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_METALLICROUGHNESS_UV_TRANSFORM\nuv*=_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=_SpecularGlossinessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_UV_TRANSFORM\nuv*=_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=_DiffuseUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_DIFFUSE_UV_TRANSFORM\nuv*=_DiffuseUVTransform;\n#endif\n#endif\nreturn uv.xy;}"),u.registerInclude("functions.frag.glsl","const float M_PI=3.141592653589793;const float c_MinReflectance=0.04;varying vec3 v_Position;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 v_TBN;\n#else\nvarying vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nvarying vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nvarying 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(_NormalSampler,UV).rgb;n=normalize(tbn*((2.0*n-1.0)*vec3(_NormalScale,_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 _DebugUVGridSize;float getDebugUVColor(vec2 uv,vec3 n){float s=dot(abs(n),vec3(1,1,1))*0.6;uv=uv/(_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"),u.registerInclude("shadow.frag.glsl","#ifdef USE_SHADOW_MAPPING\nuniform vec2 _ShadowMapSizeInv;varying vec4 v_PositionLightSpace;varying 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(_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(_ShadowSampler,coords.xy).xy;return chebyshev(moments,coords.z,0.00002);}float computeEVSMShadow(vec2 coords,float pos,float neg){vec4 moments=texture2D(_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),_ShadowMapSizeInv);if(max(dCoords.x,dCoords.y)>=min(_ShadowMapSizeInv.x,_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"),u.registerInclude("shadow-common.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");var Xe=function(){function e(){}return e.getVertexShaderCode=function(e){var t=e.featureList,n=e.material.materialType;switch(n){case te.unlit:case te.pbr:case te.shadowBase:return ke.build(ze,t);case te.skyboxFilter:return ke.build(We,t);default:throw new Error("Invalid material type "+n+" for getVertexShaderString!")}},e.getFragmentShaderCode=function(e){var t=e.featureList,n=e.material.materialType;switch(n){case te.unlit:case te.pbr:return ke.build(He,t);case te.shadowBase:return ke.build(je,t);case te.skyboxFilter:return ke.build(Je,t);default:throw new Error("Invalid material type "+n+" for getFragmentShaderString!")}},e.genVertexShaderCode=function(e){switch(e){case te.unlit:case te.pbr:case te.shadowBase:return ze;case te.skyboxFilter:return We;default:throw new Error("Invalid material type "+e+" for genVertexShaderCode!")}},e.genFragmentShaderCode=function(e){switch(e){case te.unlit:case te.pbr:return He;case te.shadowBase:return je;case te.skyboxFilter:return Je;default:throw new Error("Invalid material type "+e+" for genFragmentShaderCode!")}},e}();function qe(){return{vertexShaderCode:Xe.genVertexShaderCode(te.pbr),fragmentShaderCode:Xe.genFragmentShaderCode(te.pbr)}}function Ze(){return{vertexShaderCode:Xe.genVertexShaderCode(te.unlit),fragmentShaderCode:Xe.genFragmentShaderCode(te.unlit)}}function Ye(e){return{vertexShaderCode:Xe.getVertexShaderCode(e),fragmentShaderCode:Xe.getFragmentShaderCode(e)}}function Ke(e){return{vertexShaderCode:Xe.getVertexShaderCode(e),fragmentShaderCode:Xe.getFragmentShaderCode(e)}}function Qe(e){return{vertexShaderCode:Xe.getVertexShaderCode(e),fragmentShaderCode:Xe.getFragmentShaderCode(e)}}function $e(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform sampler2D _ColorSampler;\n\n varying vec2 v_UVCoord1;\n void main(){\n gl_FragColor = texture2D(_ColorSampler, v_UVCoord1);\n }\n "}}function et(e){return{vertexShaderCode:lt({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 tt(e){return{vertexShaderCode:lt({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 "}}function nt(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform float _Offset;\n uniform vec2 _TextureSizeInv;\n uniform sampler2D _TexturSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0.0);\n color += texture2D(_TexturSampler, v_UVCoord1 + vec2(-_Offset-0.5,-_Offset-0.5) * _TextureSizeInv);\n color += texture2D(_TexturSampler, v_UVCoord1 + vec2(-_Offset-0.5, _Offset+0.5) * _TextureSizeInv);\n color += texture2D(_TexturSampler, v_UVCoord1 + vec2( _Offset+0.5,-_Offset-0.5) * _TextureSizeInv);\n color += texture2D(_TexturSampler, v_UVCoord1 + vec2( _Offset+0.5, _Offset+0.5) * _TextureSizeInv);\n gl_FragColor = color * 0.25;\n }\n "}}function it(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform sampler2D _FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n gl_FragColor = texture2D(_FilterSampler, v_UVCoord1) * vec4(0.5);\n }\n "}}function rt(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform vec2 _BlurScale;\n uniform sampler2D _FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0);\n vec2 offset0 = vec2(0.53805) * _BlurScale.xy;\n vec2 offset1 = vec2(2.06278) * _BlurScale.xy;\n color += (texture2D(_FilterSampler, v_UVCoord1 + offset0) + texture2D(_FilterSampler, v_UVCoord1 - offset0)) * 0.44908;\n color += (texture2D(_FilterSampler, v_UVCoord1 + offset1) + texture2D(_FilterSampler, v_UVCoord1 - offset1)) * 0.05092;\n gl_FragColor = color;\n }\n "}}function ot(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform vec2 _BlurScale;\n uniform sampler2D _FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(-3.0) * _BlurScale.xy)) * (1.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(-2.0) * _BlurScale.xy)) * (6.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(-1.0) * _BlurScale.xy)) * (15.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(+0.0) * _BlurScale.xy)) * (20.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(+1.0) * _BlurScale.xy)) * (15.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(+2.0) * _BlurScale.xy)) * (6.0/64.0);\n color += texture2D(_FilterSampler, v_UVCoord1 + (vec2(+3.0) * _BlurScale.xy)) * (1.0/64.0);\n gl_FragColor = color;\n }\n "}}function at(e){return e?lt({hasNormals:!0}):"\n #version 100\n #extension GL_EXT_draw_buffers: require\n\n precision highp float;\n uniform vec4 _BaseColorFactor;\n\n #ifdef HAS_UVS\n uniform sampler2D _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 = _BaseColorFactor;\n\n #ifdef HAS_UVS\n color *= texture2D(_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 "}function st(e){return e?"\n #version 100\n precision highp float;\n attribute vec3 aPos;\n attribute vec2 aUV;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = aUV;\n gl_Position = vec4(aPos.xy, 0.0, 1.0);\n }\n ":"\n #version 100\n precision highp float;\n uniform sampler2D _AccumColorSampler;\n uniform sampler2D _AccumAlphaSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 accumColor = texture2D(_AccumColorSampler, v_UVCoord1);\n vec4 accumAlpha = texture2D(_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 "}function lt(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 effects_ObjectToWorld;\n uniform mat4 effects_MatrixVP;\n attribute vec3 aPos;\n varying vec3 v_Position;\n\n #ifdef HAS_UVS\n attribute vec2 aUV;\n varying vec2 v_UVCoord1;\n #endif\n\n #ifdef HAS_NORMALS\n uniform mat4 _NormalMatrix;\n attribute vec3 aNormal;\n varying vec3 v_Normal;\n #endif\n\n void main(){\n vec4 pos = effects_ObjectToWorld * vec4(aPos, 1);\n v_Position = pos.xyz / pos.w;\n\n #ifdef HAS_UVS\n v_UVCoord1 = aUV;\n #endif\n\n #ifdef HAS_NORMALS\n v_Normal = normalize(vec3(effects_ObjectToWorld * vec4(aNormal, 0)));\n #endif\n\n gl_Position = effects_MatrixVP * pos;\n }\n "),t.join("\n")}Xe.environment="webgl1";var ct=function(){function e(){this.now=new Set,this.last=new Set}var t=e.prototype;return t.clear=function(){this.now.clear(),this.last.clear()},t.forward=function(){var e=this.last;this.last=this.now,this.now=e,this.now.clear()},t.forAddedItem=function(e){var t=this;this.now.forEach((function(n){t.last.has(n)||e(n)}))},t.forRemovedItem=function(e){var t=this;this.last.forEach((function(n){t.now.has(n)||e(n)}))},t.forNowItem=function(e){this.now.forEach((function(t){e(t)}))},e}(),ut=function(e){function t(t,i){var r;return(r=e.call(this,t)||this).morphWeights=[],r.getHitTestParams=function(e){r.computeBoundingBox();var t=r.bounding;if(t&&(e||Number.isInteger(t.behavior))){var i=t.type;if(i===n.ModelBoundingType.box){if(G(r.content,sn)){var o=r.content;return{behavior:t.behavior,type:m.custom,collect:function(e,t){return o.hitTesting(e.origin,e.direction)}}}var a=r.transform.getWorldMatrix();return{behavior:t.behavior,type:m.custom,collect:function(e,n){return vt(e,a,t)}}}if(i===n.ModelBoundingType.sphere){var s=new ae;r.transform.assignWorldTRS(s);var l=new ae;return t.center&&l.setFromArray(t.center),l.add(s),{type:i,behavior:t.behavior,radius:t.radius||0,center:l}}}},i&&r.fromData(i),r}V(t,e);var i=t.prototype;return i.onStart=function(){var e;this.sceneManager=mn(this),this.createContent(),this.item.type=D,this.priority=this.item.renderOrder,null==(e=this.sceneManager)||e.addItem(this.content),this.item.parentId&&this.item.parent&&this.content.updateParentInfo(this.item.parentId,this.item.parent),this.setVisible(!0),this.item.getHitTestParams=this.getHitTestParams},i.onUpdate=function(e){this.sceneManager&&this.content.build(this.sceneManager),this.content.update()},i.onLateUpdate=function(e){this.content.lateUpdate()},i.render=function(e){this.getVisible()&&this.sceneManager&&this.content.render(this.sceneManager,e)},i.onDestroy=function(){var e;null==(e=this.sceneManager)||e.removeItem(this.content),this.sceneManager=void 0,this.content.dispose()},i.fromData=function(t){if(e.prototype.fromData.call(this,t),this.data=_e({},t,{materials:[]}),this.data.rootBone=t.rootBone?this.engine.findObject(t.rootBone):void 0,this.data.geometry=this.engine.findObject(t.geometry),t.materials)for(var n=0;n<t.materials.length;n++)this.data.materials[n]=this.engine.findObject(t.materials[n])},i.createContent=function(){if(this.data){var e=this.data.interaction;this.bounding=e&&JSON.parse(JSON.stringify(e)),this.content=new sn(this.engine,this.item.name,this.data,this,this.item.parentId)}},i.setVisible=function(e){var t;null==(t=this.content)||t.onVisibleChanged(e)},i.getVisible=function(){var e,t;return null!=(t=null==(e=this.content)?void 0:e.visible)&&t},i.computeBoundingBox=function(){if(this.content&&G(this.content,sn)){var e,t=this.transform.getWorldMatrix(),i=this.content.computeBoundingBox(t),r=i.getCenter(new ae),o=i.getSize(new ae);return this.bounding={behavior:null==(e=this.bounding)?void 0:e.behavior,type:n.ModelBoundingType.box,center:[r.x,r.y,r.z],size:[o.x,o.y,o.z]},this.bounding}},t}(f);ut=z([h(n.DataType.MeshComponent)],ut);var ht=function(e){function t(t,n){var i;return i=e.call(this,t)||this,n&&i.fromData(n),i}V(t,e);var n=t.prototype;return n.onStart=function(){var e;this.createContent(),this.item.type=D,this.priority=this.item.renderOrder,this.sceneManager=mn(this),null==(e=this.sceneManager)||e.addItem(this.content),this.setVisible(!0)},n.render=function(e){this.getVisible()&&this.sceneManager&&this.content.render(this.sceneManager,e)},n.onDestroy=function(){var e;null==(e=this.sceneManager)||e.removeItem(this.content),this.sceneManager=void 0,this.content.dispose()},n.fromData=function(t){e.prototype.fromData.call(this,t),t.diffuseImage=t.diffuseImage?this.engine.findObject(t.diffuseImage):void 0,t.specularImage=this.engine.findObject(t.specularImage),this.data=t},n.createContent=function(){if(this.data){var e=this.data;this.content=new Kt(this.item.name,e,this)}},n.setVisible=function(e){var t;null==(t=this.content)||t.onVisibleChanged(e)},n.getVisible=function(){var e,t;return null!=(t=null==(e=this.content)?void 0:e.visible)&&t},t}(f);ht=z([h(n.DataType.SkyboxComponent)],ht);var ft=function(e){function t(t,n){var i;return i=e.call(this,t)||this,n&&i.fromData(n),i}V(t,e);var n=t.prototype;return n.onStart=function(){this.createContent(),this.item.type=D;var e=mn(this);null==e||e.addItem(this.content),this.setVisible(!0)},n.onUpdate=function(e){this.content.update()},n.onDestroy=function(){this.content.dispose()},n.fromData=function(t){e.prototype.fromData.call(this,t),this.data=t},n.createContent=function(){if(this.data){var e=this.data;this.content=new on(this.item.name,e,this)}},n.setVisible=function(e){var t;null==(t=this.content)||t.onVisibleChanged(e)},n.getVisible=function(){var e,t;return null!=(t=null==(e=this.content)?void 0:e.visible)&&t},t}(d);ft=z([h(n.DataType.LightComponent)],ft);var dt=function(e){function t(t,n){var i;return i=e.call(this,t)||this,n&&i.fromData(n),i}V(t,e);var n=t.prototype;return n.onStart=function(){this.createContent(),this.item.type=D;var e=mn(this);null==e||e.addItem(this.content),this.updateMainCamera()},n.onUpdate=function(e){this.content.update(),this.updateMainCamera()},n.onDestroy=function(){var e;null==(e=this.content)||e.dispose()},n.fromData=function(t){e.prototype.fromData.call(this,t),this.data=t},n.createContent=function(){if(this.data){var e=this.data,t=this.engine.renderer.getWidth(),n=this.engine.renderer.getHeight();this.content=new nn(this.item.name,t,n,e,this)}},n.updateMainCamera=function(){this.content.matrix=this.transform.getWorldMatrix();var e=this.item.composition;e&&(e.camera.near=this.content.nearPlane,e.camera.far=this.content.farPlane,e.camera.fov=this.content.fov,e.camera.setTransform(this.transform))},n.setTransform=function(e,t){e&&this.transform.setPosition(e.x,e.y,e.z),t&&this.transform.setRotation(t.x,t.y,t.z),this.updateMainCamera()},t}(d);dt=z([h(n.DataType.CameraComponent)],dt);var mt=function(e){function t(t){var n;return(n=e.call(this,t)||this).elapsedTime=0,n.animation=-1,n.clips=[],n}V(t,e);var n=t.prototype;return n.onStart=function(){this.elapsedTime=0,this.item.type=D},n.onUpdate=function(e){this.elapsedTime+=.001*e,this.animation>=0&&this.animation<this.clips.length&&this.clips[this.animation].sampleAnimation(this.item,this.elapsedTime)},n.onDestroy=function(){},n.fromData=function(t){var n,i,r=this;e.prototype.fromData.call(this,t),this.data=t,this.name=null!=(n=t.name)?n:"<empty>",this.animation=null!=(i=t.animation)?i:-1,this.clips=[],t.animationClips.forEach((function(e){var t=new gt(r.engine),n=r.engine.findObject(e);t.setFromAnimationClip(n),r.clips.push(t)}))},t}(d);mt=z([h(n.DataType.AnimationComponent)],mt);var gt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).path2Node={},t}V(t,e);var n=t.prototype;return n.sampleAnimation=function(e,t){for(var n,i=this.duration,r=Math.max(0,t)%i,o=K(this.positionCurves);!(n=o()).done;){var a=n.value,s=a.keyFrames.getValue(r%this.duration),l=this.getTargetItem(e,a.path);null==l||l.transform.setPosition(s.x,s.y,s.z)}for(var c,u=K(this.rotationCurves);!(c=u()).done;){var h=c.value,f=h.keyFrames.getValue(r%this.duration),d=this.getTargetItem(e,h.path);null==d||d.transform.setQuaternion(f.x,f.y,f.z,f.w)}for(var m,g=K(this.scaleCurves);!(m=g()).done;){var p=m.value,v=p.keyFrames.getValue(r%this.duration),y=this.getTargetItem(e,p.path);null==y||y.transform.setScale(v.x,v.y,v.z)}for(var T,_=K(this.floatCurves);!(T=_()).done;){var b=T.value,C=b.keyFrames.getValue(r%this.duration),x=this.getTargetItem(e,b.path);if("ModelMeshComponent"===b.className){var S=null==x?void 0:x.getComponent(ut);if(S)pt(S,b.property.split("."),C);else console.error("Can't find mesh component.")}else console.warn("Ignore curve: className "+b.className+".")}},n.setFromAnimationClip=function(e){this.duration=e.duration,this.positionCurves=e.positionCurves.slice(),this.rotationCurves=e.rotationCurves.slice(),this.scaleCurves=e.scaleCurves.slice(),this.floatCurves=e.floatCurves.slice()},n.getTargetItem=function(e,t){if(this.path2Node[t])return this.path2Node[t];for(var n,i=e,r=K(t.split("/"));!(n=r()).done;){for(var o,a=n.value,s=!1,l=K(i.children);!(o=l()).done;){var c=o.value;if(c.name===a){i=c,s=!0;break}}if(!s)throw new Error("Can't find path in tree "+e.id+", "+t+".")}return this.path2Node[t]=i,i},t}(g);function pt(e,t,n){for(var i=t.length,r=e,o=0;o<i-1;o++){var a=t[o];if(!(a in r)||"object"!=typeof r[a])return void console.error("Invalid properties "+t+".");r=r[a]}r[t[i-1]]=n}function vt(e,t,n){var i=t,r=i.clone().invert(),o=e.clone().applyMatrix(r),a=ae.fromArray(n.center),s=ae.fromArray(n.size).multiply(.5),l=a.clone().subtract(s),c=a.clone().add(s),u=o.intersectBox({min:l,max:c},new ae);return void 0!==u?[i.transformPoint(u)]:void 0}function yt(e,t,n,i){var r=0,o=0,a=0,s=0,l=0,c=0,u=1/t.x,h=1/t.y,f=1/t.z;if(u>=0?(r=(n.x-e.x)*u,o=(i.x-e.x)*u):(r=(i.x-e.x)*u,o=(n.x-e.x)*u),h>=0?(a=(n.y-e.y)*h,s=(i.y-e.y)*h):(a=(i.y-e.y)*h,s=(n.y-e.y)*h),!(r>s||a>o||((a>r||r!=r)&&(r=a),(s<o||o!=o)&&(o=s),f>=0?(l=(n.z-e.z)*f,c=(i.z-e.z)*f):(l=(i.z-e.z)*f,c=(n.z-e.z)*f),r>c||l>o||((l>r||r!=r)&&(r=l),(c<o||o!=o)&&(o=c),o<0))))return r>=0?r:o}var Tt=new ae,_t=new ae,bt=new ae,Ct=new ae;function xt(e,t,n,i,r,o){_t.subtractVectors(i,n),bt.subtractVectors(r,n),Ct.crossVectors(_t,bt);var a=t.dot(Ct),s=0;if(a>0){if(o)return;s=1}else{if(!(a<0))return;s=-1,a=-a}Tt.subtractVectors(e,n),bt.crossVectors(Tt,bt);var l=s*t.dot(bt);if(!(l<0)){_t.crossVectors(_t,Tt);var c=s*t.dot(_t);if(!(c<0||l+c>a)){var u=-s*Tt.dot(Ct);if(!(u<0))return u/a}}}function St(e,t,n){var i=e.hitTest(t,n,!0),r=e.getHitTestRay(t,n);if(i.length<=0)return[];var o=r.origin,a=r.direction,s=i.map((function(e,t){for(var n,i=e.position,r=[0,0,0],s=0;s<3;s++)r[s]=(i.getElement(s)-o.getElement(s))/a.getElement(s);return[t,(n=Math).max.apply(n,[].concat(r))]}));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 i[e[0]]}))}function At(e,t){var n;null==(n=e.items)||n.forEach((function(e){if(e.type===D){var n=e.getComponent(ut);if(n){var i=n.content;e.id===t?i.visBoundingBox=!0:i.visBoundingBox=!1}}}))}var Mt=function(){function e(){}return e.createTexture2D=function(t,n,i,r,o){return B((function(){var s,l,c,u;return H(this,(function(h){return void 0===n.imageData?(console.error("createTexture2D: Invalid image data from "+n+"."),[2,v.create(t,{name:"createTexture2D",sourceType:p.data,data:{data:new Uint8Array([255,255,255,255]),width:1,height:1}})]):(s=new Blob([n.imageData],{type:n.mimeType}),l=window.URL||window.webkitURL,c=l.createObjectURL(s),(u=new Image).src=c,[2,new Promise((function(n,s){u.onload=function(){var s,h=null!=(s=i.minFilter)?s:a.LINEAR_MIPMAP_LINEAR,f=!1;o&&(h=a.LINEAR_MIPMAP_LINEAR,e.isPow2(u.width)&&e.isPow2(u.height)||(h=a.LINEAR),f=!r);var d,m,g,y=!1;h!=a.NEAREST_MIPMAP_NEAREST&&h!=a.LINEAR_MIPMAP_NEAREST&&h!=a.NEAREST_MIPMAP_LINEAR&&h!=a.LINEAR_MIPMAP_LINEAR||(y=!0);var T=v.create(t,{name:"createTexture2D",wrapS:null!=(d=i.wrapS)?d:a.REPEAT,wrapT:null!=(m=i.wrapT)?m:a.REPEAT,magFilter:null!=(g=i.magFilter)?g:a.LINEAR,minFilter:h,anisotropic:1,premultiplyAlpha:f,sourceType:p.image,image:u,generateMipmap:y});n(T),l.revokeObjectURL(c)},u.onerror=s}))])}))}))()},e.createTextureList=function(e,t,n){var i=this;return B((function(){return H(this,(function(r){switch(r.label){case 0:return[4,Promise.all(n.map((function(n){return i.createTexture2D(e,t[n.source],n)})))];case 1:return[2,r.sent()]}}))}))()},e.getTextureCubeData=function(e){return B((function(){var t;return H(this,(function(n){switch(n.label){case 0:return[4,Rt.loadImageFromImageData(e[0])];case 1:return t=[n.sent()],[4,Rt.loadImageFromImageData(e[1])];case 2:return t=t.concat([n.sent()]),[4,Rt.loadImageFromImageData(e[2])];case 3:return t=t.concat([n.sent()]),[4,Rt.loadImageFromImageData(e[3])];case 4:return t=t.concat([n.sent()]),[4,Rt.loadImageFromImageData(e[4])];case 5:return t=t.concat([n.sent()]),[4,Rt.loadImageFromImageData(e[5])];case 6:return[2,t.concat([n.sent()])]}}))}))()},e.getTextureCubeMipmapData=function(e){var t=this;return B((function(){var n,i,r;return H(this,(function(o){switch(o.label){case 0:n=[],i=0,o.label=1;case 1:return i<e.length?(r=n.push,[4,t.getTextureCubeData(e[i])]):[3,4];case 2:r.apply(n,[o.sent()]),o.label=3;case 3:return i++,[3,1];case 4:return[2,n]}}))}))()},e.createTextureCubeFromURL=function(e,t){var n=this;return B((function(){var i;return H(this,(function(r){switch(r.label){case 0:return[4,x().loadSource({type:p.image,target:a.TEXTURE_CUBE_MAP,map:t},n.cubemapTexConfig)];case 1:return i=r.sent(),[2,v.create(e,i)]}}))}))()},e.createTextureCubeMipmapFromURL=function(e,t){var n=this;return B((function(){var i;return H(this,(function(r){switch(r.label){case 0:return[4,x().loadSource({type:p.mipmaps,target:a.TEXTURE_CUBE_MAP,maps:t},n.cubemapMipTexConfig)];case 1:return i=r.sent(),[2,v.create(e,i)]}}))}))()},e.createTextureCubeFromBuffer=function(t,n){var i=this;return B((function(){var r;return H(this,(function(o){switch(o.label){case 0:return[4,e.getTextureCubeData(n)];case 1:return r=o.sent(),[2,v.create(t,_e({name:"createTextureCubeFromBuffer",sourceType:p.image,cube:r,target:a.TEXTURE_CUBE_MAP},i.cubemapTexConfig))]}}))}))()},e.createTextureCubeMipmapFromBuffer=function(t,n,i){var r=this;return B((function(){var o,s,l,c;return H(this,(function(u){switch(u.label){case 0:return[4,e.getTextureCubeMipmapData(n)];case 1:for(o=u.sent(),s=0;Math.pow(2,s)<i;)++s;u.label=2;case 2:return o.length<=s?(l=Math.pow(2,s-o.length),[4,S("https://gw.alipayobjects.com/zos/gltf-asset/67896749597915/img"+l+".png")]):[3,4];case 3:return c=u.sent(),o.push([c,c,c,c,c,c]),[3,2];case 4:return[2,v.create(t,_e({name:"createTextureCubeMipmapFromBuffer",sourceType:p.mipmaps,mipmaps:o,target:a.TEXTURE_CUBE_MAP},r.cubemapMipTexConfig))]}}))}))()},e.getTexture=function(e,t){return e<0||e>=t.length?null:t[e]},e.createTextureFromImage=function(e,t){var n={name:"createTextureFromImage",image:t,sourceType:p.image,flipY:!1,magFilter:a.LINEAR,minFilter:a.LINEAR,wrapT:a.REPEAT,wrapS:a.REPEAT};return v.create(e,n)},e.deleteTexture=function(e){e.dispose()},e.deleteMesh=function(e){e.dispose({geometries:y.destroy})},e.deleteGeometry=function(e){e.dispose()},e.deleteRenderPass=function(e){e.dispose({meshes:{geometries:y.destroy},depthStencilAttachment:T.force,colorAttachment:T.force})},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}();Mt.cubemapTexConfig={name:"cubemap texture",wrapS:a.CLAMP_TO_EDGE,wrapT:a.CLAMP_TO_EDGE,magFilter:a.LINEAR,minFilter:a.LINEAR},Mt.cubemapMipTexConfig={wrapS:a.CLAMP_TO_EDGE,wrapT:a.CLAMP_TO_EDGE,magFilter:a.LINEAR,minFilter:a.LINEAR_MIPMAP_LINEAR};var It,Et,wt,Nt=function(){function e(){}return e.createFilterMesh=function(t,n,i){var r=Ae.getInstance(),o=i.vertexShaderCode,a=i.fragmentShaderCode,u=c.create(t,e.getPlaneGeometry()),h=2===t.gpuCapability.level,f=s.create(t,{shader:{vertex:o,fragment:a,shared:r.shaderShared,glslVersion:h?_.GLSL3:_.GLSL1}});return i.setMaterialStates(f),l.create(t,{name:n,worldMatrix:ce.fromIdentity(),material:f,geometry:u})},e.getPlaneGeometry=function(){var t=e.getPlaneVertexArray();return{attributes:{aPos:{type:a.FLOAT,size:3,data:t,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:0},aUV:{type:a.FLOAT,size:2,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:3*Float32Array.BYTES_PER_ELEMENT,dataSource:"aPos"},aNormal:{type:a.FLOAT,size:3,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:5*Float32Array.BYTES_PER_ELEMENT,dataSource:"aPos"}},drawStart:0,drawCount:t.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}(),Lt=function(){function e(){}return e.createLightOptions=function(e){var t,n,i,r,o,a,s,l,c=null!=(t=e.color)?t:[255,255,255,255];return"point"===e.type?{color:c,intensity:null!=(n=e.intensity)?n:1,lightType:"point",range:null!=(i=e.range)?i:0}:"spot"===e.type?{color:c,intensity:null!=(r=e.intensity)?r:1,lightType:"spot",range:null!=(o=e.range)?o:0,innerConeAngle:null!=(a=e.innerConeAngle)?a:0,outerConeAngle:null!=(s=e.outerConeAngle)?s:Math.PI/4}:{color:c,intensity:null!=(l=e.intensity)?l:1,lightType:"directional"}},e.createCameraOptions=function(e){if(void 0!==e.perspective){var t,n=e.perspective;return{near:n.znear,far:null!=(t=n.zfar)?t:1e3,fov:n.yfov,clipMode:0}}},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,t,n){var i=e.getVector4(t),r=e.getFloat(n),o=le.fromIdentity();i&&o.setFromArray([1,0,0,0,1,0,i.z,i.w,1]);var a=new le;if(r){var s=Math.cos(r),l=Math.sin(r);a.setFromArray([s,l,0,-l,s,0,0,0,1]),o.multiply(a)}return i&&(a.setFromArray([i.x,0,0,0,i.y,0,0,0,1]),o.multiply(a)),o.transpose(),o},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,t,n){var r=ae.fromArray(e),o=ae.fromArray(n),a=(new ae).copyFrom(r).subtract(o);ce.fromRotationAxis(new ae(0,1,0),t*ve).transformPoint(a);var s=a.clone().add(o),l=(new ce).lookAt(s,o,new ae(0,1,0)).invert(),c=new i;return c.setValid(!0),c.cloneFromMatrix(l),c},e.preprocessScene=function(e,t,i){var o=this,a=t!==r,s="tiny3d"===i,l=e.jsonScene;if(!(l&&l.textures&&l.materials))return{};var c={};e.textureOptions.forEach((function(e){var t=e.id;t&&(c[t]=e)}));var u=!1;return a&&(l.materials.forEach((function(e){o.preprocessTextureOptions(c,e.textures._BaseColorSampler,!0,s),o.preprocessTextureOptions(c,e.textures._MetallicRoughnessSampler,!1,s),o.preprocessTextureOptions(c,e.textures._NormalSampler,!1,s),o.preprocessTextureOptions(c,e.textures._OcclusionSampler,!1,s),o.preprocessTextureOptions(c,e.textures._EmissiveSampler,!1,s)})),l.components.forEach((function(e){if(e.dataType===n.DataType.SkyboxComponent){u=!0;var t=e;t.diffuseImage&&o.preprocessTextureOptions(c,t.diffuseImage,!1,s),t.specularImage&&o.preprocessTextureOptions(c,t.specularImage,!1,s)}}))),{loadSkybox:u}},e.preprocessTextureOptions=function(e,t,n,i){var r;if(i&&t&&(r="texture"in t?t.texture.id:t.id)){var o=e[r];if(o)if(void 0===o.target||o.target===a.TEXTURE_2D){o.wrapS=a.REPEAT,o.wrapT=a.REPEAT,o.magFilter=a.LINEAR,o.minFilter=a.LINEAR_MIPMAP_LINEAR,n||(o.premultiplyAlpha=!0);var s=o;s.generateMipmap=!0;var l=s.image;l&&l.width&&l.height&&(Mt.isPow2(l.width)&&Mt.isPow2(l.height)||(o.minFilter=a.LINEAR))}else o.target===a.TEXTURE_CUBE_MAP&&(o.wrapS=a.CLAMP_TO_EDGE,o.wrapT=a.CLAMP_TO_EDGE,void 0!==o.mipmaps?1===o.mipmaps.length?(o.magFilter=a.LINEAR,o.minFilter=a.LINEAR):(o.magFilter=a.LINEAR,o.minFilter=a.LINEAR_MIPMAP_LINEAR):(o.magFilter=a.LINEAR,o.minFilter=a.LINEAR))}},e.createGeometry=function(e,t,n){var i=we(t,n),r={};for(var o in i.attributes){var a=i.attributes[o];r[this.getAttributeName(o)]=a}return i.attributes=r,c.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 "+e+".")}},e.getAttributeName=function(e){switch(e){case"POSITION":return"aPos";case"NORMAL":return"aNormal";case"TANGENT":return"aTangent";case"TEXCOORD_0":return"aUV";case"TEXCOORD_1":return"aUV2";case"JOINTS_0":return"aJoints";case"WEIGHTS_0":return"aWeights"}return e.startsWith("a")||console.warn("Unknown attribute name: "+e+"."),e},e.getTextureObj=function(e,t){return"number"!=typeof t?null:((t<0||t>=e.length)&&console.error("Invalid index for textures: "+t+", "+e.length+"."),e[t])},e}(),Rt=function(){function e(){}return e.getImageFileName=function(e,t){var n=e.lastIndexOf("/"),i=e.lastIndexOf("."),r=e.substring(n+1,i);return t?r+t:r},e.getCurrnetTimeStr=function(){var e=new Date(Date.now()),t=e.toLocaleString("zh-CN"),n=""+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 t=document.createElement("canvas");return t.width=512,t.height=512,new b({canvas:t,renderFramework:"webgl2",env:r,renderOptions:{willCaptureImage:!0},manualRender:e})},e.sleep=function(e){return B((function(){return H(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))()},e.loadImageFromGLTFImage=function(e){return B((function(){return H(this,(function(t){return[2,S(new Blob([e.imageData],{type:e.mimeType}))]}))}))()},e.loadImageFromImageData=function(e){return B((function(){return H(this,(function(t){return[2,S(new Blob([e.data],{type:e.mimeType}))]}))}))()},e.getCanvasArrayBuffer=function(e){return B((function(){return H(this,(function(t){return[2,new Promise((function(t,n){e.toBlob((function(e){e?t(e.arrayBuffer()):n(new Error("No canvas blob."))}),"image/png",1)}))]}))}))()},e.getImageArrayBuffer=function(e){var t=this;return B((function(){var n;return H(this,(function(i){return(n=document.createElement("canvas")).width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0),[2,t.getCanvasArrayBuffer(n)]}))}))()},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}(),Ot=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 ae;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}(),Ft=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}var t=e.prototype;return t.create=function(e,t){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}var n,i;this.data=t,this.length=this.data.length,this.compCount=e.size,this.offset=null!=(n=e.offset)?n:0,this.offset>0&&(this.offset%this.typeSize!=0&&console.error("Invalid offset "+this.offset+", type size "+this.typeSize+"."),this.offset=this.offset/this.typeSize),this.stride=null!=(i=e.stride)?i:0,this.stride>0?(this.stride%this.typeSize!=0&&console.error("Invalid stride "+this.stride+", type size "+this.typeSize+"."),this.stride=this.stride/this.typeSize):this.stride=this.compCount,this.compressed=!0===e.normalize},t.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 i=0;i<this.compCount;i++)n[i]*=this.compressScale,this.signed&&(n[i]=Math.max(n[i],-1));return n}},t.getLength=function(){return Math.round((this.length-this.offset)/this.stride)},e}(),Ut=function(){function e(){this.drawStart=0,this.drawCount=0,this.bindMatrices=[]}var t=e.prototype;return t.create=function(e,t){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var n=e.attributes;this.index=e.getIndexData();var i=n.aPos,r=e.getAttributeData("aPos");this.position=new Ft,this.position.create(i,r);var o=n.aJoints,a=n.aWeights;if(void 0!==o&&void 0!==a){var s=e.getAttributeData("aJoints"),l=e.getAttributeData("aWeights");this.joint=new Ft,this.joint.create(o,s),this.weight=new Ft,this.weight.create(a,l)}this.bindMatrices=t},t.getBoundingBox=function(e){var t=this;e.makeEmpty();var n=new ce,i=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0,r=new Set;if(void 0!==this.index)for(var o=0;o<this.drawCount;o++){var a=this.drawStart+o;a<this.index.length&&r.add(this.index[a])}else for(var s=0;s<this.drawCount;s++)r.add(this.drawStart+s);return r.forEach((function(r){var o=t.position.getData(r);if(void 0!==o){var a=ae.fromArray(o);if(i){var s,l,c=null==(s=t.joint)?void 0:s.getData(r),u=null==(l=t.weight)?void 0:l.getData(r);if(void 0!==c&&void 0!==u){n.setZero();for(var h=!1,f=0;f<4;f++)if(0!==u[f]){if(c[f]<0||c[f]>=t.bindMatrices.length){h=!0;break}var d=t.bindMatrices[c[f]];n.addScaledMatrix(d,u[f])}if(!h){var m=n.transformVector4(new se(a.x,a.y,a.z,1));Math.abs(m.w)>1e-4&&(m.multiply(1/m.w),a.set(m.x,m.y,m.z))}}}e.expandByPoint(a)}})),e},e}(),Dt=function(){function e(){this.drawStart=0,this.drawCount=0,this.doubleSided=!1,this.bindMatrices=[],this.hasAnimation=!1,this.skinMatrix=new ce}var t=e.prototype;return t.create=function(e,t,n){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var i=e.attributes;this.index=e.getIndexData();var r=i.aPos,o=e.getAttributeData("aPos");this.position=new Ft,this.position.create(r,o);var a=i.aJoints,s=i.aWeights;if(void 0!==a&&void 0!==s){var l=e.getAttributeData("aJoints"),c=e.getAttributeData("aWeights");this.joint=new Ft,this.joint.create(a,l),this.weight=new Ft,this.weight.create(s,c)}this.doubleSided=t,this.bindMatrices=n,this.hasAnimation=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0},t.getHitPoint=function(e,t){for(var n,i=new ae,r=new ae,o=new ae,a=new se,s=new se,l=new se,c=!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 m=this.getPosition(h,i,a),g=this.getPosition(f,r,s),p=this.getPosition(d,o,l);if(m&&g&&p){var v=xt(e,t,m,g,p,c);void 0!==v&&(void 0===n||n>v)&&(n=v)}}return n},t.getPosition=function(e,t,n){var i=this.position.getData(e);if(void 0===i)return null;if(this.hasAnimation){var r,o,a=null==(r=this.joint)?void 0:r.getData(e),s=null==(o=this.weight)?void 0:o.getData(e);if(void 0!==a&&void 0!==s){var l=this.skinMatrix;l.setZero();for(var c=0;c<4;c++)if(0!==s[c]){var u=this.bindMatrices[a[c]];l.addScaledMatrix(u,s[c])}n.set(i[0],i[1],i[2],1);var h=l.transformVector4(n),f=1/h.w;t.set(h.x*f,h.y*f,h.z*f)}}else t.set(i[0],i[1],i[2]);return t},e}(),Pt=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 G(e,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!!G(e,v)&&(e.isDestroyed&&console.error("Texture is destroyed, "+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===n.MaterialBlending.opaque||e===n.MaterialBlending.masked||e===n.MaterialBlending.translucent||e===n.MaterialBlending.additive},e.checkMatSide=function(e){return void 0===e||e===n.SideMode.BACK||e===n.SideMode.DOUBLE||e===n.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,t){G(e,c)||console.error("Invalid geometry type "+this.stringify(e)+"."),!0===e.isDestroyed&&console.error("Geometry object is destroyed."),this.checkNonnegative(e.getDrawStart())||console.error("Invalid geometry draw start: "+e.getDrawStart()+", "+this.stringify(e)+".")},e.assertGeometryBuffer=function(e,t,n){var i=this.createAttributeArray(e,t);void 0!==i&&i.getLength()<n&&console.error(t+" Length("+i.getLength()+") is less than draw count("+n+"), "+this.stringify(e)+".")},e.createAttributeArray=function(e,t){var n=e.attributes;if(void 0!==n){var i=n[t];if(void 0!==i){var r=e.getAttributeData(t);if(void 0!==r){var o=new Ft;return o.create(i,r),o}}}},e.assertModelSkinOptions=function(e){if(this.checkStringUndef(e.name)||console.error("Invalid skin name "+e.name+", "+this.stringify(e)+"."),this.checkNumberArray(e.joints)||console.error("Invalid skin joints "+e.joints+", "+this.stringify(e)+"."),this.checkNumberUndef(e.skeleton)||console.error("Invalid skin skeleton "+e.skeleton+", "+this.stringify(e)+"."),this.checkFloat32ArrayUndef(e.inverseBindMatrices)||console.error("Invalid skin inverseBindMatrices "+e.inverseBindMatrices+", "+this.stringify(e)+"."),void 0!==e.inverseBindMatrices){(e.inverseBindMatrices.length<=0||e.inverseBindMatrices.length%16!=0)&&console.error("Invalid skin inverseBindMatrices length "+e.inverseBindMatrices+", "+this.stringify(e)+"."),16*e.joints.length!==e.inverseBindMatrices.length&&console.error("Mismatch: skin joints and inverseBindMatrices length, "+e.joints+", "+e.inverseBindMatrices+", "+this.stringify(e)+".");for(var t=new ce,n=0;n<e.inverseBindMatrices.length;n+=16){for(var i=0;i<16;i++)t.elements[i]=e.inverseBindMatrices[n+i];Math.abs(t.determinant())<1e-5&&console.error("Determinant of inverseBindMatrices is too small "+t.determinant()+", index "+n/16+", "+this.stringify(e)+".")}}else e.joints.length<=0&&console.error("Invalid skin joints length "+e.joints+", "+this.stringify(e)+".")},e.assertMatOptions=function(e){e.type===n.MaterialType.unlit?(this.checkString(e.name)||console.error("Invalid material name "+e.name+", "+this.stringify(e)+"."),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor "+e.baseColorFactor+", "+this.stringify(e)+"."),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture "+e.baseColorTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform "+e.baseColorTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate "+e.baseColorTextureCoordinate+", "+this.stringify(e)+"."),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask "+e.depthMask+", "+this.stringify(e)+"."),this.checkMatBlending(e.blending)||console.error("Invalid material blending "+e.blending+", "+this.stringify(e)+"."),this.checkMatSide(e.side)||console.error("Invalid material side "+e.side+", "+this.stringify(e)+"."),e.blending===n.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, "+this.stringify(e)+"."),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff "+e.alphaCutOff+", "+this.stringify(e)+".")):e.type===n.MaterialType.pbr?(this.checkString(e.name)||console.error("Invalid material name "+e.name+", "+this.stringify(e)+"."),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor "+e.baseColorFactor+", "+this.stringify(e)+"."),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture "+e.baseColorTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform "+e.baseColorTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate "+e.baseColorTextureCoordinate+", "+this.stringify(e)+"."),this.checkBooleanUndef(e.useSpecularAA)||console.error("Invalid material useSpecularAA "+e.useSpecularAA+", "+this.stringify(e)+"."),this.checkNumber01(e.metallicFactor)||console.error("Invalid material metallicFactor "+e.metallicFactor+", "+this.stringify(e)+"."),this.checkNonnegative(e.roughnessFactor)||console.error("Invalid material roughnessFactor "+e.roughnessFactor+", "+this.stringify(e)+"."),this.checkTextureUndef(e.metallicRoughnessTexture)||console.error("Invalid material metallicRoughnessTexture "+e.metallicRoughnessTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.metallicRoughnessTextureTransform)||console.error("Invalid material metallicRoughnessTextureTransform "+e.metallicRoughnessTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.metallicRoughnessTextureCoordinate)||console.error("Invalid material metallicRoughnessTextureCoordinate "+e.metallicRoughnessTextureCoordinate+", "+this.stringify(e)+"."),this.checkTextureUndef(e.normalTexture)||console.error("Invalid material normalTexture "+e.normalTexture+", "+this.stringify(e)+"."),this.checkNonnegativeUndef(e.normalTextureScale)||console.error("Invalid material normalTextureScale "+e.normalTextureScale+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.normalTextureTransform)||console.error("Invalid material normalTextureTransform "+e.normalTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.normalTextureCoordinate)||console.error("Invalid material normalTextureCoordinate "+e.normalTextureCoordinate+", "+this.stringify(e)+"."),this.checkTextureUndef(e.occlusionTexture)||console.error("Invalid material occlusionTexture "+e.occlusionTexture+", "+this.stringify(e)+"."),this.checkNumber01Undef(e.occlusionTextureStrength)||console.error("Invalid material occlusionTextureStrength "+e.occlusionTextureStrength+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.occlusionTextureTransform)||console.error("Invalid material occlusionTextureTransform "+e.occlusionTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.occlusionTextureCoordinate)||console.error("Invalid material occlusionTextureCoordinate "+e.occlusionTextureCoordinate+", "+this.stringify(e)+"."),this.checkNonnegative4(e.emissiveFactor)||console.error("Invalid material emissiveFactor "+e.emissiveFactor+", "+this.stringify(e)+"."),this.checkNonnegative(e.emissiveIntensity)||console.error("Invalid material emissiveIntensity "+e.emissiveIntensity+", "+this.stringify(e)+"."),this.checkTextureUndef(e.emissiveTexture)||console.error("Invalid material emissiveTexture "+e.emissiveTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.emissiveTextureTransform)||console.error("Invalid material emissiveTextureTransform "+e.emissiveTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.emissiveTextureCoordinate)||console.error("Invalid material emissiveTextureCoordinate "+e.emissiveTextureCoordinate+", "+this.stringify(e)+"."),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask "+e.depthMask+", "+this.stringify(e)+"."),this.checkMatBlending(e.blending)||console.error("Invalid material blending "+e.blending+", "+this.stringify(e)+"."),this.checkMatSide(e.side)||console.error("Invalid material side "+e.side+", "+this.stringify(e)+"."),e.blending===n.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, "+this.stringify(e)+"."),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff "+e.alphaCutOff+", "+this.stringify(e)+".")):console.error("Invalid material type "+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 "+e.parent+", "+this.stringify(e)+"."),void 0!==e.skin&&this.assertModelSkinOptions(e.skin);for(var t=[],n=0;n<e.primitives.length;n++){var i=e.primitives[n];this.assertPrimOptions(i)||console.error("Invalid primitive "+i+", "+this.stringify(e)+".");var r=new Ht;r.create(i.geometry),t.push(r)}for(var o=1;o<t.length;o++){var a=t[o-1],s=t[o];a.equals(s)||console.error("Morph states mismatch: "+this.stringify(a)+", "+this.stringify(s)+", "+this.stringify(e)+".")}this.checkBooleanUndef(e.hide)||console.error("Invalid mesh hide "+e.hide+", "+this.stringify(e)+".")},e.assertModelCameraOptions=function(e){this.checkParent(e.parent)||console.error("Invalid camera parent "+e.parent+", "+this.stringify(e)+"."),this.checkNumberUndef(e.aspect)||console.error("Invalid camera aspect "+e.aspect+", "+this.stringify(e)+"."),this.checkPositive(e.near)||console.error("Invalid camera near "+e.near+", "+this.stringify(e)+"."),(!this.checkPositive(e.far)||e.far<=e.near)&&console.error("Invalid camera far "+e.far+", "+this.stringify(e)+"."),this.checkPositive(e.fov)||console.error("Invalid camera fov "+e.fov+", "+this.stringify(e)+"."),this.checkNumber01(e.clipMode)||console.error("Invalid camera clipMode "+e.clipMode+", "+this.stringify(e)+".")},e.assertModelLightOptions=function(e){"directional"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+".")):"point"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+"."),this.checkNonnegative(e.range)||console.error("Invalid light range "+e.range+", "+this.stringify(e)+".")):"spot"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+"."),this.checkNonnegative(e.range)||console.error("Invalid light range "+e.range+", "+this.stringify(e)+"."),this.checkNonnegative(e.innerConeAngle)||console.error("Invalid light innerConeAngle "+e.innerConeAngle+", "+this.stringify(e)+"."),this.checkNonnegative(e.outerConeAngle)||console.error("Invalid light outerConeAngle "+e.outerConeAngle+", "+this.stringify(e)+".")):"ambient"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+".")):console.error("Invalid light type "+this.stringify(e)+".")},e.assertModelSkyboxOptions=function(e){var t=this;this.checkBoolean(e.renderable)||console.error("Invalid skybox renderable "+e.renderable+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid skybox intensity "+e.intensity+", "+this.stringify(e)+"."),this.checkNonnegative(e.reflectionsIntensity)||console.error("Invalid skybox reflectionsIntensity "+e.reflectionsIntensity+", "+this.stringify(e)+".");var n=e.irradianceCoeffs;void 0!==n?(Array.isArray(n)&&9==n.length||console.error("Invalid skybox irradianceCoeffs "+n+", "+this.stringify(e)+"."),n.forEach((function(e){t.checkVec3(e)||console.error("Invalid skybox irradianceCoeffs "+n+", "+t.stringify(e)+".")}))):void 0!==e.diffuseImage?this.checkTexture(e.diffuseImage)||console.error("Invalid skybox diffuseImage "+e.diffuseImage+", "+this.stringify(e)+"."):console.error("Invalid skybox, irradianceCoeffs or diffuseImage should give one, "+this.stringify(e)+"."),this.checkTexture(e.specularImage)||console.error("Invalid skybox specularImage "+e.specularImage+", "+this.stringify(e)+"."),this.checkPositive(e.specularImageSize)||console.error("Invalid skybox specularImageSize "+e.specularImageSize+", "+this.stringify(e)+"."),this.checkPositive(e.specularMipCount)||console.error("Invalid skybox specularMipCount "+e.specularMipCount+", "+this.stringify(e)+"."),this.pow2(e.specularMipCount)>e.specularImageSize&&console.error("Invalid skybox specularMipCount or specularImageSize, "+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 "+e.interpolation+", "+this.stringify(e)),!1):(console.error("Invalid track path "+e.path+", "+this.stringify(e)),!1):(console.error("Invalid track input "+e.output+", "+this.stringify(e)),!1):(console.error("Invalid track input "+e.input+", "+this.stringify(e)),!1):(console.error("Invalid track node "+e.node+", "+this.stringify(e)),!1)},e.assertModelAnimOptions=function(e){var t=this;this.checkStringUndef(e.name)||console.error("Invalid animation name "+e.name+", "+this.stringify(e)+"."),Array.isArray(e.tracks)||console.error("Invalid animation tracks "+e.tracks+", "+this.stringify(e)+"."),e.tracks.forEach((function(n){t.checkModelAnimTrackOptions(n)||console.error("Invalid animation track "+n+", "+t.stringify(e)+".")}))},e.assertTreeOptions=function(e){var t=this;this.checkNumberUndef(e.animation)||console.error("Invalid tree animation "+e.animation+", "+this.stringify(e)+"."),void 0!==e.animations&&(Array.isArray(e.animations)||console.error("Invalid tree animations "+e.animations+", "+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 "+e.animations+", "+this.stringify(e)+"."))},e.stringify=function(e){var t={};for(var n in e)"internal"!==n&&"function"!=typeof e[n]&&(G(e[n],v)||G(e[n],c)?t[n]=e[n].name:G(e[n],C)||(t[n]=e[n]));return JSON.stringify(t)},e.pow2=function(e){for(var t=1;e-- >0;)t*=2;return t},e}(),Bt=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]=kt(e[n])},Te(e,[{key:"bytes",get:function(){return 2*this.size}}]),e}(),kt=(It=new Float32Array(1),Et=new Int32Array(It.buffer),function(e){It[0]=e;var t=Et[0],n=t>>16&32768,i=t>>12&2047,r=t>>23&255;return r<103?n:r>142?(n|=31744,n|=(255==r?0:1)&&8388607&t):r<113?n|=((i|=2048)>>114-r)+(i>>113-r&1):(n|=r-112<<10|i>>1,n+=1&i)});!function(e){e[e.none=0]="none",e[e.float=1]="float",e[e.half_float=2]="half_float"}(wt||(wt={}));var Vt,Gt,zt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).skeleton=0,t.jointItem=[],t.inverseBindMatrices=[],t.animationMatrices=[],t.textureDataMode=0,t.maxJointCount=0,t}V(t,e);var n=t.prototype;return n.create=function(e,t,n,i){var r;this.name=null!=(r=e.rootBoneName)?r:"Unnamed skin",this.type=Q.skin,this.rootBoneItem=n,this.skeleton=-1,this.jointItem=this.getJointItems(e,n),this.maxJointCount=Math.max(i,this.jointItem.length),this.animationMatrices=[],this.inverseBindMatrices=[],this.textureDataMode=this.getTextureDataMode(this.maxJointCount,t);var o=e.inverseBindMatrices;if(void 0!==o&&o.length>0){if(o.length%16!=0||o.length!==16*this.jointItem.length)throw new Error("Invalid array length, invert bind matrices "+o.length+", joint array "+this.jointItem.length+".");for(var a=o.length/16,s=0;s<a;s++){var l=ce.fromArray(o,16*s);this.inverseBindMatrices.push(l)}}},n.updateSkinMatrices=function(){var e=this;this.animationMatrices=[];for(var t=0;t<this.jointItem.length;t++){var n=this.jointItem[t].transform.getWorldMatrix();this.animationMatrices.push(n.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.computeMeshAnimMatrices=function(e,t,n){var i=e.clone().invert(),r=new ce;this.animationMatrices.forEach((function(e,o){var a=r.multiplyMatrices(i,e);a.elements.forEach((function(e,n){return t[16*o+n]=e})),a.clone().invert().transpose().elements.forEach((function(e,t){return n[16*o+t]=e}))}))},n.updateParentItem=function(e){this.rootBoneItem=e},n.getJointCount=function(){return this.jointItem.length},n.isTextureDataMode=function(){return 0!==this.textureDataMode},n.dispose=function(){this.rootBoneItem=void 0,this.jointItem=[],this.inverseBindMatrices=[],this.animationMatrices=[]},n.getTextureDataMode=function(e,t){var n=t.gpuCapability.detail,i=n.maxVertexUniforms-25;if(e>Math.floor(i/8)){if(n.floatTexture)return 1;if(n.halfFloatTexture)return 2;throw new Error("Too many joint count "+e+", half float texture not support.")}return 0},n.getJointItems=function(e,t){var n,i=this.genNodeName(t),r=[];return null==(n=e.boneNames)||n.forEach((function(e){var t=i[e];if(!t)throw new Error("Can't find node of bone name "+e+".");r.push(t)})),r},n.genNodeName=function(e){var t={},n=[];t[""]=e;for(var i,r=K(e.children);!(i=r()).done;){var o=i.value;this.genNodeNameDFS(o,n,t)}return t},n.genNodeNameDFS=function(e,t,n){t.push(e.name),n[t.join("/")]=e;for(var i,r=K(e.children);!(i=r()).done;){var o=i.value;this.genNodeNameDFS(o,t,n)}t.pop()},t}(Ie),Ht=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).morphWeightsLength=0,t.morphWeightsArray=[],t.hasPositionMorph=!1,t.hasNormalMorph=!1,t.hasTangentMorph=!1,t}V(t,e);var n=t.prototype;return n.create=function(e){var n=this;this.name=this.genName("Morph target"),this.type=Q.morph;var i=this.getAttributeMorphCount(t.positionNameList,e),r=this.getAttributeMorphCount(t.normalNameList,e),o=this.getAttributeMorphCount(t.tangentNameList,e),a=[i,r,o];return this.morphWeightsLength=0,a.forEach((function(e){e>0&&(0===n.morphWeightsLength?n.morphWeightsLength=e:n.morphWeightsLength=Math.min(n.morphWeightsLength,e))})),this.morphWeightsLength>0&&(this.morphWeightsArray=Array(this.morphWeightsLength).fill(0),this.hasPositionMorph=i==this.morphWeightsLength,this.hasNormalMorph=r==this.morphWeightsLength,this.hasTangentMorph=o==this.morphWeightsLength),i>0&&i!=this.morphWeightsLength?(console.error("Position morph count mismatch: "+this.morphWeightsLength+", "+i+"."),!1):r>0&&r!=this.morphWeightsLength?(console.error("Normal morph count mismatch: "+this.morphWeightsLength+", "+r+"."),!1):o>0&&o!=this.morphWeightsLength?(console.error("Tangent morph count mismatch: "+this.morphWeightsLength+", "+o+"."),!1):!(this.morphWeightsLength>5)||(console.error("Tangent morph count should not greater than 5, current "+this.morphWeightsLength+"."),!1)},n.initWeights=function(e){if(0!==this.morphWeightsArray.length){var t=this.morphWeightsArray;e.forEach((function(e,n){n<t.length&&(t[n]=e)}))}},n.updateWeights=function(e){var t=this;e.length==this.morphWeightsArray.length?e.forEach((function(e,n){return t.morphWeightsArray[n]=e})):console.error("Length of morph weights mismatch: input "+e.length+", internel "+this.morphWeightsArray.length+".")},n.hasMorph=function(){return this.morphWeightsLength>0&&(this.hasPositionMorph||this.hasNormalMorph||this.hasTangentMorph)},n.equals=function(e){return this.morphWeightsLength===e.morphWeightsLength&&this.hasPositionMorph===e.hasPositionMorph&&this.hasNormalMorph===e.hasNormalMorph&&this.hasTangentMorph===e.hasTangentMorph},n.getMorphWeightsArray=function(){return this.morphWeightsArray},n.getAttributeMorphCount=function(e,t){for(var n=0;n<e.length;n++){var i=e[n];if(void 0===t.getAttributeData(i))return n}return e.length},t}(Ie);Ht.positionNameList=["aTargetPosition0","aTargetPosition1","aTargetPosition2","aTargetPosition3","aTargetPosition4","aTargetPosition5","aTargetPosition6","aTargetPosition7"],Ht.normalNameList=["aTargetNormal0","aTargetNormal1","aTargetNormal2","aTargetNormal3","aTargetNormal4","aTargetNormal5","aTargetNormal6","aTargetNormal7"],Ht.tangentNameList=["aTargetTangent0","aTargetTangent1","aTargetTangent2","aTargetTangent3","aTargetTangent4","aTargetTangent5","aTargetTangent6","aTargetTangent7"],function(e){e[e.linear=0]="linear",e[e.step=1]="step",e[e.cubicSpline=2]="cubicSpline"}(Vt||(Vt={})),function(e){e[e.translation=0]="translation",e[e.rotation=1]="rotation",e[e.scale=2]="scale",e[e.weights=3]="weights"}(Gt||(Gt={}));var jt=function(){function e(e){this.engine=e,this.isHalfFloat=!0,this.width=0,this.height=0}var t=e.prototype;return t.create=function(e,t,n){var i,r;this.width=4,this.height=e,this.isHalfFloat=t,this.isHalfFloat&&(this.buffer=new Bt(4*this.getSize()));var o=null!=(r=null==(i=this.buffer)?void 0:i.data)?r:new Float32Array(4*this.getSize()),s=this.isHalfFloat?a.HALF_FLOAT:a.FLOAT;this.texture=v.create(this.engine,{name:n,data:{width:this.width,height:this.height,data:o},target:a.TEXTURE_2D,format:a.RGBA,type:s,wrapS:a.CLAMP_TO_EDGE,wrapT:a.CLAMP_TO_EDGE,minFilter:a.NEAREST,magFilter:a.NEAREST})},t.update=function(e){var t,n;(void 0!==this.buffer&&this.buffer.set(e,0),void 0!==this.texture)&&this.texture.updateSource({sourceType:p.data,data:{width:this.width,height:this.height,data:null!=(n=null==(t=this.buffer)?void 0:t.data)?n:e},target:a.TEXTURE_2D})},t.dispose=function(){var e;this.engine=null,this.buffer=void 0,null==(e=this.texture)||e.dispose()},t.getSize=function(){return this.width*this.height},t.getTexture=function(){return this.texture},e}(),Wt=function(){function e(){this.funcMap=new Map,this.funcMap.set(te.unlit,Ye),this.funcMap.set(te.pbr,Ye),this.funcMap.set(te.shadowBase,Ke),this.funcMap.set(te.shadowFilter,rt),this.funcMap.set(te.normalVis,et),this.funcMap.set(te.simpleFilter,it),this.funcMap.set(te.skyboxFilter,Qe)}return e.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 "+t+", shader content "+e+".")},e.getInstance=function(){return this._instance||(this._instance=new this)},e}(),Jt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).materialType=te.none,t.vertexShaderCode="",t.fragmentShaderCode="",t.ZWrite=!0,t.ZTest=!0,t.renderType=n.RenderType.Opaque,t.alphaClip=!1,t.alphaCutoff=.5,t.renderFace=n.RenderFace.Front,t}V(t,e);var i=t.prototype;return i.getShaderFeatures=function(){var e=[];return this.isAlphaClip()?e.push("ALPHAMODE_MASK 1"):this.isOpaque()&&e.push("ALPHAMODE_OPAQUE 1"),this.renderFace===n.RenderFace.Both&&e.push("DOUBLE_SIDED 1"),e},i.getShaderMacros=function(){var e=[];return this.isAlphaClip()?e.push({name:"ALPHAMODE_MASK"}):this.isOpaque()&&e.push({name:"ALPHAMODE_OPAQUE"}),this.renderFace===n.RenderFace.Both&&e.push({name:"DOUBLE_SIDED"}),e},i.updateUniforms=function(e){if(Ae.getInstance().renderMode3D===n.RenderMode3D.uv){var t=Ae.getInstance().renderMode3DUVGridSize;e.setFloat("_DebugUVGridSize",t)}},i.build=function(e){var t=this.getFeatureList(e),n=Ae.getInstance().isWebGL2,i=Wt.getInstance().genShaderCode({material:this,isWebGL2:n,featureList:t});this.vertexShaderCode=i.vertexShaderCode,this.fragmentShaderCode=i.fragmentShaderCode},i.getFeatureList=function(e){var t,n=this.getShaderFeatures();void 0!==e&&(t=n).push.apply(t,[].concat(e));this.materialType!==te.shadowBase&&(Ae.getInstance().isEditorEnv&&n.push("EDITOR_TRANSFORM"));return n},i.getMacroList=function(e){var t,n=this.getShaderMacros();void 0!==e&&(t=n).push.apply(t,[].concat(e));this.materialType!==te.shadowBase&&(Ae.getInstance().isEditorEnv&&n.push({name:"EDITOR_TRANSFORM"}));return n},i.setMaterialStates=function(e){this.renderType===n.RenderType.Transparent?(e.blending=!0,e.depthTest=this.ZTest,e.depthMask=this.ZWrite,e.blendEquation=[a.FUNC_ADD,a.FUNC_ADD],e.blendFunction=[a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA]):Ae.getInstance().isTiny3dMode?(e.blending=!1,e.depthTest=!0,e.depthMask=!0):(e.blending=!1,e.depthTest=this.ZTest,e.depthMask=this.ZWrite),this.setFaceSideStates(e)},i.setFaceSideStates=function(e){this.isBothSide()?e.culling=!1:this.isBackSide()?(e.cullFace=a.FRONT,e.frontFace=a.CCW,e.culling=!0):(e.cullFace=a.BACK,e.frontFace=a.CCW,e.culling=!0)},i.dispose=function(){this.vertexShaderCode="",this.fragmentShaderCode=""},i.isValid=function(){return this.materialType!==te.none&&e.prototype.isValid.call(this)},i.isOpaque=function(){return this.renderType===n.RenderType.Opaque},i.isAlphaClip=function(){return this.alphaClip},i.isTransparent=function(){return this.renderType===n.RenderType.Transparent},i.isFrontSide=function(){return this.renderFace===n.RenderFace.Front},i.isBackSide=function(){return this.renderFace===n.RenderFace.Back},i.isBothSide=function(){return this.renderFace===n.RenderFace.Both},t}(Ie),Xt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).baseColorFactor=new ue(1,1,1,1),t}V(t,e);var i=t.prototype;return i.create=function(e){var t,i,r,o,a;this.effectMaterial=e,this.name=e.name,this.type=Q.material,this.materialType=te.unlit,this.baseColorTexture=null!=(t=e.getTexture("_BaseColorSampler"))?t:void 0,this.baseColorTextureTrans=Lt.createUVTransform(e,"_BaseColorSampler_ST","_BaseColorRotation"),this.baseColorFactor=null!=(i=e.getColor("_BaseColorFactor"))?i:new ue(1,1,1,1),this.ZWrite=0!==e.getFloat("ZWrite"),this.ZTest=0!==e.getFloat("ZTest"),this.renderType=null!=(r=e.stringTags.RenderType)?r:n.RenderType.Opaque,this.alphaClip=1===e.getFloat("AlphaClip"),this.alphaCutoff=null!=(o=e.getFloat("_AlphaCutoff"))?o:0,this.renderFace=null!=(a=e.stringTags.RenderFace)?a:n.RenderFace.Front},i.dispose=function(){e.prototype.dispose.call(this),this.baseColorTexture=void 0},i.getShaderFeatures=function(){var t=e.prototype.getShaderFeatures.call(this);return t.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&t.push("HAS_BASE_COLOR_MAP 1"),t.push("MATERIAL_UNLIT 1"),t},i.getShaderMacros=function(){var t=e.prototype.getShaderMacros.call(this);return t.push({name:"MATERIAL_METALLICROUGHNESS"}),this.hasBaseColorTexture()&&t.push({name:"HAS_BASE_COLOR_MAP"}),t.push({name:"MATERIAL_UNLIT"}),t},i.updateUniforms=function(t){e.prototype.updateUniforms.call(this,t),void 0!==this.baseColorTexture&&(t.setInt("_BaseColorUVSet",0),t.setMatrix3("_BaseColorUVTransform",this.baseColorTextureTrans)),t.setFloat("_MetallicFactor",0),t.setFloat("_RoughnessFactor",0),t.setFloat("_Exposure",1)},i.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},i.getBaseColorTexture=function(){return this.baseColorTexture},i.setBaseColorTexture=function(e){this.baseColorTexture=e},i.getBaseColorFactor=function(){return this.baseColorFactor},i.setBaseColorFactor=function(e){G(e,ue)?this.baseColorFactor.set(e.r,e.g,e.b,e.a):G(e,se)?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},t}(Jt),qt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).baseColorFactor=new ue(1,1,1,1),t.useSpecularAA=!1,t.metallicFactor=0,t.roughnessFactor=1,t.normalTextureScale=1,t.occlusionTextureStrength=1,t.emissiveFactor=new ue(0,0,0,0),t.emissiveIntensity=1,t}V(t,e);var i=t.prototype;return i.create=function(e){var t,i,r,o,a,s,l,c,u,h,f,d,m,g,p;this.effectMaterial=e,this.name=e.name,this.type=Q.material,this.materialType=te.pbr,this.baseColorTexture=null!=(t=e.getTexture("_BaseColorSampler"))?t:void 0,this.baseColorTextureTrans=Lt.createUVTransform(e,"_BaseColorSampler_ST","_BaseColorRotation"),this.baseColorFactor=null!=(i=e.getColor("_BaseColorFactor"))?i:new ue(1,1,1,1),this.metallicRoughnessTexture=null!=(r=e.getTexture("_MetallicRoughnessSampler"))?r:void 0,this.metallicRoughnessTextureTrans=Lt.createUVTransform(e,"_MetallicRoughnessSampler_ST","_MetallicRoughnessRotation"),this.useSpecularAA=1===e.getFloat("_SpecularAA"),this.metallicFactor=null!=(o=e.getFloat("_MetallicFactor"))?o:1,this.roughnessFactor=null!=(a=e.getFloat("_RoughnessFactor"))?a:0,this.normalTexture=null!=(s=e.getTexture("_NormalSampler"))?s:void 0,this.normalTextureTrans=Lt.createUVTransform(e,"_NormalSampler_ST","_NormalRotation"),this.normalTextureScale=null!=(l=e.getFloat("_NormalScale"))?l:1,this.occlusionTexture=null!=(c=e.getTexture("_OcclusionSampler"))?c:void 0,this.occlusionTextureTrans=Lt.createUVTransform(e,"_OcclusionSampler_ST","_OcclusionRotation"),this.occlusionTextureStrength=null!=(u=e.getFloat("_OcclusionStrength"))?u:1,this.emissiveTexture=null!=(h=e.getTexture("_EmissiveSampler"))?h:void 0,this.emissiveTextureTrans=Lt.createUVTransform(e,"_EmissiveSampler_ST","_EmissiveRotation"),this.emissiveFactor=null!=(f=e.getColor("_EmissiveFactor"))?f:new ue(0,0,0,1),this.emissiveIntensity=null!=(d=e.getFloat("_EmissiveIntensity"))?d:1,this.ZWrite=0!==e.getFloat("ZWrite"),this.ZTest=0!==e.getFloat("ZTest"),this.renderType=null!=(m=e.stringTags.RenderType)?m:n.RenderType.Opaque,this.alphaClip=1===e.getFloat("AlphaClip"),this.alphaCutoff=null!=(g=e.getFloat("_AlphaCutoff"))?g:0,this.renderFace=null!=(p=e.stringTags.RenderFace)?p:n.RenderFace.Front},i.dispose=function(){e.prototype.dispose.call(this),this.baseColorTexture=void 0,this.metallicRoughnessTexture=void 0,this.normalTexture=void 0,this.occlusionTexture=void 0,this.emissiveTexture=void 0},i.getShaderFeatures=function(){var t=e.prototype.getShaderFeatures.call(this);return t.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&(t.push("HAS_BASE_COLOR_MAP 1"),void 0!==this.baseColorTextureTrans&&t.push("HAS_BASECOLOR_UV_TRANSFORM 1")),this.hasMetallicRoughnessTexture()&&(t.push("HAS_METALLIC_ROUGHNESS_MAP 1"),void 0!==this.metallicRoughnessTextureTrans&&t.push("HAS_METALLICROUGHNESS_UV_TRANSFORM 1")),this.useSpecularAA&&t.push("USE_SPECULAR_AA 1"),this.hasNormalTexture()&&(t.push("HAS_NORMAL_MAP 1"),void 0!==this.normalTextureTrans&&t.push("HAS_NORMAL_UV_TRANSFORM 1")),this.hasOcclusionTexture()&&(t.push("HAS_OCCLUSION_MAP 1"),void 0!==this.occlusionTextureTrans&&t.push("HAS_OCCLUSION_UV_TRANSFORM 1")),this.hasEmissiveTexture()?(t.push("HAS_EMISSIVE_MAP 1"),void 0!==this.emissiveTextureTrans&&t.push("HAS_EMISSIVE_UV_TRANSFORM 1")):this.hasEmissiveValue()&&t.push("HAS_EMISSIVE 1"),t},i.getShaderMacros=function(){var t=e.prototype.getShaderMacros.call(this);return t.push({name:"MATERIAL_METALLICROUGHNESS"}),this.hasBaseColorTexture()&&(t.push({name:"HAS_BASE_COLOR_MAP"}),void 0!==this.baseColorTextureTrans&&t.push({name:"HAS_BASECOLOR_UV_TRANSFORM"})),this.hasMetallicRoughnessTexture()&&(t.push({name:"HAS_METALLIC_ROUGHNESS_MAP"}),void 0!==this.metallicRoughnessTextureTrans&&t.push({name:"HAS_METALLICROUGHNESS_UV_TRANSFORM"})),this.useSpecularAA&&t.push({name:"USE_SPECULAR_AA"}),this.hasNormalTexture()&&(t.push({name:"HAS_NORMAL_MAP"}),void 0!==this.normalTextureTrans&&t.push({name:"HAS_NORMAL_UV_TRANSFORM"})),this.hasOcclusionTexture()&&(t.push({name:"HAS_OCCLUSION_MAP"}),void 0!==this.occlusionTextureTrans&&t.push({name:"HAS_OCCLUSION_UV_TRANSFORM"})),this.hasEmissiveTexture()?(t.push({name:"HAS_EMISSIVE_MAP"}),void 0!==this.emissiveTextureTrans&&t.push({name:"HAS_EMISSIVE_UV_TRANSFORM"})):this.hasEmissiveValue()&&t.push({name:"HAS_EMISSIVE"}),t},i.updateUniforms=function(t){e.prototype.updateUniforms.call(this,t),void 0!==this.baseColorTexture&&(t.setInt("_BaseColorUVSet",0),t.setMatrix3("_BaseColorUVTransform",this.baseColorTextureTrans)),void 0!==this.metallicRoughnessTexture&&(t.setInt("_MetallicRoughnessUVSet",0),t.setMatrix3("_MetallicRoughnessUVTransform",this.metallicRoughnessTextureTrans)),void 0!==this.normalTexture&&(t.setInt("_NormalUVSet",0),t.setMatrix3("_NormalUVTransform",this.normalTextureTrans)),void 0!==this.occlusionTexture&&(t.setInt("_OcclusionUVSet",0),t.setMatrix3("_OcclusionUVTransform",this.occlusionTextureTrans)),void 0!==this.emissiveTexture&&(t.setInt("_EmissiveUVSet",0),t.setMatrix3("_EmissiveUVTransform",this.emissiveTextureTrans)),t.setFloat("_Exposure",3)},i.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},i.setBaseColorTexture=function(e){this.baseColorTexture=e},i.getBaseColorFactor=function(){return this.baseColorFactor},i.setBaseColorFactor=function(e){G(e,ue)?this.baseColorFactor.set(e.r,e.g,e.b,e.a):G(e,se)?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},i.hasMetallicRoughnessTexture=function(){return void 0!==this.metallicRoughnessTexture},i.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture},i.setMetallicRoughnessTexture=function(e){this.metallicRoughnessTexture=e},i.hasNormalTexture=function(){return void 0!==this.normalTexture},i.getNormalTexture=function(){return this.normalTexture},i.setNormalTexture=function(e){this.normalTexture=e},i.hasOcclusionTexture=function(){return void 0!==this.occlusionTexture},i.getOcclusionTexture=function(){return this.occlusionTexture},i.setOcclusionTexture=function(e){this.occlusionTexture=e},i.hasEmissiveTexture=function(){return void 0!==this.emissiveTexture},i.getEmissiveTexture=function(){return this.emissiveTexture},i.setEmissiveTexture=function(e){this.emissiveTexture=e},i.hasEmissiveValue=function(){return this.emissiveFactor.luminance()*this.emissiveIntensity>0},i.getEmissiveFactor=function(){return this.emissiveFactor},i.setEmissiveFactor=function(e){G(e,ue)?this.emissiveFactor.set(e.r,e.g,e.b,e.a):G(e,ae)?this.emissiveFactor.set(e.x,e.y,e.z,0):this.emissiveFactor.set(e[0],e[1],e[2],0)},i.getEmissiveIntensity=function(){return this.emissiveIntensity},i.setEmissiveIntensity=function(e){this.emissiveIntensity=e},t}(Jt);function Zt(e){if(e.shader.getInstanceId()===be){var t=new qt;return t.create(e),t}var n=new Xt;return n.create(e),n}var Yt,Kt=function(e){function t(t,n,i){var r,o;(r=e.call(this)||this).renderable=!0,r.intensity=1,r.reflectionsIntensity=1,r.specularImageSize=0,r.specularMipCount=0,r.priority=0,r.isBuilt=!1,r.name=t,r.type=Q.skybox,r.visible=!1,r.owner=i;var a=n.irradianceCoeffs;if(r.renderable=n.renderable,r.intensity=n.intensity,r.reflectionsIntensity=n.reflectionsIntensity,a){r.irradianceCoeffs=[];for(var s=0;s<a.length;s+=3)r.irradianceCoeffs.push([a[s],a[s+1],a[s+2]])}else r.irradianceCoeffs=[];return r.diffuseImage=n.diffuseImage,r.specularImage=n.specularImage,r.specularImageSize=n.specularImageSize,r.specularMipCount=n.specularMipCount,r.priority=(null==i||null==(o=i.item)?void 0:o.renderOrder)||0,r}V(t,e);var n=t.prototype;return n.setup=function(e){this.brdfLUT=e},n.build=function(e){if(!this.isBuilt){this.isBuilt=!0,this.skyboxMaterial=new Qt,this.skyboxMaterial.create(this),this.skyboxMaterial.build();var t=e.getSceneCache();this.skyboxMesh=t.getFilterMesh("SkyboxFilterPlane",this.skyboxMaterial),this.skyboxMesh.priority=this.priority,this.skyboxMaterial.updateUniforms(this.skyboxMesh.material)}},n.render=function(e,t){if(this.updateMaterial(e),this.visible&&this.renderable&&void 0!==this.skyboxMesh){var n=this.skyboxMesh;t.drawGeometry(n.geometry,ce.IDENTITY,n.material)}},n.dispose=function(){var t;e.prototype.dispose.call(this),this.owner=void 0,this.diffuseImage=void 0,this.specularImage=void 0,this.brdfLUT=void 0,this.skyboxMesh=void 0,null==(t=this.skyboxMaterial)||t.dispose(),this.skyboxMaterial=void 0},n.updateMaterial=function(e){if(this.build(e),this.visible&&this.renderable&&void 0!==this.skyboxMesh&&void 0!==this.skyboxMaterial){var t=e.sceneStates,n=t.camera,i=t.viewMatrix,r=n.getNewProjectionMatrix(n.fov).multiply(i).invert(),o=this.skyboxMesh.material;this.skyboxMaterial.updateUniforms(o),o.setMatrix("_InvViewProjectionMatrix",r)}},Te(t,[{key:"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)))}},{key:"currentIntensity",get:function(){return this.visible?this.intensity:0}},{key:"currentReflectionsIntensity",get:function(){return this.visible?this.reflectionsIntensity:0}},{key:"hasDiffuseImage",get:function(){return void 0!==this.diffuseImage}},{key:"hasIrradianceCoeffs",get:function(){return void 0!==this.irradianceCoeffs}}]),t}(Ee),Qt=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).intensity=1,t.reflectionsIntensity=1,t.specularMipCount=0,t}V(t,e);var n=t.prototype;return n.create=function(e){this.type=Q.material,this.materialType=te.skyboxFilter,this.ZTest=!1,this.name=e.name,this.intensity=e.intensity,this.reflectionsIntensity=e.reflectionsIntensity,this.brdfLUT=e.brdfLUT,this.irradianceCoeffs=e.irradianceCoeffs,this.diffuseImage=e.diffuseImage,this.specularImage=e.specularImage,this.specularMipCount=e.specularMipCount},n.dispose=function(){e.prototype.dispose.call(this),this.brdfLUT=void 0,this.irradianceCoeffs=void 0,this.diffuseImage=void 0,this.specularImage=void 0},n.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.updateUniforms=function(e){if(void 0===this.brdfLUT)throw new Error("Setup brdfLUT for skybox at first.");if(e.setVector2("_IblIntensity",new oe(2,2)),e.setTexture("_brdfLUT",this.brdfLUT),void 0!==this.diffuseImage)e.setTexture("_DiffuseEnvSampler",this.diffuseImage);else{var t=this.irradianceCoeffs;if(void 0===t||9!=t.length)throw new Error("Invalid skybox irradiance coeffs "+t+".");["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(n,i){e.setVector3("_shCoefficients."+n,ae.fromArray(t[i]))}))}e.setInt("_MipCount",this.specularMipCount-1),e.setTexture("_SpecularEnvSampler",this.specularImage)},n.setMaterialStates=function(e){e.depthTest=!0,e.depthMask=!1,this.setFaceSideStates(e)},t}(Jt);!function(e){e[e.NFT=0]="NFT",e[e.FARM=1]="FARM"}(Yt||(Yt={}));var $t=function(){function e(){}return e.prototype.checkCubeMapImage=function(e){return B((function(){var t,n,i,r;return H(this,(function(o){switch(o.label){case 0:n=[],i=0,o.label=1;case 1:return i<e.length?[4,S(e[i])]:[3,4];case 2:if(r=o.sent(),i>0)if(i%6==0){if(2*r.width!==t.width||2*r.height!==t.height)throw new Error("Invalid cube map list1: index "+i+", image0 "+t+", image1 "+r+".")}else if(r.width!==t.width||r.height!==t.height)throw new Error("Invalid cube map list2: index "+i+", image0 "+t+", image1 "+r+".");i%6==0&&n.push([]),n[n.length-1].push(r),t=r,o.label=3;case 3:return i++,[3,1];case 4:return[2]}}))}))()},e.getBrdfLutTextureOptions=function(){return B((function(){var e;return H(this,(function(t){switch(t.label){case 0:return"https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png",[4,S("https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png")];case 1:return e=t.sent(),[2,{name:"brdfLut",wrapS:a.CLAMP_TO_EDGE,wrapT:a.CLAMP_TO_EDGE,magFilter:a.LINEAR,minFilter:a.LINEAR,anisotropic:1,sourceType:p.image,image:e,generateMipmap:!1,flipY:!1,premultiplyAlpha:!1}]}}))}))()},e.createBrdfLutTexture=function(e){var t=this;return B((function(){var n;return H(this,(function(i){switch(i.label){case 0:return[4,t.getBrdfLutTextureOptions()];case 1:return n=i.sent(),[2,v.create(e,n)]}}))}))()},e.createSkyboxOptions=function(e,t){var n=this;return B((function(){var i,r,o,a,s,l,c,u;return H(this,(function(h){switch(h.label){case 0:return[4,n.createSpecularCubeMap(e,t)];case 1:return i=h.sent(),[4,n.createDiffuseCubeMap(e,t)];case 2:return r=h.sent(),o=t.renderable,a=t.intensity,s=t.reflectionsIntensity,l=t.irradianceCoeffs,c=t.specularImageSize,u=t.specularMipCount,[2,{renderable:o,intensity:a,reflectionsIntensity:s,irradianceCoeffs:l,diffuseImage:r,specularImage:i,specularImageSize:c,specularMipCount:u}]}}))}))()},e.createSkyboxComponentData=function(t){var i,r,o,a=e.getSpecularCubeMapData(t),s=e.getDiffuseCubeMapData(t),l=t.renderable,c=t.intensity,u=t.reflectionsIntensity,h=t.irradianceCoeffs,f=t.specularImageSize,d=t.specularMipCount,m=[],g=[];s&&((o=m).push.apply(o,[].concat(s.images)),g.push(s.textureOptions),r={id:s.textureOptions.id});(i=m).push.apply(i,[].concat(a.images)),g.push(a.textureOptions);var p={id:a.textureOptions.id};return{imageList:m,textureOptionsList:g,component:{id:A(),dataType:n.DataType.SkyboxComponent,item:{id:A()},renderable:l,intensity:c,reflectionsIntensity:u,irradianceCoeffs:h,diffuseImage:r,specularImage:p,specularImageSize:f,specularMipCount:d}}},e.createSpecularCubeMap=function(e,t){return B((function(){return H(this,(function(n){return"url"===t.type?[2,Mt.createTextureCubeMipmapFromURL(e,t.specularImage)]:[2,Mt.createTextureCubeMipmapFromBuffer(e,t.specularImage,t.specularImageSize)]}))}))()},e.getSpecularCubeMapData=function(e){var t=[],i=[];e.specularImage.forEach((function(e){var n=[];e.forEach((function(e){var i=A();t.push({id:i,url:e}),n.push({id:i})})),i.push(n)}));var r=_e({id:A(),dataType:n.DataType.Texture,sourceType:p.mipmaps,target:a.TEXTURE_CUBE_MAP,mipmaps:i},Mt.cubemapMipTexConfig);return{images:t,textureOptions:r}},e.createDiffuseCubeMap=function(e,t){return B((function(){return H(this,(function(n){return void 0===t.diffuseImage?[2,null]:"url"===t.type?[2,Mt.createTextureCubeFromURL(e,t.diffuseImage)]:[2,Mt.createTextureCubeFromBuffer(e,t.diffuseImage)]}))}))()},e.getDiffuseCubeMapData=function(e){if(void 0!==e.diffuseImage){var t=[],i=[];e.diffuseImage.forEach((function(e){var n=A();t.push({id:n,url:e}),i.push({id:n})}));var r=_e({id:A(),dataType:n.DataType.Texture,sourceType:p.mipmaps,target:a.TEXTURE_CUBE_MAP,mipmaps:[i]},Mt.cubemapTexConfig);return{images:t,textureOptions:r}}},e.getSkyboxParams=function(e){void 0===e&&(e=0);var t=this.getSpecularImageList(e);return{type:"url",renderable:!0,intensity:1.8,reflectionsIntensity:1.8,irradianceCoeffs:this.getIrradianceCoeffs(e),diffuseImage:this.getDiffuseImageList(e,t),specularImage:t,specularImageSize:Math.pow(2,t.length-1),specularMipCount:t.length}},e.getIrradianceCoeffs=function(e){var t=[];switch(e){case 0:return;case 1:t=[.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:t=[.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]}return t},e.getDiffuseImageList=function(e,t){if(0==e)return t[t.length-1]},e.getSpecularImageList=function(e){var t,n,i=[];1===e?(t=i).push.apply(t,[].concat(this.getSpecularImageListAntFarm())):(n=i).push.apply(n,[].concat(this.getSpecularImageListNFT()));var r=[];return i.forEach((function(e,t){t%6==0&&r.push([]),r[r.length-1].push(e)})),r},e.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"]},e.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"]},e}(),en=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}var t=e.prototype;return t.setup=function(t){if(this.loadSkybox=t,void 0===this.brdfLutTexture||this.brdfLutTexture.isDestroyed){if(void 0===e.brdfLutTexOptions)throw new Error("Please load brdfLutTexOptions at first.");var n="brdfLutTexture";this.brdfLutTexture=v.create(this.engine,e.brdfLutTexOptions),this.deleteTexture(n),this.setTexture(n,this.brdfLutTexture)}},t.getTexture=function(e){return this.textureCache.get(e)},t.setTexture=function(e,t){this.textureCache.set(e,t)},t.getOrCreateTexture=function(e,t){var n=this.textureCache.get(e);if(void 0!==n)return n;var i=v.create(this.engine,t);return this.textureCache.set(e,i),i},t.deleteTexture=function(e){var t=this.textureCache.get(e);return void 0!==t&&t.dispose(),this.textureCache.delete(e)},t.getOrCreateGeometry=function(e,t,n){var i=this.geometryCache.get(e);if(void 0!==i)return i;var r=Lt.createGeometry(this.engine,t,n);return this.geometryCache.set(e,r),r},t.getFilterMesh=function(e,t){var n=this.meshCache.get(e);if(void 0!==n)return n;var i=Nt.createFilterMesh(this.engine,e,t);return this.meshCache.set(e,i),i},t.dispose=function(){this.engine=null,this.brdfLutTexture=void 0,this.meshCache.forEach((function(e){Mt.deleteMesh(e)})),this.meshCache.clear(),this.textureCache.forEach((function(e){Mt.deleteTexture(e)})),this.textureCache.clear(),this.geometryCache.forEach((function(e){Mt.deleteGeometry(e)})),this.geometryCache.clear(),this.renderPassCache.forEach((function(e){Mt.deleteRenderPass(e)})),this.renderPassCache.clear()},t.getRenderPasses=function(){var e=[];return this.renderPassCache.forEach((function(t){e.push(t)})),e},t.getBrdfLutTexture=function(){return this.brdfLutTexture},t.getSkyboxOptions=function(){return e.skyboxOptions},e.loadStaticResources=function(){var e=this;return B((function(){return H(this,(function(t){switch(t.label){case 0:return void 0!==e.brdfLutTexOptions?[2]:[4,$t.getBrdfLutTextureOptions()];case 1:return e.brdfLutTexOptions=t.sent(),[2]}}))}))()},e.genSkyboxOptions=function(t,n){return B((function(){var i;return H(this,(function(r){switch(r.label){case 0:return void 0===(i=n)&&(i=$t.getSkyboxParams()),[4,$t.createSkyboxOptions(t,i)];case 1:return e.skyboxOptions=r.sent(),[2,e.skyboxOptions]}}))}))()},e}(),tn=Math.PI/180,nn=function(e){function t(t,i,r,o,a){var s,l,c,u,h,f;return(s=e.call(this)||this).width=512,s.height=512,s.nearPlane=.001,s.farPlane=1e3,s.fov=45,s.viewportMatrix=ce.fromIdentity(),s.aspect=1,s.clipMode=n.CameraClipMode.landscape,s.projectionMatrix=new ce,s.viewMatrix=new ce,s.type=Q.camera,s.visible=!1,s.owner=a,s.name=t,s.width=i,s.height=r,s.nearPlane=null!=(l=o.near)?l:.001,s.farPlane=null!=(c=o.far)?c:1e3,s.fov=null!=(u=o.fov)?u:45,s.aspect=null!=(h=o.aspect)?h:s.width/s.height,s.clipMode=null!=(f=o.clipMode)?f:n.CameraClipMode.landscape,s.update(),s}V(t,e);var i=t.prototype;return i.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform);var e=this.clipMode===n.CameraClipMode.portrait;this.projectionMatrix.perspective(this.fov*tn,this.aspect,this.nearPlane,this.farPlane,e),this.projectionMatrix.premultiply(this.viewportMatrix),this.viewMatrix=this.matrix.invert()},i.getNewProjectionMatrix=function(e){var t=this.clipMode===n.CameraClipMode.portrait;return(new ce).perspective(Math.min(1.25*e,140)*tn,this.aspect,this.nearPlane,this.farPlane,t).premultiply(this.viewportMatrix)},i.computeViewAABB=function(e){var t=Math.tan(this.fov*tn*.5),n=this.aspect,i=0,r=0,o=0,a=0;this.isReversed()?(i=(o=this.farPlane*t)/n,r=(a=this.nearPlane*t)/n):(o=n*(i=this.farPlane*t),a=n*(r=this.nearPlane*t)),e.makeEmpty();var s=this.matrix;return e.expandByPoint(s.transformPoint(new ae(o,i,-this.farPlane))),e.expandByPoint(s.transformPoint(new ae(o,-i,-this.farPlane))),e.expandByPoint(s.transformPoint(new ae(-o,i,-this.farPlane))),e.expandByPoint(s.transformPoint(new ae(-o,-i,-this.farPlane))),e.expandByPoint(s.transformPoint(new ae(a,r,-this.nearPlane))),e.expandByPoint(s.transformPoint(new ae(a,-r,-this.nearPlane))),e.expandByPoint(s.transformPoint(new ae(-a,r,-this.nearPlane))),e.expandByPoint(s.transformPoint(new ae(-a,-r,-this.nearPlane))),e},i.getSize=function(){return new oe(this.width,this.height)},i.isReversed=function(){return this.clipMode===n.CameraClipMode.portrait},i.getEye=function(){return this.translation},i.setEye=function(e){this.translation=e},t}(Ee),rn=function(){function e(){this.winWidth=512,this.winHeight=512,this.cameraList=[],this.defaultCamera=new nn("camera",512,512,{id:"0",dataType:"camera",fov:60,far:1e3,near:.001,clipMode:n.CameraClipMode.portrait,item:{id:"0"}})}var t=e.prototype;return t.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()},t.insert=function(e,t,n){var i=new nn(e,this.winWidth,this.winHeight,t,n);return this.cameraList.push(i),i},t.insertCamera=function(e){this.cameraList.push(e)},t.remove=function(e){if(G(e,nn)){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)},t.dispose=function(){this.cameraList=[]},t.updateDefaultCamera=function(e,t,n,i,r,o,a,s){this.defaultCamera.fov=e,this.defaultCamera.viewportMatrix=t.clone(),this.defaultCamera.aspect=n,this.defaultCamera.nearPlane=i,this.defaultCamera.farPlane=r,this.defaultCamera.position=o,this.defaultCamera.rotation=a,this.defaultCamera.aspect=n,this.defaultCamera.clipMode=s,this.defaultCamera.update()},t.getCameraList=function(){return this.cameraList},t.getDefaultCamera=function(){return this.defaultCamera},t.getCameraCount=function(){return this.cameraList.length},t.getActiveCamera=function(){return this.defaultCamera},t.getAspect=function(){return this.winWidth/this.winHeight},e}(),on=function(e){function t(t,i,r){var o;(o=e.call(this)||this).direction=new ae(0,0,1),o.range=0,o.color=new ae(1,1,1),o.intensity=0,o.outerConeAngle=0,o.innerConeAngle=0,o.lightType=$.ambient,o.padding=new oe(0,0),o.followCamera=!1,o.name=t,o.type=Q.light,o.visible=!1,o.owner=r,o.direction=new ae(0,0,-1),o.range=0,o.outerConeAngle=0,o.innerConeAngle=0;var a,s,l=i.color;if(o.color=new ae(l.r,l.g,l.b),o.intensity=i.intensity,o.followCamera=null!=(a=i.followCamera)&&a,i.lightType===n.LightType.point)o.lightType=$.point,o.range=null!=(s=i.range)?s:-1;else if(i.lightType===n.LightType.spot){var c,u,h;o.lightType=$.spot,o.range=null!=(c=i.range)?c:-1,o.outerConeAngle=null!=(u=i.outerConeAngle)?u:Math.PI,o.innerConeAngle=null!=(h=i.innerConeAngle)?h:0}else i.lightType===n.LightType.directional?o.lightType=$.directional:o.lightType=$.ambient;return o.update(),o}V(t,e);var i=t.prototype;return i.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform)},i.isDirectional=function(){return this.lightType===$.directional},i.isPoint=function(){return this.lightType===$.point},i.isSpot=function(){return this.lightType===$.spot},i.isAmbient=function(){return this.lightType===$.ambient},i.getWorldPosition=function(){return this.translation},i.getWorldDirection=function(){return this.matrix.transformNormal(this.direction,new ae)},Te(t,[{key:"position",get:function(){return this.translation}}]),t}(Ee),an=function(){function e(){this.lightList=[]}var t=e.prototype;return t.insertItem=function(e,t,n){var i=new on(e,t,n);return this.lightList.push(i),i},t.insertLight=function(e){return this.lightList.push(e),e},t.remove=function(e){var t=this.lightList.findIndex((function(t){return t===e}));-1!==t&&this.lightList.splice(t,1)},t.dispose=function(){this.lightList=[]},Te(e,[{key:"lightCount",get:function(){return this.lightList.length}}]),e}();var sn=function(e){function t(t,n,i,r,o,a){var s,l;(s=e.call(this)||this).engine=t,s.parentIndex=-1,s.subMeshes=[],s.hide=!0,s.priority=0,s.boundingBox=new me,s.visBoundingBox=!1,s.isBuilt=!1,s.isDisposed=!1;var c=new un(i,r,a);s.name=n,s.type=Q.mesh,s.visible=!1,s.owner=r,s.parentIndex=c.getParentIndex(),s.parentItem=c.parentItem,s.parentItemId=o,s.rootBoneItem=i.rootBone,s.skin=c.getSkinObj(t),s.morph=c.getMorphObj(),s.hide=c.isHide(),s.priority=(null==r||null==(l=r.item)?void 0:l.renderOrder)||0,s.subMeshes=[];var u,h=c.getGeometry();return(null!=(u=null==r?void 0:r.materials)?u:[]).forEach((function(e){var t=new ln(s.engine);t.create(h,e,function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(s)),s.subMeshes.push(t)})),s.subMeshes.length<=0&&console.warn("No primitive inside mesh item "+n+"."),s.boundingBox=s.getItemBoundingBox(i.interaction),s}V(t,e);var i=t.prototype;return i.build=function(e){this.isBuilt||(this.isBuilt=!0,this.subMeshes.forEach((function(t){t.build(e.maxLightCount,e.skybox)})),Ae.getInstance().visBoundingBox&&(this.boundingBoxMesh=new Ge(this.engine,this.priority)))},i.update=function(){void 0!==this.owner&&(this.transform.fromEffectsTransform(this.owner.transform),this.morph&&this.morph.hasMorph()&&this.owner.morphWeights.length>0&&this.morph.updateWeights(this.owner.morphWeights))},i.lateUpdate=function(){var e;null==(e=this.skin)||e.updateSkinMatrices()},i.render=function(e,t){var n=this;if(this.updateMaterial(e),this.subMeshes.forEach((function(e,i){t.drawGeometry(e.getEffectsGeometry(),n.matrix,e.getEffectsMaterial(),i)})),this.visBoundingBox&&void 0!==this.boundingBoxMesh){var i=this.boundingBoxMesh.mesh;t.drawGeometry(i.geometry,ce.IDENTITY,i.material)}},i.dispose=function(){var t,n,i;this.isDisposed||(e.prototype.dispose.call(this),this.owner=void 0,this.isDisposed=!0,this.engine=null,this.parentItem=void 0,null==(t=this.skin)||t.dispose(),this.skin=void 0,null==(n=this.morph)||n.dispose(),this.morph=void 0,this.subMeshes.forEach((function(e){e.dispose()})),this.subMeshes=[],null==(i=this.boundingBoxMesh)||i.dispose(),this.boundingBoxMesh=void 0)},i.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]}}},i.updateParentInfo=function(e,t){this.parentItemId=e,this.parentItem=t,void 0!==this.skin&&this.skin.updateParentItem(t)},i.updateMaterial=function(e){var t=this.matrix,n=t.clone().invert().transpose(),i=e.sceneStates;if(this.subMeshes.forEach((function(e){e.updateMaterial(t,n,i)})),void 0!==this.boundingBoxMesh){this.computeBoundingBox(t);var r=new ae(1,1,1),o=this.boundingBox.min,a=this.boundingBox.max,s=new Float32Array([o.x,o.y,o.z,a.x,o.y,o.z,a.x,a.y,o.z,o.x,a.y,o.z,o.x,o.y,a.z,a.x,o.y,a.z,a.x,a.y,a.z,o.x,a.y,a.z]);this.boundingBoxMesh.update(t,i.viewProjectionMatrix,s,r)}},i.hitTesting=function(e,t){var n,i=this.matrix,r=i.clone().invert(),o=r.transformPoint(e,new ae),a=r.transformNormal(t,new ae),s=this.boundingBox,l=yt(o,a,s.min,s.max);return void 0===l?[]:(Ae.getInstance().isEditorEnv?this.subMeshes.forEach((function(e){var t=e.hitTesting(o,a,i,r);void 0!==t&&(void 0===n||n>t)&&(n=t)})):n=l,void 0===n?[]:(a.multiply(n),o.add(a),i.transformPoint(o),[o]))},i.computeBoundingBox=function(e){var t=this.boundingBox.makeEmpty(),n=e.clone().invert();return this.subMeshes.forEach((function(e){var i=e.computeBoundingBox(n);t.union(i)})),t},i.getItemBoundingBox=function(e){if(void 0===e)return new me;if(e.type===n.ModelBoundingType.box){var t,i,r=null!=(t=e.center)?t:[0,0,0],o=null!=(i=e.size)?i:[0,0,0],a=ae.fromArray(r),s=ae.fromArray(o).multiply(.5),l=a.clone().subtract(s),c=a.clone().add(s);return new me(l,c)}var u,h,f=null!=(u=e.center)?u:[0,0,0],d=.5*(null!=(h=e.radius)?h:0),m=ae.fromArray(f),g=m.clone().subtract(d),p=m.clone().add(d);return new me(g,p)},i.getParentId=function(){return this.parentItemId},Te(t,[{key:"hasSkin",get:function(){return void 0!==this.skin}}]),t}(Ee),ln=function(){function e(e){this.engine=e,this.name="",this.effectsPriority=0,this.boundingBox=new me,this.isCompressed=!1}var t=e.prototype;return t.create=function(e,t,n){if(this.parent=n,this.skin=n.skin,this.morph=n.morph,this.setGeometry(e),this.setMaterial(t),this.name=n.name,this.effectsPriority=n.priority,this.geometry.setHide(n.hide),void 0!==this.skin){var i=this.skin.maxJointCount;if(this.jointMatrixList=new Float32Array(16*i),this.jointNormalMatList=new Float32Array(16*i),this.skin.isTextureDataMode()){var r=this.skin.textureDataMode===wt.half_float;this.jointMatrixTexture=new jt(this.engine),this.jointNormalMatTexture=new jt(this.engine),this.jointMatrixTexture.create(i,r,"jointMatrixTexture"),this.jointNormalMatTexture.create(i,r,"jointNormalMatTexture")}}else(this.geometry.hasWeights()||this.geometry.hasJoints())&&console.warn("Geometry has weight and/or joint array, but the skin is missing.");this.isCompressed=this.geometry.isCompressed()},t.build=function(e,t){var n,i=Ae.getInstance(),r=this.getMacroList(e,!0,t),o=this.material.getMacroList(r),a=Ae.getInstance().isWebGL2;this.material.effectMaterial?(n=this.material.effectMaterial,o.forEach((function(e){var t=e.name,i=e.value;n.enableMacro(t,i)})),this.material.setMaterialStates(n)):(n=s.create(this.engine,{shader:{vertex:this.material.vertexShaderCode,fragment:this.material.fragmentShaderCode,shared:i.shaderShared,glslVersion:a?_.GLSL3:_.GLSL1}}),this.material.setMaterialStates(n))},t.getFeatureList=function(e,t,n){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 "+this.morph.morphWeightsLength);for(var r=0;r<this.morph.morphWeightsLength;r++)this.morph.hasPositionMorph&&i.push("HAS_TARGET_POSITION"+r),this.morph.hasNormalMorph&&i.push("HAS_TARGET_NORMAL"+r),this.morph.hasTangentMorph&&i.push("HAS_TARGET_TANGENT"+r)}void 0!==this.skin&&(i.push("USE_SKINNING 1"),i.push("JOINT_COUNT "+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.material.materialType!==te.unlit&&(e>0&&this.geometry.hasNormals()&&(i.push("USE_PUNCTUAL 1"),i.push("LIGHT_COUNT "+e)),void 0!==n&&n.available&&(i.push("USE_IBL 1"),i.push("USE_TEX_LOD 1"),n.hasDiffuseImage||i.push("IRRADIANCE_COEFFICIENTS 1")));var o=Ae.getInstance().renderMode3D,a=this.getRenderMode3DDefine(o);return void 0!==a&&(i.push("DEBUG_OUTPUT 1"),i.push(a+" 1")),i},t.getMacroList=function(e,t,n){var i=[];if(this.geometry.hasNormals()&&i.push({name:"HAS_NORMALS"}),this.geometry.hasTangents()&&i.push({name:"HAS_TANGENTS"}),this.geometry.hasUVCoords(1)&&i.push({name:"HAS_UV_SET1"}),this.geometry.hasUVCoords(2)&&i.push({name:"HAS_UV_SET2"}),void 0!==this.morph&&this.morph.hasMorph()){i.push({name:"USE_MORPHING"}),i.push({name:"WEIGHT_COUNT",value:this.morph.morphWeightsLength});for(var r=0;r<this.morph.morphWeightsLength;r++)this.morph.hasPositionMorph&&i.push({name:"HAS_TARGET_POSITION"+r}),this.morph.hasNormalMorph&&i.push({name:"HAS_TARGET_NORMAL"+r}),this.morph.hasTangentMorph&&i.push({name:"HAS_TARGET_TANGENT"+r})}void 0!==this.skin&&(i.push({name:"USE_SKINNING"}),i.push({name:"JOINT_COUNT",value:this.skin.maxJointCount}),i.push({name:"HAS_JOINT_SET1"}),i.push({name:"HAS_WEIGHT_SET1"}),this.skin.textureDataMode&&i.push({name:"USE_SKINNING_TEXTURE"})),this.material.materialType!==te.unlit&&(e>0&&this.geometry.hasNormals()&&(i.push({name:"USE_PUNCTUAL"}),i.push({name:"LIGHT_COUNT",value:e})),void 0!==n&&n.available&&(i.push({name:"USE_IBL"}),i.push({name:"USE_TEX_LOD"}),n.hasDiffuseImage||i.push({name:"IRRADIANCE_COEFFICIENTS"})));var o=Ae.getInstance().renderMode3D,a=this.getRenderMode3DDefine(o);return void 0!==a&&(i.push({name:"DEBUG_OUTPUT"}),i.push({name:a})),i},t.dispose=function(){var e,t;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)||e.dispose(),this.jointMatrixTexture=void 0,null==(t=this.jointNormalMatTexture)||t.dispose(),this.jointNormalMatTexture=void 0},t.updateMaterial=function(e,t,n){this.updateUniformsByAnimation(e,t),this.updateUniformsByScene(n),this.material.updateUniforms(this.getEffectsMaterial())},t.hitTesting=function(e,t,n,i){var r=this.boundingBox,o=yt(e,t,r.min,r.max),a=[];if(void 0!==o){if(void 0!==this.skin)this.skin.animationMatrices.forEach((function(e){a.push((new ce).multiplyMatrices(i,e))}));var s=new Dt,l=this.material.isBothSide();return s.create(this.geometry.geometry,l,a),s.getHitPoint(e,t)}},t.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 ce).multiplyMatrices(e,n))}));var n=new Ut;return n.create(this.geometry.geometry,t),n.getBoundingBox(this.boundingBox)},t.getRenderMode3DDefine=function(e){switch(e){case n.RenderMode3D.uv:return"DEBUG_UV";case n.RenderMode3D.normal:return"DEBUG_NORMAL";case n.RenderMode3D.basecolor:return"DEBUG_BASECOLOR";case n.RenderMode3D.alpha:return"DEBUG_ALPHA";case n.RenderMode3D.metallic:return"DEBUG_METALLIC";case n.RenderMode3D.roughness:return"DEBUG_ROUGHNESS";case n.RenderMode3D.ao:return"DEBUG_OCCLUSION";case n.RenderMode3D.emissive:return"DEBUG_EMISSIVE";case n.RenderMode3D.diffuse:return"DEBUG_DIFFUSE"}},t.updateUniformsByAnimation=function(e,t){var n=this.getEffectsMaterial();n.setMatrix("_NormalMatrix",t);var i=this.skin;if(void 0!==i){var r=this.jointMatrixList,o=this.jointNormalMatList;if(i.computeMeshAnimMatrices(e,r,o),i.textureDataMode){var a=this.jointMatrixTexture,s=this.jointNormalMatTexture;a.update(r),s.update(o),n.setTexture("_jointMatrixSampler",a.getTexture()),n.setTexture("_jointNormalMatrixSampler",s.getTexture())}else{var l=[],c=[];r.forEach((function(e){return l.push(e)})),o.forEach((function(e){return c.push(e)})),n.setMatrixNumberArray("_jointMatrix",l),n.setMatrixNumberArray("_jointNormalMatrix",c)}}var u=this.morph;if(void 0!==u&&u.hasMorph()){var h=u.morphWeightsArray.slice();n.setFloats("_morphWeights",h)}},t.updateUniformsByScene=function(e){var t=this.getEffectsMaterial();if(t.setVector3("_Camera",e.cameraPosition),!this.isUnlitMaterial()){for(var n=e.maxLightCount,i=e.lightList,r=e.inverseViewMatrix,o=0;o<n;o++)if(o<i.length){var a=i[o],s=a.visible?a.intensity:0;if(a.followCamera){var l=r.transformNormal(a.getWorldDirection(),new ae),c=r.transformPoint(a.getWorldPosition(),new ae);t.setVector3("_Lights["+o+"].direction",l),t.setVector3("_Lights["+o+"].position",c)}else t.setVector3("_Lights["+o+"].direction",a.getWorldDirection()),t.setVector3("_Lights["+o+"].position",a.getWorldPosition());t.setFloat("_Lights["+o+"].range",a.range),t.setVector3("_Lights["+o+"].color",a.color),t.setFloat("_Lights["+o+"].intensity",s),t.setFloat("_Lights["+o+"].innerConeCos",Math.cos(a.innerConeAngle)),t.setFloat("_Lights["+o+"].outerConeCos",Math.cos(a.outerConeAngle)),t.setInt("_Lights["+o+"].type",a.lightType),t.setVector2("_Lights["+o+"].padding",a.padding)}else t.setVector3("_Lights["+o+"].direction",ae.ZERO),t.setFloat("_Lights["+o+"].range",0),t.setVector3("_Lights["+o+"].color",ae.ZERO),t.setFloat("_Lights["+o+"].intensity",0),t.setVector3("_Lights["+o+"].position",ae.ZERO),t.setFloat("_Lights["+o+"].innerConeCos",0),t.setFloat("_Lights["+o+"].outerConeCos",0),t.setInt("_Lights["+o+"].type",99999),t.setVector2("_Lights["+o+"].padding",oe.ZERO);var u=e.skybox;if(void 0!==u&&u.available){if(t.setVector2("_IblIntensity",new oe(u.currentIntensity,u.currentReflectionsIntensity)),t.setTexture("_brdfLUT",u.brdfLUT),void 0!==u.diffuseImage)t.setTexture("_DiffuseEnvSampler",u.diffuseImage);else{var h=u.irradianceCoeffs;["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(e,n){t.setVector3("_shCoefficients."+e,ae.fromArray(h[n]))}))}t.setInt("_MipCount",u.specularMipCount-1),t.setTexture("_SpecularEnvSampler",u.specularImage)}}},t.hasSkin=function(){return void 0!==this.skin},t.getEffectsGeometry=function(){return this.geometry.geometry},t.setGeometry=function(e){G(e,cn)?this.geometry=e:this.geometry=new cn(e)},t.setMaterial=function(e){G(e,Xt)||G(e,qt)?this.material=e:this.material=Zt(e)},t.getEffectsMaterial=function(){return this.material.effectMaterial},t.isUnlitMaterial=function(){return this.material.materialType===te.unlit},t.hasMorph=function(){return void 0!==this.morph&&this.morph.hasMorph()},t.getWorldBoundingBox=function(){if(void 0===this.parent)return this.boundingBox.isEmpty()&&this.computeBoundingBox(ce.fromIdentity()),this.boundingBox;var e=this.parent.matrix;return this.boundingBox.isEmpty()&&this.computeBoundingBox(e.clone().invert()),this.boundingBox.clone().applyMatrix4(e)},e}(),cn=function(){function e(e){this.geometry=e,this.attributeNames=e.getAttributeNames()}var t=e.prototype;return t.dispose=function(){this.geometry=void 0,this.attributeNames=[]},t.hasAttribute=function(e){return-1!==this.attributeNames.findIndex((function(t){return t===e}))},t.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())},t.isCompressed=function(){this.geometry.getAttributeData("aPos");return!1},t.hasPositions=function(){return this.hasAttribute("aPos")},t.hasNormals=function(){return this.hasAttribute("aNormal")},t.hasTangents=function(){return this.hasAttribute("aTangent")},t.hasUVCoords=function(e){return 1===e?this.hasAttribute("aUV"):this.hasAttribute("aUV"+e)},t.hasColors=function(){return this.hasAttribute("aColor")},t.hasJoints=function(){return this.hasAttribute("aJoints")},t.hasWeights=function(){return this.hasAttribute("aWeights")},e}(),un=function(){function e(e,t,n){this.itemData=e,this.parentComponent=t,this.parentItem=n,this.data=e,this.geometry=e.geometry,this.rootBoneItem=e.rootBone;var i=new Ht;if(i.create(this.geometry)){var r,o;if(null==(r=e.morph)?void 0:r.weights)i.initWeights(null==(o=e.morph)?void 0:o.weights);this.morphObj=i}}var t=e.prototype;return t.hasMorphTarget=function(){return this.morphObj.hasMorph()},t.getMorphObj=function(){if(this.hasMorphTarget())return this.morphObj},t.isHide=function(){return!0===this.data.hide},t.getParentIndex=function(){return-1},t.getGeometry=function(){return this.data.geometry},t.getMaterials=function(){return this.data.materials},t.getMaterialCount=function(){return this.data.materials.length},t.hasSkin=function(){var e=this.geometry.getSkinProps();return!!(e.rootBoneName&&e.boneNames&&e.inverseBindMatrices&&this.rootBoneItem)},t.getSkinOpts=function(){return this.geometry.getSkinProps()},t.getSkinObj=function(e){var t=this.getSkinOpts();if(t.rootBoneName&&t.boneNames&&t.inverseBindMatrices&&this.rootBoneItem){var n,i,r=new zt,o=null!=(i=null==(n=this.parentComponent.sceneManager)?void 0:n.maxJointCount)?i:0;return r.create(t,e,this.rootBoneItem,o),r}},e}(),hn=function(){function e(e){this.maxLightCount=16,this.maxJointCount=0,this.renderSkybox=!1,this.compName="SceneManger",this.itemList=[],this.meshList=[],this.engine=e,this.lightManager=new an,this.cameraManager=new rn,this.parentId2Mesh=new Map,this.enableDynamicSort=!1,this.tickCount=0,this.lastTickSecond=-1,this.sceneAABBCache=new me,this.renderedMeshSet=new ct}var t=e.prototype;return t.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.maxJointCount=e.maxJointCount,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: "+this.maxLightCount+" light(s).")},t.initGlobalState=function(e){var t,i,o,a,s,l=this.engine.gpuCapability,c=Ae.getInstance();c.reset(),c.isWebGL2=2===l.level,c.runtimeEnv=null!=(t=e.runtimeEnv)?t:r,c.compatibleMode=null!=(i=e.compatibleMode)?i:"gltf",c.visBoundingBox=null!=(o=e.visBoundingBox)&&o,c.renderMode3D=null!=(a=e.renderMode3D)?a:n.RenderMode3D.none,c.renderMode3DUVGridSize=null!=(s=e.renderMode3DUVGridSize)?s:1/16},t.clean=function(){this.dispose(),this.compName="",this.renderer=void 0,this.sceneCache=void 0,this.itemList=[],this.meshList=[],this.lightManager=new an,this.cameraManager=new rn,this.parentId2Mesh=new Map,this.brdfLUT=void 0,this.skybox=void 0,this.lastTickSecond=-1,this.tickCount=0,this.renderedMeshSet=new ct},t.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)||e.dispose(),this.skybox=void 0,this.renderedMeshSet.clear(),this.renderer=void 0,this.sceneCache=void 0,this.engine=void 0,this.parentId2Mesh.clear()},t.addItem=function(e){if(G(e,sn)){var t=e;void 0!==t.parentItemId&&this.parentId2Mesh.set(t.parentItemId,t),M(this.meshList,t)}else if(G(e,Kt)){var n=e;n.setup(this.brdfLUT),this.renderSkybox||(n.renderable=!1),this.skybox=n}else G(e,on)?this.lightManager.insertLight(e):this.cameraManager.insertCamera(e);M(this.itemList,e)},t.removeItem=function(e){if(G(e,sn)){var t=e;void 0!==t.parentItemId&&this.parentId2Mesh.delete(t.parentItemId),I(this.meshList,t)}else G(e,Kt)?this.skybox=void 0:G(e,on)?this.lightManager.remove(e):this.cameraManager.remove(e);I(this.itemList,e)},t.updateDefaultCamera=function(e,t){var n=new i(_e({},e,{valid:!0})),r=(new xe).fromEffectsTransform(n);this.cameraManager.updateDefaultCamera(e.fov,t,e.aspect,e.near,e.far,r.getPosition(),r.getRotation(),e.clipMode)},t.tick=function(e){var t=e,n=this.activeCamera,i=n.viewMatrix,r=n.projectionMatrix,o=r.clone().multiply(i);this.sceneStates={deltaSeconds:t,camera:n,cameraPosition:n.getEye(),viewMatrix:i,inverseViewMatrix:i.clone().invert(),projectionMatrix:r,viewProjectionMatrix:o,winSize:n.getSize(),sceneRadius:1,lightList:this.lightManager.lightList,maxLightCount:this.maxLightCount,maxJointCount:this.maxJointCount,skybox:this.skybox},this.enableDynamicSort&&this.dynamicSortMeshes(this.sceneStates),this.tickCount+=1,this.lastTickSecond+=t},t.dynamicSortMeshes=function(e){var t=[],n=[];this.meshList.forEach((function(e){if(e.owner&&e.owner.enabled){var i=e.owner;t.push(i),n.push(i.priority)}})),n.sort((function(e,t){return e-t}));var i=e.viewMatrix;t.sort((function(e,t){var n=Mt.isTransparentMesh(e),r=Mt.isTransparentMesh(t);if(n&&r){var o=e.transform.getWorldPosition(),a=t.transform.getWorldPosition(),s=i.transformPoint(o),l=i.transformPoint(a);return s.z===l.z?e.priority-t.priority:s.z-l.z}return n?1:r?-1:e.priority-t.priority}));for(var r=-99999,o=0;o<t.length;o++){var a=t[o],s=n[o];r<s?(r=s,a.priority=s):(r+=.1,a.priority=r)}},t.queryMesh=function(e){var t=this.parentId2Mesh.get(e);if(void 0!==t&&t.visible)return t},t.getSceneAABB=function(e){var t=null!=e?e:new me;return this.itemList.forEach((function(e){if(e.type===Q.mesh){var n=e;if(n.owner){var i=n.owner.item.getWorldTransform().getWorldMatrix(),r=n.computeBoundingBox(i);r.applyMatrix4(i),t.union(r)}else t.union(n.computeBoundingBox(ce.fromIdentity()))}})),t},t.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("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")},t.getRenderer=function(){return this.renderer},t.getSceneCache=function(){return this.sceneCache},Te(e,[{key:"activeCamera",get:function(){return this.cameraManager.getActiveCamera()}},{key:"lightCount",get:function(){return this.lightManager.lightCount}},{key:"shaderLightCount",get:function(){return Math.min(10,this.lightManager.lightCount)}}]),e}(),fn=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).name="model",t}V(t,e);var i=t.prototype;return i.precompile=function(e,t){var i=2===t.engine.gpuCapability.level,r=qe(),o=Ze(),a={id:be,name:"PBR Shader",dataType:n.DataType.Shader,fragment:r.fragmentShaderCode,vertex:r.vertexShaderCode,glslVersion:i?_.GLSL3:_.GLSL1},s={id:Ce,name:"Unlit Shader",dataType:n.DataType.Shader,fragment:o.fragmentShaderCode,vertex:o.vertexShaderCode,glslVersion:i?_.GLSL3:_.GLSL1};return t.engine.addEffectsObjectData(a),t.engine.addEffectsObjectData(s),Promise.resolve()},i.onCompositionConstructed=function(e,t){this.sceneParams=t.storage;var n=e.renderer.engine;this.cache=new en(n),this.cache.setup(!1)},i.onCompositionReset=function(e,t){var i={id:"ModelPluginItem",name:"ModelPluginItem",duration:9999999,endBehavior:n.END_BEHAVIOR_FORWARD},r=new E(e.getEngine(),i);e.addItem(r);var o=r.addComponent(dn);o.fromData({cache:this.cache}),o.initial(this.sceneParams)},i.onCompositionDestroyed=function(e){this.cache.dispose(),this.cache=null,this.sceneParams=null},t.prepareResource=function(e,t){return B((function(){var n,i,r,o,a,s,l;return H(this,(function(c){switch(c.label){case 0:return void 0!==t.pluginData&&(i=["compatibleMode","renderSkybox","visBoundingBox","autoAdjustScene","enableDynamicSort","renderMode3D","renderMode3DUVGridSize"],r=t.pluginData,i.forEach((function(t){return e.storage[t]=r[t]}))),a=null!=(o=t.env)?o:"",e.storage.runtimeEnv=a,l=null!=(s=null==(n=t.pluginData)?void 0:n.compatibleMode)?s:"gltf",Lt.preprocessScene(e,a,l),[4,en.loadStaticResources()];case 1:return c.sent(),[2]}}))}))()},t}(w),dn=function(e){function t(t,i){var o;return(o=e.call(this,t)||this).runtimeEnv=r,o.compatibleMode="gltf",o.renderSkybox=!0,o.visBoundingBox=!1,o.autoAdjustScene=!1,o.enableDynamicSort=!1,o.renderMode3D=n.RenderMode3D.none,o.renderMode3DUVGridSize=1/16,i&&o.fromData(i),o}V(t,e);var i=t.prototype;return i.onLateUpdate=function(e){var t=this.item.composition;if(this.autoAdjustScene&&1==this.scene.tickCount){var n,i,r,o=t.camera,a=(new xe).fromMatrix4(o.getViewMatrix()),s=(new Se).fromPTransform(a).zAxis.clone(),l=null!=(i=o.fov)?i:45,c=null!=(r=o.aspect)?r:1,u=this.scene.getSceneAABB(),h=u.clone().applyMatrix4(a.getMatrix()).getSize(new ae).multiply(.5),f=h.x,d=h.y,m=d*Math.max(f/d/c,1),g=u.getCenter(new ae),p=m/Math.tan(.5*l*ve),v=g.clone().add(s.clone().multiply(p+h.z));t.camera.position=v,null==(n=t.items)||n.forEach((function(e){if(e.type===D){var t=e.getComponent(dt);if(null==t?void 0:t.content){var n,i=((null==(n=e.transform.parentTransform)?void 0:n.getWorldMatrix())||ce.IDENTITY.clone()).invert().transformPoint(v);t.setTransform(i),console.info("Scene AABB ["+u.min.toArray()+"], ["+u.max.toArray()+"]."),console.info("Update camera position ["+i.toArray()+"].")}}}))}this.updateSceneCamera(t),this.scene.tick(e)},i.onDestroy=function(){this.scene.dispose(),this.scene=null,this.cache=null},i.fromData=function(t){e.prototype.fromData.call(this,t);var n=t;this.cache=n.cache,this.scene=new hn(this.engine)},i.initial=function(e){var t,n,i,r,o,a,s,l,c;this.runtimeEnv=null!=(n=e.runtimeEnv)?n:this.runtimeEnv,this.compatibleMode=null!=(i=e.compatibleMode)?i:this.compatibleMode,this.renderSkybox=null!=(r=e.renderSkybox)?r:this.renderSkybox,this.visBoundingBox=null!=(o=e.visBoundingBox)?o:this.visBoundingBox,this.autoAdjustScene=null!=(a=e.autoAdjustScene)?a:this.autoAdjustScene,this.enableDynamicSort=null!=(s=e.enableDynamicSort)?s:this.enableDynamicSort,this.renderMode3D=null!=(l=e.renderMode3D)?l:this.renderMode3D,this.renderMode3DUVGridSize=null!=(c=e.renderMode3DUVGridSize)?c:this.renderMode3DUVGridSize;var u,h=this.item.composition;this.scene.initial({componentName:""+h.id,renderer:this.engine.renderer,sceneCache:this.cache,runtimeEnv:this.runtimeEnv,compatibleMode:this.compatibleMode,visBoundingBox:this.visBoundingBox,enableDynamicSort:this.enableDynamicSort,renderMode3D:this.renderMode3D,renderMode3DUVGridSize:this.renderMode3DUVGridSize,renderSkybox:this.renderSkybox,lightItemCount:this.getLightItemCount(),maxJointCount:this.getMaxJointCount(null!=(u=null==(t=this.item.composition)?void 0:t.items)?u:[])}),this.updateSceneCamera(h)},i.updateSceneCamera=function(e){this.scene.updateDefaultCamera(e.camera.getOptions(),e.camera.getViewportMatrix())},i.getLightItemCount=function(){var e,t,n=0;return(null!=(t=null==(e=this.item.composition)?void 0:e.items)?t:[]).forEach((function(e){e.getComponent(ft)&&n++})),n},i.getMaxJointCount=function(e){var t=this,n=0;return e.forEach((function(e){var i=e.getComponent(ut);if(i&&i.data){var r=i.data.geometry;if(G(r,c)){var o=r.getSkinProps();o.boneNames&&(n=Math.max(o.boneNames.length,n))}}0!==e.children.length&&(n=Math.max(t.getMaxJointCount(e.children),n))})),n},t}(d);function mn(e){var t,n=null==e||null==(t=e.item)?void 0:t.composition,i=null==n?void 0:n.getItemByName("ModelPluginItem"),r=null==i?void 0:i.getComponent(dn);return null==r?void 0:r.scene}dn=z([h(n.DataType.ModelPluginComponent)],dn);var gn,pn=function(e){function t(t,n){var i;return i=e.call(this,t)||this,n&&i.fromData(n),i}return V(t,e),t.prototype.fromData=function(t){e.prototype.fromData.call(this,t),this.options=t},t}(d);pn=z([h(n.DataType.TreeComponent)],pn),function(e){e[e.none=0]="none",e[e.translate=1]="translate",e[e.rotate_focus=2]="rotate_focus",e[e.rotate_self=3]="rotate_self",e[e.scale=4]="scale"}(gn||(gn={}));var vn=function(){function e(e){this.composition=e,this.cameraTransform=new xe,this.cameraCoordiante=new Se,this.startParams={type:gn.none,mouseEvent:!1,clientX:0,clientY:0,clientWidth:512,clientHeight:512,target:""}}var t=e.prototype;return t.updateComposition=function(e){this.composition=e},t.getItem=function(){var e,t=this;return null==(e=this.composition.items)?void 0:e.find((function(e){return e.name===t.getCurrentTarget()}))},t.getCurrentTarget=function(){return this.startParams.target},t.getCurrentType=function(){return this.startParams.type},t.onKeyEvent=function(e){this.startParams.target!==e.cameraID&&(this.startParams.target=e.cameraID,this.startParams.type=gn.translate);var t=this.getItem();if(void 0===t)return console.warn("[CameraGestureHandlerImp] Unable to locate camera item with ID: "+this.startParams.target+"."),this.composition.camera.getOptions();var n,r,o,a,s=this.composition.camera,l=new i(_e({},s.getOptions(),{valid:!0})),c=(new xe).fromEffectsTransform(l),u=(new Se).fromPTransform(c),h=null!=(n=e.xAxis)?n:0,f=null!=(r=e.yAxis)?r:0,d=null!=(o=e.zAxis)?o:0,m=u.xAxis.clone().multiply(h);if(m.add(u.yAxis.clone().multiply(f)),m.add(u.zAxis.clone().multiply(d)),m.lengthSquared()<1e-5)return s.getOptions();m.normalize();var g=null!=(a=e.speed)?a:.1,p=c.getPosition();return p.add(m.clone().multiply(g)),this.setTransform(t,p),this.startParams.type===gn.rotate_self&&(this.cameraTransform.setPosition(p),this.cameraCoordiante.origin=p),s.getOptions()},t.onXYMoveBegin=function(e,t,n,i,r){var o={type:gn.translate,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:i,target:r};return this.startGesture(o)},t.onXYMoving=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:gn.translate,mouseEvent:!0,clientX:e,clientY:t,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=n?n:.015};return this.moveGesture(r)},t.onXYMoveEnd=function(){this.endGesture()},t.onZMoveBegin=function(e,t,n,i,r){var o={type:gn.scale,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:i,target:r};return this.startGesture(o)},t.onZMoving=function(e,t,n){if(void 0===n&&(n=.015),!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:gn.scale,mouseEvent:!0,clientX:e,clientY:t,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:n};return this.moveGesture(r)},t.onZMoveEnd=function(){this.endGesture()},t.onRotateBegin=function(e,t,n,i,r){var o={type:gn.rotate_self,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:i,target:r};return this.startGesture(o)},t.onRotating=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:gn.rotate_self,mouseEvent:!0,clientX:e,clientY:t,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=n?n:1.5};return this.moveGesture(r)},t.onRotateEnd=function(){this.endGesture()},t.onRotatePointBegin=function(e,t,n,i,r,o){var a={type:gn.rotate_focus,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:i,focusPoint:r,target:o};return this.startGesture(a)},t.onRotatingPoint=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:gn.rotate_focus,mouseEvent:!0,clientX:e,clientY:t,clientWidth:i.clientWidth,clientHeight:i.clientHeight,focusPoint:i.focusPoint,target:i.target,speed:null!=n?n:8};return this.moveGesture(r)},t.onRotatePointEnd=function(){this.endGesture()},t.moveTo=function(e,t){this.startParams.target=e,this.startParams.type=gn.none;var n=this.getItem();void 0!==n?this.setPosition(n,t):console.warn("[CameraGestureHandlerImp] Can't find camera item.")},t.rotateTo=function(e,t){this.startParams.target=e,this.startParams.type=gn.none;var n=this.getItem();void 0!==n?this.setQuaternion(n,t):console.warn("[CameraGestureHandlerImp] Can't find camera item.")},t.onFocusPoint=function(e,t,n){this.startParams.target=e,this.startParams.type=gn.none;var i=this.getItem();if(void 0!==i){var r=null!=n?n:5,o=ae.fromArray(t),a=(new xe).fromEffectsTransform(i.transform),s=(new Se).fromPTransform(a),l=ae.fromArray(s.zAxis.toArray()).multiply(1).clone().multiply(r),c=o.clone().add(l);this.setTransform(i,c),this.startParams.target=""}else console.warn("[CameraGestureHandlerImp] Can't find camera item.")},t.getCameraTransform=function(){var e=this.composition.camera,t=new i(e.getOptions());return t.setValid(!0),t},t.startGesture=function(e){return this.startParams=e,this.updateCameraTransform(this.composition.camera.getOptions()),this.getItem()||console.warn("[CameraGestureHandlerImp] Invalid target specified in startGesture."),this.composition.camera.getOptions()},t.moveGesture=function(e){if(this.getCurrentType()===e.type){var t,n=this.getItem();if(void 0===n)return console.warn("[CameraGestureHandlerImp] Can't find camera item."),this.composition.camera.getOptions();var i=null!=(t=e.speed)?t:1.015,r=this.cameraCoordiante.xAxis,o=this.cameraCoordiante.yAxis,a=this.cameraCoordiante.zAxis,s=e.clientX-this.startParams.clientX,l=e.clientY-this.startParams.clientY;if(e.type===gn.translate){var c=this.cameraTransform.getPosition().clone();c.add(r.clone().multiply(-s*i)),c.add(o.clone().multiply(l*i)),n.transform.setPosition(c.x,c.y,c.z),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===gn.scale){var u=this.cameraTransform.getPosition().clone();u.add(a.clone().multiply(l*i)),n.transform.setPosition(u.x,u.y,u.z),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===gn.rotate_self){var h=s/e.clientWidth,f=l/e.clientHeight,d=h*Math.PI*i*.5,m=f*Math.PI*i*.5,g=de.fromAxisAngle(ae.Y,-d),p=de.fromAxisAngle(r,-m);g.multiply(p),g.multiply(this.cameraTransform.getRotation()),n.transform.setQuaternion(g.x,g.y,g.z,g.w),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===gn.rotate_focus){var v=s/e.clientWidth,y=l/e.clientHeight,T=v*Math.PI*i,_=y*Math.PI*i,b=de.fromAxisAngle(ae.Y,-T),C=de.fromAxisAngle(r,-_);b.multiply(C);var x=b.toMatrix4(new ce),S=ae.fromArray(e.focusPoint),A=this.cameraCoordiante.origin.clone().subtract(S);x.transformPoint(A);var M=A.add(S);b.multiply(this.cameraTransform.getRotation()),n.transform.setPosition(M.x,M.y,M.z),n.transform.setQuaternion(b.x,b.y,b.z,b.w),this.setTransform(n,M,n.transform.rotation)}else console.warn("[CameraGestureHandlerImp] Movement type not implemented.")}else console.warn("[CameraGestureHandlerImp] Invalid move type specified: "+e.type);return this.composition.camera.getOptions()},t.setTransform=function(e,t,n){var i=e.getComponent(dt);void 0!==i&&i.setTransform(t,n)},t.setPosition=function(e,t){var n;(n=e.transform).setPosition.apply(n,[].concat(t));var i=e.getComponent(dt);void 0!==i&&i.updateMainCamera()},t.setQuaternion=function(e,t){var n;(n=e.transform).setQuaternion.apply(n,[].concat(t));var i=e.getComponent(dt);void 0!==i&&i.updateMainCamera()},t.endGesture=function(){this.startParams.type=gn.none,this.startParams.mouseEvent=!1,this.startParams.target=""},t.updateCameraTransform=function(e){var t=new i(e);t.setValid(!0),this.cameraTransform.fromEffectsTransform(t),this.cameraCoordiante.fromPTransform(this.cameraTransform)},e}(),yn=function(){function e(){}return e.getTransformFromMat4=function(e){var t=e.getTransform(),n=t.rotation.toEuler(new he);return{position:t.translation.toArray(),rotation:n.toArray(),scale:t.scale.toArray()}},e.getEffectsTransformFromMat4=function(e){var t=new i({valid:!0});return t.cloneFromMatrix(e),{position:t.position.toArray(),rotation:t.rotation.toArray(),scale:t.scale.toArray()}},e.getTransformFromTranslation=function(e){return{position:e.toArray()}},e.getTransformFromDirection=function(t){var n=ae.fromArray([1,0,0]),i=t.clone().normalize(),r=n.clone().cross(i);if(r.length()<.01)return{};r.normalize();var o=i.dot(n),a=Math.acos(o),s=ce.fromRotationAxis(r,a);return e.getTransformFromMat4(s)},e.getEffectsTransformFromDirection=function(t){var n=ae.fromArray([0,0,1]),i=t.clone().normalize(),r=n.clone().cross(i);if(r.length()<.01)return{};r.normalize();var o=i.dot(n),a=Math.acos(o),s=ce.fromRotationAxis(r,a);return e.getEffectsTransformFromMat4(s)},e.getTransformFromTransDir=function(t,n){var i=e.getTransformFromDirection(n);return i.position=t.toArray(),i},e.getEffectsTransformFromTransDir=function(t,n){var i=e.getEffectsTransformFromDirection(n);return i.position=t.toArray(),i},e.getEulerFromQuat=function(e){var t=new he,n=new de(e.x,e.y,e.z,e.w);return t.order=fe.ZYX,t.setFromQuaternion(n),[t.x,t.y,t.z]},e.getQuatFromEuler=function(e){var t=new de;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}(),Tn=function(){function e(e,t){void 0===t&&(t=!0),this.renderer=e,this.keepIBLData=t,this.treeInfo=new _n,this.engine=e.engine,this.downloader=new L}var t=e.prototype;return t.processScene=function(e){var t=this;return B((function(){var i,r,o,a,s,l,c,u,h,f,d,m;return H(this,(function(g){switch(g.label){case 0:return O(e)?(r=e,[3,3]):[3,1];case 1:return[4,t.loadJSON(e)];case 2:r=g.sent(),g.label=3;case 3:if((i=r).textures||(i.textures=[]),i.textures.forEach((function(e){void 0===e.source&&(e.source=0)})),o=R(i),s=null!=(a=o.bins)?a:[],l=[],c=i.version.split("."),Number(c[0])>=3)return[2,o];if(!o.bins)return[3,7];u=K(o.bins),g.label=4;case 4:return(h=u()).done?[3,7]:(f=h.value,d=l.push,[4,t.loadBins(f.url)]);case 5:d.apply(l,[g.sent()]),g.label=6;case 6:return[3,4];case 7:return o.bins=l,m=_e({},o,{version:n.JSONSceneVersion["3_0"],playerVersion:{web:"3.0",native:"3.0"},type:"ge",compositions:[],images:[],textures:[],items:[],components:[],materials:[],shaders:[]}),t.setImage(m,o),[4,t.setTexture(m,o)];case 8:return g.sent(),t.setComponent(m,o),t.setItem(m,o),t.setComposition(m,o),m.bins=s,[2,m]}}))}))()},t.setImage=function(e,t){var n=[];t.images.forEach((function(e){n.push(e)})),e.images=n},t.setTexture=function(e,t){var n=this;return B((function(){var i,r,o,a,s,l,c,u,h,f,d,m;return H(this,(function(g){switch(g.label){case 0:if(i=[],r=t.bins,!t.textures)return[3,7];o=K(t.textures),g.label=1;case 1:return(a=o()).done?[3,7]:34067!==(s=a.value).target?[3,5]:n.keepIBLData?(i.push(s),[3,4]):[3,2];case 2:return l=s.mipmaps,c=s.target,u=l.map((function(e){return Promise.all(e.map((function(e){return n.loadMipmapImage(e,r)})))})),[4,Promise.all(u)];case 3:h=g.sent(),f=h.map((function(t){return t.map((function(t){var n=A(),i={url:t,id:n};return e.images.push(i),{id:n}}))})),d=_e({keepImageSource:!1},s,{mipmaps:f,sourceFrom:{target:c,type:p.mipmaps,mipmaps:l.map((function(e){return e.map((function(e){return[e[1][1],e[1][2]]}))}))}}),i.push(d),g.label=4;case 4:return[3,6];case 5:"number"==typeof(m=s.source)&&(s.source={id:e.images[m].id}),i.push(s),g.label=6;case 6:return[3,1];case 7:return e.textures=i,[2]}}))}))()},t.setComponent=function(e,t){for(var i,r=e.components,o=K(t.components);!(i=o()).done;){var a=i.value;if(a.dataType===n.DataType.SkyboxComponent)r.push(this.createSkyboxComponent(a,e));else if(a.dataType===n.DataType.LightComponent)r.push(this.createLightComponent(a,e));else if(a.dataType===n.DataType.CameraComponent)r.push(a),console.warn("Camera component found: "+a+".");else if(a.dataType===n.DataType.TreeComponent){var s=a;this.createItemsFromTreeComponent(a,e,t),s.options.tree.animation=void 0,s.options.tree.animations=void 0}else a.dataType!==n.DataType.MeshComponent&&r.push(a)}for(var l,c=K(t.components);!(l=c()).done;){var u=l.value;u.dataType===n.DataType.MeshComponent&&r.push(this.createMeshComponent(u,e,t))}},t.setItem=function(e,t){},t.setComposition=function(e,t){var n;e.items=t.items,(n=e.items).push.apply(n,[].concat(this.treeInfo.getAllTreeNodeList())),e.compositionId=t.compositionId,e.compositions=t.compositions,e.items.forEach((function(e){"root"===e.type&&(e.type="ECS")})),e.compositions[0].items=e.items.map((function(e){return{id:e.id}}))},t.loadJSON=function(e){var t=this;return B((function(){return H(this,(function(n){return[2,new Promise((function(n,i){t.downloader.downloadJSON(e,n,(function(t,n){i(new Error("Failed to load JSON from URL '"+e+"': status "+t+" - "+n+". Please check the URL or network settings."))}))}))]}))}))()},t.loadBins=function(e){var t=this;return B((function(){return H(this,(function(n){return[2,new Promise((function(n,i){t.downloader.downloadBinary(e,n,(function(t,n){i("Couldn't load bins "+JSON.stringify(e)+": status "+t+", "+n)}))}))]}))}))()},t.loadMipmapImage=function(e,t){return B((function(){var n,i,r,o,a;return H(this,(function(s){if(n=e[1],i=n[0],r=n[1],o=n[2],!(a=t[i]))throw new Error("Invalid bin pointer: "+JSON.stringify(e)+".");return[2,URL.createObjectURL(new Blob([new Uint8Array(a,r,o)]))]}))}))()},t.createSkyboxComponent=function(e,t){var n,i,r,o=e.options;o.irradianceCoeffs&&(n=[],o.irradianceCoeffs.forEach((function(e){return(i=n).push.apply(i,[].concat(e))})));return o.diffuseImage&&(r={id:t.textures[o.diffuseImage].id}),{id:e.id,dataType:e.dataType,item:e.item,renderable:o.renderable,intensity:o.intensity,reflectionsIntensity:o.reflectionsIntensity,irradianceCoeffs:n,diffuseImage:r,specularImage:{id:t.textures[o.specularImage].id},specularImageSize:o.specularImageSize,specularMipCount:o.specularMipCount+1}},t.createMeshComponent=function(e,t,n){var i,r=this,o=e.options,a=[],s=[];o.primitives.forEach((function(e){var t,i=we(e.geometry,n.bins),o=r.getMaterialData(e.material,n);if(G(null==(t=i.indices)?void 0:t.data,Uint8Array)){for(var l=i.indices.data,c=new Uint16Array(l.length),u=0;u<l.length;u++)c[u]=l[u];i.indices.data=c}a.push(i),s.push(o)}));var l=Cn(a);if(!l)throw new Error("No primitives available to process.");t.geometries.push(l),(i=t.materials).push.apply(i,[].concat(s));var c={id:e.id,dataType:e.dataType,item:e.item,geometry:{id:l.id},materials:s.map((function(e){return{id:e.id}}))};if(o.skin){for(var u,h=e.item.id,f=K(n.items);!(u=f()).done;){var d=u.value;d.id===e.item.id&&(h=d.parentId)}if(h===e.item.id)throw new Error("Can't item "+e.item+".");var m=this.treeInfo.getTreeItemByNodeId(h),g=this.treeInfo.getTreeNodeListByNodeId(h);if(!m||!g)throw new Error("Failed to retrieve tree node list for item with ID "+e.item.id+". Ensure the item exists and has a valid tree structure.");var p=this.setupBoneData(l,o.skin,n,m,g);c.rootBone={id:p.id}}return void 0!==o.weights&&(c.morph={weights:o.weights}),c},t.createItemsFromTreeComponent=function(e,t,i){var r=this,o=i.items[0];i.items.forEach((function(t){t.id===e.item.id&&(o=t)}));var a=e.options.tree,s=[];a.nodes.forEach((function(e,i){var a,l={id:A(),parentId:o.id,name:null!=(a=e.name)?a:"node"+i,duration:o.duration,type:"ECS",dataType:n.DataType.VFXItemData,visible:o.visible,endBehavior:o.endBehavior,delay:o.delay,content:{},renderLevel:o.renderLevel,pn:o.pn,pluginName:o.pluginName,transform:r.getTransformData(e.transform),components:[]};s.push(l),t.items.push(l)})),a.nodes.forEach((function(e,t){var n,i=s[t];null==(n=e.children)||n.forEach((function(e){s[e].parentId=i.id}))})),i.items.forEach((function(e){if(e.parentId){var t=e.parentId.indexOf("^");if(t>=0){var n=e.parentId.substring(0,t),i=+e.parentId.substring(t+1);n===o.id&&(e.parentId=s[i].id)}}})),this.treeInfo.add(o,s),this.createAnimationComponent(a,o,t,i)},t.createLightComponent=function(e,t){var n=e.options,i={id:e.id,dataType:e.dataType,item:e.item,lightType:n.lightType,color:{r:n.color[0]/255,g:n.color[1]/255,b:n.color[2]/255,a:n.color[3]/255},intensity:n.intensity};return"point"===n.lightType?i.range=n.range:"spot"===n.lightType&&(i.range=n.range,i.innerConeAngle=n.innerConeAngle,i.outerConeAngle=n.outerConeAngle),i},t.createAnimationComponent=function(e,t,i,r){var o=this,a=e.animation,s=e.animations,l={id:A(),dataType:n.DataType.AnimationComponent,item:{id:t.id},animation:a,animationClips:[]};if(s&&s.length){var c=r.bins;s.forEach((function(e){var a={id:A(),name:e.name,dataType:n.DataType.AnimationClip,positionCurves:[],rotationCurves:[],scaleCurves:[],floatCurves:[]},s=0;e.tracks.forEach((function(e){var t=Le(c,e.input);s=Math.max(s,t[t.length-1])})),e.tracks.forEach((function(e){var i=Le(c,e.input),s=Le(c,e.output);if(!G(i,Float32Array))throw new Error("Type of inputArray should be float32, "+i+".");if(!G(s,Float32Array))throw new Error("Type of outputArray should be float32, "+s+".");if("LINEAR"!==e.interpolation)throw new Error("Invalid interpolation type "+e.interpolation+".");if("rotation"===e.path){for(var l,u=[],h=[],f=[],d=0;d<i.length;d++){if(u.push([s[4*d],s[4*d+1],s[4*d+2],s[4*d+3]]),d>0){var m=de.fromArray(u[d-1]),g=de.fromArray(u[d]),p=new de,v=new de;p.slerpQuaternions(m,g,1/3),v.slerpQuaternions(m,g,2/3),h.push(p.toArray()),h.push(v.toArray())}f.push([n.BezierKeyframeType.LINE,[i[d],d]])}var y=o.treeInfo.getTreeNode(t.id,e.node),T=o.treeInfo.getNodePath(y.id),_=[n.ValueType.BEZIER_CURVE_QUAT,[f,u,h]];null==(l=a.rotationCurves)||l.push({path:T,keyFrames:_})}else if("weights"===e.path){var b=o.treeInfo.getTreeNode(t.id,e.node),C=o.treeInfo.getNodePath(b.id);if(0===b.components.length)for(var x=0;x<r.items.length;x++){var S=r.items[x];if(S.parentId===b.id){C+="/"+S.name;break}}for(var A=s.length/i.length,M=0;M<A;M++){for(var I,E=[],w=0;w<i.length;w++)E.push([n.BezierKeyframeType.LINE,[i[w],s[w*A+M]]]);var N=[n.ValueType.BEZIER_CURVE,E];null==(I=a.floatCurves)||I.push({path:C,className:"ModelMeshComponent",property:"morphWeights."+M,keyFrames:N})}}else{for(var L=[],R=[],O=[],F=0;F<i.length;F++){if(L.push([s[3*F],s[3*F+1],s[3*F+2]]),F>0){var U=ae.fromArray(L[F-1]),D=ae.fromArray(L[F]),P=(new ae).lerpVectors(U,D,1/3),B=(new ae).lerpVectors(U,D,2/3);R.push(P.toArray()),R.push(B.toArray())}O.push([n.BezierKeyframeType.LINE,[i[F],F]])}var k,V,z=o.treeInfo.getTreeNode(t.id,e.node),H=o.treeInfo.getNodePath(z.id),j=[n.ValueType.BEZIER_CURVE_PATH,[O,L,R]];if("translation"===e.path)null==(k=a.positionCurves)||k.push({path:H,keyFrames:j});else null==(V=a.scaleCurves)||V.push({path:H,keyFrames:j})}})),i.animations.push(a),l.animationClips.push({id:a.id})}))}t.components=[],t.components.push({id:l.id}),i.components.push(l)},t.getMaterialData=function(e,t){if(e.type===n.MaterialType.unlit){var i={};void 0!==e.alphaCutOff&&(i._AlphaCutoff=e.alphaCutOff);var r={_BaseColorFactor:new ue(e.baseColorFactor[0],e.baseColorFactor[1],e.baseColorFactor[2],e.baseColorFactor[3]).divide(255)},o={};e.baseColorTexture&&(o._BaseColorSampler=this.getTextureData(t,i,e.baseColorTexture,e.baseColorTextureTransform));var a={id:A(),name:e.name,dataType:n.DataType.Material,shader:{id:Ce},stringTags:{},macros:[],ints:{},floats:i,vector4s:{},colors:r,textures:o};return this.setupMaterial(e,a),a}var s={_MetallicFactor:e.metallicFactor,_RoughnessFactor:e.roughnessFactor};void 0!==e.useSpecularAA&&(s._SpecularAA=e.useSpecularAA?1:0),void 0!==e.normalTextureScale&&(s._NormalScale=e.normalTextureScale),void 0!==e.occlusionTextureStrength&&(s._OcclusionStrength=e.occlusionTextureStrength),void 0!==e.emissiveIntensity&&(s._EmissiveIntensity=e.emissiveIntensity),void 0!==e.alphaCutOff&&(s._AlphaCutoff=e.alphaCutOff);var l={_BaseColorFactor:new ue(e.baseColorFactor[0],e.baseColorFactor[1],e.baseColorFactor[2],e.baseColorFactor[3]).divide(255),_EmissiveFactor:new ue(e.emissiveFactor[0],e.emissiveFactor[1],e.emissiveFactor[2],e.emissiveFactor[3]).divide(255)},c={};e.baseColorTexture&&(c._BaseColorSampler=this.getTextureData(t,s,e.baseColorTexture,e.baseColorTextureTransform)),e.metallicRoughnessTexture&&(c._MetallicRoughnessSampler=this.getTextureData(t,s,e.metallicRoughnessTexture,e.metallicRoughnessTextureTransform)),e.normalTexture&&(c._NormalSampler=this.getTextureData(t,s,e.normalTexture,e.normalTextureTransform)),e.occlusionTexture&&(c._OcclusionSampler=this.getTextureData(t,s,e.occlusionTexture,e.occlusionTextureTransform)),e.emissiveTexture&&(c._EmissiveSampler=this.getTextureData(t,s,e.emissiveTexture,e.emissiveTextureTransform));var u={id:A(),name:e.name,dataType:n.DataType.Material,shader:{id:be},stringTags:{},macros:[],ints:{},floats:s,vector4s:{},colors:l,textures:c};return this.setupMaterial(e,u),u},t.setupMaterial=function(e,t){var i;(e.blending===n.MaterialBlending.translucent?t.stringTags.RenderType=n.RenderType.Transparent:t.stringTags.RenderType=n.RenderType.Opaque,e.blending===n.MaterialBlending.masked)?(t.floats.AlphaClip=1,t.floats._AlphaCutoff=null!=(i=e.alphaCutOff)?i:0):t.floats.AlphaClip=0;switch(e.side){case n.SideMode.BACK:t.stringTags.RenderFace=n.RenderFace.Back;break;case n.SideMode.DOUBLE:t.stringTags.RenderFace=n.RenderFace.Both;break;default:t.stringTags.RenderFace=n.RenderFace.Front}e.type===n.MaterialType.pbr&&(t.floats._SpecularAA=e.useSpecularAA?1:0),t.floats.ZWrite=!1!==e.depthMask?1:0,t.floats.ZTest=1},t.getTextureData=function(e,t,n,i){var r,o={texture:{id:null!=(r=e.textures[n].id)?r:"0"}};return i&&(i.scale&&(o.scale={x:i.scale[0],y:i.scale[1]}),i.offset&&(o.offset={x:i.offset[0],y:i.offset[1]}),i.rotation&&(t._BaseColorRotation=i.rotation)),o},t.getTransformData=function(e){var t={position:{x:0,y:0,z:0},eulerHint:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}};return(null==e?void 0:e.position)&&(t.position.x=e.position[0],t.position.y=e.position[1],t.position.z=e.position[2]),(null==e?void 0:e.quat)?(t.quat={},t.quat.x=e.quat[0],t.quat.y=e.quat[1],t.quat.z=e.quat[2],t.quat.w=e.quat[3]):(null==e?void 0:e.rotation)&&(t.eulerHint.x=e.rotation[0],t.eulerHint.y=e.rotation[1],t.eulerHint.z=e.rotation[2]),(null==e?void 0:e.scale)&&(t.scale.x=e.scale[0],t.scale.y=e.scale[1],t.scale.z=e.scale[2]),t},t.setupBoneData=function(e,t,n,i,r){var o=n.bins,a=t.joints,s=t.skeleton,l=t.inverseBindMatrices;if(!l)throw new Error("'inverseBindMatrices' is undefined for the skin configuration: "+JSON.stringify(t)+". Ensure 'inverseBindMatrices' is properly defined in your skin data.");var c=Le(o,l);e.inverseBindMatrices=Array.from(c);var u={},h=i;void 0!==s?h=r[s]:console.warn("Root bone is missing for the skeleton. Defaulting to the primary tree item as the root bone."),a.forEach((function(e){var t=r[e];t!==h&&t.parentId===h.parentId&&(console.error("Invalid node detected for 'rootBoneItem'. Adjusting 'rootBoneItem' to the primary tree item. Please verify the tree structure."),h=i)})),r.forEach((function(e){u[e.id]=e})),e.rootBoneName=h.name;var f=[];return a.forEach((function(e){for(var t=r[e],n=[];t&&t!=h&&(n.push(t.name),t.parentId);)t=u[t.parentId];f.push(n.reverse().join("/"))})),e.boneNames=f,h},e}(),_n=function(){function e(){this.tree2NodeList={},this.nodeList2Tree={},this.nodeId2Node={},this.node2Path={}}var t=e.prototype;return t.add=function(e,t){var n=this;if(this.tree2NodeList[e.id])throw new Error("Duplicate treeItem ID detected: "+e.id+". Ensure each tree item has a unique ID.");this.tree2NodeList[e.id]=t,t.forEach((function(t){if(n.nodeList2Tree[t.id])throw new Error("Duplicate tree node ID found: "+t.id+". Each node in the tree must have a unique ID.");n.nodeList2Tree[t.id]=e,n.nodeId2Node[t.id]=t})),t.forEach((function(e){n.setNodePath(e)}))},t.setNodePath=function(e){e.parentId?this.node2Path[e.parentId]?this.node2Path[e.id]=this.node2Path[e.parentId]+"/"+e.name:this.nodeId2Node[e.parentId]?(this.setNodePath(this.nodeId2Node[e.parentId]),this.node2Path[e.id]=this.node2Path[e.parentId]+"/"+e.name):this.node2Path[e.id]=e.name:this.node2Path[e.id]=e.name},t.getTreeNodeListByTreeId=function(e){return this.tree2NodeList[e]},t.getTreeNodeListByNodeId=function(e){var t=this.nodeList2Tree[e];if(!t)throw new Error("Invalid id "+e+".");return this.getTreeNodeListByTreeId(t.id)},t.getTreeItemByNodeId=function(e){return this.nodeList2Tree[e]},t.getTreeNode=function(e,t){return this.getTreeNodeListByTreeId(e)[t]},t.getAllTreeNodeList=function(){var e=this,t=[];return Object.keys(this.tree2NodeList).forEach((function(n){var i;(i=t).push.apply(i,[].concat(e.tree2NodeList[n]))})),t},t.getNodePath=function(e){return this.node2Path[e]},e}();function bn(e){var t,i=0,r=n.VertexFormatType.Float32,o=!1,s=n.VertexFormatType.Float32,l=!1,c=n.VertexFormatType.Float32,u=!1,h={vertices:new Float32Array,uvs:new Float32Array,normals:new Float32Array,indices:new Float32Array,name:null!=(t=e.name)?t:"<empty>"};for(var f in e.attributes){var d,m,g=e.attributes[f];if("aPosition"===f)i=g.data.length/g.size,h.vertices=g.data,o=null!=(d=g.normalize)&&d,r=N(null!=(m=g.type)?m:a.FLOAT);else if("aNormal"===f){var p,v;h.normals=g.data,u=null!=(p=g.normalize)&&p,c=N(null!=(v=g.type)?v:a.FLOAT)}else if("aUV1"===f){var y,T;h.uvs=g.data,l=null!=(y=g.normalize)&&y,s=N(null!=(T=g.type)?T:a.FLOAT)}}var _=xn(r,3,i),b=xn(s,2,i),C=xn(c,3,i);if(e.indices)h.indices=e.indices.data;else if(i<=65535){for(var x=new Uint16Array(i),S=0;S<i;S++)x[S]=S;h.indices=x}else{for(var M=new Uint32Array(i),I=0;I<i;I++)M[I]=I;h.indices=M}var E=n.IndexFormatType.UInt16;return 4===h.indices.BYTES_PER_ELEMENT&&(E=n.IndexFormatType.UInt32),{id:A(),dataType:n.DataType.Geometry,vertexData:{vertexCount:i,channels:[{semantic:n.VertexBufferSemantic.Position,offset:0,format:r,dimension:3,normalize:o},{semantic:n.VertexBufferSemantic.Uv,offset:_,format:s,dimension:2,normalize:l},{semantic:n.VertexBufferSemantic.Normal,offset:_+b,format:c,dimension:3,normalize:u}]},subMeshes:[],mode:n.GeometryType.TRIANGLES,indexFormat:E,indexOffset:_+b+C,buffer:Sn(h)}}function Cn(e){var t=function(t){var n,o,a,s=function(e){if(e.drawCount)return e.drawCount;if(e.indices)return e.indices.data.length;var t=0;return e.attributes.forEach((function(e){t=e.data.length/e.size})),t}(e[t]),l=i+(null!=(o=e[t].drawStart)?o:0),c=null!=(a=null==(n=e[0].indices)?void 0:n.data.BYTES_PER_ELEMENT)?a:1;if(r.push({offset:l*c,indexCount:s,vertexCount:s}),t){var u=e[0],h=e[t],f=!0;if(Object.keys(u.attributes).forEach((function(e){var t=u.attributes[e].data,n=h.attributes[e].data;t.length===n.length&&t[0]===n[0]||(f=!1)})),f)u.indices&&h.indices&&(u.indices.data=An(u.indices.data,h.indices.data));else{if(u.indices&&h.indices){var d=function(e){var t=0;return Object.keys(e.attributes).forEach((function(n){var i=e.attributes[n];t=i.data.length/i.size})),t}(u);u.indices.data=An(u.indices.data,h.indices.data,d)}Object.keys(u.attributes).forEach((function(e){var t=u.attributes[e],n=t.data,i=h.attributes[e].data;t.data=An(n,i)}))}}i=l+s};if(!(e.length<=0)){for(var i=0,r=[],o=0;o<e.length;o++)t(o);return function(e,t){var i=0;for(var r in e.attributes){i+=e.attributes[r].data.byteLength}e.indices&&(i+=e.indices.data.byteLength);var o=0,s=0,l=new Uint8Array(i),c=[];for(var u in e.attributes){var h,f,d=e.attributes[u],m=null!=(h=In[u])?h:u;o=d.data.length/d.size;var g={semantic:m,offset:s,format:N(null!=(f=d.type)?f:a.FLOAT),dimension:d.size,normalize:d.normalize};c.push(g);var p=d.data,v=new Uint8Array(p.buffer,p.byteOffset,p.byteLength);l.set(v,s),s+=v.byteLength}var y={id:A(),dataType:n.DataType.Geometry,vertexData:{vertexCount:o,channels:c},subMeshes:t,mode:n.GeometryType.TRIANGLES,indexFormat:n.IndexFormatType.None,indexOffset:0,buffer:""};if(e.indices){var T=e.indices.data,_=new Uint8Array(T.buffer,T.byteOffset,T.byteLength);l.set(_,s),y.indexOffset=s,G(T,Uint32Array)?y.indexFormat=n.IndexFormatType.UInt32:y.indexFormat=n.IndexFormatType.UInt16}return y.buffer=function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}(l),y}(e[0],r)}}function xn(e,t,i){switch(e){case n.VertexFormatType.Int8:case n.VertexFormatType.UInt8:return t*i;case n.VertexFormatType.Int16:case n.VertexFormatType.UInt16:return t*i*2;default:return t*i*4}}function Sn(e){var t=new Uint8Array(e.vertices.buffer,e.vertices.byteOffset,e.vertices.byteLength),n=new Uint8Array(e.uvs.buffer,e.uvs.byteOffset,e.uvs.byteLength),i=new Uint8Array(e.normals.buffer,e.normals.byteOffset,e.normals.byteLength),r=new Uint8Array(e.indices.buffer,e.indices.byteOffset,e.indices.byteLength),o=t.byteLength+n.byteLength+i.byteLength+r.byteLength,a=new ArrayBuffer(o),s=new Uint8Array(a,0,t.byteLength);s.set(t),(s=new Uint8Array(a,t.byteLength,n.byteLength)).set(n),(s=new Uint8Array(a,t.byteLength+n.byteLength,i.byteLength)).set(i),new Uint8Array(a,t.byteLength+n.byteLength+i.byteLength,r.byteLength).set(r);for(var l=new Uint8Array(a),c="",u=0;u<l.length;u++)c+=String.fromCharCode(l[u]);return btoa(c)}function An(e,t,n){if(G(e,Float32Array)){var i=new Float32Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}if(G(e,Int32Array)){var r=new Int32Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}if(G(e,Uint32Array)){var o=new Uint32Array(e.length+t.length);if(o.set(e),o.set(t,e.length),n)for(var a=0;a<t.length;a++)o[e.length+a]+=n;return o}if(G(e,Int16Array)){var s=new Int16Array(e.length+t.length);return s.set(e),s.set(t,e.length),s}if(G(e,Uint16Array)){var l=new Uint16Array(e.length+t.length);if(l.set(e),l.set(t,e.length),n)for(var c=0;c<t.length;c++)l[e.length+c]+=n;return l}if(G(e,Int8Array)){var u=new Int8Array(e.length+t.length);return u.set(e),u.set(t,e.length),u}var h=new Uint8Array(e.length+t.length);return h.set(e),h.set(t,e.length),h}var Mn,In={aPos:"POSITION",aUV:"TEXCOORD0",aUV2:"TEXCOORD1",aNormal:"NORMAL",aTangent:"TANGENT",aColor:"COLOR",aJoints:"JOINTS",aWeights:"WEIGHTS",a_Position:"POSITION",a_UV:"TEXCOORD0",a_UV1:"TEXCOORD0",a_UV2:"TEXCOORD1",a_Normal:"NORMAL",a_Tangent:"TANGENT",a_Color:"COLOR",a_Joints:"JOINTS",a_Joint1:"JOINTS",a_Weights:"WEIGHTS",a_Weight1:"WEIGHTS",a_Target_Position0:"POSITION_BS0",a_Target_Position1:"POSITION_BS1",a_Target_Position2:"POSITION_BS2",a_Target_Position3:"POSITION_BS3",a_Target_Position4:"POSITION_BS4",a_Target_Position5:"POSITION_BS5",a_Target_Position6:"POSITION_BS6",a_Target_Position7:"POSITION_BS7",a_Target_Normal0:"NORMAL_BS0",a_Target_Normal1:"NORMAL_BS1",a_Target_Normal2:"NORMAL_BS2",a_Target_Normal3:"NORMAL_BS3",a_Target_Tangent0:"TANGENT_BS0",a_Target_Tangent1:"TANGENT_BS1",a_Target_Tangent2:"TANGENT_BS2",a_Target_Tangent3:"TANGENT_BS3"};function En(e,t){return Mn||(Mn=new Nn),Mn.initial(e,t),Mn}function wn(e){Mn=e}var Nn=function(){function e(e){this.gltfMeshs=[],this.gltfTextures=[],this.gltfMaterials=[],this.gltfAnimations=[],this.gltfImageBasedLights=[],this.timelineAssetId="",this.images=[],this.imageElements=[],this.textures=[],this.items=[],this.components=[],this.materials=[],this.shaders=[],this.geometries=[],this.animations=[],this.sceneAABB=new me,e?this.composition=e:(this.timelineAssetId=A(),this.composition={id:"1",name:"test1",duration:99999,endBehavior:n.EndBehavior.restart,camera:{fov:45,far:2e3,near:.001,position:[0,0,8],rotation:[0,0,0],clipMode:n.CameraClipMode.portrait},items:[],timelineAsset:{id:this.timelineAssetId},sceneBindings:[]})}var t=e.prototype;return t.loadScene=function(e){var t=this;return B((function(){var n,i,r,o,a,s,l,c,u;return H(this,(function(h){switch(h.label){case 0:if(t.clear(),t.sceneOptions=e,t.loaderOptions={compatibleMode:e.gltf.compatibleMode},"string"==typeof(a=e.gltf.resource)||G(a,Uint8Array))throw new Error("Please load the resource using GLTFTools first.");return t.images=a.images.map((function(e){var t,n=new Blob([e.imageData.buffer],{type:null!=(t=e.mimeType)?t:"image/png"});return{id:e.id,url:URL.createObjectURL(n)}})),[4,Promise.all(t.images.map(B((function(e){return H(this,(function(t){return[2,S(e.url)]}))}))))];case 1:if(t.imageElements=h.sent(),t.processGLTFResource(a,t.imageElements),t.gltfMeshs=a.meshes,t.gltfTextures=a.textures,t.gltfMaterials=a.materials,t.gltfAnimations=a.animations,t.gltfImageBasedLights=a.imageBasedLights,t.textures=t.gltfTextures.map((function(e){var n=e.textureOptions,i=n.source;return"number"==typeof i&&(n.source={id:t.images[i].id}),n})),t.materials=t.gltfMaterials.map((function(e){return e.materialData})),a.meshes.forEach((function(e){t.geometries.push(e.geometryData)})),(s=a.scenes[0]).meshesComponentData.forEach((function(e){return t.checkMeshComponentData(e,a)})),(n=t.components).push.apply(n,[].concat(s.camerasComponentData)),(i=t.components).push.apply(i,[].concat(s.lightsComponentData)),(r=t.components).push.apply(r,[].concat(s.meshesComponentData)),1===s.animationsComponentData.length)l=s.animationsComponentData[0],e.effects.playAllAnimation||void 0===e.effects.playAnimation||(c=l.animationClips,(u=e.effects.playAnimation)>=0&&u<c.length?l.animationClips=[c[u]]:l.animationClips=[]),t.components.push(l);else if(s.animationsComponentData.length>1)throw new Error("Find many animation component data "+s.animationsComponentData.length);return t.animations=[],t.gltfAnimations.forEach((function(e){t.animations.push(e.animationClipData)})),t.items=[],[4,t.tryAddSkybox({skyboxType:e.gltf.skyboxType,renderable:e.gltf.skyboxVis})];case 2:return h.sent(),(o=t.items).push.apply(o,[].concat(a.scenes[0].vfxItemData)),t.items.forEach((function(e){"root"===e.type&&(e.type="ECS")})),[2,t.getLoadResult()]}}))}))()},t.processGLTFResource=function(e,t){var n=function(){var e=f.value;if(h.has(e)){var t=o.find((function(t){return t.textureOptions.id===e}));if(t){var n=A(),i=t.clone();i.textureOptions.id=n,o.push(i),r[n]=i.textureOptions,m[e]=n,d+=1}}},i=this,r={},o=e.textures,s=e.materials,l=e.scenes,c=e.imageBasedLights;o.forEach((function(e){var t=e.textureOptions,n=t.id;n?(r[n]&&console.error("Duplicate GUID found: "+n+", old "+r[n]+", new "+t+"."),r[n]=t):console.error("No GUID in texture Data: "+t+".")}));var u=new Set,h=new Set;s.forEach((function(e){var t,n,i=e.materialData,r=null==(t=i.textures._BaseColorSampler)?void 0:t.texture,o=null==(n=i.textures._EmissiveSampler)?void 0:n.texture;r&&u.add(r.id),o&&h.add(o.id)}));for(var f,d=0,m={},g=K(u);!(f=g()).done;)n();d>0&&console.warn("Add base color texture "+d),s.forEach((function(e){var n,o,a=e.materialData;if(i.processMaterialData(a),(null==(n=a.shader)?void 0:n.id)===Ce)i.processMaterialTexture(a,"_BaseColorSampler",!0,r,t);else if((null==(o=a.shader)?void 0:o.id)===be){var s,l=null==(s=a.textures._EmissiveSampler)?void 0:s.texture;l&&m[l.id]&&(l.id=m[l.id]),i.processMaterialTexture(a,"_BaseColorSampler",!0,r,t),i.processMaterialTexture(a,"_MetallicRoughnessSampler",!1,r,t),i.processMaterialTexture(a,"_NormalSampler",!1,r,t),i.processMaterialTexture(a,"_OcclusionSampler",!1,r,t),i.processMaterialTexture(a,"_EmissiveSampler",!1,r,t)}}));var p=l[0];p.camerasComponentData.forEach((function(e){return i.processCameraComponentData(e)})),p.lightsComponentData.forEach((function(e){return i.processLightComponentData(e)}));var v=[];c.forEach((function(e){var t=e.imageBaseLightData;if(void 0===t.reflectionsIntensity&&(t.reflectionsIntensity=t.intensity),t.diffuseImage){var n=r[t.diffuseImage.id];M(v,n)}if(t.specularImage){var i=r[t.specularImage.id];M(v,i)}})),v.forEach((function(e){if(e.target===a.TEXTURE_CUBE_MAP){var t=e;t.mipmaps.forEach((function(e){var t;t=[e[5],e[4]],e[4]=t[0],e[5]=t[1]})),1===t.mipmaps.length?(t.minFilter=a.LINEAR,t.magFilter=a.LINEAR):(t.minFilter=a.LINEAR_MIPMAP_LINEAR,t.magFilter=a.LINEAR)}}))},t.processComponentData=function(e){var t=this;e.forEach((function(e){e.dataType===n.DataType.LightComponent?t.processLightComponentData(e):e.dataType===n.DataType.CameraComponent?t.processCameraComponentData(e):e.dataType===n.DataType.SkyboxComponent&&t.processSkyboxComponentData(e)}))},t.processLightComponentData=function(e){e.color||(e.color={r:1,g:1,b:1,a:1}),e.intensity||(e.intensity=1),e.lightType===n.LightType.point?e.range||(e.range=0):e.lightType===n.LightType.spot&&(e.range||(e.range=0),e.innerConeAngle||(e.innerConeAngle=0),e.outerConeAngle||(e.outerConeAngle=Math.PI/4))},t.processCameraComponentData=function(e){e.type===n.CameraType.perspective&&e.fov&&(e.fov*=Math.PI/180)},t.processSkyboxComponentData=function(e){void 0===e.intensity&&(e.intensity=1),void 0===e.reflectionsIntensity&&(e.reflectionsIntensity=1)},t.processMaterialData=function(e){var t,i;(null==(t=e.shader)?void 0:t.id)===Ce?(e.colors._BaseColorFactor||(e.colors._BaseColorFactor={r:1,g:1,b:1,a:1}),void 0===e.floats._AlphaCutoff&&(e.floats._AlphaCutoff=0),void 0===e.floats.ZWrite&&(e.floats.ZWrite=1),void 0===e.floats.ZTest&&(e.floats.ZTest=1),e.stringTags.RenderType||(e.stringTags.RenderType=n.RenderType.Opaque),e.stringTags.RenderFace||(e.stringTags.RenderFace=n.RenderFace.Front)):(null==(i=e.shader)?void 0:i.id)===be?(e.colors._BaseColorFactor||(e.colors._BaseColorFactor={r:1,g:1,b:1,a:1}),void 0===e.floats._SpecularAA&&(e.floats._SpecularAA=0),void 0===e.floats._MetallicFactor&&(e.floats._MetallicFactor=1),void 0===e.floats._RoughnessFactor&&(e.floats._RoughnessFactor=0),void 0===e.floats._NormalScale&&(e.floats._NormalScale=1),void 0===e.floats._OcclusionStrength&&(e.floats._OcclusionStrength=this.isTiny3dMode()?0:1),e.colors._EmissiveFactor||(e.colors._EmissiveFactor={r:0,g:0,b:0,a:1}),void 0===e.floats._EmissiveIntensity&&(e.floats._EmissiveIntensity=1),void 0===e.floats._AlphaCutoff&&(e.floats._AlphaCutoff=0),void 0===e.floats.ZWrite&&(e.floats.ZWrite=1),void 0===e.floats.ZTest&&(e.floats.ZTest=1),e.stringTags.RenderType||(e.stringTags.RenderType=n.RenderType.Opaque),e.stringTags.RenderFace||(e.stringTags.RenderFace=n.RenderFace.Front)):console.error("Encountered unknown shader ID in material with ID: "+e.id+".")},t.processTextureOptions=function(e,t,n){var i,r=!1,o=null!=(i=e.minFilter)?i:a.LINEAR_MIPMAP_LINEAR;this.isTiny3dMode()&&(o=a.LINEAR_MIPMAP_LINEAR,n&&(Mt.isPow2(n.width)&&Mt.isPow2(n.height)||(o=a.LINEAR)),r=!t);var s,l,c,u=o==a.NEAREST_MIPMAP_NEAREST||o==a.LINEAR_MIPMAP_NEAREST||o==a.NEAREST_MIPMAP_LINEAR||o==a.LINEAR_MIPMAP_LINEAR;e.wrapS=null!=(s=e.wrapS)?s:a.REPEAT,e.wrapT=null!=(l=e.wrapT)?l:a.REPEAT,e.magFilter=null!=(c=e.magFilter)?c:a.LINEAR,e.minFilter=o,e.anisotropic=1,e.premultiplyAlpha=r,e.generateMipmap=u},t.initial=function(e,t){this.engine=e,this.loaderOptions=null!=t?t:{}},t.checkMeshComponentData=function(e,t){if(e.materials.length<=0)throw new Error("Submesh array is empty for mesh with ID: "+e.id+".");var n;if(t.meshes.forEach((function(t){t.geometryData.id===e.geometry.id&&(n=t.geometryData)})),void 0===n)throw new Error("Unable to find geometry data for mesh with ID: "+e.geometry.id+".");if(n.subMeshes.length!==e.materials.length)throw new Error("Mismatch between submeshes count ("+n.subMeshes.length+") and materials count ("+e.materials.length+").")},t.processMaterialTexture=function(e,t,n,i,r){var o=e.textures[t];if(o){var a,s=i[o.texture.id];if("number"!=typeof s.source)throw new Error("Invalid texture option source data, "+s.source);a=r[s.source],s&&this.processTextureOptions(s,n,a)}},t.getLoadResult=function(){var e=[];this.items.forEach((function(t){return e.push({id:t.id})})),this.composition.items=e;var t={version:n.JSONSceneVersion["3_0"],playerVersion:{web:"2.0",native:"2.0"},type:"ge",compositionId:this.composition.id,compositions:[this.composition],images:this.images,plugins:["model"],textures:this.textures,items:this.items,components:this.components,materials:this.materials,shaders:this.shaders,geometries:this.geometries,animations:this.animations,miscs:[{id:this.timelineAssetId,dataType:n.DataType.TimelineAsset}]},i=this.computeSceneAABB();return{source:this.getRemarkString(),jsonScene:t,sceneAABB:{min:i.min.toArray(),max:i.max.toArray()}}},t.addLight=function(e){var t=A(),i={id:A(),item:{id:t},dataType:n.DataType.LightComponent,lightType:e.lightType,color:e.color,intensity:e.intensity,range:e.range,innerConeAngle:e.innerConeAngle,outerConeAngle:e.outerConeAngle,followCamera:e.followCamera},r={id:t,name:e.name,duration:e.duration,type:n.ItemType.light,pn:0,visible:!0,endBehavior:e.endBehavior,transform:{position:{x:e.position[0],y:e.position[1],z:e.position[2]},eulerHint:{x:e.rotation[0],y:e.rotation[1],z:e.rotation[2]},scale:{x:e.scale[0],y:e.scale[1],z:e.scale[2]}},components:[{id:i.id}],content:{},dataType:n.DataType.VFXItemData};this.items.push(r),this.components.push(i)},t.addCamera=function(e){var t=A(),i={id:A(),item:{id:t},dataType:n.DataType.CameraComponent,fov:e.fov,near:e.near,far:e.far,clipMode:e.clipMode},r={id:t,name:e.name,duration:e.duration,type:"camera",pn:0,visible:!0,endBehavior:e.endBehavior,transform:{position:{x:e.position[0],y:e.position[1],z:e.position[2]},eulerHint:{x:e.rotation[0],y:e.rotation[1],z:e.rotation[2]},scale:{x:1,y:1,z:1}},components:[{id:i.id}],content:{},dataType:n.DataType.VFXItemData};this.items.push(r),this.components.push(i)},t.addSkybox=function(e){var t,i,r,o=A(),a=$t.createSkyboxComponentData(e),s=a.imageList,l=a.textureOptionsList,c=a.component;c.item.id=o,void 0!==e.intensity&&(c.intensity=e.intensity),void 0!==e.reflectionsIntensity&&(c.reflectionsIntensity=e.reflectionsIntensity),c.renderable=null!=(r=e.renderable)&&r;var u={id:o,name:"Skybox-Customize",duration:999,type:n.ItemType.skybox,pn:0,visible:!0,endBehavior:n.EndBehavior.freeze,transform:{position:{x:0,y:0,z:0},eulerHint:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},components:[{id:c.id}],content:{},dataType:n.DataType.VFXItemData};(t=this.images).push.apply(t,[].concat(s)),(i=this.textures).push.apply(i,[].concat(l)),this.items.push(u),this.components.push(c)},t.tryAddSkybox=function(e){var t=this;return B((function(){var i,r,o,a,s,l,c,u,h,f,d;return H(this,(function(m){return t.gltfImageBasedLights.length>0&&!t.ignoreSkybox()?(i=t.gltfImageBasedLights[0],t.components.push(i.imageBaseLightData)):void 0!==e.skyboxType&&(a=A(),s=t.createSkyboxComponentData(e.skyboxType),l=s.imageList,c=s.textureOptionsList,(u=s.component).item.id=a,void 0!==e.intensity&&(u.intensity=e.intensity),void 0!==e.reflectionsIntensity&&(u.reflectionsIntensity=e.reflectionsIntensity),u.renderable=null!=(h=e.renderable)&&h,d={id:a,name:"Skybox-"+e.skyboxType,duration:null!=(f=e.duration)?f:999,type:n.ItemType.skybox,pn:0,visible:!0,endBehavior:n.EndBehavior.freeze,transform:{position:{x:0,y:0,z:0},eulerHint:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},components:[{id:u.id}],content:{},dataType:n.DataType.VFXItemData},(r=t.images).push.apply(r,[].concat(l)),(o=t.textures).push.apply(o,[].concat(c)),t.items.push(d),t.components.push(u)),[2]}))}))()},t.createSkyboxComponentData=function(e){if("NFT"!==e&&"FARM"!==e)throw new Error("Invalid skybox type specified: '"+e+"'. Valid types are: 'NFT', 'FARM'.");var t="NFT"===e?Yt.NFT:Yt.FARM,n=$t.getSkyboxParams(t);return $t.createSkyboxComponentData(n)},t.dispose=function(){this.clear(),this.engine=null},t.clear=function(){this.gltfMeshs=[],this.gltfTextures=[],this.gltfMaterials=[],this.gltfAnimations=[],this.gltfImageBasedLights=[],this.images=[],this.imageElements=[],this.textures=[],this.items=[],this.components=[],this.materials=[],this.shaders=[],this.geometries=[],this.animations=[]},t.computeSceneAABB=function(){var e={};this.gltfMeshs.forEach((function(t){var n=t.geometryData.id;e[n]=t}));var t={};this.components.forEach((function(i){if(i.dataType===n.DataType.MeshComponent){var r=i;t[i.id]=e[r.geometry.id]}}));var r=new me,o={};return this.items.forEach((function(e){var n,a,s=null!=(n=e.parentId)?n:"",l=null!=(a=o[s])?a:new i,c={};e.transform&&(c.position=(new ae).copyFrom(e.transform.position),c.rotation=he.fromVector3(e.transform.eulerHint),c.scale=(new ae).copyFrom(e.transform.scale));var u=new i(c,l);o[e.id]=u,e.components.forEach((function(e){var n=t[e.id];if(n&&n.bounds){var i=ae.fromArray(n.bounds.box.min),o=ae.fromArray(n.bounds.box.max);r.union(new me(i,o))}}))})),r},t.isPlayAnimation=function(){return void 0!==this.sceneOptions.effects.playAnimation},t.isPlayAllAnimation=function(){return!0===this.sceneOptions.effects.playAllAnimation},t.getRemarkString=function(){var e=this.sceneOptions.gltf.remark;return void 0===e?"Unknown":"string"==typeof e?e:"BinaryBuffer"},t.getCompositionDuration=function(){return this.composition.duration},t.isTiny3dMode=function(){return"tiny3d"===this.loaderOptions.compatibleMode},t.getItemDuration=function(){var e;return null!=(e=this.sceneOptions.effects.duration)?e:9999},t.getEndBehavior=function(){var e;return null!=(e=this.sceneOptions.effects.endBehavior)?e:n.EndBehavior.restart},t.getSkyboxType=function(){switch(this.sceneOptions.gltf.skyboxType){case"NFT":return Yt.NFT;case"FARM":return Yt.FARM}},t.isSkyboxVis=function(){return!0===this.sceneOptions.gltf.skyboxVis},t.ignoreSkybox=function(){return!0===this.sceneOptions.gltf.ignoreSkybox},t.isEnvironmentTest=function(){return"string"==typeof this.sceneOptions.gltf.remark&&this.sceneOptions.gltf.remark.includes("EnvironmentTest")},t.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))}))},t.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)}))},t.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)}))},t.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}}))},t.createGeometry=function(e,t){return new Un(this.engine,e,t).geometry},t.createMaterial=function(e){return new Dn(e,[],this.isTiny3dMode()).material},t.createTexture2D=function(e,t,n){return Mt.createTexture2D(this.engine,e,t,n,this.isTiny3dMode())},t.createTextureCube=function(e,t){var n=this;if(0==e.length)throw new Error("createTextureCube: Invalid cubeImages length "+e);var i=[];return e.forEach((function(e){if(6!=e.length)throw new Error("createTextureCube: cubeimage count should always be 6, "+e);var t,r=[];(e.forEach((function(e){if(void 0===e.imageData)throw new Error("createTextureCube: Invalid image data from "+e);r.push({type:"buffer",data:e.imageData,mimeType:e.mimeType})})),n.isTiny3dMode())&&(t=[r[5],r[4]],r[4]=t[0],r[5]=t[1]);i.push(r)})),1==i.length?Mt.createTextureCubeFromBuffer(this.engine,i[0]):Mt.createTextureCubeMipmapFromBuffer(this.engine,i,null!=t?t:Math.pow(2,i.length-1))},t.createSkybox=function(e){var t,n,i=this,r=null!=(t=e.reflectionsIntensity)?t:e.intensity,o=e.irradianceCoefficients,a=e.specularImages.map((function(e){var t,n=e.map((function(e){return{type:"buffer",data:e.imageData,mimeType:e.mimeType}}));i.isTiny3dMode()&&(t=[n[5],n[4]],n[4]=t[0],n[5]=t[1]);return n})),s=a.length-1,l=null!=(n=e.specularImageSize)?n:Math.pow(2,s),c=[];o.forEach((function(e){var t;(t=c).push.apply(t,[].concat(e))}));var u={type:"buffer",renderable:this.isSkyboxVis(),intensity:e.intensity,reflectionsIntensity:r,irradianceCoeffs:c,specularImage:a,specularMipCount:s,specularImageSize:l};return $t.createSkyboxOptions(this.engine,u)},t.createDefaultSkybox=function(e){if("NFT"!==e&&"FARM"!==e)throw new Error("Invalid skybox type name "+e);var t="NFT"===e?Yt.NFT:Yt.FARM,n=$t.getSkyboxParams(t);return $t.createSkyboxOptions(this.engine,n)},t.scaleColorVal=function(e,t){return t?yn.scaleTo255(e):yn.scaleTo1(e)},t.scaleColorVec=function(e,t){var n=this;return e.map((function(e){return n.scaleColorVal(e,t)}))},e}();function Ln(){return'\n _BaseColorSampler ("基础贴图", 2D) = "" {}\n _BaseColorFactor ("基础颜色", Color) = (1, 1, 1, 1)\n _MetallicRoughnessSampler ("金属贴图", 2D) = "" {}\n _MetallicFactor ("金属度", Range(0, 1)) = 1\n _RoughnessFactor ("粗糙度", Range(0, 1)) = 1\n [Toggle] _SpecularAA ("高光抗锯齿", Float) = 0\n _NormalSampler ("法线贴图", 2D) = "" {}\n _NormalScale ("法线贴图强度", Range(0, 2)) = 1\n _OcclusionSampler ("AO贴图", 2D) = "" {}\n _OcclusionStrength ("AO贴图强度", Range(0, 1)) = 1\n _EmissiveSampler ("自发光贴图", 2D) = "" {}\n _EmissiveIntensity ("自发光贴图强度", Float) = 1\n _EmissiveFactor ("自发光颜色", Color) = (0, 0, 0, 1)\n _AlphaCutoff ("Alpha裁剪值", Range(0, 1)) = 0.5\n '}function Rn(){return'\n _BaseColorSampler ("基础贴图", 2D) = "" {}\n _BaseColorFactor ("基础颜色", Color) = (1, 1, 1, 1)\n _AlphaCutoff ("Alpha裁剪值", Range(0, 1)) = 0.5\n '}function On(){return{id:"00000000000000000000000000000000",name:"PBR Material",dataType:n.DataType.Material,stringTags:{RenderType:n.RenderType.Opaque,RenderFace:"Front"},macros:[],shader:{id:"pbr00000000000000000000000000000"},ints:{},floats:{ZWrite:1,ZTest:1,_SpecularAA:0,_MetallicFactor:1,_RoughnessFactor:0,_NormalScale:1,_OcclusionStrength:1,_EmissiveIntensity:1,_AlphaCutoff:.5},vector4s:{},colors:{_BaseColorFactor:{r:1,g:1,b:1,a:1},_EmissiveFactor:{r:0,g:0,b:0,a:1}},textures:{}}}function Fn(){return{id:"00000000000000000000000000000000",name:"Unlit Material",dataType:n.DataType.Material,stringTags:{ZWrite:"true",ZTest:"true",RenderType:n.RenderType.Opaque,Cull:"Front"},macros:[],shader:{id:n.BuiltinObjectGUID.UnlitShader},ints:{},floats:{_AlphaCutoff:.5},vector4s:{},colors:{_BaseColorFactor:{r:1,g:1,b:1,a:1}},textures:{}}}var Un=function(){function e(e,t,n){this.engine=e,this.gltfGeometry=t,this.hasSkinAnimation=n}var t=e.prototype;return t._getBufferAttrib=function(e){return{type:e.type,size:e.itemSize,data:e.array,normalize:e.normalized}},t.texCoordAttrib=function(e){return this.gltfGeometry.getTexCoord(e)},t.getTargetPosition=function(e){return this.gltfGeometry.getAttribute("POSITION"+e)},t.getTargetNormal=function(e){return this.gltfGeometry.getAttribute("NORMAL"+e)},t.getTargetTangent=function(e){return this.gltfGeometry.getAttribute("TANGENT"+e)},Te(e,[{key:"geometry",get:function(){var e=this,t={};if(!this.hasPosition)throw new Error("Position attribute missing");var n=this.positionAttrib;if(t.a_Position=this._getBufferAttrib(n),this.hasNormal){var i=this.normalAttrib;void 0!==i&&(t.a_Normal=this._getBufferAttrib(i))}if(this.hasTangent){var r=this.tangentAttrib;void 0!==r&&(t.a_Tangent=this._getBufferAttrib(r))}if(this.texCoordList.forEach((function(n){var i=e.texCoordAttrib(n);t["a_UV"+(n+1)]=e._getBufferAttrib(i)})),this.hasSkinAnimation){var o=this.jointAttribute;void 0!==o&&(t.a_Joint1=this._getBufferAttrib(o));var s=this.weightAttribute;void 0!==s&&(t.a_Weight1=this._getBufferAttrib(s))}for(var l=0;l<8;l++){var u=this.getTargetPosition(l);void 0!==u&&(t["a_Target_Position"+l]=this._getBufferAttrib(u));var h=this.getTargetNormal(l);void 0!==h&&(t["a_Target_Normal"+l]=this._getBufferAttrib(h));var f=this.getTargetTangent(l);void 0!==f&&(t["a_Target_Tangent"+l]=this._getBufferAttrib(f))}var d=this.indexArray;return void 0!==d?c.create(this.engine,{attributes:t,indices:{data:d},drawStart:0,drawCount:d.length,mode:a.TRIANGLES}):c.create(this.engine,{attributes:t,drawStart:0,drawCount:this.positionAttrib.array.length/3,mode:a.TRIANGLES})}},{key:"positionAttrib",get:function(){return this.gltfGeometry.getPosition()}},{key:"normalAttrib",get:function(){return this.gltfGeometry.getNormal()}},{key:"tangentAttrib",get:function(){return this.gltfGeometry.getTangent()}},{key:"jointAttribute",get:function(){return this.gltfGeometry.getJoints(0)}},{key:"weightAttribute",get:function(){return this.gltfGeometry.getWeights(0)}},{key:"hasPosition",get:function(){return void 0!==this.positionAttrib}},{key:"hasNormal",get:function(){return void 0!==this.normalAttrib}},{key:"hasTangent",get:function(){return void 0!==this.tangentAttrib}},{key:"hasTexCoord",get:function(){return this.texCoordCount>0}},{key:"texCoordCount",get:function(){for(var e=0;e<10;e++)if(void 0===this.texCoordAttrib(e))return e;return 0}},{key:"hasJointAttribute",get:function(){return void 0!==this.jointAttribute}},{key:"hasWeightAttribute",get:function(){return void 0!==this.weightAttribute}},{key:"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}}},{key:"indexCount",get:function(){return void 0!==this.gltfGeometry.indices?this.gltfGeometry.indices.array.length:0}},{key:"texCoordList",get:function(){for(var e=[],t=0;t<10&&void 0!==this.texCoordAttrib(t);t++)e.push(t);return e}}]),e}(),Dn=function(){function e(e,t,n){this.gltfMaterial=e,this.textures=t,this.tiny3dMode=n}var t=e.prototype;return t.getTextureObject=function(e){if(!(e<0||e>=this.textures.length))return this.textures[e]},t.getTextureObj=function(e){return e?this.getTextureObject(e.index):void 0},t.getTextureCoord=function(e){return e?e.texCoord:void 0},t.getTextureTransform=function(e){var t,n=null==e||null==(t=e.extensions)?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}},t.getSpecularAA=function(){var e;return null==(e=this.gltfMaterial.extras)?void 0:e.useSpecularAA},Te(e,[{key:"material",get:function(){var e=this.gltfMaterial,t=Pn.isUnlitMaterial(e),i=n.MaterialBlending.opaque;switch(e.alphaMode){case"OPAQUE":i=n.MaterialBlending.opaque;break;case"MASK":i=n.MaterialBlending.masked;break;case"BLEND":i=n.MaterialBlending.translucent}var r,o,a,s=e.doubleSided?n.SideMode.DOUBLE:n.SideMode.FRONT,l=null!=(r=e.alphaCutOff)?r:.5,c=e.name;return t?{name:c,type:n.MaterialType.unlit,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,depthMask:null==(o=e.extras)?void 0:o.depthMask,blending:i,alphaCutOff:l,side:s}:{name:c,type:n.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==(a=e.extras)?void 0:a.depthMask,blending:i,alphaCutOff:l,side:s,enableShadow:!1}}},{key:"baseColorTextureObj",get:function(){return this.getTextureObj(this.gltfMaterial.baseColorTexture)}},{key:"baseColorTextureCoord",get:function(){return this.getTextureCoord(this.gltfMaterial.baseColorTexture)}},{key:"baseColorTextureTransfrom",get:function(){return this.getTextureTransform(this.gltfMaterial.baseColorTexture)}},{key:"metallicRoughnessTextureObj",get:function(){return this.getTextureObj(this.gltfMaterial.metallicRoughnessTexture)}},{key:"metallicRoughnessTextureCoord",get:function(){return this.getTextureCoord(this.gltfMaterial.metallicRoughnessTexture)}},{key:"metallicRoughnessTextureTransfrom",get:function(){return this.getTextureTransform(this.gltfMaterial.metallicRoughnessTexture)}},{key:"normalTextureObj",get:function(){return this.getTextureObj(this.gltfMaterial.normalTexture)}},{key:"normalTextureCoord",get:function(){return this.getTextureCoord(this.gltfMaterial.normalTexture)}},{key:"normalTextureTransfrom",get:function(){return this.getTextureTransform(this.gltfMaterial.normalTexture)}},{key:"occlusionTextureObj",get:function(){return this.getTextureObj(this.gltfMaterial.occlusionTexture)}},{key:"occlusionTextureCoord",get:function(){return this.getTextureCoord(this.gltfMaterial.occlusionTexture)}},{key:"occlusionTextureTransfrom",get:function(){return this.getTextureTransform(this.gltfMaterial.occlusionTexture)}},{key:"emissiveTextureObj",get:function(){return this.getTextureObj(this.gltfMaterial.emissiveTexture)}},{key:"emissiveTextureCoord",get:function(){return this.getTextureCoord(this.gltfMaterial.emissiveTexture)}},{key:"emissiveTextureTransfrom",get:function(){return this.getTextureTransform(this.gltfMaterial.emissiveTexture)}},{key:"hasEmissive",get:function(){var e=this.emissiveFactor;return e[0]+e[1]+e[2]>0}},{key:"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]]}},{key:"metalicFactor",get:function(){var e;return null!=(e=this.gltfMaterial.metallicFactor)?e:1}},{key:"roughnessFactor",get:function(){var e;return null!=(e=this.gltfMaterial.roughnessFactor)?e:1}},{key:"normalTextureScale",get:function(){var e,t;return null!=(t=null==(e=this.gltfMaterial.normalTexture)?void 0:e.scale)?t:1}},{key:"occlusionTextureStrength",get:function(){var e,t;return null!=(t=null==(e=this.gltfMaterial.occlusionTexture)?void 0:e.strength)?t:1}},{key:"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]}}]),e}(),Pn=function(){function e(){}return e.isUnlitMaterial=function(e){var t;return void 0!==(null==(t=e.extensions)?void 0:t.KHR_materials_unlit)},e.createBoxFromGLTFBound=function(e){var t=ae.fromArray(e.box.min),n=ae.fromArray(e.box.max);return new me(t,n)},e}();F("model",fn,E);var Bn="2.8.0-alpha.1";U.info("Plugin model version: "+Bn+"."),Bn!==e.version&&console.error("注意:请统一 Model 插件与 Player 版本,不统一的版本混用会有不可预知的后果!","\nAttention: Please ensure the Model plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");export{mt as AnimationComponent,me as Box3,Ge as BoxMesh,vn as CameraGestureHandlerImp,gn as CameraGestureType,Pt as CheckerHelper,ue as Color,en as CompositionCache,St as CompositionHitTest,ve as DEG2RAD,he as Euler,fe as EulerOrder,Ve as FBOOptions,Bt as Float16ArrayWrapper,Ut as GeometryBoxProxy,Dt as HitTestingProxy,Fe as HookOGLFunc,j as InterpolationSampler,Tn as JSONConverter,yn as LoaderHelper,Nn as LoaderImpl,le as Matrix3,ce as Matrix4,Nt as MeshHelper,dt as ModelCameraComponent,ft as ModelLightComponent,ut as ModelMeshComponent,fn as ModelPlugin,dn as ModelPluginComponent,ht as ModelSkyboxComponent,pn as ModelTreeComponent,Vt as PAnimInterpType,Gt as PAnimPathType,jt as PAnimTexture,be as PBRShaderGUID,ne as PBlendMode,nn as PCamera,rn as PCameraManager,Se as PCoordinate,Ee as PEntity,ie as PFaceSideMode,cn as PGeometry,Ae as PGlobalState,on as PLight,an as PLightManager,$ as PLightType,Jt as PMaterialBase,qt as PMaterialPBR,Qt as PMaterialSkyboxFilter,te as PMaterialType,Xt as PMaterialUnlit,sn as PMesh,Ht as PMorph,Ie as PObject,Q as PObjectType,hn as PSceneManager,Wt as PShaderManager,re as PShadowType,zt as PSkin,Kt as PSkybox,$t as PSkyboxCreator,Yt as PSkyboxType,ln as PSubMesh,ee as PTextureType,xe as PTransform,Lt as PluginHelper,de as Quaternion,pe as Ray,yt as RayBoxTesting,vt as RayIntersectsBoxWithRotation,xt as RayTriangleTesting,ge as Sphere,wt as TextureDataMode,At as ToggleItemBounding,ct as TwoStatesSet,Ce as UnlitShaderGUID,D as VFX_ITEM_TYPE_3D,oe as Vector2,ae as Vector3,se as Vector4,Ot as VertexAttribBuffer,Mt as WebGLHelper,Rt as WebHelper,Z as createAnimationSampler,Zt as createPluginMaterial,qe as fetchPBRShaderCode,Ze as fetchUnlitShaderCode,En as getDefaultEffectsGLTFLoader,On as getDefaultPBRMaterialData,Fn as getDefaultUnlitMaterialData,tt as getDiffuseOnlyShaderCode,ot as getGaussianBlurShaderCodeV1,rt as getGaussianBlurShaderCodeV2,bn as getGeometryDataFromOptions,Cn as getGeometryDataFromPropsList,nt as getKawaseBlurShaderCode,et as getNormalVisShaderCode,Ye as getPBRPassShaderCode,Ln as getPBRShaderProperties,Be as getPMeshList,$e as getQuadFilterShaderCode,Pe as getRendererGPUInfo,mn as getSceneManager,Ke as getShadowPassShaderCode,it as getSimpleFilterShaderCode,Qe as getSkyBoxShaderCode,at as getTransparecyBaseShader,st as getTransparecyFilterShader,Rn as getUnlitShaderProperties,wn as setDefaultEffectsGLTFLoader,Bn as version};
|
|
2
2
|
//# sourceMappingURL=douyin.mjs.map
|