@galacean/effects-plugin-model 2.8.2 → 2.8.4
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.mjs +1 -1
- package/dist/douyin.js +1 -1
- package/dist/douyin.mjs +1 -1
- package/dist/index.js +2 -2
- package/dist/index.min.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/loader.mjs +2 -2
- package/dist/weapp.js +1 -1
- package/dist/weapp.mjs +1 -1
- package/package.json +4 -4
package/dist/weapp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@galacean/effects/weapp");function t(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var n=t(e),r="PluginModel";function i(e,t,n,r,i,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(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,l,"next",e)}function l(e){i(a,r,o,s,l,"throw",e)}s(void 0)}))}}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function s(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&&a(e,t)}function l(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):l(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(c=function(){return!!e})()}function u(e,t,n){return u=c()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&a(i,n.prototype),i},u.apply(null,arguments)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function f(e){var t="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return u(e,arguments,h(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,e)},f(e)}function d(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function p(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[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,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=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 m=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,r=t[n],i=t[n-1];e:{t:{var o;n:{r:if(!(e<r)){for(var a=n+2;;){if(void 0===r){if(e<i)break r;return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}if(n===a)break;if(i=r,e<(r=t[++n]))break t}o=t.length;break n}if(e>=i)break e;var s=t[1];e<s&&(n=2,i=s);for(var l=n-2;;){if(void 0===i)return this.cachedIndex=0,this.copySampleValue(0);if(n===l)break;if(r=i,e>=(i=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(r=t[n],void 0===(i=t[n-1]))return this.cachedIndex=0,this.copySampleValue(0);if(void 0===r)return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}this.cachedIndex=n,this.intervalChanged(n,i,r)}return this.interpolate(n,i,e,r)},t.dispose=function(){this.time=void 0,this.data=void 0},t.copySampleValue=function(e){for(var t=this.data,n=this.componentCount,r=e*n,i=new Float32Array(n),o=0;o!==n;++o)i[o]=t[r+o];return i},e}(),g=function(e){function t(t,n,r){return e.call(this,t,n,r)}s(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,r){for(var i,o=this.data,a=null!=(i=this.componentCount)?i:1,s=e*a,l=s-a,c=(n-t)/(r-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}(m),v=function(e){function t(t,n,r){return e.call(this,t,n,r)}s(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,r){for(var i,o=this.data,a=null!=(i=this.componentCount)?i:1,s=(e-1)*a,l=new Float32Array(a),c=0;c!==a;++c)l[c]=o[s+c];return l},t}(m),y=function(){function e(){}return e.slerpFlat=function(e,t,n,r,i,o,a){var s=n[r+0],l=n[r+1],c=n[r+2],u=n[r+3],h=i[o+0],f=i[o+1],d=i[o+2],p=i[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]=p);if(u!==p||s!==h||l!==f||c!==d){var m=1-a,g=s*h+l*f+c*d+u*p,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var T=Math.sqrt(y),x=Math.atan2(T,g*v);m=Math.sin(m*x)/T,a=Math.sin(a*x)/T}var b=a*v;if(s=s*m+h*b,l=l*m+f*b,c=c*m+d*b,u=u*m+p*b,m===1-a){var _=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=_,l*=_,c*=_,u*=_}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u},e}(),T=function(e){function t(t,n,r){return e.call(this,t,n,r)}s(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,r){for(var i,o=this.data,a=null!=(i=this.componentCount)?i:1,s=(n-t)/(r-t),l=e*a,c=new Float32Array(a),u=l+a;l!==u;l+=4)y.slerpFlat(c,0,o,l-a,o,l,s);return c},t}(m);function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function b(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 x(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)?x(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 _,C,S,M,A,I,E,w=e.math.Vector2,N=e.math.Vector3,L=e.math.Vector4,P=e.math.Matrix3,R=e.math.Matrix4,O=e.math.Color,F=e.math.Euler,D=e.math.EulerOrder,U=e.math.Quaternion,B=e.math.Box3,k=e.math.Sphere,V=e.math.Ray,G=e.math.DEG2RAD;function z(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function H(e,t,n){return t&&z(e.prototype,t),n&&z(e,n),e}function j(){return j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},j.apply(this,arguments)}exports.PObjectType=void 0,(_=exports.PObjectType||(exports.PObjectType={}))[_.none=0]="none",_[_.mesh=1]="mesh",_[_.texture=2]="texture",_[_.material=3]="material",_[_.light=4]="light",_[_.camera=5]="camera",_[_.skybox=6]="skybox",_[_.skin=7]="skin",_[_.morph=8]="morph",_[_.skeleton=9]="skeleton",_[_.animation=10]="animation",_[_.animationManager=11]="animationManager",_[_.reference=12]="reference",exports.PLightType=void 0,(C=exports.PLightType||(exports.PLightType={}))[C.directional=0]="directional",C[C.point=1]="point",C[C.spot=2]="spot",C[C.ambient=3]="ambient",exports.PTextureType=void 0,(S=exports.PTextureType||(exports.PTextureType={}))[S.none=0]="none",S[S.t2d=1]="t2d",S[S.t3d=2]="t3d",S[S.cube=3]="cube",exports.PMaterialType=void 0,(M=exports.PMaterialType||(exports.PMaterialType={}))[M.none=0]="none",M[M.unlit=1]="unlit",M[M.pbr=2]="pbr",M[M.normalVis=3]="normalVis",M[M.simpleFilter=4]="simpleFilter",M[M.shadowBase=5]="shadowBase",M[M.shadowFilter=6]="shadowFilter",M[M.skyboxFilter=7]="skyboxFilter",exports.PBlendMode=void 0,(A=exports.PBlendMode||(exports.PBlendMode={}))[A.opaque=0]="opaque",A[A.masked=1]="masked",A[A.translucent=2]="translucent",A[A.additive=3]="additive",exports.PFaceSideMode=void 0,(I=exports.PFaceSideMode||(exports.PFaceSideMode={}))[I.both=0]="both",I[I.front=1]="front",I[I.back=2]="back",exports.PShadowType=void 0,(E=exports.PShadowType||(exports.PShadowType={}))[E.none=0]="none",E[E.standard=1]="standard",E[E.variance=2]="variance",E[E.expVariance=3]="expVariance";var W=e.spec.BuiltinObjectGUID.PBRShader,J=e.spec.BuiltinObjectGUID.UnlitShader,X=function(){function t(){this.translation=new N(0,0,0),this.rotation=new U(0,0,0,1),this.scale=new N(1,1,1)}var n=t.prototype;return n.fromMatrix4=function(e){return this.setMatrix(e),this},n.fromEffectsTransform=function(t){if(l(t,e.Transform))this.setMatrix(t.getWorldMatrix());else{var n=new e.Transform(j({},t,{valid:!0}));n.setValid(!0),this.setMatrix(n.getWorldMatrix())}return this},n.toEffectsTransform=function(e){var t=this.getMatrix();return e.cloneFromMatrix(t),e},n.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},n.getTranslation=function(){return this.translation},n.setTranslation=function(e){l(e,N)?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},n.getPosition=function(){return this.translation},n.setPosition=function(e){l(e,N)?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},n.getRotation=function(){return this.rotation},n.setRotation=function(e){l(e,U)?this.rotation.set(e.x,e.y,e.z,e.w):l(e,F)?this.rotation.setFromEuler(e):l(e,N)?this.rotation.setFromEuler(new F(e.x,e.y,e.z,D.ZYX)):4===e.length?this.rotation.set(e[0],e[1],e[2],e[3]):this.rotation.setFromEuler(new F(e[0],e[1],e[2],D.ZYX))},n.getScale=function(){return this.scale},n.setScale=function(e){l(e,N)?this.scale.set(e.x,e.y,e.z):this.scale.set(e[0],e[1],e[2])},n.getMatrix=function(){return(new R).compose(this.getTranslation(),this.getRotation(),this.getScale())},n.setMatrix=function(e){if(l(e,R)){var t=e.getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}else{var n=R.fromArray(e).getTransform();this.setTranslation(n.translation),this.setRotation(n.rotation),this.setScale(n.scale)}},t}(),q=function(){function e(){this.origin=new N(0,0,0),this.xAxis=new N(1,0,0),this.yAxis=new N(0,1,0),this.zAxis=new N(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 R);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}(),Y=function(){function t(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=e.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16}var n=t.prototype;return n.reset=function(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=e.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16},n.hasRenderMode3D=function(){return this.renderMode3D!==e.spec.RenderMode3D.none},t.getInstance=function(){return this.instance||(this.instance=new this)},H(t,[{key:"isEditorEnv",get:function(){return this.runtimeEnv===e.PLAYER_OPTIONS_ENV_EDITOR}},{key:"isDeviceEnv",get:function(){return!this.isEditorEnv}},{key:"isTiny3dMode",get:function(){return"tiny3d"===this.compatibleMode}},{key:"isGLTFMode",get:function(){return!this.isTiny3dMode}}]),t}(),Z=1,K=function(){function e(){this.name="Unnamed Object",this.type=exports.PObjectType.none}var t=e.prototype;return t.dispose=function(){},t.isNone=function(){return this.type===exports.PObjectType.none},t.isValid=function(){return this.type!==exports.PObjectType.none},t.genName=function(e){return e+"_@"+Z++},e}(),Q=function(e){function t(){var t;return(t=e.apply(this,arguments)||this)._visible=!1,t._transform=new X,t.deleted=!1,t}s(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},H(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){l(e,X)?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 q;return e.fromPTransform(this._transform),e}}]),t}(K);function $(e,t){var n,r=e.attributes,i=j({},e);if(i.indices)i.indices=j({},i.indices),i.indices.data&&(i.indices.data=te(t,null==(n=e.indices)?void 0:n.data));else if(i.index){var o;if(i.indices=j({},i.index),i.indices.data)i.indices.data=te(t,null==(o=e.index)?void 0:o.data)}return Object.keys(r).forEach((function(e){var n=r[e],o=n.data;i.attributes[e]=j({},n),o&&(i.attributes[e].data=te(t,o))})),i}var ee={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,f32:Float32Array,i32:Int32Array,u32:Uint32Array};function te(t,n){if(2!=n.length||n[0]!==e.spec.ValueType.BINARY||!l(n[1],Array))return n;var r=n[1],i=r[0],o=r[1],a=r[2],s=r[3];if(!s)return t[i].slice(o,a);var c=ee[s]||Uint8Array;return new c(t[i],o,a/c.BYTES_PER_ELEMENT)}var ne="_Native",re=new Map;function ie(e,t){for(var n=""+e,r=[],i=0;i<t.length;i++){var o;"number"==typeof t[i]&&re.has(t[i])?r.push(re.get(t[i])+"("+t[i]+")"):r.push(null==(o=t[i])?void 0:o.toString())}return n+(r.length>0?"("+r.join(", ")+")":"()")}function oe(e,t){return function(){var n=e[t+ne].apply(this,arguments),r=e.getError();return r>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+")"}(r)+" ===> "+ie(t,arguments)),console.trace()):console.info(ie(t,arguments)),n}}var ae,se=function(){function t(e){var t,n;this.resolution=null!=(t=e.resolution)?t:new w(512,512),this.colorAttachments=null!=(n=e.colorAttachments)?n:[],this.depthAttachment=e.depthAttachment}var n=t.prototype;return n.addDepthAttachment=function(t){var n;this.depthAttachment={storageType:null!=(n=t.storageType)?n:e.RenderPassAttachmentStorageType.depth_16_texture}},n.addDefaultDepthAttachment=function(){this.depthAttachment={storageType:e.RenderPassAttachmentStorageType.depth_16_texture}},n.deleteDepthAttachment=function(){this.depthAttachment=void 0},n.addColorAttachment=function(t){var n,r,i,o;this.colorAttachments.push({texture:{format:null!=(n=t.format)?n:e.glContext.RGBA,type:null!=(r=t.type)?r:e.glContext.HALF_FLOAT,minFilter:null!=(i=t.filter)?i:e.glContext.LINEAR,magFilter:null!=(o=t.filter)?o:e.glContext.LINEAR}})},n.deleteColorAttachment=function(e){e>=0&&e<this.colorAttachments.length&&this.colorAttachments.splice(e,1)},H(t,[{key:"viewport",get:function(){return[0,0,this.resolution.x,this.resolution.y]}}]),t}(),le=function(){function t(t,n){var r=e.Material.create(t,{shader:{vertex:this.vertexShader,fragment:this.fragmentShader,shared:!0}});r.depthTest=!0,r.depthMask=!0,this.mesh=e.Mesh.create(t,{name:"boxMesh",material:r,geometry:e.Geometry.create(t,this.geometry),priority:n})}var n=t.prototype;return n.update=function(e,t,n,r){var i=this.mesh.material;i.setMatrix("effects_ObjectToWorld",e);for(var o=0;o<n.length;o+=3)i.setVector3("_PositionList["+o/3+"]",N.fromArray(n,o));i.setVector3("_LineColor",r)},n.dispose=function(){this.mesh.dispose(),this.mesh=void 0},H(t,[{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 t=new Float32Array([0,1,2,3,4,5,6,7]),n=new Uint32Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);return{attributes:{aPos:{type:e.glContext.FLOAT,size:1,data:t,stride:Float32Array.BYTES_PER_ELEMENT,offset:0}},mode:e.glContext.LINES,indices:{data:n},drawStart:0,drawCount:24}}}]),t}(),ce="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;}",ue="\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}",he="#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}",fe="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);}",de="\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"))}}(ae||(ae={})),e.ShaderFactory.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"),e.ShaderFactory.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"),e.ShaderFactory.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);}"),e.ShaderFactory.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;}"),e.ShaderFactory.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"),e.ShaderFactory.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"),e.ShaderFactory.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 pe=function(){function e(){}return e.getVertexShaderCode=function(e){var t=e.featureList,n=e.material.materialType;switch(n){case exports.PMaterialType.unlit:case exports.PMaterialType.pbr:case exports.PMaterialType.shadowBase:return ae.build(ce,t);case exports.PMaterialType.skyboxFilter:return ae.build(fe,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 exports.PMaterialType.unlit:case exports.PMaterialType.pbr:return ae.build(ue,t);case exports.PMaterialType.shadowBase:return ae.build(he,t);case exports.PMaterialType.skyboxFilter:return ae.build(de,t);default:throw new Error("Invalid material type "+n+" for getFragmentShaderString!")}},e.genVertexShaderCode=function(e){switch(e){case exports.PMaterialType.unlit:case exports.PMaterialType.pbr:case exports.PMaterialType.shadowBase:return ce;case exports.PMaterialType.skyboxFilter:return fe;default:throw new Error("Invalid material type "+e+" for genVertexShaderCode!")}},e.genFragmentShaderCode=function(e){switch(e){case exports.PMaterialType.unlit:case exports.PMaterialType.pbr:return ue;case exports.PMaterialType.shadowBase:return he;case exports.PMaterialType.skyboxFilter:return de;default:throw new Error("Invalid material type "+e+" for genFragmentShaderCode!")}},e}();function me(){return{vertexShaderCode:pe.genVertexShaderCode(exports.PMaterialType.pbr),fragmentShaderCode:pe.genFragmentShaderCode(exports.PMaterialType.pbr)}}function ge(){return{vertexShaderCode:pe.genVertexShaderCode(exports.PMaterialType.unlit),fragmentShaderCode:pe.genFragmentShaderCode(exports.PMaterialType.unlit)}}function ve(e){return{vertexShaderCode:pe.getVertexShaderCode(e),fragmentShaderCode:pe.getFragmentShaderCode(e)}}function ye(e){return{vertexShaderCode:pe.getVertexShaderCode(e),fragmentShaderCode:pe.getFragmentShaderCode(e)}}function Te(e){return{vertexShaderCode:pe.getVertexShaderCode(e),fragmentShaderCode:pe.getFragmentShaderCode(e)}}function xe(e){return{vertexShaderCode:Ce({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 be(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 _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 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 Ce(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")}pe.environment="webgl1";var Se=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}();exports.ModelMeshComponent=function(t){function n(n,r){var i;return(i=t.call(this,n)||this).morphWeights=[],i.getHitTestParams=function(t){i.computeBoundingBox();var n=i.bounding;if(n&&(t||Number.isInteger(n.behavior))){var r=n.type;if(r===e.spec.ModelBoundingType.box){if(l(i.content,mt)){var o=i.content;return{behavior:n.behavior,type:e.HitTestType.custom,collect:function(e,t){return o.hitTesting(e.origin,e.direction)}}}var a=i.transform.getWorldMatrix();return{behavior:n.behavior,type:e.HitTestType.custom,collect:function(e,t){return Ie(e,a,n)}}}if(r===e.spec.ModelBoundingType.sphere){var s=new N;i.transform.assignWorldTRS(s);var c=new N;return n.center&&c.setFromArray(n.center),c.add(s),{type:r,behavior:n.behavior,radius:n.radius||0,center:c}}}},r&&i.fromData(r),i}s(n,t);var i=n.prototype;return i.onStart=function(){var e;this.sceneManager=bt(this),this.createContent(),this.item.type=r,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(e){if(t.prototype.fromData.call(this,e),this.data=j({},e,{materials:[]}),this.data.rootBone=e.rootBone?this.engine.findObject(e.rootBone):void 0,this.data.geometry=this.engine.findObject(e.geometry),e.materials)for(var n=0;n<e.materials.length;n++)this.data.materials[n]=this.engine.findObject(e.materials[n])},i.createContent=function(){if(this.data){var e=this.data.interaction;this.bounding=e&&JSON.parse(JSON.stringify(e)),this.content=new mt(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&&l(this.content,mt)){var t,n=this.transform.getWorldMatrix(),r=this.content.computeBoundingBox(n),i=r.getCenter(new N),o=r.getSize(new N);return this.bounding={behavior:null==(t=this.bounding)?void 0:t.behavior,type:e.spec.ModelBoundingType.box,center:[i.x,i.y,i.z],size:[o.x,o.y,o.z]},this.bounding}},n}(e.RendererComponent),exports.ModelMeshComponent=d([e.effectsClass(e.spec.DataType.MeshComponent)],exports.ModelMeshComponent),exports.ModelSkyboxComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}s(t,e);var n=t.prototype;return n.onStart=function(){var e;this.createContent(),this.item.type=r,this.priority=this.item.renderOrder,this.sceneManager=bt(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 ot(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}(e.RendererComponent),exports.ModelSkyboxComponent=d([e.effectsClass(e.spec.DataType.SkyboxComponent)],exports.ModelSkyboxComponent),exports.ModelLightComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}s(t,e);var n=t.prototype;return n.onStart=function(){this.createContent(),this.item.type=r;var e=bt(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 ft(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}(e.Behaviour),exports.ModelLightComponent=d([e.effectsClass(e.spec.DataType.LightComponent)],exports.ModelLightComponent),exports.ModelCameraComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}s(t,e);var n=t.prototype;return n.onStart=function(){this.createContent(),this.item.type=r;var e=bt(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 ut(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}(e.Behaviour),exports.ModelCameraComponent=d([e.effectsClass(e.spec.DataType.CameraComponent)],exports.ModelCameraComponent),exports.AnimationComponent=function(e){function t(t){var n;return(n=e.call(this,t)||this).elapsedTime=0,n.animation=-1,n.clips=[],n}s(t,e);var n=t.prototype;return n.onStart=function(){this.elapsedTime=0,this.item.type=r},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,r,i=this;e.prototype.fromData.call(this,t),this.data=t,this.name=null!=(n=t.name)?n:"<empty>",this.animation=null!=(r=t.animation)?r:-1,this.clips=[],t.animationClips.forEach((function(e){var t=new Me(i.engine),n=i.engine.findObject(e);t.setFromAnimationClip(n),i.clips.push(t)}))},t}(e.Behaviour),exports.AnimationComponent=d([e.effectsClass(e.spec.DataType.AnimationComponent)],exports.AnimationComponent);var Me=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).path2Node={},t}s(t,e);var n=t.prototype;return n.sampleAnimation=function(e,t){for(var n,r=this.duration,i=Math.max(0,t)%r,o=b(this.positionCurves);!(n=o()).done;){var a=n.value,s=a.keyFrames.getValue(i%this.duration),l=this.getTargetItem(e,a.path);null==l||l.transform.setPosition(s.x,s.y,s.z)}for(var c,u=b(this.rotationCurves);!(c=u()).done;){var h=c.value,f=h.keyFrames.getValue(i%this.duration),d=this.getTargetItem(e,h.path);null==d||d.transform.setQuaternion(f.x,f.y,f.z,f.w)}for(var p,m=b(this.scaleCurves);!(p=m()).done;){var g=p.value,v=g.keyFrames.getValue(i%this.duration),y=this.getTargetItem(e,g.path);null==y||y.transform.setScale(v.x,v.y,v.z)}for(var T,x=b(this.floatCurves);!(T=x()).done;){var _=T.value,C=_.keyFrames.getValue(i%this.duration),S=this.getTargetItem(e,_.path);if("ModelMeshComponent"===_.className){var M=null==S?void 0:S.getComponent(exports.ModelMeshComponent);if(M)Ae(M,_.property.split("."),C);else console.error("Can't find mesh component.")}else console.warn("Ignore curve: className "+_.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,r=e,i=b(t.split("/"));!(n=i()).done;){for(var o,a=n.value,s=!1,l=b(r.children);!(o=l()).done;){var c=o.value;if(c.name===a){r=c,s=!0;break}}if(!s)throw new Error("Can't find path in tree "+e.id+", "+t+".")}return this.path2Node[t]=r,r},t}(e.AnimationClip);function Ae(e,t,n){for(var r=t.length,i=e,o=0;o<r-1;o++){var a=t[o];if(!(a in i)||"object"!=typeof i[a])return void console.error("Invalid properties "+t+".");i=i[a]}i[t[r-1]]=n}function Ie(e,t,n){var r=t,i=r.clone().invert(),o=e.clone().applyMatrix(i),a=N.fromArray(n.center),s=N.fromArray(n.size).multiply(.5),l=a.clone().subtract(s),c=a.clone().add(s),u=o.intersectBox({min:l,max:c},new N);return void 0!==u?[r.transformPoint(u)]:void 0}function Ee(e,t,n,r){var i=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?(i=(n.x-e.x)*u,o=(r.x-e.x)*u):(i=(r.x-e.x)*u,o=(n.x-e.x)*u),h>=0?(a=(n.y-e.y)*h,s=(r.y-e.y)*h):(a=(r.y-e.y)*h,s=(n.y-e.y)*h),!(i>s||a>o||((a>i||i!=i)&&(i=a),(s<o||o!=o)&&(o=s),f>=0?(l=(n.z-e.z)*f,c=(r.z-e.z)*f):(l=(r.z-e.z)*f,c=(n.z-e.z)*f),i>c||l>o||((l>i||i!=i)&&(i=l),(c<o||o!=o)&&(o=c),o<0))))return i>=0?i:o}var we=new N,Ne=new N,Le=new N,Pe=new N;function Re(e,t,n,r,i,o){Ne.subtractVectors(r,n),Le.subtractVectors(i,n),Pe.crossVectors(Ne,Le);var a=t.dot(Pe),s=0;if(a>0){if(o)return;s=1}else{if(!(a<0))return;s=-1,a=-a}we.subtractVectors(e,n),Le.crossVectors(we,Le);var l=s*t.dot(Le);if(!(l<0)){Ne.crossVectors(Ne,we);var c=s*t.dot(Ne);if(!(c<0||l+c>a)){var u=-s*we.dot(Pe);if(!(u<0))return u/a}}}var Oe=function(){function t(){}return t.createTexture2D=function(n,r,i,a,s){return o((function(){var o,l,c,u;return p(this,(function(h){return void 0===r.imageData?(console.error("createTexture2D: Invalid image data from "+r+"."),[2,e.Texture.create(n,{name:"createTexture2D",sourceType:e.TextureSourceType.data,data:{data:new Uint8Array([255,255,255,255]),width:1,height:1}})]):(o=new Blob([r.imageData],{type:r.mimeType}),l=window.URL||window.webkitURL,c=l.createObjectURL(o),(u=new Image).src=c,[2,new Promise((function(r,o){u.onload=function(){var o,h=null!=(o=i.minFilter)?o:e.glContext.LINEAR_MIPMAP_LINEAR,f=!1;s&&(h=e.glContext.LINEAR_MIPMAP_LINEAR,t.isPow2(u.width)&&t.isPow2(u.height)||(h=e.glContext.LINEAR),f=!a);var d,p,m,g=!1;h!=e.glContext.NEAREST_MIPMAP_NEAREST&&h!=e.glContext.LINEAR_MIPMAP_NEAREST&&h!=e.glContext.NEAREST_MIPMAP_LINEAR&&h!=e.glContext.LINEAR_MIPMAP_LINEAR||(g=!0);var v=e.Texture.create(n,{name:"createTexture2D",wrapS:null!=(d=i.wrapS)?d:e.glContext.REPEAT,wrapT:null!=(p=i.wrapT)?p:e.glContext.REPEAT,magFilter:null!=(m=i.magFilter)?m:e.glContext.LINEAR,minFilter:h,anisotropic:1,premultiplyAlpha:f,sourceType:e.TextureSourceType.image,image:u,generateMipmap:g});r(v),l.revokeObjectURL(c)},u.onerror=o}))])}))}))()},t.createTextureList=function(e,t,n){var r=this;return o((function(){return p(this,(function(i){switch(i.label){case 0:return[4,Promise.all(n.map((function(n){return r.createTexture2D(e,t[n.source],n)})))];case 1:return[2,i.sent()]}}))}))()},t.getTextureCubeData=function(e){return o((function(){var t;return p(this,(function(n){switch(n.label){case 0:return[4,Ve.loadImageFromImageData(e[0])];case 1:return t=[n.sent()],[4,Ve.loadImageFromImageData(e[1])];case 2:return t=t.concat([n.sent()]),[4,Ve.loadImageFromImageData(e[2])];case 3:return t=t.concat([n.sent()]),[4,Ve.loadImageFromImageData(e[3])];case 4:return t=t.concat([n.sent()]),[4,Ve.loadImageFromImageData(e[4])];case 5:return t=t.concat([n.sent()]),[4,Ve.loadImageFromImageData(e[5])];case 6:return[2,t.concat([n.sent()])]}}))}))()},t.getTextureCubeMipmapData=function(e){var t=this;return o((function(){var n,r,i;return p(this,(function(o){switch(o.label){case 0:n=[],r=0,o.label=1;case 1:return r<e.length?(i=n.push,[4,t.getTextureCubeData(e[r])]):[3,4];case 2:i.apply(n,[o.sent()]),o.label=3;case 3:return r++,[3,1];case 4:return[2,n]}}))}))()},t.createTextureCubeFromURL=function(t,n){var r=this;return o((function(){var i;return p(this,(function(o){switch(o.label){case 0:return[4,e.getDefaultTextureFactory().loadSource({type:e.TextureSourceType.image,target:e.glContext.TEXTURE_CUBE_MAP,map:n},r.cubemapTexConfig)];case 1:return i=o.sent(),[2,e.Texture.create(t,i)]}}))}))()},t.createTextureCubeMipmapFromURL=function(t,n){var r=this;return o((function(){var i;return p(this,(function(o){switch(o.label){case 0:return[4,e.getDefaultTextureFactory().loadSource({type:e.TextureSourceType.mipmaps,target:e.glContext.TEXTURE_CUBE_MAP,maps:n},r.cubemapMipTexConfig)];case 1:return i=o.sent(),[2,e.Texture.create(t,i)]}}))}))()},t.createTextureCubeFromBuffer=function(n,r){var i=this;return o((function(){var o;return p(this,(function(a){switch(a.label){case 0:return[4,t.getTextureCubeData(r)];case 1:return o=a.sent(),[2,e.Texture.create(n,j({name:"createTextureCubeFromBuffer",sourceType:e.TextureSourceType.image,cube:o,target:e.glContext.TEXTURE_CUBE_MAP},i.cubemapTexConfig))]}}))}))()},t.createTextureCubeMipmapFromBuffer=function(n,r,i){var a=this;return o((function(){var o,s,l,c,u;return p(this,(function(h){switch(h.label){case 0:return[4,t.getTextureCubeMipmapData(r)];case 1:for(o=h.sent(),s=0;Math.pow(2,s)<i;)++s;h.label=2;case 2:return o.length<=s?(l=Math.pow(2,s-o.length),c="https://gw.alipayobjects.com/zos/gltf-asset/67896749597915/img"+l+".png",[4,e.loadImage(c)]):[3,4];case 3:return u=h.sent(),o.push([u,u,u,u,u,u]),[3,2];case 4:return[2,e.Texture.create(n,j({name:"createTextureCubeMipmapFromBuffer",sourceType:e.TextureSourceType.mipmaps,mipmaps:o,target:e.glContext.TEXTURE_CUBE_MAP},a.cubemapMipTexConfig))]}}))}))()},t.getTexture=function(e,t){return e<0||e>=t.length?null:t[e]},t.createTextureFromImage=function(t,n){var r={name:"createTextureFromImage",image:n,sourceType:e.TextureSourceType.image,flipY:!1,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR,wrapT:e.glContext.REPEAT,wrapS:e.glContext.REPEAT};return e.Texture.create(t,r)},t.deleteTexture=function(e){e.dispose()},t.deleteMesh=function(t){t.dispose({geometries:e.DestroyOptions.destroy})},t.deleteGeometry=function(e){e.dispose()},t.deleteRenderPass=function(t){t.dispose({meshes:{geometries:e.DestroyOptions.destroy},depthStencilAttachment:e.RenderPassDestroyAttachmentType.force,colorAttachment:e.RenderPassDestroyAttachmentType.force})},t.isTransparentMesh=function(e){return!0===e.material.blending},t.isSupportFloatTexture=function(e){return 0!==e.gpuCapability.detail.floatTexture},t.isSupportHalfFloatTexture=function(e){return 0!==e.gpuCapability.detail.halfFloatTexture},t.isPow2=function(e){return!(e&e-1||!e)},t}();Oe.cubemapTexConfig={name:"cubemap texture",wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR},Oe.cubemapMipTexConfig={wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR_MIPMAP_LINEAR};var Fe,De,Ue,Be=function(){function t(){}return t.createFilterMesh=function(n,r,i){var o=Y.getInstance(),a=i.vertexShaderCode,s=i.fragmentShaderCode,l=e.Geometry.create(n,t.getPlaneGeometry()),c=2===n.gpuCapability.level,u=e.Material.create(n,{shader:{vertex:a,fragment:s,shared:o.shaderShared,glslVersion:c?e.GLSLVersion.GLSL3:e.GLSLVersion.GLSL1}});return i.setMaterialStates(u),e.Mesh.create(n,{name:r,worldMatrix:R.fromIdentity(),material:u,geometry:l})},t.getPlaneGeometry=function(){var n=t.getPlaneVertexArray();return{attributes:{aPos:{type:e.glContext.FLOAT,size:3,data:n,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:0},aUV:{type:e.glContext.FLOAT,size:2,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:3*Float32Array.BYTES_PER_ELEMENT,dataSource:"aPos"},aNormal:{type:e.glContext.FLOAT,size:3,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:5*Float32Array.BYTES_PER_ELEMENT,dataSource:"aPos"}},drawStart:0,drawCount:n.length/8}},t.getPlaneVertexArray=function(){return new Float32Array([-1,-1,0,0,0,0,0,1,1,-1,0,1,0,0,0,1,1,1,0,1,1,0,0,1,-1,-1,0,0,0,0,0,1,1,1,0,1,1,0,0,1,-1,1,0,0,1,0,0,1])},t}(),ke=function(){function t(){}return t.createLightOptions=function(e){var t,n,r,i,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!=(r=e.range)?r:0}:"spot"===e.type?{color:c,intensity:null!=(i=e.intensity)?i: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"}},t.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}}},t.toPlayerColor3=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2])]},t.toPlayerColor4=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2]),this.scaleTo255(e[3])]},t.toPluginColor3=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2])]},t.toPluginColor4=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2]),this.scaleTo1(e[3])]},t.createUVTransform=function(e,t,n){var r=e.getVector4(t),i=e.getFloat(n),o=P.fromIdentity();r&&o.setFromArray([1,0,0,0,1,0,r.z,r.w,1]);var a=new P;if(i){var s=Math.cos(i),l=Math.sin(i);a.setFromArray([s,l,0,-l,s,0,0,0,1]),o.multiply(a)}return r&&(a.setFromArray([r.x,0,0,0,r.y,0,0,0,1]),o.multiply(a)),o.transpose(),o},t.clamp=function(e,t,n){return Math.max(Math.min(e,n),t)},t.scaleTo255=function(e){var t=Math.round(255*e);return Math.max(0,Math.min(t,255))},t.scaleTo1=function(e){var t=e/255;return Math.max(0,Math.min(t,1))},t.focusOnPoint=function(t,n,r){var i=N.fromArray(t),o=N.fromArray(r),a=(new N).copyFrom(i).subtract(o);R.fromRotationAxis(new N(0,1,0),n*G).transformPoint(a);var s=a.clone().add(o),l=(new R).lookAt(s,o,new N(0,1,0)).invert(),c=new e.Transform;return c.setValid(!0),c.cloneFromMatrix(l),c},t.preprocessScene=function(t,n,r){var i=this,o=n!==e.PLAYER_OPTIONS_ENV_EDITOR,a="tiny3d"===r,s=t.jsonScene;if(!(s&&s.textures&&s.materials))return{};var l={};t.textureOptions.forEach((function(e){var t=e.id;t&&(l[t]=e)}));var c=!1;return o&&(s.materials.forEach((function(e){i.preprocessTextureOptions(l,e.textures._BaseColorSampler,!0,a),i.preprocessTextureOptions(l,e.textures._MetallicRoughnessSampler,!1,a),i.preprocessTextureOptions(l,e.textures._NormalSampler,!1,a),i.preprocessTextureOptions(l,e.textures._OcclusionSampler,!1,a),i.preprocessTextureOptions(l,e.textures._EmissiveSampler,!1,a)})),s.components.forEach((function(t){if(t.dataType===e.spec.DataType.SkyboxComponent){c=!0;var n=t;n.diffuseImage&&i.preprocessTextureOptions(l,n.diffuseImage,!1,a),n.specularImage&&i.preprocessTextureOptions(l,n.specularImage,!1,a)}}))),{loadSkybox:c}},t.preprocessTextureOptions=function(t,n,r,i){var o;if(i&&n&&(o="texture"in n?n.texture.id:n.id)){var a=t[o];if(a)if(void 0===a.target||a.target===e.glContext.TEXTURE_2D){a.wrapS=e.glContext.REPEAT,a.wrapT=e.glContext.REPEAT,a.magFilter=e.glContext.LINEAR,a.minFilter=e.glContext.LINEAR_MIPMAP_LINEAR,r||(a.premultiplyAlpha=!0);var s=a;s.generateMipmap=!0;var l=s.image;l&&l.width&&l.height&&(Oe.isPow2(l.width)&&Oe.isPow2(l.height)||(a.minFilter=e.glContext.LINEAR))}else a.target===e.glContext.TEXTURE_CUBE_MAP&&(a.wrapS=e.glContext.CLAMP_TO_EDGE,a.wrapT=e.glContext.CLAMP_TO_EDGE,void 0!==a.mipmaps?1===a.mipmaps.length?(a.magFilter=e.glContext.LINEAR,a.minFilter=e.glContext.LINEAR):(a.magFilter=e.glContext.LINEAR,a.minFilter=e.glContext.LINEAR_MIPMAP_LINEAR):(a.magFilter=e.glContext.LINEAR,a.minFilter=e.glContext.LINEAR))}},t.createGeometry=function(t,n,r){var i=$(n,r),o={};for(var a in i.attributes){var s=i.attributes[a];o[this.getAttributeName(a)]=s}return i.attributes=o,e.Geometry.create(t,i)},t.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+".")}},t.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},t.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])},t}(),Ve=function(){function t(){}return t.getImageFileName=function(e,t){var n=e.lastIndexOf("/"),r=e.lastIndexOf("."),i=e.substring(n+1,r);return t?i+t:i},t.getCurrnetTimeStr=function(){var e=new Date(Date.now()),t=e.toLocaleString("zh-CN"),n=""+e.getMilliseconds();return t.split(/[ /:]+/).join("")+n.padStart(3,"0")},t.saveFileForURL=function(e,t){var n=document.createElement("a");n.setAttribute("download",t),n.target="_blank",n.href=e,n.click()},t.createPlayer=function(t){void 0===t&&(t=!0);var n=document.createElement("canvas");return n.width=512,n.height=512,new e.Player({canvas:n,renderFramework:"webgl2",env:e.PLAYER_OPTIONS_ENV_EDITOR,renderOptions:{willCaptureImage:!0},manualRender:t})},t.sleep=function(e){return o((function(){return p(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))()},t.loadImageFromGLTFImage=function(t){return o((function(){return p(this,(function(n){return[2,e.loadImage(new Blob([t.imageData],{type:t.mimeType}))]}))}))()},t.loadImageFromImageData=function(t){return o((function(){return p(this,(function(n){return[2,e.loadImage(new Blob([t.data],{type:t.mimeType}))]}))}))()},t.getCanvasArrayBuffer=function(e){return o((function(){return p(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)}))]}))}))()},t.getImageArrayBuffer=function(e){var t=this;return o((function(){var n;return p(this,(function(r){return(n=document.createElement("canvas")).width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0),[2,t.getCanvasArrayBuffer(n)]}))}))()},t.getCanvasImageData=function(e){return e.getContext("2d").getImageData(0,0,e.width,e.height)},t.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)},t.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))},t.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},t}(),Ge=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 N;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}(),ze=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,r;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!=(r=e.stride)?r: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 r=0;r<this.compCount;r++)n[r]*=this.compressScale,this.signed&&(n[r]=Math.max(n[r],-1));return n}},t.getLength=function(){return Math.round((this.length-this.offset)/this.stride)},e}(),He=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 r=n.aPos,i=e.getAttributeData("aPos");this.position=new ze,this.position.create(r,i);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 ze,this.joint.create(o,s),this.weight=new ze,this.weight.create(a,l)}this.bindMatrices=t},t.getBoundingBox=function(e){var t=this;e.makeEmpty();var n=new R,r=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0,i=new Set;if(void 0!==this.index)for(var o=0;o<this.drawCount;o++){var a=this.drawStart+o;a<this.index.length&&i.add(this.index[a])}else for(var s=0;s<this.drawCount;s++)i.add(this.drawStart+s);return i.forEach((function(i){var o=t.position.getData(i);if(void 0!==o){var a=N.fromArray(o);if(r){var s,l,c=null==(s=t.joint)?void 0:s.getData(i),u=null==(l=t.weight)?void 0:l.getData(i);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 p=n.transformVector4(new L(a.x,a.y,a.z,1));Math.abs(p.w)>1e-4&&(p.multiply(1/p.w),a.set(p.x,p.y,p.z))}}}e.expandByPoint(a)}})),e},e}(),je=function(){function e(){this.drawStart=0,this.drawCount=0,this.doubleSided=!1,this.bindMatrices=[],this.hasAnimation=!1,this.skinMatrix=new R}var t=e.prototype;return t.create=function(e,t,n){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var r=e.attributes;this.index=e.getIndexData();var i=r.aPos,o=e.getAttributeData("aPos");this.position=new ze,this.position.create(i,o);var a=r.aJoints,s=r.aWeights;if(void 0!==a&&void 0!==s){var l=e.getAttributeData("aJoints"),c=e.getAttributeData("aWeights");this.joint=new ze,this.joint.create(a,l),this.weight=new ze,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,r=new N,i=new N,o=new N,a=new L,s=new L,l=new L,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 p=this.getPosition(h,r,a),m=this.getPosition(f,i,s),g=this.getPosition(d,o,l);if(p&&m&&g){var v=Re(e,t,p,m,g,c);void 0!==v&&(void 0===n||n>v)&&(n=v)}}return n},t.getPosition=function(e,t,n){var r=this.position.getData(e);if(void 0===r)return null;if(this.hasAnimation){var i,o,a=null==(i=this.joint)?void 0:i.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(r[0],r[1],r[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(r[0],r[1],r[2]);return t},e}(),We=function(){function t(){}return t.checkNumber=function(e){return"number"==typeof e},t.checkNumberUndef=function(e){return void 0===e||this.checkNumber(e)},t.checkNumber01=function(e){return this.checkNumber(e)&&e>=0&&e<=1},t.checkNumber01Undef=function(e){return void 0===e||this.checkNumber01(e)},t.checkPositive=function(e){return this.checkNumber(e)&&e>0},t.checkNonnegative=function(e){return this.checkNumber(e)&&e>=0},t.checkNonnegativeUndef=function(e){return void 0===e||this.checkNonnegative(e)},t.checkBoolean=function(e){return"boolean"==typeof e},t.checkBooleanUndef=function(e){return void 0===e||this.checkBoolean(e)},t.checkString=function(e){return"string"==typeof e},t.checkStringUndef=function(e){return void 0===e||this.checkString(e)},t.checkFloat32Array=function(e){return l(e,Float32Array)},t.checkFloat32ArrayUndef=function(e){return void 0===e||this.checkFloat32Array(e)},t.checkParent=function(e){return void 0===e||!!this.checkNumber(e)&&e>=0},t.checkTexCoord=function(e){return void 0===e||!!this.checkNumber(e)&&(e>=0&&e<=1)},t.checkVec2=function(e){var t=this;return!!Array.isArray(e)&&(2==e.length&&e.every((function(e){return t.checkNumber(e)})))},t.checkVec2Undef=function(e){return void 0===e||this.checkVec2(e)},t.checkVec3=function(e){var t=this;return!!Array.isArray(e)&&(3==e.length&&e.every((function(e){return t.checkNumber(e)})))},t.checkNonnegative3=function(e){var t=this;return!!Array.isArray(e)&&(3==e.length&&e.every((function(e){return t.checkNonnegative(e)})))},t.checkVec4=function(e){var t=this;return!!Array.isArray(e)&&(4==e.length&&e.every((function(e){return t.checkNumber(e)})))},t.checkNonnegative4=function(e){var t=this;return!!Array.isArray(e)&&(4==e.length&&e.every((function(e){return t.checkNonnegative(e)})))},t.checkNumberArray=function(e){var t=this;return!!Array.isArray(e)&&e.every((function(e){return t.checkNumber(e)}))},t.checkTexture=function(t){return!!l(t,e.Texture)&&(t.isDestroyed&&console.error("Texture is destroyed, "+t.name+"."),!t.isDestroyed)},t.checkTextureUndef=function(e){return void 0===e||this.checkTexture(e)},t.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))))},t.checkTexTransformUndef=function(e){return void 0===e||this.checkTexTransform(e)},t.checkMatBlending=function(t){return void 0===t||t===e.spec.MaterialBlending.opaque||t===e.spec.MaterialBlending.masked||t===e.spec.MaterialBlending.translucent||t===e.spec.MaterialBlending.additive},t.checkMatSide=function(t){return void 0===t||t===e.spec.SideMode.BACK||t===e.spec.SideMode.DOUBLE||t===e.spec.SideMode.FRONT},t.checkAnimPath=function(e){return"translation"===e||"rotation"===e||"scale"===e||"weights"===e},t.checkAnimInterp=function(e){return"LINEAR"===e||"STEP"===e||"CUBICSPLINE"===e},t.assertGeometry=function(t,n){l(t,e.Geometry)||console.error("Invalid geometry type "+this.stringify(t)+"."),!0===t.isDestroyed&&console.error("Geometry object is destroyed."),this.checkNonnegative(t.getDrawStart())||console.error("Invalid geometry draw start: "+t.getDrawStart()+", "+this.stringify(t)+".")},t.assertGeometryBuffer=function(e,t,n){var r=this.createAttributeArray(e,t);void 0!==r&&r.getLength()<n&&console.error(t+" Length("+r.getLength()+") is less than draw count("+n+"), "+this.stringify(e)+".")},t.createAttributeArray=function(e,t){var n=e.attributes;if(void 0!==n){var r=n[t];if(void 0!==r){var i=e.getAttributeData(t);if(void 0!==i){var o=new ze;return o.create(r,i),o}}}},t.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 R,n=0;n<e.inverseBindMatrices.length;n+=16){for(var r=0;r<16;r++)t.elements[r]=e.inverseBindMatrices[n+r];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)+".")},t.assertMatOptions=function(t){t.type===e.spec.MaterialType.unlit?(this.checkString(t.name)||console.error("Invalid material name "+t.name+", "+this.stringify(t)+"."),this.checkNonnegative4(t.baseColorFactor)||console.error("Invalid material baseColorFactor "+t.baseColorFactor+", "+this.stringify(t)+"."),this.checkTextureUndef(t.baseColorTexture)||console.error("Invalid material baseColorTexture "+t.baseColorTexture+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform "+t.baseColorTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate "+t.baseColorTextureCoordinate+", "+this.stringify(t)+"."),this.checkBooleanUndef(t.depthMask)||console.error("Invalid material depthMask "+t.depthMask+", "+this.stringify(t)+"."),this.checkMatBlending(t.blending)||console.error("Invalid material blending "+t.blending+", "+this.stringify(t)+"."),this.checkMatSide(t.side)||console.error("Invalid material side "+t.side+", "+this.stringify(t)+"."),t.blending===e.spec.MaterialBlending.masked&&void 0===t.alphaCutOff&&console.error("Material alphaCutOff is required for mask, "+this.stringify(t)+"."),this.checkNumber01Undef(t.alphaCutOff)||console.error("Invalid material alphaCutOff "+t.alphaCutOff+", "+this.stringify(t)+".")):t.type===e.spec.MaterialType.pbr?(this.checkString(t.name)||console.error("Invalid material name "+t.name+", "+this.stringify(t)+"."),this.checkNonnegative4(t.baseColorFactor)||console.error("Invalid material baseColorFactor "+t.baseColorFactor+", "+this.stringify(t)+"."),this.checkTextureUndef(t.baseColorTexture)||console.error("Invalid material baseColorTexture "+t.baseColorTexture+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform "+t.baseColorTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate "+t.baseColorTextureCoordinate+", "+this.stringify(t)+"."),this.checkBooleanUndef(t.useSpecularAA)||console.error("Invalid material useSpecularAA "+t.useSpecularAA+", "+this.stringify(t)+"."),this.checkNumber01(t.metallicFactor)||console.error("Invalid material metallicFactor "+t.metallicFactor+", "+this.stringify(t)+"."),this.checkNonnegative(t.roughnessFactor)||console.error("Invalid material roughnessFactor "+t.roughnessFactor+", "+this.stringify(t)+"."),this.checkTextureUndef(t.metallicRoughnessTexture)||console.error("Invalid material metallicRoughnessTexture "+t.metallicRoughnessTexture+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.metallicRoughnessTextureTransform)||console.error("Invalid material metallicRoughnessTextureTransform "+t.metallicRoughnessTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.metallicRoughnessTextureCoordinate)||console.error("Invalid material metallicRoughnessTextureCoordinate "+t.metallicRoughnessTextureCoordinate+", "+this.stringify(t)+"."),this.checkTextureUndef(t.normalTexture)||console.error("Invalid material normalTexture "+t.normalTexture+", "+this.stringify(t)+"."),this.checkNonnegativeUndef(t.normalTextureScale)||console.error("Invalid material normalTextureScale "+t.normalTextureScale+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.normalTextureTransform)||console.error("Invalid material normalTextureTransform "+t.normalTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.normalTextureCoordinate)||console.error("Invalid material normalTextureCoordinate "+t.normalTextureCoordinate+", "+this.stringify(t)+"."),this.checkTextureUndef(t.occlusionTexture)||console.error("Invalid material occlusionTexture "+t.occlusionTexture+", "+this.stringify(t)+"."),this.checkNumber01Undef(t.occlusionTextureStrength)||console.error("Invalid material occlusionTextureStrength "+t.occlusionTextureStrength+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.occlusionTextureTransform)||console.error("Invalid material occlusionTextureTransform "+t.occlusionTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.occlusionTextureCoordinate)||console.error("Invalid material occlusionTextureCoordinate "+t.occlusionTextureCoordinate+", "+this.stringify(t)+"."),this.checkNonnegative4(t.emissiveFactor)||console.error("Invalid material emissiveFactor "+t.emissiveFactor+", "+this.stringify(t)+"."),this.checkNonnegative(t.emissiveIntensity)||console.error("Invalid material emissiveIntensity "+t.emissiveIntensity+", "+this.stringify(t)+"."),this.checkTextureUndef(t.emissiveTexture)||console.error("Invalid material emissiveTexture "+t.emissiveTexture+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.emissiveTextureTransform)||console.error("Invalid material emissiveTextureTransform "+t.emissiveTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.emissiveTextureCoordinate)||console.error("Invalid material emissiveTextureCoordinate "+t.emissiveTextureCoordinate+", "+this.stringify(t)+"."),this.checkBooleanUndef(t.depthMask)||console.error("Invalid material depthMask "+t.depthMask+", "+this.stringify(t)+"."),this.checkMatBlending(t.blending)||console.error("Invalid material blending "+t.blending+", "+this.stringify(t)+"."),this.checkMatSide(t.side)||console.error("Invalid material side "+t.side+", "+this.stringify(t)+"."),t.blending===e.spec.MaterialBlending.masked&&void 0===t.alphaCutOff&&console.error("Material alphaCutOff is required for mask, "+this.stringify(t)+"."),this.checkNumber01Undef(t.alphaCutOff)||console.error("Invalid material alphaCutOff "+t.alphaCutOff+", "+this.stringify(t)+".")):console.error("Invalid material type "+this.stringify(t)+".")},t.assertPrimOptions=function(e,t){return this.assertGeometry(e.geometry,t),this.assertMatOptions(e.material),!0},t.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 r=e.primitives[n];this.assertPrimOptions(r)||console.error("Invalid primitive "+r+", "+this.stringify(e)+".");var i=new Ke;i.create(r.geometry),t.push(i)}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)+".")},t.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)+".")},t.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)+".")},t.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)+".")},t.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)},t.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)+".")}))},t.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)+"."))},t.stringify=function(t){var n={};for(var r in t)"internal"!==r&&"function"!=typeof t[r]&&(l(t[r],e.Texture)||l(t[r],e.Geometry)?n[r]=t[r].name:l(t[r],e.Renderer)||(n[r]=t[r]));return JSON.stringify(n)},t.pow2=function(e){for(var t=1;e-- >0;)t*=2;return t},t}(),Je=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]=Xe(e[n])},H(e,[{key:"bytes",get:function(){return 2*this.size}}]),e}(),Xe=(Fe=new Float32Array(1),De=new Int32Array(Fe.buffer),function(e){Fe[0]=e;var t=De[0],n=t>>16&32768,r=t>>12&2047,i=t>>23&255;return i<103?n:i>142?(n|=31744,n|=(255==i?0:1)&&8388607&t):i<113?n|=((r|=2048)>>114-i)+(r>>113-i&1):(n|=i-112<<10|r>>1,n+=1&r)});exports.TextureDataMode=void 0,(Ue=exports.TextureDataMode||(exports.TextureDataMode={}))[Ue.none=0]="none",Ue[Ue.float=1]="float",Ue[Ue.half_float=2]="half_float";var qe,Ye,Ze=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}s(t,e);var n=t.prototype;return n.create=function(e,t,n,r){var i;this.name=null!=(i=e.rootBoneName)?i:"Unnamed skin",this.type=exports.PObjectType.skin,this.rootBoneItem=n,this.skeleton=-1,this.jointItem=this.getJointItems(e,n),this.maxJointCount=Math.max(r,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=R.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 r=e.clone().invert(),i=new R;this.animationMatrices.forEach((function(e,o){var a=i.multiplyMatrices(r,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,r=n.maxVertexUniforms-25;if(e>Math.floor(r/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,r=this.genNodeName(t),i=[];return null==(n=e.boneNames)||n.forEach((function(e){var t=r[e];if(!t)throw new Error("Can't find node of bone name "+e+".");i.push(t)})),i},n.genNodeName=function(e){var t={},n=[];t[""]=e;for(var r,i=b(e.children);!(r=i()).done;){var o=r.value;this.genNodeNameDFS(o,n,t)}return t},n.genNodeNameDFS=function(e,t,n){t.push(e.name),n[t.join("/")]=e;for(var r,i=b(e.children);!(r=i()).done;){var o=r.value;this.genNodeNameDFS(o,t,n)}t.pop()},t}(K),Ke=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}s(t,e);var n=t.prototype;return n.create=function(e){var n=this;this.name=this.genName("Morph target"),this.type=exports.PObjectType.morph;var r=this.getAttributeMorphCount(t.positionNameList,e),i=this.getAttributeMorphCount(t.normalNameList,e),o=this.getAttributeMorphCount(t.tangentNameList,e),a=[r,i,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=r==this.morphWeightsLength,this.hasNormalMorph=i==this.morphWeightsLength,this.hasTangentMorph=o==this.morphWeightsLength),r>0&&r!=this.morphWeightsLength?(console.error("Position morph count mismatch: "+this.morphWeightsLength+", "+r+"."),!1):i>0&&i!=this.morphWeightsLength?(console.error("Normal morph count mismatch: "+this.morphWeightsLength+", "+i+"."),!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 r=e[n];if(void 0===t.getAttributeData(r))return n}return e.length},t}(K);Ke.positionNameList=["aTargetPosition0","aTargetPosition1","aTargetPosition2","aTargetPosition3","aTargetPosition4","aTargetPosition5","aTargetPosition6","aTargetPosition7"],Ke.normalNameList=["aTargetNormal0","aTargetNormal1","aTargetNormal2","aTargetNormal3","aTargetNormal4","aTargetNormal5","aTargetNormal6","aTargetNormal7"],Ke.tangentNameList=["aTargetTangent0","aTargetTangent1","aTargetTangent2","aTargetTangent3","aTargetTangent4","aTargetTangent5","aTargetTangent6","aTargetTangent7"],exports.PAnimInterpType=void 0,(qe=exports.PAnimInterpType||(exports.PAnimInterpType={}))[qe.linear=0]="linear",qe[qe.step=1]="step",qe[qe.cubicSpline=2]="cubicSpline",exports.PAnimPathType=void 0,(Ye=exports.PAnimPathType||(exports.PAnimPathType={}))[Ye.translation=0]="translation",Ye[Ye.rotation=1]="rotation",Ye[Ye.scale=2]="scale",Ye[Ye.weights=3]="weights";var Qe=function(){function t(e){this.engine=e,this.isHalfFloat=!0,this.width=0,this.height=0}var n=t.prototype;return n.create=function(t,n,r){var i,o;this.width=4,this.height=t,this.isHalfFloat=n,this.isHalfFloat&&(this.buffer=new Je(4*this.getSize()));var a=null!=(o=null==(i=this.buffer)?void 0:i.data)?o:new Float32Array(4*this.getSize()),s=this.isHalfFloat?e.glContext.HALF_FLOAT:e.glContext.FLOAT;this.texture=e.Texture.create(this.engine,{name:r,data:{width:this.width,height:this.height,data:a},target:e.glContext.TEXTURE_2D,format:e.glContext.RGBA,type:s,wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,minFilter:e.glContext.NEAREST,magFilter:e.glContext.NEAREST})},n.update=function(t){var n,r;(void 0!==this.buffer&&this.buffer.set(t,0),void 0!==this.texture)&&this.texture.updateSource({sourceType:e.TextureSourceType.data,data:{width:this.width,height:this.height,data:null!=(r=null==(n=this.buffer)?void 0:n.data)?r:t},target:e.glContext.TEXTURE_2D})},n.dispose=function(){var e;this.engine=null,this.buffer=void 0,null==(e=this.texture)||e.dispose()},n.getSize=function(){return this.width*this.height},n.getTexture=function(){return this.texture},t}(),$e=function(){function e(){this.funcMap=new Map,this.funcMap.set(exports.PMaterialType.unlit,ve),this.funcMap.set(exports.PMaterialType.pbr,ve),this.funcMap.set(exports.PMaterialType.shadowBase,ye),this.funcMap.set(exports.PMaterialType.shadowFilter,_e),this.funcMap.set(exports.PMaterialType.normalVis,xe),this.funcMap.set(exports.PMaterialType.simpleFilter,be),this.funcMap.set(exports.PMaterialType.skyboxFilter,Te)}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}(),et=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).materialType=exports.PMaterialType.none,n.vertexShaderCode="",n.fragmentShaderCode="",n.ZWrite=!0,n.ZTest=!0,n.renderType=e.spec.RenderType.Opaque,n.alphaClip=!1,n.alphaCutoff=.5,n.renderFace=e.spec.RenderFace.Front,n}s(n,t);var r=n.prototype;return r.getShaderFeatures=function(){var t=[];return this.isAlphaClip()?t.push("ALPHAMODE_MASK 1"):this.isOpaque()&&t.push("ALPHAMODE_OPAQUE 1"),this.renderFace===e.spec.RenderFace.Both&&t.push("DOUBLE_SIDED 1"),t},r.getShaderMacros=function(){var t=[];return this.isAlphaClip()?t.push({name:"ALPHAMODE_MASK"}):this.isOpaque()&&t.push({name:"ALPHAMODE_OPAQUE"}),this.renderFace===e.spec.RenderFace.Both&&t.push({name:"DOUBLE_SIDED"}),t},r.updateUniforms=function(t){if(Y.getInstance().renderMode3D===e.spec.RenderMode3D.uv){var n=Y.getInstance().renderMode3DUVGridSize;t.setFloat("_DebugUVGridSize",n)}},r.build=function(e){var t=this.getFeatureList(e),n=Y.getInstance().isWebGL2,r=$e.getInstance().genShaderCode({material:this,isWebGL2:n,featureList:t});this.vertexShaderCode=r.vertexShaderCode,this.fragmentShaderCode=r.fragmentShaderCode},r.getFeatureList=function(e){var t,n=this.getShaderFeatures();void 0!==e&&(t=n).push.apply(t,[].concat(e));this.materialType!==exports.PMaterialType.shadowBase&&(Y.getInstance().isEditorEnv&&n.push("EDITOR_TRANSFORM"));return n},r.getMacroList=function(e){var t,n=this.getShaderMacros();void 0!==e&&(t=n).push.apply(t,[].concat(e));this.materialType!==exports.PMaterialType.shadowBase&&(Y.getInstance().isEditorEnv&&n.push({name:"EDITOR_TRANSFORM"}));return n},r.setMaterialStates=function(t){this.renderType===e.spec.RenderType.Transparent?(t.blending=!0,t.depthTest=this.ZTest,t.depthMask=this.ZWrite,t.blendEquation=[e.glContext.FUNC_ADD,e.glContext.FUNC_ADD],t.blendFunction=[e.glContext.ONE,e.glContext.ONE_MINUS_SRC_ALPHA,e.glContext.ONE,e.glContext.ONE_MINUS_SRC_ALPHA]):Y.getInstance().isTiny3dMode?(t.blending=!1,t.depthTest=!0,t.depthMask=!0):(t.blending=!1,t.depthTest=this.ZTest,t.depthMask=this.ZWrite),this.setFaceSideStates(t)},r.setFaceSideStates=function(t){this.isBothSide()?t.culling=!1:this.isBackSide()?(t.cullFace=e.glContext.FRONT,t.frontFace=e.glContext.CCW,t.culling=!0):(t.cullFace=e.glContext.BACK,t.frontFace=e.glContext.CCW,t.culling=!0)},r.dispose=function(){this.vertexShaderCode="",this.fragmentShaderCode=""},r.isValid=function(){return this.materialType!==exports.PMaterialType.none&&t.prototype.isValid.call(this)},r.isOpaque=function(){return this.renderType===e.spec.RenderType.Opaque},r.isAlphaClip=function(){return this.alphaClip},r.isTransparent=function(){return this.renderType===e.spec.RenderType.Transparent},r.isFrontSide=function(){return this.renderFace===e.spec.RenderFace.Front},r.isBackSide=function(){return this.renderFace===e.spec.RenderFace.Back},r.isBothSide=function(){return this.renderFace===e.spec.RenderFace.Both},n}(K),tt=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).baseColorFactor=new O(1,1,1,1),e}s(n,t);var r=n.prototype;return r.create=function(t){var n,r,i,o,a;this.effectMaterial=t,this.name=t.name,this.type=exports.PObjectType.material,this.materialType=exports.PMaterialType.unlit,this.baseColorTexture=null!=(n=t.getTexture("_BaseColorSampler"))?n:void 0,this.baseColorTextureTrans=ke.createUVTransform(t,"_BaseColorSampler_ST","_BaseColorRotation"),this.baseColorFactor=null!=(r=t.getColor("_BaseColorFactor"))?r:new O(1,1,1,1),this.ZWrite=0!==t.getFloat("ZWrite"),this.ZTest=0!==t.getFloat("ZTest"),this.renderType=null!=(i=t.stringTags.RenderType)?i:e.spec.RenderType.Opaque,this.alphaClip=1===t.getFloat("AlphaClip"),this.alphaCutoff=null!=(o=t.getFloat("_AlphaCutoff"))?o:0,this.renderFace=null!=(a=t.stringTags.RenderFace)?a:e.spec.RenderFace.Front},r.dispose=function(){t.prototype.dispose.call(this),this.baseColorTexture=void 0},r.getShaderFeatures=function(){var e=t.prototype.getShaderFeatures.call(this);return e.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&e.push("HAS_BASE_COLOR_MAP 1"),e.push("MATERIAL_UNLIT 1"),e},r.getShaderMacros=function(){var e=t.prototype.getShaderMacros.call(this);return e.push({name:"MATERIAL_METALLICROUGHNESS"}),this.hasBaseColorTexture()&&e.push({name:"HAS_BASE_COLOR_MAP"}),e.push({name:"MATERIAL_UNLIT"}),e},r.updateUniforms=function(e){t.prototype.updateUniforms.call(this,e),void 0!==this.baseColorTexture&&(e.setInt("_BaseColorUVSet",0),e.setMatrix3("_BaseColorUVTransform",this.baseColorTextureTrans)),e.setFloat("_MetallicFactor",0),e.setFloat("_RoughnessFactor",0),e.setFloat("_Exposure",1)},r.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},r.getBaseColorTexture=function(){return this.baseColorTexture},r.setBaseColorTexture=function(e){this.baseColorTexture=e},r.getBaseColorFactor=function(){return this.baseColorFactor},r.setBaseColorFactor=function(e){l(e,O)?this.baseColorFactor.set(e.r,e.g,e.b,e.a):l(e,L)?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},n}(et),nt=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).baseColorFactor=new O(1,1,1,1),e.useSpecularAA=!1,e.metallicFactor=0,e.roughnessFactor=1,e.normalTextureScale=1,e.occlusionTextureStrength=1,e.emissiveFactor=new O(0,0,0,0),e.emissiveIntensity=1,e}s(n,t);var r=n.prototype;return r.create=function(t){var n,r,i,o,a,s,l,c,u,h,f,d,p,m,g;this.effectMaterial=t,this.name=t.name,this.type=exports.PObjectType.material,this.materialType=exports.PMaterialType.pbr,this.baseColorTexture=null!=(n=t.getTexture("_BaseColorSampler"))?n:void 0,this.baseColorTextureTrans=ke.createUVTransform(t,"_BaseColorSampler_ST","_BaseColorRotation"),this.baseColorFactor=null!=(r=t.getColor("_BaseColorFactor"))?r:new O(1,1,1,1),this.metallicRoughnessTexture=null!=(i=t.getTexture("_MetallicRoughnessSampler"))?i:void 0,this.metallicRoughnessTextureTrans=ke.createUVTransform(t,"_MetallicRoughnessSampler_ST","_MetallicRoughnessRotation"),this.useSpecularAA=1===t.getFloat("_SpecularAA"),this.metallicFactor=null!=(o=t.getFloat("_MetallicFactor"))?o:1,this.roughnessFactor=null!=(a=t.getFloat("_RoughnessFactor"))?a:0,this.normalTexture=null!=(s=t.getTexture("_NormalSampler"))?s:void 0,this.normalTextureTrans=ke.createUVTransform(t,"_NormalSampler_ST","_NormalRotation"),this.normalTextureScale=null!=(l=t.getFloat("_NormalScale"))?l:1,this.occlusionTexture=null!=(c=t.getTexture("_OcclusionSampler"))?c:void 0,this.occlusionTextureTrans=ke.createUVTransform(t,"_OcclusionSampler_ST","_OcclusionRotation"),this.occlusionTextureStrength=null!=(u=t.getFloat("_OcclusionStrength"))?u:1,this.emissiveTexture=null!=(h=t.getTexture("_EmissiveSampler"))?h:void 0,this.emissiveTextureTrans=ke.createUVTransform(t,"_EmissiveSampler_ST","_EmissiveRotation"),this.emissiveFactor=null!=(f=t.getColor("_EmissiveFactor"))?f:new O(0,0,0,1),this.emissiveIntensity=null!=(d=t.getFloat("_EmissiveIntensity"))?d:1,this.ZWrite=0!==t.getFloat("ZWrite"),this.ZTest=0!==t.getFloat("ZTest"),this.renderType=null!=(p=t.stringTags.RenderType)?p:e.spec.RenderType.Opaque,this.alphaClip=1===t.getFloat("AlphaClip"),this.alphaCutoff=null!=(m=t.getFloat("_AlphaCutoff"))?m:0,this.renderFace=null!=(g=t.stringTags.RenderFace)?g:e.spec.RenderFace.Front},r.dispose=function(){t.prototype.dispose.call(this),this.baseColorTexture=void 0,this.metallicRoughnessTexture=void 0,this.normalTexture=void 0,this.occlusionTexture=void 0,this.emissiveTexture=void 0},r.getShaderFeatures=function(){var e=t.prototype.getShaderFeatures.call(this);return e.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&(e.push("HAS_BASE_COLOR_MAP 1"),void 0!==this.baseColorTextureTrans&&e.push("HAS_BASECOLOR_UV_TRANSFORM 1")),this.hasMetallicRoughnessTexture()&&(e.push("HAS_METALLIC_ROUGHNESS_MAP 1"),void 0!==this.metallicRoughnessTextureTrans&&e.push("HAS_METALLICROUGHNESS_UV_TRANSFORM 1")),this.useSpecularAA&&e.push("USE_SPECULAR_AA 1"),this.hasNormalTexture()&&(e.push("HAS_NORMAL_MAP 1"),void 0!==this.normalTextureTrans&&e.push("HAS_NORMAL_UV_TRANSFORM 1")),this.hasOcclusionTexture()&&(e.push("HAS_OCCLUSION_MAP 1"),void 0!==this.occlusionTextureTrans&&e.push("HAS_OCCLUSION_UV_TRANSFORM 1")),this.hasEmissiveTexture()?(e.push("HAS_EMISSIVE_MAP 1"),void 0!==this.emissiveTextureTrans&&e.push("HAS_EMISSIVE_UV_TRANSFORM 1")):this.hasEmissiveValue()&&e.push("HAS_EMISSIVE 1"),e},r.getShaderMacros=function(){var e=t.prototype.getShaderMacros.call(this);return e.push({name:"MATERIAL_METALLICROUGHNESS"}),this.hasBaseColorTexture()&&(e.push({name:"HAS_BASE_COLOR_MAP"}),void 0!==this.baseColorTextureTrans&&e.push({name:"HAS_BASECOLOR_UV_TRANSFORM"})),this.hasMetallicRoughnessTexture()&&(e.push({name:"HAS_METALLIC_ROUGHNESS_MAP"}),void 0!==this.metallicRoughnessTextureTrans&&e.push({name:"HAS_METALLICROUGHNESS_UV_TRANSFORM"})),this.useSpecularAA&&e.push({name:"USE_SPECULAR_AA"}),this.hasNormalTexture()&&(e.push({name:"HAS_NORMAL_MAP"}),void 0!==this.normalTextureTrans&&e.push({name:"HAS_NORMAL_UV_TRANSFORM"})),this.hasOcclusionTexture()&&(e.push({name:"HAS_OCCLUSION_MAP"}),void 0!==this.occlusionTextureTrans&&e.push({name:"HAS_OCCLUSION_UV_TRANSFORM"})),this.hasEmissiveTexture()?(e.push({name:"HAS_EMISSIVE_MAP"}),void 0!==this.emissiveTextureTrans&&e.push({name:"HAS_EMISSIVE_UV_TRANSFORM"})):this.hasEmissiveValue()&&e.push({name:"HAS_EMISSIVE"}),e},r.updateUniforms=function(e){t.prototype.updateUniforms.call(this,e),void 0!==this.baseColorTexture&&(e.setInt("_BaseColorUVSet",0),e.setMatrix3("_BaseColorUVTransform",this.baseColorTextureTrans)),void 0!==this.metallicRoughnessTexture&&(e.setInt("_MetallicRoughnessUVSet",0),e.setMatrix3("_MetallicRoughnessUVTransform",this.metallicRoughnessTextureTrans)),void 0!==this.normalTexture&&(e.setInt("_NormalUVSet",0),e.setMatrix3("_NormalUVTransform",this.normalTextureTrans)),void 0!==this.occlusionTexture&&(e.setInt("_OcclusionUVSet",0),e.setMatrix3("_OcclusionUVTransform",this.occlusionTextureTrans)),void 0!==this.emissiveTexture&&(e.setInt("_EmissiveUVSet",0),e.setMatrix3("_EmissiveUVTransform",this.emissiveTextureTrans)),e.setFloat("_Exposure",3)},r.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},r.setBaseColorTexture=function(e){this.baseColorTexture=e},r.getBaseColorFactor=function(){return this.baseColorFactor},r.setBaseColorFactor=function(e){l(e,O)?this.baseColorFactor.set(e.r,e.g,e.b,e.a):l(e,L)?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},r.hasMetallicRoughnessTexture=function(){return void 0!==this.metallicRoughnessTexture},r.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture},r.setMetallicRoughnessTexture=function(e){this.metallicRoughnessTexture=e},r.hasNormalTexture=function(){return void 0!==this.normalTexture},r.getNormalTexture=function(){return this.normalTexture},r.setNormalTexture=function(e){this.normalTexture=e},r.hasOcclusionTexture=function(){return void 0!==this.occlusionTexture},r.getOcclusionTexture=function(){return this.occlusionTexture},r.setOcclusionTexture=function(e){this.occlusionTexture=e},r.hasEmissiveTexture=function(){return void 0!==this.emissiveTexture},r.getEmissiveTexture=function(){return this.emissiveTexture},r.setEmissiveTexture=function(e){this.emissiveTexture=e},r.hasEmissiveValue=function(){return this.emissiveFactor.luminance()*this.emissiveIntensity>0},r.getEmissiveFactor=function(){return this.emissiveFactor},r.setEmissiveFactor=function(e){l(e,O)?this.emissiveFactor.set(e.r,e.g,e.b,e.a):l(e,N)?this.emissiveFactor.set(e.x,e.y,e.z,0):this.emissiveFactor.set(e[0],e[1],e[2],0)},r.getEmissiveIntensity=function(){return this.emissiveIntensity},r.setEmissiveIntensity=function(e){this.emissiveIntensity=e},n}(et);function rt(e){if(e.shader.getInstanceId()===W){var t=new nt;return t.create(e),t}var n=new tt;return n.create(e),n}var it,ot=function(e){function t(t,n,r){var i,o;(i=e.call(this)||this).renderable=!0,i.intensity=1,i.reflectionsIntensity=1,i.specularImageSize=0,i.specularMipCount=0,i.priority=0,i.isBuilt=!1,i.name=t,i.type=exports.PObjectType.skybox,i.visible=!1,i.owner=r;var a=n.irradianceCoeffs;if(i.renderable=n.renderable,i.intensity=n.intensity,i.reflectionsIntensity=n.reflectionsIntensity,a){i.irradianceCoeffs=[];for(var s=0;s<a.length;s+=3)i.irradianceCoeffs.push([a[s],a[s+1],a[s+2]])}else i.irradianceCoeffs=[];return i.diffuseImage=n.diffuseImage,i.specularImage=n.specularImage,i.specularImageSize=n.specularImageSize,i.specularMipCount=n.specularMipCount,i.priority=(null==r||null==(o=r.item)?void 0:o.renderOrder)||0,i}s(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 at,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,R.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,r=t.viewMatrix,i=n.getNewProjectionMatrix(n.fov).multiply(r).invert(),o=this.skyboxMesh.material;this.skyboxMaterial.updateUniforms(o),o.setMatrix("_InvViewProjectionMatrix",i)}},H(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}(Q),at=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).intensity=1,t.reflectionsIntensity=1,t.specularMipCount=0,t}s(t,e);var n=t.prototype;return n.create=function(e){this.type=exports.PObjectType.material,this.materialType=exports.PMaterialType.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 w(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,r){e.setVector3("_shCoefficients."+n,N.fromArray(t[r]))}))}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}(et);exports.PSkyboxType=void 0,(it=exports.PSkyboxType||(exports.PSkyboxType={}))[it.NFT=0]="NFT",it[it.FARM=1]="FARM";var st=function(){function t(){}return t.prototype.checkCubeMapImage=function(t){return o((function(){var n,r,i,o;return p(this,(function(a){switch(a.label){case 0:r=[],i=0,a.label=1;case 1:return i<t.length?[4,e.loadImage(t[i])]:[3,4];case 2:if(o=a.sent(),i>0)if(i%6==0){if(2*o.width!==n.width||2*o.height!==n.height)throw new Error("Invalid cube map list1: index "+i+", image0 "+n+", image1 "+o+".")}else if(o.width!==n.width||o.height!==n.height)throw new Error("Invalid cube map list2: index "+i+", image0 "+n+", image1 "+o+".");i%6==0&&r.push([]),r[r.length-1].push(o),n=o,a.label=3;case 3:return i++,[3,1];case 4:return[2]}}))}))()},t.getBrdfLutTextureOptions=function(){return o((function(){var t;return p(this,(function(n){switch(n.label){case 0:return"https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png",[4,e.loadImage("https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png")];case 1:return t=n.sent(),[2,{name:"brdfLut",wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR,anisotropic:1,sourceType:e.TextureSourceType.image,image:t,generateMipmap:!1,flipY:!1,premultiplyAlpha:!1}]}}))}))()},t.createBrdfLutTexture=function(t){var n=this;return o((function(){var r;return p(this,(function(i){switch(i.label){case 0:return[4,n.getBrdfLutTextureOptions()];case 1:return r=i.sent(),[2,e.Texture.create(t,r)]}}))}))()},t.createSkyboxOptions=function(e,t){var n=this;return o((function(){var r,i,o,a,s,l,c,u;return p(this,(function(h){switch(h.label){case 0:return[4,n.createSpecularCubeMap(e,t)];case 1:return r=h.sent(),[4,n.createDiffuseCubeMap(e,t)];case 2:return i=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:i,specularImage:r,specularImageSize:c,specularMipCount:u}]}}))}))()},t.createSkyboxComponentData=function(n){var r,i,o,a=t.getSpecularCubeMapData(n),s=t.getDiffuseCubeMapData(n),l=n.renderable,c=n.intensity,u=n.reflectionsIntensity,h=n.irradianceCoeffs,f=n.specularImageSize,d=n.specularMipCount,p=[],m=[];s&&((o=p).push.apply(o,[].concat(s.images)),m.push(s.textureOptions),i={id:s.textureOptions.id});(r=p).push.apply(r,[].concat(a.images)),m.push(a.textureOptions);var g={id:a.textureOptions.id};return{imageList:p,textureOptionsList:m,component:{id:e.generateGUID(),dataType:e.spec.DataType.SkyboxComponent,item:{id:e.generateGUID()},renderable:l,intensity:c,reflectionsIntensity:u,irradianceCoeffs:h,diffuseImage:i,specularImage:g,specularImageSize:f,specularMipCount:d}}},t.createSpecularCubeMap=function(e,t){return o((function(){return p(this,(function(n){return"url"===t.type?[2,Oe.createTextureCubeMipmapFromURL(e,t.specularImage)]:[2,Oe.createTextureCubeMipmapFromBuffer(e,t.specularImage,t.specularImageSize)]}))}))()},t.getSpecularCubeMapData=function(t){var n=[],r=[];t.specularImage.forEach((function(t){var i=[];t.forEach((function(t){var r=e.generateGUID();n.push({id:r,url:t}),i.push({id:r})})),r.push(i)}));var i=j({id:e.generateGUID(),dataType:e.spec.DataType.Texture,sourceType:e.TextureSourceType.mipmaps,target:e.glContext.TEXTURE_CUBE_MAP,mipmaps:r},Oe.cubemapMipTexConfig);return{images:n,textureOptions:i}},t.createDiffuseCubeMap=function(e,t){return o((function(){return p(this,(function(n){return void 0===t.diffuseImage?[2,null]:"url"===t.type?[2,Oe.createTextureCubeFromURL(e,t.diffuseImage)]:[2,Oe.createTextureCubeFromBuffer(e,t.diffuseImage)]}))}))()},t.getDiffuseCubeMapData=function(t){if(void 0!==t.diffuseImage){var n=[],r=[];t.diffuseImage.forEach((function(t){var i=e.generateGUID();n.push({id:i,url:t}),r.push({id:i})}));var i=j({id:e.generateGUID(),dataType:e.spec.DataType.Texture,sourceType:e.TextureSourceType.mipmaps,target:e.glContext.TEXTURE_CUBE_MAP,mipmaps:[r]},Oe.cubemapTexConfig);return{images:n,textureOptions:i}}},t.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}},t.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},t.getDiffuseImageList=function(e,t){if(0==e)return t[t.length-1]},t.getSpecularImageList=function(e){var t,n,r=[];1===e?(t=r).push.apply(t,[].concat(this.getSpecularImageListAntFarm())):(n=r).push.apply(n,[].concat(this.getSpecularImageListNFT()));var i=[];return r.forEach((function(e,t){t%6==0&&i.push([]),i[i.length-1].push(e)})),i},t.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"]},t.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"]},t}(),lt=function(){function t(e){this.engine=e,this.loadSkybox=!1,this.meshCache=new Map,this.textureCache=new Map,this.geometryCache=new Map,this.renderPassCache=new Map}var n=t.prototype;return n.setup=function(n){if(this.loadSkybox=n,void 0===this.brdfLutTexture||this.brdfLutTexture.isDestroyed){if(void 0===t.brdfLutTexOptions)throw new Error("Please load brdfLutTexOptions at first.");var r="brdfLutTexture";this.brdfLutTexture=e.Texture.create(this.engine,t.brdfLutTexOptions),this.deleteTexture(r),this.setTexture(r,this.brdfLutTexture)}},n.getTexture=function(e){return this.textureCache.get(e)},n.setTexture=function(e,t){this.textureCache.set(e,t)},n.getOrCreateTexture=function(t,n){var r=this.textureCache.get(t);if(void 0!==r)return r;var i=e.Texture.create(this.engine,n);return this.textureCache.set(t,i),i},n.deleteTexture=function(e){var t=this.textureCache.get(e);return void 0!==t&&t.dispose(),this.textureCache.delete(e)},n.getOrCreateGeometry=function(e,t,n){var r=this.geometryCache.get(e);if(void 0!==r)return r;var i=ke.createGeometry(this.engine,t,n);return this.geometryCache.set(e,i),i},n.getFilterMesh=function(e,t){var n=this.meshCache.get(e);if(void 0!==n)return n;var r=Be.createFilterMesh(this.engine,e,t);return this.meshCache.set(e,r),r},n.dispose=function(){this.engine=null,this.brdfLutTexture=void 0,this.meshCache.forEach((function(e){Oe.deleteMesh(e)})),this.meshCache.clear(),this.textureCache.forEach((function(e){Oe.deleteTexture(e)})),this.textureCache.clear(),this.geometryCache.forEach((function(e){Oe.deleteGeometry(e)})),this.geometryCache.clear(),this.renderPassCache.forEach((function(e){Oe.deleteRenderPass(e)})),this.renderPassCache.clear()},n.getRenderPasses=function(){var e=[];return this.renderPassCache.forEach((function(t){e.push(t)})),e},n.getBrdfLutTexture=function(){return this.brdfLutTexture},n.getSkyboxOptions=function(){return t.skyboxOptions},t.loadStaticResources=function(){var e=this;return o((function(){return p(this,(function(t){switch(t.label){case 0:return void 0!==e.brdfLutTexOptions?[2]:[4,st.getBrdfLutTextureOptions()];case 1:return e.brdfLutTexOptions=t.sent(),[2]}}))}))()},t.genSkyboxOptions=function(e,n){return o((function(){var r;return p(this,(function(i){switch(i.label){case 0:return void 0===(r=n)&&(r=st.getSkyboxParams()),[4,st.createSkyboxOptions(e,r)];case 1:return t.skyboxOptions=i.sent(),[2,t.skyboxOptions]}}))}))()},t}(),ct=Math.PI/180,ut=function(t){function n(n,r,i,o,a){var s,l,c,u,h,f;return(s=t.call(this)||this).width=512,s.height=512,s.nearPlane=.001,s.farPlane=1e3,s.fov=45,s.viewportMatrix=R.fromIdentity(),s.aspect=1,s.clipMode=e.spec.CameraClipMode.landscape,s.projectionMatrix=new R,s.viewMatrix=new R,s.type=exports.PObjectType.camera,s.visible=!1,s.owner=a,s.name=n,s.width=r,s.height=i,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:e.spec.CameraClipMode.landscape,s.update(),s}s(n,t);var r=n.prototype;return r.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform);var t=this.clipMode===e.spec.CameraClipMode.portrait;this.projectionMatrix.perspective(this.fov*ct,this.aspect,this.nearPlane,this.farPlane,t),this.projectionMatrix.premultiply(this.viewportMatrix),this.viewMatrix=this.matrix.invert()},r.getNewProjectionMatrix=function(t){var n=this.clipMode===e.spec.CameraClipMode.portrait;return(new R).perspective(Math.min(1.25*t,140)*ct,this.aspect,this.nearPlane,this.farPlane,n).premultiply(this.viewportMatrix)},r.computeViewAABB=function(e){var t=Math.tan(this.fov*ct*.5),n=this.aspect,r=0,i=0,o=0,a=0;this.isReversed()?(r=(o=this.farPlane*t)/n,i=(a=this.nearPlane*t)/n):(o=n*(r=this.farPlane*t),a=n*(i=this.nearPlane*t)),e.makeEmpty();var s=this.matrix;return e.expandByPoint(s.transformPoint(new N(o,r,-this.farPlane))),e.expandByPoint(s.transformPoint(new N(o,-r,-this.farPlane))),e.expandByPoint(s.transformPoint(new N(-o,r,-this.farPlane))),e.expandByPoint(s.transformPoint(new N(-o,-r,-this.farPlane))),e.expandByPoint(s.transformPoint(new N(a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new N(a,-i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new N(-a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new N(-a,-i,-this.nearPlane))),e},r.getSize=function(){return new w(this.width,this.height)},r.isReversed=function(){return this.clipMode===e.spec.CameraClipMode.portrait},r.getEye=function(){return this.translation},r.setEye=function(e){this.translation=e},n}(Q),ht=function(){function t(){this.winWidth=512,this.winHeight=512,this.cameraList=[],this.defaultCamera=new ut("camera",512,512,{id:"0",dataType:"camera",fov:60,far:1e3,near:.001,clipMode:e.spec.CameraClipMode.portrait,item:{id:"0"}})}var n=t.prototype;return n.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()},n.insert=function(e,t,n){var r=new ut(e,this.winWidth,this.winHeight,t,n);return this.cameraList.push(r),r},n.insertCamera=function(e){this.cameraList.push(e)},n.remove=function(e){if(l(e,ut)){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)},n.dispose=function(){this.cameraList=[]},n.updateDefaultCamera=function(e,t,n,r,i,o,a,s){this.defaultCamera.fov=e,this.defaultCamera.viewportMatrix=t.clone(),this.defaultCamera.aspect=n,this.defaultCamera.nearPlane=r,this.defaultCamera.farPlane=i,this.defaultCamera.position=o,this.defaultCamera.rotation=a,this.defaultCamera.aspect=n,this.defaultCamera.clipMode=s,this.defaultCamera.update()},n.getCameraList=function(){return this.cameraList},n.getDefaultCamera=function(){return this.defaultCamera},n.getCameraCount=function(){return this.cameraList.length},n.getActiveCamera=function(){return this.defaultCamera},n.getAspect=function(){return this.winWidth/this.winHeight},t}(),ft=function(t){function n(n,r,i){var o;(o=t.call(this)||this).direction=new N(0,0,1),o.range=0,o.color=new N(1,1,1),o.intensity=0,o.outerConeAngle=0,o.innerConeAngle=0,o.lightType=exports.PLightType.ambient,o.padding=new w(0,0),o.followCamera=!1,o.name=n,o.type=exports.PObjectType.light,o.visible=!1,o.owner=i,o.direction=new N(0,0,-1),o.range=0,o.outerConeAngle=0,o.innerConeAngle=0;var a,s,l=r.color;if(o.color=new N(l.r,l.g,l.b),o.intensity=r.intensity,o.followCamera=null!=(a=r.followCamera)&&a,r.lightType===e.spec.LightType.point)o.lightType=exports.PLightType.point,o.range=null!=(s=r.range)?s:-1;else if(r.lightType===e.spec.LightType.spot){var c,u,h;o.lightType=exports.PLightType.spot,o.range=null!=(c=r.range)?c:-1,o.outerConeAngle=null!=(u=r.outerConeAngle)?u:Math.PI,o.innerConeAngle=null!=(h=r.innerConeAngle)?h:0}else r.lightType===e.spec.LightType.directional?o.lightType=exports.PLightType.directional:o.lightType=exports.PLightType.ambient;return o.update(),o}s(n,t);var r=n.prototype;return r.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform)},r.isDirectional=function(){return this.lightType===exports.PLightType.directional},r.isPoint=function(){return this.lightType===exports.PLightType.point},r.isSpot=function(){return this.lightType===exports.PLightType.spot},r.isAmbient=function(){return this.lightType===exports.PLightType.ambient},r.getWorldPosition=function(){return this.translation},r.getWorldDirection=function(){return this.matrix.transformNormal(this.direction,new N)},H(n,[{key:"position",get:function(){return this.translation}}]),n}(Q),dt=function(){function e(){this.lightList=[]}var t=e.prototype;return t.insertItem=function(e,t,n){var r=new ft(e,t,n);return this.lightList.push(r),r},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=[]},H(e,[{key:"lightCount",get:function(){return this.lightList.length}}]),e}();var pt,mt=function(t){function n(e,n,r,i,o,a){var s,l;(s=t.call(this)||this).engine=e,s.parentIndex=-1,s.subMeshes=[],s.hide=!0,s.priority=0,s.boundingBox=new B,s.visBoundingBox=!1,s.isBuilt=!1,s.isDisposed=!1;var c=new yt(r,i,a);s.name=n,s.type=exports.PObjectType.mesh,s.visible=!1,s.owner=i,s.parentIndex=c.getParentIndex(),s.parentItem=c.parentItem,s.parentItemId=o,s.rootBoneItem=r.rootBone,s.skin=c.getSkinObj(e),s.morph=c.getMorphObj(),s.hide=c.isHide(),s.priority=(null==i||null==(l=i.item)?void 0:l.renderOrder)||0,s.subMeshes=[];var u,h=c.getGeometry();return(null!=(u=null==i?void 0:i.materials)?u:[]).forEach((function(e){var t=new gt(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(r.interaction),s}s(n,t);var r=n.prototype;return r.build=function(e){this.isBuilt||(this.isBuilt=!0,this.subMeshes.forEach((function(t){t.build(e.maxLightCount,e.skybox)})),Y.getInstance().visBoundingBox&&(this.boundingBoxMesh=new le(this.engine,this.priority)))},r.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))},r.lateUpdate=function(){var e;null==(e=this.skin)||e.updateSkinMatrices()},r.render=function(e,t){var n=this;if(this.updateMaterial(e),this.subMeshes.forEach((function(e,r){t.drawGeometry(e.getEffectsGeometry(),n.matrix,e.getEffectsMaterial(),r)})),this.visBoundingBox&&void 0!==this.boundingBoxMesh){var r=this.boundingBoxMesh.mesh;t.drawGeometry(r.geometry,R.IDENTITY,r.material)}},r.dispose=function(){var e,n,r;this.isDisposed||(t.prototype.dispose.call(this),this.owner=void 0,this.isDisposed=!0,this.engine=null,this.parentItem=void 0,null==(e=this.skin)||e.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==(r=this.boundingBoxMesh)||r.dispose(),this.boundingBoxMesh=void 0)},r.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]}}},r.updateParentInfo=function(e,t){this.parentItemId=e,this.parentItem=t,void 0!==this.skin&&this.skin.updateParentItem(t)},r.updateMaterial=function(e){var t=this.matrix,n=t.clone().invert().transpose(),r=e.sceneStates;if(this.subMeshes.forEach((function(e){e.updateMaterial(t,n,r)})),void 0!==this.boundingBoxMesh){this.computeBoundingBox(t);var i=new N(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,r.viewProjectionMatrix,s,i)}},r.hitTesting=function(e,t){var n,r=this.matrix,i=r.clone().invert(),o=i.transformPoint(e,new N),a=i.transformNormal(t,new N),s=this.boundingBox,l=Ee(o,a,s.min,s.max);return void 0===l?[]:(Y.getInstance().isEditorEnv?this.subMeshes.forEach((function(e){var t=e.hitTesting(o,a,r,i);void 0!==t&&(void 0===n||n>t)&&(n=t)})):n=l,void 0===n?[]:(a.multiply(n),o.add(a),r.transformPoint(o),[o]))},r.computeBoundingBox=function(e){var t=this.boundingBox.makeEmpty(),n=e.clone().invert();return this.subMeshes.forEach((function(e){var r=e.computeBoundingBox(n);t.union(r)})),t},r.getItemBoundingBox=function(t){if(void 0===t)return new B;if(t.type===e.spec.ModelBoundingType.box){var n,r,i=null!=(n=t.center)?n:[0,0,0],o=null!=(r=t.size)?r:[0,0,0],a=N.fromArray(i),s=N.fromArray(o).multiply(.5),l=a.clone().subtract(s),c=a.clone().add(s);return new B(l,c)}var u,h,f=null!=(u=t.center)?u:[0,0,0],d=.5*(null!=(h=t.radius)?h:0),p=N.fromArray(f),m=p.clone().subtract(d),g=p.clone().add(d);return new B(m,g)},r.getParentId=function(){return this.parentItemId},H(n,[{key:"hasSkin",get:function(){return void 0!==this.skin}}]),n}(Q),gt=function(){function t(e){this.engine=e,this.name="",this.effectsPriority=0,this.boundingBox=new B,this.isCompressed=!1}var n=t.prototype;return n.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 r=this.skin.maxJointCount;if(this.jointMatrixList=new Float32Array(16*r),this.jointNormalMatList=new Float32Array(16*r),this.skin.isTextureDataMode()){var i=this.skin.textureDataMode===exports.TextureDataMode.half_float;this.jointMatrixTexture=new Qe(this.engine),this.jointNormalMatTexture=new Qe(this.engine),this.jointMatrixTexture.create(r,i,"jointMatrixTexture"),this.jointNormalMatTexture.create(r,i,"jointNormalMatTexture")}}else(this.geometry.hasWeights()||this.geometry.hasJoints())&&console.warn("Geometry has weight and/or joint array, but the skin is missing.");this.isCompressed=this.geometry.isCompressed()},n.build=function(t,n){var r,i=Y.getInstance(),o=this.getMacroList(t,!0,n),a=this.material.getMacroList(o),s=Y.getInstance().isWebGL2;this.material.effectMaterial?(r=this.material.effectMaterial,a.forEach((function(e){var t=e.name,n=e.value;r.enableMacro(t,n)})),this.material.setMaterialStates(r)):(r=e.Material.create(this.engine,{shader:{vertex:this.material.vertexShaderCode,fragment:this.material.fragmentShaderCode,shared:i.shaderShared,glslVersion:s?e.GLSLVersion.GLSL3:e.GLSLVersion.GLSL1}}),this.material.setMaterialStates(r))},n.getFeatureList=function(e,t,n){var r=[];if(this.geometry.hasNormals()&&r.push("HAS_NORMALS 1"),this.geometry.hasTangents()&&r.push("HAS_TANGENTS 1"),this.geometry.hasUVCoords(1)&&r.push("HAS_UV_SET1 1"),this.geometry.hasUVCoords(2)&&r.push("HAS_UV_SET2 1"),void 0!==this.morph&&this.morph.hasMorph()){r.push("USE_MORPHING"),r.push("WEIGHT_COUNT "+this.morph.morphWeightsLength);for(var i=0;i<this.morph.morphWeightsLength;i++)this.morph.hasPositionMorph&&r.push("HAS_TARGET_POSITION"+i),this.morph.hasNormalMorph&&r.push("HAS_TARGET_NORMAL"+i),this.morph.hasTangentMorph&&r.push("HAS_TARGET_TANGENT"+i)}void 0!==this.skin&&(r.push("USE_SKINNING 1"),r.push("JOINT_COUNT "+this.skin.getJointCount()),r.push("HAS_JOINT_SET1 1"),r.push("HAS_WEIGHT_SET1 1"),this.skin.textureDataMode&&r.push("USE_SKINNING_TEXTURE 1")),this.material.materialType!==exports.PMaterialType.unlit&&(e>0&&this.geometry.hasNormals()&&(r.push("USE_PUNCTUAL 1"),r.push("LIGHT_COUNT "+e)),void 0!==n&&n.available&&(r.push("USE_IBL 1"),r.push("USE_TEX_LOD 1"),n.hasDiffuseImage||r.push("IRRADIANCE_COEFFICIENTS 1")));var o=Y.getInstance().renderMode3D,a=this.getRenderMode3DDefine(o);return void 0!==a&&(r.push("DEBUG_OUTPUT 1"),r.push(a+" 1")),r},n.getMacroList=function(e,t,n){var r=[];if(this.geometry.hasNormals()&&r.push({name:"HAS_NORMALS"}),this.geometry.hasTangents()&&r.push({name:"HAS_TANGENTS"}),this.geometry.hasUVCoords(1)&&r.push({name:"HAS_UV_SET1"}),this.geometry.hasUVCoords(2)&&r.push({name:"HAS_UV_SET2"}),void 0!==this.morph&&this.morph.hasMorph()){r.push({name:"USE_MORPHING"}),r.push({name:"WEIGHT_COUNT",value:this.morph.morphWeightsLength});for(var i=0;i<this.morph.morphWeightsLength;i++)this.morph.hasPositionMorph&&r.push({name:"HAS_TARGET_POSITION"+i}),this.morph.hasNormalMorph&&r.push({name:"HAS_TARGET_NORMAL"+i}),this.morph.hasTangentMorph&&r.push({name:"HAS_TARGET_TANGENT"+i})}void 0!==this.skin&&(r.push({name:"USE_SKINNING"}),r.push({name:"JOINT_COUNT",value:this.skin.maxJointCount}),r.push({name:"HAS_JOINT_SET1"}),r.push({name:"HAS_WEIGHT_SET1"}),this.skin.textureDataMode&&r.push({name:"USE_SKINNING_TEXTURE"})),this.material.materialType!==exports.PMaterialType.unlit&&(e>0&&this.geometry.hasNormals()&&(r.push({name:"USE_PUNCTUAL"}),r.push({name:"LIGHT_COUNT",value:e})),void 0!==n&&n.available&&(r.push({name:"USE_IBL"}),r.push({name:"USE_TEX_LOD"}),n.hasDiffuseImage||r.push({name:"IRRADIANCE_COEFFICIENTS"})));var o=Y.getInstance().renderMode3D,a=this.getRenderMode3DDefine(o);return void 0!==a&&(r.push({name:"DEBUG_OUTPUT"}),r.push({name:a})),r},n.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},n.updateMaterial=function(e,t,n){this.updateUniformsByAnimation(e,t),this.updateUniformsByScene(n),this.material.updateUniforms(this.getEffectsMaterial())},n.hitTesting=function(e,t,n,r){var i=this.boundingBox,o=Ee(e,t,i.min,i.max),a=[];if(void 0!==o){if(void 0!==this.skin)this.skin.animationMatrices.forEach((function(e){a.push((new R).multiplyMatrices(r,e))}));var s=new je,l=this.material.isBothSide();return s.create(this.geometry.geometry,l,a),s.getHitPoint(e,t)}},n.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 R).multiplyMatrices(e,n))}));var n=new He;return n.create(this.geometry.geometry,t),n.getBoundingBox(this.boundingBox)},n.getRenderMode3DDefine=function(t){switch(t){case e.spec.RenderMode3D.uv:return"DEBUG_UV";case e.spec.RenderMode3D.normal:return"DEBUG_NORMAL";case e.spec.RenderMode3D.basecolor:return"DEBUG_BASECOLOR";case e.spec.RenderMode3D.alpha:return"DEBUG_ALPHA";case e.spec.RenderMode3D.metallic:return"DEBUG_METALLIC";case e.spec.RenderMode3D.roughness:return"DEBUG_ROUGHNESS";case e.spec.RenderMode3D.ao:return"DEBUG_OCCLUSION";case e.spec.RenderMode3D.emissive:return"DEBUG_EMISSIVE";case e.spec.RenderMode3D.diffuse:return"DEBUG_DIFFUSE"}},n.updateUniformsByAnimation=function(e,t){var n=this.getEffectsMaterial();n.setMatrix("_NormalMatrix",t);var r=this.skin;if(void 0!==r){var i=this.jointMatrixList,o=this.jointNormalMatList;if(r.computeMeshAnimMatrices(e,i,o),r.textureDataMode){var a=this.jointMatrixTexture,s=this.jointNormalMatTexture;a.update(i),s.update(o),n.setTexture("_jointMatrixSampler",a.getTexture()),n.setTexture("_jointNormalMatrixSampler",s.getTexture())}else{var l=[],c=[];i.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)}},n.updateUniformsByScene=function(e){var t=this.getEffectsMaterial();if(t.setVector3("_Camera",e.cameraPosition),!this.isUnlitMaterial()){for(var n=e.maxLightCount,r=e.lightList,i=e.inverseViewMatrix,o=0;o<n;o++)if(o<r.length){var a=r[o],s=a.visible?a.intensity:0;if(a.followCamera){var l=i.transformNormal(a.getWorldDirection(),new N),c=i.transformPoint(a.getWorldPosition(),new N);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",N.ZERO),t.setFloat("_Lights["+o+"].range",0),t.setVector3("_Lights["+o+"].color",N.ZERO),t.setFloat("_Lights["+o+"].intensity",0),t.setVector3("_Lights["+o+"].position",N.ZERO),t.setFloat("_Lights["+o+"].innerConeCos",0),t.setFloat("_Lights["+o+"].outerConeCos",0),t.setInt("_Lights["+o+"].type",99999),t.setVector2("_Lights["+o+"].padding",w.ZERO);var u=e.skybox;if(void 0!==u&&u.available){if(t.setVector2("_IblIntensity",new w(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,N.fromArray(h[n]))}))}t.setInt("_MipCount",u.specularMipCount-1),t.setTexture("_SpecularEnvSampler",u.specularImage)}}},n.hasSkin=function(){return void 0!==this.skin},n.getEffectsGeometry=function(){return this.geometry.geometry},n.setGeometry=function(e){l(e,vt)?this.geometry=e:this.geometry=new vt(e)},n.setMaterial=function(e){l(e,tt)||l(e,nt)?this.material=e:this.material=rt(e)},n.getEffectsMaterial=function(){return this.material.effectMaterial},n.isUnlitMaterial=function(){return this.material.materialType===exports.PMaterialType.unlit},n.hasMorph=function(){return void 0!==this.morph&&this.morph.hasMorph()},n.getWorldBoundingBox=function(){if(void 0===this.parent)return this.boundingBox.isEmpty()&&this.computeBoundingBox(R.fromIdentity()),this.boundingBox;var e=this.parent.matrix;return this.boundingBox.isEmpty()&&this.computeBoundingBox(e.clone().invert()),this.boundingBox.clone().applyMatrix4(e)},t}(),vt=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}(),yt=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 r=new Ke;if(r.create(this.geometry)){var i,o;if(null==(i=e.morph)?void 0:i.weights)r.initWeights(null==(o=e.morph)?void 0:o.weights);this.morphObj=r}}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,r,i=new Ze,o=null!=(r=null==(n=this.parentComponent.sceneManager)?void 0:n.maxJointCount)?r:0;return i.create(t,e,this.rootBoneItem,o),i}},e}(),Tt=function(){function t(e){this.maxLightCount=16,this.maxJointCount=0,this.renderSkybox=!1,this.compName="SceneManger",this.itemList=[],this.meshList=[],this.engine=e,this.lightManager=new dt,this.cameraManager=new ht,this.parentId2Mesh=new Map,this.enableDynamicSort=!1,this.tickCount=0,this.lastTickSecond=-1,this.sceneAABBCache=new B,this.renderedMeshSet=new Se}var n=t.prototype;return n.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).")},n.initGlobalState=function(t){var n,r,i,o,a,s=this.engine.gpuCapability,l=Y.getInstance();l.reset(),l.isWebGL2=2===s.level,l.runtimeEnv=null!=(n=t.runtimeEnv)?n:e.PLAYER_OPTIONS_ENV_EDITOR,l.compatibleMode=null!=(r=t.compatibleMode)?r:"gltf",l.visBoundingBox=null!=(i=t.visBoundingBox)&&i,l.renderMode3D=null!=(o=t.renderMode3D)?o:e.spec.RenderMode3D.none,l.renderMode3DUVGridSize=null!=(a=t.renderMode3DUVGridSize)?a:1/16},n.clean=function(){this.dispose(),this.compName="",this.renderer=void 0,this.sceneCache=void 0,this.itemList=[],this.meshList=[],this.lightManager=new dt,this.cameraManager=new ht,this.parentId2Mesh=new Map,this.brdfLUT=void 0,this.skybox=void 0,this.lastTickSecond=-1,this.tickCount=0,this.renderedMeshSet=new Se},n.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()},n.addItem=function(t){if(l(t,mt)){var n=t;void 0!==n.parentItemId&&this.parentId2Mesh.set(n.parentItemId,n),e.addItem(this.meshList,n)}else if(l(t,ot)){var r=t;r.setup(this.brdfLUT),this.renderSkybox||(r.renderable=!1),this.skybox=r}else l(t,ft)?this.lightManager.insertLight(t):this.cameraManager.insertCamera(t);e.addItem(this.itemList,t)},n.removeItem=function(t){if(l(t,mt)){var n=t;void 0!==n.parentItemId&&this.parentId2Mesh.delete(n.parentItemId),e.removeItem(this.meshList,n)}else l(t,ot)?this.skybox=void 0:l(t,ft)?this.lightManager.remove(t):this.cameraManager.remove(t);e.removeItem(this.itemList,t)},n.updateDefaultCamera=function(t,n){var r=new e.Transform(j({},t,{valid:!0})),i=(new X).fromEffectsTransform(r);this.cameraManager.updateDefaultCamera(t.fov,n,t.aspect,t.near,t.far,i.getPosition(),i.getRotation(),t.clipMode)},n.tick=function(e){var t=e,n=this.activeCamera,r=n.viewMatrix,i=n.projectionMatrix,o=i.clone().multiply(r);this.sceneStates={deltaSeconds:t,camera:n,cameraPosition:n.getEye(),viewMatrix:r,inverseViewMatrix:r.clone().invert(),projectionMatrix:i,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},n.dynamicSortMeshes=function(e){var t=[],n=[];this.meshList.forEach((function(e){if(e.owner&&e.owner.enabled){var r=e.owner;t.push(r),n.push(r.priority)}})),n.sort((function(e,t){return e-t}));var r=e.viewMatrix;t.sort((function(e,t){var n=Oe.isTransparentMesh(e),i=Oe.isTransparentMesh(t);if(n&&i){var o=e.transform.getWorldPosition(),a=t.transform.getWorldPosition(),s=r.transformPoint(o),l=r.transformPoint(a);return s.z===l.z?e.priority-t.priority:s.z-l.z}return n?1:i?-1:e.priority-t.priority}));for(var i=-99999,o=0;o<t.length;o++){var a=t[o],s=n[o];i<s?(i=s,a.priority=s):(i+=.1,a.priority=i)}},n.queryMesh=function(e){var t=this.parentId2Mesh.get(e);if(void 0!==t&&t.visible)return t},n.getSceneAABB=function(e){var t=null!=e?e:new B;return this.itemList.forEach((function(e){if(e.type===exports.PObjectType.mesh){var n=e;if(n.owner){var r=n.owner.item.getWorldTransform().getWorldMatrix(),i=n.computeBoundingBox(r);i.applyMatrix4(r),t.union(i)}else t.union(n.computeBoundingBox(R.fromIdentity()))}})),t},n.printDebugInfo=function(){console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),this.meshList.forEach((function(e,t){console.info("Mesh: ",t,e)})),this.cameraManager.getCameraList().forEach((function(e,t){console.info("Camera: ",t,e)})),console.info("Default Camera: ",this.cameraManager.getDefaultCamera()),this.lightManager.lightList.forEach((function(e,t){console.info("Light: ",t,e)})),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")},n.getRenderer=function(){return this.renderer},n.getSceneCache=function(){return this.sceneCache},H(t,[{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)}}]),t}(),xt=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).name="model",e}s(n,t);var r=n.prototype;return r.onAssetsLoadStart=function(e,t){return o((function(){return p(this,(function(e){switch(e.label){case 0:return[4,lt.loadStaticResources()];case 1:return e.sent(),[2]}}))}))()},r.onAssetsLoadFinish=function(t,n,r){var i,o;if(void 0!==n.pluginData){var a=n.pluginData;["compatibleMode","renderSkybox","visBoundingBox","autoAdjustScene","enableDynamicSort","renderMode3D","renderMode3DUVGridSize"].forEach((function(e){return t.storage[e]=a[e]}))}var s,l=null!=(o=n.env)?o:"";t.storage.runtimeEnv=l;var c=null!=(s=null==(i=n.pluginData)?void 0:i.compatibleMode)?s:"gltf";ke.preprocessScene(t,l,c);var u=2===r.gpuCapability.level,h=me(),f=ge(),d={id:W,name:"PBR Shader",dataType:e.spec.DataType.Shader,fragment:h.fragmentShaderCode,vertex:h.vertexShaderCode,glslVersion:u?e.GLSLVersion.GLSL3:e.GLSLVersion.GLSL1},p={id:J,name:"Unlit Shader",dataType:e.spec.DataType.Shader,fragment:f.fragmentShaderCode,vertex:f.vertexShaderCode,glslVersion:u?e.GLSLVersion.GLSL3:e.GLSLVersion.GLSL1};r.addEffectsObjectData(d),r.addEffectsObjectData(p)},r.onCompositionCreated=function(t,n){var r={id:"ModelPluginItem",name:"ModelPluginItem",duration:9999999,endBehavior:e.spec.END_BEHAVIOR_FORWARD},i=new e.VFXItem(t.getEngine(),r);t.addItem(i),i.addComponent(exports.ModelPluginComponent).sceneParams=n.storage},n}(f(e.Plugin));function bt(e){var t,n=null==e||null==(t=e.item)?void 0:t.composition,r=null==n?void 0:n.getItemByName("ModelPluginItem"),i=null==r?void 0:r.getComponent(exports.ModelPluginComponent);return null==i?void 0:i.scene}exports.ModelPluginComponent=function(t){function n(n){var r;return(r=t.call(this,n)||this).runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,r.compatibleMode="gltf",r.renderSkybox=!0,r.visBoundingBox=!1,r.autoAdjustScene=!1,r.enableDynamicSort=!1,r.renderMode3D=e.spec.RenderMode3D.none,r.renderMode3DUVGridSize=1/16,r}s(n,t);var i=n.prototype;return i.onAwake=function(){this.cache=new lt(this.engine),this.cache.setup(!1),this.scene=new Tt(this.engine),this.initial(this.sceneParams)},i.onLateUpdate=function(e){var t=this.item.composition;if(this.autoAdjustScene&&1==this.scene.tickCount){var n,i,o,a=t.camera,s=(new X).fromMatrix4(a.getViewMatrix()),l=(new q).fromPTransform(s).zAxis.clone(),c=null!=(i=a.fov)?i:45,u=null!=(o=a.aspect)?o:1,h=this.scene.getSceneAABB(),f=h.clone().applyMatrix4(s.getMatrix()).getSize(new N).multiply(.5),d=f.x,p=f.y,m=p*Math.max(d/p/u,1),g=h.getCenter(new N),v=m/Math.tan(.5*c*G),y=g.clone().add(l.clone().multiply(v+f.z));t.camera.position=y,null==(n=t.items)||n.forEach((function(e){if(e.type===r){var t=e.getComponent(exports.ModelCameraComponent);if(null==t?void 0:t.content){var n,i=((null==(n=e.transform.parentTransform)?void 0:n.getWorldMatrix())||R.IDENTITY.clone()).invert().transformPoint(y);t.setTransform(i),console.info("Scene AABB ["+h.min.toArray()+"], ["+h.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.dispose(),this.cache=null},i.initial=function(e){var t,n,r,i,o,a,s,l,c;this.runtimeEnv=null!=(n=e.runtimeEnv)?n:this.runtimeEnv,this.compatibleMode=null!=(r=e.compatibleMode)?r:this.compatibleMode,this.renderSkybox=null!=(i=e.renderSkybox)?i: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(exports.ModelLightComponent)&&n++})),n},i.getMaxJointCount=function(t){var n=this,r=0;return t.forEach((function(t){var i=t.getComponent(exports.ModelMeshComponent);if(i&&i.data){var o=i.data.geometry;if(l(o,e.Geometry)){var a=o.getSkinProps();a.boneNames&&(r=Math.max(a.boneNames.length,r))}}0!==t.children.length&&(r=Math.max(n.getMaxJointCount(t.children),r))})),r},n}(e.Behaviour),exports.ModelPluginComponent=d([e.effectsClass(e.spec.DataType.ModelPluginComponent)],exports.ModelPluginComponent),exports.ModelTreeComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}return s(t,e),t.prototype.fromData=function(t){e.prototype.fromData.call(this,t),this.options=t},t}(e.Behaviour),exports.ModelTreeComponent=d([e.effectsClass(e.spec.DataType.TreeComponent)],exports.ModelTreeComponent),exports.CameraGestureType=void 0,(pt=exports.CameraGestureType||(exports.CameraGestureType={}))[pt.none=0]="none",pt[pt.translate=1]="translate",pt[pt.rotate_focus=2]="rotate_focus",pt[pt.rotate_self=3]="rotate_self",pt[pt.scale=4]="scale";var _t=function(){function t(e){this.composition=e,this.cameraTransform=new X,this.cameraCoordiante=new q,this.startParams={type:exports.CameraGestureType.none,mouseEvent:!1,clientX:0,clientY:0,clientWidth:512,clientHeight:512,target:""}}var n=t.prototype;return n.updateComposition=function(e){this.composition=e},n.getItem=function(){var e,t=this;return null==(e=this.composition.items)?void 0:e.find((function(e){return e.name===t.getCurrentTarget()}))},n.getCurrentTarget=function(){return this.startParams.target},n.getCurrentType=function(){return this.startParams.type},n.onKeyEvent=function(t){this.startParams.target!==t.cameraID&&(this.startParams.target=t.cameraID,this.startParams.type=exports.CameraGestureType.translate);var n=this.getItem();if(void 0===n)return console.warn("[CameraGestureHandlerImp] Unable to locate camera item with ID: "+this.startParams.target+"."),this.composition.camera.getOptions();var r,i,o,a,s=this.composition.camera,l=new e.Transform(j({},s.getOptions(),{valid:!0})),c=(new X).fromEffectsTransform(l),u=(new q).fromPTransform(c),h=null!=(r=t.xAxis)?r:0,f=null!=(i=t.yAxis)?i:0,d=null!=(o=t.zAxis)?o:0,p=u.xAxis.clone().multiply(h);if(p.add(u.yAxis.clone().multiply(f)),p.add(u.zAxis.clone().multiply(d)),p.lengthSquared()<1e-5)return s.getOptions();p.normalize();var m=null!=(a=t.speed)?a:.1,g=c.getPosition();return g.add(p.clone().multiply(m)),this.setTransform(n,g),this.startParams.type===exports.CameraGestureType.rotate_self&&(this.cameraTransform.setPosition(g),this.cameraCoordiante.origin=g),s.getOptions()},n.onXYMoveBegin=function(e,t,n,r,i){var o={type:exports.CameraGestureType.translate,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:r,target:i};return this.startGesture(o)},n.onXYMoving=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,i={type:exports.CameraGestureType.translate,mouseEvent:!0,clientX:e,clientY:t,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:null!=n?n:.015};return this.moveGesture(i)},n.onXYMoveEnd=function(){this.endGesture()},n.onZMoveBegin=function(e,t,n,r,i){var o={type:exports.CameraGestureType.scale,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:r,target:i};return this.startGesture(o)},n.onZMoving=function(e,t,n){if(void 0===n&&(n=.015),!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,i={type:exports.CameraGestureType.scale,mouseEvent:!0,clientX:e,clientY:t,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:n};return this.moveGesture(i)},n.onZMoveEnd=function(){this.endGesture()},n.onRotateBegin=function(e,t,n,r,i){var o={type:exports.CameraGestureType.rotate_self,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:r,target:i};return this.startGesture(o)},n.onRotating=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,i={type:exports.CameraGestureType.rotate_self,mouseEvent:!0,clientX:e,clientY:t,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:null!=n?n:1.5};return this.moveGesture(i)},n.onRotateEnd=function(){this.endGesture()},n.onRotatePointBegin=function(e,t,n,r,i,o){var a={type:exports.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:r,focusPoint:i,target:o};return this.startGesture(a)},n.onRotatingPoint=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,i={type:exports.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:e,clientY:t,clientWidth:r.clientWidth,clientHeight:r.clientHeight,focusPoint:r.focusPoint,target:r.target,speed:null!=n?n:8};return this.moveGesture(i)},n.onRotatePointEnd=function(){this.endGesture()},n.moveTo=function(e,t){this.startParams.target=e,this.startParams.type=exports.CameraGestureType.none;var n=this.getItem();void 0!==n?this.setPosition(n,t):console.warn("[CameraGestureHandlerImp] Can't find camera item.")},n.rotateTo=function(e,t){this.startParams.target=e,this.startParams.type=exports.CameraGestureType.none;var n=this.getItem();void 0!==n?this.setQuaternion(n,t):console.warn("[CameraGestureHandlerImp] Can't find camera item.")},n.onFocusPoint=function(e,t,n){this.startParams.target=e,this.startParams.type=exports.CameraGestureType.none;var r=this.getItem();if(void 0!==r){var i=null!=n?n:5,o=N.fromArray(t),a=(new X).fromEffectsTransform(r.transform),s=(new q).fromPTransform(a),l=N.fromArray(s.zAxis.toArray()).multiply(1).clone().multiply(i),c=o.clone().add(l);this.setTransform(r,c),this.startParams.target=""}else console.warn("[CameraGestureHandlerImp] Can't find camera item.")},n.getCameraTransform=function(){var t=this.composition.camera,n=new e.Transform(t.getOptions());return n.setValid(!0),n},n.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()},n.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 r=null!=(t=e.speed)?t:1.015,i=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===exports.CameraGestureType.translate){var c=this.cameraTransform.getPosition().clone();c.add(i.clone().multiply(-s*r)),c.add(o.clone().multiply(l*r)),n.transform.setPosition(c.x,c.y,c.z),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===exports.CameraGestureType.scale){var u=this.cameraTransform.getPosition().clone();u.add(a.clone().multiply(l*r)),n.transform.setPosition(u.x,u.y,u.z),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===exports.CameraGestureType.rotate_self){var h=s/e.clientWidth,f=l/e.clientHeight,d=h*Math.PI*r*.5,p=f*Math.PI*r*.5,m=U.fromAxisAngle(N.Y,-d),g=U.fromAxisAngle(i,-p);m.multiply(g),m.multiply(this.cameraTransform.getRotation()),n.transform.setQuaternion(m.x,m.y,m.z,m.w),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===exports.CameraGestureType.rotate_focus){var v=s/e.clientWidth,y=l/e.clientHeight,T=v*Math.PI*r,x=y*Math.PI*r,b=U.fromAxisAngle(N.Y,-T),_=U.fromAxisAngle(i,-x);b.multiply(_);var C=b.toMatrix4(new R),S=N.fromArray(e.focusPoint),M=this.cameraCoordiante.origin.clone().subtract(S);C.transformPoint(M);var A=M.add(S);b.multiply(this.cameraTransform.getRotation()),n.transform.setPosition(A.x,A.y,A.z),n.transform.setQuaternion(b.x,b.y,b.z,b.w),this.setTransform(n,A,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()},n.setTransform=function(e,t,n){var r=e.getComponent(exports.ModelCameraComponent);void 0!==r&&r.setTransform(t,n)},n.setPosition=function(e,t){var n;(n=e.transform).setPosition.apply(n,[].concat(t));var r=e.getComponent(exports.ModelCameraComponent);void 0!==r&&r.updateMainCamera()},n.setQuaternion=function(e,t){var n;(n=e.transform).setQuaternion.apply(n,[].concat(t));var r=e.getComponent(exports.ModelCameraComponent);void 0!==r&&r.updateMainCamera()},n.endGesture=function(){this.startParams.type=exports.CameraGestureType.none,this.startParams.mouseEvent=!1,this.startParams.target=""},n.updateCameraTransform=function(t){var n=new e.Transform(t);n.setValid(!0),this.cameraTransform.fromEffectsTransform(n),this.cameraCoordiante.fromPTransform(this.cameraTransform)},t}(),Ct=function(){function t(){}return t.getTransformFromMat4=function(e){var t=e.getTransform(),n=t.rotation.toEuler(new F);return{position:t.translation.toArray(),rotation:n.toArray(),scale:t.scale.toArray()}},t.getEffectsTransformFromMat4=function(t){var n=new e.Transform({valid:!0});return n.cloneFromMatrix(t),{position:n.position.toArray(),rotation:n.rotation.toArray(),scale:n.scale.toArray()}},t.getTransformFromTranslation=function(e){return{position:e.toArray()}},t.getTransformFromDirection=function(e){var n=N.fromArray([1,0,0]),r=e.clone().normalize(),i=n.clone().cross(r);if(i.length()<.01)return{};i.normalize();var o=r.dot(n),a=Math.acos(o),s=R.fromRotationAxis(i,a);return t.getTransformFromMat4(s)},t.getEffectsTransformFromDirection=function(e){var n=N.fromArray([0,0,1]),r=e.clone().normalize(),i=n.clone().cross(r);if(i.length()<.01)return{};i.normalize();var o=r.dot(n),a=Math.acos(o),s=R.fromRotationAxis(i,a);return t.getEffectsTransformFromMat4(s)},t.getTransformFromTransDir=function(e,n){var r=t.getTransformFromDirection(n);return r.position=e.toArray(),r},t.getEffectsTransformFromTransDir=function(e,n){var r=t.getEffectsTransformFromDirection(n);return r.position=e.toArray(),r},t.getEulerFromQuat=function(e){var t=new F,n=new U(e.x,e.y,e.z,e.w);return t.order=D.ZYX,t.setFromQuaternion(n),[t.x,t.y,t.z]},t.getQuatFromEuler=function(e){var t=new U;return t.setFromEuler(e),[t.x,t.y,t.z,t.w]},t.toPlayerColor3=function(e){return[t.scaleTo255(e[0]),t.scaleTo255(e[1]),t.scaleTo255(e[2])]},t.toPlayerColor4=function(e){return[t.scaleTo255(e[0]),t.scaleTo255(e[1]),t.scaleTo255(e[2]),t.scaleTo255(e[3])]},t.scaleTo255=function(e){var t=255*e;return Math.max(0,Math.min(t,255))},t.scaleTo1=function(e){var t=e/255;return Math.max(0,Math.min(t,1))},t}(),St=function(){function t(t,n){void 0===n&&(n=!0),this.renderer=t,this.keepIBLData=n,this.treeInfo=new Mt,this.engine=t.engine,this.downloader=new e.Downloader}var n=t.prototype;return n.processScene=function(t){var n=this;return o((function(){var r,i,o,a,s,l,c,u,h,f,d,m;return p(this,(function(p){switch(p.label){case 0:return e.isObject(t)?(i=t,[3,3]):[3,1];case 1:return[4,n.loadJSON(t)];case 2:i=p.sent(),p.label=3;case 3:if((r=i).textures||(r.textures=[]),r.textures.forEach((function(e){void 0===e.source&&(e.source=0)})),o=e.getStandardJSON(r),s=null!=(a=o.bins)?a:[],l=[],c=r.version.split("."),Number(c[0])>=3)return[2,o];if(!o.bins)return[3,7];u=b(o.bins),p.label=4;case 4:return(h=u()).done?[3,7]:(f=h.value,d=l.push,[4,n.loadBins(f.url)]);case 5:d.apply(l,[p.sent()]),p.label=6;case 6:return[3,4];case 7:return o.bins=l,m=j({},o,{version:e.spec.JSONSceneVersion["3_0"],playerVersion:{web:"3.0",native:"3.0"},type:"ge",compositions:[],images:[],textures:[],items:[],components:[],materials:[],shaders:[]}),n.setImage(m,o),[4,n.setTexture(m,o)];case 8:return p.sent(),n.setComponent(m,o),n.setItem(m,o),n.setComposition(m,o),m.bins=s,[2,m]}}))}))()},n.setImage=function(e,t){var n=[];t.images.forEach((function(e){n.push(e)})),e.images=n},n.setTexture=function(t,n){var r=this;return o((function(){var i,o,a,s,l,c,u,h,f,d,m,g;return p(this,(function(p){switch(p.label){case 0:if(i=[],o=n.bins,!n.textures)return[3,7];a=b(n.textures),p.label=1;case 1:return(s=a()).done?[3,7]:34067!==(l=s.value).target?[3,5]:r.keepIBLData?(i.push(l),[3,4]):[3,2];case 2:return c=l.mipmaps,u=l.target,h=c.map((function(e){return Promise.all(e.map((function(e){return r.loadMipmapImage(e,o)})))})),[4,Promise.all(h)];case 3:f=p.sent(),d=f.map((function(n){return n.map((function(n){var r=e.generateGUID(),i={url:n,id:r};return t.images.push(i),{id:r}}))})),m=j({keepImageSource:!1},l,{mipmaps:d,sourceFrom:{target:u,type:e.TextureSourceType.mipmaps,mipmaps:c.map((function(e){return e.map((function(e){return[e[1][1],e[1][2]]}))}))}}),i.push(m),p.label=4;case 4:return[3,6];case 5:"number"==typeof(g=l.source)&&(l.source={id:t.images[g].id}),i.push(l),p.label=6;case 6:return[3,1];case 7:return t.textures=i,[2]}}))}))()},n.setComponent=function(t,n){for(var r,i=t.components,o=b(n.components);!(r=o()).done;){var a=r.value;if(a.dataType===e.spec.DataType.SkyboxComponent)i.push(this.createSkyboxComponent(a,t));else if(a.dataType===e.spec.DataType.LightComponent)i.push(this.createLightComponent(a,t));else if(a.dataType===e.spec.DataType.CameraComponent)i.push(a),console.warn("Camera component found: "+a+".");else if(a.dataType===e.spec.DataType.TreeComponent){var s=a;this.createItemsFromTreeComponent(a,t,n),s.options.tree.animation=void 0,s.options.tree.animations=void 0}else a.dataType!==e.spec.DataType.MeshComponent&&i.push(a)}for(var l,c=b(n.components);!(l=c()).done;){var u=l.value;u.dataType===e.spec.DataType.MeshComponent&&i.push(this.createMeshComponent(u,t,n))}},n.setItem=function(e,t){},n.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}}))},n.loadJSON=function(e){var t=this;return o((function(){return p(this,(function(n){return[2,new Promise((function(n,r){t.downloader.downloadJSON(e,n,(function(t,n){r(new Error("Failed to load JSON from URL '"+e+"': status "+t+" - "+n+". Please check the URL or network settings."))}))}))]}))}))()},n.loadBins=function(e){var t=this;return o((function(){return p(this,(function(n){return[2,new Promise((function(n,r){t.downloader.downloadBinary(e,n,(function(t,n){r("Couldn't load bins "+JSON.stringify(e)+": status "+t+", "+n)}))}))]}))}))()},n.loadMipmapImage=function(e,t){return o((function(){var n,r,i,o,a;return p(this,(function(s){if(n=e[1],r=n[0],i=n[1],o=n[2],!(a=t[r]))throw new Error("Invalid bin pointer: "+JSON.stringify(e)+".");return[2,URL.createObjectURL(new Blob([new Uint8Array(a,i,o)]))]}))}))()},n.createSkyboxComponent=function(e,t){var n,r,i,o=e.options;o.irradianceCoeffs&&(n=[],o.irradianceCoeffs.forEach((function(e){return(r=n).push.apply(r,[].concat(e))})));return o.diffuseImage&&(i={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:i,specularImage:{id:t.textures[o.specularImage].id},specularImageSize:o.specularImageSize,specularMipCount:o.specularMipCount+1}},n.createMeshComponent=function(e,t,n){var r,i=this,o=e.options,a=[],s=[];o.primitives.forEach((function(e){var t,r=$(e.geometry,n.bins),o=i.getMaterialData(e.material,n);if(l(null==(t=r.indices)?void 0:t.data,Uint8Array)){for(var c=r.indices.data,u=new Uint16Array(c.length),h=0;h<c.length;h++)u[h]=c[h];r.indices.data=u}a.push(r),s.push(o)}));var c=At(a);if(!c)throw new Error("No primitives available to process.");t.geometries.push(c),(r=t.materials).push.apply(r,[].concat(s));var u={id:e.id,dataType:e.dataType,item:e.item,geometry:{id:c.id},materials:s.map((function(e){return{id:e.id}}))};if(o.skin){for(var h,f=e.item.id,d=b(n.items);!(h=d()).done;){var p=h.value;p.id===e.item.id&&(f=p.parentId)}if(f===e.item.id)throw new Error("Can't item "+e.item+".");var m=this.treeInfo.getTreeItemByNodeId(f),g=this.treeInfo.getTreeNodeListByNodeId(f);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 v=this.setupBoneData(c,o.skin,n,m,g);u.rootBone={id:v.id}}return void 0!==o.weights&&(u.morph={weights:o.weights}),u},n.createItemsFromTreeComponent=function(t,n,r){var i=this,o=r.items[0];r.items.forEach((function(e){e.id===t.item.id&&(o=e)}));var a=t.options.tree,s=[];a.nodes.forEach((function(t,r){var a,l={id:e.generateGUID(),parentId:o.id,name:null!=(a=t.name)?a:"node"+r,duration:o.duration,type:"ECS",dataType:e.spec.DataType.VFXItemData,visible:o.visible,endBehavior:o.endBehavior,delay:o.delay,content:{},renderLevel:o.renderLevel,pn:o.pn,pluginName:o.pluginName,transform:i.getTransformData(t.transform),components:[]};s.push(l),n.items.push(l)})),a.nodes.forEach((function(e,t){var n,r=s[t];null==(n=e.children)||n.forEach((function(e){s[e].parentId=r.id}))})),r.items.forEach((function(e){if(e.parentId){var t=e.parentId.indexOf("^");if(t>=0){var n=e.parentId.substring(0,t),r=+e.parentId.substring(t+1);n===o.id&&(e.parentId=s[r].id)}}})),this.treeInfo.add(o,s),this.createAnimationComponent(a,o,n,r)},n.createLightComponent=function(e,t){var n=e.options,r={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?r.range=n.range:"spot"===n.lightType&&(r.range=n.range,r.innerConeAngle=n.innerConeAngle,r.outerConeAngle=n.outerConeAngle),r},n.createAnimationComponent=function(t,n,r,i){var o=this,a=t.animation,s=t.animations,c={id:e.generateGUID(),dataType:e.spec.DataType.AnimationComponent,item:{id:n.id},animation:a,animationClips:[]};if(s&&s.length){var u=i.bins;s.forEach((function(t){var a={id:e.generateGUID(),name:t.name,dataType:e.spec.DataType.AnimationClip,positionCurves:[],rotationCurves:[],scaleCurves:[],floatCurves:[]},s=0;t.tracks.forEach((function(e){var t=te(u,e.input);s=Math.max(s,t[t.length-1])})),t.tracks.forEach((function(t){var r=te(u,t.input),s=te(u,t.output);if(!l(r,Float32Array))throw new Error("Type of inputArray should be float32, "+r+".");if(!l(s,Float32Array))throw new Error("Type of outputArray should be float32, "+s+".");if("LINEAR"!==t.interpolation)throw new Error("Invalid interpolation type "+t.interpolation+".");if("rotation"===t.path){for(var c,h=[],f=[],d=[],p=0;p<r.length;p++){if(h.push([s[4*p],s[4*p+1],s[4*p+2],s[4*p+3]]),p>0){var m=U.fromArray(h[p-1]),g=U.fromArray(h[p]),v=new U,y=new U;v.slerpQuaternions(m,g,1/3),y.slerpQuaternions(m,g,2/3),f.push(v.toArray()),f.push(y.toArray())}d.push([e.spec.BezierKeyframeType.LINE,[r[p],p]])}var T=o.treeInfo.getTreeNode(n.id,t.node),x=o.treeInfo.getNodePath(T.id),b=[e.spec.ValueType.BEZIER_CURVE_QUAT,[d,h,f]];null==(c=a.rotationCurves)||c.push({path:x,keyFrames:b})}else if("weights"===t.path){var _=o.treeInfo.getTreeNode(n.id,t.node),C=o.treeInfo.getNodePath(_.id);if(0===_.components.length)for(var S=0;S<i.items.length;S++){var M=i.items[S];if(M.parentId===_.id){C+="/"+M.name;break}}for(var A=s.length/r.length,I=0;I<A;I++){for(var E,w=[],L=0;L<r.length;L++)w.push([e.spec.BezierKeyframeType.LINE,[r[L],s[L*A+I]]]);var P=[e.spec.ValueType.BEZIER_CURVE,w];null==(E=a.floatCurves)||E.push({path:C,className:"ModelMeshComponent",property:"morphWeights."+I,keyFrames:P})}}else{for(var R=[],O=[],F=[],D=0;D<r.length;D++){if(R.push([s[3*D],s[3*D+1],s[3*D+2]]),D>0){var B=N.fromArray(R[D-1]),k=N.fromArray(R[D]),V=(new N).lerpVectors(B,k,1/3),G=(new N).lerpVectors(B,k,2/3);O.push(V.toArray()),O.push(G.toArray())}F.push([e.spec.BezierKeyframeType.LINE,[r[D],D]])}var z,H,j=o.treeInfo.getTreeNode(n.id,t.node),W=o.treeInfo.getNodePath(j.id),J=[e.spec.ValueType.BEZIER_CURVE_PATH,[F,R,O]];if("translation"===t.path)null==(z=a.positionCurves)||z.push({path:W,keyFrames:J});else null==(H=a.scaleCurves)||H.push({path:W,keyFrames:J})}})),r.animations.push(a),c.animationClips.push({id:a.id})}))}n.components=[],n.components.push({id:c.id}),r.components.push(c)},n.getMaterialData=function(t,n){if(t.type===e.spec.MaterialType.unlit){var r={};void 0!==t.alphaCutOff&&(r._AlphaCutoff=t.alphaCutOff);var i={_BaseColorFactor:new O(t.baseColorFactor[0],t.baseColorFactor[1],t.baseColorFactor[2],t.baseColorFactor[3]).divide(255)},o={};t.baseColorTexture&&(o._BaseColorSampler=this.getTextureData(n,r,t.baseColorTexture,t.baseColorTextureTransform));var a={id:e.generateGUID(),name:t.name,dataType:e.spec.DataType.Material,shader:{id:J},stringTags:{},macros:[],ints:{},floats:r,vector4s:{},colors:i,textures:o};return this.setupMaterial(t,a),a}var s={_MetallicFactor:t.metallicFactor,_RoughnessFactor:t.roughnessFactor};void 0!==t.useSpecularAA&&(s._SpecularAA=t.useSpecularAA?1:0),void 0!==t.normalTextureScale&&(s._NormalScale=t.normalTextureScale),void 0!==t.occlusionTextureStrength&&(s._OcclusionStrength=t.occlusionTextureStrength),void 0!==t.emissiveIntensity&&(s._EmissiveIntensity=t.emissiveIntensity),void 0!==t.alphaCutOff&&(s._AlphaCutoff=t.alphaCutOff);var l={_BaseColorFactor:new O(t.baseColorFactor[0],t.baseColorFactor[1],t.baseColorFactor[2],t.baseColorFactor[3]).divide(255),_EmissiveFactor:new O(t.emissiveFactor[0],t.emissiveFactor[1],t.emissiveFactor[2],t.emissiveFactor[3]).divide(255)},c={};t.baseColorTexture&&(c._BaseColorSampler=this.getTextureData(n,s,t.baseColorTexture,t.baseColorTextureTransform)),t.metallicRoughnessTexture&&(c._MetallicRoughnessSampler=this.getTextureData(n,s,t.metallicRoughnessTexture,t.metallicRoughnessTextureTransform)),t.normalTexture&&(c._NormalSampler=this.getTextureData(n,s,t.normalTexture,t.normalTextureTransform)),t.occlusionTexture&&(c._OcclusionSampler=this.getTextureData(n,s,t.occlusionTexture,t.occlusionTextureTransform)),t.emissiveTexture&&(c._EmissiveSampler=this.getTextureData(n,s,t.emissiveTexture,t.emissiveTextureTransform));var u={id:e.generateGUID(),name:t.name,dataType:e.spec.DataType.Material,shader:{id:W},stringTags:{},macros:[],ints:{},floats:s,vector4s:{},colors:l,textures:c};return this.setupMaterial(t,u),u},n.setupMaterial=function(t,n){var r;(t.blending===e.spec.MaterialBlending.translucent?n.stringTags.RenderType=e.spec.RenderType.Transparent:n.stringTags.RenderType=e.spec.RenderType.Opaque,t.blending===e.spec.MaterialBlending.masked)?(n.floats.AlphaClip=1,n.floats._AlphaCutoff=null!=(r=t.alphaCutOff)?r:0):n.floats.AlphaClip=0;switch(t.side){case e.spec.SideMode.BACK:n.stringTags.RenderFace=e.spec.RenderFace.Back;break;case e.spec.SideMode.DOUBLE:n.stringTags.RenderFace=e.spec.RenderFace.Both;break;default:n.stringTags.RenderFace=e.spec.RenderFace.Front}t.type===e.spec.MaterialType.pbr&&(n.floats._SpecularAA=t.useSpecularAA?1:0),n.floats.ZWrite=!1!==t.depthMask?1:0,n.floats.ZTest=1},n.getTextureData=function(e,t,n,r){var i,o={texture:{id:null!=(i=e.textures[n].id)?i:"0"}};return r&&(r.scale&&(o.scale={x:r.scale[0],y:r.scale[1]}),r.offset&&(o.offset={x:r.offset[0],y:r.offset[1]}),r.rotation&&(t._BaseColorRotation=r.rotation)),o},n.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},n.setupBoneData=function(e,t,n,r,i){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=te(o,l);e.inverseBindMatrices=Array.from(c);var u={},h=r;void 0!==s?h=i[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=i[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=r)})),i.forEach((function(e){u[e.id]=e})),e.rootBoneName=h.name;var f=[];return a.forEach((function(e){for(var t=i[e],n=[];t&&t!=h&&(n.push(t.name),t.parentId);)t=u[t.parentId];f.push(n.reverse().join("/"))})),e.boneNames=f,h},t}(),Mt=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 r;(r=t).push.apply(r,[].concat(e.tree2NodeList[n]))})),t},t.getNodePath=function(e){return this.node2Path[e]},e}();function At(t){var n=function(e){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}(t[e]),l=r+(null!=(o=t[e].drawStart)?o:0),c=null!=(a=null==(n=t[0].indices)?void 0:n.data.BYTES_PER_ELEMENT)?a:1;if(i.push({offset:l*c,indexCount:s,vertexCount:s}),e){var u=t[0],h=t[e],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=wt(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 r=e.attributes[n];t=r.data.length/r.size})),t}(u);u.indices.data=wt(u.indices.data,h.indices.data,d)}Object.keys(u.attributes).forEach((function(e){var t=u.attributes[e],n=t.data,r=h.attributes[e].data;t.data=wt(n,r)}))}}r=l+s};if(!(t.length<=0)){for(var r=0,i=[],o=0;o<t.length;o++)n(o);return function(t,n){var r=0;for(var i in t.attributes){r+=t.attributes[i].data.byteLength}t.indices&&(r+=t.indices.data.byteLength);var o=0,a=0,s=new Uint8Array(r),c=[];for(var u in t.attributes){var h,f,d=t.attributes[u],p=null!=(h=Lt[u])?h:u;o=d.data.length/d.size;var m={semantic:p,offset:a,format:e.glType2VertexFormatType(null!=(f=d.type)?f:e.glContext.FLOAT),dimension:d.size,normalize:d.normalize};c.push(m);var g=d.data,v=new Uint8Array(g.buffer,g.byteOffset,g.byteLength);s.set(v,a),a+=v.byteLength}var y={id:e.generateGUID(),dataType:e.spec.DataType.Geometry,vertexData:{vertexCount:o,channels:c},subMeshes:n,mode:e.spec.GeometryType.TRIANGLES,indexFormat:e.spec.IndexFormatType.None,indexOffset:0,buffer:""};if(t.indices){var T=t.indices.data,x=new Uint8Array(T.buffer,T.byteOffset,T.byteLength);s.set(x,a),y.indexOffset=a,l(T,Uint32Array)?y.indexFormat=e.spec.IndexFormatType.UInt32:y.indexFormat=e.spec.IndexFormatType.UInt16}return y.buffer=function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}(s),y}(t[0],i)}}function It(t,n,r){switch(t){case e.spec.VertexFormatType.Int8:case e.spec.VertexFormatType.UInt8:return n*r;case e.spec.VertexFormatType.Int16:case e.spec.VertexFormatType.UInt16:return n*r*2;default:return n*r*4}}function Et(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),r=new Uint8Array(e.normals.buffer,e.normals.byteOffset,e.normals.byteLength),i=new Uint8Array(e.indices.buffer,e.indices.byteOffset,e.indices.byteLength),o=t.byteLength+n.byteLength+r.byteLength+i.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,r.byteLength)).set(r),new Uint8Array(a,t.byteLength+n.byteLength+r.byteLength,i.byteLength).set(i);for(var l=new Uint8Array(a),c="",u=0;u<l.length;u++)c+=String.fromCharCode(l[u]);return btoa(c)}function wt(e,t,n){if(l(e,Float32Array)){var r=new Float32Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}if(l(e,Int32Array)){var i=new Int32Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}if(l(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(l(e,Int16Array)){var s=new Int16Array(e.length+t.length);return s.set(e),s.set(t,e.length),s}if(l(e,Uint16Array)){var c=new Uint16Array(e.length+t.length);if(c.set(e),c.set(t,e.length),n)for(var u=0;u<t.length;u++)c[e.length+u]+=n;return c}if(l(e,Int8Array)){var h=new Int8Array(e.length+t.length);return h.set(e),h.set(t,e.length),h}var f=new Uint8Array(e.length+t.length);return f.set(e),f.set(t,e.length),f}var Nt,Lt={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"};var Pt=function(){function t(t){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 B,t?this.composition=t:(this.timelineAssetId=e.generateGUID(),this.composition={id:"1",name:"test1",duration:99999,endBehavior:e.spec.EndBehavior.restart,camera:{fov:45,far:2e3,near:.001,position:[0,0,8],rotation:[0,0,0],clipMode:e.spec.CameraClipMode.portrait},items:[],timelineAsset:{id:this.timelineAssetId},sceneBindings:[]})}var n=t.prototype;return n.loadScene=function(t){var n=this;return o((function(){var r,i,a,s,c,u,h,f,d;return p(this,(function(m){switch(m.label){case 0:if(n.clear(),n.sceneOptions=t,n.loaderOptions={compatibleMode:t.gltf.compatibleMode},"string"==typeof(c=t.gltf.resource)||l(c,Uint8Array))throw new Error("Please load the resource using GLTFTools first.");return n.images=c.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(n.images.map(o((function(t){return p(this,(function(n){return[2,e.loadImage(t.url)]}))}))))];case 1:if(n.imageElements=m.sent(),n.processGLTFResource(c,n.imageElements),n.gltfMeshs=c.meshes,n.gltfTextures=c.textures,n.gltfMaterials=c.materials,n.gltfAnimations=c.animations,n.gltfImageBasedLights=c.imageBasedLights,n.textures=n.gltfTextures.map((function(e){var t=e.textureOptions,r=t.source;return"number"==typeof r&&(t.source={id:n.images[r].id}),t})),n.materials=n.gltfMaterials.map((function(e){return e.materialData})),c.meshes.forEach((function(e){n.geometries.push(e.geometryData)})),(u=c.scenes[0]).meshesComponentData.forEach((function(e){return n.checkMeshComponentData(e,c)})),(r=n.components).push.apply(r,[].concat(u.camerasComponentData)),(i=n.components).push.apply(i,[].concat(u.lightsComponentData)),(a=n.components).push.apply(a,[].concat(u.meshesComponentData)),1===u.animationsComponentData.length)h=u.animationsComponentData[0],t.effects.playAllAnimation||void 0===t.effects.playAnimation||(f=h.animationClips,(d=t.effects.playAnimation)>=0&&d<f.length?h.animationClips=[f[d]]:h.animationClips=[]),n.components.push(h);else if(u.animationsComponentData.length>1)throw new Error("Find many animation component data "+u.animationsComponentData.length);return n.animations=[],n.gltfAnimations.forEach((function(e){n.animations.push(e.animationClipData)})),n.items=[],[4,n.tryAddSkybox({skyboxType:t.gltf.skyboxType,renderable:t.gltf.skyboxVis})];case 2:return m.sent(),(s=n.items).push.apply(s,[].concat(c.scenes[0].vfxItemData)),n.items.forEach((function(e){"root"===e.type&&(e.type="ECS")})),[2,n.getLoadResult()]}}))}))()},n.processGLTFResource=function(t,n){var r=function(){var t=f.value;if(h.has(t)){var n=a.find((function(e){return e.textureOptions.id===t}));if(n){var r=e.generateGUID(),i=n.clone();i.textureOptions.id=r,a.push(i),o[r]=i.textureOptions,p[t]=r,d+=1}}},i=this,o={},a=t.textures,s=t.materials,l=t.scenes,c=t.imageBasedLights;a.forEach((function(e){var t=e.textureOptions,n=t.id;n?(o[n]&&console.error("Duplicate GUID found: "+n+", old "+o[n]+", new "+t+"."),o[n]=t):console.error("No GUID in texture Data: "+t+".")}));var u=new Set,h=new Set;s.forEach((function(e){var t,n,r=e.materialData,i=null==(t=r.textures._BaseColorSampler)?void 0:t.texture,o=null==(n=r.textures._EmissiveSampler)?void 0:n.texture;i&&u.add(i.id),o&&h.add(o.id)}));for(var f,d=0,p={},m=b(u);!(f=m()).done;)r();d>0&&console.warn("Add base color texture "+d),s.forEach((function(e){var t,r,a=e.materialData;if(i.processMaterialData(a),(null==(t=a.shader)?void 0:t.id)===J)i.processMaterialTexture(a,"_BaseColorSampler",!0,o,n);else if((null==(r=a.shader)?void 0:r.id)===W){var s,l=null==(s=a.textures._EmissiveSampler)?void 0:s.texture;l&&p[l.id]&&(l.id=p[l.id]),i.processMaterialTexture(a,"_BaseColorSampler",!0,o,n),i.processMaterialTexture(a,"_MetallicRoughnessSampler",!1,o,n),i.processMaterialTexture(a,"_NormalSampler",!1,o,n),i.processMaterialTexture(a,"_OcclusionSampler",!1,o,n),i.processMaterialTexture(a,"_EmissiveSampler",!1,o,n)}}));var g=l[0];g.camerasComponentData.forEach((function(e){return i.processCameraComponentData(e)})),g.lightsComponentData.forEach((function(e){return i.processLightComponentData(e)}));var v=[];c.forEach((function(t){var n=t.imageBaseLightData;if(void 0===n.reflectionsIntensity&&(n.reflectionsIntensity=n.intensity),n.diffuseImage){var r=o[n.diffuseImage.id];e.addItem(v,r)}if(n.specularImage){var i=o[n.specularImage.id];e.addItem(v,i)}})),v.forEach((function(t){if(t.target===e.glContext.TEXTURE_CUBE_MAP){var n=t;n.mipmaps.forEach((function(e){var t;t=[e[5],e[4]],e[4]=t[0],e[5]=t[1]})),1===n.mipmaps.length?(n.minFilter=e.glContext.LINEAR,n.magFilter=e.glContext.LINEAR):(n.minFilter=e.glContext.LINEAR_MIPMAP_LINEAR,n.magFilter=e.glContext.LINEAR)}}))},n.processComponentData=function(t){var n=this;t.forEach((function(t){t.dataType===e.spec.DataType.LightComponent?n.processLightComponentData(t):t.dataType===e.spec.DataType.CameraComponent?n.processCameraComponentData(t):t.dataType===e.spec.DataType.SkyboxComponent&&n.processSkyboxComponentData(t)}))},n.processLightComponentData=function(t){t.color||(t.color={r:1,g:1,b:1,a:1}),t.intensity||(t.intensity=1),t.lightType===e.spec.LightType.point?t.range||(t.range=0):t.lightType===e.spec.LightType.spot&&(t.range||(t.range=0),t.innerConeAngle||(t.innerConeAngle=0),t.outerConeAngle||(t.outerConeAngle=Math.PI/4))},n.processCameraComponentData=function(t){t.type===e.spec.CameraType.perspective&&t.fov&&(t.fov*=Math.PI/180)},n.processSkyboxComponentData=function(e){void 0===e.intensity&&(e.intensity=1),void 0===e.reflectionsIntensity&&(e.reflectionsIntensity=1)},n.processMaterialData=function(t){var n,r;(null==(n=t.shader)?void 0:n.id)===J?(t.colors._BaseColorFactor||(t.colors._BaseColorFactor={r:1,g:1,b:1,a:1}),void 0===t.floats._AlphaCutoff&&(t.floats._AlphaCutoff=0),void 0===t.floats.ZWrite&&(t.floats.ZWrite=1),void 0===t.floats.ZTest&&(t.floats.ZTest=1),t.stringTags.RenderType||(t.stringTags.RenderType=e.spec.RenderType.Opaque),t.stringTags.RenderFace||(t.stringTags.RenderFace=e.spec.RenderFace.Front)):(null==(r=t.shader)?void 0:r.id)===W?(t.colors._BaseColorFactor||(t.colors._BaseColorFactor={r:1,g:1,b:1,a:1}),void 0===t.floats._SpecularAA&&(t.floats._SpecularAA=0),void 0===t.floats._MetallicFactor&&(t.floats._MetallicFactor=1),void 0===t.floats._RoughnessFactor&&(t.floats._RoughnessFactor=0),void 0===t.floats._NormalScale&&(t.floats._NormalScale=1),void 0===t.floats._OcclusionStrength&&(t.floats._OcclusionStrength=this.isTiny3dMode()?0:1),t.colors._EmissiveFactor||(t.colors._EmissiveFactor={r:0,g:0,b:0,a:1}),void 0===t.floats._EmissiveIntensity&&(t.floats._EmissiveIntensity=1),void 0===t.floats._AlphaCutoff&&(t.floats._AlphaCutoff=0),void 0===t.floats.ZWrite&&(t.floats.ZWrite=1),void 0===t.floats.ZTest&&(t.floats.ZTest=1),t.stringTags.RenderType||(t.stringTags.RenderType=e.spec.RenderType.Opaque),t.stringTags.RenderFace||(t.stringTags.RenderFace=e.spec.RenderFace.Front)):console.error("Encountered unknown shader ID in material with ID: "+t.id+".")},n.processTextureOptions=function(t,n,r){var i,o=!1,a=null!=(i=t.minFilter)?i:e.glContext.LINEAR_MIPMAP_LINEAR;this.isTiny3dMode()&&(a=e.glContext.LINEAR_MIPMAP_LINEAR,r&&(Oe.isPow2(r.width)&&Oe.isPow2(r.height)||(a=e.glContext.LINEAR)),o=!n);var s,l,c,u=a==e.glContext.NEAREST_MIPMAP_NEAREST||a==e.glContext.LINEAR_MIPMAP_NEAREST||a==e.glContext.NEAREST_MIPMAP_LINEAR||a==e.glContext.LINEAR_MIPMAP_LINEAR;t.wrapS=null!=(s=t.wrapS)?s:e.glContext.REPEAT,t.wrapT=null!=(l=t.wrapT)?l:e.glContext.REPEAT,t.magFilter=null!=(c=t.magFilter)?c:e.glContext.LINEAR,t.minFilter=a,t.anisotropic=1,t.premultiplyAlpha=o,t.generateMipmap=u},n.initial=function(e,t){this.engine=e,this.loaderOptions=null!=t?t:{}},n.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+").")},n.processMaterialTexture=function(e,t,n,r,i){var o=e.textures[t];if(o){var a,s=r[o.texture.id];if("number"!=typeof s.source)throw new Error("Invalid texture option source data, "+s.source);a=i[s.source],s&&this.processTextureOptions(s,n,a)}},n.getLoadResult=function(){var t=[];this.items.forEach((function(e){return t.push({id:e.id})})),this.composition.items=t;var n={version:e.spec.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:e.spec.DataType.TimelineAsset}]},r=this.computeSceneAABB();return{source:this.getRemarkString(),jsonScene:n,sceneAABB:{min:r.min.toArray(),max:r.max.toArray()}}},n.addLight=function(t){var n=e.generateGUID(),r={id:e.generateGUID(),item:{id:n},dataType:e.spec.DataType.LightComponent,lightType:t.lightType,color:t.color,intensity:t.intensity,range:t.range,innerConeAngle:t.innerConeAngle,outerConeAngle:t.outerConeAngle,followCamera:t.followCamera},i={id:n,name:t.name,duration:t.duration,type:e.spec.ItemType.light,pn:0,visible:!0,endBehavior:t.endBehavior,transform:{position:{x:t.position[0],y:t.position[1],z:t.position[2]},eulerHint:{x:t.rotation[0],y:t.rotation[1],z:t.rotation[2]},scale:{x:t.scale[0],y:t.scale[1],z:t.scale[2]}},components:[{id:r.id}],content:{},dataType:e.spec.DataType.VFXItemData};this.items.push(i),this.components.push(r)},n.addCamera=function(t){var n=e.generateGUID(),r={id:e.generateGUID(),item:{id:n},dataType:e.spec.DataType.CameraComponent,fov:t.fov,near:t.near,far:t.far,clipMode:t.clipMode},i={id:n,name:t.name,duration:t.duration,type:"camera",pn:0,visible:!0,endBehavior:t.endBehavior,transform:{position:{x:t.position[0],y:t.position[1],z:t.position[2]},eulerHint:{x:t.rotation[0],y:t.rotation[1],z:t.rotation[2]},scale:{x:1,y:1,z:1}},components:[{id:r.id}],content:{},dataType:e.spec.DataType.VFXItemData};this.items.push(i),this.components.push(r)},n.addSkybox=function(t){var n,r,i,o=e.generateGUID(),a=st.createSkyboxComponentData(t),s=a.imageList,l=a.textureOptionsList,c=a.component;c.item.id=o,void 0!==t.intensity&&(c.intensity=t.intensity),void 0!==t.reflectionsIntensity&&(c.reflectionsIntensity=t.reflectionsIntensity),c.renderable=null!=(i=t.renderable)&&i;var u={id:o,name:"Skybox-Customize",duration:999,type:e.spec.ItemType.skybox,pn:0,visible:!0,endBehavior:e.spec.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:e.spec.DataType.VFXItemData};(n=this.images).push.apply(n,[].concat(s)),(r=this.textures).push.apply(r,[].concat(l)),this.items.push(u),this.components.push(c)},n.tryAddSkybox=function(t){var n=this;return o((function(){var r,i,o,a,s,l,c,u,h,f,d;return p(this,(function(p){return n.gltfImageBasedLights.length>0&&!n.ignoreSkybox()?(r=n.gltfImageBasedLights[0],n.components.push(r.imageBaseLightData)):void 0!==t.skyboxType&&(a=e.generateGUID(),s=n.createSkyboxComponentData(t.skyboxType),l=s.imageList,c=s.textureOptionsList,(u=s.component).item.id=a,void 0!==t.intensity&&(u.intensity=t.intensity),void 0!==t.reflectionsIntensity&&(u.reflectionsIntensity=t.reflectionsIntensity),u.renderable=null!=(h=t.renderable)&&h,d={id:a,name:"Skybox-"+t.skyboxType,duration:null!=(f=t.duration)?f:999,type:e.spec.ItemType.skybox,pn:0,visible:!0,endBehavior:e.spec.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:e.spec.DataType.VFXItemData},(i=n.images).push.apply(i,[].concat(l)),(o=n.textures).push.apply(o,[].concat(c)),n.items.push(d),n.components.push(u)),[2]}))}))()},n.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?exports.PSkyboxType.NFT:exports.PSkyboxType.FARM,n=st.getSkyboxParams(t);return st.createSkyboxComponentData(n)},n.dispose=function(){this.clear(),this.engine=null},n.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=[]},n.computeSceneAABB=function(){var t={};this.gltfMeshs.forEach((function(e){var n=e.geometryData.id;t[n]=e}));var n={};this.components.forEach((function(r){if(r.dataType===e.spec.DataType.MeshComponent){var i=r;n[r.id]=t[i.geometry.id]}}));var r=new B,i={};return this.items.forEach((function(t){var o,a,s=null!=(o=t.parentId)?o:"",l=null!=(a=i[s])?a:new e.Transform,c={};t.transform&&(c.position=(new N).copyFrom(t.transform.position),c.rotation=F.fromVector3(t.transform.eulerHint),c.scale=(new N).copyFrom(t.transform.scale));var u=new e.Transform(c,l);i[t.id]=u,t.components.forEach((function(e){var t=n[e.id];if(t&&t.bounds){var i=N.fromArray(t.bounds.box.min),o=N.fromArray(t.bounds.box.max);r.union(new B(i,o))}}))})),r},n.isPlayAnimation=function(){return void 0!==this.sceneOptions.effects.playAnimation},n.isPlayAllAnimation=function(){return!0===this.sceneOptions.effects.playAllAnimation},n.getRemarkString=function(){var e=this.sceneOptions.gltf.remark;return void 0===e?"Unknown":"string"==typeof e?e:"BinaryBuffer"},n.getCompositionDuration=function(){return this.composition.duration},n.isTiny3dMode=function(){return"tiny3d"===this.loaderOptions.compatibleMode},n.getItemDuration=function(){var e;return null!=(e=this.sceneOptions.effects.duration)?e:9999},n.getEndBehavior=function(){var t;return null!=(t=this.sceneOptions.effects.endBehavior)?t:e.spec.EndBehavior.restart},n.getSkyboxType=function(){switch(this.sceneOptions.gltf.skyboxType){case"NFT":return exports.PSkyboxType.NFT;case"FARM":return exports.PSkyboxType.FARM}},n.isSkyboxVis=function(){return!0===this.sceneOptions.gltf.skyboxVis},n.ignoreSkybox=function(){return!0===this.sceneOptions.gltf.ignoreSkybox},n.isEnvironmentTest=function(){return"string"==typeof this.sceneOptions.gltf.remark&&this.sceneOptions.gltf.remark.includes("EnvironmentTest")},n.processLight=function(e,t){var n=this;e.forEach((function(e){void 0===e.color?e.color=t?[255,255,255,255]:[1,1,1,1]:(e.color[0]=n.scaleColorVal(e.color[0],t),e.color[1]=n.scaleColorVal(e.color[1],t),e.color[2]=n.scaleColorVal(e.color[2],t),e.color[3]=n.scaleColorVal(e.color[3],t))}))},n.processCamera=function(e,t){var n=t?180/Math.PI:Math.PI/180;e.forEach((function(e){void 0!==e.perspective&&(e.perspective.yfov*=n)}))},n.processMaterial=function(e,t){var n=this;e.forEach((function(e){void 0===e.baseColorFactor?e.baseColorFactor=t?[255,255,255,255]:[1,1,1,1]:(e.baseColorFactor[0]=n.scaleColorVal(e.baseColorFactor[0],t),e.baseColorFactor[1]=n.scaleColorVal(e.baseColorFactor[1],t),e.baseColorFactor[2]=n.scaleColorVal(e.baseColorFactor[2],t),e.baseColorFactor[3]=n.scaleColorVal(e.baseColorFactor[3],t)),void 0===e.emissiveFactor?e.emissiveFactor=t?[255,255,255,255]:[1,1,1,1]:(e.emissiveFactor[0]=n.scaleColorVal(e.emissiveFactor[0],t),e.emissiveFactor[1]=n.scaleColorVal(e.emissiveFactor[1],t),e.emissiveFactor[2]=n.scaleColorVal(e.emissiveFactor[2],t),e.emissiveFactor[3]=n.scaleColorVal(e.emissiveFactor[3],t)),t&&void 0!==e.occlusionTexture&&void 0===e.occlusionTexture.strength&&(e.occlusionTexture.strength=n.isTiny3dMode()?0:1)}))},n.createAnimations=function(e){return e.map((function(e){var t=e.channels.map((function(e){return{input:e.input.array,output:e.output.array,node:e.target.node,path:e.target.path,interpolation:e.interpolation}}));return{name:e.name,tracks:t}}))},n.createGeometry=function(e,t){return new Rt(this.engine,e,t).geometry},n.createMaterial=function(e){return new Ot(e,[],this.isTiny3dMode()).material},n.createTexture2D=function(e,t,n){return Oe.createTexture2D(this.engine,e,t,n,this.isTiny3dMode())},n.createTextureCube=function(e,t){var n=this;if(0==e.length)throw new Error("createTextureCube: Invalid cubeImages length "+e);var r=[];return e.forEach((function(e){if(6!=e.length)throw new Error("createTextureCube: cubeimage count should always be 6, "+e);var t,i=[];(e.forEach((function(e){if(void 0===e.imageData)throw new Error("createTextureCube: Invalid image data from "+e);i.push({type:"buffer",data:e.imageData,mimeType:e.mimeType})})),n.isTiny3dMode())&&(t=[i[5],i[4]],i[4]=t[0],i[5]=t[1]);r.push(i)})),1==r.length?Oe.createTextureCubeFromBuffer(this.engine,r[0]):Oe.createTextureCubeMipmapFromBuffer(this.engine,r,null!=t?t:Math.pow(2,r.length-1))},n.createSkybox=function(e){var t,n,r=this,i=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}}));r.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:i,irradianceCoeffs:c,specularImage:a,specularMipCount:s,specularImageSize:l};return st.createSkyboxOptions(this.engine,u)},n.createDefaultSkybox=function(e){if("NFT"!==e&&"FARM"!==e)throw new Error("Invalid skybox type name "+e);var t="NFT"===e?exports.PSkyboxType.NFT:exports.PSkyboxType.FARM,n=st.getSkyboxParams(t);return st.createSkyboxOptions(this.engine,n)},n.scaleColorVal=function(e,t){return t?Ct.scaleTo255(e):Ct.scaleTo1(e)},n.scaleColorVec=function(e,t){var n=this;return e.map((function(e){return n.scaleColorVal(e,t)}))},t}();var Rt=function(){function t(e,t,n){this.engine=e,this.gltfGeometry=t,this.hasSkinAnimation=n}var n=t.prototype;return n._getBufferAttrib=function(e){return{type:e.type,size:e.itemSize,data:e.array,normalize:e.normalized}},n.texCoordAttrib=function(e){return this.gltfGeometry.getTexCoord(e)},n.getTargetPosition=function(e){return this.gltfGeometry.getAttribute("POSITION"+e)},n.getTargetNormal=function(e){return this.gltfGeometry.getAttribute("NORMAL"+e)},n.getTargetTangent=function(e){return this.gltfGeometry.getAttribute("TANGENT"+e)},H(t,[{key:"geometry",get:function(){var t=this,n={};if(!this.hasPosition)throw new Error("Position attribute missing");var r=this.positionAttrib;if(n.a_Position=this._getBufferAttrib(r),this.hasNormal){var i=this.normalAttrib;void 0!==i&&(n.a_Normal=this._getBufferAttrib(i))}if(this.hasTangent){var o=this.tangentAttrib;void 0!==o&&(n.a_Tangent=this._getBufferAttrib(o))}if(this.texCoordList.forEach((function(e){var r=t.texCoordAttrib(e);n["a_UV"+(e+1)]=t._getBufferAttrib(r)})),this.hasSkinAnimation){var a=this.jointAttribute;void 0!==a&&(n.a_Joint1=this._getBufferAttrib(a));var s=this.weightAttribute;void 0!==s&&(n.a_Weight1=this._getBufferAttrib(s))}for(var l=0;l<8;l++){var c=this.getTargetPosition(l);void 0!==c&&(n["a_Target_Position"+l]=this._getBufferAttrib(c));var u=this.getTargetNormal(l);void 0!==u&&(n["a_Target_Normal"+l]=this._getBufferAttrib(u));var h=this.getTargetTangent(l);void 0!==h&&(n["a_Target_Tangent"+l]=this._getBufferAttrib(h))}var f=this.indexArray;return void 0!==f?e.Geometry.create(this.engine,{attributes:n,indices:{data:f},drawStart:0,drawCount:f.length,mode:e.glContext.TRIANGLES}):e.Geometry.create(this.engine,{attributes:n,drawStart:0,drawCount:this.positionAttrib.array.length/3,mode:e.glContext.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}}]),t}(),Ot=function(){function t(e,t,n){this.gltfMaterial=e,this.textures=t,this.tiny3dMode=n}var n=t.prototype;return n.getTextureObject=function(e){if(!(e<0||e>=this.textures.length))return this.textures[e]},n.getTextureObj=function(e){return e?this.getTextureObject(e.index):void 0},n.getTextureCoord=function(e){return e?e.texCoord:void 0},n.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}},n.getSpecularAA=function(){var e;return null==(e=this.gltfMaterial.extras)?void 0:e.useSpecularAA},H(t,[{key:"material",get:function(){var t=this.gltfMaterial,n=Ft.isUnlitMaterial(t),r=e.spec.MaterialBlending.opaque;switch(t.alphaMode){case"OPAQUE":r=e.spec.MaterialBlending.opaque;break;case"MASK":r=e.spec.MaterialBlending.masked;break;case"BLEND":r=e.spec.MaterialBlending.translucent}var i,o,a,s=t.doubleSided?e.spec.SideMode.DOUBLE:e.spec.SideMode.FRONT,l=null!=(i=t.alphaCutOff)?i:.5,c=t.name;return n?{name:c,type:e.spec.MaterialType.unlit,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,depthMask:null==(o=t.extras)?void 0:o.depthMask,blending:r,alphaCutOff:l,side:s}:{name:c,type:e.spec.MaterialType.pbr,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,useSpecularAA:this.getSpecularAA(),metallicRoughnessTexture:this.metallicRoughnessTextureObj,metallicRoughnessTextureCoordinate:this.metallicRoughnessTextureCoord,metallicRoughnessTextureTransform:this.metallicRoughnessTextureTransfrom,metallicFactor:this.metalicFactor,roughnessFactor:this.roughnessFactor,normalTexture:this.normalTextureObj,normalTextureCoordinate:this.normalTextureCoord,normalTextureTransform:this.normalTextureTransfrom,normalTextureScale:this.normalTextureScale,occlusionTexture:this.occlusionTextureObj,occlusionTextureCoordinate:this.occlusionTextureCoord,occlusionTextureTransform:this.occlusionTextureTransfrom,occlusionTextureStrength:this.occlusionTextureStrength,emissiveTexture:this.emissiveTextureObj,emissiveTextureCoordinate:this.emissiveTextureCoord,emissiveTextureTransform:this.emissiveTextureTransfrom,emissiveFactor:this.emissiveFactor,emissiveIntensity:1,depthMask:null==(a=t.extras)?void 0:a.depthMask,blending:r,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]}}]),t}(),Ft=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=N.fromArray(e.box.min),n=N.fromArray(e.box.max);return new B(t,n)},e}();e.registerPlugin("model",xt);var Dt="2.8.2";e.logger.info("Plugin model version: 2.8.2."),Dt!==n.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!"),exports.Box3=B,exports.BoxMesh=le,exports.CameraGestureHandlerImp=_t,exports.CheckerHelper=We,exports.Color=O,exports.CompositionCache=lt,exports.CompositionHitTest=function(e,t,n){var r=e.hitTest(t,n,!0),i=e.getHitTestRay(t,n);if(r.length<=0)return[];var o=i.origin,a=i.direction,s=r.map((function(e,t){for(var n,r=e.position,i=[0,0,0],s=0;s<3;s++)i[s]=(r.getElement(s)-o.getElement(s))/a.getElement(s);return[t,(n=Math).max.apply(n,[].concat(i))]}));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 r[e[0]]}))},exports.DEG2RAD=G,exports.Euler=F,exports.EulerOrder=D,exports.FBOOptions=se,exports.Float16ArrayWrapper=Je,exports.GeometryBoxProxy=He,exports.HitTestingProxy=je,exports.HookOGLFunc=function(e){console.info("HookOGLFunc "+Object.getPrototypeOf(e));var t=0;for(var n in Object.getPrototypeOf(e))"getError"!==n&&"function"==typeof e[n]&&(++t,e[n+ne]=e[n],e[n]=oe(e,n));console.info("HookCount "+t),function(e){for(var t in Object.getPrototypeOf(e))"number"==typeof e[t]&&re.set(e[t],t)}(e)},exports.InterpolationSampler=m,exports.JSONConverter=St,exports.LoaderHelper=Ct,exports.LoaderImpl=Pt,exports.Matrix3=P,exports.Matrix4=R,exports.MeshHelper=Be,exports.ModelPlugin=xt,exports.PAnimTexture=Qe,exports.PBRShaderGUID=W,exports.PCamera=ut,exports.PCameraManager=ht,exports.PCoordinate=q,exports.PEntity=Q,exports.PGeometry=vt,exports.PGlobalState=Y,exports.PLight=ft,exports.PLightManager=dt,exports.PMaterialBase=et,exports.PMaterialPBR=nt,exports.PMaterialSkyboxFilter=at,exports.PMaterialUnlit=tt,exports.PMesh=mt,exports.PMorph=Ke,exports.PObject=K,exports.PSceneManager=Tt,exports.PShaderManager=$e,exports.PSkin=Ze,exports.PSkybox=ot,exports.PSkyboxCreator=st,exports.PSubMesh=gt,exports.PTransform=X,exports.PluginHelper=ke,exports.Quaternion=U,exports.Ray=V,exports.RayBoxTesting=Ee,exports.RayIntersectsBoxWithRotation=Ie,exports.RayTriangleTesting=Re,exports.Sphere=k,exports.ToggleItemBounding=function(e,t){var n;null==(n=e.items)||n.forEach((function(e){if(e.type===r){var n=e.getComponent(exports.ModelMeshComponent);if(n){var i=n.content;e.id===t?i.visBoundingBox=!0:i.visBoundingBox=!1}}}))},exports.TwoStatesSet=Se,exports.UnlitShaderGUID=J,exports.VFX_ITEM_TYPE_3D=r,exports.Vector2=w,exports.Vector3=N,exports.Vector4=L,exports.VertexAttribBuffer=Ge,exports.WebGLHelper=Oe,exports.WebHelper=Ve,exports.createAnimationSampler=function(e,t,n,r,i){switch(e){case"LINEAR":return"rotation"===i?new T(t,n,r):new g(t,n,r);case"STEP":return new v(t,n,r);default:return new g(t,n,r)}},exports.createPluginMaterial=rt,exports.fetchPBRShaderCode=me,exports.fetchUnlitShaderCode=ge,exports.getDefaultEffectsGLTFLoader=function(e,t){return Nt||(Nt=new Pt),Nt.initial(e,t),Nt},exports.getDefaultPBRMaterialData=function(){return{id:"00000000000000000000000000000000",name:"PBR Material",dataType:e.spec.DataType.Material,stringTags:{RenderType:e.spec.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:{}}},exports.getDefaultUnlitMaterialData=function(){return{id:"00000000000000000000000000000000",name:"Unlit Material",dataType:e.spec.DataType.Material,stringTags:{ZWrite:"true",ZTest:"true",RenderType:e.spec.RenderType.Opaque,Cull:"Front"},macros:[],shader:{id:e.spec.BuiltinObjectGUID.UnlitShader},ints:{},floats:{_AlphaCutoff:.5},vector4s:{},colors:{_BaseColorFactor:{r:1,g:1,b:1,a:1}},textures:{}}},exports.getDiffuseOnlyShaderCode=function(e){return{vertexShaderCode:Ce({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 "}},exports.getGaussianBlurShaderCodeV1=function(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 "}},exports.getGaussianBlurShaderCodeV2=_e,exports.getGeometryDataFromOptions=function(t){var n,r=0,i=e.spec.VertexFormatType.Float32,o=!1,a=e.spec.VertexFormatType.Float32,s=!1,l=e.spec.VertexFormatType.Float32,c=!1,u={vertices:new Float32Array,uvs:new Float32Array,normals:new Float32Array,indices:new Float32Array,name:null!=(n=t.name)?n:"<empty>"};for(var h in t.attributes){var f,d,p=t.attributes[h];if("aPosition"===h)r=p.data.length/p.size,u.vertices=p.data,o=null!=(f=p.normalize)&&f,i=e.glType2VertexFormatType(null!=(d=p.type)?d:e.glContext.FLOAT);else if("aNormal"===h){var m,g;u.normals=p.data,c=null!=(m=p.normalize)&&m,l=e.glType2VertexFormatType(null!=(g=p.type)?g:e.glContext.FLOAT)}else if("aUV1"===h){var v,y;u.uvs=p.data,s=null!=(v=p.normalize)&&v,a=e.glType2VertexFormatType(null!=(y=p.type)?y:e.glContext.FLOAT)}}var T=It(i,3,r),x=It(a,2,r),b=It(l,3,r);if(t.indices)u.indices=t.indices.data;else if(r<=65535){for(var _=new Uint16Array(r),C=0;C<r;C++)_[C]=C;u.indices=_}else{for(var S=new Uint32Array(r),M=0;M<r;M++)S[M]=M;u.indices=S}var A=e.spec.IndexFormatType.UInt16;return 4===u.indices.BYTES_PER_ELEMENT&&(A=e.spec.IndexFormatType.UInt32),{id:e.generateGUID(),dataType:e.spec.DataType.Geometry,vertexData:{vertexCount:r,channels:[{semantic:e.spec.VertexBufferSemantic.Position,offset:0,format:i,dimension:3,normalize:o},{semantic:e.spec.VertexBufferSemantic.Uv,offset:T,format:a,dimension:2,normalize:s},{semantic:e.spec.VertexBufferSemantic.Normal,offset:T+x,format:l,dimension:3,normalize:c}]},subMeshes:[],mode:e.spec.GeometryType.TRIANGLES,indexFormat:A,indexOffset:T+x+b,buffer:Et(u)}},exports.getGeometryDataFromPropsList=At,exports.getKawaseBlurShaderCode=function(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 "}},exports.getNormalVisShaderCode=xe,exports.getPBRPassShaderCode=ve,exports.getPBRShaderProperties=function(){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 '},exports.getPMeshList=function(e){var t=[],n=e.getCompositions()[0];return null==n||n.items.forEach((function(e){if(e.type===r){var n=e.getComponent(exports.ModelMeshComponent);(null==n?void 0:n.content.type)===exports.PObjectType.mesh&&t.push(n.content)}})),t},exports.getQuadFilterShaderCode=function(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 "}},exports.getRendererGPUInfo=function(e){var t=e.gpuCapability;return JSON.stringify(t,void 0,2)},exports.getSceneManager=bt,exports.getShadowPassShaderCode=ye,exports.getSimpleFilterShaderCode=be,exports.getSkyBoxShaderCode=Te,exports.getTransparecyBaseShader=function(e){return e?Ce({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 "},exports.getTransparecyFilterShader=function(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 "},exports.getUnlitShaderProperties=function(){return'\n _BaseColorSampler ("基础贴图", 2D) = "" {}\n _BaseColorFactor ("基础颜色", Color) = (1, 1, 1, 1)\n _AlphaCutoff ("Alpha裁剪值", Range(0, 1)) = 0.5\n '},exports.setDefaultEffectsGLTFLoader=function(e){Nt=e},exports.version=Dt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@galacean/effects/weapp");function t(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var n=t(e),r="PluginModel";function i(e,t,n,r,i,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(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,l,"next",e)}function l(e){i(a,r,o,s,l,"throw",e)}s(void 0)}))}}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function s(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&&a(e,t)}function l(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):l(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(c=function(){return!!e})()}function u(e,t,n){return u=c()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&a(i,n.prototype),i},u.apply(null,arguments)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function f(e){var t="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return u(e,arguments,h(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,e)},f(e)}function d(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function p(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[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,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=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 m=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,r=t[n],i=t[n-1];e:{t:{var o;n:{r:if(!(e<r)){for(var a=n+2;;){if(void 0===r){if(e<i)break r;return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}if(n===a)break;if(i=r,e<(r=t[++n]))break t}o=t.length;break n}if(e>=i)break e;var s=t[1];e<s&&(n=2,i=s);for(var l=n-2;;){if(void 0===i)return this.cachedIndex=0,this.copySampleValue(0);if(n===l)break;if(r=i,e>=(i=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(r=t[n],void 0===(i=t[n-1]))return this.cachedIndex=0,this.copySampleValue(0);if(void 0===r)return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}this.cachedIndex=n,this.intervalChanged(n,i,r)}return this.interpolate(n,i,e,r)},t.dispose=function(){this.time=void 0,this.data=void 0},t.copySampleValue=function(e){for(var t=this.data,n=this.componentCount,r=e*n,i=new Float32Array(n),o=0;o!==n;++o)i[o]=t[r+o];return i},e}(),g=function(e){function t(t,n,r){return e.call(this,t,n,r)}s(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,r){for(var i,o=this.data,a=null!=(i=this.componentCount)?i:1,s=e*a,l=s-a,c=(n-t)/(r-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}(m),v=function(e){function t(t,n,r){return e.call(this,t,n,r)}s(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,r){for(var i,o=this.data,a=null!=(i=this.componentCount)?i:1,s=(e-1)*a,l=new Float32Array(a),c=0;c!==a;++c)l[c]=o[s+c];return l},t}(m),y=function(){function e(){}return e.slerpFlat=function(e,t,n,r,i,o,a){var s=n[r+0],l=n[r+1],c=n[r+2],u=n[r+3],h=i[o+0],f=i[o+1],d=i[o+2],p=i[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]=p);if(u!==p||s!==h||l!==f||c!==d){var m=1-a,g=s*h+l*f+c*d+u*p,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var T=Math.sqrt(y),x=Math.atan2(T,g*v);m=Math.sin(m*x)/T,a=Math.sin(a*x)/T}var b=a*v;if(s=s*m+h*b,l=l*m+f*b,c=c*m+d*b,u=u*m+p*b,m===1-a){var _=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=_,l*=_,c*=_,u*=_}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u},e}(),T=function(e){function t(t,n,r){return e.call(this,t,n,r)}s(t,e);var n=t.prototype;return n.intervalChanged=function(e,t,n){},n.interpolate=function(e,t,n,r){for(var i,o=this.data,a=null!=(i=this.componentCount)?i:1,s=(n-t)/(r-t),l=e*a,c=new Float32Array(a),u=l+a;l!==u;l+=4)y.slerpFlat(c,0,o,l-a,o,l,s);return c},t}(m);function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function b(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 x(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)?x(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 _,C,S,M,A,I,E,w=e.math.Vector2,N=e.math.Vector3,L=e.math.Vector4,P=e.math.Matrix3,R=e.math.Matrix4,O=e.math.Color,F=e.math.Euler,D=e.math.EulerOrder,U=e.math.Quaternion,B=e.math.Box3,k=e.math.Sphere,V=e.math.Ray,G=e.math.DEG2RAD;function z(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function H(e,t,n){return t&&z(e.prototype,t),n&&z(e,n),e}function j(){return j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},j.apply(this,arguments)}exports.PObjectType=void 0,(_=exports.PObjectType||(exports.PObjectType={}))[_.none=0]="none",_[_.mesh=1]="mesh",_[_.texture=2]="texture",_[_.material=3]="material",_[_.light=4]="light",_[_.camera=5]="camera",_[_.skybox=6]="skybox",_[_.skin=7]="skin",_[_.morph=8]="morph",_[_.skeleton=9]="skeleton",_[_.animation=10]="animation",_[_.animationManager=11]="animationManager",_[_.reference=12]="reference",exports.PLightType=void 0,(C=exports.PLightType||(exports.PLightType={}))[C.directional=0]="directional",C[C.point=1]="point",C[C.spot=2]="spot",C[C.ambient=3]="ambient",exports.PTextureType=void 0,(S=exports.PTextureType||(exports.PTextureType={}))[S.none=0]="none",S[S.t2d=1]="t2d",S[S.t3d=2]="t3d",S[S.cube=3]="cube",exports.PMaterialType=void 0,(M=exports.PMaterialType||(exports.PMaterialType={}))[M.none=0]="none",M[M.unlit=1]="unlit",M[M.pbr=2]="pbr",M[M.normalVis=3]="normalVis",M[M.simpleFilter=4]="simpleFilter",M[M.shadowBase=5]="shadowBase",M[M.shadowFilter=6]="shadowFilter",M[M.skyboxFilter=7]="skyboxFilter",exports.PBlendMode=void 0,(A=exports.PBlendMode||(exports.PBlendMode={}))[A.opaque=0]="opaque",A[A.masked=1]="masked",A[A.translucent=2]="translucent",A[A.additive=3]="additive",exports.PFaceSideMode=void 0,(I=exports.PFaceSideMode||(exports.PFaceSideMode={}))[I.both=0]="both",I[I.front=1]="front",I[I.back=2]="back",exports.PShadowType=void 0,(E=exports.PShadowType||(exports.PShadowType={}))[E.none=0]="none",E[E.standard=1]="standard",E[E.variance=2]="variance",E[E.expVariance=3]="expVariance";var W=e.spec.BuiltinObjectGUID.PBRShader,J=e.spec.BuiltinObjectGUID.UnlitShader,X=function(){function t(){this.translation=new N(0,0,0),this.rotation=new U(0,0,0,1),this.scale=new N(1,1,1)}var n=t.prototype;return n.fromMatrix4=function(e){return this.setMatrix(e),this},n.fromEffectsTransform=function(t){if(l(t,e.Transform))this.setMatrix(t.getWorldMatrix());else{var n=new e.Transform(j({},t,{valid:!0}));n.setValid(!0),this.setMatrix(n.getWorldMatrix())}return this},n.toEffectsTransform=function(e){var t=this.getMatrix();return e.cloneFromMatrix(t),e},n.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},n.getTranslation=function(){return this.translation},n.setTranslation=function(e){l(e,N)?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},n.getPosition=function(){return this.translation},n.setPosition=function(e){l(e,N)?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},n.getRotation=function(){return this.rotation},n.setRotation=function(e){l(e,U)?this.rotation.set(e.x,e.y,e.z,e.w):l(e,F)?this.rotation.setFromEuler(e):l(e,N)?this.rotation.setFromEuler(new F(e.x,e.y,e.z,D.ZYX)):4===e.length?this.rotation.set(e[0],e[1],e[2],e[3]):this.rotation.setFromEuler(new F(e[0],e[1],e[2],D.ZYX))},n.getScale=function(){return this.scale},n.setScale=function(e){l(e,N)?this.scale.set(e.x,e.y,e.z):this.scale.set(e[0],e[1],e[2])},n.getMatrix=function(){return(new R).compose(this.getTranslation(),this.getRotation(),this.getScale())},n.setMatrix=function(e){if(l(e,R)){var t=e.getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}else{var n=R.fromArray(e).getTransform();this.setTranslation(n.translation),this.setRotation(n.rotation),this.setScale(n.scale)}},t}(),q=function(){function e(){this.origin=new N(0,0,0),this.xAxis=new N(1,0,0),this.yAxis=new N(0,1,0),this.zAxis=new N(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 R);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}(),Y=function(){function t(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=e.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16}var n=t.prototype;return n.reset=function(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=e.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16},n.hasRenderMode3D=function(){return this.renderMode3D!==e.spec.RenderMode3D.none},t.getInstance=function(){return this.instance||(this.instance=new this)},H(t,[{key:"isEditorEnv",get:function(){return this.runtimeEnv===e.PLAYER_OPTIONS_ENV_EDITOR}},{key:"isDeviceEnv",get:function(){return!this.isEditorEnv}},{key:"isTiny3dMode",get:function(){return"tiny3d"===this.compatibleMode}},{key:"isGLTFMode",get:function(){return!this.isTiny3dMode}}]),t}(),Z=1,K=function(){function e(){this.name="Unnamed Object",this.type=exports.PObjectType.none}var t=e.prototype;return t.dispose=function(){},t.isNone=function(){return this.type===exports.PObjectType.none},t.isValid=function(){return this.type!==exports.PObjectType.none},t.genName=function(e){return e+"_@"+Z++},e}(),Q=function(e){function t(){var t;return(t=e.apply(this,arguments)||this)._visible=!1,t._transform=new X,t.deleted=!1,t}s(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},H(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){l(e,X)?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 q;return e.fromPTransform(this._transform),e}}]),t}(K);function $(e,t){var n,r=e.attributes,i=j({},e);if(i.indices)i.indices=j({},i.indices),i.indices.data&&(i.indices.data=te(t,null==(n=e.indices)?void 0:n.data));else if(i.index){var o;if(i.indices=j({},i.index),i.indices.data)i.indices.data=te(t,null==(o=e.index)?void 0:o.data)}return Object.keys(r).forEach((function(e){var n=r[e],o=n.data;i.attributes[e]=j({},n),o&&(i.attributes[e].data=te(t,o))})),i}var ee={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,f32:Float32Array,i32:Int32Array,u32:Uint32Array};function te(t,n){if(2!=n.length||n[0]!==e.spec.ValueType.BINARY||!l(n[1],Array))return n;var r=n[1],i=r[0],o=r[1],a=r[2],s=r[3];if(!s)return t[i].slice(o,a);var c=ee[s]||Uint8Array;return new c(t[i],o,a/c.BYTES_PER_ELEMENT)}var ne="_Native",re=new Map;function ie(e,t){for(var n=""+e,r=[],i=0;i<t.length;i++){var o;"number"==typeof t[i]&&re.has(t[i])?r.push(re.get(t[i])+"("+t[i]+")"):r.push(null==(o=t[i])?void 0:o.toString())}return n+(r.length>0?"("+r.join(", ")+")":"()")}function oe(e,t){return function(){var n=e[t+ne].apply(this,arguments),r=e.getError();return r>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+")"}(r)+" ===> "+ie(t,arguments)),console.trace()):console.info(ie(t,arguments)),n}}var ae,se=function(){function t(e){var t,n;this.resolution=null!=(t=e.resolution)?t:new w(512,512),this.colorAttachments=null!=(n=e.colorAttachments)?n:[],this.depthAttachment=e.depthAttachment}var n=t.prototype;return n.addDepthAttachment=function(t){var n;this.depthAttachment={storageType:null!=(n=t.storageType)?n:e.RenderPassAttachmentStorageType.depth_16_texture}},n.addDefaultDepthAttachment=function(){this.depthAttachment={storageType:e.RenderPassAttachmentStorageType.depth_16_texture}},n.deleteDepthAttachment=function(){this.depthAttachment=void 0},n.addColorAttachment=function(t){var n,r,i,o;this.colorAttachments.push({texture:{format:null!=(n=t.format)?n:e.glContext.RGBA,type:null!=(r=t.type)?r:e.glContext.HALF_FLOAT,minFilter:null!=(i=t.filter)?i:e.glContext.LINEAR,magFilter:null!=(o=t.filter)?o:e.glContext.LINEAR}})},n.deleteColorAttachment=function(e){e>=0&&e<this.colorAttachments.length&&this.colorAttachments.splice(e,1)},H(t,[{key:"viewport",get:function(){return[0,0,this.resolution.x,this.resolution.y]}}]),t}(),le=function(){function t(t,n){var r=e.Material.create(t,{shader:{vertex:this.vertexShader,fragment:this.fragmentShader,shared:!0}});r.depthTest=!0,r.depthMask=!0,this.mesh=e.Mesh.create(t,{name:"boxMesh",material:r,geometry:e.Geometry.create(t,this.geometry),priority:n})}var n=t.prototype;return n.update=function(e,t,n,r){var i=this.mesh.material;i.setMatrix("effects_ObjectToWorld",e);for(var o=0;o<n.length;o+=3)i.setVector3("_PositionList["+o/3+"]",N.fromArray(n,o));i.setVector3("_LineColor",r)},n.dispose=function(){this.mesh.dispose(),this.mesh=void 0},H(t,[{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 t=new Float32Array([0,1,2,3,4,5,6,7]),n=new Uint32Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);return{attributes:{aPos:{type:e.glContext.FLOAT,size:1,data:t,stride:Float32Array.BYTES_PER_ELEMENT,offset:0}},mode:e.glContext.LINES,indices:{data:n},drawStart:0,drawCount:24}}}]),t}(),ce="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;}",ue="\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}",he="#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}",fe="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);}",de="\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"))}}(ae||(ae={})),e.ShaderFactory.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"),e.ShaderFactory.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"),e.ShaderFactory.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);}"),e.ShaderFactory.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;}"),e.ShaderFactory.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"),e.ShaderFactory.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"),e.ShaderFactory.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 pe=function(){function e(){}return e.getVertexShaderCode=function(e){var t=e.featureList,n=e.material.materialType;switch(n){case exports.PMaterialType.unlit:case exports.PMaterialType.pbr:case exports.PMaterialType.shadowBase:return ae.build(ce,t);case exports.PMaterialType.skyboxFilter:return ae.build(fe,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 exports.PMaterialType.unlit:case exports.PMaterialType.pbr:return ae.build(ue,t);case exports.PMaterialType.shadowBase:return ae.build(he,t);case exports.PMaterialType.skyboxFilter:return ae.build(de,t);default:throw new Error("Invalid material type "+n+" for getFragmentShaderString!")}},e.genVertexShaderCode=function(e){switch(e){case exports.PMaterialType.unlit:case exports.PMaterialType.pbr:case exports.PMaterialType.shadowBase:return ce;case exports.PMaterialType.skyboxFilter:return fe;default:throw new Error("Invalid material type "+e+" for genVertexShaderCode!")}},e.genFragmentShaderCode=function(e){switch(e){case exports.PMaterialType.unlit:case exports.PMaterialType.pbr:return ue;case exports.PMaterialType.shadowBase:return he;case exports.PMaterialType.skyboxFilter:return de;default:throw new Error("Invalid material type "+e+" for genFragmentShaderCode!")}},e}();function me(){return{vertexShaderCode:pe.genVertexShaderCode(exports.PMaterialType.pbr),fragmentShaderCode:pe.genFragmentShaderCode(exports.PMaterialType.pbr)}}function ge(){return{vertexShaderCode:pe.genVertexShaderCode(exports.PMaterialType.unlit),fragmentShaderCode:pe.genFragmentShaderCode(exports.PMaterialType.unlit)}}function ve(e){return{vertexShaderCode:pe.getVertexShaderCode(e),fragmentShaderCode:pe.getFragmentShaderCode(e)}}function ye(e){return{vertexShaderCode:pe.getVertexShaderCode(e),fragmentShaderCode:pe.getFragmentShaderCode(e)}}function Te(e){return{vertexShaderCode:pe.getVertexShaderCode(e),fragmentShaderCode:pe.getFragmentShaderCode(e)}}function xe(e){return{vertexShaderCode:Ce({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 be(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 _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 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 Ce(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")}pe.environment="webgl1";var Se=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}();exports.ModelMeshComponent=function(t){function n(n,r){var i;return(i=t.call(this,n)||this).morphWeights=[],i.getHitTestParams=function(t){i.computeBoundingBox();var n=i.bounding;if(n&&(t||Number.isInteger(n.behavior))){var r=n.type;if(r===e.spec.ModelBoundingType.box){if(l(i.content,mt)){var o=i.content;return{behavior:n.behavior,type:e.HitTestType.custom,collect:function(e,t){return o.hitTesting(e.origin,e.direction)}}}var a=i.transform.getWorldMatrix();return{behavior:n.behavior,type:e.HitTestType.custom,collect:function(e,t){return Ie(e,a,n)}}}if(r===e.spec.ModelBoundingType.sphere){var s=new N;i.transform.assignWorldTRS(s);var c=new N;return n.center&&c.setFromArray(n.center),c.add(s),{type:r,behavior:n.behavior,radius:n.radius||0,center:c}}}},r&&i.fromData(r),i}s(n,t);var i=n.prototype;return i.onStart=function(){var e;this.sceneManager=bt(this),this.createContent(),this.item.type=r,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(e){if(t.prototype.fromData.call(this,e),this.data=j({},e,{materials:[]}),this.data.rootBone=e.rootBone?this.engine.findObject(e.rootBone):void 0,this.data.geometry=this.engine.findObject(e.geometry),e.materials)for(var n=0;n<e.materials.length;n++)this.data.materials[n]=this.engine.findObject(e.materials[n])},i.createContent=function(){if(this.data){var e=this.data.interaction;this.bounding=e&&JSON.parse(JSON.stringify(e)),this.content=new mt(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&&l(this.content,mt)){var t,n=this.transform.getWorldMatrix(),r=this.content.computeBoundingBox(n),i=r.getCenter(new N),o=r.getSize(new N);return this.bounding={behavior:null==(t=this.bounding)?void 0:t.behavior,type:e.spec.ModelBoundingType.box,center:[i.x,i.y,i.z],size:[o.x,o.y,o.z]},this.bounding}},n}(e.RendererComponent),exports.ModelMeshComponent=d([e.effectsClass(e.spec.DataType.MeshComponent)],exports.ModelMeshComponent),exports.ModelSkyboxComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}s(t,e);var n=t.prototype;return n.onStart=function(){var e;this.createContent(),this.item.type=r,this.priority=this.item.renderOrder,this.sceneManager=bt(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 ot(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}(e.RendererComponent),exports.ModelSkyboxComponent=d([e.effectsClass(e.spec.DataType.SkyboxComponent)],exports.ModelSkyboxComponent),exports.ModelLightComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}s(t,e);var n=t.prototype;return n.onStart=function(){this.createContent(),this.item.type=r;var e=bt(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 ft(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}(e.Behaviour),exports.ModelLightComponent=d([e.effectsClass(e.spec.DataType.LightComponent)],exports.ModelLightComponent),exports.ModelCameraComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}s(t,e);var n=t.prototype;return n.onStart=function(){this.createContent(),this.item.type=r;var e=bt(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 ut(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}(e.Behaviour),exports.ModelCameraComponent=d([e.effectsClass(e.spec.DataType.CameraComponent)],exports.ModelCameraComponent),exports.AnimationComponent=function(e){function t(t){var n;return(n=e.call(this,t)||this).elapsedTime=0,n.animation=-1,n.clips=[],n}s(t,e);var n=t.prototype;return n.onStart=function(){this.elapsedTime=0,this.item.type=r},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,r,i=this;e.prototype.fromData.call(this,t),this.data=t,this.name=null!=(n=t.name)?n:"<empty>",this.animation=null!=(r=t.animation)?r:-1,this.clips=[],t.animationClips.forEach((function(e){var t=new Me(i.engine),n=i.engine.findObject(e);t.setFromAnimationClip(n),i.clips.push(t)}))},t}(e.Behaviour),exports.AnimationComponent=d([e.effectsClass(e.spec.DataType.AnimationComponent)],exports.AnimationComponent);var Me=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).path2Node={},t}s(t,e);var n=t.prototype;return n.sampleAnimation=function(e,t){for(var n,r=this.duration,i=Math.max(0,t)%r,o=b(this.positionCurves);!(n=o()).done;){var a=n.value,s=a.keyFrames.getValue(i%this.duration),l=this.getTargetItem(e,a.path);null==l||l.transform.setPosition(s.x,s.y,s.z)}for(var c,u=b(this.rotationCurves);!(c=u()).done;){var h=c.value,f=h.keyFrames.getValue(i%this.duration),d=this.getTargetItem(e,h.path);null==d||d.transform.setQuaternion(f.x,f.y,f.z,f.w)}for(var p,m=b(this.scaleCurves);!(p=m()).done;){var g=p.value,v=g.keyFrames.getValue(i%this.duration),y=this.getTargetItem(e,g.path);null==y||y.transform.setScale(v.x,v.y,v.z)}for(var T,x=b(this.floatCurves);!(T=x()).done;){var _=T.value,C=_.keyFrames.getValue(i%this.duration),S=this.getTargetItem(e,_.path);if("ModelMeshComponent"===_.className){var M=null==S?void 0:S.getComponent(exports.ModelMeshComponent);if(M)Ae(M,_.property.split("."),C);else console.error("Can't find mesh component.")}else console.warn("Ignore curve: className "+_.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,r=e,i=b(t.split("/"));!(n=i()).done;){for(var o,a=n.value,s=!1,l=b(r.children);!(o=l()).done;){var c=o.value;if(c.name===a){r=c,s=!0;break}}if(!s)throw new Error("Can't find path in tree "+e.id+", "+t+".")}return this.path2Node[t]=r,r},t}(e.AnimationClip);function Ae(e,t,n){for(var r=t.length,i=e,o=0;o<r-1;o++){var a=t[o];if(!(a in i)||"object"!=typeof i[a])return void console.error("Invalid properties "+t+".");i=i[a]}i[t[r-1]]=n}function Ie(e,t,n){var r=t,i=r.clone().invert(),o=e.clone().applyMatrix(i),a=N.fromArray(n.center),s=N.fromArray(n.size).multiply(.5),l=a.clone().subtract(s),c=a.clone().add(s),u=o.intersectBox({min:l,max:c},new N);return void 0!==u?[r.transformPoint(u)]:void 0}function Ee(e,t,n,r){var i=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?(i=(n.x-e.x)*u,o=(r.x-e.x)*u):(i=(r.x-e.x)*u,o=(n.x-e.x)*u),h>=0?(a=(n.y-e.y)*h,s=(r.y-e.y)*h):(a=(r.y-e.y)*h,s=(n.y-e.y)*h),!(i>s||a>o||((a>i||i!=i)&&(i=a),(s<o||o!=o)&&(o=s),f>=0?(l=(n.z-e.z)*f,c=(r.z-e.z)*f):(l=(r.z-e.z)*f,c=(n.z-e.z)*f),i>c||l>o||((l>i||i!=i)&&(i=l),(c<o||o!=o)&&(o=c),o<0))))return i>=0?i:o}var we=new N,Ne=new N,Le=new N,Pe=new N;function Re(e,t,n,r,i,o){Ne.subtractVectors(r,n),Le.subtractVectors(i,n),Pe.crossVectors(Ne,Le);var a=t.dot(Pe),s=0;if(a>0){if(o)return;s=1}else{if(!(a<0))return;s=-1,a=-a}we.subtractVectors(e,n),Le.crossVectors(we,Le);var l=s*t.dot(Le);if(!(l<0)){Ne.crossVectors(Ne,we);var c=s*t.dot(Ne);if(!(c<0||l+c>a)){var u=-s*we.dot(Pe);if(!(u<0))return u/a}}}var Oe=function(){function t(){}return t.createTexture2D=function(n,r,i,a,s){return o((function(){var o,l,c,u;return p(this,(function(h){return void 0===r.imageData?(console.error("createTexture2D: Invalid image data from "+r+"."),[2,e.Texture.create(n,{name:"createTexture2D",sourceType:e.TextureSourceType.data,data:{data:new Uint8Array([255,255,255,255]),width:1,height:1}})]):(o=new Blob([r.imageData],{type:r.mimeType}),l=window.URL||window.webkitURL,c=l.createObjectURL(o),(u=new Image).src=c,[2,new Promise((function(r,o){u.onload=function(){var o,h=null!=(o=i.minFilter)?o:e.glContext.LINEAR_MIPMAP_LINEAR,f=!1;s&&(h=e.glContext.LINEAR_MIPMAP_LINEAR,t.isPow2(u.width)&&t.isPow2(u.height)||(h=e.glContext.LINEAR),f=!a);var d,p,m,g=!1;h!=e.glContext.NEAREST_MIPMAP_NEAREST&&h!=e.glContext.LINEAR_MIPMAP_NEAREST&&h!=e.glContext.NEAREST_MIPMAP_LINEAR&&h!=e.glContext.LINEAR_MIPMAP_LINEAR||(g=!0);var v=e.Texture.create(n,{name:"createTexture2D",wrapS:null!=(d=i.wrapS)?d:e.glContext.REPEAT,wrapT:null!=(p=i.wrapT)?p:e.glContext.REPEAT,magFilter:null!=(m=i.magFilter)?m:e.glContext.LINEAR,minFilter:h,anisotropic:1,premultiplyAlpha:f,sourceType:e.TextureSourceType.image,image:u,generateMipmap:g});r(v),l.revokeObjectURL(c)},u.onerror=o}))])}))}))()},t.createTextureList=function(e,t,n){var r=this;return o((function(){return p(this,(function(i){switch(i.label){case 0:return[4,Promise.all(n.map((function(n){return r.createTexture2D(e,t[n.source],n)})))];case 1:return[2,i.sent()]}}))}))()},t.getTextureCubeData=function(e){return o((function(){var t;return p(this,(function(n){switch(n.label){case 0:return[4,Ve.loadImageFromImageData(e[0])];case 1:return t=[n.sent()],[4,Ve.loadImageFromImageData(e[1])];case 2:return t=t.concat([n.sent()]),[4,Ve.loadImageFromImageData(e[2])];case 3:return t=t.concat([n.sent()]),[4,Ve.loadImageFromImageData(e[3])];case 4:return t=t.concat([n.sent()]),[4,Ve.loadImageFromImageData(e[4])];case 5:return t=t.concat([n.sent()]),[4,Ve.loadImageFromImageData(e[5])];case 6:return[2,t.concat([n.sent()])]}}))}))()},t.getTextureCubeMipmapData=function(e){var t=this;return o((function(){var n,r,i;return p(this,(function(o){switch(o.label){case 0:n=[],r=0,o.label=1;case 1:return r<e.length?(i=n.push,[4,t.getTextureCubeData(e[r])]):[3,4];case 2:i.apply(n,[o.sent()]),o.label=3;case 3:return r++,[3,1];case 4:return[2,n]}}))}))()},t.createTextureCubeFromURL=function(t,n){var r=this;return o((function(){var i;return p(this,(function(o){switch(o.label){case 0:return[4,e.getDefaultTextureFactory().loadSource({type:e.TextureSourceType.image,target:e.glContext.TEXTURE_CUBE_MAP,map:n},r.cubemapTexConfig)];case 1:return i=o.sent(),[2,e.Texture.create(t,i)]}}))}))()},t.createTextureCubeMipmapFromURL=function(t,n){var r=this;return o((function(){var i;return p(this,(function(o){switch(o.label){case 0:return[4,e.getDefaultTextureFactory().loadSource({type:e.TextureSourceType.mipmaps,target:e.glContext.TEXTURE_CUBE_MAP,maps:n},r.cubemapMipTexConfig)];case 1:return i=o.sent(),[2,e.Texture.create(t,i)]}}))}))()},t.createTextureCubeFromBuffer=function(n,r){var i=this;return o((function(){var o;return p(this,(function(a){switch(a.label){case 0:return[4,t.getTextureCubeData(r)];case 1:return o=a.sent(),[2,e.Texture.create(n,j({name:"createTextureCubeFromBuffer",sourceType:e.TextureSourceType.image,cube:o,target:e.glContext.TEXTURE_CUBE_MAP},i.cubemapTexConfig))]}}))}))()},t.createTextureCubeMipmapFromBuffer=function(n,r,i){var a=this;return o((function(){var o,s,l,c,u;return p(this,(function(h){switch(h.label){case 0:return[4,t.getTextureCubeMipmapData(r)];case 1:for(o=h.sent(),s=0;Math.pow(2,s)<i;)++s;h.label=2;case 2:return o.length<=s?(l=Math.pow(2,s-o.length),c="https://gw.alipayobjects.com/zos/gltf-asset/67896749597915/img"+l+".png",[4,e.loadImage(c)]):[3,4];case 3:return u=h.sent(),o.push([u,u,u,u,u,u]),[3,2];case 4:return[2,e.Texture.create(n,j({name:"createTextureCubeMipmapFromBuffer",sourceType:e.TextureSourceType.mipmaps,mipmaps:o,target:e.glContext.TEXTURE_CUBE_MAP},a.cubemapMipTexConfig))]}}))}))()},t.getTexture=function(e,t){return e<0||e>=t.length?null:t[e]},t.createTextureFromImage=function(t,n){var r={name:"createTextureFromImage",image:n,sourceType:e.TextureSourceType.image,flipY:!1,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR,wrapT:e.glContext.REPEAT,wrapS:e.glContext.REPEAT};return e.Texture.create(t,r)},t.deleteTexture=function(e){e.dispose()},t.deleteMesh=function(t){t.dispose({geometries:e.DestroyOptions.destroy})},t.deleteGeometry=function(e){e.dispose()},t.deleteRenderPass=function(t){t.dispose({meshes:{geometries:e.DestroyOptions.destroy},depthStencilAttachment:e.RenderPassDestroyAttachmentType.force,colorAttachment:e.RenderPassDestroyAttachmentType.force})},t.isTransparentMesh=function(e){return!0===e.material.blending},t.isSupportFloatTexture=function(e){return 0!==e.gpuCapability.detail.floatTexture},t.isSupportHalfFloatTexture=function(e){return 0!==e.gpuCapability.detail.halfFloatTexture},t.isPow2=function(e){return!(e&e-1||!e)},t}();Oe.cubemapTexConfig={name:"cubemap texture",wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR},Oe.cubemapMipTexConfig={wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR_MIPMAP_LINEAR};var Fe,De,Ue,Be=function(){function t(){}return t.createFilterMesh=function(n,r,i){var o=Y.getInstance(),a=i.vertexShaderCode,s=i.fragmentShaderCode,l=e.Geometry.create(n,t.getPlaneGeometry()),c=2===n.gpuCapability.level,u=e.Material.create(n,{shader:{vertex:a,fragment:s,shared:o.shaderShared,glslVersion:c?e.GLSLVersion.GLSL3:e.GLSLVersion.GLSL1}});return i.setMaterialStates(u),e.Mesh.create(n,{name:r,worldMatrix:R.fromIdentity(),material:u,geometry:l})},t.getPlaneGeometry=function(){var n=t.getPlaneVertexArray();return{attributes:{aPos:{type:e.glContext.FLOAT,size:3,data:n,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:0},aUV:{type:e.glContext.FLOAT,size:2,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:3*Float32Array.BYTES_PER_ELEMENT,dataSource:"aPos"},aNormal:{type:e.glContext.FLOAT,size:3,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:5*Float32Array.BYTES_PER_ELEMENT,dataSource:"aPos"}},drawStart:0,drawCount:n.length/8}},t.getPlaneVertexArray=function(){return new Float32Array([-1,-1,0,0,0,0,0,1,1,-1,0,1,0,0,0,1,1,1,0,1,1,0,0,1,-1,-1,0,0,0,0,0,1,1,1,0,1,1,0,0,1,-1,1,0,0,1,0,0,1])},t}(),ke=function(){function t(){}return t.createLightOptions=function(e){var t,n,r,i,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!=(r=e.range)?r:0}:"spot"===e.type?{color:c,intensity:null!=(i=e.intensity)?i: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"}},t.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}}},t.toPlayerColor3=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2])]},t.toPlayerColor4=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2]),this.scaleTo255(e[3])]},t.toPluginColor3=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2])]},t.toPluginColor4=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2]),this.scaleTo1(e[3])]},t.createUVTransform=function(e,t,n){var r=e.getVector4(t),i=e.getFloat(n),o=P.fromIdentity();r&&o.setFromArray([1,0,0,0,1,0,r.z,r.w,1]);var a=new P;if(i){var s=Math.cos(i),l=Math.sin(i);a.setFromArray([s,l,0,-l,s,0,0,0,1]),o.multiply(a)}return r&&(a.setFromArray([r.x,0,0,0,r.y,0,0,0,1]),o.multiply(a)),o.transpose(),o},t.clamp=function(e,t,n){return Math.max(Math.min(e,n),t)},t.scaleTo255=function(e){var t=Math.round(255*e);return Math.max(0,Math.min(t,255))},t.scaleTo1=function(e){var t=e/255;return Math.max(0,Math.min(t,1))},t.focusOnPoint=function(t,n,r){var i=N.fromArray(t),o=N.fromArray(r),a=(new N).copyFrom(i).subtract(o);R.fromRotationAxis(new N(0,1,0),n*G).transformPoint(a);var s=a.clone().add(o),l=(new R).lookAt(s,o,new N(0,1,0)).invert(),c=new e.Transform;return c.setValid(!0),c.cloneFromMatrix(l),c},t.preprocessScene=function(t,n,r){var i=this,o=n!==e.PLAYER_OPTIONS_ENV_EDITOR,a="tiny3d"===r,s=t.jsonScene;if(!(s&&s.textures&&s.materials))return{};var l={};t.textureOptions.forEach((function(e){var t=e.id;t&&(l[t]=e)}));var c=!1;return o&&(s.materials.forEach((function(e){i.preprocessTextureOptions(l,e.textures._BaseColorSampler,!0,a),i.preprocessTextureOptions(l,e.textures._MetallicRoughnessSampler,!1,a),i.preprocessTextureOptions(l,e.textures._NormalSampler,!1,a),i.preprocessTextureOptions(l,e.textures._OcclusionSampler,!1,a),i.preprocessTextureOptions(l,e.textures._EmissiveSampler,!1,a)})),s.components.forEach((function(t){if(t.dataType===e.spec.DataType.SkyboxComponent){c=!0;var n=t;n.diffuseImage&&i.preprocessTextureOptions(l,n.diffuseImage,!1,a),n.specularImage&&i.preprocessTextureOptions(l,n.specularImage,!1,a)}}))),{loadSkybox:c}},t.preprocessTextureOptions=function(t,n,r,i){var o;if(i&&n&&(o="texture"in n?n.texture.id:n.id)){var a=t[o];if(a)if(void 0===a.target||a.target===e.glContext.TEXTURE_2D){a.wrapS=e.glContext.REPEAT,a.wrapT=e.glContext.REPEAT,a.magFilter=e.glContext.LINEAR,a.minFilter=e.glContext.LINEAR_MIPMAP_LINEAR,r||(a.premultiplyAlpha=!0);var s=a;s.generateMipmap=!0;var l=s.image;l&&l.width&&l.height&&(Oe.isPow2(l.width)&&Oe.isPow2(l.height)||(a.minFilter=e.glContext.LINEAR))}else a.target===e.glContext.TEXTURE_CUBE_MAP&&(a.wrapS=e.glContext.CLAMP_TO_EDGE,a.wrapT=e.glContext.CLAMP_TO_EDGE,void 0!==a.mipmaps?1===a.mipmaps.length?(a.magFilter=e.glContext.LINEAR,a.minFilter=e.glContext.LINEAR):(a.magFilter=e.glContext.LINEAR,a.minFilter=e.glContext.LINEAR_MIPMAP_LINEAR):(a.magFilter=e.glContext.LINEAR,a.minFilter=e.glContext.LINEAR))}},t.createGeometry=function(t,n,r){var i=$(n,r),o={};for(var a in i.attributes){var s=i.attributes[a];o[this.getAttributeName(a)]=s}return i.attributes=o,e.Geometry.create(t,i)},t.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+".")}},t.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},t.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])},t}(),Ve=function(){function t(){}return t.getImageFileName=function(e,t){var n=e.lastIndexOf("/"),r=e.lastIndexOf("."),i=e.substring(n+1,r);return t?i+t:i},t.getCurrnetTimeStr=function(){var e=new Date(Date.now()),t=e.toLocaleString("zh-CN"),n=""+e.getMilliseconds();return t.split(/[ /:]+/).join("")+n.padStart(3,"0")},t.saveFileForURL=function(e,t){var n=document.createElement("a");n.setAttribute("download",t),n.target="_blank",n.href=e,n.click()},t.createPlayer=function(t){void 0===t&&(t=!0);var n=document.createElement("canvas");return n.width=512,n.height=512,new e.Player({canvas:n,renderFramework:"webgl2",env:e.PLAYER_OPTIONS_ENV_EDITOR,renderOptions:{willCaptureImage:!0},manualRender:t})},t.sleep=function(e){return o((function(){return p(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))()},t.loadImageFromGLTFImage=function(t){return o((function(){return p(this,(function(n){return[2,e.loadImage(new Blob([t.imageData],{type:t.mimeType}))]}))}))()},t.loadImageFromImageData=function(t){return o((function(){return p(this,(function(n){return[2,e.loadImage(new Blob([t.data],{type:t.mimeType}))]}))}))()},t.getCanvasArrayBuffer=function(e){return o((function(){return p(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)}))]}))}))()},t.getImageArrayBuffer=function(e){var t=this;return o((function(){var n;return p(this,(function(r){return(n=document.createElement("canvas")).width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0),[2,t.getCanvasArrayBuffer(n)]}))}))()},t.getCanvasImageData=function(e){return e.getContext("2d").getImageData(0,0,e.width,e.height)},t.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)},t.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))},t.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},t}(),Ge=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 N;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}(),ze=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,r;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!=(r=e.stride)?r: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 r=0;r<this.compCount;r++)n[r]*=this.compressScale,this.signed&&(n[r]=Math.max(n[r],-1));return n}},t.getLength=function(){return Math.round((this.length-this.offset)/this.stride)},e}(),He=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 r=n.aPos,i=e.getAttributeData("aPos");this.position=new ze,this.position.create(r,i);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 ze,this.joint.create(o,s),this.weight=new ze,this.weight.create(a,l)}this.bindMatrices=t},t.getBoundingBox=function(e){var t=this;e.makeEmpty();var n=new R,r=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0,i=new Set;if(void 0!==this.index)for(var o=0;o<this.drawCount;o++){var a=this.drawStart+o;a<this.index.length&&i.add(this.index[a])}else for(var s=0;s<this.drawCount;s++)i.add(this.drawStart+s);return i.forEach((function(i){var o=t.position.getData(i);if(void 0!==o){var a=N.fromArray(o);if(r){var s,l,c=null==(s=t.joint)?void 0:s.getData(i),u=null==(l=t.weight)?void 0:l.getData(i);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 p=n.transformVector4(new L(a.x,a.y,a.z,1));Math.abs(p.w)>1e-4&&(p.multiply(1/p.w),a.set(p.x,p.y,p.z))}}}e.expandByPoint(a)}})),e},e}(),je=function(){function e(){this.drawStart=0,this.drawCount=0,this.doubleSided=!1,this.bindMatrices=[],this.hasAnimation=!1,this.skinMatrix=new R}var t=e.prototype;return t.create=function(e,t,n){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var r=e.attributes;this.index=e.getIndexData();var i=r.aPos,o=e.getAttributeData("aPos");this.position=new ze,this.position.create(i,o);var a=r.aJoints,s=r.aWeights;if(void 0!==a&&void 0!==s){var l=e.getAttributeData("aJoints"),c=e.getAttributeData("aWeights");this.joint=new ze,this.joint.create(a,l),this.weight=new ze,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,r=new N,i=new N,o=new N,a=new L,s=new L,l=new L,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 p=this.getPosition(h,r,a),m=this.getPosition(f,i,s),g=this.getPosition(d,o,l);if(p&&m&&g){var v=Re(e,t,p,m,g,c);void 0!==v&&(void 0===n||n>v)&&(n=v)}}return n},t.getPosition=function(e,t,n){var r=this.position.getData(e);if(void 0===r)return null;if(this.hasAnimation){var i,o,a=null==(i=this.joint)?void 0:i.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(r[0],r[1],r[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(r[0],r[1],r[2]);return t},e}(),We=function(){function t(){}return t.checkNumber=function(e){return"number"==typeof e},t.checkNumberUndef=function(e){return void 0===e||this.checkNumber(e)},t.checkNumber01=function(e){return this.checkNumber(e)&&e>=0&&e<=1},t.checkNumber01Undef=function(e){return void 0===e||this.checkNumber01(e)},t.checkPositive=function(e){return this.checkNumber(e)&&e>0},t.checkNonnegative=function(e){return this.checkNumber(e)&&e>=0},t.checkNonnegativeUndef=function(e){return void 0===e||this.checkNonnegative(e)},t.checkBoolean=function(e){return"boolean"==typeof e},t.checkBooleanUndef=function(e){return void 0===e||this.checkBoolean(e)},t.checkString=function(e){return"string"==typeof e},t.checkStringUndef=function(e){return void 0===e||this.checkString(e)},t.checkFloat32Array=function(e){return l(e,Float32Array)},t.checkFloat32ArrayUndef=function(e){return void 0===e||this.checkFloat32Array(e)},t.checkParent=function(e){return void 0===e||!!this.checkNumber(e)&&e>=0},t.checkTexCoord=function(e){return void 0===e||!!this.checkNumber(e)&&(e>=0&&e<=1)},t.checkVec2=function(e){var t=this;return!!Array.isArray(e)&&(2==e.length&&e.every((function(e){return t.checkNumber(e)})))},t.checkVec2Undef=function(e){return void 0===e||this.checkVec2(e)},t.checkVec3=function(e){var t=this;return!!Array.isArray(e)&&(3==e.length&&e.every((function(e){return t.checkNumber(e)})))},t.checkNonnegative3=function(e){var t=this;return!!Array.isArray(e)&&(3==e.length&&e.every((function(e){return t.checkNonnegative(e)})))},t.checkVec4=function(e){var t=this;return!!Array.isArray(e)&&(4==e.length&&e.every((function(e){return t.checkNumber(e)})))},t.checkNonnegative4=function(e){var t=this;return!!Array.isArray(e)&&(4==e.length&&e.every((function(e){return t.checkNonnegative(e)})))},t.checkNumberArray=function(e){var t=this;return!!Array.isArray(e)&&e.every((function(e){return t.checkNumber(e)}))},t.checkTexture=function(t){return!!l(t,e.Texture)&&(t.isDestroyed&&console.error("Texture is destroyed, "+t.name+"."),!t.isDestroyed)},t.checkTextureUndef=function(e){return void 0===e||this.checkTexture(e)},t.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))))},t.checkTexTransformUndef=function(e){return void 0===e||this.checkTexTransform(e)},t.checkMatBlending=function(t){return void 0===t||t===e.spec.MaterialBlending.opaque||t===e.spec.MaterialBlending.masked||t===e.spec.MaterialBlending.translucent||t===e.spec.MaterialBlending.additive},t.checkMatSide=function(t){return void 0===t||t===e.spec.SideMode.BACK||t===e.spec.SideMode.DOUBLE||t===e.spec.SideMode.FRONT},t.checkAnimPath=function(e){return"translation"===e||"rotation"===e||"scale"===e||"weights"===e},t.checkAnimInterp=function(e){return"LINEAR"===e||"STEP"===e||"CUBICSPLINE"===e},t.assertGeometry=function(t,n){l(t,e.Geometry)||console.error("Invalid geometry type "+this.stringify(t)+"."),!0===t.isDestroyed&&console.error("Geometry object is destroyed."),this.checkNonnegative(t.getDrawStart())||console.error("Invalid geometry draw start: "+t.getDrawStart()+", "+this.stringify(t)+".")},t.assertGeometryBuffer=function(e,t,n){var r=this.createAttributeArray(e,t);void 0!==r&&r.getLength()<n&&console.error(t+" Length("+r.getLength()+") is less than draw count("+n+"), "+this.stringify(e)+".")},t.createAttributeArray=function(e,t){var n=e.attributes;if(void 0!==n){var r=n[t];if(void 0!==r){var i=e.getAttributeData(t);if(void 0!==i){var o=new ze;return o.create(r,i),o}}}},t.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 R,n=0;n<e.inverseBindMatrices.length;n+=16){for(var r=0;r<16;r++)t.elements[r]=e.inverseBindMatrices[n+r];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)+".")},t.assertMatOptions=function(t){t.type===e.spec.MaterialType.unlit?(this.checkString(t.name)||console.error("Invalid material name "+t.name+", "+this.stringify(t)+"."),this.checkNonnegative4(t.baseColorFactor)||console.error("Invalid material baseColorFactor "+t.baseColorFactor+", "+this.stringify(t)+"."),this.checkTextureUndef(t.baseColorTexture)||console.error("Invalid material baseColorTexture "+t.baseColorTexture+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform "+t.baseColorTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate "+t.baseColorTextureCoordinate+", "+this.stringify(t)+"."),this.checkBooleanUndef(t.depthMask)||console.error("Invalid material depthMask "+t.depthMask+", "+this.stringify(t)+"."),this.checkMatBlending(t.blending)||console.error("Invalid material blending "+t.blending+", "+this.stringify(t)+"."),this.checkMatSide(t.side)||console.error("Invalid material side "+t.side+", "+this.stringify(t)+"."),t.blending===e.spec.MaterialBlending.masked&&void 0===t.alphaCutOff&&console.error("Material alphaCutOff is required for mask, "+this.stringify(t)+"."),this.checkNumber01Undef(t.alphaCutOff)||console.error("Invalid material alphaCutOff "+t.alphaCutOff+", "+this.stringify(t)+".")):t.type===e.spec.MaterialType.pbr?(this.checkString(t.name)||console.error("Invalid material name "+t.name+", "+this.stringify(t)+"."),this.checkNonnegative4(t.baseColorFactor)||console.error("Invalid material baseColorFactor "+t.baseColorFactor+", "+this.stringify(t)+"."),this.checkTextureUndef(t.baseColorTexture)||console.error("Invalid material baseColorTexture "+t.baseColorTexture+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform "+t.baseColorTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate "+t.baseColorTextureCoordinate+", "+this.stringify(t)+"."),this.checkBooleanUndef(t.useSpecularAA)||console.error("Invalid material useSpecularAA "+t.useSpecularAA+", "+this.stringify(t)+"."),this.checkNumber01(t.metallicFactor)||console.error("Invalid material metallicFactor "+t.metallicFactor+", "+this.stringify(t)+"."),this.checkNonnegative(t.roughnessFactor)||console.error("Invalid material roughnessFactor "+t.roughnessFactor+", "+this.stringify(t)+"."),this.checkTextureUndef(t.metallicRoughnessTexture)||console.error("Invalid material metallicRoughnessTexture "+t.metallicRoughnessTexture+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.metallicRoughnessTextureTransform)||console.error("Invalid material metallicRoughnessTextureTransform "+t.metallicRoughnessTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.metallicRoughnessTextureCoordinate)||console.error("Invalid material metallicRoughnessTextureCoordinate "+t.metallicRoughnessTextureCoordinate+", "+this.stringify(t)+"."),this.checkTextureUndef(t.normalTexture)||console.error("Invalid material normalTexture "+t.normalTexture+", "+this.stringify(t)+"."),this.checkNonnegativeUndef(t.normalTextureScale)||console.error("Invalid material normalTextureScale "+t.normalTextureScale+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.normalTextureTransform)||console.error("Invalid material normalTextureTransform "+t.normalTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.normalTextureCoordinate)||console.error("Invalid material normalTextureCoordinate "+t.normalTextureCoordinate+", "+this.stringify(t)+"."),this.checkTextureUndef(t.occlusionTexture)||console.error("Invalid material occlusionTexture "+t.occlusionTexture+", "+this.stringify(t)+"."),this.checkNumber01Undef(t.occlusionTextureStrength)||console.error("Invalid material occlusionTextureStrength "+t.occlusionTextureStrength+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.occlusionTextureTransform)||console.error("Invalid material occlusionTextureTransform "+t.occlusionTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.occlusionTextureCoordinate)||console.error("Invalid material occlusionTextureCoordinate "+t.occlusionTextureCoordinate+", "+this.stringify(t)+"."),this.checkNonnegative4(t.emissiveFactor)||console.error("Invalid material emissiveFactor "+t.emissiveFactor+", "+this.stringify(t)+"."),this.checkNonnegative(t.emissiveIntensity)||console.error("Invalid material emissiveIntensity "+t.emissiveIntensity+", "+this.stringify(t)+"."),this.checkTextureUndef(t.emissiveTexture)||console.error("Invalid material emissiveTexture "+t.emissiveTexture+", "+this.stringify(t)+"."),this.checkTexTransformUndef(t.emissiveTextureTransform)||console.error("Invalid material emissiveTextureTransform "+t.emissiveTextureTransform+", "+this.stringify(t)+"."),this.checkTexCoord(t.emissiveTextureCoordinate)||console.error("Invalid material emissiveTextureCoordinate "+t.emissiveTextureCoordinate+", "+this.stringify(t)+"."),this.checkBooleanUndef(t.depthMask)||console.error("Invalid material depthMask "+t.depthMask+", "+this.stringify(t)+"."),this.checkMatBlending(t.blending)||console.error("Invalid material blending "+t.blending+", "+this.stringify(t)+"."),this.checkMatSide(t.side)||console.error("Invalid material side "+t.side+", "+this.stringify(t)+"."),t.blending===e.spec.MaterialBlending.masked&&void 0===t.alphaCutOff&&console.error("Material alphaCutOff is required for mask, "+this.stringify(t)+"."),this.checkNumber01Undef(t.alphaCutOff)||console.error("Invalid material alphaCutOff "+t.alphaCutOff+", "+this.stringify(t)+".")):console.error("Invalid material type "+this.stringify(t)+".")},t.assertPrimOptions=function(e,t){return this.assertGeometry(e.geometry,t),this.assertMatOptions(e.material),!0},t.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 r=e.primitives[n];this.assertPrimOptions(r)||console.error("Invalid primitive "+r+", "+this.stringify(e)+".");var i=new Ke;i.create(r.geometry),t.push(i)}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)+".")},t.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)+".")},t.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)+".")},t.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)+".")},t.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)},t.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)+".")}))},t.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)+"."))},t.stringify=function(t){var n={};for(var r in t)"internal"!==r&&"function"!=typeof t[r]&&(l(t[r],e.Texture)||l(t[r],e.Geometry)?n[r]=t[r].name:l(t[r],e.Renderer)||(n[r]=t[r]));return JSON.stringify(n)},t.pow2=function(e){for(var t=1;e-- >0;)t*=2;return t},t}(),Je=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]=Xe(e[n])},H(e,[{key:"bytes",get:function(){return 2*this.size}}]),e}(),Xe=(Fe=new Float32Array(1),De=new Int32Array(Fe.buffer),function(e){Fe[0]=e;var t=De[0],n=t>>16&32768,r=t>>12&2047,i=t>>23&255;return i<103?n:i>142?(n|=31744,n|=(255==i?0:1)&&8388607&t):i<113?n|=((r|=2048)>>114-i)+(r>>113-i&1):(n|=i-112<<10|r>>1,n+=1&r)});exports.TextureDataMode=void 0,(Ue=exports.TextureDataMode||(exports.TextureDataMode={}))[Ue.none=0]="none",Ue[Ue.float=1]="float",Ue[Ue.half_float=2]="half_float";var qe,Ye,Ze=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}s(t,e);var n=t.prototype;return n.create=function(e,t,n,r){var i;this.name=null!=(i=e.rootBoneName)?i:"Unnamed skin",this.type=exports.PObjectType.skin,this.rootBoneItem=n,this.skeleton=-1,this.jointItem=this.getJointItems(e,n),this.maxJointCount=Math.max(r,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=R.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 r=e.clone().invert(),i=new R;this.animationMatrices.forEach((function(e,o){var a=i.multiplyMatrices(r,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,r=n.maxVertexUniforms-25;if(e>Math.floor(r/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,r=this.genNodeName(t),i=[];return null==(n=e.boneNames)||n.forEach((function(e){var t=r[e];if(!t)throw new Error("Can't find node of bone name "+e+".");i.push(t)})),i},n.genNodeName=function(e){var t={},n=[];t[""]=e;for(var r,i=b(e.children);!(r=i()).done;){var o=r.value;this.genNodeNameDFS(o,n,t)}return t},n.genNodeNameDFS=function(e,t,n){t.push(e.name),n[t.join("/")]=e;for(var r,i=b(e.children);!(r=i()).done;){var o=r.value;this.genNodeNameDFS(o,t,n)}t.pop()},t}(K),Ke=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}s(t,e);var n=t.prototype;return n.create=function(e){var n=this;this.name=this.genName("Morph target"),this.type=exports.PObjectType.morph;var r=this.getAttributeMorphCount(t.positionNameList,e),i=this.getAttributeMorphCount(t.normalNameList,e),o=this.getAttributeMorphCount(t.tangentNameList,e),a=[r,i,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=r==this.morphWeightsLength,this.hasNormalMorph=i==this.morphWeightsLength,this.hasTangentMorph=o==this.morphWeightsLength),r>0&&r!=this.morphWeightsLength?(console.error("Position morph count mismatch: "+this.morphWeightsLength+", "+r+"."),!1):i>0&&i!=this.morphWeightsLength?(console.error("Normal morph count mismatch: "+this.morphWeightsLength+", "+i+"."),!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 r=e[n];if(void 0===t.getAttributeData(r))return n}return e.length},t}(K);Ke.positionNameList=["aTargetPosition0","aTargetPosition1","aTargetPosition2","aTargetPosition3","aTargetPosition4","aTargetPosition5","aTargetPosition6","aTargetPosition7"],Ke.normalNameList=["aTargetNormal0","aTargetNormal1","aTargetNormal2","aTargetNormal3","aTargetNormal4","aTargetNormal5","aTargetNormal6","aTargetNormal7"],Ke.tangentNameList=["aTargetTangent0","aTargetTangent1","aTargetTangent2","aTargetTangent3","aTargetTangent4","aTargetTangent5","aTargetTangent6","aTargetTangent7"],exports.PAnimInterpType=void 0,(qe=exports.PAnimInterpType||(exports.PAnimInterpType={}))[qe.linear=0]="linear",qe[qe.step=1]="step",qe[qe.cubicSpline=2]="cubicSpline",exports.PAnimPathType=void 0,(Ye=exports.PAnimPathType||(exports.PAnimPathType={}))[Ye.translation=0]="translation",Ye[Ye.rotation=1]="rotation",Ye[Ye.scale=2]="scale",Ye[Ye.weights=3]="weights";var Qe=function(){function t(e){this.engine=e,this.isHalfFloat=!0,this.width=0,this.height=0}var n=t.prototype;return n.create=function(t,n,r){var i,o;this.width=4,this.height=t,this.isHalfFloat=n,this.isHalfFloat&&(this.buffer=new Je(4*this.getSize()));var a=null!=(o=null==(i=this.buffer)?void 0:i.data)?o:new Float32Array(4*this.getSize()),s=this.isHalfFloat?e.glContext.HALF_FLOAT:e.glContext.FLOAT;this.texture=e.Texture.create(this.engine,{name:r,data:{width:this.width,height:this.height,data:a},target:e.glContext.TEXTURE_2D,format:e.glContext.RGBA,type:s,wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,minFilter:e.glContext.NEAREST,magFilter:e.glContext.NEAREST})},n.update=function(t){var n,r;(void 0!==this.buffer&&this.buffer.set(t,0),void 0!==this.texture)&&this.texture.updateSource({sourceType:e.TextureSourceType.data,data:{width:this.width,height:this.height,data:null!=(r=null==(n=this.buffer)?void 0:n.data)?r:t},target:e.glContext.TEXTURE_2D})},n.dispose=function(){var e;this.engine=null,this.buffer=void 0,null==(e=this.texture)||e.dispose()},n.getSize=function(){return this.width*this.height},n.getTexture=function(){return this.texture},t}(),$e=function(){function e(){this.funcMap=new Map,this.funcMap.set(exports.PMaterialType.unlit,ve),this.funcMap.set(exports.PMaterialType.pbr,ve),this.funcMap.set(exports.PMaterialType.shadowBase,ye),this.funcMap.set(exports.PMaterialType.shadowFilter,_e),this.funcMap.set(exports.PMaterialType.normalVis,xe),this.funcMap.set(exports.PMaterialType.simpleFilter,be),this.funcMap.set(exports.PMaterialType.skyboxFilter,Te)}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}(),et=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).materialType=exports.PMaterialType.none,n.vertexShaderCode="",n.fragmentShaderCode="",n.ZWrite=!0,n.ZTest=!0,n.renderType=e.spec.RenderType.Opaque,n.alphaClip=!1,n.alphaCutoff=.5,n.renderFace=e.spec.RenderFace.Front,n}s(n,t);var r=n.prototype;return r.getShaderFeatures=function(){var t=[];return this.isAlphaClip()?t.push("ALPHAMODE_MASK 1"):this.isOpaque()&&t.push("ALPHAMODE_OPAQUE 1"),this.renderFace===e.spec.RenderFace.Both&&t.push("DOUBLE_SIDED 1"),t},r.getShaderMacros=function(){var t=[];return this.isAlphaClip()?t.push({name:"ALPHAMODE_MASK"}):this.isOpaque()&&t.push({name:"ALPHAMODE_OPAQUE"}),this.renderFace===e.spec.RenderFace.Both&&t.push({name:"DOUBLE_SIDED"}),t},r.updateUniforms=function(t){if(Y.getInstance().renderMode3D===e.spec.RenderMode3D.uv){var n=Y.getInstance().renderMode3DUVGridSize;t.setFloat("_DebugUVGridSize",n)}},r.build=function(e){var t=this.getFeatureList(e),n=Y.getInstance().isWebGL2,r=$e.getInstance().genShaderCode({material:this,isWebGL2:n,featureList:t});this.vertexShaderCode=r.vertexShaderCode,this.fragmentShaderCode=r.fragmentShaderCode},r.getFeatureList=function(e){var t,n=this.getShaderFeatures();void 0!==e&&(t=n).push.apply(t,[].concat(e));this.materialType!==exports.PMaterialType.shadowBase&&(Y.getInstance().isEditorEnv&&n.push("EDITOR_TRANSFORM"));return n},r.getMacroList=function(e){var t,n=this.getShaderMacros();void 0!==e&&(t=n).push.apply(t,[].concat(e));this.materialType!==exports.PMaterialType.shadowBase&&(Y.getInstance().isEditorEnv&&n.push({name:"EDITOR_TRANSFORM"}));return n},r.setMaterialStates=function(t){this.renderType===e.spec.RenderType.Transparent?(t.blending=!0,t.depthTest=this.ZTest,t.depthMask=this.ZWrite,t.blendEquation=[e.glContext.FUNC_ADD,e.glContext.FUNC_ADD],t.blendFunction=[e.glContext.ONE,e.glContext.ONE_MINUS_SRC_ALPHA,e.glContext.ONE,e.glContext.ONE_MINUS_SRC_ALPHA]):Y.getInstance().isTiny3dMode?(t.blending=!1,t.depthTest=!0,t.depthMask=!0):(t.blending=!1,t.depthTest=this.ZTest,t.depthMask=this.ZWrite),this.setFaceSideStates(t)},r.setFaceSideStates=function(t){this.isBothSide()?t.culling=!1:this.isBackSide()?(t.cullFace=e.glContext.FRONT,t.frontFace=e.glContext.CCW,t.culling=!0):(t.cullFace=e.glContext.BACK,t.frontFace=e.glContext.CCW,t.culling=!0)},r.dispose=function(){this.vertexShaderCode="",this.fragmentShaderCode=""},r.isValid=function(){return this.materialType!==exports.PMaterialType.none&&t.prototype.isValid.call(this)},r.isOpaque=function(){return this.renderType===e.spec.RenderType.Opaque},r.isAlphaClip=function(){return this.alphaClip},r.isTransparent=function(){return this.renderType===e.spec.RenderType.Transparent},r.isFrontSide=function(){return this.renderFace===e.spec.RenderFace.Front},r.isBackSide=function(){return this.renderFace===e.spec.RenderFace.Back},r.isBothSide=function(){return this.renderFace===e.spec.RenderFace.Both},n}(K),tt=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).baseColorFactor=new O(1,1,1,1),e}s(n,t);var r=n.prototype;return r.create=function(t){var n,r,i,o,a;this.effectMaterial=t,this.name=t.name,this.type=exports.PObjectType.material,this.materialType=exports.PMaterialType.unlit,this.baseColorTexture=null!=(n=t.getTexture("_BaseColorSampler"))?n:void 0,this.baseColorTextureTrans=ke.createUVTransform(t,"_BaseColorSampler_ST","_BaseColorRotation"),this.baseColorFactor=null!=(r=t.getColor("_BaseColorFactor"))?r:new O(1,1,1,1),this.ZWrite=0!==t.getFloat("ZWrite"),this.ZTest=0!==t.getFloat("ZTest"),this.renderType=null!=(i=t.stringTags.RenderType)?i:e.spec.RenderType.Opaque,this.alphaClip=1===t.getFloat("AlphaClip"),this.alphaCutoff=null!=(o=t.getFloat("_AlphaCutoff"))?o:0,this.renderFace=null!=(a=t.stringTags.RenderFace)?a:e.spec.RenderFace.Front},r.dispose=function(){t.prototype.dispose.call(this),this.baseColorTexture=void 0},r.getShaderFeatures=function(){var e=t.prototype.getShaderFeatures.call(this);return e.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&e.push("HAS_BASE_COLOR_MAP 1"),e.push("MATERIAL_UNLIT 1"),e},r.getShaderMacros=function(){var e=t.prototype.getShaderMacros.call(this);return e.push({name:"MATERIAL_METALLICROUGHNESS"}),this.hasBaseColorTexture()&&e.push({name:"HAS_BASE_COLOR_MAP"}),e.push({name:"MATERIAL_UNLIT"}),e},r.updateUniforms=function(e){t.prototype.updateUniforms.call(this,e),void 0!==this.baseColorTexture&&(e.setInt("_BaseColorUVSet",0),e.setMatrix3("_BaseColorUVTransform",this.baseColorTextureTrans)),e.setFloat("_MetallicFactor",0),e.setFloat("_RoughnessFactor",0),e.setFloat("_Exposure",1)},r.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},r.getBaseColorTexture=function(){return this.baseColorTexture},r.setBaseColorTexture=function(e){this.baseColorTexture=e},r.getBaseColorFactor=function(){return this.baseColorFactor},r.setBaseColorFactor=function(e){l(e,O)?this.baseColorFactor.set(e.r,e.g,e.b,e.a):l(e,L)?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},n}(et),nt=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).baseColorFactor=new O(1,1,1,1),e.useSpecularAA=!1,e.metallicFactor=0,e.roughnessFactor=1,e.normalTextureScale=1,e.occlusionTextureStrength=1,e.emissiveFactor=new O(0,0,0,0),e.emissiveIntensity=1,e}s(n,t);var r=n.prototype;return r.create=function(t){var n,r,i,o,a,s,l,c,u,h,f,d,p,m,g;this.effectMaterial=t,this.name=t.name,this.type=exports.PObjectType.material,this.materialType=exports.PMaterialType.pbr,this.baseColorTexture=null!=(n=t.getTexture("_BaseColorSampler"))?n:void 0,this.baseColorTextureTrans=ke.createUVTransform(t,"_BaseColorSampler_ST","_BaseColorRotation"),this.baseColorFactor=null!=(r=t.getColor("_BaseColorFactor"))?r:new O(1,1,1,1),this.metallicRoughnessTexture=null!=(i=t.getTexture("_MetallicRoughnessSampler"))?i:void 0,this.metallicRoughnessTextureTrans=ke.createUVTransform(t,"_MetallicRoughnessSampler_ST","_MetallicRoughnessRotation"),this.useSpecularAA=1===t.getFloat("_SpecularAA"),this.metallicFactor=null!=(o=t.getFloat("_MetallicFactor"))?o:1,this.roughnessFactor=null!=(a=t.getFloat("_RoughnessFactor"))?a:0,this.normalTexture=null!=(s=t.getTexture("_NormalSampler"))?s:void 0,this.normalTextureTrans=ke.createUVTransform(t,"_NormalSampler_ST","_NormalRotation"),this.normalTextureScale=null!=(l=t.getFloat("_NormalScale"))?l:1,this.occlusionTexture=null!=(c=t.getTexture("_OcclusionSampler"))?c:void 0,this.occlusionTextureTrans=ke.createUVTransform(t,"_OcclusionSampler_ST","_OcclusionRotation"),this.occlusionTextureStrength=null!=(u=t.getFloat("_OcclusionStrength"))?u:1,this.emissiveTexture=null!=(h=t.getTexture("_EmissiveSampler"))?h:void 0,this.emissiveTextureTrans=ke.createUVTransform(t,"_EmissiveSampler_ST","_EmissiveRotation"),this.emissiveFactor=null!=(f=t.getColor("_EmissiveFactor"))?f:new O(0,0,0,1),this.emissiveIntensity=null!=(d=t.getFloat("_EmissiveIntensity"))?d:1,this.ZWrite=0!==t.getFloat("ZWrite"),this.ZTest=0!==t.getFloat("ZTest"),this.renderType=null!=(p=t.stringTags.RenderType)?p:e.spec.RenderType.Opaque,this.alphaClip=1===t.getFloat("AlphaClip"),this.alphaCutoff=null!=(m=t.getFloat("_AlphaCutoff"))?m:0,this.renderFace=null!=(g=t.stringTags.RenderFace)?g:e.spec.RenderFace.Front},r.dispose=function(){t.prototype.dispose.call(this),this.baseColorTexture=void 0,this.metallicRoughnessTexture=void 0,this.normalTexture=void 0,this.occlusionTexture=void 0,this.emissiveTexture=void 0},r.getShaderFeatures=function(){var e=t.prototype.getShaderFeatures.call(this);return e.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&(e.push("HAS_BASE_COLOR_MAP 1"),void 0!==this.baseColorTextureTrans&&e.push("HAS_BASECOLOR_UV_TRANSFORM 1")),this.hasMetallicRoughnessTexture()&&(e.push("HAS_METALLIC_ROUGHNESS_MAP 1"),void 0!==this.metallicRoughnessTextureTrans&&e.push("HAS_METALLICROUGHNESS_UV_TRANSFORM 1")),this.useSpecularAA&&e.push("USE_SPECULAR_AA 1"),this.hasNormalTexture()&&(e.push("HAS_NORMAL_MAP 1"),void 0!==this.normalTextureTrans&&e.push("HAS_NORMAL_UV_TRANSFORM 1")),this.hasOcclusionTexture()&&(e.push("HAS_OCCLUSION_MAP 1"),void 0!==this.occlusionTextureTrans&&e.push("HAS_OCCLUSION_UV_TRANSFORM 1")),this.hasEmissiveTexture()?(e.push("HAS_EMISSIVE_MAP 1"),void 0!==this.emissiveTextureTrans&&e.push("HAS_EMISSIVE_UV_TRANSFORM 1")):this.hasEmissiveValue()&&e.push("HAS_EMISSIVE 1"),e},r.getShaderMacros=function(){var e=t.prototype.getShaderMacros.call(this);return e.push({name:"MATERIAL_METALLICROUGHNESS"}),this.hasBaseColorTexture()&&(e.push({name:"HAS_BASE_COLOR_MAP"}),void 0!==this.baseColorTextureTrans&&e.push({name:"HAS_BASECOLOR_UV_TRANSFORM"})),this.hasMetallicRoughnessTexture()&&(e.push({name:"HAS_METALLIC_ROUGHNESS_MAP"}),void 0!==this.metallicRoughnessTextureTrans&&e.push({name:"HAS_METALLICROUGHNESS_UV_TRANSFORM"})),this.useSpecularAA&&e.push({name:"USE_SPECULAR_AA"}),this.hasNormalTexture()&&(e.push({name:"HAS_NORMAL_MAP"}),void 0!==this.normalTextureTrans&&e.push({name:"HAS_NORMAL_UV_TRANSFORM"})),this.hasOcclusionTexture()&&(e.push({name:"HAS_OCCLUSION_MAP"}),void 0!==this.occlusionTextureTrans&&e.push({name:"HAS_OCCLUSION_UV_TRANSFORM"})),this.hasEmissiveTexture()?(e.push({name:"HAS_EMISSIVE_MAP"}),void 0!==this.emissiveTextureTrans&&e.push({name:"HAS_EMISSIVE_UV_TRANSFORM"})):this.hasEmissiveValue()&&e.push({name:"HAS_EMISSIVE"}),e},r.updateUniforms=function(e){t.prototype.updateUniforms.call(this,e),void 0!==this.baseColorTexture&&(e.setInt("_BaseColorUVSet",0),e.setMatrix3("_BaseColorUVTransform",this.baseColorTextureTrans)),void 0!==this.metallicRoughnessTexture&&(e.setInt("_MetallicRoughnessUVSet",0),e.setMatrix3("_MetallicRoughnessUVTransform",this.metallicRoughnessTextureTrans)),void 0!==this.normalTexture&&(e.setInt("_NormalUVSet",0),e.setMatrix3("_NormalUVTransform",this.normalTextureTrans)),void 0!==this.occlusionTexture&&(e.setInt("_OcclusionUVSet",0),e.setMatrix3("_OcclusionUVTransform",this.occlusionTextureTrans)),void 0!==this.emissiveTexture&&(e.setInt("_EmissiveUVSet",0),e.setMatrix3("_EmissiveUVTransform",this.emissiveTextureTrans)),e.setFloat("_Exposure",3)},r.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},r.setBaseColorTexture=function(e){this.baseColorTexture=e},r.getBaseColorFactor=function(){return this.baseColorFactor},r.setBaseColorFactor=function(e){l(e,O)?this.baseColorFactor.set(e.r,e.g,e.b,e.a):l(e,L)?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},r.hasMetallicRoughnessTexture=function(){return void 0!==this.metallicRoughnessTexture},r.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture},r.setMetallicRoughnessTexture=function(e){this.metallicRoughnessTexture=e},r.hasNormalTexture=function(){return void 0!==this.normalTexture},r.getNormalTexture=function(){return this.normalTexture},r.setNormalTexture=function(e){this.normalTexture=e},r.hasOcclusionTexture=function(){return void 0!==this.occlusionTexture},r.getOcclusionTexture=function(){return this.occlusionTexture},r.setOcclusionTexture=function(e){this.occlusionTexture=e},r.hasEmissiveTexture=function(){return void 0!==this.emissiveTexture},r.getEmissiveTexture=function(){return this.emissiveTexture},r.setEmissiveTexture=function(e){this.emissiveTexture=e},r.hasEmissiveValue=function(){return this.emissiveFactor.luminance()*this.emissiveIntensity>0},r.getEmissiveFactor=function(){return this.emissiveFactor},r.setEmissiveFactor=function(e){l(e,O)?this.emissiveFactor.set(e.r,e.g,e.b,e.a):l(e,N)?this.emissiveFactor.set(e.x,e.y,e.z,0):this.emissiveFactor.set(e[0],e[1],e[2],0)},r.getEmissiveIntensity=function(){return this.emissiveIntensity},r.setEmissiveIntensity=function(e){this.emissiveIntensity=e},n}(et);function rt(e){if(e.shader.getInstanceId()===W){var t=new nt;return t.create(e),t}var n=new tt;return n.create(e),n}var it,ot=function(e){function t(t,n,r){var i,o;(i=e.call(this)||this).renderable=!0,i.intensity=1,i.reflectionsIntensity=1,i.specularImageSize=0,i.specularMipCount=0,i.priority=0,i.isBuilt=!1,i.name=t,i.type=exports.PObjectType.skybox,i.visible=!1,i.owner=r;var a=n.irradianceCoeffs;if(i.renderable=n.renderable,i.intensity=n.intensity,i.reflectionsIntensity=n.reflectionsIntensity,a){i.irradianceCoeffs=[];for(var s=0;s<a.length;s+=3)i.irradianceCoeffs.push([a[s],a[s+1],a[s+2]])}else i.irradianceCoeffs=[];return i.diffuseImage=n.diffuseImage,i.specularImage=n.specularImage,i.specularImageSize=n.specularImageSize,i.specularMipCount=n.specularMipCount,i.priority=(null==r||null==(o=r.item)?void 0:o.renderOrder)||0,i}s(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 at,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,R.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,r=t.viewMatrix,i=n.getNewProjectionMatrix(n.fov).multiply(r).invert(),o=this.skyboxMesh.material;this.skyboxMaterial.updateUniforms(o),o.setMatrix("_InvViewProjectionMatrix",i)}},H(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}(Q),at=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).intensity=1,t.reflectionsIntensity=1,t.specularMipCount=0,t}s(t,e);var n=t.prototype;return n.create=function(e){this.type=exports.PObjectType.material,this.materialType=exports.PMaterialType.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 w(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,r){e.setVector3("_shCoefficients."+n,N.fromArray(t[r]))}))}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}(et);exports.PSkyboxType=void 0,(it=exports.PSkyboxType||(exports.PSkyboxType={}))[it.NFT=0]="NFT",it[it.FARM=1]="FARM";var st=function(){function t(){}return t.prototype.checkCubeMapImage=function(t){return o((function(){var n,r,i,o;return p(this,(function(a){switch(a.label){case 0:r=[],i=0,a.label=1;case 1:return i<t.length?[4,e.loadImage(t[i])]:[3,4];case 2:if(o=a.sent(),i>0)if(i%6==0){if(2*o.width!==n.width||2*o.height!==n.height)throw new Error("Invalid cube map list1: index "+i+", image0 "+n+", image1 "+o+".")}else if(o.width!==n.width||o.height!==n.height)throw new Error("Invalid cube map list2: index "+i+", image0 "+n+", image1 "+o+".");i%6==0&&r.push([]),r[r.length-1].push(o),n=o,a.label=3;case 3:return i++,[3,1];case 4:return[2]}}))}))()},t.getBrdfLutTextureOptions=function(){return o((function(){var t;return p(this,(function(n){switch(n.label){case 0:return"https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png",[4,e.loadImage("https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png")];case 1:return t=n.sent(),[2,{name:"brdfLut",wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR,anisotropic:1,sourceType:e.TextureSourceType.image,image:t,generateMipmap:!1,flipY:!1,premultiplyAlpha:!1}]}}))}))()},t.createBrdfLutTexture=function(t){var n=this;return o((function(){var r;return p(this,(function(i){switch(i.label){case 0:return[4,n.getBrdfLutTextureOptions()];case 1:return r=i.sent(),[2,e.Texture.create(t,r)]}}))}))()},t.createSkyboxOptions=function(e,t){var n=this;return o((function(){var r,i,o,a,s,l,c,u;return p(this,(function(h){switch(h.label){case 0:return[4,n.createSpecularCubeMap(e,t)];case 1:return r=h.sent(),[4,n.createDiffuseCubeMap(e,t)];case 2:return i=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:i,specularImage:r,specularImageSize:c,specularMipCount:u}]}}))}))()},t.createSkyboxComponentData=function(n){var r,i,o,a=t.getSpecularCubeMapData(n),s=t.getDiffuseCubeMapData(n),l=n.renderable,c=n.intensity,u=n.reflectionsIntensity,h=n.irradianceCoeffs,f=n.specularImageSize,d=n.specularMipCount,p=[],m=[];s&&((o=p).push.apply(o,[].concat(s.images)),m.push(s.textureOptions),i={id:s.textureOptions.id});(r=p).push.apply(r,[].concat(a.images)),m.push(a.textureOptions);var g={id:a.textureOptions.id};return{imageList:p,textureOptionsList:m,component:{id:e.generateGUID(),dataType:e.spec.DataType.SkyboxComponent,item:{id:e.generateGUID()},renderable:l,intensity:c,reflectionsIntensity:u,irradianceCoeffs:h,diffuseImage:i,specularImage:g,specularImageSize:f,specularMipCount:d}}},t.createSpecularCubeMap=function(e,t){return o((function(){return p(this,(function(n){return"url"===t.type?[2,Oe.createTextureCubeMipmapFromURL(e,t.specularImage)]:[2,Oe.createTextureCubeMipmapFromBuffer(e,t.specularImage,t.specularImageSize)]}))}))()},t.getSpecularCubeMapData=function(t){var n=[],r=[];t.specularImage.forEach((function(t){var i=[];t.forEach((function(t){var r=e.generateGUID();n.push({id:r,url:t}),i.push({id:r})})),r.push(i)}));var i=j({id:e.generateGUID(),dataType:e.spec.DataType.Texture,sourceType:e.TextureSourceType.mipmaps,target:e.glContext.TEXTURE_CUBE_MAP,mipmaps:r},Oe.cubemapMipTexConfig);return{images:n,textureOptions:i}},t.createDiffuseCubeMap=function(e,t){return o((function(){return p(this,(function(n){return void 0===t.diffuseImage?[2,null]:"url"===t.type?[2,Oe.createTextureCubeFromURL(e,t.diffuseImage)]:[2,Oe.createTextureCubeFromBuffer(e,t.diffuseImage)]}))}))()},t.getDiffuseCubeMapData=function(t){if(void 0!==t.diffuseImage){var n=[],r=[];t.diffuseImage.forEach((function(t){var i=e.generateGUID();n.push({id:i,url:t}),r.push({id:i})}));var i=j({id:e.generateGUID(),dataType:e.spec.DataType.Texture,sourceType:e.TextureSourceType.mipmaps,target:e.glContext.TEXTURE_CUBE_MAP,mipmaps:[r]},Oe.cubemapTexConfig);return{images:n,textureOptions:i}}},t.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}},t.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},t.getDiffuseImageList=function(e,t){if(0==e)return t[t.length-1]},t.getSpecularImageList=function(e){var t,n,r=[];1===e?(t=r).push.apply(t,[].concat(this.getSpecularImageListAntFarm())):(n=r).push.apply(n,[].concat(this.getSpecularImageListNFT()));var i=[];return r.forEach((function(e,t){t%6==0&&i.push([]),i[i.length-1].push(e)})),i},t.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"]},t.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"]},t}(),lt=function(){function t(e){this.engine=e,this.loadSkybox=!1,this.meshCache=new Map,this.textureCache=new Map,this.geometryCache=new Map,this.renderPassCache=new Map}var n=t.prototype;return n.setup=function(n){if(this.loadSkybox=n,void 0===this.brdfLutTexture||this.brdfLutTexture.isDestroyed){if(void 0===t.brdfLutTexOptions)throw new Error("Please load brdfLutTexOptions at first.");var r="brdfLutTexture";this.brdfLutTexture=e.Texture.create(this.engine,t.brdfLutTexOptions),this.deleteTexture(r),this.setTexture(r,this.brdfLutTexture)}},n.getTexture=function(e){return this.textureCache.get(e)},n.setTexture=function(e,t){this.textureCache.set(e,t)},n.getOrCreateTexture=function(t,n){var r=this.textureCache.get(t);if(void 0!==r)return r;var i=e.Texture.create(this.engine,n);return this.textureCache.set(t,i),i},n.deleteTexture=function(e){var t=this.textureCache.get(e);return void 0!==t&&t.dispose(),this.textureCache.delete(e)},n.getOrCreateGeometry=function(e,t,n){var r=this.geometryCache.get(e);if(void 0!==r)return r;var i=ke.createGeometry(this.engine,t,n);return this.geometryCache.set(e,i),i},n.getFilterMesh=function(e,t){var n=this.meshCache.get(e);if(void 0!==n)return n;var r=Be.createFilterMesh(this.engine,e,t);return this.meshCache.set(e,r),r},n.dispose=function(){this.engine=null,this.brdfLutTexture=void 0,this.meshCache.forEach((function(e){Oe.deleteMesh(e)})),this.meshCache.clear(),this.textureCache.forEach((function(e){Oe.deleteTexture(e)})),this.textureCache.clear(),this.geometryCache.forEach((function(e){Oe.deleteGeometry(e)})),this.geometryCache.clear(),this.renderPassCache.forEach((function(e){Oe.deleteRenderPass(e)})),this.renderPassCache.clear()},n.getRenderPasses=function(){var e=[];return this.renderPassCache.forEach((function(t){e.push(t)})),e},n.getBrdfLutTexture=function(){return this.brdfLutTexture},n.getSkyboxOptions=function(){return t.skyboxOptions},t.loadStaticResources=function(){var e=this;return o((function(){return p(this,(function(t){switch(t.label){case 0:return void 0!==e.brdfLutTexOptions?[2]:[4,st.getBrdfLutTextureOptions()];case 1:return e.brdfLutTexOptions=t.sent(),[2]}}))}))()},t.genSkyboxOptions=function(e,n){return o((function(){var r;return p(this,(function(i){switch(i.label){case 0:return void 0===(r=n)&&(r=st.getSkyboxParams()),[4,st.createSkyboxOptions(e,r)];case 1:return t.skyboxOptions=i.sent(),[2,t.skyboxOptions]}}))}))()},t}(),ct=Math.PI/180,ut=function(t){function n(n,r,i,o,a){var s,l,c,u,h,f;return(s=t.call(this)||this).width=512,s.height=512,s.nearPlane=.001,s.farPlane=1e3,s.fov=45,s.viewportMatrix=R.fromIdentity(),s.aspect=1,s.clipMode=e.spec.CameraClipMode.landscape,s.projectionMatrix=new R,s.viewMatrix=new R,s.type=exports.PObjectType.camera,s.visible=!1,s.owner=a,s.name=n,s.width=r,s.height=i,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:e.spec.CameraClipMode.landscape,s.update(),s}s(n,t);var r=n.prototype;return r.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform);var t=this.clipMode===e.spec.CameraClipMode.portrait;this.projectionMatrix.perspective(this.fov*ct,this.aspect,this.nearPlane,this.farPlane,t),this.projectionMatrix.premultiply(this.viewportMatrix),this.viewMatrix=this.matrix.invert()},r.getNewProjectionMatrix=function(t){var n=this.clipMode===e.spec.CameraClipMode.portrait;return(new R).perspective(Math.min(1.25*t,140)*ct,this.aspect,this.nearPlane,this.farPlane,n).premultiply(this.viewportMatrix)},r.computeViewAABB=function(e){var t=Math.tan(this.fov*ct*.5),n=this.aspect,r=0,i=0,o=0,a=0;this.isReversed()?(r=(o=this.farPlane*t)/n,i=(a=this.nearPlane*t)/n):(o=n*(r=this.farPlane*t),a=n*(i=this.nearPlane*t)),e.makeEmpty();var s=this.matrix;return e.expandByPoint(s.transformPoint(new N(o,r,-this.farPlane))),e.expandByPoint(s.transformPoint(new N(o,-r,-this.farPlane))),e.expandByPoint(s.transformPoint(new N(-o,r,-this.farPlane))),e.expandByPoint(s.transformPoint(new N(-o,-r,-this.farPlane))),e.expandByPoint(s.transformPoint(new N(a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new N(a,-i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new N(-a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new N(-a,-i,-this.nearPlane))),e},r.getSize=function(){return new w(this.width,this.height)},r.isReversed=function(){return this.clipMode===e.spec.CameraClipMode.portrait},r.getEye=function(){return this.translation},r.setEye=function(e){this.translation=e},n}(Q),ht=function(){function t(){this.winWidth=512,this.winHeight=512,this.cameraList=[],this.defaultCamera=new ut("camera",512,512,{id:"0",dataType:"camera",fov:60,far:1e3,near:.001,clipMode:e.spec.CameraClipMode.portrait,item:{id:"0"}})}var n=t.prototype;return n.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()},n.insert=function(e,t,n){var r=new ut(e,this.winWidth,this.winHeight,t,n);return this.cameraList.push(r),r},n.insertCamera=function(e){this.cameraList.push(e)},n.remove=function(e){if(l(e,ut)){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)},n.dispose=function(){this.cameraList=[]},n.updateDefaultCamera=function(e,t,n,r,i,o,a,s){this.defaultCamera.fov=e,this.defaultCamera.viewportMatrix=t.clone(),this.defaultCamera.aspect=n,this.defaultCamera.nearPlane=r,this.defaultCamera.farPlane=i,this.defaultCamera.position=o,this.defaultCamera.rotation=a,this.defaultCamera.aspect=n,this.defaultCamera.clipMode=s,this.defaultCamera.update()},n.getCameraList=function(){return this.cameraList},n.getDefaultCamera=function(){return this.defaultCamera},n.getCameraCount=function(){return this.cameraList.length},n.getActiveCamera=function(){return this.defaultCamera},n.getAspect=function(){return this.winWidth/this.winHeight},t}(),ft=function(t){function n(n,r,i){var o;(o=t.call(this)||this).direction=new N(0,0,1),o.range=0,o.color=new N(1,1,1),o.intensity=0,o.outerConeAngle=0,o.innerConeAngle=0,o.lightType=exports.PLightType.ambient,o.padding=new w(0,0),o.followCamera=!1,o.name=n,o.type=exports.PObjectType.light,o.visible=!1,o.owner=i,o.direction=new N(0,0,-1),o.range=0,o.outerConeAngle=0,o.innerConeAngle=0;var a,s,l=r.color;if(o.color=new N(l.r,l.g,l.b),o.intensity=r.intensity,o.followCamera=null!=(a=r.followCamera)&&a,r.lightType===e.spec.LightType.point)o.lightType=exports.PLightType.point,o.range=null!=(s=r.range)?s:-1;else if(r.lightType===e.spec.LightType.spot){var c,u,h;o.lightType=exports.PLightType.spot,o.range=null!=(c=r.range)?c:-1,o.outerConeAngle=null!=(u=r.outerConeAngle)?u:Math.PI,o.innerConeAngle=null!=(h=r.innerConeAngle)?h:0}else r.lightType===e.spec.LightType.directional?o.lightType=exports.PLightType.directional:o.lightType=exports.PLightType.ambient;return o.update(),o}s(n,t);var r=n.prototype;return r.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform)},r.isDirectional=function(){return this.lightType===exports.PLightType.directional},r.isPoint=function(){return this.lightType===exports.PLightType.point},r.isSpot=function(){return this.lightType===exports.PLightType.spot},r.isAmbient=function(){return this.lightType===exports.PLightType.ambient},r.getWorldPosition=function(){return this.translation},r.getWorldDirection=function(){return this.matrix.transformNormal(this.direction,new N)},H(n,[{key:"position",get:function(){return this.translation}}]),n}(Q),dt=function(){function e(){this.lightList=[]}var t=e.prototype;return t.insertItem=function(e,t,n){var r=new ft(e,t,n);return this.lightList.push(r),r},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=[]},H(e,[{key:"lightCount",get:function(){return this.lightList.length}}]),e}();var pt,mt=function(t){function n(e,n,r,i,o,a){var s,l;(s=t.call(this)||this).engine=e,s.parentIndex=-1,s.subMeshes=[],s.hide=!0,s.priority=0,s.boundingBox=new B,s.visBoundingBox=!1,s.isBuilt=!1,s.isDisposed=!1;var c=new yt(r,i,a);s.name=n,s.type=exports.PObjectType.mesh,s.visible=!1,s.owner=i,s.parentIndex=c.getParentIndex(),s.parentItem=c.parentItem,s.parentItemId=o,s.rootBoneItem=r.rootBone,s.skin=c.getSkinObj(e),s.morph=c.getMorphObj(),s.hide=c.isHide(),s.priority=(null==i||null==(l=i.item)?void 0:l.renderOrder)||0,s.subMeshes=[];var u,h=c.getGeometry();return(null!=(u=null==i?void 0:i.materials)?u:[]).forEach((function(e){var t=new gt(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(r.interaction),s}s(n,t);var r=n.prototype;return r.build=function(e){this.isBuilt||(this.isBuilt=!0,this.subMeshes.forEach((function(t){t.build(e.maxLightCount,e.skybox)})),Y.getInstance().visBoundingBox&&(this.boundingBoxMesh=new le(this.engine,this.priority)))},r.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))},r.lateUpdate=function(){var e;null==(e=this.skin)||e.updateSkinMatrices()},r.render=function(e,t){var n=this;if(this.updateMaterial(e),this.subMeshes.forEach((function(e,r){t.drawGeometry(e.getEffectsGeometry(),n.matrix,e.getEffectsMaterial(),r)})),this.visBoundingBox&&void 0!==this.boundingBoxMesh){var r=this.boundingBoxMesh.mesh;t.drawGeometry(r.geometry,R.IDENTITY,r.material)}},r.dispose=function(){var e,n,r;this.isDisposed||(t.prototype.dispose.call(this),this.owner=void 0,this.isDisposed=!0,this.engine=null,this.parentItem=void 0,null==(e=this.skin)||e.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==(r=this.boundingBoxMesh)||r.dispose(),this.boundingBoxMesh=void 0)},r.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]}}},r.updateParentInfo=function(e,t){this.parentItemId=e,this.parentItem=t,void 0!==this.skin&&this.skin.updateParentItem(t)},r.updateMaterial=function(e){var t=this.matrix,n=t.clone().invert().transpose(),r=e.sceneStates;if(this.subMeshes.forEach((function(e){e.updateMaterial(t,n,r)})),void 0!==this.boundingBoxMesh){this.computeBoundingBox(t);var i=new N(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,r.viewProjectionMatrix,s,i)}},r.hitTesting=function(e,t){var n,r=this.matrix,i=r.clone().invert(),o=i.transformPoint(e,new N),a=i.transformNormal(t,new N),s=this.boundingBox,l=Ee(o,a,s.min,s.max);return void 0===l?[]:(Y.getInstance().isEditorEnv?this.subMeshes.forEach((function(e){var t=e.hitTesting(o,a,r,i);void 0!==t&&(void 0===n||n>t)&&(n=t)})):n=l,void 0===n?[]:(a.multiply(n),o.add(a),r.transformPoint(o),[o]))},r.computeBoundingBox=function(e){var t=this.boundingBox.makeEmpty(),n=e.clone().invert();return this.subMeshes.forEach((function(e){var r=e.computeBoundingBox(n);t.union(r)})),t},r.getItemBoundingBox=function(t){if(void 0===t)return new B;if(t.type===e.spec.ModelBoundingType.box){var n,r,i=null!=(n=t.center)?n:[0,0,0],o=null!=(r=t.size)?r:[0,0,0],a=N.fromArray(i),s=N.fromArray(o).multiply(.5),l=a.clone().subtract(s),c=a.clone().add(s);return new B(l,c)}var u,h,f=null!=(u=t.center)?u:[0,0,0],d=.5*(null!=(h=t.radius)?h:0),p=N.fromArray(f),m=p.clone().subtract(d),g=p.clone().add(d);return new B(m,g)},r.getParentId=function(){return this.parentItemId},H(n,[{key:"hasSkin",get:function(){return void 0!==this.skin}}]),n}(Q),gt=function(){function t(e){this.engine=e,this.name="",this.effectsPriority=0,this.boundingBox=new B,this.isCompressed=!1}var n=t.prototype;return n.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 r=this.skin.maxJointCount;if(this.jointMatrixList=new Float32Array(16*r),this.jointNormalMatList=new Float32Array(16*r),this.skin.isTextureDataMode()){var i=this.skin.textureDataMode===exports.TextureDataMode.half_float;this.jointMatrixTexture=new Qe(this.engine),this.jointNormalMatTexture=new Qe(this.engine),this.jointMatrixTexture.create(r,i,"jointMatrixTexture"),this.jointNormalMatTexture.create(r,i,"jointNormalMatTexture")}}else(this.geometry.hasWeights()||this.geometry.hasJoints())&&console.warn("Geometry has weight and/or joint array, but the skin is missing.");this.isCompressed=this.geometry.isCompressed()},n.build=function(t,n){var r,i=Y.getInstance(),o=this.getMacroList(t,!0,n),a=this.material.getMacroList(o),s=Y.getInstance().isWebGL2;this.material.effectMaterial?(r=this.material.effectMaterial,a.forEach((function(e){var t=e.name,n=e.value;r.enableMacro(t,n)})),this.material.setMaterialStates(r)):(r=e.Material.create(this.engine,{shader:{vertex:this.material.vertexShaderCode,fragment:this.material.fragmentShaderCode,shared:i.shaderShared,glslVersion:s?e.GLSLVersion.GLSL3:e.GLSLVersion.GLSL1}}),this.material.setMaterialStates(r))},n.getFeatureList=function(e,t,n){var r=[];if(this.geometry.hasNormals()&&r.push("HAS_NORMALS 1"),this.geometry.hasTangents()&&r.push("HAS_TANGENTS 1"),this.geometry.hasUVCoords(1)&&r.push("HAS_UV_SET1 1"),this.geometry.hasUVCoords(2)&&r.push("HAS_UV_SET2 1"),void 0!==this.morph&&this.morph.hasMorph()){r.push("USE_MORPHING"),r.push("WEIGHT_COUNT "+this.morph.morphWeightsLength);for(var i=0;i<this.morph.morphWeightsLength;i++)this.morph.hasPositionMorph&&r.push("HAS_TARGET_POSITION"+i),this.morph.hasNormalMorph&&r.push("HAS_TARGET_NORMAL"+i),this.morph.hasTangentMorph&&r.push("HAS_TARGET_TANGENT"+i)}void 0!==this.skin&&(r.push("USE_SKINNING 1"),r.push("JOINT_COUNT "+this.skin.getJointCount()),r.push("HAS_JOINT_SET1 1"),r.push("HAS_WEIGHT_SET1 1"),this.skin.textureDataMode&&r.push("USE_SKINNING_TEXTURE 1")),this.material.materialType!==exports.PMaterialType.unlit&&(e>0&&this.geometry.hasNormals()&&(r.push("USE_PUNCTUAL 1"),r.push("LIGHT_COUNT "+e)),void 0!==n&&n.available&&(r.push("USE_IBL 1"),r.push("USE_TEX_LOD 1"),n.hasDiffuseImage||r.push("IRRADIANCE_COEFFICIENTS 1")));var o=Y.getInstance().renderMode3D,a=this.getRenderMode3DDefine(o);return void 0!==a&&(r.push("DEBUG_OUTPUT 1"),r.push(a+" 1")),r},n.getMacroList=function(e,t,n){var r=[];if(this.geometry.hasNormals()&&r.push({name:"HAS_NORMALS"}),this.geometry.hasTangents()&&r.push({name:"HAS_TANGENTS"}),this.geometry.hasUVCoords(1)&&r.push({name:"HAS_UV_SET1"}),this.geometry.hasUVCoords(2)&&r.push({name:"HAS_UV_SET2"}),void 0!==this.morph&&this.morph.hasMorph()){r.push({name:"USE_MORPHING"}),r.push({name:"WEIGHT_COUNT",value:this.morph.morphWeightsLength});for(var i=0;i<this.morph.morphWeightsLength;i++)this.morph.hasPositionMorph&&r.push({name:"HAS_TARGET_POSITION"+i}),this.morph.hasNormalMorph&&r.push({name:"HAS_TARGET_NORMAL"+i}),this.morph.hasTangentMorph&&r.push({name:"HAS_TARGET_TANGENT"+i})}void 0!==this.skin&&(r.push({name:"USE_SKINNING"}),r.push({name:"JOINT_COUNT",value:this.skin.maxJointCount}),r.push({name:"HAS_JOINT_SET1"}),r.push({name:"HAS_WEIGHT_SET1"}),this.skin.textureDataMode&&r.push({name:"USE_SKINNING_TEXTURE"})),this.material.materialType!==exports.PMaterialType.unlit&&(e>0&&this.geometry.hasNormals()&&(r.push({name:"USE_PUNCTUAL"}),r.push({name:"LIGHT_COUNT",value:e})),void 0!==n&&n.available&&(r.push({name:"USE_IBL"}),r.push({name:"USE_TEX_LOD"}),n.hasDiffuseImage||r.push({name:"IRRADIANCE_COEFFICIENTS"})));var o=Y.getInstance().renderMode3D,a=this.getRenderMode3DDefine(o);return void 0!==a&&(r.push({name:"DEBUG_OUTPUT"}),r.push({name:a})),r},n.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},n.updateMaterial=function(e,t,n){this.updateUniformsByAnimation(e,t),this.updateUniformsByScene(n),this.material.updateUniforms(this.getEffectsMaterial())},n.hitTesting=function(e,t,n,r){var i=this.boundingBox,o=Ee(e,t,i.min,i.max),a=[];if(void 0!==o){if(void 0!==this.skin)this.skin.animationMatrices.forEach((function(e){a.push((new R).multiplyMatrices(r,e))}));var s=new je,l=this.material.isBothSide();return s.create(this.geometry.geometry,l,a),s.getHitPoint(e,t)}},n.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 R).multiplyMatrices(e,n))}));var n=new He;return n.create(this.geometry.geometry,t),n.getBoundingBox(this.boundingBox)},n.getRenderMode3DDefine=function(t){switch(t){case e.spec.RenderMode3D.uv:return"DEBUG_UV";case e.spec.RenderMode3D.normal:return"DEBUG_NORMAL";case e.spec.RenderMode3D.basecolor:return"DEBUG_BASECOLOR";case e.spec.RenderMode3D.alpha:return"DEBUG_ALPHA";case e.spec.RenderMode3D.metallic:return"DEBUG_METALLIC";case e.spec.RenderMode3D.roughness:return"DEBUG_ROUGHNESS";case e.spec.RenderMode3D.ao:return"DEBUG_OCCLUSION";case e.spec.RenderMode3D.emissive:return"DEBUG_EMISSIVE";case e.spec.RenderMode3D.diffuse:return"DEBUG_DIFFUSE"}},n.updateUniformsByAnimation=function(e,t){var n=this.getEffectsMaterial();n.setMatrix("_NormalMatrix",t);var r=this.skin;if(void 0!==r){var i=this.jointMatrixList,o=this.jointNormalMatList;if(r.computeMeshAnimMatrices(e,i,o),r.textureDataMode){var a=this.jointMatrixTexture,s=this.jointNormalMatTexture;a.update(i),s.update(o),n.setTexture("_jointMatrixSampler",a.getTexture()),n.setTexture("_jointNormalMatrixSampler",s.getTexture())}else{var l=[],c=[];i.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)}},n.updateUniformsByScene=function(e){var t=this.getEffectsMaterial();if(t.setVector3("_Camera",e.cameraPosition),!this.isUnlitMaterial()){for(var n=e.maxLightCount,r=e.lightList,i=e.inverseViewMatrix,o=0;o<n;o++)if(o<r.length){var a=r[o],s=a.visible?a.intensity:0;if(a.followCamera){var l=i.transformNormal(a.getWorldDirection(),new N),c=i.transformPoint(a.getWorldPosition(),new N);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",N.ZERO),t.setFloat("_Lights["+o+"].range",0),t.setVector3("_Lights["+o+"].color",N.ZERO),t.setFloat("_Lights["+o+"].intensity",0),t.setVector3("_Lights["+o+"].position",N.ZERO),t.setFloat("_Lights["+o+"].innerConeCos",0),t.setFloat("_Lights["+o+"].outerConeCos",0),t.setInt("_Lights["+o+"].type",99999),t.setVector2("_Lights["+o+"].padding",w.ZERO);var u=e.skybox;if(void 0!==u&&u.available){if(t.setVector2("_IblIntensity",new w(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,N.fromArray(h[n]))}))}t.setInt("_MipCount",u.specularMipCount-1),t.setTexture("_SpecularEnvSampler",u.specularImage)}}},n.hasSkin=function(){return void 0!==this.skin},n.getEffectsGeometry=function(){return this.geometry.geometry},n.setGeometry=function(e){l(e,vt)?this.geometry=e:this.geometry=new vt(e)},n.setMaterial=function(e){l(e,tt)||l(e,nt)?this.material=e:this.material=rt(e)},n.getEffectsMaterial=function(){return this.material.effectMaterial},n.isUnlitMaterial=function(){return this.material.materialType===exports.PMaterialType.unlit},n.hasMorph=function(){return void 0!==this.morph&&this.morph.hasMorph()},n.getWorldBoundingBox=function(){if(void 0===this.parent)return this.boundingBox.isEmpty()&&this.computeBoundingBox(R.fromIdentity()),this.boundingBox;var e=this.parent.matrix;return this.boundingBox.isEmpty()&&this.computeBoundingBox(e.clone().invert()),this.boundingBox.clone().applyMatrix4(e)},t}(),vt=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}(),yt=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 r=new Ke;if(r.create(this.geometry)){var i,o;if(null==(i=e.morph)?void 0:i.weights)r.initWeights(null==(o=e.morph)?void 0:o.weights);this.morphObj=r}}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,r,i=new Ze,o=null!=(r=null==(n=this.parentComponent.sceneManager)?void 0:n.maxJointCount)?r:0;return i.create(t,e,this.rootBoneItem,o),i}},e}(),Tt=function(){function t(e){this.maxLightCount=16,this.maxJointCount=0,this.renderSkybox=!1,this.compName="SceneManger",this.itemList=[],this.meshList=[],this.engine=e,this.lightManager=new dt,this.cameraManager=new ht,this.parentId2Mesh=new Map,this.enableDynamicSort=!1,this.tickCount=0,this.lastTickSecond=-1,this.sceneAABBCache=new B,this.renderedMeshSet=new Se}var n=t.prototype;return n.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).")},n.initGlobalState=function(t){var n,r,i,o,a,s=this.engine.gpuCapability,l=Y.getInstance();l.reset(),l.isWebGL2=2===s.level,l.runtimeEnv=null!=(n=t.runtimeEnv)?n:e.PLAYER_OPTIONS_ENV_EDITOR,l.compatibleMode=null!=(r=t.compatibleMode)?r:"gltf",l.visBoundingBox=null!=(i=t.visBoundingBox)&&i,l.renderMode3D=null!=(o=t.renderMode3D)?o:e.spec.RenderMode3D.none,l.renderMode3DUVGridSize=null!=(a=t.renderMode3DUVGridSize)?a:1/16},n.clean=function(){this.dispose(),this.compName="",this.renderer=void 0,this.sceneCache=void 0,this.itemList=[],this.meshList=[],this.lightManager=new dt,this.cameraManager=new ht,this.parentId2Mesh=new Map,this.brdfLUT=void 0,this.skybox=void 0,this.lastTickSecond=-1,this.tickCount=0,this.renderedMeshSet=new Se},n.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()},n.addItem=function(t){if(l(t,mt)){var n=t;void 0!==n.parentItemId&&this.parentId2Mesh.set(n.parentItemId,n),e.addItem(this.meshList,n)}else if(l(t,ot)){var r=t;r.setup(this.brdfLUT),this.renderSkybox||(r.renderable=!1),this.skybox=r}else l(t,ft)?this.lightManager.insertLight(t):this.cameraManager.insertCamera(t);e.addItem(this.itemList,t)},n.removeItem=function(t){if(l(t,mt)){var n=t;void 0!==n.parentItemId&&this.parentId2Mesh.delete(n.parentItemId),e.removeItem(this.meshList,n)}else l(t,ot)?this.skybox=void 0:l(t,ft)?this.lightManager.remove(t):this.cameraManager.remove(t);e.removeItem(this.itemList,t)},n.updateDefaultCamera=function(t,n){var r=new e.Transform(j({},t,{valid:!0})),i=(new X).fromEffectsTransform(r);this.cameraManager.updateDefaultCamera(t.fov,n,t.aspect,t.near,t.far,i.getPosition(),i.getRotation(),t.clipMode)},n.tick=function(e){var t=e,n=this.activeCamera,r=n.viewMatrix,i=n.projectionMatrix,o=i.clone().multiply(r);this.sceneStates={deltaSeconds:t,camera:n,cameraPosition:n.getEye(),viewMatrix:r,inverseViewMatrix:r.clone().invert(),projectionMatrix:i,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},n.dynamicSortMeshes=function(e){var t=[],n=[];this.meshList.forEach((function(e){if(e.owner&&e.owner.enabled){var r=e.owner;t.push(r),n.push(r.priority)}})),n.sort((function(e,t){return e-t}));var r=e.viewMatrix;t.sort((function(e,t){var n=Oe.isTransparentMesh(e),i=Oe.isTransparentMesh(t);if(n&&i){var o=e.transform.getWorldPosition(),a=t.transform.getWorldPosition(),s=r.transformPoint(o),l=r.transformPoint(a);return s.z===l.z?e.priority-t.priority:s.z-l.z}return n?1:i?-1:e.priority-t.priority}));for(var i=-99999,o=0;o<t.length;o++){var a=t[o],s=n[o];i<s?(i=s,a.priority=s):(i+=.1,a.priority=i)}},n.queryMesh=function(e){var t=this.parentId2Mesh.get(e);if(void 0!==t&&t.visible)return t},n.getSceneAABB=function(e){var t=null!=e?e:new B;return this.itemList.forEach((function(e){if(e.type===exports.PObjectType.mesh){var n=e;if(n.owner){var r=n.owner.item.getWorldTransform().getWorldMatrix(),i=n.computeBoundingBox(r);i.applyMatrix4(r),t.union(i)}else t.union(n.computeBoundingBox(R.fromIdentity()))}})),t},n.printDebugInfo=function(){console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),this.meshList.forEach((function(e,t){console.info("Mesh: ",t,e)})),this.cameraManager.getCameraList().forEach((function(e,t){console.info("Camera: ",t,e)})),console.info("Default Camera: ",this.cameraManager.getDefaultCamera()),this.lightManager.lightList.forEach((function(e,t){console.info("Light: ",t,e)})),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")},n.getRenderer=function(){return this.renderer},n.getSceneCache=function(){return this.sceneCache},H(t,[{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)}}]),t}(),xt=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).name="model",e}s(n,t);var r=n.prototype;return r.onAssetsLoadStart=function(e,t){return o((function(){return p(this,(function(e){switch(e.label){case 0:return[4,lt.loadStaticResources()];case 1:return e.sent(),[2]}}))}))()},r.onAssetsLoadFinish=function(t,n,r){var i,o;if(void 0!==n.pluginData){var a=n.pluginData;["compatibleMode","renderSkybox","visBoundingBox","autoAdjustScene","enableDynamicSort","renderMode3D","renderMode3DUVGridSize"].forEach((function(e){return t.storage[e]=a[e]}))}var s,l=null!=(o=n.env)?o:"";t.storage.runtimeEnv=l;var c=null!=(s=null==(i=n.pluginData)?void 0:i.compatibleMode)?s:"gltf";ke.preprocessScene(t,l,c);var u=2===r.gpuCapability.level,h=me(),f=ge(),d={id:W,name:"PBR Shader",dataType:e.spec.DataType.Shader,fragment:h.fragmentShaderCode,vertex:h.vertexShaderCode,glslVersion:u?e.GLSLVersion.GLSL3:e.GLSLVersion.GLSL1},p={id:J,name:"Unlit Shader",dataType:e.spec.DataType.Shader,fragment:f.fragmentShaderCode,vertex:f.vertexShaderCode,glslVersion:u?e.GLSLVersion.GLSL3:e.GLSLVersion.GLSL1};r.addEffectsObjectData(d),r.addEffectsObjectData(p)},r.onCompositionCreated=function(t,n){var r={id:"ModelPluginItem",name:"ModelPluginItem",duration:9999999,endBehavior:e.spec.END_BEHAVIOR_FORWARD},i=new e.VFXItem(t.getEngine(),r);t.addItem(i),i.addComponent(exports.ModelPluginComponent).sceneParams=n.storage},n}(f(e.Plugin));function bt(e){var t,n=null==e||null==(t=e.item)?void 0:t.composition,r=null==n?void 0:n.getItemByName("ModelPluginItem"),i=null==r?void 0:r.getComponent(exports.ModelPluginComponent);return null==i?void 0:i.scene}exports.ModelPluginComponent=function(t){function n(n){var r;return(r=t.call(this,n)||this).runtimeEnv=e.PLAYER_OPTIONS_ENV_EDITOR,r.compatibleMode="gltf",r.renderSkybox=!0,r.visBoundingBox=!1,r.autoAdjustScene=!1,r.enableDynamicSort=!1,r.renderMode3D=e.spec.RenderMode3D.none,r.renderMode3DUVGridSize=1/16,r}s(n,t);var i=n.prototype;return i.onAwake=function(){this.cache=new lt(this.engine),this.cache.setup(!1),this.scene=new Tt(this.engine),this.initial(this.sceneParams)},i.onLateUpdate=function(e){var t=this.item.composition;if(this.autoAdjustScene&&1==this.scene.tickCount){var n,i,o,a=t.camera,s=(new X).fromMatrix4(a.getViewMatrix()),l=(new q).fromPTransform(s).zAxis.clone(),c=null!=(i=a.fov)?i:45,u=null!=(o=a.aspect)?o:1,h=this.scene.getSceneAABB(),f=h.clone().applyMatrix4(s.getMatrix()).getSize(new N).multiply(.5),d=f.x,p=f.y,m=p*Math.max(d/p/u,1),g=h.getCenter(new N),v=m/Math.tan(.5*c*G),y=g.clone().add(l.clone().multiply(v+f.z));t.camera.position=y,null==(n=t.items)||n.forEach((function(e){if(e.type===r){var t=e.getComponent(exports.ModelCameraComponent);if(null==t?void 0:t.content){var n,i=((null==(n=e.transform.parentTransform)?void 0:n.getWorldMatrix())||R.IDENTITY.clone()).invert().transformPoint(y);t.setTransform(i),console.info("Scene AABB ["+h.min.toArray()+"], ["+h.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.dispose(),this.cache=null},i.initial=function(e){var t,n,r,i,o,a,s,l,c;this.runtimeEnv=null!=(n=e.runtimeEnv)?n:this.runtimeEnv,this.compatibleMode=null!=(r=e.compatibleMode)?r:this.compatibleMode,this.renderSkybox=null!=(i=e.renderSkybox)?i: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(exports.ModelLightComponent)&&n++})),n},i.getMaxJointCount=function(t){var n=this,r=0;return t.forEach((function(t){var i=t.getComponent(exports.ModelMeshComponent);if(i&&i.data){var o=i.data.geometry;if(l(o,e.Geometry)){var a=o.getSkinProps();a.boneNames&&(r=Math.max(a.boneNames.length,r))}}0!==t.children.length&&(r=Math.max(n.getMaxJointCount(t.children),r))})),r},n}(e.Behaviour),exports.ModelPluginComponent=d([e.effectsClass(e.spec.DataType.ModelPluginComponent)],exports.ModelPluginComponent),exports.ModelTreeComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}return s(t,e),t.prototype.fromData=function(t){e.prototype.fromData.call(this,t),this.options=t},t}(e.Behaviour),exports.ModelTreeComponent=d([e.effectsClass(e.spec.DataType.TreeComponent)],exports.ModelTreeComponent),exports.CameraGestureType=void 0,(pt=exports.CameraGestureType||(exports.CameraGestureType={}))[pt.none=0]="none",pt[pt.translate=1]="translate",pt[pt.rotate_focus=2]="rotate_focus",pt[pt.rotate_self=3]="rotate_self",pt[pt.scale=4]="scale";var _t=function(){function t(e){this.composition=e,this.cameraTransform=new X,this.cameraCoordiante=new q,this.startParams={type:exports.CameraGestureType.none,mouseEvent:!1,clientX:0,clientY:0,clientWidth:512,clientHeight:512,target:""}}var n=t.prototype;return n.updateComposition=function(e){this.composition=e},n.getItem=function(){var e,t=this;return null==(e=this.composition.items)?void 0:e.find((function(e){return e.name===t.getCurrentTarget()}))},n.getCurrentTarget=function(){return this.startParams.target},n.getCurrentType=function(){return this.startParams.type},n.onKeyEvent=function(t){this.startParams.target!==t.cameraID&&(this.startParams.target=t.cameraID,this.startParams.type=exports.CameraGestureType.translate);var n=this.getItem();if(void 0===n)return console.warn("[CameraGestureHandlerImp] Unable to locate camera item with ID: "+this.startParams.target+"."),this.composition.camera.getOptions();var r,i,o,a,s=this.composition.camera,l=new e.Transform(j({},s.getOptions(),{valid:!0})),c=(new X).fromEffectsTransform(l),u=(new q).fromPTransform(c),h=null!=(r=t.xAxis)?r:0,f=null!=(i=t.yAxis)?i:0,d=null!=(o=t.zAxis)?o:0,p=u.xAxis.clone().multiply(h);if(p.add(u.yAxis.clone().multiply(f)),p.add(u.zAxis.clone().multiply(d)),p.lengthSquared()<1e-5)return s.getOptions();p.normalize();var m=null!=(a=t.speed)?a:.1,g=c.getPosition();return g.add(p.clone().multiply(m)),this.setTransform(n,g),this.startParams.type===exports.CameraGestureType.rotate_self&&(this.cameraTransform.setPosition(g),this.cameraCoordiante.origin=g),s.getOptions()},n.onXYMoveBegin=function(e,t,n,r,i){var o={type:exports.CameraGestureType.translate,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:r,target:i};return this.startGesture(o)},n.onXYMoving=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,i={type:exports.CameraGestureType.translate,mouseEvent:!0,clientX:e,clientY:t,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:null!=n?n:.015};return this.moveGesture(i)},n.onXYMoveEnd=function(){this.endGesture()},n.onZMoveBegin=function(e,t,n,r,i){var o={type:exports.CameraGestureType.scale,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:r,target:i};return this.startGesture(o)},n.onZMoving=function(e,t,n){if(void 0===n&&(n=.015),!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,i={type:exports.CameraGestureType.scale,mouseEvent:!0,clientX:e,clientY:t,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:n};return this.moveGesture(i)},n.onZMoveEnd=function(){this.endGesture()},n.onRotateBegin=function(e,t,n,r,i){var o={type:exports.CameraGestureType.rotate_self,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:r,target:i};return this.startGesture(o)},n.onRotating=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,i={type:exports.CameraGestureType.rotate_self,mouseEvent:!0,clientX:e,clientY:t,clientWidth:r.clientWidth,clientHeight:r.clientHeight,target:r.target,speed:null!=n?n:1.5};return this.moveGesture(i)},n.onRotateEnd=function(){this.endGesture()},n.onRotatePointBegin=function(e,t,n,r,i,o){var a={type:exports.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:e,clientY:t,clientWidth:n,clientHeight:r,focusPoint:i,target:o};return this.startGesture(a)},n.onRotatingPoint=function(e,t,n){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var r=this.startParams,i={type:exports.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:e,clientY:t,clientWidth:r.clientWidth,clientHeight:r.clientHeight,focusPoint:r.focusPoint,target:r.target,speed:null!=n?n:8};return this.moveGesture(i)},n.onRotatePointEnd=function(){this.endGesture()},n.moveTo=function(e,t){this.startParams.target=e,this.startParams.type=exports.CameraGestureType.none;var n=this.getItem();void 0!==n?this.setPosition(n,t):console.warn("[CameraGestureHandlerImp] Can't find camera item.")},n.rotateTo=function(e,t){this.startParams.target=e,this.startParams.type=exports.CameraGestureType.none;var n=this.getItem();void 0!==n?this.setQuaternion(n,t):console.warn("[CameraGestureHandlerImp] Can't find camera item.")},n.onFocusPoint=function(e,t,n){this.startParams.target=e,this.startParams.type=exports.CameraGestureType.none;var r=this.getItem();if(void 0!==r){var i=null!=n?n:5,o=N.fromArray(t),a=(new X).fromEffectsTransform(r.transform),s=(new q).fromPTransform(a),l=N.fromArray(s.zAxis.toArray()).multiply(1).clone().multiply(i),c=o.clone().add(l);this.setTransform(r,c),this.startParams.target=""}else console.warn("[CameraGestureHandlerImp] Can't find camera item.")},n.getCameraTransform=function(){var t=this.composition.camera,n=new e.Transform(t.getOptions());return n.setValid(!0),n},n.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()},n.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 r=null!=(t=e.speed)?t:1.015,i=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===exports.CameraGestureType.translate){var c=this.cameraTransform.getPosition().clone();c.add(i.clone().multiply(-s*r)),c.add(o.clone().multiply(l*r)),n.transform.setPosition(c.x,c.y,c.z),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===exports.CameraGestureType.scale){var u=this.cameraTransform.getPosition().clone();u.add(a.clone().multiply(l*r)),n.transform.setPosition(u.x,u.y,u.z),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===exports.CameraGestureType.rotate_self){var h=s/e.clientWidth,f=l/e.clientHeight,d=h*Math.PI*r*.5,p=f*Math.PI*r*.5,m=U.fromAxisAngle(N.Y,-d),g=U.fromAxisAngle(i,-p);m.multiply(g),m.multiply(this.cameraTransform.getRotation()),n.transform.setQuaternion(m.x,m.y,m.z,m.w),this.setTransform(n,n.transform.position,n.transform.rotation)}else if(e.type===exports.CameraGestureType.rotate_focus){var v=s/e.clientWidth,y=l/e.clientHeight,T=v*Math.PI*r,x=y*Math.PI*r,b=U.fromAxisAngle(N.Y,-T),_=U.fromAxisAngle(i,-x);b.multiply(_);var C=b.toMatrix4(new R),S=N.fromArray(e.focusPoint),M=this.cameraCoordiante.origin.clone().subtract(S);C.transformPoint(M);var A=M.add(S);b.multiply(this.cameraTransform.getRotation()),n.transform.setPosition(A.x,A.y,A.z),n.transform.setQuaternion(b.x,b.y,b.z,b.w),this.setTransform(n,A,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()},n.setTransform=function(e,t,n){var r=e.getComponent(exports.ModelCameraComponent);void 0!==r&&r.setTransform(t,n)},n.setPosition=function(e,t){var n;(n=e.transform).setPosition.apply(n,[].concat(t));var r=e.getComponent(exports.ModelCameraComponent);void 0!==r&&r.updateMainCamera()},n.setQuaternion=function(e,t){var n;(n=e.transform).setQuaternion.apply(n,[].concat(t));var r=e.getComponent(exports.ModelCameraComponent);void 0!==r&&r.updateMainCamera()},n.endGesture=function(){this.startParams.type=exports.CameraGestureType.none,this.startParams.mouseEvent=!1,this.startParams.target=""},n.updateCameraTransform=function(t){var n=new e.Transform(t);n.setValid(!0),this.cameraTransform.fromEffectsTransform(n),this.cameraCoordiante.fromPTransform(this.cameraTransform)},t}(),Ct=function(){function t(){}return t.getTransformFromMat4=function(e){var t=e.getTransform(),n=t.rotation.toEuler(new F);return{position:t.translation.toArray(),rotation:n.toArray(),scale:t.scale.toArray()}},t.getEffectsTransformFromMat4=function(t){var n=new e.Transform({valid:!0});return n.cloneFromMatrix(t),{position:n.position.toArray(),rotation:n.rotation.toArray(),scale:n.scale.toArray()}},t.getTransformFromTranslation=function(e){return{position:e.toArray()}},t.getTransformFromDirection=function(e){var n=N.fromArray([1,0,0]),r=e.clone().normalize(),i=n.clone().cross(r);if(i.length()<.01)return{};i.normalize();var o=r.dot(n),a=Math.acos(o),s=R.fromRotationAxis(i,a);return t.getTransformFromMat4(s)},t.getEffectsTransformFromDirection=function(e){var n=N.fromArray([0,0,1]),r=e.clone().normalize(),i=n.clone().cross(r);if(i.length()<.01)return{};i.normalize();var o=r.dot(n),a=Math.acos(o),s=R.fromRotationAxis(i,a);return t.getEffectsTransformFromMat4(s)},t.getTransformFromTransDir=function(e,n){var r=t.getTransformFromDirection(n);return r.position=e.toArray(),r},t.getEffectsTransformFromTransDir=function(e,n){var r=t.getEffectsTransformFromDirection(n);return r.position=e.toArray(),r},t.getEulerFromQuat=function(e){var t=new F,n=new U(e.x,e.y,e.z,e.w);return t.order=D.ZYX,t.setFromQuaternion(n),[t.x,t.y,t.z]},t.getQuatFromEuler=function(e){var t=new U;return t.setFromEuler(e),[t.x,t.y,t.z,t.w]},t.toPlayerColor3=function(e){return[t.scaleTo255(e[0]),t.scaleTo255(e[1]),t.scaleTo255(e[2])]},t.toPlayerColor4=function(e){return[t.scaleTo255(e[0]),t.scaleTo255(e[1]),t.scaleTo255(e[2]),t.scaleTo255(e[3])]},t.scaleTo255=function(e){var t=255*e;return Math.max(0,Math.min(t,255))},t.scaleTo1=function(e){var t=e/255;return Math.max(0,Math.min(t,1))},t}(),St=function(){function t(t,n){void 0===n&&(n=!0),this.renderer=t,this.keepIBLData=n,this.treeInfo=new Mt,this.engine=t.engine,this.downloader=new e.Downloader}var n=t.prototype;return n.processScene=function(t){var n=this;return o((function(){var r,i,o,a,s,l,c,u,h,f,d,m;return p(this,(function(p){switch(p.label){case 0:return e.isObject(t)?(i=t,[3,3]):[3,1];case 1:return[4,n.loadJSON(t)];case 2:i=p.sent(),p.label=3;case 3:if((r=i).textures||(r.textures=[]),r.textures.forEach((function(e){void 0===e.source&&(e.source=0)})),o=e.getStandardJSON(r),s=null!=(a=o.bins)?a:[],l=[],c=r.version.split("."),Number(c[0])>=3)return[2,o];if(!o.bins)return[3,7];u=b(o.bins),p.label=4;case 4:return(h=u()).done?[3,7]:(f=h.value,d=l.push,[4,n.loadBins(f.url)]);case 5:d.apply(l,[p.sent()]),p.label=6;case 6:return[3,4];case 7:return o.bins=l,m=j({},o,{version:e.spec.JSONSceneVersion["3_0"],playerVersion:{web:"3.0",native:"3.0"},type:"ge",compositions:[],images:[],textures:[],items:[],components:[],materials:[],shaders:[]}),n.setImage(m,o),[4,n.setTexture(m,o)];case 8:return p.sent(),n.setComponent(m,o),n.setItem(m,o),n.setComposition(m,o),m.bins=s,[2,m]}}))}))()},n.setImage=function(e,t){var n=[];t.images.forEach((function(e){n.push(e)})),e.images=n},n.setTexture=function(t,n){var r=this;return o((function(){var i,o,a,s,l,c,u,h,f,d,m,g;return p(this,(function(p){switch(p.label){case 0:if(i=[],o=n.bins,!n.textures)return[3,7];a=b(n.textures),p.label=1;case 1:return(s=a()).done?[3,7]:34067!==(l=s.value).target?[3,5]:r.keepIBLData?(i.push(l),[3,4]):[3,2];case 2:return c=l.mipmaps,u=l.target,h=c.map((function(e){return Promise.all(e.map((function(e){return r.loadMipmapImage(e,o)})))})),[4,Promise.all(h)];case 3:f=p.sent(),d=f.map((function(n){return n.map((function(n){var r=e.generateGUID(),i={url:n,id:r};return t.images.push(i),{id:r}}))})),m=j({keepImageSource:!1},l,{mipmaps:d,sourceFrom:{target:u,type:e.TextureSourceType.mipmaps,mipmaps:c.map((function(e){return e.map((function(e){return[e[1][1],e[1][2]]}))}))}}),i.push(m),p.label=4;case 4:return[3,6];case 5:"number"==typeof(g=l.source)&&(l.source={id:t.images[g].id}),i.push(l),p.label=6;case 6:return[3,1];case 7:return t.textures=i,[2]}}))}))()},n.setComponent=function(t,n){for(var r,i=t.components,o=b(n.components);!(r=o()).done;){var a=r.value;if(a.dataType===e.spec.DataType.SkyboxComponent)i.push(this.createSkyboxComponent(a,t));else if(a.dataType===e.spec.DataType.LightComponent)i.push(this.createLightComponent(a,t));else if(a.dataType===e.spec.DataType.CameraComponent)i.push(a),console.warn("Camera component found: "+a+".");else if(a.dataType===e.spec.DataType.TreeComponent){var s=a;this.createItemsFromTreeComponent(a,t,n),s.options.tree.animation=void 0,s.options.tree.animations=void 0}else a.dataType!==e.spec.DataType.MeshComponent&&i.push(a)}for(var l,c=b(n.components);!(l=c()).done;){var u=l.value;u.dataType===e.spec.DataType.MeshComponent&&i.push(this.createMeshComponent(u,t,n))}},n.setItem=function(e,t){},n.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}}))},n.loadJSON=function(e){var t=this;return o((function(){return p(this,(function(n){return[2,new Promise((function(n,r){t.downloader.downloadJSON(e,n,(function(t,n){r(new Error("Failed to load JSON from URL '"+e+"': status "+t+" - "+n+". Please check the URL or network settings."))}))}))]}))}))()},n.loadBins=function(e){var t=this;return o((function(){return p(this,(function(n){return[2,new Promise((function(n,r){t.downloader.downloadBinary(e,n,(function(t,n){r("Couldn't load bins "+JSON.stringify(e)+": status "+t+", "+n)}))}))]}))}))()},n.loadMipmapImage=function(e,t){return o((function(){var n,r,i,o,a;return p(this,(function(s){if(n=e[1],r=n[0],i=n[1],o=n[2],!(a=t[r]))throw new Error("Invalid bin pointer: "+JSON.stringify(e)+".");return[2,URL.createObjectURL(new Blob([new Uint8Array(a,i,o)]))]}))}))()},n.createSkyboxComponent=function(e,t){var n,r,i,o=e.options;o.irradianceCoeffs&&(n=[],o.irradianceCoeffs.forEach((function(e){return(r=n).push.apply(r,[].concat(e))})));return o.diffuseImage&&(i={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:i,specularImage:{id:t.textures[o.specularImage].id},specularImageSize:o.specularImageSize,specularMipCount:o.specularMipCount+1}},n.createMeshComponent=function(e,t,n){var r,i=this,o=e.options,a=[],s=[];o.primitives.forEach((function(e){var t,r=$(e.geometry,n.bins),o=i.getMaterialData(e.material,n);if(l(null==(t=r.indices)?void 0:t.data,Uint8Array)){for(var c=r.indices.data,u=new Uint16Array(c.length),h=0;h<c.length;h++)u[h]=c[h];r.indices.data=u}a.push(r),s.push(o)}));var c=At(a);if(!c)throw new Error("No primitives available to process.");t.geometries.push(c),(r=t.materials).push.apply(r,[].concat(s));var u={id:e.id,dataType:e.dataType,item:e.item,geometry:{id:c.id},materials:s.map((function(e){return{id:e.id}}))};if(o.skin){for(var h,f=e.item.id,d=b(n.items);!(h=d()).done;){var p=h.value;p.id===e.item.id&&(f=p.parentId)}if(f===e.item.id)throw new Error("Can't item "+e.item+".");var m=this.treeInfo.getTreeItemByNodeId(f),g=this.treeInfo.getTreeNodeListByNodeId(f);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 v=this.setupBoneData(c,o.skin,n,m,g);u.rootBone={id:v.id}}return void 0!==o.weights&&(u.morph={weights:o.weights}),u},n.createItemsFromTreeComponent=function(t,n,r){var i=this,o=r.items[0];r.items.forEach((function(e){e.id===t.item.id&&(o=e)}));var a=t.options.tree,s=[];a.nodes.forEach((function(t,r){var a,l={id:e.generateGUID(),parentId:o.id,name:null!=(a=t.name)?a:"node"+r,duration:o.duration,type:"ECS",dataType:e.spec.DataType.VFXItemData,visible:o.visible,endBehavior:o.endBehavior,delay:o.delay,content:{},renderLevel:o.renderLevel,pn:o.pn,pluginName:o.pluginName,transform:i.getTransformData(t.transform),components:[]};s.push(l),n.items.push(l)})),a.nodes.forEach((function(e,t){var n,r=s[t];null==(n=e.children)||n.forEach((function(e){s[e].parentId=r.id}))})),r.items.forEach((function(e){if(e.parentId){var t=e.parentId.indexOf("^");if(t>=0){var n=e.parentId.substring(0,t),r=+e.parentId.substring(t+1);n===o.id&&(e.parentId=s[r].id)}}})),this.treeInfo.add(o,s),this.createAnimationComponent(a,o,n,r)},n.createLightComponent=function(e,t){var n=e.options,r={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?r.range=n.range:"spot"===n.lightType&&(r.range=n.range,r.innerConeAngle=n.innerConeAngle,r.outerConeAngle=n.outerConeAngle),r},n.createAnimationComponent=function(t,n,r,i){var o=this,a=t.animation,s=t.animations,c={id:e.generateGUID(),dataType:e.spec.DataType.AnimationComponent,item:{id:n.id},animation:a,animationClips:[]};if(s&&s.length){var u=i.bins;s.forEach((function(t){var a={id:e.generateGUID(),name:t.name,dataType:e.spec.DataType.AnimationClip,positionCurves:[],rotationCurves:[],scaleCurves:[],floatCurves:[]},s=0;t.tracks.forEach((function(e){var t=te(u,e.input);s=Math.max(s,t[t.length-1])})),t.tracks.forEach((function(t){var r=te(u,t.input),s=te(u,t.output);if(!l(r,Float32Array))throw new Error("Type of inputArray should be float32, "+r+".");if(!l(s,Float32Array))throw new Error("Type of outputArray should be float32, "+s+".");if("LINEAR"!==t.interpolation)throw new Error("Invalid interpolation type "+t.interpolation+".");if("rotation"===t.path){for(var c,h=[],f=[],d=[],p=0;p<r.length;p++){if(h.push([s[4*p],s[4*p+1],s[4*p+2],s[4*p+3]]),p>0){var m=U.fromArray(h[p-1]),g=U.fromArray(h[p]),v=new U,y=new U;v.slerpQuaternions(m,g,1/3),y.slerpQuaternions(m,g,2/3),f.push(v.toArray()),f.push(y.toArray())}d.push([e.spec.BezierKeyframeType.LINE,[r[p],p]])}var T=o.treeInfo.getTreeNode(n.id,t.node),x=o.treeInfo.getNodePath(T.id),b=[e.spec.ValueType.BEZIER_CURVE_QUAT,[d,h,f]];null==(c=a.rotationCurves)||c.push({path:x,keyFrames:b})}else if("weights"===t.path){var _=o.treeInfo.getTreeNode(n.id,t.node),C=o.treeInfo.getNodePath(_.id);if(0===_.components.length)for(var S=0;S<i.items.length;S++){var M=i.items[S];if(M.parentId===_.id){C+="/"+M.name;break}}for(var A=s.length/r.length,I=0;I<A;I++){for(var E,w=[],L=0;L<r.length;L++)w.push([e.spec.BezierKeyframeType.LINE,[r[L],s[L*A+I]]]);var P=[e.spec.ValueType.BEZIER_CURVE,w];null==(E=a.floatCurves)||E.push({path:C,className:"ModelMeshComponent",property:"morphWeights."+I,keyFrames:P})}}else{for(var R=[],O=[],F=[],D=0;D<r.length;D++){if(R.push([s[3*D],s[3*D+1],s[3*D+2]]),D>0){var B=N.fromArray(R[D-1]),k=N.fromArray(R[D]),V=(new N).lerpVectors(B,k,1/3),G=(new N).lerpVectors(B,k,2/3);O.push(V.toArray()),O.push(G.toArray())}F.push([e.spec.BezierKeyframeType.LINE,[r[D],D]])}var z,H,j=o.treeInfo.getTreeNode(n.id,t.node),W=o.treeInfo.getNodePath(j.id),J=[e.spec.ValueType.BEZIER_CURVE_PATH,[F,R,O]];if("translation"===t.path)null==(z=a.positionCurves)||z.push({path:W,keyFrames:J});else null==(H=a.scaleCurves)||H.push({path:W,keyFrames:J})}})),r.animations.push(a),c.animationClips.push({id:a.id})}))}n.components=[],n.components.push({id:c.id}),r.components.push(c)},n.getMaterialData=function(t,n){if(t.type===e.spec.MaterialType.unlit){var r={};void 0!==t.alphaCutOff&&(r._AlphaCutoff=t.alphaCutOff);var i={_BaseColorFactor:new O(t.baseColorFactor[0],t.baseColorFactor[1],t.baseColorFactor[2],t.baseColorFactor[3]).divide(255)},o={};t.baseColorTexture&&(o._BaseColorSampler=this.getTextureData(n,r,t.baseColorTexture,t.baseColorTextureTransform));var a={id:e.generateGUID(),name:t.name,dataType:e.spec.DataType.Material,shader:{id:J},stringTags:{},macros:[],ints:{},floats:r,vector4s:{},colors:i,textures:o};return this.setupMaterial(t,a),a}var s={_MetallicFactor:t.metallicFactor,_RoughnessFactor:t.roughnessFactor};void 0!==t.useSpecularAA&&(s._SpecularAA=t.useSpecularAA?1:0),void 0!==t.normalTextureScale&&(s._NormalScale=t.normalTextureScale),void 0!==t.occlusionTextureStrength&&(s._OcclusionStrength=t.occlusionTextureStrength),void 0!==t.emissiveIntensity&&(s._EmissiveIntensity=t.emissiveIntensity),void 0!==t.alphaCutOff&&(s._AlphaCutoff=t.alphaCutOff);var l={_BaseColorFactor:new O(t.baseColorFactor[0],t.baseColorFactor[1],t.baseColorFactor[2],t.baseColorFactor[3]).divide(255),_EmissiveFactor:new O(t.emissiveFactor[0],t.emissiveFactor[1],t.emissiveFactor[2],t.emissiveFactor[3]).divide(255)},c={};t.baseColorTexture&&(c._BaseColorSampler=this.getTextureData(n,s,t.baseColorTexture,t.baseColorTextureTransform)),t.metallicRoughnessTexture&&(c._MetallicRoughnessSampler=this.getTextureData(n,s,t.metallicRoughnessTexture,t.metallicRoughnessTextureTransform)),t.normalTexture&&(c._NormalSampler=this.getTextureData(n,s,t.normalTexture,t.normalTextureTransform)),t.occlusionTexture&&(c._OcclusionSampler=this.getTextureData(n,s,t.occlusionTexture,t.occlusionTextureTransform)),t.emissiveTexture&&(c._EmissiveSampler=this.getTextureData(n,s,t.emissiveTexture,t.emissiveTextureTransform));var u={id:e.generateGUID(),name:t.name,dataType:e.spec.DataType.Material,shader:{id:W},stringTags:{},macros:[],ints:{},floats:s,vector4s:{},colors:l,textures:c};return this.setupMaterial(t,u),u},n.setupMaterial=function(t,n){var r;(t.blending===e.spec.MaterialBlending.translucent?n.stringTags.RenderType=e.spec.RenderType.Transparent:n.stringTags.RenderType=e.spec.RenderType.Opaque,t.blending===e.spec.MaterialBlending.masked)?(n.floats.AlphaClip=1,n.floats._AlphaCutoff=null!=(r=t.alphaCutOff)?r:0):n.floats.AlphaClip=0;switch(t.side){case e.spec.SideMode.BACK:n.stringTags.RenderFace=e.spec.RenderFace.Back;break;case e.spec.SideMode.DOUBLE:n.stringTags.RenderFace=e.spec.RenderFace.Both;break;default:n.stringTags.RenderFace=e.spec.RenderFace.Front}t.type===e.spec.MaterialType.pbr&&(n.floats._SpecularAA=t.useSpecularAA?1:0),n.floats.ZWrite=!1!==t.depthMask?1:0,n.floats.ZTest=1},n.getTextureData=function(e,t,n,r){var i,o={texture:{id:null!=(i=e.textures[n].id)?i:"0"}};return r&&(r.scale&&(o.scale={x:r.scale[0],y:r.scale[1]}),r.offset&&(o.offset={x:r.offset[0],y:r.offset[1]}),r.rotation&&(t._BaseColorRotation=r.rotation)),o},n.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},n.setupBoneData=function(e,t,n,r,i){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=te(o,l);e.inverseBindMatrices=Array.from(c);var u={},h=r;void 0!==s?h=i[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=i[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=r)})),i.forEach((function(e){u[e.id]=e})),e.rootBoneName=h.name;var f=[];return a.forEach((function(e){for(var t=i[e],n=[];t&&t!=h&&(n.push(t.name),t.parentId);)t=u[t.parentId];f.push(n.reverse().join("/"))})),e.boneNames=f,h},t}(),Mt=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 r;(r=t).push.apply(r,[].concat(e.tree2NodeList[n]))})),t},t.getNodePath=function(e){return this.node2Path[e]},e}();function At(t){var n=function(e){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}(t[e]),l=r+(null!=(o=t[e].drawStart)?o:0),c=null!=(a=null==(n=t[0].indices)?void 0:n.data.BYTES_PER_ELEMENT)?a:1;if(i.push({offset:l*c,indexCount:s,vertexCount:s}),e){var u=t[0],h=t[e],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=wt(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 r=e.attributes[n];t=r.data.length/r.size})),t}(u);u.indices.data=wt(u.indices.data,h.indices.data,d)}Object.keys(u.attributes).forEach((function(e){var t=u.attributes[e],n=t.data,r=h.attributes[e].data;t.data=wt(n,r)}))}}r=l+s};if(!(t.length<=0)){for(var r=0,i=[],o=0;o<t.length;o++)n(o);return function(t,n){var r=0;for(var i in t.attributes){r+=t.attributes[i].data.byteLength}t.indices&&(r+=t.indices.data.byteLength);var o=0,a=0,s=new Uint8Array(r),c=[];for(var u in t.attributes){var h,f,d=t.attributes[u],p=null!=(h=Lt[u])?h:u;o=d.data.length/d.size;var m={semantic:p,offset:a,format:e.glType2VertexFormatType(null!=(f=d.type)?f:e.glContext.FLOAT),dimension:d.size,normalize:d.normalize};c.push(m);var g=d.data,v=new Uint8Array(g.buffer,g.byteOffset,g.byteLength);s.set(v,a),a+=v.byteLength}var y={id:e.generateGUID(),dataType:e.spec.DataType.Geometry,vertexData:{vertexCount:o,channels:c},subMeshes:n,mode:e.spec.GeometryType.TRIANGLES,indexFormat:e.spec.IndexFormatType.None,indexOffset:0,buffer:""};if(t.indices){var T=t.indices.data,x=new Uint8Array(T.buffer,T.byteOffset,T.byteLength);s.set(x,a),y.indexOffset=a,l(T,Uint32Array)?y.indexFormat=e.spec.IndexFormatType.UInt32:y.indexFormat=e.spec.IndexFormatType.UInt16}return y.buffer=function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}(s),y}(t[0],i)}}function It(t,n,r){switch(t){case e.spec.VertexFormatType.Int8:case e.spec.VertexFormatType.UInt8:return n*r;case e.spec.VertexFormatType.Int16:case e.spec.VertexFormatType.UInt16:return n*r*2;default:return n*r*4}}function Et(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),r=new Uint8Array(e.normals.buffer,e.normals.byteOffset,e.normals.byteLength),i=new Uint8Array(e.indices.buffer,e.indices.byteOffset,e.indices.byteLength),o=t.byteLength+n.byteLength+r.byteLength+i.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,r.byteLength)).set(r),new Uint8Array(a,t.byteLength+n.byteLength+r.byteLength,i.byteLength).set(i);for(var l=new Uint8Array(a),c="",u=0;u<l.length;u++)c+=String.fromCharCode(l[u]);return btoa(c)}function wt(e,t,n){if(l(e,Float32Array)){var r=new Float32Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}if(l(e,Int32Array)){var i=new Int32Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}if(l(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(l(e,Int16Array)){var s=new Int16Array(e.length+t.length);return s.set(e),s.set(t,e.length),s}if(l(e,Uint16Array)){var c=new Uint16Array(e.length+t.length);if(c.set(e),c.set(t,e.length),n)for(var u=0;u<t.length;u++)c[e.length+u]+=n;return c}if(l(e,Int8Array)){var h=new Int8Array(e.length+t.length);return h.set(e),h.set(t,e.length),h}var f=new Uint8Array(e.length+t.length);return f.set(e),f.set(t,e.length),f}var Nt,Lt={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"};var Pt=function(){function t(t){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 B,t?this.composition=t:(this.timelineAssetId=e.generateGUID(),this.composition={id:"1",name:"test1",duration:99999,endBehavior:e.spec.EndBehavior.restart,camera:{fov:45,far:2e3,near:.001,position:[0,0,8],rotation:[0,0,0],clipMode:e.spec.CameraClipMode.portrait},items:[],timelineAsset:{id:this.timelineAssetId},sceneBindings:[]})}var n=t.prototype;return n.loadScene=function(t){var n=this;return o((function(){var r,i,a,s,c,u,h,f,d;return p(this,(function(m){switch(m.label){case 0:if(n.clear(),n.sceneOptions=t,n.loaderOptions={compatibleMode:t.gltf.compatibleMode},"string"==typeof(c=t.gltf.resource)||l(c,Uint8Array))throw new Error("Please load the resource using GLTFTools first.");return n.images=c.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(n.images.map(o((function(t){return p(this,(function(n){return[2,e.loadImage(t.url)]}))}))))];case 1:if(n.imageElements=m.sent(),n.processGLTFResource(c,n.imageElements),n.gltfMeshs=c.meshes,n.gltfTextures=c.textures,n.gltfMaterials=c.materials,n.gltfAnimations=c.animations,n.gltfImageBasedLights=c.imageBasedLights,n.textures=n.gltfTextures.map((function(e){var t=e.textureOptions,r=t.source;return"number"==typeof r&&(t.source={id:n.images[r].id}),t})),n.materials=n.gltfMaterials.map((function(e){return e.materialData})),c.meshes.forEach((function(e){n.geometries.push(e.geometryData)})),(u=c.scenes[0]).meshesComponentData.forEach((function(e){return n.checkMeshComponentData(e,c)})),(r=n.components).push.apply(r,[].concat(u.camerasComponentData)),(i=n.components).push.apply(i,[].concat(u.lightsComponentData)),(a=n.components).push.apply(a,[].concat(u.meshesComponentData)),1===u.animationsComponentData.length)h=u.animationsComponentData[0],t.effects.playAllAnimation||void 0===t.effects.playAnimation||(f=h.animationClips,(d=t.effects.playAnimation)>=0&&d<f.length?h.animationClips=[f[d]]:h.animationClips=[]),n.components.push(h);else if(u.animationsComponentData.length>1)throw new Error("Find many animation component data "+u.animationsComponentData.length);return n.animations=[],n.gltfAnimations.forEach((function(e){n.animations.push(e.animationClipData)})),n.items=[],[4,n.tryAddSkybox({skyboxType:t.gltf.skyboxType,renderable:t.gltf.skyboxVis})];case 2:return m.sent(),(s=n.items).push.apply(s,[].concat(c.scenes[0].vfxItemData)),n.items.forEach((function(e){"root"===e.type&&(e.type="ECS")})),[2,n.getLoadResult()]}}))}))()},n.processGLTFResource=function(t,n){var r=function(){var t=f.value;if(h.has(t)){var n=a.find((function(e){return e.textureOptions.id===t}));if(n){var r=e.generateGUID(),i=n.clone();i.textureOptions.id=r,a.push(i),o[r]=i.textureOptions,p[t]=r,d+=1}}},i=this,o={},a=t.textures,s=t.materials,l=t.scenes,c=t.imageBasedLights;a.forEach((function(e){var t=e.textureOptions,n=t.id;n?(o[n]&&console.error("Duplicate GUID found: "+n+", old "+o[n]+", new "+t+"."),o[n]=t):console.error("No GUID in texture Data: "+t+".")}));var u=new Set,h=new Set;s.forEach((function(e){var t,n,r=e.materialData,i=null==(t=r.textures._BaseColorSampler)?void 0:t.texture,o=null==(n=r.textures._EmissiveSampler)?void 0:n.texture;i&&u.add(i.id),o&&h.add(o.id)}));for(var f,d=0,p={},m=b(u);!(f=m()).done;)r();d>0&&console.warn("Add base color texture "+d),s.forEach((function(e){var t,r,a=e.materialData;if(i.processMaterialData(a),(null==(t=a.shader)?void 0:t.id)===J)i.processMaterialTexture(a,"_BaseColorSampler",!0,o,n);else if((null==(r=a.shader)?void 0:r.id)===W){var s,l=null==(s=a.textures._EmissiveSampler)?void 0:s.texture;l&&p[l.id]&&(l.id=p[l.id]),i.processMaterialTexture(a,"_BaseColorSampler",!0,o,n),i.processMaterialTexture(a,"_MetallicRoughnessSampler",!1,o,n),i.processMaterialTexture(a,"_NormalSampler",!1,o,n),i.processMaterialTexture(a,"_OcclusionSampler",!1,o,n),i.processMaterialTexture(a,"_EmissiveSampler",!1,o,n)}}));var g=l[0];g.camerasComponentData.forEach((function(e){return i.processCameraComponentData(e)})),g.lightsComponentData.forEach((function(e){return i.processLightComponentData(e)}));var v=[];c.forEach((function(t){var n=t.imageBaseLightData;if(void 0===n.reflectionsIntensity&&(n.reflectionsIntensity=n.intensity),n.diffuseImage){var r=o[n.diffuseImage.id];e.addItem(v,r)}if(n.specularImage){var i=o[n.specularImage.id];e.addItem(v,i)}})),v.forEach((function(t){if(t.target===e.glContext.TEXTURE_CUBE_MAP){var n=t;n.mipmaps.forEach((function(e){var t;t=[e[5],e[4]],e[4]=t[0],e[5]=t[1]})),1===n.mipmaps.length?(n.minFilter=e.glContext.LINEAR,n.magFilter=e.glContext.LINEAR):(n.minFilter=e.glContext.LINEAR_MIPMAP_LINEAR,n.magFilter=e.glContext.LINEAR)}}))},n.processComponentData=function(t){var n=this;t.forEach((function(t){t.dataType===e.spec.DataType.LightComponent?n.processLightComponentData(t):t.dataType===e.spec.DataType.CameraComponent?n.processCameraComponentData(t):t.dataType===e.spec.DataType.SkyboxComponent&&n.processSkyboxComponentData(t)}))},n.processLightComponentData=function(t){t.color||(t.color={r:1,g:1,b:1,a:1}),t.intensity||(t.intensity=1),t.lightType===e.spec.LightType.point?t.range||(t.range=0):t.lightType===e.spec.LightType.spot&&(t.range||(t.range=0),t.innerConeAngle||(t.innerConeAngle=0),t.outerConeAngle||(t.outerConeAngle=Math.PI/4))},n.processCameraComponentData=function(t){t.type===e.spec.CameraType.perspective&&t.fov&&(t.fov*=Math.PI/180)},n.processSkyboxComponentData=function(e){void 0===e.intensity&&(e.intensity=1),void 0===e.reflectionsIntensity&&(e.reflectionsIntensity=1)},n.processMaterialData=function(t){var n,r;(null==(n=t.shader)?void 0:n.id)===J?(t.colors._BaseColorFactor||(t.colors._BaseColorFactor={r:1,g:1,b:1,a:1}),void 0===t.floats._AlphaCutoff&&(t.floats._AlphaCutoff=0),void 0===t.floats.ZWrite&&(t.floats.ZWrite=1),void 0===t.floats.ZTest&&(t.floats.ZTest=1),t.stringTags.RenderType||(t.stringTags.RenderType=e.spec.RenderType.Opaque),t.stringTags.RenderFace||(t.stringTags.RenderFace=e.spec.RenderFace.Front)):(null==(r=t.shader)?void 0:r.id)===W?(t.colors._BaseColorFactor||(t.colors._BaseColorFactor={r:1,g:1,b:1,a:1}),void 0===t.floats._SpecularAA&&(t.floats._SpecularAA=0),void 0===t.floats._MetallicFactor&&(t.floats._MetallicFactor=1),void 0===t.floats._RoughnessFactor&&(t.floats._RoughnessFactor=0),void 0===t.floats._NormalScale&&(t.floats._NormalScale=1),void 0===t.floats._OcclusionStrength&&(t.floats._OcclusionStrength=this.isTiny3dMode()?0:1),t.colors._EmissiveFactor||(t.colors._EmissiveFactor={r:0,g:0,b:0,a:1}),void 0===t.floats._EmissiveIntensity&&(t.floats._EmissiveIntensity=1),void 0===t.floats._AlphaCutoff&&(t.floats._AlphaCutoff=0),void 0===t.floats.ZWrite&&(t.floats.ZWrite=1),void 0===t.floats.ZTest&&(t.floats.ZTest=1),t.stringTags.RenderType||(t.stringTags.RenderType=e.spec.RenderType.Opaque),t.stringTags.RenderFace||(t.stringTags.RenderFace=e.spec.RenderFace.Front)):console.error("Encountered unknown shader ID in material with ID: "+t.id+".")},n.processTextureOptions=function(t,n,r){var i,o=!1,a=null!=(i=t.minFilter)?i:e.glContext.LINEAR_MIPMAP_LINEAR;this.isTiny3dMode()&&(a=e.glContext.LINEAR_MIPMAP_LINEAR,r&&(Oe.isPow2(r.width)&&Oe.isPow2(r.height)||(a=e.glContext.LINEAR)),o=!n);var s,l,c,u=a==e.glContext.NEAREST_MIPMAP_NEAREST||a==e.glContext.LINEAR_MIPMAP_NEAREST||a==e.glContext.NEAREST_MIPMAP_LINEAR||a==e.glContext.LINEAR_MIPMAP_LINEAR;t.wrapS=null!=(s=t.wrapS)?s:e.glContext.REPEAT,t.wrapT=null!=(l=t.wrapT)?l:e.glContext.REPEAT,t.magFilter=null!=(c=t.magFilter)?c:e.glContext.LINEAR,t.minFilter=a,t.anisotropic=1,t.premultiplyAlpha=o,t.generateMipmap=u},n.initial=function(e,t){this.engine=e,this.loaderOptions=null!=t?t:{}},n.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+").")},n.processMaterialTexture=function(e,t,n,r,i){var o=e.textures[t];if(o){var a,s=r[o.texture.id];if("number"!=typeof s.source)throw new Error("Invalid texture option source data, "+s.source);a=i[s.source],s&&this.processTextureOptions(s,n,a)}},n.getLoadResult=function(){var t=[];this.items.forEach((function(e){return t.push({id:e.id})})),this.composition.items=t;var n={version:e.spec.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:e.spec.DataType.TimelineAsset}]},r=this.computeSceneAABB();return{source:this.getRemarkString(),jsonScene:n,sceneAABB:{min:r.min.toArray(),max:r.max.toArray()}}},n.addLight=function(t){var n=e.generateGUID(),r={id:e.generateGUID(),item:{id:n},dataType:e.spec.DataType.LightComponent,lightType:t.lightType,color:t.color,intensity:t.intensity,range:t.range,innerConeAngle:t.innerConeAngle,outerConeAngle:t.outerConeAngle,followCamera:t.followCamera},i={id:n,name:t.name,duration:t.duration,type:e.spec.ItemType.light,pn:0,visible:!0,endBehavior:t.endBehavior,transform:{position:{x:t.position[0],y:t.position[1],z:t.position[2]},eulerHint:{x:t.rotation[0],y:t.rotation[1],z:t.rotation[2]},scale:{x:t.scale[0],y:t.scale[1],z:t.scale[2]}},components:[{id:r.id}],content:{},dataType:e.spec.DataType.VFXItemData};this.items.push(i),this.components.push(r)},n.addCamera=function(t){var n=e.generateGUID(),r={id:e.generateGUID(),item:{id:n},dataType:e.spec.DataType.CameraComponent,fov:t.fov,near:t.near,far:t.far,clipMode:t.clipMode},i={id:n,name:t.name,duration:t.duration,type:"camera",pn:0,visible:!0,endBehavior:t.endBehavior,transform:{position:{x:t.position[0],y:t.position[1],z:t.position[2]},eulerHint:{x:t.rotation[0],y:t.rotation[1],z:t.rotation[2]},scale:{x:1,y:1,z:1}},components:[{id:r.id}],content:{},dataType:e.spec.DataType.VFXItemData};this.items.push(i),this.components.push(r)},n.addSkybox=function(t){var n,r,i,o=e.generateGUID(),a=st.createSkyboxComponentData(t),s=a.imageList,l=a.textureOptionsList,c=a.component;c.item.id=o,void 0!==t.intensity&&(c.intensity=t.intensity),void 0!==t.reflectionsIntensity&&(c.reflectionsIntensity=t.reflectionsIntensity),c.renderable=null!=(i=t.renderable)&&i;var u={id:o,name:"Skybox-Customize",duration:999,type:e.spec.ItemType.skybox,pn:0,visible:!0,endBehavior:e.spec.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:e.spec.DataType.VFXItemData};(n=this.images).push.apply(n,[].concat(s)),(r=this.textures).push.apply(r,[].concat(l)),this.items.push(u),this.components.push(c)},n.tryAddSkybox=function(t){var n=this;return o((function(){var r,i,o,a,s,l,c,u,h,f,d;return p(this,(function(p){return n.gltfImageBasedLights.length>0&&!n.ignoreSkybox()?(r=n.gltfImageBasedLights[0],n.components.push(r.imageBaseLightData)):void 0!==t.skyboxType&&(a=e.generateGUID(),s=n.createSkyboxComponentData(t.skyboxType),l=s.imageList,c=s.textureOptionsList,(u=s.component).item.id=a,void 0!==t.intensity&&(u.intensity=t.intensity),void 0!==t.reflectionsIntensity&&(u.reflectionsIntensity=t.reflectionsIntensity),u.renderable=null!=(h=t.renderable)&&h,d={id:a,name:"Skybox-"+t.skyboxType,duration:null!=(f=t.duration)?f:999,type:e.spec.ItemType.skybox,pn:0,visible:!0,endBehavior:e.spec.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:e.spec.DataType.VFXItemData},(i=n.images).push.apply(i,[].concat(l)),(o=n.textures).push.apply(o,[].concat(c)),n.items.push(d),n.components.push(u)),[2]}))}))()},n.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?exports.PSkyboxType.NFT:exports.PSkyboxType.FARM,n=st.getSkyboxParams(t);return st.createSkyboxComponentData(n)},n.dispose=function(){this.clear(),this.engine=null},n.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=[]},n.computeSceneAABB=function(){var t={};this.gltfMeshs.forEach((function(e){var n=e.geometryData.id;t[n]=e}));var n={};this.components.forEach((function(r){if(r.dataType===e.spec.DataType.MeshComponent){var i=r;n[r.id]=t[i.geometry.id]}}));var r=new B,i={};return this.items.forEach((function(t){var o,a,s=null!=(o=t.parentId)?o:"",l=null!=(a=i[s])?a:new e.Transform,c={};t.transform&&(c.position=(new N).copyFrom(t.transform.position),c.rotation=F.fromVector3(t.transform.eulerHint),c.scale=(new N).copyFrom(t.transform.scale));var u=new e.Transform(c,l);i[t.id]=u,t.components.forEach((function(e){var t=n[e.id];if(t&&t.bounds){var i=N.fromArray(t.bounds.box.min),o=N.fromArray(t.bounds.box.max);r.union(new B(i,o))}}))})),r},n.isPlayAnimation=function(){return void 0!==this.sceneOptions.effects.playAnimation},n.isPlayAllAnimation=function(){return!0===this.sceneOptions.effects.playAllAnimation},n.getRemarkString=function(){var e=this.sceneOptions.gltf.remark;return void 0===e?"Unknown":"string"==typeof e?e:"BinaryBuffer"},n.getCompositionDuration=function(){return this.composition.duration},n.isTiny3dMode=function(){return"tiny3d"===this.loaderOptions.compatibleMode},n.getItemDuration=function(){var e;return null!=(e=this.sceneOptions.effects.duration)?e:9999},n.getEndBehavior=function(){var t;return null!=(t=this.sceneOptions.effects.endBehavior)?t:e.spec.EndBehavior.restart},n.getSkyboxType=function(){switch(this.sceneOptions.gltf.skyboxType){case"NFT":return exports.PSkyboxType.NFT;case"FARM":return exports.PSkyboxType.FARM}},n.isSkyboxVis=function(){return!0===this.sceneOptions.gltf.skyboxVis},n.ignoreSkybox=function(){return!0===this.sceneOptions.gltf.ignoreSkybox},n.isEnvironmentTest=function(){return"string"==typeof this.sceneOptions.gltf.remark&&this.sceneOptions.gltf.remark.includes("EnvironmentTest")},n.processLight=function(e,t){var n=this;e.forEach((function(e){void 0===e.color?e.color=t?[255,255,255,255]:[1,1,1,1]:(e.color[0]=n.scaleColorVal(e.color[0],t),e.color[1]=n.scaleColorVal(e.color[1],t),e.color[2]=n.scaleColorVal(e.color[2],t),e.color[3]=n.scaleColorVal(e.color[3],t))}))},n.processCamera=function(e,t){var n=t?180/Math.PI:Math.PI/180;e.forEach((function(e){void 0!==e.perspective&&(e.perspective.yfov*=n)}))},n.processMaterial=function(e,t){var n=this;e.forEach((function(e){void 0===e.baseColorFactor?e.baseColorFactor=t?[255,255,255,255]:[1,1,1,1]:(e.baseColorFactor[0]=n.scaleColorVal(e.baseColorFactor[0],t),e.baseColorFactor[1]=n.scaleColorVal(e.baseColorFactor[1],t),e.baseColorFactor[2]=n.scaleColorVal(e.baseColorFactor[2],t),e.baseColorFactor[3]=n.scaleColorVal(e.baseColorFactor[3],t)),void 0===e.emissiveFactor?e.emissiveFactor=t?[255,255,255,255]:[1,1,1,1]:(e.emissiveFactor[0]=n.scaleColorVal(e.emissiveFactor[0],t),e.emissiveFactor[1]=n.scaleColorVal(e.emissiveFactor[1],t),e.emissiveFactor[2]=n.scaleColorVal(e.emissiveFactor[2],t),e.emissiveFactor[3]=n.scaleColorVal(e.emissiveFactor[3],t)),t&&void 0!==e.occlusionTexture&&void 0===e.occlusionTexture.strength&&(e.occlusionTexture.strength=n.isTiny3dMode()?0:1)}))},n.createAnimations=function(e){return e.map((function(e){var t=e.channels.map((function(e){return{input:e.input.array,output:e.output.array,node:e.target.node,path:e.target.path,interpolation:e.interpolation}}));return{name:e.name,tracks:t}}))},n.createGeometry=function(e,t){return new Rt(this.engine,e,t).geometry},n.createMaterial=function(e){return new Ot(e,[],this.isTiny3dMode()).material},n.createTexture2D=function(e,t,n){return Oe.createTexture2D(this.engine,e,t,n,this.isTiny3dMode())},n.createTextureCube=function(e,t){var n=this;if(0==e.length)throw new Error("createTextureCube: Invalid cubeImages length "+e);var r=[];return e.forEach((function(e){if(6!=e.length)throw new Error("createTextureCube: cubeimage count should always be 6, "+e);var t,i=[];(e.forEach((function(e){if(void 0===e.imageData)throw new Error("createTextureCube: Invalid image data from "+e);i.push({type:"buffer",data:e.imageData,mimeType:e.mimeType})})),n.isTiny3dMode())&&(t=[i[5],i[4]],i[4]=t[0],i[5]=t[1]);r.push(i)})),1==r.length?Oe.createTextureCubeFromBuffer(this.engine,r[0]):Oe.createTextureCubeMipmapFromBuffer(this.engine,r,null!=t?t:Math.pow(2,r.length-1))},n.createSkybox=function(e){var t,n,r=this,i=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}}));r.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:i,irradianceCoeffs:c,specularImage:a,specularMipCount:s,specularImageSize:l};return st.createSkyboxOptions(this.engine,u)},n.createDefaultSkybox=function(e){if("NFT"!==e&&"FARM"!==e)throw new Error("Invalid skybox type name "+e);var t="NFT"===e?exports.PSkyboxType.NFT:exports.PSkyboxType.FARM,n=st.getSkyboxParams(t);return st.createSkyboxOptions(this.engine,n)},n.scaleColorVal=function(e,t){return t?Ct.scaleTo255(e):Ct.scaleTo1(e)},n.scaleColorVec=function(e,t){var n=this;return e.map((function(e){return n.scaleColorVal(e,t)}))},t}();var Rt=function(){function t(e,t,n){this.engine=e,this.gltfGeometry=t,this.hasSkinAnimation=n}var n=t.prototype;return n._getBufferAttrib=function(e){return{type:e.type,size:e.itemSize,data:e.array,normalize:e.normalized}},n.texCoordAttrib=function(e){return this.gltfGeometry.getTexCoord(e)},n.getTargetPosition=function(e){return this.gltfGeometry.getAttribute("POSITION"+e)},n.getTargetNormal=function(e){return this.gltfGeometry.getAttribute("NORMAL"+e)},n.getTargetTangent=function(e){return this.gltfGeometry.getAttribute("TANGENT"+e)},H(t,[{key:"geometry",get:function(){var t=this,n={};if(!this.hasPosition)throw new Error("Position attribute missing");var r=this.positionAttrib;if(n.a_Position=this._getBufferAttrib(r),this.hasNormal){var i=this.normalAttrib;void 0!==i&&(n.a_Normal=this._getBufferAttrib(i))}if(this.hasTangent){var o=this.tangentAttrib;void 0!==o&&(n.a_Tangent=this._getBufferAttrib(o))}if(this.texCoordList.forEach((function(e){var r=t.texCoordAttrib(e);n["a_UV"+(e+1)]=t._getBufferAttrib(r)})),this.hasSkinAnimation){var a=this.jointAttribute;void 0!==a&&(n.a_Joint1=this._getBufferAttrib(a));var s=this.weightAttribute;void 0!==s&&(n.a_Weight1=this._getBufferAttrib(s))}for(var l=0;l<8;l++){var c=this.getTargetPosition(l);void 0!==c&&(n["a_Target_Position"+l]=this._getBufferAttrib(c));var u=this.getTargetNormal(l);void 0!==u&&(n["a_Target_Normal"+l]=this._getBufferAttrib(u));var h=this.getTargetTangent(l);void 0!==h&&(n["a_Target_Tangent"+l]=this._getBufferAttrib(h))}var f=this.indexArray;return void 0!==f?e.Geometry.create(this.engine,{attributes:n,indices:{data:f},drawStart:0,drawCount:f.length,mode:e.glContext.TRIANGLES}):e.Geometry.create(this.engine,{attributes:n,drawStart:0,drawCount:this.positionAttrib.array.length/3,mode:e.glContext.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}}]),t}(),Ot=function(){function t(e,t,n){this.gltfMaterial=e,this.textures=t,this.tiny3dMode=n}var n=t.prototype;return n.getTextureObject=function(e){if(!(e<0||e>=this.textures.length))return this.textures[e]},n.getTextureObj=function(e){return e?this.getTextureObject(e.index):void 0},n.getTextureCoord=function(e){return e?e.texCoord:void 0},n.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}},n.getSpecularAA=function(){var e;return null==(e=this.gltfMaterial.extras)?void 0:e.useSpecularAA},H(t,[{key:"material",get:function(){var t=this.gltfMaterial,n=Ft.isUnlitMaterial(t),r=e.spec.MaterialBlending.opaque;switch(t.alphaMode){case"OPAQUE":r=e.spec.MaterialBlending.opaque;break;case"MASK":r=e.spec.MaterialBlending.masked;break;case"BLEND":r=e.spec.MaterialBlending.translucent}var i,o,a,s=t.doubleSided?e.spec.SideMode.DOUBLE:e.spec.SideMode.FRONT,l=null!=(i=t.alphaCutOff)?i:.5,c=t.name;return n?{name:c,type:e.spec.MaterialType.unlit,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,depthMask:null==(o=t.extras)?void 0:o.depthMask,blending:r,alphaCutOff:l,side:s}:{name:c,type:e.spec.MaterialType.pbr,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,useSpecularAA:this.getSpecularAA(),metallicRoughnessTexture:this.metallicRoughnessTextureObj,metallicRoughnessTextureCoordinate:this.metallicRoughnessTextureCoord,metallicRoughnessTextureTransform:this.metallicRoughnessTextureTransfrom,metallicFactor:this.metalicFactor,roughnessFactor:this.roughnessFactor,normalTexture:this.normalTextureObj,normalTextureCoordinate:this.normalTextureCoord,normalTextureTransform:this.normalTextureTransfrom,normalTextureScale:this.normalTextureScale,occlusionTexture:this.occlusionTextureObj,occlusionTextureCoordinate:this.occlusionTextureCoord,occlusionTextureTransform:this.occlusionTextureTransfrom,occlusionTextureStrength:this.occlusionTextureStrength,emissiveTexture:this.emissiveTextureObj,emissiveTextureCoordinate:this.emissiveTextureCoord,emissiveTextureTransform:this.emissiveTextureTransfrom,emissiveFactor:this.emissiveFactor,emissiveIntensity:1,depthMask:null==(a=t.extras)?void 0:a.depthMask,blending:r,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]}}]),t}(),Ft=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=N.fromArray(e.box.min),n=N.fromArray(e.box.max);return new B(t,n)},e}();e.registerPlugin("model",xt);var Dt="2.8.4";e.logger.info("Plugin model version: 2.8.4."),Dt!==n.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!"),exports.Box3=B,exports.BoxMesh=le,exports.CameraGestureHandlerImp=_t,exports.CheckerHelper=We,exports.Color=O,exports.CompositionCache=lt,exports.CompositionHitTest=function(e,t,n){var r=e.hitTest(t,n,!0),i=e.getHitTestRay(t,n);if(r.length<=0)return[];var o=i.origin,a=i.direction,s=r.map((function(e,t){for(var n,r=e.position,i=[0,0,0],s=0;s<3;s++)i[s]=(r.getElement(s)-o.getElement(s))/a.getElement(s);return[t,(n=Math).max.apply(n,[].concat(i))]}));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 r[e[0]]}))},exports.DEG2RAD=G,exports.Euler=F,exports.EulerOrder=D,exports.FBOOptions=se,exports.Float16ArrayWrapper=Je,exports.GeometryBoxProxy=He,exports.HitTestingProxy=je,exports.HookOGLFunc=function(e){console.info("HookOGLFunc "+Object.getPrototypeOf(e));var t=0;for(var n in Object.getPrototypeOf(e))"getError"!==n&&"function"==typeof e[n]&&(++t,e[n+ne]=e[n],e[n]=oe(e,n));console.info("HookCount "+t),function(e){for(var t in Object.getPrototypeOf(e))"number"==typeof e[t]&&re.set(e[t],t)}(e)},exports.InterpolationSampler=m,exports.JSONConverter=St,exports.LoaderHelper=Ct,exports.LoaderImpl=Pt,exports.Matrix3=P,exports.Matrix4=R,exports.MeshHelper=Be,exports.ModelPlugin=xt,exports.PAnimTexture=Qe,exports.PBRShaderGUID=W,exports.PCamera=ut,exports.PCameraManager=ht,exports.PCoordinate=q,exports.PEntity=Q,exports.PGeometry=vt,exports.PGlobalState=Y,exports.PLight=ft,exports.PLightManager=dt,exports.PMaterialBase=et,exports.PMaterialPBR=nt,exports.PMaterialSkyboxFilter=at,exports.PMaterialUnlit=tt,exports.PMesh=mt,exports.PMorph=Ke,exports.PObject=K,exports.PSceneManager=Tt,exports.PShaderManager=$e,exports.PSkin=Ze,exports.PSkybox=ot,exports.PSkyboxCreator=st,exports.PSubMesh=gt,exports.PTransform=X,exports.PluginHelper=ke,exports.Quaternion=U,exports.Ray=V,exports.RayBoxTesting=Ee,exports.RayIntersectsBoxWithRotation=Ie,exports.RayTriangleTesting=Re,exports.Sphere=k,exports.ToggleItemBounding=function(e,t){var n;null==(n=e.items)||n.forEach((function(e){if(e.type===r){var n=e.getComponent(exports.ModelMeshComponent);if(n){var i=n.content;e.id===t?i.visBoundingBox=!0:i.visBoundingBox=!1}}}))},exports.TwoStatesSet=Se,exports.UnlitShaderGUID=J,exports.VFX_ITEM_TYPE_3D=r,exports.Vector2=w,exports.Vector3=N,exports.Vector4=L,exports.VertexAttribBuffer=Ge,exports.WebGLHelper=Oe,exports.WebHelper=Ve,exports.createAnimationSampler=function(e,t,n,r,i){switch(e){case"LINEAR":return"rotation"===i?new T(t,n,r):new g(t,n,r);case"STEP":return new v(t,n,r);default:return new g(t,n,r)}},exports.createPluginMaterial=rt,exports.fetchPBRShaderCode=me,exports.fetchUnlitShaderCode=ge,exports.getDefaultEffectsGLTFLoader=function(e,t){return Nt||(Nt=new Pt),Nt.initial(e,t),Nt},exports.getDefaultPBRMaterialData=function(){return{id:"00000000000000000000000000000000",name:"PBR Material",dataType:e.spec.DataType.Material,stringTags:{RenderType:e.spec.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:{}}},exports.getDefaultUnlitMaterialData=function(){return{id:"00000000000000000000000000000000",name:"Unlit Material",dataType:e.spec.DataType.Material,stringTags:{ZWrite:"true",ZTest:"true",RenderType:e.spec.RenderType.Opaque,Cull:"Front"},macros:[],shader:{id:e.spec.BuiltinObjectGUID.UnlitShader},ints:{},floats:{_AlphaCutoff:.5},vector4s:{},colors:{_BaseColorFactor:{r:1,g:1,b:1,a:1}},textures:{}}},exports.getDiffuseOnlyShaderCode=function(e){return{vertexShaderCode:Ce({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 "}},exports.getGaussianBlurShaderCodeV1=function(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 "}},exports.getGaussianBlurShaderCodeV2=_e,exports.getGeometryDataFromOptions=function(t){var n,r=0,i=e.spec.VertexFormatType.Float32,o=!1,a=e.spec.VertexFormatType.Float32,s=!1,l=e.spec.VertexFormatType.Float32,c=!1,u={vertices:new Float32Array,uvs:new Float32Array,normals:new Float32Array,indices:new Float32Array,name:null!=(n=t.name)?n:"<empty>"};for(var h in t.attributes){var f,d,p=t.attributes[h];if("aPosition"===h)r=p.data.length/p.size,u.vertices=p.data,o=null!=(f=p.normalize)&&f,i=e.glType2VertexFormatType(null!=(d=p.type)?d:e.glContext.FLOAT);else if("aNormal"===h){var m,g;u.normals=p.data,c=null!=(m=p.normalize)&&m,l=e.glType2VertexFormatType(null!=(g=p.type)?g:e.glContext.FLOAT)}else if("aUV1"===h){var v,y;u.uvs=p.data,s=null!=(v=p.normalize)&&v,a=e.glType2VertexFormatType(null!=(y=p.type)?y:e.glContext.FLOAT)}}var T=It(i,3,r),x=It(a,2,r),b=It(l,3,r);if(t.indices)u.indices=t.indices.data;else if(r<=65535){for(var _=new Uint16Array(r),C=0;C<r;C++)_[C]=C;u.indices=_}else{for(var S=new Uint32Array(r),M=0;M<r;M++)S[M]=M;u.indices=S}var A=e.spec.IndexFormatType.UInt16;return 4===u.indices.BYTES_PER_ELEMENT&&(A=e.spec.IndexFormatType.UInt32),{id:e.generateGUID(),dataType:e.spec.DataType.Geometry,vertexData:{vertexCount:r,channels:[{semantic:e.spec.VertexBufferSemantic.Position,offset:0,format:i,dimension:3,normalize:o},{semantic:e.spec.VertexBufferSemantic.Uv,offset:T,format:a,dimension:2,normalize:s},{semantic:e.spec.VertexBufferSemantic.Normal,offset:T+x,format:l,dimension:3,normalize:c}]},subMeshes:[],mode:e.spec.GeometryType.TRIANGLES,indexFormat:A,indexOffset:T+x+b,buffer:Et(u)}},exports.getGeometryDataFromPropsList=At,exports.getKawaseBlurShaderCode=function(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 "}},exports.getNormalVisShaderCode=xe,exports.getPBRPassShaderCode=ve,exports.getPBRShaderProperties=function(){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 '},exports.getPMeshList=function(e){var t=[],n=e.getCompositions()[0];return null==n||n.items.forEach((function(e){if(e.type===r){var n=e.getComponent(exports.ModelMeshComponent);(null==n?void 0:n.content.type)===exports.PObjectType.mesh&&t.push(n.content)}})),t},exports.getQuadFilterShaderCode=function(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 "}},exports.getRendererGPUInfo=function(e){var t=e.gpuCapability;return JSON.stringify(t,void 0,2)},exports.getSceneManager=bt,exports.getShadowPassShaderCode=ye,exports.getSimpleFilterShaderCode=be,exports.getSkyBoxShaderCode=Te,exports.getTransparecyBaseShader=function(e){return e?Ce({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 "},exports.getTransparecyFilterShader=function(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 "},exports.getUnlitShaderProperties=function(){return'\n _BaseColorSampler ("基础贴图", 2D) = "" {}\n _BaseColorFactor ("基础颜色", Color) = (1, 1, 1, 1)\n _AlphaCutoff ("Alpha裁剪值", Range(0, 1)) = 0.5\n '},exports.setDefaultEffectsGLTFLoader=function(e){Nt=e},exports.version=Dt;
|
|
2
2
|
//# sourceMappingURL=weapp.js.map
|