@rings-webgpu/core 1.0.24 → 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.
- package/dist/rings.es.js +2 -2
- package/dist/rings.es.js.map +3 -3
- package/dist/rings.es.max.js +27 -4
- package/dist/rings.umd.js +2 -2
- package/dist/rings.umd.js.map +3 -3
- package/dist/rings.umd.max.js +27 -4
- package/package.json +1 -1
package/dist/rings.es.js
CHANGED
|
@@ -7228,7 +7228,7 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
7228
7228
|
}
|
|
7229
7229
|
`;class L0{computeShader;worldPosMap;worldNormalMap;colorMap;shadowMap;pointShadowMap;lightingTexture;constructor(){let e=m.setting.gi;this.lightingTexture=new At(e.probeSourceTextureSize,e.probeSourceTextureSize,Y.rgba16float,!1,GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.STORAGE_BINDING)}create(e){let t=oe.getLightEntries(e.scene);this.computeShader=new fe(O0);let a=oe.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",oe.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",m.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=y.beginCommandEncoder(),r=m.setting.gi;this.computeShader.workerSizeX=r.probeSourceTextureSize/8,this.computeShader.workerSizeY=r.probeSourceTextureSize/8,this.computeShader.workerSizeZ=1,y.computeCommand(a,[this.computeShader]),y.endCommandEncoder(a)}}let _s=new $e("GIRenderStartEvent"),Ln=new $e("GIRenderCompleteEvent");class F2{count;complete}class G0 extends xa{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 Pn(.01,5e3),this.sizeW=t.probeSourceTextureSize,this.sizeH=t.probeSourceTextureSize,this.probeNext=t.probeSourceTextureSize/t.probeSize,this.initIrradianceMap(e),this.probeRenderResult=new F2;let a=new T0(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 L0,this.bouncePass=new P0(this.volume),this.irradianceComputePass=new N0(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=J.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=J.instance.getRenderNodes(e.scene,t);y.bindCamera(a,t);let n=Math.max(0,m.setting.render.drawOpMin),o=Math.min(m.setting.render.drawOpMax,i.opaqueList.length),l=J.instance.getRenderShaderCollect(e);for(const c of l){let f=c[1];for(const d of f){let h=d[1];if(!h.isDestroyed&&h.preInit(this.passType)){h.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))}J.instance.sky&&(J.instance.sky.preInit(this.passType)||J.instance.sky.nodeUpdate(e,this.passType,this.rendererPassState,null),J.instance.sky.renderPass2(e,this.passType,this.rendererPassState,null,a)),n=Math.max(0,m.setting.render.drawTrMin),o=Math.min(m.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(!m.setting.gi.enable)return;this.volume.updateOrientation(),this.volume.isVolumeFrameChange=!1,this.volume.uploadBuffer(),this.rendProbe(e);let a=this.probeRenderResult.count>0;(J.instance.state.giLightingChange||a||m.setting.gi.realTimeGI)&&(J.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(Ln)}startRenderGI(e=0){this.nextProbeIndex==-1&&e==0&&this.dispatchEvent(_s),this.nextProbeIndex=e,this.renderStatus="rendering"}startRenderCloudGI(){this.dispatchEvent(_s),this.nextProbeIndex=0,this.renderStatus="rendering",this.isRenderCloudGI=!0}rendProbe(e){let t=m.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=J.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 At(t.octRTMaxSize,t.octRTMaxSize,Y.rgba16float,!1,a),this.irradianceDepthMap.name="irradianceDepthMap",this.irradianceColorMap=new At(t.octRTMaxSize,t.octRTMaxSize,Y.rgba16float,!1,a),this.irradianceColorMap.name="irradianceColorMap"}writeToTexture(e,t,a,r){console.log(e.name);const i=k.device.createBuffer({size:t.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});k.device.queue.writeBuffer(i,0,t);const n=y.beginCommandEncoder();n.copyBufferToTexture({buffer:i,bytesPerRow:a*16},{texture:e.getGPUTexture()},{width:a,height:r,depthOrArrayLayers:1}),y.endCommandEncoder(n)}}class z0 extends xa{constructor(){super(),this.passType=H.UI}compute(e,t){let a=y.beginCommandEncoder(),r=y.lastRenderPassState.getLastRenderTexture(),i=ne.getGUIBufferFrame().getColorTexture();y.copyTexture(a,r,i),y.endCommandEncoder(a)}render(e,t,a,r=!1){this.renderContext.clean();let i=e.scene,n=e.camera;oe.updateCameraGroup(n),this.rendererPassState.camera3D=n;let o=J.instance.getRenderNodes(i,n);{this.renderContext.specialtRenderPass();let l=this.renderContext.encoder;o.opaqueList&&(y.bindCamera(l,n),this.drawNodes(e,this.renderContext,o.opaqueList,t,a))}{let l=this.renderContext.encoder;!r&&o.transparentList&&(y.bindCamera(l,n),this.drawNodes(e,this.renderContext,o.transparentList,t,a)),this.renderContext.endRenderPass()}}drawNodes(e,t,a,r,i){let n=J.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=m.setting.render.drawOpMin;o<Math.min(a.length,m.setting.render.drawOpMax);++o){let l=a[o];l.transform.enable&&l.enable&&(!l.hasMask(Be.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 J0 extends Q0{constructor(e){super(e)}start(){super.start();{let e=new A0,t=ne.getGBufferFrame(ne.colorPass_GBuffer);if(m.setting.render.zPrePass&&(t.zPreTexture=this.depthPassRenderer.rendererPassState.depthTexture),e.setRenderStates(t),m.setting.gi.enable){let a=oe.getLightEntries(this.view.scene);this.ddgiProbeRenderer=new G0(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=ne.getGUIBufferFrame(),t=new z0;t.setRenderStates(e),this.rendererMap.addRenderer(t)}m.setting.render.debug&&this.debug()}debug(){}}class W0{_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 Z0{_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 j0{_factor=1;constructor(){}getInterpolation(e){return Math.cos((e+1)*Math.PI)/2+.5}}class Y0{getInterpolation(e){return e}}class X0{getInterpolation(e){return 4.9*e+4.9*e}}class zt{constructor(){}static bounce(e){return e*e*9.8}getInterpolation(e){return e*=1.1226,e<.3535?zt.bounce(e):e<.7408?zt.bounce(e-.54719)+.7:e<.9644?zt.bounce(e-.8526)+.9:zt.bounce(e-1.0435)+.95}getBounceInterpolation(e){return e<.5?zt.bounce(e):zt.bounce(e-1)}geJumpUp(e,t){return t<.5?(t=t/.5,e*t-zt.bounce(t)):t<.8?(t=(t-.5)/(.8-.5),(e*t-zt.bounce(t))*.3):t<1?(t=(t-.8)/(1-.8),(e*t-zt.bounce(t))*.15):e*t-zt.bounce(t)}}class H0{_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 ns{_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*ns.a(e*2,this._tension):.5*(ns.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 K0{_cycles;constructor(e){this._cycles=e}getInterpolation(e){return Math.sin(2*this._cycles*Math.PI*e)}}class q0{_tension;constructor(){this._tension=2}getInterpolation(e){return e-=1,e*e*((this._tension+1)*e+this._tension)+1}}var Gn=(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))(Gn||{});class pr{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 pr;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=pr.interpolators;for(let a of t)a.complete?pr.remove(a,!0):a.tick(e)}static remove(e,t){let a=pr.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=W0,window.DecelerateInterpolator=Z0,window.AccelerateDecelerateInterpolator=j0,window.LinearInterpolator=Y0,window.BounceInterpolator=zt,window.AnticipateInterpolator=H0,window.AnticipateOvershootInterpolator=ns,window.CycleInterpolator=K0,window.OvershootInterpolator=q0,window.JumperInterpolator=X0,this._interpolator=new window[Gn[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,pr.remove(this)}}class Ct{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){
|
|
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
|
|
@@ -7762,7 +7762,7 @@ else if (typeof exports === 'object')
|
|
|
7762
7762
|
`;class Qf{compute;constructor(){this.compute=new fe(If)}generateBRDFLUTTexture(){let e=new Ae(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=y.beginCommandEncoder();return y.computeCommand(t,[this.compute]),y.endCommandEncoder(t),e}}class ri{id;guiTexture;uvRec=new te(0,0,1,1);uvBorder=new te(0,0,0,0);offsetSize=new te(0,0,4,4);borderSize=new te(0,0,0,0);trimSize=new K;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||m.res.defaultGUITexture}}class mr{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=m.res.whiteTexture,e.addressModeU="clamp-to-edge",e.addressModeV="clamp-to-edge",this.texture=e,mr._maxUid++,this._staticId=mr._maxUid,this.init()}init(){this.dynamicId=-1,this.width=this.texture.width,this.height=this.texture.height}}class tb{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 ii=new tb;class Tf{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 Mf{id=0;file=""}class Nf{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class za extends st{static format=ze.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 ri;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),ii.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 Tf;a.trim().split(t).forEach((i,n)=>{if(n<2)za.readLineProperty(i,r);else if(n<r.pages+2){let o=new Mf;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 Nf;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 m.res.loadTexture(r,null,!0);let i=m.res.getTexture(r),n=new mr(i);e.push(n)}za.parseSprite(e,t),t.fontChar[" "]||za.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ri,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),ii.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 ab(s,e){let t=new ri;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 mr(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function Vf(s,e,t){let a=new ri;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 Pf{_spriteMap=new Map;_spriteList=[];textureSize=new K;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=Vf(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 Of extends st{static format=ze.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await m.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 Pf(this._json.size),t=new mr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);m.res.addAtlas(this.baseUrl,e),this.data=e}}var Lt=Uint8Array,si=Uint16Array,rb=Int32Array,Lf=new Lt([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]),Gf=new Lt([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]),ib=new Lt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),zf=function(s,e){for(var t=new si(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new rb(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}},Jf=zf(Lf,2),Wf=Jf.b,sb=Jf.r;Wf[28]=258,sb[258]=28;for(var nb=zf(Gf,0),ob=nb.b,uo=new si(32768),Te=0;Te<32768;++Te){var ir=(Te&43690)>>1|(Te&21845)<<1;ir=(ir&52428)>>2|(ir&13107)<<2,ir=(ir&61680)>>4|(ir&3855)<<4,uo[Te]=((ir&65280)>>8|(ir&255)<<8)>>1}for(var Fi=(function(s,e,t){for(var a=s.length,r=0,i=new si(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new si(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new si(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],d=n[s[r]-1]++<<f,h=d|(1<<f)-1;d<=h;++d)o[uo[d]>>l]=c}else for(o=new si(a),r=0;r<a;++r)s[r]&&(o[r]=uo[n[s[r]-1]++]>>15-s[r]);return o}),ki=new Lt(288),Te=0;Te<144;++Te)ki[Te]=8;for(var Te=144;Te<256;++Te)ki[Te]=9;for(var Te=256;Te<280;++Te)ki[Te]=7;for(var Te=280;Te<288;++Te)ki[Te]=8;for(var Zf=new Lt(32),Te=0;Te<32;++Te)Zf[Te]=5;var lb=Fi(ki,9,1),cb=Fi(Zf,5,1),bo=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},sa=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},go=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},fb=function(s){return(s+7)/8|0},po=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new Lt(s.subarray(e,t))},db=["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"],Ht=function(s,e,t){var a=new Error(e||db[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,Ht),!t)throw a;return a},hb=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new Lt(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new Lt(r*3));var c=function(Ft){var kt=t.length;if(Ft>kt){var Nt=new Lt(Math.max(kt*2,Ft));Nt.set(t),t=Nt}},f=e.f||0,d=e.p||0,h=e.b||0,b=e.l,p=e.d,g=e.m,A=e.n,D=r*8;do{if(!b){f=sa(s,d,1);var _=sa(s,d+1,3);if(d+=3,_)if(_==1)b=lb,p=cb,g=9,A=5;else if(_==2){var C=sa(s,d,31)+257,F=sa(s,d+10,15)+4,w=C+sa(s,d+5,31)+1;d+=14;for(var S=new Lt(w),M=new Lt(19),T=0;T<F;++T)M[ib[T]]=sa(s,d+T*3,7);d+=F*3;for(var Q=bo(M),L=(1<<Q)-1,X=Fi(M,Q,1),T=0;T<w;){var ie=X[sa(s,d,L)];d+=ie&15;var U=ie>>4;if(U<16)S[T++]=U;else{var q=0,be=0;for(U==16?(be=3+sa(s,d,3),d+=2,q=S[T-1]):U==17?(be=3+sa(s,d,7),d+=3):U==18&&(be=11+sa(s,d,127),d+=7);be--;)S[T++]=q}}var Ue=S.subarray(0,C),Z=S.subarray(C);g=bo(Ue),A=bo(Z),b=Fi(Ue,g,1),p=Fi(Z,A,1)}else Ht(1);else{var U=fb(d)+4,v=s[U-4]|s[U-3]<<8,x=U+v;if(x>r){l&&Ht(0);break}o&&c(h+v),t.set(s.subarray(U,x),h),e.b=h+=v,e.p=d=x*8,e.f=f;continue}if(d>D){l&&Ht(0);break}}o&&c(h+131072);for(var de=(1<<g)-1,ce=(1<<A)-1,De=d;;De=d){var q=b[go(s,d)&de],_e=q>>4;if(d+=q&15,d>D){l&&Ht(0);break}if(q||Ht(2),_e<256)t[h++]=_e;else if(_e==256){De=d,b=null;break}else{var Ne=_e-254;if(_e>264){var T=_e-257,we=Lf[T];Ne=sa(s,d,(1<<we)-1)+Wf[T],d+=we}var Ce=p[go(s,d)&ce],Me=Ce>>4;Ce||Ht(3),d+=Ce&15;var Z=ob[Me];if(Me>3){var we=Gf[Me];Z+=go(s,d)&(1<<we)-1,d+=we}if(d>D){l&&Ht(0);break}o&&c(h+131072);var ct=h+Ne;if(h<Z){var ga=i-Z,Mt=Math.min(Z,ct);for(ga+h<0&&Ht(3);h<Mt;++h)t[h]=a[ga+h]}for(;h<ct;++h)t[h]=t[h-Z]}}e.l=b,e.p=De,e.b=h,e.f=f,b&&(f=1,e.m=g,e.d=p,e.n=A)}while(!f);return h!=t.length&&n?po(t,0,h):t.subarray(0,h)},ub=new Lt(0),ya=function(s,e){return s[e]|s[e+1]<<8},na=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},mo=function(s,e){return na(s,e)+na(s,e+4)*4294967296};function bb(s,e){return hb(s,{i:2},e&&e.out,e&&e.dictionary)}var Ao=typeof TextDecoder<"u"&&new TextDecoder,gb=0;try{Ao.decode(ub,{stream:!0}),gb=1}catch{}var pb=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:po(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 jf(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(Ao)return Ao.decode(s);var r=pb(s),i=r.s,t=r.r;return t.length&&Ht(8),i}}var mb=function(s,e){return e+30+ya(s,e+26)+ya(s,e+28)},Ab=function(s,e,t){var a=ya(s,e+28),r=jf(s.subarray(e+46,e+46+a),!(ya(s,e+8)&2048)),i=e+46+a,n=na(s,e+20),o=t&&n==4294967295?Db(s,i):[n,na(s,e+24),na(s,e+42)],l=o[0],c=o[1],f=o[2];return[ya(s,e+10),l,c,r,i+ya(s,e+30)+ya(s,e+32),f]},Db=function(s,e){for(;ya(s,e)!=1;e+=4+ya(s,e+2));return[mo(s,e+12),mo(s,e+4),mo(s,e+20)]};function _b(s,e){for(var t={},a=s.length-22;na(s,a)!=101010256;--a)(!a||s.length-a>65558)&&Ht(13);var r=ya(s,a+8);if(!r)return{};var i=na(s,a+16),n=i==4294967295||r==65535;if(n){var o=na(s,a-12);n=na(s,o)==101075792,n&&(r=na(s,o+32),i=na(s,o+48))}for(var l=0;l<r;++l){var c=Ab(s,i,n),f=c[0],d=c[1],h=c[2],b=c[3],p=c[4],g=c[5],A=mb(s,g);i=p,f?f==8?t[b]=bb(s.subarray(A,A+d),{out:new Lt(h)}):Ht(14,"unknown compression type "+f):t[b]=po(s,A,A+d)}return t}class nt extends mt{constructor(){super(),this.shader=new Oi,this.baseMap=m.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 Rr extends Ee{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),d=new Uint16Array(i*r*2*3),h=0,b=0,p=0;for(t=0;t<=r;++t){var g=Math.PI*t/r,A=n*Math.cos(g),D=n*Math.sin(g);for(e=0;e<=i;++e){var _=2*Math.PI*e/i,U=D*Math.cos(_),v=D*Math.sin(_),x=1/Math.sqrt(U*U+A*A+v*v);if(l[h++]=U,l[h++]=A,l[h++]=v,c[b++]=U*x,c[b++]=A*x,c[b++]=v*x,f[p++]=e/i,f[p++]=t/r,e>0&&t>0){var C=(i+1)*t+e,F=(i+1)*t+e-1,w=(i+1)*(t-1)+e-1,S=(i+1)*(t-1)+e;t==r?(d[a++]=C,d[a++]=w,d[a++]=S):t==1?(d[a++]=C,d[a++]=F,d[a++]=w):(d[a++]=C,d[a++]=F,d[a++]=w,d[a++]=C,d[a++]=w,d[a++]=S)}}}this.setIndices(d),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:d.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new ge(u.ZERO,new u(this.radius*2,this.radius*2,this.radius*2))}}class os extends ee{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 u(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),os.register3DRepresentation)this.marker=os.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new ee;const e=this.marker.addComponent($);e.geometry=new Rr(.1,32,16),e.material=new nt,e.material.baseColor=this.positionValid?new P(0,1,0,1):new P(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class ls extends ee{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new os(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),ls.register3DRepresentation?(this.line=ls.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new P(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Ee,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 ee,o=n.addComponent($),l=new nt;return l.topology="line-list",l.baseColor=t,l.blendMode=ae.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class Yf extends st{static format=ze.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=_b(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(jf(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 ls(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 Xf{_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 pt().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 pt;r==".gltf"?a=await i.load(e,Dt,t):a=await i.load(e,eo,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 pt;r==".obj"&&(a=await i.load(e,gf,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 pt().load(e,co,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 pt().load(e,Rf,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 Va;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(d=>{l.push(d),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 ro;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 xs;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 Cs;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 to;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 to;return await a.loadStd(e),a}async loadJSON(e,t){return await new pt().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new pt().load(e,za,t,a),n=i.data;return ii.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new pt().load(e,Of,t,e)).data}async loadKMZ(e,t){return(await new pt().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 d=new wn;return d.name=o,d.create(16,16,f,!0),o&&this.addTexture(o,d),d}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 Qf().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new xs,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 mr(this.whiteTexture),this.defaultGUISprite=new ri(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new ka}}class Hf extends Pe{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=m.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=m.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;m.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Bb="1.0.23";class m{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 k.presentationSize}static get aspect(){return k.aspect}static get width(){return k.windowWidth}static get height(){return k.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 P(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",Bb),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await pe.init(E.allocCount,this.setting.doublePrecision),await k.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,ne.getGBufferFrame(ne.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),z.init(),Ma.init(),oe.init(),vt.init(),It.init(),this.res=new Xf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new nl,this.inputSystem.initCanvas(k.canvas)}static startRenderJob(e){let t=new J0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Hf).addPost(On),(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){Fe.delta=e-Fe.time,Fe.time=e,Fe.frame+=1,pr.tick(Fe.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=k.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of xe.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}let r=k.device.createCommandEncoder();for(const n of xe.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o,r)}}k.device.queue.submit([r.finish()]);for(const n of xe.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}for(const n of xe.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];o&&f.enable&&d(o)}}this._renderLoop&&await this._renderLoop(),pe.updateAllContinueTransform(0,E.useCount,16),oe.modelMatrixBindGroup.writeBuffer(E.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of xe.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}this._lateRender&&await this._lateRender()}}let Ss=`
|
|
7765
|
+
`}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await m.res.loadTexture(r,null,!0);let i=m.res.getTexture(r),n=new mr(i);e.push(n)}za.parseSprite(e,t),t.fontChar[" "]||za.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ri,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),ii.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 ab(s,e){let t=new ri;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 mr(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function Vf(s,e,t){let a=new ri;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 Pf{_spriteMap=new Map;_spriteList=[];textureSize=new K;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=Vf(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 Of extends st{static format=ze.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await m.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 Pf(this._json.size),t=new mr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);m.res.addAtlas(this.baseUrl,e),this.data=e}}var Lt=Uint8Array,si=Uint16Array,rb=Int32Array,Lf=new Lt([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]),Gf=new Lt([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]),ib=new Lt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),zf=function(s,e){for(var t=new si(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new rb(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}},Jf=zf(Lf,2),Wf=Jf.b,sb=Jf.r;Wf[28]=258,sb[258]=28;for(var nb=zf(Gf,0),ob=nb.b,uo=new si(32768),Te=0;Te<32768;++Te){var ir=(Te&43690)>>1|(Te&21845)<<1;ir=(ir&52428)>>2|(ir&13107)<<2,ir=(ir&61680)>>4|(ir&3855)<<4,uo[Te]=((ir&65280)>>8|(ir&255)<<8)>>1}for(var Fi=(function(s,e,t){for(var a=s.length,r=0,i=new si(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new si(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new si(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],d=n[s[r]-1]++<<f,h=d|(1<<f)-1;d<=h;++d)o[uo[d]>>l]=c}else for(o=new si(a),r=0;r<a;++r)s[r]&&(o[r]=uo[n[s[r]-1]++]>>15-s[r]);return o}),ki=new Lt(288),Te=0;Te<144;++Te)ki[Te]=8;for(var Te=144;Te<256;++Te)ki[Te]=9;for(var Te=256;Te<280;++Te)ki[Te]=7;for(var Te=280;Te<288;++Te)ki[Te]=8;for(var Zf=new Lt(32),Te=0;Te<32;++Te)Zf[Te]=5;var lb=Fi(ki,9,1),cb=Fi(Zf,5,1),bo=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},sa=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},go=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},fb=function(s){return(s+7)/8|0},po=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new Lt(s.subarray(e,t))},db=["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"],Ht=function(s,e,t){var a=new Error(e||db[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,Ht),!t)throw a;return a},hb=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new Lt(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new Lt(r*3));var c=function(Ft){var kt=t.length;if(Ft>kt){var Nt=new Lt(Math.max(kt*2,Ft));Nt.set(t),t=Nt}},f=e.f||0,d=e.p||0,h=e.b||0,b=e.l,p=e.d,g=e.m,A=e.n,D=r*8;do{if(!b){f=sa(s,d,1);var _=sa(s,d+1,3);if(d+=3,_)if(_==1)b=lb,p=cb,g=9,A=5;else if(_==2){var C=sa(s,d,31)+257,F=sa(s,d+10,15)+4,w=C+sa(s,d+5,31)+1;d+=14;for(var S=new Lt(w),M=new Lt(19),T=0;T<F;++T)M[ib[T]]=sa(s,d+T*3,7);d+=F*3;for(var Q=bo(M),L=(1<<Q)-1,X=Fi(M,Q,1),T=0;T<w;){var ie=X[sa(s,d,L)];d+=ie&15;var U=ie>>4;if(U<16)S[T++]=U;else{var q=0,be=0;for(U==16?(be=3+sa(s,d,3),d+=2,q=S[T-1]):U==17?(be=3+sa(s,d,7),d+=3):U==18&&(be=11+sa(s,d,127),d+=7);be--;)S[T++]=q}}var Ue=S.subarray(0,C),Z=S.subarray(C);g=bo(Ue),A=bo(Z),b=Fi(Ue,g,1),p=Fi(Z,A,1)}else Ht(1);else{var U=fb(d)+4,v=s[U-4]|s[U-3]<<8,x=U+v;if(x>r){l&&Ht(0);break}o&&c(h+v),t.set(s.subarray(U,x),h),e.b=h+=v,e.p=d=x*8,e.f=f;continue}if(d>D){l&&Ht(0);break}}o&&c(h+131072);for(var de=(1<<g)-1,ce=(1<<A)-1,De=d;;De=d){var q=b[go(s,d)&de],_e=q>>4;if(d+=q&15,d>D){l&&Ht(0);break}if(q||Ht(2),_e<256)t[h++]=_e;else if(_e==256){De=d,b=null;break}else{var Ne=_e-254;if(_e>264){var T=_e-257,we=Lf[T];Ne=sa(s,d,(1<<we)-1)+Wf[T],d+=we}var Ce=p[go(s,d)&ce],Me=Ce>>4;Ce||Ht(3),d+=Ce&15;var Z=ob[Me];if(Me>3){var we=Gf[Me];Z+=go(s,d)&(1<<we)-1,d+=we}if(d>D){l&&Ht(0);break}o&&c(h+131072);var ct=h+Ne;if(h<Z){var ga=i-Z,Mt=Math.min(Z,ct);for(ga+h<0&&Ht(3);h<Mt;++h)t[h]=a[ga+h]}for(;h<ct;++h)t[h]=t[h-Z]}}e.l=b,e.p=De,e.b=h,e.f=f,b&&(f=1,e.m=g,e.d=p,e.n=A)}while(!f);return h!=t.length&&n?po(t,0,h):t.subarray(0,h)},ub=new Lt(0),ya=function(s,e){return s[e]|s[e+1]<<8},na=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},mo=function(s,e){return na(s,e)+na(s,e+4)*4294967296};function bb(s,e){return hb(s,{i:2},e&&e.out,e&&e.dictionary)}var Ao=typeof TextDecoder<"u"&&new TextDecoder,gb=0;try{Ao.decode(ub,{stream:!0}),gb=1}catch{}var pb=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:po(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 jf(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(Ao)return Ao.decode(s);var r=pb(s),i=r.s,t=r.r;return t.length&&Ht(8),i}}var mb=function(s,e){return e+30+ya(s,e+26)+ya(s,e+28)},Ab=function(s,e,t){var a=ya(s,e+28),r=jf(s.subarray(e+46,e+46+a),!(ya(s,e+8)&2048)),i=e+46+a,n=na(s,e+20),o=t&&n==4294967295?Db(s,i):[n,na(s,e+24),na(s,e+42)],l=o[0],c=o[1],f=o[2];return[ya(s,e+10),l,c,r,i+ya(s,e+30)+ya(s,e+32),f]},Db=function(s,e){for(;ya(s,e)!=1;e+=4+ya(s,e+2));return[mo(s,e+12),mo(s,e+4),mo(s,e+20)]};function _b(s,e){for(var t={},a=s.length-22;na(s,a)!=101010256;--a)(!a||s.length-a>65558)&&Ht(13);var r=ya(s,a+8);if(!r)return{};var i=na(s,a+16),n=i==4294967295||r==65535;if(n){var o=na(s,a-12);n=na(s,o)==101075792,n&&(r=na(s,o+32),i=na(s,o+48))}for(var l=0;l<r;++l){var c=Ab(s,i,n),f=c[0],d=c[1],h=c[2],b=c[3],p=c[4],g=c[5],A=mb(s,g);i=p,f?f==8?t[b]=bb(s.subarray(A,A+d),{out:new Lt(h)}):Ht(14,"unknown compression type "+f):t[b]=po(s,A,A+d)}return t}class nt extends mt{constructor(){super(),this.shader=new Oi,this.baseMap=m.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 Rr extends Ee{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),d=new Uint16Array(i*r*2*3),h=0,b=0,p=0;for(t=0;t<=r;++t){var g=Math.PI*t/r,A=n*Math.cos(g),D=n*Math.sin(g);for(e=0;e<=i;++e){var _=2*Math.PI*e/i,U=D*Math.cos(_),v=D*Math.sin(_),x=1/Math.sqrt(U*U+A*A+v*v);if(l[h++]=U,l[h++]=A,l[h++]=v,c[b++]=U*x,c[b++]=A*x,c[b++]=v*x,f[p++]=e/i,f[p++]=t/r,e>0&&t>0){var C=(i+1)*t+e,F=(i+1)*t+e-1,w=(i+1)*(t-1)+e-1,S=(i+1)*(t-1)+e;t==r?(d[a++]=C,d[a++]=w,d[a++]=S):t==1?(d[a++]=C,d[a++]=F,d[a++]=w):(d[a++]=C,d[a++]=F,d[a++]=w,d[a++]=C,d[a++]=w,d[a++]=S)}}}this.setIndices(d),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:d.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new ge(u.ZERO,new u(this.radius*2,this.radius*2,this.radius*2))}}class os extends ee{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 u(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),os.register3DRepresentation)this.marker=os.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new ee;const e=this.marker.addComponent($);e.geometry=new Rr(.1,32,16),e.material=new nt,e.material.baseColor=this.positionValid?new P(0,1,0,1):new P(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class ls extends ee{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new os(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),ls.register3DRepresentation?(this.line=ls.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new P(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Ee,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 ee,o=n.addComponent($),l=new nt;return l.topology="line-list",l.baseColor=t,l.blendMode=ae.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class Yf extends st{static format=ze.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=_b(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(jf(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 ls(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 Xf{_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 pt().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 pt;r==".gltf"?a=await i.load(e,Dt,t):a=await i.load(e,eo,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 pt;r==".obj"&&(a=await i.load(e,gf,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 pt().load(e,co,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 pt().load(e,Rf,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 Va;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(d=>{l.push(d),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 ro;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 xs;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 Cs;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 to;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 to;return await a.loadStd(e),a}async loadJSON(e,t){return await new pt().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new pt().load(e,za,t,a),n=i.data;return ii.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new pt().load(e,Of,t,e)).data}async loadKMZ(e,t){return(await new pt().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 d=new wn;return d.name=o,d.create(16,16,f,!0),o&&this.addTexture(o,d),d}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 Qf().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new xs,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 mr(this.whiteTexture),this.defaultGUISprite=new ri(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new ka}}class Hf extends Pe{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=m.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=m.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;m.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Bb="1.0.24";class m{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 k.presentationSize}static get aspect(){return k.aspect}static get width(){return k.windowWidth}static get height(){return k.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 P(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",Bb),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await pe.init(E.allocCount,this.setting.doublePrecision),await k.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,ne.getGBufferFrame(ne.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),z.init(),Ma.init(),oe.init(),vt.init(),It.init(),this.res=new Xf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new nl,this.inputSystem.initCanvas(k.canvas)}static startRenderJob(e){let t=new J0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Hf).addPost(On),(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){Fe.delta=e-Fe.time,Fe.time=e,Fe.frame+=1,pr.tick(Fe.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=k.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of xe.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}let r=k.device.createCommandEncoder();for(const n of xe.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o,r)}}k.device.queue.submit([r.finish()]);for(const n of xe.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}for(const n of xe.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];o&&f.enable&&d(o)}}this._renderLoop&&await this._renderLoop(),pe.updateAllContinueTransform(0,E.useCount,16),oe.modelMatrixBindGroup.writeBuffer(E.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of xe.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}this._lateRender&&await this._lateRender()}}let Ss=`
|
|
7766
7766
|
struct BloomCfg{
|
|
7767
7767
|
downSampleStep: f32,
|
|
7768
7768
|
downSampleBlurSize: f32,
|