@rings-webgpu/core 1.0.23 → 1.0.25

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.
@@ -32698,9 +32698,32 @@ class StringUtil {
32698
32698
  return url.substring(0, s_pos);
32699
32699
  }
32700
32700
  static normalizePath(url) {
32701
- var tmp = url.replaceAll(`//`, `/`);
32702
- tmp = tmp.replaceAll(`\\`, `/`);
32703
- return tmp;
32701
+ if (!url) {
32702
+ return url;
32703
+ }
32704
+ let normalized = url.replace(/\\/g, "/");
32705
+ const preserveLeadingDoubleSlash = normalized.startsWith("//");
32706
+ const protectedTokens = [];
32707
+ let tokenIndex = 0;
32708
+ normalized = normalized.replace(
32709
+ /([a-zA-Z][a-zA-Z0-9+\-.]*):\/{2}/g,
32710
+ (match, scheme, offset) => {
32711
+ if (scheme.length === 1 && offset === 0) {
32712
+ return match;
32713
+ }
32714
+ const token = `__SCHEME_SLASH_${tokenIndex++}__`;
32715
+ protectedTokens.push(token);
32716
+ return `${scheme}:${token}`;
32717
+ }
32718
+ );
32719
+ normalized = normalized.replace(/\/{2,}/g, "/");
32720
+ protectedTokens.forEach((token) => {
32721
+ normalized = normalized.replace(token, "//");
32722
+ });
32723
+ if (preserveLeadingDoubleSlash) {
32724
+ normalized = `//${normalized.replace(/^\/+/, "")}`;
32725
+ }
32726
+ return normalized;
32704
32727
  }
32705
32728
  static getStringList(str, char = ";") {
32706
32729
  return str.split(char);
@@ -37078,6 +37101,7 @@ class OBJParser extends ParserBase {
37078
37101
  }
37079
37102
  }
37080
37103
  }
37104
+ const promiseList = [];
37081
37105
  for (const key in this.matLibs) {
37082
37106
  const mat2 = this.matLibs[key];
37083
37107
  if (mat2.textures && mat2.textures.length > 0) {
@@ -37085,10 +37109,16 @@ class OBJParser extends ParserBase {
37085
37109
  const texUrl = StringUtil.normalizePath(
37086
37110
  this.baseUrl + mat2.textures[i]
37087
37111
  );
37088
- await Engine3D.res.loadTexture(texUrl);
37112
+ promiseList.push(Engine3D.res.loadTexture(texUrl).catch(
37113
+ (error) => {
37114
+ console.error(`Failed to load texture: ${texUrl}`, error);
37115
+ return null;
37116
+ }
37117
+ ));
37089
37118
  }
37090
37119
  }
37091
37120
  }
37121
+ await Promise.all(promiseList);
37092
37122
  sourceData = null;
37093
37123
  return true;
37094
37124
  }
@@ -40953,7 +40983,12 @@ class Res {
40953
40983
  }
40954
40984
  let texture = new BitmapTexture2D();
40955
40985
  texture.flipY = flipY;
40956
- await texture.load(url, loaderFunctions);
40986
+ try {
40987
+ await texture.load(url, loaderFunctions);
40988
+ } catch (error) {
40989
+ console.error(`Failed to load texture: ${url}`, error);
40990
+ return null;
40991
+ }
40957
40992
  this._texturePool.set(url, texture);
40958
40993
  return texture;
40959
40994
  }
@@ -41253,7 +41288,7 @@ class PostProcessingComponent extends ComponentBase {
41253
41288
  }
41254
41289
  }
41255
41290
 
41256
- const version = "1.0.22";
41291
+ const version = "1.0.24";
41257
41292
 
41258
41293
  class Engine3D {
41259
41294
  /**
package/dist/rings.umd.js CHANGED
@@ -7228,7 +7228,7 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
7228
7228
  }
7229
7229
  `;class p0{computeShader;worldPosMap;worldNormalMap;colorMap;shadowMap;pointShadowMap;lightingTexture;constructor(){let e=A.setting.gi;this.lightingTexture=new gt(e.probeSourceTextureSize,e.probeSourceTextureSize,Y.rgba16float,!1,GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.STORAGE_BINDING)}create(e){let t=le.getLightEntries(e.scene);this.computeShader=new fe(m0);let a=le.getCameraGroup(e.camera);this.computeShader.setUniformBuffer("globalUniform",a.uniformGPUBuffer),this.computeShader.setStorageTexture("outputBuffer",this.lightingTexture),this.computeShader.setStorageBuffer("lightBuffer",t.storageGPUBuffer),this.computeShader.setStorageBuffer("models",le.modelMatrixBindGroup.matrixBufferDst),this.computeShader.setSamplerTexture("positionMap",this.worldPosMap),this.computeShader.setSamplerTexture("normalMap",this.worldNormalMap),this.computeShader.setSamplerTexture("colorMap",this.colorMap),this.computeShader.setSamplerTexture("shadowMap",this.shadowMap),this.computeShader.setSamplerTexture("pointShadowMap",this.pointShadowMap),this.computeShader.setSamplerTexture("prefilterMap",A.res.defaultSky)}setInputs(e){this.worldPosMap=e[0],this.worldNormalMap=e[1],this.colorMap=e[2],this.shadowMap=e[3],this.pointShadowMap=e[4]}compute(e,t){this.computeShader||this.create(e);let a=S.beginCommandEncoder(),r=A.setting.gi;this.computeShader.workerSizeX=r.probeSourceTextureSize/8,this.computeShader.workerSizeY=r.probeSourceTextureSize/8,this.computeShader.workerSizeZ=1,S.computeCommand(a,[this.computeShader]),S.endCommandEncoder(a)}}let cn=new qe("GIRenderStartEvent"),Bs=new qe("GIRenderCompleteEvent");class t2{count;complete}class A0 extends ma{cubeCamera;volume;probeCountPerFrame=1;nextProbeIndex=-1;tempProbeList=[];isRenderCloudGI;probeRenderResult;renderStatus="none";positionMap;normalMap;colorMap;probeNext=128;sizeW;sizeH;lightingPass;bouncePass;irradianceComputePass;irradianceDepthMap;irradianceColorMap;constructor(e){super(),this.passType=H.GI,this.volume=e;let t=e.setting;this.cubeCamera=new Ds(.01,5e3),this.sizeW=t.probeSourceTextureSize,this.sizeH=t.probeSourceTextureSize,this.probeNext=t.probeSourceTextureSize/t.probeSize,this.initIrradianceMap(e),this.probeRenderResult=new t2;let a=new d0(this.sizeW,this.sizeH,!1);this.positionMap=a.renderTargets[0],this.normalMap=a.renderTargets[1],this.colorMap=a.renderTargets[2],this.setRenderStates(a)}setInputTexture(e){this.lightingPass=new p0,this.bouncePass=new g0(this.volume),this.irradianceComputePass=new u0(this.volume),this.lightingPass.setInputs([this.positionMap,this.normalMap,this.colorMap,e[0],e[1]]),this.bouncePass.setInputs([this.normalMap,this.colorMap,this.lightingPass.lightingTexture,this.irradianceColorMap]),this.irradianceComputePass.setTextures([this.positionMap,this.normalMap,this.bouncePass.blendTexture],this.irradianceColorMap,this.irradianceDepthMap)}setIrradianceData(e,t,a,r){if(a!=this.irradianceColorMap.width||r!=this.irradianceColorMap.height){console.error("irradiance image size not match !");return}this.writeToTexture(this.irradianceColorMap,e,a,r),this.writeToTexture(this.irradianceDepthMap,t,a,r)}updateProbe(e,t,a){let r=W.instance.getLights(e.scene),i=this.volume.setting.probeSize;t.drawCallFrame+=1,this.cubeCamera.x=t.x,this.cubeCamera.y=t.y,this.cubeCamera.z=t.z,this.volume.setting.debugCamera?(this.cubeCamera.x=e.camera.transform.x,this.cubeCamera.y=e.camera.transform.y,this.cubeCamera.z=e.camera.transform.z,this.cubeCamera.rotationX=e.camera.transform.rotationX,this.cubeCamera.rotationY=e.camera.transform.rotationY,this.cubeCamera.rotationZ=e.camera.transform.rotationZ):(this.cubeCamera.rotationX=t.rotationX,this.cubeCamera.rotationY=t.rotationY,this.cubeCamera.rotationZ=t.rotationZ);let n=this.cubeCamera,o=Math.floor(t.index/this.probeNext)*(i*6),l=Math.floor(t.index%this.probeNext)*i;a.setViewport(0+o,l,i,i,0,1),this.renderSceneOnce(e,n.right_camera,a,r),a.setViewport(i+o,l,i,i,0,1),this.renderSceneOnce(e,n.left_camera,a,r),a.setViewport(i*2+o,l,i,i,0,1),this.renderSceneOnce(e,n.up_camera,a,r),a.setViewport(i*3+o,l,i,i,0,1),this.renderSceneOnce(e,n.down_camera,a,r),a.setViewport(i*4+o,l,i,i,0,1),this.renderSceneOnce(e,n.front_camera,a,r),a.setViewport(i*5+o,l,i,i,0,1),this.renderSceneOnce(e,n.back_camera,a,r)}renderSceneOnce(e,t,a,r){this.volume.uploadBuffer();let i=W.instance.getRenderNodes(e.scene,t);S.bindCamera(a,t);let n=Math.max(0,A.setting.render.drawOpMin),o=Math.min(A.setting.render.drawOpMax,i.opaqueList.length),l=W.instance.getRenderShaderCollect(e);for(const c of l){let f=c[1];for(const h of f){let u=h[1];if(!u.isDestroyed&&u.preInit(this.passType)){u.nodeUpdate(e,this.passType,this.rendererPassState,null);break}}}for(let c=n;c<o;++c){let f=i.opaqueList[c];f.enable&&f.transform.enable&&!f.isDestroyed&&(f.preInit(this.passType)||f.nodeUpdate(e,this.passType,this.rendererPassState,null),f.renderPass2(e,this.passType,this.rendererPassState,null,a))}W.instance.sky&&(W.instance.sky.preInit(this.passType)||W.instance.sky.nodeUpdate(e,this.passType,this.rendererPassState,null),W.instance.sky.renderPass2(e,this.passType,this.rendererPassState,null,a)),n=Math.max(0,A.setting.render.drawTrMin),o=Math.min(A.setting.render.drawTrMax,i.transparentList.length);for(let c=n;c<o;++c){let f=i.transparentList[c];f.enable&&f.transform.enable&&!f.isDestroyed&&(f.preInit(this.passType)||f.nodeUpdate(e,this.passType,this.rendererPassState,null),f.renderPass2(e,this.passType,this.rendererPassState,null,a))}}render(e,t){if(!A.setting.gi.enable)return;this.volume.updateOrientation(),this.volume.isVolumeFrameChange=!1,this.volume.uploadBuffer(),this.rendProbe(e);let a=this.probeRenderResult.count>0;(W.instance.state.giLightingChange||a||A.setting.gi.realTimeGI)&&(W.instance.state.giLightingChange=!1,this.lightingPass.compute(e,this.rendererPassState),this.bouncePass.compute(e,this.rendererPassState),this.irradianceComputePass.compute(e,this.rendererPassState)),this.probeRenderResult.complete&&this.dispatchEvent(Bs)}startRenderGI(e=0){this.nextProbeIndex==-1&&e==0&&this.dispatchEvent(cn),this.nextProbeIndex=e,this.renderStatus="rendering"}startRenderCloudGI(){this.dispatchEvent(cn),this.nextProbeIndex=0,this.renderStatus="rendering",this.isRenderCloudGI=!0}rendProbe(e){let t=A.setting.gi.autoRenderProbe,a=!1;if(t?(this.nextProbeIndex==-1&&this.startRenderGI(),a=!0):a=this.renderStatus=="rendering",this.probeRenderResult.count=0,this.probeRenderResult.complete=!1,a){let r=W.instance.getProbes(e.scene);this.renderContext.clean(),this.renderContext.beginOpaqueRenderPass(),this.tempProbeList.length=0;let i=Math.min(this.probeCountPerFrame,r.length);for(this.probeRenderResult.count=i;i>0;){const o=r[this.nextProbeIndex];this.updateProbe(e,o,this.renderContext.encoder),i--,this.nextProbeIndex++,o.drawCallFrame<3&&this.tempProbeList.push(o)}this.tempProbeList.length>0&&this.volume.updateProbes(this.tempProbeList);let n=this.nextProbeIndex>=r.length;this.nextProbeIndex>=r.length&&this.isRenderCloudGI&&this.updateProbe(e,r[0],this.renderContext.encoder),this.renderContext.endRenderPass(),n&&(this.nextProbeIndex=-1,this.renderStatus="complete",this.probeRenderResult.complete=!0)}}initIrradianceMap(e){let t=e.setting,a=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST;this.irradianceDepthMap=new gt(t.octRTMaxSize,t.octRTMaxSize,Y.rgba16float,!1,a),this.irradianceDepthMap.name="irradianceDepthMap",this.irradianceColorMap=new gt(t.octRTMaxSize,t.octRTMaxSize,Y.rgba16float,!1,a),this.irradianceColorMap.name="irradianceColorMap"}writeToTexture(e,t,a,r){console.log(e.name);const i=E.device.createBuffer({size:t.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});E.device.queue.writeBuffer(i,0,t);const n=S.beginCommandEncoder();n.copyBufferToTexture({buffer:i,bytesPerRow:a*16},{texture:e.getGPUTexture()},{width:a,height:r,depthOrArrayLayers:1}),S.endCommandEncoder(n)}}class D0 extends ma{constructor(){super(),this.passType=H.UI}compute(e,t){let a=S.beginCommandEncoder(),r=S.lastRenderPassState.getLastRenderTexture(),i=oe.getGUIBufferFrame().getColorTexture();S.copyTexture(a,r,i),S.endCommandEncoder(a)}render(e,t,a,r=!1){this.renderContext.clean();let i=e.scene,n=e.camera;le.updateCameraGroup(n),this.rendererPassState.camera3D=n;let o=W.instance.getRenderNodes(i,n);{this.renderContext.specialtRenderPass();let l=this.renderContext.encoder;o.opaqueList&&(S.bindCamera(l,n),this.drawNodes(e,this.renderContext,o.opaqueList,t,a))}{let l=this.renderContext.encoder;!r&&o.transparentList&&(S.bindCamera(l,n),this.drawNodes(e,this.renderContext,o.transparentList,t,a)),this.renderContext.endRenderPass()}}drawNodes(e,t,a,r,i){let n=W.instance.getRenderShaderCollect(e);if(n){for(const o of n){let l=o[1];for(const c of l){let f=c[1];if(!f.isDestroyed&&f.preInit(this._rendererType)){f.nodeUpdate(e,this._rendererType,this.rendererPassState,i);break}}}for(let o=A.setting.render.drawOpMin;o<Math.min(a.length,A.setting.render.drawOpMax);++o){let l=a[o];l.transform.enable&&l.enable&&(!l.hasMask(De.UI)||l.isRecievePostEffectUI||l.isDestroyed||(l.preInit(this._rendererType)||l.nodeUpdate(e,this._rendererType,this.rendererPassState,i),l.renderPass(e,this.passType,this.renderContext)))}}}occlusionRenderNodeTest(e,t,a){return a.zDepthRenderNodeTest(t)>0}}class _0 extends f0{constructor(e){super(e)}start(){super.start();{let e=new Yc,t=oe.getGBufferFrame(oe.colorPass_GBuffer);if(A.setting.render.zPrePass&&(t.zPreTexture=this.depthPassRenderer.rendererPassState.depthTexture),e.setRenderStates(t),A.setting.gi.enable){let a=le.getLightEntries(this.view.scene);this.ddgiProbeRenderer=new A0(a.irradianceVolume),this.ddgiProbeRenderer.setInputTexture([this.shadowMapPassRenderer.depth2DArrayTexture,this.pointLightShadowRenderer.cubeArrayTexture]),e.setIrradiance(this.ddgiProbeRenderer.irradianceColorMap,this.ddgiProbeRenderer.irradianceDepthMap),this.rendererMap.addRenderer(this.ddgiProbeRenderer)}this.rendererMap.addRenderer(e)}{let e=oe.getGUIBufferFrame(),t=new D0;t.setRenderStates(e),this.rendererMap.addRenderer(t)}A.setting.render.debug&&this.debug()}debug(){}}class B0{_factor;_doubleFactor;constructor(){this._factor=1,this._doubleFactor=2}get accelerateInterpolator(){return this._factor}set accelerateInterpolator(e){this._factor=e,this._doubleFactor=2*this._factor}getInterpolation(e){return this._factor==1?e*e:Math.pow(e,this._doubleFactor)}}class U0{_factor=1;constructor(){}get decelerateInterpolator(){return this._factor}set decelerateInterpolator(e){this._factor=e}getInterpolation(e){let t;return this._factor==1?t=1-(1-e)*(1-e):t=1-Math.pow(1-e,2*this._factor),t}}class v0{_factor=1;constructor(){}getInterpolation(e){return Math.cos((e+1)*Math.PI)/2+.5}}class y0{getInterpolation(e){return e}}class C0{getInterpolation(e){return 4.9*e+4.9*e}}class Vt{constructor(){}static bounce(e){return e*e*9.8}getInterpolation(e){return e*=1.1226,e<.3535?Vt.bounce(e):e<.7408?Vt.bounce(e-.54719)+.7:e<.9644?Vt.bounce(e-.8526)+.9:Vt.bounce(e-1.0435)+.95}getBounceInterpolation(e){return e<.5?Vt.bounce(e):Vt.bounce(e-1)}geJumpUp(e,t){return t<.5?(t=t/.5,e*t-Vt.bounce(t)):t<.8?(t=(t-.5)/(.8-.5),(e*t-Vt.bounce(t))*.3):t<1?(t=(t-.8)/(1-.8),(e*t-Vt.bounce(t))*.15):e*t-Vt.bounce(t)}}class S0{_tension;constructor(){this._tension=2}get anticipateInterpolator(){return this._tension}set anticipateInterpolator(e){this._tension=e}getInterpolation(e){return e*e*((this._tension+1)*e-this._tension)}}class Bi{_tension;constructor(){this._tension=1*1.5}anticipateOvershootInterpolator(e){this._tension=e*1.5}anticipateOvershootInterpolator2(e,t){this._tension=e*t}getInterpolation(e){return e<.5?.5*Bi.a(e*2,this._tension):.5*(Bi.o(e*2-2,this._tension)+2)}static a(e,t){return e*e*((t+1)*e-t)}static o(e,t){return e*e*((t+1)*e+t)}}class x0{_cycles;constructor(e){this._cycles=e}getInterpolation(e){return Math.sin(2*this._cycles*Math.PI*e)}}class F0{_tension;constructor(){this._tension=2}getInterpolation(e){return e-=1,e*e*((this._tension+1)*e+this._tension)+1}}var Us=(s=>(s[s.AccelerateInterpolator=0]="AccelerateInterpolator",s[s.DecelerateInterpolator=1]="DecelerateInterpolator",s[s.AccelerateDecelerateInterpolator=2]="AccelerateDecelerateInterpolator",s[s.LinearInterpolator=3]="LinearInterpolator",s[s.BounceInterpolator=4]="BounceInterpolator",s[s.AnticipateInterpolator=5]="AnticipateInterpolator",s[s.AnticipateOvershootInterpolator=6]="AnticipateOvershootInterpolator",s[s.CycleInterpolator=7]="CycleInterpolator",s[s.OvershootInterpolator=8]="OvershootInterpolator",s[s.JumperInterpolator=9]="JumperInterpolator",s))(Us||{});class rr{static interpolators=[];complete=!1;onComplete;onProgress;target;property;targetProperty;durtion;interpolatorEnum;delayTime=0;_interpolator;_ct=0;_p=0;static to(e,t,a,r=0){var i=new rr;return i.target=e,i.property=t,i.durtion=a,i.interpolatorEnum=r,i.start(),i.delayTime=t.delayTime?t.delayTime:0,t.onComplete&&(i.onComplete=t.onComplete),t.onProgress&&(i.onProgress=t.onProgress),this.interpolators.push(i),i}static tick(e){let t=rr.interpolators;for(let a of t)a.complete?rr.remove(a,!0):a.tick(e)}static remove(e,t){let a=rr.interpolators,r=a.indexOf(e);r!=-1&&a.splice(r,1),t&&e.dispose()}static removeList(e,t){e.forEach(a=>{this.remove(a,t)})}start(){window.AccelerateInterpolator=B0,window.DecelerateInterpolator=U0,window.AccelerateDecelerateInterpolator=v0,window.LinearInterpolator=y0,window.BounceInterpolator=Vt,window.AnticipateInterpolator=S0,window.AnticipateOvershootInterpolator=Bi,window.CycleInterpolator=x0,window.OvershootInterpolator=F0,window.JumperInterpolator=C0,this._interpolator=new window[Us[this.interpolatorEnum]],this.targetProperty={};for(let e in this.property)this.targetProperty[e]=this.target[e]}tick(e){if(this.delayTime<=0){this._p=Math.min(this._ct/this.durtion,1);let t=this._interpolator.getInterpolation(this._p),a=this.property,r=this.target,i=this.targetProperty,n,o;for(let l in a)o=a[l],n=i[l],r[l]=n+(o-n)*t;this.onProgress!=null&&this.onProgress(this._p),this._ct>=this.durtion&&(this.complete=!0,this.onComplete!=null&&this.onComplete(this.target)),this._ct+=e}else this.delayTime-=e}dispose(){this.onComplete=null,this.onProgress=null,this.target=null,this.property=null,this.targetProperty=null,this.interpolatorEnum=null,this._interpolator=null,rr.remove(this)}}class yt{static _filterChar=[" "," ",";",`
7230
7230
  `,"\r"," ",`
7231
- `,"\r"," "];static hasString(e,t){for(var a=0;a<e.length;++a)if(e[a]==t)return a;return-1}static getEllipsis(e,t=4){let a=e;return a.length>t&&(a=a.slice(0,t)+"..."),a}static getURLName(e){var t;t=e.split("/");let a=t[t.length-1];return a=a.split(".")[0],a}static getFileFormat(e){var t=e.lastIndexOf(".");t++;var a=e.length;e.indexOf("?",t)!==-1&&(a=e.indexOf("?",t));var r=e.substr(t,a-t);return r=r.toLowerCase(),r}static readLineProperty(e,t){e.trim().split(" ").forEach((a,r)=>{let i=a.split("=");if(i.length>1){let n=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,n)&&(o.indexOf('"')==-1?t[n]=parseFloat(i[1]):t[n]=o.replace('"',"").replace('"',""))}})}static getPath(e){var t=e.lastIndexOf("/");return t++,e.substring(0,t)}static normalizePath(e){var t=e.replaceAll("//","/");return t=t.replaceAll("\\","/"),t}static getStringList(e,t=";"){return e.split(t)}static formatTime(e){let a=e/1e3/60,r=Math.floor(a),i=Math.floor(a-r);return[r.toString(),i.toString()]}static trim(e){return e.replace(/^\s+/g,"").replace(/\s+$/g,"")}static isEmpty(e){return!e||typeof e>"u"||e==null||typeof e=="string"&&this.trim(e)===""||e==="null"}static strCut(e,t){if(e.length*2<=t)return e;for(var a=0,r="",i=0;i<e.length;i++)if(r=r+e.charAt(i),e.charCodeAt(i)>128){if(a=a+2,a>=t)return r.substring(0,r.length-1)+"..."}else if(a=a+1,a>=t)return r.substring(0,r.length-2)+"...";return r}static toQueryPair(e,t,a=!1){return e+"="+(a?encodeURIComponent(t):t)}static stringFormat(e,...t){if(arguments.length===0)throw new Error("please give arg at least one !");if(arguments.length===2&&typeof arguments[1]=="object")for(let a in arguments[1]){let r=new RegExp("({"+a+"})","g");e=e.replace(r,arguments[1][a])}else for(let a=0;a<t.length;a++){if(t[a]==null)return e;{let r=new RegExp("({["+a+"]})","g");e=e.replace(r,t[a])}}return e}static parseJson2String(e,t){let a=null,r="",i=0,n=" ";return t=t||{},t.newlineAfterColonIfBeforeBraceOrBracket=t.newlineAfterColonIfBeforeBraceOrBracket===!0,t.spaceAfterColon=t.spaceAfterColon!==!1,typeof e!="string"||(e=JSON.parse(e)),e=JSON.stringify(e),a=/([\{\}])/g,e=e.replace(a,`\r
7231
+ `,"\r"," "];static hasString(e,t){for(var a=0;a<e.length;++a)if(e[a]==t)return a;return-1}static getEllipsis(e,t=4){let a=e;return a.length>t&&(a=a.slice(0,t)+"..."),a}static getURLName(e){var t;t=e.split("/");let a=t[t.length-1];return a=a.split(".")[0],a}static getFileFormat(e){var t=e.lastIndexOf(".");t++;var a=e.length;e.indexOf("?",t)!==-1&&(a=e.indexOf("?",t));var r=e.substr(t,a-t);return r=r.toLowerCase(),r}static readLineProperty(e,t){e.trim().split(" ").forEach((a,r)=>{let i=a.split("=");if(i.length>1){let n=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,n)&&(o.indexOf('"')==-1?t[n]=parseFloat(i[1]):t[n]=o.replace('"',"").replace('"',""))}})}static getPath(e){var t=e.lastIndexOf("/");return t++,e.substring(0,t)}static normalizePath(e){if(!e)return e;let t=e.replace(/\\/g,"/");const a=t.startsWith("//"),r=[];let i=0;return t=t.replace(/([a-zA-Z][a-zA-Z0-9+\-.]*):\/{2}/g,(n,o,l)=>{if(o.length===1&&l===0)return n;const c=`__SCHEME_SLASH_${i++}__`;return r.push(c),`${o}:${c}`}),t=t.replace(/\/{2,}/g,"/"),r.forEach(n=>{t=t.replace(n,"//")}),a&&(t=`//${t.replace(/^\/+/,"")}`),t}static getStringList(e,t=";"){return e.split(t)}static formatTime(e){let a=e/1e3/60,r=Math.floor(a),i=Math.floor(a-r);return[r.toString(),i.toString()]}static trim(e){return e.replace(/^\s+/g,"").replace(/\s+$/g,"")}static isEmpty(e){return!e||typeof e>"u"||e==null||typeof e=="string"&&this.trim(e)===""||e==="null"}static strCut(e,t){if(e.length*2<=t)return e;for(var a=0,r="",i=0;i<e.length;i++)if(r=r+e.charAt(i),e.charCodeAt(i)>128){if(a=a+2,a>=t)return r.substring(0,r.length-1)+"..."}else if(a=a+1,a>=t)return r.substring(0,r.length-2)+"...";return r}static toQueryPair(e,t,a=!1){return e+"="+(a?encodeURIComponent(t):t)}static stringFormat(e,...t){if(arguments.length===0)throw new Error("please give arg at least one !");if(arguments.length===2&&typeof arguments[1]=="object")for(let a in arguments[1]){let r=new RegExp("({"+a+"})","g");e=e.replace(r,arguments[1][a])}else for(let a=0;a<t.length;a++){if(t[a]==null)return e;{let r=new RegExp("({["+a+"]})","g");e=e.replace(r,t[a])}}return e}static parseJson2String(e,t){let a=null,r="",i=0,n=" ";return t=t||{},t.newlineAfterColonIfBeforeBraceOrBracket=t.newlineAfterColonIfBeforeBraceOrBracket===!0,t.spaceAfterColon=t.spaceAfterColon!==!1,typeof e!="string"||(e=JSON.parse(e)),e=JSON.stringify(e),a=/([\{\}])/g,e=e.replace(a,`\r
7232
7232
  $1\r
7233
7233
  `),a=/([\[\]])/g,e=e.replace(a,`\r
7234
7234
  $1\r
@@ -7272,7 +7272,7 @@ else if (typeof define === 'function' && define['amd'])
7272
7272
  define([], function() { return DracoDecoderModule; });
7273
7273
  else if (typeof exports === 'object')
7274
7274
  exports["DracoDecoderModule"] = DracoDecoderModule;
7275
- `;class Es{static _workerCode;static _workers=new Map;static async apply(e,t){if(!t.extensions)return;const a=t.extensions.KHR_draco_mesh_compression;if(!a)return;let r=this._workers.get(e.gltf);r||(r=new Worker(await this.initDecoder()),this._workers.set(e.gltf,r)),r.postMessage({type:"init",decoderConfig:{}});let i=e.parseBufferView(a.bufferView);if(!i.result){let n=await new Promise((o,l)=>{r.onmessage=c=>{const f=c.data;f.type=="decode"?o(f.result):f.type=="error"&&l(f.error)},r.postMessage({type:"decoder",buffer:i,attributes:a.attributes},[i])});i.result=n}return i.result}static unload(e){let t=this._workers.get(e);t&&(t.terminate(),this._workers.delete(e))}static async initDecoder(){if(!this._workerCode){const e=new Blob([E0,"",`(${B2})()`],{type:"application/javascript"});this._workerCode=URL.createObjectURL(e)}return this._workerCode}}function B2(){let s,e;onmessage=t=>{const a=t.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise((n,o)=>{s.onModuleLoaded=l=>{n({draco:l})},DracoDecoderModule(s)});break;case"decoder":const r=a.buffer,i=a.attributes;e.then(n=>{const o=n.draco;let l=new o.Decoder,c=new o.DecoderBuffer;c.Init(new Int8Array(r),r.byteLength);let f,h;try{const u=l.GetEncodedGeometryType(c);u==o.TRIANGULAR_MESH?(h=new o.Mesh,f=l.DecodeBufferToMesh(c,h)):self.postMessage(new Error("INVALID_GEOMETRY_TYPE:"+u)),f.ok()||self.postMessage(new Error("DracoDecode:"+f.error_msg()));let g={};for(const p in i){let m=l.GetAttributeByUniqueId(h,i[p]);const D=m.num_components(),B=h.num_points()*D,v=B*Float32Array.BYTES_PER_ELEMENT,C=o.DT_FLOAT32,y=o._malloc(v);l.GetAttributeDataArrayForAllPoints(h,m,C,v,y);const F=new Float32Array(o.HEAPF32.buffer,y,B).slice();o._free(y),g[p]={data:F,numComponents:D,normalize:!1}}{const m=h.num_faces()*3,D=m*4,_=o._malloc(D);l.GetTrianglesUInt32Array(h,D,_);const B=new Uint32Array(o.HEAPF32.buffer,_,m).slice();o._free(_),g.indices={data:B,numComponents:1,normalize:!1}}self.postMessage({type:"decode",result:g})}catch(u){self.postMessage({type:"error",error:u.message})}finally{o.destroy(h),o.destroy(l),o.destroy(c)}});break}}}class R0{gltf;constructor(e){this.gltf=e}parse(e){const t=this.gltf.cameras[e];if(!t)return this.errorMiss("camera",e);if(t.isParsed)return t.dcamera;t.isParsed=!0,t.dcamera=!1;const{name:a,type:r,perspective:i,orthographic:n}=t;if(r==="perspective"&&i){const{aspectRatio:o,yfov:l,zfar:c,znear:f}=i;t.dcamera=Object.assign({},{name:a,type:r,yfov:l,znear:f,aspectRatio:o,zfar:c})}else if(r==="orthographic"&&n){const{xmag:o,ymag:l,zfar:c,znear:f}=n;t.dcamera=Object.assign({},{name:a,type:r,xmag:o,ymag:l,zfar:c,znear:f})}return t.dcamera}errorMiss(e,t){throw new Error(e+t)}}class Dt extends nt{static format=Ge.JSON;_gltf;async parseJson(e){this._gltf=new fn,this._gltf={...this._gltf,...e},this._gltf.resources={},await Promise.all([this.load_gltf_bin(),this.load_gltf_textures()]);let t=new hn,a=await t.parse(this.initUrl,this._gltf,this._gltf.scene);return t.destroy(),t=null,a?(this.data=a.rootNode,a.rootNode):(this._gltf=null,null)}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}static _counter=0;static getMeshNameCounter(){return function(){return`GLTF_NO_NAME_PRIMITIVE_${Dt._counter++}`}}static getModelNameCounter(){let e=0;return function(){return`GLTF_NO_NAME_MESH_${e++}`}}static getTexCoordDefine(e){return`UV_NUM ${e}`}static getVertexColorDefine(e){return`HAS_VERTEXCOLOR ${e}`}static getBaseColorTextureDefine(){return"HAS_BASECOLORMAP"}static getMetalRoughnessDefine(){return"HAS_METALROUGHNESSMAP"}static getNormalMapDefine(){return"HAS_NORMALMAP"}static getEmissiveMapDefine(){return"HAS_EMISSIVEMAP"}static getOcclusionMapDefine(){return"HAS_OCCLUSIONMAP"}static getMorphTargetsDefine(e){return`MORPH_TARGET_NUM ${e}`}static getMorphtargetPositionDefine(){return"HAS_MORPH_POSITION"}static getMorphtargetNormalDefine(){return"HAS_MORPH_NORMAL"}static getMorphtargetTangentDefine(){return"HAS_MORPH_TANGENT"}static getJointsNumDefine(e){return`JOINTS_NUM ${e}`}static getJointVec8Define(){return"JOINT_VEC8"}static getHasNormalDefine(){return"HAS_NORMAL"}static getHasTangentDefine(){return"HAS_TANGENT"}static getHasNormalMapDefine(){return"HAS_NORMAL_MAP"}static getAlphaMaskDefine(){return"ALPHA_MASK"}static getAlphaBlendDefine(){return"ALPHA_BLEND"}static defaultMaterial={name:"GLTF_DEFAULT_MATERIAL",alphaCutoff:.33,alphaMode:"MASK",pbrMetallicRoughness:{name:"GLTF_DEFAULT_MATERIAL",defines:[],doubleSided:!1,baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1,emissiveFactor:[0,0,0]}};async load_gltf_bin(){if(this._gltf.buffers&&this._gltf.buffers.length>0){let e=[];for(let t=0;t<this._gltf.buffers.length;t++){const a=this._gltf.buffers[t];if(a.uri.substring(0,5)!=="data:"){let r=yt.parseUrl(this.baseUrl,a.uri);this.loaderFunctions?.onUrl&&(r=await this.loaderFunctions.onUrl(r));let i=new At().loadBinData(r,this.loaderFunctions).then(n=>{this._gltf.resources[a.uri]=n});e.push(i)}}await Promise.all(e)}}async load_gltf_textures(){if(this._gltf,this._gltf.images){let e=[];for(let t=0;t<this._gltf.images.length;t++){const a=this._gltf.images[t];if(a.uri){let r=yt.parseUrl(this.baseUrl,a.uri);this.loaderFunctions?.onUrl&&(r=await this.loaderFunctions.onUrl(r));let i=new At().loadAsyncBitmapTexture(r,this.loaderFunctions).then(n=>{n.name=yt.getURLName(a.uri),this._gltf.resources[n.name]=n});e.push(i)}}await Promise.all(e)}}}class w0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}async parse(e){const t=this.gltf.meshes[e];if(!t)return this.errorMiss("mesh",e);if(t.isParsed)return t.dprimitives;const a=t.primitives,r=t.extras,i=[];for(let n=0;n<a.length;n++){const o=a[n],{attributes:l,indices:c,material:f,mode:h,name:u,targets:g,morphTargetsRelative:p,extensions:m}=o;let D=t.name;for(let k in l)D+=k;D+=`indices:${c}`,D+=`material:${f}`;const _={attribArrays:{indices:[]},weights:[],defines:[],material:null,drawMode:null,meshName:null,modelName:null,morphTargetsRelative:!1,targetNames:r?r.targetNames:null};let B=!1,v=0,C=!1,y;m&&m.KHR_draco_mesh_compression&&(y=await Es.apply(this.subParser,o));for(const k in l){const w=y?y[k]:this.parseAccessor(l[k]);if(w){let x;switch(k){case"POSITION":x=V.position;break;case"NORMAL":x=V.normal,B=!0;break;case"TEXCOORD_0":x=V.uv,v++;break;case"JOINTS_0":x=V.joints0;break;case"JOINTS_1":x=V.joints1,C=!0;break;case"WEIGHTS_0":x=V.weights0;break;case"WEIGHTS_1":x=V.weights1;break;default:x=k}_.attribArrays[x]=w}}if(B&&_.defines.push(Dt.getHasNormalDefine()),v&&_.defines.push(Dt.getTexCoordDefine(v)),C&&_.defines.push(Dt.getJointVec8Define()),c!==void 0){const k=y?y.indices:this.parseAccessor(c);k&&(_.attribArrays.indices=k)}const F=await this.parseMaterial(f);if(F&&(_.material=F,_.defines=_.defines.concat(F.defines)),_.drawMode=h===void 0?4:h,_.meshName=()=>D,_.modelName=t.name||Dt.getModelNameCounter(),g){_.defines.push(Dt.getMorphTargetsDefine(g.length)),_.morphTargetsRelative=!0;let k=!1,w=!1,x=!1;for(let M=0;M<g.length;M++){const N=g[M];Object.keys(N).forEach(Q=>{const G=this.parseAccessor(N[Q]);if(G){let X;switch(Q){case"POSITION":X=Zt.MORPH_POSITION_PREFIX+M,k=!0;break;case"NORMAL":X=Zt.MORPH_NORMAL_PREFIX+M,w=!0;break;case"TANGENT":X=Zt.MORPH_TANGENT_PREFIX+M,x=!0;break;default:X=!1}X?_.attribArrays[X]=G:console.error(`glTF has unsupported morph target attribute ${Q}`)}})}k&&_.defines.push(Dt.getMorphtargetPositionDefine()),w&&_.defines.push(Dt.getMorphtargetNormalDefine()),x&&_.defines.push(Dt.getMorphtargetTangentDefine()),_.weights=t.weights||new Array(g.length).fill(0)}i.push(_)}return t.dprimitives=i,t.isParsed=!0,t.dprimitives}parseAccessor(e){return this.subParser.parseAccessor(e)}parseMaterial(e){return this.subParser.parseMaterial(e)}errorMiss(e,t){throw new Error(e+t)}}class I0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}async parse(e){let t;if(e==null?t=Dt.defaultMaterial:t=this.gltf.materials[e],!t)return this.errorMiss("material",e);if(t.isParsed)return t.dmaterial;let{name:a,pbrMetallicRoughness:r,normalTexture:i,occlusionTexture:n,emissiveTexture:o,emissiveFactor:l,alphaMode:c,alphaCutoff:f,doubleSided:h,extensions:u}=t;const g={name:a,defines:[],doubleSided:!!h,baseColorFactor:[1,1,1,1],emissiveFactor:null,alphaCutoff:0,enableBlend:!1,baseColorTexture:null,metallicRoughnessTexture:null,normalTexture:null,occlusionTexture:null,emissiveTexture:null,extensions:null,baseMapOffsetSize:null,normalMapOffsetSize:null,emissiveMapOffsetSize:null,roughnessMapOffsetSize:null,metallicMapOffsetSize:null,aoMapOffsetSize:null,metallicFactor:0,roughnessFactor:1};if(r){const{baseColorFactor:p,metallicFactor:m,roughnessFactor:D,baseColorTexture:_,metallicRoughnessTexture:B}=r;if(Object.assign(g,{baseColorFactor:p||[1,1,1,1],metallicFactor:m===void 0?1:m,roughnessFactor:D===void 0?.5:D}),_){let v=_.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.baseMapOffsetSize=F}}const C=await this.parseTexture(_.index);C?g.baseColorTexture=C:g.baseColorTexture=A.res.redTexture}if(i){let v=i.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.normalMapOffsetSize=F}}const C=await this.parseTexture(i.index);C?g.normalTexture=C:g.normalTexture=A.res.normalTexture}if(B){let v=B.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.roughnessMapOffsetSize=F}}const C=await this.parseTexture(B.index);C?g.metallicRoughnessTexture=C:g.metallicRoughnessTexture=A.res.blackTexture}}else Object.assign(g,{baseColorFactor:[1,1,1,1],metallicFactor:0,roughnessFactor:.5});if(g.baseColorFactor&&g.baseColorFactor[3]<1&&(c=c==="MASK"?"MASK":"BLEND"),c&&c!=="OPAQUE"&&(c==="MASK"&&(g.defines.push(Dt.getAlphaMaskDefine()),g.alphaCutoff=f===void 0?.5:f),c==="BLEND"&&(g.defines.push(Dt.getAlphaBlendDefine()),g.enableBlend=!0)),i){const p=await this.parseTexture(i.index);p?g.normalTexture=p:g.normalTexture=A.res.normalTexture}if(n){const p=await this.parseTexture(n.index);p&&(g.occlusionTexture=p)}if(l&&(g.emissiveFactor=l),o){const p=await this.parseTexture(o.index);p?g.emissiveTexture=p:g.emissiveTexture=A.res.blackTexture}return u&&(g.extensions=u),t.isParsed=!0,t.dmaterial=g,g}async parseTexture(e){return this.subParser.parseTexture(e)}errorMiss(e,t){throw new Error(e+t)}}class Q0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}parse(e){const t=this.gltf.skins[e];if(!t)return this.errorMiss("skin",e);if(t.isParsed)return t.dskin;const{name:a,joints:r,inverseBindMatrices:i,skeleton:n}=t;if(!r)return this.errorMiss("skin.joints",e);t.isParsed=!0,t.dskin=!1;let o={name:a,skeleton:null,inverseBindMatrices:null,joints:r,defines:[Dt.getJointsNumDefine(r.length)]};if(n)o.skeleton=n;else{var l=-1;for(let c=0;c<this.gltf.nodes.length;c++)if(this.gltf.nodes[c].name=="root"){l=c;break}if(l==-1){let c=this.gltf.scenes[this.gltf.scene];l=c.nodes[c.nodes.length-1]}o.skeleton=l}if(o.inverseBindMatrices=Zt.IDENTITY_INVERSE_BIND_MATRICES,i!==void 0){const c=this.parseAccessor(i);if(c){const f=c.data,h=[];for(let u=0;u<f.length;u+=16)h.push(f.slice(u,u+16));o.inverseBindMatrices=h}else o=null}return t.dskin=o,t.dskin}parseAccessor(e){return this.subParser.parseAccessor(e)}errorMiss(e,t){throw new Error(e+t)}}class T0{name="";index=0;instanceID="";parent=null;scale=new b;rotation=new Z;translation=new b;constructor(e=""){this.name=e}}class Rs{index;worldMatrix;constructor(e,t=!1){this.index=e,this.worldMatrix=new R(!t)}}class vi{time;_skeleton;_jointsPose;mJointMatrixIndexTable;constructor(e,t=!1){this._skeleton=e,this._jointsPose=new Array(e.numJoint),this.mJointMatrixIndexTable=new Array(e.numJoint);for(let a=0;a<e.numJoint;a++){let r=new Rs(a,t);this._jointsPose[a]=r,this.mJointMatrixIndexTable[a]=r.worldMatrix.index}}buildSkeletonPose(e){let t=new b,a=new Z,r=new b,i=new Array(this._skeleton.numJoint);this.time=e[11]>0?e[11]:e[24];for(let n=0;n<this._skeleton.numJoint;n++){let o=12*n*4,l=new Float32Array(e.buffer,e.byteOffset+o,12),c=new R;t.set(l[0],l[1],l[2]),a.set(l[4],l[5],l[6],l[7]),r.set(l[8],l[9],l[10]),en(a.getEulerAngles(),r,t,c),i[n]=c;let f=new Rs(n);const h=this._skeleton.getJointParentIndex(n);if(h<0)f.worldMatrix.copyFrom(c);else{let u=this._jointsPose[h];tc(u.worldMatrix,c,f.worldMatrix)}this._jointsPose[n]=f}}get numJoint(){return this._skeleton.numJoint}get joints(){return this._jointsPose}get jointMatrixIndexTable(){return this.mJointMatrixIndexTable}lerp(e,t,a){if(e&&t)for(let r=0;r<this._jointsPose.length;r++){let i=e._jointsPose[r],n=t._jointsPose[r];this._jointsPose[r].worldMatrix.lerp(i.worldMatrix,n.worldMatrix,a)}else for(let r=0;r<this._jointsPose.length;r++){let i=e._jointsPose[r];this._jointsPose[r].worldMatrix.copyFrom(i.worldMatrix)}}copyFrom(e){for(let t=0;t<this._jointsPose.length;t++)this._jointsPose[t].worldMatrix.copyFrom(e._jointsPose[t].worldMatrix)}reset(){for(let e=0;e<this._jointsPose.length;e++)this._jointsPose[e].worldMatrix.identity()}}class M0 extends qe{skeletonAnimation;constructor(e,t){super(),this.type=e,this.time=t}}class dn{name="";_skeleton;_skeletonPoses;_animationClipData;_events;constructor(e,t,a,r){if(this.name=e,this._skeleton=t,this._animationClipData=r,a>0&&r){this._skeletonPoses=new Array(a);let i=12*t.numJoint;for(let n=0;n<a;n++){let o=i*n*4;const l=r.buffer instanceof ArrayBuffer?r.buffer:new Uint8Array(r.buffer).buffer;let c=new Float32Array(l,o,i),f=new vi(t);f.buildSkeletonPose(c),this._skeletonPoses[n]=f}}}get totalTime(){return this._skeletonPoses[this._skeletonPoses.length-1].time}get frameRate(){return this.totalTime/this._skeletonPoses.length}get skeleton(){return this._skeleton}get numFrame(){return this._skeletonPoses.length-1}get animationClipData(){return this._animationClipData}getSkeletonPose(e){return this._skeletonPoses[e]}getLerpSkeletonPose(e,t,a,r){let i=this.getSkeletonPose(e),n=this.getSkeletonPose(t);return r.lerp(i,n,a),r}createSubClip(e,t,a){var r=new dn(e,this._skeleton,0,null);const i=Math.max(Math.floor(t/this.frameRate),0),n=Math.min(Math.floor(a/this.frameRate),this._skeletonPoses.length-1);r._skeletonPoses=this._skeletonPoses.slice(i,n);const o=12*this._skeleton.numJoint*4,l=this._animationClipData.buffer instanceof ArrayBuffer?this._animationClipData.buffer:new Uint8Array(this._animationClipData.buffer).buffer;return this._animationClipData=new Float32Array(l,i*o,(n-i)*o),r}addEvent(e,t){this._events||(this._events=new Array),this._events.push(new M0(e,t))}removeEvent(e){this._events&&(this._events=this._events.filter(t=>t.type!=e))}getEvents(){return this._events}}class ws{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}parse(e){let t=new go;return t.name="Id:"+e,t.count=0,t.boneData=[],t.boneMap=new Map,this.buildSkeleton(t,void 0,e),t}parseSkeletonAnimation(e,t){let a=new ko;a.clipName=t.name,a.useSkeletonPos=!1,a.useSkeletonScale=!1;for(let r of t.channels){let i=t.samplers[r.sampler];const n=this.subParser.parseAccessor(i.input),o=this.subParser.parseAccessor(i.output);let l=r.target.node,c=r.target.path,f=this.gltf.nodes[l];if(!f||!e.boneMap.has(f.name))continue;let h=e.boneMap.get(f.name);switch(c){case"scale":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.useSkeletonScale=!0,a.scaleCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new b().set(o.data[m+0],o.data[m+1],o.data[m+2]);D.split(z.vector3,_,"value"),u.addKeyFrame(D)}}break;case"rotation":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.rotationCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new Z().set(o.data[m+0],o.data[m+1],o.data[m+2],o.data[m+3]);D.split(z.quaternion,_,"value"),u.addKeyFrame(D)}}break;case"translation":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.useSkeletonPos=!0,a.positionCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new b().set(o.data[m+0],o.data[m+1],o.data[m+2]);D.split(z.vector3,_,"value"),u.addKeyFrame(D)}}break}}return a}parseSkeletonAnimationOld(e,t){let a=this.subParser.parseAccessor(t.samplers[0].input),r=a.data.length,i=a.data[1]-a.data[0];a.data[a.data.length-1];let n=12*e.numJoint,o=new Float32Array(n*r);for(var l=0;l<e.numJoint;l++)for(var c=0;c<r;c++){var f=n*c+12*l;o[f+0]=1,o[f+1]=1,o[f+2]=1,o[f+3]=1}for(let m of t.channels){let D=t.samplers[m.sampler];const _=this.subParser.parseAccessor(D.input),B=this.subParser.parseAccessor(D.output);let v=m.target.node,C=m.target.path,y=this.gltf.nodes[v];if(!y)continue;let F=e.getJointByName(y.name);if(F)switch(C){case"scale":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=1}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2]);for(var c=0;c<r;c++){let M=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,M);var f=n*c+12*F.index;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=1,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break;case"rotation":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index+4;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=B.data[h+3]}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2],B.data[u+3]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2],B.data[g+3]);for(var c=0;c<r;c++){let Q=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,Q);var f=n*c+12*F.index+4;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=b.HELP_2.w,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break;case"translation":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index+8;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=_.data[c*_.numComponents]}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2]);for(var c=0;c<r;c++){let Q=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,Q);var f=n*c+12*F.index+8;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=k,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break}}return new dn(t.name,e,r,o)}buildSkeleton(e,t,a){let r=this.gltf.nodes[a];r.name||(r.name="Bone"+e.count);let i=new bo;if(i.boneName=r.name,i.bonePath=t?t.bonePath+"/"+r.name:r.name,i.parentBoneName=t?t.boneName:"",i.boneID=e.count++,i.parentBoneID=t?t.boneID:-1,i.instanceID="",i.parentInstanceID="",i.s=new b(1,1,1),r.scale&&i.s.set(r.scale[0],r.scale[1],r.scale[2]),i.q=new Z,r.rotation&&i.q.set(r.rotation[0],r.rotation[1],r.rotation[2],r.rotation[3]),i.t=new b,r.translation&&i.t.set(r.translation[0],r.translation[1],r.translation[2]),e.boneData.push(i),e.boneMap.set(i.boneName,i),r.children)for(let n of r.children)this.buildSkeleton(e,i,n)}buildSkeletonOld(e,t,a,r=0){let i=this.gltf.nodes[a];i.name||(i.name="Node_"+a);let n=new T0(i.name);if(n.parent=t,i.scale&&n.scale.set(i.scale[0],i.scale[1],i.scale[2]),i.rotation&&n.rotation.set(i.rotation[0],i.rotation[1],i.rotation[2],i.rotation[3]),i.translation&&n.translation.set(i.translation[0],i.translation[1],i.translation[2]),e.addJoint(n),i.children)for(let o of i.children)this.buildSkeletonOld(e,n,o,r+1)}}class Is{static list=[];static add(e){this.list.indexOf(e)==-1&&this.list.push(e)}static remove(e){let t=this.list.indexOf(e);t!=-1&&this.list.splice(t,1)}}class yi extends Pe{name;size=1;lightData;dirFix=1;bindOnChange;needUpdateShadow=!0;realTimeShadow=!0;_castGI=!1;_castShadow=!1;_iesProfiles;constructor(){super()}init(){this.transform.object3D.bound=new ge(new b,new b),this.lightData=new tn,this.lightData.lightMatrixIndex=this.transform.worldMatrix.index}onChange(){this.bindOnChange&&this.bindOnChange(),this.transform.object3D.bound.setFromCenterAndSize(this.transform.worldPosition,new b(this.size,this.size,this.size)),this._castGI&&(W.instance.state.giLightingChange=!0),this._castShadow?(this.needUpdateShadow=!0,Et.addShadowLight(this)):Et.removeShadowLight(this),this.transform.view3D&&A.renderJobs&&A.renderJobs.get(this.transform.view3D).reflectionRenderer&&A.renderJobs.get(this.transform.view3D).reflectionRenderer.forceUpdate()}start(){this.transform.onPositionChange=()=>this.onPositionChange(),this.transform.onRotationChange=()=>this.onRotChange(),this.onPositionChange(),this.onRotChange()}onPositionChange(){this.lightData.lightPosition.copyFrom(this.transform.worldPosition),this.onChange()}onRotChange(){this.dirFix==1?this.lightData.direction.copyFrom(this.transform.forward):this.lightData.direction.copyFrom(this.transform.back),this.lightData.lightTangent.copyFrom(this.transform.up),this.onChange()}onScaleChange(){this.onChange()}onEnable(){this.onChange(),W.instance.addLight(this.transform.scene3D,this)}onDisable(){this.onChange(),W.instance.removeLight(this.transform.scene3D,this),Et.removeShadowLight(this)}set iesProfiles(e){this._iesProfiles=e,this.lightData.iesIndex=e.index,ra.use=!0,this.onChange()}get iesProfile(){return this._iesProfiles}get r(){return this.lightData.lightColor.r}set r(e){this.lightData.lightColor.r=e,this.onChange()}get g(){return this.lightData.lightColor.g}set g(e){this.lightData.lightColor.g=e,this.onChange()}get b(){return this.lightData.lightColor.b}set b(e){this.lightData.lightColor.b=e,this.onChange()}get lightColor(){return this.lightData.lightColor}set lightColor(e){this.lightData.lightColor=e,this.onChange()}get color(){return this.lightData.lightColor}set color(e){this.lightData.lightColor=e,this.onChange()}get intensity(){return this.lightData.intensity}set intensity(e){this.lightData.intensity=e,this.onChange()}set castShadow(e){e!=this._castShadow&&(this._castShadow=e,this.onChange())}get castShadow(){return this._castShadow}get shadowIndex(){return this.lightData.castShadowIndex}get castGI(){return this._castGI}set castGI(e){e?Is.add(this):Is.remove(this),this._castGI=e,e&&this.onChange()}get direction(){return this.lightData.direction}destroy(e){this.bindOnChange=null,W.instance.removeLight(this.transform.scene3D,this),Et.removeShadowLight(this),this.transform.eventDispatcher.removeEventListener(kt.ROTATION_ONCHANGE,this.onRotChange,this),this.transform.eventDispatcher.removeEventListener(kt.SCALE_ONCHANGE,this.onScaleChange,this),super.destroy(e)}}var U2=Object.getOwnPropertyDescriptor,v2=(s,e,t,a)=>{for(var r=a>1?void 0:a?U2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.DirectLight=class extends yi{shadowCamera;constructor(){super()}init(){super.init(),this.object3D.name==""&&(this.object3D.name="DirectionLight_"+xt()),this.radius=Number.MAX_SAFE_INTEGER,this.lightData.lightType=Ye.DirectionLight,this.lightData.linear=0,this.lightData.quadratic=.3}start(){super.start(),this.castGI=!0}get radius(){return this.lightData.range}set radius(e){this.lightData.range=e,this.onChange()}get indirect(){return this.lightData.quadratic}set indirect(e){this.lightData.quadratic=e,this.onChange()}debug(){}},d.DirectLight=v2([Mt(d.DirectLight,"DirectLight")],d.DirectLight);var y2=Object.getOwnPropertyDescriptor,C2=(s,e,t,a)=>{for(var r=a>1?void 0:a?y2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.PointLight=class extends yi{constructor(){super()}init(){super.init(),this.lightData.lightType=Ye.PointLight,this.object3D.name==""&&(this.object3D.name="PointLight"+xt())}get range(){return this.lightData.range}set range(e){this.lightData.range=e,this.onChange()}get at(){return this.lightData.linear}set at(e){this.lightData.linear=e,this.onChange()}get radius(){return this.lightData.radius}set radius(e){this.lightData.radius=e,this.onChange()}get quadratic(){return this.lightData.quadratic}set quadratic(e){this.lightData.quadratic=e,this.onChange()}start(){this.transform.rotationX=90,super.start()}onUpdate(){}onGraphic(e){}debug(){}debugDraw(e){}},d.PointLight=C2([Mt(d.PointLight,"PointLight")],d.PointLight);var S2=Object.getOwnPropertyDescriptor,x2=(s,e,t,a)=>{for(var r=a>1?void 0:a?S2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.SpotLight=class extends yi{constructor(){super()}init(){super.init(),this.lightData.lightType=Ye.SpotLight,this.object3D.name==""&&(this.object3D.name="SpotLight"+xt())}get innerAngle(){return this.lightData.innerAngle/this.lightData.outerAngle*100}set innerAngle(e){this.lightData.innerAngle=ie(e,0,100)/100*this.lightData.outerAngle,this.onChange()}get outerAngle(){return this.lightData.outerAngle*Wr*2}set outerAngle(e){this.lightData.outerAngle=ie(e,1,179)*at*.5,this.onChange()}get radius(){return this.lightData.radius}set radius(e){this.lightData.radius=e,this.onChange()}get range(){return this.lightData.range}set range(e){this.lightData.range=e,this.onChange()}get at(){return this.lightData.linear}set at(e){this.lightData.linear=e,this.onChange()}start(){super.start(),this.lightData.lightType=Ye.SpotLight}onUpdate(){}onGraphic(e){}debug(){}debugDraw(e){}},d.SpotLight=x2([Mt(d.SpotLight,"SpotLight")],d.SpotLight);class N0{static apply(e,t,a){let r=t.extensions;if(r&&r.KHR_materials_clearcoat){a.shader.getDefaultColorShader().setDefine("USE_CLEARCOAT",!0);let i=r.KHR_materials_clearcoat;"clearcoatFactor"in i&&(t.clearcoatFactor=i.clearcoatFactor,a.clearcoatFactor=t.clearcoatFactor),"clearcoatRoughnessFactor"in i&&(t.clearcoatRoughnessFactor=i.clearcoatRoughnessFactor,a.clearcoatRoughnessFactor=t.clearcoatRoughnessFactor)}}}class P0{static apply(e,t,a){let r=t.extensions;r&&r.KHR_materials_emissive_strength?(a.emissiveIntensity=r.KHR_materials_emissive_strength.emissiveStrength,a.emissiveMap==A.res.blackTexture&&(a.emissiveMap=A.res.whiteTexture)):a.emissiveIntensity=1}}class V0{static apply(e,t,a){let r=t.extensions;r&&r.KHR_materials_unlit?a.supportLight=!1:a.supportLight=!0}}class O0{gltf;subParser;_testCount=8;_hasCastShadow=!1;constructor(e){this.gltf=e.gltf,this.subParser=e}async convertNodeToObject3D(e,t){const a=new d.Object3D;if(a.name=e.name,a[Zt.GLTF_NODE_INDEX_PROPERTY]=e.nodeId,e.nodeObj=a,e.matrix&&(e.translation=[0,0,0],e.rotation=[0,0,0,1],e.scale=[1,1,1]),e.translation&&(a.transform.x=e.translation[0],a.transform.y=e.translation[1],a.transform.z=e.translation[2]),e.rotation){let r=new Z;r.setFromArray(e.rotation),a.transform.localRotQuat=r}return e.scale&&(a.transform.scaleX=e.scale[0],a.transform.scaleY=e.scale[1],a.transform.scaleZ=e.scale[2]),t.addChild(a),e.light&&this.convertLight(e,a),e.primitives&&this.convertprimitives(e,a),e.skeleton&&this.convertSkeletonAnim(a,e.skeleton),a}convertSkeletonAnim(e,t){let a=this.subParser.parseSkeleton(t.skeleton);A.res.addObj(a.name,a);let r=[];for(let n=0;n<this.gltf.animations.length;n++){let o=this.gltf.animations[n];o.name||(o.name=n.toString());let l=this.subParser.parseSkeletonAnimation(a,o);r.push(l)}let i=e.addComponent(d.AnimatorComponent);i.avatar=a.name,i.clips=r}convertLight(e,t){switch(e.light.type){case"directional":let a=t.addComponent(d.DirectLight);t.name=e.light.name,a.intensity=e.light.intensity*.1,a.radius=Number.MAX_SAFE_INTEGER,a.dirFix=-1,this._hasCastShadow||(this._hasCastShadow=!0,a.castShadow=this._hasCastShadow),a.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1),a.debug();break;case"point":if(this._testCount>0){let i=t.addComponent(d.PointLight);i.name=e.light.name,i.intensity=e.light.intensity?e.light.intensity*8*2:1,i.radius=8,i.at=2,i.range=e.light.range?e.light.range:8,i.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1)}this._testCount--;break;case"spot":let r=t.addComponent(d.SpotLight);r.name=e.light.name,r.intensity=e.light.intensity*5,r.radius=1,r.dirFix=-1,r.at=2,r.range=e.light.range?e.light.range:8,r.outerAngle=e.light.spot.outerConeAngle*Wr,r.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1);break}}convertprimitives(e,t){for(let a=0;a<e.primitives.length;a++){const r=e.primitives[a];r.modelName;let i=r.material;i.name==null&&(i.name=xt());let n,o=`matkey_${i.name}`;if(i&&this.gltf.resources[o])n=this.gltf.resources[o];else{let g=i;const p=g?.extensions?.KHR_materials_unlit!==void 0;let m=p?new st:new pa;if(n=m,this.gltf.resources[o]=m,m.name=i.name,g){const{baseColorTexture:D,baseColorFactor:_,metallicFactor:B,roughnessFactor:v,doubleSided:C,metallicRoughnessTexture:y,normalTexture:F,occlusionTexture:k,emissiveTexture:w,emissiveFactor:x,enableBlend:M,alphaCutoff:N}=g;let Q=m=this.applyMaterialExtensions(g,m);if(p){const G=Q;G.baseColor=new O(_[0],_[1],_[2],_[3]),D&&(G.baseMap=D),Q.doubleSide=C,"enableBlend"in g&&(g.enableBlend?(g.defines?.includes("ALPHA_BLEND")?Q.blendMode=te.ALPHA:Q.blendMode=te.NORMAL,Q.castShadow=!1):Q.blendMode=te.NONE),"alphaCutoff"in g&&N>0&&N<1&&(Q.setUniformFloat("alphaCutoff",N),Q.blendMode=te.NORMAL,Q.transparent=!0)}else if("enableBlend"in g&&(g.enableBlend?(g.defines?.includes("ALPHA_BLEND")?Q.blendMode=te.ALPHA:Q.blendMode=te.NORMAL,Q.castShadow=!1):Q.blendMode=te.NONE),"alphaCutoff"in g&&N>0&&N<1&&(Q.setUniformFloat("alphaCutoff",N),Q.blendMode=te.NORMAL,Q.transparent=!0),g.baseMapOffsetSize&&Q.setUniformVector4("baseMapOffsetSize",g.baseMapOffsetSize),g.normalMapOffsetSize&&Q.setUniformVector4("normalMapOffsetSize",g.normalMapOffsetSize),g.emissiveMapOffsetSize&&Q.setUniformVector4("emissiveMapOffsetSize",g.emissiveMapOffsetSize),g.roughnessMapOffsetSize&&Q.setUniformVector4("roughnessMapOffsetSize",g.roughnessMapOffsetSize),g.metallicMapOffsetSize&&Q.setUniformVector4("metallicMapOffsetSize",g.metallicMapOffsetSize),g.aoMapOffsetSize&&Q.setUniformVector4("aoMapOffsetSize",g.aoMapOffsetSize),Q.setUniformColor("baseColor",new O(_[0],_[1],_[2],_[3])),Q.setUniformFloat("roughness",v??1),Q.setUniformFloat("metallic",B??0),Q.setUniformFloat("ao",1),Q.doubleSide=C,D&&Q.setTexture("baseMap",D),F&&Q.setTexture("normalMap",F),y?(Q.setTexture("maskMap",y),Q.shader.setDefine("USE_ROUGHNESS_G",!0),Q.shader.setDefine("USE_METALLIC_B",!0)):(Q.shader.setDefine("USE_ROUGHNESS_G",!1),Q.shader.setDefine("USE_METALLIC_B",!1)),w&&Q.setTexture("emissiveMap",w),x&&(x[0]>0||x[1]>0||x[2]>0)){Q.shader.getTexture("emissiveMap")||Q.shader.setTexture("emissiveMap",A.res.whiteTexture),Q.shader.setDefine("USE_EMISSIVEMAP",!0),Q.setUniformColor("emissiveColor",new O(x[0],x[1],x[2],x[3])),Q.blendMode!=te.NONE&&(Q.blendMode=te.ADD);let G=n.getUniformFloat("emissiveIntensity");(!G||G<=0)&&n.setUniformFloat("emissiveIntensity",1)}}}const{attribArrays:l,modelName:c,drawMode:f}=r;let h;if(!l.indices.data){let g=[],p=l.position.data.length/3/3;for(let m=0;m<p;m++){let D=m*3;g.push(D+2),g.push(D+0),g.push(D+1)}l.indices={data:new Uint8Array(g),normalize:!1,numComponents:1}}let u=!l.normal;if(u){let g=[],p=l.position.data.length/3;for(let m=0;m<p;m++)g.push(0),g.push(0),g.push(0);l.normal={data:new Float32Array(g),normalize:!1,numComponents:3}}if(l.indices.data&&l.indices.data.length>3){let g=r.meshName();this.gltf.resources[g]&&(h=this.gltf.resources[g]);const p=new d.Object3D;if(p.name=c+a,this.gltf.animations&&l[V.joints0]!=null){h||=this.createGeometryBase(c,l,r,e.skin),this.gltf.resources[g]=h,u&&l.indices?.data&&l.indices.data.length>0&&h.computeNormals();let m=this.gltf.nodes[e.skin.skeleton];m.dnode&&m.dnode.nodeObj?this.convertSkeletonAnim(t,e.skin):m.dnode.skeleton=e.skin;let D=p.addComponent(d.SkinnedMeshRenderer2);D.geometry=h,D.material=n}else{h||=this.createGeometryBase(c,l,r),this.gltf.resources[g]=h,u&&l.indices?.data&&l.indices.data.length>0&&h.computeNormals(),h.hasAttribute(V.joints0)&&h.vertexAttributeMap.delete(V.joints0);let m=p.addComponent(d.MeshRenderer);m.castShadow=!0,m.castGI=!0,m.geometry=h,m.material=n}e.skin&&e.skin.defines,t.addChild(p)}}}createGeometryBase(e,t,a,r){"indices"in t&&(t.indices.data.length>65534?t.indices.data=new Uint32Array(t.indices.data):t.indices.data=new Uint16Array(t.indices.data));let i=new Fe;if(i.name=e,"indices"in t&&(t.indices.data.length>65535?t.indices.data=new Uint32Array(t.indices.data):t.indices.data=new Uint16Array(t.indices.data)),a.morphTargetsRelative){let l=new Ao,c=a.targetNames;if(c&&c.length>0){l.shapeNames=[],l.shapeIndexs=[];for(let f=0;f<c.length;f++)l.shapeNames.push(c[f]),l.shapeIndexs.push(f)}l.vertexCount=t.position.data.length/3,l.blendCount=l.shapeNames.length,l.blendShapePropertyDatas=[],l.blendShapeMap=new Map;for(let f=0;f<l.blendCount;f++){let h=new po;h.shapeName=l.shapeNames[f],h.shapeIndex=l.shapeIndexs[f],h.frameCount=1,h.blendPositionList=t[Zt.MORPH_POSITION_PREFIX+f].data,h.blendNormalList=t[Zt.MORPH_NORMAL_PREFIX+f].data,l.blendShapePropertyDatas.push(h),l.blendShapeMap.set(h.shapeName,h)}i.blendShapeData=l}i.morphTargetsRelative=a.morphTargetsRelative;let n=a.targetNames;if(n&&n.length>0){let l=i.morphTargetDictionary={};for(let c=0;c<n.length;c++)l[n[c]]=c}if(i.morphTargetDictionary){let l=t.position.data.length/3,c=new Float32Array(l);for(let f=0;f<l;f++)c[f]=f;t.vIndex={data:c,normalize:!1,numComponents:1}}for(const l in t){let c=t[l];i.setAttribute(l,c.data)}if(r){i.skinNames=new Array(r.joints.length);for(let l=0;l<r.joints.length;l++){const c=r.joints[l],f=this.gltf.nodes[c];i.skinNames[l]=f.name}i.bindPose=new Array(r.inverseBindMatrices.length);for(let l=0;l<r.inverseBindMatrices.length;l++){const c=r.inverseBindMatrices[l];let f=new R;f.rawData.set(c),i.bindPose[l]=f}}let o=i.getAttribute(V.indices);return i.addSubGeometry({indexStart:0,indexCount:o.data.length,vertexStart:0,index:0,vertexCount:0,firstStart:0,topology:0}),i}applyMaterialExtensions(e,t){return e.extensions&&(N0.apply(this.gltf,e,t),V0.apply(this.gltf,e,t),P0.apply(this.gltf,e,t)),t}parseSkinJoints(e){let t=[];for(let a of e.joints){let r=this.gltf.nodes[a];t.push(r.name)}return t}}class hn{currentSceneName;gltf;initUrl;_generator;_version;_BASE64_MARKER=";base64,";_cameraParser=null;_meshParser=null;_materialParser=null;_skinParser=null;_skeletonParser=null;_converter=null;constructor(){}get version(){return this.version?this.version:this.gltf?this.gltf.asset?(this._version=this.gltf.asset.version,this.gltf.asset.minVersion&&(this._version+=`\r minVersion${this.gltf.asset.minVersion}`),this.version):this.errorMiss("asset"):(console.warn("glTF not loaded."),null)}async parse(e,t,a){this.gltf=t,this.initUrl=e;const{version:r,generator:i}=this.gltf.asset;if(this._generator=i,r!=="2.0")return console.error(`GLTFParser only support glTF 2.0 for now! Received glTF version: ${this.version}`),!1;const n={nodes:await this.parseScene(a),animations:this.parseAnimations(),name:this.currentSceneName};return await this.convertToNode(n)}destroy(){Es.unload(this.gltf),this.gltf=null}async parseScene(e){const t=e||this.gltf.scene||0,a=this.gltf.scenes[t];if(typeof a>"u")return this.errorMiss("scene",t);this.currentSceneName=a.name||"GLTF_NO_NAME_SCENE";const r=[],i=a.nodes;for(let n=0;n<i.length;n++){const o=await this.parseNode(i[n]);o&&r.push(o)}return r}async parseNode(e){const t=this.gltf.nodes[e];if(!t)return this.errorMiss("node",e);if(t.isParsed)return t.dnode;const{name:a,matrix:r,translation:i,rotation:n,scale:o}=t,l={name:a,matrix:r,translation:i,rotation:n,scale:o,nodeId:e,camera:null,primitives:null,skin:null,children:null,light:null};if(t.camera!==void 0&&(l.camera=this.parseCamera(t.camera)),t.mesh!==void 0&&(l.primitives=await this.parseMesh(t.mesh)),t.extensions!==void 0&&this.applyNodeExtensions(t,l),t.skin!==void 0){const c=this.parseSkin(t.skin);c&&(l.skin=c)}if(l.children=[],t.children)for(let c=0;c<t.children.length;c++)l.children.push(await this.parseNode(t.children[c]));return t.dnode=l,t.isParsed=!0,t.dnode}errorMiss(e,t){throw new Error(e+t)}parseCamera(e){return this._cameraParser||(this._cameraParser=new R0(this.gltf)),this._cameraParser.parse(e)}async parseMesh(e){return this._meshParser||(this._meshParser=new w0(this)),this._meshParser.parse(e)}async parseTexture(e){let t=this.gltf.textures[e];if(t&&!t.dtexture){if(t&&t.source!=null){let a=this.gltf.images[t.source];if(a.uri){let r=a.uri;r=yt.getURLName(r),t.dtexture=this.gltf.resources[r]}else if(a.bufferView){let r=this.parseBufferView(a.bufferView),i=new La,n=new Blob([r],{type:a.mimeType});await i.loadFromBlob(n),t.dtexture=i}else t.dtexture=this.gltf.resources[a.name]}else if(t.name){let a=yt.getURLName(t.name);t.dtexture=this.gltf.resources[a]}}return t.dtexture||console.log("miss texture , please check texture!",e,t),t.dtexture}async parseMaterial(e){return this._materialParser||(this._materialParser=new I0(this)),this._materialParser.parse(e)}parseAnimations(){return[]}async parseObject3D(e,t){return this._converter||(this._converter=new O0(this)),this._converter.convertNodeToObject3D(e,t)}parseSkeleton(e){return this._skeletonParser||(this._skeletonParser=new ws(this)),this._skeletonParser.parse(e)}parseSkeletonAnimation(e,t){return this._skeletonParser||(this._skeletonParser=new ws(this)),this._skeletonParser.parseSkeletonAnimation(e,t)}async traverse(e,t){for(let a=0;a<t.length;a++){const r=await this.parseObject3D(t[a],e);await this.traverse(r,t[a].children)}}async convertToNode(e){const t=new d.Object3D;t.name=e.name;const a=e.nodes;e.animations;const r=[],i=[];return await this.traverse(t,a),{rootNode:t,textures:r,animations:void 0,cameras:i}}parseSkin(e){return this._skinParser||(this._skinParser=new Q0(this)),this._skinParser.parse(e)}parseAccessor(e){const t=this.gltf.accessors[e];if(!t)return this.errorMiss("accessor",e);if(t.isParsed)return t.daccessor;t.isParsed=!0,t.daccessor=!1;const a=!!t.normalized,r=this.gltf.bufferViews[t.bufferView],i=r&&r.byteStride,n=ks(t.componentType);let o=1;switch(t.type){case"SCALAR":o=1;break;case"VEC2":o=2;break;case"VEC3":o=3;break;case"VEC4":case"MAT2":o=4;break;case"MAT3":o=9;break;case"MAT4":o=16;break;default:o=0;break}if(o===0)return console.error(`glTF has unknown data type in accessor: ${t.type}`),!1;const l=o*n.BYTES_PER_ELEMENT;let c;if(r!==void 0){if(c=this.parseBufferView(t.bufferView),!c)return t.daccessor}else c=new Uint8Array(l*t.count).buffer;let f=this.getTypedArrayFromArrayBuffer(c,i,t.byteOffset||0,n,o,t.count);if(t.sparse){const{count:h,indices:u,values:g}=t.sparse;f=new n(f);const p=u.byteOffset||0,m=this.gltf.bufferViews[u.bufferView],D=ks(u.componentType),_=this.parseBufferView(u.bufferView),B=this.getTypedArrayFromArrayBuffer(_,m.byteStride,p,D,1,h),v=g.byteOffset||0,C=this.gltf.bufferViews[g.bufferView],y=this.parseBufferView(g.bufferView),F=this.getTypedArrayFromArrayBuffer(y,C.byteStride,v,n,o,h);for(let k=0;k<B.length;k++)f.set(F.slice(k*o,k*o+o),B[k]*o)}return t.computeResult={typedArray:f,arrayType:n,numComponents:o},t.daccessor={data:f,numComponents:o,normalize:a},t.daccessor}getTypedArrayFromArrayBuffer(e,t,a,r,i,n){let o;const l=i*r.BYTES_PER_ELEMENT;if(t&&l!==t){const c=i*n;o=new r(c);for(let f=0;f<n;f++){const h=new r(e,a+f*t,i);for(let u=0;u<i;u++)o[f*i+u]=h[u]}}else o=new r(e,a,n*i);return o}parseBufferView(e){const t=this.gltf.bufferViews[e];if(!t)return this.errorMiss("bufferView",e);if(t.isParsed)return t.dbufferView;t.isParsed=!0,t.dbufferView=!1;const a=this.parseBuffer(t.buffer);if(a){const{byteOffset:r,byteLength:i}=t,n=new Uint8Array(a,r||0,i);t.dbufferView=new Uint8Array(n).buffer}return t.dbufferView}parseBuffer(e){const t=this.gltf.buffers[e];if(!t)return this.errorMiss("buffer",e);if(t.isParsed)return t.dbuffer;if(t.isParsed=!0,t.dbuffer=!1,t.uri.substring(0,5)!=="data:"){const a=t.uri,r=this.gltf.resources[a];r?r.byteLength===t.byteLength?t.dbuffer=this.gltf.resources[a]:console.error(`load gltf resource "${a}" at buffers[${e} failed, ArrayBuffer.byteLength not equals buffer's byteLength]`):console.error(`load gltf resource "${a}" at buffers[${e}] failed`)}else{const a=t.uri.indexOf(this._BASE64_MARKER)+this._BASE64_MARKER.length,r=window.atob(t.uri.substring(a)),i=new Uint8Array(r.length);for(let n=0;n<r.length;n++)i[n]=r.charCodeAt(n);t.dbuffer=i.buffer}return t.dbuffer}getLight(e){return this.gltf.extensions.KHR_lights_punctual.lights[e]}applyNodeExtensions(e,t){let a=e.extensions;a.KHR_lights_punctual&&this.gltf.extensions.KHR_lights_punctual&&(t.light=this.getLight(a.KHR_lights_punctual.light))}}class L0{magic;version;length}class G0{chunkLength;chunkType;chunkData}class Qs extends nt{static format=Ge.BIN;_gltf;async parseBuffer(e){let t=new Uint8Array(e);t.pos=0;const a=this.parseHeader(t);if(a.magic!=1179937895)return console.error("invalid GLB file"),!1;if(a.version!==2)return console.error(`GLBParser only support glTF 2.0 for now! Received glTF version: ${a.version}`),!1;let r=[];for(;t.pos<t.length;){let h=this.parseChunk(t);r.push(h)}if(r[0].chunkType!=1313821514)return console.error("invalid GLBChunk"),!1;let i="",n=65535,o=r[0].chunkData;for(let h=0;h<o.length;h+=n){let u=o.length-h;u=Math.min(u,n);let g=o.subarray(h,h+u);i+=String.fromCharCode(...g)}let l=JSON.parse(i);this._gltf=new fn,this._gltf={...this._gltf,...l},this._gltf.resources={};for(let h=0;h<this._gltf.buffers.length;h++){let u=this._gltf.buffers[h];u.isParsed=!0,u.dbuffer=r[h+1].chunkData.buffer}if(this._gltf.images)for(let h=0;h<this._gltf.images.length;h++){let u=this._gltf.images[h];u.name=u.name||"bufferView_"+u.bufferView.toString();const g=this._gltf.bufferViews[u.bufferView],p=this._gltf.buffers[g.buffer];let m=new Uint8Array(p.dbuffer,g.byteOffset,g.byteLength),D=new Blob([m],{type:u.mimeType}),_=new La;await _.loadFromBlob(D),_.name=u.name,this._gltf.resources[u.name]=_}let f=await new hn().parse(this.initUrl,this._gltf,this._gltf.scene);return f?(this.data=f.rootNode,f.rootNode):null}async parseJsonAndBuffer(e,t){this._gltf=new fn,this._gltf={...this._gltf,...e},this._gltf.resources={};let a=this._gltf.buffers[0];if(a.isParsed=!0,a.dbuffer=t,this._gltf.images)for(let n=0;n<this._gltf.images.length;n++){let o=this._gltf.images[n];o.name=o.name||"bufferView_"+o.bufferView.toString();const l=this._gltf.bufferViews[o.bufferView],c=this._gltf.buffers[l.buffer];let f=new Uint8Array(c.dbuffer,l.byteOffset,l.byteLength),h=new Blob([f],{type:o.mimeType}),u=new La;await u.loadFromBlob(h),u.name=o.name,this._gltf.resources[o.name]=u}let i=await new hn().parse(this.initUrl,this._gltf,this._gltf.scene);return i?(this.data=i.rootNode,i.rootNode):null}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}parseHeader(e){let t=e.pos,a=new L0,r=new Uint32Array(e.buffer,t,3);return e.pos+=r.byteLength,a.magic=r[0],a.version=r[1],a.length=r[2],a}parseChunk(e){let t=e.pos,a=new G0,r=new Uint32Array(e.buffer,t,2);t=e.pos+=r.byteLength,a.chunkLength=r[0],a.chunkType=r[1],a.chunkData=new Uint8Array(e.buffer,t,a.chunkLength);const i=new Uint8Array(a.chunkLength);for(let n=0;n<a.chunkLength;n++)i[n]=a.chunkData[n];return a.chunkData=i,e.pos+=a.chunkLength,a}}class z0 extends it{constructor(){super();let e=new Ne("PBRLItShader","PBRLItShader");e.setShaderEntry("VertMain","FragMain"),e.passType=H.COLOR,this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformColor("baseColor",new O(.75,.75,.75,1)),this.setUniformColor("emissiveColor",new O(0,0,0)),this.setUniformVector4("materialF0",new $(.04,.04,.04,1)),this.setUniformColor("specularColor",new O(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",1),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new O(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this.setUniformFloat("clearcoatIor",1.5),this.setUniformVector4("baseMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("normalMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("emissiveMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("roughnessMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("metallicMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("aoMapOffsetSize",new $(0,0,1,1)),this.baseMap=A.res.whiteTexture,this.normalMap=A.res.normalTexture,this.maskMap=A.res.maskTexture}get baseMap(){return this.getDefaultColorShader().getTexture("baseMap")}set baseMap(e){this.getDefaultColorShader().setTexture("baseMap",e)}get baseColor(){return this.getDefaultColorShader().getUniform("baseColor")}set baseColor(e){this.getDefaultColorShader().setUniformColor("baseColor",e)}get normalMap(){return this.getDefaultColorShader().getTexture("normalMap")}set normalMap(e){this.getDefaultColorShader().setTexture("normalMap",e)}get doubleSide(){return this.getDefaultColorShader().doubleSide}set doubleSide(e){this.getDefaultColorShader().doubleSide=e}get alphaCutoff(){return this.getDefaultColorShader().shaderState.alphaCutoff}set alphaCutoff(e){this.getDefaultColorShader().setDefine("USE_ALPHACUT",!0),this.getDefaultColorShader().shaderState.alphaCutoff=e,this.getDefaultColorShader().setUniform("alphaCutoff",e)}get emissiveColor(){return this.getDefaultColorShader().getUniform("emissiveColor")}set emissiveColor(e){this.getDefaultColorShader().setUniform("emissiveColor",e)}get emissiveIntensity(){return this.getDefaultColorShader().getUniform("emissiveIntensity")}set emissiveIntensity(e){this.getDefaultColorShader().setUniform("emissiveIntensity",e)}get transformUV1(){return this.getDefaultColorShader().uniforms.transformUV1.vector4}set transformUV1(e){this.getDefaultColorShader().setUniform("transformUV1",e)}get uvTransform_2(){return this.getDefaultColorShader().uniforms.transformUV2.vector4}set uvTransform_2(e){this.getDefaultColorShader().setUniform("transformUV2",e)}get depthWriteEnabled(){return this.getDefaultColorShader().shaderState.depthWriteEnabled}set depthWriteEnabled(e){this.getDefaultColorShader().shaderState.depthWriteEnabled=e}get materialF0(){return this.getDefaultColorShader().uniforms.materialF0.vector4}set materialF0(e){this.getDefaultColorShader().setUniform("materialF0",e)}get specularColor(){return this.getDefaultColorShader().uniforms.specularColor.color}set specularColor(e){this.getDefaultColorShader().setUniform("specularColor",e)}get roughness(){return this.getDefaultColorShader().uniforms.roughness.value}set roughness(e){this.getDefaultColorShader().setUniform("roughness",e)}get metallic(){return this.getDefaultColorShader().uniforms.metallic.value}set metallic(e){this.getDefaultColorShader().setUniform("metallic",e)}get ao(){return this.getDefaultColorShader().uniforms.ao.value}set ao(e){this.getDefaultColorShader().setUniform("ao",e)}get metallic_min(){return this.getDefaultColorShader().uniforms.metallic_min.value}set metallic_min(e){this.getDefaultColorShader().setUniform("metallic_min",e)}get metallic_max(){return this.getDefaultColorShader().uniforms.metallic_max.value}set metallic_max(e){this.getDefaultColorShader().setUniform("metallic_max",e)}get roughness_min(){return this.getDefaultColorShader().uniforms.roughness_min.value}set roughness_min(e){this.getDefaultColorShader().setUniform("roughness_min",e)}get roughness_max(){return this.getDefaultColorShader().uniforms.roughness_max.value}set roughness_max(e){this.getDefaultColorShader().setUniform("roughness_max",e)}get normalScale(){return this.getDefaultColorShader().uniforms.normalScale.value}set normalScale(e){this.getDefaultColorShader().setUniform("normalScale",e)}get maskMap(){return this.getDefaultColorShader().textures.maskMap}set maskMap(e){this.getDefaultColorShader().setDefine("USE_MR",!0),this.getDefaultColorShader().setTexture("maskMap",e)}set aoMap(e){e&&(this.getDefaultColorShader().setTexture("aoMap",e),e!=A.res.whiteTexture&&this.getDefaultColorShader().setDefine("USE_AOTEX",!0))}get aoMap(){return this.getDefaultColorShader().textures.aoMap}set clearCoatRoughnessMap(e){e&&(console.log("USE_CLEARCOAT_ROUGHNESS"),this.getDefaultColorShader().setTexture("clearCoatRoughnessMap",e),this.getDefaultColorShader().setDefine("USE_CLEARCOAT_ROUGHNESS",!0))}get clearCoatRoughnessMap(){return this.getDefaultColorShader().textures.clearCoatRoughnessMap}get brdfLUT(){return this.getDefaultColorShader().textures.brdfLUT}set brdfLUT(e){this.getDefaultColorShader().setTexture("brdfLUT",e),this.getDefaultColorShader().setTexture("brdflutMap",e)}get emissiveMap(){return this.getDefaultColorShader().textures.emissiveMap}set emissiveMap(e){this.getDefaultColorShader().setTexture("emissiveMap",e)}set envIntensity(e){this.getDefaultColorShader().setUniformFloat("envIntensity",e)}get envIntensity(){return this.getDefaultColorShader().uniforms.envIntensity.value}set ior(e){this.getDefaultColorShader().setUniformFloat("ior",e)}get ior(){return this.getDefaultColorShader().uniforms.ior.value}useCleanCoat(){this.getDefaultColorShader().setDefine("USE_CLEARCOAT",!0)}set clearcoatFactor(e){this.getDefaultColorShader().setUniformFloat("clearcoatFactor",e),this.useCleanCoat()}get clearcoatFactor(){return this.getDefaultColorShader().uniforms.clearcoatFactor.value}set clearcoatRoughnessFactor(e){this.getDefaultColorShader().setUniformFloat("clearcoatRoughnessFactor",e),this.useCleanCoat()}get clearcoatRoughnessFactor(){return this.getDefaultColorShader().uniforms.clearcoatRoughnessFactor.value}set clearcoatWeight(e){this.getDefaultColorShader().setUniformFloat("clearcoatWeight",e),this.useCleanCoat()}get clearcoatWeight(){return this.getDefaultColorShader().uniforms.clearcoatWeight.value}set clearcoatColor(e){this.getDefaultColorShader().setUniformColor("clearcoatColor",e),this.useCleanCoat()}get clearcoatColor(){return this.getDefaultColorShader().uniforms.clearcoatColor.color}}class pa extends ut{constructor(){super();let e=new z0;this.shader=e}clone(){let e=new pa,t=e.shader.getDefaultColorShader(),a=this.shader.getDefaultColorShader();return t.defineValue={...a.defineValue},t.setUniform("shadowBias",a.getUniform("shadowBias")),t.setUniform("baseColor",a.getUniform("baseColor")),t.setUniform("specularColor",a.getUniform("specularColor")),t.setUniform("emissiveColor",a.getUniform("emissiveColor")),t.setUniform("materialF0",a.getUniform("materialF0")),t.setUniform("envIntensity",a.getUniform("envIntensity")),t.setUniform("normalScale",a.getUniform("normalScale")),t.setUniform("roughness",a.getUniform("roughness")),t.setUniform("metallic",a.getUniform("metallic")),t.setUniform("ao",a.getUniform("ao")),t.setUniform("roughness_min",a.getUniform("roughness_min")),t.setUniform("roughness_max",a.getUniform("roughness_max")),t.setUniform("metallic_min",a.getUniform("metallic_min")),t.setUniform("metallic_max",a.getUniform("metallic_max")),t.setUniform("emissiveIntensity",a.getUniform("emissiveIntensity")),t.setUniform("alphaCutoff",a.getUniform("alphaCutoff")),t.setUniform("ior",a.getUniform("ior")),t.setUniform("clearcoatFactor",a.getUniform("clearcoatFactor")),t.setUniform("clearcoatRoughnessFactor",a.getUniform("clearcoatRoughnessFactor")),t.setUniform("clearcoatColor",a.getUniform("clearcoatColor")),t.setUniform("clearcoatWeight",a.getUniform("clearcoatWeight")),t.setUniform("clearcoatIor",a.getUniform("clearcoatIor")),t.setTexture("baseMap",a.getTexture("baseMap")),t.setTexture("normalMap",a.getTexture("normalMap")),t.setTexture("emissiveMap",a.getTexture("emissiveMap")),t.setTexture("aoMap",a.getTexture("aoMap")),t.setTexture("maskMap",a.getTexture("maskMap")),t.setTexture("empty",a.getTexture("empty")),t.setUniform("baseMapOffsetSize",a.getUniform("baseMapOffsetSize")),t.setUniform("normalMapOffsetSize",a.getUniform("normalMapOffsetSize")),t.setUniform("emissiveMapOffsetSize",a.getUniform("emissiveMapOffsetSize")),t.setUniform("roughnessMapOffsetSize",a.getUniform("roughnessMapOffsetSize")),t.setUniform("metallicMapOffsetSize",a.getUniform("metallicMapOffsetSize")),t.setUniform("aoMapOffsetSize",a.getUniform("aoMapOffsetSize")),e}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set maskMap(e){this.shader.setTexture("maskMap",e)}get maskMap(){return this.shader.getTexture("maskMap")}set normalMap(e){this.shader.setTexture("normalMap",e)}get normalMap(){return this.shader.getTexture("normalMap")}set emissiveMap(e){this.shader.setTexture("emissiveMap",e)}get emissiveMap(){return this.shader.getTexture("emissiveMap")}set aoMap(e){this.shader.setTexture("aoMap",e)}get aoMap(){return this.shader.getTexture("aoMap")}set clearCoatRoughnessMap(e){this.shader.setTexture("clearCoatRoughnessMap",e),this.shader.setDefine("USE_CLEARCOAT",!0),this.shader.setDefine("USE_CLEARCOAT_ROUGHNESS",!0)}get clearCoatRoughnessMap(){return this.shader.getTexture("clearCoatRoughnessMap")}set clearcoatColor(e){this.shader.setUniformColor("clearcoatColor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatColor(){return this.shader.getUniformColor("clearcoatColor")}set clearcoatWeight(e){this.shader.setUniformFloat("clearcoatWeight",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatWeight(){return this.shader.getUniformFloat("clearcoatWeight")}set clearcoatFactor(e){this.shader.setUniformFloat("clearcoatFactor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatFactor(){return this.shader.getUniformFloat("clearcoatFactor")}set clearcoatRoughnessFactor(e){this.shader.setUniformFloat("clearcoatRoughnessFactor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatRoughnessFactor(){return this.shader.getUniformFloat("clearcoatRoughnessFactor")}set ior(e){this.shader.setUniformFloat("clearcoatIor",e)}get ior(){return this.shader.getUniformFloat("clearcoatIor")}set alphaCutoff(e){this.shader.setUniform("alphaCutoff",e)}get alphaCutoff(){return this.shader.getUniform("alphaCutoff")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}get roughness(){return this.shader.getUniformFloat("roughness")}set roughness(e){this.shader.setUniformFloat("roughness",e)}get metallic(){return this.shader.getUniformFloat("metallic")}set metallic(e){this.shader.setUniformFloat("metallic",e)}get emissiveColor(){return this.shader.getUniformColor("emissiveColor")}set emissiveColor(e){this.shader.setUniformColor("emissiveColor",e)}get emissiveIntensity(){return this.shader.getUniformFloat("emissiveIntensity")}set emissiveIntensity(e){this.shader.setUniformFloat("emissiveIntensity",e)}get ao(){return this.shader.getUniform("ao")}set ao(e){this.shader.setUniform("ao",e)}}class J0 extends nt{static format=Ge.TEXT;textData="";source_vertices;source_normals;source_tangents;source_textureCoords;matLibs;geometrys;activeGeo;currentObjectName;currentMaterialName;facesMaterialsIndex;mtl;mtlUrl;async parseString(e){return this.source_vertices=[],this.source_normals=[],this.source_tangents=[],this.source_textureCoords=[],this.currentObjectName="default",this.currentMaterialName="",this.matLibs={},this.geometrys={},this.activeGeo=void 0,this.textData=e,await Promise.all([this.parserOBJ(),this.loadMTL()]),this.parser_mesh(),"null"}applyVector2(e,t,a){e>=0&&t[e]&&t[e].length>0?(a.push(t[e][0]),a.push(-t[e][1])):(a.push(0),a.push(0))}applyVector3(e,t,a){e>=0&&t[e]&&t[e].length>0?(a.push(t[e][0]),a.push(t[e][1]),a.push(t[e][2])):(a.push(0),a.push(0),a.push(0))}applyVector4(e,t,a){a.push(t[e][0]),a.push(t[e][1]),a.push(t[e][2]),a.push(t[e][3])}parseUVIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}parseVertexIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}parseNormalIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}calculateFaceNormal(e,t,a){const r=[t[0]-e[0],t[1]-e[1],t[2]-e[2]],i=[a[0]-e[0],a[1]-e[1],a[2]-e[2]],n=[r[1]*i[2]-r[2]*i[1],r[2]*i[0]-r[0]*i[2],r[0]*i[1]-r[1]*i[0]],o=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);return o>0&&(n[0]/=o,n[1]/=o,n[2]/=o),n}async loadMTL(){let t=await new At().loadTxt(this.baseUrl+this.mtlUrl),a=t.data,r,i=a.split(/\r?\n/);for(let l=0;l<i.length;l++){let c=i[l];var n=c.indexOf("#");n!=-1&&(c=c.substring(0,n)),c=c.trim();var o=c.split(/\s+/);o[0]==="newmtl"?(r={name:o[1]},this.matLibs[o[1]]=r):o[0].indexOf("map_")!=-1?(r[o[0]]=o[1],r.textures||(r.textures=[o[o.length-1]]),r.textures.push(o[o.length-1])):o.length==2?r[o[0]]=Number(o[1]):o.length==3?r[o[0]]=[Number(o[1]),Number(o[2])]:o.length==4&&(r[o[0]]=[Number(o[1]),Number(o[2]),Number(o[3])])}for(const l in this.matLibs){const c=this.matLibs[l];if(c.textures&&c.textures.length>0)for(let f=0;f<c.textures.length;f++){const h=yt.normalizePath(this.baseUrl+c.textures[f]);await A.res.loadTexture(h)}}return t=null,!0}async load_textures(){}getGeometryKey(e,t){const a=(e??this.currentObjectName??"default")||"default",r=t??this.currentMaterialName??"",i=r.length>0?r:"default";return`${a}::${i}`}ensureActiveGeo(e,t){const a=(e??this.currentObjectName??"default")||"default",r=t??this.currentMaterialName??"",i=this.getGeometryKey(a,r);this.geometrys[i]?this.geometrys[i].source_mat!==r&&(this.geometrys[i].source_mat=r):this.geometrys[i]={type:a,name:i,source_mat:r,source_faces:[]},this.activeGeo=this.geometrys[i]}parserLine(e){var t=e.indexOf("#");if(t!=-1){if(e.indexOf("# object")!=-1){const p=e.split(/\s+/),m=p[1]||"default",D=p[2]||"default";this.currentObjectName=D,this.activeGeo=void 0,this.ensureActiveGeo(D,this.currentMaterialName),this.activeGeo&&(this.activeGeo.type=m)}e=e.substring(0,t)}e=e.trim();var a=e.split(/\s+/);if(a[0]==="v"){var r=[Number(a[1]),Number(a[2]),Number(a[3]),a[4]?1:Number(a[4])];this.source_vertices.push(r)}else if(a[0]==="vt"){var i=[Number(a[1]),Number(a[2]),a[3]?1:Number(a[3])];this.source_textureCoords.push(i)}else if(a[0]==="vn"){var n=[Number(a[1]),Number(a[2]),Number(a[3])];this.source_normals.push(n)}else if(a[0]==="f"){for(var o={indices:[],texture:[],normal:[]},l=1;l<a.length;++l){var c=a[l];if(c.length!==0){var f=c.split("/"),h=f[0]||"",u=f.length>=2&&f[1]||"",g=f.length>=3&&f[2]||"";h.length!==0&&(o.indices.push(h),o.texture.push(u),o.normal.push(g))}}this.ensureActiveGeo(),this.activeGeo.source_faces.push(o)}else a[0]==="usemtl"?(this.currentMaterialName=a[1]||"",this.ensureActiveGeo(this.currentObjectName,this.currentMaterialName)):a[0]==="mtllib"&&(this.mtlUrl=a[1])}async parserOBJ(){let e=this.textData.split(/\r?\n/);for(let t=0;t<e.length;t++){const a=e[t];this.parserLine(a)}return this.textData="",!0}async parser_mesh(){let e=new d.Object3D;for(const t in this.geometrys){const a=this.geometrys[t];a.vertex_arr=[],a.normal_arr=[],a.uv_arr=[],a.indeice_arr=[];let r=0;const i=this.source_vertices.length,n=this.source_normals.length,o=this.source_textureCoords.length;for(let p=0;p<a.source_faces.length;p++){const m=a.source_faces[p];let D=this.parseVertexIndex(m.indices[0],i),_=this.parseVertexIndex(m.indices[1],i),B=this.parseVertexIndex(m.indices[2],i);const v=G=>{if(!G||G.length===0)return-1;const X=this.parseNormalIndex(G,n);return Number.isFinite(X)&&X>=0&&X<n?X:-1},C=G=>{if(!G||G.length===0)return-1;const X=this.parseUVIndex(G,o);return Number.isFinite(X)&&X>=0&&X<o?X:-1};let y=v(m.normal[0]),F=v(m.normal[1]),k=v(m.normal[2]);const w=y<0||F<0||k<0;let x=null;w&&D>=0&&_>=0&&B>=0&&this.source_vertices[D]&&this.source_vertices[_]&&this.source_vertices[B]&&(x=this.calculateFaceNormal(this.source_vertices[D],this.source_vertices[_],this.source_vertices[B]));let M=C(m.texture[0]),N=C(m.texture[1]),Q=C(m.texture[2]);if(this.applyVector3(D,this.source_vertices,a.vertex_arr),y>=0?this.applyVector3(y,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),M>=0?this.applyVector2(M,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(_,this.source_vertices,a.vertex_arr),F>=0?this.applyVector3(F,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),N>=0?this.applyVector2(N,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(B,this.source_vertices,a.vertex_arr),k>=0?this.applyVector3(k,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),Q>=0?this.applyVector2(Q,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,m.indices.length>3){let G=this.parseVertexIndex(m.indices[3],i),X=v(m.normal[3]),ne=C(m.texture[3]),q=null;(y<0||k<0||X<0)&&D>=0&&B>=0&&G>=0&&this.source_vertices[D]&&this.source_vertices[B]&&this.source_vertices[G]&&(q=this.calculateFaceNormal(this.source_vertices[D],this.source_vertices[B],this.source_vertices[G])),this.applyVector3(D,this.source_vertices,a.vertex_arr),y>=0?this.applyVector3(y,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),M>=0?this.applyVector2(M,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(B,this.source_vertices,a.vertex_arr),k>=0?this.applyVector3(k,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),Q>=0?this.applyVector2(Q,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(G,this.source_vertices,a.vertex_arr),X>=0?this.applyVector3(X,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),ne>=0?this.applyVector2(ne,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++}}let l=new Fe;l.setIndices(new Uint32Array(a.indeice_arr)),l.setAttribute(V.position,new Float32Array(a.vertex_arr)),l.setAttribute(V.normal,new Float32Array(a.normal_arr)),l.setAttribute(V.uv,new Float32Array(a.uv_arr)),l.setAttribute(V.TEXCOORD_1,new Float32Array(a.uv_arr)),l.addSubGeometry({indexStart:0,indexCount:a.indeice_arr.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});let c=new pa;const f=a.source_mat,h=f?this.matLibs[f]:void 0;if(h&&h.map_Kd){const p=yt.normalizePath(this.baseUrl+h.map_Kd),m=A.res.getTexture(p);m&&(c.baseMap=m)}let u=new d.Object3D,g=u.addComponent(d.MeshRenderer);g.geometry=l,g.material=c,e.addChild(u)}this.data=e}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}}let W0=`
7275
+ `;class Es{static _workerCode;static _workers=new Map;static async apply(e,t){if(!t.extensions)return;const a=t.extensions.KHR_draco_mesh_compression;if(!a)return;let r=this._workers.get(e.gltf);r||(r=new Worker(await this.initDecoder()),this._workers.set(e.gltf,r)),r.postMessage({type:"init",decoderConfig:{}});let i=e.parseBufferView(a.bufferView);if(!i.result){let n=await new Promise((o,l)=>{r.onmessage=c=>{const f=c.data;f.type=="decode"?o(f.result):f.type=="error"&&l(f.error)},r.postMessage({type:"decoder",buffer:i,attributes:a.attributes},[i])});i.result=n}return i.result}static unload(e){let t=this._workers.get(e);t&&(t.terminate(),this._workers.delete(e))}static async initDecoder(){if(!this._workerCode){const e=new Blob([E0,"",`(${B2})()`],{type:"application/javascript"});this._workerCode=URL.createObjectURL(e)}return this._workerCode}}function B2(){let s,e;onmessage=t=>{const a=t.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise((n,o)=>{s.onModuleLoaded=l=>{n({draco:l})},DracoDecoderModule(s)});break;case"decoder":const r=a.buffer,i=a.attributes;e.then(n=>{const o=n.draco;let l=new o.Decoder,c=new o.DecoderBuffer;c.Init(new Int8Array(r),r.byteLength);let f,h;try{const u=l.GetEncodedGeometryType(c);u==o.TRIANGULAR_MESH?(h=new o.Mesh,f=l.DecodeBufferToMesh(c,h)):self.postMessage(new Error("INVALID_GEOMETRY_TYPE:"+u)),f.ok()||self.postMessage(new Error("DracoDecode:"+f.error_msg()));let g={};for(const p in i){let m=l.GetAttributeByUniqueId(h,i[p]);const D=m.num_components(),B=h.num_points()*D,v=B*Float32Array.BYTES_PER_ELEMENT,C=o.DT_FLOAT32,y=o._malloc(v);l.GetAttributeDataArrayForAllPoints(h,m,C,v,y);const F=new Float32Array(o.HEAPF32.buffer,y,B).slice();o._free(y),g[p]={data:F,numComponents:D,normalize:!1}}{const m=h.num_faces()*3,D=m*4,_=o._malloc(D);l.GetTrianglesUInt32Array(h,D,_);const B=new Uint32Array(o.HEAPF32.buffer,_,m).slice();o._free(_),g.indices={data:B,numComponents:1,normalize:!1}}self.postMessage({type:"decode",result:g})}catch(u){self.postMessage({type:"error",error:u.message})}finally{o.destroy(h),o.destroy(l),o.destroy(c)}});break}}}class R0{gltf;constructor(e){this.gltf=e}parse(e){const t=this.gltf.cameras[e];if(!t)return this.errorMiss("camera",e);if(t.isParsed)return t.dcamera;t.isParsed=!0,t.dcamera=!1;const{name:a,type:r,perspective:i,orthographic:n}=t;if(r==="perspective"&&i){const{aspectRatio:o,yfov:l,zfar:c,znear:f}=i;t.dcamera=Object.assign({},{name:a,type:r,yfov:l,znear:f,aspectRatio:o,zfar:c})}else if(r==="orthographic"&&n){const{xmag:o,ymag:l,zfar:c,znear:f}=n;t.dcamera=Object.assign({},{name:a,type:r,xmag:o,ymag:l,zfar:c,znear:f})}return t.dcamera}errorMiss(e,t){throw new Error(e+t)}}class Dt extends nt{static format=Ge.JSON;_gltf;async parseJson(e){this._gltf=new fn,this._gltf={...this._gltf,...e},this._gltf.resources={},await Promise.all([this.load_gltf_bin(),this.load_gltf_textures()]);let t=new hn,a=await t.parse(this.initUrl,this._gltf,this._gltf.scene);return t.destroy(),t=null,a?(this.data=a.rootNode,a.rootNode):(this._gltf=null,null)}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}static _counter=0;static getMeshNameCounter(){return function(){return`GLTF_NO_NAME_PRIMITIVE_${Dt._counter++}`}}static getModelNameCounter(){let e=0;return function(){return`GLTF_NO_NAME_MESH_${e++}`}}static getTexCoordDefine(e){return`UV_NUM ${e}`}static getVertexColorDefine(e){return`HAS_VERTEXCOLOR ${e}`}static getBaseColorTextureDefine(){return"HAS_BASECOLORMAP"}static getMetalRoughnessDefine(){return"HAS_METALROUGHNESSMAP"}static getNormalMapDefine(){return"HAS_NORMALMAP"}static getEmissiveMapDefine(){return"HAS_EMISSIVEMAP"}static getOcclusionMapDefine(){return"HAS_OCCLUSIONMAP"}static getMorphTargetsDefine(e){return`MORPH_TARGET_NUM ${e}`}static getMorphtargetPositionDefine(){return"HAS_MORPH_POSITION"}static getMorphtargetNormalDefine(){return"HAS_MORPH_NORMAL"}static getMorphtargetTangentDefine(){return"HAS_MORPH_TANGENT"}static getJointsNumDefine(e){return`JOINTS_NUM ${e}`}static getJointVec8Define(){return"JOINT_VEC8"}static getHasNormalDefine(){return"HAS_NORMAL"}static getHasTangentDefine(){return"HAS_TANGENT"}static getHasNormalMapDefine(){return"HAS_NORMAL_MAP"}static getAlphaMaskDefine(){return"ALPHA_MASK"}static getAlphaBlendDefine(){return"ALPHA_BLEND"}static defaultMaterial={name:"GLTF_DEFAULT_MATERIAL",alphaCutoff:.33,alphaMode:"MASK",pbrMetallicRoughness:{name:"GLTF_DEFAULT_MATERIAL",defines:[],doubleSided:!1,baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1,emissiveFactor:[0,0,0]}};async load_gltf_bin(){if(this._gltf.buffers&&this._gltf.buffers.length>0){let e=[];for(let t=0;t<this._gltf.buffers.length;t++){const a=this._gltf.buffers[t];if(a.uri.substring(0,5)!=="data:"){let r=yt.parseUrl(this.baseUrl,a.uri);this.loaderFunctions?.onUrl&&(r=await this.loaderFunctions.onUrl(r));let i=new At().loadBinData(r,this.loaderFunctions).then(n=>{this._gltf.resources[a.uri]=n});e.push(i)}}await Promise.all(e)}}async load_gltf_textures(){if(this._gltf,this._gltf.images){let e=[];for(let t=0;t<this._gltf.images.length;t++){const a=this._gltf.images[t];if(a.uri){let r=yt.parseUrl(this.baseUrl,a.uri);this.loaderFunctions?.onUrl&&(r=await this.loaderFunctions.onUrl(r));let i=new At().loadAsyncBitmapTexture(r,this.loaderFunctions).then(n=>{n.name=yt.getURLName(a.uri),this._gltf.resources[n.name]=n});e.push(i)}}await Promise.all(e)}}}class w0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}async parse(e){const t=this.gltf.meshes[e];if(!t)return this.errorMiss("mesh",e);if(t.isParsed)return t.dprimitives;const a=t.primitives,r=t.extras,i=[];for(let n=0;n<a.length;n++){const o=a[n],{attributes:l,indices:c,material:f,mode:h,name:u,targets:g,morphTargetsRelative:p,extensions:m}=o;let D=t.name;for(let k in l)D+=k;D+=`indices:${c}`,D+=`material:${f}`;const _={attribArrays:{indices:[]},weights:[],defines:[],material:null,drawMode:null,meshName:null,modelName:null,morphTargetsRelative:!1,targetNames:r?r.targetNames:null};let B=!1,v=0,C=!1,y;m&&m.KHR_draco_mesh_compression&&(y=await Es.apply(this.subParser,o));for(const k in l){const w=y?y[k]:this.parseAccessor(l[k]);if(w){let x;switch(k){case"POSITION":x=V.position;break;case"NORMAL":x=V.normal,B=!0;break;case"TEXCOORD_0":x=V.uv,v++;break;case"JOINTS_0":x=V.joints0;break;case"JOINTS_1":x=V.joints1,C=!0;break;case"WEIGHTS_0":x=V.weights0;break;case"WEIGHTS_1":x=V.weights1;break;default:x=k}_.attribArrays[x]=w}}if(B&&_.defines.push(Dt.getHasNormalDefine()),v&&_.defines.push(Dt.getTexCoordDefine(v)),C&&_.defines.push(Dt.getJointVec8Define()),c!==void 0){const k=y?y.indices:this.parseAccessor(c);k&&(_.attribArrays.indices=k)}const F=await this.parseMaterial(f);if(F&&(_.material=F,_.defines=_.defines.concat(F.defines)),_.drawMode=h===void 0?4:h,_.meshName=()=>D,_.modelName=t.name||Dt.getModelNameCounter(),g){_.defines.push(Dt.getMorphTargetsDefine(g.length)),_.morphTargetsRelative=!0;let k=!1,w=!1,x=!1;for(let M=0;M<g.length;M++){const N=g[M];Object.keys(N).forEach(Q=>{const G=this.parseAccessor(N[Q]);if(G){let X;switch(Q){case"POSITION":X=Zt.MORPH_POSITION_PREFIX+M,k=!0;break;case"NORMAL":X=Zt.MORPH_NORMAL_PREFIX+M,w=!0;break;case"TANGENT":X=Zt.MORPH_TANGENT_PREFIX+M,x=!0;break;default:X=!1}X?_.attribArrays[X]=G:console.error(`glTF has unsupported morph target attribute ${Q}`)}})}k&&_.defines.push(Dt.getMorphtargetPositionDefine()),w&&_.defines.push(Dt.getMorphtargetNormalDefine()),x&&_.defines.push(Dt.getMorphtargetTangentDefine()),_.weights=t.weights||new Array(g.length).fill(0)}i.push(_)}return t.dprimitives=i,t.isParsed=!0,t.dprimitives}parseAccessor(e){return this.subParser.parseAccessor(e)}parseMaterial(e){return this.subParser.parseMaterial(e)}errorMiss(e,t){throw new Error(e+t)}}class I0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}async parse(e){let t;if(e==null?t=Dt.defaultMaterial:t=this.gltf.materials[e],!t)return this.errorMiss("material",e);if(t.isParsed)return t.dmaterial;let{name:a,pbrMetallicRoughness:r,normalTexture:i,occlusionTexture:n,emissiveTexture:o,emissiveFactor:l,alphaMode:c,alphaCutoff:f,doubleSided:h,extensions:u}=t;const g={name:a,defines:[],doubleSided:!!h,baseColorFactor:[1,1,1,1],emissiveFactor:null,alphaCutoff:0,enableBlend:!1,baseColorTexture:null,metallicRoughnessTexture:null,normalTexture:null,occlusionTexture:null,emissiveTexture:null,extensions:null,baseMapOffsetSize:null,normalMapOffsetSize:null,emissiveMapOffsetSize:null,roughnessMapOffsetSize:null,metallicMapOffsetSize:null,aoMapOffsetSize:null,metallicFactor:0,roughnessFactor:1};if(r){const{baseColorFactor:p,metallicFactor:m,roughnessFactor:D,baseColorTexture:_,metallicRoughnessTexture:B}=r;if(Object.assign(g,{baseColorFactor:p||[1,1,1,1],metallicFactor:m===void 0?1:m,roughnessFactor:D===void 0?.5:D}),_){let v=_.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.baseMapOffsetSize=F}}const C=await this.parseTexture(_.index);C?g.baseColorTexture=C:g.baseColorTexture=A.res.redTexture}if(i){let v=i.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.normalMapOffsetSize=F}}const C=await this.parseTexture(i.index);C?g.normalTexture=C:g.normalTexture=A.res.normalTexture}if(B){let v=B.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.roughnessMapOffsetSize=F}}const C=await this.parseTexture(B.index);C?g.metallicRoughnessTexture=C:g.metallicRoughnessTexture=A.res.blackTexture}}else Object.assign(g,{baseColorFactor:[1,1,1,1],metallicFactor:0,roughnessFactor:.5});if(g.baseColorFactor&&g.baseColorFactor[3]<1&&(c=c==="MASK"?"MASK":"BLEND"),c&&c!=="OPAQUE"&&(c==="MASK"&&(g.defines.push(Dt.getAlphaMaskDefine()),g.alphaCutoff=f===void 0?.5:f),c==="BLEND"&&(g.defines.push(Dt.getAlphaBlendDefine()),g.enableBlend=!0)),i){const p=await this.parseTexture(i.index);p?g.normalTexture=p:g.normalTexture=A.res.normalTexture}if(n){const p=await this.parseTexture(n.index);p&&(g.occlusionTexture=p)}if(l&&(g.emissiveFactor=l),o){const p=await this.parseTexture(o.index);p?g.emissiveTexture=p:g.emissiveTexture=A.res.blackTexture}return u&&(g.extensions=u),t.isParsed=!0,t.dmaterial=g,g}async parseTexture(e){return this.subParser.parseTexture(e)}errorMiss(e,t){throw new Error(e+t)}}class Q0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}parse(e){const t=this.gltf.skins[e];if(!t)return this.errorMiss("skin",e);if(t.isParsed)return t.dskin;const{name:a,joints:r,inverseBindMatrices:i,skeleton:n}=t;if(!r)return this.errorMiss("skin.joints",e);t.isParsed=!0,t.dskin=!1;let o={name:a,skeleton:null,inverseBindMatrices:null,joints:r,defines:[Dt.getJointsNumDefine(r.length)]};if(n)o.skeleton=n;else{var l=-1;for(let c=0;c<this.gltf.nodes.length;c++)if(this.gltf.nodes[c].name=="root"){l=c;break}if(l==-1){let c=this.gltf.scenes[this.gltf.scene];l=c.nodes[c.nodes.length-1]}o.skeleton=l}if(o.inverseBindMatrices=Zt.IDENTITY_INVERSE_BIND_MATRICES,i!==void 0){const c=this.parseAccessor(i);if(c){const f=c.data,h=[];for(let u=0;u<f.length;u+=16)h.push(f.slice(u,u+16));o.inverseBindMatrices=h}else o=null}return t.dskin=o,t.dskin}parseAccessor(e){return this.subParser.parseAccessor(e)}errorMiss(e,t){throw new Error(e+t)}}class T0{name="";index=0;instanceID="";parent=null;scale=new b;rotation=new Z;translation=new b;constructor(e=""){this.name=e}}class Rs{index;worldMatrix;constructor(e,t=!1){this.index=e,this.worldMatrix=new R(!t)}}class vi{time;_skeleton;_jointsPose;mJointMatrixIndexTable;constructor(e,t=!1){this._skeleton=e,this._jointsPose=new Array(e.numJoint),this.mJointMatrixIndexTable=new Array(e.numJoint);for(let a=0;a<e.numJoint;a++){let r=new Rs(a,t);this._jointsPose[a]=r,this.mJointMatrixIndexTable[a]=r.worldMatrix.index}}buildSkeletonPose(e){let t=new b,a=new Z,r=new b,i=new Array(this._skeleton.numJoint);this.time=e[11]>0?e[11]:e[24];for(let n=0;n<this._skeleton.numJoint;n++){let o=12*n*4,l=new Float32Array(e.buffer,e.byteOffset+o,12),c=new R;t.set(l[0],l[1],l[2]),a.set(l[4],l[5],l[6],l[7]),r.set(l[8],l[9],l[10]),en(a.getEulerAngles(),r,t,c),i[n]=c;let f=new Rs(n);const h=this._skeleton.getJointParentIndex(n);if(h<0)f.worldMatrix.copyFrom(c);else{let u=this._jointsPose[h];tc(u.worldMatrix,c,f.worldMatrix)}this._jointsPose[n]=f}}get numJoint(){return this._skeleton.numJoint}get joints(){return this._jointsPose}get jointMatrixIndexTable(){return this.mJointMatrixIndexTable}lerp(e,t,a){if(e&&t)for(let r=0;r<this._jointsPose.length;r++){let i=e._jointsPose[r],n=t._jointsPose[r];this._jointsPose[r].worldMatrix.lerp(i.worldMatrix,n.worldMatrix,a)}else for(let r=0;r<this._jointsPose.length;r++){let i=e._jointsPose[r];this._jointsPose[r].worldMatrix.copyFrom(i.worldMatrix)}}copyFrom(e){for(let t=0;t<this._jointsPose.length;t++)this._jointsPose[t].worldMatrix.copyFrom(e._jointsPose[t].worldMatrix)}reset(){for(let e=0;e<this._jointsPose.length;e++)this._jointsPose[e].worldMatrix.identity()}}class M0 extends qe{skeletonAnimation;constructor(e,t){super(),this.type=e,this.time=t}}class dn{name="";_skeleton;_skeletonPoses;_animationClipData;_events;constructor(e,t,a,r){if(this.name=e,this._skeleton=t,this._animationClipData=r,a>0&&r){this._skeletonPoses=new Array(a);let i=12*t.numJoint;for(let n=0;n<a;n++){let o=i*n*4;const l=r.buffer instanceof ArrayBuffer?r.buffer:new Uint8Array(r.buffer).buffer;let c=new Float32Array(l,o,i),f=new vi(t);f.buildSkeletonPose(c),this._skeletonPoses[n]=f}}}get totalTime(){return this._skeletonPoses[this._skeletonPoses.length-1].time}get frameRate(){return this.totalTime/this._skeletonPoses.length}get skeleton(){return this._skeleton}get numFrame(){return this._skeletonPoses.length-1}get animationClipData(){return this._animationClipData}getSkeletonPose(e){return this._skeletonPoses[e]}getLerpSkeletonPose(e,t,a,r){let i=this.getSkeletonPose(e),n=this.getSkeletonPose(t);return r.lerp(i,n,a),r}createSubClip(e,t,a){var r=new dn(e,this._skeleton,0,null);const i=Math.max(Math.floor(t/this.frameRate),0),n=Math.min(Math.floor(a/this.frameRate),this._skeletonPoses.length-1);r._skeletonPoses=this._skeletonPoses.slice(i,n);const o=12*this._skeleton.numJoint*4,l=this._animationClipData.buffer instanceof ArrayBuffer?this._animationClipData.buffer:new Uint8Array(this._animationClipData.buffer).buffer;return this._animationClipData=new Float32Array(l,i*o,(n-i)*o),r}addEvent(e,t){this._events||(this._events=new Array),this._events.push(new M0(e,t))}removeEvent(e){this._events&&(this._events=this._events.filter(t=>t.type!=e))}getEvents(){return this._events}}class ws{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}parse(e){let t=new go;return t.name="Id:"+e,t.count=0,t.boneData=[],t.boneMap=new Map,this.buildSkeleton(t,void 0,e),t}parseSkeletonAnimation(e,t){let a=new ko;a.clipName=t.name,a.useSkeletonPos=!1,a.useSkeletonScale=!1;for(let r of t.channels){let i=t.samplers[r.sampler];const n=this.subParser.parseAccessor(i.input),o=this.subParser.parseAccessor(i.output);let l=r.target.node,c=r.target.path,f=this.gltf.nodes[l];if(!f||!e.boneMap.has(f.name))continue;let h=e.boneMap.get(f.name);switch(c){case"scale":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.useSkeletonScale=!0,a.scaleCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new b().set(o.data[m+0],o.data[m+1],o.data[m+2]);D.split(z.vector3,_,"value"),u.addKeyFrame(D)}}break;case"rotation":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.rotationCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new Z().set(o.data[m+0],o.data[m+1],o.data[m+2],o.data[m+3]);D.split(z.quaternion,_,"value"),u.addKeyFrame(D)}}break;case"translation":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.useSkeletonPos=!0,a.positionCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new b().set(o.data[m+0],o.data[m+1],o.data[m+2]);D.split(z.vector3,_,"value"),u.addKeyFrame(D)}}break}}return a}parseSkeletonAnimationOld(e,t){let a=this.subParser.parseAccessor(t.samplers[0].input),r=a.data.length,i=a.data[1]-a.data[0];a.data[a.data.length-1];let n=12*e.numJoint,o=new Float32Array(n*r);for(var l=0;l<e.numJoint;l++)for(var c=0;c<r;c++){var f=n*c+12*l;o[f+0]=1,o[f+1]=1,o[f+2]=1,o[f+3]=1}for(let m of t.channels){let D=t.samplers[m.sampler];const _=this.subParser.parseAccessor(D.input),B=this.subParser.parseAccessor(D.output);let v=m.target.node,C=m.target.path,y=this.gltf.nodes[v];if(!y)continue;let F=e.getJointByName(y.name);if(F)switch(C){case"scale":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=1}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2]);for(var c=0;c<r;c++){let M=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,M);var f=n*c+12*F.index;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=1,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break;case"rotation":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index+4;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=B.data[h+3]}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2],B.data[u+3]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2],B.data[g+3]);for(var c=0;c<r;c++){let Q=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,Q);var f=n*c+12*F.index+4;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=b.HELP_2.w,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break;case"translation":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index+8;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=_.data[c*_.numComponents]}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2]);for(var c=0;c<r;c++){let Q=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,Q);var f=n*c+12*F.index+8;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=k,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break}}return new dn(t.name,e,r,o)}buildSkeleton(e,t,a){let r=this.gltf.nodes[a];r.name||(r.name="Bone"+e.count);let i=new bo;if(i.boneName=r.name,i.bonePath=t?t.bonePath+"/"+r.name:r.name,i.parentBoneName=t?t.boneName:"",i.boneID=e.count++,i.parentBoneID=t?t.boneID:-1,i.instanceID="",i.parentInstanceID="",i.s=new b(1,1,1),r.scale&&i.s.set(r.scale[0],r.scale[1],r.scale[2]),i.q=new Z,r.rotation&&i.q.set(r.rotation[0],r.rotation[1],r.rotation[2],r.rotation[3]),i.t=new b,r.translation&&i.t.set(r.translation[0],r.translation[1],r.translation[2]),e.boneData.push(i),e.boneMap.set(i.boneName,i),r.children)for(let n of r.children)this.buildSkeleton(e,i,n)}buildSkeletonOld(e,t,a,r=0){let i=this.gltf.nodes[a];i.name||(i.name="Node_"+a);let n=new T0(i.name);if(n.parent=t,i.scale&&n.scale.set(i.scale[0],i.scale[1],i.scale[2]),i.rotation&&n.rotation.set(i.rotation[0],i.rotation[1],i.rotation[2],i.rotation[3]),i.translation&&n.translation.set(i.translation[0],i.translation[1],i.translation[2]),e.addJoint(n),i.children)for(let o of i.children)this.buildSkeletonOld(e,n,o,r+1)}}class Is{static list=[];static add(e){this.list.indexOf(e)==-1&&this.list.push(e)}static remove(e){let t=this.list.indexOf(e);t!=-1&&this.list.splice(t,1)}}class yi extends Pe{name;size=1;lightData;dirFix=1;bindOnChange;needUpdateShadow=!0;realTimeShadow=!0;_castGI=!1;_castShadow=!1;_iesProfiles;constructor(){super()}init(){this.transform.object3D.bound=new ge(new b,new b),this.lightData=new tn,this.lightData.lightMatrixIndex=this.transform.worldMatrix.index}onChange(){this.bindOnChange&&this.bindOnChange(),this.transform.object3D.bound.setFromCenterAndSize(this.transform.worldPosition,new b(this.size,this.size,this.size)),this._castGI&&(W.instance.state.giLightingChange=!0),this._castShadow?(this.needUpdateShadow=!0,Et.addShadowLight(this)):Et.removeShadowLight(this),this.transform.view3D&&A.renderJobs&&A.renderJobs.get(this.transform.view3D).reflectionRenderer&&A.renderJobs.get(this.transform.view3D).reflectionRenderer.forceUpdate()}start(){this.transform.onPositionChange=()=>this.onPositionChange(),this.transform.onRotationChange=()=>this.onRotChange(),this.onPositionChange(),this.onRotChange()}onPositionChange(){this.lightData.lightPosition.copyFrom(this.transform.worldPosition),this.onChange()}onRotChange(){this.dirFix==1?this.lightData.direction.copyFrom(this.transform.forward):this.lightData.direction.copyFrom(this.transform.back),this.lightData.lightTangent.copyFrom(this.transform.up),this.onChange()}onScaleChange(){this.onChange()}onEnable(){this.onChange(),W.instance.addLight(this.transform.scene3D,this)}onDisable(){this.onChange(),W.instance.removeLight(this.transform.scene3D,this),Et.removeShadowLight(this)}set iesProfiles(e){this._iesProfiles=e,this.lightData.iesIndex=e.index,ra.use=!0,this.onChange()}get iesProfile(){return this._iesProfiles}get r(){return this.lightData.lightColor.r}set r(e){this.lightData.lightColor.r=e,this.onChange()}get g(){return this.lightData.lightColor.g}set g(e){this.lightData.lightColor.g=e,this.onChange()}get b(){return this.lightData.lightColor.b}set b(e){this.lightData.lightColor.b=e,this.onChange()}get lightColor(){return this.lightData.lightColor}set lightColor(e){this.lightData.lightColor=e,this.onChange()}get color(){return this.lightData.lightColor}set color(e){this.lightData.lightColor=e,this.onChange()}get intensity(){return this.lightData.intensity}set intensity(e){this.lightData.intensity=e,this.onChange()}set castShadow(e){e!=this._castShadow&&(this._castShadow=e,this.onChange())}get castShadow(){return this._castShadow}get shadowIndex(){return this.lightData.castShadowIndex}get castGI(){return this._castGI}set castGI(e){e?Is.add(this):Is.remove(this),this._castGI=e,e&&this.onChange()}get direction(){return this.lightData.direction}destroy(e){this.bindOnChange=null,W.instance.removeLight(this.transform.scene3D,this),Et.removeShadowLight(this),this.transform.eventDispatcher.removeEventListener(kt.ROTATION_ONCHANGE,this.onRotChange,this),this.transform.eventDispatcher.removeEventListener(kt.SCALE_ONCHANGE,this.onScaleChange,this),super.destroy(e)}}var U2=Object.getOwnPropertyDescriptor,v2=(s,e,t,a)=>{for(var r=a>1?void 0:a?U2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.DirectLight=class extends yi{shadowCamera;constructor(){super()}init(){super.init(),this.object3D.name==""&&(this.object3D.name="DirectionLight_"+xt()),this.radius=Number.MAX_SAFE_INTEGER,this.lightData.lightType=Ye.DirectionLight,this.lightData.linear=0,this.lightData.quadratic=.3}start(){super.start(),this.castGI=!0}get radius(){return this.lightData.range}set radius(e){this.lightData.range=e,this.onChange()}get indirect(){return this.lightData.quadratic}set indirect(e){this.lightData.quadratic=e,this.onChange()}debug(){}},d.DirectLight=v2([Mt(d.DirectLight,"DirectLight")],d.DirectLight);var y2=Object.getOwnPropertyDescriptor,C2=(s,e,t,a)=>{for(var r=a>1?void 0:a?y2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.PointLight=class extends yi{constructor(){super()}init(){super.init(),this.lightData.lightType=Ye.PointLight,this.object3D.name==""&&(this.object3D.name="PointLight"+xt())}get range(){return this.lightData.range}set range(e){this.lightData.range=e,this.onChange()}get at(){return this.lightData.linear}set at(e){this.lightData.linear=e,this.onChange()}get radius(){return this.lightData.radius}set radius(e){this.lightData.radius=e,this.onChange()}get quadratic(){return this.lightData.quadratic}set quadratic(e){this.lightData.quadratic=e,this.onChange()}start(){this.transform.rotationX=90,super.start()}onUpdate(){}onGraphic(e){}debug(){}debugDraw(e){}},d.PointLight=C2([Mt(d.PointLight,"PointLight")],d.PointLight);var S2=Object.getOwnPropertyDescriptor,x2=(s,e,t,a)=>{for(var r=a>1?void 0:a?S2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.SpotLight=class extends yi{constructor(){super()}init(){super.init(),this.lightData.lightType=Ye.SpotLight,this.object3D.name==""&&(this.object3D.name="SpotLight"+xt())}get innerAngle(){return this.lightData.innerAngle/this.lightData.outerAngle*100}set innerAngle(e){this.lightData.innerAngle=ie(e,0,100)/100*this.lightData.outerAngle,this.onChange()}get outerAngle(){return this.lightData.outerAngle*Wr*2}set outerAngle(e){this.lightData.outerAngle=ie(e,1,179)*at*.5,this.onChange()}get radius(){return this.lightData.radius}set radius(e){this.lightData.radius=e,this.onChange()}get range(){return this.lightData.range}set range(e){this.lightData.range=e,this.onChange()}get at(){return this.lightData.linear}set at(e){this.lightData.linear=e,this.onChange()}start(){super.start(),this.lightData.lightType=Ye.SpotLight}onUpdate(){}onGraphic(e){}debug(){}debugDraw(e){}},d.SpotLight=x2([Mt(d.SpotLight,"SpotLight")],d.SpotLight);class N0{static apply(e,t,a){let r=t.extensions;if(r&&r.KHR_materials_clearcoat){a.shader.getDefaultColorShader().setDefine("USE_CLEARCOAT",!0);let i=r.KHR_materials_clearcoat;"clearcoatFactor"in i&&(t.clearcoatFactor=i.clearcoatFactor,a.clearcoatFactor=t.clearcoatFactor),"clearcoatRoughnessFactor"in i&&(t.clearcoatRoughnessFactor=i.clearcoatRoughnessFactor,a.clearcoatRoughnessFactor=t.clearcoatRoughnessFactor)}}}class P0{static apply(e,t,a){let r=t.extensions;r&&r.KHR_materials_emissive_strength?(a.emissiveIntensity=r.KHR_materials_emissive_strength.emissiveStrength,a.emissiveMap==A.res.blackTexture&&(a.emissiveMap=A.res.whiteTexture)):a.emissiveIntensity=1}}class V0{static apply(e,t,a){let r=t.extensions;r&&r.KHR_materials_unlit?a.supportLight=!1:a.supportLight=!0}}class O0{gltf;subParser;_testCount=8;_hasCastShadow=!1;constructor(e){this.gltf=e.gltf,this.subParser=e}async convertNodeToObject3D(e,t){const a=new d.Object3D;if(a.name=e.name,a[Zt.GLTF_NODE_INDEX_PROPERTY]=e.nodeId,e.nodeObj=a,e.matrix&&(e.translation=[0,0,0],e.rotation=[0,0,0,1],e.scale=[1,1,1]),e.translation&&(a.transform.x=e.translation[0],a.transform.y=e.translation[1],a.transform.z=e.translation[2]),e.rotation){let r=new Z;r.setFromArray(e.rotation),a.transform.localRotQuat=r}return e.scale&&(a.transform.scaleX=e.scale[0],a.transform.scaleY=e.scale[1],a.transform.scaleZ=e.scale[2]),t.addChild(a),e.light&&this.convertLight(e,a),e.primitives&&this.convertprimitives(e,a),e.skeleton&&this.convertSkeletonAnim(a,e.skeleton),a}convertSkeletonAnim(e,t){let a=this.subParser.parseSkeleton(t.skeleton);A.res.addObj(a.name,a);let r=[];for(let n=0;n<this.gltf.animations.length;n++){let o=this.gltf.animations[n];o.name||(o.name=n.toString());let l=this.subParser.parseSkeletonAnimation(a,o);r.push(l)}let i=e.addComponent(d.AnimatorComponent);i.avatar=a.name,i.clips=r}convertLight(e,t){switch(e.light.type){case"directional":let a=t.addComponent(d.DirectLight);t.name=e.light.name,a.intensity=e.light.intensity*.1,a.radius=Number.MAX_SAFE_INTEGER,a.dirFix=-1,this._hasCastShadow||(this._hasCastShadow=!0,a.castShadow=this._hasCastShadow),a.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1),a.debug();break;case"point":if(this._testCount>0){let i=t.addComponent(d.PointLight);i.name=e.light.name,i.intensity=e.light.intensity?e.light.intensity*8*2:1,i.radius=8,i.at=2,i.range=e.light.range?e.light.range:8,i.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1)}this._testCount--;break;case"spot":let r=t.addComponent(d.SpotLight);r.name=e.light.name,r.intensity=e.light.intensity*5,r.radius=1,r.dirFix=-1,r.at=2,r.range=e.light.range?e.light.range:8,r.outerAngle=e.light.spot.outerConeAngle*Wr,r.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1);break}}convertprimitives(e,t){for(let a=0;a<e.primitives.length;a++){const r=e.primitives[a];r.modelName;let i=r.material;i.name==null&&(i.name=xt());let n,o=`matkey_${i.name}`;if(i&&this.gltf.resources[o])n=this.gltf.resources[o];else{let g=i;const p=g?.extensions?.KHR_materials_unlit!==void 0;let m=p?new st:new pa;if(n=m,this.gltf.resources[o]=m,m.name=i.name,g){const{baseColorTexture:D,baseColorFactor:_,metallicFactor:B,roughnessFactor:v,doubleSided:C,metallicRoughnessTexture:y,normalTexture:F,occlusionTexture:k,emissiveTexture:w,emissiveFactor:x,enableBlend:M,alphaCutoff:N}=g;let Q=m=this.applyMaterialExtensions(g,m);if(p){const G=Q;G.baseColor=new O(_[0],_[1],_[2],_[3]),D&&(G.baseMap=D),Q.doubleSide=C,"enableBlend"in g&&(g.enableBlend?(g.defines?.includes("ALPHA_BLEND")?Q.blendMode=te.ALPHA:Q.blendMode=te.NORMAL,Q.castShadow=!1):Q.blendMode=te.NONE),"alphaCutoff"in g&&N>0&&N<1&&(Q.setUniformFloat("alphaCutoff",N),Q.blendMode=te.NORMAL,Q.transparent=!0)}else if("enableBlend"in g&&(g.enableBlend?(g.defines?.includes("ALPHA_BLEND")?Q.blendMode=te.ALPHA:Q.blendMode=te.NORMAL,Q.castShadow=!1):Q.blendMode=te.NONE),"alphaCutoff"in g&&N>0&&N<1&&(Q.setUniformFloat("alphaCutoff",N),Q.blendMode=te.NORMAL,Q.transparent=!0),g.baseMapOffsetSize&&Q.setUniformVector4("baseMapOffsetSize",g.baseMapOffsetSize),g.normalMapOffsetSize&&Q.setUniformVector4("normalMapOffsetSize",g.normalMapOffsetSize),g.emissiveMapOffsetSize&&Q.setUniformVector4("emissiveMapOffsetSize",g.emissiveMapOffsetSize),g.roughnessMapOffsetSize&&Q.setUniformVector4("roughnessMapOffsetSize",g.roughnessMapOffsetSize),g.metallicMapOffsetSize&&Q.setUniformVector4("metallicMapOffsetSize",g.metallicMapOffsetSize),g.aoMapOffsetSize&&Q.setUniformVector4("aoMapOffsetSize",g.aoMapOffsetSize),Q.setUniformColor("baseColor",new O(_[0],_[1],_[2],_[3])),Q.setUniformFloat("roughness",v??1),Q.setUniformFloat("metallic",B??0),Q.setUniformFloat("ao",1),Q.doubleSide=C,D&&Q.setTexture("baseMap",D),F&&Q.setTexture("normalMap",F),y?(Q.setTexture("maskMap",y),Q.shader.setDefine("USE_ROUGHNESS_G",!0),Q.shader.setDefine("USE_METALLIC_B",!0)):(Q.shader.setDefine("USE_ROUGHNESS_G",!1),Q.shader.setDefine("USE_METALLIC_B",!1)),w&&Q.setTexture("emissiveMap",w),x&&(x[0]>0||x[1]>0||x[2]>0)){Q.shader.getTexture("emissiveMap")||Q.shader.setTexture("emissiveMap",A.res.whiteTexture),Q.shader.setDefine("USE_EMISSIVEMAP",!0),Q.setUniformColor("emissiveColor",new O(x[0],x[1],x[2],x[3])),Q.blendMode!=te.NONE&&(Q.blendMode=te.ADD);let G=n.getUniformFloat("emissiveIntensity");(!G||G<=0)&&n.setUniformFloat("emissiveIntensity",1)}}}const{attribArrays:l,modelName:c,drawMode:f}=r;let h;if(!l.indices.data){let g=[],p=l.position.data.length/3/3;for(let m=0;m<p;m++){let D=m*3;g.push(D+2),g.push(D+0),g.push(D+1)}l.indices={data:new Uint8Array(g),normalize:!1,numComponents:1}}let u=!l.normal;if(u){let g=[],p=l.position.data.length/3;for(let m=0;m<p;m++)g.push(0),g.push(0),g.push(0);l.normal={data:new Float32Array(g),normalize:!1,numComponents:3}}if(l.indices.data&&l.indices.data.length>3){let g=r.meshName();this.gltf.resources[g]&&(h=this.gltf.resources[g]);const p=new d.Object3D;if(p.name=c+a,this.gltf.animations&&l[V.joints0]!=null){h||=this.createGeometryBase(c,l,r,e.skin),this.gltf.resources[g]=h,u&&l.indices?.data&&l.indices.data.length>0&&h.computeNormals();let m=this.gltf.nodes[e.skin.skeleton];m.dnode&&m.dnode.nodeObj?this.convertSkeletonAnim(t,e.skin):m.dnode.skeleton=e.skin;let D=p.addComponent(d.SkinnedMeshRenderer2);D.geometry=h,D.material=n}else{h||=this.createGeometryBase(c,l,r),this.gltf.resources[g]=h,u&&l.indices?.data&&l.indices.data.length>0&&h.computeNormals(),h.hasAttribute(V.joints0)&&h.vertexAttributeMap.delete(V.joints0);let m=p.addComponent(d.MeshRenderer);m.castShadow=!0,m.castGI=!0,m.geometry=h,m.material=n}e.skin&&e.skin.defines,t.addChild(p)}}}createGeometryBase(e,t,a,r){"indices"in t&&(t.indices.data.length>65534?t.indices.data=new Uint32Array(t.indices.data):t.indices.data=new Uint16Array(t.indices.data));let i=new Fe;if(i.name=e,"indices"in t&&(t.indices.data.length>65535?t.indices.data=new Uint32Array(t.indices.data):t.indices.data=new Uint16Array(t.indices.data)),a.morphTargetsRelative){let l=new Ao,c=a.targetNames;if(c&&c.length>0){l.shapeNames=[],l.shapeIndexs=[];for(let f=0;f<c.length;f++)l.shapeNames.push(c[f]),l.shapeIndexs.push(f)}l.vertexCount=t.position.data.length/3,l.blendCount=l.shapeNames.length,l.blendShapePropertyDatas=[],l.blendShapeMap=new Map;for(let f=0;f<l.blendCount;f++){let h=new po;h.shapeName=l.shapeNames[f],h.shapeIndex=l.shapeIndexs[f],h.frameCount=1,h.blendPositionList=t[Zt.MORPH_POSITION_PREFIX+f].data,h.blendNormalList=t[Zt.MORPH_NORMAL_PREFIX+f].data,l.blendShapePropertyDatas.push(h),l.blendShapeMap.set(h.shapeName,h)}i.blendShapeData=l}i.morphTargetsRelative=a.morphTargetsRelative;let n=a.targetNames;if(n&&n.length>0){let l=i.morphTargetDictionary={};for(let c=0;c<n.length;c++)l[n[c]]=c}if(i.morphTargetDictionary){let l=t.position.data.length/3,c=new Float32Array(l);for(let f=0;f<l;f++)c[f]=f;t.vIndex={data:c,normalize:!1,numComponents:1}}for(const l in t){let c=t[l];i.setAttribute(l,c.data)}if(r){i.skinNames=new Array(r.joints.length);for(let l=0;l<r.joints.length;l++){const c=r.joints[l],f=this.gltf.nodes[c];i.skinNames[l]=f.name}i.bindPose=new Array(r.inverseBindMatrices.length);for(let l=0;l<r.inverseBindMatrices.length;l++){const c=r.inverseBindMatrices[l];let f=new R;f.rawData.set(c),i.bindPose[l]=f}}let o=i.getAttribute(V.indices);return i.addSubGeometry({indexStart:0,indexCount:o.data.length,vertexStart:0,index:0,vertexCount:0,firstStart:0,topology:0}),i}applyMaterialExtensions(e,t){return e.extensions&&(N0.apply(this.gltf,e,t),V0.apply(this.gltf,e,t),P0.apply(this.gltf,e,t)),t}parseSkinJoints(e){let t=[];for(let a of e.joints){let r=this.gltf.nodes[a];t.push(r.name)}return t}}class hn{currentSceneName;gltf;initUrl;_generator;_version;_BASE64_MARKER=";base64,";_cameraParser=null;_meshParser=null;_materialParser=null;_skinParser=null;_skeletonParser=null;_converter=null;constructor(){}get version(){return this.version?this.version:this.gltf?this.gltf.asset?(this._version=this.gltf.asset.version,this.gltf.asset.minVersion&&(this._version+=`\r minVersion${this.gltf.asset.minVersion}`),this.version):this.errorMiss("asset"):(console.warn("glTF not loaded."),null)}async parse(e,t,a){this.gltf=t,this.initUrl=e;const{version:r,generator:i}=this.gltf.asset;if(this._generator=i,r!=="2.0")return console.error(`GLTFParser only support glTF 2.0 for now! Received glTF version: ${this.version}`),!1;const n={nodes:await this.parseScene(a),animations:this.parseAnimations(),name:this.currentSceneName};return await this.convertToNode(n)}destroy(){Es.unload(this.gltf),this.gltf=null}async parseScene(e){const t=e||this.gltf.scene||0,a=this.gltf.scenes[t];if(typeof a>"u")return this.errorMiss("scene",t);this.currentSceneName=a.name||"GLTF_NO_NAME_SCENE";const r=[],i=a.nodes;for(let n=0;n<i.length;n++){const o=await this.parseNode(i[n]);o&&r.push(o)}return r}async parseNode(e){const t=this.gltf.nodes[e];if(!t)return this.errorMiss("node",e);if(t.isParsed)return t.dnode;const{name:a,matrix:r,translation:i,rotation:n,scale:o}=t,l={name:a,matrix:r,translation:i,rotation:n,scale:o,nodeId:e,camera:null,primitives:null,skin:null,children:null,light:null};if(t.camera!==void 0&&(l.camera=this.parseCamera(t.camera)),t.mesh!==void 0&&(l.primitives=await this.parseMesh(t.mesh)),t.extensions!==void 0&&this.applyNodeExtensions(t,l),t.skin!==void 0){const c=this.parseSkin(t.skin);c&&(l.skin=c)}if(l.children=[],t.children)for(let c=0;c<t.children.length;c++)l.children.push(await this.parseNode(t.children[c]));return t.dnode=l,t.isParsed=!0,t.dnode}errorMiss(e,t){throw new Error(e+t)}parseCamera(e){return this._cameraParser||(this._cameraParser=new R0(this.gltf)),this._cameraParser.parse(e)}async parseMesh(e){return this._meshParser||(this._meshParser=new w0(this)),this._meshParser.parse(e)}async parseTexture(e){let t=this.gltf.textures[e];if(t&&!t.dtexture){if(t&&t.source!=null){let a=this.gltf.images[t.source];if(a.uri){let r=a.uri;r=yt.getURLName(r),t.dtexture=this.gltf.resources[r]}else if(a.bufferView){let r=this.parseBufferView(a.bufferView),i=new La,n=new Blob([r],{type:a.mimeType});await i.loadFromBlob(n),t.dtexture=i}else t.dtexture=this.gltf.resources[a.name]}else if(t.name){let a=yt.getURLName(t.name);t.dtexture=this.gltf.resources[a]}}return t.dtexture||console.log("miss texture , please check texture!",e,t),t.dtexture}async parseMaterial(e){return this._materialParser||(this._materialParser=new I0(this)),this._materialParser.parse(e)}parseAnimations(){return[]}async parseObject3D(e,t){return this._converter||(this._converter=new O0(this)),this._converter.convertNodeToObject3D(e,t)}parseSkeleton(e){return this._skeletonParser||(this._skeletonParser=new ws(this)),this._skeletonParser.parse(e)}parseSkeletonAnimation(e,t){return this._skeletonParser||(this._skeletonParser=new ws(this)),this._skeletonParser.parseSkeletonAnimation(e,t)}async traverse(e,t){for(let a=0;a<t.length;a++){const r=await this.parseObject3D(t[a],e);await this.traverse(r,t[a].children)}}async convertToNode(e){const t=new d.Object3D;t.name=e.name;const a=e.nodes;e.animations;const r=[],i=[];return await this.traverse(t,a),{rootNode:t,textures:r,animations:void 0,cameras:i}}parseSkin(e){return this._skinParser||(this._skinParser=new Q0(this)),this._skinParser.parse(e)}parseAccessor(e){const t=this.gltf.accessors[e];if(!t)return this.errorMiss("accessor",e);if(t.isParsed)return t.daccessor;t.isParsed=!0,t.daccessor=!1;const a=!!t.normalized,r=this.gltf.bufferViews[t.bufferView],i=r&&r.byteStride,n=ks(t.componentType);let o=1;switch(t.type){case"SCALAR":o=1;break;case"VEC2":o=2;break;case"VEC3":o=3;break;case"VEC4":case"MAT2":o=4;break;case"MAT3":o=9;break;case"MAT4":o=16;break;default:o=0;break}if(o===0)return console.error(`glTF has unknown data type in accessor: ${t.type}`),!1;const l=o*n.BYTES_PER_ELEMENT;let c;if(r!==void 0){if(c=this.parseBufferView(t.bufferView),!c)return t.daccessor}else c=new Uint8Array(l*t.count).buffer;let f=this.getTypedArrayFromArrayBuffer(c,i,t.byteOffset||0,n,o,t.count);if(t.sparse){const{count:h,indices:u,values:g}=t.sparse;f=new n(f);const p=u.byteOffset||0,m=this.gltf.bufferViews[u.bufferView],D=ks(u.componentType),_=this.parseBufferView(u.bufferView),B=this.getTypedArrayFromArrayBuffer(_,m.byteStride,p,D,1,h),v=g.byteOffset||0,C=this.gltf.bufferViews[g.bufferView],y=this.parseBufferView(g.bufferView),F=this.getTypedArrayFromArrayBuffer(y,C.byteStride,v,n,o,h);for(let k=0;k<B.length;k++)f.set(F.slice(k*o,k*o+o),B[k]*o)}return t.computeResult={typedArray:f,arrayType:n,numComponents:o},t.daccessor={data:f,numComponents:o,normalize:a},t.daccessor}getTypedArrayFromArrayBuffer(e,t,a,r,i,n){let o;const l=i*r.BYTES_PER_ELEMENT;if(t&&l!==t){const c=i*n;o=new r(c);for(let f=0;f<n;f++){const h=new r(e,a+f*t,i);for(let u=0;u<i;u++)o[f*i+u]=h[u]}}else o=new r(e,a,n*i);return o}parseBufferView(e){const t=this.gltf.bufferViews[e];if(!t)return this.errorMiss("bufferView",e);if(t.isParsed)return t.dbufferView;t.isParsed=!0,t.dbufferView=!1;const a=this.parseBuffer(t.buffer);if(a){const{byteOffset:r,byteLength:i}=t,n=new Uint8Array(a,r||0,i);t.dbufferView=new Uint8Array(n).buffer}return t.dbufferView}parseBuffer(e){const t=this.gltf.buffers[e];if(!t)return this.errorMiss("buffer",e);if(t.isParsed)return t.dbuffer;if(t.isParsed=!0,t.dbuffer=!1,t.uri.substring(0,5)!=="data:"){const a=t.uri,r=this.gltf.resources[a];r?r.byteLength===t.byteLength?t.dbuffer=this.gltf.resources[a]:console.error(`load gltf resource "${a}" at buffers[${e} failed, ArrayBuffer.byteLength not equals buffer's byteLength]`):console.error(`load gltf resource "${a}" at buffers[${e}] failed`)}else{const a=t.uri.indexOf(this._BASE64_MARKER)+this._BASE64_MARKER.length,r=window.atob(t.uri.substring(a)),i=new Uint8Array(r.length);for(let n=0;n<r.length;n++)i[n]=r.charCodeAt(n);t.dbuffer=i.buffer}return t.dbuffer}getLight(e){return this.gltf.extensions.KHR_lights_punctual.lights[e]}applyNodeExtensions(e,t){let a=e.extensions;a.KHR_lights_punctual&&this.gltf.extensions.KHR_lights_punctual&&(t.light=this.getLight(a.KHR_lights_punctual.light))}}class L0{magic;version;length}class G0{chunkLength;chunkType;chunkData}class Qs extends nt{static format=Ge.BIN;_gltf;async parseBuffer(e){let t=new Uint8Array(e);t.pos=0;const a=this.parseHeader(t);if(a.magic!=1179937895)return console.error("invalid GLB file"),!1;if(a.version!==2)return console.error(`GLBParser only support glTF 2.0 for now! Received glTF version: ${a.version}`),!1;let r=[];for(;t.pos<t.length;){let h=this.parseChunk(t);r.push(h)}if(r[0].chunkType!=1313821514)return console.error("invalid GLBChunk"),!1;let i="",n=65535,o=r[0].chunkData;for(let h=0;h<o.length;h+=n){let u=o.length-h;u=Math.min(u,n);let g=o.subarray(h,h+u);i+=String.fromCharCode(...g)}let l=JSON.parse(i);this._gltf=new fn,this._gltf={...this._gltf,...l},this._gltf.resources={};for(let h=0;h<this._gltf.buffers.length;h++){let u=this._gltf.buffers[h];u.isParsed=!0,u.dbuffer=r[h+1].chunkData.buffer}if(this._gltf.images)for(let h=0;h<this._gltf.images.length;h++){let u=this._gltf.images[h];u.name=u.name||"bufferView_"+u.bufferView.toString();const g=this._gltf.bufferViews[u.bufferView],p=this._gltf.buffers[g.buffer];let m=new Uint8Array(p.dbuffer,g.byteOffset,g.byteLength),D=new Blob([m],{type:u.mimeType}),_=new La;await _.loadFromBlob(D),_.name=u.name,this._gltf.resources[u.name]=_}let f=await new hn().parse(this.initUrl,this._gltf,this._gltf.scene);return f?(this.data=f.rootNode,f.rootNode):null}async parseJsonAndBuffer(e,t){this._gltf=new fn,this._gltf={...this._gltf,...e},this._gltf.resources={};let a=this._gltf.buffers[0];if(a.isParsed=!0,a.dbuffer=t,this._gltf.images)for(let n=0;n<this._gltf.images.length;n++){let o=this._gltf.images[n];o.name=o.name||"bufferView_"+o.bufferView.toString();const l=this._gltf.bufferViews[o.bufferView],c=this._gltf.buffers[l.buffer];let f=new Uint8Array(c.dbuffer,l.byteOffset,l.byteLength),h=new Blob([f],{type:o.mimeType}),u=new La;await u.loadFromBlob(h),u.name=o.name,this._gltf.resources[o.name]=u}let i=await new hn().parse(this.initUrl,this._gltf,this._gltf.scene);return i?(this.data=i.rootNode,i.rootNode):null}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}parseHeader(e){let t=e.pos,a=new L0,r=new Uint32Array(e.buffer,t,3);return e.pos+=r.byteLength,a.magic=r[0],a.version=r[1],a.length=r[2],a}parseChunk(e){let t=e.pos,a=new G0,r=new Uint32Array(e.buffer,t,2);t=e.pos+=r.byteLength,a.chunkLength=r[0],a.chunkType=r[1],a.chunkData=new Uint8Array(e.buffer,t,a.chunkLength);const i=new Uint8Array(a.chunkLength);for(let n=0;n<a.chunkLength;n++)i[n]=a.chunkData[n];return a.chunkData=i,e.pos+=a.chunkLength,a}}class z0 extends it{constructor(){super();let e=new Ne("PBRLItShader","PBRLItShader");e.setShaderEntry("VertMain","FragMain"),e.passType=H.COLOR,this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformColor("baseColor",new O(.75,.75,.75,1)),this.setUniformColor("emissiveColor",new O(0,0,0)),this.setUniformVector4("materialF0",new $(.04,.04,.04,1)),this.setUniformColor("specularColor",new O(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",1),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new O(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this.setUniformFloat("clearcoatIor",1.5),this.setUniformVector4("baseMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("normalMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("emissiveMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("roughnessMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("metallicMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("aoMapOffsetSize",new $(0,0,1,1)),this.baseMap=A.res.whiteTexture,this.normalMap=A.res.normalTexture,this.maskMap=A.res.maskTexture}get baseMap(){return this.getDefaultColorShader().getTexture("baseMap")}set baseMap(e){this.getDefaultColorShader().setTexture("baseMap",e)}get baseColor(){return this.getDefaultColorShader().getUniform("baseColor")}set baseColor(e){this.getDefaultColorShader().setUniformColor("baseColor",e)}get normalMap(){return this.getDefaultColorShader().getTexture("normalMap")}set normalMap(e){this.getDefaultColorShader().setTexture("normalMap",e)}get doubleSide(){return this.getDefaultColorShader().doubleSide}set doubleSide(e){this.getDefaultColorShader().doubleSide=e}get alphaCutoff(){return this.getDefaultColorShader().shaderState.alphaCutoff}set alphaCutoff(e){this.getDefaultColorShader().setDefine("USE_ALPHACUT",!0),this.getDefaultColorShader().shaderState.alphaCutoff=e,this.getDefaultColorShader().setUniform("alphaCutoff",e)}get emissiveColor(){return this.getDefaultColorShader().getUniform("emissiveColor")}set emissiveColor(e){this.getDefaultColorShader().setUniform("emissiveColor",e)}get emissiveIntensity(){return this.getDefaultColorShader().getUniform("emissiveIntensity")}set emissiveIntensity(e){this.getDefaultColorShader().setUniform("emissiveIntensity",e)}get transformUV1(){return this.getDefaultColorShader().uniforms.transformUV1.vector4}set transformUV1(e){this.getDefaultColorShader().setUniform("transformUV1",e)}get uvTransform_2(){return this.getDefaultColorShader().uniforms.transformUV2.vector4}set uvTransform_2(e){this.getDefaultColorShader().setUniform("transformUV2",e)}get depthWriteEnabled(){return this.getDefaultColorShader().shaderState.depthWriteEnabled}set depthWriteEnabled(e){this.getDefaultColorShader().shaderState.depthWriteEnabled=e}get materialF0(){return this.getDefaultColorShader().uniforms.materialF0.vector4}set materialF0(e){this.getDefaultColorShader().setUniform("materialF0",e)}get specularColor(){return this.getDefaultColorShader().uniforms.specularColor.color}set specularColor(e){this.getDefaultColorShader().setUniform("specularColor",e)}get roughness(){return this.getDefaultColorShader().uniforms.roughness.value}set roughness(e){this.getDefaultColorShader().setUniform("roughness",e)}get metallic(){return this.getDefaultColorShader().uniforms.metallic.value}set metallic(e){this.getDefaultColorShader().setUniform("metallic",e)}get ao(){return this.getDefaultColorShader().uniforms.ao.value}set ao(e){this.getDefaultColorShader().setUniform("ao",e)}get metallic_min(){return this.getDefaultColorShader().uniforms.metallic_min.value}set metallic_min(e){this.getDefaultColorShader().setUniform("metallic_min",e)}get metallic_max(){return this.getDefaultColorShader().uniforms.metallic_max.value}set metallic_max(e){this.getDefaultColorShader().setUniform("metallic_max",e)}get roughness_min(){return this.getDefaultColorShader().uniforms.roughness_min.value}set roughness_min(e){this.getDefaultColorShader().setUniform("roughness_min",e)}get roughness_max(){return this.getDefaultColorShader().uniforms.roughness_max.value}set roughness_max(e){this.getDefaultColorShader().setUniform("roughness_max",e)}get normalScale(){return this.getDefaultColorShader().uniforms.normalScale.value}set normalScale(e){this.getDefaultColorShader().setUniform("normalScale",e)}get maskMap(){return this.getDefaultColorShader().textures.maskMap}set maskMap(e){this.getDefaultColorShader().setDefine("USE_MR",!0),this.getDefaultColorShader().setTexture("maskMap",e)}set aoMap(e){e&&(this.getDefaultColorShader().setTexture("aoMap",e),e!=A.res.whiteTexture&&this.getDefaultColorShader().setDefine("USE_AOTEX",!0))}get aoMap(){return this.getDefaultColorShader().textures.aoMap}set clearCoatRoughnessMap(e){e&&(console.log("USE_CLEARCOAT_ROUGHNESS"),this.getDefaultColorShader().setTexture("clearCoatRoughnessMap",e),this.getDefaultColorShader().setDefine("USE_CLEARCOAT_ROUGHNESS",!0))}get clearCoatRoughnessMap(){return this.getDefaultColorShader().textures.clearCoatRoughnessMap}get brdfLUT(){return this.getDefaultColorShader().textures.brdfLUT}set brdfLUT(e){this.getDefaultColorShader().setTexture("brdfLUT",e),this.getDefaultColorShader().setTexture("brdflutMap",e)}get emissiveMap(){return this.getDefaultColorShader().textures.emissiveMap}set emissiveMap(e){this.getDefaultColorShader().setTexture("emissiveMap",e)}set envIntensity(e){this.getDefaultColorShader().setUniformFloat("envIntensity",e)}get envIntensity(){return this.getDefaultColorShader().uniforms.envIntensity.value}set ior(e){this.getDefaultColorShader().setUniformFloat("ior",e)}get ior(){return this.getDefaultColorShader().uniforms.ior.value}useCleanCoat(){this.getDefaultColorShader().setDefine("USE_CLEARCOAT",!0)}set clearcoatFactor(e){this.getDefaultColorShader().setUniformFloat("clearcoatFactor",e),this.useCleanCoat()}get clearcoatFactor(){return this.getDefaultColorShader().uniforms.clearcoatFactor.value}set clearcoatRoughnessFactor(e){this.getDefaultColorShader().setUniformFloat("clearcoatRoughnessFactor",e),this.useCleanCoat()}get clearcoatRoughnessFactor(){return this.getDefaultColorShader().uniforms.clearcoatRoughnessFactor.value}set clearcoatWeight(e){this.getDefaultColorShader().setUniformFloat("clearcoatWeight",e),this.useCleanCoat()}get clearcoatWeight(){return this.getDefaultColorShader().uniforms.clearcoatWeight.value}set clearcoatColor(e){this.getDefaultColorShader().setUniformColor("clearcoatColor",e),this.useCleanCoat()}get clearcoatColor(){return this.getDefaultColorShader().uniforms.clearcoatColor.color}}class pa extends ut{constructor(){super();let e=new z0;this.shader=e}clone(){let e=new pa,t=e.shader.getDefaultColorShader(),a=this.shader.getDefaultColorShader();return t.defineValue={...a.defineValue},t.setUniform("shadowBias",a.getUniform("shadowBias")),t.setUniform("baseColor",a.getUniform("baseColor")),t.setUniform("specularColor",a.getUniform("specularColor")),t.setUniform("emissiveColor",a.getUniform("emissiveColor")),t.setUniform("materialF0",a.getUniform("materialF0")),t.setUniform("envIntensity",a.getUniform("envIntensity")),t.setUniform("normalScale",a.getUniform("normalScale")),t.setUniform("roughness",a.getUniform("roughness")),t.setUniform("metallic",a.getUniform("metallic")),t.setUniform("ao",a.getUniform("ao")),t.setUniform("roughness_min",a.getUniform("roughness_min")),t.setUniform("roughness_max",a.getUniform("roughness_max")),t.setUniform("metallic_min",a.getUniform("metallic_min")),t.setUniform("metallic_max",a.getUniform("metallic_max")),t.setUniform("emissiveIntensity",a.getUniform("emissiveIntensity")),t.setUniform("alphaCutoff",a.getUniform("alphaCutoff")),t.setUniform("ior",a.getUniform("ior")),t.setUniform("clearcoatFactor",a.getUniform("clearcoatFactor")),t.setUniform("clearcoatRoughnessFactor",a.getUniform("clearcoatRoughnessFactor")),t.setUniform("clearcoatColor",a.getUniform("clearcoatColor")),t.setUniform("clearcoatWeight",a.getUniform("clearcoatWeight")),t.setUniform("clearcoatIor",a.getUniform("clearcoatIor")),t.setTexture("baseMap",a.getTexture("baseMap")),t.setTexture("normalMap",a.getTexture("normalMap")),t.setTexture("emissiveMap",a.getTexture("emissiveMap")),t.setTexture("aoMap",a.getTexture("aoMap")),t.setTexture("maskMap",a.getTexture("maskMap")),t.setTexture("empty",a.getTexture("empty")),t.setUniform("baseMapOffsetSize",a.getUniform("baseMapOffsetSize")),t.setUniform("normalMapOffsetSize",a.getUniform("normalMapOffsetSize")),t.setUniform("emissiveMapOffsetSize",a.getUniform("emissiveMapOffsetSize")),t.setUniform("roughnessMapOffsetSize",a.getUniform("roughnessMapOffsetSize")),t.setUniform("metallicMapOffsetSize",a.getUniform("metallicMapOffsetSize")),t.setUniform("aoMapOffsetSize",a.getUniform("aoMapOffsetSize")),e}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set maskMap(e){this.shader.setTexture("maskMap",e)}get maskMap(){return this.shader.getTexture("maskMap")}set normalMap(e){this.shader.setTexture("normalMap",e)}get normalMap(){return this.shader.getTexture("normalMap")}set emissiveMap(e){this.shader.setTexture("emissiveMap",e)}get emissiveMap(){return this.shader.getTexture("emissiveMap")}set aoMap(e){this.shader.setTexture("aoMap",e)}get aoMap(){return this.shader.getTexture("aoMap")}set clearCoatRoughnessMap(e){this.shader.setTexture("clearCoatRoughnessMap",e),this.shader.setDefine("USE_CLEARCOAT",!0),this.shader.setDefine("USE_CLEARCOAT_ROUGHNESS",!0)}get clearCoatRoughnessMap(){return this.shader.getTexture("clearCoatRoughnessMap")}set clearcoatColor(e){this.shader.setUniformColor("clearcoatColor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatColor(){return this.shader.getUniformColor("clearcoatColor")}set clearcoatWeight(e){this.shader.setUniformFloat("clearcoatWeight",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatWeight(){return this.shader.getUniformFloat("clearcoatWeight")}set clearcoatFactor(e){this.shader.setUniformFloat("clearcoatFactor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatFactor(){return this.shader.getUniformFloat("clearcoatFactor")}set clearcoatRoughnessFactor(e){this.shader.setUniformFloat("clearcoatRoughnessFactor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatRoughnessFactor(){return this.shader.getUniformFloat("clearcoatRoughnessFactor")}set ior(e){this.shader.setUniformFloat("clearcoatIor",e)}get ior(){return this.shader.getUniformFloat("clearcoatIor")}set alphaCutoff(e){this.shader.setUniform("alphaCutoff",e)}get alphaCutoff(){return this.shader.getUniform("alphaCutoff")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}get roughness(){return this.shader.getUniformFloat("roughness")}set roughness(e){this.shader.setUniformFloat("roughness",e)}get metallic(){return this.shader.getUniformFloat("metallic")}set metallic(e){this.shader.setUniformFloat("metallic",e)}get emissiveColor(){return this.shader.getUniformColor("emissiveColor")}set emissiveColor(e){this.shader.setUniformColor("emissiveColor",e)}get emissiveIntensity(){return this.shader.getUniformFloat("emissiveIntensity")}set emissiveIntensity(e){this.shader.setUniformFloat("emissiveIntensity",e)}get ao(){return this.shader.getUniform("ao")}set ao(e){this.shader.setUniform("ao",e)}}class J0 extends nt{static format=Ge.TEXT;textData="";source_vertices;source_normals;source_tangents;source_textureCoords;matLibs;geometrys;activeGeo;currentObjectName;currentMaterialName;facesMaterialsIndex;mtl;mtlUrl;async parseString(e){return this.source_vertices=[],this.source_normals=[],this.source_tangents=[],this.source_textureCoords=[],this.currentObjectName="default",this.currentMaterialName="",this.matLibs={},this.geometrys={},this.activeGeo=void 0,this.textData=e,await Promise.all([this.parserOBJ(),this.loadMTL()]),this.parser_mesh(),"null"}applyVector2(e,t,a){e>=0&&t[e]&&t[e].length>0?(a.push(t[e][0]),a.push(-t[e][1])):(a.push(0),a.push(0))}applyVector3(e,t,a){e>=0&&t[e]&&t[e].length>0?(a.push(t[e][0]),a.push(t[e][1]),a.push(t[e][2])):(a.push(0),a.push(0),a.push(0))}applyVector4(e,t,a){a.push(t[e][0]),a.push(t[e][1]),a.push(t[e][2]),a.push(t[e][3])}parseUVIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}parseVertexIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}parseNormalIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}calculateFaceNormal(e,t,a){const r=[t[0]-e[0],t[1]-e[1],t[2]-e[2]],i=[a[0]-e[0],a[1]-e[1],a[2]-e[2]],n=[r[1]*i[2]-r[2]*i[1],r[2]*i[0]-r[0]*i[2],r[0]*i[1]-r[1]*i[0]],o=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);return o>0&&(n[0]/=o,n[1]/=o,n[2]/=o),n}async loadMTL(){let t=await new At().loadTxt(this.baseUrl+this.mtlUrl),a=t.data,r,i=a.split(/\r?\n/);for(let c=0;c<i.length;c++){let f=i[c];var n=f.indexOf("#");n!=-1&&(f=f.substring(0,n)),f=f.trim();var o=f.split(/\s+/);o[0]==="newmtl"?(r={name:o[1]},this.matLibs[o[1]]=r):o[0].indexOf("map_")!=-1?(r[o[0]]=o[1],r.textures||(r.textures=[o[o.length-1]]),r.textures.push(o[o.length-1])):o.length==2?r[o[0]]=Number(o[1]):o.length==3?r[o[0]]=[Number(o[1]),Number(o[2])]:o.length==4&&(r[o[0]]=[Number(o[1]),Number(o[2]),Number(o[3])])}const l=[];for(const c in this.matLibs){const f=this.matLibs[c];if(f.textures&&f.textures.length>0)for(let h=0;h<f.textures.length;h++){const u=yt.normalizePath(this.baseUrl+f.textures[h]);l.push(A.res.loadTexture(u).catch(g=>(console.error(`Failed to load texture: ${u}`,g),null)))}}return await Promise.all(l),t=null,!0}async load_textures(){}getGeometryKey(e,t){const a=(e??this.currentObjectName??"default")||"default",r=t??this.currentMaterialName??"",i=r.length>0?r:"default";return`${a}::${i}`}ensureActiveGeo(e,t){const a=(e??this.currentObjectName??"default")||"default",r=t??this.currentMaterialName??"",i=this.getGeometryKey(a,r);this.geometrys[i]?this.geometrys[i].source_mat!==r&&(this.geometrys[i].source_mat=r):this.geometrys[i]={type:a,name:i,source_mat:r,source_faces:[]},this.activeGeo=this.geometrys[i]}parserLine(e){var t=e.indexOf("#");if(t!=-1){if(e.indexOf("# object")!=-1){const p=e.split(/\s+/),m=p[1]||"default",D=p[2]||"default";this.currentObjectName=D,this.activeGeo=void 0,this.ensureActiveGeo(D,this.currentMaterialName),this.activeGeo&&(this.activeGeo.type=m)}e=e.substring(0,t)}e=e.trim();var a=e.split(/\s+/);if(a[0]==="v"){var r=[Number(a[1]),Number(a[2]),Number(a[3]),a[4]?1:Number(a[4])];this.source_vertices.push(r)}else if(a[0]==="vt"){var i=[Number(a[1]),Number(a[2]),a[3]?1:Number(a[3])];this.source_textureCoords.push(i)}else if(a[0]==="vn"){var n=[Number(a[1]),Number(a[2]),Number(a[3])];this.source_normals.push(n)}else if(a[0]==="f"){for(var o={indices:[],texture:[],normal:[]},l=1;l<a.length;++l){var c=a[l];if(c.length!==0){var f=c.split("/"),h=f[0]||"",u=f.length>=2&&f[1]||"",g=f.length>=3&&f[2]||"";h.length!==0&&(o.indices.push(h),o.texture.push(u),o.normal.push(g))}}this.ensureActiveGeo(),this.activeGeo.source_faces.push(o)}else a[0]==="usemtl"?(this.currentMaterialName=a[1]||"",this.ensureActiveGeo(this.currentObjectName,this.currentMaterialName)):a[0]==="mtllib"&&(this.mtlUrl=a[1])}async parserOBJ(){let e=this.textData.split(/\r?\n/);for(let t=0;t<e.length;t++){const a=e[t];this.parserLine(a)}return this.textData="",!0}async parser_mesh(){let e=new d.Object3D;for(const t in this.geometrys){const a=this.geometrys[t];a.vertex_arr=[],a.normal_arr=[],a.uv_arr=[],a.indeice_arr=[];let r=0;const i=this.source_vertices.length,n=this.source_normals.length,o=this.source_textureCoords.length;for(let p=0;p<a.source_faces.length;p++){const m=a.source_faces[p];let D=this.parseVertexIndex(m.indices[0],i),_=this.parseVertexIndex(m.indices[1],i),B=this.parseVertexIndex(m.indices[2],i);const v=G=>{if(!G||G.length===0)return-1;const X=this.parseNormalIndex(G,n);return Number.isFinite(X)&&X>=0&&X<n?X:-1},C=G=>{if(!G||G.length===0)return-1;const X=this.parseUVIndex(G,o);return Number.isFinite(X)&&X>=0&&X<o?X:-1};let y=v(m.normal[0]),F=v(m.normal[1]),k=v(m.normal[2]);const w=y<0||F<0||k<0;let x=null;w&&D>=0&&_>=0&&B>=0&&this.source_vertices[D]&&this.source_vertices[_]&&this.source_vertices[B]&&(x=this.calculateFaceNormal(this.source_vertices[D],this.source_vertices[_],this.source_vertices[B]));let M=C(m.texture[0]),N=C(m.texture[1]),Q=C(m.texture[2]);if(this.applyVector3(D,this.source_vertices,a.vertex_arr),y>=0?this.applyVector3(y,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),M>=0?this.applyVector2(M,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(_,this.source_vertices,a.vertex_arr),F>=0?this.applyVector3(F,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),N>=0?this.applyVector2(N,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(B,this.source_vertices,a.vertex_arr),k>=0?this.applyVector3(k,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),Q>=0?this.applyVector2(Q,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,m.indices.length>3){let G=this.parseVertexIndex(m.indices[3],i),X=v(m.normal[3]),ne=C(m.texture[3]),q=null;(y<0||k<0||X<0)&&D>=0&&B>=0&&G>=0&&this.source_vertices[D]&&this.source_vertices[B]&&this.source_vertices[G]&&(q=this.calculateFaceNormal(this.source_vertices[D],this.source_vertices[B],this.source_vertices[G])),this.applyVector3(D,this.source_vertices,a.vertex_arr),y>=0?this.applyVector3(y,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),M>=0?this.applyVector2(M,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(B,this.source_vertices,a.vertex_arr),k>=0?this.applyVector3(k,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),Q>=0?this.applyVector2(Q,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(G,this.source_vertices,a.vertex_arr),X>=0?this.applyVector3(X,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),ne>=0?this.applyVector2(ne,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++}}let l=new Fe;l.setIndices(new Uint32Array(a.indeice_arr)),l.setAttribute(V.position,new Float32Array(a.vertex_arr)),l.setAttribute(V.normal,new Float32Array(a.normal_arr)),l.setAttribute(V.uv,new Float32Array(a.uv_arr)),l.setAttribute(V.TEXCOORD_1,new Float32Array(a.uv_arr)),l.addSubGeometry({indexStart:0,indexCount:a.indeice_arr.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});let c=new pa;const f=a.source_mat,h=f?this.matLibs[f]:void 0;if(h&&h.map_Kd){const p=yt.normalizePath(this.baseUrl+h.map_Kd),m=A.res.getTexture(p);m&&(c.baseMap=m)}let u=new d.Object3D,g=u.addComponent(d.MeshRenderer);g.geometry=l,g.material=c,e.addChild(u)}this.data=e}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}}let W0=`
7276
7276
  struct ImageSize {
7277
7277
  srcWidth: i32,
7278
7278
  srcHeight: i32,
@@ -7762,7 +7762,7 @@ else if (typeof exports === 'object')
7762
7762
  `;class ff{compute;constructor(){this.compute=new fe(cf)}generateBRDFLUTTexture(){let e=new pe(256,256,Y.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);this.compute.setStorageTexture("brdflutTexture",e),this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let t=S.beginCommandEncoder();return S.computeCommand(t,[this.compute]),S.endCommandEncoder(t),e}}class qr{id;guiTexture;uvRec=new $(0,0,1,1);uvBorder=new $(0,0,0,0);offsetSize=new $(0,0,4,4);borderSize=new $(0,0,0,0);trimSize=new K;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||A.res.defaultGUITexture}}class ir{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=A.res.whiteTexture,e.addressModeU="clamp-to-edge",e.addressModeV="clamp-to-edge",this.texture=e,ir._maxUid++,this._staticId=ir._maxUid,this.init()}init(){this.dynamicId=-1,this.width=this.texture.width,this.height=this.texture.height}}class F2{fntCache={};fntData={};addFontData(e,t,a){this.fntData[`${e}${t}`]=a}getFontData(e,t){return this.fntData[`${e}${t}`]}addFnt(e,t,a,r){let i=`${e}${t}`;this.fntCache[i]||(this.fntCache[i]={}),this.fntCache[i][a]=r}getFnt(e,t,a){let r=`${e}${t}`,i=this.fntCache[r];return i?i[a]:this.fntCache[" "]}}let $r=new F2;class df{face="";size=0;bold=!1;italic=!1;stretchH=0;spacing="";outline=0;lineHeight=0;base=0;scaleW=0;scaleH=0;pages=0;packed=0;alphaChnl=0;redChnl=0;greenChnl=0;blueChnl=0;count=0;fontPage=[];fontChar={};constructor(){}}class hf{id=0;file=""}class uf{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class za extends nt{static format=Ge.TEXT;static parseSprite(e,t){for(const a in t.fontChar)if(Object.prototype.hasOwnProperty.call(t.fontChar,a)){const r=t.fontChar[a];let i=new qr;i.id=r.id.toString(),i.offsetSize.set(0,0,r.width,r.height),i.trimSize.set(r.width,r.height),i.width=r.width,i.height=r.height,i.xadvance=r.xadvance,i.xoffset=r.xoffset,i.yoffset=r.yoffset,i.guiTexture=e[r.page],i.uvRec.set(r.x/t.scaleW,(t.scaleH-(r.y+r.height))/t.scaleH,r.width/t.scaleW,r.height/t.scaleH),$r.addFnt(t.face,t.size,i.id,i)}}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}async parseString(e){let t=this.getNewLine(e),a=e,r=new df;a.trim().split(t).forEach((i,n)=>{if(n<2)za.readLineProperty(i,r);else if(n<r.pages+2){let o=new hf;za.readLineProperty(i,o),r.fontPage.push(o)}else if(n<r.pages+3)za.readLineProperty(i,r);else if(r.count>0){let o=new uf;za.readLineProperty(i,o),r.fontChar[o.id]=o,r.count--}}),a="",this.data=r,await this.loadFontTextures()}getNewLine(e){return e.indexOf(`\r
7763
7763
  `)!=-1?`\r
7764
7764
  `:e.indexOf("\r")!=-1?"\r":`
7765
- `}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await A.res.loadTexture(r,null,!0);let i=A.res.getTexture(r),n=new ir(i);e.push(n)}za.parseSprite(e,t),t.fontChar[" "]||za.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new qr,r=e.size*.5,i=e.lineHeight*.5;a.id=" ",a.offsetSize.set(0,0,e.size,e.size),a.trimSize.set(r,i),a.width=r,a.height=i,a.xadvance=0,a.xoffset=0,a.yoffset=0,a.guiTexture=t,a.uvRec.set(0,0,1e-6,1e-6),$r.addFnt(e.face,e.size,a.id,a)}static readLineProperty(e,t){e.trim().split(" ").forEach((a,r)=>{let i=a.split("=");if(i.length>1){let n=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,n)&&(o.indexOf('"')==-1?t[n]=parseFloat(i[1]):t[n]=o.replace('"',"").replace('"',""))}})}}function k2(s,e){let t=new qr;return t.id=s,t.offsetSize.set(0,0,e.width,e.height),t.trimSize.set(e.width,e.height),t.width=e.width,t.height=e.height,t.xadvance=0,t.xoffset=0,t.yoffset=0,t.guiTexture=new ir(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function bf(s,e,t){let a=new qr;a.guiTexture=s,a.id=e,a.uvRec.copyFrom(t.textureRect),a.trimSize.x=t.textureRect.z,a.trimSize.y=t.textureRect.w,a.offsetSize.x=t.textureRectOffset.x,a.offsetSize.y=t.textureRectOffset.y,a.offsetSize.z=t.size.x,a.offsetSize.w=t.size.y,a.width=t.size.x,a.height=t.size.y;let r=1/s.width,i=1/s.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let n=.1;return t.border.x<=n&&t.border.y<=n&&t.border.z<=n&&t.border.x<=n?a.isSliced=!1:(a.borderSize.copyFrom(t.border),a.uvBorder.copyFrom(t.border),a.uvBorder.x-=t.textureRectOffset.x,a.uvBorder.y-=t.textureRectOffset.y,a.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),a.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),a.uvBorder.x/=t.textureRect.z,a.uvBorder.z/=t.textureRect.z,a.uvBorder.y/=t.textureRect.w,a.uvBorder.w/=t.textureRect.w,a.isSliced=!0),a}class gf{_spriteMap=new Map;_spriteList=[];textureSize=new K;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=bf(e,t,a);return this._spriteMap.set(r.id,r),this._spriteList.push(r),r}getSprite(e){return this._spriteMap.get(e)}get spriteList(){return this._spriteList}}class mf extends nt{static format=Ge.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await A.res.loadTexture(t,null,!0),this.data={json:this._json,texture:this._texture},this.parseAtlas()}verification(){if(this.data)return!0;throw new Error("verify failed.")}parseAtlas(){let e=new gf(this._json.size),t=new ir(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);A.res.addAtlas(this.baseUrl,e),this.data=e}}var Ot=Uint8Array,ei=Uint16Array,E2=Int32Array,pf=new Ot([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Af=new Ot([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),R2=new Ot([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Df=function(s,e){for(var t=new ei(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new E2(t[30]),a=1;a<30;++a)for(var i=t[a];i<t[a+1];++i)r[i]=i-t[a]<<5|a;return{b:t,r}},_f=Df(pf,2),Bf=_f.b,w2=_f.r;Bf[28]=258,w2[258]=28;for(var I2=Df(Af,0),Q2=I2.b,js=new ei(32768),we=0;we<32768;++we){var nr=(we&43690)>>1|(we&21845)<<1;nr=(nr&52428)>>2|(nr&13107)<<2,nr=(nr&61680)>>4|(nr&3855)<<4,js[we]=((nr&65280)>>8|(nr&255)<<8)>>1}for(var Si=(function(s,e,t){for(var a=s.length,r=0,i=new ei(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new ei(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new ei(1<<e);var l=15-e;for(r=0;r<a;++r)if(s[r])for(var c=r<<4|s[r],f=e-s[r],h=n[s[r]-1]++<<f,u=h|(1<<f)-1;h<=u;++h)o[js[h]>>l]=c}else for(o=new ei(a),r=0;r<a;++r)s[r]&&(o[r]=js[n[s[r]-1]++]>>15-s[r]);return o}),xi=new Ot(288),we=0;we<144;++we)xi[we]=8;for(var we=144;we<256;++we)xi[we]=9;for(var we=256;we<280;++we)xi[we]=7;for(var we=280;we<288;++we)xi[we]=8;for(var Uf=new Ot(32),we=0;we<32;++we)Uf[we]=5;var T2=Si(xi,9,1),M2=Si(Uf,5,1),Zs=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},oa=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},Ys=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},N2=function(s){return(s+7)/8|0},Xs=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new Ot(s.subarray(e,t))},P2=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Xt=function(s,e,t){var a=new Error(e||P2[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,Xt),!t)throw a;return a},V2=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new Ot(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new Ot(r*3));var c=function(It){var Qt=t.length;if(It>Qt){var Gt=new Ot(Math.max(Qt*2,It));Gt.set(t),t=Gt}},f=e.f||0,h=e.p||0,u=e.b||0,g=e.l,p=e.d,m=e.m,D=e.n,_=r*8;do{if(!g){f=oa(s,h,1);var B=oa(s,h+1,3);if(h+=3,B)if(B==1)g=T2,p=M2,m=9,D=5;else if(B==2){var F=oa(s,h,31)+257,k=oa(s,h+10,15)+4,w=F+oa(s,h+5,31)+1;h+=14;for(var x=new Ot(w),M=new Ot(19),N=0;N<k;++N)M[R2[N]]=oa(s,h+N*3,7);h+=k*3;for(var Q=Zs(M),G=(1<<Q)-1,X=Si(M,Q,1),N=0;N<w;){var ne=X[oa(s,h,G)];h+=ne&15;var v=ne>>4;if(v<16)x[N++]=v;else{var q=0,he=0;for(v==16?(he=3+oa(s,h,3),h+=2,q=x[N-1]):v==17?(he=3+oa(s,h,7),h+=3):v==18&&(he=11+oa(s,h,127),h+=7);he--;)x[N++]=q}}var Be=x.subarray(0,F),ae=x.subarray(F);m=Zs(Be),D=Zs(ae),g=Si(Be,m,1),p=Si(ae,D,1)}else Xt(1);else{var v=N2(h)+4,C=s[v-4]|s[v-3]<<8,y=v+C;if(y>r){l&&Xt(0);break}o&&c(u+C),t.set(s.subarray(v,y),u),e.b=u+=C,e.p=h=y*8,e.f=f;continue}if(h>_){l&&Xt(0);break}}o&&c(u+131072);for(var ee=(1<<m)-1,se=(1<<D)-1,Ae=h;;Ae=h){var q=g[Ys(s,h)&ee],Ue=q>>4;if(h+=q&15,h>_){l&&Xt(0);break}if(q||Xt(2),Ue<256)t[u++]=Ue;else if(Ue==256){Ae=h,g=null;break}else{var Se=Ue-254;if(Ue>264){var N=Ue-257,Te=pf[N];Se=oa(s,h,(1<<Te)-1)+Bf[N],h+=Te}var ve=p[Ys(s,h)&se],Me=ve>>4;ve||Xt(3),h+=ve&15;var ae=Q2[Me];if(Me>3){var Te=Af[Me];ae+=Ys(s,h)&(1<<Te)-1,h+=Te}if(h>_){l&&Xt(0);break}o&&c(u+131072);var Ut=u+Se;if(u<ae){var ya=i-ae,Ca=Math.min(ae,Ut);for(ya+u<0&&Xt(3);u<Ca;++u)t[u]=a[ya+u]}for(;u<Ut;++u)t[u]=t[u-ae]}}e.l=g,e.p=Ae,e.b=u,e.f=f,g&&(f=1,e.m=m,e.d=p,e.n=D)}while(!f);return u!=t.length&&n?Xs(t,0,u):t.subarray(0,u)},O2=new Ot(0),Aa=function(s,e){return s[e]|s[e+1]<<8},la=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},Hs=function(s,e){return la(s,e)+la(s,e+4)*4294967296};function L2(s,e){return V2(s,{i:2},e&&e.out,e&&e.dictionary)}var Ks=typeof TextDecoder<"u"&&new TextDecoder,G2=0;try{Ks.decode(O2,{stream:!0}),G2=1}catch{}var z2=function(s){for(var e="",t=0;;){var a=s[t++],r=(a>127)+(a>223)+(a>239);if(t+r>s.length)return{s:e,r:Xs(s,t-1)};r?r==3?(a=((a&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|s[t++]&63):e+=String.fromCharCode((a&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(a)}};function vf(s,e){if(e){for(var t="",a=0;a<s.length;a+=16384)t+=String.fromCharCode.apply(null,s.subarray(a,a+16384));return t}else{if(Ks)return Ks.decode(s);var r=z2(s),i=r.s,t=r.r;return t.length&&Xt(8),i}}var J2=function(s,e){return e+30+Aa(s,e+26)+Aa(s,e+28)},W2=function(s,e,t){var a=Aa(s,e+28),r=vf(s.subarray(e+46,e+46+a),!(Aa(s,e+8)&2048)),i=e+46+a,n=la(s,e+20),o=t&&n==4294967295?j2(s,i):[n,la(s,e+24),la(s,e+42)],l=o[0],c=o[1],f=o[2];return[Aa(s,e+10),l,c,r,i+Aa(s,e+30)+Aa(s,e+32),f]},j2=function(s,e){for(;Aa(s,e)!=1;e+=4+Aa(s,e+2));return[Hs(s,e+12),Hs(s,e+4),Hs(s,e+20)]};function Z2(s,e){for(var t={},a=s.length-22;la(s,a)!=101010256;--a)(!a||s.length-a>65558)&&Xt(13);var r=Aa(s,a+8);if(!r)return{};var i=la(s,a+16),n=i==4294967295||r==65535;if(n){var o=la(s,a-12);n=la(s,o)==101075792,n&&(r=la(s,o+32),i=la(s,o+48))}for(var l=0;l<r;++l){var c=W2(s,i,n),f=c[0],h=c[1],u=c[2],g=c[3],p=c[4],m=c[5],D=J2(s,m);i=p,f?f==8?t[g]=L2(s.subarray(D,D+h),{out:new Ot(u)}):Xt(14,"unknown compression type "+f):t[g]=Xs(s,D,D+h)}return t}class st extends ut{constructor(){super(),this.shader=new d.UnLitShader,this.baseMap=A.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}class Cr extends Fe{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,n,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=n,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,n=this.radius;var o=(r+1)*(i+1);let l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),h=new Uint16Array(i*r*2*3),u=0,g=0,p=0;for(t=0;t<=r;++t){var m=Math.PI*t/r,D=n*Math.cos(m),_=n*Math.sin(m);for(e=0;e<=i;++e){var B=2*Math.PI*e/i,v=_*Math.cos(B),C=_*Math.sin(B),y=1/Math.sqrt(v*v+D*D+C*C);if(l[u++]=v,l[u++]=D,l[u++]=C,c[g++]=v*y,c[g++]=D*y,c[g++]=C*y,f[p++]=e/i,f[p++]=t/r,e>0&&t>0){var F=(i+1)*t+e,k=(i+1)*t+e-1,w=(i+1)*(t-1)+e-1,x=(i+1)*(t-1)+e;t==r?(h[a++]=F,h[a++]=w,h[a++]=x):t==1?(h[a++]=F,h[a++]=k,h[a++]=w):(h[a++]=F,h[a++]=k,h[a++]=w,h[a++]=F,h[a++]=w,h[a++]=x)}}}this.setIndices(h),this.setAttribute(V.position,l),this.setAttribute(V.normal,c),this.setAttribute(V.uv,f),this.setAttribute(V.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new ge(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class Fi extends d.Object3D{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new b(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),Fi.register3DRepresentation)this.marker=Fi.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new d.Object3D;const e=this.marker.addComponent(d.MeshRenderer);e.geometry=new Cr(.1,32,16),e.material=new st,e.material.baseColor=this.positionValid?new O(0,1,0,1):new O(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class ki extends d.Object3D{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new Fi(t);this.addChild(a)}this.entityChildren=this.entityChildren.sort((t,a)=>t.positionIndex-a.positionIndex)}setup3DRepresentation(){this.line&&(this.removeChild(this.line),this.line=null),ki.register3DRepresentation?(this.line=ki.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new O(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Fe,r=new Float32Array(e.length*3);for(let c=0;c<e.length;c++)r[c*3]=e[c].x,r[c*3+1]=e[c].y,r[c*3+2]=e[c].z;const i=new Uint16Array((e.length-1)*2);for(let c=0;c<e.length-1;c++)i[c*2]=c,i[c*2+1]=c+1;a.setIndices(i),a.setAttribute(V.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const n=new d.Object3D,o=n.addComponent(d.MeshRenderer),l=new st;return l.topology="line-list",l.baseColor=t,l.blendMode=te.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class yf extends nt{static format=Ge.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Z2(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(vf(n),"application/xml"),c={};this.parseNode(l,c);const f=i.replace("wpmz/","").split(".")[0];Object.assign(t,{[f]:c["#document"].kml.Document})}const r=new ki(t.waylines);this.data=r}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const a=["Placemark","actionGroup","action"],r=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[r]=void 0;else{let i=null,n=!1;for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];if(l.nodeType==Node.TEXT_NODE){const c=l.nodeValue?.trim();c&&c.length>0&&(i=c)}else l.nodeType==Node.ELEMENT_NODE&&(n=!0)}if(i&&!n)t[r]=i;else if(n){a.includes(r)?t[r]?.length?t[r].push({}):t[r]=[{}]:t[r]={};for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[r])?t[r].at(-1):t[r])}}else t[r]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class Cf{_texturePool;_materialPool;_prefabPool;_gltfPool;_geometryPool;_atlasList;_obj;constructor(){this._texturePool=new Map,this._materialPool=new Map,this._prefabPool=new Map,this._geometryPool=new Map,this._gltfPool=new Map,this._atlasList=new Map,this._obj=new Map}getGltf(e){return this._gltfPool.get(e)}addObj(e,t){this._obj.set(e,t)}getObj(e){return this._obj.get(e)}addTexture(e,t){this._texturePool.set(e,t)}getTexture(e){return this._texturePool.get(e)}addGeometry(e,t){this._geometryPool.set(e,t)}getGeometry(e){return this._geometryPool.get(e)}addMat(e,t){return this._materialPool.set(e,t)}getMat(e){return this._materialPool.get(e)}addPrefab(e,t){this._prefabPool.set(e,t)}getPrefab(e){return this._prefabPool.get(e).instantiate()}addAtlas(e,t){t.name=e,this._atlasList.set(e,t)}getAtlas(e){return this._atlasList.get(e)}getGUISprite(e){for(let t of this._atlasList.values()){let a=t.getSprite(e);if(a)return a}return null}async load(e,t,a){return(await new At().load(e,t,a)).data}async loadGltf(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new At;r==".gltf"?a=await i.load(e,Dt,t):a=await i.load(e,Qs,t);let n=a.data;return this._prefabPool.set(e,n),this._gltfPool.set(e,a.gltf),n}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new At;r==".obj"&&(a=await i.load(e,J0,t));let n=a.data;return this._prefabPool.set(e,n),n}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new At().load(e,zs,t,a)).data;return this._prefabPool.set(e,n),n}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new At().load(e,lf,t,a)).data;return this._prefabPool.set(e,n),n}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new La;return r.flipY=a,await r.load(e,t),this._texturePool.set(e,r),r}async loadTextureCount(e,t,a,r){return new Promise(async(i,n)=>{let o=0,l=[];t==0&&i(l);for(let c=0;c<t;c++){const f=e.shift();this.loadTexture(f,a,r).then(h=>{l.push(h),o++,o==t&&i(l)})}})}async loadBitmapTextures(e,t=5,a,r){let i=[],n=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<n;l++){let c=await this.loadTextureCount(e,l==n-1?o:t,a,r);i.push(...c)}return i}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Ns;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadHDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new gn;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadLDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new pn;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadTextureCubeMaps(e){let t=e[0];if(this._texturePool.has(t))return this._texturePool.get(t);let a=new Ts;return await a.load(e),this._texturePool.set(e[0],a),a}async loadTextureCubeStd(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Ts;return await a.loadStd(e),a}async loadJSON(e,t){return await new At().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new At().load(e,za,t,a),n=i.data;return $r.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new At().load(e,mf,t,e)).data}async loadKMZ(e,t){return(await new At().load(e,yf,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,n,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,n);let h=new ds;return h.name=o,h.create(16,16,f,!0),o&&this.addTexture(o,h),h}fillColor(e,t,a,r,i,n,o){for(let l=0;l<t;l++)for(let c=0;c<a;c++){let f=c*t+l;e[f*4+0]=r,e[f*4+1]=i,e[f*4+2]=n,e[f*4+3]=o}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new ff().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new gn,this.defaultSky.createFromTexture(128,this.blackTexture),me.getInstance().attached(this.defaultSky,this),me.getInstance().attached(t,this),me.getInstance().attached(this.normalTexture,this),me.getInstance().attached(this.maskTexture,this),me.getInstance().attached(this.whiteTexture,this),me.getInstance().attached(this.blackTexture,this),me.getInstance().attached(this.redTexture,this),me.getInstance().attached(this.blueTexture,this),me.getInstance().attached(this.greenTexture,this),me.getInstance().attached(this.yellowTexture,this),me.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new ir(this.whiteTexture),this.defaultGUISprite=new qr(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new pa}}class Sf extends Pe{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=A.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=A.getRenderJob(e);this._postList.forEach(a=>{t.removePost(a)})}addPost(e){if(this._postList.has(e))return;let t=new e;return this._postList.set(e,t),this._enable&&this.activePost(),t}removePost(e){if(!this._postList.has(e))return;let t=this._postList.get(e);this._postList.delete(e);let a=this.transform.view3D;A.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Y2="1.0.22";class A{static res;static inputSystem;static views;static _frameRateValue=0;static _frameRate=360;static _time=0;static _beforeRender;static _renderLoop;static _lateRender;static _requestAnimationFrameID=0;static get frameRate(){return this._frameRate}static set frameRate(e){this._frameRate=e,this._frameRateValue=1e3/e,e>=360&&(this._frameRateValue=0)}static get size(){return E.presentationSize}static get aspect(){return E.aspect}static get width(){return E.windowWidth}static get height(){return E.windowHeight}static setting={doublePrecision:!1,occlusionQuery:{enable:!0,debug:!1},pick:{enable:!0,mode:"bound",detail:"mesh"},render:{debug:!1,renderPassState:4,renderState_left:5,renderState_right:5,renderState_split:.5,quadScale:1,hdrExposure:1.5,debugQuad:-1,maxPointLight:1e3,maxDirectLight:4,maxSportLight:1e3,drawOpMin:0,drawOpMax:Number.MAX_SAFE_INTEGER,drawTrMin:0,drawTrMax:Number.MAX_SAFE_INTEGER,zPrePass:!1,useLogDepth:!1,useCompressGBuffer:!1,gi:!1,postProcessing:{bloom:{downSampleStep:3,downSampleBlurSize:9,downSampleBlurSigma:1,upSampleBlurSize:9,upSampleBlurSigma:1,luminanceThreshole:1,bloomIntensity:1,hdr:1},globalFog:{debug:!1,enable:!1,fogType:0,fogHeightScale:.1,start:400,end:10,density:.02,ins:.5,skyFactor:.5,skyRoughness:.4,overrideSkyFactor:.8,fogColor:new O(96/255,117/255,133/255,1),falloff:.7,rayLength:200,scatteringExponent:2.7,dirHeightLine:10},godRay:{blendColor:!0,rayMarchCount:16,scatteringExponent:5,intensity:.5},ssao:{enable:!1,radius:.15,bias:-.1,aoPower:2,debug:!0},outline:{enable:!1,strength:1,groupCount:4,outlinePixel:2,fadeOutlinePixel:4,textureScale:1,useAddMode:!1,debug:!0},taa:{enable:!1,jitterSeedCount:8,blendFactor:.1,sharpFactor:.6,sharpPreBlurFactor:.5,temporalJitterScale:.13,debug:!0},gtao:{enable:!1,darkFactor:1,maxDistance:5,maxPixel:50,rayMarchSegment:6,multiBounce:!1,usePosFloat32:!0,blendColor:!0,debug:!0},ssr:{enable:!1,pixelRatio:1,fadeEdgeRatio:.2,rayMarchRatio:.5,fadeDistanceMin:600,fadeDistanceMax:2e3,roughnessThreshold:.5,powDotRN:.2,mixThreshold:.1,debug:!0},fxaa:{enable:!1},depthOfView:{enable:!1,iterationCount:3,pixelOffset:1,near:150,far:300}}},shadow:{enable:!0,type:"HARD",pointShadowBias:5e-4,shadowSize:2048,pointShadowSize:1024,shadowSoft:.005,shadowBound:100,shadowBias:.05,needUpdate:!0,autoUpdate:!0,updateFrameRate:2,csmMargin:.1,csmScatteringExp:.7,csmAreaScale:.4,debug:!1},gi:{enable:!1,offsetX:0,offsetY:0,offsetZ:0,probeSpace:64,probeXCount:4,probeYCount:2,probeZCount:4,probeSize:32,probeSourceTextureSize:2048,octRTMaxSize:2048,octRTSideSize:16,maxDistance:64*1.73,normalBias:.25,depthSharpness:1,hysteresis:.98,lerpHysteresis:.01,irradianceChebyshevBias:.01,rayNumber:144,irradianceDistanceBias:32,indirectIntensity:1,ddgiGamma:2.2,bounceIntensity:.025,probeRoughness:1,realTimeGI:!1,debug:!1,autoRenderProbe:!1},sky:{type:"HDRSKY",sky:null,skyExposure:1,defaultFar:65536,defaultNear:1},light:{maxLight:4096},material:{materialChannelDebug:!1,materialDebug:!1},loader:{numConcurrent:20},reflectionSetting:{reflectionProbeMaxCount:8,reflectionProbeSize:256,width:256*6,height:8*256,enable:!0}};static renderJobs;static async init(e={}){console.log("Rings Version",Y2),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await be.init(R.allocCount,this.setting.doublePrecision),await E.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,oe.getGBufferFrame(oe.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),J.init(),Va.init(),le.init(),mt.init(),Et.init(),this.res=new Cf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new No,this.inputSystem.initCanvas(E.canvas)}static startRenderJob(e){let t=new _0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Sf).addPost(_s),(this.setting.pick.mode=="pixel"||this.setting.pick.mode=="bound")&&(e.enablePick=!0),t}static startRenderView(e){this.renderJobs||=new Map,this.views=[e];let t=this.startRenderJob(e);return this.resume(),t}static startRenderViews(e){this.renderJobs||=new Map,this.views=e;for(let t=0;t<e.length;t++)this.startRenderJob(e[t]);this.resume()}static getRenderJob(e){return this.renderJobs.get(e)}static pause(){this._requestAnimationFrameID!==0&&(cancelAnimationFrame(this._requestAnimationFrameID),this._requestAnimationFrameID=0)}static resume(){this._requestAnimationFrameID===0&&(this._requestAnimationFrameID=requestAnimationFrame(e=>this.render(e)))}static async render(e){if(this._frameRateValue>0){let t=e-this._time;if(t<this._frameRateValue){let a=performance.now();await new Promise(r=>{setTimeout(()=>{e+=performance.now()-a,r(!0)},this._frameRateValue-t)})}this._time=e}await this.updateFrame(e),this._requestAnimationFrameID=0,this.resume()}static async updateFrame(e){xe.delta=e-xe.time,xe.time=e,xe.frame+=1,rr.tick(xe.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=E.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of ye.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}let r=E.device.createCommandEncoder();for(const n of ye.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o,r)}}E.device.queue.submit([r.finish()]);for(const n of ye.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}for(const n of ye.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];o&&f.enable&&h(o)}}this._renderLoop&&await this._renderLoop(),be.updateAllContinueTransform(0,R.useCount,16),le.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of ye.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}this._lateRender&&await this._lateRender()}}let An=`
7765
+ `}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await A.res.loadTexture(r,null,!0);let i=A.res.getTexture(r),n=new ir(i);e.push(n)}za.parseSprite(e,t),t.fontChar[" "]||za.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new qr,r=e.size*.5,i=e.lineHeight*.5;a.id=" ",a.offsetSize.set(0,0,e.size,e.size),a.trimSize.set(r,i),a.width=r,a.height=i,a.xadvance=0,a.xoffset=0,a.yoffset=0,a.guiTexture=t,a.uvRec.set(0,0,1e-6,1e-6),$r.addFnt(e.face,e.size,a.id,a)}static readLineProperty(e,t){e.trim().split(" ").forEach((a,r)=>{let i=a.split("=");if(i.length>1){let n=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,n)&&(o.indexOf('"')==-1?t[n]=parseFloat(i[1]):t[n]=o.replace('"',"").replace('"',""))}})}}function k2(s,e){let t=new qr;return t.id=s,t.offsetSize.set(0,0,e.width,e.height),t.trimSize.set(e.width,e.height),t.width=e.width,t.height=e.height,t.xadvance=0,t.xoffset=0,t.yoffset=0,t.guiTexture=new ir(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function bf(s,e,t){let a=new qr;a.guiTexture=s,a.id=e,a.uvRec.copyFrom(t.textureRect),a.trimSize.x=t.textureRect.z,a.trimSize.y=t.textureRect.w,a.offsetSize.x=t.textureRectOffset.x,a.offsetSize.y=t.textureRectOffset.y,a.offsetSize.z=t.size.x,a.offsetSize.w=t.size.y,a.width=t.size.x,a.height=t.size.y;let r=1/s.width,i=1/s.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let n=.1;return t.border.x<=n&&t.border.y<=n&&t.border.z<=n&&t.border.x<=n?a.isSliced=!1:(a.borderSize.copyFrom(t.border),a.uvBorder.copyFrom(t.border),a.uvBorder.x-=t.textureRectOffset.x,a.uvBorder.y-=t.textureRectOffset.y,a.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),a.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),a.uvBorder.x/=t.textureRect.z,a.uvBorder.z/=t.textureRect.z,a.uvBorder.y/=t.textureRect.w,a.uvBorder.w/=t.textureRect.w,a.isSliced=!0),a}class gf{_spriteMap=new Map;_spriteList=[];textureSize=new K;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=bf(e,t,a);return this._spriteMap.set(r.id,r),this._spriteList.push(r),r}getSprite(e){return this._spriteMap.get(e)}get spriteList(){return this._spriteList}}class mf extends nt{static format=Ge.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await A.res.loadTexture(t,null,!0),this.data={json:this._json,texture:this._texture},this.parseAtlas()}verification(){if(this.data)return!0;throw new Error("verify failed.")}parseAtlas(){let e=new gf(this._json.size),t=new ir(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);A.res.addAtlas(this.baseUrl,e),this.data=e}}var Ot=Uint8Array,ei=Uint16Array,E2=Int32Array,pf=new Ot([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Af=new Ot([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),R2=new Ot([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Df=function(s,e){for(var t=new ei(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new E2(t[30]),a=1;a<30;++a)for(var i=t[a];i<t[a+1];++i)r[i]=i-t[a]<<5|a;return{b:t,r}},_f=Df(pf,2),Bf=_f.b,w2=_f.r;Bf[28]=258,w2[258]=28;for(var I2=Df(Af,0),Q2=I2.b,js=new ei(32768),we=0;we<32768;++we){var nr=(we&43690)>>1|(we&21845)<<1;nr=(nr&52428)>>2|(nr&13107)<<2,nr=(nr&61680)>>4|(nr&3855)<<4,js[we]=((nr&65280)>>8|(nr&255)<<8)>>1}for(var Si=(function(s,e,t){for(var a=s.length,r=0,i=new ei(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new ei(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new ei(1<<e);var l=15-e;for(r=0;r<a;++r)if(s[r])for(var c=r<<4|s[r],f=e-s[r],h=n[s[r]-1]++<<f,u=h|(1<<f)-1;h<=u;++h)o[js[h]>>l]=c}else for(o=new ei(a),r=0;r<a;++r)s[r]&&(o[r]=js[n[s[r]-1]++]>>15-s[r]);return o}),xi=new Ot(288),we=0;we<144;++we)xi[we]=8;for(var we=144;we<256;++we)xi[we]=9;for(var we=256;we<280;++we)xi[we]=7;for(var we=280;we<288;++we)xi[we]=8;for(var Uf=new Ot(32),we=0;we<32;++we)Uf[we]=5;var T2=Si(xi,9,1),M2=Si(Uf,5,1),Zs=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},oa=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},Ys=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},N2=function(s){return(s+7)/8|0},Xs=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new Ot(s.subarray(e,t))},P2=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Xt=function(s,e,t){var a=new Error(e||P2[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,Xt),!t)throw a;return a},V2=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new Ot(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new Ot(r*3));var c=function(It){var Qt=t.length;if(It>Qt){var Gt=new Ot(Math.max(Qt*2,It));Gt.set(t),t=Gt}},f=e.f||0,h=e.p||0,u=e.b||0,g=e.l,p=e.d,m=e.m,D=e.n,_=r*8;do{if(!g){f=oa(s,h,1);var B=oa(s,h+1,3);if(h+=3,B)if(B==1)g=T2,p=M2,m=9,D=5;else if(B==2){var F=oa(s,h,31)+257,k=oa(s,h+10,15)+4,w=F+oa(s,h+5,31)+1;h+=14;for(var x=new Ot(w),M=new Ot(19),N=0;N<k;++N)M[R2[N]]=oa(s,h+N*3,7);h+=k*3;for(var Q=Zs(M),G=(1<<Q)-1,X=Si(M,Q,1),N=0;N<w;){var ne=X[oa(s,h,G)];h+=ne&15;var v=ne>>4;if(v<16)x[N++]=v;else{var q=0,he=0;for(v==16?(he=3+oa(s,h,3),h+=2,q=x[N-1]):v==17?(he=3+oa(s,h,7),h+=3):v==18&&(he=11+oa(s,h,127),h+=7);he--;)x[N++]=q}}var Be=x.subarray(0,F),ae=x.subarray(F);m=Zs(Be),D=Zs(ae),g=Si(Be,m,1),p=Si(ae,D,1)}else Xt(1);else{var v=N2(h)+4,C=s[v-4]|s[v-3]<<8,y=v+C;if(y>r){l&&Xt(0);break}o&&c(u+C),t.set(s.subarray(v,y),u),e.b=u+=C,e.p=h=y*8,e.f=f;continue}if(h>_){l&&Xt(0);break}}o&&c(u+131072);for(var ee=(1<<m)-1,se=(1<<D)-1,Ae=h;;Ae=h){var q=g[Ys(s,h)&ee],Ue=q>>4;if(h+=q&15,h>_){l&&Xt(0);break}if(q||Xt(2),Ue<256)t[u++]=Ue;else if(Ue==256){Ae=h,g=null;break}else{var Se=Ue-254;if(Ue>264){var N=Ue-257,Te=pf[N];Se=oa(s,h,(1<<Te)-1)+Bf[N],h+=Te}var ve=p[Ys(s,h)&se],Me=ve>>4;ve||Xt(3),h+=ve&15;var ae=Q2[Me];if(Me>3){var Te=Af[Me];ae+=Ys(s,h)&(1<<Te)-1,h+=Te}if(h>_){l&&Xt(0);break}o&&c(u+131072);var Ut=u+Se;if(u<ae){var ya=i-ae,Ca=Math.min(ae,Ut);for(ya+u<0&&Xt(3);u<Ca;++u)t[u]=a[ya+u]}for(;u<Ut;++u)t[u]=t[u-ae]}}e.l=g,e.p=Ae,e.b=u,e.f=f,g&&(f=1,e.m=m,e.d=p,e.n=D)}while(!f);return u!=t.length&&n?Xs(t,0,u):t.subarray(0,u)},O2=new Ot(0),Aa=function(s,e){return s[e]|s[e+1]<<8},la=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},Hs=function(s,e){return la(s,e)+la(s,e+4)*4294967296};function L2(s,e){return V2(s,{i:2},e&&e.out,e&&e.dictionary)}var Ks=typeof TextDecoder<"u"&&new TextDecoder,G2=0;try{Ks.decode(O2,{stream:!0}),G2=1}catch{}var z2=function(s){for(var e="",t=0;;){var a=s[t++],r=(a>127)+(a>223)+(a>239);if(t+r>s.length)return{s:e,r:Xs(s,t-1)};r?r==3?(a=((a&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|s[t++]&63):e+=String.fromCharCode((a&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(a)}};function vf(s,e){if(e){for(var t="",a=0;a<s.length;a+=16384)t+=String.fromCharCode.apply(null,s.subarray(a,a+16384));return t}else{if(Ks)return Ks.decode(s);var r=z2(s),i=r.s,t=r.r;return t.length&&Xt(8),i}}var J2=function(s,e){return e+30+Aa(s,e+26)+Aa(s,e+28)},W2=function(s,e,t){var a=Aa(s,e+28),r=vf(s.subarray(e+46,e+46+a),!(Aa(s,e+8)&2048)),i=e+46+a,n=la(s,e+20),o=t&&n==4294967295?j2(s,i):[n,la(s,e+24),la(s,e+42)],l=o[0],c=o[1],f=o[2];return[Aa(s,e+10),l,c,r,i+Aa(s,e+30)+Aa(s,e+32),f]},j2=function(s,e){for(;Aa(s,e)!=1;e+=4+Aa(s,e+2));return[Hs(s,e+12),Hs(s,e+4),Hs(s,e+20)]};function Z2(s,e){for(var t={},a=s.length-22;la(s,a)!=101010256;--a)(!a||s.length-a>65558)&&Xt(13);var r=Aa(s,a+8);if(!r)return{};var i=la(s,a+16),n=i==4294967295||r==65535;if(n){var o=la(s,a-12);n=la(s,o)==101075792,n&&(r=la(s,o+32),i=la(s,o+48))}for(var l=0;l<r;++l){var c=W2(s,i,n),f=c[0],h=c[1],u=c[2],g=c[3],p=c[4],m=c[5],D=J2(s,m);i=p,f?f==8?t[g]=L2(s.subarray(D,D+h),{out:new Ot(u)}):Xt(14,"unknown compression type "+f):t[g]=Xs(s,D,D+h)}return t}class st extends ut{constructor(){super(),this.shader=new d.UnLitShader,this.baseMap=A.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}class Cr extends Fe{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,n,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=n,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,n=this.radius;var o=(r+1)*(i+1);let l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),h=new Uint16Array(i*r*2*3),u=0,g=0,p=0;for(t=0;t<=r;++t){var m=Math.PI*t/r,D=n*Math.cos(m),_=n*Math.sin(m);for(e=0;e<=i;++e){var B=2*Math.PI*e/i,v=_*Math.cos(B),C=_*Math.sin(B),y=1/Math.sqrt(v*v+D*D+C*C);if(l[u++]=v,l[u++]=D,l[u++]=C,c[g++]=v*y,c[g++]=D*y,c[g++]=C*y,f[p++]=e/i,f[p++]=t/r,e>0&&t>0){var F=(i+1)*t+e,k=(i+1)*t+e-1,w=(i+1)*(t-1)+e-1,x=(i+1)*(t-1)+e;t==r?(h[a++]=F,h[a++]=w,h[a++]=x):t==1?(h[a++]=F,h[a++]=k,h[a++]=w):(h[a++]=F,h[a++]=k,h[a++]=w,h[a++]=F,h[a++]=w,h[a++]=x)}}}this.setIndices(h),this.setAttribute(V.position,l),this.setAttribute(V.normal,c),this.setAttribute(V.uv,f),this.setAttribute(V.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new ge(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class Fi extends d.Object3D{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new b(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),Fi.register3DRepresentation)this.marker=Fi.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new d.Object3D;const e=this.marker.addComponent(d.MeshRenderer);e.geometry=new Cr(.1,32,16),e.material=new st,e.material.baseColor=this.positionValid?new O(0,1,0,1):new O(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class ki extends d.Object3D{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new Fi(t);this.addChild(a)}this.entityChildren=this.entityChildren.sort((t,a)=>t.positionIndex-a.positionIndex)}setup3DRepresentation(){this.line&&(this.removeChild(this.line),this.line=null),ki.register3DRepresentation?(this.line=ki.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new O(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Fe,r=new Float32Array(e.length*3);for(let c=0;c<e.length;c++)r[c*3]=e[c].x,r[c*3+1]=e[c].y,r[c*3+2]=e[c].z;const i=new Uint16Array((e.length-1)*2);for(let c=0;c<e.length-1;c++)i[c*2]=c,i[c*2+1]=c+1;a.setIndices(i),a.setAttribute(V.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const n=new d.Object3D,o=n.addComponent(d.MeshRenderer),l=new st;return l.topology="line-list",l.baseColor=t,l.blendMode=te.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class yf extends nt{static format=Ge.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Z2(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(vf(n),"application/xml"),c={};this.parseNode(l,c);const f=i.replace("wpmz/","").split(".")[0];Object.assign(t,{[f]:c["#document"].kml.Document})}const r=new ki(t.waylines);this.data=r}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const a=["Placemark","actionGroup","action"],r=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[r]=void 0;else{let i=null,n=!1;for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];if(l.nodeType==Node.TEXT_NODE){const c=l.nodeValue?.trim();c&&c.length>0&&(i=c)}else l.nodeType==Node.ELEMENT_NODE&&(n=!0)}if(i&&!n)t[r]=i;else if(n){a.includes(r)?t[r]?.length?t[r].push({}):t[r]=[{}]:t[r]={};for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[r])?t[r].at(-1):t[r])}}else t[r]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class Cf{_texturePool;_materialPool;_prefabPool;_gltfPool;_geometryPool;_atlasList;_obj;constructor(){this._texturePool=new Map,this._materialPool=new Map,this._prefabPool=new Map,this._geometryPool=new Map,this._gltfPool=new Map,this._atlasList=new Map,this._obj=new Map}getGltf(e){return this._gltfPool.get(e)}addObj(e,t){this._obj.set(e,t)}getObj(e){return this._obj.get(e)}addTexture(e,t){this._texturePool.set(e,t)}getTexture(e){return this._texturePool.get(e)}addGeometry(e,t){this._geometryPool.set(e,t)}getGeometry(e){return this._geometryPool.get(e)}addMat(e,t){return this._materialPool.set(e,t)}getMat(e){return this._materialPool.get(e)}addPrefab(e,t){this._prefabPool.set(e,t)}getPrefab(e){return this._prefabPool.get(e).instantiate()}addAtlas(e,t){t.name=e,this._atlasList.set(e,t)}getAtlas(e){return this._atlasList.get(e)}getGUISprite(e){for(let t of this._atlasList.values()){let a=t.getSprite(e);if(a)return a}return null}async load(e,t,a){return(await new At().load(e,t,a)).data}async loadGltf(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new At;r==".gltf"?a=await i.load(e,Dt,t):a=await i.load(e,Qs,t);let n=a.data;return this._prefabPool.set(e,n),this._gltfPool.set(e,a.gltf),n}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new At;r==".obj"&&(a=await i.load(e,J0,t));let n=a.data;return this._prefabPool.set(e,n),n}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new At().load(e,zs,t,a)).data;return this._prefabPool.set(e,n),n}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new At().load(e,lf,t,a)).data;return this._prefabPool.set(e,n),n}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new La;r.flipY=a;try{await r.load(e,t)}catch(i){return console.error(`Failed to load texture: ${e}`,i),null}return this._texturePool.set(e,r),r}async loadTextureCount(e,t,a,r){return new Promise(async(i,n)=>{let o=0,l=[];t==0&&i(l);for(let c=0;c<t;c++){const f=e.shift();this.loadTexture(f,a,r).then(h=>{l.push(h),o++,o==t&&i(l)})}})}async loadBitmapTextures(e,t=5,a,r){let i=[],n=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<n;l++){let c=await this.loadTextureCount(e,l==n-1?o:t,a,r);i.push(...c)}return i}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Ns;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadHDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new gn;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadLDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new pn;return a=await a.load(e,t),this._texturePool.set(e,a),a}async loadTextureCubeMaps(e){let t=e[0];if(this._texturePool.has(t))return this._texturePool.get(t);let a=new Ts;return await a.load(e),this._texturePool.set(e[0],a),a}async loadTextureCubeStd(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Ts;return await a.loadStd(e),a}async loadJSON(e,t){return await new At().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new At().load(e,za,t,a),n=i.data;return $r.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new At().load(e,mf,t,e)).data}async loadKMZ(e,t){return(await new At().load(e,yf,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,n,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,n);let h=new ds;return h.name=o,h.create(16,16,f,!0),o&&this.addTexture(o,h),h}fillColor(e,t,a,r,i,n,o){for(let l=0;l<t;l++)for(let c=0;c<a;c++){let f=c*t+l;e[f*4+0]=r,e[f*4+1]=i,e[f*4+2]=n,e[f*4+3]=o}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new ff().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new gn,this.defaultSky.createFromTexture(128,this.blackTexture),me.getInstance().attached(this.defaultSky,this),me.getInstance().attached(t,this),me.getInstance().attached(this.normalTexture,this),me.getInstance().attached(this.maskTexture,this),me.getInstance().attached(this.whiteTexture,this),me.getInstance().attached(this.blackTexture,this),me.getInstance().attached(this.redTexture,this),me.getInstance().attached(this.blueTexture,this),me.getInstance().attached(this.greenTexture,this),me.getInstance().attached(this.yellowTexture,this),me.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new ir(this.whiteTexture),this.defaultGUISprite=new qr(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new pa}}class Sf extends Pe{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=A.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=A.getRenderJob(e);this._postList.forEach(a=>{t.removePost(a)})}addPost(e){if(this._postList.has(e))return;let t=new e;return this._postList.set(e,t),this._enable&&this.activePost(),t}removePost(e){if(!this._postList.has(e))return;let t=this._postList.get(e);this._postList.delete(e);let a=this.transform.view3D;A.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Y2="1.0.24";class A{static res;static inputSystem;static views;static _frameRateValue=0;static _frameRate=360;static _time=0;static _beforeRender;static _renderLoop;static _lateRender;static _requestAnimationFrameID=0;static get frameRate(){return this._frameRate}static set frameRate(e){this._frameRate=e,this._frameRateValue=1e3/e,e>=360&&(this._frameRateValue=0)}static get size(){return E.presentationSize}static get aspect(){return E.aspect}static get width(){return E.windowWidth}static get height(){return E.windowHeight}static setting={doublePrecision:!1,occlusionQuery:{enable:!0,debug:!1},pick:{enable:!0,mode:"bound",detail:"mesh"},render:{debug:!1,renderPassState:4,renderState_left:5,renderState_right:5,renderState_split:.5,quadScale:1,hdrExposure:1.5,debugQuad:-1,maxPointLight:1e3,maxDirectLight:4,maxSportLight:1e3,drawOpMin:0,drawOpMax:Number.MAX_SAFE_INTEGER,drawTrMin:0,drawTrMax:Number.MAX_SAFE_INTEGER,zPrePass:!1,useLogDepth:!1,useCompressGBuffer:!1,gi:!1,postProcessing:{bloom:{downSampleStep:3,downSampleBlurSize:9,downSampleBlurSigma:1,upSampleBlurSize:9,upSampleBlurSigma:1,luminanceThreshole:1,bloomIntensity:1,hdr:1},globalFog:{debug:!1,enable:!1,fogType:0,fogHeightScale:.1,start:400,end:10,density:.02,ins:.5,skyFactor:.5,skyRoughness:.4,overrideSkyFactor:.8,fogColor:new O(96/255,117/255,133/255,1),falloff:.7,rayLength:200,scatteringExponent:2.7,dirHeightLine:10},godRay:{blendColor:!0,rayMarchCount:16,scatteringExponent:5,intensity:.5},ssao:{enable:!1,radius:.15,bias:-.1,aoPower:2,debug:!0},outline:{enable:!1,strength:1,groupCount:4,outlinePixel:2,fadeOutlinePixel:4,textureScale:1,useAddMode:!1,debug:!0},taa:{enable:!1,jitterSeedCount:8,blendFactor:.1,sharpFactor:.6,sharpPreBlurFactor:.5,temporalJitterScale:.13,debug:!0},gtao:{enable:!1,darkFactor:1,maxDistance:5,maxPixel:50,rayMarchSegment:6,multiBounce:!1,usePosFloat32:!0,blendColor:!0,debug:!0},ssr:{enable:!1,pixelRatio:1,fadeEdgeRatio:.2,rayMarchRatio:.5,fadeDistanceMin:600,fadeDistanceMax:2e3,roughnessThreshold:.5,powDotRN:.2,mixThreshold:.1,debug:!0},fxaa:{enable:!1},depthOfView:{enable:!1,iterationCount:3,pixelOffset:1,near:150,far:300}}},shadow:{enable:!0,type:"HARD",pointShadowBias:5e-4,shadowSize:2048,pointShadowSize:1024,shadowSoft:.005,shadowBound:100,shadowBias:.05,needUpdate:!0,autoUpdate:!0,updateFrameRate:2,csmMargin:.1,csmScatteringExp:.7,csmAreaScale:.4,debug:!1},gi:{enable:!1,offsetX:0,offsetY:0,offsetZ:0,probeSpace:64,probeXCount:4,probeYCount:2,probeZCount:4,probeSize:32,probeSourceTextureSize:2048,octRTMaxSize:2048,octRTSideSize:16,maxDistance:64*1.73,normalBias:.25,depthSharpness:1,hysteresis:.98,lerpHysteresis:.01,irradianceChebyshevBias:.01,rayNumber:144,irradianceDistanceBias:32,indirectIntensity:1,ddgiGamma:2.2,bounceIntensity:.025,probeRoughness:1,realTimeGI:!1,debug:!1,autoRenderProbe:!1},sky:{type:"HDRSKY",sky:null,skyExposure:1,defaultFar:65536,defaultNear:1},light:{maxLight:4096},material:{materialChannelDebug:!1,materialDebug:!1},loader:{numConcurrent:20},reflectionSetting:{reflectionProbeMaxCount:8,reflectionProbeSize:256,width:256*6,height:8*256,enable:!0}};static renderJobs;static async init(e={}){console.log("Rings Version",Y2),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await be.init(R.allocCount,this.setting.doublePrecision),await E.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,oe.getGBufferFrame(oe.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),J.init(),Va.init(),le.init(),mt.init(),Et.init(),this.res=new Cf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new No,this.inputSystem.initCanvas(E.canvas)}static startRenderJob(e){let t=new _0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Sf).addPost(_s),(this.setting.pick.mode=="pixel"||this.setting.pick.mode=="bound")&&(e.enablePick=!0),t}static startRenderView(e){this.renderJobs||=new Map,this.views=[e];let t=this.startRenderJob(e);return this.resume(),t}static startRenderViews(e){this.renderJobs||=new Map,this.views=e;for(let t=0;t<e.length;t++)this.startRenderJob(e[t]);this.resume()}static getRenderJob(e){return this.renderJobs.get(e)}static pause(){this._requestAnimationFrameID!==0&&(cancelAnimationFrame(this._requestAnimationFrameID),this._requestAnimationFrameID=0)}static resume(){this._requestAnimationFrameID===0&&(this._requestAnimationFrameID=requestAnimationFrame(e=>this.render(e)))}static async render(e){if(this._frameRateValue>0){let t=e-this._time;if(t<this._frameRateValue){let a=performance.now();await new Promise(r=>{setTimeout(()=>{e+=performance.now()-a,r(!0)},this._frameRateValue-t)})}this._time=e}await this.updateFrame(e),this._requestAnimationFrameID=0,this.resume()}static async updateFrame(e){xe.delta=e-xe.time,xe.time=e,xe.frame+=1,rr.tick(xe.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=E.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of ye.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}let r=E.device.createCommandEncoder();for(const n of ye.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o,r)}}E.device.queue.submit([r.finish()]);for(const n of ye.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}for(const n of ye.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];o&&f.enable&&h(o)}}this._renderLoop&&await this._renderLoop(),be.updateAllContinueTransform(0,R.useCount,16),le.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of ye.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}this._lateRender&&await this._lateRender()}}let An=`
7766
7766
  struct BloomCfg{
7767
7767
  downSampleStep: f32,
7768
7768
  downSampleBlurSize: f32,