@rings-webgpu/core 1.0.43 → 1.0.44
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 -3
- package/dist/rings.es.js.map +2 -2
- package/dist/rings.es.max.js +2 -3
- package/dist/rings.umd.js +2 -3
- package/dist/rings.umd.js.map +2 -2
- package/dist/rings.umd.max.js +2 -3
- package/package.json +1 -1
package/dist/rings.es.max.js
CHANGED
|
@@ -25419,7 +25419,6 @@ const PointCloud_FS = (
|
|
|
25419
25419
|
}
|
|
25420
25420
|
|
|
25421
25421
|
o.color = vColor;
|
|
25422
|
-
o.gBuffer = vec4f(0.0);
|
|
25423
25422
|
return o;
|
|
25424
25423
|
}
|
|
25425
25424
|
`
|
|
@@ -25446,7 +25445,7 @@ let PointCloudShader = class extends Shader {
|
|
|
25446
25445
|
pass.cullMode = GPUCullMode.none;
|
|
25447
25446
|
pass.shaderState.transparent = false;
|
|
25448
25447
|
pass.shaderState.blendMode = BlendMode.NORMAL;
|
|
25449
|
-
pass.shaderState.writeMasks = [15,
|
|
25448
|
+
pass.shaderState.writeMasks = [15, 0];
|
|
25450
25449
|
pass.shaderState.castReflection = false;
|
|
25451
25450
|
this.addRenderPass(pass);
|
|
25452
25451
|
this.setDefault();
|
|
@@ -42364,7 +42363,7 @@ class PostProcessingComponent extends ComponentBase {
|
|
|
42364
42363
|
}
|
|
42365
42364
|
}
|
|
42366
42365
|
|
|
42367
|
-
const version = "1.0.
|
|
42366
|
+
const version = "1.0.43";
|
|
42368
42367
|
|
|
42369
42368
|
class Engine3D {
|
|
42370
42369
|
/**
|
package/dist/rings.umd.js
CHANGED
|
@@ -6143,10 +6143,9 @@ struct InstanceData {
|
|
|
6143
6143
|
}
|
|
6144
6144
|
|
|
6145
6145
|
o.color = vColor;
|
|
6146
|
-
o.gBuffer = vec4f(0.0);
|
|
6147
6146
|
return o;
|
|
6148
6147
|
}
|
|
6149
|
-
`;var p2=Object.getOwnPropertyDescriptor,A2=(n,e,t,a)=>{for(var r=a>1?void 0:a?p2(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.PointCloudShader=class extends gt{constructor(){super(),X.register("pointcloud_vs_dc",t0),X.register("pointcloud_fs_dc",a0);const e=new qe("pointcloud_vs_dc","pointcloud_fs_dc");e.passType=de.COLOR,e.setShaderEntry("VertMain","FragMain"),e.topology=ls.triangle_list,e.depthWriteEnabled=!0,e.cullMode=Vt.none,e.shaderState.transparent=!1,e.shaderState.blendMode=Ae.NORMAL,e.shaderState.writeMasks=[15,15],e.shaderState.castReflection=!1,this.addRenderPass(e),this.setDefault()}setDefault(){const e=this.getDefaultColorShader(),t=new T;e.setUniform("modelMatrix",t.rawData),e.setUniformArray("tex_params",new Float32Array([0,0,0,4])),e.setUniformArray("pointParams",new Float32Array([0,0,0,128]))}},d.PointCloudShader=A2([Ta(d.PointCloudShader,"PointCloudShader")],d.PointCloudShader);class r0 extends Dt{_texParams=new Float32Array([0,0,0,4]);_pointParamsArray=new Float32Array([0,0,0,128]);constructor(){super(),this.shader=new d.PointCloudShader}setPointTextures(e,t,a,r){const i=this.shader.getDefaultColorShader();if(!i.getUniform("modelMatrix")){const s=new T;i.setUniform("modelMatrix",s.rawData)}i.setTexture("pointColor",t),i.setTexture("pointPosition",e),this._texParams[0]=a[0],this._texParams[1]=a[1],this._texParams[2]=a[2],this._texParams[3]=a[3],i.setUniformArray("tex_params",this._texParams),i.setUniformArray("pointParams",this._pointParamsArray),r&&i.setTexture("pointOrder",r),i.shaderState.depthCompare=it.less}setTransformMatrix(e){this.shader.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}setPointSize(e){this._texParams[3]=Math.max(.1,e),this.shader.getDefaultColorShader().setUniformArray("tex_params",this._texParams)}setPointShape(e){this._pointParamsArray[0]=e==="circle"?1:0,this.shader.getDefaultColorShader().setUniformArray("pointParams",this._pointParamsArray)}enableDebugFullScreen(e){this._pointParamsArray[1]=e?1:0,this.shader.getDefaultColorShader().setUniformArray("pointParams",this._pointParamsArray)}setBatchSize(e){this._pointParamsArray[3]=Math.max(1,e|0),this.shader.getDefaultColorShader().setUniformArray("pointParams",this._pointParamsArray)}}class Fn extends Ve{batchSize;constructor(e=128){super(),this.batchSize=e;const t=new Float32Array(12*e);for(let r=0;r<e;++r){const i=r*12;t.set([-1,-1,r,1,-1,r,1,1,r,-1,1,r],i)}const a=new Uint32Array(6*e);for(let r=0;r<e;++r){const i=r*4,s=r*6;a.set([0+i,1+i,2+i,0+i,2+i,3+i],s)}this.setAttribute(G.position,t),this.setIndices(a),this.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:t.length/3,firstStart:0,index:0,topology:0})}}class i0 extends dt{create(e,t,a,r=!0){let i=I.device;const s=e*4*4;this.format=le.rgba32float,this.createTextureDescriptor(e,t,1,this.format);const l=i.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(l,0,a.buffer);const c=E.beginCommandEncoder();return c.copyBufferToTexture({buffer:l,bytesPerRow:s},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),E.endCommandEncoder(c),r&&(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float"),this.gpuSampler=i.createSampler({}),this}fromBuffer(e,t,a){let r=I.device;const i=e*4*4;this.format=le.rgba32float,this.mipmapCount=1,this.createTextureDescriptor(e,t,this.mipmapCount,this.format);const s=E.beginCommandEncoder();return s.copyBufferToTexture({buffer:a,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),E.endCommandEncoder(s),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=r.createSampler({}),this}}var D2=Object.getOwnPropertyDescriptor,_2=(n,e,t,a)=>{for(var r=a>1?void 0:a?D2(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.PointCloudRenderer=class extends Ba{count=0;size=new fe;pointColor;pointPosition;pointOrder;texParams;pointCloudMaterial;_positions;get positions(){return this._positions}_colors;_orderData;_fullCount=0;get fullCount(){return this._fullCount}_batchSize=128;instanceCount=0;_texturesInitialized=!1;_debugFullScreen=!1;_centerOffset=new g;get centerOffset(){return this._centerOffset}constructor(){super()}initFromData(e,t,a){if(!e||!t||a<=0){console.error("PointCloudRenderer: Invalid input data");return}if(e.length<a*3){console.error("PointCloudRenderer: Positions array too small");return}if(t.length<a*4){console.error("PointCloudRenderer: Colors array too small");return}this.count=a,this._fullCount=a,this.size=this.evalTextureSize(a),this._positions=e,this._colors=t,this.centerizePositions(),this.buildPositionTexture(),this.buildColorTexture(),this.texParams=new Float32Array([this.count,this.size.x,this.count,4]),this.buildOrderTexture(),this.pointCloudMaterial=new r0,this.geometry=new Fn(this._batchSize),this.materials=[this.pointCloudMaterial],this.instanceCount=Math.ceil(this.count/this._batchSize)}evalTextureSize(e){let t=Math.ceil(Math.sqrt(e));const a=64;t=Math.ceil(t/a)*a;const r=Math.ceil(e/t);return new fe(t,r)}centerizePositions(){if(this.count===0)return;let e=0,t=0,a=0;for(let o=0;o<this.count;o++){const l=o*3;e+=this._positions[l+0],t+=this._positions[l+1],a+=this._positions[l+2]}const r=e/this.count,i=t/this.count,s=a/this.count;this._centerOffset.set(r,i,s);for(let o=0;o<this.count;o++){const l=o*3;this._positions[l+0]-=r,this._positions[l+1]-=i,this._positions[l+2]-=s}this.object3D.localPosition=this._centerOffset}buildPositionTexture(){const e=this.size.x|0,t=this.size.y|0,a=this.count,r=new Float32Array(e*t*4);for(let i=0;i<a;i++){const s=i*4,o=i*3;r[s+0]=this._positions[o+0],r[s+1]=this._positions[o+1],r[s+2]=this._positions[o+2],r[s+3]=0}if(a<e*t){const i=(a-1)*4;for(let s=a;s<e*t;s++){const o=s*4;r[o+0]=r[i+0],r[o+1]=r[i+1],r[o+2]=r[i+2],r[o+3]=0}}this.pointPosition=new i0().create(e,t,r),this.pointPosition.name="pointPosition",this.pointPosition.minFilter="nearest",this.pointPosition.magFilter="nearest",this.pointPosition.addressModeU="clamp-to-edge",this.pointPosition.addressModeV="clamp-to-edge"}buildColorTexture(){const e=this.size.x|0,t=this.size.y|0,a=this.count,r=new Uint8Array(e*t*4);for(let i=0;i<a;i++){const s=i*4,o=i*4;r[s+0]=this._colors[o+0],r[s+1]=this._colors[o+1],r[s+2]=this._colors[o+2],r[s+3]=this._colors[o+3]}if(a<e*t){const i=(a-1)*4;for(let s=a;s<e*t;s++){const o=s*4;r[o+0]=r[i+0],r[o+1]=r[i+1],r[o+2]=r[i+2],r[o+3]=r[i+3]}}this.pointColor=new Si().create(e,t,r,!1),this.pointColor.name="pointColor",this.pointColor.minFilter="nearest",this.pointColor.magFilter="nearest",this.pointColor.mipmapFilter="nearest",this.pointColor.addressModeU="clamp-to-edge",this.pointColor.addressModeV="clamp-to-edge"}buildOrderTexture(){const e=this.size.x*this.size.y;this._orderData=new Uint32Array(e);for(let t=0;t<e;t++)this._orderData[t]=t<this.count?t:this.count>0?this.count-1:0;this.pointOrder=new Ds().create(this.size.x,this.size.y,this._orderData),this.pointOrder.name="pointOrder",this.pointOrder.minFilter="nearest",this.pointOrder.magFilter="nearest",this.pointOrder.addressModeU="clamp-to-edge",this.pointOrder.addressModeV="clamp-to-edge"}nodeUpdate(e,t,a,r){const i=this.object3D.transform.worldMatrix;this.pointCloudMaterial.setTransformMatrix(i),this._texturesInitialized||(this.pointCloudMaterial.setPointTextures(this.pointPosition,this.pointColor,this.texParams,this.pointOrder),this.pointCloudMaterial.setBatchSize(this._batchSize),this.pointCloudMaterial.setPointSize(this.texParams[3]),this.pointCloudMaterial.enableDebugFullScreen(this._debugFullScreen),this._texturesInitialized=!0),super.nodeUpdate(e,t,a,r)}renderPass(e,t,a){const r=a.encoder;for(let i of this.materials){const s=i.getPass(t);if(!(!s||s.length===0))for(const o of s){if(!o.pipeline)continue;o.apply(this.geometry,a.rendererPassState||a),E.bindPipeline(r,o),E.bindGeometryBuffer(r,this.geometry);const c=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?E.drawIndexed(r,c.indexCount,this.instanceCount,c.indexStart,0,0):E.drawIndexed(r,c.indexCount,1,c.indexStart,0,0)}}}setPointSize(e){this.texParams[3]=Math.max(.1,e),this.pointCloudMaterial&&this.pointCloudMaterial.setPointSize(e)}setPointShape(e){this.pointCloudMaterial&&this.pointCloudMaterial.setPointShape(e)}enableDebugFullScreen(e){this._debugFullScreen=e,this.pointCloudMaterial&&this.pointCloudMaterial.enableDebugFullScreen(e)}setBatchSize(e){if(this._batchSize=Math.max(1,e|0),this.geometry){const t=this.geometry;xe.getInstance().detached(t,this),xe.getInstance().hasReference(t)||t.destroy(),this.geometry=new Fn(this._batchSize)}this.pointCloudMaterial&&(this.pointCloudMaterial.setBatchSize(this._batchSize),this.pointCloudMaterial.enableDebugFullScreen(this._debugFullScreen)),this.instanceCount=Math.ceil(this.count/this._batchSize)}destroy(e){this.pointColor&&(this.pointColor.destroy(e),this.pointColor=null),this.pointPosition&&(this.pointPosition.destroy(e),this.pointPosition=null),this.pointOrder&&(this.pointOrder.destroy(e),this.pointOrder=null),this._positions=null,this._colors=null,this._orderData=null,this.texParams=null,super.destroy(e)}},d.PointCloudRenderer=_2([Nt(d.PointCloudRenderer,"PointCloudRenderer")],d.PointCloudRenderer);class kn{static maxVector=new g(Number.MAX_VALUE*.1,Number.MAX_VALUE*.1,Number.MAX_VALUE*.1);static minVector=this.maxVector.clone().multiplyScalar(-1);static genMeshMaxVector=g.ZERO.clone();static genMeshMinVector=g.ZERO.clone();static genMeshVectorList8=[new g,new g,new g,new g,new g,new g,new g,new g];static genPointCloudBounds(e,t){t||=new Ce(g.ZERO,g.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let a=e.getComponents(d.PointCloudRenderer);if(!a)return console.warn("genPointCloudBounds: No PointCloudRenderer found on object"),t;for(const r of a){const i=r.positions,s=r.fullCount;if(!i||s===0){console.warn("genPointCloudBounds: No position data available");continue}const o=r.object3D.transform.worldMatrix,l=new g;for(let c=0;c<s;c++){const f=c*3;l.set(i[f+0],i[f+1],i[f+2]),o.transformPoint(l,l),t.expandByPoint(l)}}return t}static genGSplatBounds(e,t){t||=new Ce(g.ZERO,g.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let a=e.getComponents(d.GSplatRenderer);if(!a)return console.warn("genGSplatBounds: No GSplatRenderer found on object"),t;for(const r of a){const i=r.positions,s=r.fullCount;if(!i||s===0)return console.warn("genGSplatBounds: No position data available"),t;const o=r.object3D.transform.worldMatrix,l=new g;for(let c=0;c<s;c++){const f=c*3;l.set(i[f+0],i[f+1],i[f+2]),o.transformPoint(l,l),t.expandByPoint(l)}t.setFromMinMax(t.min,t.max)}return t}static genMeshBounds(e,t){let a=this.genMeshMinVector,r=this.genMeshMaxVector,i=this.genMeshVectorList8;t||=new Ce(g.ZERO,g.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let s=e.getComponents(d.MeshRenderer);for(const o of s)if(o&&o.geometry){let l=o.object3D.transform.worldMatrix;a.copy(o.geometry.bounds.min),r.copy(o.geometry.bounds.max),i[0].set(a.x,a.y,a.z),i[1].set(a.x,a.y,r.z),i[2].set(a.x,r.y,a.z),i[3].set(a.x,r.y,r.z),i[4].set(r.x,a.y,a.z),i[5].set(r.x,a.y,r.z),i[6].set(r.x,r.y,a.z),i[7].set(r.x,r.y,r.z);for(const c of i)l.transformPoint(c,c),t.expandByPoint(c)}return r.copyFrom(t.max),a.copyFrom(t.min),t.setFromMinMax(a,r),t}static transformBound(e,t,a){let r=this.genMeshMinVector.copyFrom(t.min),i=this.genMeshMaxVector.copyFrom(t.max),s=this.genMeshVectorList8;a||=new Ce(g.ZERO,g.ZERO),a.setFromMinMax(this.maxVector,this.minVector),s[0].set(r.x,r.y,r.z),s[1].set(r.x,r.y,i.z),s[2].set(r.x,i.y,r.z),s[3].set(r.x,i.y,i.z),s[4].set(i.x,r.y,r.z),s[5].set(i.x,r.y,i.z),s[6].set(i.x,i.y,r.z),s[7].set(i.x,i.y,i.z);for(const o of s)e.transformPoint(o,o),a.expandByPoint(o);return i.copyFrom(a.max),r.copyFrom(a.min),a.setFromMinMax(r,i),a}}class s0 extends ja{name="";_instanceID="";_numChildren;get instanceID(){return this._instanceID}transform;renderNode;entityChildren;components;waitDisposeComponents;_bound;_boundWorld;_isBoundChange=!0;_dispose=!1;get dispose(){return this._dispose}getObjectByName(e){if(e.indexOf("/")>=0){let a=e.split("/"),r=this;for(;a.length>0&&r;){let i=a.shift();if(r=r.getChildByName(i,!1),!r)return null}return r}else return this.getChildByName(e,!1)}constructor(){super(),this.entityChildren=[],this.components=new Map,this._instanceID=tn().toString(),this.waitDisposeComponents=[]}get numChildren(){return this._numChildren}addChild(e){if(e==null)throw new Error("child is null!");if(e===this)throw new Error("child is self!");return this.entityChildren.indexOf(e)==-1?(e.removeFromParent(),e.transform.parent=this.transform,this.entityChildren.push(e),this._numChildren=this.entityChildren.length,this.noticeComponents("onAddChild",e),e):null}removeChild(e){if(e===null)return;if(e===this)throw new Error("add child is self!");let t=this.entityChildren.indexOf(e);t!=-1&&(this.entityChildren.splice(t,1),e.transform.parent=null,this._numChildren=this.entityChildren.length,this.noticeComponents("onRemoveChild",e))}removeAllChild(){for(;this.numChildren>0;)this.removeChild(this.entityChildren[0])}removeSelf(){return this.removeFromParent()}removeChildByIndex(e){e>=0&&e<this.entityChildren.length?this.removeChild(this.entityChildren[e]):console.error("remove child by index , index out of range")}hasChild(e){return this.entityChildren.indexOf(e)!=-1}removeFromParent(){let e=this.transform.parent;return e&&e.object3D&&e.object3D.removeChild(this),this}getChildByIndex(e){let t=null;return e<this.entityChildren.length&&(t=this.entityChildren[e]),t}getChildByName(e,t=!0){let a=null;for(const r of this.entityChildren){if(r.name==e)return a=r,a;if(t&&(a=r.getChildByName(e,t),a))return a}return a}update(){}instantiate(){return null}onTransformLocalChange(e){this._isBoundChange=!0}get bound(){return(this._isBoundChange||!this._bound)&&this.updateBound(),this._boundWorld}set bound(e){this._bound=e,this._boundWorld=this._bound.clone(),this._isBoundChange=!0}updateBound(){return this._bound||(this._bound=new Ce,this._boundWorld=this._bound.clone(),this._isBoundChange=!0),this._isBoundChange&&(kn.transformBound(this.transform.worldMatrix,this._bound,this._boundWorld),this._isBoundChange=!1),this._boundWorld}waitUpdate(){this._dispose?(this.transform.parent&&this.transform.parent.object3D.removeChild(this),this.components.forEach((e,t)=>{e.enable=!1,e.beforeDestroy(),e.destroy()}),this.components.clear()):Ne.waitStartComponent.forEach((e,t)=>{for(;e.length>0;){const a=e.shift();a.__start(),Ne.waitStartComponent.delete(a.object3D)}})}noticeComponents(e,t){for(let a of this.components.values())a[e]?.(t)}destroy(e){this._dispose||(this.components.forEach(t=>{t.beforeDestroy(e)}),this.components.forEach(t=>{t.destroy(e)}),this.components.clear(),this.components.clear(),this.entityChildren&&(this.entityChildren.forEach(t=>{t.destroy(e)}),this.removeAllChild(),this.entityChildren=[]),this._bound&&this._bound.destroy&&(this._bound.destroy(),this._bound=null),this._boundWorld&&this._boundWorld.destroy&&(this._boundWorld.destroy(),this._boundWorld=null),this.transform.parent=null,this._dispose=!0,super.destroy())}}var B2=Object.getOwnPropertyDescriptor,v2=(n,e,t,a)=>{for(var r=a>1?void 0:a?B2(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.Object3D=class extends s0{_isScene3D;prefabRef;serializeTag;constructor(){super(),this.transform=this.addComponent(zt),this.transform.eventDispatcher.addEventListener(zt.LOCAL_ONCHANGE,this.onTransformLocalChange,this)}get isScene3D(){return this._isScene3D}forChild(e){this.entityChildren.forEach(t=>{e(t),t.forChild(e)})}addComponent(e,t){if(!this.components.has(e)){let a=new e;return a.object3D=this,this.components.set(e,a),a.__init(t),Ne.appendWaitStart(a),a}return this.components.get(e)}getOrAddComponent(e){let t=this.components.get(e);return t||(t=this.addComponent(e)),t}removeComponent(e){if(this.components.has(e)){let t=this.components.get(e);Ne.removeWaitStart(this,t),this.components.delete(e),t.__stop(),t.beforeDestroy(),t.destroy()}}hasComponent(e){return this.components.has(e)}getComponent(e){return this.components.get(e)}getComponentFromParent(e){if(!this.parent)return null;let t=this.parent.object3D.getComponent(e);return t||this.parent.object3D.getComponentFromParent(e)}getComponentsInChild(e){let t=[],a=this.components.get(e);a&&t.push(a);for(let r=0;r<this.entityChildren.length;r++){let s=this.entityChildren[r].getComponentsInChild(e);t.push(...s)}return t}getComponents(e,t,a){t||=[];let r=this.getComponent(e);r&&(r.enable||a)&&t.push(r);for(let i=0,s=this.entityChildren.length;i<s;i++){let o=this.entityChildren[i];o&&o instanceof d.Object3D&&o.getComponents(e,t,a)}return t}getComponentsExt(e,t,a){t||=[];let r=this.components.get(e);if(r&&(r.enable||a))t.push(r);else for(const i of this.entityChildren)i instanceof d.Object3D&&i.getComponentsExt(e,t,a);return t}getComponentsByProperty(e,t,a=!0,r,i){r||=[];let s;for(const o of this.components.values())o&&(o.enable||i)&&o[e]===t&&(r.push(o),s=!0);if(!(s&&a))for(const o of this.entityChildren)o instanceof d.Object3D&&o.getComponentsByProperty(e,t,a,r,i);return r}clone(){return this.instantiate()}instantiate(){let e=new d.Object3D;return e.name=this.name,e.serializeTag=this.serializeTag,e.prefabRef=this.prefabRef,this.entityChildren.forEach((t,a)=>{let r=t.instantiate();e.addChild(r)}),this.components.forEach((t,a)=>{t.cloneTo(e)}),e}get localPosition(){return this.transform.localPosition}set localPosition(e){this.transform.localPosition=e}get localRotation(){return this.transform.localRotation}set localRotation(e){this.transform.localRotation=e}get localScale(){return this.transform.localScale}set localScale(e){this.transform.localScale=e}get localQuaternion(){return this.transform.localRotQuat}set localQuaternion(e){this.transform.localRotQuat=e}notifyChange(){this.transform.notifyChange()}get parent(){return this.transform.parent}get parentObject(){return this.transform.parent.object3D}set x(e){this.transform.x=e}get x(){return this.transform.x}set y(e){this.transform.y=e}get y(){return this.transform.y}set z(e){this.transform.z=e}get z(){return this.transform.z}set scaleX(e){this.transform.scaleX=e}get scaleX(){return this.transform.scaleX}set scaleY(e){this.transform.scaleY=e}get scaleY(){return this.transform.scaleY}set scaleZ(e){this.transform.scaleZ=e}get scaleZ(){return this.transform.scaleZ}set rotationX(e){this.transform.rotationX=e}get rotationX(){return this.transform.rotationX}set rotationY(e){this.transform.rotationY=e}get rotationY(){return this.transform.rotationY}set rotationZ(e){this.transform.rotationZ=e}get rotationZ(){return this.transform.rotationZ}fixedUpdate(){}lateUpdate(){}traverse(e){e(this);for(let t=0,a=this.entityChildren.length;t<a;t++){let r=this.entityChildren[t];r instanceof d.Object3D&&r.traverse(e)}}destroy(e){this.transform.eventDispatcher.removeEventListener(zt.LOCAL_ONCHANGE,this.onTransformLocalChange,this);const t=this.batchTable;t&&typeof t.destroy=="function"&&(t.destroy(),this.batchTable=null);const a=this.featureTable;a&&typeof a.destroy=="function"&&(a.destroy(),this.featureTable=null),super.destroy(e)}},d.Object3D=v2([U2],d.Object3D);function U2(n,e){return class extends d.Object3D{set active(t){this.transform.enable=t>0}get active(){return this.transform.enable?1:0}get materialColor(){return this.getComponent(d.MeshRenderer)?.material?.shader.getDefaultColorShader().baseColor}set materialColor(t){let a=this.getComponent(d.MeshRenderer)?.material;a&&(a.shader.getDefaultColorShader().baseColor=t)}notifyMaterialColorChange(t,a){this.getComponent(d.MeshRenderer).materials?.[t]?.shader.getDefaultColorShader().uniforms[a].onChange()}}}class ht{static createCamera3DObject(e,t){return this.createCamera3D(null,e,t)}static createCamera3D(e,t,a){return e||=new d.Object3D,t&&t.addChild(e),a&&(e.name=a),e.getOrAddComponent(Hr)}static UnProjection(e,t,a=1,r){let i=new g(e,t,0),s=1,o=g.HELP_0,l=I.canvas.offsetLeft,c=I.canvas.offsetTop,f=I.canvas.clientWidth,h=I.canvas.clientHeight;o.x=((i.x-l)*s/f-.5)*2,o.y=-((i.y-c)*s/h-.5)*2,o.z=a;let u=new g(0,0,0),b=T.helpMatrix2;b.copyFrom(r.projectionMatrix),b.invert();let A=T.helpMatrix;return A.identity(),A.multiply(b),A.multiply(r.transform.worldMatrix),A.perspectiveMultiplyPoint3(o,u),u}static Projection(e,t,a){let r=a||new g(0,0,0),i=T.helpMatrix;i.copyFrom(t.viewMatrix),i.multiply(t.projectionMatrix),i.perspectiveMultiplyPoint3(e,r);let s=I.canvas.clientWidth/2,o=I.canvas.clientHeight/2;return r.x=r.x*s+s,r.y=o-r.y*o,r}static UnProjection2(e,t,a,r,i){let s=i||new g(0,0,0),o=T.helpMatrix;o.copyFrom(r.pvMatrixInv);let l=I.canvas.clientWidth/2,c=I.canvas.clientHeight/2;return s.x=(e-l)/l,s.y=(c-t)/c,s.z=a,o.perspectiveMultiplyPoint3(s,s),s}}class Wt{static maxNumDirectionShadow=8;static maxNumPointShadow=8;static directionLightList;static pointLightList;static shadowLights;static init(){this.directionLightList=new Map,this.pointLightList=new Map,this.shadowLights=new Map}static createBuffer(e){if(!this.shadowLights.has(e.scene)){let t=new Float32Array(16);this.shadowLights.set(e.scene,t)}}static getShadowLightList(e){if(!e.transform.view3D)return null;if(e.lightData.lightType==ft.DirectionLight){let t=this.directionLightList.get(e.transform.view3D.scene);return t||(t=[],this.directionLightList.set(e.transform.view3D.scene,t)),t}else if(e.lightData.lightType==ft.PointLight){let t=this.pointLightList.get(e.transform.view3D.scene);return t||(t=[],this.pointLightList.set(e.transform.view3D.scene,t)),t}else if(e.lightData.lightType==ft.SpotLight){let t=this.pointLightList.get(e.transform.view3D.scene);return t||(t=[],this.pointLightList.set(e.transform.view3D.scene,t)),t}}static getShadowLightWhichScene(e,t){if(t==ft.DirectionLight){let a=this.directionLightList.get(e);return a||(a=[],this.directionLightList.set(e,a)),a}else if(t==ft.PointLight){let a=this.pointLightList.get(e);return a||(a=[],this.pointLightList.set(e,a)),a}}static getDirectShadowLightWhichScene(e){let t=this.directionLightList.get(e);return t||(t=[],this.directionLightList.set(e,t)),t}static getPointShadowLightWhichScene(e){let t=this.pointLightList.get(e);return t||(t=[],this.pointLightList.set(e,t)),t}static addShadowLight(e){if(!e.transform.view3D)return null;let t=e.transform.view3D.scene;if(e.lightData.lightType==ft.DirectionLight){let a=this.directionLightList.get(t);if(a||(a=[],this.directionLightList.set(t,a)),!e.shadowCamera){e.shadowCamera=ht.createCamera3DObject(null,"shadowCamera"),e.shadowCamera.isShadowCamera=!0;let r=-1e3;e.shadowCamera.orthoOffCenter(r,-r,r,-r,1,1e4)}return a.indexOf(e)==-1&&a.push(e),a}else if(e.lightData.lightType==ft.PointLight||e.lightData.lightType==ft.SpotLight){let a=this.pointLightList.get(t);return a&&a.length>=8||(a||(a=[],this.pointLightList.set(t,a)),a.indexOf(e)==-1&&a.push(e)),a}}static removeShadowLight(e){if(e.lightData.castShadowIndex=-1,!e.transform.view3D)return null;if(e.lightData.lightType==ft.DirectionLight){let t=this.directionLightList.get(e.transform.view3D.scene);if(t){let a=t.indexOf(e);a!=-1&&t.splice(a,1)}return e.lightData.castShadowIndex=-1,t}else if(e.lightData.lightType==ft.PointLight||e.lightData.lightType==ft.SpotLight){let t=this.pointLightList.get(e.transform.view3D.scene);if(t){let a=t.indexOf(e);a!=-1&&t.splice(a,1)}return e.lightData.castShadowIndex=-1,t}}static update(e){let t=this.shadowLights.get(e.scene),a=Wt.directionLightList.get(e.scene),r=Wt.pointLightList.get(e.scene),i=0,s=0,o=0,l=0;if(t.fill(0),a){let f=0;for(let h=0;h<a.length;h++){const u=a[h];t[h]=u.lightData.index,u.lightData.castShadowIndex=f++}s=a.length}if(r){o=s;let f=0;for(let h=o;h<r.length;h++){const u=r[h];t[h]=u.lightData.index,u.lightData.castShadowIndex=f++}l=o+r.length}ve.getAllCameraGroup().forEach(f=>{f.dirShadowStart=i,f.dirShadowEnd=s,f.pointShadowStart=o,f.pointShadowEnd=l,f.shadowLights.set(new Float32Array(t))})}}class En{uuid;usage;globalBindGroup;uniformGPUBuffer;matrixBindGroup;uniformByteLength;matrixesByteLength;shadowMatrixRaw=new Float32Array(128);csmMatrixRaw=new Float32Array(ia.Cascades*16);csmShadowBias=new Float32Array(4);shadowLights=new Float32Array(16);dirShadowStart=0;dirShadowEnd=0;pointShadowStart=0;pointShadowEnd=0;constructor(e){this.uuid=Gt(),this.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.uniformGPUBuffer=new Ct(8336),this.uniformGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBindGroup=e,this.createBindGroup()}createBindGroup(){this.uniformByteLength=this.uniformGPUBuffer.memory.shareDataBuffer.byteLength,this.matrixesByteLength=T.block*4*T.maxCount,this.globalBindGroup=I.device.createBindGroup({label:"global_bindGroupLayout",layout:An.getGlobalDataBindGroupLayout(),entries:[{binding:0,resource:{buffer:this.uniformGPUBuffer.buffer,offset:0,size:this.uniformByteLength}},{binding:1,resource:{buffer:this.matrixBindGroup.matrixBufferDst.buffer,offset:0,size:this.matrixesByteLength}}]})}setCamera(e){this.uniformGPUBuffer.setMatrix("_projectionMatrix",e.projectionMatrix),this.uniformGPUBuffer.setMatrix("_viewMatrix",e.viewMatrix),this.uniformGPUBuffer.setMatrix("_cameraWorldMatrix",e.transform.worldMatrix),this.uniformGPUBuffer.setMatrix("pvMatrixInv",e.projectionMatrixInv),this.uniformGPUBuffer.setMatrix("viewToWorld",e.cameraToWorld);let t=Wt.getDirectShadowLightWhichScene(e.transform.scene3D);this.csmShadowBias.fill(1e-4),this.shadowMatrixRaw.fill(0),this.csmMatrixRaw.fill(0);for(let l=0;l<8;l++)if(l<t.length){let c=t[l].shadowCamera;this.shadowMatrixRaw.set(c.pvMatrix.rawData,l*16)}else this.shadowMatrixRaw.set(e.transform.worldMatrix.rawData,l*16);this.uniformGPUBuffer.setFloat32Array("shadowMatrix",this.shadowMatrixRaw);let a=B.setting.shadow.shadowSize;if(ia.Cascades>1&&e.enableCSM&&t[0])for(let l=0;l<ia.Cascades;l++){let c=e.csm.children[l].shadowCamera;this.csmMatrixRaw.set(c.pvMatrix.rawData,l*16),this.csmShadowBias[l]=e.getCSMShadowBiasScale(c)}this.uniformGPUBuffer.setFloat32Array("csmShadowBias",this.csmShadowBias),this.uniformGPUBuffer.setFloat32Array("csmMatrix",this.csmMatrixRaw),this.uniformGPUBuffer.setFloat32Array("shadowLights",this.shadowLights);let r=B.setting.reflectionSetting,i=$.instance.getReflections(e.transform.scene3D).length;this.uniformGPUBuffer.setFloat("reflectionProbeSize",r.reflectionProbeSize),this.uniformGPUBuffer.setFloat("reflectionProbeMaxCount",r.reflectionProbeMaxCount),this.uniformGPUBuffer.setFloat("reflectionMapWidth",r.width),this.uniformGPUBuffer.setFloat("reflectionMapHeight",r.height),this.uniformGPUBuffer.setFloat("reflectionCount",i),this.uniformGPUBuffer.setFloat("test2",ct.testObj.testValue2),this.uniformGPUBuffer.setFloat("test3",ct.testObj.testValue3),this.uniformGPUBuffer.setFloat("test4",ct.testObj.testValue4),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",ze.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",ze.time),this.uniformGPUBuffer.setFloat("delta",ze.delta),this.uniformGPUBuffer.setFloat("shadowBias",e.getShadowBias(a)),this.uniformGPUBuffer.setFloat("skyExposure",B.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",B.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",B.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",B.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",B.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",B.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",B.setting.render.renderState_split);let s=B.inputSystem.mouseX*I.pixelRatio,o=B.inputSystem.mouseY*I.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",s),this.uniformGPUBuffer.setFloat("mouseY",o),this.uniformGPUBuffer.setFloat("windowWidth",I.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",I.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",B.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",a),this.uniformGPUBuffer.setFloat("shadowSoft",B.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",e.enableCSM?1:0),this.uniformGPUBuffer.setFloat("csmMargin",B.setting.shadow.csmMargin),this.uniformGPUBuffer.setInt32("nDirShadowStart",this.dirShadowStart),this.uniformGPUBuffer.setInt32("nDirShadowEnd",this.dirShadowEnd),this.uniformGPUBuffer.setInt32("nPointShadowStart",this.pointShadowStart),this.uniformGPUBuffer.setInt32("nPointShadowEnd",this.pointShadowEnd),this.uniformGPUBuffer.setVector3("cameraForward",e.transform.forward),this.uniformGPUBuffer.setVector4Array("frustumPlanes",e.frustum.planes),this.uniformGPUBuffer.apply()}setShadowCamera(e){this.uniformGPUBuffer.setMatrix("_projectionMatrix",e.projectionMatrix),this.uniformGPUBuffer.setMatrix("_viewMatrix",e.viewMatrix),this.uniformGPUBuffer.setMatrix("_pvMatrix",e.pvMatrix),this.uniformGPUBuffer.setMatrix("pvMatrixInv",e.projectionMatrixInv),this.uniformGPUBuffer.setMatrix("viewToWorld",e.cameraToWorld),this.csmShadowBias.fill(1e-4),this.shadowMatrixRaw.fill(0),this.csmMatrixRaw.fill(0),this.uniformGPUBuffer.setFloat32Array("shadowCamera",this.shadowMatrixRaw),this.uniformGPUBuffer.setFloat32Array("csmShadowBias",this.csmShadowBias),this.uniformGPUBuffer.setFloat32Array("csmMatrix",this.csmMatrixRaw),this.uniformGPUBuffer.setFloat32Array("shadowLights",this.shadowLights),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",ze.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",ze.time),this.uniformGPUBuffer.setFloat("delta",ze.delta),this.uniformGPUBuffer.setFloat("shadowBias",B.setting.shadow.shadowBias),this.uniformGPUBuffer.setFloat("skyExposure",B.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",B.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",B.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",B.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",B.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",B.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",B.setting.render.renderState_split);let t=B.inputSystem.mouseX*I.pixelRatio,a=B.inputSystem.mouseY*I.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",t),this.uniformGPUBuffer.setFloat("mouseY",a),this.uniformGPUBuffer.setFloat("windowWidth",I.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",I.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",B.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",B.setting.shadow.shadowSize),this.uniformGPUBuffer.setFloat("shadowSoft",B.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",0),this.uniformGPUBuffer.setFloat("csmMargin",B.setting.shadow.csmMargin),this.uniformGPUBuffer.setInt32("nDirShadowStart",this.dirShadowStart),this.uniformGPUBuffer.setInt32("nDirShadowEnd",this.dirShadowEnd),this.uniformGPUBuffer.setInt32("nPointShadowStart",this.pointShadowStart),this.uniformGPUBuffer.setInt32("nPointShadowEnd",this.pointShadowEnd),this.uniformGPUBuffer.apply()}setShadowLight(){}}class n0{setting;probesBufferData;probesBuffer;isVolumeFrameChange=!0;randomOrientation;startPosition=new g;isVolumeChange=!0;irradianceVolumeBuffer;directionDistance=20;randomSeedCount=3;useRandomIndex=0;centerDirection=new g(0,0,this.directionDistance).normalize(1);arroundPositions=[];updateOrientation(){return this.useRandomIndex++,this.useRandomIndex>=this.arroundPositions.length&&(this.useRandomIndex=0),T.fromToRotation(this.centerDirection,this.arroundPositions[this.useRandomIndex],this.randomOrientation),this.randomOrientation}init(e){this.setting=e,this.randomOrientation=new T(!1),this.randomOrientation.identity(),this.irradianceVolumeBuffer=new Ct(80),this.createFramesBuffer(),this.arroundPositions.push(this.centerDirection.clone());for(let t=0;t<this.randomSeedCount;t++){let a=Math.PI*2*t/this.randomSeedCount,r=new g(Math.sin(a),Math.cos(a),this.directionDistance).normalize(1);this.arroundPositions.push(r)}}setVolumeDataChange(){this.isVolumeChange=!0}updateProbes(e){let t=this.probesBufferData;for(let a of e){let r=a.index*4;t[r+3]=a.drawCallFrame}}createFramesBuffer(){if(!this.probesBufferData){let e=this.setting.probeXCount*this.setting.probeYCount*this.setting.probeZCount;this.probesBufferData=new Float32Array(e*4),this.probesBufferData.fill(-1),this.probesBuffer=new Pe(e*4,GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST)}}uploadBuffer(){this.isVolumeChange&&(this.fillIrradianceData(),this.isVolumeChange=!1,this.isVolumeFrameChange=!0),this.probesBuffer.setFloat32Array("uniformFramesBuffer",this.probesBufferData)}calcPosition(e,t,a,r){let i=this.setting,s=this.setting.probeSpace;return r=r||new g,r.x=e*s-s*(i.probeXCount-1)*.5+i.offsetX,r.y=t*s-s*(i.probeYCount-1)*.5+i.offsetY,r.z=a*s-s*(i.probeZCount-1)*.5+i.offsetZ,r}debugX=0;debugY=0;debugZ=0;fillIrradianceData(){let e=this.setting,t=this.calcPosition(0,0,0,this.startPosition);this.irradianceVolumeBuffer.setFloat("orientationIndex",this.randomOrientation.index),this.irradianceVolumeBuffer.setFloat("hysteresis",e.hysteresis),this.irradianceVolumeBuffer.setFloat("OctRTSideSize",e.octRTSideSize),this.irradianceVolumeBuffer.setFloat("OctRTMaxSize",e.octRTMaxSize),this.irradianceVolumeBuffer.setFloat("startX",t.x),this.irradianceVolumeBuffer.setFloat("startY",t.y),this.irradianceVolumeBuffer.setFloat("startZ",t.z),this.irradianceVolumeBuffer.setFloat("ProbeSpace",e.probeSpace),this.irradianceVolumeBuffer.setFloat("probeXCount",e.probeXCount),this.irradianceVolumeBuffer.setFloat("probeYCount",e.probeYCount),this.irradianceVolumeBuffer.setFloat("probeZCount",e.probeZCount),this.irradianceVolumeBuffer.setFloat("maxDistance",e.probeSpace*1.732),this.irradianceVolumeBuffer.setFloat("depthSharpness",e.depthSharpness),this.irradianceVolumeBuffer.setFloat("ProbeSourceTextureSize",e.probeSourceTextureSize),this.irradianceVolumeBuffer.setFloat("ProbeSize",e.probeSize),this.irradianceVolumeBuffer.setFloat("bounceIntensity",e.bounceIntensity),this.irradianceVolumeBuffer.setFloat("probeRoughness",e.probeRoughness),this.irradianceVolumeBuffer.setFloat("normalBias",e.normalBias),this.irradianceVolumeBuffer.setFloat("irradianceChebyshevBias",e.irradianceChebyshevBias),this.irradianceVolumeBuffer.setFloat("rayNumber",e.rayNumber),this.irradianceVolumeBuffer.setFloat("irradianceDistanceBias",e.irradianceDistanceBias),this.irradianceVolumeBuffer.setFloat("indirectIntensity",e.indirectIntensity),this.irradianceVolumeBuffer.setFloat("ddgiGamma",e.ddgiGamma),this.irradianceVolumeBuffer.setFloat("lerpHysteresis",e.lerpHysteresis),this.irradianceVolumeBuffer.setFloat("debugX",this.debugX),this.irradianceVolumeBuffer.setFloat("debugY",this.debugY),this.irradianceVolumeBuffer.setFloat("debugZ",this.debugZ),this.irradianceVolumeBuffer.apply()}}class o0{storageGPUBuffer;irradianceVolume;_lightList=[];constructor(){this.storageGPUBuffer=new Pe(hs.lightSize*B.setting.light.maxLight,GPUBufferUsage.COPY_SRC),this.irradianceVolume=new n0,this.irradianceVolume.init(B.setting.gi);for(let e=0;e<B.setting.light.maxLight;e++){let t=this.storageGPUBuffer.memory.allocation_node(hs.lightSize*4);this._lightList.push(t)}this.storageGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e){this.storageGPUBuffer.clean();let t=$.instance.getLights(e.scene);for(let a=0;a<t.length;a++){const r=t[a].lightData;r.index=a,this.writeLightBytes(r,this._lightList[a])}this.storageGPUBuffer.apply()}writeLightBytes(e,t){t.offset=0,t.writeFloat(e.index),t.writeInt32(e.lightType),t.writeFloat(e.radius),t.writeFloat(e.linear),t.writeVector3(e.lightPosition),t.writeFloat(e.lightMatrixIndex),t.writeVector3(e.direction),t.writeFloat(e.quadratic),t.writeRGBColor(e.lightColor),t.writeFloat(e.intensity),t.writeFloat(e.innerAngle),t.writeFloat(e.outerAngle),t.writeFloat(e.range),t.writeInt32(e.castShadowIndex),t.writeVector3(e.lightTangent),t.writeFloat(e.iesIndex)}}class l0{storageGPUBuffer;reflectionMap;sourceReflectionMap;count;constructor(){this.storageGPUBuffer=new Pe(768)}update(e){this.storageGPUBuffer.clean();let t=$.instance.getReflections(e.scene);for(let a=0;a<t.length;a++){const r=t[a];r.gid=a,this.storageGPUBuffer.setFloat("gid",r.gid),this.storageGPUBuffer.setVector3("worldPosition",r.transform.worldPosition),this.storageGPUBuffer.setFloat("radius",r.radius),this.storageGPUBuffer.setVector3("bound",r.transform.worldPosition)}this.count=t.length,this.storageGPUBuffer.apply()}}class c0 extends Za{size;constructor(e,t=0,a){super(),this.bufferType=ga.StorageGPUBuffer,this.size=e,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|t,e,a,"MatrixGPUBuffer")}writeBufferByHeap(e,t){let a;e instanceof Float64Array?a=new Float32Array(e):a=e;let r=I.device;if(a.length>0){let i=null;for(;this.mapAsyncReady.length&&(i=this.mapAsyncReady.shift(),i.usedSize!=a.byteLength);)i.destroy(),this.mapAsyncBuffersOutstanding--,i=null;i||(i=r.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,mappedAtCreation:!0}),i.usedSize=a.byteLength,this.mapAsyncBuffersOutstanding++,this.mapAsyncBuffersOutstanding>10&&console.warn(` Warning: mapAsync requests from ${this.mapAsyncBuffersOutstanding} frames ago have not resolved yet. MB of staging buffers allocated.`));let s=new Float32Array(a.buffer,a.byteOffset,t);new Float32Array(i.getMappedRange(0,t*4)).set(s),i.unmap();const l=r.createCommandEncoder();l.copyBufferToBuffer(i,0,this.buffer,0,t*4),r.queue.submit([l.finish()]),i.mapAsync(GPUMapMode.WRITE).then(()=>this.mapAsyncReady.push(i))}}}class f0{uuid;index;usage;groupBufferSize;matrixBufferDst;constructor(){this.uuid=Gt(),this.groupBufferSize=0,this.usage=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.cacheWorldMatrix()}cacheWorldMatrix(){this.groupBufferSize=T.maxCount*T.blockBytes,this.matrixBufferDst=new c0(this.groupBufferSize/4),this.matrixBufferDst.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBufferDst.buffer.label=this.groupBufferSize.toString()}writeBuffer(e){const t=T.dynamicMatrixBytes;this.matrixBufferDst.mapAsyncWrite(t,e)}}class ve{static _cameraBindGroups;static _lightEntriesMap;static _reflectionEntriesMap;static modelMatrixBindGroup;static init(){this.modelMatrixBindGroup=new f0,this._cameraBindGroups=new Map,this._lightEntriesMap=new Map,this._reflectionEntriesMap=new Map}static getAllCameraGroup(){return this._cameraBindGroups}static getCameraGroup(e){let t=this._cameraBindGroups.get(e);return t||(t=new En(this.modelMatrixBindGroup),this._cameraBindGroups.set(e,t)),e.isShadowCamera?t.setShadowCamera(e):t.setCamera(e),t}static updateCameraGroup(e){let t=this._cameraBindGroups.get(e);t||(t=new En(this.modelMatrixBindGroup),this._cameraBindGroups.set(e,t)),e.isShadowCamera?t.setShadowCamera(e):t.setCamera(e)}static getLightEntries(e){e||console.log("getLightEntries scene is null");let t=this._lightEntriesMap.get(e);return t||(t=new o0,this._lightEntriesMap.set(e,t)),this._lightEntriesMap.get(e)}static getReflectionEntries(e){e||console.log("getLightEntries scene is null");let t=this._reflectionEntriesMap.get(e);return t||(t=new l0,this._reflectionEntriesMap.set(e,t)),this._reflectionEntriesMap.get(e)}}class E{static lastGeometry;static lastPipeline;static lastShader;static drawCount=0;static renderPassCount=0;static geometryCount=0;static pipelineCount=0;static matrixCount=0;static lastRenderPassState;static LastCommand;static multiTextureViewCache=new WeakMap;static swapchainTextureCache={texture:null,view:null};static bindPipeline(e,t){if(E.lastShader!=t)E.lastShader=t;else return!1;E.lastPipeline!=t.pipeline&&(E.lastPipeline=t.pipeline,e.setPipeline(t.pipeline));for(let a=1;a<t.bindGroups.length;a++){const r=t.bindGroups[a];r&&e.setBindGroup(a,r)}return!0}static bindCamera(e,t){let a=ve.getCameraGroup(t);e.setBindGroup(0,a.globalBindGroup)}static bindGeometryBuffer(e,t){if(this.lastGeometry!=t&&(this.lastGeometry=t,t.indicesBuffer)){e.setIndexBuffer(t.indicesBuffer.indicesGPUBuffer.buffer,t.indicesBuffer.indicesFormat);let a=t.vertexBuffer.vertexGPUBuffer,r=t.vertexBuffer.vertexBufferLayouts;for(let i=0;i<r.length;i++){const s=r[i];e.setVertexBuffer(i,a.buffer,s.offset,s.size)}}}static cleanCache(){this.lastGeometry=null,this.lastPipeline=null,this.lastShader=null}static createPipeline(e){return ct.countStart("GPUContext","pipeline"),I.device.createRenderPipeline(e)}static beginCommandEncoder(){return ct.countStart("GPUContext","beginCommandEncoder"),this.LastCommand&&I.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=I.device.createCommandEncoder(),this.LastCommand}static endCommandEncoder(e){this.LastCommand==e&&(I.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=null,ct.countStart("GPUContext","endCommandEncoder"))}static recordBundleEncoder(e){return I.device.createRenderBundleEncoder(e)}static beginRenderPass(e,t){if(this.cleanCache(),this.renderPassCount++,this.lastRenderPassState=t,t.depthTexture){let a=t.renderPassDescriptor.depthStencilAttachment;a.view=t.depthTexture.getGPUView()}if(t.renderTargets&&t.renderTargets.length>0){for(let a=0;a<t.renderTargets.length;++a){const r=t.renderTargets[a];let i=t.renderPassDescriptor.colorAttachments[a];if(t.multisample>0&&t.renderTargets.length==1){let s=this.multiTextureViewCache.get(t.multiTexture);s||(s=t.multiTexture.createView(),this.multiTextureViewCache.set(t.multiTexture,s)),i.view=s,i.resolveTarget=r.getGPUView()}else i.view=r.getGPUView()}return e.beginRenderPass(t.renderPassDescriptor)}else{let a=t.renderPassDescriptor.colorAttachments[0];if(a){const r=I.context.getCurrentTexture();if(t.multisample>0){let i=this.multiTextureViewCache.get(t.multiTexture);i||(i=t.multiTexture.createView(),this.multiTextureViewCache.set(t.multiTexture,i)),a.view=i,this.swapchainTextureCache.texture!==r&&(this.swapchainTextureCache.texture=r,this.swapchainTextureCache.view=r.createView()),a.resolveTarget=this.swapchainTextureCache.view}else this.swapchainTextureCache.texture!==r&&(this.swapchainTextureCache.texture=r,this.swapchainTextureCache.view=r.createView()),a.view=this.swapchainTextureCache.view}return e.beginRenderPass(t.renderPassDescriptor)}}static drawIndexed(e,t,a,r,i,s){e.drawIndexed(t,a,r,i,s),this.drawCount++}static draw(e,t,a,r,i){e.draw(t,a,r,i),this.drawCount++}static endPass(e){e.insertDebugMarker("end"),e.end()}static computeCommand(e,t){let a=e.beginComputePass();for(let r=0;r<t.length;r++)t[r].compute(a);a.end()}static copyTexture(e,t,a){e.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:a.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:a.width,height:a.height,depthOrArrayLayers:1})}}class d0{source;input;output;reset(e){this.input&&this.input.destroy(),this.output&&this.output.destroy(),this.input=this.output=null,this.source=e}apply(e){if(this.source){if(!this.input){let t=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this.input=new Pe(this.source.length,t,this.source),this.input.apply()}if(!this.output){let t=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC;this.output=new Pe(e*3,t),this.output.apply()}}}}class h0{enable;morphTargetsRelative;MaxMorphTargetCount=64;_computeConfigArray;_computeConfigBuffer;_morphInfluenceArray;_morphInfluenceBuffer;_positionAttrDataGroup;_normalAttrDataGroup;_isInfluenceDirty;_morphTargetCount;_totalVertexCount;_computeShader;_computeShaders;_computeWorkGroupXY=1;_collectMorphTargetData;_blendTarget;constructor(){this._isInfluenceDirty=!0,this.generateGPUBuffer(),this._positionAttrDataGroup=new d0,this._normalAttrDataGroup=new d0}initMorphTarget(e){this._collectMorphTargetData=this.collectMorphTargetList(e),this._computeShader&&this._computeShader.destroy();let t=Xt.CsMain;this._computeShader=new Se(t),this._collectMorphTargetData.mergedNormal?this._computeShader.setDefine("USE_MORPHNORMALS",!0):this._computeShader.deleteDefine("USE_MORPHNORMALS"),this._computeShaders=[this._computeShader],this._isInfluenceDirty=!0,this._morphTargetCount=this._collectMorphTargetData.mtCount,this._totalVertexCount=this._collectMorphTargetData.vCount,this._morphInfluenceArray.fill(0),this._computeWorkGroupXY=this.calcWorkGroup(this._totalVertexCount),this._positionAttrDataGroup.reset(this._collectMorphTargetData.mergedPos),this._normalAttrDataGroup.reset(this._collectMorphTargetData.mergedNormal)}applyRenderShader(e){this.uploadMorphTargetBuffer(),this.uploadConfigGBuffer(),e.setUniformBuffer("morphTargetConfig",this._computeConfigBuffer),e.setStorageBuffer("morphTargetOpPositions",this._positionAttrDataGroup.output),this._collectMorphTargetData.mergedNormal&&e.setStorageBuffer("morphTargetOpNormals",this._normalAttrDataGroup.output)}computeMorphTarget(e){this.uploadConfigGBuffer(),this.uploadMorphTargetBuffer(),this._computeShader.setUniformBuffer("morphTargetConfig",this._computeConfigBuffer),this._computeShader.setStorageBuffer("morphTargetInfluence",this._morphInfluenceBuffer),this._computeShader.setStorageBuffer("morphTargetPositions",this._positionAttrDataGroup.input),this._computeShader.setStorageBuffer("morphTargetOpPositions",this._positionAttrDataGroup.output),this._collectMorphTargetData.mergedNormal&&(this._computeShader.setStorageBuffer("morphTargetNormals",this._normalAttrDataGroup.input),this._computeShader.setStorageBuffer("morphTargetOpNormals",this._normalAttrDataGroup.output)),this._computeShader.workerSizeX=this._computeWorkGroupXY,this._computeShader.workerSizeY=this._computeWorkGroupXY,this._computeShader.workerSizeZ=1,E.computeCommand(e,this._computeShaders)}updateInfluence(e,t){this._isInfluenceDirty=!0,this._morphInfluenceArray[e]=t}get blendShape(){return this._blendTarget}collectMorphTargetList(e){let t=this.collectAttribute("a_morphPositions_",e),a=t.length,r=t[0].data.length/3;if(this._blendTarget={},e.blendShapeData)for(let l=0;l<e.blendShapeData.shapeIndexs.length;l++){let c=e.blendShapeData.shapeIndexs[l],f=e.blendShapeData.shapeNames[l].split("."),h=f[f.length-1];this._blendTarget[h]=u=>this.updateInfluence(c,u)}let i=new Float32Array(r*a*3);{let l=0;for(let c=0;c<a;c++){let f=t[c];i.set(f.data,l),l+=f.data.length}}let s=this.collectAttribute("a_morphNormals_",e),o;if(s&&s.length>0){let l=0;o=new Float32Array(r*a*3);for(let c=0;c<a;c++){let f=s[c];o.set(f.data,l),l+=f.data.length}}return{mtCount:a,vCount:r,mergedPos:i,mergedNormal:o}}collectAttribute(e,t){let a=[];for(let r=0;r<this.MaxMorphTargetCount;r++){let i=e+r,s=t.getAttribute(i);if(s)a[r]=s;else break}return a}uploadConfigGBuffer(){if(this._isInfluenceDirty){let e=0;for(let t=0;t<this._morphTargetCount;t++)e+=this._morphInfluenceArray[t];this._morphInfluenceBuffer.setFloat32Array("data",this._morphInfluenceArray),this._morphInfluenceBuffer.apply(),this._computeConfigArray[0]=this.morphTargetsRelative?1:1-e,this._computeConfigArray[1]=this._morphTargetCount,this._computeConfigArray[2]=this._totalVertexCount,this._computeConfigArray[3]=this._computeWorkGroupXY,this._computeConfigBuffer.setFloat32Array("data",this._computeConfigArray),this._computeConfigBuffer.apply(),this._isInfluenceDirty=!1}}calcWorkGroup(e){let t=Math.ceil(Math.sqrt(e)),a=Math.ceil(Math.log2(t));return t=Math.pow(2,a),t}uploadMorphTargetBuffer(){this._positionAttrDataGroup.output||this._positionAttrDataGroup.apply(this._totalVertexCount),this._normalAttrDataGroup.output||this._normalAttrDataGroup.apply(this._totalVertexCount)}generateGPUBuffer(){this._computeConfigArray=new Float32Array(4),this._computeConfigBuffer=new Ct(4),this._morphInfluenceArray=new Float32Array(this.MaxMorphTargetCount);let e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this._morphInfluenceBuffer=new Pe(this.MaxMorphTargetCount,e)}destroy(e){this._computeConfigBuffer&&(this._computeConfigBuffer.destroy(e),this._computeConfigBuffer=null),this._morphInfluenceBuffer&&(this._morphInfluenceBuffer.destroy(e),this._morphInfluenceBuffer=null),this._computeShader&&(this._computeShader.destroy(e),this._computeShader=null),this._positionAttrDataGroup&&(this._positionAttrDataGroup.input&&this._positionAttrDataGroup.input.destroy(e),this._positionAttrDataGroup.output&&this._positionAttrDataGroup.output.destroy(e),this._positionAttrDataGroup=null),this._normalAttrDataGroup&&(this._normalAttrDataGroup.input&&this._normalAttrDataGroup.input.destroy(e),this._normalAttrDataGroup.output&&this._normalAttrDataGroup.output.destroy(e),this._normalAttrDataGroup=null),this._computeConfigArray=null,this._morphInfluenceArray=null,this._collectMorphTargetData=null,this._blendTarget=null,this._computeShaders=null}}var y2=Object.defineProperty,C2=Object.getOwnPropertyDescriptor,wn=(n,e,t,a)=>{for(var r=a>1?void 0:a?C2(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=(a?s(e,t,r):s(r))||r);return a&&r&&y2(e,t,r),r};d.MeshRenderer=class extends Ba{receiveShadow;morphData;constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(e){e.addComponent(d.MeshRenderer).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.receiveShadow=e.receiveShadow,this}get geometry(){return this._geometry}set geometry(e){if(super.geometry=e,e){let t=e.morphTargetDictionary!=null;t&&(this.morphData||=new h0,this.morphData.morphTargetsRelative=e.morphTargetsRelative,this.morphData.initMorphTarget(e)),this.morphData&&(this.morphData.enable=t),this.morphData?.enable?this.addRendererMask(Me.MorphTarget):this.removeRendererMask(Me.MorphTarget),this.object3D.bound=this._geometry.bounds.clone()}else this.morphData&&(this.morphData.enable=!1),this.removeRendererMask(Me.MorphTarget);this._readyPipeline||(this.initPipeline(),this._computes&&(this.onCompute=os(this.onCompute,()=>{for(let t=0;t<this._computes.length;t++)this._computes[t].onUpdate()})))}get material(){return this._materials[0]}set material(e){this.materials=[e]}setMorphInfluence(e,t){if(this.morphData&&this.morphData.enable){let a=this._geometry.morphTargetDictionary[e];a>=0&&this.morphData.updateInfluence(a,t)}}setMorphInfluenceIndex(e,t){this.morphData&&this.morphData.enable&&e>=0&&this.morphData.updateInfluence(e,t)}onCompute(e,t){this.morphData&&this.morphData.enable&&this.morphData.computeMorphTarget(t)}nodeUpdate(e,t,a,r){if(this.morphData&&this.morphData.enable)for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(t);if(o)for(let l=0;l<o.length;l++)this.morphData.applyRenderShader(o[l])}super.nodeUpdate(e,t,a,r)}destroy(e){this.morphData&&(this.morphData.destroy(e),this.morphData=null),super.destroy(e)}},wn([jr],d.MeshRenderer.prototype,"geometry",1),wn([jr],d.MeshRenderer.prototype,"material",1),d.MeshRenderer=wn([Nt(d.MeshRenderer,"MeshRenderer")],d.MeshRenderer);class Qa{static compressGBufferTex_NAME="compressGBufferTex_NAME";static colorBufferTex_NAME="colorBufferTex";static positionBufferTex_NAME="positionBufferTex";static normalBufferTex_NAME="normalBufferTex";static materialBufferTex_NAME="materialBufferTex";static zBufferTexture_NAME="zBufferTexture";static zPreDepthTexture_NAME="zPreDepthTexture";static outTex_NAME="outTex"}class u0{label="";customSize=!1;zPreTexture=null;depthTexture=null;renderTargetTextures;outColor=-1;renderTargets;rtTextureDescriptors;irradianceBuffer;multisample=0;multiTexture;depthViewIndex=0;depthCleanValue=0;isOutTarget=!0;camera3D;rtFrame;renderPassDescriptor;renderBundleEncoderDescriptor;depthLoadOp;getLastRenderTexture(){return this.renderTargets&&this.renderTargets.length>0?this.renderTargets[0]:B.res.redTexture}}class Et extends dt{resolveTarget;sampleCount;autoResize;clear;constructor(e,t,a=le.rgba8unorm,r=!1,i,s=1,o=0,l=!0,c=!0){super(e,t,s),this.name=Gt(),this.autoResize=c,this.useMipmap=r,this.sampleCount=o,this.format=a,this.numberLayer=s,this.clear=l,i!=null?this.usage=i:this.usage=i|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST,this.resize(e,t),this.autoResize&&I.addEventListener(nr.RESIZE,f=>{let{width:h,height:u}=f.data;this.resize(h,u),this._textureChange=!0},this)}resize(e,t){let a=I.device;this.gpuTexture&&(dt.delayDestroyTexture(this.gpuTexture),this.gpuTexture=null,this.view=null),this.width=e,this.height=t,this.createTextureDescriptor(e,t,1,this.format,this.usage,this.numberLayer,this.sampleCount),this.useMipmap=!1,this.visibility=GPUShaderStage.COMPUTE|GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,this.format==le.rgba32float?(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=a.createSampler({})):this.format==le.depth32float?(this.samplerBindingLayout.type="filtering",this.sampler_comparisonBindingLayout.type="comparison",this.textureBindingLayout.sampleType="depth",this.gpuSampler=I.device.createSampler({}),this.gpuSampler_comparison=I.device.createSampler({compare:"less",label:"sampler_comparison"})):this.format==le.depth24plus?(this.samplerBindingLayout={type:"filtering"},this.sampler_comparisonBindingLayout={type:"comparison"},this.textureBindingLayout.sampleType="depth",this.gpuSampler=I.device.createSampler({}),this.gpuSampler_comparison=I.device.createSampler({compare:"less",label:"sampler_comparison"})):(this.samplerBindingLayout.type="filtering",this.textureBindingLayout.sampleType="float",this.sampleCount>0&&(this.textureBindingLayout.multisampled=!0),this.minFilter="linear",this.magFilter="linear",this.mipmapFilter="linear",this.addressModeU=Ht.clamp_to_edge,this.addressModeV=Ht.clamp_to_edge,this.gpuSampler=a.createSampler(this)),this._textureChange=!0}create(e,t,a=!0){let r=I.device;const i=e*4;let s=new Float32Array(e*t*4);const o=r.createBuffer({size:s.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(o,0,s);const l=E.beginCommandEncoder();l.copyBufferToTexture({buffer:o,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),E.endCommandEncoder(l)}clone(){let e=new Et(this.width,this.height,this.format,this.useMipmap,this.usage,this.numberLayer,this.sampleCount,this.clear,this.autoResize);return e.name="clone_"+e.name,e}readTextureToImage(){let e=I.device,t=I.windowWidth,a=I.windowHeight,r=new Float32Array(t*a*4);const i=e.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});return E.beginCommandEncoder().copyTextureToBuffer({texture:this.getGPUTexture()},{buffer:i},[t,a]),i.getMappedRange(0,r.byteLength)}}class We{storeOp="store";loadOp="clear";clearValue=[0,0,0,0]}class nt{label;customSize=!1;renderTargets;rtDescriptors;zPreTexture;depthTexture;depthViewIndex=0;depthCleanValue=1;depthLoadOp="clear";isOutTarget=!0;constructor(e,t,a,r,i=!0){this.renderTargets=e,this.rtDescriptors=t,this.depthTexture=a,this.zPreTexture=r,this.isOutTarget=i}clone2Frame(e){e.renderTargets.push(...this.renderTargets.concat());for(let t=0;t<this.rtDescriptors.length;t++){const a=this.rtDescriptors[t];let r=new We;r.loadOp=a.loadOp,r.storeOp=a.storeOp,r.clearValue=a.clearValue,e.rtDescriptors.push(r)}e.depthTexture=this.depthTexture,e.zPreTexture=this.zPreTexture,e.customSize=this.customSize}clone(){let e=new nt([],[]);return this.clone2Frame(e),e}}class Be extends nt{static colorPass_GBuffer="ColorPassGBuffer";static reflections_GBuffer="reflections_GBuffer";static gui_GBuffer="gui_GBuffer";static gBufferMap=new Map;_colorBufferTex;_compressGBufferTex;constructor(){super([],[])}createGBuffer(e,t,a,r=!0,i=!0,s){let o=this.renderTargets,l=this.rtDescriptors;if(i){let f=new We;f.loadOp="clear",this._colorBufferTex=wt.createRTTexture(e+Qa.colorBufferTex_NAME,t,a,le.rgba16float,!0),o.push(this._colorBufferTex),l.push(f)}this._compressGBufferTex=new Et(t,a,le.rgba32float,!1,void 0,1,0,!0,!0),o.push(this._compressGBufferTex),s?this.depthTexture=s:(this.depthTexture=new Et(t,a,le.depth24plus,!1,void 0,1,0,!0,!0),this.depthTexture.name=e+"_depthTexture");let c;c=new We,l.push(c)}getPositionMap(){return this.renderTargets[1]}getNormalMap(){return this.renderTargets[2]}getColorTexture(){return this._colorBufferTex}getCompressGBufferTexture(){return this._compressGBufferTex}static getGBufferFrame(e,t=0,a=0,r=!0,i){let s;if(Be.gBufferMap.has(e))s=Be.gBufferMap.get(e);else{s=new Be;let o=I.presentationSize;s.createGBuffer(e,t==0?o[0]:t,a==0?o[1]:a,t!=0&&a!=0,r,i),Be.gBufferMap.set(e,s)}return s}static getGUIBufferFrame(){let e=this.getGBufferFrame(this.colorPass_GBuffer);return Be.getGBufferFrame(Be.gui_GBuffer,0,0,!0,e.depthTexture)}clone(){let e=new Be;return this.clone2Frame(e),e}}class Ye{static rendererPassState=new Map;static createRendererPassState(e,t=null){let a=Ye.rendererPassState.get(e);if(a||(a=new u0,a.label=e.label,a.customSize=e.customSize,a.rtFrame=e,a.zPreTexture=e.zPreTexture,a.depthTexture=e.depthTexture,a.depthViewIndex=e.depthViewIndex,a.isOutTarget=e.isOutTarget,a.depthCleanValue=e.depthCleanValue,a.depthLoadOp=e.depthLoadOp,Ye.rendererPassState.set(e,a)),e&&e.renderTargets.length>0){a.renderTargets=e.renderTargets,a.rtTextureDescriptors=e.rtDescriptors,a.renderPassDescriptor=Ye.getRenderPassDescriptor(a),a.renderPassDescriptor.depthStencilAttachment&&(a.renderPassDescriptor.depthStencilAttachment.depthLoadOp=e.depthLoadOp),t=="load"&&e?.renderTargets[0]&&e.renderTargets[0].name.startsWith(Be.gui_GBuffer)&&(a.renderPassDescriptor.colorAttachments[0].loadOp="load"),a.depthLoadOp=e.depthLoadOp,a.renderBundleEncoderDescriptor=Ye.getRenderBundleDescriptor(a),a.renderTargetTextures=[];for(let r=0;r<e.renderTargets.length;r++){const i=e.renderTargets[r];a.renderTargetTextures[r]={format:i.format},i.name.indexOf(Qa.colorBufferTex_NAME)!=-1&&(a.outColor=r)}}else a.renderPassDescriptor=Ye.getRenderPassDescriptor(a,t),a.renderBundleEncoderDescriptor=Ye.getRenderBundleDescriptor(a),a.renderTargetTextures=[{format:I.presentationFormat}],a.outColor=0;return a}static getRenderPassDescriptor(e,t=null){if(e.renderPassDescriptor)return e.renderPassDescriptor;I.device,I.presentationSize;let a=[];if(e.renderTargets&&e.renderTargets.length>0){e.renderTargets[0].width,e.renderTargets[0].height;for(let i=0;i<e.renderTargets.length;i++){const s=e.renderTargets[i],o=e.rtTextureDescriptors[i];a.push({view:s.getGPUView(),resolveTarget:void 0,loadOp:o.loadOp,clearValue:o.clearValue,storeOp:o.storeOp})}}else if(!e.customSize){let i=I.canvasConfig&&I.canvasConfig.alpha?[1,1,1,0]:[0,0,0,1];e.isOutTarget==!0&&a.push({view:void 0,resolveTarget:void 0,loadOp:I.canvasConfig&&I.canvasConfig.alpha||t!=null?"load":"clear",clearValue:i,storeOp:"store"})}let r=null;return e.depthTexture||e.zPreTexture?(e.zPreTexture&&(e.depthTexture=e.zPreTexture),r={label:`${e.label} renderPassDescriptor zPreTexture${e.zPreTexture?"load":"clear"}`,colorAttachments:a,depthStencilAttachment:{view:e.depthTexture.getGPUView(),depthLoadOp:e.zPreTexture?"load":e.depthLoadOp,depthClearValue:e.zPreTexture?1:e.depthCleanValue,depthStoreOp:"store"}}):r={colorAttachments:a,label:"renderPassDescriptor not writeDepth"},e.renderPassDescriptor=r,r}static getRenderBundleDescriptor(e){if(e.renderBundleEncoderDescriptor)return e.renderBundleEncoderDescriptor;I.presentationSize;let t=[];if(e.renderTargets&&e.renderTargets.length>0){e.renderTargets[0].width,e.renderTargets[0].height;for(let r=0;r<e.renderTargets.length;r++){const i=e.renderTargets[r];t.push(i.format)}}let a=null;return e.depthTexture?a={colorFormats:t,depthStencilFormat:e.depthTexture.format}:a={colorFormats:t},e.renderBundleEncoderDescriptor=a,e.renderBundleEncoderDescriptor}}class $r extends Ve{width;height;segmentW;segmentH;up;constructor(e,t,a=1,r=1,i=g.Y_AXIS){super(),this.width=e,this.height=t,this.segmentW=a,this.segmentH=r,this.up=i,this.buildGeometry(this.up)}buildGeometry(e){var t,a,r,i,s=this.segmentW+1;(this.segmentH+1)*s,this.bounds=new Ce(g.ZERO.clone(),new g(this.width,1,this.height)),r=this.segmentH*this.segmentW*6;let o=(this.segmentW+1)*(this.segmentH+1),l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),h;this.segmentW*this.segmentH*2*3>=Uint16Array.length?h=new Uint32Array(this.segmentW*this.segmentH*2*3):h=new Uint16Array(this.segmentW*this.segmentH*2*3),r=0;for(var b=0,A=0,m=0,p=0;p<=this.segmentH;++p)for(var D=0;D<=this.segmentW;++D){switch(t=(D/this.segmentW-.5)*this.width,a=(p/this.segmentH-.5)*this.height,e){case g.Y_AXIS:l[b++]=t,l[b++]=0,l[b++]=a,c[A++]=0,c[A++]=1,c[A++]=0;break;case g.Z_AXIS:l[b++]=t,l[b++]=-a,l[b++]=0,c[A++]=0,c[A++]=0,c[A++]=1;break;case g.X_AXIS:l[b++]=0,l[b++]=t,l[b++]=a,c[A++]=1,c[A++]=0,c[A++]=0;break;default:l[b++]=t,l[b++]=0,l[b++]=a,c[A++]=0,c[A++]=1,c[A++]=0;break}f[m++]=D/this.segmentW,f[m++]=p/this.segmentH,D!=this.segmentW&&p!=this.segmentH&&(i=D+p*s,h[r++]=i+1,h[r++]=i,h[r++]=i+s,h[r++]=i+1,h[r++]=i+s,h[r++]=i+s+1)}this.setIndices(h),this.setAttribute(G.position,l),this.setAttribute(G.normal,c),this.setAttribute(G.uv,f),this.setAttribute(G.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}var S2=Object.getOwnPropertyDescriptor,x2=(n,e,t,a)=>{for(var r=a>1?void 0:a?S2(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.QuadShader=class extends gt{constructor(e="QuadGlsl_vs",t="QuadGlsl_fs"){super();let a=new qe(e,t);this.addRenderPass(a);let r=a.shaderState;a.blendMode=Ae.NONE,r.frontFace="cw",r.depthWriteEnabled=!1,r.depthCompare=it.always,r.multisample=0,this.setTexture("baseMap",B.res.blackTexture),this.setUniformFloat("x",0),this.setUniformFloat("y",0),this.setUniformFloat("width",100),this.setUniformFloat("height",100)}},d.QuadShader=x2([Ta(d.QuadShader,"QuadShader")],d.QuadShader);class Rn extends d.Object3D{width=128;height=128;quadRenderer;material;rendererPassState;quadShader;constructor(e="QuadGlsl_vs",t="QuadGlsl_fs",a,r=0,i=!1){super();let s=a?a.renderTargets:[];this.material=new Dt,this.quadShader=new d.QuadShader(e,t),this.material.shader=this.quadShader,this.quadRenderer=this.addComponent(d.MeshRenderer),this.quadRenderer.material=this.material,this.quadRenderer.castGI=!1,this.quadRenderer.castShadow=!1,this.quadRenderer.drawType=i?2:0,this.quadRenderer.geometry=new $r(100,100,1,1),this.quadRenderer.material=this.material,this.quadRenderer.__start(),this.quadRenderer._enable=!0,this.quadRenderer.onEnable(),this.rendererPassState=Ye.createRendererPassState(a,"load"),r>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=I.device.createTexture({size:{width:I.presentationSize[0],height:I.presentationSize[1]},sampleCount:r,format:s.length>0?s[0].format:I.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT})),I.addEventListener(nr.RESIZE,o=>{this.rendererPassState=Ye.createRendererPassState(a,"load"),r>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=I.device.createTexture({size:{width:I.presentationSize[0],height:I.presentationSize[1]},sampleCount:r,format:s.length>0?s[0].format:I.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT}))},this)}renderTarget(e,t,a){let r=e.camera,i=E.beginRenderPass(a,t.rendererPassState);E.bindCamera(i,r),t.quadRenderer.nodeUpdate(e,de.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,de.COLOR,t.rendererPassState,null,i),E.endPass(i)}renderToViewQuad(e,t,a,r){let i=e.camera;t.quadShader.setTexture("baseMap",r);let s=E.beginRenderPass(a,t.rendererPassState);E.bindCamera(s,i),t.quadRenderer.nodeUpdate(e,de.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,de.COLOR,t.rendererPassState,null,s),E.endPass(s)}}class wt{static rtTextureMap;static rtViewQuad;static init(){this.rtTextureMap=new Map,this.rtViewQuad=new Map}static createRTTexture(e,t,a,r,i=!1,s=0){let o=this.rtTextureMap.get(e);return o||(e==Qa.colorBufferTex_NAME?o=new Et(t,a,r,i,void 0,1,s,!1):o=new Et(t,a,r,i,void 0,1,s,!0),o.name=e,wt.rtTextureMap.set(e,o)),o}static createRTTextureArray(e,t,a,r,i=1,s=!1,o=0){let l=this.rtTextureMap.get(e);return l||(l=new Et(t,a,r,s,void 0,i,o),l.name=e,wt.rtTextureMap.set(e,l)),l}static createViewQuad(e,t,a,r,i=0){let s=new nt([r],[new We]),o=new Rn(t,a,s,i);return wt.rtViewQuad.set(e,o),o}static getTexture(e){return this.rtTextureMap.get(e)}static CreateSplitTexture(e){let t=this.getTexture(Qa.colorBufferTex_NAME),a=this.getTexture(e+"_split");return a||(a=this.createRTTexture(e+"_split",t.width,t.height,t.format,!1)),a}static WriteSplitColorTexture(e){let t=this.getTexture(Qa.colorBufferTex_NAME),a=this.getTexture(e+"_split");const r=E.beginCommandEncoder();r.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:a.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:a.width,height:a.height,depthOrArrayLayers:1}),E.endCommandEncoder(r)}}class In{command;encoder;rendererPassStates;rtFrame;constructor(e){this.rtFrame=e,this.rendererPassStates=[]}clean(){this.rendererPassStates.length=0,E.cleanCache()}beginContinueRendererPassState(e="load",t="load"){if(this.rendererPassStates.length>0){let a=this.rtFrame.clone();for(const i of a.rtDescriptors)i.loadOp="load";a.depthLoadOp=t;let r=Ye.createRendererPassState(a,e);return this.rendererPassStates.push(r),r}else{this.rtFrame.depthLoadOp=t;let a=Ye.createRendererPassState(this.rtFrame,e);return this.rendererPassStates.push(a),a}}get rendererPassState(){return this.rendererPassStates[this.rendererPassStates.length-1]}beginOpaqueRenderPass(){this.beginContinueRendererPassState("clear","clear"),this.begineNewCommand(),this.beginNewEncoder()}beginTransparentRenderPass(){this.beginContinueRendererPassState("load","load"),this.begineNewCommand(),this.beginNewEncoder()}specialtRenderPass(){this.beginContinueRendererPassState("load","load"),this.begineNewCommand(),this.beginNewEncoder()}endRenderPass(){this.endEncoder(),this.endCommand()}begineNewCommand(){return this.command=E.beginCommandEncoder(),this.command}endCommand(){E.endCommandEncoder(this.command),this.command=null}beginNewEncoder(){return this.encoder=E.beginRenderPass(this.command,this.rendererPassState),this.encoder}endEncoder(){E.endPass(this.encoder),this.encoder=null}}class Ma extends ja{rendererPassState;splitRendererPassState;useRenderBundle=!1;debugViewQuads;debugTextures;renderContext;_rendererType;_rtFrame;get passType(){return this._rendererType}set passType(e){this._rendererType=e}constructor(){super(),this.debugTextures=[],this.debugViewQuads=[]}setRenderStates(e){if(this._rtFrame=e,e){this.rendererPassState=Ye.createRendererPassState(e);let t=e.clone();t.depthLoadOp="load";for(const a of t.rtDescriptors)a.loadOp="load";this.splitRendererPassState=Ye.createRendererPassState(t)}this.renderContext=new In(e)}getRenderContext(e){return this._rtFrame=e,new In(e)}setIrradiance(e,t){this.rendererPassState.irradianceBuffer=[e,t]}compute(e,t){}render(e,t,a,r=!1){E.cleanCache();let i=e.camera,s=e.scene;this.rendererPassState.camera3D=i;let o=$.instance.getRenderNodes(s,i),l=this.renderBundleOp(e,o,t,a),c=r?[]:this.renderBundleTr(e,o,t,a);{let f=E.beginCommandEncoder(),h=E.beginRenderPass(f,this.rendererPassState);l.length>0&&h.executeBundles(l),!r&&$.instance.sky&&(E.bindCamera(h,i),$.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,h)),this.drawRenderNodes(e,h,f,o.opaqueList,t),E.endPass(h),E.endCommandEncoder(f)}{let f=E.beginCommandEncoder(),h=E.beginRenderPass(f,this.rendererPassState);c.length>0&&h.executeBundles(c),r||(E.bindCamera(h,i),this.drawRenderNodes(e,h,f,o.transparentList,t)),E.endPass(h),E.endCommandEncoder(f)}}nodeUpload(e,t,a){}occlusionRenderNodeTest(e,t,a){return a?a.occlusionRenderNodeTest(e)>0:!0}renderOp(e,t,a,r,i){}renderTr(e,t,a,r,i){}renderBundleOp(e,t,a,r){let i=$.instance.getOpRenderGroup(e.scene);if(i){let s=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))s.push(o.bundleMap.get(this._rendererType));else{let l=E.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),s.push(c)}}),s}return[]}renderBundleTr(e,t,a,r){let i=$.instance.getTrRenderGroup(e.scene);if(i){let s=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))s.push(o.bundleMap.get(this._rendererType));else{let l=E.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),s.push(c)}}),s}return[]}recordRenderBundleNode(e,t,a,r){E.bindCamera(t,e.camera),E.bindGeometryBuffer(t,a[0].geometry);for(let i=0;i<a.length;++i){let s=a[i];s.transform.worldMatrix.index,s.transform.enable&&s.recordRenderPass2(e,this._rendererType,this.rendererPassState,r,t)}}drawRenderNodes(e,t,a,r,i,s){E.bindCamera(t,e.camera);for(let o=B.setting.render.drawOpMin;o<Math.min(r.length,B.setting.render.drawOpMax);++o){let l=r[o];l.transform.enable&&l.enable&&l.renderPass2(e,this._rendererType,this.rendererPassState,s,t)}}}class b0 extends Ma{constructor(){super(),this.passType=de.COLOR}render(e,t,a,r=!1){this.renderContext.clean();let i=e.scene,s=e.camera;ve.updateCameraGroup(s),this.rendererPassState.camera3D=s;let o=$.instance.getRenderNodes(i,s),l=this.renderBundleOp(e,o,t,a),c=r?[]:this.renderBundleTr(e,o,t,a);{this.renderContext.beginOpaqueRenderPass();let f=this.renderContext.encoder;l.length>0&&($.instance.getOpRenderGroup(i),f.executeBundles(l)),!r&&$.instance.sky&&(E.bindCamera(f,s),$.instance.sky.preInit(this._rendererType)||$.instance.sky.nodeUpdate(e,this._rendererType,this.rendererPassState,a),$.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,f)),o.opaqueList&&(E.bindCamera(f,s),this.drawNodes(e,this.renderContext,o.opaqueList,t,a))}{let f=this.renderContext.encoder;c.length>0&&f.executeBundles(c),!r&&o.transparentList&&(E.bindCamera(f,s),this.drawNodes(e,this.renderContext,o.transparentList,t,a));let h=$.instance.getGraphicList();for(let u=0;u<h.length;u++){const b=h[u];b.nodeUpdate(e,this._rendererType,this.splitRendererPassState,a),b.renderPass2(e,this._rendererType,this.splitRendererPassState,a,f)}this.renderContext.endRenderPass(),ct.end("ColorPass Draw Transparent")}}drawNodes(e,t,a,r,i){let s=$.instance.getRenderShaderCollect(e);if(s){for(const o of s){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=B.setting.render.drawOpMin;o<Math.min(a.length,B.setting.render.drawOpMax);++o){let l=a[o];l.transform.enable&&l.enable&&(l.hasMask(Me.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 Tn{frustumCullingList;zVisibleList;_renderList;static enable=!0;constructor(){this._renderList=new Map}occlusionRenderNodeTest(e){return B.setting.occlusionQuery.enable?this.frustumCullingList?this.frustumCullingList[e]:0:1}zDepthRenderNodeTest(e){return this.zVisibleList?this.zVisibleList[e]:0}update(e,t){}collect(e,t){}renderCommitTesting(e,t){return!0}}class ei extends Za{constructor(e,t){super(),this.bufferType=ga.ComputeGPUBuffer,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,e,t,"ComputeGPUBuffer")}}class g0{clusterBuffer;lightAssignBuffer;assignTableBuffer;clustersUniformBuffer;constructor(e,t){this.clusterBuffer=new ei(e*2*4),this.clustersUniformBuffer=new Ct(10),this.clustersUniformBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.lightAssignBuffer=new ei(e*t),this.lightAssignBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.assignTableBuffer=new ei(e*4),this.assignTableBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e,t,a,r,i,s,o,l,c,f){this.clustersUniformBuffer.setFloat("clusterTileX",r),this.clustersUniformBuffer.setFloat("clusterTileY",i),this.clustersUniformBuffer.setFloat("clusterTileZ",s),this.clustersUniformBuffer.setFloat("numLights",o),this.clustersUniformBuffer.setFloat("maxNumLightsPerCluster",l),this.clustersUniformBuffer.setFloat("near",c),this.clustersUniformBuffer.setFloat("far",f),this.clustersUniformBuffer.setFloat("screenWidth",e),this.clustersUniformBuffer.setFloat("screenHeight",t),this.clustersUniformBuffer.setFloat("clusterPix",a),this.clustersUniformBuffer.apply()}}class Rt{static clusterTileX=16;static clusterTileY=16;static clusterTileZ=32}let m0=`
|
|
6148
|
+
`;var p2=Object.getOwnPropertyDescriptor,A2=(n,e,t,a)=>{for(var r=a>1?void 0:a?p2(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.PointCloudShader=class extends gt{constructor(){super(),X.register("pointcloud_vs_dc",t0),X.register("pointcloud_fs_dc",a0);const e=new qe("pointcloud_vs_dc","pointcloud_fs_dc");e.passType=de.COLOR,e.setShaderEntry("VertMain","FragMain"),e.topology=ls.triangle_list,e.depthWriteEnabled=!0,e.cullMode=Vt.none,e.shaderState.transparent=!1,e.shaderState.blendMode=Ae.NORMAL,e.shaderState.writeMasks=[15,0],e.shaderState.castReflection=!1,this.addRenderPass(e),this.setDefault()}setDefault(){const e=this.getDefaultColorShader(),t=new T;e.setUniform("modelMatrix",t.rawData),e.setUniformArray("tex_params",new Float32Array([0,0,0,4])),e.setUniformArray("pointParams",new Float32Array([0,0,0,128]))}},d.PointCloudShader=A2([Ta(d.PointCloudShader,"PointCloudShader")],d.PointCloudShader);class r0 extends Dt{_texParams=new Float32Array([0,0,0,4]);_pointParamsArray=new Float32Array([0,0,0,128]);constructor(){super(),this.shader=new d.PointCloudShader}setPointTextures(e,t,a,r){const i=this.shader.getDefaultColorShader();if(!i.getUniform("modelMatrix")){const s=new T;i.setUniform("modelMatrix",s.rawData)}i.setTexture("pointColor",t),i.setTexture("pointPosition",e),this._texParams[0]=a[0],this._texParams[1]=a[1],this._texParams[2]=a[2],this._texParams[3]=a[3],i.setUniformArray("tex_params",this._texParams),i.setUniformArray("pointParams",this._pointParamsArray),r&&i.setTexture("pointOrder",r),i.shaderState.depthCompare=it.less}setTransformMatrix(e){this.shader.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}setPointSize(e){this._texParams[3]=Math.max(.1,e),this.shader.getDefaultColorShader().setUniformArray("tex_params",this._texParams)}setPointShape(e){this._pointParamsArray[0]=e==="circle"?1:0,this.shader.getDefaultColorShader().setUniformArray("pointParams",this._pointParamsArray)}enableDebugFullScreen(e){this._pointParamsArray[1]=e?1:0,this.shader.getDefaultColorShader().setUniformArray("pointParams",this._pointParamsArray)}setBatchSize(e){this._pointParamsArray[3]=Math.max(1,e|0),this.shader.getDefaultColorShader().setUniformArray("pointParams",this._pointParamsArray)}}class Fn extends Ve{batchSize;constructor(e=128){super(),this.batchSize=e;const t=new Float32Array(12*e);for(let r=0;r<e;++r){const i=r*12;t.set([-1,-1,r,1,-1,r,1,1,r,-1,1,r],i)}const a=new Uint32Array(6*e);for(let r=0;r<e;++r){const i=r*4,s=r*6;a.set([0+i,1+i,2+i,0+i,2+i,3+i],s)}this.setAttribute(G.position,t),this.setIndices(a),this.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:t.length/3,firstStart:0,index:0,topology:0})}}class i0 extends dt{create(e,t,a,r=!0){let i=I.device;const s=e*4*4;this.format=le.rgba32float,this.createTextureDescriptor(e,t,1,this.format);const l=i.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(l,0,a.buffer);const c=E.beginCommandEncoder();return c.copyBufferToTexture({buffer:l,bytesPerRow:s},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),E.endCommandEncoder(c),r&&(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float"),this.gpuSampler=i.createSampler({}),this}fromBuffer(e,t,a){let r=I.device;const i=e*4*4;this.format=le.rgba32float,this.mipmapCount=1,this.createTextureDescriptor(e,t,this.mipmapCount,this.format);const s=E.beginCommandEncoder();return s.copyBufferToTexture({buffer:a,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),E.endCommandEncoder(s),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=r.createSampler({}),this}}var D2=Object.getOwnPropertyDescriptor,_2=(n,e,t,a)=>{for(var r=a>1?void 0:a?D2(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.PointCloudRenderer=class extends Ba{count=0;size=new fe;pointColor;pointPosition;pointOrder;texParams;pointCloudMaterial;_positions;get positions(){return this._positions}_colors;_orderData;_fullCount=0;get fullCount(){return this._fullCount}_batchSize=128;instanceCount=0;_texturesInitialized=!1;_debugFullScreen=!1;_centerOffset=new g;get centerOffset(){return this._centerOffset}constructor(){super()}initFromData(e,t,a){if(!e||!t||a<=0){console.error("PointCloudRenderer: Invalid input data");return}if(e.length<a*3){console.error("PointCloudRenderer: Positions array too small");return}if(t.length<a*4){console.error("PointCloudRenderer: Colors array too small");return}this.count=a,this._fullCount=a,this.size=this.evalTextureSize(a),this._positions=e,this._colors=t,this.centerizePositions(),this.buildPositionTexture(),this.buildColorTexture(),this.texParams=new Float32Array([this.count,this.size.x,this.count,4]),this.buildOrderTexture(),this.pointCloudMaterial=new r0,this.geometry=new Fn(this._batchSize),this.materials=[this.pointCloudMaterial],this.instanceCount=Math.ceil(this.count/this._batchSize)}evalTextureSize(e){let t=Math.ceil(Math.sqrt(e));const a=64;t=Math.ceil(t/a)*a;const r=Math.ceil(e/t);return new fe(t,r)}centerizePositions(){if(this.count===0)return;let e=0,t=0,a=0;for(let o=0;o<this.count;o++){const l=o*3;e+=this._positions[l+0],t+=this._positions[l+1],a+=this._positions[l+2]}const r=e/this.count,i=t/this.count,s=a/this.count;this._centerOffset.set(r,i,s);for(let o=0;o<this.count;o++){const l=o*3;this._positions[l+0]-=r,this._positions[l+1]-=i,this._positions[l+2]-=s}this.object3D.localPosition=this._centerOffset}buildPositionTexture(){const e=this.size.x|0,t=this.size.y|0,a=this.count,r=new Float32Array(e*t*4);for(let i=0;i<a;i++){const s=i*4,o=i*3;r[s+0]=this._positions[o+0],r[s+1]=this._positions[o+1],r[s+2]=this._positions[o+2],r[s+3]=0}if(a<e*t){const i=(a-1)*4;for(let s=a;s<e*t;s++){const o=s*4;r[o+0]=r[i+0],r[o+1]=r[i+1],r[o+2]=r[i+2],r[o+3]=0}}this.pointPosition=new i0().create(e,t,r),this.pointPosition.name="pointPosition",this.pointPosition.minFilter="nearest",this.pointPosition.magFilter="nearest",this.pointPosition.addressModeU="clamp-to-edge",this.pointPosition.addressModeV="clamp-to-edge"}buildColorTexture(){const e=this.size.x|0,t=this.size.y|0,a=this.count,r=new Uint8Array(e*t*4);for(let i=0;i<a;i++){const s=i*4,o=i*4;r[s+0]=this._colors[o+0],r[s+1]=this._colors[o+1],r[s+2]=this._colors[o+2],r[s+3]=this._colors[o+3]}if(a<e*t){const i=(a-1)*4;for(let s=a;s<e*t;s++){const o=s*4;r[o+0]=r[i+0],r[o+1]=r[i+1],r[o+2]=r[i+2],r[o+3]=r[i+3]}}this.pointColor=new Si().create(e,t,r,!1),this.pointColor.name="pointColor",this.pointColor.minFilter="nearest",this.pointColor.magFilter="nearest",this.pointColor.mipmapFilter="nearest",this.pointColor.addressModeU="clamp-to-edge",this.pointColor.addressModeV="clamp-to-edge"}buildOrderTexture(){const e=this.size.x*this.size.y;this._orderData=new Uint32Array(e);for(let t=0;t<e;t++)this._orderData[t]=t<this.count?t:this.count>0?this.count-1:0;this.pointOrder=new Ds().create(this.size.x,this.size.y,this._orderData),this.pointOrder.name="pointOrder",this.pointOrder.minFilter="nearest",this.pointOrder.magFilter="nearest",this.pointOrder.addressModeU="clamp-to-edge",this.pointOrder.addressModeV="clamp-to-edge"}nodeUpdate(e,t,a,r){const i=this.object3D.transform.worldMatrix;this.pointCloudMaterial.setTransformMatrix(i),this._texturesInitialized||(this.pointCloudMaterial.setPointTextures(this.pointPosition,this.pointColor,this.texParams,this.pointOrder),this.pointCloudMaterial.setBatchSize(this._batchSize),this.pointCloudMaterial.setPointSize(this.texParams[3]),this.pointCloudMaterial.enableDebugFullScreen(this._debugFullScreen),this._texturesInitialized=!0),super.nodeUpdate(e,t,a,r)}renderPass(e,t,a){const r=a.encoder;for(let i of this.materials){const s=i.getPass(t);if(!(!s||s.length===0))for(const o of s){if(!o.pipeline)continue;o.apply(this.geometry,a.rendererPassState||a),E.bindPipeline(r,o),E.bindGeometryBuffer(r,this.geometry);const c=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?E.drawIndexed(r,c.indexCount,this.instanceCount,c.indexStart,0,0):E.drawIndexed(r,c.indexCount,1,c.indexStart,0,0)}}}setPointSize(e){this.texParams[3]=Math.max(.1,e),this.pointCloudMaterial&&this.pointCloudMaterial.setPointSize(e)}setPointShape(e){this.pointCloudMaterial&&this.pointCloudMaterial.setPointShape(e)}enableDebugFullScreen(e){this._debugFullScreen=e,this.pointCloudMaterial&&this.pointCloudMaterial.enableDebugFullScreen(e)}setBatchSize(e){if(this._batchSize=Math.max(1,e|0),this.geometry){const t=this.geometry;xe.getInstance().detached(t,this),xe.getInstance().hasReference(t)||t.destroy(),this.geometry=new Fn(this._batchSize)}this.pointCloudMaterial&&(this.pointCloudMaterial.setBatchSize(this._batchSize),this.pointCloudMaterial.enableDebugFullScreen(this._debugFullScreen)),this.instanceCount=Math.ceil(this.count/this._batchSize)}destroy(e){this.pointColor&&(this.pointColor.destroy(e),this.pointColor=null),this.pointPosition&&(this.pointPosition.destroy(e),this.pointPosition=null),this.pointOrder&&(this.pointOrder.destroy(e),this.pointOrder=null),this._positions=null,this._colors=null,this._orderData=null,this.texParams=null,super.destroy(e)}},d.PointCloudRenderer=_2([Nt(d.PointCloudRenderer,"PointCloudRenderer")],d.PointCloudRenderer);class kn{static maxVector=new g(Number.MAX_VALUE*.1,Number.MAX_VALUE*.1,Number.MAX_VALUE*.1);static minVector=this.maxVector.clone().multiplyScalar(-1);static genMeshMaxVector=g.ZERO.clone();static genMeshMinVector=g.ZERO.clone();static genMeshVectorList8=[new g,new g,new g,new g,new g,new g,new g,new g];static genPointCloudBounds(e,t){t||=new Ce(g.ZERO,g.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let a=e.getComponents(d.PointCloudRenderer);if(!a)return console.warn("genPointCloudBounds: No PointCloudRenderer found on object"),t;for(const r of a){const i=r.positions,s=r.fullCount;if(!i||s===0){console.warn("genPointCloudBounds: No position data available");continue}const o=r.object3D.transform.worldMatrix,l=new g;for(let c=0;c<s;c++){const f=c*3;l.set(i[f+0],i[f+1],i[f+2]),o.transformPoint(l,l),t.expandByPoint(l)}}return t}static genGSplatBounds(e,t){t||=new Ce(g.ZERO,g.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let a=e.getComponents(d.GSplatRenderer);if(!a)return console.warn("genGSplatBounds: No GSplatRenderer found on object"),t;for(const r of a){const i=r.positions,s=r.fullCount;if(!i||s===0)return console.warn("genGSplatBounds: No position data available"),t;const o=r.object3D.transform.worldMatrix,l=new g;for(let c=0;c<s;c++){const f=c*3;l.set(i[f+0],i[f+1],i[f+2]),o.transformPoint(l,l),t.expandByPoint(l)}t.setFromMinMax(t.min,t.max)}return t}static genMeshBounds(e,t){let a=this.genMeshMinVector,r=this.genMeshMaxVector,i=this.genMeshVectorList8;t||=new Ce(g.ZERO,g.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let s=e.getComponents(d.MeshRenderer);for(const o of s)if(o&&o.geometry){let l=o.object3D.transform.worldMatrix;a.copy(o.geometry.bounds.min),r.copy(o.geometry.bounds.max),i[0].set(a.x,a.y,a.z),i[1].set(a.x,a.y,r.z),i[2].set(a.x,r.y,a.z),i[3].set(a.x,r.y,r.z),i[4].set(r.x,a.y,a.z),i[5].set(r.x,a.y,r.z),i[6].set(r.x,r.y,a.z),i[7].set(r.x,r.y,r.z);for(const c of i)l.transformPoint(c,c),t.expandByPoint(c)}return r.copyFrom(t.max),a.copyFrom(t.min),t.setFromMinMax(a,r),t}static transformBound(e,t,a){let r=this.genMeshMinVector.copyFrom(t.min),i=this.genMeshMaxVector.copyFrom(t.max),s=this.genMeshVectorList8;a||=new Ce(g.ZERO,g.ZERO),a.setFromMinMax(this.maxVector,this.minVector),s[0].set(r.x,r.y,r.z),s[1].set(r.x,r.y,i.z),s[2].set(r.x,i.y,r.z),s[3].set(r.x,i.y,i.z),s[4].set(i.x,r.y,r.z),s[5].set(i.x,r.y,i.z),s[6].set(i.x,i.y,r.z),s[7].set(i.x,i.y,i.z);for(const o of s)e.transformPoint(o,o),a.expandByPoint(o);return i.copyFrom(a.max),r.copyFrom(a.min),a.setFromMinMax(r,i),a}}class s0 extends ja{name="";_instanceID="";_numChildren;get instanceID(){return this._instanceID}transform;renderNode;entityChildren;components;waitDisposeComponents;_bound;_boundWorld;_isBoundChange=!0;_dispose=!1;get dispose(){return this._dispose}getObjectByName(e){if(e.indexOf("/")>=0){let a=e.split("/"),r=this;for(;a.length>0&&r;){let i=a.shift();if(r=r.getChildByName(i,!1),!r)return null}return r}else return this.getChildByName(e,!1)}constructor(){super(),this.entityChildren=[],this.components=new Map,this._instanceID=tn().toString(),this.waitDisposeComponents=[]}get numChildren(){return this._numChildren}addChild(e){if(e==null)throw new Error("child is null!");if(e===this)throw new Error("child is self!");return this.entityChildren.indexOf(e)==-1?(e.removeFromParent(),e.transform.parent=this.transform,this.entityChildren.push(e),this._numChildren=this.entityChildren.length,this.noticeComponents("onAddChild",e),e):null}removeChild(e){if(e===null)return;if(e===this)throw new Error("add child is self!");let t=this.entityChildren.indexOf(e);t!=-1&&(this.entityChildren.splice(t,1),e.transform.parent=null,this._numChildren=this.entityChildren.length,this.noticeComponents("onRemoveChild",e))}removeAllChild(){for(;this.numChildren>0;)this.removeChild(this.entityChildren[0])}removeSelf(){return this.removeFromParent()}removeChildByIndex(e){e>=0&&e<this.entityChildren.length?this.removeChild(this.entityChildren[e]):console.error("remove child by index , index out of range")}hasChild(e){return this.entityChildren.indexOf(e)!=-1}removeFromParent(){let e=this.transform.parent;return e&&e.object3D&&e.object3D.removeChild(this),this}getChildByIndex(e){let t=null;return e<this.entityChildren.length&&(t=this.entityChildren[e]),t}getChildByName(e,t=!0){let a=null;for(const r of this.entityChildren){if(r.name==e)return a=r,a;if(t&&(a=r.getChildByName(e,t),a))return a}return a}update(){}instantiate(){return null}onTransformLocalChange(e){this._isBoundChange=!0}get bound(){return(this._isBoundChange||!this._bound)&&this.updateBound(),this._boundWorld}set bound(e){this._bound=e,this._boundWorld=this._bound.clone(),this._isBoundChange=!0}updateBound(){return this._bound||(this._bound=new Ce,this._boundWorld=this._bound.clone(),this._isBoundChange=!0),this._isBoundChange&&(kn.transformBound(this.transform.worldMatrix,this._bound,this._boundWorld),this._isBoundChange=!1),this._boundWorld}waitUpdate(){this._dispose?(this.transform.parent&&this.transform.parent.object3D.removeChild(this),this.components.forEach((e,t)=>{e.enable=!1,e.beforeDestroy(),e.destroy()}),this.components.clear()):Ne.waitStartComponent.forEach((e,t)=>{for(;e.length>0;){const a=e.shift();a.__start(),Ne.waitStartComponent.delete(a.object3D)}})}noticeComponents(e,t){for(let a of this.components.values())a[e]?.(t)}destroy(e){this._dispose||(this.components.forEach(t=>{t.beforeDestroy(e)}),this.components.forEach(t=>{t.destroy(e)}),this.components.clear(),this.components.clear(),this.entityChildren&&(this.entityChildren.forEach(t=>{t.destroy(e)}),this.removeAllChild(),this.entityChildren=[]),this._bound&&this._bound.destroy&&(this._bound.destroy(),this._bound=null),this._boundWorld&&this._boundWorld.destroy&&(this._boundWorld.destroy(),this._boundWorld=null),this.transform.parent=null,this._dispose=!0,super.destroy())}}var B2=Object.getOwnPropertyDescriptor,v2=(n,e,t,a)=>{for(var r=a>1?void 0:a?B2(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.Object3D=class extends s0{_isScene3D;prefabRef;serializeTag;constructor(){super(),this.transform=this.addComponent(zt),this.transform.eventDispatcher.addEventListener(zt.LOCAL_ONCHANGE,this.onTransformLocalChange,this)}get isScene3D(){return this._isScene3D}forChild(e){this.entityChildren.forEach(t=>{e(t),t.forChild(e)})}addComponent(e,t){if(!this.components.has(e)){let a=new e;return a.object3D=this,this.components.set(e,a),a.__init(t),Ne.appendWaitStart(a),a}return this.components.get(e)}getOrAddComponent(e){let t=this.components.get(e);return t||(t=this.addComponent(e)),t}removeComponent(e){if(this.components.has(e)){let t=this.components.get(e);Ne.removeWaitStart(this,t),this.components.delete(e),t.__stop(),t.beforeDestroy(),t.destroy()}}hasComponent(e){return this.components.has(e)}getComponent(e){return this.components.get(e)}getComponentFromParent(e){if(!this.parent)return null;let t=this.parent.object3D.getComponent(e);return t||this.parent.object3D.getComponentFromParent(e)}getComponentsInChild(e){let t=[],a=this.components.get(e);a&&t.push(a);for(let r=0;r<this.entityChildren.length;r++){let s=this.entityChildren[r].getComponentsInChild(e);t.push(...s)}return t}getComponents(e,t,a){t||=[];let r=this.getComponent(e);r&&(r.enable||a)&&t.push(r);for(let i=0,s=this.entityChildren.length;i<s;i++){let o=this.entityChildren[i];o&&o instanceof d.Object3D&&o.getComponents(e,t,a)}return t}getComponentsExt(e,t,a){t||=[];let r=this.components.get(e);if(r&&(r.enable||a))t.push(r);else for(const i of this.entityChildren)i instanceof d.Object3D&&i.getComponentsExt(e,t,a);return t}getComponentsByProperty(e,t,a=!0,r,i){r||=[];let s;for(const o of this.components.values())o&&(o.enable||i)&&o[e]===t&&(r.push(o),s=!0);if(!(s&&a))for(const o of this.entityChildren)o instanceof d.Object3D&&o.getComponentsByProperty(e,t,a,r,i);return r}clone(){return this.instantiate()}instantiate(){let e=new d.Object3D;return e.name=this.name,e.serializeTag=this.serializeTag,e.prefabRef=this.prefabRef,this.entityChildren.forEach((t,a)=>{let r=t.instantiate();e.addChild(r)}),this.components.forEach((t,a)=>{t.cloneTo(e)}),e}get localPosition(){return this.transform.localPosition}set localPosition(e){this.transform.localPosition=e}get localRotation(){return this.transform.localRotation}set localRotation(e){this.transform.localRotation=e}get localScale(){return this.transform.localScale}set localScale(e){this.transform.localScale=e}get localQuaternion(){return this.transform.localRotQuat}set localQuaternion(e){this.transform.localRotQuat=e}notifyChange(){this.transform.notifyChange()}get parent(){return this.transform.parent}get parentObject(){return this.transform.parent.object3D}set x(e){this.transform.x=e}get x(){return this.transform.x}set y(e){this.transform.y=e}get y(){return this.transform.y}set z(e){this.transform.z=e}get z(){return this.transform.z}set scaleX(e){this.transform.scaleX=e}get scaleX(){return this.transform.scaleX}set scaleY(e){this.transform.scaleY=e}get scaleY(){return this.transform.scaleY}set scaleZ(e){this.transform.scaleZ=e}get scaleZ(){return this.transform.scaleZ}set rotationX(e){this.transform.rotationX=e}get rotationX(){return this.transform.rotationX}set rotationY(e){this.transform.rotationY=e}get rotationY(){return this.transform.rotationY}set rotationZ(e){this.transform.rotationZ=e}get rotationZ(){return this.transform.rotationZ}fixedUpdate(){}lateUpdate(){}traverse(e){e(this);for(let t=0,a=this.entityChildren.length;t<a;t++){let r=this.entityChildren[t];r instanceof d.Object3D&&r.traverse(e)}}destroy(e){this.transform.eventDispatcher.removeEventListener(zt.LOCAL_ONCHANGE,this.onTransformLocalChange,this);const t=this.batchTable;t&&typeof t.destroy=="function"&&(t.destroy(),this.batchTable=null);const a=this.featureTable;a&&typeof a.destroy=="function"&&(a.destroy(),this.featureTable=null),super.destroy(e)}},d.Object3D=v2([U2],d.Object3D);function U2(n,e){return class extends d.Object3D{set active(t){this.transform.enable=t>0}get active(){return this.transform.enable?1:0}get materialColor(){return this.getComponent(d.MeshRenderer)?.material?.shader.getDefaultColorShader().baseColor}set materialColor(t){let a=this.getComponent(d.MeshRenderer)?.material;a&&(a.shader.getDefaultColorShader().baseColor=t)}notifyMaterialColorChange(t,a){this.getComponent(d.MeshRenderer).materials?.[t]?.shader.getDefaultColorShader().uniforms[a].onChange()}}}class ht{static createCamera3DObject(e,t){return this.createCamera3D(null,e,t)}static createCamera3D(e,t,a){return e||=new d.Object3D,t&&t.addChild(e),a&&(e.name=a),e.getOrAddComponent(Hr)}static UnProjection(e,t,a=1,r){let i=new g(e,t,0),s=1,o=g.HELP_0,l=I.canvas.offsetLeft,c=I.canvas.offsetTop,f=I.canvas.clientWidth,h=I.canvas.clientHeight;o.x=((i.x-l)*s/f-.5)*2,o.y=-((i.y-c)*s/h-.5)*2,o.z=a;let u=new g(0,0,0),b=T.helpMatrix2;b.copyFrom(r.projectionMatrix),b.invert();let A=T.helpMatrix;return A.identity(),A.multiply(b),A.multiply(r.transform.worldMatrix),A.perspectiveMultiplyPoint3(o,u),u}static Projection(e,t,a){let r=a||new g(0,0,0),i=T.helpMatrix;i.copyFrom(t.viewMatrix),i.multiply(t.projectionMatrix),i.perspectiveMultiplyPoint3(e,r);let s=I.canvas.clientWidth/2,o=I.canvas.clientHeight/2;return r.x=r.x*s+s,r.y=o-r.y*o,r}static UnProjection2(e,t,a,r,i){let s=i||new g(0,0,0),o=T.helpMatrix;o.copyFrom(r.pvMatrixInv);let l=I.canvas.clientWidth/2,c=I.canvas.clientHeight/2;return s.x=(e-l)/l,s.y=(c-t)/c,s.z=a,o.perspectiveMultiplyPoint3(s,s),s}}class Wt{static maxNumDirectionShadow=8;static maxNumPointShadow=8;static directionLightList;static pointLightList;static shadowLights;static init(){this.directionLightList=new Map,this.pointLightList=new Map,this.shadowLights=new Map}static createBuffer(e){if(!this.shadowLights.has(e.scene)){let t=new Float32Array(16);this.shadowLights.set(e.scene,t)}}static getShadowLightList(e){if(!e.transform.view3D)return null;if(e.lightData.lightType==ft.DirectionLight){let t=this.directionLightList.get(e.transform.view3D.scene);return t||(t=[],this.directionLightList.set(e.transform.view3D.scene,t)),t}else if(e.lightData.lightType==ft.PointLight){let t=this.pointLightList.get(e.transform.view3D.scene);return t||(t=[],this.pointLightList.set(e.transform.view3D.scene,t)),t}else if(e.lightData.lightType==ft.SpotLight){let t=this.pointLightList.get(e.transform.view3D.scene);return t||(t=[],this.pointLightList.set(e.transform.view3D.scene,t)),t}}static getShadowLightWhichScene(e,t){if(t==ft.DirectionLight){let a=this.directionLightList.get(e);return a||(a=[],this.directionLightList.set(e,a)),a}else if(t==ft.PointLight){let a=this.pointLightList.get(e);return a||(a=[],this.pointLightList.set(e,a)),a}}static getDirectShadowLightWhichScene(e){let t=this.directionLightList.get(e);return t||(t=[],this.directionLightList.set(e,t)),t}static getPointShadowLightWhichScene(e){let t=this.pointLightList.get(e);return t||(t=[],this.pointLightList.set(e,t)),t}static addShadowLight(e){if(!e.transform.view3D)return null;let t=e.transform.view3D.scene;if(e.lightData.lightType==ft.DirectionLight){let a=this.directionLightList.get(t);if(a||(a=[],this.directionLightList.set(t,a)),!e.shadowCamera){e.shadowCamera=ht.createCamera3DObject(null,"shadowCamera"),e.shadowCamera.isShadowCamera=!0;let r=-1e3;e.shadowCamera.orthoOffCenter(r,-r,r,-r,1,1e4)}return a.indexOf(e)==-1&&a.push(e),a}else if(e.lightData.lightType==ft.PointLight||e.lightData.lightType==ft.SpotLight){let a=this.pointLightList.get(t);return a&&a.length>=8||(a||(a=[],this.pointLightList.set(t,a)),a.indexOf(e)==-1&&a.push(e)),a}}static removeShadowLight(e){if(e.lightData.castShadowIndex=-1,!e.transform.view3D)return null;if(e.lightData.lightType==ft.DirectionLight){let t=this.directionLightList.get(e.transform.view3D.scene);if(t){let a=t.indexOf(e);a!=-1&&t.splice(a,1)}return e.lightData.castShadowIndex=-1,t}else if(e.lightData.lightType==ft.PointLight||e.lightData.lightType==ft.SpotLight){let t=this.pointLightList.get(e.transform.view3D.scene);if(t){let a=t.indexOf(e);a!=-1&&t.splice(a,1)}return e.lightData.castShadowIndex=-1,t}}static update(e){let t=this.shadowLights.get(e.scene),a=Wt.directionLightList.get(e.scene),r=Wt.pointLightList.get(e.scene),i=0,s=0,o=0,l=0;if(t.fill(0),a){let f=0;for(let h=0;h<a.length;h++){const u=a[h];t[h]=u.lightData.index,u.lightData.castShadowIndex=f++}s=a.length}if(r){o=s;let f=0;for(let h=o;h<r.length;h++){const u=r[h];t[h]=u.lightData.index,u.lightData.castShadowIndex=f++}l=o+r.length}ve.getAllCameraGroup().forEach(f=>{f.dirShadowStart=i,f.dirShadowEnd=s,f.pointShadowStart=o,f.pointShadowEnd=l,f.shadowLights.set(new Float32Array(t))})}}class En{uuid;usage;globalBindGroup;uniformGPUBuffer;matrixBindGroup;uniformByteLength;matrixesByteLength;shadowMatrixRaw=new Float32Array(128);csmMatrixRaw=new Float32Array(ia.Cascades*16);csmShadowBias=new Float32Array(4);shadowLights=new Float32Array(16);dirShadowStart=0;dirShadowEnd=0;pointShadowStart=0;pointShadowEnd=0;constructor(e){this.uuid=Gt(),this.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.uniformGPUBuffer=new Ct(8336),this.uniformGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBindGroup=e,this.createBindGroup()}createBindGroup(){this.uniformByteLength=this.uniformGPUBuffer.memory.shareDataBuffer.byteLength,this.matrixesByteLength=T.block*4*T.maxCount,this.globalBindGroup=I.device.createBindGroup({label:"global_bindGroupLayout",layout:An.getGlobalDataBindGroupLayout(),entries:[{binding:0,resource:{buffer:this.uniformGPUBuffer.buffer,offset:0,size:this.uniformByteLength}},{binding:1,resource:{buffer:this.matrixBindGroup.matrixBufferDst.buffer,offset:0,size:this.matrixesByteLength}}]})}setCamera(e){this.uniformGPUBuffer.setMatrix("_projectionMatrix",e.projectionMatrix),this.uniformGPUBuffer.setMatrix("_viewMatrix",e.viewMatrix),this.uniformGPUBuffer.setMatrix("_cameraWorldMatrix",e.transform.worldMatrix),this.uniformGPUBuffer.setMatrix("pvMatrixInv",e.projectionMatrixInv),this.uniformGPUBuffer.setMatrix("viewToWorld",e.cameraToWorld);let t=Wt.getDirectShadowLightWhichScene(e.transform.scene3D);this.csmShadowBias.fill(1e-4),this.shadowMatrixRaw.fill(0),this.csmMatrixRaw.fill(0);for(let l=0;l<8;l++)if(l<t.length){let c=t[l].shadowCamera;this.shadowMatrixRaw.set(c.pvMatrix.rawData,l*16)}else this.shadowMatrixRaw.set(e.transform.worldMatrix.rawData,l*16);this.uniformGPUBuffer.setFloat32Array("shadowMatrix",this.shadowMatrixRaw);let a=B.setting.shadow.shadowSize;if(ia.Cascades>1&&e.enableCSM&&t[0])for(let l=0;l<ia.Cascades;l++){let c=e.csm.children[l].shadowCamera;this.csmMatrixRaw.set(c.pvMatrix.rawData,l*16),this.csmShadowBias[l]=e.getCSMShadowBiasScale(c)}this.uniformGPUBuffer.setFloat32Array("csmShadowBias",this.csmShadowBias),this.uniformGPUBuffer.setFloat32Array("csmMatrix",this.csmMatrixRaw),this.uniformGPUBuffer.setFloat32Array("shadowLights",this.shadowLights);let r=B.setting.reflectionSetting,i=$.instance.getReflections(e.transform.scene3D).length;this.uniformGPUBuffer.setFloat("reflectionProbeSize",r.reflectionProbeSize),this.uniformGPUBuffer.setFloat("reflectionProbeMaxCount",r.reflectionProbeMaxCount),this.uniformGPUBuffer.setFloat("reflectionMapWidth",r.width),this.uniformGPUBuffer.setFloat("reflectionMapHeight",r.height),this.uniformGPUBuffer.setFloat("reflectionCount",i),this.uniformGPUBuffer.setFloat("test2",ct.testObj.testValue2),this.uniformGPUBuffer.setFloat("test3",ct.testObj.testValue3),this.uniformGPUBuffer.setFloat("test4",ct.testObj.testValue4),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",ze.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",ze.time),this.uniformGPUBuffer.setFloat("delta",ze.delta),this.uniformGPUBuffer.setFloat("shadowBias",e.getShadowBias(a)),this.uniformGPUBuffer.setFloat("skyExposure",B.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",B.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",B.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",B.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",B.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",B.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",B.setting.render.renderState_split);let s=B.inputSystem.mouseX*I.pixelRatio,o=B.inputSystem.mouseY*I.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",s),this.uniformGPUBuffer.setFloat("mouseY",o),this.uniformGPUBuffer.setFloat("windowWidth",I.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",I.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",B.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",a),this.uniformGPUBuffer.setFloat("shadowSoft",B.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",e.enableCSM?1:0),this.uniformGPUBuffer.setFloat("csmMargin",B.setting.shadow.csmMargin),this.uniformGPUBuffer.setInt32("nDirShadowStart",this.dirShadowStart),this.uniformGPUBuffer.setInt32("nDirShadowEnd",this.dirShadowEnd),this.uniformGPUBuffer.setInt32("nPointShadowStart",this.pointShadowStart),this.uniformGPUBuffer.setInt32("nPointShadowEnd",this.pointShadowEnd),this.uniformGPUBuffer.setVector3("cameraForward",e.transform.forward),this.uniformGPUBuffer.setVector4Array("frustumPlanes",e.frustum.planes),this.uniformGPUBuffer.apply()}setShadowCamera(e){this.uniformGPUBuffer.setMatrix("_projectionMatrix",e.projectionMatrix),this.uniformGPUBuffer.setMatrix("_viewMatrix",e.viewMatrix),this.uniformGPUBuffer.setMatrix("_pvMatrix",e.pvMatrix),this.uniformGPUBuffer.setMatrix("pvMatrixInv",e.projectionMatrixInv),this.uniformGPUBuffer.setMatrix("viewToWorld",e.cameraToWorld),this.csmShadowBias.fill(1e-4),this.shadowMatrixRaw.fill(0),this.csmMatrixRaw.fill(0),this.uniformGPUBuffer.setFloat32Array("shadowCamera",this.shadowMatrixRaw),this.uniformGPUBuffer.setFloat32Array("csmShadowBias",this.csmShadowBias),this.uniformGPUBuffer.setFloat32Array("csmMatrix",this.csmMatrixRaw),this.uniformGPUBuffer.setFloat32Array("shadowLights",this.shadowLights),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",ze.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",ze.time),this.uniformGPUBuffer.setFloat("delta",ze.delta),this.uniformGPUBuffer.setFloat("shadowBias",B.setting.shadow.shadowBias),this.uniformGPUBuffer.setFloat("skyExposure",B.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",B.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",B.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",B.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",B.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",B.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",B.setting.render.renderState_split);let t=B.inputSystem.mouseX*I.pixelRatio,a=B.inputSystem.mouseY*I.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",t),this.uniformGPUBuffer.setFloat("mouseY",a),this.uniformGPUBuffer.setFloat("windowWidth",I.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",I.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",B.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",B.setting.shadow.shadowSize),this.uniformGPUBuffer.setFloat("shadowSoft",B.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",0),this.uniformGPUBuffer.setFloat("csmMargin",B.setting.shadow.csmMargin),this.uniformGPUBuffer.setInt32("nDirShadowStart",this.dirShadowStart),this.uniformGPUBuffer.setInt32("nDirShadowEnd",this.dirShadowEnd),this.uniformGPUBuffer.setInt32("nPointShadowStart",this.pointShadowStart),this.uniformGPUBuffer.setInt32("nPointShadowEnd",this.pointShadowEnd),this.uniformGPUBuffer.apply()}setShadowLight(){}}class n0{setting;probesBufferData;probesBuffer;isVolumeFrameChange=!0;randomOrientation;startPosition=new g;isVolumeChange=!0;irradianceVolumeBuffer;directionDistance=20;randomSeedCount=3;useRandomIndex=0;centerDirection=new g(0,0,this.directionDistance).normalize(1);arroundPositions=[];updateOrientation(){return this.useRandomIndex++,this.useRandomIndex>=this.arroundPositions.length&&(this.useRandomIndex=0),T.fromToRotation(this.centerDirection,this.arroundPositions[this.useRandomIndex],this.randomOrientation),this.randomOrientation}init(e){this.setting=e,this.randomOrientation=new T(!1),this.randomOrientation.identity(),this.irradianceVolumeBuffer=new Ct(80),this.createFramesBuffer(),this.arroundPositions.push(this.centerDirection.clone());for(let t=0;t<this.randomSeedCount;t++){let a=Math.PI*2*t/this.randomSeedCount,r=new g(Math.sin(a),Math.cos(a),this.directionDistance).normalize(1);this.arroundPositions.push(r)}}setVolumeDataChange(){this.isVolumeChange=!0}updateProbes(e){let t=this.probesBufferData;for(let a of e){let r=a.index*4;t[r+3]=a.drawCallFrame}}createFramesBuffer(){if(!this.probesBufferData){let e=this.setting.probeXCount*this.setting.probeYCount*this.setting.probeZCount;this.probesBufferData=new Float32Array(e*4),this.probesBufferData.fill(-1),this.probesBuffer=new Pe(e*4,GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST)}}uploadBuffer(){this.isVolumeChange&&(this.fillIrradianceData(),this.isVolumeChange=!1,this.isVolumeFrameChange=!0),this.probesBuffer.setFloat32Array("uniformFramesBuffer",this.probesBufferData)}calcPosition(e,t,a,r){let i=this.setting,s=this.setting.probeSpace;return r=r||new g,r.x=e*s-s*(i.probeXCount-1)*.5+i.offsetX,r.y=t*s-s*(i.probeYCount-1)*.5+i.offsetY,r.z=a*s-s*(i.probeZCount-1)*.5+i.offsetZ,r}debugX=0;debugY=0;debugZ=0;fillIrradianceData(){let e=this.setting,t=this.calcPosition(0,0,0,this.startPosition);this.irradianceVolumeBuffer.setFloat("orientationIndex",this.randomOrientation.index),this.irradianceVolumeBuffer.setFloat("hysteresis",e.hysteresis),this.irradianceVolumeBuffer.setFloat("OctRTSideSize",e.octRTSideSize),this.irradianceVolumeBuffer.setFloat("OctRTMaxSize",e.octRTMaxSize),this.irradianceVolumeBuffer.setFloat("startX",t.x),this.irradianceVolumeBuffer.setFloat("startY",t.y),this.irradianceVolumeBuffer.setFloat("startZ",t.z),this.irradianceVolumeBuffer.setFloat("ProbeSpace",e.probeSpace),this.irradianceVolumeBuffer.setFloat("probeXCount",e.probeXCount),this.irradianceVolumeBuffer.setFloat("probeYCount",e.probeYCount),this.irradianceVolumeBuffer.setFloat("probeZCount",e.probeZCount),this.irradianceVolumeBuffer.setFloat("maxDistance",e.probeSpace*1.732),this.irradianceVolumeBuffer.setFloat("depthSharpness",e.depthSharpness),this.irradianceVolumeBuffer.setFloat("ProbeSourceTextureSize",e.probeSourceTextureSize),this.irradianceVolumeBuffer.setFloat("ProbeSize",e.probeSize),this.irradianceVolumeBuffer.setFloat("bounceIntensity",e.bounceIntensity),this.irradianceVolumeBuffer.setFloat("probeRoughness",e.probeRoughness),this.irradianceVolumeBuffer.setFloat("normalBias",e.normalBias),this.irradianceVolumeBuffer.setFloat("irradianceChebyshevBias",e.irradianceChebyshevBias),this.irradianceVolumeBuffer.setFloat("rayNumber",e.rayNumber),this.irradianceVolumeBuffer.setFloat("irradianceDistanceBias",e.irradianceDistanceBias),this.irradianceVolumeBuffer.setFloat("indirectIntensity",e.indirectIntensity),this.irradianceVolumeBuffer.setFloat("ddgiGamma",e.ddgiGamma),this.irradianceVolumeBuffer.setFloat("lerpHysteresis",e.lerpHysteresis),this.irradianceVolumeBuffer.setFloat("debugX",this.debugX),this.irradianceVolumeBuffer.setFloat("debugY",this.debugY),this.irradianceVolumeBuffer.setFloat("debugZ",this.debugZ),this.irradianceVolumeBuffer.apply()}}class o0{storageGPUBuffer;irradianceVolume;_lightList=[];constructor(){this.storageGPUBuffer=new Pe(hs.lightSize*B.setting.light.maxLight,GPUBufferUsage.COPY_SRC),this.irradianceVolume=new n0,this.irradianceVolume.init(B.setting.gi);for(let e=0;e<B.setting.light.maxLight;e++){let t=this.storageGPUBuffer.memory.allocation_node(hs.lightSize*4);this._lightList.push(t)}this.storageGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e){this.storageGPUBuffer.clean();let t=$.instance.getLights(e.scene);for(let a=0;a<t.length;a++){const r=t[a].lightData;r.index=a,this.writeLightBytes(r,this._lightList[a])}this.storageGPUBuffer.apply()}writeLightBytes(e,t){t.offset=0,t.writeFloat(e.index),t.writeInt32(e.lightType),t.writeFloat(e.radius),t.writeFloat(e.linear),t.writeVector3(e.lightPosition),t.writeFloat(e.lightMatrixIndex),t.writeVector3(e.direction),t.writeFloat(e.quadratic),t.writeRGBColor(e.lightColor),t.writeFloat(e.intensity),t.writeFloat(e.innerAngle),t.writeFloat(e.outerAngle),t.writeFloat(e.range),t.writeInt32(e.castShadowIndex),t.writeVector3(e.lightTangent),t.writeFloat(e.iesIndex)}}class l0{storageGPUBuffer;reflectionMap;sourceReflectionMap;count;constructor(){this.storageGPUBuffer=new Pe(768)}update(e){this.storageGPUBuffer.clean();let t=$.instance.getReflections(e.scene);for(let a=0;a<t.length;a++){const r=t[a];r.gid=a,this.storageGPUBuffer.setFloat("gid",r.gid),this.storageGPUBuffer.setVector3("worldPosition",r.transform.worldPosition),this.storageGPUBuffer.setFloat("radius",r.radius),this.storageGPUBuffer.setVector3("bound",r.transform.worldPosition)}this.count=t.length,this.storageGPUBuffer.apply()}}class c0 extends Za{size;constructor(e,t=0,a){super(),this.bufferType=ga.StorageGPUBuffer,this.size=e,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|t,e,a,"MatrixGPUBuffer")}writeBufferByHeap(e,t){let a;e instanceof Float64Array?a=new Float32Array(e):a=e;let r=I.device;if(a.length>0){let i=null;for(;this.mapAsyncReady.length&&(i=this.mapAsyncReady.shift(),i.usedSize!=a.byteLength);)i.destroy(),this.mapAsyncBuffersOutstanding--,i=null;i||(i=r.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,mappedAtCreation:!0}),i.usedSize=a.byteLength,this.mapAsyncBuffersOutstanding++,this.mapAsyncBuffersOutstanding>10&&console.warn(` Warning: mapAsync requests from ${this.mapAsyncBuffersOutstanding} frames ago have not resolved yet. MB of staging buffers allocated.`));let s=new Float32Array(a.buffer,a.byteOffset,t);new Float32Array(i.getMappedRange(0,t*4)).set(s),i.unmap();const l=r.createCommandEncoder();l.copyBufferToBuffer(i,0,this.buffer,0,t*4),r.queue.submit([l.finish()]),i.mapAsync(GPUMapMode.WRITE).then(()=>this.mapAsyncReady.push(i))}}}class f0{uuid;index;usage;groupBufferSize;matrixBufferDst;constructor(){this.uuid=Gt(),this.groupBufferSize=0,this.usage=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.cacheWorldMatrix()}cacheWorldMatrix(){this.groupBufferSize=T.maxCount*T.blockBytes,this.matrixBufferDst=new c0(this.groupBufferSize/4),this.matrixBufferDst.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBufferDst.buffer.label=this.groupBufferSize.toString()}writeBuffer(e){const t=T.dynamicMatrixBytes;this.matrixBufferDst.mapAsyncWrite(t,e)}}class ve{static _cameraBindGroups;static _lightEntriesMap;static _reflectionEntriesMap;static modelMatrixBindGroup;static init(){this.modelMatrixBindGroup=new f0,this._cameraBindGroups=new Map,this._lightEntriesMap=new Map,this._reflectionEntriesMap=new Map}static getAllCameraGroup(){return this._cameraBindGroups}static getCameraGroup(e){let t=this._cameraBindGroups.get(e);return t||(t=new En(this.modelMatrixBindGroup),this._cameraBindGroups.set(e,t)),e.isShadowCamera?t.setShadowCamera(e):t.setCamera(e),t}static updateCameraGroup(e){let t=this._cameraBindGroups.get(e);t||(t=new En(this.modelMatrixBindGroup),this._cameraBindGroups.set(e,t)),e.isShadowCamera?t.setShadowCamera(e):t.setCamera(e)}static getLightEntries(e){e||console.log("getLightEntries scene is null");let t=this._lightEntriesMap.get(e);return t||(t=new o0,this._lightEntriesMap.set(e,t)),this._lightEntriesMap.get(e)}static getReflectionEntries(e){e||console.log("getLightEntries scene is null");let t=this._reflectionEntriesMap.get(e);return t||(t=new l0,this._reflectionEntriesMap.set(e,t)),this._reflectionEntriesMap.get(e)}}class E{static lastGeometry;static lastPipeline;static lastShader;static drawCount=0;static renderPassCount=0;static geometryCount=0;static pipelineCount=0;static matrixCount=0;static lastRenderPassState;static LastCommand;static multiTextureViewCache=new WeakMap;static swapchainTextureCache={texture:null,view:null};static bindPipeline(e,t){if(E.lastShader!=t)E.lastShader=t;else return!1;E.lastPipeline!=t.pipeline&&(E.lastPipeline=t.pipeline,e.setPipeline(t.pipeline));for(let a=1;a<t.bindGroups.length;a++){const r=t.bindGroups[a];r&&e.setBindGroup(a,r)}return!0}static bindCamera(e,t){let a=ve.getCameraGroup(t);e.setBindGroup(0,a.globalBindGroup)}static bindGeometryBuffer(e,t){if(this.lastGeometry!=t&&(this.lastGeometry=t,t.indicesBuffer)){e.setIndexBuffer(t.indicesBuffer.indicesGPUBuffer.buffer,t.indicesBuffer.indicesFormat);let a=t.vertexBuffer.vertexGPUBuffer,r=t.vertexBuffer.vertexBufferLayouts;for(let i=0;i<r.length;i++){const s=r[i];e.setVertexBuffer(i,a.buffer,s.offset,s.size)}}}static cleanCache(){this.lastGeometry=null,this.lastPipeline=null,this.lastShader=null}static createPipeline(e){return ct.countStart("GPUContext","pipeline"),I.device.createRenderPipeline(e)}static beginCommandEncoder(){return ct.countStart("GPUContext","beginCommandEncoder"),this.LastCommand&&I.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=I.device.createCommandEncoder(),this.LastCommand}static endCommandEncoder(e){this.LastCommand==e&&(I.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=null,ct.countStart("GPUContext","endCommandEncoder"))}static recordBundleEncoder(e){return I.device.createRenderBundleEncoder(e)}static beginRenderPass(e,t){if(this.cleanCache(),this.renderPassCount++,this.lastRenderPassState=t,t.depthTexture){let a=t.renderPassDescriptor.depthStencilAttachment;a.view=t.depthTexture.getGPUView()}if(t.renderTargets&&t.renderTargets.length>0){for(let a=0;a<t.renderTargets.length;++a){const r=t.renderTargets[a];let i=t.renderPassDescriptor.colorAttachments[a];if(t.multisample>0&&t.renderTargets.length==1){let s=this.multiTextureViewCache.get(t.multiTexture);s||(s=t.multiTexture.createView(),this.multiTextureViewCache.set(t.multiTexture,s)),i.view=s,i.resolveTarget=r.getGPUView()}else i.view=r.getGPUView()}return e.beginRenderPass(t.renderPassDescriptor)}else{let a=t.renderPassDescriptor.colorAttachments[0];if(a){const r=I.context.getCurrentTexture();if(t.multisample>0){let i=this.multiTextureViewCache.get(t.multiTexture);i||(i=t.multiTexture.createView(),this.multiTextureViewCache.set(t.multiTexture,i)),a.view=i,this.swapchainTextureCache.texture!==r&&(this.swapchainTextureCache.texture=r,this.swapchainTextureCache.view=r.createView()),a.resolveTarget=this.swapchainTextureCache.view}else this.swapchainTextureCache.texture!==r&&(this.swapchainTextureCache.texture=r,this.swapchainTextureCache.view=r.createView()),a.view=this.swapchainTextureCache.view}return e.beginRenderPass(t.renderPassDescriptor)}}static drawIndexed(e,t,a,r,i,s){e.drawIndexed(t,a,r,i,s),this.drawCount++}static draw(e,t,a,r,i){e.draw(t,a,r,i),this.drawCount++}static endPass(e){e.insertDebugMarker("end"),e.end()}static computeCommand(e,t){let a=e.beginComputePass();for(let r=0;r<t.length;r++)t[r].compute(a);a.end()}static copyTexture(e,t,a){e.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:a.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:a.width,height:a.height,depthOrArrayLayers:1})}}class d0{source;input;output;reset(e){this.input&&this.input.destroy(),this.output&&this.output.destroy(),this.input=this.output=null,this.source=e}apply(e){if(this.source){if(!this.input){let t=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this.input=new Pe(this.source.length,t,this.source),this.input.apply()}if(!this.output){let t=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC;this.output=new Pe(e*3,t),this.output.apply()}}}}class h0{enable;morphTargetsRelative;MaxMorphTargetCount=64;_computeConfigArray;_computeConfigBuffer;_morphInfluenceArray;_morphInfluenceBuffer;_positionAttrDataGroup;_normalAttrDataGroup;_isInfluenceDirty;_morphTargetCount;_totalVertexCount;_computeShader;_computeShaders;_computeWorkGroupXY=1;_collectMorphTargetData;_blendTarget;constructor(){this._isInfluenceDirty=!0,this.generateGPUBuffer(),this._positionAttrDataGroup=new d0,this._normalAttrDataGroup=new d0}initMorphTarget(e){this._collectMorphTargetData=this.collectMorphTargetList(e),this._computeShader&&this._computeShader.destroy();let t=Xt.CsMain;this._computeShader=new Se(t),this._collectMorphTargetData.mergedNormal?this._computeShader.setDefine("USE_MORPHNORMALS",!0):this._computeShader.deleteDefine("USE_MORPHNORMALS"),this._computeShaders=[this._computeShader],this._isInfluenceDirty=!0,this._morphTargetCount=this._collectMorphTargetData.mtCount,this._totalVertexCount=this._collectMorphTargetData.vCount,this._morphInfluenceArray.fill(0),this._computeWorkGroupXY=this.calcWorkGroup(this._totalVertexCount),this._positionAttrDataGroup.reset(this._collectMorphTargetData.mergedPos),this._normalAttrDataGroup.reset(this._collectMorphTargetData.mergedNormal)}applyRenderShader(e){this.uploadMorphTargetBuffer(),this.uploadConfigGBuffer(),e.setUniformBuffer("morphTargetConfig",this._computeConfigBuffer),e.setStorageBuffer("morphTargetOpPositions",this._positionAttrDataGroup.output),this._collectMorphTargetData.mergedNormal&&e.setStorageBuffer("morphTargetOpNormals",this._normalAttrDataGroup.output)}computeMorphTarget(e){this.uploadConfigGBuffer(),this.uploadMorphTargetBuffer(),this._computeShader.setUniformBuffer("morphTargetConfig",this._computeConfigBuffer),this._computeShader.setStorageBuffer("morphTargetInfluence",this._morphInfluenceBuffer),this._computeShader.setStorageBuffer("morphTargetPositions",this._positionAttrDataGroup.input),this._computeShader.setStorageBuffer("morphTargetOpPositions",this._positionAttrDataGroup.output),this._collectMorphTargetData.mergedNormal&&(this._computeShader.setStorageBuffer("morphTargetNormals",this._normalAttrDataGroup.input),this._computeShader.setStorageBuffer("morphTargetOpNormals",this._normalAttrDataGroup.output)),this._computeShader.workerSizeX=this._computeWorkGroupXY,this._computeShader.workerSizeY=this._computeWorkGroupXY,this._computeShader.workerSizeZ=1,E.computeCommand(e,this._computeShaders)}updateInfluence(e,t){this._isInfluenceDirty=!0,this._morphInfluenceArray[e]=t}get blendShape(){return this._blendTarget}collectMorphTargetList(e){let t=this.collectAttribute("a_morphPositions_",e),a=t.length,r=t[0].data.length/3;if(this._blendTarget={},e.blendShapeData)for(let l=0;l<e.blendShapeData.shapeIndexs.length;l++){let c=e.blendShapeData.shapeIndexs[l],f=e.blendShapeData.shapeNames[l].split("."),h=f[f.length-1];this._blendTarget[h]=u=>this.updateInfluence(c,u)}let i=new Float32Array(r*a*3);{let l=0;for(let c=0;c<a;c++){let f=t[c];i.set(f.data,l),l+=f.data.length}}let s=this.collectAttribute("a_morphNormals_",e),o;if(s&&s.length>0){let l=0;o=new Float32Array(r*a*3);for(let c=0;c<a;c++){let f=s[c];o.set(f.data,l),l+=f.data.length}}return{mtCount:a,vCount:r,mergedPos:i,mergedNormal:o}}collectAttribute(e,t){let a=[];for(let r=0;r<this.MaxMorphTargetCount;r++){let i=e+r,s=t.getAttribute(i);if(s)a[r]=s;else break}return a}uploadConfigGBuffer(){if(this._isInfluenceDirty){let e=0;for(let t=0;t<this._morphTargetCount;t++)e+=this._morphInfluenceArray[t];this._morphInfluenceBuffer.setFloat32Array("data",this._morphInfluenceArray),this._morphInfluenceBuffer.apply(),this._computeConfigArray[0]=this.morphTargetsRelative?1:1-e,this._computeConfigArray[1]=this._morphTargetCount,this._computeConfigArray[2]=this._totalVertexCount,this._computeConfigArray[3]=this._computeWorkGroupXY,this._computeConfigBuffer.setFloat32Array("data",this._computeConfigArray),this._computeConfigBuffer.apply(),this._isInfluenceDirty=!1}}calcWorkGroup(e){let t=Math.ceil(Math.sqrt(e)),a=Math.ceil(Math.log2(t));return t=Math.pow(2,a),t}uploadMorphTargetBuffer(){this._positionAttrDataGroup.output||this._positionAttrDataGroup.apply(this._totalVertexCount),this._normalAttrDataGroup.output||this._normalAttrDataGroup.apply(this._totalVertexCount)}generateGPUBuffer(){this._computeConfigArray=new Float32Array(4),this._computeConfigBuffer=new Ct(4),this._morphInfluenceArray=new Float32Array(this.MaxMorphTargetCount);let e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this._morphInfluenceBuffer=new Pe(this.MaxMorphTargetCount,e)}destroy(e){this._computeConfigBuffer&&(this._computeConfigBuffer.destroy(e),this._computeConfigBuffer=null),this._morphInfluenceBuffer&&(this._morphInfluenceBuffer.destroy(e),this._morphInfluenceBuffer=null),this._computeShader&&(this._computeShader.destroy(e),this._computeShader=null),this._positionAttrDataGroup&&(this._positionAttrDataGroup.input&&this._positionAttrDataGroup.input.destroy(e),this._positionAttrDataGroup.output&&this._positionAttrDataGroup.output.destroy(e),this._positionAttrDataGroup=null),this._normalAttrDataGroup&&(this._normalAttrDataGroup.input&&this._normalAttrDataGroup.input.destroy(e),this._normalAttrDataGroup.output&&this._normalAttrDataGroup.output.destroy(e),this._normalAttrDataGroup=null),this._computeConfigArray=null,this._morphInfluenceArray=null,this._collectMorphTargetData=null,this._blendTarget=null,this._computeShaders=null}}var y2=Object.defineProperty,C2=Object.getOwnPropertyDescriptor,wn=(n,e,t,a)=>{for(var r=a>1?void 0:a?C2(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=(a?s(e,t,r):s(r))||r);return a&&r&&y2(e,t,r),r};d.MeshRenderer=class extends Ba{receiveShadow;morphData;constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(e){e.addComponent(d.MeshRenderer).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.receiveShadow=e.receiveShadow,this}get geometry(){return this._geometry}set geometry(e){if(super.geometry=e,e){let t=e.morphTargetDictionary!=null;t&&(this.morphData||=new h0,this.morphData.morphTargetsRelative=e.morphTargetsRelative,this.morphData.initMorphTarget(e)),this.morphData&&(this.morphData.enable=t),this.morphData?.enable?this.addRendererMask(Me.MorphTarget):this.removeRendererMask(Me.MorphTarget),this.object3D.bound=this._geometry.bounds.clone()}else this.morphData&&(this.morphData.enable=!1),this.removeRendererMask(Me.MorphTarget);this._readyPipeline||(this.initPipeline(),this._computes&&(this.onCompute=os(this.onCompute,()=>{for(let t=0;t<this._computes.length;t++)this._computes[t].onUpdate()})))}get material(){return this._materials[0]}set material(e){this.materials=[e]}setMorphInfluence(e,t){if(this.morphData&&this.morphData.enable){let a=this._geometry.morphTargetDictionary[e];a>=0&&this.morphData.updateInfluence(a,t)}}setMorphInfluenceIndex(e,t){this.morphData&&this.morphData.enable&&e>=0&&this.morphData.updateInfluence(e,t)}onCompute(e,t){this.morphData&&this.morphData.enable&&this.morphData.computeMorphTarget(t)}nodeUpdate(e,t,a,r){if(this.morphData&&this.morphData.enable)for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(t);if(o)for(let l=0;l<o.length;l++)this.morphData.applyRenderShader(o[l])}super.nodeUpdate(e,t,a,r)}destroy(e){this.morphData&&(this.morphData.destroy(e),this.morphData=null),super.destroy(e)}},wn([jr],d.MeshRenderer.prototype,"geometry",1),wn([jr],d.MeshRenderer.prototype,"material",1),d.MeshRenderer=wn([Nt(d.MeshRenderer,"MeshRenderer")],d.MeshRenderer);class Qa{static compressGBufferTex_NAME="compressGBufferTex_NAME";static colorBufferTex_NAME="colorBufferTex";static positionBufferTex_NAME="positionBufferTex";static normalBufferTex_NAME="normalBufferTex";static materialBufferTex_NAME="materialBufferTex";static zBufferTexture_NAME="zBufferTexture";static zPreDepthTexture_NAME="zPreDepthTexture";static outTex_NAME="outTex"}class u0{label="";customSize=!1;zPreTexture=null;depthTexture=null;renderTargetTextures;outColor=-1;renderTargets;rtTextureDescriptors;irradianceBuffer;multisample=0;multiTexture;depthViewIndex=0;depthCleanValue=0;isOutTarget=!0;camera3D;rtFrame;renderPassDescriptor;renderBundleEncoderDescriptor;depthLoadOp;getLastRenderTexture(){return this.renderTargets&&this.renderTargets.length>0?this.renderTargets[0]:B.res.redTexture}}class Et extends dt{resolveTarget;sampleCount;autoResize;clear;constructor(e,t,a=le.rgba8unorm,r=!1,i,s=1,o=0,l=!0,c=!0){super(e,t,s),this.name=Gt(),this.autoResize=c,this.useMipmap=r,this.sampleCount=o,this.format=a,this.numberLayer=s,this.clear=l,i!=null?this.usage=i:this.usage=i|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST,this.resize(e,t),this.autoResize&&I.addEventListener(nr.RESIZE,f=>{let{width:h,height:u}=f.data;this.resize(h,u),this._textureChange=!0},this)}resize(e,t){let a=I.device;this.gpuTexture&&(dt.delayDestroyTexture(this.gpuTexture),this.gpuTexture=null,this.view=null),this.width=e,this.height=t,this.createTextureDescriptor(e,t,1,this.format,this.usage,this.numberLayer,this.sampleCount),this.useMipmap=!1,this.visibility=GPUShaderStage.COMPUTE|GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,this.format==le.rgba32float?(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=a.createSampler({})):this.format==le.depth32float?(this.samplerBindingLayout.type="filtering",this.sampler_comparisonBindingLayout.type="comparison",this.textureBindingLayout.sampleType="depth",this.gpuSampler=I.device.createSampler({}),this.gpuSampler_comparison=I.device.createSampler({compare:"less",label:"sampler_comparison"})):this.format==le.depth24plus?(this.samplerBindingLayout={type:"filtering"},this.sampler_comparisonBindingLayout={type:"comparison"},this.textureBindingLayout.sampleType="depth",this.gpuSampler=I.device.createSampler({}),this.gpuSampler_comparison=I.device.createSampler({compare:"less",label:"sampler_comparison"})):(this.samplerBindingLayout.type="filtering",this.textureBindingLayout.sampleType="float",this.sampleCount>0&&(this.textureBindingLayout.multisampled=!0),this.minFilter="linear",this.magFilter="linear",this.mipmapFilter="linear",this.addressModeU=Ht.clamp_to_edge,this.addressModeV=Ht.clamp_to_edge,this.gpuSampler=a.createSampler(this)),this._textureChange=!0}create(e,t,a=!0){let r=I.device;const i=e*4;let s=new Float32Array(e*t*4);const o=r.createBuffer({size:s.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(o,0,s);const l=E.beginCommandEncoder();l.copyBufferToTexture({buffer:o,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),E.endCommandEncoder(l)}clone(){let e=new Et(this.width,this.height,this.format,this.useMipmap,this.usage,this.numberLayer,this.sampleCount,this.clear,this.autoResize);return e.name="clone_"+e.name,e}readTextureToImage(){let e=I.device,t=I.windowWidth,a=I.windowHeight,r=new Float32Array(t*a*4);const i=e.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});return E.beginCommandEncoder().copyTextureToBuffer({texture:this.getGPUTexture()},{buffer:i},[t,a]),i.getMappedRange(0,r.byteLength)}}class We{storeOp="store";loadOp="clear";clearValue=[0,0,0,0]}class nt{label;customSize=!1;renderTargets;rtDescriptors;zPreTexture;depthTexture;depthViewIndex=0;depthCleanValue=1;depthLoadOp="clear";isOutTarget=!0;constructor(e,t,a,r,i=!0){this.renderTargets=e,this.rtDescriptors=t,this.depthTexture=a,this.zPreTexture=r,this.isOutTarget=i}clone2Frame(e){e.renderTargets.push(...this.renderTargets.concat());for(let t=0;t<this.rtDescriptors.length;t++){const a=this.rtDescriptors[t];let r=new We;r.loadOp=a.loadOp,r.storeOp=a.storeOp,r.clearValue=a.clearValue,e.rtDescriptors.push(r)}e.depthTexture=this.depthTexture,e.zPreTexture=this.zPreTexture,e.customSize=this.customSize}clone(){let e=new nt([],[]);return this.clone2Frame(e),e}}class Be extends nt{static colorPass_GBuffer="ColorPassGBuffer";static reflections_GBuffer="reflections_GBuffer";static gui_GBuffer="gui_GBuffer";static gBufferMap=new Map;_colorBufferTex;_compressGBufferTex;constructor(){super([],[])}createGBuffer(e,t,a,r=!0,i=!0,s){let o=this.renderTargets,l=this.rtDescriptors;if(i){let f=new We;f.loadOp="clear",this._colorBufferTex=wt.createRTTexture(e+Qa.colorBufferTex_NAME,t,a,le.rgba16float,!0),o.push(this._colorBufferTex),l.push(f)}this._compressGBufferTex=new Et(t,a,le.rgba32float,!1,void 0,1,0,!0,!0),o.push(this._compressGBufferTex),s?this.depthTexture=s:(this.depthTexture=new Et(t,a,le.depth24plus,!1,void 0,1,0,!0,!0),this.depthTexture.name=e+"_depthTexture");let c;c=new We,l.push(c)}getPositionMap(){return this.renderTargets[1]}getNormalMap(){return this.renderTargets[2]}getColorTexture(){return this._colorBufferTex}getCompressGBufferTexture(){return this._compressGBufferTex}static getGBufferFrame(e,t=0,a=0,r=!0,i){let s;if(Be.gBufferMap.has(e))s=Be.gBufferMap.get(e);else{s=new Be;let o=I.presentationSize;s.createGBuffer(e,t==0?o[0]:t,a==0?o[1]:a,t!=0&&a!=0,r,i),Be.gBufferMap.set(e,s)}return s}static getGUIBufferFrame(){let e=this.getGBufferFrame(this.colorPass_GBuffer);return Be.getGBufferFrame(Be.gui_GBuffer,0,0,!0,e.depthTexture)}clone(){let e=new Be;return this.clone2Frame(e),e}}class Ye{static rendererPassState=new Map;static createRendererPassState(e,t=null){let a=Ye.rendererPassState.get(e);if(a||(a=new u0,a.label=e.label,a.customSize=e.customSize,a.rtFrame=e,a.zPreTexture=e.zPreTexture,a.depthTexture=e.depthTexture,a.depthViewIndex=e.depthViewIndex,a.isOutTarget=e.isOutTarget,a.depthCleanValue=e.depthCleanValue,a.depthLoadOp=e.depthLoadOp,Ye.rendererPassState.set(e,a)),e&&e.renderTargets.length>0){a.renderTargets=e.renderTargets,a.rtTextureDescriptors=e.rtDescriptors,a.renderPassDescriptor=Ye.getRenderPassDescriptor(a),a.renderPassDescriptor.depthStencilAttachment&&(a.renderPassDescriptor.depthStencilAttachment.depthLoadOp=e.depthLoadOp),t=="load"&&e?.renderTargets[0]&&e.renderTargets[0].name.startsWith(Be.gui_GBuffer)&&(a.renderPassDescriptor.colorAttachments[0].loadOp="load"),a.depthLoadOp=e.depthLoadOp,a.renderBundleEncoderDescriptor=Ye.getRenderBundleDescriptor(a),a.renderTargetTextures=[];for(let r=0;r<e.renderTargets.length;r++){const i=e.renderTargets[r];a.renderTargetTextures[r]={format:i.format},i.name.indexOf(Qa.colorBufferTex_NAME)!=-1&&(a.outColor=r)}}else a.renderPassDescriptor=Ye.getRenderPassDescriptor(a,t),a.renderBundleEncoderDescriptor=Ye.getRenderBundleDescriptor(a),a.renderTargetTextures=[{format:I.presentationFormat}],a.outColor=0;return a}static getRenderPassDescriptor(e,t=null){if(e.renderPassDescriptor)return e.renderPassDescriptor;I.device,I.presentationSize;let a=[];if(e.renderTargets&&e.renderTargets.length>0){e.renderTargets[0].width,e.renderTargets[0].height;for(let i=0;i<e.renderTargets.length;i++){const s=e.renderTargets[i],o=e.rtTextureDescriptors[i];a.push({view:s.getGPUView(),resolveTarget:void 0,loadOp:o.loadOp,clearValue:o.clearValue,storeOp:o.storeOp})}}else if(!e.customSize){let i=I.canvasConfig&&I.canvasConfig.alpha?[1,1,1,0]:[0,0,0,1];e.isOutTarget==!0&&a.push({view:void 0,resolveTarget:void 0,loadOp:I.canvasConfig&&I.canvasConfig.alpha||t!=null?"load":"clear",clearValue:i,storeOp:"store"})}let r=null;return e.depthTexture||e.zPreTexture?(e.zPreTexture&&(e.depthTexture=e.zPreTexture),r={label:`${e.label} renderPassDescriptor zPreTexture${e.zPreTexture?"load":"clear"}`,colorAttachments:a,depthStencilAttachment:{view:e.depthTexture.getGPUView(),depthLoadOp:e.zPreTexture?"load":e.depthLoadOp,depthClearValue:e.zPreTexture?1:e.depthCleanValue,depthStoreOp:"store"}}):r={colorAttachments:a,label:"renderPassDescriptor not writeDepth"},e.renderPassDescriptor=r,r}static getRenderBundleDescriptor(e){if(e.renderBundleEncoderDescriptor)return e.renderBundleEncoderDescriptor;I.presentationSize;let t=[];if(e.renderTargets&&e.renderTargets.length>0){e.renderTargets[0].width,e.renderTargets[0].height;for(let r=0;r<e.renderTargets.length;r++){const i=e.renderTargets[r];t.push(i.format)}}let a=null;return e.depthTexture?a={colorFormats:t,depthStencilFormat:e.depthTexture.format}:a={colorFormats:t},e.renderBundleEncoderDescriptor=a,e.renderBundleEncoderDescriptor}}class $r extends Ve{width;height;segmentW;segmentH;up;constructor(e,t,a=1,r=1,i=g.Y_AXIS){super(),this.width=e,this.height=t,this.segmentW=a,this.segmentH=r,this.up=i,this.buildGeometry(this.up)}buildGeometry(e){var t,a,r,i,s=this.segmentW+1;(this.segmentH+1)*s,this.bounds=new Ce(g.ZERO.clone(),new g(this.width,1,this.height)),r=this.segmentH*this.segmentW*6;let o=(this.segmentW+1)*(this.segmentH+1),l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),h;this.segmentW*this.segmentH*2*3>=Uint16Array.length?h=new Uint32Array(this.segmentW*this.segmentH*2*3):h=new Uint16Array(this.segmentW*this.segmentH*2*3),r=0;for(var b=0,A=0,m=0,p=0;p<=this.segmentH;++p)for(var D=0;D<=this.segmentW;++D){switch(t=(D/this.segmentW-.5)*this.width,a=(p/this.segmentH-.5)*this.height,e){case g.Y_AXIS:l[b++]=t,l[b++]=0,l[b++]=a,c[A++]=0,c[A++]=1,c[A++]=0;break;case g.Z_AXIS:l[b++]=t,l[b++]=-a,l[b++]=0,c[A++]=0,c[A++]=0,c[A++]=1;break;case g.X_AXIS:l[b++]=0,l[b++]=t,l[b++]=a,c[A++]=1,c[A++]=0,c[A++]=0;break;default:l[b++]=t,l[b++]=0,l[b++]=a,c[A++]=0,c[A++]=1,c[A++]=0;break}f[m++]=D/this.segmentW,f[m++]=p/this.segmentH,D!=this.segmentW&&p!=this.segmentH&&(i=D+p*s,h[r++]=i+1,h[r++]=i,h[r++]=i+s,h[r++]=i+1,h[r++]=i+s,h[r++]=i+s+1)}this.setIndices(h),this.setAttribute(G.position,l),this.setAttribute(G.normal,c),this.setAttribute(G.uv,f),this.setAttribute(G.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}var S2=Object.getOwnPropertyDescriptor,x2=(n,e,t,a)=>{for(var r=a>1?void 0:a?S2(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.QuadShader=class extends gt{constructor(e="QuadGlsl_vs",t="QuadGlsl_fs"){super();let a=new qe(e,t);this.addRenderPass(a);let r=a.shaderState;a.blendMode=Ae.NONE,r.frontFace="cw",r.depthWriteEnabled=!1,r.depthCompare=it.always,r.multisample=0,this.setTexture("baseMap",B.res.blackTexture),this.setUniformFloat("x",0),this.setUniformFloat("y",0),this.setUniformFloat("width",100),this.setUniformFloat("height",100)}},d.QuadShader=x2([Ta(d.QuadShader,"QuadShader")],d.QuadShader);class Rn extends d.Object3D{width=128;height=128;quadRenderer;material;rendererPassState;quadShader;constructor(e="QuadGlsl_vs",t="QuadGlsl_fs",a,r=0,i=!1){super();let s=a?a.renderTargets:[];this.material=new Dt,this.quadShader=new d.QuadShader(e,t),this.material.shader=this.quadShader,this.quadRenderer=this.addComponent(d.MeshRenderer),this.quadRenderer.material=this.material,this.quadRenderer.castGI=!1,this.quadRenderer.castShadow=!1,this.quadRenderer.drawType=i?2:0,this.quadRenderer.geometry=new $r(100,100,1,1),this.quadRenderer.material=this.material,this.quadRenderer.__start(),this.quadRenderer._enable=!0,this.quadRenderer.onEnable(),this.rendererPassState=Ye.createRendererPassState(a,"load"),r>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=I.device.createTexture({size:{width:I.presentationSize[0],height:I.presentationSize[1]},sampleCount:r,format:s.length>0?s[0].format:I.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT})),I.addEventListener(nr.RESIZE,o=>{this.rendererPassState=Ye.createRendererPassState(a,"load"),r>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=I.device.createTexture({size:{width:I.presentationSize[0],height:I.presentationSize[1]},sampleCount:r,format:s.length>0?s[0].format:I.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT}))},this)}renderTarget(e,t,a){let r=e.camera,i=E.beginRenderPass(a,t.rendererPassState);E.bindCamera(i,r),t.quadRenderer.nodeUpdate(e,de.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,de.COLOR,t.rendererPassState,null,i),E.endPass(i)}renderToViewQuad(e,t,a,r){let i=e.camera;t.quadShader.setTexture("baseMap",r);let s=E.beginRenderPass(a,t.rendererPassState);E.bindCamera(s,i),t.quadRenderer.nodeUpdate(e,de.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,de.COLOR,t.rendererPassState,null,s),E.endPass(s)}}class wt{static rtTextureMap;static rtViewQuad;static init(){this.rtTextureMap=new Map,this.rtViewQuad=new Map}static createRTTexture(e,t,a,r,i=!1,s=0){let o=this.rtTextureMap.get(e);return o||(e==Qa.colorBufferTex_NAME?o=new Et(t,a,r,i,void 0,1,s,!1):o=new Et(t,a,r,i,void 0,1,s,!0),o.name=e,wt.rtTextureMap.set(e,o)),o}static createRTTextureArray(e,t,a,r,i=1,s=!1,o=0){let l=this.rtTextureMap.get(e);return l||(l=new Et(t,a,r,s,void 0,i,o),l.name=e,wt.rtTextureMap.set(e,l)),l}static createViewQuad(e,t,a,r,i=0){let s=new nt([r],[new We]),o=new Rn(t,a,s,i);return wt.rtViewQuad.set(e,o),o}static getTexture(e){return this.rtTextureMap.get(e)}static CreateSplitTexture(e){let t=this.getTexture(Qa.colorBufferTex_NAME),a=this.getTexture(e+"_split");return a||(a=this.createRTTexture(e+"_split",t.width,t.height,t.format,!1)),a}static WriteSplitColorTexture(e){let t=this.getTexture(Qa.colorBufferTex_NAME),a=this.getTexture(e+"_split");const r=E.beginCommandEncoder();r.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:a.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:a.width,height:a.height,depthOrArrayLayers:1}),E.endCommandEncoder(r)}}class In{command;encoder;rendererPassStates;rtFrame;constructor(e){this.rtFrame=e,this.rendererPassStates=[]}clean(){this.rendererPassStates.length=0,E.cleanCache()}beginContinueRendererPassState(e="load",t="load"){if(this.rendererPassStates.length>0){let a=this.rtFrame.clone();for(const i of a.rtDescriptors)i.loadOp="load";a.depthLoadOp=t;let r=Ye.createRendererPassState(a,e);return this.rendererPassStates.push(r),r}else{this.rtFrame.depthLoadOp=t;let a=Ye.createRendererPassState(this.rtFrame,e);return this.rendererPassStates.push(a),a}}get rendererPassState(){return this.rendererPassStates[this.rendererPassStates.length-1]}beginOpaqueRenderPass(){this.beginContinueRendererPassState("clear","clear"),this.begineNewCommand(),this.beginNewEncoder()}beginTransparentRenderPass(){this.beginContinueRendererPassState("load","load"),this.begineNewCommand(),this.beginNewEncoder()}specialtRenderPass(){this.beginContinueRendererPassState("load","load"),this.begineNewCommand(),this.beginNewEncoder()}endRenderPass(){this.endEncoder(),this.endCommand()}begineNewCommand(){return this.command=E.beginCommandEncoder(),this.command}endCommand(){E.endCommandEncoder(this.command),this.command=null}beginNewEncoder(){return this.encoder=E.beginRenderPass(this.command,this.rendererPassState),this.encoder}endEncoder(){E.endPass(this.encoder),this.encoder=null}}class Ma extends ja{rendererPassState;splitRendererPassState;useRenderBundle=!1;debugViewQuads;debugTextures;renderContext;_rendererType;_rtFrame;get passType(){return this._rendererType}set passType(e){this._rendererType=e}constructor(){super(),this.debugTextures=[],this.debugViewQuads=[]}setRenderStates(e){if(this._rtFrame=e,e){this.rendererPassState=Ye.createRendererPassState(e);let t=e.clone();t.depthLoadOp="load";for(const a of t.rtDescriptors)a.loadOp="load";this.splitRendererPassState=Ye.createRendererPassState(t)}this.renderContext=new In(e)}getRenderContext(e){return this._rtFrame=e,new In(e)}setIrradiance(e,t){this.rendererPassState.irradianceBuffer=[e,t]}compute(e,t){}render(e,t,a,r=!1){E.cleanCache();let i=e.camera,s=e.scene;this.rendererPassState.camera3D=i;let o=$.instance.getRenderNodes(s,i),l=this.renderBundleOp(e,o,t,a),c=r?[]:this.renderBundleTr(e,o,t,a);{let f=E.beginCommandEncoder(),h=E.beginRenderPass(f,this.rendererPassState);l.length>0&&h.executeBundles(l),!r&&$.instance.sky&&(E.bindCamera(h,i),$.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,h)),this.drawRenderNodes(e,h,f,o.opaqueList,t),E.endPass(h),E.endCommandEncoder(f)}{let f=E.beginCommandEncoder(),h=E.beginRenderPass(f,this.rendererPassState);c.length>0&&h.executeBundles(c),r||(E.bindCamera(h,i),this.drawRenderNodes(e,h,f,o.transparentList,t)),E.endPass(h),E.endCommandEncoder(f)}}nodeUpload(e,t,a){}occlusionRenderNodeTest(e,t,a){return a?a.occlusionRenderNodeTest(e)>0:!0}renderOp(e,t,a,r,i){}renderTr(e,t,a,r,i){}renderBundleOp(e,t,a,r){let i=$.instance.getOpRenderGroup(e.scene);if(i){let s=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))s.push(o.bundleMap.get(this._rendererType));else{let l=E.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),s.push(c)}}),s}return[]}renderBundleTr(e,t,a,r){let i=$.instance.getTrRenderGroup(e.scene);if(i){let s=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))s.push(o.bundleMap.get(this._rendererType));else{let l=E.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),s.push(c)}}),s}return[]}recordRenderBundleNode(e,t,a,r){E.bindCamera(t,e.camera),E.bindGeometryBuffer(t,a[0].geometry);for(let i=0;i<a.length;++i){let s=a[i];s.transform.worldMatrix.index,s.transform.enable&&s.recordRenderPass2(e,this._rendererType,this.rendererPassState,r,t)}}drawRenderNodes(e,t,a,r,i,s){E.bindCamera(t,e.camera);for(let o=B.setting.render.drawOpMin;o<Math.min(r.length,B.setting.render.drawOpMax);++o){let l=r[o];l.transform.enable&&l.enable&&l.renderPass2(e,this._rendererType,this.rendererPassState,s,t)}}}class b0 extends Ma{constructor(){super(),this.passType=de.COLOR}render(e,t,a,r=!1){this.renderContext.clean();let i=e.scene,s=e.camera;ve.updateCameraGroup(s),this.rendererPassState.camera3D=s;let o=$.instance.getRenderNodes(i,s),l=this.renderBundleOp(e,o,t,a),c=r?[]:this.renderBundleTr(e,o,t,a);{this.renderContext.beginOpaqueRenderPass();let f=this.renderContext.encoder;l.length>0&&($.instance.getOpRenderGroup(i),f.executeBundles(l)),!r&&$.instance.sky&&(E.bindCamera(f,s),$.instance.sky.preInit(this._rendererType)||$.instance.sky.nodeUpdate(e,this._rendererType,this.rendererPassState,a),$.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,f)),o.opaqueList&&(E.bindCamera(f,s),this.drawNodes(e,this.renderContext,o.opaqueList,t,a))}{let f=this.renderContext.encoder;c.length>0&&f.executeBundles(c),!r&&o.transparentList&&(E.bindCamera(f,s),this.drawNodes(e,this.renderContext,o.transparentList,t,a));let h=$.instance.getGraphicList();for(let u=0;u<h.length;u++){const b=h[u];b.nodeUpdate(e,this._rendererType,this.splitRendererPassState,a),b.renderPass2(e,this._rendererType,this.splitRendererPassState,a,f)}this.renderContext.endRenderPass(),ct.end("ColorPass Draw Transparent")}}drawNodes(e,t,a,r,i){let s=$.instance.getRenderShaderCollect(e);if(s){for(const o of s){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=B.setting.render.drawOpMin;o<Math.min(a.length,B.setting.render.drawOpMax);++o){let l=a[o];l.transform.enable&&l.enable&&(l.hasMask(Me.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 Tn{frustumCullingList;zVisibleList;_renderList;static enable=!0;constructor(){this._renderList=new Map}occlusionRenderNodeTest(e){return B.setting.occlusionQuery.enable?this.frustumCullingList?this.frustumCullingList[e]:0:1}zDepthRenderNodeTest(e){return this.zVisibleList?this.zVisibleList[e]:0}update(e,t){}collect(e,t){}renderCommitTesting(e,t){return!0}}class ei extends Za{constructor(e,t){super(),this.bufferType=ga.ComputeGPUBuffer,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,e,t,"ComputeGPUBuffer")}}class g0{clusterBuffer;lightAssignBuffer;assignTableBuffer;clustersUniformBuffer;constructor(e,t){this.clusterBuffer=new ei(e*2*4),this.clustersUniformBuffer=new Ct(10),this.clustersUniformBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.lightAssignBuffer=new ei(e*t),this.lightAssignBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.assignTableBuffer=new ei(e*4),this.assignTableBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e,t,a,r,i,s,o,l,c,f){this.clustersUniformBuffer.setFloat("clusterTileX",r),this.clustersUniformBuffer.setFloat("clusterTileY",i),this.clustersUniformBuffer.setFloat("clusterTileZ",s),this.clustersUniformBuffer.setFloat("numLights",o),this.clustersUniformBuffer.setFloat("maxNumLightsPerCluster",l),this.clustersUniformBuffer.setFloat("near",c),this.clustersUniformBuffer.setFloat("far",f),this.clustersUniformBuffer.setFloat("screenWidth",e),this.clustersUniformBuffer.setFloat("screenHeight",t),this.clustersUniformBuffer.setFloat("clusterPix",a),this.clustersUniformBuffer.apply()}}class Rt{static clusterTileX=16;static clusterTileY=16;static clusterTileZ=32}let m0=`
|
|
6150
6149
|
#include "GlobalUniform"
|
|
6151
6150
|
|
|
6152
6151
|
struct ClusterBox{
|
|
@@ -7916,7 +7915,7 @@ else if (typeof exports === 'object')
|
|
|
7916
7915
|
`;class Ff{compute;constructor(){this.compute=new Se(xf)}generateBRDFLUTTexture(){let e=new Ie(256,256,le.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=E.beginCommandEncoder();return E.computeCommand(t,[this.compute]),E.endCommandEncoder(t),e}}class ai{id;guiTexture;uvRec=new ue(0,0,1,1);uvBorder=new ue(0,0,0,0);offsetSize=new ue(0,0,4,4);borderSize=new ue(0,0,0,0);trimSize=new fe;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||B.res.defaultGUITexture}}class mr{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=B.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 ri=new tb;class kf{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 Ef{id=0;file=""}class wf{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class tr extends rt{static format=Je.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 ai;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),ri.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 kf;a.trim().split(t).forEach((i,s)=>{if(s<2)tr.readLineProperty(i,r);else if(s<r.pages+2){let o=new Ef;tr.readLineProperty(i,o),r.fontPage.push(o)}else if(s<r.pages+3)tr.readLineProperty(i,r);else if(r.count>0){let o=new wf;tr.readLineProperty(i,o),r.fontChar[o.id]=o,r.count--}}),a="",this.data=r,await this.loadFontTextures()}getNewLine(e){return e.indexOf(`\r
|
|
7917
7916
|
`)!=-1?`\r
|
|
7918
7917
|
`:e.indexOf("\r")!=-1?"\r":`
|
|
7919
|
-
`}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await B.res.loadTexture(r,null,!0);let i=B.res.getTexture(r),s=new mr(i);e.push(s)}tr.parseSprite(e,t),t.fontChar[" "]||tr.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ai,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),ri.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 s=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,s)&&(o.indexOf('"')==-1?t[s]=parseFloat(i[1]):t[s]=o.replace('"',"").replace('"',""))}})}}function ab(n,e){let t=new ai;return t.id=n,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 Rf(n,e,t){let a=new ai;a.guiTexture=n,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/n.width,i=1/n.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let s=.1;return t.border.x<=s&&t.border.y<=s&&t.border.z<=s&&t.border.x<=s?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 If{_spriteMap=new Map;_spriteList=[];textureSize=new fe;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=Rf(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 Tf extends rt{static format=Je.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await B.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 If(this._json.size),t=new mr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);B.res.addAtlas(this.baseUrl,e),this.data=e}}var $t=Uint8Array,ii=Uint16Array,rb=Int32Array,Qf=new $t([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]),Mf=new $t([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 $t([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pf=function(n,e){for(var t=new ii(31),a=0;a<31;++a)t[a]=e+=1<<n[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}},Nf=Pf(Qf,2),Vf=Nf.b,sb=Nf.r;Vf[28]=258,sb[258]=28;for(var nb=Pf(Mf,0),ob=nb.b,oo=new ii(32768),Xe=0;Xe<32768;++Xe){var pr=(Xe&43690)>>1|(Xe&21845)<<1;pr=(pr&52428)>>2|(pr&13107)<<2,pr=(pr&61680)>>4|(pr&3855)<<4,oo[Xe]=((pr&65280)>>8|(pr&255)<<8)>>1}for(var Ti=(function(n,e,t){for(var a=n.length,r=0,i=new ii(e);r<a;++r)n[r]&&++i[n[r]-1];var s=new ii(e);for(r=1;r<e;++r)s[r]=s[r-1]+i[r-1]<<1;var o;if(t){o=new ii(1<<e);var l=15-e;for(r=0;r<a;++r)if(n[r])for(var c=r<<4|n[r],f=e-n[r],h=s[n[r]-1]++<<f,u=h|(1<<f)-1;h<=u;++h)o[oo[h]>>l]=c}else for(o=new ii(a),r=0;r<a;++r)n[r]&&(o[r]=oo[s[n[r]-1]++]>>15-n[r]);return o}),Qi=new $t(288),Xe=0;Xe<144;++Xe)Qi[Xe]=8;for(var Xe=144;Xe<256;++Xe)Qi[Xe]=9;for(var Xe=256;Xe<280;++Xe)Qi[Xe]=7;for(var Xe=280;Xe<288;++Xe)Qi[Xe]=8;for(var Of=new $t(32),Xe=0;Xe<32;++Xe)Of[Xe]=5;var lb=Ti(Qi,9,1),cb=Ti(Of,5,1),lo=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},Ua=function(n,e,t){var a=e/8|0;return(n[a]|n[a+1]<<8)>>(e&7)&t},co=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},fb=function(n){return(n+7)/8|0},fo=function(n,e,t){return(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length),new $t(n.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"],ca=function(n,e,t){var a=new Error(e||db[n]);if(a.code=n,Error.captureStackTrace&&Error.captureStackTrace(a,ca),!t)throw a;return a},hb=function(n,e,t,a){var r=n.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new $t(0);var s=!t,o=s||e.i!=2,l=e.i;s&&(t=new $t(r*3));var c=function(ie){var ce=t.length;if(ie>ce){var ge=new $t(Math.max(ce*2,ie));ge.set(t),t=ge}},f=e.f||0,h=e.p||0,u=e.b||0,b=e.l,A=e.d,m=e.m,p=e.n,D=r*8;do{if(!b){f=Ua(n,h,1);var _=Ua(n,h+1,3);if(h+=3,_)if(_==1)b=lb,A=cb,m=9,p=5;else if(_==2){var S=Ua(n,h,31)+257,F=Ua(n,h+10,15)+4,k=S+Ua(n,h+5,31)+1;h+=14;for(var x=new $t(k),w=new $t(19),R=0;R<F;++R)w[ib[R]]=Ua(n,h+R*3,7);h+=F*3;for(var Q=lo(w),M=(1<<Q)-1,j=Ti(w,Q,1),R=0;R<k;){var he=j[Ua(n,h,M)];h+=he&15;var v=he>>4;if(v<16)x[R++]=v;else{var ae=0,P=0;for(v==16?(P=3+Ua(n,h,3),h+=2,ae=x[R-1]):v==17?(P=3+Ua(n,h,7),h+=3):v==18&&(P=11+Ua(n,h,127),h+=7);P--;)x[R++]=ae}}var z=x.subarray(0,S),W=x.subarray(S);m=lo(z),p=lo(W),b=Ti(z,m,1),A=Ti(W,p,1)}else ca(1);else{var v=fb(h)+4,U=n[v-4]|n[v-3]<<8,y=v+U;if(y>r){l&&ca(0);break}o&&c(u+U),t.set(n.subarray(v,y),u),e.b=u+=U,e.p=h=y*8,e.f=f;continue}if(h>D){l&&ca(0);break}}o&&c(u+131072);for(var V=(1<<m)-1,te=(1<<p)-1,J=h;;J=h){var ae=b[co(n,h)&V],K=ae>>4;if(h+=ae&15,h>D){l&&ca(0);break}if(ae||ca(2),K<256)t[u++]=K;else if(K==256){J=h,b=null;break}else{var ee=K-254;if(K>264){var R=K-257,re=Qf[R];ee=Ua(n,h,(1<<re)-1)+Vf[R],h+=re}var oe=A[co(n,h)&te],pe=oe>>4;oe||ca(3),h+=oe&15;var W=ob[pe];if(pe>3){var re=Mf[pe];W+=co(n,h)&(1<<re)-1,h+=re}if(h>D){l&&ca(0);break}o&&c(u+131072);var Te=u+ee;if(u<W){var Oe=i-W,q=Math.min(W,Te);for(Oe+u<0&&ca(3);u<q;++u)t[u]=a[Oe+u]}for(;u<Te;++u)t[u]=t[u-W]}}e.l=b,e.p=J,e.b=u,e.f=f,b&&(f=1,e.m=m,e.d=A,e.n=p)}while(!f);return u!=t.length&&s?fo(t,0,u):t.subarray(0,u)},ub=new $t(0),Pa=function(n,e){return n[e]|n[e+1]<<8},ya=function(n,e){return(n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24)>>>0},ho=function(n,e){return ya(n,e)+ya(n,e+4)*4294967296};function bb(n,e){return hb(n,{i:2},e&&e.out,e&&e.dictionary)}var uo=typeof TextDecoder<"u"&&new TextDecoder,gb=0;try{uo.decode(ub,{stream:!0}),gb=1}catch{}var mb=function(n){for(var e="",t=0;;){var a=n[t++],r=(a>127)+(a>223)+(a>239);if(t+r>n.length)return{s:e,r:fo(n,t-1)};r?r==3?(a=((a&15)<<18|(n[t++]&63)<<12|(n[t++]&63)<<6|n[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|n[t++]&63):e+=String.fromCharCode((a&15)<<12|(n[t++]&63)<<6|n[t++]&63):e+=String.fromCharCode(a)}};function Lf(n,e){if(e){for(var t="",a=0;a<n.length;a+=16384)t+=String.fromCharCode.apply(null,n.subarray(a,a+16384));return t}else{if(uo)return uo.decode(n);var r=mb(n),i=r.s,t=r.r;return t.length&&ca(8),i}}var pb=function(n,e){return e+30+Pa(n,e+26)+Pa(n,e+28)},Ab=function(n,e,t){var a=Pa(n,e+28),r=Lf(n.subarray(e+46,e+46+a),!(Pa(n,e+8)&2048)),i=e+46+a,s=ya(n,e+20),o=t&&s==4294967295?Db(n,i):[s,ya(n,e+24),ya(n,e+42)],l=o[0],c=o[1],f=o[2];return[Pa(n,e+10),l,c,r,i+Pa(n,e+30)+Pa(n,e+32),f]},Db=function(n,e){for(;Pa(n,e)!=1;e+=4+Pa(n,e+2));return[ho(n,e+12),ho(n,e+4),ho(n,e+20)]};function _b(n,e){for(var t={},a=n.length-22;ya(n,a)!=101010256;--a)(!a||n.length-a>65558)&&ca(13);var r=Pa(n,a+8);if(!r)return{};var i=ya(n,a+16),s=i==4294967295||r==65535;if(s){var o=ya(n,a-12);s=ya(n,o)==101075792,s&&(r=ya(n,o+32),i=ya(n,o+48))}for(var l=0;l<r;++l){var c=Ab(n,i,s),f=c[0],h=c[1],u=c[2],b=c[3],A=c[4],m=c[5],p=pb(n,m);i=A,f?f==8?t[b]=bb(n.subarray(p,p+h),{out:new $t(u)}):ca(14,"unknown compression type "+f):t[b]=fo(n,p,p+h)}return t}class Bt extends Dt{constructor(){super(),this.shader=new d.UnLitShader,this.baseMap=B.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 Ir extends Ve{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,s,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=s,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,s=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,b=0,A=0;for(t=0;t<=r;++t){var m=Math.PI*t/r,p=s*Math.cos(m),D=s*Math.sin(m);for(e=0;e<=i;++e){var _=2*Math.PI*e/i,v=D*Math.cos(_),U=D*Math.sin(_),y=1/Math.sqrt(v*v+p*p+U*U);if(l[u++]=v,l[u++]=p,l[u++]=U,c[b++]=v*y,c[b++]=p*y,c[b++]=U*y,f[A++]=e/i,f[A++]=t/r,e>0&&t>0){var S=(i+1)*t+e,F=(i+1)*t+e-1,k=(i+1)*(t-1)+e-1,x=(i+1)*(t-1)+e;t==r?(h[a++]=S,h[a++]=k,h[a++]=x):t==1?(h[a++]=S,h[a++]=F,h[a++]=k):(h[a++]=S,h[a++]=F,h[a++]=k,h[a++]=S,h[a++]=k,h[a++]=x)}}}this.setIndices(h),this.setAttribute(G.position,l),this.setAttribute(G.normal,c),this.setAttribute(G.uv,f),this.setAttribute(G.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Ce(g.ZERO,new g(this.radius*2,this.radius*2,this.radius*2))}}class Mi 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 g(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),Mi.register3DRepresentation)this.marker=Mi.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new d.Object3D;const e=this.marker.addComponent(d.MeshRenderer);e.geometry=new Ir(.1,32,16),e.material=new Bt,e.material.baseColor=this.positionValid?new Z(0,1,0,1):new Z(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class Pi 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 Mi(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),Pi.register3DRepresentation?(this.line=Pi.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new Z(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Ve,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(G.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const s=new d.Object3D,o=s.addComponent(d.MeshRenderer),l=new Bt;return l.topology="line-list",l.baseColor=t,l.blendMode=Ae.ADD,l.castReflection=!1,o.geometry=a,o.material=l,s}}class Gf extends rt{static format=Je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=_b(new Uint8Array(e));for(const i in a){const s=a[i],l=new DOMParser().parseFromString(Lf(s),"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 Pi(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,s=!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&&(s=!0)}if(i&&!s)t[r]=i;else if(s){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 zf{_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 Tt().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 Tt;r==".gltf"?a=await i.load(e,_t,t):a=await i.load(e,Hn,t);let s=a.data;return this._prefabPool.set(e,s),this._gltfPool.set(e,a.gltf),s}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new Tt;r==".obj"&&(a=await i.load(e,wi,t));let s=a.data;return this._prefabPool.set(e,s),s}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let s=(await new Tt().load(e,ro,t,a)).data;return this._prefabPool.set(e,s),s}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let s=(await new Tt().load(e,no,t,a)).data;return this._prefabPool.set(e,s),s}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new $a;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}destroyTexture(e){const t=this._texturePool.get(e);return t?xe.getInstance().hasReference(t)?!1:(t.isDestroyed||t.destroy(),this._texturePool.delete(e),!0):!1}destroyTextureAllUnUsed(){for(const[e,t]of this._texturePool.entries())this.destroyTexture(e)}async loadTextureCount(e,t,a,r){return new Promise(async(i,s)=>{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=[],s=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<s;l++){let c=await this.loadTextureCount(e,l==s-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 $n;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 ks;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 Kn;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 Kn;return await a.loadStd(e),a}async loadJSON(e,t){return await new Tt().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new Tt().load(e,tr,t,a),s=i.data;return ri.addFontData(s.face,s.size,s),i.data}async loadAtlas(e,t){return(await new Tt().load(e,Tf,t,e)).data}async loadKMZ(e,t){return(await new Tt().load(e,Gf,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,s,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,s);let h=new Si;return h.name=o,h.create(16,16,f,!0),o&&this.addTexture(o,h),h}fillColor(e,t,a,r,i,s,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]=s,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 xs,this.defaultSky.createFromTexture(128,this.blackTexture),xe.getInstance().attached(this.defaultSky,this),xe.getInstance().attached(t,this),xe.getInstance().attached(this.normalTexture,this),xe.getInstance().attached(this.maskTexture,this),xe.getInstance().attached(this.whiteTexture,this),xe.getInstance().attached(this.blackTexture,this),xe.getInstance().attached(this.redTexture,this),xe.getInstance().attached(this.blueTexture,this),xe.getInstance().attached(this.greenTexture,this),xe.getInstance().attached(this.yellowTexture,this),xe.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new mr(this.whiteTexture),this.defaultGUISprite=new ai(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new qt}}class Wf extends $e{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=B.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=B.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;B.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Bb="1.0.42";class B{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 I.presentationSize}static get aspect(){return I.aspect}static get width(){return I.windowWidth}static get height(){return I.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 Z(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 Ee.init(T.allocCount,this.setting.doublePrecision),await I.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,Be.getGBufferFrame(Be.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),X.init(),Ka.init(),ve.init(),wt.init(),Wt.init(),this.res=new zf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new tl,this.inputSystem.initCanvas(I.canvas)}static startRenderJob(e){let t=new O0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Wf).addPost(Mn),(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){ze.delta=e-ze.time,ze.time=e,ze.frame+=1,br.tick(ze.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const s=t[a];s.scene.waitUpdate();let[o,l]=I.presentationSize;s.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const s of Ne.componentsBeforeUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}let r=I.device.createCommandEncoder();for(const s of Ne.componentsComputeList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o,r)}}I.device.queue.submit([r.finish()]);for(const s of Ne.componentsUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}for(const s of Ne.graphicComponent){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];o&&f.enable&&h(o)}}this._renderLoop&&await this._renderLoop(),Ee.updateAllContinueTransform(0,T.useCount,16),ve.modelMatrixBindGroup.writeBuffer(T.useCount*16),this.renderJobs.forEach((s,o)=>{s.renderState||s.start(),s.renderFrame()});for(const s of Ne.componentsLateUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}this._lateRender&&await this._lateRender()}}let Es=`
|
|
7918
|
+
`}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await B.res.loadTexture(r,null,!0);let i=B.res.getTexture(r),s=new mr(i);e.push(s)}tr.parseSprite(e,t),t.fontChar[" "]||tr.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ai,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),ri.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 s=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,s)&&(o.indexOf('"')==-1?t[s]=parseFloat(i[1]):t[s]=o.replace('"',"").replace('"',""))}})}}function ab(n,e){let t=new ai;return t.id=n,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 Rf(n,e,t){let a=new ai;a.guiTexture=n,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/n.width,i=1/n.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let s=.1;return t.border.x<=s&&t.border.y<=s&&t.border.z<=s&&t.border.x<=s?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 If{_spriteMap=new Map;_spriteList=[];textureSize=new fe;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=Rf(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 Tf extends rt{static format=Je.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await B.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 If(this._json.size),t=new mr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);B.res.addAtlas(this.baseUrl,e),this.data=e}}var $t=Uint8Array,ii=Uint16Array,rb=Int32Array,Qf=new $t([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]),Mf=new $t([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 $t([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pf=function(n,e){for(var t=new ii(31),a=0;a<31;++a)t[a]=e+=1<<n[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}},Nf=Pf(Qf,2),Vf=Nf.b,sb=Nf.r;Vf[28]=258,sb[258]=28;for(var nb=Pf(Mf,0),ob=nb.b,oo=new ii(32768),Xe=0;Xe<32768;++Xe){var pr=(Xe&43690)>>1|(Xe&21845)<<1;pr=(pr&52428)>>2|(pr&13107)<<2,pr=(pr&61680)>>4|(pr&3855)<<4,oo[Xe]=((pr&65280)>>8|(pr&255)<<8)>>1}for(var Ti=(function(n,e,t){for(var a=n.length,r=0,i=new ii(e);r<a;++r)n[r]&&++i[n[r]-1];var s=new ii(e);for(r=1;r<e;++r)s[r]=s[r-1]+i[r-1]<<1;var o;if(t){o=new ii(1<<e);var l=15-e;for(r=0;r<a;++r)if(n[r])for(var c=r<<4|n[r],f=e-n[r],h=s[n[r]-1]++<<f,u=h|(1<<f)-1;h<=u;++h)o[oo[h]>>l]=c}else for(o=new ii(a),r=0;r<a;++r)n[r]&&(o[r]=oo[s[n[r]-1]++]>>15-n[r]);return o}),Qi=new $t(288),Xe=0;Xe<144;++Xe)Qi[Xe]=8;for(var Xe=144;Xe<256;++Xe)Qi[Xe]=9;for(var Xe=256;Xe<280;++Xe)Qi[Xe]=7;for(var Xe=280;Xe<288;++Xe)Qi[Xe]=8;for(var Of=new $t(32),Xe=0;Xe<32;++Xe)Of[Xe]=5;var lb=Ti(Qi,9,1),cb=Ti(Of,5,1),lo=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},Ua=function(n,e,t){var a=e/8|0;return(n[a]|n[a+1]<<8)>>(e&7)&t},co=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},fb=function(n){return(n+7)/8|0},fo=function(n,e,t){return(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length),new $t(n.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"],ca=function(n,e,t){var a=new Error(e||db[n]);if(a.code=n,Error.captureStackTrace&&Error.captureStackTrace(a,ca),!t)throw a;return a},hb=function(n,e,t,a){var r=n.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new $t(0);var s=!t,o=s||e.i!=2,l=e.i;s&&(t=new $t(r*3));var c=function(ie){var ce=t.length;if(ie>ce){var ge=new $t(Math.max(ce*2,ie));ge.set(t),t=ge}},f=e.f||0,h=e.p||0,u=e.b||0,b=e.l,A=e.d,m=e.m,p=e.n,D=r*8;do{if(!b){f=Ua(n,h,1);var _=Ua(n,h+1,3);if(h+=3,_)if(_==1)b=lb,A=cb,m=9,p=5;else if(_==2){var S=Ua(n,h,31)+257,F=Ua(n,h+10,15)+4,k=S+Ua(n,h+5,31)+1;h+=14;for(var x=new $t(k),w=new $t(19),R=0;R<F;++R)w[ib[R]]=Ua(n,h+R*3,7);h+=F*3;for(var Q=lo(w),M=(1<<Q)-1,j=Ti(w,Q,1),R=0;R<k;){var he=j[Ua(n,h,M)];h+=he&15;var v=he>>4;if(v<16)x[R++]=v;else{var ae=0,P=0;for(v==16?(P=3+Ua(n,h,3),h+=2,ae=x[R-1]):v==17?(P=3+Ua(n,h,7),h+=3):v==18&&(P=11+Ua(n,h,127),h+=7);P--;)x[R++]=ae}}var z=x.subarray(0,S),W=x.subarray(S);m=lo(z),p=lo(W),b=Ti(z,m,1),A=Ti(W,p,1)}else ca(1);else{var v=fb(h)+4,U=n[v-4]|n[v-3]<<8,y=v+U;if(y>r){l&&ca(0);break}o&&c(u+U),t.set(n.subarray(v,y),u),e.b=u+=U,e.p=h=y*8,e.f=f;continue}if(h>D){l&&ca(0);break}}o&&c(u+131072);for(var V=(1<<m)-1,te=(1<<p)-1,J=h;;J=h){var ae=b[co(n,h)&V],K=ae>>4;if(h+=ae&15,h>D){l&&ca(0);break}if(ae||ca(2),K<256)t[u++]=K;else if(K==256){J=h,b=null;break}else{var ee=K-254;if(K>264){var R=K-257,re=Qf[R];ee=Ua(n,h,(1<<re)-1)+Vf[R],h+=re}var oe=A[co(n,h)&te],pe=oe>>4;oe||ca(3),h+=oe&15;var W=ob[pe];if(pe>3){var re=Mf[pe];W+=co(n,h)&(1<<re)-1,h+=re}if(h>D){l&&ca(0);break}o&&c(u+131072);var Te=u+ee;if(u<W){var Oe=i-W,q=Math.min(W,Te);for(Oe+u<0&&ca(3);u<q;++u)t[u]=a[Oe+u]}for(;u<Te;++u)t[u]=t[u-W]}}e.l=b,e.p=J,e.b=u,e.f=f,b&&(f=1,e.m=m,e.d=A,e.n=p)}while(!f);return u!=t.length&&s?fo(t,0,u):t.subarray(0,u)},ub=new $t(0),Pa=function(n,e){return n[e]|n[e+1]<<8},ya=function(n,e){return(n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24)>>>0},ho=function(n,e){return ya(n,e)+ya(n,e+4)*4294967296};function bb(n,e){return hb(n,{i:2},e&&e.out,e&&e.dictionary)}var uo=typeof TextDecoder<"u"&&new TextDecoder,gb=0;try{uo.decode(ub,{stream:!0}),gb=1}catch{}var mb=function(n){for(var e="",t=0;;){var a=n[t++],r=(a>127)+(a>223)+(a>239);if(t+r>n.length)return{s:e,r:fo(n,t-1)};r?r==3?(a=((a&15)<<18|(n[t++]&63)<<12|(n[t++]&63)<<6|n[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|n[t++]&63):e+=String.fromCharCode((a&15)<<12|(n[t++]&63)<<6|n[t++]&63):e+=String.fromCharCode(a)}};function Lf(n,e){if(e){for(var t="",a=0;a<n.length;a+=16384)t+=String.fromCharCode.apply(null,n.subarray(a,a+16384));return t}else{if(uo)return uo.decode(n);var r=mb(n),i=r.s,t=r.r;return t.length&&ca(8),i}}var pb=function(n,e){return e+30+Pa(n,e+26)+Pa(n,e+28)},Ab=function(n,e,t){var a=Pa(n,e+28),r=Lf(n.subarray(e+46,e+46+a),!(Pa(n,e+8)&2048)),i=e+46+a,s=ya(n,e+20),o=t&&s==4294967295?Db(n,i):[s,ya(n,e+24),ya(n,e+42)],l=o[0],c=o[1],f=o[2];return[Pa(n,e+10),l,c,r,i+Pa(n,e+30)+Pa(n,e+32),f]},Db=function(n,e){for(;Pa(n,e)!=1;e+=4+Pa(n,e+2));return[ho(n,e+12),ho(n,e+4),ho(n,e+20)]};function _b(n,e){for(var t={},a=n.length-22;ya(n,a)!=101010256;--a)(!a||n.length-a>65558)&&ca(13);var r=Pa(n,a+8);if(!r)return{};var i=ya(n,a+16),s=i==4294967295||r==65535;if(s){var o=ya(n,a-12);s=ya(n,o)==101075792,s&&(r=ya(n,o+32),i=ya(n,o+48))}for(var l=0;l<r;++l){var c=Ab(n,i,s),f=c[0],h=c[1],u=c[2],b=c[3],A=c[4],m=c[5],p=pb(n,m);i=A,f?f==8?t[b]=bb(n.subarray(p,p+h),{out:new $t(u)}):ca(14,"unknown compression type "+f):t[b]=fo(n,p,p+h)}return t}class Bt extends Dt{constructor(){super(),this.shader=new d.UnLitShader,this.baseMap=B.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 Ir extends Ve{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,s,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=s,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,s=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,b=0,A=0;for(t=0;t<=r;++t){var m=Math.PI*t/r,p=s*Math.cos(m),D=s*Math.sin(m);for(e=0;e<=i;++e){var _=2*Math.PI*e/i,v=D*Math.cos(_),U=D*Math.sin(_),y=1/Math.sqrt(v*v+p*p+U*U);if(l[u++]=v,l[u++]=p,l[u++]=U,c[b++]=v*y,c[b++]=p*y,c[b++]=U*y,f[A++]=e/i,f[A++]=t/r,e>0&&t>0){var S=(i+1)*t+e,F=(i+1)*t+e-1,k=(i+1)*(t-1)+e-1,x=(i+1)*(t-1)+e;t==r?(h[a++]=S,h[a++]=k,h[a++]=x):t==1?(h[a++]=S,h[a++]=F,h[a++]=k):(h[a++]=S,h[a++]=F,h[a++]=k,h[a++]=S,h[a++]=k,h[a++]=x)}}}this.setIndices(h),this.setAttribute(G.position,l),this.setAttribute(G.normal,c),this.setAttribute(G.uv,f),this.setAttribute(G.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Ce(g.ZERO,new g(this.radius*2,this.radius*2,this.radius*2))}}class Mi 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 g(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),Mi.register3DRepresentation)this.marker=Mi.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new d.Object3D;const e=this.marker.addComponent(d.MeshRenderer);e.geometry=new Ir(.1,32,16),e.material=new Bt,e.material.baseColor=this.positionValid?new Z(0,1,0,1):new Z(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class Pi 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 Mi(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),Pi.register3DRepresentation?(this.line=Pi.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new Z(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Ve,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(G.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const s=new d.Object3D,o=s.addComponent(d.MeshRenderer),l=new Bt;return l.topology="line-list",l.baseColor=t,l.blendMode=Ae.ADD,l.castReflection=!1,o.geometry=a,o.material=l,s}}class Gf extends rt{static format=Je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=_b(new Uint8Array(e));for(const i in a){const s=a[i],l=new DOMParser().parseFromString(Lf(s),"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 Pi(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,s=!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&&(s=!0)}if(i&&!s)t[r]=i;else if(s){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 zf{_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 Tt().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 Tt;r==".gltf"?a=await i.load(e,_t,t):a=await i.load(e,Hn,t);let s=a.data;return this._prefabPool.set(e,s),this._gltfPool.set(e,a.gltf),s}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new Tt;r==".obj"&&(a=await i.load(e,wi,t));let s=a.data;return this._prefabPool.set(e,s),s}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let s=(await new Tt().load(e,ro,t,a)).data;return this._prefabPool.set(e,s),s}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let s=(await new Tt().load(e,no,t,a)).data;return this._prefabPool.set(e,s),s}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new $a;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}destroyTexture(e){const t=this._texturePool.get(e);return t?xe.getInstance().hasReference(t)?!1:(t.isDestroyed||t.destroy(),this._texturePool.delete(e),!0):!1}destroyTextureAllUnUsed(){for(const[e,t]of this._texturePool.entries())this.destroyTexture(e)}async loadTextureCount(e,t,a,r){return new Promise(async(i,s)=>{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=[],s=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<s;l++){let c=await this.loadTextureCount(e,l==s-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 $n;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 ks;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 Kn;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 Kn;return await a.loadStd(e),a}async loadJSON(e,t){return await new Tt().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new Tt().load(e,tr,t,a),s=i.data;return ri.addFontData(s.face,s.size,s),i.data}async loadAtlas(e,t){return(await new Tt().load(e,Tf,t,e)).data}async loadKMZ(e,t){return(await new Tt().load(e,Gf,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,s,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,s);let h=new Si;return h.name=o,h.create(16,16,f,!0),o&&this.addTexture(o,h),h}fillColor(e,t,a,r,i,s,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]=s,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 xs,this.defaultSky.createFromTexture(128,this.blackTexture),xe.getInstance().attached(this.defaultSky,this),xe.getInstance().attached(t,this),xe.getInstance().attached(this.normalTexture,this),xe.getInstance().attached(this.maskTexture,this),xe.getInstance().attached(this.whiteTexture,this),xe.getInstance().attached(this.blackTexture,this),xe.getInstance().attached(this.redTexture,this),xe.getInstance().attached(this.blueTexture,this),xe.getInstance().attached(this.greenTexture,this),xe.getInstance().attached(this.yellowTexture,this),xe.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new mr(this.whiteTexture),this.defaultGUISprite=new ai(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new qt}}class Wf extends $e{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=B.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=B.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;B.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Bb="1.0.43";class B{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 I.presentationSize}static get aspect(){return I.aspect}static get width(){return I.windowWidth}static get height(){return I.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 Z(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 Ee.init(T.allocCount,this.setting.doublePrecision),await I.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,Be.getGBufferFrame(Be.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),X.init(),Ka.init(),ve.init(),wt.init(),Wt.init(),this.res=new zf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new tl,this.inputSystem.initCanvas(I.canvas)}static startRenderJob(e){let t=new O0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Wf).addPost(Mn),(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){ze.delta=e-ze.time,ze.time=e,ze.frame+=1,br.tick(ze.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const s=t[a];s.scene.waitUpdate();let[o,l]=I.presentationSize;s.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const s of Ne.componentsBeforeUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}let r=I.device.createCommandEncoder();for(const s of Ne.componentsComputeList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o,r)}}I.device.queue.submit([r.finish()]);for(const s of Ne.componentsUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}for(const s of Ne.graphicComponent){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];o&&f.enable&&h(o)}}this._renderLoop&&await this._renderLoop(),Ee.updateAllContinueTransform(0,T.useCount,16),ve.modelMatrixBindGroup.writeBuffer(T.useCount*16),this.renderJobs.forEach((s,o)=>{s.renderState||s.start(),s.renderFrame()});for(const s of Ne.componentsLateUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}this._lateRender&&await this._lateRender()}}let Es=`
|
|
7920
7919
|
struct BloomCfg{
|
|
7921
7920
|
downSampleStep: f32,
|
|
7922
7921
|
downSampleBlurSize: f32,
|