@galacean/effects-plugin-model 2.0.0-alpha.2 → 2.0.0-alpha.21
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 +13071 -0
- package/dist/alipay.js.map +1 -0
- package/dist/alipay.mjs +12952 -0
- package/dist/alipay.mjs.map +1 -0
- package/dist/gesture/index.d.ts +2 -2
- package/dist/gltf/index.d.ts +2 -1
- package/dist/gltf/json-converter.d.ts +53 -0
- package/dist/gltf/loader-ext.d.ts +6 -37
- package/dist/gltf/loader-impl.d.ts +61 -63
- package/dist/gltf/protocol.d.ts +51 -29
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8118 -6773
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +3 -4
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +7974 -6665
- package/dist/index.mjs.map +1 -1
- package/dist/loader.mjs +10761 -9510
- package/dist/loader.mjs.map +1 -1
- package/dist/plugin/model-item.d.ts +73 -37
- package/dist/plugin/model-plugin.d.ts +4 -3
- package/dist/plugin/model-tree-item.d.ts +4 -8
- package/dist/runtime/animation.d.ts +18 -15
- package/dist/runtime/camera.d.ts +7 -6
- package/dist/runtime/common.d.ts +2 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/light.d.ts +6 -5
- package/dist/runtime/material.d.ts +74 -92
- package/dist/runtime/math.d.ts +2 -1
- package/dist/runtime/mesh.d.ts +20 -22
- package/dist/runtime/scene.d.ts +2 -1
- package/dist/runtime/shader-libs/standard-shader-source.d.ts +1 -0
- package/dist/runtime/shader-libs/standard-shader.d.ts +8 -0
- package/dist/runtime/skybox.d.ts +25 -6
- package/dist/utility/plugin-helper.d.ts +12 -11
- package/dist/utility/shader-helper.d.ts +2 -0
- package/package.json +12 -7
package/dist/index.min.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
!/*!
|
|
2
2
|
* Name: @galacean/effects-plugin-model
|
|
3
3
|
* Description: Galacean Effects player model plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 飂兮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
7
|
-
*/
|
|
8
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ge=e.ge||{},e.ge.modelPlugin={}),e.ge)}(this,(function(e,t){"use strict";var n="PluginModel",o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var r=function(){return r=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};function a(e,t,n,o){var i,r=arguments.length,a=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(r<3?i(a):r>3?i(t,n,a):i(t,n))||a);return r>3&&a&&Object.defineProperty(t,n,a),a}function s(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))}function c(e,t){var n,o,i,r,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function l(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,i,r=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=r.next()).done;)a.push(o.value)}catch(e){i={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var f=t.math.Vector2,h=t.math.Vector3,d=t.math.Vector4,p=t.math.Matrix3,m=t.math.Matrix4,g=t.math.Euler,v=t.math.EulerOrder,y=t.math.Quaternion,_=t.math.Box3;t.math.Sphere,t.math.Ray;var b,T,x,C,M,S,A,I=t.math.DEG2RAD;e.PObjectType=void 0,(b=e.PObjectType||(e.PObjectType={}))[b.none=0]="none",b[b.mesh=1]="mesh",b[b.texture=2]="texture",b[b.material=3]="material",b[b.light=4]="light",b[b.camera=5]="camera",b[b.skybox=6]="skybox",b[b.skin=7]="skin",b[b.morph=8]="morph",b[b.skeleton=9]="skeleton",b[b.animation=10]="animation",b[b.animationManager=11]="animationManager",b[b.reference=12]="reference",e.PLightType=void 0,(T=e.PLightType||(e.PLightType={}))[T.directional=0]="directional",T[T.point=1]="point",T[T.spot=2]="spot",T[T.ambient=3]="ambient",e.PTextureType=void 0,(x=e.PTextureType||(e.PTextureType={}))[x.none=0]="none",x[x.t2d=1]="t2d",x[x.t3d=2]="t3d",x[x.cube=3]="cube",e.PMaterialType=void 0,(C=e.PMaterialType||(e.PMaterialType={}))[C.none=0]="none",C[C.unlit=1]="unlit",C[C.pbr=2]="pbr",C[C.normalVis=3]="normalVis",C[C.simpleFilter=4]="simpleFilter",C[C.shadowBase=5]="shadowBase",C[C.shadowFilter=6]="shadowFilter",C[C.skyboxFilter=7]="skyboxFilter",e.PBlendMode=void 0,(M=e.PBlendMode||(e.PBlendMode={}))[M.opaque=0]="opaque",M[M.masked=1]="masked",M[M.translucent=2]="translucent",M[M.additive=3]="additive",e.PFaceSideMode=void 0,(S=e.PFaceSideMode||(e.PFaceSideMode={}))[S.both=0]="both",S[S.front=1]="front",S[S.back=2]="back",e.PShadowType=void 0,(A=e.PShadowType||(e.PShadowType={}))[A.none=0]="none",A[A.standard=1]="standard",A[A.variance=2]="variance",A[A.expVariance=3]="expVariance";var E=function(){function e(){this.translation=new h(0,0,0),this.rotation=new y(0,0,0,1),this.scale=new h(1,1,1)}return e.prototype.fromMatrix4=function(e){return this.setMatrix(e),this},e.prototype.fromEffectsTransform=function(e){if(e instanceof t.Transform)this.setMatrix(e.getWorldMatrix());else{var n=new t.Transform(r(r({},e),{valid:!0}));n.setValid(!0),this.setMatrix(n.getWorldMatrix())}return this},e.prototype.toEffectsTransform=function(e){var t=this.getMatrix();return e.cloneFromMatrix(t),e},e.prototype.fromBaseTransform=function(e){return e.position?this.setTranslation(e.position):this.translation.set(0,0,0),e.rotation?this.setRotation(e.rotation):this.rotation.set(0,0,0,1),e.scale?this.setScale(e.scale):this.scale.set(1,1,1),this},e.prototype.getTranslation=function(){return this.translation},e.prototype.setTranslation=function(e){e instanceof h?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},e.prototype.getPosition=function(){return this.translation},e.prototype.setPosition=function(e){e instanceof h?this.translation.set(e.x,e.y,e.z):this.translation.set(e[0],e[1],e[2])},e.prototype.getRotation=function(){return this.rotation},e.prototype.setRotation=function(e){e instanceof y?this.rotation.set(e.x,e.y,e.z,e.w):e instanceof g?this.rotation.setFromEuler(e):e instanceof h?this.rotation.setFromEuler(new g(e.x,e.y,e.z,v.ZYX)):4===e.length?this.rotation.set(e[0],e[1],e[2],e[3]):this.rotation.setFromEuler(new g(e[0],e[1],e[2],v.ZYX))},e.prototype.getScale=function(){return this.scale},e.prototype.setScale=function(e){e instanceof h?this.scale.set(e.x,e.y,e.z):this.scale.set(e[0],e[1],e[2])},e.prototype.getMatrix=function(){return(new m).compose(this.getTranslation(),this.getRotation(),this.getScale())},e.prototype.setMatrix=function(e){if(e instanceof m){var t=e.getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}else{t=m.fromArray(e).getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}},e}(),P=function(){function e(){this.origin=new h(0,0,0),this.xAxis=new h(1,0,0),this.yAxis=new h(0,1,0),this.zAxis=new h(0,0,1)}return e.prototype.fromPTransform=function(e,t){void 0===t&&(t=!1),this.origin.copyFrom(e.getPosition());var n=e.getRotation().toMatrix4(new m);return t&&n.invert(),this.fromRotationMatrix(n),this},e.prototype.fromRotationMatrix=function(e){var t=e.elements;this.xAxis.set(t[0],t[1],t[2]),this.yAxis.set(t[4],t[5],t[6]),this.zAxis.set(t[8],t[9],t[10])},e}(),w=function(){function e(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=t.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16}return e.getInstance=function(){return this.instance||(this.instance=new this)},e.prototype.reset=function(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=t.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16},e.prototype.hasRenderMode3D=function(){return this.renderMode3D!==t.spec.RenderMode3D.none},Object.defineProperty(e.prototype,"isEditorEnv",{get:function(){return this.runtimeEnv===t.PLAYER_OPTIONS_ENV_EDITOR},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDeviceEnv",{get:function(){return!this.isEditorEnv},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isTiny3dMode",{get:function(){return"tiny3d"===this.compatibleMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isGLTFMode",{get:function(){return!this.isTiny3dMode},enumerable:!1,configurable:!0}),e}(),O=1,N=function(){function t(){this.name="Unnamed Object",this.type=e.PObjectType.none}return t.prototype.dispose=function(){},t.prototype.isNone=function(){return this.type===e.PObjectType.none},t.prototype.isValid=function(){return this.type!==e.PObjectType.none},t.prototype.genName=function(e){return"".concat(e,"_@").concat(O++)},t}(),L=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._visible=!1,t._transform=new E,t.deleted=!1,t}return i(t,e),t.prototype.update=function(){},t.prototype.render=function(e,t){},t.prototype.onVisibleChanged=function(e){this.visible=e},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.visible=!1,this.deleted=!0},Object.defineProperty(t.prototype,"visible",{get:function(){return this._visible&&this.isValid()},set:function(e){this._visible=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transform",{get:function(){return this._transform},set:function(e){e instanceof E?this._transform=e:(void 0!==e.position&&this._transform.setTranslation(e.position),void 0!==e.rotation&&this._transform.setRotation(e.rotation),void 0!==e.scale&&this._transform.setScale(e.scale))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"translation",{get:function(){return this._transform.getTranslation()},set:function(e){this._transform.setTranslation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._transform.getTranslation()},set:function(e){this._transform.setTranslation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._transform.getRotation()},set:function(e){this._transform.setRotation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scale",{get:function(){return this._transform.getScale()},set:function(e){this._transform.setScale(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matrix",{get:function(){return this._transform.getMatrix()},set:function(e){this._transform.setMatrix(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinate",{get:function(){var e=new P;return e.fromPTransform(this._transform),e},enumerable:!1,configurable:!0}),t}(N);var R={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,f32:Float32Array,i32:Int32Array,u32:Uint32Array};function F(e,n){if(2!=n.length||n[0]!==t.spec.ValueType.BINARY||!(n[1]instanceof Array))return n;var o=l(n[1],4),i=o[0],r=o[1],a=o[2],s=o[3];if(!s)return e[i].slice(r,a);var c=R[s]||Uint8Array;return new c(e[i],r,a/c.BYTES_PER_ELEMENT)}var U,D=function(){function e(e,t,n){this.time=e,this.data=t,this.componentCount=n,this.cachedIndex=0}return e.prototype.evaluate=function(e){var t=this.time,n=this.cachedIndex,o=t[n],i=t[n-1];e:{t:{var r=void 0;n:{o:if(!(e<o)){for(var a=n+2;;){if(void 0===o){if(e<i)break o;return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}if(n===a)break;if(i=o,e<(o=t[++n]))break t}r=t.length;break n}if(e>=i)break e;var s=t[1];e<s&&(n=2,i=s);for(a=n-2;;){if(void 0===i)return this.cachedIndex=0,this.copySampleValue(0);if(n===a)break;if(o=i,e>=(i=t[--n-1]))break t}r=n,n=0}for(;n<r;){var c=n+r>>>1;e<t[c]?r=c:n=c+1}if(o=t[n],void 0===(i=t[n-1]))return this.cachedIndex=0,this.copySampleValue(0);if(void 0===o)return n=t.length,this.cachedIndex=n,this.copySampleValue(n-1)}this.cachedIndex=n,this.intervalChanged(n,i,o)}return this.interpolate(n,i,e,o)},e.prototype.dispose=function(){this.time=void 0,this.data=void 0},e.prototype.copySampleValue=function(e){for(var t=this.data,n=this.componentCount,o=e*n,i=new Float32Array(n),r=0;r!==n;++r)i[r]=t[o+r];return i},e}(),B=function(e){function t(t,n,o){return e.call(this,t,n,o)||this}return i(t,e),t.prototype.intervalChanged=function(e,t,n){},t.prototype.interpolate=function(e,t,n,o){for(var i,r=this.data,a=null!==(i=this.componentCount)&&void 0!==i?i:1,s=e*a,c=s-a,l=(n-t)/(o-t),u=1-l,f=new Float32Array(a),h=0;h!==a;++h)f[h]=r[c+h]*u+r[s+h]*l;return f},t}(D),k=function(e){function t(t,n,o){return e.call(this,t,n,o)||this}return i(t,e),t.prototype.intervalChanged=function(e,t,n){},t.prototype.interpolate=function(e,t,n,o){for(var i,r=this.data,a=null!==(i=this.componentCount)&&void 0!==i?i:1,s=(e-1)*a,c=new Float32Array(a),l=0;l!==a;++l)c[l]=r[s+l];return c},t}(D),V=function(){function e(){}return e.slerpFlat=function(e,t,n,o,i,r,a){var s=n[o+0],c=n[o+1],l=n[o+2],u=n[o+3],f=i[r+0],h=i[r+1],d=i[r+2],p=i[r+3];if(0===a)return e[t+0]=s,e[t+1]=c,e[t+2]=l,void(e[t+3]=u);if(1===a)return e[t+0]=f,e[t+1]=h,e[t+2]=d,void(e[t+3]=p);if(u!==p||s!==f||c!==h||l!==d){var m=1-a,g=s*f+c*h+l*d+u*p,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var _=Math.sqrt(y),b=Math.atan2(_,g*v);m=Math.sin(m*b)/_,a=Math.sin(a*b)/_}var T=a*v;if(s=s*m+f*T,c=c*m+h*T,l=l*m+d*T,u=u*m+p*T,m===1-a){var x=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=x,c*=x,l*=x,u*=x}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u},e}(),G=function(e){function t(t,n,o){return e.call(this,t,n,o)||this}return i(t,e),t.prototype.intervalChanged=function(e,t,n){},t.prototype.interpolate=function(e,t,n,o){for(var i,r=this.data,a=null!==(i=this.componentCount)&&void 0!==i?i:1,s=(n-t)/(o-t),c=e*a,l=new Float32Array(a),u=c+a;c!==u;c+=4)V.slerpFlat(l,0,r,c-a,r,c,s);return l},t}(D);function j(e,t,n,o,i){switch(e){case"LINEAR":return"rotation"===i?new G(t,n,o):new B(t,n,o);case"STEP":return new k(t,n,o);default:return new B(t,n,o)}}e.TextureDataMode=void 0,(U=e.TextureDataMode||(e.TextureDataMode={}))[U.none=0]="none",U[U.float=1]="float",U[U.half_float=2]="half_float";var z,H,W=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.skeleton=0,n.jointList=[],n.inverseBindMatrices=[],n.animationMatrices=[],n.textureDataMode=e.TextureDataMode.none,n}return i(n,t),n.prototype.create=function(t,n,o){var i,r;this.name=this.genName(null!==(i=t.name)&&void 0!==i?i:"Unnamed skin"),this.type=e.PObjectType.skin,this.parentItem=o,this.skeleton=null!==(r=t.skeleton)&&void 0!==r?r:-1,this.jointList=t.joints,this.animationMatrices=[],this.inverseBindMatrices=[],this.textureDataMode=this.getTextureDataMode(this.getJointCount(),n);var a=t.inverseBindMatrices;if(void 0!==a&&a.length>0){if(a.length%16!=0||a.length!==16*this.jointList.length)throw new Error("Invalid array length, invert bind matrices ".concat(a.length,", joint array ").concat(this.jointList.length));for(var s=a.length/16,c=0;c<s;c++){var l=m.fromArray(a,16*c);this.inverseBindMatrices.push(l)}}},n.prototype.updateSkinMatrices=function(){var e,t=this;this.animationMatrices=[];var n=null===(e=this.parentItem)||void 0===e?void 0:e.getComponent(ut);if(void 0!==n)for(var o=0;o<this.jointList.length;o++){var i=this.jointList[o],r=n.content.getNodeById(i);if(void 0===r){console.error("Can't find joint ".concat(i," in node tree ").concat(this.parentItem,"."));break}var a=r.transform.getWorldMatrix();this.animationMatrices.push(a.clone())}this.animationMatrices.length===this.inverseBindMatrices.length?this.animationMatrices.forEach((function(e,n){e.multiply(t.inverseBindMatrices[n])})):(this.animationMatrices=this.inverseBindMatrices,console.error("Some error occured, replace skin animation matrices by invert bind matrices"))},n.prototype.computeMeshAnimMatrices=function(e,t,n){var o=e.clone().invert(),i=new m;this.animationMatrices.forEach((function(e,r){var a=i.multiplyMatrices(o,e);a.elements.forEach((function(e,n){return t[16*r+n]=e})),a.clone().invert().transpose().elements.forEach((function(e,t){return n[16*r+t]=e}))}))},n.prototype.updateParentItem=function(e){this.parentItem=e},n.prototype.getJointCount=function(){return this.jointList.length},n.prototype.isTextureDataMode=function(){return this.textureDataMode!==e.TextureDataMode.none},n.prototype.dispose=function(){this.parentItem=void 0,this.jointList=[],this.inverseBindMatrices=[],this.animationMatrices=[]},n.prototype.getTextureDataMode=function(t,n){var o=n.gpuCapability.detail,i=o.maxVertexUniforms-25;if(t>Math.floor(i/8)){if(o.floatTexture)return e.TextureDataMode.float;if(o.halfFloatTexture)return e.TextureDataMode.half_float;throw new Error("Too many joint count ".concat(t,", half float texture not support"))}return e.TextureDataMode.none},n}(N),X=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.morphWeightsLength=0,e.hasPositionMorph=!1,e.hasNormalMorph=!1,e.hasTangentMorph=!1,e}return i(n,t),n.prototype.create=function(t){var o=this;this.name=this.genName("Morph target"),this.type=e.PObjectType.morph;var i=this.getAttributeMorphCount(n.positionNameList,t),r=this.getAttributeMorphCount(n.normalNameList,t),a=this.getAttributeMorphCount(n.tangentNameList,t),s=[i,r,a];return this.morphWeightsLength=0,s.forEach((function(e){e>0&&(0===o.morphWeightsLength?o.morphWeightsLength=e:o.morphWeightsLength=Math.min(o.morphWeightsLength,e))})),this.morphWeightsLength>0&&(this.morphWeightsArray=new Float32Array(this.morphWeightsLength),this.hasPositionMorph=i==this.morphWeightsLength,this.hasNormalMorph=r==this.morphWeightsLength,this.hasTangentMorph=a==this.morphWeightsLength),i>0&&i!=this.morphWeightsLength?(console.error("Position morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(i)),!1):r>0&&r!=this.morphWeightsLength?(console.error("Normal morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(r)),!1):a>0&&a!=this.morphWeightsLength?(console.error("Tangent morph count mismatch: ".concat(this.morphWeightsLength,", ").concat(a)),!1):!(this.morphWeightsLength>5)||(console.error("Tangent morph count should not greater than 5, current ".concat(this.morphWeightsLength)),!1)},n.prototype.dispose=function(){this.morphWeightsArray=void 0},n.prototype.initWeights=function(e){if(void 0!==this.morphWeightsArray){var t=this.morphWeightsArray;e.forEach((function(e,n){n<t.length&&(t[n]=e)}))}},n.prototype.hasMorph=function(){return this.morphWeightsLength>0&&(this.hasPositionMorph||this.hasNormalMorph||this.hasTangentMorph)},n.prototype.equals=function(e){return this.morphWeightsLength===e.morphWeightsLength&&this.hasPositionMorph===e.hasPositionMorph&&this.hasNormalMorph===e.hasNormalMorph&&this.hasTangentMorph===e.hasTangentMorph},n.prototype.getMorphWeightsArray=function(){return this.morphWeightsArray},n.prototype.getAttributeMorphCount=function(e,t){for(var n=0;n<e.length;n++){var o=e[n];if(void 0===t.getAttributeData(o))return n}return e.length},n.positionNameList=["a_Target_Position0","a_Target_Position1","a_Target_Position2","a_Target_Position3","a_Target_Position4","a_Target_Position5","a_Target_Position6","a_Target_Position7"],n.normalNameList=["a_Target_Normal0","a_Target_Normal1","a_Target_Normal2","a_Target_Normal3","a_Target_Normal4","a_Target_Normal5","a_Target_Normal6","a_Target_Normal7"],n.tangentNameList=["a_Target_Tangent0","a_Target_Tangent1","a_Target_Tangent2","a_Target_Tangent3","a_Target_Tangent4","a_Target_Tangent5","a_Target_Tangent6","a_Target_Tangent7"],n}(N);e.PAnimInterpType=void 0,(z=e.PAnimInterpType||(e.PAnimInterpType={}))[z.linear=0]="linear",z[z.step=1]="step",z[z.cubicSpline=2]="cubicSpline",e.PAnimPathType=void 0,(H=e.PAnimPathType||(e.PAnimPathType={}))[H.translation=0]="translation",H[H.rotation=1]="rotation",H[H.scale=2]="scale",H[H.weights=3]="weights";var J,Y=function(){function t(t){this.path=e.PAnimPathType.translation,this.interp=e.PAnimInterpType.linear;var n=t.node,o=t.input,i=t.output,r=t.path,a=t.interpolation;if(this.node=n,this.timeArray=o,this.dataArray=i,"translation"===r?(this.path=e.PAnimPathType.translation,this.component=3):"rotation"===r?(this.path=e.PAnimPathType.rotation,this.component=4):"scale"===r?(this.path=e.PAnimPathType.scale,this.component=3):"weights"===r?(this.path=e.PAnimPathType.weights,this.component=this.dataArray.length/this.timeArray.length,this.component<=0?console.error("Invalid weights component: ".concat(this.timeArray.length,", ").concat(this.component,", ").concat(this.dataArray.length)):this.timeArray.length*this.component!=this.dataArray.length&&console.error("Invalid weights array length: ".concat(this.timeArray.length,", ").concat(this.component,", ").concat(this.dataArray.length))):console.error("Invalid path status: ".concat(r)),this.timeArray.length*this.component>this.dataArray.length)throw new Error("Data length mismatch: ".concat(this.timeArray.length,", ").concat(this.component,", ").concat(this.dataArray.length));this.interp="LINEAR"===a?e.PAnimInterpType.linear:"STEP"===a?e.PAnimInterpType.step:e.PAnimInterpType.cubicSpline,this.sampler=j(this.getInterpInfo(),this.timeArray,this.dataArray,this.component,this.getPathInfo())}return t.prototype.dispose=function(){var e;this.timeArray=void 0,this.dataArray=void 0,null===(e=this.sampler)||void 0===e||e.dispose(),this.sampler=void 0},t.prototype.tick=function(t,n,o){var i,r=n.getComponent(ut),a=null===(i=null==r?void 0:r.content)||void 0===i?void 0:i.getNodeById(this.node);if(void 0!==this.sampler&&void 0!==a){var s=this.sampler.evaluate(t);switch(this.path){case e.PAnimPathType.translation:a.transform.setPosition(s[0],s[1],s[2]);break;case e.PAnimPathType.rotation:a.transform.setQuaternion(s[0],s[1],s[2],s[3]);break;case e.PAnimPathType.scale:a.transform.setScale(s[0],s[1],s[2]);break;case e.PAnimPathType.weights:var c=this.genParentId(n.id,this.node),l=null==o?void 0:o.queryMesh(c);void 0!==l&&l.updateMorphWeights(s)}}else void 0!==this.sampler&&console.error("AnimTrack: error",this.sampler,a)},t.prototype.getEndTime=function(){var e=this.timeArray.length-1;return this.timeArray[e]},t.prototype.genParentId=function(e,t){return"".concat(e,"^").concat(t)},t.prototype.getPathInfo=function(){return this.path===e.PAnimPathType.scale?"scale":this.path===e.PAnimPathType.rotation?"rotation":"translation"},t.prototype.getInterpInfo=function(){return this.interp===e.PAnimInterpType.cubicSpline?"CUBICSPLINE":this.interp===e.PAnimInterpType.step?"STEP":"LINEAR"},t}(),q=function(){function e(e){this.engine=e,this.isHalfFloat=!0,this.width=0,this.height=0}return e.prototype.create=function(e,n,o){var i,r;this.width=4,this.height=e,this.isHalfFloat=n,this.isHalfFloat&&(this.buffer=new Ye(4*this.getSize()));var a=null!==(r=null===(i=this.buffer)||void 0===i?void 0:i.data)&&void 0!==r?r:new Float32Array(4*this.getSize()),s=this.isHalfFloat?t.glContext.HALF_FLOAT:t.glContext.FLOAT;this.texture=t.Texture.create(this.engine,{name:o,data:{width:this.width,height:this.height,data:a},target:t.glContext.TEXTURE_2D,format:t.glContext.RGBA,type:s,wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,minFilter:t.glContext.NEAREST,magFilter:t.glContext.NEAREST})},e.prototype.update=function(e){var n,o;void 0!==this.buffer&&this.buffer.set(e,0),void 0!==this.texture&&this.texture.updateSource({sourceType:t.TextureSourceType.data,data:{width:this.width,height:this.height,data:null!==(o=null===(n=this.buffer)||void 0===n?void 0:n.data)&&void 0!==o?o:e},target:t.glContext.TEXTURE_2D})},e.prototype.dispose=function(){var e;this.engine=null,this.buffer=void 0,null===(e=this.texture)||void 0===e||e.dispose()},e.prototype.getSize=function(){return this.width*this.height},e.prototype.getTexture=function(){return this.texture},e}(),K=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.time=0,e.duration=0,e.tracks=[],e}return i(n,t),n.prototype.create=function(t){var n,o=this;this.name=this.genName(null!==(n=t.name)&&void 0!==n?n:"Unnamed animation"),this.type=e.PObjectType.animation,this.time=0,this.duration=0,this.tracks=[],t.tracks.forEach((function(e){var t=new Y(e);o.tracks.push(t),o.duration=Math.max(o.duration,t.getEndTime())}))},n.prototype.tick=function(e,t,n){this.time=e;var o=this.time%this.duration;this.tracks.forEach((function(e){e.tick(o,t,n)}))},n.prototype.dispose=function(){this.tracks.forEach((function(e){e.dispose()})),this.tracks=[]},n}(N),Q=function(t){function n(n,o){var i,r,a,s=t.call(this)||this;return s.animation=0,s.speed=0,s.delay=0,s.time=0,s.animations=[],s.name=s.genName(null!==(i=o.name)&&void 0!==i?i:"Unnamed tree"),s.type=e.PObjectType.animationManager,s.ownerItem=o,s.animation=null!==(r=n.animation)&&void 0!==r?r:-1,s.speed=1,s.delay=null!==(a=o.start)&&void 0!==a?a:0,s.animations=[],void 0!==n.animations&&n.animations.forEach((function(e){var t=s.createAnimation(e);s.animations.push(t)})),s}return i(n,t),n.prototype.setSceneManager=function(e){this.sceneManager=e},n.prototype.createAnimation=function(e){var t=new K;return t.create(e),t},n.prototype.tick=function(e){var t=this,n=e*this.speed*.001;this.time+=n;var o=this.time-this.delay;o>=0&&(this.animation>=0&&this.animation<this.animations.length?this.animations[this.animation].tick(o,this.ownerItem,this.sceneManager):-88888888==this.animation&&this.animations.forEach((function(e){e.tick(o,t.ownerItem,t.sceneManager)})))},n.prototype.dispose=function(){this.ownerItem=null,this.animations.forEach((function(e){e.dispose()})),this.animations=[],this.sceneManager=null},n.prototype.getTreeItem=function(){return this.ownerItem},n}(N),Z=Math.PI/180,$=function(n){function o(o,i,r,a,s){var c,l=n.call(this)||this;return l.width=512,l.height=512,l.nearPlane=.001,l.farPlane=1e3,l.fovy=45,l.aspect=1,l.clipMode=t.spec.CameraClipMode.landscape,l.projectionMatrix=new m,l.viewMatrix=new m,l.type=e.PObjectType.camera,l.visible=!1,l.owner=s,l.name=o,l.width=i,l.height=r,l.nearPlane=a.near,l.farPlane=a.far,l.fovy=a.fov,l.aspect=null!==(c=a.aspect)&&void 0!==c?c:l.width/l.height,l.clipMode=a.clipMode,l.update(),l}return i(o,n),o.prototype.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform);var e=this.clipMode===t.spec.CameraClipMode.portrait;this.projectionMatrix.perspective(this.fovy*Z,this.aspect,this.nearPlane,this.farPlane,e),this.viewMatrix=this.matrix.invert()},o.prototype.getNewProjectionMatrix=function(e){var n=this.clipMode===t.spec.CameraClipMode.portrait;return(new m).perspective(Math.min(1.25*e,140)*Z,this.aspect,this.nearPlane,this.farPlane,n)},o.prototype.computeViewAABB=function(e){var t=Math.tan(this.fovy*Z*.5),n=this.aspect,o=0,i=0,r=0,a=0;this.isReversed()?(o=(r=this.farPlane*t)/n,i=(a=this.nearPlane*t)/n):(r=n*(o=this.farPlane*t),a=n*(i=this.nearPlane*t)),e.makeEmpty();var s=this.matrix;return e.expandByPoint(s.transformPoint(new h(r,o,-this.farPlane))),e.expandByPoint(s.transformPoint(new h(r,-o,-this.farPlane))),e.expandByPoint(s.transformPoint(new h(-r,o,-this.farPlane))),e.expandByPoint(s.transformPoint(new h(-r,-o,-this.farPlane))),e.expandByPoint(s.transformPoint(new h(a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new h(a,-i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new h(-a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new h(-a,-i,-this.nearPlane))),e},o.prototype.getSize=function(){return new f(this.width,this.height)},o.prototype.isReversed=function(){return this.clipMode===t.spec.CameraClipMode.portrait},o.prototype.getEye=function(){return this.translation},o.prototype.setEye=function(e){this.translation=e},o}(L),ee=function(){function e(){this.winWidth=512,this.winHeight=512,this.cameraList=[],this.defaultCamera=new $("camera",512,512,{fov:60,far:1e3,near:.001,position:[0,0,-1.5],clipMode:t.spec.CameraClipMode.portrait})}return e.prototype.initial=function(e,t){this.winWidth=e,this.winHeight=t;var n=this.defaultCamera;n.width=e,n.height=t,n.aspect=e/t,n.update()},e.prototype.insert=function(e,t,n){var o=new $(e,this.winWidth,this.winHeight,t,n);return this.cameraList.push(o),o},e.prototype.insertCamera=function(e){this.cameraList.push(e)},e.prototype.remove=function(e){if(e instanceof $){var t=this.cameraList.findIndex((function(t){return t===e}));-1!==t&&this.cameraList.splice(t,1)}else e>=0&&e<this.cameraList.length&&this.cameraList.splice(e,1)},e.prototype.dispose=function(){this.cameraList=[]},e.prototype.updateDefaultCamera=function(e,t,n,o,i,r,a){this.defaultCamera.fovy=e,this.defaultCamera.aspect=t,this.defaultCamera.nearPlane=n,this.defaultCamera.farPlane=o,this.defaultCamera.position=i,this.defaultCamera.rotation=r,this.defaultCamera.aspect=t,this.defaultCamera.clipMode=a,this.defaultCamera.update()},e.prototype.getCameraList=function(){return this.cameraList},e.prototype.getDefaultCamera=function(){return this.defaultCamera},e.prototype.getCameraCount=function(){return this.cameraList.length},e.prototype.getActiveCamera=function(){return this.defaultCamera},e.prototype.getAspect=function(){return this.winWidth/this.winHeight},e}(),te=function(t){function n(n,o,i){var r=t.call(this)||this;r.direction=new h(0,0,1),r.range=0,r.color=new h(1,1,1),r.intensity=0,r.outerConeAngle=0,r.innerConeAngle=0,r.lightType=e.PLightType.ambient,r.padding=new f(0,0),r.name=n,r.type=e.PObjectType.light,r.visible=!1,r.owner=i,r.direction=new h(0,0,-1),r.range=0,r.outerConeAngle=0,r.innerConeAngle=0;var a=Ge.toPluginColor4(o.color);return r.color=new h(a[0],a[1],a[2]),r.intensity=o.intensity,"point"===o.lightType?(r.lightType=e.PLightType.point,r.range=o.range):"spot"===o.lightType?(r.lightType=e.PLightType.spot,r.range=o.range,r.outerConeAngle=o.outerConeAngle,r.innerConeAngle=o.innerConeAngle):"directional"===o.lightType?r.lightType=e.PLightType.directional:r.lightType=e.PLightType.ambient,r.update(),r}return i(n,t),n.prototype.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform)},n.prototype.isDirectional=function(){return this.lightType===e.PLightType.directional},n.prototype.isPoint=function(){return this.lightType===e.PLightType.point},n.prototype.isSpot=function(){return this.lightType===e.PLightType.spot},n.prototype.isAmbient=function(){return this.lightType===e.PLightType.ambient},Object.defineProperty(n.prototype,"position",{get:function(){return this.translation},enumerable:!1,configurable:!0}),n.prototype.getWorldPosition=function(){return this.translation},n.prototype.getWorldDirection=function(){return this.matrix.transformNormal(this.direction,new h)},n}(L),ne=function(){function e(){this.lightList=[]}return e.prototype.insertItem=function(e,t,n){var o=new te(e,t,n);return this.lightList.push(o),o},e.prototype.insertLight=function(e){return this.lightList.push(e),e},e.prototype.remove=function(e){var t=this.lightList.findIndex((function(t){return t===e}));-1!==t&&this.lightList.splice(t,1)},e.prototype.dispose=function(){this.lightList=[]},Object.defineProperty(e.prototype,"lightCount",{get:function(){return this.lightList.length},enumerable:!1,configurable:!0}),e}(),oe=function(){function e(e){var t,n;this.resolution=null!==(t=e.resolution)&&void 0!==t?t:new f(512,512),this.colorAttachments=null!==(n=e.colorAttachments)&&void 0!==n?n:[],this.depthAttachment=e.depthAttachment}return e.prototype.addDepthAttachment=function(e){var n;this.depthAttachment={storageType:null!==(n=e.storageType)&&void 0!==n?n:t.RenderPassAttachmentStorageType.depth_16_texture}},e.prototype.addDefaultDepthAttachment=function(){this.depthAttachment={storageType:t.RenderPassAttachmentStorageType.depth_16_texture}},e.prototype.deleteDepthAttachment=function(){this.depthAttachment=void 0},e.prototype.addColorAttachment=function(e){var n,o,i,r;this.colorAttachments.push({texture:{format:null!==(n=e.format)&&void 0!==n?n:t.glContext.RGBA,type:null!==(o=e.type)&&void 0!==o?o:t.glContext.HALF_FLOAT,minFilter:null!==(i=e.filter)&&void 0!==i?i:t.glContext.LINEAR,magFilter:null!==(r=e.filter)&&void 0!==r?r:t.glContext.LINEAR}})},e.prototype.deleteColorAttachment=function(e){e>=0&&e<this.colorAttachments.length&&this.colorAttachments.splice(e,1)},Object.defineProperty(e.prototype,"viewport",{get:function(){return[0,0,this.resolution.x,this.resolution.y]},enumerable:!1,configurable:!0}),e}(),ie=function(){function e(e,n){var o=t.Material.create(e,{shader:{vertex:this.vertexShader,fragment:this.fragmentShader,shared:!0}});o.depthTest=!0,o.depthMask=!0,this.mesh=t.Mesh.create(e,{name:"boxMesh",material:o,geometry:t.Geometry.create(e,this.geometry),priority:n})}return e.prototype.update=function(e,t,n,o){var i=this.mesh.material;i.setMatrix("u_ModelMatrix",e),i.setMatrix("u_ViewProjectionMatrix",t);for(var r=0;r<n.length;r+=3)i.setVector3("u_PositionList[".concat(r/3,"]"),h.fromArray(n,r));i.setVector3("u_LineColor",o)},e.prototype.dispose=function(){this.mesh.dispose(),this.mesh=void 0},Object.defineProperty(e.prototype,"vertexShader",{get:function(){return"\n #version 100\n precision highp float;\n\n uniform mat4 u_ModelMatrix;\n uniform mat4 u_ViewProjectionMatrix;\n uniform vec3 u_PositionList[8];\n attribute vec3 a_Position;\n void main(){\n int index = int(a_Position.x + 0.5);\n vec4 pos = u_ModelMatrix * vec4(u_PositionList[index], 1);\n gl_Position = u_ViewProjectionMatrix * pos;\n }\n "},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fragmentShader",{get:function(){return"\n #version 100\n precision highp float;\n\n uniform vec3 u_LineColor;\n void main(){\n gl_FragColor = vec4(u_LineColor, 1);\n }\n "},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometry",{get:function(){var e=new Float32Array([0,1,2,3,4,5,6,7]),n=new Uint32Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);return{attributes:{a_Position:{type:t.glContext.FLOAT,size:1,data:e,stride:Float32Array.BYTES_PER_ELEMENT,offset:0}},mode:t.glContext.LINES,indices:{data:n},drawStart:0,drawCount:24}},enumerable:!1,configurable:!0}),e}(),re=function(n){function o(t,o,i,r,a,s){var c,l=n.call(this)||this;l.engine=t,l.parentIndex=-1,l.primitives=[],l.hide=!0,l.priority=0,l.boundingBox=new _,l.visBoundingBox=!1,l.isBuilt=!1,l.isDisposed=!1;var u=new ce(i,s);return l.name=o,l.type=e.PObjectType.mesh,l.visible=!1,l.owner=r,l.parentIndex=u.getParentIndex(),l.parentItem=u.parentItem,l.parentItemId=a,l.skin=u.getSkinObj(t),l.morph=u.getMorphObj(),l.hide=u.isHide(),l.priority=(null===(c=null==r?void 0:r.item)||void 0===c?void 0:c.listIndex)||0,l.primitives=[],u.getPrimitives().forEach((function(e){var t=new ae(l.engine);t.create(e,l),l.primitives.push(t)})),l.primitives.length<=0&&console.warn("No primitive inside mesh item ".concat(o)),l.boundingBox=l.getItemBoundingBox(i.interaction),l}return i(o,n),o.prototype.build=function(e){this.isBuilt||(this.isBuilt=!0,this.primitives.forEach((function(t){t.build(e.maxLightCount,{},e.skybox)})),w.getInstance().visBoundingBox&&(this.boundingBoxMesh=new ie(this.engine,this.priority)))},o.prototype.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform)},o.prototype.render=function(e,t){var n;if(null===(n=this.skin)||void 0===n||n.updateSkinMatrices(),this.updateMaterial(e),this.primitives.forEach((function(e){var n=e.effectsMesh;n.geometry.flush(),n.material.initialize(),t.drawGeometry(n.geometry,n.material)})),this.visBoundingBox&&void 0!==this.boundingBoxMesh){var o=this.boundingBoxMesh.mesh;o.geometry.flush(),o.material.initialize(),t.drawGeometry(o.geometry,o.material)}},o.prototype.dispose=function(){var e,t,o;this.isDisposed||(n.prototype.dispose.call(this),this.owner=void 0,this.isDisposed=!0,this.engine=null,this.parentItem=void 0,null===(e=this.skin)||void 0===e||e.dispose(),this.skin=void 0,null===(t=this.morph)||void 0===t||t.dispose(),this.morph=void 0,this.primitives.forEach((function(e){e.dispose()})),this.primitives=[],null===(o=this.boundingBoxMesh)||void 0===o||o.dispose(),this.boundingBoxMesh=void 0)},o.prototype.updateMorphWeights=function(e){if(void 0!==this.morph&&this.morph.hasMorph()){var t=this.morph.morphWeightsArray;if(void 0!==t){if(t.length!=e.length)throw new Error("weight array length mismatch");for(var n=0;n<t.length;n++)t[n]=e[n]}}},o.prototype.updateParentInfo=function(e,t){this.parentItemId=e,this.parentItem=t,void 0!==this.skin&&this.skin.updateParentItem(t)},o.prototype.updateMaterial=function(e){var t=this.matrix,n=t.clone().invert().transpose(),o=e.sceneStates;if(this.primitives.forEach((function(e){e.updateMaterial(t,n,o)})),void 0!==this.boundingBoxMesh){this.computeBoundingBox(t);var i=new h(1,1,1),r=this.boundingBox.min,a=this.boundingBox.max,s=new Float32Array([r.x,r.y,r.z,a.x,r.y,r.z,a.x,a.y,r.z,r.x,a.y,r.z,r.x,r.y,a.z,a.x,r.y,a.z,a.x,a.y,a.z,r.x,a.y,a.z]);this.boundingBoxMesh.update(t,o.viewProjectionMatrix,s,i)}},o.prototype.hitTesting=function(e,t){var n,o=this.matrix,i=o.clone().invert(),r=i.transformPoint(e,new h),a=i.transformNormal(t,new h),s=this.boundingBox,c=Oe(r,a,s.min,s.max);return void 0===c?[]:(w.getInstance().isEditorEnv?this.primitives.forEach((function(e){var t=e.hitTesting(r,a,o,i);void 0!==t&&(void 0===n||n>t)&&(n=t)})):n=c,void 0===n?[]:(a.multiply(n),r.add(a),o.transformPoint(r),[r]))},o.prototype.computeBoundingBox=function(e){var t=this.boundingBox.makeEmpty(),n=e.clone().invert();return this.primitives.forEach((function(e){var o=e.computeBoundingBox(n);t.union(o)})),t},o.prototype.getItemBoundingBox=function(e){var n,o,i,r;if(void 0===e)return new _;if(e.type===t.spec.ModelBoundingType.box){var a=null!==(n=e.center)&&void 0!==n?n:[0,0,0],s=null!==(o=e.size)&&void 0!==o?o:[0,0,0],c=h.fromArray(a),l=h.fromArray(s).multiply(.5),u=c.clone().subtract(l),f=c.clone().add(l);return new _(u,f)}a=null!==(i=e.center)&&void 0!==i?i:[0,0,0];var d=.5*(null!==(r=e.radius)&&void 0!==r?r:0);u=(c=h.fromArray(a)).clone().subtract(d),f=c.clone().add(d);return new _(u,f)},o.prototype.getParentId=function(){return this.parentItemId},Object.defineProperty(o.prototype,"hasSkin",{get:function(){return void 0!==this.skin},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"mriMeshs",{get:function(){return this.primitives.map((function(e){return e.effectsMesh}))},enumerable:!1,configurable:!0}),o}(L),ae=function(){function n(e){this.engine=e,this.name="",this.effectsPriority=0,this.boundingBox=new _,this.isCompressed=!1}return n.prototype.create=function(t,n){if(this.parent=n,this.skin=n.skin,this.morph=n.morph,this.setGeometry(t.geometry),this.setMaterial(t.material),this.name=n.name,this.effectsPriority=n.priority,this.geometry.setHide(n.hide),void 0!==this.skin){var o=this.skin.getJointCount();if(this.jointMatrixList=new Float32Array(16*o),this.jointNormalMatList=new Float32Array(16*o),this.skin.isTextureDataMode()){var i=this.skin.textureDataMode===e.TextureDataMode.half_float;this.jointMatrixTexture=new q(this.engine),this.jointNormalMatTexture=new q(this.engine),this.jointMatrixTexture.create(o,i,"jointMatrixTexture"),this.jointNormalMatTexture.create(o,i,"jointNormalMatTexture")}}else(this.geometry.hasWeights()||this.geometry.hasJoints())&&console.warn("Geometry has weight and/or joint array, but the skin is missing.");this.isCompressed=this.geometry.isCompressed()},n.prototype.build=function(e,n,o){var i=w.getInstance(),r=this.getFeatureList(e,!0,o);this.material.build(r);var a=null!=n?n:{};a.u_ViewProjectionMatrix="VIEWPROJECTION",a.u_ModelMatrix="MODEL",a.uEditorTransform="EDITOR_TRANSFORM";var s=t.Material.create(this.engine,{shader:{vertex:this.material.vertexShaderCode,fragment:this.material.fragmentShaderCode,shared:i.shaderShared},uniformSemantics:a});this.material.setMaterialStates(s);var c=t.Mesh.create(this.engine,{name:this.name,material:s,geometry:this.getEffectsGeometry(),priority:this.effectsPriority});void 0!==this.effectsMesh&&this.effectsMesh.dispose(),this.effectsMesh=c},n.prototype.getFeatureList=function(t,n,o){var i=[];if(this.geometry.hasNormals()&&i.push("HAS_NORMALS 1"),this.geometry.hasTangents()&&i.push("HAS_TANGENTS 1"),this.geometry.hasUVCoords(1)&&i.push("HAS_UV_SET1 1"),this.geometry.hasUVCoords(2)&&i.push("HAS_UV_SET2 1"),void 0!==this.morph&&this.morph.hasMorph()){i.push("USE_MORPHING"),i.push("WEIGHT_COUNT ".concat(this.morph.morphWeightsLength));for(var r=0;r<this.morph.morphWeightsLength;r++)this.morph.hasPositionMorph&&i.push("HAS_TARGET_POSITION".concat(r)),this.morph.hasNormalMorph&&i.push("HAS_TARGET_NORMAL".concat(r)),this.morph.hasTangentMorph&&i.push("HAS_TARGET_TANGENT".concat(r))}void 0!==this.skin&&(i.push("USE_SKINNING 1"),i.push("JOINT_COUNT ".concat(this.skin.getJointCount())),i.push("HAS_JOINT_SET1 1"),i.push("HAS_WEIGHT_SET1 1"),this.skin.textureDataMode&&i.push("USE_SKINNING_TEXTURE 1")),this.material.materialType!==e.PMaterialType.unlit&&(t>0&&this.geometry.hasNormals()&&(i.push("USE_PUNCTUAL 1"),i.push("LIGHT_COUNT ".concat(t))),void 0!==o&&o.available&&(i.push("USE_IBL 1"),i.push("USE_TEX_LOD 1"),o.hasDiffuseImage||i.push("IRRADIANCE_COEFFICIENTS 1")));var a=w.getInstance().renderMode3D,s=this.getRenderMode3DDefine(a);return void 0!==s&&(i.push("DEBUG_OUTPUT 1"),i.push("".concat(s," 1"))),i},n.prototype.dispose=function(){var e,n;this.engine=null,this.parent=void 0,this.skin=void 0,this.morph=void 0,this.geometry.dispose(),this.material.dispose(),this.jointMatrixList=void 0,this.jointNormalMatList=void 0,null===(e=this.jointMatrixTexture)||void 0===e||e.dispose(),this.jointMatrixTexture=void 0,null===(n=this.jointNormalMatTexture)||void 0===n||n.dispose(),this.jointNormalMatTexture=void 0,this.effectsMesh.dispose({geometries:t.DestroyOptions.keep,material:t.DestroyOptions.keep}),this.effectsMesh=void 0},n.prototype.updateMaterial=function(e,t,n){this.updateUniformsByAnimation(e,t),this.updateUniformsByScene(n),this.material.updateUniforms(this.getModelMaterial())},n.prototype.hitTesting=function(t,n,o,i){var r=this.boundingBox,a=Oe(t,n,r.min,r.max),s=[];if(void 0!==a){if(void 0!==this.skin)this.skin.animationMatrices.forEach((function(e){s.push((new m).multiplyMatrices(i,e))}));var c=new Xe,l=this.material.faceSideMode===e.PFaceSideMode.both;return c.create(this.geometry.geometry,l,s),c.getHitPoint(t,n)}},n.prototype.computeBoundingBox=function(e){if(void 0===this.skin&&!this.boundingBox.isEmpty())return this.boundingBox;var t=[];void 0!==this.skin&&this.skin.animationMatrices.forEach((function(n){t.push((new m).multiplyMatrices(e,n))}));var n=new We;return n.create(this.geometry.geometry,t),n.getBoundingBox(this.boundingBox)},n.prototype.getRenderMode3DDefine=function(e){switch(e){case t.spec.RenderMode3D.uv:return"DEBUG_UV";case t.spec.RenderMode3D.normal:return"DEBUG_NORMAL";case t.spec.RenderMode3D.basecolor:return"DEBUG_BASECOLOR";case t.spec.RenderMode3D.alpha:return"DEBUG_ALPHA";case t.spec.RenderMode3D.metallic:return"DEBUG_METALLIC";case t.spec.RenderMode3D.roughness:return"DEBUG_ROUGHNESS";case t.spec.RenderMode3D.ao:return"DEBUG_OCCLUSION";case t.spec.RenderMode3D.emissive:return"DEBUG_EMISSIVE"}},n.prototype.updateUniformsByAnimation=function(e,t){var n=this.getModelMaterial();n.setMatrix("u_ModelMatrix",e),n.setMatrix("u_NormalMatrix",t);var o=this.skin;if(void 0!==o){var i=this.jointMatrixList,r=this.jointNormalMatList;if(o.computeMeshAnimMatrices(e,i,r),o.textureDataMode){var a=this.jointMatrixTexture,s=this.jointNormalMatTexture;a.update(i),s.update(r),n.setTexture("u_jointMatrixSampler",a.getTexture()),n.setTexture("u_jointNormalMatrixSampler",s.getTexture())}else{var c=[],l=[];i.forEach((function(e){return c.push(e)})),r.forEach((function(e){return l.push(e)})),n.setMatrixNumberArray("u_jointMatrix",c),n.setMatrixNumberArray("u_jointNormalMatrix",l)}}var u=this.morph;if(void 0!==u&&u.hasMorph()){var f=u.morphWeightsArray,h=[];f.forEach((function(e){return h.push(e)})),n.setFloats("u_morphWeights",h)}},n.prototype.updateUniformsByScene=function(e){var t,n=this.getModelMaterial();if(n.setMatrix("u_ViewProjectionMatrix",e.viewProjectionMatrix),n.setVector3("u_Camera",e.cameraPosition),!this.isUnlitMaterial()){for(var o=e.maxLightCount,i=e.lightList,r=0;r<o;r++)if(r<i.length){var a=i[r],s=a.visible?a.intensity:0;n.setVector3("u_Lights[".concat(r,"].direction"),a.getWorldDirection()),n.setFloat("u_Lights[".concat(r,"].range"),a.range),n.setVector3("u_Lights[".concat(r,"].color"),a.color),n.setFloat("u_Lights[".concat(r,"].intensity"),s),n.setVector3("u_Lights[".concat(r,"].position"),a.getWorldPosition()),n.setFloat("u_Lights[".concat(r,"].innerConeCos"),Math.cos(a.innerConeAngle)),n.setFloat("u_Lights[".concat(r,"].outerConeCos"),Math.cos(a.outerConeAngle)),n.setInt("u_Lights[".concat(r,"].type"),a.lightType),n.setVector2("u_Lights[".concat(r,"].padding"),a.padding)}else n.setVector3("u_Lights[".concat(r,"].direction"),h.ZERO),n.setFloat("u_Lights[".concat(r,"].range"),0),n.setVector3("u_Lights[".concat(r,"].color"),h.ZERO),n.setFloat("u_Lights[".concat(r,"].intensity"),0),n.setVector3("u_Lights[".concat(r,"].position"),h.ZERO),n.setFloat("u_Lights[".concat(r,"].innerConeCos"),0),n.setFloat("u_Lights[".concat(r,"].outerConeCos"),0),n.setInt("u_Lights[".concat(r,"].type"),99999),n.setVector2("u_Lights[".concat(r,"].padding"),f.ZERO);var c=e.skybox;if(void 0!==c&&c.available){if(n.setVector2("u_IblIntensity",new f(c.currentIntensity,c.currentReflectionsIntensity)),n.setTexture("u_brdfLUT",c.brdfLUT),void 0!==c.diffuseImage)n.setTexture("u_DiffuseEnvSampler",c.diffuseImage);else{var l=c.irradianceCoeffs;["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(e,t){n.setVector3("u_shCoefficients.".concat(e),h.fromArray(l[t]))}))}n.setInt("u_MipCount",null!==(t=c.specularMipCount)&&void 0!==t?t:1),n.setTexture("u_SpecularEnvSampler",c.specularImage)}}},n.prototype.hasSkin=function(){return void 0!==this.skin},n.prototype.getEffectsGeometry=function(){return this.geometry.geometry},n.prototype.setGeometry=function(e){this.geometry=e instanceof se?e:new se(e)},n.prototype.setMaterial=function(e){this.material=e instanceof Qe||e instanceof Ze?e:$e(e)},n.prototype.getModelMaterial=function(){return this.effectsMesh.material},n.prototype.isUnlitMaterial=function(){return this.material.materialType===e.PMaterialType.unlit},n.prototype.hasMorph=function(){return void 0!==this.morph&&this.morph.hasMorph()},n.prototype.getWorldBoundingBox=function(){if(void 0===this.parent)return this.boundingBox.isEmpty()&&this.computeBoundingBox(m.fromIdentity()),this.boundingBox;var e=this.parent.matrix;return this.boundingBox.isEmpty()&&this.computeBoundingBox(e.clone().invert()),this.boundingBox.clone().applyMatrix4(e)},n}(),se=function(){function e(e){this.geometry=e,this.attributeNames=e.getAttributeNames()}return e.prototype.dispose=function(){this.geometry=void 0,this.attributeNames=[]},e.prototype.hasAttribute=function(e){return-1!==this.attributeNames.findIndex((function(t){return t===e}))},e.prototype.setHide=function(e){var t=this.geometry;if(0===t.getDrawCount()){var n=t.getIndexData();void 0!==n&&t.setDrawCount(n.length)}e?t.getDrawCount()>=0&&t.setDrawCount(-t.getDrawCount()):t.getDrawCount()<0&&t.setDrawCount(-t.getDrawCount())},e.prototype.isCompressed=function(){this.geometry.getAttributeData("a_Position");return!1},e.prototype.hasPositions=function(){return this.hasAttribute("a_Position")},e.prototype.hasNormals=function(){return this.hasAttribute("a_Normal")},e.prototype.hasTangents=function(){return this.hasAttribute("a_Tangent")},e.prototype.hasUVCoords=function(e){return this.hasAttribute("a_UV".concat(e))},e.prototype.hasColors=function(){return this.hasAttribute("a_Color")},e.prototype.hasJoints=function(){return this.hasAttribute("a_Joint1")},e.prototype.hasWeights=function(){return this.hasAttribute("a_Weight1")},e}(),ce=function(){function e(e,t){this.itemContent=e,this.parentItem=t,this.options=e.options;var n=!0,o=new X,i=e.options;i.primitives.forEach((function(e,t){if(0===t)o.create(e.geometry);else{var i=new X;i.create(e.geometry)?o.equals(i)||(n=!1,console.error("Morpth target mismatch between primtives: ".concat(JSON.stringify(o),", ").concat(JSON.stringify(i)))):n=!1}})),n?(void 0!==i.weights&&o.initWeights(i.weights),this.morphObj=o):this.morphObj=new X}return e.prototype.hasMorphTarget=function(){return this.morphObj.hasMorph()},e.prototype.getMorphObj=function(){if(this.hasMorphTarget())return this.morphObj},e.prototype.isHide=function(){return!0===this.options.hide},e.prototype.getParentNode=function(){var e,t=this.getParentIndex(),n=null===(e=this.parentItem)||void 0===e?void 0:e.getComponent(ut);if(void 0!==n&&t>=0)return n.content.getNodeById(t)},e.prototype.getParentIndex=function(){var e;return null!==(e=this.options.parent)&&void 0!==e?e:-1},e.prototype.getPrimitives=function(){return this.options.primitives},e.prototype.getPrimitiveCount=function(){return this.options.primitives.length},e.prototype.hasSkin=function(){return void 0!==this.options.skin},e.prototype.getSkinOpts=function(){return this.options.skin},e.prototype.getSkinObj=function(e){var t=this.getSkinOpts();if(void 0!==t){var n=new W;return n.create(t,e,this.parentItem),n}},e}(),le=function(){function e(){this.now=new Set,this.last=new Set}return e.prototype.clear=function(){this.now.clear(),this.last.clear()},e.prototype.forward=function(){var e=this.last;this.last=this.now,this.now=e,this.now.clear()},e.prototype.forAddedItem=function(e){var t=this;this.now.forEach((function(n){t.last.has(n)||e(n)}))},e.prototype.forRemovedItem=function(e){var t=this;this.last.forEach((function(n){t.now.has(n)||e(n)}))},e.prototype.forNowItem=function(e){this.now.forEach((function(t){e(t)}))},e}(),ue=function(){function n(e){this.maxLightCount=16,this.renderSkybox=!1,this.compName="SceneManger",this.itemList=[],this.meshList=[],this.engine=e,this.lightManager=new ne,this.cameraManager=new ee,this.parentId2Mesh=new Map,this.enableDynamicSort=!1,this.tickCount=0,this.lastTickSecond=-1,this.sceneAABBCache=new _,this.renderedMeshSet=new le}return n.prototype.initial=function(e){this.clean(),this.compName=e.componentName,this.renderer=e.renderer,this.engine=e.renderer.engine,this.sceneCache=e.sceneCache,this.enableDynamicSort=!0===e.enableDynamicSort,this.renderSkybox=e.renderSkybox,this.maxLightCount=e.lightItemCount,this.cameraManager.initial(this.renderer.getWidth(),this.renderer.getHeight()),this.brdfLUT=this.sceneCache.getBrdfLutTexture(),this.initGlobalState(e),this.maxLightCount>8&&console.warn("Too many light items: ".concat(this.maxLightCount," light(s)"))},n.prototype.initGlobalState=function(e){var n,o,i,r,a,s=this.engine.gpuCapability,c=w.getInstance();c.reset(),c.isWebGL2=2===s.level,c.runtimeEnv=null!==(n=e.runtimeEnv)&&void 0!==n?n:t.PLAYER_OPTIONS_ENV_EDITOR,c.compatibleMode=null!==(o=e.compatibleMode)&&void 0!==o?o:"gltf",c.visBoundingBox=null!==(i=e.visBoundingBox)&&void 0!==i&&i,c.renderMode3D=null!==(r=e.renderMode3D)&&void 0!==r?r:t.spec.RenderMode3D.none,c.renderMode3DUVGridSize=null!==(a=e.renderMode3DUVGridSize)&&void 0!==a?a:1/16},n.prototype.clean=function(){this.dispose(),this.compName="",this.renderer=void 0,this.sceneCache=void 0,this.itemList=[],this.meshList=[],this.lightManager=new ne,this.cameraManager=new ee,this.parentId2Mesh=new Map,this.brdfLUT=void 0,this.skybox=void 0,this.lastTickSecond=-1,this.tickCount=0,this.renderedMeshSet=new le},n.prototype.dispose=function(){var e;this.itemList.forEach((function(e){return e.dispose()})),this.itemList=[],this.meshList.forEach((function(e){return e.dispose()})),this.meshList=[],this.lightManager.dispose(),this.cameraManager.dispose(),this.brdfLUT=void 0,null===(e=this.skybox)||void 0===e||e.dispose(),this.skybox=void 0,this.renderedMeshSet.clear(),this.renderer=void 0,this.sceneCache=void 0,this.engine=void 0,this.parentId2Mesh.clear()},n.prototype.addItem=function(e){if(e instanceof re){var n=e;void 0!==n.parentItemId&&this.parentId2Mesh.set(n.parentItemId,n),t.addItem(this.meshList,n)}else if(e instanceof tt){var o=e;o.setup(this.brdfLUT),this.renderSkybox||(o.renderable=!1),this.skybox=o}else e instanceof te?this.lightManager.insertLight(e):this.cameraManager.insertCamera(e);t.addItem(this.itemList,e)},n.prototype.removeItem=function(e){if(e instanceof re){var n=e;void 0!==n.parentItemId&&this.parentId2Mesh.delete(n.parentItemId),t.removeItem(this.meshList,n)}else e instanceof tt?this.skybox=void 0:e instanceof te?this.lightManager.remove(e):this.cameraManager.remove(e);t.removeItem(this.itemList,e)},n.prototype.updateDefaultCamera=function(e){var n=new t.Transform(r(r({},e),{valid:!0})),o=(new E).fromEffectsTransform(n);this.cameraManager.updateDefaultCamera(e.fov,e.aspect,e.near,e.far,o.getPosition(),o.getRotation(),e.clipMode)},n.prototype.tick=function(e){var t=e,n=this.activeCamera,o=n.viewMatrix,i=n.projectionMatrix,r=i.clone().multiply(o);this.sceneStates={deltaSeconds:t,camera:n,cameraPosition:n.getEye(),viewMatrix:o,projectionMatrix:i,viewProjectionMatrix:r,winSize:n.getSize(),sceneRadius:1,lightList:this.lightManager.lightList,maxLightCount:this.maxLightCount,skybox:this.skybox},this.tickCount+=1,this.lastTickSecond+=t},n.prototype.dynamicSortMeshes=function(e){var t=[],n=[];this.renderedMeshSet.now.forEach((function(e){t.push(e),n.push(e.priority)})),n.sort((function(e,t){return e-t}));var o=e.viewMatrix;t.sort((function(e,t){var n=ke.isTransparentMesh(e),i=ke.isTransparentMesh(t);if(n&&i){var r=h.fromArray(e.worldMatrix.elements,12),a=h.fromArray(t.worldMatrix.elements,12),s=o.transformPoint(r),c=o.transformPoint(a);return s.z-c.z}return n?1:i?-1:0}));for(var i=0;i<t.length;i++){var r=t[i],a=n[i];r.priority=a}},n.prototype.queryMesh=function(e){var t=this.parentId2Mesh.get(e);if(void 0!==t&&t.visible)return t},n.prototype.getSceneAABB=function(t){var n=null!=t?t:new _;return this.itemList.forEach((function(t){if(t.type===e.PObjectType.mesh){var o=t;if(o.owner){var i=o.owner.item.getWorldTransform().getWorldMatrix(),r=o.computeBoundingBox(i);r.applyMatrix4(i),n.union(r)}else n.union(o.computeBoundingBox(m.fromIdentity()))}})),n},n.prototype.printDebugInfo=function(){console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),this.meshList.forEach((function(e,t){console.info("Mesh: ",t,e)})),this.cameraManager.getCameraList().forEach((function(e,t){console.info("Camera: ",t,e)})),console.info("Default Camera: ",this.cameraManager.getDefaultCamera()),this.lightManager.lightList.forEach((function(e,t){console.info("Light: ",t,e)})),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),console.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")},n.prototype.getRenderer=function(){return this.renderer},n.prototype.getSceneCache=function(){return this.sceneCache},Object.defineProperty(n.prototype,"activeCamera",{get:function(){return this.cameraManager.getActiveCamera()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lightCount",{get:function(){return this.lightManager.lightCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"shaderLightCount",{get:function(){return Math.min(10,this.lightManager.lightCount)},enumerable:!1,configurable:!0}),n}(),fe={"animation.vert.glsl":"#ifdef HAS_TARGET_POSITION0\nvsIn vec3 a_Target_Position0;\n#endif\n#ifdef HAS_TARGET_POSITION1\nvsIn vec3 a_Target_Position1;\n#endif\n#ifdef HAS_TARGET_POSITION2\nvsIn vec3 a_Target_Position2;\n#endif\n#ifdef HAS_TARGET_POSITION3\nvsIn vec3 a_Target_Position3;\n#endif\n#ifdef HAS_TARGET_POSITION4\nvsIn vec3 a_Target_Position4;\n#endif\n#ifdef HAS_TARGET_POSITION5\nvsIn vec3 a_Target_Position5;\n#endif\n#ifdef HAS_TARGET_POSITION6\nvsIn vec3 a_Target_Position6;\n#endif\n#ifdef HAS_TARGET_POSITION7\nvsIn vec3 a_Target_Position7;\n#endif\n#ifdef HAS_TARGET_NORMAL0\nvsIn vec3 a_Target_Normal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nvsIn vec3 a_Target_Normal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nvsIn vec3 a_Target_Normal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nvsIn vec3 a_Target_Normal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nvsIn vec3 a_Target_Normal4;\n#endif\n#ifdef HAS_TARGET_TANGENT0\nvsIn vec3 a_Target_Tangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\nvsIn vec3 a_Target_Tangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\nvsIn vec3 a_Target_Tangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\nvsIn vec3 a_Target_Tangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\nvsIn vec3 a_Target_Tangent4;\n#endif\n#ifdef USE_MORPHING\nuniform float u_morphWeights[WEIGHT_COUNT];\n#endif\n#ifdef HAS_JOINT_SET1\nvsIn vec4 a_Joint1;\n#endif\n#ifdef HAS_JOINT_SET2\nvsIn vec4 a_Joint2;\n#endif\n#ifdef HAS_WEIGHT_SET1\nvsIn vec4 a_Weight1;\n#endif\n#ifdef HAS_WEIGHT_SET2\nvsIn vec4 a_Weight2;\n#endif\n#ifdef USE_SKINNING\n#ifdef USE_SKINNING_TEXTURE\nuniform sampler2D u_jointMatrixSampler;uniform sampler2D u_jointNormalMatrixSampler;\n#else\nuniform mat4 u_jointMatrix[JOINT_COUNT];uniform mat4 u_jointNormalMatrix[JOINT_COUNT];\n#endif\n#endif\n#define ROW0_U ((0.5 + 0.0) / 4.0)\n#define ROW1_U ((0.5 + 1.0) / 4.0)\n#define ROW2_U ((0.5 + 2.0) / 4.0)\n#define ROW3_U ((0.5 + 3.0) / 4.0)\n#ifdef USE_SKINNING\nmat4 getJointMatrix(float boneNdx){\n#ifdef USE_SKINNING_TEXTURE\nfloat v=(boneNdx+0.5)/float(JOINT_COUNT);return mat4(texture2D(u_jointMatrixSampler,vec2(ROW0_U,v)),texture2D(u_jointMatrixSampler,vec2(ROW1_U,v)),texture2D(u_jointMatrixSampler,vec2(ROW2_U,v)),texture2D(u_jointMatrixSampler,vec2(ROW3_U,v)));\n#else\nreturn u_jointMatrix[int(boneNdx)];\n#endif\n}mat4 getJointNormalMatrix(float boneNdx){\n#ifdef USE_SKINNING_TEXTURE\nfloat v=(boneNdx+0.5)/float(JOINT_COUNT);return mat4(texture2D(u_jointNormalMatrixSampler,vec2(ROW0_U,v)),texture2D(u_jointNormalMatrixSampler,vec2(ROW1_U,v)),texture2D(u_jointNormalMatrixSampler,vec2(ROW2_U,v)),texture2D(u_jointNormalMatrixSampler,vec2(ROW3_U,v)));\n#else\nreturn u_jointNormalMatrix[int(boneNdx)];\n#endif\n}mat4 getSkinningMatrix(){mat4 skin=mat4(0);\n#if defined(HAS_WEIGHT_SET1) && defined(HAS_JOINT_SET1)\nskin+=a_Weight1.x*getJointMatrix(a_Joint1.x)+a_Weight1.y*getJointMatrix(a_Joint1.y)+a_Weight1.z*getJointMatrix(a_Joint1.z)+a_Weight1.w*getJointMatrix(a_Joint1.w);\n#endif\nreturn skin;}mat4 getSkinningNormalMatrix(){mat4 skin=mat4(0);\n#if defined(HAS_WEIGHT_SET1) && defined(HAS_JOINT_SET1)\nskin+=a_Weight1.x*getJointNormalMatrix(a_Joint1.x)+a_Weight1.y*getJointNormalMatrix(a_Joint1.y)+a_Weight1.z*getJointNormalMatrix(a_Joint1.z)+a_Weight1.w*getJointNormalMatrix(a_Joint1.w);\n#endif\nreturn skin;}\n#endif\n#ifdef USE_MORPHING\nvec4 getTargetPosition(){vec4 pos=vec4(0);\n#ifdef HAS_TARGET_POSITION0\npos.xyz+=u_morphWeights[0]*a_Target_Position0;\n#endif\n#ifdef HAS_TARGET_POSITION1\npos.xyz+=u_morphWeights[1]*a_Target_Position1;\n#endif\n#ifdef HAS_TARGET_POSITION2\npos.xyz+=u_morphWeights[2]*a_Target_Position2;\n#endif\n#ifdef HAS_TARGET_POSITION3\npos.xyz+=u_morphWeights[3]*a_Target_Position3;\n#endif\n#ifdef HAS_TARGET_POSITION4\npos.xyz+=u_morphWeights[4]*a_Target_Position4;\n#endif\nreturn pos;}vec4 getTargetNormal(){vec4 normal=vec4(0);\n#ifdef HAS_TARGET_NORMAL0\nnormal.xyz+=u_morphWeights[0]*a_Target_Normal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nnormal.xyz+=u_morphWeights[1]*a_Target_Normal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nnormal.xyz+=u_morphWeights[2]*a_Target_Normal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nnormal.xyz+=u_morphWeights[3]*a_Target_Normal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nnormal.xyz+=u_morphWeights[4]*a_Target_Normal4;\n#endif\nreturn normal;}vec4 getTargetTangent(){vec4 tangent=vec4(0);\n#ifdef HAS_TARGET_TANGENT0\ntangent.xyz+=u_morphWeights[0]*a_Target_Tangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\ntangent.xyz+=u_morphWeights[1]*a_Target_Tangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\ntangent.xyz+=u_morphWeights[2]*a_Target_Tangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\ntangent.xyz+=u_morphWeights[3]*a_Target_Tangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\ntangent.xyz+=u_morphWeights[4]*a_Target_Tangent4;\n#endif\nreturn tangent;}\n#endif\n","extensions.frag.glsl":"vec3 _dFdx(vec3 coord){\n#if defined(GL_OES_standard_derivatives) || defined(WEBGL2)\nreturn dFdx(coord);\n#endif\nreturn vec3(0.0);}vec3 _dFdy(vec3 coord){\n#if defined(GL_OES_standard_derivatives) || defined(WEBGL2)\nreturn dFdy(coord);\n#endif\nreturn vec3(0.0);}\n#ifdef USE_TEX_LOD\nvec4 _textureCubeLodEXT(samplerCube sampler,vec3 coord,float lod){\n#if defined(WEBGL2) || defined(GL_EXT_shader_texture_lod)\nreturn textureCubeLodEXT(sampler,coord,lod);\n#else\nreturn textureCube(sampler,coord,lod);\n#endif\n}\n#endif\n","tonemapping.frag.glsl":"uniform float u_Exposure;const float GAMMA=2.2;const float INV_GAMMA=1.0/GAMMA;vec3 LINEARtoSRGB(vec3 color){return pow(color,vec3(INV_GAMMA));}vec4 SRGBtoLINEAR(vec4 srgbIn){return vec4(pow(srgbIn.xyz,vec3(GAMMA)),srgbIn.w);}vec3 toneMapUncharted2Impl(vec3 color){const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;return((color*(A*color+C*B)+D*E)/(color*(A*color+B)+D*F))-E/F;}vec3 toneMapUncharted(vec3 color){const float W=11.2;color=toneMapUncharted2Impl(color*2.0);vec3 whiteScale=1.0/toneMapUncharted2Impl(vec3(W));return LINEARtoSRGB(color*whiteScale);}vec3 toneMapHejlRichard(vec3 color){color=max(vec3(0.0),color-vec3(0.004));return(color*(6.2*color+.5))/(color*(6.2*color+1.7)+0.06);}vec3 toneMapACES(vec3 color){const float A=2.51;const float B=0.03;const float C=2.43;const float D=0.59;const float E=0.14;return LINEARtoSRGB(clamp((color*(A*color+B))/(color*(C*color+D)+E),0.0,1.0));}vec3 toneMap(vec3 color){color*=u_Exposure;\n#ifdef TONEMAP_UNCHARTED\nreturn toneMapUncharted(color);\n#endif\n#ifdef TONEMAP_HEJLRICHARD\nreturn toneMapHejlRichard(color);\n#endif\n#ifdef TONEMAP_ACES\nreturn toneMapACES(color);\n#endif\nreturn LINEARtoSRGB(color);}","textures.vert.glsl":"fsIn vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nfsIn vec2 v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D u_NormalSampler;uniform float u_NormalScale;uniform int u_NormalUVSet;uniform mat3 u_NormalUVTransform;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D u_EmissiveSampler;uniform int u_EmissiveUVSet;uniform vec3 u_EmissiveFactor;uniform mat3 u_EmissiveUVTransform;\n#endif\n#ifdef HAS_EMISSIVE\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_OCCLUSION_MAP\nuniform sampler2D u_OcclusionSampler;uniform int u_OcclusionUVSet;uniform float u_OcclusionStrength;uniform mat3 u_OcclusionUVTransform;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nuniform sampler2D u_BaseColorSampler;uniform int u_BaseColorUVSet;uniform mat3 u_BaseColorUVTransform;\n#endif\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nuniform sampler2D u_MetallicRoughnessSampler;uniform int u_MetallicRoughnessUVSet;uniform mat3 u_MetallicRoughnessUVTransform;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D u_DiffuseSampler;uniform int u_DiffuseUVSet;uniform mat3 u_DiffuseUVTransform;\n#endif\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nuniform sampler2D u_SpecularGlossinessSampler;uniform int u_SpecularGlossinessUVSet;uniform mat3 u_SpecularGlossinessUVTransform;\n#endif\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;uniform samplerCube u_SpecularEnvSampler;uniform sampler2D u_brdfLUT;uniform vec2 u_IblIntensity;\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients u_shCoefficients;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform sampler2D u_ShadowSampler;\n#endif\nvec2 getNormalUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_NORMAL_MAP\n#ifdef HAS_UV_SET2\nuv.xy=u_NormalUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_UV_TRANSFORM\nuv*=u_NormalUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getEmissiveUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_EMISSIVE_MAP\n#ifdef HAS_UV_SET2\nuv.xy=u_EmissiveUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_EMISSIVE_UV_TRANSFORM\nuv*=u_EmissiveUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getOcclusionUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_OCCLUSION_MAP\n#ifdef HAS_UV_SET2\nuv.xy=u_OcclusionUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_OCCLUSION_UV_TRANSFORM\nuv*=u_OcclusionUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getBaseColorUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_BASE_COLOR_MAP\n#ifdef HAS_UV_SET2\nuv.xy=u_BaseColorUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_BASECOLOR_UV_TRANSFORM\nuv*=u_BaseColorUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getMetallicRoughnessUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\n#ifdef HAS_UV_SET2\nuv.xy=u_MetallicRoughnessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_METALLICROUGHNESS_UV_TRANSFORM\nuv*=u_MetallicRoughnessUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getSpecularGlossinessUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\n#ifdef HAS_UV_SET2\nuv.xy=u_SpecularGlossinessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_UV_TRANSFORM\nuv*=u_SpecularGlossinessUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getDiffuseUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_DIFFUSE_MAP\n#ifdef HAS_UV_SET2\nuv.xy=u_DiffuseUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_DIFFUSE_UV_TRANSFORM\nuv*=u_DiffuseUVTransform;\n#endif\n#endif\nreturn uv.xy;}","functions.frag.glsl":"const float M_PI=3.141592653589793;const float c_MinReflectance=0.04;fsIn vec3 v_Position;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nfsIn mat3 v_TBN;\n#else\nfsIn vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nfsIn vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nfsIn vec4 v_Color;\n#endif\nstruct AngularInfo{float NdotL;float NdotV;float NdotH;float LdotH;float VdotH;vec3 padding;};vec4 getVertexColor(){vec4 color=vec4(1.0,1.0,1.0,1.0);\n#ifdef HAS_VERTEX_COLOR_VEC3\ncolor.rgb=v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\ncolor=v_Color;\n#endif\nreturn color;}vec3 getNormal(){vec2 UV=getNormalUV();\n#ifndef HAS_TANGENTS\nvec3 pos_dx=_dFdx(v_Position);vec3 pos_dy=_dFdy(v_Position);vec3 tex_dx=_dFdx(vec3(UV,0.0));vec3 tex_dy=_dFdy(vec3(UV,0.0));vec3 t=(tex_dy.t*pos_dx-tex_dx.t*pos_dy)/(tex_dx.s*tex_dy.t-tex_dy.s*tex_dx.t);\n#ifdef HAS_NORMALS\nvec3 ng=normalize(v_Normal);\n#else\nvec3 ng=cross(pos_dx,pos_dy);\n#endif\nt=normalize(t-ng*dot(ng,t));vec3 b=normalize(cross(ng,t));mat3 tbn=mat3(t,b,ng);\n#else\nmat3 tbn=v_TBN;\n#endif\n#ifdef HAS_NORMAL_MAP\nvec3 n=texture2D(u_NormalSampler,UV).rgb;n=normalize(tbn*((2.0*n-1.0)*vec3(u_NormalScale,u_NormalScale,1.0)));\n#else\nvec3 n=normalize(tbn[2].xyz);\n#endif\n#ifdef DOUBLE_SIDED\nfloat faceDirection=gl_FrontFacing ? 1.0 :-1.0;n=n*faceDirection;\n#endif\nreturn n;}float getPerceivedBrightness(vec3 vector){return sqrt(0.299*vector.r*vector.r+0.587*vector.g*vector.g+0.114*vector.b*vector.b);}float solveMetallic(vec3 diffuse,vec3 specular,float oneMinusSpecularStrength){float specularBrightness=getPerceivedBrightness(specular);if(specularBrightness<c_MinReflectance){return 0.0;}float diffuseBrightness=getPerceivedBrightness(diffuse);float a=c_MinReflectance;float b=diffuseBrightness*oneMinusSpecularStrength/(1.0-c_MinReflectance)+specularBrightness-2.0*c_MinReflectance;float c=c_MinReflectance-specularBrightness;float D=b*b-4.0*a*c;return clamp((-b+sqrt(D))/(2.0*a),0.0,1.0);}AngularInfo getAngularInfo(vec3 pointToLight,vec3 normal,vec3 view){vec3 n=normalize(normal);vec3 v=normalize(view);vec3 l=normalize(pointToLight);vec3 h=normalize(l+v);float NdotL=clamp(dot(n,l),0.0,1.0);float NdotV=clamp(dot(n,v),0.0,1.0);float NdotH=clamp(dot(n,h),0.0,1.0);float LdotH=clamp(dot(l,h),0.0,1.0);float VdotH=clamp(dot(v,h),0.0,1.0);return AngularInfo(NdotL,NdotV,NdotH,LdotH,VdotH,vec3(0,0,0));}float getAARoughnessFactor(vec3 normal){vec3 dxy=max(abs(_dFdx(normal)),abs(_dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z)*2.0;}\n#ifdef DEBUG_UV\nuniform float u_DebugUVGridSize;float getDebugUVColor(vec2 uv,vec3 n){float s=dot(abs(n),vec3(1,1,1))*0.6;uv=uv/(u_DebugUVGridSize*2.0);uv=uv-floor(uv);uv=uv*2.0-vec2(1.0);return s*(uv.x*uv.y>=0.0 ? 0.2: 1.0);}\n#endif\n","shadow.frag.glsl":"#ifdef USE_SHADOW_MAPPING\nuniform vec2 u_ShadowMapSizeInv;fsIn vec4 v_PositionLightSpace;fsIn vec4 v_dPositionLightSpace;\n#endif\nfloat linstep(float low,float high,float v){return clamp((v-low)/(high-low),0.0,1.0);}\n#ifdef USE_SHADOW_MAPPING\nfloat chebyshev(vec2 moments,float depth,float minVar){float p=step(depth,moments.x+SHADOWMAP_BAIS);float variance=max(moments.y-moments.x*moments.x,minVar);float d=depth-(moments.x+SHADOWMAP_BAIS);float pMax=linstep(0.2,1.0,variance/(variance+d*d));return mix(0.1,1.0,min(max(p,pMax),1.0));}float getShadowContributionSM(){vec3 coords=v_PositionLightSpace.xyz/v_PositionLightSpace.w*0.5+0.5;if(coords.z<0.01||coords.z>0.99||coords.x<0.01||coords.x>0.99||coords.y<0.01||coords.y>0.99){return 1.0;}vec2 moments=vec2(1.0)-texture2D(u_ShadowSampler,coords.xy).xy;return coords.z<moments.x*1.008+0.008? 1.0: 0.2;}float getShadowContributionVSM(){vec3 coords=v_PositionLightSpace.xyz/v_PositionLightSpace.w*0.5+0.5;if(coords.z<0.01||coords.z>0.99||coords.x<0.01||coords.x>0.99||coords.y<0.01||coords.y>0.99){return 1.0;}vec2 moments=vec2(1.0)-texture2D(u_ShadowSampler,coords.xy).xy;return chebyshev(moments,coords.z,0.00002);}float computeEVSMShadow(vec2 coords,float pos,float neg){vec4 moments=texture2D(u_ShadowSampler,coords);float posShadow=chebyshev(moments.xy,pos,0.00002);float negShadow=chebyshev(moments.zw,neg,0.00002);return min(posShadow,negShadow);}float getShadowContributionEVSM(){vec3 coords=v_PositionLightSpace.xyz/v_PositionLightSpace.w*0.5+0.5;if(coords.z<0.01||coords.z>0.99||coords.x<0.01||coords.x>0.99||coords.y<0.01||coords.y>0.99){return 1.0;}float depth=coords.z;float pos=EVSM_FUNC0(depth);float neg=EVSM_FUNC1(depth);\n#ifdef SHADOWMAP_EVSM_PCF\nvec2 newCoords=v_dPositionLightSpace.xy/v_dPositionLightSpace.w*0.5+0.5;vec2 dCoords=min(abs(newCoords-coords.xy),u_ShadowMapSizeInv);if(max(dCoords.x,dCoords.y)>=min(u_ShadowMapSizeInv.x,u_ShadowMapSizeInv.y)*0.5){vec2 coords0=coords.xy+vec2(-1.0,-1.0)*dCoords;vec2 coords1=coords.xy+vec2(-1.0,1.0)*dCoords;vec2 coords2=coords.xy+vec2(1.0,-1.0)*dCoords;vec2 coords3=coords.xy+vec2(1.0,1.0)*dCoords;float shadow0=computeEVSMShadow(coords0,pos,neg);float shadow1=computeEVSMShadow(coords1,pos,neg);float shadow2=computeEVSMShadow(coords2,pos,neg);float shadow3=computeEVSMShadow(coords3,pos,neg);return(shadow0+shadow1+shadow2+shadow3)*0.25;}else{return computeEVSMShadow(coords.xy,pos,neg);}\n#else\nreturn computeEVSMShadow(coords.xy,pos,neg);\n#endif\n}float getShadowContribution(){\n#if defined(SHADOWMAP_STANDARD)\nreturn getShadowContributionSM();\n#elif defined(SHADOWMAP_VSM)\nreturn getShadowContributionVSM();\n#else\nreturn getShadowContributionEVSM();\n#endif\n}\n#endif\n","webglCompatibility.glsl":"#ifdef WEBGL2\n#define vsIn in\n#define vsOut out\n#define fsIn in\n#define fsOut out\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\n#else\n#define vsIn attribute\n#define vsOut varying\n#define fsIn varying\n#define fsOut varying\n#endif\n","shadowCommon.vert.glsl":"\n#define SHADOWMAP_BAIS 0.001\n#define EVSM_FUNC0(DEPTH) -exp(-7.0 * DEPTH)\n#define EVSM_FUNC1(DEPTH) -exp(-6.0 * DEPTH)\n"};!function(e){e.build=function(e,t,n){for(var o;null!==(o=/#include <(.+)>/gm.exec(e));)e=e.replace(o[0],fe[o[1]]);return e=e.replace(/#define FEATURES/,t.map((function(e){return"#define ".concat(e)})).join("\n")),n?"#version 300 es\n"+e:"#version 100\n"+e}}(J||(J={}));var he=function(){function t(){}return t.getVertexShaderCode=function(t){var n=t.isWebGL2,o=t.featureList,i=t.material.materialType;switch(i){case e.PMaterialType.unlit:case e.PMaterialType.pbr:case e.PMaterialType.shadowBase:return J.build("precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\n#include <animation.vert.glsl>\nvsIn vec4 a_Position;vsOut vec3 v_Position;\n#ifdef HAS_NORMALS\nvsIn vec4 a_Normal;\n#endif\n#ifdef HAS_TANGENTS\nvsIn vec4 a_Tangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvsOut mat3 v_TBN;\n#else\nvsOut vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nvsIn vec2 a_UV1;\n#endif\n#ifdef HAS_UV_SET2\nvsIn vec2 a_UV2;\n#endif\nvsOut vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nvsOut vec2 v_UVCoord2;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nvsIn vec3 a_Color;vsOut vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nvsIn vec4 a_Color;vsOut vec4 v_Color;\n#endif\nuniform mat4 u_ViewProjectionMatrix;uniform mat4 u_ModelMatrix;uniform mat4 u_NormalMatrix;\n#ifdef EDITOR_TRANSFORM\nuniform vec4 uEditorTransform;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform mat4 u_LightViewProjectionMatrix;uniform float u_DeltaSceneSize;vsOut vec4 v_PositionLightSpace;vsOut vec4 v_dPositionLightSpace;\n#endif\nvec4 getPosition(){vec4 pos=vec4(a_Position.xyz,1.0);\n#ifdef USE_MORPHING\npos+=getTargetPosition();\n#endif\n#ifdef USE_SKINNING\npos=getSkinningMatrix()*pos;\n#endif\nreturn pos;}\n#ifdef HAS_NORMALS\nvec4 getNormal(){vec4 normal=a_Normal;\n#ifdef USE_MORPHING\nnormal+=getTargetNormal();\n#endif\n#ifdef USE_SKINNING\nnormal=getSkinningNormalMatrix()*normal;\n#endif\nreturn normalize(normal);}\n#endif\n#ifdef HAS_TANGENTS\nvec4 getTangent(){vec4 tangent=a_Tangent;\n#ifdef USE_MORPHING\ntangent+=getTargetTangent();\n#endif\n#ifdef USE_SKINNING\ntangent=getSkinningMatrix()*tangent;\n#endif\nreturn normalize(tangent);}\n#endif\nvoid main(){vec4 pos=u_ModelMatrix*getPosition();v_Position=vec3(pos.xyz)/pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec4 tangent=getTangent();vec3 normalW=normalize(vec3(u_NormalMatrix*vec4(getNormal().xyz,0.0)));vec3 tangentW=normalize(vec3(u_ModelMatrix*vec4(tangent.xyz,0.0)));vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\n#else\nv_Normal=normalize(vec3(u_NormalMatrix*vec4(getNormal().xyz,0.0)));\n#endif\n#endif\nv_UVCoord1=vec2(0.0,0.0);\n#ifdef HAS_UV_SET1\nv_UVCoord1=a_UV1;\n#endif\n#ifdef HAS_UV_SET2\nv_UVCoord2=a_UV2;\n#endif\n#if defined(HAS_VERTEX_COLOR_VEC3) || defined(HAS_VERTEX_COLOR_VEC4)\nv_Color=a_Color;\n#endif\n#ifdef USE_SHADOW_MAPPING\nv_PositionLightSpace=u_LightViewProjectionMatrix*pos;vec3 dpos=vec3(u_DeltaSceneSize);v_dPositionLightSpace=u_LightViewProjectionMatrix*(pos+vec4(dpos,0));\n#endif\ngl_Position=u_ViewProjectionMatrix*pos;\n#ifdef EDITOR_TRANSFORM\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}",o,n);case e.PMaterialType.skyboxFilter:return J.build("precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\nvsIn vec3 a_Position;vsOut vec3 v_CameraDir;uniform mat4 u_InvViewProjectionMatrix;void main(){vec4 dir=u_InvViewProjectionMatrix*vec4(a_Position.xy,1,1);v_CameraDir=normalize(dir.xyz/dir.w);gl_Position=vec4(a_Position.xy,0.99999,1);}",o,n);default:throw new Error("Invalid material type ".concat(i," for getVertexShaderString!"))}},t.getFragmentShaderCode=function(t){var n=t.isWebGL2,o=t.featureList,i=t.material.materialType;switch(i){case e.PMaterialType.unlit:case e.PMaterialType.pbr:return J.build("\n#define FEATURES\n#ifndef WEBGL2\n#extension GL_OES_standard_derivatives : enable\n#endif\n#if !defined(WEBGL2) && defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef USE_HDR\n#extension GL_OES_texture_float : enable\n#extension GL_OES_texture_float_linear : enable\n#endif\n#if !defined(WEBGL2) && defined(USE_WBOIT)\n#extension GL_EXT_draw_buffers: require\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\n#ifdef USE_WBOIT\nlayout(location=0)out vec4 outFragColor0;layout(location=1)out vec4 outFragColor1;\n#else\nout vec4 outFragColor;\n#endif\n#else\n#ifdef USE_WBOIT\n#define outFragColor0 gl_FragData[0]\n#define outFragColor1 gl_FragData[1]\n#else\n#define outFragColor gl_FragColor\n#endif\n#endif\n#include <webglCompatibility.glsl>\n#include <extensions.frag.glsl>\n#include <tonemapping.frag.glsl>\n#include <textures.vert.glsl>\n#include <functions.frag.glsl>\n#include <shadowCommon.vert.glsl>\n#include <shadow.frag.glsl>\nstruct Light{vec3 direction;float range;vec3 color;float intensity;vec3 position;float innerConeCos;float outerConeCos;int type;vec2 padding;};const int LightType_Directional=0;const int LightType_Point=1;const int LightType_Spot=2;const int LightType_Ambient=3;\n#ifdef USE_PUNCTUAL\nuniform Light u_Lights[LIGHT_COUNT];\n#endif\n#if defined(MATERIAL_SPECULARGLOSSINESS) || defined(MATERIAL_METALLICROUGHNESS)\nuniform float u_MetallicFactor;uniform float u_RoughnessFactor;uniform vec4 u_BaseColorFactor;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\nuniform vec3 u_SpecularFactor;uniform vec4 u_DiffuseFactor;uniform float u_GlossinessFactor;\n#endif\n#ifdef ALPHAMODE_MASK\nuniform float u_AlphaCutoff;\n#endif\n#ifdef ADD_FOG\nuniform vec4 u_FogColor;\n#ifdef LINEAR_FOG\nuniform float u_FogNear;uniform float u_FogFar;\n#endif\n#ifdef EXP_FOG\nuniform float u_FogDensity;\n#endif\n#endif\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\nuniform vec3 u_Camera;uniform int u_MipCount;struct MaterialInfo{float perceptualRoughness;vec3 reflectance0;float alphaRoughness;vec3 diffuseColor;vec3 reflectance90;vec3 specularColor;};\n#ifdef ADD_FOG\nvec3 getMixFogColor(vec3 baseColor){vec3 distance=u_Camera-v_Position;float fogAmount=0.0;\n#ifdef LINEAR_FOG\nfogAmount=smoothstep(u_FogNear,u_FogFar,distance[2]);\n#endif\n#ifdef EXP_FOG\n#define LOG2 1.442695\nfogAmount=1.-exp2(-u_FogDensity*u_FogDensity*distance[2]*distance[2]*LOG2);fogAmount=clamp(fogAmount,0.,1.);\n#endif\nvec3 mixColor=baseColor.rgb+(vec3(u_FogColor)-baseColor.rgb)*fogAmount;return mixColor;}\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 getIrradiance(vec3 norm,SHCoefficients c){float x=norm.x;float y=norm.y;float z=norm.z;float c1=0.429043;float c2=0.511664;float c3=0.743125;float c4=0.886227;float c5=0.247708;vec3 irradiance=c1*c.l22*(x*x-y*y)+c3*c.l20*(z*z)+c4*c.l00-c5*c.l20+2.0*c1*(c.l2m2*x*y+c.l21*x*z+c.l2m1*y*z)+2.0*c2*(c.l11*x+c.l1m1*y+c.l10*z);return irradiance;}\n#endif\n#ifdef USE_IBL\nvec3 getIBLContribution(MaterialInfo materialInfo,vec3 n,vec3 v){float NdotV=clamp(dot(n,v),0.0,1.0);float lod=clamp(materialInfo.perceptualRoughness*float(u_MipCount),0.0,float(u_MipCount));vec3 reflection=normalize(reflect(-v,n));vec2 brdfSamplePoint=clamp(vec2(NdotV,materialInfo.perceptualRoughness),vec2(0.0,0.0),vec2(1.0,1.0));vec2 brdf=texture2D(u_brdfLUT,brdfSamplePoint).rg;vec4 diffuseColor=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,u_shCoefficients);diffuseColor=vec4(irradiance,1.0);\n#else\ndiffuseColor=textureCube(u_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(u_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(u_SpecularEnvSampler,reflection,lod);\n#endif\n#ifdef USE_HDR\nvec3 diffuseLight=diffuseColor.rgb;vec3 specularLight=specularSample.rgb;\n#else\nvec3 diffuseLight=SRGBtoLINEAR(diffuseColor).rgb;vec3 specularLight=SRGBtoLINEAR(specularSample).rgb;\n#endif\nvec3 diffuse=diffuseLight*materialInfo.diffuseColor;vec3 specular=specularLight*(materialInfo.specularColor*brdf.x+brdf.y);return diffuse*u_IblIntensity[0]+specular*u_IblIntensity[1];}\n#endif\nvec3 diffuse(MaterialInfo materialInfo){return materialInfo.diffuseColor/M_PI;}vec3 specularReflection(MaterialInfo materialInfo,AngularInfo angularInfo){return materialInfo.reflectance0+(materialInfo.reflectance90-materialInfo.reflectance0)*pow(clamp(1.0-angularInfo.VdotH,0.0,1.0),5.0);}float visibilityOcclusion(MaterialInfo materialInfo,AngularInfo angularInfo){float NdotL=angularInfo.NdotL;float NdotV=angularInfo.NdotV;float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGX=GGXV+GGXL;if(GGX>0.0){return 0.5/GGX;}return 0.0;}float microfacetDistribution(MaterialInfo materialInfo,AngularInfo angularInfo){float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float f=(angularInfo.NdotH*alphaRoughnessSq-angularInfo.NdotH)*angularInfo.NdotH+1.0;return alphaRoughnessSq/(M_PI*f*f);}vec3 getPointShade(vec3 pointToLight,MaterialInfo materialInfo,vec3 normal,vec3 view){AngularInfo angularInfo=getAngularInfo(pointToLight,normal,view);if(angularInfo.NdotL>0.0||angularInfo.NdotV>0.0){vec3 F=specularReflection(materialInfo,angularInfo);float Vis=visibilityOcclusion(materialInfo,angularInfo);float D=microfacetDistribution(materialInfo,angularInfo);vec3 diffuseContrib=(1.0-F)*diffuse(materialInfo);vec3 specContrib=F*Vis*D;return angularInfo.NdotL*(diffuseContrib+specContrib);}return vec3(0.0,0.0,0.0);}float getRangeAttenuation(float range,float distance){if(range<=0.0){return 1.0;}return 1.0/(pow(5.0*distance/range,2.0)+1.0);}float getSpotAttenuation(vec3 pointToLight,vec3 spotDirection,float outerConeCos,float innerConeCos){float actualCos=dot(normalize(spotDirection),normalize(-pointToLight));if(actualCos>outerConeCos){if(actualCos<innerConeCos){return smoothstep(outerConeCos,innerConeCos,actualCos);}return 1.0;}return 0.0;}vec3 applyDirectionalLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=-light.direction;vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return light.intensity*light.color*shade;}vec3 applyPointLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float attenuation=getRangeAttenuation(light.range,distance);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view);return light.color*shade*attenuation*light.intensity;}vec3 applySpotLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float rangeAttenuation=getRangeAttenuation(light.range,distance);float spotAttenuation=getSpotAttenuation(pointToLight,light.direction,light.outerConeCos,light.innerConeCos);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return rangeAttenuation*spotAttenuation*light.intensity*light.color*shade;}vec3 applyAmbientLight(Light light,MaterialInfo materialInfo){return light.intensity*light.color*diffuse(materialInfo);}float weight(float z,float a){return clamp(pow(min(1.0,a*10.0)+0.01,3.0)*1e8*pow(1.0-z*0.9,3.0),1e-2,3e3);}void writeFragmentColor(vec4 fragColor){\n#if !defined(ALPHAMODE_OPAQUE) && defined(USE_WBOIT)\nfloat w=weight(gl_FragCoord.z,fragColor.a);fragColor.rgb*=fragColor.a;outFragColor0=vec4(fragColor.rgb*w,fragColor.a);outFragColor1=vec4(fragColor.a*w);\n#else\noutFragColor=fragColor;\n#endif\n}void main(){float perceptualRoughness=0.0;float metallic=0.0;vec4 baseColor=vec4(0.0,0.0,0.0,1.0);vec3 diffuseColor=vec3(0.0);vec3 specularColor=vec3(0.0);vec3 f0=vec3(0.04);\n#ifdef PREVIEW_BORDER\nwriteFragmentColor(uPreviewColor);return;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nvec4 sgSample=SRGBtoLINEAR(texture2D(u_SpecularGlossinessSampler,getSpecularGlossinessUV()));perceptualRoughness=(1.0-sgSample.a*u_GlossinessFactor);f0=sgSample.rgb*u_SpecularFactor;\n#else\nf0=u_SpecularFactor;perceptualRoughness=1.0-u_GlossinessFactor;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nbaseColor=SRGBtoLINEAR(texture2D(u_DiffuseSampler,getDiffuseUV()))*u_DiffuseFactor;\n#else\nbaseColor=SRGBtoLINEAR(u_DiffuseFactor);\n#endif\nbaseColor*=getVertexColor();specularColor=f0;float oneMinusSpecularStrength=1.0-max(max(f0.r,f0.g),f0.b);diffuseColor=baseColor.rgb*oneMinusSpecularStrength;\n#ifdef DEBUG_METALLIC\nmetallic=solveMetallic(baseColor.rgb,specularColor,oneMinusSpecularStrength);\n#endif\n#endif\n#ifdef MATERIAL_METALLICROUGHNESS\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nvec4 mrSample=texture2D(u_MetallicRoughnessSampler,getMetallicRoughnessUV());perceptualRoughness=mrSample.g*u_RoughnessFactor;metallic=mrSample.b*u_MetallicFactor;\n#else\nmetallic=u_MetallicFactor;perceptualRoughness=u_RoughnessFactor;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nbaseColor=SRGBtoLINEAR(texture2D(u_BaseColorSampler,getBaseColorUV()))*u_BaseColorFactor;\n#else\nbaseColor=SRGBtoLINEAR(u_BaseColorFactor);\n#endif\nbaseColor*=getVertexColor();diffuseColor=baseColor.rgb*(vec3(1.0)-f0)*(1.0-metallic);specularColor=mix(f0,baseColor.rgb,metallic);\n#endif\n#ifdef ALPHAMODE_MASK\nif(baseColor.a<u_AlphaCutoff){discard;}baseColor.a=1.0;\n#endif\n#ifdef ALPHAMODE_OPAQUE\nbaseColor.a=1.0;\n#endif\n#ifdef MATERIAL_UNLIT\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec3 mixColor=getMixFogColor(baseColor.rgb);vec4 fragColorUnlit=vec4(LINEARtoSRGB(mixColor)*baseColor.a,baseColor.a);\n#else\nvec4 fragColorUnlit=vec4(LINEARtoSRGB(baseColor.rgb)*baseColor.a,baseColor.a);\n#endif\nwriteFragmentColor(fragColorUnlit);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),getNormal()));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=getNormal()*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\noutFragColor.rgb=vec3(1.0);\n#endif\n#ifdef DEBUG_EMISSIVE\noutFragColor.rgb=vec3(0.0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\nreturn;\n#endif\nmetallic=clamp(metallic,0.0,1.0);float alphaRoughness=perceptualRoughness*perceptualRoughness;vec3 normal=getNormal();\n#ifdef USE_SPECULAR_AA\nfloat AARoughnessFactor=getAARoughnessFactor(normal);perceptualRoughness+=AARoughnessFactor;alphaRoughness+=AARoughnessFactor;\n#endif\nperceptualRoughness=clamp(perceptualRoughness,0.04,1.0);alphaRoughness=clamp(alphaRoughness,0.04,1.0);float reflectance=max(max(specularColor.r,specularColor.g),specularColor.b);vec3 specularEnvironmentR0=specularColor.rgb;vec3 specularEnvironmentR90=vec3(clamp(reflectance*50.0,0.0,1.0));MaterialInfo materialInfo=MaterialInfo(perceptualRoughness,specularEnvironmentR0,alphaRoughness,diffuseColor,specularEnvironmentR90,specularColor);vec3 color=vec3(0.0,0.0,0.0);vec3 view=normalize(u_Camera-v_Position);float shadow=1.0;\n#ifdef USE_SHADOW_MAPPING\nshadow=getShadowContribution();\n#endif\n#ifdef USE_PUNCTUAL\nfor(int i=0;i<LIGHT_COUNT;++i){Light light=u_Lights[i];if(light.type==LightType_Directional){color+=applyDirectionalLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Point){color+=applyPointLight(light,materialInfo,normal,view);}else if(light.type==LightType_Spot){color+=applySpotLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Ambient){color+=applyAmbientLight(light,materialInfo);}}\n#endif\n#ifdef USE_IBL\ncolor+=getIBLContribution(materialInfo,normal,view);\n#endif\nfloat ao=1.0;\n#ifdef HAS_OCCLUSION_MAP\nao=texture2D(u_OcclusionSampler,getOcclusionUV()).r;color=mix(color,color*ao,u_OcclusionStrength);\n#endif\nvec3 emissive=vec3(0);\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec4 toneMapColor=SRGBtoLINEAR(vec4(toneMap(color),baseColor.a));color=getMixFogColor(toneMapColor.rgb);vec4 fragColorOut=vec4(LINEARtoSRGB(color.rgb)*baseColor.a,baseColor.a);\n#else\ncolor=toneMap(color)*baseColor.a;\n#ifdef HAS_EMISSIVE\ncolor+=u_EmissiveFactor;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(u_EmissiveSampler,getEmissiveUV())).rgb*u_EmissiveFactor;color+=emissive;\n#endif\nvec4 fragColorOut=vec4(color,baseColor.a);\n#endif\nwriteFragmentColor(fragColorOut);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),normal));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=normal*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\n#ifdef HAS_OCCLUSION_MAP\noutFragColor.rgb=vec3(mix(1.0,ao,u_OcclusionStrength));\n#else\noutFragColor.rgb=vec3(1.0);\n#endif\n#endif\n#ifdef DEBUG_EMISSIVE\n#ifdef HAS_EMISSIVE\nemissive=u_EmissiveFactor;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(u_EmissiveSampler,getEmissiveUV())).rgb*u_EmissiveFactor;\n#endif\noutFragColor.rgb=LINEARtoSRGB(emissive);\n#endif\n#ifdef DEBUG_F0\noutFragColor.rgb=vec3(f0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\n}",o,n);case e.PMaterialType.shadowBase:return J.build("#define FEATURES\n#include <shadowCommon.vert.glsl>\n#include <webglCompatibility.glsl>\n#if defined(SHADOWMAP_VSM) && !defined(WEBGL2)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\nout vec4 outFragColor;\n#else\n#define outFragColor gl_FragColor\n#endif\nvec4 CalcMomentVSM(float depth){float dx=0.0;float dy=0.0;\n#if defined(SHADOWMAP_VSM) && (defined(GL_OES_standard_derivatives) || defined(WEBGL2))\ndx=dFdx(depth);dy=dFdy(depth);\n#endif\nfloat moment2=depth*depth+0.25*(dx*dx+dy*dy);return vec4(1.0-depth,1.0-moment2,0.0,1.0);}vec4 CalcMomentEVSM(float depth){float pos=EVSM_FUNC0(depth);float neg=EVSM_FUNC1(depth);return vec4(pos,pos*pos,neg,neg*neg);}void main(){\n#if defined(SHADOWMAP_STANDARD) || defined(SHADOWMAP_VSM)\noutFragColor=CalcMomentVSM(gl_FragCoord.z);\n#else\noutFragColor=CalcMomentEVSM(gl_FragCoord.z);\n#endif\n}",o,n);case e.PMaterialType.skyboxFilter:return J.build("precision highp float;\n#define FEATURES\n#if !defined(WEBGL2) && defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#if !defined(WEBGL2)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#include <webglCompatibility.glsl>\n#include <extensions.frag.glsl>\n#ifdef WEBGL2\nout vec4 outFragColor;\n#else\n#define outFragColor gl_FragColor\n#endif\nuniform sampler2D u_brdfLUT;uniform vec2 u_IblIntensity;uniform int u_MipCount;uniform samplerCube u_DiffuseEnvSampler;uniform samplerCube u_SpecularEnvSampler;fsIn vec3 v_CameraDir;\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients u_shCoefficients;vec3 getIrradiance(vec3 norm,SHCoefficients c){float x=norm.x;float y=norm.y;float z=norm.z;float c1=0.429043;float c2=0.511664;float c3=0.743125;float c4=0.886227;float c5=0.247708;vec3 irradiance=c1*c.l22*(x*x-y*y)+c3*c.l20*(z*z)+c4*c.l00-c5*c.l20+2.0*c1*(c.l2m2*x*y+c.l21*x*z+c.l2m1*y*z)+2.0*c2*(c.l11*x+c.l1m1*y+c.l10*z);return irradiance;}\n#endif\nvec3 getIBLContribution(vec3 n,vec3 v){const float metallic=0.9;const float perceptualRoughness=0.1;const vec4 baseColor=vec4(1.0);const vec3 f0=vec3(0.04);const vec3 diffuseColor=baseColor.rgb*(vec3(1.0)-f0)*(1.0-metallic);const vec3 specularColor=mix(f0,baseColor.rgb,metallic);float NdotV=clamp(dot(n,v),0.0,1.0);float lod=clamp(perceptualRoughness*float(u_MipCount),0.0,float(u_MipCount));vec3 reflection=normalize(reflect(-v,n));vec2 brdfSamplePoint=clamp(vec2(NdotV,perceptualRoughness),vec2(0.0,0.0),vec2(1.0,1.0));vec2 brdf=texture2D(u_brdfLUT,brdfSamplePoint).rg;vec4 diffuseSample=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,u_shCoefficients);diffuseSample=vec4(irradiance,1.0);\n#else\ndiffuseSample=textureCube(u_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(u_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(u_SpecularEnvSampler,reflection,lod);\n#endif\nvec3 diffuseLight=diffuseSample.rgb;vec3 specularLight=specularSample.rgb;vec3 diffuse=diffuseLight*diffuseColor;vec3 specular=specularLight*(specularColor*brdf.x+brdf.y);return diffuse*u_IblIntensity[0]+specular*u_IblIntensity[1];}void main(){vec3 dir=normalize(v_CameraDir);outFragColor=vec4(getIBLContribution(dir,dir),1.0);}",o,n);default:throw new Error("Invalid material type ".concat(i," for getFragmentShaderString!"))}},t.environment="webgl1",t}();function de(e){return{vertexShaderCode:he.getVertexShaderCode(e),fragmentShaderCode:he.getFragmentShaderCode(e)}}function pe(e){return{vertexShaderCode:he.getVertexShaderCode(e),fragmentShaderCode:he.getFragmentShaderCode(e)}}function me(e){return{vertexShaderCode:he.getVertexShaderCode(e),fragmentShaderCode:he.getFragmentShaderCode(e)}}function ge(e){return{vertexShaderCode:_e({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 ve(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform sampler2D u_FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n gl_FragColor = texture2D(u_FilterSampler, v_UVCoord1) * vec4(0.5);\n }\n "}}function ye(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform vec2 u_BlurScale;\n uniform sampler2D u_FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0);\n vec2 offset0 = vec2(0.53805) * u_BlurScale.xy;\n vec2 offset1 = vec2(2.06278) * u_BlurScale.xy;\n color += (texture2D(u_FilterSampler, v_UVCoord1 + offset0) + texture2D(u_FilterSampler, v_UVCoord1 - offset0)) * 0.44908;\n color += (texture2D(u_FilterSampler, v_UVCoord1 + offset1) + texture2D(u_FilterSampler, v_UVCoord1 - offset1)) * 0.05092;\n gl_FragColor = color;\n }\n "}}function _e(e){void 0===e&&(e={});var t=["#version 100"];return e.hasUVs&&t.push("#define HAS_UVS 1"),e.hasNormals&&t.push("#define HAS_NORMALS 1"),t.push("\n precision highp float;\n\n uniform mat4 u_ModelMatrix;\n uniform mat4 u_ViewProjectionMatrix;\n attribute vec3 a_Position;\n varying vec3 v_Position;\n\n #ifdef HAS_UVS\n attribute vec2 a_UV1;\n varying vec2 v_UVCoord1;\n #endif\n\n #ifdef HAS_NORMALS\n uniform mat4 u_NormalMatrix;\n attribute vec3 a_Normal;\n varying vec3 v_Normal;\n #endif\n\n void main(){\n vec4 pos = u_ModelMatrix * vec4(a_Position, 1);\n v_Position = pos.xyz / pos.w;\n\n #ifdef HAS_UVS\n v_UVCoord1 = a_UV1;\n #endif\n\n #ifdef HAS_NORMALS\n v_Normal = normalize(vec3(u_ModelMatrix * vec4(a_Normal, 0)));\n #endif\n\n gl_Position = u_ViewProjectionMatrix * pos;\n }\n "),t.join("\n")}var be,Te=function(){function t(){this.funcMap=new Map,this.funcMap.set(e.PMaterialType.unlit,de),this.funcMap.set(e.PMaterialType.pbr,de),this.funcMap.set(e.PMaterialType.shadowBase,pe),this.funcMap.set(e.PMaterialType.shadowFilter,ye),this.funcMap.set(e.PMaterialType.normalVis,ge),this.funcMap.set(e.PMaterialType.simpleFilter,ve),this.funcMap.set(e.PMaterialType.skyboxFilter,me)}return t.getInstance=function(){return this._instance||(this._instance=new this)},t.prototype.genShaderCode=function(e){var t=e.material.materialType,n=this.funcMap.get(t);if(void 0!==n)return n(e);throw new Error("Invalid material type ".concat(t,", shader content ").concat(e))},t}(),xe="_Native",Ce=new Map;function Me(e,t){for(var n,o="".concat(e),i=[],r=0;r<t.length;r++)"number"==typeof t[r]&&Ce.has(t[r])?i.push(Ce.get(t[r])+"(".concat(t[r],")")):i.push(null===(n=t[r])||void 0===n?void 0:n.toString());return o+(i.length>0?"("+i.join(", ")+")":"()")}function Se(e,t){return function(){var n=e[t+xe].apply(this,arguments),o=e.getError();return o>0?(console.info("OpenGLError: "+function(e){var t,n=new Map;return n.set(WebGLRenderingContext.NO_ERROR,"NO_ERROR"),n.set(WebGLRenderingContext.INVALID_ENUM,"INVALID_ENUM"),n.set(WebGLRenderingContext.INVALID_VALUE,"INVALID_VALUE"),n.set(WebGLRenderingContext.INVALID_OPERATION,"INVALID_OPERATION"),n.set(WebGLRenderingContext.INVALID_FRAMEBUFFER_OPERATION,"INVALID_FRAMEBUFFER_OPERATION"),n.set(WebGLRenderingContext.OUT_OF_MEMORY,"OUT_OF_MEMORY"),n.set(WebGLRenderingContext.CONTEXT_LOST_WEBGL,"CONTEXT_LOST_WEBGL"),(null!==(t=n.get(e))&&void 0!==t?t:"UNKNOWN_ERROR")+"(".concat(e,")")}(o)+" ===> "+Me(t,arguments)),console.trace()):console.info(Me(t,arguments)),n}}e.ModelDataType=void 0,(be=e.ModelDataType||(e.ModelDataType={}))[be.MeshComponent=1e4]="MeshComponent",be[be.SkyboxComponent=10001]="SkyboxComponent",be[be.LightComponent=10002]="LightComponent",be[be.CameraComponent=10003]="CameraComponent",be[be.ModelPluginComponent=10004]="ModelPluginComponent",be[be.TreeComponent=10005]="TreeComponent";var Ae=function(o){function r(e,n){var i=o.call(this,e)||this;return i.getHitTestParams=function(e){i.computeBoundingBox();var n=i.bounding;if(n&&(e||Number.isInteger(n.behavior))){var o=n.type;if(o===t.spec.ModelBoundingType.box){if(i.content instanceof re){var r=i.content;return{behavior:n.behavior,type:t.HitTestType.custom,collect:function(e,t){return r.hitTesting(e.origin,e.direction)}}}var a=i.transform.getWorldMatrix();return{behavior:n.behavior,type:t.HitTestType.custom,collect:function(e,t){return we(e,a,n)}}}if(o===t.spec.ModelBoundingType.sphere){var s=new h;i.transform.assignWorldTRS(s);var c=new h;return n.center&&c.setFromArray(n.center),c.add(s),{type:o,behavior:n.behavior,radius:n.radius||0,center:c}}}},n&&i.fromData(n),i}return i(r,o),r.prototype.start=function(){var e;this.createContent(),this.item.type=n,this.priority=this.item.listIndex,this.sceneManager=st(this),null===(e=this.sceneManager)||void 0===e||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},r.prototype.update=function(e){this.sceneManager&&this.content.build(this.sceneManager),this.content.update()},r.prototype.render=function(e){this.getVisible()&&this.sceneManager&&this.content.render(this.sceneManager,e)},r.prototype.onDestroy=function(){var e;null===(e=this.sceneManager)||void 0===e||e.removeItem(this.content),this.sceneManager=void 0,this.content.dispose()},r.prototype.fromData=function(e){o.prototype.fromData.call(this,e),this.options=e},r.prototype.createContent=function(){if(this.options){var e=this.options.interaction;this.bounding=e&&JSON.parse(JSON.stringify(e));var t=this.options.options;Je.assertModelMeshOptions(t),this.content=new re(this.engine,this.item.name,this.options,this,this.item.parentId)}},r.prototype.setVisible=function(e){var t;null===(t=this.content)||void 0===t||t.onVisibleChanged(e)},r.prototype.getVisible=function(){var e,t;return null!==(t=null===(e=this.content)||void 0===e?void 0:e.visible)&&void 0!==t&&t},r.prototype.computeBoundingBox=function(){var e;if(this.content&&this.content instanceof re){var n=this.transform.getWorldMatrix(),o=this.content.computeBoundingBox(n),i=o.getCenter(new h),r=o.getSize(new h);return this.bounding={behavior:null===(e=this.bounding)||void 0===e?void 0:e.behavior,type:t.spec.ModelBoundingType.box,center:[i.x,i.y,i.z],size:[r.x,r.y,r.z]},this.bounding}},r=a([t.effectsClass(e.ModelDataType.MeshComponent)],r)}(t.RendererComponent),Ie=function(o){function r(e,t){var n=o.call(this,e)||this;return t&&n.fromData(t),n}return i(r,o),r.prototype.start=function(){var e;this.createContent(),this.item.type=n,this.priority=this.item.listIndex,this.sceneManager=st(this),null===(e=this.sceneManager)||void 0===e||e.addItem(this.content),this.setVisible(!0)},r.prototype.render=function(e){this.getVisible()&&this.sceneManager&&this.content.render(this.sceneManager,e)},r.prototype.onDestroy=function(){var e;null===(e=this.sceneManager)||void 0===e||e.removeItem(this.content),this.sceneManager=void 0,this.content.dispose()},r.prototype.fromData=function(e){o.prototype.fromData.call(this,e),this.options=e},r.prototype.createContent=function(){if(this.options){var e=this.options.options;Je.assertModelSkyboxOptions(e),this.content=new tt(this.item.name,e,this)}},r.prototype.setVisible=function(e){var t;null===(t=this.content)||void 0===t||t.onVisibleChanged(e)},r.prototype.getVisible=function(){var e,t;return null!==(t=null===(e=this.content)||void 0===e?void 0:e.visible)&&void 0!==t&&t},r=a([t.effectsClass(e.ModelDataType.SkyboxComponent)],r)}(t.RendererComponent),Ee=function(o){function r(e,t){var n=o.call(this,e)||this;return t&&n.fromData(t),n}return i(r,o),r.prototype.start=function(){this.createContent(),this.item.type=n;var e=st(this);null==e||e.addItem(this.content),this.setVisible(!0)},r.prototype.update=function(e){this.content.update()},r.prototype.onDestroy=function(){this.content.dispose()},r.prototype.fromData=function(e){o.prototype.fromData.call(this,e),this.options=e},r.prototype.createContent=function(){if(this.options){var e=this.options.options;Je.assertModelLightOptions(e),this.content=new te(this.item.name,e,this)}},r.prototype.setVisible=function(e){var t;null===(t=this.content)||void 0===t||t.onVisibleChanged(e)},r.prototype.getVisible=function(){var e,t;return null!==(t=null===(e=this.content)||void 0===e?void 0:e.visible)&&void 0!==t&&t},r=a([t.effectsClass(e.ModelDataType.LightComponent)],r)}(t.ItemBehaviour),Pe=function(o){function r(e,t){var n=o.call(this,e)||this;return t&&n.fromData(t),n}return i(r,o),r.prototype.start=function(){this.createContent(),this.item.type=n,this.timeline=this.item.getComponent(t.TimelineComponent);var e=st(this);null==e||e.addItem(this.content)},r.prototype.update=function(e){this.content.update(),this.updateMainCamera()},r.prototype.onDestroy=function(){this.content.dispose()},r.prototype.fromData=function(e){o.prototype.fromData.call(this,e),this.options=e},r.prototype.createContent=function(){if(this.options){var e=this.options.options;Je.assertModelCameraOptions(e);var t=this.engine.renderer.getWidth(),n=this.engine.renderer.getHeight();this.content=new $(this.item.name,t,n,e,this)}},r.prototype.updateMainCamera=function(){this.content.matrix=this.transform.getWorldMatrix();var e=this.item.composition;e&&(e.camera.position=this.transform.position.clone(),e.camera.setQuat(this.transform.quat),e.camera.near=this.content.nearPlane,e.camera.far=this.content.farPlane,e.camera.fov=this.content.fovy)},r.prototype.setTransform=function(e,t){var n,o,i=null===(o=null===(n=this.timeline)||void 0===n?void 0:n.findTrack("AnimationTrack"))||void 0===o?void 0:o.findClip("AnimationTimelineClip");void 0!==e&&(this.transform.setPosition(e.x,e.y,e.z),i&&(i.playable.originalTransform.position=e.clone())),void 0!==t&&(this.transform.setRotation(t.x,t.y,t.z),i&&(i.playable.originalTransform.rotation=t.clone())),this.updateMainCamera()},r=a([t.effectsClass(e.ModelDataType.CameraComponent)],r)}(t.ItemBehaviour);function we(e,t,n){var o=t,i=o.clone().invert(),r=e.clone().applyMatrix(i),a=h.fromArray(n.center),s=h.fromArray(n.size).multiply(.5),c=a.clone().subtract(s),l=a.clone().add(s),u=r.intersectBox({min:c,max:l},new h);return void 0!==u?[o.transformPoint(u)]:void 0}function Oe(e,t,n,o){var i=0,r=0,a=0,s=0,c=0,l=0,u=1/t.x,f=1/t.y,h=1/t.z;if(u>=0?(i=(n.x-e.x)*u,r=(o.x-e.x)*u):(i=(o.x-e.x)*u,r=(n.x-e.x)*u),f>=0?(a=(n.y-e.y)*f,s=(o.y-e.y)*f):(a=(o.y-e.y)*f,s=(n.y-e.y)*f),!(i>s||a>r||((a>i||i!=i)&&(i=a),(s<r||r!=r)&&(r=s),h>=0?(c=(n.z-e.z)*h,l=(o.z-e.z)*h):(c=(o.z-e.z)*h,l=(n.z-e.z)*h),i>l||c>r||((c>i||i!=i)&&(i=c),(l<r||r!=r)&&(r=l),r<0))))return i>=0?i:r}var Ne=new h,Le=new h,Re=new h,Fe=new h;function Ue(e,t,n,o,i,r){Le.subtractVectors(o,n),Re.subtractVectors(i,n),Fe.crossVectors(Le,Re);var a=t.dot(Fe),s=0;if(a>0){if(r)return;s=1}else{if(!(a<0))return;s=-1,a=-a}Ne.subtractVectors(e,n),Re.crossVectors(Ne,Re);var c=s*t.dot(Re);if(!(c<0)){Le.crossVectors(Le,Ne);var l=s*t.dot(Le);if(!(l<0||c+l>a)){var u=-s*Ne.dot(Fe);if(!(u<0))return u/a}}}var De,Be,ke=function(){function e(){}return e.createTexture2D=function(n,o,i,r,a){return s(this,void 0,void 0,(function(){var s,l,u,f;return c(this,(function(c){return void 0===o.imageData?(console.error("createTexture2D: Invalid image data from ".concat(o)),[2,t.Texture.create(n,{name:"createTexture2D",sourceType:t.TextureSourceType.data,data:{data:new Uint8Array([255,255,255,255]),width:1,height:1}})]):(s=new Blob([o.imageData],{type:o.mimeType}),l=window.URL||window.webkitURL,u=l.createObjectURL(s),(f=new Image).src=u,[2,new Promise((function(o,s){f.onload=function(){var s,c,h,d,p=null!==(s=i.minFilter)&&void 0!==s?s:t.glContext.LINEAR_MIPMAP_LINEAR,m=!1;a&&(p=t.glContext.LINEAR_MIPMAP_LINEAR,e.isPow2(f.width)&&e.isPow2(f.height)||(p=t.glContext.LINEAR),m=!r);var g=!1;p!=t.glContext.NEAREST_MIPMAP_NEAREST&&p!=t.glContext.LINEAR_MIPMAP_NEAREST&&p!=t.glContext.NEAREST_MIPMAP_LINEAR&&p!=t.glContext.LINEAR_MIPMAP_LINEAR||(g=!0);var v=t.Texture.create(n,{name:"createTexture2D",wrapS:null!==(c=i.wrapS)&&void 0!==c?c:t.glContext.REPEAT,wrapT:null!==(h=i.wrapT)&&void 0!==h?h:t.glContext.REPEAT,magFilter:null!==(d=i.magFilter)&&void 0!==d?d:t.glContext.LINEAR,minFilter:p,anisotropic:1,premultiplyAlpha:m,sourceType:t.TextureSourceType.image,image:f,generateMipmap:g});o(v),l.revokeObjectURL(u)},f.onerror=s}))])}))}))},e.createTextureList=function(e,t,n){return s(this,void 0,void 0,(function(){var o=this;return c(this,(function(i){switch(i.label){case 0:return[4,Promise.all(n.map((function(n){return o.createTexture2D(e,t[n.source],n)})))];case 1:return[2,i.sent()]}}))}))},e.getTextureCubeData=function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return[4,je.loadImageFromImageData(e[0])];case 1:return t=[n.sent()],[4,je.loadImageFromImageData(e[1])];case 2:return t=t.concat([n.sent()]),[4,je.loadImageFromImageData(e[2])];case 3:return t=t.concat([n.sent()]),[4,je.loadImageFromImageData(e[3])];case 4:return t=t.concat([n.sent()]),[4,je.loadImageFromImageData(e[4])];case 5:return t=t.concat([n.sent()]),[4,je.loadImageFromImageData(e[5])];case 6:return[2,t.concat([n.sent()])]}}))}))},e.getTextureCubeMipmapData=function(e){return s(this,void 0,void 0,(function(){var t,n,o,i;return c(this,(function(r){switch(r.label){case 0:t=[],n=0,r.label=1;case 1:return n<e.length?(i=(o=t).push,[4,this.getTextureCubeData(e[n])]):[3,4];case 2:i.apply(o,[r.sent()]),r.label=3;case 3:return n++,[3,1];case 4:return[2,t]}}))}))},e.createTextureCubeFromURL=function(e,n){return s(this,void 0,void 0,(function(){var o;return c(this,(function(i){switch(i.label){case 0:return[4,t.getDefaultTextureFactory().loadSource({type:t.TextureSourceType.image,target:t.glContext.TEXTURE_CUBE_MAP,map:n},this.cubemapTexConfig)];case 1:return o=i.sent(),[2,t.Texture.create(e,o)]}}))}))},e.createTextureCubeMipmapFromURL=function(e,n){return s(this,void 0,void 0,(function(){var o;return c(this,(function(i){switch(i.label){case 0:return[4,t.getDefaultTextureFactory().loadSource({type:t.TextureSourceType.mipmaps,target:t.glContext.TEXTURE_CUBE_MAP,maps:n},this.cubemapMipTexConfig)];case 1:return o=i.sent(),[2,t.Texture.create(e,o)]}}))}))},e.createTextureCubeFromBuffer=function(n,o){return s(this,void 0,void 0,(function(){var i;return c(this,(function(a){switch(a.label){case 0:return[4,e.getTextureCubeData(o)];case 1:return i=a.sent(),[2,t.Texture.create(n,r({name:"createTextureCubeFromBuffer",sourceType:t.TextureSourceType.image,cube:i,target:t.glContext.TEXTURE_CUBE_MAP},this.cubemapTexConfig))]}}))}))},e.createTextureCubeMipmapFromBuffer=function(n,o,i){return s(this,void 0,void 0,(function(){var a,s,l,u,f;return c(this,(function(c){switch(c.label){case 0:return[4,e.getTextureCubeMipmapData(o)];case 1:for(a=c.sent(),s=0;Math.pow(2,s)<i;)++s;c.label=2;case 2:return a.length<=s?(l=Math.pow(2,s-a.length),u="https://gw.alipayobjects.com/zos/gltf-asset/67896749597915/img".concat(l,".png"),[4,t.loadImage(u)]):[3,4];case 3:return f=c.sent(),a.push([f,f,f,f,f,f]),[3,2];case 4:return[2,t.Texture.create(n,r({name:"createTextureCubeMipmapFromBuffer",sourceType:t.TextureSourceType.mipmaps,mipmaps:a,target:t.glContext.TEXTURE_CUBE_MAP},this.cubemapMipTexConfig))]}}))}))},e.getTexture=function(e,t){return e<0||e>=t.length?void 0:t[e]},e.createTextureFromImage=function(e,n){var o={name:"createTextureFromImage",image:n,sourceType:t.TextureSourceType.image,flipY:!1,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR,wrapT:t.glContext.REPEAT,wrapS:t.glContext.REPEAT};return t.Texture.create(e,o)},e.createRenderPass=function(e,n,o,i,r){var a=i instanceof t.Mesh?[i]:i;return new t.RenderPass(e,{name:n,priority:o,attachments:r.colorAttachments,depthStencilAttachment:r.depthAttachment,clearAction:{clearDepth:1,clearStencil:0,clearColor:[0,0,0,0],colorAction:t.TextureLoadAction.clear,depthAction:t.TextureLoadAction.clear},meshes:a,viewport:r.viewport})},e.deleteTexture=function(e){e.dispose()},e.deleteMesh=function(e){e.dispose({geometries:t.DestroyOptions.destroy,material:{textures:t.DestroyOptions.destroy}})},e.deleteGeometry=function(e){e.dispose()},e.deleteRenderPass=function(e){e.dispose({meshes:{geometries:t.DestroyOptions.destroy,material:{textures:t.DestroyOptions.destroy}},depthStencilAttachment:t.RenderPassDestroyAttachmentType.force,colorAttachment:t.RenderPassDestroyAttachmentType.force,semantics:t.DestroyOptions.destroy})},e.isTransparentMesh=function(e){return!0===e.material.blending},e.isSupportFloatTexture=function(e){return 0!==e.gpuCapability.detail.floatTexture},e.isSupportHalfFloatTexture=function(e){return 0!==e.gpuCapability.detail.halfFloatTexture},e.isPow2=function(e){return!(e&e-1||!e)},e.cubemapTexConfig={name:"cubemap texture",wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR},e.cubemapMipTexConfig={wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR_MIPMAP_LINEAR},e}(),Ve=function(){function e(){}return e.createFilterMesh=function(n,o,i,r){var a=w.getInstance(),s=i.vertexShaderCode,c=i.fragmentShaderCode,l=t.Geometry.create(n,e.getPlaneGeometry()),u=t.Material.create(n,{shader:{vertex:s,fragment:c,shared:a.shaderShared},uniformSemantics:r});return i.setMaterialStates(u),t.Mesh.create(n,{name:o,worldMatrix:m.fromIdentity(),material:u,geometry:l})},e.getPlaneGeometry=function(){var n=e.getPlaneVertexArray();return{attributes:{a_Position:{type:t.glContext.FLOAT,size:3,data:n,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:0},a_UV1:{type:t.glContext.FLOAT,size:2,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:3*Float32Array.BYTES_PER_ELEMENT,dataSource:"a_Position"},a_Normal:{type:t.glContext.FLOAT,size:3,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:5*Float32Array.BYTES_PER_ELEMENT,dataSource:"a_Position"}},drawStart:0,drawCount:n.length/8}},e.getPlaneVertexArray=function(){return new Float32Array([-1,-1,0,0,0,0,0,1,1,-1,0,1,0,0,0,1,1,1,0,1,1,0,0,1,-1,-1,0,0,0,0,0,1,1,1,0,1,1,0,0,1,-1,1,0,0,1,0,0,1])},e}(),Ge=function(){function e(){}return e.createLightOptions=function(e){var t,n,o,i,r,a,s,c,l=null!==(t=e.color)&&void 0!==t?t:[255,255,255,255];return"point"===e.type?{color:l,intensity:null!==(n=e.intensity)&&void 0!==n?n:1,lightType:"point",range:null!==(o=e.range)&&void 0!==o?o:0}:"spot"===e.type?{color:l,intensity:null!==(i=e.intensity)&&void 0!==i?i:1,lightType:"spot",range:null!==(r=e.range)&&void 0!==r?r:0,innerConeAngle:null!==(a=e.innerConeAngle)&&void 0!==a?a:0,outerConeAngle:null!==(s=e.outerConeAngle)&&void 0!==s?s:Math.PI/4}:{color:l,intensity:null!==(c=e.intensity)&&void 0!==c?c:1,lightType:"directional"}},e.createCameraOptions=function(e){if(void 0!==e.perspective){var t=e.perspective;t.znear,t.zfar,t.yfov}},e.toPlayerColor3=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2])]},e.toPlayerColor4=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2]),this.scaleTo255(e[3])]},e.toPluginColor3=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2])]},e.toPluginColor4=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2]),this.scaleTo1(e[3])]},e.createUVTransform=function(e){if(void 0!==e&&(void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale)){var t=p.fromIdentity(),n=new p;if(void 0!==e.offset&&(n.setFromArray([1,0,0,0,1,0,e.offset[0],e.offset[1],1]),t.multiply(n)),void 0!==e.rotation){var o=Math.cos(e.rotation),i=Math.sin(e.rotation);n.setFromArray([o,i,0,-i,o,0,0,0,1]),t.multiply(n)}return void 0!==e.scale&&(n.setFromArray([e.scale[0],0,0,0,e.scale[1],0,0,0,1]),t.multiply(n)),t.transpose(),t}},e.clamp=function(e,t,n){return Math.max(Math.min(e,n),t)},e.scaleTo255=function(e){var t=Math.round(255*e);return Math.max(0,Math.min(t,255))},e.scaleTo1=function(e){var t=e/255;return Math.max(0,Math.min(t,1))},e.focusOnPoint=function(e,n,o){var i=h.fromArray(e),r=h.fromArray(o),a=(new h).copyFrom(i).subtract(r);m.fromRotationAxis(new h(0,1,0),n*I).transformPoint(a);var s=a.clone().add(r),c=(new m).lookAt(s,r,new h(0,1,0)).invert(),l=new t.Transform;return l.setValid(!0),l.cloneFromMatrix(c),l},e.preprocessScene=function(e,n,o,i){var r=this,a=n!==t.PLAYER_OPTIONS_ENV_EDITOR,s="tiny3d"===o,c=e.jsonScene;if(void 0===c||void 0===c.compositions)return{};var l=!1;if(a){var u=e.textureOptions;c.compositions.forEach((function(e){e.items.forEach((function(e){if("mesh"===e.type)e.content.options.primitives.forEach((function(e){var n=e.material;n.type===t.spec.MaterialType.pbr?(void 0!==n.baseColorTexture&&r.preprocessTextureOptions(n.baseColorTexture,u,!0,s),void 0!==n.metallicRoughnessTexture&&r.preprocessTextureOptions(n.metallicRoughnessTexture,u,!1,s),void 0!==n.normalTexture&&r.preprocessTextureOptions(n.normalTexture,u,!1,s),void 0!==n.occlusionTexture&&r.preprocessTextureOptions(n.occlusionTexture,u,!1,s),void 0!==n.emissiveTexture&&r.preprocessTextureOptions(n.emissiveTexture,u,!1,s)):void 0!==n.baseColorTexture&&r.preprocessTextureOptions(n.baseColorTexture,u,!0,s)}));else if("skybox"===e.type){l=!0;var n=e.content.options;r.preprocessTextureOptions(n.specularImage,u,!1,s),void 0!==n.diffuseImage&&r.preprocessTextureOptions(n.diffuseImage,u,!1,s)}}))}))}else c.compositions.forEach((function(e){e.items.forEach((function(e){"skybox"===e.type&&(l=!0)}))}));return i&&c.compositions.forEach((function(e){var n=0;e.items.forEach((function(e){"light"!==e.type&&"skybox"!==e.type||++n})),0==n&&(e.items.push({id:"dir-light1",duration:100,name:"dir-light1",type:t.spec.ItemType.light,transform:{rotation:[45,-45,0]},pluginName:"model",endBehavior:0,content:{options:{lightType:"directional",color:[255,255,255,255],intensity:1.5}}}),e.items.push({id:"dir-light2",duration:100,name:"dir-light2",type:t.spec.ItemType.light,transform:{rotation:[0,90,0]},pluginName:"model",endBehavior:0,content:{options:{lightType:"directional",color:[255,255,255,255],intensity:.2}}}))})),{loadSkybox:l}},e.preprocessTextureOptions=function(e,n,o,i){if(!(e<0||e>=n.length)){var r=n[e];i&&void 0!==r&&(void 0===r.target||r.target===t.glContext.TEXTURE_2D?(r.wrapS=t.glContext.REPEAT,r.wrapT=t.glContext.REPEAT,r.magFilter=t.glContext.LINEAR,r.minFilter=t.glContext.LINEAR_MIPMAP_LINEAR,r.generateMipmap=!0,o||(r.premultiplyAlpha=!0)):r.target===t.glContext.TEXTURE_CUBE_MAP&&(r.wrapS=t.glContext.CLAMP_TO_EDGE,r.wrapT=t.glContext.CLAMP_TO_EDGE,void 0!==r.mipmaps?(r.magFilter=t.glContext.LINEAR,r.minFilter=t.glContext.LINEAR_MIPMAP_LINEAR):(r.magFilter=t.glContext.LINEAR,r.minFilter=t.glContext.LINEAR)))}},e.setupItem3DOptions=function(e,n,o){var i=this;if(!(void 0===e||e.bins.length<=0)){var r=e.jsonScene,a=new Set;void 0===r.compositionId&&a.add(0),r.compositions.forEach((function(e,t){(e.id===r.compositionId||o.refCompositionProps.has(e.id))&&a.add(t)})),a.forEach((function(a){r.compositions[a].items.forEach((function(r){var s=r.id,c=o.getEngine().jsonSceneData[s];if("mesh"===c.type){var l=c,u=l.content.options.skin;if(l.content.options.primitives.forEach((function(r,c){if(!(r.geometry instanceof t.Geometry)){var l="Geom_C".concat(a,"_I").concat(s,"_P").concat(c),u=n.getOrCreateGeometry(l,r.geometry,e.bins),f=r;f.geometry=u;var h,d=r.material;if(d.type===t.spec.MaterialType.pbr)(h=f.material).baseColorTexture=i.getTextureObj(o.textures,d.baseColorTexture),h.metallicRoughnessTexture=i.getTextureObj(o.textures,d.metallicRoughnessTexture),h.normalTexture=i.getTextureObj(o.textures,d.normalTexture),h.occlusionTexture=i.getTextureObj(o.textures,d.occlusionTexture),h.emissiveTexture=i.getTextureObj(o.textures,d.emissiveTexture);else(h=f.material).baseColorTexture=i.getTextureObj(o.textures,d.baseColorTexture)}})),void 0!==u&&void 0!==u.inverseBindMatrices){var f=u,h=F(e.bins,u.inverseBindMatrices);h instanceof Float32Array?f.inverseBindMatrices=h:console.error("setupItem3DOptions: Invalid inverseBindMatrices type, ".concat(h))}}else if("tree"===c.type){var d=c,p=c.content.options.tree.animations,m=d.content.options.tree.animations;void 0!==p&&void 0!==m&&p.forEach((function(t,n){var o=m[n];t.tracks.forEach((function(t,n){var i=F(e.bins,t.input),r=F(e.bins,t.output),a=o.tracks[n];i instanceof Float32Array?a.input=i:console.error("setupItem3DOptions: Type of inputArray should be float32, ".concat(i)),r instanceof Float32Array?a.output=r:console.error("setupItem3DOptions: Type of outputArray should be float32, ".concat(r))}))}))}else if("skybox"===c.type){var g=c,v=c.content.options,y=g.content.options,_=i.getTextureObj(o.textures,v.specularImage);void 0===_&&console.error("setupItem3DOptions: skybox specualrImage is undefined, ".concat(Je.stringify(v))),y.specularImage=_;var b=i.getTextureObj(o.textures,v.diffuseImage);void 0!==b&&(y.diffuseImage=b)}}))}))}},e.createGeometry=function(e,n,o){var i=function(e,t){var n,o,i=e.attributes,a=r({},e);return a.indices?(a.indices=r({},a.indices),a.indices.data&&(a.indices.data=F(t,null===(n=e.indices)||void 0===n?void 0:n.data))):a.index&&(a.indices=r({},a.index),a.indices.data&&(a.indices.data=F(t,null===(o=e.index)||void 0===o?void 0:o.data))),Object.keys(i).forEach((function(e){var n=i[e],o=n.data;a.attributes[e]=r({},n),o&&(a.attributes[e].data=F(t,o))})),a}(n,o),a={};for(var s in i.attributes){var c=i.attributes[s];a[this.getAttributeName(s)]=c}return i.attributes=a,t.Geometry.create(e,i)},e.getIndexArray=function(e,t){switch(e){case WebGLRenderingContext.UNSIGNED_INT:case WebGLRenderingContext.UNSIGNED_SHORT:case WebGLRenderingContext.UNSIGNED_BYTE:return t;default:console.error("Invalid index attribute type ".concat(e))}},e.getAttributeName=function(e){switch(e){case"POSITION":return"a_Position";case"NORMAL":return"a_Normal";case"TANGENT":return"a_Tangent";case"TEXCOORD_0":return"a_UV1";case"TEXCOORD_1":return"a_UV2";case"JOINTS_0":return"a_Joint1";case"WEIGHTS_0":return"a_Weight1"}return e.startsWith("a_")||console.warn("Unknown attribute name: ".concat(e)),e},e.getTextureObj=function(e,t){return"number"!=typeof t?t:((t<0||t>=e.length)&&console.error("Invalid index for textures: ".concat(t,", ").concat(e.length)),e[t])},e}(),je=function(){function e(){}return e.getImageFileName=function(e,t){var n=e.lastIndexOf("/"),o=e.lastIndexOf("."),i=e.substring(n+1,o);return t?i+t:i},e.getCurrnetTimeStr=function(){var e=new Date(Date.now()),t=e.toLocaleString("zh-CN"),n="".concat(e.getMilliseconds());return t.split(/[ /:]+/).join("")+n.padStart(3,"0")},e.saveFileForURL=function(e,t){var n=document.createElement("a");n.setAttribute("download",t),n.target="_blank",n.href=e,n.click()},e.createPlayer=function(e){void 0===e&&(e=!0);var n=document.createElement("canvas");return n.width=512,n.height=512,new t.Player({canvas:n,renderFramework:"webgl2",env:t.PLAYER_OPTIONS_ENV_EDITOR,willCaptureImage:!0,manualRender:e})},e.sleep=function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,e)}))]}))}))},e.loadImageFromGLTFImage=function(e){return s(this,void 0,void 0,(function(){return c(this,(function(n){return[2,t.loadImage(new Blob([e.imageData],{type:e.mimeType}))]}))}))},e.loadImageFromImageData=function(e){return s(this,void 0,void 0,(function(){return c(this,(function(n){return[2,t.loadImage(new Blob([e.data],{type:e.mimeType}))]}))}))},e.getCanvasArrayBuffer=function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,new Promise((function(t,n){e.toBlob((function(e){e?t(e.arrayBuffer()):n(Error("no canvas blob"))}),"image/png",1)}))]}))}))},e.getImageArrayBuffer=function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(n){return(t=document.createElement("canvas")).width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0),[2,this.getCanvasArrayBuffer(t)]}))}))},e.getCanvasImageData=function(e){return e.getContext("2d").getImageData(0,0,e.width,e.height)},e.flipImageData=function(e){var t=document.createElement("canvas"),n=t.getContext("2d");return t.width=e.width,t.height=e.height,n.putImageData(e,0,0),n.globalCompositeOperation="copy",n.scale(1,-1),n.translate(0,-e.height),n.drawImage(t,0,0),n.setTransform(1,0,0,1,0,0),n.globalCompositeOperation="source-over",n.getImageData(0,0,t.width,t.height)},e.getImageData=function(e){var t=document.createElement("canvas");t.width=e.width,t.height=e.height;var n=t.getContext("2d");return n.drawImage(e,0,0),this.flipImageData(n.getImageData(0,0,t.width,t.height))},e.getWebGLCanvasImageBuffer=function(e){var t=e.getContext("webgl2"),n=new Uint8Array(e.width*e.height*4);return t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,n),n},e}(),ze=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 h;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}(),He=function(){function e(){this.length=0,this.offset=0,this.stride=0,this.typeSize=0,this.compCount=0,this.signed=!1,this.compressed=!1,this.compressScale=1}return e.prototype.create=function(e,t){var n,o;switch(e.type){case WebGLRenderingContext.INT:this.typeSize=4,this.signed=!0,this.compressScale=1/2147483647;break;case WebGLRenderingContext.SHORT:this.typeSize=2,this.signed=!0,this.compressScale=1/32767;break;default:this.typeSize=4,this.signed=!0,this.compressScale=1}this.data=t,this.length=this.data.length,this.compCount=e.size,this.offset=null!==(n=e.offset)&&void 0!==n?n:0,this.offset>0&&(this.offset%this.typeSize!=0&&console.error("Invalid offset ".concat(this.offset,", type size ").concat(this.typeSize)),this.offset=this.offset/this.typeSize),this.stride=null!==(o=e.stride)&&void 0!==o?o:0,this.stride>0?(this.stride%this.typeSize!=0&&console.error("Invalid stride ".concat(this.stride,", type size ").concat(this.typeSize)),this.stride=this.stride/this.typeSize):this.stride=this.compCount,this.compressed=!0===e.normalize},e.prototype.getData=function(e){var t=this.offset;if(!((t+=e*this.stride)+this.compCount>this.length)){var n;if(n=2===this.compCount?[this.data[t],this.data[t+1],0,0]:3===this.compCount?[this.data[t],this.data[t+1],this.data[t+2],0]:[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]],this.compressed)for(var o=0;o<this.compCount;o++)n[o]*=this.compressScale,this.signed&&(n[o]=Math.max(n[o],-1));return n}},e.prototype.getLength=function(){return Math.round((this.length-this.offset)/this.stride)},e}(),We=function(){function e(){this.drawStart=0,this.drawCount=0,this.bindMatrices=[]}return e.prototype.create=function(e,t){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var n=e.attributes;this.index=e.getIndexData();var o=n.a_Position,i=e.getAttributeData("a_Position");this.position=new He,this.position.create(o,i);var r=n.a_Joint1,a=n.a_Weight1;if(void 0!==r&&void 0!==a){var s=e.getAttributeData("a_Joint1"),c=e.getAttributeData("a_Weight1");this.joint=new He,this.joint.create(r,s),this.weight=new He,this.weight.create(a,c)}this.bindMatrices=t},e.prototype.getBoundingBox=function(e){var t=this;e.makeEmpty();var n=new m,o=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0,i=new Set;if(void 0!==this.index)for(var r=0;r<this.drawCount;r++){var a=this.drawStart+r;a<this.index.length&&i.add(this.index[a])}else for(r=0;r<this.drawCount;r++)i.add(this.drawStart+r);return i.forEach((function(i){var r,a,s=t.position.getData(i);if(void 0!==s){var c=h.fromArray(s);if(o){var l=null===(r=t.joint)||void 0===r?void 0:r.getData(i),u=null===(a=t.weight)||void 0===a?void 0:a.getData(i);if(void 0!==l&&void 0!==u){n.setZero();for(var f=!1,p=0;p<4;p++)if(0!==u[p]){if(l[p]<0||l[p]>=t.bindMatrices.length){f=!0;break}var m=t.bindMatrices[l[p]];n.addScaledMatrix(m,u[p])}if(!f){var g=n.transformVector4(new d(c.x,c.y,c.z,1));Math.abs(g.w)>1e-4&&(g.multiply(1/g.w),c.set(g.x,g.y,g.z))}}}e.expandByPoint(c)}})),e},e}(),Xe=function(){function e(){this.drawStart=0,this.drawCount=0,this.doubleSided=!1,this.bindMatrices=[],this.hasAnimation=!1,this.skinMatrix=new m}return e.prototype.create=function(e,t,n){this.drawStart=0,this.drawCount=Math.abs(e.getDrawCount());var o=e.attributes;this.index=e.getIndexData();var i=o.a_Position,r=e.getAttributeData("a_Position");this.position=new He,this.position.create(i,r);var a=o.a_Joint1,s=o.a_Weight1;if(void 0!==a&&void 0!==s){var c=e.getAttributeData("a_Joint1"),l=e.getAttributeData("a_Weight1");this.joint=new He,this.joint.create(a,c),this.weight=new He,this.weight.create(s,l)}this.doubleSided=t,this.bindMatrices=n,this.hasAnimation=void 0!==this.joint&&void 0!==this.weight&&this.bindMatrices.length>0},e.prototype.getHitPoint=function(e,t){for(var n,o=new h,i=new h,r=new h,a=new d,s=new d,c=new d,l=!this.doubleSided,u=0;u+2<this.drawCount;u+=3){var f=this.drawStart+u,p=this.drawStart+u+1,m=this.drawStart+u+2;void 0!==this.index&&(f=this.index[f],p=this.index[p],m=this.index[m]);var g=this.getPosition(f,o,a),v=this.getPosition(p,i,s),y=this.getPosition(m,r,c);if(void 0!==g&&void 0!==v&&void 0!==y){var _=Ue(e,t,g,v,y,l);void 0!==_&&(void 0===n||n>_)&&(n=_)}}return n},e.prototype.getPosition=function(e,t,n){var o,i,r=this.position.getData(e);if(void 0!==r){if(this.hasAnimation){var a=null===(o=this.joint)||void 0===o?void 0:o.getData(e),s=null===(i=this.weight)||void 0===i?void 0:i.getData(e);if(void 0!==a&&void 0!==s){var c=this.skinMatrix;c.setZero();for(var l=0;l<4;l++)if(0!==s[l]){var u=this.bindMatrices[a[l]];c.addScaledMatrix(u,s[l])}n.set(r[0],r[1],r[2],1);var f=c.transformVector4(n),h=1/f.w;t.set(f.x*h,f.y*h,f.z*h)}}else t.set(r[0],r[1],r[2]);return t}},e}(),Je=function(){function e(){}return e.checkNumber=function(e){return"number"==typeof e},e.checkNumberUndef=function(e){return void 0===e||this.checkNumber(e)},e.checkNumber01=function(e){return this.checkNumber(e)&&e>=0&&e<=1},e.checkNumber01Undef=function(e){return void 0===e||this.checkNumber01(e)},e.checkPositive=function(e){return this.checkNumber(e)&&e>0},e.checkNonnegative=function(e){return this.checkNumber(e)&&e>=0},e.checkNonnegativeUndef=function(e){return void 0===e||this.checkNonnegative(e)},e.checkBoolean=function(e){return"boolean"==typeof e},e.checkBooleanUndef=function(e){return void 0===e||this.checkBoolean(e)},e.checkString=function(e){return"string"==typeof e},e.checkStringUndef=function(e){return void 0===e||this.checkString(e)},e.checkFloat32Array=function(e){return e instanceof Float32Array},e.checkFloat32ArrayUndef=function(e){return void 0===e||this.checkFloat32Array(e)},e.checkParent=function(e){return void 0===e||!!this.checkNumber(e)&&e>=0},e.checkTexCoord=function(e){return void 0===e||!!this.checkNumber(e)&&(e>=0&&e<=1)},e.checkVec2=function(e){var t=this;return!!Array.isArray(e)&&(2==e.length&&e.every((function(e){return t.checkNumber(e)})))},e.checkVec2Undef=function(e){return void 0===e||this.checkVec2(e)},e.checkVec3=function(e){var t=this;return!!Array.isArray(e)&&(3==e.length&&e.every((function(e){return t.checkNumber(e)})))},e.checkNonnegative3=function(e){var t=this;return!!Array.isArray(e)&&(3==e.length&&e.every((function(e){return t.checkNonnegative(e)})))},e.checkVec4=function(e){var t=this;return!!Array.isArray(e)&&(4==e.length&&e.every((function(e){return t.checkNumber(e)})))},e.checkNonnegative4=function(e){var t=this;return!!Array.isArray(e)&&(4==e.length&&e.every((function(e){return t.checkNonnegative(e)})))},e.checkNumberArray=function(e){var t=this;return!!Array.isArray(e)&&e.every((function(e){return t.checkNumber(e)}))},e.checkTexture=function(e){return e instanceof t.Texture&&(e.isDestroyed&&console.error("Texture is destroyed, ".concat(e.name)),!e.isDestroyed)},e.checkTextureUndef=function(e){return void 0===e||this.checkTexture(e)},e.checkTexTransform=function(e){return!!this.checkVec2Undef(e.offset)&&(!!this.checkNumberUndef(e.rotation)&&(!!this.checkVec2Undef(e.scale)&&(void 0===e.scale||!(Math.abs(e.scale[0])<1e-5||Math.abs(e.scale[1])<1e-5))))},e.checkTexTransformUndef=function(e){return void 0===e||this.checkTexTransform(e)},e.checkMatBlending=function(e){return void 0===e||e===t.spec.MaterialBlending.opaque||e===t.spec.MaterialBlending.masked||e===t.spec.MaterialBlending.translucent||e===t.spec.MaterialBlending.additive},e.checkMatSide=function(e){return void 0===e||e===t.spec.SideMode.BACK||e===t.spec.SideMode.DOUBLE||e===t.spec.SideMode.FRONT},e.checkAnimPath=function(e){return"translation"===e||"rotation"===e||"scale"===e||"weights"===e},e.checkAnimInterp=function(e){return"LINEAR"===e||"STEP"===e||"CUBICSPLINE"===e},e.assertGeometry=function(e,n){e instanceof t.Geometry||console.error("Invalid geometry type ".concat(this.stringify(e))),!0===e.isDestroyed&&console.error("Geometry object is destroyed"),this.checkNonnegative(e.getDrawStart())||console.error("Invalid geometry draw start: ".concat(e.getDrawStart(),", ").concat(this.stringify(e)))},e.assertGeometryBuffer=function(e,t,n){var o=this.createAttributeArray(e,t);void 0!==o&&o.getLength()<n&&console.error("".concat(t," Length(").concat(o.getLength(),") is less than draw count(").concat(n,"), ").concat(this.stringify(e)))},e.createAttributeArray=function(e,t){var n=e.attributes;if(void 0!==n){var o=n[t];if(void 0!==o){var i=e.getAttributeData(t);if(void 0!==i){var r=new He;return r.create(o,i),r}}}},e.assertModelSkinOptions=function(e){if(this.checkStringUndef(e.name)||console.error("Invalid skin name ".concat(e.name,", ").concat(this.stringify(e))),this.checkNumberArray(e.joints)||console.error("Invalid skin joints ".concat(e.joints,", ").concat(this.stringify(e))),this.checkNumberUndef(e.skeleton)||console.error("Invalid skin skeleton ".concat(e.skeleton,", ").concat(this.stringify(e))),this.checkFloat32ArrayUndef(e.inverseBindMatrices)||console.error("Invalid skin inverseBindMatrices ".concat(e.inverseBindMatrices,", ").concat(this.stringify(e))),void 0!==e.inverseBindMatrices){(e.inverseBindMatrices.length<=0||e.inverseBindMatrices.length%16!=0)&&console.error("Invalid skin inverseBindMatrices length ".concat(e.inverseBindMatrices,", ").concat(this.stringify(e))),16*e.joints.length!==e.inverseBindMatrices.length&&console.error("Mismatch: skin joints and inverseBindMatrices length, ".concat(e.joints,", ").concat(e.inverseBindMatrices,", ").concat(this.stringify(e)));for(var t=new m,n=0;n<e.inverseBindMatrices.length;n+=16){for(var o=0;o<16;o++)t.elements[o]=e.inverseBindMatrices[n+o];Math.abs(t.determinant())<1e-5&&console.error("Determinant of inverseBindMatrices is too small ".concat(t.determinant(),", index ").concat(n/16,", ").concat(this.stringify(e)))}}else e.joints.length<=0&&console.error("Invalid skin joints length ".concat(e.joints,", ").concat(this.stringify(e)))},e.assertMatOptions=function(e){e.type===t.spec.MaterialType.unlit?(this.checkString(e.name)||console.error("Invalid material name ".concat(e.name,", ").concat(this.stringify(e))),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor ".concat(e.baseColorFactor,", ").concat(this.stringify(e))),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture ".concat(e.baseColorTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform ".concat(e.baseColorTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate ".concat(e.baseColorTextureCoordinate,", ").concat(this.stringify(e))),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask ".concat(e.depthMask,", ").concat(this.stringify(e))),this.checkMatBlending(e.blending)||console.error("Invalid material blending ".concat(e.blending,", ").concat(this.stringify(e))),this.checkMatSide(e.side)||console.error("Invalid material side ".concat(e.side,", ").concat(this.stringify(e))),e.blending===t.spec.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, ".concat(this.stringify(e))),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff ".concat(e.alphaCutOff,", ").concat(this.stringify(e)))):e.type===t.spec.MaterialType.pbr?(this.checkString(e.name)||console.error("Invalid material name ".concat(e.name,", ").concat(this.stringify(e))),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor ".concat(e.baseColorFactor,", ").concat(this.stringify(e))),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture ".concat(e.baseColorTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform ".concat(e.baseColorTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate ".concat(e.baseColorTextureCoordinate,", ").concat(this.stringify(e))),this.checkBooleanUndef(e.useSpecularAA)||console.error("Invalid material useSpecularAA ".concat(e.useSpecularAA,", ").concat(this.stringify(e))),this.checkNumber01(e.metallicFactor)||console.error("Invalid material metallicFactor ".concat(e.metallicFactor,", ").concat(this.stringify(e))),this.checkNonnegative(e.roughnessFactor)||console.error("Invalid material roughnessFactor ".concat(e.roughnessFactor,", ").concat(this.stringify(e))),this.checkTextureUndef(e.metallicRoughnessTexture)||console.error("Invalid material metallicRoughnessTexture ".concat(e.metallicRoughnessTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.metallicRoughnessTextureTransform)||console.error("Invalid material metallicRoughnessTextureTransform ".concat(e.metallicRoughnessTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.metallicRoughnessTextureCoordinate)||console.error("Invalid material metallicRoughnessTextureCoordinate ".concat(e.metallicRoughnessTextureCoordinate,", ").concat(this.stringify(e))),this.checkTextureUndef(e.normalTexture)||console.error("Invalid material normalTexture ".concat(e.normalTexture,", ").concat(this.stringify(e))),this.checkNonnegativeUndef(e.normalTextureScale)||console.error("Invalid material normalTextureScale ".concat(e.normalTextureScale,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.normalTextureTransform)||console.error("Invalid material normalTextureTransform ".concat(e.normalTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.normalTextureCoordinate)||console.error("Invalid material normalTextureCoordinate ".concat(e.normalTextureCoordinate,", ").concat(this.stringify(e))),this.checkTextureUndef(e.occlusionTexture)||console.error("Invalid material occlusionTexture ".concat(e.occlusionTexture,", ").concat(this.stringify(e))),this.checkNumber01Undef(e.occlusionTextureStrength)||console.error("Invalid material occlusionTextureStrength ".concat(e.occlusionTextureStrength,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.occlusionTextureTransform)||console.error("Invalid material occlusionTextureTransform ".concat(e.occlusionTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.occlusionTextureCoordinate)||console.error("Invalid material occlusionTextureCoordinate ".concat(e.occlusionTextureCoordinate,", ").concat(this.stringify(e))),this.checkNonnegative4(e.emissiveFactor)||console.error("Invalid material emissiveFactor ".concat(e.emissiveFactor,", ").concat(this.stringify(e))),this.checkNonnegative(e.emissiveIntensity)||console.error("Invalid material emissiveIntensity ".concat(e.emissiveIntensity,", ").concat(this.stringify(e))),this.checkTextureUndef(e.emissiveTexture)||console.error("Invalid material emissiveTexture ".concat(e.emissiveTexture,", ").concat(this.stringify(e))),this.checkTexTransformUndef(e.emissiveTextureTransform)||console.error("Invalid material emissiveTextureTransform ".concat(e.emissiveTextureTransform,", ").concat(this.stringify(e))),this.checkTexCoord(e.emissiveTextureCoordinate)||console.error("Invalid material emissiveTextureCoordinate ".concat(e.emissiveTextureCoordinate,", ").concat(this.stringify(e))),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask ".concat(e.depthMask,", ").concat(this.stringify(e))),this.checkMatBlending(e.blending)||console.error("Invalid material blending ".concat(e.blending,", ").concat(this.stringify(e))),this.checkMatSide(e.side)||console.error("Invalid material side ".concat(e.side,", ").concat(this.stringify(e))),e.blending===t.spec.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, ".concat(this.stringify(e))),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff ".concat(e.alphaCutOff,", ").concat(this.stringify(e)))):console.error("Invalid material type ".concat(this.stringify(e)))},e.assertPrimOptions=function(e,t){return this.assertGeometry(e.geometry,t),this.assertMatOptions(e.material),!0},e.assertModelMeshOptions=function(e){this.checkParent(e.parent)||console.error("Invalid mesh parent ".concat(e.parent,", ").concat(this.stringify(e))),void 0!==e.skin&&this.assertModelSkinOptions(e.skin);for(var t=[],n=0;n<e.primitives.length;n++){var o=e.primitives[n];this.assertPrimOptions(o)||console.error("Invalid primitive ".concat(o,", ").concat(this.stringify(e)));var i=new X;i.create(o.geometry),t.push(i)}for(n=1;n<t.length;n++){var r=t[n-1],a=t[n];r.equals(a)||console.error("Morph states mismatch: ".concat(this.stringify(r),", ").concat(this.stringify(a),", ").concat(this.stringify(e)))}this.checkBooleanUndef(e.hide)||console.error("Invalid mesh hide ".concat(e.hide,", ").concat(this.stringify(e)))},e.assertModelCameraOptions=function(e){this.checkParent(e.parent)||console.error("Invalid camera parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNumberUndef(e.aspect)||console.error("Invalid camera aspect ".concat(e.aspect,", ").concat(this.stringify(e))),this.checkPositive(e.near)||console.error("Invalid camera near ".concat(e.near,", ").concat(this.stringify(e))),(!this.checkPositive(e.far)||e.far<=e.near)&&console.error("Invalid camera far ".concat(e.far,", ").concat(this.stringify(e))),this.checkPositive(e.fov)||console.error("Invalid camera fov ".concat(e.fov,", ").concat(this.stringify(e))),this.checkNumber01(e.clipMode)||console.error("Invalid camera clipMode ".concat(e.clipMode,", ").concat(this.stringify(e)))},e.assertModelLightOptions=function(e){"directional"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e)))):"point"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e))),this.checkNonnegative(e.range)||console.error("Invalid light range ".concat(e.range,", ").concat(this.stringify(e)))):"spot"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e))),this.checkNonnegative(e.range)||console.error("Invalid light range ".concat(e.range,", ").concat(this.stringify(e))),this.checkNonnegative(e.innerConeAngle)||console.error("Invalid light innerConeAngle ".concat(e.innerConeAngle,", ").concat(this.stringify(e))),this.checkNonnegative(e.outerConeAngle)||console.error("Invalid light outerConeAngle ".concat(e.outerConeAngle,", ").concat(this.stringify(e)))):"ambient"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent ".concat(e.parent,", ").concat(this.stringify(e))),this.checkNonnegative4(e.color)||console.error("Invalid light color ".concat(e.color,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity ".concat(e.intensity,", ").concat(this.stringify(e)))):console.error("Invalid light type ".concat(this.stringify(e)))},e.assertModelSkyboxOptions=function(e){var t=this;this.checkBoolean(e.renderable)||console.error("Invalid skybox renderable ".concat(e.renderable,", ").concat(this.stringify(e))),this.checkNonnegative(e.intensity)||console.error("Invalid skybox intensity ".concat(e.intensity,", ").concat(this.stringify(e))),this.checkNonnegative(e.reflectionsIntensity)||console.error("Invalid skybox reflectionsIntensity ".concat(e.reflectionsIntensity,", ").concat(this.stringify(e)));var n=e.irradianceCoeffs;void 0!==n?(Array.isArray(n)&&9==n.length||console.error("Invalid skybox irradianceCoeffs ".concat(n,", ").concat(this.stringify(e))),n.forEach((function(e){t.checkVec3(e)||console.error("Invalid skybox irradianceCoeffs ".concat(n,", ").concat(t.stringify(e)))}))):void 0!==e.diffuseImage?this.checkTexture(e.diffuseImage)||console.error("Invalid skybox diffuseImage ".concat(e.diffuseImage,", ").concat(this.stringify(e))):console.error("Invalid skybox, irradianceCoeffs or diffuseImage should give one, ".concat(this.stringify(e))),this.checkTexture(e.specularImage)||console.error("Invalid skybox specularImage ".concat(e.specularImage,", ").concat(this.stringify(e))),this.checkPositive(e.specularImageSize)||console.error("Invalid skybox specularImageSize ".concat(e.specularImageSize,", ").concat(this.stringify(e))),this.checkPositive(e.specularMipCount)||console.error("Invalid skybox specularMipCount ".concat(e.specularMipCount,", ").concat(this.stringify(e))),this.pow2(e.specularMipCount)>e.specularImageSize&&console.error("Invalid skybox specularMipCount or specularImageSize, ".concat(this.stringify(e)))},e.checkModelAnimTrackOptions=function(e){return this.checkNonnegative(e.node)?this.checkFloat32Array(e.input)?this.checkFloat32Array(e.output)?this.checkAnimPath(e.path)?!!this.checkAnimInterp(e.interpolation)||(console.error("Invalid track interpolation ".concat(e.interpolation,", ").concat(this.stringify(e))),!1):(console.error("Invalid track path ".concat(e.path,", ").concat(this.stringify(e))),!1):(console.error("Invalid track input ".concat(e.output,", ").concat(this.stringify(e))),!1):(console.error("Invalid track input ".concat(e.input,", ").concat(this.stringify(e))),!1):(console.error("Invalid track node ".concat(e.node,", ").concat(this.stringify(e))),!1)},e.assertModelAnimOptions=function(e){var t=this;this.checkStringUndef(e.name)||console.error("Invalid animation name ".concat(e.name,", ").concat(this.stringify(e))),Array.isArray(e.tracks)||console.error("Invalid animation tracks ".concat(e.tracks,", ").concat(this.stringify(e))),e.tracks.forEach((function(n){t.checkModelAnimTrackOptions(n)||console.error("Invalid animation track ".concat(n,", ").concat(t.stringify(e)))}))},e.assertTreeOptions=function(e){var t=this;this.checkNumberUndef(e.animation)||console.error("Invalid tree animation ".concat(e.animation,", ").concat(this.stringify(e))),void 0!==e.animations&&(Array.isArray(e.animations)||console.error("Invalid tree animations ".concat(e.animations,", ").concat(this.stringify(e))),e.animations.forEach((function(e){t.assertModelAnimOptions(e)})),void 0!==e.animation&&(e.animation<-1||e.animation>=e.animations.length)&&console.error("Invalid tree animations ".concat(e.animations,", ").concat(this.stringify(e))))},e.stringify=function(e){var n={};for(var o in e)"internal"!==o&&"function"!=typeof e[o]&&(e[o]instanceof t.Texture||e[o]instanceof t.Geometry?n[o]=e[o].name:e[o]instanceof t.Renderer||(n[o]=e[o]));return JSON.stringify(n)},e.pow2=function(e){for(var t=1;e-- >0;)t*=2;return t},e}(),Ye=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]=qe(e[n])},Object.defineProperty(e.prototype,"bytes",{get:function(){return 2*this.size},enumerable:!1,configurable:!0}),e}(),qe=(De=new Float32Array(1),Be=new Int32Array(De.buffer),function(e){De[0]=e;var t=Be[0],n=t>>16&32768,o=t>>12&2047,i=t>>23&255;return i<103?n:i>142?(n|=31744,n|=(255==i?0:1)&&8388607&t):i<113?n|=((o|=2048)>>114-i)+(o>>113-i&1):(n|=i-112<<10|o>>1,n+=1&o)}),Ke=function(n){function o(){var t=null!==n&&n.apply(this,arguments)||this;return t.materialType=e.PMaterialType.none,t.vertexShaderCode="",t.fragmentShaderCode="",t.depthMask=!0,t.depthTestHint=!0,t.blendMode=e.PBlendMode.opaque,t.alphaCutOff=.5,t.faceSideMode=e.PFaceSideMode.front,t}return i(o,n),o.prototype.getShaderFeatures=function(){var t=[];return this.isOpaque()?t.push("ALPHAMODE_OPAQUE 1"):this.isMasked()&&t.push("ALPHAMODE_MASK 1"),this.faceSideMode===e.PFaceSideMode.both&&t.push("DOUBLE_SIDED 1"),t},o.prototype.updateUniforms=function(e){if(this.isMasked()&&e.setFloat("u_AlphaCutoff",this.alphaCutOff),w.getInstance().renderMode3D===t.spec.RenderMode3D.uv){var n=w.getInstance().renderMode3DUVGridSize;e.setFloat("u_DebugUVGridSize",n)}},o.prototype.build=function(t){var n=this.getShaderFeatures();void 0!==t&&n.push.apply(n,u([],l(t),!1));var o=w.getInstance().isWebGL2;(o&&n.push("WEBGL2"),this.materialType!==e.PMaterialType.shadowBase)&&(w.getInstance().isEditorEnv&&n.push("EDITOR_TRANSFORM"));var i=Te.getInstance().genShaderCode({material:this,isWebGL2:o,featureList:n});this.vertexShaderCode=i.vertexShaderCode,this.fragmentShaderCode=i.fragmentShaderCode},o.prototype.getBlendMode=function(n){return n===t.spec.MaterialBlending.masked?e.PBlendMode.masked:n===t.spec.MaterialBlending.translucent?e.PBlendMode.translucent:n===t.spec.MaterialBlending.additive?e.PBlendMode.additive:e.PBlendMode.opaque},o.prototype.getFaceSideMode=function(n){return n===t.spec.SideMode.DOUBLE?e.PFaceSideMode.both:n===t.spec.SideMode.BACK?e.PFaceSideMode.back:e.PFaceSideMode.front},o.prototype.setMaterialStates=function(n){this.blendMode===e.PBlendMode.translucent||this.blendMode===e.PBlendMode.additive?(n.blending=!0,n.depthTest=!0,n.blendEquation=[t.glContext.FUNC_ADD,t.glContext.FUNC_ADD],this.blendMode===e.PBlendMode.translucent?n.blendFunction=[t.glContext.ONE,t.glContext.ONE_MINUS_SRC_ALPHA,t.glContext.ONE,t.glContext.ONE_MINUS_SRC_ALPHA]:n.blendFunction=[t.glContext.ONE,t.glContext.ONE,t.glContext.ONE,t.glContext.ONE],n.depthMask=this.depthMask):w.getInstance().isTiny3dMode?(n.blending=!1,n.depthTest=!0,n.depthMask=!0):(n.blending=!1,n.depthTest=this.depthTestHint,n.depthMask=this.depthMask),this.setFaceSideStates(n)},o.prototype.setFaceSideStates=function(e){this.isBothFace()?e.culling=!1:this.isBackFace()?(e.cullFace=t.glContext.FRONT,e.frontFace=t.glContext.CCW,e.culling=!0):(e.cullFace=t.glContext.BACK,e.frontFace=t.glContext.CCW,e.culling=!0)},o.prototype.dispose=function(){this.vertexShaderCode="",this.fragmentShaderCode=""},o.prototype.isValid=function(){return this.materialType!==e.PMaterialType.none&&n.prototype.isValid.call(this)},o.prototype.isOpaque=function(){return this.blendMode===e.PBlendMode.opaque},o.prototype.isMasked=function(){return this.blendMode===e.PBlendMode.masked},o.prototype.isTranslucent=function(){return this.blendMode===e.PBlendMode.translucent},o.prototype.isAdditive=function(){return this.blendMode===e.PBlendMode.additive},o.prototype.requireBlend=function(){return this.blendMode===e.PBlendMode.translucent||this.blendMode===e.PBlendMode.additive},o.prototype.isFrontFace=function(){return this.faceSideMode===e.PFaceSideMode.front},o.prototype.isBackFace=function(){return this.faceSideMode===e.PFaceSideMode.back},o.prototype.isBothFace=function(){return this.faceSideMode===e.PFaceSideMode.both},o}(N),Qe=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.baseColorFactor=new d(1,1,1,1),e}return i(n,t),n.prototype.create=function(t){var n;this.name=t.name,this.type=e.PObjectType.material,this.materialType=e.PMaterialType.unlit,t.baseColorTexture&&(this.baseColorTexture=t.baseColorTexture),this.setBaseColorFactor(Ge.toPluginColor4(t.baseColorFactor)),!1===t.depthMask?this.depthMask=!1:this.depthMask=!0,this.blendMode=this.getBlendMode(t.blending),this.alphaCutOff=null!==(n=t.alphaCutOff)&&void 0!==n?n:0,this.faceSideMode=this.getFaceSideMode(t.side)},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.baseColorTexture=void 0},n.prototype.getShaderFeatures=function(){var e=t.prototype.getShaderFeatures.call(this);return e.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&e.push("HAS_BASE_COLOR_MAP 1"),e.push("MATERIAL_UNLIT 1"),e},n.prototype.updateUniforms=function(e){t.prototype.updateUniforms.call(this,e);var n=(new p).identity();e.setVector4("u_BaseColorFactor",this.baseColorFactor),this.hasBaseColorTexture()&&(e.setTexture("u_BaseColorSampler",this.getBaseColorTexture()),e.setInt("u_BaseColorUVSet",0),e.setMatrix3("u_BaseColorUVTransform",n)),e.setFloat("u_MetallicFactor",0),e.setFloat("u_RoughnessFactor",0),e.setFloat("u_Exposure",1)},n.prototype.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},n.prototype.getBaseColorTexture=function(){return this.baseColorTexture},n.prototype.setBaseColorTexture=function(e){this.baseColorTexture=e},n.prototype.getBaseColorFactor=function(){return this.baseColorFactor},n.prototype.setBaseColorFactor=function(e){e instanceof d?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},n}(Ke),Ze=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.baseColorFactor=new d(1,1,1,1),e.useSpecularAA=!1,e.metallicFactor=0,e.roughnessFactor=1,e.normalTextureScale=1,e.occlusionTextureStrength=1,e.emissiveFactor=new h(0,0,0),e.emissiveIntensity=1,e.enableShadow=!1,e}return i(n,t),n.prototype.create=function(t){var n,o,i,r,a;this.name=t.name,this.type=e.PObjectType.material,this.materialType=e.PMaterialType.pbr,t.baseColorTexture&&(this.baseColorTexture=t.baseColorTexture),t.baseColorTextureTransform&&(this.baseColorTextureTrans=Ge.createUVTransform(t.baseColorTextureTransform)),this.setBaseColorFactor(Ge.toPluginColor4(t.baseColorFactor)),t.metallicRoughnessTexture&&(this.metallicRoughnessTexture=t.metallicRoughnessTexture),t.metallicRoughnessTextureTransform&&(this.metallicRoughnessTextureTrans=Ge.createUVTransform(t.metallicRoughnessTextureTransform)),this.useSpecularAA=null!==(n=t.useSpecularAA)&&void 0!==n&&n,this.metallicFactor=t.metallicFactor,this.roughnessFactor=Ge.clamp(t.roughnessFactor,0,1),t.normalTexture&&(this.normalTexture=t.normalTexture),t.normalTextureTransform&&(this.normalTextureTrans=Ge.createUVTransform(t.normalTextureTransform)),this.normalTextureScale=null!==(o=t.normalTextureScale)&&void 0!==o?o:1,t.occlusionTexture&&(this.occlusionTexture=t.occlusionTexture),t.occlusionTextureTransform&&(this.occlusionTextureTrans=Ge.createUVTransform(t.occlusionTextureTransform)),this.occlusionTextureStrength=null!==(i=t.occlusionTextureStrength)&&void 0!==i?i:1,t.emissiveTexture&&(this.emissiveTexture=t.emissiveTexture),t.emissiveTextureTransform&&(this.emissiveTextureTrans=Ge.createUVTransform(t.emissiveTextureTransform));var s=Ge.toPluginColor4(t.emissiveFactor);this.emissiveFactor=h.fromArray(s),this.emissiveIntensity=t.emissiveIntensity,this.enableShadow=null!==(r=t.enableShadow)&&void 0!==r&&r,!1===t.depthMask?this.depthMask=!1:this.depthMask=!0,this.blendMode=this.getBlendMode(t.blending),this.alphaCutOff=null!==(a=t.alphaCutOff)&&void 0!==a?a:0,this.faceSideMode=this.getFaceSideMode(t.side)},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.baseColorTexture=void 0,this.metallicRoughnessTexture=void 0,this.normalTexture=void 0,this.occlusionTexture=void 0,this.emissiveTexture=void 0},n.prototype.getShaderFeatures=function(){var e=t.prototype.getShaderFeatures.call(this);return e.push("MATERIAL_METALLICROUGHNESS 1"),this.hasBaseColorTexture()&&(e.push("HAS_BASE_COLOR_MAP 1"),void 0!==this.baseColorTextureTrans&&e.push("HAS_BASECOLOR_UV_TRANSFORM 1")),this.hasMetallicRoughnessTexture()&&(e.push("HAS_METALLIC_ROUGHNESS_MAP 1"),void 0!==this.metallicRoughnessTextureTrans&&e.push("HAS_METALLICROUGHNESS_UV_TRANSFORM 1")),this.useSpecularAA&&e.push("USE_SPECULAR_AA 1"),this.hasNormalTexture()&&(e.push("HAS_NORMAL_MAP 1"),void 0!==this.normalTextureTrans&&e.push("HAS_NORMAL_UV_TRANSFORM 1")),this.hasOcclusionTexture()&&(e.push("HAS_OCCLUSION_MAP 1"),void 0!==this.occlusionTextureTrans&&e.push("HAS_OCCLUSION_UV_TRANSFORM 1")),this.hasEmissiveTexture()?(e.push("HAS_EMISSIVE_MAP 1"),void 0!==this.emissiveTextureTrans&&e.push("HAS_EMISSIVE_UV_TRANSFORM 1")):this.hasEmissiveFactor()&&e.push("HAS_EMISSIVE 1"),e},n.prototype.updateUniforms=function(e){t.prototype.updateUniforms.call(this,e);var n=(new p).identity();if(e.setVector4("u_BaseColorFactor",this.baseColorFactor),void 0!==this.baseColorTexture&&(e.setTexture("u_BaseColorSampler",this.baseColorTexture),e.setInt("u_BaseColorUVSet",0),void 0!==this.baseColorTextureTrans?e.setMatrix3("u_BaseColorUVTransform",this.baseColorTextureTrans):e.setMatrix3("u_BaseColorUVTransform",n)),e.setFloat("u_MetallicFactor",this.metallicFactor),e.setFloat("u_RoughnessFactor",this.roughnessFactor),void 0!==this.metallicRoughnessTexture&&(e.setTexture("u_MetallicRoughnessSampler",this.metallicRoughnessTexture),e.setInt("u_MetallicRoughnessUVSet",0),void 0!==this.metallicRoughnessTextureTrans?e.setMatrix3("u_MetallicRoughnessUVTransform",this.metallicRoughnessTextureTrans):e.setMatrix3("u_MetallicRoughnessUVTransform",n)),void 0!==this.normalTexture&&(e.setTexture("u_NormalSampler",this.normalTexture),e.setFloat("u_NormalScale",this.normalTextureScale),e.setInt("u_NormalUVSet",0),void 0!==this.normalTextureTrans?e.setMatrix3("u_NormalUVTransform",this.normalTextureTrans):e.setMatrix3("u_NormalUVTransform",n)),void 0!==this.occlusionTexture&&(e.setTexture("u_OcclusionSampler",this.occlusionTexture),e.setFloat("u_OcclusionStrength",this.occlusionTextureStrength),e.setInt("u_OcclusionUVSet",0),void 0!==this.occlusionTextureTrans?e.setMatrix3("u_OcclusionUVTransform",this.occlusionTextureTrans):e.setMatrix3("u_OcclusionUVTransform",n)),void 0!==this.emissiveTexture){var o=this.getEmissiveFactor();e.setTexture("u_EmissiveSampler",this.emissiveTexture),e.setVector3("u_EmissiveFactor",o),e.setInt("u_EmissiveUVSet",0),void 0!==this.emissiveTextureTrans?e.setMatrix3("u_EmissiveUVTransform",this.emissiveTextureTrans):e.setMatrix3("u_EmissiveUVTransform",n)}else if(this.hasEmissiveFactor()){o=this.getEmissiveFactor();e.setVector3("u_EmissiveFactor",o)}e.setFloat("u_Exposure",3)},n.prototype.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},n.prototype.hasBaseColorTextureTrans=function(){return void 0!==this.baseColorTextureTrans},n.prototype.setBaseColorTexture=function(e){this.baseColorTexture=e},n.prototype.getBaseColorFactor=function(){return this.baseColorFactor},n.prototype.setBaseColorFactor=function(e){e instanceof d?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},n.prototype.hasMetallicRoughnessTexture=function(){return void 0!==this.metallicRoughnessTexture},n.prototype.hasMetallicRoughnessTextureTrans=function(){return void 0!==this.metallicRoughnessTextureTrans},n.prototype.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture},n.prototype.setMetallicRoughnessTexture=function(e){this.metallicRoughnessTexture=e},n.prototype.hasNormalTexture=function(){return void 0!==this.normalTexture},n.prototype.hasNormalTextureTrans=function(){return void 0!==this.normalTextureTrans},n.prototype.getNormalTexture=function(){return this.normalTexture},n.prototype.setNormalTexture=function(e){this.normalTexture=e},n.prototype.hasOcclusionTexture=function(){return void 0!==this.occlusionTexture},n.prototype.hasOcclusionTextureTrans=function(){return void 0!==this.occlusionTextureTrans},n.prototype.getOcclusionTexture=function(){return this.occlusionTexture},n.prototype.setOcclusionTexture=function(e){this.occlusionTexture=e},n.prototype.hasEmissiveTexture=function(){return void 0!==this.emissiveTexture},n.prototype.hasEmissiveTextureTrans=function(){return void 0!==this.emissiveTextureTrans},n.prototype.getEmissiveTexture=function(){return this.emissiveTexture},n.prototype.setEmissiveTexture=function(e){this.emissiveTexture=e},n.prototype.hasEmissiveFactor=function(){return this.emissiveFactor.sum()*this.emissiveIntensity>0},n.prototype.getEmissiveFactor=function(){return this.emissiveFactor.clone().multiply(this.emissiveIntensity)},n.prototype.setEmissiveFactor=function(e){e instanceof h?this.emissiveFactor.set(e.x,e.y,e.z):this.emissiveFactor.set(e[0],e[1],e[2])},n}(Ke);function $e(e){if(e.type===t.spec.MaterialType.pbr){var n=new Ze;return n.create(e),n}var o=new Qe;return o.create(e),o}var et,tt=function(t){function n(n,o,i){var r,a=t.call(this)||this;return a.renderable=!0,a.intensity=1,a.reflectionsIntensity=1,a.specularImageSize=0,a.specularMipCount=0,a.priority=0,a.isBuilt=!1,a.name=n,a.type=e.PObjectType.skybox,a.visible=!1,a.owner=i,a.renderable=o.renderable,a.intensity=o.intensity,a.reflectionsIntensity=o.reflectionsIntensity,a.irradianceCoeffs=o.irradianceCoeffs,a.diffuseImage=o.diffuseImage,a.specularImage=o.specularImage,a.specularImageSize=o.specularImageSize,a.specularMipCount=o.specularMipCount,a.priority=(null===(r=null==i?void 0:i.item)||void 0===r?void 0:r.listIndex)||0,a}return i(n,t),n.prototype.setup=function(e){this.brdfLUT=e},n.prototype.build=function(e){if(!this.isBuilt){this.isBuilt=!0,this.skyboxMaterial=new nt,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.prototype.render=function(e,t){if(this.updateMaterial(e),this.visible&&this.renderable&&void 0!==this.skyboxMesh){var n=this.skyboxMesh;n.geometry.flush(),n.material.initialize(),t.drawGeometry(n.geometry,n.material)}},n.prototype.dispose=function(){var e;t.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===(e=this.skyboxMaterial)||void 0===e||e.dispose(),this.skyboxMaterial=void 0},n.prototype.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,o=t.viewMatrix,i=n.getNewProjectionMatrix(n.fovy).multiply(o).invert(),r=this.skyboxMesh.material;this.skyboxMaterial.updateUniforms(r),r.setMatrix("u_InvViewProjectionMatrix",i)}},Object.defineProperty(n.prototype,"available",{get:function(){return!!this.isValid()&&(!(this.intensity<=0&&this.reflectionsIntensity<=0)&&((void 0!==this.irradianceCoeffs||void 0!==this.diffuseImage)&&(void 0!==this.specularImage&&this.specularMipCount>0)))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentIntensity",{get:function(){return this.visible?this.intensity:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentReflectionsIntensity",{get:function(){return this.visible?this.reflectionsIntensity:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasDiffuseImage",{get:function(){return void 0!==this.diffuseImage},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasIrradianceCoeffs",{get:function(){return void 0!==this.irradianceCoeffs},enumerable:!1,configurable:!0}),n}(L),nt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.intensity=1,e.reflectionsIntensity=1,e.specularMipCount=0,e}return i(n,t),n.prototype.create=function(t){this.type=e.PObjectType.material,this.materialType=e.PMaterialType.skyboxFilter,this.depthTestHint=!1,this.name=t.name,this.intensity=t.intensity,this.reflectionsIntensity=t.reflectionsIntensity,this.brdfLUT=t.brdfLUT,this.irradianceCoeffs=t.irradianceCoeffs,this.diffuseImage=t.diffuseImage,this.specularImage=t.specularImage,this.specularMipCount=t.specularMipCount},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.brdfLUT=void 0,this.irradianceCoeffs=void 0,this.diffuseImage=void 0,this.specularImage=void 0},n.prototype.getShaderFeatures=function(){var e=[];return e.push("USE_IBL 1"),e.push("USE_TEX_LOD 1"),void 0===this.diffuseImage&&e.push("IRRADIANCE_COEFFICIENTS 1"),e},n.prototype.updateUniforms=function(e){if(void 0===this.brdfLUT)throw new Error("Setup brdfLUT for skybox at first.");if(e.setVector2("u_IblIntensity",new f(2,2)),e.setTexture("u_brdfLUT",this.brdfLUT),void 0!==this.diffuseImage)e.setTexture("u_DiffuseEnvSampler",this.diffuseImage);else{var t=this.irradianceCoeffs;if(void 0===t||9!=t.length)throw new Error("Invalid skybox irradiance coeffs ".concat(t));["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach((function(n,o){e.setVector3("u_shCoefficients.".concat(n),h.fromArray(t[o]))}))}e.setInt("u_MipCount",this.specularMipCount),e.setTexture("u_SpecularEnvSampler",this.specularImage)},n.prototype.setMaterialStates=function(e){e.depthTest=!0,e.depthMask=!1,this.setFaceSideStates(e)},n}(Ke);e.PSkyboxType=void 0,(et=e.PSkyboxType||(e.PSkyboxType={}))[et.NFT=0]="NFT",et[et.FARM=1]="FARM";var ot=function(){function n(){}return n.getBrdfLutTextureOptions=function(){return s(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return"https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png",[4,t.loadImage("https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png")];case 1:return e=n.sent(),[2,{name:"brdfLut",wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR,anisotropic:1,sourceType:t.TextureSourceType.image,image:e,generateMipmap:!1,flipY:!1,premultiplyAlpha:!1}]}}))}))},n.createBrdfLutTexture=function(e){return s(this,void 0,void 0,(function(){var n;return c(this,(function(o){switch(o.label){case 0:return[4,this.getBrdfLutTextureOptions()];case 1:return n=o.sent(),[2,t.Texture.create(e,n)]}}))}))},n.createSkyboxOptions=function(e,t){return s(this,void 0,void 0,(function(){var n,o,i,r,a,s,l,u;return c(this,(function(c){switch(c.label){case 0:return[4,this.createSpecularCubeMap(e,t)];case 1:return n=c.sent(),[4,this.createDiffuseCubeMap(e,t)];case 2:return o=c.sent(),i=t.renderable,r=t.intensity,a=t.reflectionsIntensity,s=t.irradianceCoeffs,l=t.specularImageSize,u=t.specularMipCount,[2,{renderable:i,intensity:r,reflectionsIntensity:a,irradianceCoeffs:s,diffuseImage:o,specularImage:n,specularImageSize:l,specularMipCount:u}]}}))}))},n.createSpecularCubeMap=function(e,n){return s(this,void 0,void 0,(function(){return c(this,(function(o){return t.glContext.CLAMP_TO_EDGE,t.glContext.CLAMP_TO_EDGE,t.glContext.LINEAR,t.glContext.LINEAR_MIPMAP_LINEAR,"url"===n.type?[2,ke.createTextureCubeMipmapFromURL(e,n.specularImage)]:[2,ke.createTextureCubeMipmapFromBuffer(e,n.specularImage,n.specularImageSize)]}))}))},n.createDiffuseCubeMap=function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(n){return void 0===t.diffuseImage?[2]:"url"===t.type?[2,ke.createTextureCubeFromURL(e,t.diffuseImage)]:[2,ke.createTextureCubeFromBuffer(e,t.diffuseImage)]}))}))},n.getSkyboxParams=function(t){void 0===t&&(t=e.PSkyboxType.NFT);var n=this.getSpecularImageList(t);return{type:"url",renderable:!0,intensity:1.8,reflectionsIntensity:1.8,irradianceCoeffs:this.getIrradianceCoeffs(t),diffuseImage:this.getDiffuseImageList(t,n),specularImage:n,specularImageSize:Math.pow(2,n.length-1),specularMipCount:n.length-1}},n.prototype.checkCubeMapImage=function(e){return s(this,void 0,void 0,(function(){var n,o,i,r;return c(this,(function(a){switch(a.label){case 0:o=[],i=0,a.label=1;case 1:return i<e.length?[4,t.loadImage(e[i])]:[3,4];case 2:if(r=a.sent(),i>0)if(i%6==0){if(2*r.width!==n.width||2*r.height!==n.height)throw new Error("Invalid cube map list1: index ".concat(i,", image0 ").concat(n,", image1 ").concat(r))}else if(r.width!==n.width||r.height!==n.height)throw new Error("Invalid cube map list2: index ".concat(i,", image0 ").concat(n,", image1 ").concat(r));i%6==0&&o.push([]),o[o.length-1].push(r),n=r,a.label=3;case 3:return i++,[3,1];case 4:return[2]}}))}))},n.getIrradianceCoeffs=function(t){var n=[];switch(t){case e.PSkyboxType.NFT:return;case e.PSkyboxType.FARM:n=[.2665672302246094,.27008703351020813,.2836797833442688,-.15421263873577118,-.15587495267391205,-.16371899843215942,.06483837962150574,.06468029320240021,.06616337597370148,-.11598809063434601,-.11796595901250839,-.1261979341506958,.023678265511989594,.02456280030310154,.02591511607170105,-.032404184341430664,-.03217344358563423,-.03126845508813858,.009165619499981403,.009345818310976028,.008521141484379768,-.021998587995767593,-.02203795686364174,-.021759089082479477,.00046658870996907353,.0005610908847302198,.0007202711421996355];break;default:n=[.3746267259120941,.3523011803627014,.33955901861190796,.12082185596227646,.18179306387901306,.26912716031074524,-.020699946209788322,-.004648427478969097,.00797625258564949,-.06842170655727386,-.05139023810625076,-.03317255899310112,.044127799570560455,.028159862384200096,.007428745273500681,.07887077331542969,.06773484498262405,.04738233983516693,-.012322401627898216,-.015187464654445648,-.02020176313817501,-.1091032400727272,-.0823250338435173,-.046844951808452606,-.05779704451560974,-.06689254194498062,-.08212742954492569]}for(var o=[],i=0;i<n.length;i+=3)o.push([n[i],n[i+1],n[i+2]]);return o},n.getDiffuseImageList=function(t,n){if(t==e.PSkyboxType.NFT)return n[n.length-1]},n.getSpecularImageList=function(t){var n=[];if(t===e.PSkyboxType.FARM)n.push.apply(n,u([],l(this.getSpecularImageListAntFarm()),!1));else n.push.apply(n,u([],l(this.getSpecularImageListNFT()),!1));var o=[];return n.forEach((function(e,t){t%6==0&&o.push([]),o[o.length-1].push(e)})),o},n.getSpecularImageListNFT=function(){return["https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img0.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img1.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img2.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img3.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img5.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img4.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img6.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img7.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img8.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img9.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img11.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img10.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img12.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img13.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img14.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img15.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img17.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img16.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img18.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img19.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img20.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img21.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img23.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img22.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img24.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img25.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img26.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img27.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img29.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img28.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img30.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img31.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img32.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img33.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img35.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img34.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img36.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img37.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img38.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img39.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img41.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img40.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img42.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img43.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img44.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img45.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img47.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img46.png"]},n.getSpecularImageListAntFarm=function(){return["https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_5.png"]},n}(),it=function(){function e(e){this.engine=e,this.loadSkybox=!1,this.meshCache=new Map,this.textureCache=new Map,this.geometryCache=new Map,this.renderPassCache=new Map}return e.loadStaticResources=function(){return s(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return void 0!==this.brdfLutTexOptions?[2]:(e=this,[4,ot.getBrdfLutTextureOptions()]);case 1:return e.brdfLutTexOptions=t.sent(),[2]}}))}))},e.genSkyboxOptions=function(t,n){return s(this,void 0,void 0,(function(){var o,i;return c(this,(function(r){switch(r.label){case 0:return void 0===(o=n)&&(o=ot.getSkyboxParams()),i=e,[4,ot.createSkyboxOptions(t,o)];case 1:return i.skyboxOptions=r.sent(),[2,e.skyboxOptions]}}))}))},e.prototype.setup=function(n){if(this.loadSkybox=n,void 0===this.brdfLutTexture||this.brdfLutTexture.isDestroyed){if(void 0===e.brdfLutTexOptions)throw new Error("Please load brdfLutTexOptions at first");var o="brdfLutTexture";this.brdfLutTexture=t.Texture.create(this.engine,e.brdfLutTexOptions),this.deleteTexture(o),this.setTexture(o,this.brdfLutTexture)}},e.prototype.getTexture=function(e){return this.textureCache.get(e)},e.prototype.setTexture=function(e,t){this.textureCache.set(e,t)},e.prototype.getOrCreateTexture=function(e,n){var o=this.textureCache.get(e);if(void 0!==o)return o;var i=t.Texture.create(this.engine,n);return this.textureCache.set(e,i),i},e.prototype.deleteTexture=function(e){var t=this.textureCache.get(e);return void 0!==t&&t.dispose(),this.textureCache.delete(e)},e.prototype.getOrCreateGeometry=function(e,t,n){var o=this.geometryCache.get(e);if(void 0!==o)return o;var i=Ge.createGeometry(this.engine,t,n);return this.geometryCache.set(e,i),i},e.prototype.getFilterMesh=function(e,t,n){var o=this.meshCache.get(e);if(void 0!==o)return o;var i=Ve.createFilterMesh(this.engine,e,t,n);return this.meshCache.set(e,i),i},e.prototype.getShadowBasePass=function(e,t,n,o){return this.getRenderPass(e,t,n,o)},e.prototype.getShadowFilterPass=function(e,t,n,o){return this.getRenderPass(e,t,n,o)},e.prototype.getRenderPass=function(e,t,n,o){var i=this.renderPassCache.get(e);if(void 0!==i)return i.setMeshes([]),n.forEach((function(e){i.addMesh(e)})),i;var r=this.engine.renderer,a=ke.createRenderPass(r,e,t,n,o);return this.renderPassCache.set(e,a),a},e.prototype.dispose=function(){this.engine=null,this.brdfLutTexture=void 0,this.meshCache.forEach((function(e){ke.deleteMesh(e)})),this.meshCache.clear(),this.textureCache.forEach((function(e){ke.deleteTexture(e)})),this.textureCache.clear(),this.geometryCache.forEach((function(e){ke.deleteGeometry(e)})),this.geometryCache.clear(),this.renderPassCache.forEach((function(e){ke.deleteRenderPass(e)})),this.renderPassCache.clear()},e.prototype.getRenderPasses=function(){var e=[];return this.renderPassCache.forEach((function(t){e.push(t)})),e},e.prototype.getBrdfLutTexture=function(){return this.brdfLutTexture},e.prototype.getSkyboxOptions=function(){return e.skyboxOptions},e}(),rt=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="model",t}return i(n,e),n.prepareResource=function(e,t){var n,o,i,r,a;return s(this,void 0,void 0,(function(){var s,l,u,f,h;return c(this,(function(c){switch(c.label){case 0:return void 0!==t.pluginData&&(s=["compatibleMode","renderSkybox","visBoundingBox","autoAdjustScene","enableDynamicSort","renderMode3D","renderMode3DUVGridSize"],l=t.pluginData,s.forEach((function(t){return e.storage[t]=l[t]}))),u=null!==(n=t.env)&&void 0!==n?n:"",e.storage.runtimeEnv=u,f=null!==(i=null===(o=t.pluginData)||void 0===o?void 0:o.compatibleMode)&&void 0!==i?i:"gltf",h=null!==(a=null===(r=t.pluginData)||void 0===r?void 0:r.autoAdjustScene)&&void 0!==a&&a,Ge.preprocessScene(e,u,f,h),[4,it.loadStaticResources()];case 1:return c.sent(),[2]}}))}))},n.prototype.onCompositionConstructed=function(e,t){this.sceneParams=t.storage;var n=e.renderer.engine;this.cache=new it(n),this.cache.setup(!1),Ge.setupItem3DOptions(t,this.cache,e)},n.prototype.onCompositionReset=function(e,n){var o={id:"ModelPluginItem",name:"ModelPluginItem",duration:9999999,endBehavior:t.spec.END_BEHAVIOR_FORWARD},i=new t.VFXItem(e.getEngine(),o);e.addItem(i);var r=i.addComponent(at);r.fromData({cache:this.cache}),r.initial(this.sceneParams)},n.prototype.onCompositionDestroyed=function(e){this.cache.dispose(),this.cache=null,this.sceneParams=null},n}(t.AbstractPlugin),at=function(o){function r(e,n){var i=o.call(this,e)||this;return i.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,i.compatibleMode="gltf",i.renderSkybox=!0,i.visBoundingBox=!1,i.autoAdjustScene=!1,i.enableDynamicSort=!1,i.renderMode3D=t.spec.RenderMode3D.none,i.renderMode3DUVGridSize=1/16,n&&i.fromData(n),i}return i(r,o),r.prototype.lateUpdate=function(e){var t,o,i,r=this.item.composition;if(this.autoAdjustScene&&1==this.scene.tickCount){var a=r.camera,s=(new E).fromMatrix4(a.getViewMatrix()),c=(new P).fromPTransform(s).zAxis.clone(),l=null!==(t=a.fov)&&void 0!==t?t:45,u=null!==(o=a.aspect)&&void 0!==o?o:1,f=this.scene.getSceneAABB(),d=f.clone().applyMatrix4(s.getMatrix()).getSize(new h).multiply(.5),p=d.x,g=d.y,v=g*Math.max(p/g/u,1),y=f.getCenter(new h),_=v/Math.tan(.5*l*I),b=y.clone().add(c.clone().multiply(_+d.z));r.camera.position=b,null===(i=r.items)||void 0===i||i.forEach((function(e){var t;if(e.type===n){var o=e.getComponent(Pe);if(null==o?void 0:o.content){var i=((null===(t=e.transform.parentTransform)||void 0===t?void 0:t.getWorldMatrix())||m.IDENTITY.clone()).invert().transformPoint(b);o.setTransform(i),console.info("Scene AABB [".concat(f.min.toArray(),"], [").concat(f.max.toArray(),"]")),console.info("Update camera position [".concat(i.toArray(),"]"))}}}))}this.updateSceneCamera(r),this.scene.tick(e)},r.prototype.onDestroy=function(){this.scene.dispose(),this.scene=null,this.cache=null},r.prototype.fromData=function(e){o.prototype.fromData.call(this,e);var t=e;this.cache=t.cache,this.scene=new ue(this.engine)},r.prototype.initial=function(e){var t,n,o,i,r,a,s,c;this.runtimeEnv=null!==(t=e.runtimeEnv)&&void 0!==t?t:this.runtimeEnv,this.compatibleMode=null!==(n=e.compatibleMode)&&void 0!==n?n:this.compatibleMode,this.renderSkybox=null!==(o=e.renderSkybox)&&void 0!==o?o:this.renderSkybox,this.visBoundingBox=null!==(i=e.visBoundingBox)&&void 0!==i?i:this.visBoundingBox,this.autoAdjustScene=null!==(r=e.autoAdjustScene)&&void 0!==r?r:this.autoAdjustScene,this.enableDynamicSort=null!==(a=e.enableDynamicSort)&&void 0!==a?a:this.enableDynamicSort,this.renderMode3D=null!==(s=e.renderMode3D)&&void 0!==s?s:this.renderMode3D,this.renderMode3DUVGridSize=null!==(c=e.renderMode3DUVGridSize)&&void 0!==c?c:this.renderMode3DUVGridSize;var l=this.item.composition;this.scene.initial({componentName:"".concat(l.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()}),this.updateSceneCamera(l)},r.prototype.updateSceneCamera=function(e){this.scene.updateDefaultCamera(e.camera.getOptions())},r.prototype.getLightItemCount=function(){var e,n,o=0;return(null!==(n=null===(e=this.item.composition)||void 0===e?void 0:e.items)&&void 0!==n?n:[]).forEach((function(e){e.type===t.spec.ItemType.light&&o++})),o},r=a([t.effectsClass(e.ModelDataType.ModelPluginComponent)],r)}(t.ItemBehaviour);function st(e){var t,n=null===(t=null==e?void 0:e.item)||void 0===t?void 0:t.composition,o=null==n?void 0:n.getItemByName("ModelPluginItem"),i=null==o?void 0:o.getComponent(at);return null==i?void 0:i.scene}var ct,lt=function(){function e(e,t){this.baseTransform=t.transform,this.animationManager=new Q(e,t),this.build(e)}return e.prototype.tick=function(e){this.animationManager.tick(e)},e.prototype.getNodes=function(){return this.nodes},e.prototype.getNodeById=function(e){var t=this.cacheMap;if(!t[e]){var n="^".concat(e);t[e]=this.allNodes.find((function(e){return e.id===n}))}return t[e]},e.prototype.getNodeByName=function(e){var t=this.cacheMap;return t[e]||(t[e]=this.allNodes.find((function(t){return t.name===e}))),t[e]},e.prototype.getNodeTransform=function(e){var t=this.getNodeById(e);return t?t.transform:this.baseTransform},e.prototype.dispose=function(){var e;this.allNodes=[],this.nodes=[],this.cacheMap={},this.baseTransform=null,null===(e=this.animationManager)||void 0===e||e.dispose(),this.animationManager=null},e.prototype.build=function(e){var n=this,o=this.baseTransform,i=e.nodes.map((function(e,i){return{name:e.name||e.id||i+"",transform:new t.Transform(r(r({},e.transform),{valid:!0}),o),id:"^".concat(e.id||i),children:[],tree:n}}));this.cacheMap={},i.forEach((function(t,n){var r=e.nodes[n].children;t.transform.name=t.name,t.transform.setValid(!0),r&&r.forEach((function(e){var n=i[e];n&&n!==t&&(n.transform.parentTransform!==o&&console.error("Node parent has been set."),n.transform.parentTransform=t.transform,t.children.push(n))}))})),this.allNodes=i,this.nodes=e.children.map((function(e){return i[e]}))},e}(),ut=function(n){function o(e,t){var o=n.call(this,e)||this;return t&&o.fromData(t),o}return i(o,n),o.prototype.fromData=function(e){n.prototype.fromData.call(this,e),this.options=e,this.createContent()},o.prototype.start=function(){this.item.type=t.spec.ItemType.tree,this.content.baseTransform.setValid(!0);var e=st(this);e&&this.content.animationManager.setSceneManager(e)},o.prototype.update=function(e){var t;null===(t=this.content)||void 0===t||t.tick(e)},o.prototype.onDestroy=function(){var e;null===(e=this.content)||void 0===e||e.dispose()},o.prototype.createContent=function(){if(this.options){var e=this.options.options.tree;this.content=new lt(e,this.item)}},o.prototype.getNodeTransform=function(e){if(void 0===this.content)return this.transform;var t=this.item.id+"^";if(0===e.indexOf(t)){var n=e.substring(t.length);return this.content.getNodeTransform(n)}return this.transform},o=a([t.effectsClass(e.ModelDataType.TreeComponent)],o)}(t.ItemBehaviour),ft=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="tree",t.order=2,t}return i(t,e),t}(t.AbstractPlugin);e.CameraGestureType=void 0,(ct=e.CameraGestureType||(e.CameraGestureType={}))[ct.none=0]="none",ct[ct.translate=1]="translate",ct[ct.rotate_focus=2]="rotate_focus",ct[ct.rotate_self=3]="rotate_self",ct[ct.scale=4]="scale";var ht,dt=function(){function n(t){this.composition=t,this.cameraTransform=new E,this.cameraCoordiante=new P,this.startParams={type:e.CameraGestureType.none,mouseEvent:!1,clientX:0,clientY:0,clientWidth:512,clientHeight:512,target:""}}return n.prototype.getItem=function(){var e,t=this;return null===(e=this.composition.items)||void 0===e?void 0:e.find((function(e){return e.id===t.getCurrentTarget()}))},n.prototype.getCurrentTarget=function(){return this.startParams.target},n.prototype.getCurrentType=function(){return this.startParams.type},n.prototype.onKeyEvent=function(n){var o,i,a,s;this.startParams.target!==n.cameraID&&(this.startParams.target=n.cameraID,this.startParams.type=e.CameraGestureType.translate);var c=this.getItem();if(void 0===c)return console.warn("can't find camera item ".concat(this.startParams.target)),this.composition.camera.getOptions();var l=this.composition.camera,u=new t.Transform(r(r({},l.getOptions()),{valid:!0})),f=(new E).fromEffectsTransform(u),h=(new P).fromPTransform(f),d=null!==(o=n.xAxis)&&void 0!==o?o:0,p=null!==(i=n.yAxis)&&void 0!==i?i:0,m=null!==(a=n.zAxis)&&void 0!==a?a:0,g=h.xAxis.clone().multiply(d);if(g.add(h.yAxis.clone().multiply(p)),g.add(h.zAxis.clone().multiply(m)),g.lengthSquared()<1e-5)return l.getOptions();g.normalize();var v=null!==(s=n.speed)&&void 0!==s?s:.1,y=f.getPosition();return y.add(g.clone().multiply(v)),this.setTransform(c,y),this.startParams.type===e.CameraGestureType.rotate_self&&(this.cameraTransform.setPosition(y),this.cameraCoordiante.origin=y),l.getOptions()},n.prototype.onXYMoveBegin=function(t,n,o,i,r){var a={type:e.CameraGestureType.translate,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,target:r};return this.startGesture(a)},n.prototype.onXYMoving=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.translate,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=o?o:.015};return this.moveGesture(r)},n.prototype.onXYMoveEnd=function(){this.endGesture()},n.prototype.onZMoveBegin=function(t,n,o,i,r){var a={type:e.CameraGestureType.scale,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,target:r};return this.startGesture(a)},n.prototype.onZMoving=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.scale,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=o?o:.015};return this.moveGesture(r)},n.prototype.onZMoveEnd=function(){this.endGesture()},n.prototype.onRotateBegin=function(t,n,o,i,r){var a={type:e.CameraGestureType.rotate_self,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,target:r};return this.startGesture(a)},n.prototype.onRotating=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.rotate_self,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=o?o:1.5};return this.moveGesture(r)},n.prototype.onRotateEnd=function(){this.endGesture()},n.prototype.onRotatePointBegin=function(t,n,o,i,r,a){var s={type:e.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:t,clientY:n,clientWidth:o,clientHeight:i,focusPoint:r,target:a};return this.startGesture(s)},n.prototype.onRotatingPoint=function(t,n,o){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,r={type:e.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,focusPoint:i.focusPoint,target:i.target,speed:null!=o?o:8};return this.moveGesture(r)},n.prototype.onRotatePointEnd=function(){this.endGesture()},n.prototype.moveTo=function(t,n){this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var o=this.getItem();void 0!==o?this.setPosition(o,n):console.warn("can't find camera item")},n.prototype.rotateTo=function(t,n){this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var o=this.getItem();void 0!==o?this.setQuaternion(o,n):console.warn("can't find camera item")},n.prototype.onFocusPoint=function(t,n,o){this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var i=this.getItem();if(void 0!==i){var r=null!=o?o:5,a=h.fromArray(n),s=(new E).fromEffectsTransform(i.transform),c=(new P).fromPTransform(s),l=h.fromArray(c.zAxis.toArray()).multiply(1).clone().multiply(r),u=a.clone().add(l);this.setTransform(i,u),this.startParams.target=""}else console.warn("can't find camera item")},n.prototype.getCameraTransform=function(){var e=this.composition.camera,n=new t.Transform(e.getOptions());return n.setValid(!0),n},n.prototype.startGesture=function(e){return this.startParams=e,this.updateCameraTransform(this.composition.camera.getOptions()),this.getItem()||console.warn("invalid target"),this.composition.camera.getOptions()},n.prototype.moveGesture=function(t){var n;if(this.getCurrentType()===t.type){var o=this.getItem();if(void 0===o)return console.warn("can't find camera item"),this.composition.camera.getOptions();var i=null!==(n=t.speed)&&void 0!==n?n:1.015,r=this.cameraCoordiante.xAxis,a=this.cameraCoordiante.yAxis,s=this.cameraCoordiante.zAxis,c=t.clientX-this.startParams.clientX,l=t.clientY-this.startParams.clientY;if(t.type===e.CameraGestureType.translate)(u=this.cameraTransform.getPosition().clone()).add(r.clone().multiply(-c*i)),u.add(a.clone().multiply(l*i)),o.transform.setPosition(u.x,u.y,u.z),this.setTransform(o,o.transform.position,o.transform.rotation);else if(t.type===e.CameraGestureType.scale){var u;(u=this.cameraTransform.getPosition().clone()).add(s.clone().multiply(l*i)),o.transform.setPosition(u.x,u.y,u.z),this.setTransform(o,o.transform.position,o.transform.rotation)}else if(t.type===e.CameraGestureType.rotate_self){var f=c/t.clientWidth,d=l/t.clientHeight,p=f*Math.PI*i*.5,g=d*Math.PI*i*.5,v=y.fromAxisAngle(h.Y,-p),_=y.fromAxisAngle(r,-g);v.multiply(_),v.multiply(this.cameraTransform.getRotation()),o.transform.setQuaternion(v.x,v.y,v.z,v.w),this.setTransform(o,o.transform.position,o.transform.rotation)}else if(t.type===e.CameraGestureType.rotate_focus){f=c/t.clientWidth,d=l/t.clientHeight,p=f*Math.PI*i,g=d*Math.PI*i,v=y.fromAxisAngle(h.Y,-p),_=y.fromAxisAngle(r,-g);v.multiply(_);var b=v.toMatrix4(new m),T=h.fromArray(t.focusPoint),x=this.cameraCoordiante.origin.clone().subtract(T);b.transformPoint(x);var C=x.add(T);v.multiply(this.cameraTransform.getRotation()),o.transform.setPosition(C.x,C.y,C.z),o.transform.setQuaternion(v.x,v.y,v.z,v.w),this.setTransform(o,C,o.transform.rotation)}else console.warn("not implement")}else console.warn("invalid move type");return this.composition.camera.getOptions()},n.prototype.setTransform=function(e,t,n){var o=e.getComponent(Pe);void 0!==o&&o.setTransform(t,n)},n.prototype.setPosition=function(e,t){var n;(n=e.transform).setPosition.apply(n,u([],l(t),!1));var o=e.getComponent(Pe);void 0!==o&&o.updateMainCamera()},n.prototype.setQuaternion=function(e,t){var n;(n=e.transform).setQuaternion.apply(n,u([],l(t),!1));var o=e.getComponent(Pe);void 0!==o&&o.updateMainCamera()},n.prototype.endGesture=function(){this.startParams.type=e.CameraGestureType.none,this.startParams.mouseEvent=!1,this.startParams.target=""},n.prototype.updateCameraTransform=function(e){var n=new t.Transform(e);n.setValid(!0),this.cameraTransform.fromEffectsTransform(n),this.cameraCoordiante.fromPTransform(this.cameraTransform)},n}(),pt=function(){function e(){}return e.getTransformFromMat4=function(e){var t=e.getTransform(),n=t.rotation.toEuler(new g);return{position:t.translation.toArray(),rotation:n.toArray(),scale:t.scale.toArray()}},e.getEffectsTransformFromMat4=function(e){var n=new t.Transform({valid:!0});return n.cloneFromMatrix(e),{position:n.position.toArray(),rotation:n.rotation.toArray(),scale:n.scale.toArray()}},e.getTransformFromTranslation=function(e){return{position:e.toArray()}},e.getTransformFromDirection=function(t){var n=h.fromArray([1,0,0]),o=t.clone().normalize(),i=n.clone().cross(o);if(i.length()<.01)return{};i.normalize();var r=o.dot(n),a=Math.acos(r),s=m.fromRotationAxis(i,a);return e.getTransformFromMat4(s)},e.getEffectsTransformFromDirection=function(t){var n=h.fromArray([0,0,1]),o=t.clone().normalize(),i=n.clone().cross(o);if(i.length()<.01)return{};i.normalize();var r=o.dot(n),a=Math.acos(r),s=m.fromRotationAxis(i,a);return e.getEffectsTransformFromMat4(s)},e.getTransformFromTransDir=function(t,n){var o=e.getTransformFromDirection(n);return o.position=t.toArray(),o},e.getEffectsTransformFromTransDir=function(t,n){var o=e.getEffectsTransformFromDirection(n);return o.position=t.toArray(),o},e.getEulerFromQuat=function(e){var t=new g,n=new y(e.x,e.y,e.z,e.w);return t.order=v.ZYX,t.setFromQuaternion(n),[t.x,t.y,t.z]},e.getQuatFromEuler=function(e){var t=new y;return t.setFromEuler(e),[t.x,t.y,t.z,t.w]},e.toPlayerColor3=function(t){return[e.scaleTo255(t[0]),e.scaleTo255(t[1]),e.scaleTo255(t[2])]},e.toPlayerColor4=function(t){return[e.scaleTo255(t[0]),e.scaleTo255(t[1]),e.scaleTo255(t[2]),e.scaleTo255(t[3])]},e.scaleTo255=function(e){var t=255*e;return Math.max(0,Math.min(t,255))},e.scaleTo1=function(e){var t=e/255;return Math.max(0,Math.min(t,1))},e}();var mt=function(){function n(){}return n.prototype.initial=function(e,t){this.engine=e,this._loaderOptions=null!=t?t:{}},n.prototype.processLight=function(e,t){var n=this;e.forEach((function(e){void 0===e.color?e.color=t?[255,255,255,255]:[1,1,1,1]:(e.color[0]=n.scaleColorVal(e.color[0],t),e.color[1]=n.scaleColorVal(e.color[1],t),e.color[2]=n.scaleColorVal(e.color[2],t),e.color[3]=n.scaleColorVal(e.color[3],t))}))},n.prototype.processCamera=function(e,t){var n=t?180/Math.PI:Math.PI/180;e.forEach((function(e){void 0!==e.perspective&&(e.perspective.yfov*=n)}))},n.prototype.processMaterial=function(e,t){var n=this;e.forEach((function(e){void 0===e.baseColorFactor?e.baseColorFactor=t?[255,255,255,255]:[1,1,1,1]:(e.baseColorFactor[0]=n.scaleColorVal(e.baseColorFactor[0],t),e.baseColorFactor[1]=n.scaleColorVal(e.baseColorFactor[1],t),e.baseColorFactor[2]=n.scaleColorVal(e.baseColorFactor[2],t),e.baseColorFactor[3]=n.scaleColorVal(e.baseColorFactor[3],t)),void 0===e.emissiveFactor?e.emissiveFactor=t?[255,255,255,255]:[1,1,1,1]:(e.emissiveFactor[0]=n.scaleColorVal(e.emissiveFactor[0],t),e.emissiveFactor[1]=n.scaleColorVal(e.emissiveFactor[1],t),e.emissiveFactor[2]=n.scaleColorVal(e.emissiveFactor[2],t),e.emissiveFactor[3]=n.scaleColorVal(e.emissiveFactor[3],t)),t&&void 0!==e.occlusionTexture&&void 0===e.occlusionTexture.strength&&(e.occlusionTexture.strength=n.isTiny3dMode()?0:1)}))},n.prototype.createTreeOptions=function(e){return{nodes:e.nodes.map((function(e,t){var n,o,i,r=e.children.map((function(e){if(void 0===e.nodeIndex)throw new Error("Undefined nodeIndex for child ".concat(e));return e.nodeIndex}));if(void 0!==e.matrix){if(16!==e.matrix.length)throw new Error("Invalid matrix length ".concat(e.matrix.length," for node ").concat(e));var a=m.fromArray(e.matrix).getTransform();n=a.translation.toArray(),o=a.rotation.toArray(),i=a.scale.toArray()}else void 0!==e.translation&&(n=e.translation),void 0!==e.rotation&&(o=e.rotation),void 0!==e.scale&&(i=e.scale);return e.nodeIndex=t,{name:e.name,transform:{position:n,quat:o,scale:i},children:r,id:"".concat(e.nodeIndex)}})),children:e.rootNodes.map((function(e){if(void 0===e.nodeIndex)throw new Error("Undefined nodeIndex for root ".concat(e));return e.nodeIndex})),animation:-1,animations:[]}},n.prototype.createAnimations=function(e){return e.map((function(e){var t=e.channels.map((function(e){return{input:e.input.array,output:e.output.array,node:e.target.node,path:e.target.path,interpolation:e.interpolation}}));return{name:e.name,tracks:t}}))},n.prototype.createGeometry=function(e,t){return new vt(this.engine,e,t).geometry},n.prototype.createMaterial=function(e){return new yt(e,[],this.isTiny3dMode()).material},n.prototype.createTexture2D=function(e,t,n){return ke.createTexture2D(this.engine,e,t,n,this.isTiny3dMode())},n.prototype.createTextureCube=function(e,t){var n=this;if(0==e.length)throw new Error("createTextureCube: Invalid cubeImages length ".concat(e));var o=[];return e.forEach((function(e){var t;if(6!=e.length)throw new Error("createTextureCube: cubeimage count should always be 6, ".concat(e));var i=[];e.forEach((function(e){if(void 0===e.imageData)throw new Error("createTextureCube: Invalid image data from ".concat(e));i.push({type:"buffer",data:e.imageData,mimeType:e.mimeType})})),n.isTiny3dMode()&&(t=l([i[5],i[4]],2),i[4]=t[0],i[5]=t[1]),o.push(i)})),1==o.length?ke.createTextureCubeFromBuffer(this.engine,o[0]):ke.createTextureCubeMipmapFromBuffer(this.engine,o,null!=t?t:Math.pow(2,o.length-1))},n.prototype.createSkybox=function(e){var t,n,o=this,i=null!==(t=e.reflectionsIntensity)&&void 0!==t?t:e.intensity,r=e.irradianceCoefficients,a=e.specularImages.map((function(e){var t,n=e.map((function(e){return{type:"buffer",data:e.imageData,mimeType:e.mimeType}}));return o.isTiny3dMode()&&(t=l([n[5],n[4]],2),n[4]=t[0],n[5]=t[1]),n})),s=a.length-1,c=null!==(n=e.specularImageSize)&&void 0!==n?n:Math.pow(2,s),u={type:"buffer",renderable:this.isSkyboxVis(),intensity:e.intensity,reflectionsIntensity:i,irradianceCoeffs:r,specularImage:a,specularMipCount:s,specularImageSize:c};return ot.createSkyboxOptions(this.engine,u)},n.prototype.createDefaultSkybox=function(t){if("NFT"!==t&&"FARM"!==t)throw new Error("Invalid skybox type name ".concat(t));var n="NFT"===t?e.PSkyboxType.NFT:e.PSkyboxType.FARM,o=ot.getSkyboxParams(n);return ot.createSkyboxOptions(this.engine,o)},n.prototype.scaleColorVal=function(e,t){return t?pt.scaleTo255(e):pt.scaleTo1(e)},n.prototype.scaleColorVec=function(e,t){var n=this;return e.map((function(e){return n.scaleColorVal(e,t)}))},n.prototype.loadScene=function(e){var n;return s(this,void 0,void 0,(function(){var o,i,r,a,s,l=this;return c(this,(function(c){switch(c.label){case 0:if(this._clear(),this._sceneOptions=e,this.engine=null===(n=e.effects.renderer)||void 0===n?void 0:n.engine,this._loaderOptions={compatibleMode:e.gltf.compatibleMode},"string"==typeof(o=e.gltf.resource)||o instanceof Uint8Array)throw new Error("Please load resource by GLTFTools at first");return this._gltfScene=o.scenes[0],this._gltfSkins=this._gltfScene.skins,this._gltfMeshs=o.meshes,this._gltfLights=this._gltfScene.lights,this._gltfCameras=this._gltfScene.cameras,this._gltfImages=o.images,this._gltfTextures=o.textures,this._gltfMaterials=o.materials,this._gltfAnimations=o.animations,this._gltfImageBasedLights=o.imageBasedLights,[4,this._preprocess()];case 1:return c.sent(),r="sceneTree",(i=[]).push(this._createItemTree(r,this._gltfScene)),void 0!==(a=this._createItemSkybox())&&i.push(a),this._gltfScene.nodes.forEach((function(e){if(void 0!==e.mesh){var t=l._createItemMesh(e,r);void 0!==t&&i.push(t)}if(void 0!==e.light){var n=l._createItemLight(e,r);void 0!==n&&i.push(n)}if(void 0!==e.camera){var o=l._createItemCamera(e,r);void 0!==o&&i.push(o)}})),s=new _,this._gltfScene.rootNodes.forEach((function(e){var n=new t.Transform({valid:!0});l._computeSceneAABB(e,n,s)})),[2,{source:this.getRemarkString(),items:i,sceneAABB:{min:s.min.toArray(),max:s.max.toArray()}}]}}))}))},n.prototype._preprocess=function(){return s(this,void 0,void 0,(function(){var t,n,o,i,r,a,s,u=this;return c(this,(function(c){switch(c.label){case 0:this.getTextureManager().initial(this._gltfImages,this._gltfTextures),t=0,c.label=1;case 1:return t<this._gltfMaterials.length?(n=this._gltfMaterials[t],[4,this.tryAddTexture2D(t,n.baseColorTexture,!0)]):[3,8];case 2:return c.sent(),_t.isUnlitMaterial(n)?[3,7]:[4,this.tryAddTexture2D(t,n.metallicRoughnessTexture,!1)];case 3:return c.sent(),[4,this.tryAddTexture2D(t,n.normalTexture,!1)];case 4:return c.sent(),[4,this.tryAddTexture2D(t,n.emissiveTexture,!1)];case 5:return c.sent(),[4,this.tryAddTexture2D(t,n.occlusionTexture,!1)];case 6:c.sent(),c.label=7;case 7:return t++,[3,1];case 8:return this._gltfImageBasedLights.length>0&&!this.ignoreSkybox()?(o=this._gltfImageBasedLights[0],this.isEnvironmentTest()&&o.specularImages.forEach((function(e){var t,n;u.isTiny3dMode()&&(t=l([e[5],e[4]],2),e[4]=t[0],e[5]=t[1]),n=l([e[3],e[2]],2),e[2]=n[0],e[3]=n[1]})),i=this,[4,this.createSkybox(o)]):[3,10];case 9:return i._skyboxOptions=c.sent(),[3,12];case 10:return void 0===(r=this.getSkyboxType())?[3,12]:(a=r===e.PSkyboxType.FARM?"FARM":"NFT",s=this,[4,this.createDefaultSkybox(a)]);case 11:s._skyboxOptions=c.sent(),c.label=12;case 12:return this._skyboxOptions&&(this._skyboxOptions.renderable=this.isSkyboxVis()),this._gltfData2PlayerData(this._gltfScene,this._gltfMaterials),[2]}}))}))},n.prototype.tryAddTexture2D=function(e,t,n){var o=this;if(void 0!==t&&void 0===this.getTexture2D(e,t,n,!0)){var i=t.index,r=this._gltfTextures[i],a=this._gltfImages[r.source];return ke.createTexture2D(this.engine,a,r,n,this.isTiny3dMode()).then((function(t){o.getTextureManager().addTexture(e,i,t,n)}))}},n.prototype.getTexture2D=function(e,t,n,o){if(void 0!==t){var i=t.index,r=this.getTextureManager().getTexture(e,i,n);return void 0===r&&!0!==o&&console.warn("Can't find texture for mat ".concat(e,", tex ").concat(JSON.stringify(t),", basecolor ").concat(n)),r}},n.prototype._gltfData2PlayerData=function(e,t){this.processCamera(e.cameras,!0),this.processLight(e.lights,!0),this.processMaterial(t,!0)},n.prototype._createItemTree=function(e,n){var o=this.createTreeOptions(n),i=this.createAnimations(this._gltfAnimations);return o.animations=i,o.animation=this.getPlayAnimationIndex(o),{id:e,name:n.name,duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:t.spec.ItemType.tree,content:{options:{tree:o}}}},n.prototype._createItemMesh=function(e,n){var o,i,r=this,a=e.mesh;if(void 0===a)throw new Error("Invalid mesh index in node ".concat(e));if(void 0!==e.skin){var s=this._gltfSkins[e.skin];i={name:s.name,joints:s.jointIndexList,skeleton:s.skeleton,inverseBindMatrices:s.inverseBindMatrices}}var c=this._gltfMeshs[a],l=c.primitives.map((function(e){var n=e.material,o=r._gltfMaterials[n],a=r.createGeometry(e,void 0!==i),s=r.createMaterial(o);return s.baseColorTexture=r.getTexture2D(n,o.baseColorTexture,!0),s.type===t.spec.MaterialType.pbr&&(s.metallicRoughnessTexture=r.getTexture2D(n,o.metallicRoughnessTexture,!1),s.normalTexture=r.getTexture2D(n,o.normalTexture,!1),s.emissiveTexture=r.getTexture2D(n,o.emissiveTexture,!1),s.occlusionTexture=r.getTexture2D(n,o.occlusionTexture,!1)),{geometry:a,material:s}})),u={parent:e.nodeIndex,skin:i,primitives:l,weights:c.weights},f=_t.createBoxFromGLTFBound(c.bounds),d=f.getSize(new h),p=f.getCenter(new h),m={behavior:t.spec.InteractBehavior.NOTIFY,type:t.spec.ModelBoundingType.box,size:[d.x,d.y,d.z],center:[p.x,p.y,p.z]};return{id:"mesh_ni".concat(null!==(o=e.nodeIndex)&&void 0!==o?o:0,"_mi").concat(a),parentId:"".concat(n,"^").concat(e.nodeIndex),name:c.name,duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:t.spec.ItemType.mesh,pluginName:"model",content:{options:u,interaction:m}}},n.prototype._createItemLight=function(e,n){var o,i,r=e.light;if(void 0!==r){var a=this._gltfLights[r],s=this.createLightOptions(a);return{id:"light_ni".concat(null!==(o=e.nodeIndex)&&void 0!==o?o:0,"_li").concat(r),parentId:"".concat(n,"^").concat(e.nodeIndex),name:null!==(i=a.name)&&void 0!==i?i:"light",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:t.spec.ItemType.light,pluginName:"model",content:{options:s}}}},n.prototype._createItemCamera=function(e,t){var n,o,i=e.camera;if(void 0!==i){var r=this._gltfCameras[i],a=this.createCameraOptions(r);if(void 0!==a)return{id:"camera_ni".concat(null!==(n=e.nodeIndex)&&void 0!==n?n:0,"_ci").concat(i),parentId:"".concat(t,"^").concat(e.nodeIndex),name:null!==(o=r.name)&&void 0!==o?o:"camera",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:"camera",pluginName:"model",content:{options:a}}}},n.prototype._createItemSkybox=function(){if(void 0!==this._skyboxOptions)return{id:"skybox_0",name:"skybox",duration:this.getItemDuration(),endBehavior:this.getItemEndBehavior(),type:"skybox",pluginName:"model",content:{options:this._skyboxOptions}}},n.prototype._computeSceneAABB=function(e,n,o){var i=this,r={};if(e.matrix){var a=m.fromArray(e.matrix).getTransform();r.position=a.translation.toArray(),r.quat=a.rotation.toArray(),r.scale=a.scale.toArray()}else e.translation&&(r.position=e.translation),e.rotation&&(r.quat=e.rotation),e.scale&&(r.scale=e.scale);var s=new t.Transform(r,n);if(s.setValid(!0),void 0!==e.mesh){var c=this._gltfMeshs[e.mesh],l=_t.createBoxFromGLTFBound(c.bounds);l.applyMatrix4(s.getWorldMatrix()),o.union(l)}e.children.forEach((function(e){i._computeSceneAABB(e,s,o)}))},n.prototype.createLightOptions=function(e){return Ge.createLightOptions(e)},n.prototype.createCameraOptions=function(e){return Ge.createCameraOptions(e)},n.prototype._clear=function(){this._textureManager&&(this._textureManager.dispose(),this._textureManager=void 0),this._textureManager=new gt(this)},n.prototype.getPlayAnimationIndex=function(e){var t=e.animations;if(void 0===t||t.length<=0)return-1;if(this.isPlayAllAnimation())return-88888888;var n=this._sceneOptions.effects.playAnimation;if(void 0===n)return-1;if("number"==typeof n)return n>=0&&n<t.length?n:-1;var o=-1;return t.forEach((function(e,t){e.name===n&&(o=t)})),o},n.prototype.isPlayAnimation=function(){return void 0!==this._sceneOptions.effects.playAnimation},n.prototype.isPlayAllAnimation=function(){return!0===this._sceneOptions.effects.playAllAnimation},n.prototype.getRemarkString=function(){var e=this._sceneOptions.gltf.remark;return void 0===e?"Unknown":"string"==typeof e?e:"BinaryBuffer"},n.prototype.isTiny3dMode=function(){return"tiny3d"===this._loaderOptions.compatibleMode},n.prototype.getTextureManager=function(){return this._textureManager},n.prototype.getItemDuration=function(){var e;return null!==(e=this._sceneOptions.effects.duration)&&void 0!==e?e:9999},n.prototype.getItemEndBehavior=function(){var e;return null!==(e=this._sceneOptions.effects.endBehavior)&&void 0!==e?e:t.spec.ItemEndBehavior.loop},n.prototype.getSkyboxType=function(){switch(this._sceneOptions.gltf.skyboxType){case"NFT":return e.PSkyboxType.NFT;case"FARM":return e.PSkyboxType.FARM}},n.prototype.isSkyboxVis=function(){return!0===this._sceneOptions.gltf.skyboxVis},n.prototype.ignoreSkybox=function(){return!0===this._sceneOptions.gltf.ignoreSkybox},n.prototype.isEnvironmentTest=function(){return"string"==typeof this._sceneOptions.gltf.remark&&this._sceneOptions.gltf.remark.includes("EnvironmentTest")},n}(),gt=function(){function e(e){this._owner=e,this._gltfImages=[],this._gltfTextures=[],this._textureMap=new Map}return e.prototype.initial=function(e,t){this._gltfImages=e,this._gltfTextures=t,this._textureMap.clear()},e.prototype.dispose=function(){this._textureMap.clear()},e.prototype.addTexture=function(e,t,n,o){var i=o?1e5*e+t:t;this._textureMap.set(i,n)},e.prototype.getTexture=function(e,t,n){var o=n?1e5*e+t:t;return this._textureMap.get(o)},e}(),vt=function(){function e(e,t,n){this.engine=e,this.gltfGeometry=t,this.hasSkinAnimation=n}return Object.defineProperty(e.prototype,"geometry",{get:function(){var e=this,n={};if(!this.hasPosition)throw new Error("Position attribute missing");var o=this.positionAttrib;(n.a_Position=this._getBufferAttrib(o),this.hasNormal)&&(void 0!==(o=this.normalAttrib)&&(n.a_Normal=this._getBufferAttrib(o)));this.hasTangent&&(void 0!==(o=this.tangentAttrib)&&(n.a_Tangent=this._getBufferAttrib(o)));if(this.texCoordList.forEach((function(t){var o=e.texCoordAttrib(t),i="a_UV".concat(t+1);n[i]=e._getBufferAttrib(o)})),this.hasSkinAnimation){var i=this.jointAttribute;void 0!==i&&(n.a_Joint1=this._getBufferAttrib(i));var r=this.weightAttribute;void 0!==r&&(n.a_Weight1=this._getBufferAttrib(r))}for(var a=0;a<8;a++){var s=this.getTargetPosition(a);void 0!==s&&(n["a_Target_Position".concat(a)]=this._getBufferAttrib(s));var c=this.getTargetNormal(a);void 0!==c&&(n["a_Target_Normal".concat(a)]=this._getBufferAttrib(c));var l=this.getTargetTangent(a);void 0!==l&&(n["a_Target_Tangent".concat(a)]=this._getBufferAttrib(l))}var u=this.indexArray;return void 0!==u?t.Geometry.create(this.engine,{attributes:n,indices:{data:u},drawStart:0,drawCount:u.length,mode:t.glContext.TRIANGLES}):t.Geometry.create(this.engine,{attributes:n,drawStart:0,drawCount:this.positionAttrib.array.length/3,mode:t.glContext.TRIANGLES})},enumerable:!1,configurable:!0}),e.prototype._getBufferAttrib=function(e){return{type:e.type,size:e.itemSize,data:e.array,normalize:e.normalized}},Object.defineProperty(e.prototype,"positionAttrib",{get:function(){return this.gltfGeometry.getPosition()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalAttrib",{get:function(){return this.gltfGeometry.getNormal()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tangentAttrib",{get:function(){return this.gltfGeometry.getTangent()},enumerable:!1,configurable:!0}),e.prototype.texCoordAttrib=function(e){return this.gltfGeometry.getTexCoord(e)},Object.defineProperty(e.prototype,"jointAttribute",{get:function(){return this.gltfGeometry.getJoints(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"weightAttribute",{get:function(){return this.gltfGeometry.getWeights(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPosition",{get:function(){return void 0!==this.positionAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNormal",{get:function(){return void 0!==this.normalAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasTangent",{get:function(){return void 0!==this.tangentAttrib},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasTexCoord",{get:function(){return this.texCoordCount>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texCoordCount",{get:function(){for(var e=0;e<10;e++)if(void 0===this.texCoordAttrib(e))return e;return 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasJointAttribute",{get:function(){return void 0!==this.jointAttribute},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasWeightAttribute",{get:function(){return void 0!==this.weightAttribute},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indexArray",{get:function(){if(void 0!==this.gltfGeometry.indices)switch(this.gltfGeometry.indices.type){case WebGLRenderingContext.UNSIGNED_INT:case WebGLRenderingContext.UNSIGNED_SHORT:case WebGLRenderingContext.UNSIGNED_BYTE:return this.gltfGeometry.indices.array}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"indexCount",{get:function(){return void 0!==this.gltfGeometry.indices?this.gltfGeometry.indices.array.length:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texCoordList",{get:function(){for(var e=[],t=0;t<10&&void 0!==this.texCoordAttrib(t);t++)e.push(t);return e},enumerable:!1,configurable:!0}),e.prototype.getTargetPosition=function(e){return this.gltfGeometry.getAttribute("POSITION".concat(e))},e.prototype.getTargetNormal=function(e){return this.gltfGeometry.getAttribute("NORMAL".concat(e))},e.prototype.getTargetTangent=function(e){return this.gltfGeometry.getAttribute("TANGENT".concat(e))},e}(),yt=function(){function e(e,t,n){this.gltfMaterial=e,this.textures=t,this.tiny3dMode=n}return Object.defineProperty(e.prototype,"material",{get:function(){var e,n,o,i=this.gltfMaterial,r=_t.isUnlitMaterial(i),a=t.spec.MaterialBlending.opaque;switch(i.alphaMode){case"OPAQUE":a=t.spec.MaterialBlending.opaque;break;case"MASK":a=t.spec.MaterialBlending.masked;break;case"BLEND":a=t.spec.MaterialBlending.translucent}var s=i.doubleSided?t.spec.SideMode.DOUBLE:t.spec.SideMode.FRONT,c=null!==(e=i.alphaCutOff)&&void 0!==e?e:.5,l=i.name;return r?{name:l,type:t.spec.MaterialType.unlit,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,depthMask:null===(n=i.extras)||void 0===n?void 0:n.depthMask,blending:a,alphaCutOff:c,side:s}:{name:l,type:t.spec.MaterialType.pbr,baseColorTexture:this.baseColorTextureObj,baseColorTextureCoordinate:this.baseColorTextureCoord,baseColorTextureTransform:this.baseColorTextureTransfrom,baseColorFactor:this.baseColorFactor,useSpecularAA:this.getSpecularAA(),metallicRoughnessTexture:this.metallicRoughnessTextureObj,metallicRoughnessTextureCoordinate:this.metallicRoughnessTextureCoord,metallicRoughnessTextureTransform:this.metallicRoughnessTextureTransfrom,metallicFactor:this.metalicFactor,roughnessFactor:this.roughnessFactor,normalTexture:this.normalTextureObj,normalTextureCoordinate:this.normalTextureCoord,normalTextureTransform:this.normalTextureTransfrom,normalTextureScale:this.normalTextureScale,occlusionTexture:this.occlusionTextureObj,occlusionTextureCoordinate:this.occlusionTextureCoord,occlusionTextureTransform:this.occlusionTextureTransfrom,occlusionTextureStrength:this.occlusionTextureStrength,emissiveTexture:this.emissiveTextureObj,emissiveTextureCoordinate:this.emissiveTextureCoord,emissiveTextureTransform:this.emissiveTextureTransfrom,emissiveFactor:this.emissiveFactor,emissiveIntensity:1,depthMask:null===(o=i.extras)||void 0===o?void 0:o.depthMask,blending:a,alphaCutOff:c,side:s,enableShadow:!1}},enumerable:!1,configurable:!0}),e.prototype.getTextureObject=function(e){if(!(e<0||e>=this.textures.length))return this.textures[e]},e.prototype.getTextureObj=function(e){return e?this.getTextureObject(e.index):void 0},e.prototype.getTextureCoord=function(e){return e?e.texCoord:void 0},e.prototype.getTextureTransform=function(e){var t,n=null===(t=null==e?void 0:e.extensions)||void 0===t?void 0:t.KHR_texture_transform;if(void 0!==n&&(void 0!==n.offset||void 0!==n.rotation||void 0!==n.scale))return{offset:n.offset,rotation:n.rotation,scale:n.scale}},Object.defineProperty(e.prototype,"baseColorTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.baseColorTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metallicRoughnessTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metallicRoughnessTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metallicRoughnessTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.metallicRoughnessTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.normalTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.occlusionTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveTextureObj",{get:function(){return this.getTextureObj(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveTextureCoord",{get:function(){return this.getTextureCoord(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveTextureTransfrom",{get:function(){return this.getTextureTransform(this.gltfMaterial.emissiveTexture)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasEmissive",{get:function(){var e=this.emissiveFactor;return e[0]+e[1]+e[2]>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorFactor",{get:function(){var e=this.gltfMaterial.baseColorFactor;return void 0===e||4!=e.length?[1,1,1,1]:[e[0],e[1],e[2],e[3]]},enumerable:!1,configurable:!0}),e.prototype.getSpecularAA=function(){var e;return null===(e=this.gltfMaterial.extras)||void 0===e?void 0:e.useSpecularAA},Object.defineProperty(e.prototype,"metalicFactor",{get:function(){var e;return null!==(e=this.gltfMaterial.metallicFactor)&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"roughnessFactor",{get:function(){var e;return null!==(e=this.gltfMaterial.roughnessFactor)&&void 0!==e?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalTextureScale",{get:function(){var e,t;return null!==(t=null===(e=this.gltfMaterial.normalTexture)||void 0===e?void 0:e.scale)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"occlusionTextureStrength",{get:function(){var e,t;return null!==(t=null===(e=this.gltfMaterial.occlusionTexture)||void 0===e?void 0:e.strength)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissiveFactor",{get:function(){var e=this.gltfMaterial.emissiveFactor;return void 0===e||4!=e.length?[0,0,0,1]:[e[0],e[1],e[2],1]},enumerable:!1,configurable:!0}),e}(),_t=function(){function e(){}return e.isUnlitMaterial=function(e){var t;return void 0!==(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_unlit)},e.createBoxFromGLTFBound=function(e){var t=h.fromArray(e.box.min),n=h.fromArray(e.box.max);return new _(t,n)},e}();t.registerPlugin("tree",ft,t.VFXItem,!0),t.registerPlugin("model",rt,t.VFXItem);var bt="2.0.0-alpha.2";t.logger.info("plugin model version: "+bt),e.BoxMesh=ie,e.CameraGestureHandlerImp=dt,e.CheckerHelper=Je,e.CompositionCache=it,e.CompositionHitTest=function(e,t,n){var o=e.hitTest(t,n,!0),i=e.getHitTestRay(t,n);if(o.length<=0)return[];var r=i.origin,a=i.direction,s=o.map((function(e,t){for(var n=e.position,o=[0,0,0],i=0;i<3;i++)o[i]=(n.getElement(i)-r.getElement(i))/a.getElement(i);return[t,Math.max.apply(Math,u([],l(o),!1))]}));return s.sort((function(e,t){return(e[1]>=0?e[1]:e[1]+1e9)-(t[1]>=0?t[1]:t[1]+1e9)})),s.map((function(e){return o[e[0]]}))},e.FBOOptions=oe,e.Float16ArrayWrapper=Ye,e.GeometryBoxProxy=We,e.HitTestingProxy=Xe,e.HookOGLFunc=function(e){console.info("HookOGLFunc "+Object.getPrototypeOf(e));var t=0;for(var n in Object.getPrototypeOf(e))"getError"!==n&&"function"==typeof e[n]&&(++t,e[n+xe]=e[n],e[n]=Se(e,n));console.info("HookCount "+t),function(e){for(var t in Object.getPrototypeOf(e))"number"==typeof e[t]&&Ce.set(e[t],t)}(e)},e.InterpolationSampler=D,e.LoaderHelper=pt,e.LoaderImpl=mt,e.MeshHelper=Ve,e.ModelCameraComponent=Pe,e.ModelLightComponent=Ee,e.ModelMeshComponent=Ae,e.ModelPlugin=rt,e.ModelPluginComponent=at,e.ModelSkyboxComponent=Ie,e.ModelTreeComponent=ut,e.ModelTreeItem=lt,e.ModelTreePlugin=ft,e.PAnimTexture=q,e.PAnimTrack=Y,e.PAnimation=K,e.PAnimationManager=Q,e.PCamera=$,e.PCameraManager=ee,e.PCoordinate=P,e.PEntity=L,e.PGeometry=se,e.PGlobalState=w,e.PLight=te,e.PLightManager=ne,e.PMaterialBase=Ke,e.PMaterialPBR=Ze,e.PMaterialSkyboxFilter=nt,e.PMaterialUnlit=Qe,e.PMesh=re,e.PMorph=X,e.PObject=N,e.PPrimitive=ae,e.PSceneManager=ue,e.PShaderManager=Te,e.PSkin=W,e.PSkybox=tt,e.PSkyboxCreator=ot,e.PTransform=E,e.PluginHelper=Ge,e.RayBoxTesting=Oe,e.RayIntersectsBoxWithRotation=we,e.RayTriangleTesting=Ue,e.ToggleItemBounding=function(e,t){var o;null===(o=e.items)||void 0===o||o.forEach((function(e){if(e.type===n){var o=e.getComponent(Ae);if(o){var i=o.content;e.id===t?i.visBoundingBox=!0:i.visBoundingBox=!1}}}))},e.TwoStatesSet=le,e.VFX_ITEM_TYPE_3D=n,e.VertexAttribBuffer=ze,e.WebGLHelper=ke,e.WebHelper=je,e.createAnimationSampler=j,e.createInternalMaterial=function(e){return{}},e.createPluginMaterial=$e,e.getDefaultEffectsGLTFLoader=function(e,t){return ht||(ht=new mt),ht.initial(e,t),ht},e.getDiffuseOnlyShaderCode=function(e){return{vertexShaderCode:_e({hasNormals:!0}),fragmentShaderCode:"\n #version 100\n precision highp float;\n varying vec3 v_Normal;\n void main(){\n vec3 lightDir = normalize(vec3(1, 1, 1));\n gl_FragColor = vec4(max(0.0, dot(v_Normal, lightDir)) * 0.8);\n }\n "}},e.getGaussianBlurShaderCodeV1=function(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform vec2 u_BlurScale;\n uniform sampler2D u_FilterSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(-3.0) * u_BlurScale.xy)) * (1.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(-2.0) * u_BlurScale.xy)) * (6.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(-1.0) * u_BlurScale.xy)) * (15.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+0.0) * u_BlurScale.xy)) * (20.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+1.0) * u_BlurScale.xy)) * (15.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+2.0) * u_BlurScale.xy)) * (6.0/64.0);\n color += texture2D(u_FilterSampler, v_UVCoord1 + (vec2(+3.0) * u_BlurScale.xy)) * (1.0/64.0);\n gl_FragColor = color;\n }\n "}},e.getGaussianBlurShaderCodeV2=ye,e.getKawaseBlurShaderCode=function(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform float u_Offset;\n uniform vec2 u_TextureSizeInv;\n uniform sampler2D u_TexturSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 color = vec4(0.0);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2(-u_Offset-0.5,-u_Offset-0.5) * u_TextureSizeInv);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2(-u_Offset-0.5, u_Offset+0.5) * u_TextureSizeInv);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2( u_Offset+0.5,-u_Offset-0.5) * u_TextureSizeInv);\n color += texture2D(u_TexturSampler, v_UVCoord1 + vec2( u_Offset+0.5, u_Offset+0.5) * u_TextureSizeInv);\n gl_FragColor = color * 0.25;\n }\n "}},e.getNormalVisShaderCode=ge,e.getPBRPassShaderCode=de,e.getPMeshList=function(t){var o=[],i=t.getCompositions()[0];return null==i||i.items.forEach((function(t){if(t.type===n){var i=t.getComponent(Ae);(null==i?void 0:i.content.type)===e.PObjectType.mesh&&o.push(i.content)}})),o},e.getQuadFilterShaderCode=function(e){return{vertexShaderCode:"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ",fragmentShaderCode:"\n #version 100\n precision highp float;\n uniform sampler2D u_ColorSampler;\n\n varying vec2 v_UVCoord1;\n void main(){\n gl_FragColor = texture2D(u_ColorSampler, v_UVCoord1);\n }\n "}},e.getRendererGPUInfo=function(e){var t=e.gpuCapability;return JSON.stringify(t,void 0,2)},e.getSceneManager=st,e.getShadowPassShaderCode=pe,e.getSimpleFilterShaderCode=ve,e.getSkyBoxShaderCode=me,e.getTransparecyBaseShader=function(e){return e?_e({hasNormals:!0}):"\n #version 100\n #extension GL_EXT_draw_buffers: require\n\n precision highp float;\n uniform vec4 u_BaseColorFactor;\n\n #ifdef HAS_UVS\n uniform sampler2D u_BaseColorSampler;\n varying vec2 v_UVCoord1;\n #endif\n\n varying vec3 v_Normal;\n\n float weight(float z, float a) {\n return clamp(pow(min(1.0, a * 10.0) + 0.01, 3.0) * 1e8 * pow(1.0 - z * 0.9, 3.0), 1e-2, 3e3);\n }\n\n void main() {\n vec4 color = u_BaseColorFactor;\n\n #ifdef HAS_UVS\n color *= texture2D(u_BaseColorSampler, v_UVCoord1);\n #endif\n\n color.rgb *= color.a * dot(normalize(v_Normal), normalize(vec3(0, 1, 3))) * 5.0;\n float w = weight(gl_FragCoord.z, color.a);\n gl_FragData[0] = vec4(color.rgb * w, color.a);\n gl_FragData[1] = vec4(color.a * w);\n }\n "},e.getTransparecyFilterShader=function(e){return e?"\n #version 100\n precision highp float;\n attribute vec3 a_Position;\n attribute vec2 a_UV1;\n\n varying vec2 v_UVCoord1;\n void main(){\n v_UVCoord1 = a_UV1;\n gl_Position = vec4(a_Position.xy, 0.0, 1.0);\n }\n ":"\n #version 100\n precision highp float;\n uniform sampler2D u_AccumColorSampler;\n uniform sampler2D u_AccumAlphaSampler;\n\n varying vec2 v_UVCoord1;\n void main() {\n vec4 accumColor = texture2D(u_AccumColorSampler, v_UVCoord1);\n vec4 accumAlpha = texture2D(u_AccumAlphaSampler, v_UVCoord1);\n float finalAlpha = 1.0 - accumColor.a;\n vec3 finalColor = accumColor.rgb / clamp(accumAlpha.r, 0.001, 50000.0);\n gl_FragColor = vec4(finalColor, finalAlpha);\n }\n "},e.setDefaultEffectsGLTFLoader=function(e){ht=e},e.version=bt,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
6
|
+
* Version: v2.0.0-alpha.21
|
|
7
|
+
*/function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ge=e.ge||{},e.ge.modelPlugin={}),e.ge)}(this,function(e,t){"use strict";var n,r,i,o,a,s,l,c,u,h,f,d,m,p,g,v,y,T=function(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)}(t),_="PluginModel";function b(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function C(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function a(e){b(o,r,i,a,s,"next",e)}function s(e){b(o,r,i,a,s,"throw",e)}a(void 0)})}}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function x(e,t){if("function"!=typeof t&&null!==t)throw 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&&S(e,t)}function M(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):M(e,t)}function I(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 A(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)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 a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],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 E(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 N(e,t,n){return t&&E(e.prototype,t),n&&E(e,n),e}function w(){return(w=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}).apply(this,arguments)}"function"==typeof SuppressedError&&SuppressedError;var P=t.math.Vector2,L=t.math.Vector3,R=t.math.Vector4,O=t.math.Matrix3,D=t.math.Matrix4,F=t.math.Color,U=t.math.Euler,B=t.math.EulerOrder,k=t.math.Quaternion,V=t.math.Box3,G=t.math.Sphere,z=t.math.Ray,H=t.math.DEG2RAD;e.PObjectType=void 0,(n=e.PObjectType||(e.PObjectType={}))[n.none=0]="none",n[n.mesh=1]="mesh",n[n.texture=2]="texture",n[n.material=3]="material",n[n.light=4]="light",n[n.camera=5]="camera",n[n.skybox=6]="skybox",n[n.skin=7]="skin",n[n.morph=8]="morph",n[n.skeleton=9]="skeleton",n[n.animation=10]="animation",n[n.animationManager=11]="animationManager",n[n.reference=12]="reference",e.PLightType=void 0,(r=e.PLightType||(e.PLightType={}))[r.directional=0]="directional",r[r.point=1]="point",r[r.spot=2]="spot",r[r.ambient=3]="ambient",e.PTextureType=void 0,(i=e.PTextureType||(e.PTextureType={}))[i.none=0]="none",i[i.t2d=1]="t2d",i[i.t3d=2]="t3d",i[i.cube=3]="cube",e.PMaterialType=void 0,(o=e.PMaterialType||(e.PMaterialType={}))[o.none=0]="none",o[o.unlit=1]="unlit",o[o.pbr=2]="pbr",o[o.normalVis=3]="normalVis",o[o.simpleFilter=4]="simpleFilter",o[o.shadowBase=5]="shadowBase",o[o.shadowFilter=6]="shadowFilter",o[o.skyboxFilter=7]="skyboxFilter",e.PBlendMode=void 0,(a=e.PBlendMode||(e.PBlendMode={}))[a.opaque=0]="opaque",a[a.masked=1]="masked",a[a.translucent=2]="translucent",a[a.additive=3]="additive",e.PFaceSideMode=void 0,(s=e.PFaceSideMode||(e.PFaceSideMode={}))[s.both=0]="both",s[s.front=1]="front",s[s.back=2]="back",e.PShadowType=void 0,(l=e.PShadowType||(e.PShadowType={}))[l.none=0]="none",l[l.standard=1]="standard",l[l.variance=2]="variance",l[l.expVariance=3]="expVariance";var j="pbr00000000000000000000000000000",W="unlit000000000000000000000000000",X=function(){function e(){this.translation=new L(0,0,0),this.rotation=new k(0,0,0,1),this.scale=new L(1,1,1)}var n=e.prototype;return n.fromMatrix4=function(e){return this.setMatrix(e),this},n.fromEffectsTransform=function(e){if(M(e,t.Transform))this.setMatrix(e.getWorldMatrix());else{var n=new t.Transform(w({},e,{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){M(e,L)?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){M(e,L)?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){M(e,k)?this.rotation.set(e.x,e.y,e.z,e.w):M(e,U)?this.rotation.setFromEuler(e):M(e,L)?this.rotation.setFromEuler(new U(e.x,e.y,e.z,B.ZYX)):4===e.length?this.rotation.set(e[0],e[1],e[2],e[3]):this.rotation.setFromEuler(new U(e[0],e[1],e[2],B.ZYX))},n.getScale=function(){return this.scale},n.setScale=function(e){M(e,L)?this.scale.set(e.x,e.y,e.z):this.scale.set(e[0],e[1],e[2])},n.getMatrix=function(){return new D().compose(this.getTranslation(),this.getRotation(),this.getScale())},n.setMatrix=function(e){if(M(e,D)){var t=e.getTransform();this.setTranslation(t.translation),this.setRotation(t.rotation),this.setScale(t.scale)}else{var n=D.fromArray(e).getTransform();this.setTranslation(n.translation),this.setRotation(n.rotation),this.setScale(n.scale)}},e}(),J=function(){function e(){this.origin=new L(0,0,0),this.xAxis=new L(1,0,0),this.yAxis=new L(0,1,0),this.zAxis=new L(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 D);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}(),q=function(){function e(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=t.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16}var n=e.prototype;return n.reset=function(){this.isWebGL2=!1,this.shaderShared=!0,this.runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,this.compatibleMode="gltf",this.visBoundingBox=!1,this.renderMode3D=t.spec.RenderMode3D.none,this.renderMode3DUVGridSize=1/16},n.hasRenderMode3D=function(){return this.renderMode3D!==t.spec.RenderMode3D.none},e.getInstance=function(){return this.instance||(this.instance=new this)},N(e,[{key:"isEditorEnv",get:function(){return this.runtimeEnv===t.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}}]),e}(),Y=1,Z=function(){function t(){this.name="Unnamed Object",this.type=e.PObjectType.none}var n=t.prototype;return n.dispose=function(){},n.isNone=function(){return this.type===e.PObjectType.none},n.isValid=function(){return this.type!==e.PObjectType.none},n.genName=function(e){return e+"_@"+Y++},t}(),K=function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._visible=!1,t._transform=new X,t.deleted=!1,t}x(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},N(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){M(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 J;return e.fromPTransform(this._transform),e}}]),t}(Z);function Q(e,t){var n,r,i=e.attributes,o=w({},e);return o.indices?(o.indices=w({},o.indices),o.indices.data&&(o.indices.data=ee(t,null==(n=e.indices)?void 0:n.data))):o.index&&(o.indices=w({},o.index),o.indices.data&&(o.indices.data=ee(t,null==(r=e.index)?void 0:r.data))),Object.keys(i).forEach(function(e){var n=i[e],r=n.data;o.attributes[e]=w({},n),r&&(o.attributes[e].data=ee(t,r))}),o}var $={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,f32:Float32Array,i32:Int32Array,u32:Uint32Array};function ee(e,n){if(2!=n.length||n[0]!==t.spec.ValueType.BINARY||!M(n[1],Array))return n;var r=n[1],i=r[0],o=r[1],a=r[2],s=r[3];if(!s)return e[i].slice(o,a);var l=$[s]||Uint8Array;return new l(e[i],o,a/l.BYTES_PER_ELEMENT)}function et(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function en(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 et(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return et(e,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 TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var er=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,n=this.time,r=this.cachedIndex,i=n[r],o=n[r-1];e:{t:{n:{r:if(!(e<i)){for(var a=r+2;;){if(void 0===i){if(e<o)break r;return r=n.length,this.cachedIndex=r,this.copySampleValue(r-1)}if(r===a)break;if(o=i,e<(i=n[++r]))break t}t=n.length;break n}if(!(e>=o)){var s=n[1];e<s&&(r=2,o=s);for(var l=r-2;;){if(void 0===o)return this.cachedIndex=0,this.copySampleValue(0);if(r===l)break;if(i=o,e>=(o=n[--r-1]))break t}t=r,r=0;break n}break e}for(;r<t;){var c=r+t>>>1;e<n[c]?t=c:r=c+1}if(i=n[r],void 0===(o=n[r-1]))return this.cachedIndex=0,this.copySampleValue(0);if(void 0===i)return r=n.length,this.cachedIndex=r,this.copySampleValue(r-1)}this.cachedIndex=r,this.intervalChanged(r,o,i)}return this.interpolate(r,o,e,i)},t.dispose=function(){this.time=void 0,this.data=void 0},t.copySampleValue=function(e){for(var t=this.data,n=this.componentCount,r=e*n,i=new Float32Array(n),o=0;o!==n;++o)i[o]=t[r+o];return i},e}(),ei=function(e){function t(t,n,r){return e.call(this,t,n,r)}x(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}(er),eo=function(e){function t(t,n,r){return e.call(this,t,n,r)}x(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}(er),ea=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],m=i[o+3];if(0===a){e[t+0]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u;return}if(1===a){e[t+0]=h,e[t+1]=f,e[t+2]=d,e[t+3]=m;return}if(u!==m||s!==h||l!==f||c!==d){var p=1-a,g=s*h+l*f+c*d+u*m,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var T=Math.sqrt(y),_=Math.atan2(T,g*v);p=Math.sin(p*_)/T,a=Math.sin(a*_)/T}var b=a*v;if(s=s*p+h*b,l=l*p+f*b,c=c*p+d*b,u=u*p+m*b,p===1-a){var C=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=C,l*=C,c*=C,u*=C}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u},e}(),es=function(e){function t(t,n,r){return e.call(this,t,n,r)}x(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)ea.slerpFlat(c,0,o,l-a,o,l,s);return c},t}(er);function el(e,t,n,r,i){switch(e){case"LINEAR":if("rotation"===i)return new es(t,n,r);return new ei(t,n,r);case"STEP":return new eo(t,n,r);default:return new ei(t,n,r)}}e.TextureDataMode=void 0,(c=e.TextureDataMode||(e.TextureDataMode={}))[c.none=0]="none",c[c.float=1]="float",c[c.half_float=2]="half_float";var ec=function(t){function n(){var e;return e=t.apply(this,arguments)||this,e.skeleton=0,e.jointItem=[],e.inverseBindMatrices=[],e.animationMatrices=[],e.textureDataMode=0,e}x(n,t);var r=n.prototype;return r.create=function(t,n,r){this.name=null!=(i=t.rootBoneName)?i:"Unnamed skin",this.type=e.PObjectType.skin,this.rootBoneItem=r,this.skeleton=-1,this.jointItem=this.getJointItems(t,r),this.animationMatrices=[],this.inverseBindMatrices=[],this.textureDataMode=this.getTextureDataMode(this.getJointCount(),n);var i,o=t.inverseBindMatrices;if(void 0!==o&&o.length>0){if(o.length%16!=0||o.length!==16*this.jointItem.length)throw 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=D.fromArray(o,16*s);this.inverseBindMatrices.push(l)}}},r.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."))},r.computeMeshAnimMatrices=function(e,t,n){var r=e.clone().invert(),i=new D;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})})},r.updateParentItem=function(e){this.rootBoneItem=e},r.getJointCount=function(){return this.jointItem.length},r.isTextureDataMode=function(){return 0!==this.textureDataMode},r.dispose=function(){this.rootBoneItem=void 0,this.jointItem=[],this.inverseBindMatrices=[],this.animationMatrices=[]},r.getTextureDataMode=function(e,t){var n=t.gpuCapability.detail;if(!(e>Math.floor((n.maxVertexUniforms-25)/8)))return 0;if(n.floatTexture)return 1;if(n.halfFloatTexture)return 2;throw Error("Too many joint count "+e+", half float texture not support.")},r.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 Error("Can't find node of bone name "+e+".");i.push(t)}),i},r.genNodeName=function(e){var t={},n=[];t[""]=e;for(var r,i=en(e.children);!(r=i()).done;){var o=r.value;this.genNodeNameDFS(o,n,t)}return t},r.genNodeNameDFS=function(e,t,n){t.push(e.name),n[t.join("/")]=e;for(var r,i=en(e.children);!(r=i()).done;){var o=r.value;this.genNodeNameDFS(o,t,n)}t.pop()},n}(Z),eu=function(t){function n(){var e;return e=t.apply(this,arguments)||this,e.morphWeightsLength=0,e.morphWeightsArray=[],e.hasPositionMorph=!1,e.hasNormalMorph=!1,e.hasTangentMorph=!1,e}x(n,t);var r=n.prototype;return r.create=function(t){var r=this;this.name=this.genName("Morph target"),this.type=e.PObjectType.morph;var i=this.getAttributeMorphCount(n.positionNameList,t),o=this.getAttributeMorphCount(n.normalNameList,t),a=this.getAttributeMorphCount(n.tangentNameList,t);return(this.morphWeightsLength=0,[i,o,a].forEach(function(e){e>0&&(0===r.morphWeightsLength?r.morphWeightsLength=e:r.morphWeightsLength=Math.min(r.morphWeightsLength,e))}),this.morphWeightsLength>0&&(this.morphWeightsArray=Array(this.morphWeightsLength).fill(0),this.hasPositionMorph=i==this.morphWeightsLength,this.hasNormalMorph=o==this.morphWeightsLength,this.hasTangentMorph=a==this.morphWeightsLength),i>0&&i!=this.morphWeightsLength)?(console.error("Position morph count mismatch: "+this.morphWeightsLength+", "+i+"."),!1):o>0&&o!=this.morphWeightsLength?(console.error("Normal morph count mismatch: "+this.morphWeightsLength+", "+o+"."),!1):a>0&&a!=this.morphWeightsLength?(console.error("Tangent morph count mismatch: "+this.morphWeightsLength+", "+a+"."),!1):!(this.morphWeightsLength>5)||(console.error("Tangent morph count should not greater than 5, current "+this.morphWeightsLength+"."),!1)},r.initWeights=function(e){if(0!==this.morphWeightsArray.length){var t=this.morphWeightsArray;e.forEach(function(e,n){n<t.length&&(t[n]=e)})}},r.updateWeights=function(e){var t=this;if(e.length!=this.morphWeightsArray.length){console.error("Length of morph weights mismatch: input "+e.length+", internel "+this.morphWeightsArray.length+".");return}e.forEach(function(e,n){return t.morphWeightsArray[n]=e})},r.hasMorph=function(){return this.morphWeightsLength>0&&(this.hasPositionMorph||this.hasNormalMorph||this.hasTangentMorph)},r.equals=function(e){return this.morphWeightsLength===e.morphWeightsLength&&this.hasPositionMorph===e.hasPositionMorph&&this.hasNormalMorph===e.hasNormalMorph&&this.hasTangentMorph===e.hasTangentMorph},r.getMorphWeightsArray=function(){return this.morphWeightsArray},r.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},n}(Z);eu.positionNameList=["aTargetPosition0","aTargetPosition1","aTargetPosition2","aTargetPosition3","aTargetPosition4","aTargetPosition5","aTargetPosition6","aTargetPosition7"],eu.normalNameList=["aTargetNormal0","aTargetNormal1","aTargetNormal2","aTargetNormal3","aTargetNormal4","aTargetNormal5","aTargetNormal6","aTargetNormal7"],eu.tangentNameList=["aTargetTangent0","aTargetTangent1","aTargetTangent2","aTargetTangent3","aTargetTangent4","aTargetTangent5","aTargetTangent6","aTargetTangent7"],e.PAnimInterpType=void 0,(u=e.PAnimInterpType||(e.PAnimInterpType={}))[u.linear=0]="linear",u[u.step=1]="step",u[u.cubicSpline=2]="cubicSpline",e.PAnimPathType=void 0,(h=e.PAnimPathType||(e.PAnimPathType={}))[h.translation=0]="translation",h[h.rotation=1]="rotation",h[h.scale=2]="scale",h[h.weights=3]="weights";var eh=function(){function t(e){this.path=0,this.interp=0;var t=e.node,n=e.input,r=e.output,i=e.path,o=e.interpolation;if(this.node=t,this.timeArray=n,this.dataArray=r,"translation"===i?(this.path=0,this.component=3):"rotation"===i?(this.path=1,this.component=4):"scale"===i?(this.path=2,this.component=3):"weights"===i?(this.path=3,this.component=this.dataArray.length/this.timeArray.length,this.component<=0?console.error("Invalid weights component: "+this.timeArray.length+", "+this.component+", "+this.dataArray.length+"."):this.timeArray.length*this.component!=this.dataArray.length&&console.error("Invalid weights array length: "+this.timeArray.length+", "+this.component+", "+this.dataArray.length+".")):console.error("Invalid path status: "+i+"."),this.timeArray.length*this.component>this.dataArray.length)throw Error("Data length mismatch: "+this.timeArray.length+", "+this.component+", "+this.dataArray.length+".");"LINEAR"===o?this.interp=0:"STEP"===o?this.interp=1:this.interp=2,this.sampler=el(this.getInterpInfo(),this.timeArray,this.dataArray,this.component,this.getPathInfo())}var n=t.prototype;return n.dispose=function(){var e;this.timeArray=void 0,this.dataArray=void 0,null==(e=this.sampler)||e.dispose(),this.sampler=void 0},n.tick=function(t,n,r){var i,o=n.getComponent(e.ModelTreeComponent),a=null==o?void 0:null==(i=o.content)?void 0:i.getNodeById(this.node);if(void 0!==this.sampler&&void 0!==a){var s=this.sampler.evaluate(t);switch(this.path){case 0:a.transform.setPosition(s[0],s[1],s[2]);break;case 1:a.transform.setQuaternion(s[0],s[1],s[2],s[3]);break;case 2:a.transform.setScale(s[0],s[1],s[2]);break;case 3:var l=this.genParentId(n.id,this.node),c=null==r?void 0:r.queryMesh(l);void 0!==c&&c.updateMorphWeights(s)}}else void 0!==this.sampler&&console.error("AnimTrack: error",this.sampler,a)},n.getEndTime=function(){var e=this.timeArray.length-1;return this.timeArray[e]},n.genParentId=function(e,t){return e+"^"+t},n.getPathInfo=function(){return 2===this.path?"scale":1===this.path?"rotation":"translation"},n.getInterpInfo=function(){return 2===this.interp?"CUBICSPLINE":1===this.interp?"STEP":"LINEAR"},t}(),ef=function(){function e(e){this.engine=e,this.isHalfFloat=!0,this.width=0,this.height=0}var n=e.prototype;return n.create=function(e,n,r){this.width=4,this.height=e,this.isHalfFloat=n,this.isHalfFloat&&(this.buffer=new tn(4*this.getSize()));var i,o,a=null!=(o=null==(i=this.buffer)?void 0:i.data)?o:new Float32Array(4*this.getSize()),s=this.isHalfFloat?t.glContext.HALF_FLOAT:t.glContext.FLOAT;this.texture=t.Texture.create(this.engine,{name:r,data:{width:this.width,height:this.height,data:a},target:t.glContext.TEXTURE_2D,format:t.glContext.RGBA,type:s,wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,minFilter:t.glContext.NEAREST,magFilter:t.glContext.NEAREST})},n.update=function(e){if(void 0!==this.buffer&&this.buffer.set(e,0),void 0!==this.texture){var n,r;this.texture.updateSource({sourceType:t.TextureSourceType.data,data:{width:this.width,height:this.height,data:null!=(r=null==(n=this.buffer)?void 0:n.data)?r:e},target:t.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},e}(),ed=function(t){function n(){var e;return e=t.apply(this,arguments)||this,e.time=0,e.duration=0,e.tracks=[],e}x(n,t);var r=n.prototype;return r.create=function(t){var n,r=this;this.name=this.genName(null!=(n=t.name)?n:"Unnamed animation"),this.type=e.PObjectType.animation,this.time=0,this.duration=0,this.tracks=[],t.tracks.forEach(function(e){var t=new eh(e);r.tracks.push(t),r.duration=Math.max(r.duration,t.getEndTime())})},r.tick=function(e,t,n){this.time=e;var r=this.time%this.duration;this.tracks.forEach(function(e){e.tick(r,t,n)})},r.dispose=function(){this.tracks.forEach(function(e){e.dispose()}),this.tracks=[]},n}(Z),em=function(t){function n(n,r){var i,o,a,s;return(i=t.call(this)||this).animation=0,i.speed=0,i.delay=0,i.time=0,i.animations=[],i.name=i.genName(null!=(o=r.name)?o:"Unnamed tree"),i.type=e.PObjectType.animationManager,i.ownerItem=r,i.animation=null!=(a=n.animation)?a:-1,i.speed=1,i.delay=null!=(s=r.start)?s:0,i.animations=[],void 0!==n.animations&&n.animations.forEach(function(e){var t=i.createAnimation(e);i.animations.push(t)}),i}x(n,t);var r=n.prototype;return r.setSceneManager=function(e){this.sceneManager=e},r.createAnimation=function(e){var t=new ed;return t.create(e),t},r.tick=function(e){var t=this,n=e*this.speed*.001;this.time+=n;var r=this.time-this.delay;r>=0&&(this.animation>=0&&this.animation<this.animations.length?this.animations[this.animation].tick(r,this.ownerItem,this.sceneManager):-88888888==this.animation&&this.animations.forEach(function(e){e.tick(r,t.ownerItem,t.sceneManager)}))},r.dispose=function(){this.ownerItem=null,this.animations.forEach(function(e){e.dispose()}),this.animations=[],this.sceneManager=null},r.getTreeItem=function(){return this.ownerItem},n}(Z),ep=Math.PI/180,eg=function(n){function r(r,i,o,a,s){var l,c,u,h,f,d;return(l=n.call(this)||this).width=512,l.height=512,l.nearPlane=.001,l.farPlane=1e3,l.fov=45,l.aspect=1,l.clipMode=t.spec.CameraClipMode.landscape,l.projectionMatrix=new D,l.viewMatrix=new D,l.type=e.PObjectType.camera,l.visible=!1,l.owner=s,l.name=r,l.width=i,l.height=o,l.nearPlane=null!=(c=a.near)?c:.001,l.farPlane=null!=(u=a.far)?u:1e3,l.fov=null!=(h=a.fov)?h:45,l.aspect=null!=(f=a.aspect)?f:l.width/l.height,l.clipMode=null!=(d=a.clipMode)?d:t.spec.CameraClipMode.landscape,l.update(),l}x(r,n);var i=r.prototype;return i.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform);var e=this.clipMode===t.spec.CameraClipMode.portrait;this.projectionMatrix.perspective(this.fov*ep,this.aspect,this.nearPlane,this.farPlane,e),this.viewMatrix=this.matrix.invert()},i.getNewProjectionMatrix=function(e){var n=this.clipMode===t.spec.CameraClipMode.portrait;return new D().perspective(Math.min(1.25*e,140)*ep,this.aspect,this.nearPlane,this.farPlane,n)},i.computeViewAABB=function(e){var t=Math.tan(this.fov*ep*.5),n=this.aspect,r=0,i=0,o=0,a=0;this.isReversed()?(o=this.farPlane*t,a=this.nearPlane*t,r=o/n,i=a/n):(r=this.farPlane*t,i=this.nearPlane*t,o=n*r,a=n*i),e.makeEmpty();var s=this.matrix;return e.expandByPoint(s.transformPoint(new L(o,r,-this.farPlane))),e.expandByPoint(s.transformPoint(new L(o,-r,-this.farPlane))),e.expandByPoint(s.transformPoint(new L(-o,r,-this.farPlane))),e.expandByPoint(s.transformPoint(new L(-o,-r,-this.farPlane))),e.expandByPoint(s.transformPoint(new L(a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new L(a,-i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new L(-a,i,-this.nearPlane))),e.expandByPoint(s.transformPoint(new L(-a,-i,-this.nearPlane))),e},i.getSize=function(){return new P(this.width,this.height)},i.isReversed=function(){return this.clipMode===t.spec.CameraClipMode.portrait},i.getEye=function(){return this.translation},i.setEye=function(e){this.translation=e},r}(K),ev=function(){function e(){this.winWidth=512,this.winHeight=512,this.cameraList=[],this.defaultCamera=new eg("camera",512,512,{id:"0",dataType:"camera",fov:60,far:1e3,near:.001,clipMode:t.spec.CameraClipMode.portrait,item:{id:"0"}})}var n=e.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 eg(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(M(e,eg)){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){this.defaultCamera.fov=e,this.defaultCamera.aspect=t,this.defaultCamera.nearPlane=n,this.defaultCamera.farPlane=r,this.defaultCamera.position=i,this.defaultCamera.rotation=o,this.defaultCamera.aspect=t,this.defaultCamera.clipMode=a,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},e}(),ey=function(n){function r(r,i,o){(a=n.call(this)||this).direction=new L(0,0,1),a.range=0,a.color=new L(1,1,1),a.intensity=0,a.outerConeAngle=0,a.innerConeAngle=0,a.lightType=e.PLightType.ambient,a.padding=new P(0,0),a.name=r,a.type=e.PObjectType.light,a.visible=!1,a.owner=o,a.direction=new L(0,0,-1),a.range=0,a.outerConeAngle=0,a.innerConeAngle=0;var a,s,l,c,u,h=i.color;return a.color=new L(h.r,h.g,h.b),a.intensity=i.intensity,i.lightType===t.spec.LightType.point?(a.lightType=e.PLightType.point,a.range=null!=(s=i.range)?s:-1):i.lightType===t.spec.LightType.spot?(a.lightType=e.PLightType.spot,a.range=null!=(l=i.range)?l:-1,a.outerConeAngle=null!=(c=i.outerConeAngle)?c:Math.PI,a.innerConeAngle=null!=(u=i.innerConeAngle)?u:0):i.lightType===t.spec.LightType.directional?a.lightType=e.PLightType.directional:a.lightType=e.PLightType.ambient,a.update(),a}x(r,n);var i=r.prototype;return i.update=function(){void 0!==this.owner&&this.transform.fromEffectsTransform(this.owner.transform)},i.isDirectional=function(){return this.lightType===e.PLightType.directional},i.isPoint=function(){return this.lightType===e.PLightType.point},i.isSpot=function(){return this.lightType===e.PLightType.spot},i.isAmbient=function(){return this.lightType===e.PLightType.ambient},i.getWorldPosition=function(){return this.translation},i.getWorldDirection=function(){return this.matrix.transformNormal(this.direction,new L)},N(r,[{key:"position",get:function(){return this.translation}}]),r}(K),eT=function(){function e(){this.lightList=[]}var t=e.prototype;return t.insertItem=function(e,t,n){var r=new ey(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=[]},N(e,[{key:"lightCount",get:function(){return this.lightList.length}}]),e}(),e_=function(){function e(e){var t,n;this.resolution=null!=(t=e.resolution)?t:new P(512,512),this.colorAttachments=null!=(n=e.colorAttachments)?n:[],this.depthAttachment=e.depthAttachment}var n=e.prototype;return n.addDepthAttachment=function(e){var n;this.depthAttachment={storageType:null!=(n=e.storageType)?n:t.RenderPassAttachmentStorageType.depth_16_texture}},n.addDefaultDepthAttachment=function(){this.depthAttachment={storageType:t.RenderPassAttachmentStorageType.depth_16_texture}},n.deleteDepthAttachment=function(){this.depthAttachment=void 0},n.addColorAttachment=function(e){var n,r,i,o;this.colorAttachments.push({texture:{format:null!=(n=e.format)?n:t.glContext.RGBA,type:null!=(r=e.type)?r:t.glContext.HALF_FLOAT,minFilter:null!=(i=e.filter)?i:t.glContext.LINEAR,magFilter:null!=(o=e.filter)?o:t.glContext.LINEAR}})},n.deleteColorAttachment=function(e){e>=0&&e<this.colorAttachments.length&&this.colorAttachments.splice(e,1)},N(e,[{key:"viewport",get:function(){return[0,0,this.resolution.x,this.resolution.y]}}]),e}(),eb=function(){function e(e,n){var r=t.Material.create(e,{shader:{vertex:this.vertexShader,fragment:this.fragmentShader,shared:!0}});r.depthTest=!0,r.depthMask=!0,this.mesh=t.Mesh.create(e,{name:"boxMesh",material:r,geometry:t.Geometry.create(e,this.geometry),priority:n})}var n=e.prototype;return n.update=function(e,t,n,r){var i=this.mesh.material;i.setMatrix("_ModelMatrix",e),i.setMatrix("_ViewProjectionMatrix",t);for(var o=0;o<n.length;o+=3)i.setVector3("_PositionList["+o/3+"]",L.fromArray(n,o));i.setVector3("_LineColor",r)},n.dispose=function(){this.mesh.dispose(),this.mesh=void 0},N(e,[{key:"vertexShader",get:function(){return"\n precision highp float;\n\n uniform mat4 _ModelMatrix;\n uniform mat4 _ViewProjectionMatrix;\n uniform vec3 _PositionList[8];\n attribute vec3 aPos;\n void main(){\n int index = int(aPos.x + 0.5);\n vec4 pos = _ModelMatrix * vec4(_PositionList[index], 1);\n gl_Position = _ViewProjectionMatrix * pos;\n }\n "}},{key:"fragmentShader",get:function(){return"\n precision highp float;\n\n uniform vec3 _LineColor;\n void main(){\n gl_FragColor = vec4(_LineColor, 1);\n }\n "}},{key:"geometry",get:function(){var e=new Float32Array([0,1,2,3,4,5,6,7]),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:t.glContext.FLOAT,size:1,data:e,stride:Float32Array.BYTES_PER_ELEMENT,offset:0}},mode:t.glContext.LINES,indices:{data:n},drawStart:0,drawCount:24}}}]),e}(),eC=function(n){function r(t,r,i,o,a,s){(l=n.call(this)||this).engine=t,l.parentIndex=-1,l.subMeshes=[],l.hide=!0,l.priority=0,l.boundingBox=new V,l.visBoundingBox=!1,l.isBuilt=!1,l.isDisposed=!1;var l,c,u,h=new eM(i,s);l.name=r,l.type=e.PObjectType.mesh,l.visible=!1,l.owner=o,l.parentIndex=h.getParentIndex(),l.parentItem=h.parentItem,l.parentItemId=a,l.rootBoneItem=i.rootBone,l.skin=h.getSkinObj(t),l.morph=h.getMorphObj(),l.hide=h.isHide(),l.priority=(null==o?void 0:null==(c=o.item)?void 0:c.renderOrder)||0,l.subMeshes=[];var f=h.getGeometry();return(null!=(u=null==o?void 0:o.materials)?u:[]).forEach(function(e){var t=new eS(l.engine);t.create(f,e,function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(l)),l.subMeshes.push(t)}),l.subMeshes.length<=0&&console.warn("No primitive inside mesh item "+r+"."),l.boundingBox=l.getItemBoundingBox(i.interaction),l}x(r,n);var i=r.prototype;return i.build=function(e){!this.isBuilt&&(this.isBuilt=!0,this.subMeshes.forEach(function(t){t.build(e.maxLightCount,{},e.skybox)}),q.getInstance().visBoundingBox&&(this.boundingBoxMesh=new eb(this.engine,this.priority)))},i.update=function(){void 0!==this.owner&&(this.transform.fromEffectsTransform(this.owner.transform),this.morph&&this.morph.hasMorph()&&this.owner.morphWeights.length>0&&this.morph.updateWeights(this.owner.morphWeights))},i.render=function(e,t){var n;if(null==(n=this.skin)||n.updateSkinMatrices(),this.updateMaterial(e),this.subMeshes.forEach(function(e,n){t.drawGeometry(e.getEffectsGeometry(),e.getEffectsMaterial(),n)}),this.visBoundingBox&&void 0!==this.boundingBoxMesh){var r=this.boundingBoxMesh.mesh;t.drawGeometry(r.geometry,r.material)}},i.dispose=function(){var e,t,r;this.isDisposed||(n.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==(t=this.morph)||t.dispose(),this.morph=void 0,this.subMeshes.forEach(function(e){e.dispose()}),this.subMeshes=[],null==(r=this.boundingBoxMesh)||r.dispose(),this.boundingBoxMesh=void 0)},i.updateMorphWeights=function(e){if(void 0!==this.morph&&this.morph.hasMorph()){var t=this.morph.morphWeightsArray;if(void 0!==t){if(t.length!=e.length)throw Error("Weight array length mismatch.");for(var n=0;n<t.length;n++)t[n]=e[n]}}},i.updateParentInfo=function(e,t){this.parentItemId=e,this.parentItem=t,void 0!==this.skin&&this.skin.updateParentItem(t)},i.updateMaterial=function(e){var t=this.matrix,n=t.clone().invert().transpose(),r=e.sceneStates;if(this.subMeshes.forEach(function(e){e.updateMaterial(t,n,r)}),void 0!==this.boundingBoxMesh){this.computeBoundingBox(t);var i=new L(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)}},i.hitTesting=function(e,t){var n,r=this.matrix,i=r.clone().invert(),o=i.transformPoint(e,new L),a=i.transformNormal(t,new L),s=this.boundingBox,l=eK(o,a,s.min,s.max);return void 0===l?[]:(q.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])},i.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},i.getItemBoundingBox=function(e){if(void 0===e)return new V;if(e.type===t.spec.ModelBoundingType.box){var n,r,i=null!=(n=e.center)?n:[0,0,0],o=null!=(r=e.size)?r:[0,0,0],a=L.fromArray(i),s=L.fromArray(o).multiply(.5);return new V(a.clone().subtract(s),a.clone().add(s))}var l,c,u=null!=(l=e.center)?l:[0,0,0],h=(null!=(c=e.radius)?c:0)*.5,f=L.fromArray(u);return new V(f.clone().subtract(h),f.clone().add(h))},i.getParentId=function(){return this.parentItemId},N(r,[{key:"hasSkin",get:function(){return void 0!==this.skin}}]),r}(K),eS=function(){function n(e){this.engine=e,this.name="",this.effectsPriority=0,this.boundingBox=new V,this.isCompressed=!1}var r=n.prototype;return r.create=function(t,n,r){if(this.parent=r,this.skin=r.skin,this.morph=r.morph,this.setGeometry(t),this.setMaterial(n),this.name=r.name,this.effectsPriority=r.priority,this.geometry.setHide(r.hide),void 0!==this.skin){var i=this.skin.getJointCount();if(this.jointMatrixList=new Float32Array(16*i),this.jointNormalMatList=new Float32Array(16*i),this.skin.isTextureDataMode()){var o=this.skin.textureDataMode===e.TextureDataMode.half_float;this.jointMatrixTexture=new ef(this.engine),this.jointNormalMatTexture=new ef(this.engine),this.jointMatrixTexture.create(i,o,"jointMatrixTexture"),this.jointNormalMatTexture.create(i,o,"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()},r.build=function(e,n,r){var i,o=q.getInstance(),a=this.getMacroList(e,!0,r),s=this.material.getMacroList(a),l=null!=n?n:{};l._ViewProjectionMatrix="VIEWPROJECTION",l._ModelMatrix="MODEL",l.uEditorTransform="EDITOR_TRANSFORM";var c=q.getInstance().isWebGL2;this.material.effectMaterial?((i=this.material.effectMaterial).uniformSemantics=l,s.forEach(function(e){var t=e.name,n=e.value;i.enableMacro(t,n)})):i=t.Material.create(this.engine,{shader:{vertex:this.material.vertexShaderCode,fragment:this.material.fragmentShaderCode,shared:o.shaderShared,glslVersion:c?t.GLSLVersion.GLSL3:t.GLSLVersion.GLSL1},uniformSemantics:l}),this.material.setMaterialStates(i)},r.getFeatureList=function(t,n,r){var i=[];if(this.geometry.hasNormals()&&i.push("HAS_NORMALS 1"),this.geometry.hasTangents()&&i.push("HAS_TANGENTS 1"),this.geometry.hasUVCoords(1)&&i.push("HAS_UV_SET1 1"),this.geometry.hasUVCoords(2)&&i.push("HAS_UV_SET2 1"),void 0!==this.morph&&this.morph.hasMorph()){i.push("USE_MORPHING"),i.push("WEIGHT_COUNT "+this.morph.morphWeightsLength);for(var o=0;o<this.morph.morphWeightsLength;o++)this.morph.hasPositionMorph&&i.push("HAS_TARGET_POSITION"+o),this.morph.hasNormalMorph&&i.push("HAS_TARGET_NORMAL"+o),this.morph.hasTangentMorph&&i.push("HAS_TARGET_TANGENT"+o)}void 0!==this.skin&&(i.push("USE_SKINNING 1"),i.push("JOINT_COUNT "+this.skin.getJointCount()),i.push("HAS_JOINT_SET1 1"),i.push("HAS_WEIGHT_SET1 1"),this.skin.textureDataMode&&i.push("USE_SKINNING_TEXTURE 1")),this.material.materialType!==e.PMaterialType.unlit&&(t>0&&this.geometry.hasNormals()&&(i.push("USE_PUNCTUAL 1"),i.push("LIGHT_COUNT "+t)),void 0!==r&&r.available&&(i.push("USE_IBL 1"),i.push("USE_TEX_LOD 1"),r.hasDiffuseImage||i.push("IRRADIANCE_COEFFICIENTS 1")));var a=q.getInstance().renderMode3D,s=this.getRenderMode3DDefine(a);return void 0!==s&&(i.push("DEBUG_OUTPUT 1"),i.push(""+s+" 1")),i},r.getMacroList=function(t,n,r){var i=[];if(this.geometry.hasNormals()&&i.push({name:"HAS_NORMALS"}),this.geometry.hasTangents()&&i.push({name:"HAS_TANGENTS"}),this.geometry.hasUVCoords(1)&&i.push({name:"HAS_UV_SET1"}),this.geometry.hasUVCoords(2)&&i.push({name:"HAS_UV_SET2"}),void 0!==this.morph&&this.morph.hasMorph()){i.push({name:"USE_MORPHING"}),i.push({name:"WEIGHT_COUNT",value:this.morph.morphWeightsLength});for(var o=0;o<this.morph.morphWeightsLength;o++)this.morph.hasPositionMorph&&i.push({name:"HAS_TARGET_POSITION"+o}),this.morph.hasNormalMorph&&i.push({name:"HAS_TARGET_NORMAL"+o}),this.morph.hasTangentMorph&&i.push({name:"HAS_TARGET_TANGENT"+o})}void 0!==this.skin&&(i.push({name:"USE_SKINNING"}),i.push({name:"JOINT_COUNT",value:this.skin.getJointCount()}),i.push({name:"HAS_JOINT_SET1"}),i.push({name:"HAS_WEIGHT_SET1"}),this.skin.textureDataMode&&i.push({name:"USE_SKINNING_TEXTURE"})),this.material.materialType!==e.PMaterialType.unlit&&(t>0&&this.geometry.hasNormals()&&(i.push({name:"USE_PUNCTUAL"}),i.push({name:"LIGHT_COUNT",value:t})),void 0!==r&&r.available&&(i.push({name:"USE_IBL"}),i.push({name:"USE_TEX_LOD"}),r.hasDiffuseImage||i.push({name:"IRRADIANCE_COEFFICIENTS"})));var a=q.getInstance().renderMode3D,s=this.getRenderMode3DDefine(a);return void 0!==s&&(i.push({name:"DEBUG_OUTPUT"}),i.push({name:s})),i},r.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},r.updateMaterial=function(e,t,n){this.updateUniformsByAnimation(e,t),this.updateUniformsByScene(n),this.material.updateUniforms(this.getEffectsMaterial())},r.hitTesting=function(e,t,n,r){var i=this.boundingBox,o=eK(e,t,i.min,i.max),a=[];if(void 0!==o){void 0!==this.skin&&this.skin.animationMatrices.forEach(function(e){a.push(new D().multiplyMatrices(r,e))});var s=new te,l=this.material.isBothSide();return s.create(this.geometry.geometry,l,a),s.getHitPoint(e,t)}},r.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 D().multiplyMatrices(e,n))});var n=new e9;return n.create(this.geometry.geometry,t),n.getBoundingBox(this.boundingBox)},r.getRenderMode3DDefine=function(e){switch(e){case t.spec.RenderMode3D.uv:return"DEBUG_UV";case t.spec.RenderMode3D.normal:return"DEBUG_NORMAL";case t.spec.RenderMode3D.basecolor:return"DEBUG_BASECOLOR";case t.spec.RenderMode3D.alpha:return"DEBUG_ALPHA";case t.spec.RenderMode3D.metallic:return"DEBUG_METALLIC";case t.spec.RenderMode3D.roughness:return"DEBUG_ROUGHNESS";case t.spec.RenderMode3D.ao:return"DEBUG_OCCLUSION";case t.spec.RenderMode3D.emissive:return"DEBUG_EMISSIVE"}},r.updateUniformsByAnimation=function(e,t){var n=this.getEffectsMaterial();n.setMatrix("_ModelMatrix",e),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)}},r.updateUniformsByScene=function(e){var t=this.getEffectsMaterial();if(t.setMatrix("_ViewProjectionMatrix",e.viewProjectionMatrix),t.setVector3("_Camera",e.cameraPosition),!this.isUnlitMaterial()){for(var n=e.maxLightCount,r=e.lightList,i=0;i<n;i++)if(i<r.length){var o=r[i],a=o.visible?o.intensity:0;t.setVector3("_Lights["+i+"].direction",o.getWorldDirection()),t.setFloat("_Lights["+i+"].range",o.range),t.setVector3("_Lights["+i+"].color",o.color),t.setFloat("_Lights["+i+"].intensity",a),t.setVector3("_Lights["+i+"].position",o.getWorldPosition()),t.setFloat("_Lights["+i+"].innerConeCos",Math.cos(o.innerConeAngle)),t.setFloat("_Lights["+i+"].outerConeCos",Math.cos(o.outerConeAngle)),t.setInt("_Lights["+i+"].type",o.lightType),t.setVector2("_Lights["+i+"].padding",o.padding)}else t.setVector3("_Lights["+i+"].direction",L.ZERO),t.setFloat("_Lights["+i+"].range",0),t.setVector3("_Lights["+i+"].color",L.ZERO),t.setFloat("_Lights["+i+"].intensity",0),t.setVector3("_Lights["+i+"].position",L.ZERO),t.setFloat("_Lights["+i+"].innerConeCos",0),t.setFloat("_Lights["+i+"].outerConeCos",0),t.setInt("_Lights["+i+"].type",99999),t.setVector2("_Lights["+i+"].padding",P.ZERO);var s=e.skybox;if(void 0!==s&&s.available){if(t.setVector2("_IblIntensity",new P(s.currentIntensity,s.currentReflectionsIntensity)),t.setTexture("_brdfLUT",s.brdfLUT),void 0!==s.diffuseImage)t.setTexture("_DiffuseEnvSampler",s.diffuseImage);else{var l=s.irradianceCoeffs;["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach(function(e,n){t.setVector3("_shCoefficients."+e,L.fromArray(l[n]))})}t.setInt("_MipCount",s.specularMipCount-1),t.setTexture("_SpecularEnvSampler",s.specularImage)}}},r.hasSkin=function(){return void 0!==this.skin},r.getEffectsGeometry=function(){return this.geometry.geometry},r.setGeometry=function(e){M(e,ex)?this.geometry=e:this.geometry=new ex(e)},r.setMaterial=function(e){M(e,to)?this.material=e:M(e,ta)?this.material=e:this.material=ts(e)},r.getEffectsMaterial=function(){return this.material.effectMaterial},r.isUnlitMaterial=function(){return this.material.materialType===e.PMaterialType.unlit},r.hasMorph=function(){return void 0!==this.morph&&this.morph.hasMorph()},r.getWorldBoundingBox=function(){if(void 0===this.parent)return this.boundingBox.isEmpty()&&this.computeBoundingBox(D.fromIdentity()),this.boundingBox;var e=this.parent.matrix;return this.boundingBox.isEmpty()&&this.computeBoundingBox(e.clone().invert()),this.boundingBox.clone().applyMatrix4(e)},n}(),ex=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()):0>t.getDrawCount()&&t.setDrawCount(-t.getDrawCount())},t.isCompressed=function(){return this.geometry.getAttributeData("aPos"),!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}(),eM=function(){function t(e,t){this.itemData=e,this.parentItem=t,this.data=e,this.geometry=e.geometry,this.rootBoneItem=e.rootBone;var n,r,i=new eu;i.create(this.geometry)&&((null==(n=e.morph)?void 0:n.weights)&&i.initWeights(null==(r=e.morph)?void 0:r.weights),this.morphObj=i)}var n=t.prototype;return n.hasMorphTarget=function(){return this.morphObj.hasMorph()},n.getMorphObj=function(){if(this.hasMorphTarget())return this.morphObj},n.isHide=function(){return!0===this.data.hide},n.getParentNode=function(){var t,n=this.getParentIndex(),r=null==(t=this.parentItem)?void 0:t.getComponent(e.ModelTreeComponent);if(void 0!==r&&n>=0)return r.content.getNodeById(n)},n.getParentIndex=function(){return -1},n.getGeometry=function(){return this.data.geometry},n.getMaterials=function(){return this.data.materials},n.getMaterialCount=function(){return this.data.materials.length},n.hasSkin=function(){var e=this.geometry.getSkinProps();return!!(e.rootBoneName&&e.boneNames&&e.inverseBindMatrices&&this.rootBoneItem)},n.getSkinOpts=function(){return this.geometry.getSkinProps()},n.getSkinObj=function(e){var t=this.getSkinOpts();if(t.rootBoneName&&t.boneNames&&t.inverseBindMatrices&&this.rootBoneItem){var n=new ec;return n.create(t,e,this.rootBoneItem),n}},t}(),eI=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}(),eA=function(){function n(e){this.maxLightCount=16,this.renderSkybox=!1,this.compName="SceneManger",this.itemList=[],this.meshList=[],this.engine=e,this.lightManager=new eT,this.cameraManager=new ev,this.parentId2Mesh=new Map,this.enableDynamicSort=!1,this.tickCount=0,this.lastTickSecond=-1,this.sceneAABBCache=new V,this.renderedMeshSet=new eI}var r=n.prototype;return r.initial=function(e){this.clean(),this.compName=e.componentName,this.renderer=e.renderer,this.engine=e.renderer.engine,this.sceneCache=e.sceneCache,this.enableDynamicSort=!0===e.enableDynamicSort,this.renderSkybox=e.renderSkybox,this.maxLightCount=e.lightItemCount,this.cameraManager.initial(this.renderer.getWidth(),this.renderer.getHeight()),this.brdfLUT=this.sceneCache.getBrdfLutTexture(),this.initGlobalState(e),this.maxLightCount>8&&console.warn("Too many light items: "+this.maxLightCount+" light(s).")},r.initGlobalState=function(e){var n,r,i,o,a,s=this.engine.gpuCapability,l=q.getInstance();l.reset(),l.isWebGL2=2===s.level,l.runtimeEnv=null!=(n=e.runtimeEnv)?n:t.PLAYER_OPTIONS_ENV_EDITOR,l.compatibleMode=null!=(r=e.compatibleMode)?r:"gltf",l.visBoundingBox=null!=(i=e.visBoundingBox)&&i,l.renderMode3D=null!=(o=e.renderMode3D)?o:t.spec.RenderMode3D.none,l.renderMode3DUVGridSize=null!=(a=e.renderMode3DUVGridSize)?a:1/16},r.clean=function(){this.dispose(),this.compName="",this.renderer=void 0,this.sceneCache=void 0,this.itemList=[],this.meshList=[],this.lightManager=new eT,this.cameraManager=new ev,this.parentId2Mesh=new Map,this.brdfLUT=void 0,this.skybox=void 0,this.lastTickSecond=-1,this.tickCount=0,this.renderedMeshSet=new eI},r.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()},r.addItem=function(e){M(e,eC)?(void 0!==e.parentItemId&&this.parentId2Mesh.set(e.parentItemId,e),t.addItem(this.meshList,e)):M(e,tl)?(e.setup(this.brdfLUT),this.renderSkybox||(e.renderable=!1),this.skybox=e):M(e,ey)?this.lightManager.insertLight(e):this.cameraManager.insertCamera(e),t.addItem(this.itemList,e)},r.removeItem=function(e){M(e,eC)?(void 0!==e.parentItemId&&this.parentId2Mesh.delete(e.parentItemId),t.removeItem(this.meshList,e)):M(e,tl)?this.skybox=void 0:M(e,ey)?this.lightManager.remove(e):this.cameraManager.remove(e),t.removeItem(this.itemList,e)},r.updateDefaultCamera=function(e){var n=new t.Transform(w({},e,{valid:!0})),r=new X().fromEffectsTransform(n);this.cameraManager.updateDefaultCamera(e.fov,e.aspect,e.near,e.far,r.getPosition(),r.getRotation(),e.clipMode)},r.tick=function(e){var t=this.activeCamera,n=t.viewMatrix,r=t.projectionMatrix,i=r.clone().multiply(n);this.sceneStates={deltaSeconds:e,camera:t,cameraPosition:t.getEye(),viewMatrix:n,projectionMatrix:r,viewProjectionMatrix:i,winSize:t.getSize(),sceneRadius:1,lightList:this.lightManager.lightList,maxLightCount:this.maxLightCount,skybox:this.skybox},this.enableDynamicSort&&this.dynamicSortMeshes(this.sceneStates),this.tickCount+=1,this.lastTickSecond+=e},r.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=e3.isTransparentMesh(e),i=e3.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)}},r.queryMesh=function(e){var t=this.parentId2Mesh.get(e);if(void 0!==t&&t.visible)return t},r.getSceneAABB=function(t){var n=null!=t?t:new V;return this.itemList.forEach(function(t){if(t.type===e.PObjectType.mesh){if(t.owner){var r=t.owner.item.getWorldTransform().getWorldMatrix(),i=t.computeBoundingBox(r);i.applyMatrix4(r),n.union(i)}else n.union(t.computeBoundingBox(D.fromIdentity()))}}),n},r.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("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")},r.getRenderer=function(){return this.renderer},r.getSceneCache=function(){return this.sceneCache},N(n,[{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)}}]),n}(),eE="precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\n#include <animation.vert.glsl>\nvsIn vec4 aPos;vsOut vec3 v_Position;\n#ifdef HAS_NORMALS\nvsIn vec4 aNormal;\n#endif\n#ifdef HAS_TANGENTS\nvsIn vec4 aTangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvsOut mat3 v_TBN;\n#else\nvsOut vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nvsIn vec2 aUV;\n#endif\n#ifdef HAS_UV_SET2\nvsIn vec2 aUV2;\n#endif\nvsOut vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nvsOut vec2 v_UVCoord2;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nvsIn vec3 aColor;vsOut vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nvsIn vec4 aColor;vsOut vec4 v_Color;\n#endif\nuniform mat4 _ViewProjectionMatrix;uniform mat4 _ModelMatrix;uniform mat4 _NormalMatrix;\n#ifdef EDITOR_TRANSFORM\nuniform vec4 uEditorTransform;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform mat4 _LightViewProjectionMatrix;uniform float _DeltaSceneSize;vsOut vec4 v_PositionLightSpace;vsOut 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=_ModelMatrix*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(_ModelMatrix*vec4(tangent.xyz,0.0)));vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\n#else\nv_Normal=normalize(vec3(_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=_ViewProjectionMatrix*pos;\n#ifdef EDITOR_TRANSFORM\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}",eN="\n#define FEATURES\n#ifndef WEBGL2\n#extension GL_OES_standard_derivatives : enable\n#endif\n#if !defined(WEBGL2) && defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef USE_HDR\n#extension GL_OES_texture_float : enable\n#extension GL_OES_texture_float_linear : enable\n#endif\n#if !defined(WEBGL2) && defined(USE_WBOIT)\n#extension GL_EXT_draw_buffers: require\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\n#ifdef USE_WBOIT\nlayout(location=0)out vec4 outFragColor0;layout(location=1)out vec4 outFragColor1;\n#else\nout vec4 outFragColor;\n#endif\n#else\n#ifdef USE_WBOIT\n#define outFragColor0 gl_FragData[0]\n#define outFragColor1 gl_FragData[1]\n#else\n#define outFragColor gl_FragColor\n#endif\n#endif\n#include <webglCompatibility.glsl>\n#include <extensions.frag.glsl>\n#include <tonemapping.frag.glsl>\n#include <textures.vert.glsl>\n#include <functions.frag.glsl>\n#include <shadowCommon.vert.glsl>\n#include <shadow.frag.glsl>\nstruct Light{vec3 direction;float range;vec3 color;float intensity;vec3 position;float innerConeCos;float outerConeCos;int type;vec2 padding;};const int LightType_Directional=0;const int LightType_Point=1;const int LightType_Spot=2;const int LightType_Ambient=3;\n#ifdef USE_PUNCTUAL\nuniform Light _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 writeFragmentColor(vec4 fragColor){\n#if !defined(ALPHAMODE_OPAQUE) && defined(USE_WBOIT)\nfloat w=weight(gl_FragCoord.z,fragColor.a);fragColor.rgb*=fragColor.a;outFragColor0=vec4(fragColor.rgb*w,fragColor.a);outFragColor1=vec4(fragColor.a*w);\n#else\noutFragColor=fragColor;\n#endif\n}void main(){float perceptualRoughness=0.0;float metallic=0.0;vec4 baseColor=vec4(0.0,0.0,0.0,1.0);vec3 diffuseColor=vec3(0.0);vec3 specularColor=vec3(0.0);vec3 f0=vec3(0.04);\n#ifdef PREVIEW_BORDER\nwriteFragmentColor(uPreviewColor);return;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nvec4 sgSample=SRGBtoLINEAR(texture2D(_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\nwriteFragmentColor(fragColorUnlit);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),getNormal()));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=getNormal()*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\noutFragColor.rgb=vec3(1.0);\n#endif\n#ifdef DEBUG_EMISSIVE\noutFragColor.rgb=vec3(0.0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\nreturn;\n#endif\nmetallic=clamp(metallic,0.0,1.0);float alphaRoughness=perceptualRoughness*perceptualRoughness;vec3 normal=getNormal();\n#ifdef USE_SPECULAR_AA\nfloat AARoughnessFactor=getAARoughnessFactor(normal);perceptualRoughness+=AARoughnessFactor;alphaRoughness+=AARoughnessFactor;\n#endif\nperceptualRoughness=clamp(perceptualRoughness,0.04,1.0);alphaRoughness=clamp(alphaRoughness,0.04,1.0);float reflectance=max(max(specularColor.r,specularColor.g),specularColor.b);vec3 specularEnvironmentR0=specularColor.rgb;vec3 specularEnvironmentR90=vec3(clamp(reflectance*50.0,0.0,1.0));MaterialInfo materialInfo=MaterialInfo(perceptualRoughness,specularEnvironmentR0,alphaRoughness,diffuseColor,specularEnvironmentR90,specularColor);vec3 color=vec3(0.0,0.0,0.0);vec3 view=normalize(_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\nwriteFragmentColor(fragColorOut);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),normal));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=normal*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\n#ifdef HAS_OCCLUSION_MAP\noutFragColor.rgb=vec3(mix(1.0,ao,_OcclusionStrength));\n#else\noutFragColor.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\noutFragColor.rgb=LINEARtoSRGB(emissive);\n#endif\n#ifdef DEBUG_F0\noutFragColor.rgb=vec3(f0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\n}",ew="#define FEATURES\n#include <shadowCommon.vert.glsl>\n#include <webglCompatibility.glsl>\n#if defined(SHADOWMAP_VSM) && !defined(WEBGL2)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\nout vec4 outFragColor;\n#else\n#define outFragColor gl_FragColor\n#endif\nvec4 CalcMomentVSM(float depth){float dx=0.0;float dy=0.0;\n#if defined(SHADOWMAP_VSM) && (defined(GL_OES_standard_derivatives) || defined(WEBGL2))\ndx=dFdx(depth);dy=dFdy(depth);\n#endif\nfloat moment2=depth*depth+0.25*(dx*dx+dy*dy);return vec4(1.0-depth,1.0-moment2,0.0,1.0);}vec4 CalcMomentEVSM(float depth){float pos=EVSM_FUNC0(depth);float neg=EVSM_FUNC1(depth);return vec4(pos,pos*pos,neg,neg*neg);}void main(){\n#if defined(SHADOWMAP_STANDARD) || defined(SHADOWMAP_VSM)\noutFragColor=CalcMomentVSM(gl_FragCoord.z);\n#else\noutFragColor=CalcMomentEVSM(gl_FragCoord.z);\n#endif\n}",eP="precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\nvsIn vec3 aPos;vsOut 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);}",eL="\n#define FEATURES\n#if !defined(WEBGL2) && defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#if !defined(WEBGL2)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#include <webglCompatibility.glsl>\n#include <extensions.frag.glsl>\n#ifdef WEBGL2\nout vec4 outFragColor;\n#else\n#define outFragColor gl_FragColor\n#endif\nuniform sampler2D _brdfLUT;uniform vec2 _IblIntensity;uniform int _MipCount;uniform samplerCube _DiffuseEnvSampler;uniform samplerCube _SpecularEnvSampler;fsIn 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);outFragColor=vec4(getIBLContribution(dir,dir),1.0);}",eR={"animation.vert.glsl":"#ifdef HAS_TARGET_POSITION0\nvsIn vec3 aTargetPosition0;\n#endif\n#ifdef HAS_TARGET_POSITION1\nvsIn vec3 aTargetPosition1;\n#endif\n#ifdef HAS_TARGET_POSITION2\nvsIn vec3 aTargetPosition2;\n#endif\n#ifdef HAS_TARGET_POSITION3\nvsIn vec3 aTargetPosition3;\n#endif\n#ifdef HAS_TARGET_POSITION4\nvsIn vec3 aTargetPosition4;\n#endif\n#ifdef HAS_TARGET_POSITION5\nvsIn vec3 aTargetPosition5;\n#endif\n#ifdef HAS_TARGET_POSITION6\nvsIn vec3 aTargetPosition6;\n#endif\n#ifdef HAS_TARGET_POSITION7\nvsIn vec3 aTargetPosition7;\n#endif\n#ifdef HAS_TARGET_NORMAL0\nvsIn vec3 aTargetNormal0;\n#endif\n#ifdef HAS_TARGET_NORMAL1\nvsIn vec3 aTargetNormal1;\n#endif\n#ifdef HAS_TARGET_NORMAL2\nvsIn vec3 aTargetNormal2;\n#endif\n#ifdef HAS_TARGET_NORMAL3\nvsIn vec3 aTargetNormal3;\n#endif\n#ifdef HAS_TARGET_NORMAL4\nvsIn vec3 aTargetNormal4;\n#endif\n#ifdef HAS_TARGET_TANGENT0\nvsIn vec3 aTargetTangent0;\n#endif\n#ifdef HAS_TARGET_TANGENT1\nvsIn vec3 aTargetTangent1;\n#endif\n#ifdef HAS_TARGET_TANGENT2\nvsIn vec3 aTargetTangent2;\n#endif\n#ifdef HAS_TARGET_TANGENT3\nvsIn vec3 aTargetTangent3;\n#endif\n#ifdef HAS_TARGET_TANGENT4\nvsIn vec3 aTargetTangent4;\n#endif\n#ifdef USE_MORPHING\nuniform float _morphWeights[WEIGHT_COUNT];\n#endif\n#ifdef HAS_JOINT_SET1\nvsIn vec4 aJoints;\n#endif\n#ifdef HAS_JOINT_SET2\nvsIn vec4 aJoint2;\n#endif\n#ifdef HAS_WEIGHT_SET1\nvsIn vec4 aWeights;\n#endif\n#ifdef HAS_WEIGHT_SET2\nvsIn 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","extensions.frag.glsl":"vec3 _dFdx(vec3 coord){\n#if defined(GL_OES_standard_derivatives) || defined(WEBGL2)\nreturn dFdx(coord);\n#endif\nreturn vec3(0.0);}vec3 _dFdy(vec3 coord){\n#if defined(GL_OES_standard_derivatives) || defined(WEBGL2)\nreturn dFdy(coord);\n#endif\nreturn vec3(0.0);}\n#ifdef USE_TEX_LOD\nvec4 _textureCubeLodEXT(samplerCube sampler,vec3 coord,float lod){\n#if defined(WEBGL2) || defined(GL_EXT_shader_texture_lod)\nreturn textureCubeLodEXT(sampler,coord,lod);\n#else\nreturn textureCube(sampler,coord,lod);\n#endif\n}\n#endif\n","tonemapping.frag.glsl":"uniform float _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);}","textures.vert.glsl":"fsIn vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nfsIn vec2 v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D _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;}","functions.frag.glsl":"const float M_PI=3.141592653589793;const float c_MinReflectance=0.04;fsIn vec3 v_Position;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nfsIn mat3 v_TBN;\n#else\nfsIn vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nfsIn vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nfsIn vec4 v_Color;\n#endif\nstruct AngularInfo{float NdotL;float NdotV;float NdotH;float LdotH;float VdotH;vec3 padding;};vec4 getVertexColor(){vec4 color=vec4(1.0,1.0,1.0,1.0);\n#ifdef HAS_VERTEX_COLOR_VEC3\ncolor.rgb=v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\ncolor=v_Color;\n#endif\nreturn color;}vec3 getNormal(){vec2 UV=getNormalUV();\n#ifndef HAS_TANGENTS\nvec3 pos_dx=_dFdx(v_Position);vec3 pos_dy=_dFdy(v_Position);vec3 tex_dx=_dFdx(vec3(UV,0.0));vec3 tex_dy=_dFdy(vec3(UV,0.0));vec3 t=(tex_dy.t*pos_dx-tex_dx.t*pos_dy)/(tex_dx.s*tex_dy.t-tex_dy.s*tex_dx.t);\n#ifdef HAS_NORMALS\nvec3 ng=normalize(v_Normal);\n#else\nvec3 ng=cross(pos_dx,pos_dy);\n#endif\nt=normalize(t-ng*dot(ng,t));vec3 b=normalize(cross(ng,t));mat3 tbn=mat3(t,b,ng);\n#else\nmat3 tbn=v_TBN;\n#endif\n#ifdef HAS_NORMAL_MAP\nvec3 n=texture2D(_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","shadow.frag.glsl":"#ifdef USE_SHADOW_MAPPING\nuniform vec2 _ShadowMapSizeInv;fsIn vec4 v_PositionLightSpace;fsIn vec4 v_dPositionLightSpace;\n#endif\nfloat linstep(float low,float high,float v){return clamp((v-low)/(high-low),0.0,1.0);}\n#ifdef USE_SHADOW_MAPPING\nfloat chebyshev(vec2 moments,float depth,float minVar){float p=step(depth,moments.x+SHADOWMAP_BAIS);float variance=max(moments.y-moments.x*moments.x,minVar);float d=depth-(moments.x+SHADOWMAP_BAIS);float pMax=linstep(0.2,1.0,variance/(variance+d*d));return mix(0.1,1.0,min(max(p,pMax),1.0));}float getShadowContributionSM(){vec3 coords=v_PositionLightSpace.xyz/v_PositionLightSpace.w*0.5+0.5;if(coords.z<0.01||coords.z>0.99||coords.x<0.01||coords.x>0.99||coords.y<0.01||coords.y>0.99){return 1.0;}vec2 moments=vec2(1.0)-texture2D(_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","webglCompatibility.glsl":"#ifdef WEBGL2\n#define vsIn in\n#define vsOut out\n#define fsIn in\n#define fsOut out\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\n#else\n#define vsIn attribute\n#define vsOut varying\n#define fsIn varying\n#define fsOut varying\n#endif\n","shadowCommon.vert.glsl":"\n#define SHADOWMAP_BAIS 0.001\n#define EVSM_FUNC0(DEPTH) -exp(-7.0 * DEPTH)\n#define EVSM_FUNC1(DEPTH) -exp(-6.0 * DEPTH)\n"};(f=v||(v={})).build=function(e,t,n){for(var r;null!==(r=/#include <(.+)>/gm.exec(e));)e=e.replace(r[0],eR[r[1]]);return(e=e.replace(/#define FEATURES/,t.map(function(e){return"#define "+e}).join("\n")),n)?"#version 300 es\n"+e:e},f.getSourceCode=function(e,t){for(var n;null!==(n=/#include <(.+)>/gm.exec(e));)e=e.replace(n[0],eR[n[1]]);return t?"#version 300 es\n"+e:e};var eO=function(){function t(){}return t.getVertexShaderCode=function(t){var n=t.isWebGL2,r=t.featureList,i=t.material.materialType;switch(i){case e.PMaterialType.unlit:case e.PMaterialType.pbr:case e.PMaterialType.shadowBase:return v.build(eE,r,n);case e.PMaterialType.skyboxFilter:return v.build(eP,r,n);default:throw Error("Invalid material type "+i+" for getVertexShaderString!")}},t.getFragmentShaderCode=function(t){var n=t.isWebGL2,r=t.featureList,i=t.material.materialType;switch(i){case e.PMaterialType.unlit:case e.PMaterialType.pbr:return v.build(eN,r,n);case e.PMaterialType.shadowBase:return v.build(ew,r,n);case e.PMaterialType.skyboxFilter:return v.build(eL,r,n);default:throw Error("Invalid material type "+i+" for getFragmentShaderString!")}},t.genVertexShaderCode=function(t,n){switch(t){case e.PMaterialType.unlit:case e.PMaterialType.pbr:case e.PMaterialType.shadowBase:return v.getSourceCode(eE,n);case e.PMaterialType.skyboxFilter:return v.getSourceCode(eP,n);default:throw Error("Invalid material type "+t+" for genVertexShaderCode!")}},t.genFragmentShaderCode=function(t,n){switch(t){case e.PMaterialType.unlit:case e.PMaterialType.pbr:return v.getSourceCode(eN,n);case e.PMaterialType.shadowBase:return v.getSourceCode(ew,n);case e.PMaterialType.skyboxFilter:return v.getSourceCode(eL,n);default:throw Error("Invalid material type "+t+" for genFragmentShaderCode!")}},t}();function eD(t){return{vertexShaderCode:eO.genVertexShaderCode(e.PMaterialType.pbr,t),fragmentShaderCode:eO.genFragmentShaderCode(e.PMaterialType.pbr,t)}}function eF(t){return{vertexShaderCode:eO.genVertexShaderCode(e.PMaterialType.unlit,t),fragmentShaderCode:eO.genFragmentShaderCode(e.PMaterialType.unlit,t)}}function eU(e){return{vertexShaderCode:eO.getVertexShaderCode(e),fragmentShaderCode:eO.getFragmentShaderCode(e)}}function eB(e){return{vertexShaderCode:eO.getVertexShaderCode(e),fragmentShaderCode:eO.getFragmentShaderCode(e)}}function ek(e){return{vertexShaderCode:eO.getVertexShaderCode(e),fragmentShaderCode:eO.getFragmentShaderCode(e)}}function eV(e){return{vertexShaderCode:eH({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 eG(e){return{vertexShaderCode:ej(),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 ez(e){return{vertexShaderCode:ej(),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 eH(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 _ModelMatrix;\n uniform mat4 _ViewProjectionMatrix;\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 = _ModelMatrix * 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(_ModelMatrix * vec4(aNormal, 0)));\n #endif\n\n gl_Position = _ViewProjectionMatrix * pos;\n }\n "),t.join("\n")}function ej(){return"\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 "}eO.environment="webgl1";var eW=function(){function t(){this.funcMap=new Map,this.funcMap.set(e.PMaterialType.unlit,eU),this.funcMap.set(e.PMaterialType.pbr,eU),this.funcMap.set(e.PMaterialType.shadowBase,eB),this.funcMap.set(e.PMaterialType.shadowFilter,ez),this.funcMap.set(e.PMaterialType.normalVis,eV),this.funcMap.set(e.PMaterialType.simpleFilter,eG),this.funcMap.set(e.PMaterialType.skyboxFilter,ek)}return t.prototype.genShaderCode=function(e){var t=e.material.materialType,n=this.funcMap.get(t);if(void 0!==n)return n(e);throw Error("Invalid material type "+t+", shader content "+e+".")},t.getInstance=function(){return this._instance||(this._instance=new this)},t}(),eX="_Native",eJ=new Map;function eq(e,t){for(var n,r=[],i=0;i<t.length;i++){if("number"==typeof t[i]&&eJ.has(t[i])){r.push(eJ.get(t[i])+"("+t[i]+")");continue}r.push(null==(n=t[i])?void 0:n.toString())}return""+e+(r.length>0?"("+r.join(", ")+")":"()")}e.ModelMeshComponent=function(e){function n(n,r){var i;return(i=e.call(this,n)||this).morphWeights=[],i.getHitTestParams=function(e){i.computeBoundingBox();var n=i.bounding;if(n&&(e||Number.isInteger(n.behavior))){var r=n.type;if(r===t.spec.ModelBoundingType.box){if(M(i.content,eC)){var o=i.content;return{behavior:n.behavior,type:t.HitTestType.custom,collect:function(e,t){return o.hitTesting(e.origin,e.direction)}}}var a=i.transform.getWorldMatrix();return{behavior:n.behavior,type:t.HitTestType.custom,collect:function(e,t){return eZ(e,a,n)}}}if(r===t.spec.ModelBoundingType.sphere){var s=new L;i.transform.assignWorldTRS(s);var l=new L;return n.center&&l.setFromArray(n.center),l.add(s),{type:r,behavior:n.behavior,radius:n.radius||0,center:l}}}},r&&i.fromData(r),i}x(n,e);var r=n.prototype;return r.start=function(){var e;this.createContent(),this.item.type=_,this.priority=this.item.renderOrder,this.sceneManager=td(this),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},r.update=function(e){this.sceneManager&&this.content.build(this.sceneManager),this.content.update()},r.render=function(e){this.getVisible()&&this.sceneManager&&this.content.render(this.sceneManager,e)},r.onDestroy=function(){var e;null==(e=this.sceneManager)||e.removeItem(this.content),this.sceneManager=void 0,this.content.dispose()},r.fromData=function(t){e.prototype.fromData.call(this,t),this.data=t},r.createContent=function(){if(this.data){var e=this.data.interaction;this.bounding=e&&JSON.parse(JSON.stringify(e)),this.content=new eC(this.engine,this.item.name,this.data,this,this.item.parentId)}},r.setVisible=function(e){var t;null==(t=this.content)||t.onVisibleChanged(e)},r.getVisible=function(){var e,t;return null!=(t=null==(e=this.content)?void 0:e.visible)&&t},r.computeBoundingBox=function(){if(this.content&&M(this.content,eC)){var e,n=this.transform.getWorldMatrix(),r=this.content.computeBoundingBox(n),i=r.getCenter(new L),o=r.getSize(new L);return this.bounding={behavior:null==(e=this.bounding)?void 0:e.behavior,type:t.spec.ModelBoundingType.box,center:[i.x,i.y,i.z],size:[o.x,o.y,o.z]},this.bounding}},n}(t.RendererComponent),e.ModelMeshComponent=I([t.effectsClass(t.spec.DataType.MeshComponent)],e.ModelMeshComponent),e.ModelSkyboxComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}x(t,e);var n=t.prototype;return n.start=function(){var e;this.createContent(),this.item.type=_,this.priority=this.item.renderOrder,this.sceneManager=td(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),this.data=t},n.createContent=function(){if(this.data){var e=this.data;this.content=new tl(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}(t.RendererComponent),e.ModelSkyboxComponent=I([t.effectsClass(t.spec.DataType.SkyboxComponent)],e.ModelSkyboxComponent),e.ModelLightComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}x(t,e);var n=t.prototype;return n.start=function(){this.createContent(),this.item.type=_;var e=td(this);null==e||e.addItem(this.content),this.setVisible(!0)},n.update=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 ey(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}(t.ItemBehaviour),e.ModelLightComponent=I([t.effectsClass(t.spec.DataType.LightComponent)],e.ModelLightComponent),e.ModelCameraComponent=function(e){function t(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}x(t,e);var n=t.prototype;return n.start=function(){this.createContent(),this.item.type=_;var e=td(this);null==e||e.addItem(this.content),this.updateMainCamera()},n.update=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 eg(this.item.name,t,n,e,this)}},n.updateMainCamera=function(){this.content.matrix=this.transform.getWorldMatrix();var e=this.item.composition;e&&(e.camera.position=this.transform.position.clone(),e.camera.setQuat(this.transform.quat),e.camera.near=this.content.nearPlane,e.camera.far=this.content.farPlane,e.camera.fov=this.content.fov)},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}(t.ItemBehaviour),e.ModelCameraComponent=I([t.effectsClass(t.spec.DataType.CameraComponent)],e.ModelCameraComponent),e.AnimationComponent=function(e){function t(t){var n;return(n=e.call(this,t)||this).elapsedTime=0,n.animation=-1,n.clips=[],n}x(t,e);var n=t.prototype;return n.start=function(){this.elapsedTime=0,this.item.type=_},n.update=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 eY(i.engine);t.setFromAnimationClip(e),i.clips.push(t)})},t}(t.ItemBehaviour),e.AnimationComponent=I([t.effectsClass(t.spec.DataType.AnimationComponent)],e.AnimationComponent);var eY=function(t){function n(){var e;return e=t.apply(this,arguments)||this,e.path2Node={},e}x(n,t);var r=n.prototype;return r.sampleAnimation=function(t,n){for(var r,i=Math.max(0,n)%t.duration,o=en(this.positionCurves);!(r=o()).done;){var a=r.value,s=a.keyFrames.getValue(i%this.duration),l=this.getTargetItem(t,a.path);null==l||l.transform.setPosition(s.x,s.y,s.z)}for(var c,u=en(this.rotationCurves);!(c=u()).done;){var h=c.value,f=h.keyFrames.getValue(i%this.duration),d=this.getTargetItem(t,h.path);null==d||d.transform.setQuaternion(f.x,f.y,f.z,f.w)}for(var m,p=en(this.scaleCurves);!(m=p()).done;){var g=m.value,v=g.keyFrames.getValue(i%this.duration),y=this.getTargetItem(t,g.path);null==y||y.transform.setScale(v.x,v.y,v.z)}for(var T,_=en(this.floatCurves);!(T=_()).done;){var b=T.value,C=b.keyFrames.getValue(i%this.duration),S=this.getTargetItem(t,b.path);if("ModelMeshComponent"===b.className){var x=null==S?void 0:S.getComponent(e.ModelMeshComponent);x?function(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]){console.error("Invalid properties "+t+".");return}i=i[a]}i[t[r-1]]=n}(x,b.property.split("."),C):console.error("Can't find mesh component.")}else console.warn("Ignore curve: className "+b.className+".")}},r.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()},r.getTargetItem=function(e,t){if(this.path2Node[t])return this.path2Node[t];for(var n,r=e,i=t.split("/"),o=en(i);!(n=o()).done;){for(var a,s=n.value,l=!1,c=en(r.children);!(a=c()).done;){var u=a.value;if(u.name===s){r=u,l=!0;break}}if(!l)throw Error("Can't find path in tree "+e.id+", "+t+".")}return this.path2Node[t]=r,r},n}(t.AnimationClip);function eZ(e,t,n){var r=t.clone().invert(),i=e.clone().applyMatrix(r),o=L.fromArray(n.center),a=L.fromArray(n.size).multiply(.5),s=o.clone().subtract(a),l=o.clone().add(a),c=i.intersectBox({min:s,max:l},new L);return void 0!==c?[t.transformPoint(c)]:void 0}function eK(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 eQ=new L,e$=new L,e0=new L,e1=new L;function e2(e,t,n,r,i,o){e$.subtractVectors(r,n),e0.subtractVectors(i,n),e1.crossVectors(e$,e0);var a=t.dot(e1),s=0;if(a>0){if(o)return;s=1}else{if(!(a<0))return;s=-1,a=-a}eQ.subtractVectors(e,n),e0.crossVectors(eQ,e0);var l=s*t.dot(e0);if(!(l<0)){e$.crossVectors(e$,eQ);var c=s*t.dot(e$);if(!(c<0)&&!(l+c>a)){var u=-s*eQ.dot(e1);if(!(u<0))return u/a}}}var e3=function(){function e(){}return e.createTexture2D=function(n,r,i,o,a){return C(function(){var s,l,c,u;return A(this,function(h){return void 0===r.imageData?(console.error("createTexture2D: Invalid image data from "+r+"."),[2,t.Texture.create(n,{name:"createTexture2D",sourceType:t.TextureSourceType.data,data:{data:new Uint8Array([255,255,255,255]),width:1,height:1}})]):(s=new Blob([r.imageData],{type:r.mimeType}),c=(l=window.URL||window.webkitURL).createObjectURL(s),(u=new Image).src=c,[2,new Promise(function(r,s){u.onload=function(){var s,h,f,d,m=null!=(s=i.minFilter)?s:t.glContext.LINEAR_MIPMAP_LINEAR,p=!1;a&&(m=t.glContext.LINEAR_MIPMAP_LINEAR,e.isPow2(u.width)&&e.isPow2(u.height)||(m=t.glContext.LINEAR),p=!o);var g=!1;(m==t.glContext.NEAREST_MIPMAP_NEAREST||m==t.glContext.LINEAR_MIPMAP_NEAREST||m==t.glContext.NEAREST_MIPMAP_LINEAR||m==t.glContext.LINEAR_MIPMAP_LINEAR)&&(g=!0),r(t.Texture.create(n,{name:"createTexture2D",wrapS:null!=(h=i.wrapS)?h:t.glContext.REPEAT,wrapT:null!=(f=i.wrapT)?f:t.glContext.REPEAT,magFilter:null!=(d=i.magFilter)?d:t.glContext.LINEAR,minFilter:m,anisotropic:1,premultiplyAlpha:p,sourceType:t.TextureSourceType.image,image:u,generateMipmap:g})),l.revokeObjectURL(c)},u.onerror=s})])})})()},e.createTextureList=function(e,t,n){var r=this;return C(function(){return A(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()]}})})()},e.getTextureCubeData=function(e){return C(function(){var t;return A(this,function(n){switch(n.label){case 0:return[4,e8.loadImageFromImageData(e[0])];case 1:return t=[n.sent()],[4,e8.loadImageFromImageData(e[1])];case 2:return t=t.concat([n.sent()]),[4,e8.loadImageFromImageData(e[2])];case 3:return t=t.concat([n.sent()]),[4,e8.loadImageFromImageData(e[3])];case 4:return t=t.concat([n.sent()]),[4,e8.loadImageFromImageData(e[4])];case 5:return t=t.concat([n.sent()]),[4,e8.loadImageFromImageData(e[5])];case 6:return[2,t.concat([n.sent()])]}})})()},e.getTextureCubeMipmapData=function(e){var t=this;return C(function(){var n,r,i;return A(this,function(o){switch(o.label){case 0:n=[],r=0,o.label=1;case 1:if(!(r<e.length))return[3,4];return i=n.push,[4,t.getTextureCubeData(e[r])];case 2:i.apply(n,[o.sent()]),o.label=3;case 3:return r++,[3,1];case 4:return[2,n]}})})()},e.createTextureCubeFromURL=function(e,n){var r=this;return C(function(){var i;return A(this,function(o){switch(o.label){case 0:return[4,t.getDefaultTextureFactory().loadSource({type:t.TextureSourceType.image,target:t.glContext.TEXTURE_CUBE_MAP,map:n},r.cubemapTexConfig)];case 1:return i=o.sent(),[2,t.Texture.create(e,i)]}})})()},e.createTextureCubeMipmapFromURL=function(e,n){var r=this;return C(function(){var i;return A(this,function(o){switch(o.label){case 0:return[4,t.getDefaultTextureFactory().loadSource({type:t.TextureSourceType.mipmaps,target:t.glContext.TEXTURE_CUBE_MAP,maps:n},r.cubemapMipTexConfig)];case 1:return i=o.sent(),[2,t.Texture.create(e,i)]}})})()},e.createTextureCubeFromBuffer=function(n,r){var i=this;return C(function(){var o;return A(this,function(a){switch(a.label){case 0:return[4,e.getTextureCubeData(r)];case 1:return o=a.sent(),[2,t.Texture.create(n,w({name:"createTextureCubeFromBuffer",sourceType:t.TextureSourceType.image,cube:o,target:t.glContext.TEXTURE_CUBE_MAP},i.cubemapTexConfig))]}})})()},e.createTextureCubeMipmapFromBuffer=function(n,r,i){var o=this;return C(function(){var a,s,l,c;return A(this,function(u){switch(u.label){case 0:return[4,e.getTextureCubeMipmapData(r)];case 1:for(a=u.sent(),s=0;Math.pow(2,s)<i;)++s;u.label=2;case 2:if(!(a.length<=s))return[3,4];return l="https://gw.alipayobjects.com/zos/gltf-asset/67896749597915/img"+Math.pow(2,s-a.length)+".png",[4,t.loadImage(l)];case 3:return c=u.sent(),a.push([c,c,c,c,c,c]),[3,2];case 4:return[2,t.Texture.create(n,w({name:"createTextureCubeMipmapFromBuffer",sourceType:t.TextureSourceType.mipmaps,mipmaps:a,target:t.glContext.TEXTURE_CUBE_MAP},o.cubemapMipTexConfig))]}})})()},e.getTexture=function(e,t){return e<0||e>=t.length?null:t[e]},e.createTextureFromImage=function(e,n){var r={name:"createTextureFromImage",image:n,sourceType:t.TextureSourceType.image,flipY:!1,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR,wrapT:t.glContext.REPEAT,wrapS:t.glContext.REPEAT};return t.Texture.create(e,r)},e.createRenderPass=function(e,n,r,i,o){var a=M(i,t.Mesh)?[i]:i;return new t.RenderPass(e,{name:n,priority:r,attachments:o.colorAttachments,depthStencilAttachment:o.depthAttachment,clearAction:{clearDepth:1,clearStencil:0,clearColor:[0,0,0,0],colorAction:t.TextureLoadAction.clear,depthAction:t.TextureLoadAction.clear},meshes:a,viewport:o.viewport})},e.deleteTexture=function(e){e.dispose()},e.deleteMesh=function(e){e.dispose({geometries:t.DestroyOptions.destroy,material:{textures:t.DestroyOptions.destroy}})},e.deleteGeometry=function(e){e.dispose()},e.deleteRenderPass=function(e){e.dispose({meshes:{geometries:t.DestroyOptions.destroy,material:{textures:t.DestroyOptions.destroy}},depthStencilAttachment:t.RenderPassDestroyAttachmentType.force,colorAttachment:t.RenderPassDestroyAttachmentType.force,semantics:t.DestroyOptions.destroy})},e.isTransparentMesh=function(e){return!0===e.material.blending},e.isSupportFloatTexture=function(e){return 0!==e.gpuCapability.detail.floatTexture},e.isSupportHalfFloatTexture=function(e){return 0!==e.gpuCapability.detail.halfFloatTexture},e.isPow2=function(e){return!(e&e-1)&&!!e},e}();e3.cubemapTexConfig={name:"cubemap texture",wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR},e3.cubemapMipTexConfig={wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR_MIPMAP_LINEAR};var e4=function(){function e(){}return e.createFilterMesh=function(n,r,i,o){var a=q.getInstance(),s=i.vertexShaderCode,l=i.fragmentShaderCode,c=t.Geometry.create(n,e.getPlaneGeometry()),u=2===n.gpuCapability.level,h=t.Material.create(n,{shader:{vertex:s,fragment:l,shared:a.shaderShared,glslVersion:u?t.GLSLVersion.GLSL3:t.GLSLVersion.GLSL1},uniformSemantics:o});return i.setMaterialStates(h),t.Mesh.create(n,{name:r,worldMatrix:D.fromIdentity(),material:h,geometry:c})},e.getPlaneGeometry=function(){var n=e.getPlaneVertexArray();return{attributes:{aPos:{type:t.glContext.FLOAT,size:3,data:n,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:0},aUV:{type:t.glContext.FLOAT,size:2,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:3*Float32Array.BYTES_PER_ELEMENT,dataSource:"aPos"},aNormal:{type:t.glContext.FLOAT,size:3,stride:8*Float32Array.BYTES_PER_ELEMENT,offset:5*Float32Array.BYTES_PER_ELEMENT,dataSource:"aPos"}},drawStart:0,drawCount:n.length/8}},e.getPlaneVertexArray=function(){return new Float32Array([-1,-1,0,0,0,0,0,1,1,-1,0,1,0,0,0,1,1,1,0,1,1,0,0,1,-1,-1,0,0,0,0,0,1,1,1,0,1,1,0,0,1,-1,1,0,0,1,0,0,1])},e}(),e6=function(){function e(){}return e.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"}},e.createCameraOptions=function(e){if(void 0!==e.perspective){var t,n=e.perspective;return{near:n.znear,far:null!=(t=n.zfar)?t:1e3,fov:n.yfov,clipMode:0}}},e.toPlayerColor3=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2])]},e.toPlayerColor4=function(e){return[this.scaleTo255(e[0]),this.scaleTo255(e[1]),this.scaleTo255(e[2]),this.scaleTo255(e[3])]},e.toPluginColor3=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2])]},e.toPluginColor4=function(e){return[this.scaleTo1(e[0]),this.scaleTo1(e[1]),this.scaleTo1(e[2]),this.scaleTo1(e[3])]},e.createUVTransform=function(e,t,n){var r=e.getVector4(t),i=e.getFloat(n),o=O.fromIdentity();r&&o.setFromArray([1,0,0,0,1,0,r.z,r.w,1]);var a=new O;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},e.clamp=function(e,t,n){return Math.max(Math.min(e,n),t)},e.scaleTo255=function(e){return Math.max(0,Math.min(Math.round(255*e),255))},e.scaleTo1=function(e){return Math.max(0,Math.min(e/255,1))},e.focusOnPoint=function(e,n,r){var i=L.fromArray(e),o=L.fromArray(r),a=new L().copyFrom(i).subtract(o);D.fromRotationAxis(new L(0,1,0),n*H).transformPoint(a);var s=a.clone().add(o),l=new D().lookAt(s,o,new L(0,1,0)).invert(),c=new t.Transform;return c.setValid(!0),c.cloneFromMatrix(l),c},e.preprocessScene=function(e,n,r){var i=this,o=n!==t.PLAYER_OPTIONS_ENV_EDITOR,a="tiny3d"===r,s=e.jsonScene;if(!(s&&s.textures&&s.materials))return{};var l={};e.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(e){e.dataType===t.spec.DataType.SkyboxComponent&&(c=!0,e.diffuseImage&&i.preprocessTextureOptions(l,e.diffuseImage,!1,a),e.specularImage&&i.preprocessTextureOptions(l,e.specularImage,!1,a))})),{loadSkybox:c}},e.preprocessTextureOptions=function(e,n,r,i){if(i&&n&&(o="texture"in n?n.texture.id:n.id)){var o,a=e[o];if(a){if(void 0===a.target||a.target===t.glContext.TEXTURE_2D){a.wrapS=t.glContext.REPEAT,a.wrapT=t.glContext.REPEAT,a.magFilter=t.glContext.LINEAR,a.minFilter=t.glContext.LINEAR_MIPMAP_LINEAR,r||(a.premultiplyAlpha=!0),a.generateMipmap=!0;var s=a.image;s&&s.width&&s.height&&(!e3.isPow2(s.width)||!e3.isPow2(s.height))&&(a.minFilter=t.glContext.LINEAR)}else a.target===t.glContext.TEXTURE_CUBE_MAP&&(a.wrapS=t.glContext.CLAMP_TO_EDGE,a.wrapT=t.glContext.CLAMP_TO_EDGE,void 0!==a.mipmaps?1===a.mipmaps.length?(a.magFilter=t.glContext.LINEAR,a.minFilter=t.glContext.LINEAR):(a.magFilter=t.glContext.LINEAR,a.minFilter=t.glContext.LINEAR_MIPMAP_LINEAR):(a.magFilter=t.glContext.LINEAR,a.minFilter=t.glContext.LINEAR))}}},e.setupItem3DOptions=function(e,n,r){var i=this;if(void 0!==e&&!(e.bins.length<=0)){var o=e.jsonScene,a=new Set;void 0===o.compositionId&&a.add(0),o.compositions.forEach(function(e,t){(e.id===o.compositionId||r.refCompositionProps.has(e.id))&&a.add(t)}),a.forEach(function(a){o.compositions[a].items.forEach(function(o){var s=o.id,l=r.getEngine().jsonSceneData[s];if(l.type===t.spec.ItemType.mesh){var c=l.content.options.skin;if(l.content.options.primitives.forEach(function(o,l){if(!M(o.geometry,t.Geometry)){var c=n.getOrCreateGeometry("Geom_C"+a+"_I"+s+"_P"+l,o.geometry,e.bins);o.geometry=c;var u=o.material;if(u.type===t.spec.MaterialType.pbr){var h=o.material;h.baseColorTexture=i.getTextureObj(r.textures,u.baseColorTexture),h.metallicRoughnessTexture=i.getTextureObj(r.textures,u.metallicRoughnessTexture),h.normalTexture=i.getTextureObj(r.textures,u.normalTexture),h.occlusionTexture=i.getTextureObj(r.textures,u.occlusionTexture),h.emissiveTexture=i.getTextureObj(r.textures,u.emissiveTexture)}else o.material.baseColorTexture=i.getTextureObj(r.textures,u.baseColorTexture)}}),void 0!==c&&void 0!==c.inverseBindMatrices){var u=ee(e.bins,c.inverseBindMatrices);M(u,Float32Array)?c.inverseBindMatrices=u:console.error("setupItem3DOptions: Invalid inverseBindMatrices type, "+u+".")}}else if(l.type===t.spec.ItemType.tree){var h=l.content.options.tree.animations,f=l.content.options.tree.animations;void 0!==h&&void 0!==f&&h.forEach(function(t,n){var r=f[n];t.tracks.forEach(function(t,n){var i=ee(e.bins,t.input),o=ee(e.bins,t.output),a=r.tracks[n];M(i,Float32Array)?a.input=i:console.error("setupItem3DOptions: Type of inputArray should be float32, "+i+"."),M(o,Float32Array)?a.output=o:console.error("setupItem3DOptions: Type of outputArray should be float32, "+o+".")})})}else if(l.type===t.spec.ItemType.skybox){var d=l.content.options,m=l.content.options,p=i.getTextureObj(r.textures,d.specularImage);void 0===p&&console.error("setupItem3DOptions: skybox specualrImage is undefined, "+tt.stringify(d)+"."),m.specularImage=p;var g=i.getTextureObj(r.textures,d.diffuseImage);void 0!==g&&(m.diffuseImage=g)}})})}},e.createGeometry=function(e,n,r){var i=Q(n,r),o={};for(var a in i.attributes){var s=i.attributes[a];o[this.getAttributeName(a)]=s}return i.attributes=o,t.Geometry.create(e,i)},e.getIndexArray=function(e,t){switch(e){case WebGLRenderingContext.UNSIGNED_INT:case WebGLRenderingContext.UNSIGNED_SHORT:case WebGLRenderingContext.UNSIGNED_BYTE:return t;default:console.error("Invalid index attribute type "+e+".")}},e.getAttributeName=function(e){switch(e){case"POSITION":return"aPos";case"NORMAL":return"aNormal";case"TANGENT":return"aTangent";case"TEXCOORD_0":return"aUV";case"TEXCOORD_1":return"aUV2";case"JOINTS_0":return"aJoints";case"WEIGHTS_0":return"aWeights"}return e.startsWith("a")||console.warn("Unknown attribute name: "+e+"."),e},e.getTextureObj=function(e,t){return"number"!=typeof t?null:((t<0||t>=e.length)&&console.error("Invalid index for textures: "+t+", "+e.length+"."),e[t])},e}(),e8=function(){function e(){}return e.getImageFileName=function(e,t){var n=e.lastIndexOf("/"),r=e.lastIndexOf("."),i=e.substring(n+1,r);return t?i+t:i},e.getCurrnetTimeStr=function(){var e=new Date(Date.now()),t=e.toLocaleString("zh-CN"),n=""+e.getMilliseconds();return t.split(/[ /:]+/).join("")+n.padStart(3,"0")},e.saveFileForURL=function(e,t){var n=document.createElement("a");n.setAttribute("download",t),n.target="_blank",n.href=e,n.click()},e.createPlayer=function(e){void 0===e&&(e=!0);var n=document.createElement("canvas");return n.width=512,n.height=512,new t.Player({canvas:n,renderFramework:"webgl2",env:t.PLAYER_OPTIONS_ENV_EDITOR,renderOptions:{willCaptureImage:!0},manualRender:e})},e.sleep=function(e){return C(function(){return A(this,function(t){return[2,new Promise(function(t){return setTimeout(t,e)})]})})()},e.loadImageFromGLTFImage=function(e){return C(function(){return A(this,function(n){return[2,t.loadImage(new Blob([e.imageData],{type:e.mimeType}))]})})()},e.loadImageFromImageData=function(e){return C(function(){return A(this,function(n){return[2,t.loadImage(new Blob([e.data],{type:e.mimeType}))]})})()},e.getCanvasArrayBuffer=function(e){return C(function(){return A(this,function(t){return[2,new Promise(function(t,n){e.toBlob(function(e){e?t(e.arrayBuffer()):n(Error("No canvas blob."))},"image/png",1)})]})})()},e.getImageArrayBuffer=function(e){var t=this;return C(function(){var n;return A(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)]})})()},e.getCanvasImageData=function(e){return e.getContext("2d").getImageData(0,0,e.width,e.height)},e.flipImageData=function(e){var t=document.createElement("canvas"),n=t.getContext("2d");return t.width=e.width,t.height=e.height,n.putImageData(e,0,0),n.globalCompositeOperation="copy",n.scale(1,-1),n.translate(0,-e.height),n.drawImage(t,0,0),n.setTransform(1,0,0,1,0,0),n.globalCompositeOperation="source-over",n.getImageData(0,0,t.width,t.height)},e.getImageData=function(e){var t=document.createElement("canvas");t.width=e.width,t.height=e.height;var n=t.getContext("2d");return n.drawImage(e,0,0),this.flipImageData(n.getImageData(0,0,t.width,t.height))},e.getWebGLCanvasImageBuffer=function(e){var t=e.getContext("webgl2"),n=new Uint8Array(e.width*e.height*4);return t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,n),n},e}(),e5=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 L;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}(),e7=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){var n,r;switch(e.type){case WebGLRenderingContext.INT:this.typeSize=4,this.signed=!0,this.compressScale=1/2147483647;break;case WebGLRenderingContext.SHORT:this.typeSize=2,this.signed=!0,this.compressScale=1/32767;break;default:this.typeSize=4,this.signed=!0,this.compressScale=1}this.data=t,this.length=this.data.length,this.compCount=e.size,this.offset=null!=(n=e.offset)?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,n=this.offset;if(!((n+=e*this.stride)+this.compCount>this.length)){if(t=2===this.compCount?[this.data[n],this.data[n+1],0,0]:3===this.compCount?[this.data[n],this.data[n+1],this.data[n+2],0]:[this.data[n],this.data[n+1],this.data[n+2],this.data[n+3]],this.compressed)for(var r=0;r<this.compCount;r++)t[r]*=this.compressScale,this.signed&&(t[r]=Math.max(t[r],-1));return t}},t.getLength=function(){return Math.round((this.length-this.offset)/this.stride)},e}(),e9=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 e7,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 e7,this.joint.create(o,s),this.weight=new e7,this.weight.create(a,l)}this.bindMatrices=t},t.getBoundingBox=function(e){var t=this;e.makeEmpty();var n=new D,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=L.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 m=n.transformVector4(new R(a.x,a.y,a.z,1));Math.abs(m.w)>1e-4&&(m.multiply(1/m.w),a.set(m.x,m.y,m.z))}}}e.expandByPoint(a)}}),e},e}(),te=function(){function e(){this.drawStart=0,this.drawCount=0,this.doubleSided=!1,this.bindMatrices=[],this.hasAnimation=!1,this.skinMatrix=new D}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 e7,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 e7,this.joint.create(a,l),this.weight=new e7,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 L,i=new L,o=new L,a=new R,s=new R,l=new R,c=!this.doubleSided,u=0;u+2<this.drawCount;u+=3){var h=this.drawStart+u,f=this.drawStart+u+1,d=this.drawStart+u+2;void 0!==this.index&&(h=this.index[h],f=this.index[f],d=this.index[d]);var m=this.getPosition(h,r,a),p=this.getPosition(f,i,s),g=this.getPosition(d,o,l);if(m&&p&&g){var v=e2(e,t,m,p,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}(),tt=function(){function e(){}return e.checkNumber=function(e){return"number"==typeof e},e.checkNumberUndef=function(e){return void 0===e||this.checkNumber(e)},e.checkNumber01=function(e){return this.checkNumber(e)&&e>=0&&e<=1},e.checkNumber01Undef=function(e){return void 0===e||this.checkNumber01(e)},e.checkPositive=function(e){return this.checkNumber(e)&&e>0},e.checkNonnegative=function(e){return this.checkNumber(e)&&e>=0},e.checkNonnegativeUndef=function(e){return void 0===e||this.checkNonnegative(e)},e.checkBoolean=function(e){return"boolean"==typeof e},e.checkBooleanUndef=function(e){return void 0===e||this.checkBoolean(e)},e.checkString=function(e){return"string"==typeof e},e.checkStringUndef=function(e){return void 0===e||this.checkString(e)},e.checkFloat32Array=function(e){return M(e,Float32Array)},e.checkFloat32ArrayUndef=function(e){return void 0===e||this.checkFloat32Array(e)},e.checkParent=function(e){return void 0===e||!!this.checkNumber(e)&&e>=0},e.checkTexCoord=function(e){return void 0===e||!!this.checkNumber(e)&&e>=0&&e<=1},e.checkVec2=function(e){var t=this;return!!Array.isArray(e)&&2==e.length&&e.every(function(e){return t.checkNumber(e)})},e.checkVec2Undef=function(e){return void 0===e||this.checkVec2(e)},e.checkVec3=function(e){var t=this;return!!Array.isArray(e)&&3==e.length&&e.every(function(e){return t.checkNumber(e)})},e.checkNonnegative3=function(e){var t=this;return!!Array.isArray(e)&&3==e.length&&e.every(function(e){return t.checkNonnegative(e)})},e.checkVec4=function(e){var t=this;return!!Array.isArray(e)&&4==e.length&&e.every(function(e){return t.checkNumber(e)})},e.checkNonnegative4=function(e){var t=this;return!!Array.isArray(e)&&4==e.length&&e.every(function(e){return t.checkNonnegative(e)})},e.checkNumberArray=function(e){var t=this;return!!Array.isArray(e)&&e.every(function(e){return t.checkNumber(e)})},e.checkTexture=function(e){return!!M(e,t.Texture)&&(e.isDestroyed&&console.error("Texture is destroyed, "+e.name+"."),!e.isDestroyed)},e.checkTextureUndef=function(e){return void 0===e||this.checkTexture(e)},e.checkTexTransform=function(e){return!(!this.checkVec2Undef(e.offset)||!this.checkNumberUndef(e.rotation)||!this.checkVec2Undef(e.scale)||void 0!==e.scale&&(1e-5>Math.abs(e.scale[0])||1e-5>Math.abs(e.scale[1])))},e.checkTexTransformUndef=function(e){return void 0===e||this.checkTexTransform(e)},e.checkMatBlending=function(e){return void 0===e||e===t.spec.MaterialBlending.opaque||e===t.spec.MaterialBlending.masked||e===t.spec.MaterialBlending.translucent||e===t.spec.MaterialBlending.additive},e.checkMatSide=function(e){return void 0===e||e===t.spec.SideMode.BACK||e===t.spec.SideMode.DOUBLE||e===t.spec.SideMode.FRONT},e.checkAnimPath=function(e){return"translation"===e||"rotation"===e||"scale"===e||"weights"===e},e.checkAnimInterp=function(e){return"LINEAR"===e||"STEP"===e||"CUBICSPLINE"===e},e.assertGeometry=function(e,n){M(e,t.Geometry)||console.error("Invalid geometry type "+this.stringify(e)+"."),!0===e.isDestroyed&&console.error("Geometry object is destroyed."),this.checkNonnegative(e.getDrawStart())||console.error("Invalid geometry draw start: "+e.getDrawStart()+", "+this.stringify(e)+".")},e.assertGeometryBuffer=function(e,t,n){var 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)+".")},e.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 e7;return o.create(r,i),o}}}},e.assertModelSkinOptions=function(e){if(this.checkStringUndef(e.name)||console.error("Invalid skin name "+e.name+", "+this.stringify(e)+"."),this.checkNumberArray(e.joints)||console.error("Invalid skin joints "+e.joints+", "+this.stringify(e)+"."),this.checkNumberUndef(e.skeleton)||console.error("Invalid skin skeleton "+e.skeleton+", "+this.stringify(e)+"."),this.checkFloat32ArrayUndef(e.inverseBindMatrices)||console.error("Invalid skin inverseBindMatrices "+e.inverseBindMatrices+", "+this.stringify(e)+"."),void 0!==e.inverseBindMatrices){(e.inverseBindMatrices.length<=0||e.inverseBindMatrices.length%16!=0)&&console.error("Invalid skin inverseBindMatrices length "+e.inverseBindMatrices+", "+this.stringify(e)+"."),16*e.joints.length!==e.inverseBindMatrices.length&&console.error("Mismatch: skin joints and inverseBindMatrices length, "+e.joints+", "+e.inverseBindMatrices+", "+this.stringify(e)+".");for(var t=new D,n=0;n<e.inverseBindMatrices.length;n+=16){for(var r=0;r<16;r++)t.elements[r]=e.inverseBindMatrices[n+r];1e-5>Math.abs(t.determinant())&&console.error("Determinant of inverseBindMatrices is too small "+t.determinant()+", index "+n/16+", "+this.stringify(e)+".")}}else e.joints.length<=0&&console.error("Invalid skin joints length "+e.joints+", "+this.stringify(e)+".")},e.assertMatOptions=function(e){e.type===t.spec.MaterialType.unlit?(this.checkString(e.name)||console.error("Invalid material name "+e.name+", "+this.stringify(e)+"."),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor "+e.baseColorFactor+", "+this.stringify(e)+"."),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture "+e.baseColorTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform "+e.baseColorTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate "+e.baseColorTextureCoordinate+", "+this.stringify(e)+"."),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask "+e.depthMask+", "+this.stringify(e)+"."),this.checkMatBlending(e.blending)||console.error("Invalid material blending "+e.blending+", "+this.stringify(e)+"."),this.checkMatSide(e.side)||console.error("Invalid material side "+e.side+", "+this.stringify(e)+"."),e.blending===t.spec.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, "+this.stringify(e)+"."),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff "+e.alphaCutOff+", "+this.stringify(e)+".")):e.type===t.spec.MaterialType.pbr?(this.checkString(e.name)||console.error("Invalid material name "+e.name+", "+this.stringify(e)+"."),this.checkNonnegative4(e.baseColorFactor)||console.error("Invalid material baseColorFactor "+e.baseColorFactor+", "+this.stringify(e)+"."),this.checkTextureUndef(e.baseColorTexture)||console.error("Invalid material baseColorTexture "+e.baseColorTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.baseColorTextureTransform)||console.error("Invalid material baseColorTextureTransform "+e.baseColorTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.baseColorTextureCoordinate)||console.error("Invalid material baseColorTextureCoordinate "+e.baseColorTextureCoordinate+", "+this.stringify(e)+"."),this.checkBooleanUndef(e.useSpecularAA)||console.error("Invalid material useSpecularAA "+e.useSpecularAA+", "+this.stringify(e)+"."),this.checkNumber01(e.metallicFactor)||console.error("Invalid material metallicFactor "+e.metallicFactor+", "+this.stringify(e)+"."),this.checkNonnegative(e.roughnessFactor)||console.error("Invalid material roughnessFactor "+e.roughnessFactor+", "+this.stringify(e)+"."),this.checkTextureUndef(e.metallicRoughnessTexture)||console.error("Invalid material metallicRoughnessTexture "+e.metallicRoughnessTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.metallicRoughnessTextureTransform)||console.error("Invalid material metallicRoughnessTextureTransform "+e.metallicRoughnessTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.metallicRoughnessTextureCoordinate)||console.error("Invalid material metallicRoughnessTextureCoordinate "+e.metallicRoughnessTextureCoordinate+", "+this.stringify(e)+"."),this.checkTextureUndef(e.normalTexture)||console.error("Invalid material normalTexture "+e.normalTexture+", "+this.stringify(e)+"."),this.checkNonnegativeUndef(e.normalTextureScale)||console.error("Invalid material normalTextureScale "+e.normalTextureScale+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.normalTextureTransform)||console.error("Invalid material normalTextureTransform "+e.normalTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.normalTextureCoordinate)||console.error("Invalid material normalTextureCoordinate "+e.normalTextureCoordinate+", "+this.stringify(e)+"."),this.checkTextureUndef(e.occlusionTexture)||console.error("Invalid material occlusionTexture "+e.occlusionTexture+", "+this.stringify(e)+"."),this.checkNumber01Undef(e.occlusionTextureStrength)||console.error("Invalid material occlusionTextureStrength "+e.occlusionTextureStrength+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.occlusionTextureTransform)||console.error("Invalid material occlusionTextureTransform "+e.occlusionTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.occlusionTextureCoordinate)||console.error("Invalid material occlusionTextureCoordinate "+e.occlusionTextureCoordinate+", "+this.stringify(e)+"."),this.checkNonnegative4(e.emissiveFactor)||console.error("Invalid material emissiveFactor "+e.emissiveFactor+", "+this.stringify(e)+"."),this.checkNonnegative(e.emissiveIntensity)||console.error("Invalid material emissiveIntensity "+e.emissiveIntensity+", "+this.stringify(e)+"."),this.checkTextureUndef(e.emissiveTexture)||console.error("Invalid material emissiveTexture "+e.emissiveTexture+", "+this.stringify(e)+"."),this.checkTexTransformUndef(e.emissiveTextureTransform)||console.error("Invalid material emissiveTextureTransform "+e.emissiveTextureTransform+", "+this.stringify(e)+"."),this.checkTexCoord(e.emissiveTextureCoordinate)||console.error("Invalid material emissiveTextureCoordinate "+e.emissiveTextureCoordinate+", "+this.stringify(e)+"."),this.checkBooleanUndef(e.depthMask)||console.error("Invalid material depthMask "+e.depthMask+", "+this.stringify(e)+"."),this.checkMatBlending(e.blending)||console.error("Invalid material blending "+e.blending+", "+this.stringify(e)+"."),this.checkMatSide(e.side)||console.error("Invalid material side "+e.side+", "+this.stringify(e)+"."),e.blending===t.spec.MaterialBlending.masked&&void 0===e.alphaCutOff&&console.error("Material alphaCutOff is required for mask, "+this.stringify(e)+"."),this.checkNumber01Undef(e.alphaCutOff)||console.error("Invalid material alphaCutOff "+e.alphaCutOff+", "+this.stringify(e)+".")):console.error("Invalid material type "+this.stringify(e)+".")},e.assertPrimOptions=function(e,t){return this.assertGeometry(e.geometry,t),this.assertMatOptions(e.material),!0},e.assertModelMeshOptions=function(e){this.checkParent(e.parent)||console.error("Invalid mesh parent "+e.parent+", "+this.stringify(e)+"."),void 0!==e.skin&&this.assertModelSkinOptions(e.skin);for(var t=[],n=0;n<e.primitives.length;n++){var r=e.primitives[n];this.assertPrimOptions(r)||console.error("Invalid primitive "+r+", "+this.stringify(e)+".");var i=new eu;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)+".")},e.assertModelCameraOptions=function(e){this.checkParent(e.parent)||console.error("Invalid camera parent "+e.parent+", "+this.stringify(e)+"."),this.checkNumberUndef(e.aspect)||console.error("Invalid camera aspect "+e.aspect+", "+this.stringify(e)+"."),this.checkPositive(e.near)||console.error("Invalid camera near "+e.near+", "+this.stringify(e)+"."),(!this.checkPositive(e.far)||e.far<=e.near)&&console.error("Invalid camera far "+e.far+", "+this.stringify(e)+"."),this.checkPositive(e.fov)||console.error("Invalid camera fov "+e.fov+", "+this.stringify(e)+"."),this.checkNumber01(e.clipMode)||console.error("Invalid camera clipMode "+e.clipMode+", "+this.stringify(e)+".")},e.assertModelLightOptions=function(e){"directional"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+".")):"point"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+"."),this.checkNonnegative(e.range)||console.error("Invalid light range "+e.range+", "+this.stringify(e)+".")):"spot"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+"."),this.checkNonnegative(e.range)||console.error("Invalid light range "+e.range+", "+this.stringify(e)+"."),this.checkNonnegative(e.innerConeAngle)||console.error("Invalid light innerConeAngle "+e.innerConeAngle+", "+this.stringify(e)+"."),this.checkNonnegative(e.outerConeAngle)||console.error("Invalid light outerConeAngle "+e.outerConeAngle+", "+this.stringify(e)+".")):"ambient"===e.lightType?(this.checkParent(e.parent)||console.error("Invalid light parent "+e.parent+", "+this.stringify(e)+"."),this.checkNonnegative4(e.color)||console.error("Invalid light color "+e.color+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid light intensity "+e.intensity+", "+this.stringify(e)+".")):console.error("Invalid light type "+this.stringify(e)+".")},e.assertModelSkyboxOptions=function(e){var t=this;this.checkBoolean(e.renderable)||console.error("Invalid skybox renderable "+e.renderable+", "+this.stringify(e)+"."),this.checkNonnegative(e.intensity)||console.error("Invalid skybox intensity "+e.intensity+", "+this.stringify(e)+"."),this.checkNonnegative(e.reflectionsIntensity)||console.error("Invalid skybox reflectionsIntensity "+e.reflectionsIntensity+", "+this.stringify(e)+".");var n=e.irradianceCoeffs;void 0!==n?(Array.isArray(n)&&9==n.length||console.error("Invalid skybox irradianceCoeffs "+n+", "+this.stringify(e)+"."),n.forEach(function(e){t.checkVec3(e)||console.error("Invalid skybox irradianceCoeffs "+n+", "+t.stringify(e)+".")})):void 0!==e.diffuseImage?this.checkTexture(e.diffuseImage)||console.error("Invalid skybox diffuseImage "+e.diffuseImage+", "+this.stringify(e)+"."):console.error("Invalid skybox, irradianceCoeffs or diffuseImage should give one, "+this.stringify(e)+"."),this.checkTexture(e.specularImage)||console.error("Invalid skybox specularImage "+e.specularImage+", "+this.stringify(e)+"."),this.checkPositive(e.specularImageSize)||console.error("Invalid skybox specularImageSize "+e.specularImageSize+", "+this.stringify(e)+"."),this.checkPositive(e.specularMipCount)||console.error("Invalid skybox specularMipCount "+e.specularMipCount+", "+this.stringify(e)+"."),this.pow2(e.specularMipCount)>e.specularImageSize&&console.error("Invalid skybox specularMipCount or specularImageSize, "+this.stringify(e)+".")},e.checkModelAnimTrackOptions=function(e){return this.checkNonnegative(e.node)?this.checkFloat32Array(e.input)?this.checkFloat32Array(e.output)?this.checkAnimPath(e.path)?!!this.checkAnimInterp(e.interpolation)||(console.error("Invalid track interpolation "+e.interpolation+", "+this.stringify(e)),!1):(console.error("Invalid track path "+e.path+", "+this.stringify(e)),!1):(console.error("Invalid track input "+e.output+", "+this.stringify(e)),!1):(console.error("Invalid track input "+e.input+", "+this.stringify(e)),!1):(console.error("Invalid track node "+e.node+", "+this.stringify(e)),!1)},e.assertModelAnimOptions=function(e){var t=this;this.checkStringUndef(e.name)||console.error("Invalid animation name "+e.name+", "+this.stringify(e)+"."),Array.isArray(e.tracks)||console.error("Invalid animation tracks "+e.tracks+", "+this.stringify(e)+"."),e.tracks.forEach(function(n){t.checkModelAnimTrackOptions(n)||console.error("Invalid animation track "+n+", "+t.stringify(e)+".")})},e.assertTreeOptions=function(e){var t=this;this.checkNumberUndef(e.animation)||console.error("Invalid tree animation "+e.animation+", "+this.stringify(e)+"."),void 0!==e.animations&&(Array.isArray(e.animations)||console.error("Invalid tree animations "+e.animations+", "+this.stringify(e)+"."),e.animations.forEach(function(e){t.assertModelAnimOptions(e)}),void 0!==e.animation&&(e.animation<-1||e.animation>=e.animations.length)&&console.error("Invalid tree animations "+e.animations+", "+this.stringify(e)+"."))},e.stringify=function(e){var n={};for(var r in e)if("internal"!==r&&"function"!=typeof e[r]){if(M(e[r],t.Texture)||M(e[r],t.Geometry)){n[r]=e[r].name;continue}M(e[r],t.Renderer)||(n[r]=e[r])}return JSON.stringify(n)},e.pow2=function(e){for(var t=1;e-- >0;)t*=2;return t},e}(),tn=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]=tr(e[n])},N(e,[{key:"bytes",get:function(){return 2*this.size}}]),e}(),tr=(m=new Int32Array((d=new Float32Array(1)).buffer),function(e){d[0]=e;var t=m[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?(r|=2048,n|=(r>>114-i)+(r>>113-i&1)):(n|=i-112<<10|r>>1,n+=1&r)}),ti=function(n){function r(){var r;return r=n.apply(this,arguments)||this,r.materialType=e.PMaterialType.none,r.vertexShaderCode="",r.fragmentShaderCode="",r.ZWrite=!0,r.ZTest=!0,r.renderType=t.spec.RenderType.Opaque,r.alphaClip=!1,r.alphaCutoff=.5,r.renderFace=t.spec.RenderFace.Front,r}x(r,n);var i=r.prototype;return i.getShaderFeatures=function(){var e=[];return this.isAlphaClip()?e.push("ALPHAMODE_MASK 1"):this.isOpaque()&&e.push("ALPHAMODE_OPAQUE 1"),this.renderFace===t.spec.RenderFace.Both&&e.push("DOUBLE_SIDED 1"),e},i.getShaderMacros=function(){var e=[];return this.isAlphaClip()?e.push({name:"ALPHAMODE_MASK"}):this.isOpaque()&&e.push({name:"ALPHAMODE_OPAQUE"}),this.renderFace===t.spec.RenderFace.Both&&e.push({name:"DOUBLE_SIDED"}),e},i.updateUniforms=function(e){if(q.getInstance().renderMode3D===t.spec.RenderMode3D.uv){var n=q.getInstance().renderMode3DUVGridSize;e.setFloat("_DebugUVGridSize",n)}},i.build=function(e){var t=this.getFeatureList(e),n=q.getInstance().isWebGL2,r=eW.getInstance().genShaderCode({material:this,isWebGL2:n,featureList:t});this.vertexShaderCode=r.vertexShaderCode,this.fragmentShaderCode=r.fragmentShaderCode},i.getFeatureList=function(t){var n=this.getShaderFeatures();return void 0!==t&&n.push.apply(n,[].concat(t)),q.getInstance().isWebGL2&&n.push("WEBGL2"),this.materialType!==e.PMaterialType.shadowBase&&q.getInstance().isEditorEnv&&n.push("EDITOR_TRANSFORM"),n},i.getMacroList=function(t){var n=this.getShaderMacros();return void 0!==t&&n.push.apply(n,[].concat(t)),q.getInstance().isWebGL2&&n.push({name:"WEBGL2"}),this.materialType!==e.PMaterialType.shadowBase&&q.getInstance().isEditorEnv&&n.push({name:"EDITOR_TRANSFORM"}),n},i.setMaterialStates=function(e){this.renderType===t.spec.RenderType.Transparent?(e.blending=!0,e.depthTest=this.ZTest,e.depthMask=this.ZWrite,e.blendEquation=[t.glContext.FUNC_ADD,t.glContext.FUNC_ADD],e.blendFunction=[t.glContext.ONE,t.glContext.ONE_MINUS_SRC_ALPHA,t.glContext.ONE,t.glContext.ONE_MINUS_SRC_ALPHA]):q.getInstance().isTiny3dMode?(e.blending=!1,e.depthTest=!0,e.depthMask=!0):(e.blending=!1,e.depthTest=this.ZTest,e.depthMask=this.ZWrite),this.setFaceSideStates(e)},i.setFaceSideStates=function(e){this.isBothSide()?e.culling=!1:(this.isBackSide()?e.cullFace=t.glContext.FRONT:e.cullFace=t.glContext.BACK,e.frontFace=t.glContext.CCW,e.culling=!0)},i.dispose=function(){this.vertexShaderCode="",this.fragmentShaderCode=""},i.isValid=function(){return this.materialType!==e.PMaterialType.none&&n.prototype.isValid.call(this)},i.isOpaque=function(){return this.renderType===t.spec.RenderType.Opaque},i.isAlphaClip=function(){return this.alphaClip},i.isTransparent=function(){return this.renderType===t.spec.RenderType.Transparent},i.isFrontSide=function(){return this.renderFace===t.spec.RenderFace.Front},i.isBackSide=function(){return this.renderFace===t.spec.RenderFace.Back},i.isBothSide=function(){return this.renderFace===t.spec.RenderFace.Both},r}(Z),to=function(n){function r(){var e;return e=n.apply(this,arguments)||this,e.baseColorFactor=new F(1,1,1,1),e}x(r,n);var i=r.prototype;return i.create=function(n){var r,i,o,a,s;this.effectMaterial=n,this.name=n.name,this.type=e.PObjectType.material,this.materialType=e.PMaterialType.unlit,this.baseColorTexture=null!=(r=n.getTexture("_BaseColorSampler"))?r:void 0,this.baseColorTextureTrans=e6.createUVTransform(n,"_BaseColorSampler_ST","_BaseColorRotation"),this.baseColorFactor=null!=(i=n.getColor("_BaseColorFactor"))?i:new F(1,1,1,1),this.ZWrite=0!==n.getFloat("ZWrite"),this.ZTest=0!==n.getFloat("ZTest"),this.renderType=null!=(o=n.stringTags.RenderType)?o:t.spec.RenderType.Opaque,this.alphaClip=1===n.getFloat("AlphaClip"),this.alphaCutoff=null!=(a=n.getFloat("_AlphaCutoff"))?a:0,this.renderFace=null!=(s=n.stringTags.RenderFace)?s:t.spec.RenderFace.Front},i.dispose=function(){n.prototype.dispose.call(this),this.baseColorTexture=void 0},i.getShaderFeatures=function(){var e=n.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},i.getShaderMacros=function(){var e=n.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},i.updateUniforms=function(e){n.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)},i.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},i.getBaseColorTexture=function(){return this.baseColorTexture},i.setBaseColorTexture=function(e){this.baseColorTexture=e},i.getBaseColorFactor=function(){return this.baseColorFactor},i.setBaseColorFactor=function(e){M(e,F)?this.baseColorFactor.set(e.r,e.g,e.b,e.a):M(e,R)?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},r}(ti),ta=function(n){function r(){var e;return e=n.apply(this,arguments)||this,e.baseColorFactor=new F(1,1,1,1),e.useSpecularAA=!1,e.metallicFactor=0,e.roughnessFactor=1,e.normalTextureScale=1,e.occlusionTextureStrength=1,e.emissiveFactor=new F(0,0,0,0),e.emissiveIntensity=1,e}x(r,n);var i=r.prototype;return i.create=function(n){var r,i,o,a,s,l,c,u,h,f,d,m,p,g,v;this.effectMaterial=n,this.name=n.name,this.type=e.PObjectType.material,this.materialType=e.PMaterialType.pbr,this.baseColorTexture=null!=(r=n.getTexture("_BaseColorSampler"))?r:void 0,this.baseColorTextureTrans=e6.createUVTransform(n,"_BaseColorSampler_ST","_BaseColorRotation"),this.baseColorFactor=null!=(i=n.getColor("_BaseColorFactor"))?i:new F(1,1,1,1),this.metallicRoughnessTexture=null!=(o=n.getTexture("_MetallicRoughnessSampler"))?o:void 0,this.metallicRoughnessTextureTrans=e6.createUVTransform(n,"_MetallicRoughnessSampler_ST","_MetallicRoughnessRotation"),this.useSpecularAA=1===n.getFloat("_SpecularAA"),this.metallicFactor=null!=(a=n.getFloat("_MetallicFactor"))?a:1,this.roughnessFactor=null!=(s=n.getFloat("_RoughnessFactor"))?s:0,this.normalTexture=null!=(l=n.getTexture("_NormalSampler"))?l:void 0,this.normalTextureTrans=e6.createUVTransform(n,"_NormalSampler_ST","_NormalRotation"),this.normalTextureScale=null!=(c=n.getFloat("_NormalScale"))?c:1,this.occlusionTexture=null!=(u=n.getTexture("_OcclusionSampler"))?u:void 0,this.occlusionTextureTrans=e6.createUVTransform(n,"_OcclusionSampler_ST","_OcclusionRotation"),this.occlusionTextureStrength=null!=(h=n.getFloat("_OcclusionStrength"))?h:1,this.emissiveTexture=null!=(f=n.getTexture("_EmissiveSampler"))?f:void 0,this.emissiveTextureTrans=e6.createUVTransform(n,"_EmissiveSampler_ST","_EmissiveRotation"),this.emissiveFactor=null!=(d=n.getColor("_EmissiveFactor"))?d:new F(0,0,0,1),this.emissiveIntensity=null!=(m=n.getFloat("_EmissiveIntensity"))?m:1,this.ZWrite=0!==n.getFloat("ZWrite"),this.ZTest=0!==n.getFloat("ZTest"),this.renderType=null!=(p=n.stringTags.RenderType)?p:t.spec.RenderType.Opaque,this.alphaClip=1===n.getFloat("AlphaClip"),this.alphaCutoff=null!=(g=n.getFloat("_AlphaCutoff"))?g:0,this.renderFace=null!=(v=n.stringTags.RenderFace)?v:t.spec.RenderFace.Front},i.dispose=function(){n.prototype.dispose.call(this),this.baseColorTexture=void 0,this.metallicRoughnessTexture=void 0,this.normalTexture=void 0,this.occlusionTexture=void 0,this.emissiveTexture=void 0},i.getShaderFeatures=function(){var e=n.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},i.getShaderMacros=function(){var e=n.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},i.updateUniforms=function(e){n.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)},i.hasBaseColorTexture=function(){return void 0!==this.baseColorTexture},i.setBaseColorTexture=function(e){this.baseColorTexture=e},i.getBaseColorFactor=function(){return this.baseColorFactor},i.setBaseColorFactor=function(e){M(e,F)?this.baseColorFactor.set(e.r,e.g,e.b,e.a):M(e,R)?this.baseColorFactor.set(e.x,e.y,e.z,e.w):this.baseColorFactor.set(e[0],e[1],e[2],e[3])},i.hasMetallicRoughnessTexture=function(){return void 0!==this.metallicRoughnessTexture},i.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture},i.setMetallicRoughnessTexture=function(e){this.metallicRoughnessTexture=e},i.hasNormalTexture=function(){return void 0!==this.normalTexture},i.getNormalTexture=function(){return this.normalTexture},i.setNormalTexture=function(e){this.normalTexture=e},i.hasOcclusionTexture=function(){return void 0!==this.occlusionTexture},i.getOcclusionTexture=function(){return this.occlusionTexture},i.setOcclusionTexture=function(e){this.occlusionTexture=e},i.hasEmissiveTexture=function(){return void 0!==this.emissiveTexture},i.getEmissiveTexture=function(){return this.emissiveTexture},i.setEmissiveTexture=function(e){this.emissiveTexture=e},i.hasEmissiveValue=function(){return this.emissiveFactor.luminance()*this.emissiveIntensity>0},i.getEmissiveFactor=function(){return this.emissiveFactor},i.setEmissiveFactor=function(e){M(e,F)?this.emissiveFactor.set(e.r,e.g,e.b,e.a):M(e,L)?this.emissiveFactor.set(e.x,e.y,e.z,0):this.emissiveFactor.set(e[0],e[1],e[2],0)},i.getEmissiveIntensity=function(){return this.emissiveIntensity},i.setEmissiveIntensity=function(e){this.emissiveIntensity=e},r}(ti);function ts(e){if(e.shader.getInstanceId()===j){var t=new ta;return t.create(e),t}var n=new to;return n.create(e),n}var tl=function(t){function n(n,r,i){(o=t.call(this)||this).renderable=!0,o.intensity=1,o.reflectionsIntensity=1,o.specularImageSize=0,o.specularMipCount=0,o.priority=0,o.isBuilt=!1,o.name=n,o.type=e.PObjectType.skybox,o.visible=!1,o.owner=i;var o,a,s=r.irradianceCoeffs;if(o.renderable=r.renderable,o.intensity=r.intensity,o.reflectionsIntensity=r.reflectionsIntensity,s){o.irradianceCoeffs=[];for(var l=0;l<s.length;l+=3)o.irradianceCoeffs.push([s[l],s[l+1],s[l+2]])}else o.irradianceCoeffs=[];return o.diffuseImage=r.diffuseImage,o.specularImage=r.specularImage,o.specularImageSize=r.specularImageSize,o.specularMipCount=r.specularMipCount,o.priority=(null==i?void 0:null==(a=i.item)?void 0:a.renderOrder)||0,o}x(n,t);var r=n.prototype;return r.setup=function(e){this.brdfLUT=e},r.build=function(e){if(!this.isBuilt){this.isBuilt=!0,this.skyboxMaterial=new tc,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)}},r.render=function(e,t){if(this.updateMaterial(e),this.visible&&this.renderable&&void 0!==this.skyboxMesh){var n=this.skyboxMesh;t.drawGeometry(n.geometry,n.material)}},r.dispose=function(){var e;t.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==(e=this.skyboxMaterial)||e.dispose(),this.skyboxMaterial=void 0},r.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)}},N(n,[{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}}]),n}(K),tc=function(t){function n(){var e;return e=t.apply(this,arguments)||this,e.intensity=1,e.reflectionsIntensity=1,e.specularMipCount=0,e}x(n,t);var r=n.prototype;return r.create=function(t){this.type=e.PObjectType.material,this.materialType=e.PMaterialType.skyboxFilter,this.ZTest=!1,this.name=t.name,this.intensity=t.intensity,this.reflectionsIntensity=t.reflectionsIntensity,this.brdfLUT=t.brdfLUT,this.irradianceCoeffs=t.irradianceCoeffs,this.diffuseImage=t.diffuseImage,this.specularImage=t.specularImage,this.specularMipCount=t.specularMipCount},r.dispose=function(){t.prototype.dispose.call(this),this.brdfLUT=void 0,this.irradianceCoeffs=void 0,this.diffuseImage=void 0,this.specularImage=void 0},r.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},r.updateUniforms=function(e){if(void 0===this.brdfLUT)throw Error("Setup brdfLUT for skybox at first.");if(e.setVector2("_IblIntensity",new P(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 Error("Invalid skybox irradiance coeffs "+t+".");["l00","l1m1","l10","l11","l2m2","l2m1","l20","l21","l22"].forEach(function(n,r){e.setVector3("_shCoefficients."+n,L.fromArray(t[r]))})}e.setInt("_MipCount",this.specularMipCount-1),e.setTexture("_SpecularEnvSampler",this.specularImage)},r.setMaterialStates=function(e){e.depthTest=!0,e.depthMask=!1,this.setFaceSideStates(e)},n}(ti);e.PSkyboxType=void 0,(p=e.PSkyboxType||(e.PSkyboxType={}))[p.NFT=0]="NFT",p[p.FARM=1]="FARM";var tu=function(){function e(){}return e.prototype.checkCubeMapImage=function(e){return C(function(){var n,r,i,o;return A(this,function(a){switch(a.label){case 0:r=[],i=0,a.label=1;case 1:if(!(i<e.length))return[3,4];return[4,t.loadImage(e[i])];case 2:if(o=a.sent(),i>0){if(i%6==0){if(2*o.width!==n.width||2*o.height!==n.height)throw Error("Invalid cube map list1: index "+i+", image0 "+n+", image1 "+o+".")}else if(o.width!==n.width||o.height!==n.height)throw 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]}})})()},e.getBrdfLutTextureOptions=function(){return C(function(){var e,n;return A(this,function(r){switch(r.label){case 0:return e="https://gw.alipayobjects.com/zos/gltf-asset/61420044606400/lut-ggx.png",[4,t.loadImage(e)];case 1:return n=r.sent(),[2,{name:"brdfLut",wrapS:t.glContext.CLAMP_TO_EDGE,wrapT:t.glContext.CLAMP_TO_EDGE,magFilter:t.glContext.LINEAR,minFilter:t.glContext.LINEAR,anisotropic:1,sourceType:t.TextureSourceType.image,image:n,generateMipmap:!1,flipY:!1,premultiplyAlpha:!1}]}})})()},e.createBrdfLutTexture=function(e){var n=this;return C(function(){var r;return A(this,function(i){switch(i.label){case 0:return[4,n.getBrdfLutTextureOptions()];case 1:return r=i.sent(),[2,t.Texture.create(e,r)]}})})()},e.createSkyboxOptions=function(e,t){var n=this;return C(function(){var r,i,o,a,s,l,c,u;return A(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}]}})})()},e.createSkyboxComponentData=function(n){var r,i=e.getSpecularCubeMapData(n),o=e.getDiffuseCubeMapData(n),a=n.renderable,s=n.intensity,l=n.reflectionsIntensity,c=n.irradianceCoeffs,u=n.specularImageSize,h=n.specularMipCount,f=[],d=[];o&&(f.push.apply(f,[].concat(o.images)),d.push(o.textureOptions),r={id:o.textureOptions.id}),f.push.apply(f,[].concat(i.images)),d.push(i.textureOptions);var m={id:i.textureOptions.id};return{imageList:f,textureOptionsList:d,component:{id:t.generateGUID(),dataType:t.spec.DataType.SkyboxComponent,item:{id:t.generateGUID()},renderable:a,intensity:s,reflectionsIntensity:l,irradianceCoeffs:c,diffuseImage:r,specularImage:m,specularImageSize:u,specularMipCount:h}}},e.createSpecularCubeMap=function(e,t){return C(function(){return A(this,function(n){return"url"===t.type?[2,e3.createTextureCubeMipmapFromURL(e,t.specularImage)]:[2,e3.createTextureCubeMipmapFromBuffer(e,t.specularImage,t.specularImageSize)]})})()},e.getSpecularCubeMapData=function(e){var n=[],r=[];return e.specularImage.forEach(function(e){var i=[];e.forEach(function(e){var r=t.generateGUID();n.push({id:r,url:e}),i.push({id:r})}),r.push(i)}),{images:n,textureOptions:w({id:t.generateGUID(),dataType:t.spec.DataType.Texture,sourceType:t.TextureSourceType.mipmaps,target:t.glContext.TEXTURE_CUBE_MAP,mipmaps:r},e3.cubemapMipTexConfig)}},e.createDiffuseCubeMap=function(e,t){return C(function(){return A(this,function(n){return void 0===t.diffuseImage?[2,null]:"url"===t.type?[2,e3.createTextureCubeFromURL(e,t.diffuseImage)]:[2,e3.createTextureCubeFromBuffer(e,t.diffuseImage)]})})()},e.getDiffuseCubeMapData=function(e){if(void 0!==e.diffuseImage){var n=[],r=[];return e.diffuseImage.forEach(function(e){var i=t.generateGUID();n.push({id:i,url:e}),r.push({id:i})}),{images:n,textureOptions:w({id:t.generateGUID(),dataType:t.spec.DataType.Texture,sourceType:t.TextureSourceType.mipmaps,target:t.glContext.TEXTURE_CUBE_MAP,mipmaps:[r]},e3.cubemapTexConfig)}}},e.getSkyboxParams=function(e){void 0===e&&(e=0);var t=this.getSpecularImageList(e);return{type:"url",renderable:!0,intensity:1.8,reflectionsIntensity:1.8,irradianceCoeffs:this.getIrradianceCoeffs(e),diffuseImage:this.getDiffuseImageList(e,t),specularImage:t,specularImageSize:Math.pow(2,t.length-1),specularMipCount:t.length}},e.getIrradianceCoeffs=function(e){var t=[];switch(e){case 0:return;case 1:t=[.2665672302246094,.27008703351020813,.2836797833442688,-.15421263873577118,-.15587495267391205,-.16371899843215942,.06483837962150574,.06468029320240021,.06616337597370148,-.11598809063434601,-.11796595901250839,-.1261979341506958,.023678265511989594,.02456280030310154,.02591511607170105,-.032404184341430664,-.03217344358563423,-.03126845508813858,.009165619499981403,.009345818310976028,.008521141484379768,-.021998587995767593,-.02203795686364174,-.021759089082479477,46658870996907353e-20,5610908847302198e-19,7202711421996355e-19];break;default:t=[.3746267259120941,.3523011803627014,.33955901861190796,.12082185596227646,.18179306387901306,.26912716031074524,-.020699946209788322,-.004648427478969097,.00797625258564949,-.06842170655727386,-.05139023810625076,-.03317255899310112,.044127799570560455,.028159862384200096,.007428745273500681,.07887077331542969,.06773484498262405,.04738233983516693,-.012322401627898216,-.015187464654445648,-.02020176313817501,-.1091032400727272,-.0823250338435173,-.046844951808452606,-.05779704451560974,-.06689254194498062,-.08212742954492569]}return t},e.getDiffuseImageList=function(e,t){if(0==e)return t[t.length-1]},e.getSpecularImageList=function(e){var t=[];1===e?t.push.apply(t,[].concat(this.getSpecularImageListAntFarm())):t.push.apply(t,[].concat(this.getSpecularImageListNFT()));var n=[];return t.forEach(function(e,t){t%6==0&&n.push([]),n[n.length-1].push(e)}),n},e.getSpecularImageListNFT=function(){return["https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img0.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img1.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img2.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img3.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img5.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img4.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img6.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img7.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img8.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img9.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img11.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img10.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img12.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img13.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img14.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img15.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img17.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img16.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img18.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img19.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img20.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img21.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img23.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img22.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img24.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img25.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img26.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img27.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img29.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img28.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img30.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img31.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img32.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img33.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img35.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img34.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img36.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img37.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img38.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img39.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img41.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img40.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img42.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img43.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img44.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img45.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img47.png","https://gw.alipayobjects.com/zos/gltf-asset/1656063861448/227da6e6-8d07-4f8b-bbb0-3b22fde48c0b_img46.png"]},e.getSpecularImageListAntFarm=function(){return["https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_32_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_16_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_8_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_4_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_2_5.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_0.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_1.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_2.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_3.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_4.png","https://gw.alipayobjects.com/zos/gltf-asset/58741584603363/M_Cubemap_1_5.png"]},e}(),th=function(){function e(e){this.engine=e,this.loadSkybox=!1,this.meshCache=new Map,this.textureCache=new Map,this.geometryCache=new Map,this.renderPassCache=new Map}var n=e.prototype;return n.setup=function(n){if(this.loadSkybox=n,void 0===this.brdfLutTexture||this.brdfLutTexture.isDestroyed){if(void 0===e.brdfLutTexOptions)throw Error("Please load brdfLutTexOptions at first.");var r="brdfLutTexture";this.brdfLutTexture=t.Texture.create(this.engine,e.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(e,n){var r=this.textureCache.get(e);if(void 0!==r)return r;var i=t.Texture.create(this.engine,n);return this.textureCache.set(e,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=e6.createGeometry(this.engine,t,n);return this.geometryCache.set(e,i),i},n.getFilterMesh=function(e,t,n){var r=this.meshCache.get(e);if(void 0!==r)return r;var i=e4.createFilterMesh(this.engine,e,t,n);return this.meshCache.set(e,i),i},n.getShadowBasePass=function(e,t,n,r){return this.getRenderPass(e,t,n,r)},n.getShadowFilterPass=function(e,t,n,r){return this.getRenderPass(e,t,n,r)},n.getRenderPass=function(e,t,n,r){var i=this.renderPassCache.get(e);if(void 0!==i)return i.setMeshes([]),n.forEach(function(e){i.addMesh(e)}),i;var o=this.engine.renderer,a=e3.createRenderPass(o,e,t,n,r);return this.renderPassCache.set(e,a),a},n.dispose=function(){this.engine=null,this.brdfLutTexture=void 0,this.meshCache.forEach(function(e){e3.deleteMesh(e)}),this.meshCache.clear(),this.textureCache.forEach(function(e){e3.deleteTexture(e)}),this.textureCache.clear(),this.geometryCache.forEach(function(e){e3.deleteGeometry(e)}),this.geometryCache.clear(),this.renderPassCache.forEach(function(e){e3.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 e.skyboxOptions},e.loadStaticResources=function(){var e=this;return C(function(){return A(this,function(t){switch(t.label){case 0:if(void 0!==e.brdfLutTexOptions)return[2];return[4,tu.getBrdfLutTextureOptions()];case 1:return e.brdfLutTexOptions=t.sent(),[2]}})})()},e.genSkyboxOptions=function(t,n){return C(function(){var r;return A(this,function(i){switch(i.label){case 0:return void 0===(r=n)&&(r=tu.getSkyboxParams()),[4,tu.createSkyboxOptions(t,r)];case 1:return e.skyboxOptions=i.sent(),[2,e.skyboxOptions]}})})()},e}(),tf=function(n){function r(){var e;return e=n.apply(this,arguments)||this,e.name="model",e}x(r,n);var i=r.prototype;return i.onCompositionConstructed=function(e,t){this.sceneParams=t.storage;var n=e.renderer.engine;this.cache=new th(n),this.cache.setup(!1)},i.onCompositionReset=function(n,r){var i={id:"ModelPluginItem",name:"ModelPluginItem",duration:9999999,endBehavior:t.spec.END_BEHAVIOR_FORWARD},o=new t.VFXItem(n.getEngine(),i);n.addItem(o);var a=o.addComponent(e.ModelPluginComponent);a.fromData({cache:this.cache}),a.initial(this.sceneParams)},i.onCompositionDestroyed=function(e){this.cache.dispose(),this.cache=null,this.sceneParams=null},r.prepareResource=function(e,t){return C(function(){var n,r,i,o,a,s,l;return A(this,function(c){switch(c.label){case 0:return void 0!==t.pluginData&&(r=["compatibleMode","renderSkybox","visBoundingBox","autoAdjustScene","enableDynamicSort","renderMode3D","renderMode3DUVGridSize"],i=t.pluginData,r.forEach(function(t){return e.storage[t]=i[t]})),a=null!=(o=t.env)?o:"",e.storage.runtimeEnv=a,l=null!=(s=null==(n=t.pluginData)?void 0:n.compatibleMode)?s:"gltf",e6.preprocessScene(e,a,l),[4,th.loadStaticResources()];case 1:return c.sent(),[2]}})})()},r.precompile=function(e,n){var r=2===n.engine.gpuCapability.level,i=eD(r),o=eF(r),a={id:j,name:"PBR Shader",dataType:t.spec.DataType.Shader,fragment:i.fragmentShaderCode,vertex:i.vertexShaderCode,glslVersion:r?t.GLSLVersion.GLSL3:t.GLSLVersion.GLSL1},s={id:W,name:"Unlit Shader",dataType:t.spec.DataType.Shader,fragment:o.fragmentShaderCode,vertex:o.vertexShaderCode,glslVersion:r?t.GLSLVersion.GLSL3:t.GLSLVersion.GLSL1};return n.engine.addEffectsObjectData(a),n.engine.addEffectsObjectData(s),Promise.resolve()},r}(t.AbstractPlugin);function td(t){var n,r=null==t?void 0:null==(n=t.item)?void 0:n.composition,i=null==r?void 0:r.getItemByName("ModelPluginItem"),o=null==i?void 0:i.getComponent(e.ModelPluginComponent);return null==o?void 0:o.scene}e.ModelPluginComponent=function(n){function r(e,r){var i;return(i=n.call(this,e)||this).runtimeEnv=t.PLAYER_OPTIONS_ENV_EDITOR,i.compatibleMode="gltf",i.renderSkybox=!0,i.visBoundingBox=!1,i.autoAdjustScene=!1,i.enableDynamicSort=!1,i.renderMode3D=t.spec.RenderMode3D.none,i.renderMode3DUVGridSize=1/16,r&&i.fromData(r),i}x(r,n);var i=r.prototype;return i.lateUpdate=function(t){var n=this.item.composition;if(this.autoAdjustScene&&1==this.scene.tickCount){var r,i,o,a=n.camera,s=new X().fromMatrix4(a.getViewMatrix()),l=new J().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 L).multiply(.5),d=f.x,m=f.y,p=h.getCenter(new L),g=m*Math.max(d/m/u,1)/Math.tan(.5*c*H),v=p.clone().add(l.clone().multiply(g+f.z));n.camera.position=v,null==(r=n.items)||r.forEach(function(t){if(t.type===_){var n=t.getComponent(e.ModelCameraComponent);if(null==n?void 0:n.content){var r,i=((null==(r=t.transform.parentTransform)?void 0:r.getWorldMatrix())||D.IDENTITY.clone()).invert().transformPoint(v);n.setTransform(i),console.info("Scene AABB ["+h.min.toArray()+"], ["+h.max.toArray()+"]."),console.info("Update camera position ["+i.toArray()+"].")}}})}this.updateSceneCamera(n),this.scene.tick(t)},i.onDestroy=function(){this.scene.dispose(),this.scene=null,this.cache=null},i.fromData=function(e){n.prototype.fromData.call(this,e),this.cache=e.cache,this.scene=new eA(this.engine)},i.initial=function(e){this.runtimeEnv=null!=(t=e.runtimeEnv)?t:this.runtimeEnv,this.compatibleMode=null!=(n=e.compatibleMode)?n:this.compatibleMode,this.renderSkybox=null!=(r=e.renderSkybox)?r:this.renderSkybox,this.visBoundingBox=null!=(i=e.visBoundingBox)?i:this.visBoundingBox,this.autoAdjustScene=null!=(o=e.autoAdjustScene)?o:this.autoAdjustScene,this.enableDynamicSort=null!=(a=e.enableDynamicSort)?a:this.enableDynamicSort,this.renderMode3D=null!=(s=e.renderMode3D)?s:this.renderMode3D,this.renderMode3DUVGridSize=null!=(l=e.renderMode3DUVGridSize)?l:this.renderMode3DUVGridSize;var t,n,r,i,o,a,s,l,c=this.item.composition;this.scene.initial({componentName:""+c.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()}),this.updateSceneCamera(c)},i.updateSceneCamera=function(e){this.scene.updateDefaultCamera(e.camera.getOptions())},i.getLightItemCount=function(){var t,n,r=0;return(null!=(n=null==(t=this.item.composition)?void 0:t.items)?n:[]).forEach(function(t){t.getComponent(e.ModelLightComponent)&&r++}),r},r}(t.ItemBehaviour),e.ModelPluginComponent=I([t.effectsClass(t.spec.DataType.ModelPluginComponent)],e.ModelPluginComponent);var tm=function(){function e(e,t){this.baseTransform=t.transform,this.animationManager=new em(e,t),this.build(e)}var n=e.prototype;return n.tick=function(e){this.animationManager.tick(e)},n.getNodes=function(){return this.nodes},n.getNodeById=function(e){var t=this.cacheMap;if(!t[e]){var n="^"+e;t[e]=this.allNodes.find(function(e){return e.id===n})}return t[e]},n.getNodeByName=function(e){var t=this.cacheMap;return t[e]||(t[e]=this.allNodes.find(function(t){return t.name===e})),t[e]},n.getNodeTransform=function(e){var t=this.getNodeById(e);return t?t.transform:this.baseTransform},n.dispose=function(){var e;this.allNodes=[],this.nodes=[],this.cacheMap={},this.baseTransform=null,null==(e=this.animationManager)||e.dispose(),this.animationManager=null},n.build=function(e){var n=this,r=this.baseTransform,i=e.nodes.map(function(e,i){return{name:e.name||e.id||i+"",transform:new t.Transform(w({},e.transform,{valid:!0}),r),id:"^"+(e.id||i),children:[],tree:n}});this.cacheMap={},i.forEach(function(t,n){var o=e.nodes[n].children;t.transform.name=t.name,t.transform.setValid(!0),o&&o.forEach(function(e){var n=i[e];n&&n!==t&&(n.transform.parentTransform!==r&&console.error("Node parent has been set."),n.transform.parentTransform=t.transform,t.children.push(n))})}),this.allNodes=i,this.nodes=e.children.map(function(e){return i[e]})},e}();e.ModelTreeComponent=function(e){function n(t,n){var r;return r=e.call(this,t)||this,n&&r.fromData(n),r}x(n,e);var r=n.prototype;return r.fromData=function(t){e.prototype.fromData.call(this,t),this.options=t,this.createContent()},r.start=function(){this.item.type=t.spec.ItemType.tree,this.content.baseTransform.setValid(!0);var e=td(this);e&&this.content.animationManager.setSceneManager(e)},r.update=function(e){var t;null==(t=this.content)||t.tick(e)},r.onDestroy=function(){var e;null==(e=this.content)||e.dispose()},r.createContent=function(){if(this.options){var e=this.options.options.tree;this.content=new tm(e,this.item)}},r.getNodeTransform=function(e){if(void 0===this.content)return this.transform;var t=this.item.id+"^";if(0!==e.indexOf(t))return this.transform;var n=e.substring(t.length);return this.content.getNodeTransform(n)},n}(t.ItemBehaviour),e.ModelTreeComponent=I([t.effectsClass(t.spec.DataType.TreeComponent)],e.ModelTreeComponent);var tp=function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.name="tree",t.order=2,t}return x(t,e),t}(t.AbstractPlugin);e.CameraGestureType=void 0,(g=e.CameraGestureType||(e.CameraGestureType={}))[g.none=0]="none",g[g.translate=1]="translate",g[g.rotate_focus=2]="rotate_focus",g[g.rotate_self=3]="rotate_self",g[g.scale=4]="scale";var tg=function(){function n(t){this.composition=t,this.cameraTransform=new X,this.cameraCoordiante=new J,this.startParams={type:e.CameraGestureType.none,mouseEvent:!1,clientX:0,clientY:0,clientWidth:512,clientHeight:512,target:""}}var r=n.prototype;return r.getItem=function(){var e,t=this;return null==(e=this.composition.items)?void 0:e.find(function(e){return e.name===t.getCurrentTarget()})},r.getCurrentTarget=function(){return this.startParams.target},r.getCurrentType=function(){return this.startParams.type},r.onKeyEvent=function(n){this.startParams.target!==n.cameraID&&(this.startParams.target=n.cameraID,this.startParams.type=e.CameraGestureType.translate);var r,i,o,a,s=this.getItem();if(void 0===s)return console.warn("[CameraGestureHandlerImp] Unable to locate camera item with ID: "+this.startParams.target+"."),this.composition.camera.getOptions();var l=this.composition.camera,c=new t.Transform(w({},l.getOptions(),{valid:!0})),u=new X().fromEffectsTransform(c),h=new J().fromPTransform(u),f=null!=(r=n.xAxis)?r:0,d=null!=(i=n.yAxis)?i:0,m=null!=(o=n.zAxis)?o:0,p=h.xAxis.clone().multiply(f);if(p.add(h.yAxis.clone().multiply(d)),p.add(h.zAxis.clone().multiply(m)),1e-5>p.lengthSquared())return l.getOptions();p.normalize();var g=null!=(a=n.speed)?a:.1,v=u.getPosition();return v.add(p.clone().multiply(g)),this.setTransform(s,v),this.startParams.type===e.CameraGestureType.rotate_self&&(this.cameraTransform.setPosition(v),this.cameraCoordiante.origin=v),l.getOptions()},r.onXYMoveBegin=function(t,n,r,i,o){var a={type:e.CameraGestureType.translate,mouseEvent:!0,clientX:t,clientY:n,clientWidth:r,clientHeight:i,target:o};return this.startGesture(a)},r.onXYMoving=function(t,n,r){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,o={type:e.CameraGestureType.translate,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=r?r:.015};return this.moveGesture(o)},r.onXYMoveEnd=function(){this.endGesture()},r.onZMoveBegin=function(t,n,r,i,o){var a={type:e.CameraGestureType.scale,mouseEvent:!0,clientX:t,clientY:n,clientWidth:r,clientHeight:i,target:o};return this.startGesture(a)},r.onZMoving=function(t,n,r){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,o={type:e.CameraGestureType.scale,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=r?r:.015};return this.moveGesture(o)},r.onZMoveEnd=function(){this.endGesture()},r.onRotateBegin=function(t,n,r,i,o){var a={type:e.CameraGestureType.rotate_self,mouseEvent:!0,clientX:t,clientY:n,clientWidth:r,clientHeight:i,target:o};return this.startGesture(a)},r.onRotating=function(t,n,r){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,o={type:e.CameraGestureType.rotate_self,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,target:i.target,speed:null!=r?r:1.5};return this.moveGesture(o)},r.onRotateEnd=function(){this.endGesture()},r.onRotatePointBegin=function(t,n,r,i,o,a){var s={type:e.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:t,clientY:n,clientWidth:r,clientHeight:i,focusPoint:o,target:a};return this.startGesture(s)},r.onRotatingPoint=function(t,n,r){if(!this.startParams.mouseEvent)return this.composition.camera.getOptions();var i=this.startParams,o={type:e.CameraGestureType.rotate_focus,mouseEvent:!0,clientX:t,clientY:n,clientWidth:i.clientWidth,clientHeight:i.clientHeight,focusPoint:i.focusPoint,target:i.target,speed:null!=r?r:8};return this.moveGesture(o)},r.onRotatePointEnd=function(){this.endGesture()},r.moveTo=function(t,n){this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var r=this.getItem();if(void 0===r){console.warn("[CameraGestureHandlerImp] Can't find camera item.");return}this.setPosition(r,n)},r.rotateTo=function(t,n){this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var r=this.getItem();if(void 0===r){console.warn("[CameraGestureHandlerImp] Can't find camera item.");return}this.setQuaternion(r,n)},r.onFocusPoint=function(t,n,r){this.startParams.target=t,this.startParams.type=e.CameraGestureType.none;var i=this.getItem();if(void 0===i){console.warn("[CameraGestureHandlerImp] Can't find camera item.");return}var o=L.fromArray(n),a=new X().fromEffectsTransform(i.transform),s=new J().fromPTransform(a),l=L.fromArray(s.zAxis.toArray()).multiply(1).clone().multiply(null!=r?r:5),c=o.clone().add(l);this.setTransform(i,c),this.startParams.target=""},r.getCameraTransform=function(){var e=this.composition.camera,n=new t.Transform(e.getOptions());return n.setValid(!0),n},r.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()},r.moveGesture=function(t){if(this.getCurrentType()===t.type){var n,r=this.getItem();if(void 0===r)return console.warn("[CameraGestureHandlerImp] Can't find camera item."),this.composition.camera.getOptions();var i=null!=(n=t.speed)?n:1.015,o=this.cameraCoordiante.xAxis,a=this.cameraCoordiante.yAxis,s=this.cameraCoordiante.zAxis,l=t.clientX-this.startParams.clientX,c=t.clientY-this.startParams.clientY;if(t.type===e.CameraGestureType.translate){var u=this.cameraTransform.getPosition().clone();u.add(o.clone().multiply(-l*i)),u.add(a.clone().multiply(c*i)),r.transform.setPosition(u.x,u.y,u.z),this.setTransform(r,r.transform.position,r.transform.rotation)}else if(t.type===e.CameraGestureType.scale){var h=this.cameraTransform.getPosition().clone();h.add(s.clone().multiply(c*i)),r.transform.setPosition(h.x,h.y,h.z),this.setTransform(r,r.transform.position,r.transform.rotation)}else if(t.type===e.CameraGestureType.rotate_self){var f=l/t.clientWidth,d=c/t.clientHeight,m=k.fromAxisAngle(L.Y,-(f*Math.PI*i*.5)),p=k.fromAxisAngle(o,-(d*Math.PI*i*.5));m.multiply(p),m.multiply(this.cameraTransform.getRotation()),r.transform.setQuaternion(m.x,m.y,m.z,m.w),this.setTransform(r,r.transform.position,r.transform.rotation)}else if(t.type===e.CameraGestureType.rotate_focus){var g=l/t.clientWidth,v=c/t.clientHeight,y=k.fromAxisAngle(L.Y,-(g*Math.PI*i)),T=k.fromAxisAngle(o,-(v*Math.PI*i));y.multiply(T);var _=y.toMatrix4(new D),b=L.fromArray(t.focusPoint),C=this.cameraCoordiante.origin.clone().subtract(b);_.transformPoint(C);var S=C.add(b);y.multiply(this.cameraTransform.getRotation()),r.transform.setPosition(S.x,S.y,S.z),r.transform.setQuaternion(y.x,y.y,y.z,y.w),this.setTransform(r,S,r.transform.rotation)}else console.warn("[CameraGestureHandlerImp] Movement type not implemented.")}else console.warn("[CameraGestureHandlerImp] Invalid move type specified: "+t.type);return this.composition.camera.getOptions()},r.setTransform=function(t,n,r){var i=t.getComponent(e.ModelCameraComponent);void 0!==i&&i.setTransform(n,r)},r.setPosition=function(t,n){(r=t.transform).setPosition.apply(r,[].concat(n));var r,i=t.getComponent(e.ModelCameraComponent);void 0!==i&&i.updateMainCamera()},r.setQuaternion=function(t,n){(r=t.transform).setQuaternion.apply(r,[].concat(n));var r,i=t.getComponent(e.ModelCameraComponent);void 0!==i&&i.updateMainCamera()},r.endGesture=function(){this.startParams.type=e.CameraGestureType.none,this.startParams.mouseEvent=!1,this.startParams.target=""},r.updateCameraTransform=function(e){var n=new t.Transform(e);n.setValid(!0),this.cameraTransform.fromEffectsTransform(n),this.cameraCoordiante.fromPTransform(this.cameraTransform)},n}(),tv=function(){function e(){}return e.getTransformFromMat4=function(e){var t=e.getTransform(),n=t.rotation.toEuler(new U);return{position:t.translation.toArray(),rotation:n.toArray(),scale:t.scale.toArray()}},e.getEffectsTransformFromMat4=function(e){var n=new t.Transform({valid:!0});return n.cloneFromMatrix(e),{position:n.position.toArray(),rotation:n.rotation.toArray(),scale:n.scale.toArray()}},e.getTransformFromTranslation=function(e){return{position:e.toArray()}},e.getTransformFromDirection=function(t){var n=L.fromArray([1,0,0]),r=t.clone().normalize(),i=n.clone().cross(r);if(.01>i.length())return{};i.normalize();var o=r.dot(n),a=D.fromRotationAxis(i,Math.acos(o));return e.getTransformFromMat4(a)},e.getEffectsTransformFromDirection=function(t){var n=L.fromArray([0,0,1]),r=t.clone().normalize(),i=n.clone().cross(r);if(.01>i.length())return{};i.normalize();var o=r.dot(n),a=D.fromRotationAxis(i,Math.acos(o));return e.getEffectsTransformFromMat4(a)},e.getTransformFromTransDir=function(t,n){var r=e.getTransformFromDirection(n);return r.position=t.toArray(),r},e.getEffectsTransformFromTransDir=function(t,n){var r=e.getEffectsTransformFromDirection(n);return r.position=t.toArray(),r},e.getEulerFromQuat=function(e){var t=new U,n=new k(e.x,e.y,e.z,e.w);return t.order=B.ZYX,t.setFromQuaternion(n),[t.x,t.y,t.z]},e.getQuatFromEuler=function(e){var t=new k;return t.setFromEuler(e),[t.x,t.y,t.z,t.w]},e.toPlayerColor3=function(t){return[e.scaleTo255(t[0]),e.scaleTo255(t[1]),e.scaleTo255(t[2])]},e.toPlayerColor4=function(t){return[e.scaleTo255(t[0]),e.scaleTo255(t[1]),e.scaleTo255(t[2]),e.scaleTo255(t[3])]},e.scaleTo255=function(e){return Math.max(0,Math.min(255*e,255))},e.scaleTo1=function(e){return Math.max(0,Math.min(e/255,1))},e}(),ty=function(){function e(e){this.treeInfo=new tT,this.engine=e.renderer.engine,this.renderer=e.renderer,this.downloader=new t.Downloader}var n=e.prototype;return n.processScene=function(e){var n=this;return C(function(){var r,i,o,a,s,l,c,u,h;return A(this,function(f){switch(f.label){case 0:if(!t.isObject(e))return[3,1];return i=e,[3,3];case 1:return[4,n.loadJSON(e)];case 2:i=f.sent(),f.label=3;case 3:if((r=i).textures.forEach(function(e){void 0===e.source&&(e.source=0)}),o=t.getStandardJSON(r),a=[],!o.bins)return[3,7];s=en(o.bins),f.label=4;case 4:if((l=s()).done)return[3,7];return c=l.value,u=a.push,[4,n.loadBins(c.url)];case 5:u.apply(a,[f.sent()]),f.label=6;case 6:return[3,4];case 7:return o.bins=a,h=w({},o,{version:"3.0",playerVersion:{web:"3.0",native:"3.0"},type:"ge",compositions:[],images:[],textures:[],items:[],components:[],materials:[],shaders:[],geometries:[]}),n.setImage(h,o),[4,n.setTexture(h,o)];case 8:return f.sent(),n.setComponent(h,o),n.setItem(h,o),n.setComposition(h,o),[2,h]}})})()},n.setImage=function(e,t){var n=[];t.images.forEach(function(e){n.push(e)}),e.images=n},n.setTexture=function(e,n){var r=this;return C(function(){var i,o,a,s,l,c,u,h,f,d;return A(this,function(m){switch(m.label){case 0:if(i=[],o=n.bins,!n.textures)return[3,5];a=en(n.textures),m.label=1;case 1:if((s=a()).done)return[3,5];if(34067!==(l=s.value).target)return[3,3];return c=l.mipmaps,u=l.target,[4,Promise.all(c.map(function(e){return Promise.all(e.map(function(e){return r.loadMipmapImage(e,o)}))}))];case 2:return h=m.sent().map(function(n){return n.map(function(n){var r=t.generateGUID();return e.images.push({url:n,id:r}),{id:r}})}),f=w({keepImageSource:!1},l,{mipmaps:h,sourceFrom:{target:u,type:t.TextureSourceType.mipmaps,mipmaps:c.map(function(e){return e.map(function(e){return[e[1][1],e[1][2]]})})}}),i.push(f),[3,4];case 3:"number"==typeof(d=l.source)&&(l.source={id:e.images[d].id}),i.push(l),m.label=4;case 4:return[3,1];case 5:return e.textures=i,[2]}})})()},n.setComponent=function(e,n){for(var r,i=e.components,o=en(n.components);!(r=o()).done;){var a=r.value;a.dataType===t.spec.DataType.SkyboxComponent?i.push(this.createSkyboxComponent(a,e)):a.dataType===t.spec.DataType.LightComponent?i.push(this.createLightComponent(a,e)):a.dataType===t.spec.DataType.CameraComponent?(i.push(a),console.warn("Camera component found: "+a+".")):a.dataType===t.spec.DataType.TreeComponent?(this.createItemsFromTreeComponent(a,e,n),a.options.tree.animation=void 0,a.options.tree.animations=void 0,i.push(a)):a.dataType!==t.spec.DataType.MeshComponent&&i.push(a)}for(var s,l=en(n.components);!(s=l()).done;){var c=s.value;c.dataType===t.spec.DataType.MeshComponent&&i.push(this.createMeshComponent(c,e,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 C(function(){return A(this,function(n){return[2,new Promise(function(n,r){t.downloader.downloadJSON(e,n,function(t,n){r(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 C(function(){return A(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 C(function(){var n,r,i,o,a;return A(this,function(s){if(r=(n=e[1])[0],i=n[1],o=n[2],!(a=t[r]))throw 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;return o.irradianceCoeffs&&(n=[],o.irradianceCoeffs.forEach(function(e){return(r=n).push.apply(r,[].concat(e))})),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=this,i=e.options,o=[],a=[];i.primitives.forEach(function(e){var t,i=Q(e.geometry,n.bins),s=r.getMaterialData(e.material,n);if(M(null==(t=i.indices)?void 0:t.data,Uint8Array)){for(var l=i.indices.data,c=new Uint16Array(l.length),u=0;u<l.length;u++)c[u]=l[u];i.indices.data=c}o.push(i),a.push(s)});var s=t_(o);if(!s)throw Error("No primitives available to process.");t.geometries.push(s),(c=t.materials).push.apply(c,[].concat(a));var l={id:e.id,dataType:e.dataType,item:e.item,geometry:{id:s.id},materials:a.map(function(e){return{id:e.id}})};if(i.skin){for(var c,u,h=e.item.id,f=en(n.items);!(u=f()).done;){var d=u.value;d.id===e.item.id&&(h=d.parentId)}if(h===e.item.id)throw Error("Can't item "+e.item+".");var m=this.treeInfo.getTreeItemByNodeId(h),p=this.treeInfo.getTreeNodeListByNodeId(h);if(!m||!p)throw 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 g=this.setupBoneData(s,i.skin,n,m,p);l.rootBone={id:g.id}}return void 0!==i.weights&&(l.morph={weights:i.weights}),l},n.createItemsFromTreeComponent=function(e,n,r){var i=this,o=r.items[0];r.items.forEach(function(t){t.id===e.item.id&&(o=t)});var a=e.options.tree,s=[];a.nodes.forEach(function(e,r){var a,l={id:t.generateGUID(),parentId:o.id,name:null!=(a=e.name)?a:"node"+r,duration:o.duration,type:"ECS",dataType:t.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(e.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(e,n,r,i){var o=this,a=e.animation,s=e.animations,l={id:t.generateGUID(),dataType:t.spec.DataType.AnimationComponent,item:{id:n.id},animation:a,animationClips:[]};if(s&&s.length){var c=i.bins;s.forEach(function(e){var a={id:t.generateGUID(),name:e.name,dataType:t.spec.DataType.AnimationClip,positionCurves:[],rotationCurves:[],scaleCurves:[],floatCurves:[]},s=0;e.tracks.forEach(function(e){var t=ee(c,e.input);s=Math.max(s,t[t.length-1])}),e.tracks.forEach(function(e){var r=ee(c,e.input),s=ee(c,e.output);if(!M(r,Float32Array))throw Error("Type of inputArray should be float32, "+r+".");if(!M(s,Float32Array))throw Error("Type of outputArray should be float32, "+s+".");if("LINEAR"!==e.interpolation)throw Error("Invalid interpolation type "+e.interpolation+".");if("rotation"===e.path){for(var l=[],u=[],h=[],f=0;f<r.length;f++){if(l.push([s[4*f],s[4*f+1],s[4*f+2],s[4*f+3]]),f>0){var d=k.fromArray(l[f-1]),m=k.fromArray(l[f]),p=new k,g=new k;p.slerpQuaternions(d,m,1/3),g.slerpQuaternions(d,m,2/3),u.push(p.toArray()),u.push(g.toArray())}h.push([t.spec.BezierKeyframeType.LINE,[r[f],f]])}var v=o.treeInfo.getTreeNode(n.id,e.node),y=o.treeInfo.getNodePath(v.id),T=[t.spec.ValueType.BEZIER_CURVE_QUAT,[h,l,u]];a.rotationCurves.push({path:y,keyFrames:T})}else if("weights"===e.path){var _=o.treeInfo.getTreeNode(n.id,e.node),b=o.treeInfo.getNodePath(_.id);if(0===_.components.length)for(var C=0;C<i.items.length;C++){var S=i.items[C];if(S.parentId===_.id){b+="/"+S.name;break}}for(var x=s.length/r.length,I=0;I<x;I++){for(var A=[],E=0;E<r.length;E++)A.push([t.spec.BezierKeyframeType.LINE,[r[E],s[E*x+I]]]);var N=[t.spec.ValueType.BEZIER_CURVE,A];a.floatCurves.push({path:b,className:"ModelMeshComponent",property:"morphWeights."+I,keyFrames:N})}}else{for(var w=[],P=[],R=[],O=0;O<r.length;O++){if(w.push([s[3*O],s[3*O+1],s[3*O+2]]),O>0){var D=L.fromArray(w[O-1]),F=L.fromArray(w[O]),U=new L().lerpVectors(D,F,1/3),B=new L().lerpVectors(D,F,2/3);P.push(U.toArray()),P.push(B.toArray())}R.push([t.spec.BezierKeyframeType.LINE,[r[O],O]])}var V=o.treeInfo.getTreeNode(n.id,e.node),G=o.treeInfo.getNodePath(V.id),z=[t.spec.ValueType.BEZIER_CURVE_PATH,[R,w,P]];"translation"===e.path?a.positionCurves.push({path:G,keyFrames:z}):a.scaleCurves.push({path:G,keyFrames:z})}}),r.animations.push(a),l.animationClips.push({id:a.id})})}n.components.push({id:l.id}),r.components.push(l)},n.getMaterialData=function(e,n){if(e.type===t.spec.MaterialType.unlit){var r={};void 0!==e.alphaCutOff&&(r._AlphaCutoff=e.alphaCutOff);var i={_BaseColorFactor:new F(e.baseColorFactor[0],e.baseColorFactor[1],e.baseColorFactor[2],e.baseColorFactor[3]).divide(255)},o={};e.baseColorTexture&&(o._BaseColorSampler=this.getTextureData(n,r,e.baseColorTexture,e.baseColorTextureTransform));var a={id:t.generateGUID(),name:e.name,dataType:t.spec.DataType.Material,shader:{id:W},stringTags:{},macros:[],ints:{},floats:r,vector4s:{},colors:i,textures:o};return this.setupMaterial(e,a),a}var s={_MetallicFactor:e.metallicFactor,_RoughnessFactor:e.roughnessFactor};void 0!==e.useSpecularAA&&(s._SpecularAA=e.useSpecularAA?1:0),void 0!==e.normalTextureScale&&(s._NormalScale=e.normalTextureScale),void 0!==e.occlusionTextureStrength&&(s._OcclusionStrength=e.occlusionTextureStrength),void 0!==e.emissiveIntensity&&(s._EmissiveIntensity=e.emissiveIntensity),void 0!==e.alphaCutOff&&(s._AlphaCutoff=e.alphaCutOff);var l={_BaseColorFactor:new F(e.baseColorFactor[0],e.baseColorFactor[1],e.baseColorFactor[2],e.baseColorFactor[3]).divide(255),_EmissiveFactor:new F(e.emissiveFactor[0],e.emissiveFactor[1],e.emissiveFactor[2],e.emissiveFactor[3]).divide(255)},c={};e.baseColorTexture&&(c._BaseColorSampler=this.getTextureData(n,s,e.baseColorTexture,e.baseColorTextureTransform)),e.metallicRoughnessTexture&&(c._MetallicRoughnessSampler=this.getTextureData(n,s,e.metallicRoughnessTexture,e.metallicRoughnessTextureTransform)),e.normalTexture&&(c._NormalSampler=this.getTextureData(n,s,e.normalTexture,e.normalTextureTransform)),e.occlusionTexture&&(c._OcclusionSampler=this.getTextureData(n,s,e.occlusionTexture,e.occlusionTextureTransform)),e.emissiveTexture&&(c._EmissiveSampler=this.getTextureData(n,s,e.emissiveTexture,e.emissiveTextureTransform));var u={id:t.generateGUID(),name:e.name,dataType:t.spec.DataType.Material,shader:{id:j},stringTags:{},macros:[],ints:{},floats:s,vector4s:{},colors:l,textures:c};return this.setupMaterial(e,u),u},n.setupMaterial=function(e,n){if(e.blending===t.spec.MaterialBlending.translucent?n.stringTags.RenderType=t.spec.RenderType.Transparent:n.stringTags.RenderType=t.spec.RenderType.Opaque,e.blending===t.spec.MaterialBlending.masked){var r;n.floats.AlphaClip=1,n.floats._AlphaCutoff=null!=(r=e.alphaCutOff)?r:0}else n.floats.AlphaClip=0;switch(e.side){case t.spec.SideMode.BACK:n.stringTags.RenderFace=t.spec.RenderFace.Back;break;case t.spec.SideMode.DOUBLE:n.stringTags.RenderFace=t.spec.RenderFace.Both;break;default:n.stringTags.RenderFace=t.spec.RenderFace.Front}e.type===t.spec.MaterialType.pbr&&(n.floats._SpecularAA=e.useSpecularAA?1:0),n.floats.ZWrite=!1!==e.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 Error("'inverseBindMatrices' is undefined for the skin configuration: "+JSON.stringify(t)+". Ensure 'inverseBindMatrices' is properly defined in your skin data.");var c=ee(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;)if(n.push(t.name),t.parentId)t=u[t.parentId];else break;f.push(n.reverse().join("/"))}),e.boneNames=f,h},e}(),tT=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 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 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 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){t.push.apply(t,[].concat(e.tree2NodeList[n]))}),t},t.getNodePath=function(e){return this.node2Path[e]},e}();function t_(e){if(!(e.length<=0)){for(var n=0,r=[],i=0;i<e.length;i++)!function(t){var i,o,a,s=function(e){if(e.drawCount)return e.drawCount;if(e.indices)return e.indices.data.length;var t=0;return e.attributes.forEach(function(e){t=e.data.length/e.size}),t}(e[t]),l=n+(null!=(o=e[t].drawStart)?o:0),c=null!=(a=null==(i=e[0].indices)?void 0:i.data.BYTES_PER_ELEMENT)?a:1;if(r.push({offset:l*c,indexCount:s,vertexCount:s}),t){var u=e[0],h=e[t],f=!0;if(Object.keys(u.attributes).forEach(function(e){var t=u.attributes[e].data,n=h.attributes[e].data;(t.length!==n.length||t[0]!==n[0])&&(f=!1)}),f)u.indices&&h.indices&&(u.indices.data=tC(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=tC(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=tC(n,r)})}}n=l+s}(i);return function(e,n){var r=0;for(var i in e.attributes)r+=e.attributes[i].data.byteLength;e.indices&&(r+=e.indices.data.byteLength);var o=0,a=0,s=new Uint8Array(r),l=[];for(var c in e.attributes){var u,h=e.attributes[c],f=tS[c];if(!f)throw Error("Invalid attrib "+c+".");o=h.data.length/h.size;var d={semantic:f,offset:a,format:t.glType2VertexFormatType(null!=(u=h.type)?u:t.glContext.FLOAT),dimension:h.size,normalize:h.normalize};l.push(d);var m=h.data,p=new Uint8Array(m.buffer,m.byteOffset,m.byteLength);s.set(p,a),a+=p.byteLength}var g={id:t.generateGUID(),dataType:t.spec.DataType.Geometry,vertexData:{vertexCount:o,channels:l},subMeshes:n,mode:t.spec.GeometryType.TRIANGLES,indexFormat:t.spec.IndexFormatType.None,indexOffset:0,buffer:""};if(e.indices){var v=e.indices.data,y=new Uint8Array(v.buffer,v.byteOffset,v.byteLength);s.set(y,a),g.indexOffset=a,M(v,Uint32Array)?g.indexFormat=t.spec.IndexFormatType.UInt32:g.indexFormat=t.spec.IndexFormatType.UInt16}return g.buffer=function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}(s),g}(e[0],r)}}function tb(e,n,r){switch(e){case t.spec.VertexFormatType.Int8:case t.spec.VertexFormatType.UInt8:return n*r;case t.spec.VertexFormatType.Int16:case t.spec.VertexFormatType.UInt16:return n*r*2;default:return n*r*4}}function tC(e,t,n){if(M(e,Float32Array)){var r=new Float32Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}if(M(e,Int32Array)){var i=new Int32Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}if(M(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(M(e,Int16Array)){var s=new Int16Array(e.length+t.length);return s.set(e),s.set(t,e.length),s}if(M(e,Uint16Array)){var l=new Uint16Array(e.length+t.length);if(l.set(e),l.set(t,e.length),n)for(var c=0;c<t.length;c++)l[e.length+c]+=n;return l}if(M(e,Int8Array)){var u=new Int8Array(e.length+t.length);return u.set(e),u.set(t,e.length),u}var h=new Uint8Array(e.length+t.length);return h.set(e),h.set(t,e.length),h}var tS={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"},tx=function(){function n(e){this.gltfSkins=[],this.gltfMeshs=[],this.gltfLights=[],this.gltfCameras=[],this.gltfImages=[],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 V,e?this.composition=e:(this.timelineAssetId=t.generateGUID(),this.composition={id:"1",name:"test1",duration:9999,endBehavior:t.spec.CompositionEndBehavior.restart,camera:{fov:45,far:2e3,near:.001,position:[0,0,8],rotation:[0,0,0],clipMode:t.spec.CameraClipMode.portrait},items:[],timelineAsset:{id:this.timelineAssetId},sceneBindings:[]})}var r=n.prototype;return r.loadScene=function(e){var n=this;return C(function(){var r,i,o,a,s,l,c,u,h;return A(this,function(f){switch(f.label){case 0:if(n.clear(),n.sceneOptions=e,n.loaderOptions={compatibleMode:e.gltf.compatibleMode},"string"==typeof(s=e.gltf.resource)||M(s,Uint8Array))throw Error("Please load the resource using GLTFTools first.");return n.images=s.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(C(function(e){return A(this,function(n){return[2,t.loadImage(e.url)]})})))];case 1:if(n.imageElements=f.sent(),n.processGLTFResource(s,n.imageElements),n.gltfScene=s.scenes[0],n.gltfSkins=n.gltfScene.skins,n.gltfMeshs=s.meshes,n.gltfLights=n.gltfScene.lights,n.gltfCameras=n.gltfScene.cameras,n.gltfImages=s.images,n.gltfTextures=s.textures,n.gltfMaterials=s.materials,n.gltfAnimations=s.animations,n.gltfImageBasedLights=s.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}),s.meshes.forEach(function(e){n.geometries.push(e.geometryData)}),(l=s.scenes[0]).meshesComponentData.forEach(function(e){return n.checkMeshComponentData(e,s)}),(r=n.components).push.apply(r,[].concat(l.camerasComponentData)),(i=n.components).push.apply(i,[].concat(l.lightsComponentData)),(o=n.components).push.apply(o,[].concat(l.meshesComponentData)),1===l.animationsComponentData.length)c=l.animationsComponentData[0],e.effects.playAllAnimation||void 0===e.effects.playAnimation||(u=c.animationClips,(h=e.effects.playAnimation)>=0&&h<u.length?c.animationClips=[u[h]]:c.animationClips=[]),n.components.push(c);else if(l.animationsComponentData.length>1)throw Error("Find many animation component data "+l.animationsComponentData.length);return n.animations=[],n.gltfAnimations.forEach(function(e){n.animations.push(e.animationClipData)}),n.items=[],[4,n.tryAddSkybox({skyboxType:e.gltf.skyboxType,renderable:e.gltf.skyboxVis})];case 2:return f.sent(),(a=n.items).push.apply(a,[].concat(s.scenes[0].vfxItemData)),n.items.forEach(function(e){"root"===e.type&&(e.type="ECS")}),[2,n.getLoadResult()]}})})()},r.processGLTFResource=function(e,n){var r=this,i={},o=e.textures,a=e.materials,s=e.scenes,l=e.imageBasedLights;o.forEach(function(e){var t=e.textureOptions,n=t.id;n?(i[n]&&console.error("Duplicate GUID found: "+n+", old "+i[n]+", new "+t+"."),i[n]=t):console.error("No GUID in texture Data: "+t+".")});var c=new Set,u=new Set;a.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&&c.add(i.id),o&&u.add(o.id)});for(var h,f=0,d={},m=en(c);!(h=m()).done;)!function(){var e=h.value;if(u.has(e)){var n=o.find(function(t){return t.textureOptions.id===e});if(n){var r=t.generateGUID(),a=w({},n);a.textureOptions=w({},n.textureOptions,{id:r}),o.push(a),i[r]=a.textureOptions,d[e]=r,f+=1}}}();f>0&&console.warn("Add base color texture "+f),a.forEach(function(e){var t=e.materialData;if(r.processMaterialData(t),(null==(o=t.shader)?void 0:o.id)===W)r.processMaterialTexture(t,"_BaseColorSampler",!0,i,n);else if((null==(a=t.shader)?void 0:a.id)===j){var o,a,s,l=null==(s=t.textures._EmissiveSampler)?void 0:s.texture;l&&d[l.id]&&(l.id=d[l.id]),r.processMaterialTexture(t,"_BaseColorSampler",!0,i,n),r.processMaterialTexture(t,"_MetallicRoughnessSampler",!1,i,n),r.processMaterialTexture(t,"_NormalSampler",!1,i,n),r.processMaterialTexture(t,"_OcclusionSampler",!1,i,n),r.processMaterialTexture(t,"_EmissiveSampler",!1,i,n)}});var p=s[0];p.camerasComponentData.forEach(function(e){return r.processCameraComponentData(e)}),p.lightsComponentData.forEach(function(e){return r.processLightComponentData(e)});var g=[];l.forEach(function(e){var n=e.imageBaseLightData;if(void 0===n.reflectionsIntensity&&(n.reflectionsIntensity=n.intensity),n.diffuseImage){var r=i[n.diffuseImage.id];t.addItem(g,r)}if(n.specularImage){var o=i[n.specularImage.id];t.addItem(g,o)}}),g.forEach(function(e){e.target===t.glContext.TEXTURE_CUBE_MAP&&(e.mipmaps.forEach(function(e){var t;t=[e[5],e[4]],e[4]=t[0],e[5]=t[1]}),1===e.mipmaps.length?e.minFilter=t.glContext.LINEAR:e.minFilter=t.glContext.LINEAR_MIPMAP_LINEAR,e.magFilter=t.glContext.LINEAR)})},r.processComponentData=function(e){var n=this;e.forEach(function(e){e.dataType===t.spec.DataType.LightComponent?n.processLightComponentData(e):e.dataType===t.spec.DataType.CameraComponent?n.processCameraComponentData(e):e.dataType===t.spec.DataType.SkyboxComponent&&n.processSkyboxComponentData(e)})},r.processLightComponentData=function(e){e.color||(e.color={r:1,g:1,b:1,a:1}),e.intensity||(e.intensity=1),e.lightType===t.spec.LightType.point?e.range||(e.range=0):e.lightType!==t.spec.LightType.spot||(e.range||(e.range=0),e.innerConeAngle||(e.innerConeAngle=0),e.outerConeAngle||(e.outerConeAngle=Math.PI/4))},r.processCameraComponentData=function(e){e.type===t.spec.CameraType.perspective&&e.fov&&(e.fov*=Math.PI/180)},r.processSkyboxComponentData=function(e){void 0===e.intensity&&(e.intensity=1),void 0===e.reflectionsIntensity&&(e.reflectionsIntensity=1)},r.processMaterialData=function(e){var n,r;(null==(n=e.shader)?void 0:n.id)===W?(e.colors._BaseColorFactor||(e.colors._BaseColorFactor={r:1,g:1,b:1,a:1}),void 0===e.floats._AlphaCutoff&&(e.floats._AlphaCutoff=0),void 0===e.floats.ZWrite&&(e.floats.ZWrite=1),void 0===e.floats.ZTest&&(e.floats.ZTest=1),e.stringTags.RenderType||(e.stringTags.RenderType=t.spec.RenderType.Opaque),e.stringTags.RenderFace||(e.stringTags.RenderFace=t.spec.RenderFace.Front)):(null==(r=e.shader)?void 0:r.id)===j?(e.colors._BaseColorFactor||(e.colors._BaseColorFactor={r:1,g:1,b:1,a:1}),void 0===e.floats._SpecularAA&&(e.floats._SpecularAA=0),void 0===e.floats._MetallicFactor&&(e.floats._MetallicFactor=1),void 0===e.floats._RoughnessFactor&&(e.floats._RoughnessFactor=0),void 0===e.floats._NormalScale&&(e.floats._NormalScale=1),void 0===e.floats._OcclusionStrength&&(e.floats._OcclusionStrength=this.isTiny3dMode()?0:1),e.colors._EmissiveFactor||(e.colors._EmissiveFactor={r:0,g:0,b:0,a:1}),void 0===e.floats._EmissiveIntensity&&(e.floats._EmissiveIntensity=1),void 0===e.floats._AlphaCutoff&&(e.floats._AlphaCutoff=0),void 0===e.floats.ZWrite&&(e.floats.ZWrite=1),void 0===e.floats.ZTest&&(e.floats.ZTest=1),e.stringTags.RenderType||(e.stringTags.RenderType=t.spec.RenderType.Opaque),e.stringTags.RenderFace||(e.stringTags.RenderFace=t.spec.RenderFace.Front)):console.error("Encountered unknown shader ID in material with ID: "+e.id+".")},r.processTextureOptions=function(e,n,r){var i,o,a,s,l=!1,c=null!=(i=e.minFilter)?i:t.glContext.LINEAR_MIPMAP_LINEAR;this.isTiny3dMode()&&(c=t.glContext.LINEAR_MIPMAP_LINEAR,!r||e3.isPow2(r.width)&&e3.isPow2(r.height)||(c=t.glContext.LINEAR),l=!n);var u=c==t.glContext.NEAREST_MIPMAP_NEAREST||c==t.glContext.LINEAR_MIPMAP_NEAREST||c==t.glContext.NEAREST_MIPMAP_LINEAR||c==t.glContext.LINEAR_MIPMAP_LINEAR;e.wrapS=null!=(o=e.wrapS)?o:t.glContext.REPEAT,e.wrapT=null!=(a=e.wrapT)?a:t.glContext.REPEAT,e.magFilter=null!=(s=e.magFilter)?s:t.glContext.LINEAR,e.minFilter=c,e.anisotropic=1,e.premultiplyAlpha=l,e.generateMipmap=u},r.initial=function(e){this.loaderOptions=null!=e?e:{}},r.checkMeshComponentData=function(e,t){var n;if(e.materials.length<=0)throw Error("Submesh array is empty for mesh with ID: "+e.id+".");if(t.meshes.forEach(function(t){t.geometryData.id===e.geometry.id&&(n=t.geometryData)}),void 0===n)throw Error("Unable to find geometry data for mesh with ID: "+e.geometry.id+".");if(n.subMeshes.length!==e.materials.length)throw Error("Mismatch between submeshes count ("+n.subMeshes.length+") and materials count ("+e.materials.length+").")},r.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 Error("Invalid texture option source data, "+s.source);a=i[s.source],s&&this.processTextureOptions(s,n,a)}},r.getLoadResult=function(){var e=[];this.items.forEach(function(t){return e.push({id:t.id})}),this.composition.items=e;var n={version:"3.0",playerVersion:{web:"2.0",native:"2.0"},type:"ge",compositionId:this.composition.id,compositions:[this.composition],images:this.images,shapes:[],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:t.spec.DataType.TimelineAsset}]},r=this.computeSceneAABB();return{source:this.getRemarkString(),jsonScene:n,sceneAABB:{min:r.min.toArray(),max:r.max.toArray()}}},r.addLight=function(e){var n=t.generateGUID(),r={id:t.generateGUID(),item:{id:n},dataType:t.spec.DataType.LightComponent,lightType:e.lightType,color:e.color,intensity:e.intensity,range:e.range,innerConeAngle:e.innerConeAngle,outerConeAngle:e.outerConeAngle},i={id:n,name:e.name,duration:e.duration,type:t.spec.ItemType.light,pn:0,visible:!0,endBehavior:e.endBehavior,transform:{position:{x:e.position[0],y:e.position[1],z:e.position[2]},eulerHint:{x:e.rotation[0],y:e.rotation[1],z:e.rotation[2]},scale:{x:e.scale[0],y:e.scale[1],z:e.scale[2]}},components:[{id:r.id}],content:{},dataType:t.spec.DataType.VFXItemData};this.items.push(i),this.components.push(r)},r.addCamera=function(e){var n=t.generateGUID(),r={id:t.generateGUID(),item:{id:n},dataType:t.spec.DataType.CameraComponent,fov:e.fov,near:e.near,far:e.far,clipMode:e.clipMode},i={id:n,name:e.name,duration:e.duration,type:"camera",pn:0,visible:!0,endBehavior:e.endBehavior,transform:{position:{x:e.position[0],y:e.position[1],z:e.position[2]},eulerHint:{x:e.rotation[0],y:e.rotation[1],z:e.rotation[2]},scale:{x:1,y:1,z:1}},components:[{id:r.id}],content:{},dataType:t.spec.DataType.VFXItemData};this.items.push(i),this.components.push(r)},r.tryAddSkybox=function(e){var n=this;return C(function(){var r,i,o,a,s,l,c,u,h,f,d;return A(this,function(m){return n.gltfImageBasedLights.length>0&&!n.ignoreSkybox()?(r=n.gltfImageBasedLights[0],n.components.push(r.imageBaseLightData)):void 0!==e.skyboxType&&(a=t.generateGUID(),l=(s=n.createSkyboxComponentData(e.skyboxType)).imageList,c=s.textureOptionsList,(u=s.component).item.id=a,void 0!==e.intensity&&(u.intensity=e.intensity),void 0!==e.reflectionsIntensity&&(u.reflectionsIntensity=e.reflectionsIntensity),u.renderable=null!=(h=e.renderable)&&h,d={id:a,name:"Skybox-"+e.skyboxType,duration:null!=(f=e.duration)?f:999,type:t.spec.ItemType.skybox,pn:0,visible:!0,endBehavior:t.spec.ItemEndBehavior.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:t.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]})})()},r.createSkyboxComponentData=function(t){if("NFT"!==t&&"FARM"!==t)throw Error("Invalid skybox type specified: '"+t+"'. Valid types are: 'NFT', 'FARM'.");var n="NFT"===t?e.PSkyboxType.NFT:e.PSkyboxType.FARM,r=tu.getSkyboxParams(n);return tu.createSkyboxComponentData(r)},r.clear=function(){this.images=[],this.textures=[],this.items=[],this.components=[],this.materials=[],this.shaders=[],this.geometries=[]},r.computeSceneAABB=function(){var e={};this.gltfMeshs.forEach(function(t){e[t.geometryData.id]=t});var n={};this.components.forEach(function(r){r.dataType===t.spec.DataType.MeshComponent&&(n[r.id]=e[r.geometry.id])});var r=new V,i={};return this.items.forEach(function(e){var o,a,s=null!=(a=i[null!=(o=e.parentId)?o:""])?a:new t.Transform,l={};e.transform&&(l.position=new L().copyFrom(e.transform.position),l.rotation=U.fromVector3(e.transform.eulerHint),l.scale=new L().copyFrom(e.transform.scale));var c=new t.Transform(l,s);i[e.id]=c,e.components.forEach(function(e){var t=n[e.id];if(t&&t.bounds){var i=L.fromArray(t.bounds.box.min),o=L.fromArray(t.bounds.box.max);r.union(new V(i,o))}})}),r},r.getPlayAnimationIndex=function(e){var t=e.animations;if(void 0===t||t.length<=0)return -1;if(this.isPlayAllAnimation())return -88888888;var n=this.sceneOptions.effects.playAnimation;if(void 0===n)return -1;if("number"==typeof n)return n>=0&&n<t.length?n:-1;var r=-1;return t.forEach(function(e,t){e.name===n&&(r=t)}),r},r.isPlayAnimation=function(){return void 0!==this.sceneOptions.effects.playAnimation},r.isPlayAllAnimation=function(){return!0===this.sceneOptions.effects.playAllAnimation},r.getRemarkString=function(){var e=this.sceneOptions.gltf.remark;return void 0===e?"Unknown":"string"==typeof e?e:"BinaryBuffer"},r.getCompositionDuration=function(){return this.composition.duration},r.isTiny3dMode=function(){return"tiny3d"===this.loaderOptions.compatibleMode},r.getItemDuration=function(){var e;return null!=(e=this.sceneOptions.effects.duration)?e:9999},r.getItemEndBehavior=function(){var e;return null!=(e=this.sceneOptions.effects.endBehavior)?e:t.spec.ItemEndBehavior.loop},r.getSkyboxType=function(){switch(this.sceneOptions.gltf.skyboxType){case"NFT":return e.PSkyboxType.NFT;case"FARM":return e.PSkyboxType.FARM}},r.isSkyboxVis=function(){return!0===this.sceneOptions.gltf.skyboxVis},r.ignoreSkybox=function(){return!0===this.sceneOptions.gltf.ignoreSkybox},r.isEnvironmentTest=function(){return"string"==typeof this.sceneOptions.gltf.remark&&this.sceneOptions.gltf.remark.includes("EnvironmentTest")},n}();t.registerPlugin("tree",tp,t.VFXItem,!0),t.registerPlugin("model",tf,t.VFXItem);var tM="2.0.0-alpha.21";t.logger.info("Plugin model version: "+tM+"."),tM!==T.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!"),e.Box3=V,e.BoxMesh=eb,e.CameraGestureHandlerImp=tg,e.CheckerHelper=tt,e.Color=F,e.CompositionCache=th,e.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]]})},e.DEG2RAD=H,e.Euler=U,e.EulerOrder=B,e.FBOOptions=e_,e.Float16ArrayWrapper=tn,e.GeometryBoxProxy=e9,e.HitTestingProxy=te,e.HookOGLFunc=function(e){console.info("HookOGLFunc "+Object.getPrototypeOf(e));var t=0;for(var n in Object.getPrototypeOf(e))"getError"!==n&&"function"==typeof e[n]&&(++t,e[n+eX]=e[n],e[n]=function(e,t){return function(){var n,r,i=e[t+eX].apply(this,arguments),o=e.getError();return o>0?(console.info("OpenGLError: "+((r=new Map).set(WebGLRenderingContext.NO_ERROR,"NO_ERROR"),r.set(WebGLRenderingContext.INVALID_ENUM,"INVALID_ENUM"),r.set(WebGLRenderingContext.INVALID_VALUE,"INVALID_VALUE"),r.set(WebGLRenderingContext.INVALID_OPERATION,"INVALID_OPERATION"),r.set(WebGLRenderingContext.INVALID_FRAMEBUFFER_OPERATION,"INVALID_FRAMEBUFFER_OPERATION"),r.set(WebGLRenderingContext.OUT_OF_MEMORY,"OUT_OF_MEMORY"),r.set(WebGLRenderingContext.CONTEXT_LOST_WEBGL,"CONTEXT_LOST_WEBGL"),(null!=(n=r.get(o))?n:"UNKNOWN_ERROR")+"("+o+")")+" ===> "+eq(t,arguments)),console.trace()):console.info(eq(t,arguments)),i}}(e,n));console.info("HookCount "+t),function(e){for(var t in Object.getPrototypeOf(e))"number"==typeof e[t]&&eJ.set(e[t],t)}(e)},e.InterpolationSampler=er,e.JSONConverter=ty,e.LoaderHelper=tv,e.LoaderImpl=tx,e.Matrix3=O,e.Matrix4=D,e.MeshHelper=e4,e.ModelPlugin=tf,e.ModelTreeItem=tm,e.ModelTreePlugin=tp,e.PAnimTexture=ef,e.PAnimTrack=eh,e.PAnimation=ed,e.PAnimationManager=em,e.PBRShaderGUID=j,e.PCamera=eg,e.PCameraManager=ev,e.PCoordinate=J,e.PEntity=K,e.PGeometry=ex,e.PGlobalState=q,e.PLight=ey,e.PLightManager=eT,e.PMaterialBase=ti,e.PMaterialPBR=ta,e.PMaterialSkyboxFilter=tc,e.PMaterialUnlit=to,e.PMesh=eC,e.PMorph=eu,e.PObject=Z,e.PSceneManager=eA,e.PShaderManager=eW,e.PSkin=ec,e.PSkybox=tl,e.PSkyboxCreator=tu,e.PSubMesh=eS,e.PTransform=X,e.PluginHelper=e6,e.Quaternion=k,e.Ray=z,e.RayBoxTesting=eK,e.RayIntersectsBoxWithRotation=eZ,e.RayTriangleTesting=e2,e.Sphere=G,e.ToggleItemBounding=function(t,n){var r;null==(r=t.items)||r.forEach(function(t){if(t.type===_){var r=t.getComponent(e.ModelMeshComponent);if(r){var i=r.content;t.id===n?i.visBoundingBox=!0:i.visBoundingBox=!1}}})},e.TwoStatesSet=eI,e.UnlitShaderGUID=W,e.VFX_ITEM_TYPE_3D=_,e.Vector2=P,e.Vector3=L,e.Vector4=R,e.VertexAttribBuffer=e5,e.WebGLHelper=e3,e.WebHelper=e8,e.createAnimationSampler=el,e.createPluginMaterial=ts,e.fetchPBRShaderCode=eD,e.fetchUnlitShaderCode=eF,e.getDefaultEffectsGLTFLoader=function(e){return y||(y=new tx),y.initial(e),y},e.getDefaultPBRMaterialData=function(){return{id:"00000000000000000000000000000000",name:"PBR Material",dataType:t.spec.DataType.Material,stringTags:{RenderType:t.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:{}}},e.getDefaultUnlitMaterialData=function(){return{id:"00000000000000000000000000000000",name:"Unlit Material",dataType:t.spec.DataType.Material,stringTags:{ZWrite:"true",ZTest:"true",RenderType:t.spec.RenderType.Opaque,Cull:"Front"},macros:[],shader:{id:"unlit000000000000000000000000000"},ints:{},floats:{_AlphaCutoff:.5},vector4s:{},colors:{_BaseColorFactor:{r:1,g:1,b:1,a:1}},textures:{}}},e.getDiffuseOnlyShaderCode=function(e){return{vertexShaderCode:eH({hasNormals:!0}),fragmentShaderCode:"\n #version 100\n precision highp float;\n varying vec3 v_Normal;\n void main(){\n vec3 lightDir = normalize(vec3(1, 1, 1));\n gl_FragColor = vec4(max(0.0, dot(v_Normal, lightDir)) * 0.8);\n }\n "}},e.getGaussianBlurShaderCodeV1=function(e){return{vertexShaderCode:ej(),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 "}},e.getGaussianBlurShaderCodeV2=ez,e.getGeometryDataFromOptions=function(e){var n=0,r=t.spec.VertexFormatType.Float32,i=!1,o=t.spec.VertexFormatType.Float32,a=!1,s=t.spec.VertexFormatType.Float32,l=!1,c={vertices:new Float32Array,uvs:new Float32Array,normals:new Float32Array,indices:new Float32Array,name:null!=(h=e.name)?h:"<empty>"};for(var u in e.attributes){var h,f,d,m,p,g,v,y=e.attributes[u];"aPosition"===u?(n=y.data.length/y.size,c.vertices=y.data,i=null!=(f=y.normalize)&&f,r=t.glType2VertexFormatType(null!=(d=y.type)?d:t.glContext.FLOAT)):"aNormal"===u?(c.normals=y.data,l=null!=(m=y.normalize)&&m,s=t.glType2VertexFormatType(null!=(p=y.type)?p:t.glContext.FLOAT)):"aUV1"===u&&(c.uvs=y.data,a=null!=(g=y.normalize)&&g,o=t.glType2VertexFormatType(null!=(v=y.type)?v:t.glContext.FLOAT))}var T=tb(r,3,n),_=tb(o,2,n),b=tb(s,3,n);if(e.indices)c.indices=e.indices.data;else if(n<=65535){for(var C=new Uint16Array(n),S=0;S<n;S++)C[S]=S;c.indices=C}else{for(var x=new Uint32Array(n),M=0;M<n;M++)x[M]=M;c.indices=x}var I=t.spec.IndexFormatType.UInt16;return 4===c.indices.BYTES_PER_ELEMENT&&(I=t.spec.IndexFormatType.UInt32),{id:t.generateGUID(),dataType:t.spec.DataType.Geometry,vertexData:{vertexCount:n,channels:[{semantic:t.spec.VertexBufferSemantic.Position,offset:0,format:r,dimension:3,normalize:i},{semantic:t.spec.VertexBufferSemantic.Uv,offset:T,format:o,dimension:2,normalize:a},{semantic:t.spec.VertexBufferSemantic.Normal,offset:T+_,format:s,dimension:3,normalize:l}]},subMeshes:[],mode:t.spec.GeometryType.TRIANGLES,indexFormat:I,indexOffset:T+_+b,buffer:function(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=new ArrayBuffer(t.byteLength+n.byteLength+r.byteLength+i.byteLength),a=new Uint8Array(o,0,t.byteLength);a.set(t),(a=new Uint8Array(o,t.byteLength,n.byteLength)).set(n),(a=new Uint8Array(o,t.byteLength+n.byteLength,r.byteLength)).set(r),new Uint8Array(o,t.byteLength+n.byteLength+r.byteLength,i.byteLength).set(i);for(var s=new Uint8Array(o),l="",c=0;c<s.length;c++)l+=String.fromCharCode(s[c]);return btoa(l)}(c)}},e.getGeometryDataFromPropsList=t_,e.getKawaseBlurShaderCode=function(e){return{vertexShaderCode:ej(),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 "}},e.getNormalVisShaderCode=eV,e.getPBRPassShaderCode=eU,e.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 '},e.getPMeshList=function(t){var n=[],r=t.getCompositions()[0];return null==r||r.items.forEach(function(t){if(t.type===_){var r=t.getComponent(e.ModelMeshComponent);(null==r?void 0:r.content.type)===e.PObjectType.mesh&&n.push(r.content)}}),n},e.getQuadFilterShaderCode=function(e){return{vertexShaderCode:ej(),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 "}},e.getRendererGPUInfo=function(e){return JSON.stringify(e.gpuCapability,void 0,2)},e.getSceneManager=td,e.getShadowPassShaderCode=eB,e.getSimpleFilterShaderCode=eG,e.getSkyBoxShaderCode=ek,e.getTransparecyBaseShader=function(e){return e?eH({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 "},e.getTransparecyFilterShader=function(e){return e?ej():"\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 "},e.getUnlitShaderProperties=function(){return'\n _BaseColorSampler ("基础贴图", 2D) = "" {}\n _BaseColorFactor ("基础颜色", Color) = (1, 1, 1, 1)\n _AlphaCutoff ("Alpha裁剪值", Range(0, 1)) = 0.5\n '},e.setDefaultEffectsGLTFLoader=function(e){y=e},e.version=tM,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
9
8
|
//# sourceMappingURL=index.min.js.map
|