@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.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 Z2=Object.getOwnPropertyDescriptor,Y2=(s,e,t,a)=>{for(var r=a>1?void 0:a?Z2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let ki=class extends At{constructor(){super(),Y.register("pointcloud_vs_dc",F0),Y.register("pointcloud_fs_dc",k0);const s=new qe("pointcloud_vs_dc","pointcloud_fs_dc");s.passType=fe.COLOR,s.setShaderEntry("VertMain","FragMain"),s.topology=Ss.triangle_list,s.depthWriteEnabled=!0,s.cullMode=Lt.none,s.shaderState.transparent=!1,s.shaderState.blendMode=De.NORMAL,s.shaderState.writeMasks=[15,15],s.shaderState.castReflection=!1,this.addRenderPass(s),this.setDefault()}setDefault(){const s=this.getDefaultColorShader(),e=new R;s.setUniform("modelMatrix",e.rawData),s.setUniformArray("tex_params",new Float32Array([0,0,0,4])),s.setUniformArray("pointParams",new Float32Array([0,0,0,128]))}};ki=Y2([Na(ki,"PointCloudShader")],ki);class E0 extends vt{_texParams=new Float32Array([0,0,0,4]);_pointParamsArray=new Float32Array([0,0,0,128]);constructor(){super(),this.shader=new ki}setPointTextures(e,t,a,r){const i=this.shader.getDefaultColorShader();if(!i.getUniform("modelMatrix")){const n=new R;i.setUniform("modelMatrix",n.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=nt.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 Kn extends Le{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,n=r*6;a.set([0+i,1+i,2+i,0+i,2+i,3+i],n)}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 w0 extends ut{create(e,t,a,r=!0){let i=I.device;const n=e*4*4;this.format=oe.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=k.beginCommandEncoder();return c.copyBufferToTexture({buffer:l,bytesPerRow:n},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),k.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=oe.rgba32float,this.mipmapCount=1,this.createTextureDescriptor(e,t,this.mipmapCount,this.format);const n=k.beginCommandEncoder();return n.copyBufferToTexture({buffer:a,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),k.endCommandEncoder(n),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=r.createSampler({}),this}}var X2=Object.getOwnPropertyDescriptor,H2=(s,e,t,a)=>{for(var r=a>1?void 0:a?X2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let qa=class extends Ba{count=0;size=new de;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 b;get centerOffset(){return this._centerOffset}constructor(){super()}initFromData(s,e,t){if(!s||!e||t<=0){console.error("PointCloudRenderer: Invalid input data");return}if(s.length<t*3){console.error("PointCloudRenderer: Positions array too small");return}if(e.length<t*4){console.error("PointCloudRenderer: Colors array too small");return}this.count=t,this._fullCount=t,this.size=this.evalTextureSize(t),this._positions=s,this._colors=e,this.centerizePositions(),this.buildPositionTexture(),this.buildColorTexture(),this.texParams=new Float32Array([this.count,this.size.x,this.count,4]),this.buildOrderTexture(),this.pointCloudMaterial=new E0,this.geometry=new Kn(this._batchSize),this.materials=[this.pointCloudMaterial],this.instanceCount=Math.ceil(this.count/this._batchSize)}evalTextureSize(s){let e=Math.ceil(Math.sqrt(s));const t=64;e=Math.ceil(e/t)*t;const a=Math.ceil(s/e);return new de(e,a)}centerizePositions(){if(this.count===0)return;let s=0,e=0,t=0;for(let n=0;n<this.count;n++){const o=n*3;s+=this._positions[o+0],e+=this._positions[o+1],t+=this._positions[o+2]}const a=s/this.count,r=e/this.count,i=t/this.count;this._centerOffset.set(a,r,i);for(let n=0;n<this.count;n++){const o=n*3;this._positions[o+0]-=a,this._positions[o+1]-=r,this._positions[o+2]-=i}this.object3D.localPosition=this._centerOffset}buildPositionTexture(){const s=this.size.x|0,e=this.size.y|0,t=this.count,a=new Float32Array(s*e*4);for(let r=0;r<t;r++){const i=r*4,n=r*3;a[i+0]=this._positions[n+0],a[i+1]=this._positions[n+1],a[i+2]=this._positions[n+2],a[i+3]=0}if(t<s*e){const r=(t-1)*4;for(let i=t;i<s*e;i++){const n=i*4;a[n+0]=a[r+0],a[n+1]=a[r+1],a[n+2]=a[r+2],a[n+3]=0}}this.pointPosition=new w0().create(s,e,a),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 s=this.size.x|0,e=this.size.y|0,t=this.count,a=new Uint8Array(s*e*4);for(let r=0;r<t;r++){const i=r*4,n=r*4;a[i+0]=this._colors[n+0],a[i+1]=this._colors[n+1],a[i+2]=this._colors[n+2],a[i+3]=this._colors[n+3]}if(t<s*e){const r=(t-1)*4;for(let i=t;i<s*e;i++){const n=i*4;a[n+0]=a[r+0],a[n+1]=a[r+1],a[n+2]=a[r+2],a[n+3]=a[r+3]}}this.pointColor=new Fi().create(s,e,a,!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 s=this.size.x*this.size.y;this._orderData=new Uint32Array(s);for(let e=0;e<s;e++)this._orderData[e]=e<this.count?e:this.count>0?this.count-1:0;this.pointOrder=new Qs().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(s,e,t,a){const r=this.object3D.transform.worldMatrix;this.pointCloudMaterial.setTransformMatrix(r),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(s,e,t,a)}renderPass(s,e,t){const a=t.encoder;for(let r of this.materials){const i=r.getPass(e);if(!(!i||i.length===0))for(const n of i){if(!n.pipeline)continue;n.apply(this.geometry,t.rendererPassState||t),k.bindPipeline(a,n),k.bindGeometryBuffer(a,this.geometry);const l=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?k.drawIndexed(a,l.indexCount,this.instanceCount,l.indexStart,0,0):k.drawIndexed(a,l.indexCount,1,l.indexStart,0,0)}}}setPointSize(s){this.texParams[3]=Math.max(.1,s),this.pointCloudMaterial&&this.pointCloudMaterial.setPointSize(s)}setPointShape(s){this.pointCloudMaterial&&this.pointCloudMaterial.setPointShape(s)}enableDebugFullScreen(s){this._debugFullScreen=s,this.pointCloudMaterial&&this.pointCloudMaterial.enableDebugFullScreen(s)}setBatchSize(s){if(this._batchSize=Math.max(1,s|0),this.geometry){const e=this.geometry;ke.getInstance().detached(e,this),ke.getInstance().hasReference(e)||e.destroy(),this.geometry=new Kn(this._batchSize)}this.pointCloudMaterial&&(this.pointCloudMaterial.setBatchSize(this._batchSize),this.pointCloudMaterial.enableDebugFullScreen(this._debugFullScreen)),this.instanceCount=Math.ceil(this.count/this._batchSize)}destroy(s){this.pointColor&&(this.pointColor.destroy(s),this.pointColor=null),this.pointPosition&&(this.pointPosition.destroy(s),this.pointPosition=null),this.pointOrder&&(this.pointOrder.destroy(s),this.pointOrder=null),this._positions=null,this._colors=null,this._orderData=null,this.texParams=null,super.destroy(s)}};qa=H2([Ot(qa,"PointCloudRenderer")],qa);class qn{static maxVector=new b(Number.MAX_VALUE*.1,Number.MAX_VALUE*.1,Number.MAX_VALUE*.1);static minVector=this.maxVector.clone().multiplyScalar(-1);static genMeshMaxVector=b.ZERO.clone();static genMeshMinVector=b.ZERO.clone();static genMeshVectorList8=[new b,new b,new b,new b,new b,new b,new b,new b];static genPointCloudBounds(e,t){t||=new Ce(b.ZERO,b.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let a=e.getComponents(qa);if(!a)return console.warn("genPointCloudBounds: No PointCloudRenderer found on object"),t;for(const r of a){const i=r.positions,n=r.fullCount;if(!i||n===0){console.warn("genPointCloudBounds: No position data available");continue}const o=r.object3D.transform.worldMatrix,l=new b;for(let c=0;c<n;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(b.ZERO,b.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let a=e.getComponents(ii);if(!a)return console.warn("genGSplatBounds: No GSplatRenderer found on object"),t;for(const r of a){const i=r.positions,n=r.fullCount;if(!i||n===0)return console.warn("genGSplatBounds: No position data available"),t;const o=r.object3D.transform.worldMatrix,l=new b;for(let c=0;c<n;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(b.ZERO,b.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let n=e.getComponents(he);for(const o of n)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),n=this.genMeshVectorList8;a||=new Ce(b.ZERO,b.ZERO),a.setFromMinMax(this.maxVector,this.minVector),n[0].set(r.x,r.y,r.z),n[1].set(r.x,r.y,i.z),n[2].set(r.x,i.y,r.z),n[3].set(r.x,i.y,i.z),n[4].set(i.x,r.y,r.z),n[5].set(i.x,r.y,i.z),n[6].set(i.x,i.y,r.z),n[7].set(i.x,i.y,i.z);for(const o of n)e.transformPoint(o,o),a.expandByPoint(o);return i.copyFrom(a.max),r.copyFrom(a.min),a.setFromMinMax(r,i),a}}class I0 extends Za{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=yn().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&&(qn.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()):Oe.waitStartComponent.forEach((e,t)=>{for(;e.length>0;){const a=e.shift();a.__start(),Oe.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 K2=Object.getOwnPropertyDescriptor,q2=(s,e,t,a)=>{for(var r=a>1?void 0:a?K2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let ne=class extends I0{_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(s){this.entityChildren.forEach(e=>{s(e),e.forChild(s)})}addComponent(s,e){if(!this.components.has(s)){let t=new s;return t.object3D=this,this.components.set(s,t),t.__init(e),Oe.appendWaitStart(t),t}return this.components.get(s)}getOrAddComponent(s){let e=this.components.get(s);return e||(e=this.addComponent(s)),e}removeComponent(s){if(this.components.has(s)){let e=this.components.get(s);Oe.removeWaitStart(this,e),this.components.delete(s),e.__stop(),e.beforeDestroy(),e.destroy()}}hasComponent(s){return this.components.has(s)}getComponent(s){return this.components.get(s)}getComponentFromParent(s){if(!this.parent)return null;let e=this.parent.object3D.getComponent(s);return e||this.parent.object3D.getComponentFromParent(s)}getComponentsInChild(s){let e=[],t=this.components.get(s);t&&e.push(t);for(let a=0;a<this.entityChildren.length;a++){let i=this.entityChildren[a].getComponentsInChild(s);e.push(...i)}return e}getComponents(s,e,t){e||=[];let a=this.getComponent(s);a&&(a.enable||t)&&e.push(a);for(let r=0,i=this.entityChildren.length;r<i;r++){let n=this.entityChildren[r];n&&n instanceof ne&&n.getComponents(s,e,t)}return e}getComponentsExt(s,e,t){e||=[];let a=this.components.get(s);if(a&&(a.enable||t))e.push(a);else for(const r of this.entityChildren)r instanceof ne&&r.getComponentsExt(s,e,t);return e}getComponentsByProperty(s,e,t=!0,a,r){a||=[];let i;for(const n of this.components.values())n&&(n.enable||r)&&n[s]===e&&(a.push(n),i=!0);if(!(i&&t))for(const n of this.entityChildren)n instanceof ne&&n.getComponentsByProperty(s,e,t,a,r);return a}clone(){return this.instantiate()}instantiate(){let s=new ne;return s.name=this.name,s.serializeTag=this.serializeTag,s.prefabRef=this.prefabRef,this.entityChildren.forEach((e,t)=>{let a=e.instantiate();s.addChild(a)}),this.components.forEach((e,t)=>{e.cloneTo(s)}),s}get localPosition(){return this.transform.localPosition}set localPosition(s){this.transform.localPosition=s}get localRotation(){return this.transform.localRotation}set localRotation(s){this.transform.localRotation=s}get localScale(){return this.transform.localScale}set localScale(s){this.transform.localScale=s}get localQuaternion(){return this.transform.localRotQuat}set localQuaternion(s){this.transform.localRotQuat=s}notifyChange(){this.transform.notifyChange()}get parent(){return this.transform.parent}get parentObject(){return this.transform.parent.object3D}set x(s){this.transform.x=s}get x(){return this.transform.x}set y(s){this.transform.y=s}get y(){return this.transform.y}set z(s){this.transform.z=s}get z(){return this.transform.z}set scaleX(s){this.transform.scaleX=s}get scaleX(){return this.transform.scaleX}set scaleY(s){this.transform.scaleY=s}get scaleY(){return this.transform.scaleY}set scaleZ(s){this.transform.scaleZ=s}get scaleZ(){return this.transform.scaleZ}set rotationX(s){this.transform.rotationX=s}get rotationX(){return this.transform.rotationX}set rotationY(s){this.transform.rotationY=s}get rotationY(){return this.transform.rotationY}set rotationZ(s){this.transform.rotationZ=s}get rotationZ(){return this.transform.rotationZ}fixedUpdate(){}lateUpdate(){}traverse(s){s(this);for(let e=0,t=this.entityChildren.length;e<t;e++){let a=this.entityChildren[e];a instanceof ne&&a.traverse(s)}}destroy(s){this.transform.eventDispatcher.removeEventListener(Zt.LOCAL_ONCHANGE,this.onTransformLocalChange,this);const e=this.batchTable;e&&typeof e.destroy=="function"&&(e.destroy(),this.batchTable=null);const t=this.featureTable;t&&typeof t.destroy=="function"&&(t.destroy(),this.featureTable=null),super.destroy(s)}};ne=q2([$2],ne);function $2(s,e){return class extends ne{set active(t){this.transform.enable=t>0}get active(){return this.transform.enable?1:0}get materialColor(){return this.getComponent(he)?.material?.shader.getDefaultColorShader().baseColor}set materialColor(t){let a=this.getComponent(he)?.material;a&&(a.shader.getDefaultColorShader().baseColor=t)}notifyMaterialColorChange(t,a){this.getComponent(he).materials?.[t]?.shader.getDefaultColorShader().uniforms[a].onChange()}}}class bt{static createCamera3DObject(e,t){return this.createCamera3D(null,e,t)}static createCamera3D(e,t,a){return e||=new ne,t&&t.addChild(e),a&&(e.name=a),e.getOrAddComponent(ti)}static UnProjection(e,t,a=1,r){let i=new b(e,t,0),n=1,o=b.HELP_0,l=I.canvas.offsetLeft,c=I.canvas.offsetTop,f=I.canvas.clientWidth,d=I.canvas.clientHeight;o.x=((i.x-l)*n/f-.5)*2,o.y=-((i.y-c)*n/d-.5)*2,o.z=a;let h=new b(0,0,0),u=R.helpMatrix2;u.copyFrom(r.projectionMatrix),u.invert();let m=R.helpMatrix;return m.identity(),m.multiply(u),m.multiply(r.transform.worldMatrix),m.perspectiveMultiplyPoint3(o,h),h}static Projection(e,t,a){let r=a||new b(0,0,0),i=R.helpMatrix;i.copyFrom(t.viewMatrix),i.multiply(t.projectionMatrix),i.perspectiveMultiplyPoint3(e,r);let n=I.canvas.clientWidth/2,o=I.canvas.clientHeight/2;return r.x=r.x*n+n,r.y=o-r.y*o,r}static UnProjection2(e,t,a,r,i){let n=i||new b(0,0,0),o=R.helpMatrix;o.copyFrom(r.pvMatrixInv);let l=I.canvas.clientWidth/2,c=I.canvas.clientHeight/2;return n.x=(e-l)/l,n.y=(c-t)/c,n.z=a,o.perspectiveMultiplyPoint3(n,n),n}}class jt{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==ht.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==ht.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==ht.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==ht.DirectionLight){let a=this.directionLightList.get(e);return a||(a=[],this.directionLightList.set(e,a)),a}else if(t==ht.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==ht.DirectionLight){let a=this.directionLightList.get(t);if(a||(a=[],this.directionLightList.set(t,a)),!e.shadowCamera){e.shadowCamera=bt.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==ht.PointLight||e.lightData.lightType==ht.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==ht.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==ht.PointLight||e.lightData.lightType==ht.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=jt.directionLightList.get(e.scene),r=jt.pointLightList.get(e.scene),i=0,n=0,o=0,l=0;if(t.fill(0),a){let f=0;for(let d=0;d<a.length;d++){const h=a[d];t[d]=h.lightData.index,h.lightData.castShadowIndex=f++}n=a.length}if(r){o=n;let f=0;for(let d=o;d<r.length;d++){const h=r[d];t[d]=h.lightData.index,h.lightData.castShadowIndex=f++}l=o+r.length}xe.getAllCameraGroup().forEach(f=>{f.dirShadowStart=i,f.dirShadowEnd=n,f.pointShadowStart=o,f.pointShadowEnd=l,f.shadowLights.set(new Float32Array(t))})}}class $n{uuid;usage;globalBindGroup;uniformGPUBuffer;matrixBindGroup;uniformByteLength;matrixesByteLength;shadowMatrixRaw=new Float32Array(128);csmMatrixRaw=new Float32Array(sa.Cascades*16);csmShadowBias=new Float32Array(4);shadowLights=new Float32Array(16);dirShadowStart=0;dirShadowEnd=0;pointShadowStart=0;pointShadowEnd=0;constructor(e){this.uuid=zt(),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=R.block*4*R.maxCount,this.globalBindGroup=I.device.createBindGroup({label:"global_bindGroupLayout",layout:Ln.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=jt.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=_.setting.shadow.shadowSize;if(sa.Cascades>1&&e.enableCSM&&t[0])for(let l=0;l<sa.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=_.setting.reflectionSetting,i=q.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",dt.testObj.testValue2),this.uniformGPUBuffer.setFloat("test3",dt.testObj.testValue3),this.uniformGPUBuffer.setFloat("test4",dt.testObj.testValue4),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",We.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",We.time),this.uniformGPUBuffer.setFloat("delta",We.delta),this.uniformGPUBuffer.setFloat("shadowBias",e.getShadowBias(a)),this.uniformGPUBuffer.setFloat("skyExposure",_.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",_.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",_.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",_.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",_.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",_.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",_.setting.render.renderState_split);let n=_.inputSystem.mouseX*I.pixelRatio,o=_.inputSystem.mouseY*I.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",n),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",_.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",a),this.uniformGPUBuffer.setFloat("shadowSoft",_.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",e.enableCSM?1:0),this.uniformGPUBuffer.setFloat("csmMargin",_.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",We.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",We.time),this.uniformGPUBuffer.setFloat("delta",We.delta),this.uniformGPUBuffer.setFloat("shadowBias",_.setting.shadow.shadowBias),this.uniformGPUBuffer.setFloat("skyExposure",_.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",_.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",_.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",_.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",_.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",_.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",_.setting.render.renderState_split);let t=_.inputSystem.mouseX*I.pixelRatio,a=_.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",_.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",_.setting.shadow.shadowSize),this.uniformGPUBuffer.setFloat("shadowSoft",_.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",0),this.uniformGPUBuffer.setFloat("csmMargin",_.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 R0{setting;probesBufferData;probesBuffer;isVolumeFrameChange=!0;randomOrientation;startPosition=new b;isVolumeChange=!0;irradianceVolumeBuffer;directionDistance=20;randomSeedCount=3;useRandomIndex=0;centerDirection=new b(0,0,this.directionDistance).normalize(1);arroundPositions=[];updateOrientation(){return this.useRandomIndex++,this.useRandomIndex>=this.arroundPositions.length&&(this.useRandomIndex=0),R.fromToRotation(this.centerDirection,this.arroundPositions[this.useRandomIndex],this.randomOrientation),this.randomOrientation}init(e){this.setting=e,this.randomOrientation=new R(!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 b(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,n=this.setting.probeSpace;return r=r||new b,r.x=e*n-n*(i.probeXCount-1)*.5+i.offsetX,r.y=t*n-n*(i.probeYCount-1)*.5+i.offsetY,r.z=a*n-n*(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 Q0{storageGPUBuffer;irradianceVolume;_lightList=[];constructor(){this.storageGPUBuffer=new Pe(ws.lightSize*_.setting.light.maxLight,GPUBufferUsage.COPY_SRC),this.irradianceVolume=new R0,this.irradianceVolume.init(_.setting.gi);for(let e=0;e<_.setting.light.maxLight;e++){let t=this.storageGPUBuffer.memory.allocation_node(ws.lightSize*4);this._lightList.push(t)}this.storageGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e){this.storageGPUBuffer.clean();let t=q.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 T0{storageGPUBuffer;reflectionMap;sourceReflectionMap;count;constructor(){this.storageGPUBuffer=new Pe(768)}update(e){this.storageGPUBuffer.clean();let t=q.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 M0 extends Ya{size;constructor(e,t=0,a){super(),this.bufferType=Aa.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 n=new Float32Array(a.buffer,a.byteOffset,t);new Float32Array(i.getMappedRange(0,t*4)).set(n),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 N0{uuid;index;usage;groupBufferSize;matrixBufferDst;constructor(){this.uuid=zt(),this.groupBufferSize=0,this.usage=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.cacheWorldMatrix()}cacheWorldMatrix(){this.groupBufferSize=R.maxCount*R.blockBytes,this.matrixBufferDst=new M0(this.groupBufferSize/4),this.matrixBufferDst.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBufferDst.buffer.label=this.groupBufferSize.toString()}writeBuffer(e){const t=R.dynamicMatrixBytes;this.matrixBufferDst.mapAsyncWrite(t,e)}}class xe{static _cameraBindGroups;static _lightEntriesMap;static _reflectionEntriesMap;static modelMatrixBindGroup;static init(){this.modelMatrixBindGroup=new N0,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 $n(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 $n(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 Q0,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 T0,this._reflectionEntriesMap.set(e,t)),this._reflectionEntriesMap.get(e)}}class k{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(k.lastShader!=t)k.lastShader=t;else return!1;k.lastPipeline!=t.pipeline&&(k.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=xe.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 n=r[i];e.setVertexBuffer(i,a.buffer,n.offset,n.size)}}}static cleanCache(){this.lastGeometry=null,this.lastPipeline=null,this.lastShader=null}static createPipeline(e){return dt.countStart("GPUContext","pipeline"),I.device.createRenderPipeline(e)}static beginCommandEncoder(){return dt.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,dt.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 n=this.multiTextureViewCache.get(t.multiTexture);n||(n=t.multiTexture.createView(),this.multiTextureViewCache.set(t.multiTexture,n)),i.view=n,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,n){e.drawIndexed(t,a,r,i,n),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 P0{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 V0{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 P0,this._normalAttrDataGroup=new P0}initMorphTarget(e){this._collectMorphTargetData=this.collectMorphTargetList(e),this._computeShader&&this._computeShader.destroy();let t=Ht.CsMain;this._computeShader=new Fe(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,k.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("."),d=f[f.length-1];this._blendTarget[d]=h=>this.updateInfluence(c,h)}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 n=this.collectAttribute("a_morphNormals_",e),o;if(n&&n.length>0){let l=0;o=new Float32Array(r*a*3);for(let c=0;c<a;c++){let f=n[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,n=t.getAttribute(i);if(n)a[r]=n;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 eb=Object.defineProperty,tb=Object.getOwnPropertyDescriptor,eo=(s,e,t,a)=>{for(var r=a>1?void 0:a?tb(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=(a?n(e,t,r):n(r))||r);return a&&r&&eb(e,t,r),r};let he=class extends Ba{receiveShadow;morphData;constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(s){s.addComponent(he).copyComponent(this)}copyComponent(s){return super.copyComponent(s),this.receiveShadow=s.receiveShadow,this}get geometry(){return this._geometry}set geometry(s){if(super.geometry=s,s){let e=s.morphTargetDictionary!=null;e&&(this.morphData||=new V0,this.morphData.morphTargetsRelative=s.morphTargetsRelative,this.morphData.initMorphTarget(s)),this.morphData&&(this.morphData.enable=e),this.morphData?.enable?this.addRendererMask(Ne.MorphTarget):this.removeRendererMask(Ne.MorphTarget),this.object3D.bound=this._geometry.bounds.clone()}else this.morphData&&(this.morphData.enable=!1),this.removeRendererMask(Ne.MorphTarget);this._readyPipeline||(this.initPipeline(),this._computes&&(this.onCompute=Cs(this.onCompute,()=>{for(let e=0;e<this._computes.length;e++)this._computes[e].onUpdate()})))}get material(){return this._materials[0]}set material(s){this.materials=[s]}setMorphInfluence(s,e){if(this.morphData&&this.morphData.enable){let t=this._geometry.morphTargetDictionary[s];t>=0&&this.morphData.updateInfluence(t,e)}}setMorphInfluenceIndex(s,e){this.morphData&&this.morphData.enable&&s>=0&&this.morphData.updateInfluence(s,e)}onCompute(s,e){this.morphData&&this.morphData.enable&&this.morphData.computeMorphTarget(e)}nodeUpdate(s,e,t,a){if(this.morphData&&this.morphData.enable)for(let r=0;r<this.materials.length;r++){let n=this.materials[r].getPass(e);if(n)for(let o=0;o<n.length;o++)this.morphData.applyRenderShader(n[o])}super.nodeUpdate(s,e,t,a)}destroy(s){this.morphData&&(this.morphData.destroy(s),this.morphData=null),super.destroy(s)}};eo([Kr],he.prototype,"geometry",1),eo([Kr],he.prototype,"material",1),he=eo([Ot(he,"MeshRenderer")],he);class Pa{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 O0{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]:_.res.redTexture}}class Rt extends ut{resolveTarget;sampleCount;autoResize;clear;constructor(e,t,a=oe.rgba8unorm,r=!1,i,n=1,o=0,l=!0,c=!0){super(e,t,n),this.name=zt(),this.autoResize=c,this.useMipmap=r,this.sampleCount=o,this.format=a,this.numberLayer=n,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(lr.RESIZE,f=>{let{width:d,height:h}=f.data;this.resize(d,h),this._textureChange=!0},this)}resize(e,t){let a=I.device;this.gpuTexture&&(ut.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==oe.rgba32float?(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=a.createSampler({})):this.format==oe.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==oe.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=Kt.clamp_to_edge,this.addressModeV=Kt.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 n=new Float32Array(e*t*4);const o=r.createBuffer({size:n.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(o,0,n);const l=k.beginCommandEncoder();l.copyBufferToTexture({buffer:o,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),k.endCommandEncoder(l)}clone(){let e=new Rt(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 k.beginCommandEncoder().copyTextureToBuffer({texture:this.getGPUTexture()},{buffer:i},[t,a]),i.getMappedRange(0,r.byteLength)}}class Je{storeOp="store";loadOp="clear";clearValue=[0,0,0,0]}class ct{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 Je;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 ct([],[]);return this.clone2Frame(e),e}}class ve extends ct{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,n){let o=this.renderTargets,l=this.rtDescriptors;if(i){let f=new Je;f.loadOp="clear",this._colorBufferTex=Mt.createRTTexture(e+Pa.colorBufferTex_NAME,t,a,oe.rgba16float,!0),o.push(this._colorBufferTex),l.push(f)}this._compressGBufferTex=new Rt(t,a,oe.rgba32float,!1,void 0,1,0,!0,!0),o.push(this._compressGBufferTex),n?this.depthTexture=n:(this.depthTexture=new Rt(t,a,oe.depth24plus,!1,void 0,1,0,!0,!0),this.depthTexture.name=e+"_depthTexture");let c;c=new Je,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 n;if(ve.gBufferMap.has(e))n=ve.gBufferMap.get(e);else{n=new ve;let o=I.presentationSize;n.createGBuffer(e,t==0?o[0]:t,a==0?o[1]:a,t!=0&&a!=0,r,i),ve.gBufferMap.set(e,n)}return n}static getGUIBufferFrame(){let e=this.getGBufferFrame(this.colorPass_GBuffer);return ve.getGBufferFrame(ve.gui_GBuffer,0,0,!0,e.depthTexture)}clone(){let e=new ve;return this.clone2Frame(e),e}}class He{static rendererPassState=new Map;static createRendererPassState(e,t=null){let a=He.rendererPassState.get(e);if(a||(a=new O0,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,He.rendererPassState.set(e,a)),e&&e.renderTargets.length>0){a.renderTargets=e.renderTargets,a.rtTextureDescriptors=e.rtDescriptors,a.renderPassDescriptor=He.getRenderPassDescriptor(a),a.renderPassDescriptor.depthStencilAttachment&&(a.renderPassDescriptor.depthStencilAttachment.depthLoadOp=e.depthLoadOp),t=="load"&&e?.renderTargets[0]&&e.renderTargets[0].name.startsWith(ve.gui_GBuffer)&&(a.renderPassDescriptor.colorAttachments[0].loadOp="load"),a.depthLoadOp=e.depthLoadOp,a.renderBundleEncoderDescriptor=He.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(Pa.colorBufferTex_NAME)!=-1&&(a.outColor=r)}}else a.renderPassDescriptor=He.getRenderPassDescriptor(a,t),a.renderBundleEncoderDescriptor=He.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 n=e.renderTargets[i],o=e.rtTextureDescriptors[i];a.push({view:n.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 si extends Le{width;height;segmentW;segmentH;up;constructor(e,t,a=1,r=1,i=b.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,n=this.segmentW+1;(this.segmentH+1)*n,this.bounds=new Ce(b.ZERO.clone(),new b(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),d;this.segmentW*this.segmentH*2*3>=Uint16Array.length?d=new Uint32Array(this.segmentW*this.segmentH*2*3):d=new Uint16Array(this.segmentW*this.segmentH*2*3),r=0;for(var u=0,m=0,g=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 b.Y_AXIS:l[u++]=t,l[u++]=0,l[u++]=a,c[m++]=0,c[m++]=1,c[m++]=0;break;case b.Z_AXIS:l[u++]=t,l[u++]=-a,l[u++]=0,c[m++]=0,c[m++]=0,c[m++]=1;break;case b.X_AXIS:l[u++]=0,l[u++]=t,l[u++]=a,c[m++]=1,c[m++]=0,c[m++]=0;break;default:l[u++]=t,l[u++]=0,l[u++]=a,c[m++]=0,c[m++]=1,c[m++]=0;break}f[g++]=D/this.segmentW,f[g++]=p/this.segmentH,D!=this.segmentW&&p!=this.segmentH&&(i=D+p*n,d[r++]=i+1,d[r++]=i,d[r++]=i+n,d[r++]=i+1,d[r++]=i+n,d[r++]=i+n+1)}this.setIndices(d),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:d.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}var ab=Object.getOwnPropertyDescriptor,rb=(s,e,t,a)=>{for(var r=a>1?void 0:a?ab(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Ei=class extends At{constructor(s="QuadGlsl_vs",e="QuadGlsl_fs"){super();let t=new qe(s,e);this.addRenderPass(t);let a=t.shaderState;t.blendMode=De.NONE,a.frontFace="cw",a.depthWriteEnabled=!1,a.depthCompare=nt.always,a.multisample=0,this.setTexture("baseMap",_.res.blackTexture),this.setUniformFloat("x",0),this.setUniformFloat("y",0),this.setUniformFloat("width",100),this.setUniformFloat("height",100)}};Ei=rb([Na(Ei,"QuadShader")],Ei);class to extends ne{width=128;height=128;quadRenderer;material;rendererPassState;quadShader;constructor(e="QuadGlsl_vs",t="QuadGlsl_fs",a,r=0,i=!1){super();let n=a?a.renderTargets:[];this.material=new vt,this.quadShader=new Ei(e,t),this.material.shader=this.quadShader,this.quadRenderer=this.addComponent(he),this.quadRenderer.material=this.material,this.quadRenderer.castGI=!1,this.quadRenderer.castShadow=!1,this.quadRenderer.drawType=i?2:0,this.quadRenderer.geometry=new si(100,100,1,1),this.quadRenderer.material=this.material,this.quadRenderer.__start(),this.quadRenderer._enable=!0,this.quadRenderer.onEnable(),this.rendererPassState=He.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:n.length>0?n[0].format:I.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT})),I.addEventListener(lr.RESIZE,o=>{this.rendererPassState=He.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:n.length>0?n[0].format:I.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT}))},this)}renderTarget(e,t,a){let r=e.camera,i=k.beginRenderPass(a,t.rendererPassState);k.bindCamera(i,r),t.quadRenderer.nodeUpdate(e,fe.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,fe.COLOR,t.rendererPassState,null,i),k.endPass(i)}renderToViewQuad(e,t,a,r){let i=e.camera;t.quadShader.setTexture("baseMap",r);let n=k.beginRenderPass(a,t.rendererPassState);k.bindCamera(n,i),t.quadRenderer.nodeUpdate(e,fe.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,fe.COLOR,t.rendererPassState,null,n),k.endPass(n)}}class Mt{static rtTextureMap;static rtViewQuad;static init(){this.rtTextureMap=new Map,this.rtViewQuad=new Map}static createRTTexture(e,t,a,r,i=!1,n=0){let o=this.rtTextureMap.get(e);return o||(e==Pa.colorBufferTex_NAME?o=new Rt(t,a,r,i,void 0,1,n,!1):o=new Rt(t,a,r,i,void 0,1,n,!0),o.name=e,Mt.rtTextureMap.set(e,o)),o}static createRTTextureArray(e,t,a,r,i=1,n=!1,o=0){let l=this.rtTextureMap.get(e);return l||(l=new Rt(t,a,r,n,void 0,i,o),l.name=e,Mt.rtTextureMap.set(e,l)),l}static createViewQuad(e,t,a,r,i=0){let n=new ct([r],[new Je]),o=new to(t,a,n,i);return Mt.rtViewQuad.set(e,o),o}static getTexture(e){return this.rtTextureMap.get(e)}static CreateSplitTexture(e){let t=this.getTexture(Pa.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(Pa.colorBufferTex_NAME),a=this.getTexture(e+"_split");const r=k.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}),k.endCommandEncoder(r)}}class ao{command;encoder;rendererPassStates;rtFrame;constructor(e){this.rtFrame=e,this.rendererPassStates=[]}clean(){this.rendererPassStates.length=0,k.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=He.createRendererPassState(a,e);return this.rendererPassStates.push(r),r}else{this.rtFrame.depthLoadOp=t;let a=He.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=k.beginCommandEncoder(),this.command}endCommand(){k.endCommandEncoder(this.command),this.command=null}beginNewEncoder(){return this.encoder=k.beginRenderPass(this.command,this.rendererPassState),this.encoder}endEncoder(){k.endPass(this.encoder),this.encoder=null}}class Va extends Za{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=He.createRendererPassState(e);let t=e.clone();t.depthLoadOp="load";for(const a of t.rtDescriptors)a.loadOp="load";this.splitRendererPassState=He.createRendererPassState(t)}this.renderContext=new ao(e)}getRenderContext(e){return this._rtFrame=e,new ao(e)}setIrradiance(e,t){this.rendererPassState.irradianceBuffer=[e,t]}compute(e,t){}render(e,t,a,r=!1){k.cleanCache();let i=e.camera,n=e.scene;this.rendererPassState.camera3D=i;let o=q.instance.getRenderNodes(n,i),l=this.renderBundleOp(e,o,t,a),c=r?[]:this.renderBundleTr(e,o,t,a);{let f=k.beginCommandEncoder(),d=k.beginRenderPass(f,this.rendererPassState);l.length>0&&d.executeBundles(l),!r&&q.instance.sky&&(k.bindCamera(d,i),q.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,d)),this.drawRenderNodes(e,d,f,o.opaqueList,t),k.endPass(d),k.endCommandEncoder(f)}{let f=k.beginCommandEncoder(),d=k.beginRenderPass(f,this.rendererPassState);c.length>0&&d.executeBundles(c),r||(k.bindCamera(d,i),this.drawRenderNodes(e,d,f,o.transparentList,t)),k.endPass(d),k.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=q.instance.getOpRenderGroup(e.scene);if(i){let n=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))n.push(o.bundleMap.get(this._rendererType));else{let l=k.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),n.push(c)}}),n}return[]}renderBundleTr(e,t,a,r){let i=q.instance.getTrRenderGroup(e.scene);if(i){let n=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))n.push(o.bundleMap.get(this._rendererType));else{let l=k.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),n.push(c)}}),n}return[]}recordRenderBundleNode(e,t,a,r){k.bindCamera(t,e.camera),k.bindGeometryBuffer(t,a[0].geometry);for(let i=0;i<a.length;++i){let n=a[i];n.transform.worldMatrix.index,n.transform.enable&&n.recordRenderPass2(e,this._rendererType,this.rendererPassState,r,t)}}drawRenderNodes(e,t,a,r,i,n){k.bindCamera(t,e.camera);for(let o=_.setting.render.drawOpMin;o<Math.min(r.length,_.setting.render.drawOpMax);++o){let l=r[o];l.transform.enable&&l.enable&&l.renderPass2(e,this._rendererType,this.rendererPassState,n,t)}}}class L0 extends Va{constructor(){super(),this.passType=fe.COLOR}render(e,t,a,r=!1){this.renderContext.clean();let i=e.scene,n=e.camera;xe.updateCameraGroup(n),this.rendererPassState.camera3D=n;let o=q.instance.getRenderNodes(i,n),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&&(q.instance.getOpRenderGroup(i),f.executeBundles(l)),!r&&q.instance.sky&&(k.bindCamera(f,n),q.instance.sky.preInit(this._rendererType)||q.instance.sky.nodeUpdate(e,this._rendererType,this.rendererPassState,a),q.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,f)),o.opaqueList&&(k.bindCamera(f,n),this.drawNodes(e,this.renderContext,o.opaqueList,t,a))}{let f=this.renderContext.encoder;c.length>0&&f.executeBundles(c),!r&&o.transparentList&&(k.bindCamera(f,n),this.drawNodes(e,this.renderContext,o.transparentList,t,a));let d=q.instance.getGraphicList();for(let h=0;h<d.length;h++){const u=d[h];u.nodeUpdate(e,this._rendererType,this.splitRendererPassState,a),u.renderPass2(e,this._rendererType,this.splitRendererPassState,a,f)}this.renderContext.endRenderPass(),dt.end("ColorPass Draw Transparent")}}drawNodes(e,t,a,r,i){let n=q.instance.getRenderShaderCollect(e);if(n){for(const o of n){let l=o[1];for(const c of l){let f=c[1];if(!f.isDestroyed&&f.preInit(this._rendererType)){f.nodeUpdate(e,this._rendererType,this.rendererPassState,i);break}}}for(let o=_.setting.render.drawOpMin;o<Math.min(a.length,_.setting.render.drawOpMax);++o){let l=a[o];l.transform.enable&&l.enable&&(l.hasMask(Ne.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 ro{frustumCullingList;zVisibleList;_renderList;static enable=!0;constructor(){this._renderList=new Map}occlusionRenderNodeTest(e){return _.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 ni extends Ya{constructor(e,t){super(),this.bufferType=Aa.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 ni(e*2*4),this.clustersUniformBuffer=new Ct(10),this.clustersUniformBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.lightAssignBuffer=new ni(e*t),this.lightAssignBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.assignTableBuffer=new ni(e*4),this.assignTableBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e,t,a,r,i,n,o,l,c,f){this.clustersUniformBuffer.setFloat("clusterTileX",r),this.clustersUniformBuffer.setFloat("clusterTileY",i),this.clustersUniformBuffer.setFloat("clusterTileZ",n),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 Et{static clusterTileX=16;static clusterTileY=16;static clusterTileZ=32}let z0=`
|
|
6148
|
+
`;var Z2=Object.getOwnPropertyDescriptor,Y2=(s,e,t,a)=>{for(var r=a>1?void 0:a?Z2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let ki=class extends At{constructor(){super(),Y.register("pointcloud_vs_dc",F0),Y.register("pointcloud_fs_dc",k0);const s=new qe("pointcloud_vs_dc","pointcloud_fs_dc");s.passType=fe.COLOR,s.setShaderEntry("VertMain","FragMain"),s.topology=Ss.triangle_list,s.depthWriteEnabled=!0,s.cullMode=Lt.none,s.shaderState.transparent=!1,s.shaderState.blendMode=De.NORMAL,s.shaderState.writeMasks=[15,0],s.shaderState.castReflection=!1,this.addRenderPass(s),this.setDefault()}setDefault(){const s=this.getDefaultColorShader(),e=new R;s.setUniform("modelMatrix",e.rawData),s.setUniformArray("tex_params",new Float32Array([0,0,0,4])),s.setUniformArray("pointParams",new Float32Array([0,0,0,128]))}};ki=Y2([Na(ki,"PointCloudShader")],ki);class E0 extends vt{_texParams=new Float32Array([0,0,0,4]);_pointParamsArray=new Float32Array([0,0,0,128]);constructor(){super(),this.shader=new ki}setPointTextures(e,t,a,r){const i=this.shader.getDefaultColorShader();if(!i.getUniform("modelMatrix")){const n=new R;i.setUniform("modelMatrix",n.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=nt.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 Kn extends Le{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,n=r*6;a.set([0+i,1+i,2+i,0+i,2+i,3+i],n)}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 w0 extends ut{create(e,t,a,r=!0){let i=I.device;const n=e*4*4;this.format=oe.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=k.beginCommandEncoder();return c.copyBufferToTexture({buffer:l,bytesPerRow:n},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),k.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=oe.rgba32float,this.mipmapCount=1,this.createTextureDescriptor(e,t,this.mipmapCount,this.format);const n=k.beginCommandEncoder();return n.copyBufferToTexture({buffer:a,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),k.endCommandEncoder(n),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=r.createSampler({}),this}}var X2=Object.getOwnPropertyDescriptor,H2=(s,e,t,a)=>{for(var r=a>1?void 0:a?X2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let qa=class extends Ba{count=0;size=new de;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 b;get centerOffset(){return this._centerOffset}constructor(){super()}initFromData(s,e,t){if(!s||!e||t<=0){console.error("PointCloudRenderer: Invalid input data");return}if(s.length<t*3){console.error("PointCloudRenderer: Positions array too small");return}if(e.length<t*4){console.error("PointCloudRenderer: Colors array too small");return}this.count=t,this._fullCount=t,this.size=this.evalTextureSize(t),this._positions=s,this._colors=e,this.centerizePositions(),this.buildPositionTexture(),this.buildColorTexture(),this.texParams=new Float32Array([this.count,this.size.x,this.count,4]),this.buildOrderTexture(),this.pointCloudMaterial=new E0,this.geometry=new Kn(this._batchSize),this.materials=[this.pointCloudMaterial],this.instanceCount=Math.ceil(this.count/this._batchSize)}evalTextureSize(s){let e=Math.ceil(Math.sqrt(s));const t=64;e=Math.ceil(e/t)*t;const a=Math.ceil(s/e);return new de(e,a)}centerizePositions(){if(this.count===0)return;let s=0,e=0,t=0;for(let n=0;n<this.count;n++){const o=n*3;s+=this._positions[o+0],e+=this._positions[o+1],t+=this._positions[o+2]}const a=s/this.count,r=e/this.count,i=t/this.count;this._centerOffset.set(a,r,i);for(let n=0;n<this.count;n++){const o=n*3;this._positions[o+0]-=a,this._positions[o+1]-=r,this._positions[o+2]-=i}this.object3D.localPosition=this._centerOffset}buildPositionTexture(){const s=this.size.x|0,e=this.size.y|0,t=this.count,a=new Float32Array(s*e*4);for(let r=0;r<t;r++){const i=r*4,n=r*3;a[i+0]=this._positions[n+0],a[i+1]=this._positions[n+1],a[i+2]=this._positions[n+2],a[i+3]=0}if(t<s*e){const r=(t-1)*4;for(let i=t;i<s*e;i++){const n=i*4;a[n+0]=a[r+0],a[n+1]=a[r+1],a[n+2]=a[r+2],a[n+3]=0}}this.pointPosition=new w0().create(s,e,a),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 s=this.size.x|0,e=this.size.y|0,t=this.count,a=new Uint8Array(s*e*4);for(let r=0;r<t;r++){const i=r*4,n=r*4;a[i+0]=this._colors[n+0],a[i+1]=this._colors[n+1],a[i+2]=this._colors[n+2],a[i+3]=this._colors[n+3]}if(t<s*e){const r=(t-1)*4;for(let i=t;i<s*e;i++){const n=i*4;a[n+0]=a[r+0],a[n+1]=a[r+1],a[n+2]=a[r+2],a[n+3]=a[r+3]}}this.pointColor=new Fi().create(s,e,a,!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 s=this.size.x*this.size.y;this._orderData=new Uint32Array(s);for(let e=0;e<s;e++)this._orderData[e]=e<this.count?e:this.count>0?this.count-1:0;this.pointOrder=new Qs().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(s,e,t,a){const r=this.object3D.transform.worldMatrix;this.pointCloudMaterial.setTransformMatrix(r),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(s,e,t,a)}renderPass(s,e,t){const a=t.encoder;for(let r of this.materials){const i=r.getPass(e);if(!(!i||i.length===0))for(const n of i){if(!n.pipeline)continue;n.apply(this.geometry,t.rendererPassState||t),k.bindPipeline(a,n),k.bindGeometryBuffer(a,this.geometry);const l=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?k.drawIndexed(a,l.indexCount,this.instanceCount,l.indexStart,0,0):k.drawIndexed(a,l.indexCount,1,l.indexStart,0,0)}}}setPointSize(s){this.texParams[3]=Math.max(.1,s),this.pointCloudMaterial&&this.pointCloudMaterial.setPointSize(s)}setPointShape(s){this.pointCloudMaterial&&this.pointCloudMaterial.setPointShape(s)}enableDebugFullScreen(s){this._debugFullScreen=s,this.pointCloudMaterial&&this.pointCloudMaterial.enableDebugFullScreen(s)}setBatchSize(s){if(this._batchSize=Math.max(1,s|0),this.geometry){const e=this.geometry;ke.getInstance().detached(e,this),ke.getInstance().hasReference(e)||e.destroy(),this.geometry=new Kn(this._batchSize)}this.pointCloudMaterial&&(this.pointCloudMaterial.setBatchSize(this._batchSize),this.pointCloudMaterial.enableDebugFullScreen(this._debugFullScreen)),this.instanceCount=Math.ceil(this.count/this._batchSize)}destroy(s){this.pointColor&&(this.pointColor.destroy(s),this.pointColor=null),this.pointPosition&&(this.pointPosition.destroy(s),this.pointPosition=null),this.pointOrder&&(this.pointOrder.destroy(s),this.pointOrder=null),this._positions=null,this._colors=null,this._orderData=null,this.texParams=null,super.destroy(s)}};qa=H2([Ot(qa,"PointCloudRenderer")],qa);class qn{static maxVector=new b(Number.MAX_VALUE*.1,Number.MAX_VALUE*.1,Number.MAX_VALUE*.1);static minVector=this.maxVector.clone().multiplyScalar(-1);static genMeshMaxVector=b.ZERO.clone();static genMeshMinVector=b.ZERO.clone();static genMeshVectorList8=[new b,new b,new b,new b,new b,new b,new b,new b];static genPointCloudBounds(e,t){t||=new Ce(b.ZERO,b.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let a=e.getComponents(qa);if(!a)return console.warn("genPointCloudBounds: No PointCloudRenderer found on object"),t;for(const r of a){const i=r.positions,n=r.fullCount;if(!i||n===0){console.warn("genPointCloudBounds: No position data available");continue}const o=r.object3D.transform.worldMatrix,l=new b;for(let c=0;c<n;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(b.ZERO,b.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let a=e.getComponents(ii);if(!a)return console.warn("genGSplatBounds: No GSplatRenderer found on object"),t;for(const r of a){const i=r.positions,n=r.fullCount;if(!i||n===0)return console.warn("genGSplatBounds: No position data available"),t;const o=r.object3D.transform.worldMatrix,l=new b;for(let c=0;c<n;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(b.ZERO,b.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let n=e.getComponents(he);for(const o of n)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),n=this.genMeshVectorList8;a||=new Ce(b.ZERO,b.ZERO),a.setFromMinMax(this.maxVector,this.minVector),n[0].set(r.x,r.y,r.z),n[1].set(r.x,r.y,i.z),n[2].set(r.x,i.y,r.z),n[3].set(r.x,i.y,i.z),n[4].set(i.x,r.y,r.z),n[5].set(i.x,r.y,i.z),n[6].set(i.x,i.y,r.z),n[7].set(i.x,i.y,i.z);for(const o of n)e.transformPoint(o,o),a.expandByPoint(o);return i.copyFrom(a.max),r.copyFrom(a.min),a.setFromMinMax(r,i),a}}class I0 extends Za{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=yn().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&&(qn.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()):Oe.waitStartComponent.forEach((e,t)=>{for(;e.length>0;){const a=e.shift();a.__start(),Oe.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 K2=Object.getOwnPropertyDescriptor,q2=(s,e,t,a)=>{for(var r=a>1?void 0:a?K2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let ne=class extends I0{_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(s){this.entityChildren.forEach(e=>{s(e),e.forChild(s)})}addComponent(s,e){if(!this.components.has(s)){let t=new s;return t.object3D=this,this.components.set(s,t),t.__init(e),Oe.appendWaitStart(t),t}return this.components.get(s)}getOrAddComponent(s){let e=this.components.get(s);return e||(e=this.addComponent(s)),e}removeComponent(s){if(this.components.has(s)){let e=this.components.get(s);Oe.removeWaitStart(this,e),this.components.delete(s),e.__stop(),e.beforeDestroy(),e.destroy()}}hasComponent(s){return this.components.has(s)}getComponent(s){return this.components.get(s)}getComponentFromParent(s){if(!this.parent)return null;let e=this.parent.object3D.getComponent(s);return e||this.parent.object3D.getComponentFromParent(s)}getComponentsInChild(s){let e=[],t=this.components.get(s);t&&e.push(t);for(let a=0;a<this.entityChildren.length;a++){let i=this.entityChildren[a].getComponentsInChild(s);e.push(...i)}return e}getComponents(s,e,t){e||=[];let a=this.getComponent(s);a&&(a.enable||t)&&e.push(a);for(let r=0,i=this.entityChildren.length;r<i;r++){let n=this.entityChildren[r];n&&n instanceof ne&&n.getComponents(s,e,t)}return e}getComponentsExt(s,e,t){e||=[];let a=this.components.get(s);if(a&&(a.enable||t))e.push(a);else for(const r of this.entityChildren)r instanceof ne&&r.getComponentsExt(s,e,t);return e}getComponentsByProperty(s,e,t=!0,a,r){a||=[];let i;for(const n of this.components.values())n&&(n.enable||r)&&n[s]===e&&(a.push(n),i=!0);if(!(i&&t))for(const n of this.entityChildren)n instanceof ne&&n.getComponentsByProperty(s,e,t,a,r);return a}clone(){return this.instantiate()}instantiate(){let s=new ne;return s.name=this.name,s.serializeTag=this.serializeTag,s.prefabRef=this.prefabRef,this.entityChildren.forEach((e,t)=>{let a=e.instantiate();s.addChild(a)}),this.components.forEach((e,t)=>{e.cloneTo(s)}),s}get localPosition(){return this.transform.localPosition}set localPosition(s){this.transform.localPosition=s}get localRotation(){return this.transform.localRotation}set localRotation(s){this.transform.localRotation=s}get localScale(){return this.transform.localScale}set localScale(s){this.transform.localScale=s}get localQuaternion(){return this.transform.localRotQuat}set localQuaternion(s){this.transform.localRotQuat=s}notifyChange(){this.transform.notifyChange()}get parent(){return this.transform.parent}get parentObject(){return this.transform.parent.object3D}set x(s){this.transform.x=s}get x(){return this.transform.x}set y(s){this.transform.y=s}get y(){return this.transform.y}set z(s){this.transform.z=s}get z(){return this.transform.z}set scaleX(s){this.transform.scaleX=s}get scaleX(){return this.transform.scaleX}set scaleY(s){this.transform.scaleY=s}get scaleY(){return this.transform.scaleY}set scaleZ(s){this.transform.scaleZ=s}get scaleZ(){return this.transform.scaleZ}set rotationX(s){this.transform.rotationX=s}get rotationX(){return this.transform.rotationX}set rotationY(s){this.transform.rotationY=s}get rotationY(){return this.transform.rotationY}set rotationZ(s){this.transform.rotationZ=s}get rotationZ(){return this.transform.rotationZ}fixedUpdate(){}lateUpdate(){}traverse(s){s(this);for(let e=0,t=this.entityChildren.length;e<t;e++){let a=this.entityChildren[e];a instanceof ne&&a.traverse(s)}}destroy(s){this.transform.eventDispatcher.removeEventListener(Zt.LOCAL_ONCHANGE,this.onTransformLocalChange,this);const e=this.batchTable;e&&typeof e.destroy=="function"&&(e.destroy(),this.batchTable=null);const t=this.featureTable;t&&typeof t.destroy=="function"&&(t.destroy(),this.featureTable=null),super.destroy(s)}};ne=q2([$2],ne);function $2(s,e){return class extends ne{set active(t){this.transform.enable=t>0}get active(){return this.transform.enable?1:0}get materialColor(){return this.getComponent(he)?.material?.shader.getDefaultColorShader().baseColor}set materialColor(t){let a=this.getComponent(he)?.material;a&&(a.shader.getDefaultColorShader().baseColor=t)}notifyMaterialColorChange(t,a){this.getComponent(he).materials?.[t]?.shader.getDefaultColorShader().uniforms[a].onChange()}}}class bt{static createCamera3DObject(e,t){return this.createCamera3D(null,e,t)}static createCamera3D(e,t,a){return e||=new ne,t&&t.addChild(e),a&&(e.name=a),e.getOrAddComponent(ti)}static UnProjection(e,t,a=1,r){let i=new b(e,t,0),n=1,o=b.HELP_0,l=I.canvas.offsetLeft,c=I.canvas.offsetTop,f=I.canvas.clientWidth,d=I.canvas.clientHeight;o.x=((i.x-l)*n/f-.5)*2,o.y=-((i.y-c)*n/d-.5)*2,o.z=a;let h=new b(0,0,0),u=R.helpMatrix2;u.copyFrom(r.projectionMatrix),u.invert();let m=R.helpMatrix;return m.identity(),m.multiply(u),m.multiply(r.transform.worldMatrix),m.perspectiveMultiplyPoint3(o,h),h}static Projection(e,t,a){let r=a||new b(0,0,0),i=R.helpMatrix;i.copyFrom(t.viewMatrix),i.multiply(t.projectionMatrix),i.perspectiveMultiplyPoint3(e,r);let n=I.canvas.clientWidth/2,o=I.canvas.clientHeight/2;return r.x=r.x*n+n,r.y=o-r.y*o,r}static UnProjection2(e,t,a,r,i){let n=i||new b(0,0,0),o=R.helpMatrix;o.copyFrom(r.pvMatrixInv);let l=I.canvas.clientWidth/2,c=I.canvas.clientHeight/2;return n.x=(e-l)/l,n.y=(c-t)/c,n.z=a,o.perspectiveMultiplyPoint3(n,n),n}}class jt{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==ht.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==ht.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==ht.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==ht.DirectionLight){let a=this.directionLightList.get(e);return a||(a=[],this.directionLightList.set(e,a)),a}else if(t==ht.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==ht.DirectionLight){let a=this.directionLightList.get(t);if(a||(a=[],this.directionLightList.set(t,a)),!e.shadowCamera){e.shadowCamera=bt.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==ht.PointLight||e.lightData.lightType==ht.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==ht.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==ht.PointLight||e.lightData.lightType==ht.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=jt.directionLightList.get(e.scene),r=jt.pointLightList.get(e.scene),i=0,n=0,o=0,l=0;if(t.fill(0),a){let f=0;for(let d=0;d<a.length;d++){const h=a[d];t[d]=h.lightData.index,h.lightData.castShadowIndex=f++}n=a.length}if(r){o=n;let f=0;for(let d=o;d<r.length;d++){const h=r[d];t[d]=h.lightData.index,h.lightData.castShadowIndex=f++}l=o+r.length}xe.getAllCameraGroup().forEach(f=>{f.dirShadowStart=i,f.dirShadowEnd=n,f.pointShadowStart=o,f.pointShadowEnd=l,f.shadowLights.set(new Float32Array(t))})}}class $n{uuid;usage;globalBindGroup;uniformGPUBuffer;matrixBindGroup;uniformByteLength;matrixesByteLength;shadowMatrixRaw=new Float32Array(128);csmMatrixRaw=new Float32Array(sa.Cascades*16);csmShadowBias=new Float32Array(4);shadowLights=new Float32Array(16);dirShadowStart=0;dirShadowEnd=0;pointShadowStart=0;pointShadowEnd=0;constructor(e){this.uuid=zt(),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=R.block*4*R.maxCount,this.globalBindGroup=I.device.createBindGroup({label:"global_bindGroupLayout",layout:Ln.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=jt.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=_.setting.shadow.shadowSize;if(sa.Cascades>1&&e.enableCSM&&t[0])for(let l=0;l<sa.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=_.setting.reflectionSetting,i=q.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",dt.testObj.testValue2),this.uniformGPUBuffer.setFloat("test3",dt.testObj.testValue3),this.uniformGPUBuffer.setFloat("test4",dt.testObj.testValue4),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",We.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",We.time),this.uniformGPUBuffer.setFloat("delta",We.delta),this.uniformGPUBuffer.setFloat("shadowBias",e.getShadowBias(a)),this.uniformGPUBuffer.setFloat("skyExposure",_.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",_.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",_.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",_.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",_.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",_.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",_.setting.render.renderState_split);let n=_.inputSystem.mouseX*I.pixelRatio,o=_.inputSystem.mouseY*I.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",n),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",_.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",a),this.uniformGPUBuffer.setFloat("shadowSoft",_.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",e.enableCSM?1:0),this.uniformGPUBuffer.setFloat("csmMargin",_.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",We.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",We.time),this.uniformGPUBuffer.setFloat("delta",We.delta),this.uniformGPUBuffer.setFloat("shadowBias",_.setting.shadow.shadowBias),this.uniformGPUBuffer.setFloat("skyExposure",_.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",_.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",_.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",_.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",_.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",_.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",_.setting.render.renderState_split);let t=_.inputSystem.mouseX*I.pixelRatio,a=_.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",_.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",_.setting.shadow.shadowSize),this.uniformGPUBuffer.setFloat("shadowSoft",_.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",0),this.uniformGPUBuffer.setFloat("csmMargin",_.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 R0{setting;probesBufferData;probesBuffer;isVolumeFrameChange=!0;randomOrientation;startPosition=new b;isVolumeChange=!0;irradianceVolumeBuffer;directionDistance=20;randomSeedCount=3;useRandomIndex=0;centerDirection=new b(0,0,this.directionDistance).normalize(1);arroundPositions=[];updateOrientation(){return this.useRandomIndex++,this.useRandomIndex>=this.arroundPositions.length&&(this.useRandomIndex=0),R.fromToRotation(this.centerDirection,this.arroundPositions[this.useRandomIndex],this.randomOrientation),this.randomOrientation}init(e){this.setting=e,this.randomOrientation=new R(!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 b(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,n=this.setting.probeSpace;return r=r||new b,r.x=e*n-n*(i.probeXCount-1)*.5+i.offsetX,r.y=t*n-n*(i.probeYCount-1)*.5+i.offsetY,r.z=a*n-n*(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 Q0{storageGPUBuffer;irradianceVolume;_lightList=[];constructor(){this.storageGPUBuffer=new Pe(ws.lightSize*_.setting.light.maxLight,GPUBufferUsage.COPY_SRC),this.irradianceVolume=new R0,this.irradianceVolume.init(_.setting.gi);for(let e=0;e<_.setting.light.maxLight;e++){let t=this.storageGPUBuffer.memory.allocation_node(ws.lightSize*4);this._lightList.push(t)}this.storageGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e){this.storageGPUBuffer.clean();let t=q.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 T0{storageGPUBuffer;reflectionMap;sourceReflectionMap;count;constructor(){this.storageGPUBuffer=new Pe(768)}update(e){this.storageGPUBuffer.clean();let t=q.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 M0 extends Ya{size;constructor(e,t=0,a){super(),this.bufferType=Aa.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 n=new Float32Array(a.buffer,a.byteOffset,t);new Float32Array(i.getMappedRange(0,t*4)).set(n),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 N0{uuid;index;usage;groupBufferSize;matrixBufferDst;constructor(){this.uuid=zt(),this.groupBufferSize=0,this.usage=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.cacheWorldMatrix()}cacheWorldMatrix(){this.groupBufferSize=R.maxCount*R.blockBytes,this.matrixBufferDst=new M0(this.groupBufferSize/4),this.matrixBufferDst.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBufferDst.buffer.label=this.groupBufferSize.toString()}writeBuffer(e){const t=R.dynamicMatrixBytes;this.matrixBufferDst.mapAsyncWrite(t,e)}}class xe{static _cameraBindGroups;static _lightEntriesMap;static _reflectionEntriesMap;static modelMatrixBindGroup;static init(){this.modelMatrixBindGroup=new N0,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 $n(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 $n(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 Q0,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 T0,this._reflectionEntriesMap.set(e,t)),this._reflectionEntriesMap.get(e)}}class k{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(k.lastShader!=t)k.lastShader=t;else return!1;k.lastPipeline!=t.pipeline&&(k.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=xe.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 n=r[i];e.setVertexBuffer(i,a.buffer,n.offset,n.size)}}}static cleanCache(){this.lastGeometry=null,this.lastPipeline=null,this.lastShader=null}static createPipeline(e){return dt.countStart("GPUContext","pipeline"),I.device.createRenderPipeline(e)}static beginCommandEncoder(){return dt.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,dt.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 n=this.multiTextureViewCache.get(t.multiTexture);n||(n=t.multiTexture.createView(),this.multiTextureViewCache.set(t.multiTexture,n)),i.view=n,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,n){e.drawIndexed(t,a,r,i,n),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 P0{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 V0{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 P0,this._normalAttrDataGroup=new P0}initMorphTarget(e){this._collectMorphTargetData=this.collectMorphTargetList(e),this._computeShader&&this._computeShader.destroy();let t=Ht.CsMain;this._computeShader=new Fe(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,k.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("."),d=f[f.length-1];this._blendTarget[d]=h=>this.updateInfluence(c,h)}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 n=this.collectAttribute("a_morphNormals_",e),o;if(n&&n.length>0){let l=0;o=new Float32Array(r*a*3);for(let c=0;c<a;c++){let f=n[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,n=t.getAttribute(i);if(n)a[r]=n;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 eb=Object.defineProperty,tb=Object.getOwnPropertyDescriptor,eo=(s,e,t,a)=>{for(var r=a>1?void 0:a?tb(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=(a?n(e,t,r):n(r))||r);return a&&r&&eb(e,t,r),r};let he=class extends Ba{receiveShadow;morphData;constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(s){s.addComponent(he).copyComponent(this)}copyComponent(s){return super.copyComponent(s),this.receiveShadow=s.receiveShadow,this}get geometry(){return this._geometry}set geometry(s){if(super.geometry=s,s){let e=s.morphTargetDictionary!=null;e&&(this.morphData||=new V0,this.morphData.morphTargetsRelative=s.morphTargetsRelative,this.morphData.initMorphTarget(s)),this.morphData&&(this.morphData.enable=e),this.morphData?.enable?this.addRendererMask(Ne.MorphTarget):this.removeRendererMask(Ne.MorphTarget),this.object3D.bound=this._geometry.bounds.clone()}else this.morphData&&(this.morphData.enable=!1),this.removeRendererMask(Ne.MorphTarget);this._readyPipeline||(this.initPipeline(),this._computes&&(this.onCompute=Cs(this.onCompute,()=>{for(let e=0;e<this._computes.length;e++)this._computes[e].onUpdate()})))}get material(){return this._materials[0]}set material(s){this.materials=[s]}setMorphInfluence(s,e){if(this.morphData&&this.morphData.enable){let t=this._geometry.morphTargetDictionary[s];t>=0&&this.morphData.updateInfluence(t,e)}}setMorphInfluenceIndex(s,e){this.morphData&&this.morphData.enable&&s>=0&&this.morphData.updateInfluence(s,e)}onCompute(s,e){this.morphData&&this.morphData.enable&&this.morphData.computeMorphTarget(e)}nodeUpdate(s,e,t,a){if(this.morphData&&this.morphData.enable)for(let r=0;r<this.materials.length;r++){let n=this.materials[r].getPass(e);if(n)for(let o=0;o<n.length;o++)this.morphData.applyRenderShader(n[o])}super.nodeUpdate(s,e,t,a)}destroy(s){this.morphData&&(this.morphData.destroy(s),this.morphData=null),super.destroy(s)}};eo([Kr],he.prototype,"geometry",1),eo([Kr],he.prototype,"material",1),he=eo([Ot(he,"MeshRenderer")],he);class Pa{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 O0{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]:_.res.redTexture}}class Rt extends ut{resolveTarget;sampleCount;autoResize;clear;constructor(e,t,a=oe.rgba8unorm,r=!1,i,n=1,o=0,l=!0,c=!0){super(e,t,n),this.name=zt(),this.autoResize=c,this.useMipmap=r,this.sampleCount=o,this.format=a,this.numberLayer=n,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(lr.RESIZE,f=>{let{width:d,height:h}=f.data;this.resize(d,h),this._textureChange=!0},this)}resize(e,t){let a=I.device;this.gpuTexture&&(ut.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==oe.rgba32float?(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=a.createSampler({})):this.format==oe.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==oe.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=Kt.clamp_to_edge,this.addressModeV=Kt.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 n=new Float32Array(e*t*4);const o=r.createBuffer({size:n.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(o,0,n);const l=k.beginCommandEncoder();l.copyBufferToTexture({buffer:o,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),k.endCommandEncoder(l)}clone(){let e=new Rt(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 k.beginCommandEncoder().copyTextureToBuffer({texture:this.getGPUTexture()},{buffer:i},[t,a]),i.getMappedRange(0,r.byteLength)}}class Je{storeOp="store";loadOp="clear";clearValue=[0,0,0,0]}class ct{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 Je;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 ct([],[]);return this.clone2Frame(e),e}}class ve extends ct{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,n){let o=this.renderTargets,l=this.rtDescriptors;if(i){let f=new Je;f.loadOp="clear",this._colorBufferTex=Mt.createRTTexture(e+Pa.colorBufferTex_NAME,t,a,oe.rgba16float,!0),o.push(this._colorBufferTex),l.push(f)}this._compressGBufferTex=new Rt(t,a,oe.rgba32float,!1,void 0,1,0,!0,!0),o.push(this._compressGBufferTex),n?this.depthTexture=n:(this.depthTexture=new Rt(t,a,oe.depth24plus,!1,void 0,1,0,!0,!0),this.depthTexture.name=e+"_depthTexture");let c;c=new Je,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 n;if(ve.gBufferMap.has(e))n=ve.gBufferMap.get(e);else{n=new ve;let o=I.presentationSize;n.createGBuffer(e,t==0?o[0]:t,a==0?o[1]:a,t!=0&&a!=0,r,i),ve.gBufferMap.set(e,n)}return n}static getGUIBufferFrame(){let e=this.getGBufferFrame(this.colorPass_GBuffer);return ve.getGBufferFrame(ve.gui_GBuffer,0,0,!0,e.depthTexture)}clone(){let e=new ve;return this.clone2Frame(e),e}}class He{static rendererPassState=new Map;static createRendererPassState(e,t=null){let a=He.rendererPassState.get(e);if(a||(a=new O0,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,He.rendererPassState.set(e,a)),e&&e.renderTargets.length>0){a.renderTargets=e.renderTargets,a.rtTextureDescriptors=e.rtDescriptors,a.renderPassDescriptor=He.getRenderPassDescriptor(a),a.renderPassDescriptor.depthStencilAttachment&&(a.renderPassDescriptor.depthStencilAttachment.depthLoadOp=e.depthLoadOp),t=="load"&&e?.renderTargets[0]&&e.renderTargets[0].name.startsWith(ve.gui_GBuffer)&&(a.renderPassDescriptor.colorAttachments[0].loadOp="load"),a.depthLoadOp=e.depthLoadOp,a.renderBundleEncoderDescriptor=He.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(Pa.colorBufferTex_NAME)!=-1&&(a.outColor=r)}}else a.renderPassDescriptor=He.getRenderPassDescriptor(a,t),a.renderBundleEncoderDescriptor=He.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 n=e.renderTargets[i],o=e.rtTextureDescriptors[i];a.push({view:n.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 si extends Le{width;height;segmentW;segmentH;up;constructor(e,t,a=1,r=1,i=b.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,n=this.segmentW+1;(this.segmentH+1)*n,this.bounds=new Ce(b.ZERO.clone(),new b(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),d;this.segmentW*this.segmentH*2*3>=Uint16Array.length?d=new Uint32Array(this.segmentW*this.segmentH*2*3):d=new Uint16Array(this.segmentW*this.segmentH*2*3),r=0;for(var u=0,m=0,g=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 b.Y_AXIS:l[u++]=t,l[u++]=0,l[u++]=a,c[m++]=0,c[m++]=1,c[m++]=0;break;case b.Z_AXIS:l[u++]=t,l[u++]=-a,l[u++]=0,c[m++]=0,c[m++]=0,c[m++]=1;break;case b.X_AXIS:l[u++]=0,l[u++]=t,l[u++]=a,c[m++]=1,c[m++]=0,c[m++]=0;break;default:l[u++]=t,l[u++]=0,l[u++]=a,c[m++]=0,c[m++]=1,c[m++]=0;break}f[g++]=D/this.segmentW,f[g++]=p/this.segmentH,D!=this.segmentW&&p!=this.segmentH&&(i=D+p*n,d[r++]=i+1,d[r++]=i,d[r++]=i+n,d[r++]=i+1,d[r++]=i+n,d[r++]=i+n+1)}this.setIndices(d),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:d.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}var ab=Object.getOwnPropertyDescriptor,rb=(s,e,t,a)=>{for(var r=a>1?void 0:a?ab(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};let Ei=class extends At{constructor(s="QuadGlsl_vs",e="QuadGlsl_fs"){super();let t=new qe(s,e);this.addRenderPass(t);let a=t.shaderState;t.blendMode=De.NONE,a.frontFace="cw",a.depthWriteEnabled=!1,a.depthCompare=nt.always,a.multisample=0,this.setTexture("baseMap",_.res.blackTexture),this.setUniformFloat("x",0),this.setUniformFloat("y",0),this.setUniformFloat("width",100),this.setUniformFloat("height",100)}};Ei=rb([Na(Ei,"QuadShader")],Ei);class to extends ne{width=128;height=128;quadRenderer;material;rendererPassState;quadShader;constructor(e="QuadGlsl_vs",t="QuadGlsl_fs",a,r=0,i=!1){super();let n=a?a.renderTargets:[];this.material=new vt,this.quadShader=new Ei(e,t),this.material.shader=this.quadShader,this.quadRenderer=this.addComponent(he),this.quadRenderer.material=this.material,this.quadRenderer.castGI=!1,this.quadRenderer.castShadow=!1,this.quadRenderer.drawType=i?2:0,this.quadRenderer.geometry=new si(100,100,1,1),this.quadRenderer.material=this.material,this.quadRenderer.__start(),this.quadRenderer._enable=!0,this.quadRenderer.onEnable(),this.rendererPassState=He.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:n.length>0?n[0].format:I.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT})),I.addEventListener(lr.RESIZE,o=>{this.rendererPassState=He.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:n.length>0?n[0].format:I.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT}))},this)}renderTarget(e,t,a){let r=e.camera,i=k.beginRenderPass(a,t.rendererPassState);k.bindCamera(i,r),t.quadRenderer.nodeUpdate(e,fe.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,fe.COLOR,t.rendererPassState,null,i),k.endPass(i)}renderToViewQuad(e,t,a,r){let i=e.camera;t.quadShader.setTexture("baseMap",r);let n=k.beginRenderPass(a,t.rendererPassState);k.bindCamera(n,i),t.quadRenderer.nodeUpdate(e,fe.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,fe.COLOR,t.rendererPassState,null,n),k.endPass(n)}}class Mt{static rtTextureMap;static rtViewQuad;static init(){this.rtTextureMap=new Map,this.rtViewQuad=new Map}static createRTTexture(e,t,a,r,i=!1,n=0){let o=this.rtTextureMap.get(e);return o||(e==Pa.colorBufferTex_NAME?o=new Rt(t,a,r,i,void 0,1,n,!1):o=new Rt(t,a,r,i,void 0,1,n,!0),o.name=e,Mt.rtTextureMap.set(e,o)),o}static createRTTextureArray(e,t,a,r,i=1,n=!1,o=0){let l=this.rtTextureMap.get(e);return l||(l=new Rt(t,a,r,n,void 0,i,o),l.name=e,Mt.rtTextureMap.set(e,l)),l}static createViewQuad(e,t,a,r,i=0){let n=new ct([r],[new Je]),o=new to(t,a,n,i);return Mt.rtViewQuad.set(e,o),o}static getTexture(e){return this.rtTextureMap.get(e)}static CreateSplitTexture(e){let t=this.getTexture(Pa.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(Pa.colorBufferTex_NAME),a=this.getTexture(e+"_split");const r=k.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}),k.endCommandEncoder(r)}}class ao{command;encoder;rendererPassStates;rtFrame;constructor(e){this.rtFrame=e,this.rendererPassStates=[]}clean(){this.rendererPassStates.length=0,k.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=He.createRendererPassState(a,e);return this.rendererPassStates.push(r),r}else{this.rtFrame.depthLoadOp=t;let a=He.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=k.beginCommandEncoder(),this.command}endCommand(){k.endCommandEncoder(this.command),this.command=null}beginNewEncoder(){return this.encoder=k.beginRenderPass(this.command,this.rendererPassState),this.encoder}endEncoder(){k.endPass(this.encoder),this.encoder=null}}class Va extends Za{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=He.createRendererPassState(e);let t=e.clone();t.depthLoadOp="load";for(const a of t.rtDescriptors)a.loadOp="load";this.splitRendererPassState=He.createRendererPassState(t)}this.renderContext=new ao(e)}getRenderContext(e){return this._rtFrame=e,new ao(e)}setIrradiance(e,t){this.rendererPassState.irradianceBuffer=[e,t]}compute(e,t){}render(e,t,a,r=!1){k.cleanCache();let i=e.camera,n=e.scene;this.rendererPassState.camera3D=i;let o=q.instance.getRenderNodes(n,i),l=this.renderBundleOp(e,o,t,a),c=r?[]:this.renderBundleTr(e,o,t,a);{let f=k.beginCommandEncoder(),d=k.beginRenderPass(f,this.rendererPassState);l.length>0&&d.executeBundles(l),!r&&q.instance.sky&&(k.bindCamera(d,i),q.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,d)),this.drawRenderNodes(e,d,f,o.opaqueList,t),k.endPass(d),k.endCommandEncoder(f)}{let f=k.beginCommandEncoder(),d=k.beginRenderPass(f,this.rendererPassState);c.length>0&&d.executeBundles(c),r||(k.bindCamera(d,i),this.drawRenderNodes(e,d,f,o.transparentList,t)),k.endPass(d),k.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=q.instance.getOpRenderGroup(e.scene);if(i){let n=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))n.push(o.bundleMap.get(this._rendererType));else{let l=k.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),n.push(c)}}),n}return[]}renderBundleTr(e,t,a,r){let i=q.instance.getTrRenderGroup(e.scene);if(i){let n=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))n.push(o.bundleMap.get(this._rendererType));else{let l=k.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),n.push(c)}}),n}return[]}recordRenderBundleNode(e,t,a,r){k.bindCamera(t,e.camera),k.bindGeometryBuffer(t,a[0].geometry);for(let i=0;i<a.length;++i){let n=a[i];n.transform.worldMatrix.index,n.transform.enable&&n.recordRenderPass2(e,this._rendererType,this.rendererPassState,r,t)}}drawRenderNodes(e,t,a,r,i,n){k.bindCamera(t,e.camera);for(let o=_.setting.render.drawOpMin;o<Math.min(r.length,_.setting.render.drawOpMax);++o){let l=r[o];l.transform.enable&&l.enable&&l.renderPass2(e,this._rendererType,this.rendererPassState,n,t)}}}class L0 extends Va{constructor(){super(),this.passType=fe.COLOR}render(e,t,a,r=!1){this.renderContext.clean();let i=e.scene,n=e.camera;xe.updateCameraGroup(n),this.rendererPassState.camera3D=n;let o=q.instance.getRenderNodes(i,n),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&&(q.instance.getOpRenderGroup(i),f.executeBundles(l)),!r&&q.instance.sky&&(k.bindCamera(f,n),q.instance.sky.preInit(this._rendererType)||q.instance.sky.nodeUpdate(e,this._rendererType,this.rendererPassState,a),q.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,f)),o.opaqueList&&(k.bindCamera(f,n),this.drawNodes(e,this.renderContext,o.opaqueList,t,a))}{let f=this.renderContext.encoder;c.length>0&&f.executeBundles(c),!r&&o.transparentList&&(k.bindCamera(f,n),this.drawNodes(e,this.renderContext,o.transparentList,t,a));let d=q.instance.getGraphicList();for(let h=0;h<d.length;h++){const u=d[h];u.nodeUpdate(e,this._rendererType,this.splitRendererPassState,a),u.renderPass2(e,this._rendererType,this.splitRendererPassState,a,f)}this.renderContext.endRenderPass(),dt.end("ColorPass Draw Transparent")}}drawNodes(e,t,a,r,i){let n=q.instance.getRenderShaderCollect(e);if(n){for(const o of n){let l=o[1];for(const c of l){let f=c[1];if(!f.isDestroyed&&f.preInit(this._rendererType)){f.nodeUpdate(e,this._rendererType,this.rendererPassState,i);break}}}for(let o=_.setting.render.drawOpMin;o<Math.min(a.length,_.setting.render.drawOpMax);++o){let l=a[o];l.transform.enable&&l.enable&&(l.hasMask(Ne.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 ro{frustumCullingList;zVisibleList;_renderList;static enable=!0;constructor(){this._renderList=new Map}occlusionRenderNodeTest(e){return _.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 ni extends Ya{constructor(e,t){super(),this.bufferType=Aa.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 ni(e*2*4),this.clustersUniformBuffer=new Ct(10),this.clustersUniformBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.lightAssignBuffer=new ni(e*t),this.lightAssignBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.assignTableBuffer=new ni(e*4),this.assignTableBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e,t,a,r,i,n,o,l,c,f){this.clustersUniformBuffer.setFloat("clusterTileX",r),this.clustersUniformBuffer.setFloat("clusterTileY",i),this.clustersUniformBuffer.setFloat("clusterTileZ",n),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 Et{static clusterTileX=16;static clusterTileY=16;static clusterTileZ=32}let z0=`
|
|
6150
6149
|
#include "GlobalUniform"
|
|
6151
6150
|
|
|
6152
6151
|
struct ClusterBox{
|
|
@@ -7916,7 +7915,7 @@ else if (typeof exports === 'object')
|
|
|
7916
7915
|
`;class td{compute;constructor(){this.compute=new Fe(ed)}generateBRDFLUTTexture(){let e=new Te(256,256,oe.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=k.beginCommandEncoder();return k.computeCommand(t,[this.compute]),k.endCommandEncoder(t),e}}class ci{id;guiTexture;uvRec=new be(0,0,1,1);uvBorder=new be(0,0,0,0);offsetSize=new be(0,0,4,4);borderSize=new be(0,0,0,0);trimSize=new de;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||_.res.defaultGUITexture}}class Fr{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=_.res.whiteTexture,e.addressModeU="clamp-to-edge",e.addressModeV="clamp-to-edge",this.texture=e,Fr._maxUid++,this._staticId=Fr._maxUid,this.init()}init(){this.dynamicId=-1,this.width=this.texture.width,this.height=this.texture.height}}class wb{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 fi=new wb;class ad{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 rd{id=0;file=""}class id{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class ir extends it{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 ci;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),fi.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 ad;a.trim().split(t).forEach((i,n)=>{if(n<2)ir.readLineProperty(i,r);else if(n<r.pages+2){let o=new rd;ir.readLineProperty(i,o),r.fontPage.push(o)}else if(n<r.pages+3)ir.readLineProperty(i,r);else if(r.count>0){let o=new id;ir.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 _.res.loadTexture(r,null,!0);let i=_.res.getTexture(r),n=new Fr(i);e.push(n)}ir.parseSprite(e,t),t.fontChar[" "]||ir.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ci,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),fi.addFnt(e.face,e.size,a.id,a)}static readLineProperty(e,t){e.trim().split(" ").forEach((a,r)=>{let i=a.split("=");if(i.length>1){let n=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,n)&&(o.indexOf('"')==-1?t[n]=parseFloat(i[1]):t[n]=o.replace('"',"").replace('"',""))}})}}function Ib(s,e){let t=new ci;return t.id=s,t.offsetSize.set(0,0,e.width,e.height),t.trimSize.set(e.width,e.height),t.width=e.width,t.height=e.height,t.xadvance=0,t.xoffset=0,t.yoffset=0,t.guiTexture=new Fr(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function sd(s,e,t){let a=new ci;a.guiTexture=s,a.id=e,a.uvRec.copyFrom(t.textureRect),a.trimSize.x=t.textureRect.z,a.trimSize.y=t.textureRect.w,a.offsetSize.x=t.textureRectOffset.x,a.offsetSize.y=t.textureRectOffset.y,a.offsetSize.z=t.size.x,a.offsetSize.w=t.size.y,a.width=t.size.x,a.height=t.size.y;let r=1/s.width,i=1/s.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let n=.1;return t.border.x<=n&&t.border.y<=n&&t.border.z<=n&&t.border.x<=n?a.isSliced=!1:(a.borderSize.copyFrom(t.border),a.uvBorder.copyFrom(t.border),a.uvBorder.x-=t.textureRectOffset.x,a.uvBorder.y-=t.textureRectOffset.y,a.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),a.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),a.uvBorder.x/=t.textureRect.z,a.uvBorder.z/=t.textureRect.z,a.uvBorder.y/=t.textureRect.w,a.uvBorder.w/=t.textureRect.w,a.isSliced=!0),a}class nd{_spriteMap=new Map;_spriteList=[];textureSize=new de;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=sd(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 od extends it{static format=je.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await _.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 nd(this._json.size),t=new Fr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);_.res.addAtlas(this.baseUrl,e),this.data=e}}var qt=Uint8Array,di=Uint16Array,Rb=Int32Array,ld=new qt([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]),cd=new qt([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]),Qb=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fd=function(s,e){for(var t=new di(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new Rb(t[30]),a=1;a<30;++a)for(var i=t[a];i<t[a+1];++i)r[i]=i-t[a]<<5|a;return{b:t,r}},dd=fd(ld,2),hd=dd.b,Tb=dd.r;hd[28]=258,Tb[258]=28;for(var Mb=fd(cd,0),Nb=Mb.b,wo=new di(32768),Ke=0;Ke<32768;++Ke){var gr=(Ke&43690)>>1|(Ke&21845)<<1;gr=(gr&52428)>>2|(gr&13107)<<2,gr=(gr&61680)>>4|(gr&3855)<<4,wo[Ke]=((gr&65280)>>8|(gr&255)<<8)>>1}for(var Pi=(function(s,e,t){for(var a=s.length,r=0,i=new di(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new di(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new di(1<<e);var l=15-e;for(r=0;r<a;++r)if(s[r])for(var c=r<<4|s[r],f=e-s[r],d=n[s[r]-1]++<<f,h=d|(1<<f)-1;d<=h;++d)o[wo[d]>>l]=c}else for(o=new di(a),r=0;r<a;++r)s[r]&&(o[r]=wo[n[s[r]-1]++]>>15-s[r]);return o}),Vi=new qt(288),Ke=0;Ke<144;++Ke)Vi[Ke]=8;for(var Ke=144;Ke<256;++Ke)Vi[Ke]=9;for(var Ke=256;Ke<280;++Ke)Vi[Ke]=7;for(var Ke=280;Ke<288;++Ke)Vi[Ke]=8;for(var ud=new qt(32),Ke=0;Ke<32;++Ke)ud[Ke]=5;var Pb=Pi(Vi,9,1),Vb=Pi(ud,5,1),Io=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},va=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},Ro=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Ob=function(s){return(s+7)/8|0},Qo=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new qt(s.subarray(e,t))},Lb=["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(s,e,t){var a=new Error(e||Lb[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,ca),!t)throw a;return a},Gb=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new qt(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new qt(r*3));var c=function(ie){var le=t.length;if(ie>le){var ge=new qt(Math.max(le*2,ie));ge.set(t),t=ge}},f=e.f||0,d=e.p||0,h=e.b||0,u=e.l,m=e.d,g=e.m,p=e.n,D=r*8;do{if(!u){f=va(s,d,1);var A=va(s,d+1,3);if(d+=3,A)if(A==1)u=Pb,m=Vb,g=9,p=5;else if(A==2){var y=va(s,d,31)+257,S=va(s,d+10,15)+4,F=y+va(s,d+5,31)+1;d+=14;for(var C=new qt(F),w=new qt(19),E=0;E<S;++E)w[Qb[E]]=va(s,d+E*3,7);d+=S*3;for(var Q=Io(w),T=(1<<Q)-1,j=Pi(w,Q,1),E=0;E<F;){var ue=j[va(s,d,T)];d+=ue&15;var B=ue>>4;if(B<16)C[E++]=B;else{var ee=0,N=0;for(B==16?(N=3+va(s,d,3),d+=2,ee=C[E-1]):B==17?(N=3+va(s,d,7),d+=3):B==18&&(N=11+va(s,d,127),d+=7);N--;)C[E++]=ee}}var M=C.subarray(0,y),O=C.subarray(y);g=Io(M),p=Io(O),u=Pi(M,g,1),m=Pi(O,p,1)}else ca(1);else{var B=Ob(d)+4,v=s[B-4]|s[B-3]<<8,U=B+v;if(U>r){l&&ca(0);break}o&&c(h+v),t.set(s.subarray(B,U),h),e.b=h+=v,e.p=d=U*8,e.f=f;continue}if(d>D){l&&ca(0);break}}o&&c(h+131072);for(var W=(1<<g)-1,ae=(1<<p)-1,z=d;;z=d){var ee=u[Ro(s,d)&W],K=ee>>4;if(d+=ee&15,d>D){l&&ca(0);break}if(ee||ca(2),K<256)t[h++]=K;else if(K==256){z=d,u=null;break}else{var $=K-254;if(K>264){var E=K-257,re=ld[E];$=va(s,d,(1<<re)-1)+hd[E],d+=re}var ce=m[Ro(s,d)&ae],Ae=ce>>4;ce||ca(3),d+=ce&15;var O=Nb[Ae];if(Ae>3){var re=cd[Ae];O+=Ro(s,d)&(1<<re)-1,d+=re}if(d>D){l&&ca(0);break}o&&c(h+131072);var Qe=h+$;if(h<O){var Ve=i-O,H=Math.min(O,Qe);for(Ve+h<0&&ca(3);h<H;++h)t[h]=a[Ve+h]}for(;h<Qe;++h)t[h]=t[h-O]}}e.l=u,e.p=z,e.b=h,e.f=f,u&&(f=1,e.m=g,e.d=m,e.n=p)}while(!f);return h!=t.length&&n?Qo(t,0,h):t.subarray(0,h)},zb=new qt(0),Oa=function(s,e){return s[e]|s[e+1]<<8},xa=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},To=function(s,e){return xa(s,e)+xa(s,e+4)*4294967296};function Wb(s,e){return Gb(s,{i:2},e&&e.out,e&&e.dictionary)}var Mo=typeof TextDecoder<"u"&&new TextDecoder,Jb=0;try{Mo.decode(zb,{stream:!0}),Jb=1}catch{}var jb=function(s){for(var e="",t=0;;){var a=s[t++],r=(a>127)+(a>223)+(a>239);if(t+r>s.length)return{s:e,r:Qo(s,t-1)};r?r==3?(a=((a&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|s[t++]&63):e+=String.fromCharCode((a&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(a)}};function bd(s,e){if(e){for(var t="",a=0;a<s.length;a+=16384)t+=String.fromCharCode.apply(null,s.subarray(a,a+16384));return t}else{if(Mo)return Mo.decode(s);var r=jb(s),i=r.s,t=r.r;return t.length&&ca(8),i}}var Zb=function(s,e){return e+30+Oa(s,e+26)+Oa(s,e+28)},Yb=function(s,e,t){var a=Oa(s,e+28),r=bd(s.subarray(e+46,e+46+a),!(Oa(s,e+8)&2048)),i=e+46+a,n=xa(s,e+20),o=t&&n==4294967295?Xb(s,i):[n,xa(s,e+24),xa(s,e+42)],l=o[0],c=o[1],f=o[2];return[Oa(s,e+10),l,c,r,i+Oa(s,e+30)+Oa(s,e+32),f]},Xb=function(s,e){for(;Oa(s,e)!=1;e+=4+Oa(s,e+2));return[To(s,e+12),To(s,e+4),To(s,e+20)]};function Hb(s,e){for(var t={},a=s.length-22;xa(s,a)!=101010256;--a)(!a||s.length-a>65558)&&ca(13);var r=Oa(s,a+8);if(!r)return{};var i=xa(s,a+16),n=i==4294967295||r==65535;if(n){var o=xa(s,a-12);n=xa(s,o)==101075792,n&&(r=xa(s,o+32),i=xa(s,o+48))}for(var l=0;l<r;++l){var c=Yb(s,i,n),f=c[0],d=c[1],h=c[2],u=c[3],m=c[4],g=c[5],p=Zb(s,g);i=m,f?f==8?t[u]=Wb(s.subarray(p,p+d),{out:new qt(h)}):ca(14,"unknown compression type "+f):t[u]=Qo(s,p,p+d)}return t}class Bt extends vt{constructor(){super(),this.shader=new qi,this.baseMap=_.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 Nr extends Le{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,n,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=n,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,n=this.radius;var o=(r+1)*(i+1);let l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),d=new Uint16Array(i*r*2*3),h=0,u=0,m=0;for(t=0;t<=r;++t){var g=Math.PI*t/r,p=n*Math.cos(g),D=n*Math.sin(g);for(e=0;e<=i;++e){var A=2*Math.PI*e/i,B=D*Math.cos(A),v=D*Math.sin(A),U=1/Math.sqrt(B*B+p*p+v*v);if(l[h++]=B,l[h++]=p,l[h++]=v,c[u++]=B*U,c[u++]=p*U,c[u++]=v*U,f[m++]=e/i,f[m++]=t/r,e>0&&t>0){var y=(i+1)*t+e,S=(i+1)*t+e-1,F=(i+1)*(t-1)+e-1,C=(i+1)*(t-1)+e;t==r?(d[a++]=y,d[a++]=F,d[a++]=C):t==1?(d[a++]=y,d[a++]=S,d[a++]=F):(d[a++]=y,d[a++]=S,d[a++]=F,d[a++]=y,d[a++]=F,d[a++]=C)}}}this.setIndices(d),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:d.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Ce(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class _s extends ne{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new b(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),_s.register3DRepresentation)this.marker=_s.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new ne;const e=this.marker.addComponent(he);e.geometry=new Nr(.1,32,16),e.material=new Bt,e.material.baseColor=this.positionValid?new J(0,1,0,1):new J(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class Bs extends ne{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new _s(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),Bs.register3DRepresentation?(this.line=Bs.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new J(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Le,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 n=new ne,o=n.addComponent(he),l=new Bt;return l.topology="line-list",l.baseColor=t,l.blendMode=De.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class gd extends it{static format=je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Hb(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(bd(n),"application/xml"),c={};this.parseNode(l,c);const f=i.replace("wpmz/","").split(".")[0];Object.assign(t,{[f]:c["#document"].kml.Document})}const r=new Bs(t.waylines);this.data=r}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const a=["Placemark","actionGroup","action"],r=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[r]=void 0;else{let i=null,n=!1;for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];if(l.nodeType==Node.TEXT_NODE){const c=l.nodeValue?.trim();c&&c.length>0&&(i=c)}else l.nodeType==Node.ELEMENT_NODE&&(n=!0)}if(i&&!n)t[r]=i;else if(n){a.includes(r)?t[r]?.length?t[r].push({}):t[r]=[{}]:t[r]={};for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[r])?t[r].at(-1):t[r])}}else t[r]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class pd{_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 It().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 It;r==".gltf"?a=await i.load(e,xt,t):a=await i.load(e,_o,t);let n=a.data;return this._prefabPool.set(e,n),this._gltfPool.set(e,a.gltf),n}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new It;r==".obj"&&(a=await i.load(e,Ds,t));let n=a.data;return this._prefabPool.set(e,n),n}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new It().load(e,So,t,a)).data;return this._prefabPool.set(e,n),n}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new It().load(e,Eo,t,a)).data;return this._prefabPool.set(e,n),n}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new $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?ke.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,n)=>{let o=0,l=[];t==0&&i(l);for(let c=0;c<t;c++){const f=e.shift();this.loadTexture(f,a,r).then(d=>{l.push(d),o++,o==t&&i(l)})}})}async loadBitmapTextures(e,t=5,a,r){let i=[],n=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<n;l++){let c=await this.loadTextureCount(e,l==n-1?o:t,a,r);i.push(...c)}return i}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new xo;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 Os;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 Gs;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 Bo;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 Bo;return await a.loadStd(e),a}async loadJSON(e,t){return await new It().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new It().load(e,ir,t,a),n=i.data;return fi.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new It().load(e,od,t,e)).data}async loadKMZ(e,t){return(await new It().load(e,gd,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,n,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,n);let d=new Fi;return d.name=o,d.create(16,16,f,!0),o&&this.addTexture(o,d),d}fillColor(e,t,a,r,i,n,o){for(let l=0;l<t;l++)for(let c=0;c<a;c++){let f=c*t+l;e[f*4+0]=r,e[f*4+1]=i,e[f*4+2]=n,e[f*4+3]=o}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new td().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new Os,this.defaultSky.createFromTexture(128,this.blackTexture),ke.getInstance().attached(this.defaultSky,this),ke.getInstance().attached(t,this),ke.getInstance().attached(this.normalTexture,this),ke.getInstance().attached(this.maskTexture,this),ke.getInstance().attached(this.whiteTexture,this),ke.getInstance().attached(this.blackTexture,this),ke.getInstance().attached(this.redTexture,this),ke.getInstance().attached(this.blueTexture,this),ke.getInstance().attached(this.greenTexture,this),ke.getInstance().attached(this.yellowTexture,this),ke.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new Fr(this.whiteTexture),this.defaultGUISprite=new ci(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new ta}}class md extends et{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=_.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=_.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;_.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Kb="1.0.42";class _{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 J(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",Kb),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await Re.init(R.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,ve.getGBufferFrame(ve.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),Y.init(),Ha.init(),xe.init(),Mt.init(),jt.init(),this.res=new pd,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new Sl,this.inputSystem.initCanvas(I.canvas)}static startRenderJob(e){let t=new bf(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(md).addPost(so),(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){We.delta=e-We.time,We.time=e,We.frame+=1,Sr.tick(We.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=I.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of Oe.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}let r=I.device.createCommandEncoder();for(const n of Oe.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o,r)}}I.device.queue.submit([r.finish()]);for(const n of Oe.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}for(const n of Oe.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];o&&f.enable&&d(o)}}this._renderLoop&&await this._renderLoop(),Re.updateAllContinueTransform(0,R.useCount,16),xe.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of Oe.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}this._lateRender&&await this._lateRender()}}let zs=`
|
|
7918
|
+
`}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await _.res.loadTexture(r,null,!0);let i=_.res.getTexture(r),n=new Fr(i);e.push(n)}ir.parseSprite(e,t),t.fontChar[" "]||ir.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ci,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),fi.addFnt(e.face,e.size,a.id,a)}static readLineProperty(e,t){e.trim().split(" ").forEach((a,r)=>{let i=a.split("=");if(i.length>1){let n=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,n)&&(o.indexOf('"')==-1?t[n]=parseFloat(i[1]):t[n]=o.replace('"',"").replace('"',""))}})}}function Ib(s,e){let t=new ci;return t.id=s,t.offsetSize.set(0,0,e.width,e.height),t.trimSize.set(e.width,e.height),t.width=e.width,t.height=e.height,t.xadvance=0,t.xoffset=0,t.yoffset=0,t.guiTexture=new Fr(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function sd(s,e,t){let a=new ci;a.guiTexture=s,a.id=e,a.uvRec.copyFrom(t.textureRect),a.trimSize.x=t.textureRect.z,a.trimSize.y=t.textureRect.w,a.offsetSize.x=t.textureRectOffset.x,a.offsetSize.y=t.textureRectOffset.y,a.offsetSize.z=t.size.x,a.offsetSize.w=t.size.y,a.width=t.size.x,a.height=t.size.y;let r=1/s.width,i=1/s.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let n=.1;return t.border.x<=n&&t.border.y<=n&&t.border.z<=n&&t.border.x<=n?a.isSliced=!1:(a.borderSize.copyFrom(t.border),a.uvBorder.copyFrom(t.border),a.uvBorder.x-=t.textureRectOffset.x,a.uvBorder.y-=t.textureRectOffset.y,a.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),a.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),a.uvBorder.x/=t.textureRect.z,a.uvBorder.z/=t.textureRect.z,a.uvBorder.y/=t.textureRect.w,a.uvBorder.w/=t.textureRect.w,a.isSliced=!0),a}class nd{_spriteMap=new Map;_spriteList=[];textureSize=new de;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=sd(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 od extends it{static format=je.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await _.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 nd(this._json.size),t=new Fr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);_.res.addAtlas(this.baseUrl,e),this.data=e}}var qt=Uint8Array,di=Uint16Array,Rb=Int32Array,ld=new qt([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]),cd=new qt([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]),Qb=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fd=function(s,e){for(var t=new di(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new Rb(t[30]),a=1;a<30;++a)for(var i=t[a];i<t[a+1];++i)r[i]=i-t[a]<<5|a;return{b:t,r}},dd=fd(ld,2),hd=dd.b,Tb=dd.r;hd[28]=258,Tb[258]=28;for(var Mb=fd(cd,0),Nb=Mb.b,wo=new di(32768),Ke=0;Ke<32768;++Ke){var gr=(Ke&43690)>>1|(Ke&21845)<<1;gr=(gr&52428)>>2|(gr&13107)<<2,gr=(gr&61680)>>4|(gr&3855)<<4,wo[Ke]=((gr&65280)>>8|(gr&255)<<8)>>1}for(var Pi=(function(s,e,t){for(var a=s.length,r=0,i=new di(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new di(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new di(1<<e);var l=15-e;for(r=0;r<a;++r)if(s[r])for(var c=r<<4|s[r],f=e-s[r],d=n[s[r]-1]++<<f,h=d|(1<<f)-1;d<=h;++d)o[wo[d]>>l]=c}else for(o=new di(a),r=0;r<a;++r)s[r]&&(o[r]=wo[n[s[r]-1]++]>>15-s[r]);return o}),Vi=new qt(288),Ke=0;Ke<144;++Ke)Vi[Ke]=8;for(var Ke=144;Ke<256;++Ke)Vi[Ke]=9;for(var Ke=256;Ke<280;++Ke)Vi[Ke]=7;for(var Ke=280;Ke<288;++Ke)Vi[Ke]=8;for(var ud=new qt(32),Ke=0;Ke<32;++Ke)ud[Ke]=5;var Pb=Pi(Vi,9,1),Vb=Pi(ud,5,1),Io=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},va=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},Ro=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Ob=function(s){return(s+7)/8|0},Qo=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new qt(s.subarray(e,t))},Lb=["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(s,e,t){var a=new Error(e||Lb[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,ca),!t)throw a;return a},Gb=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new qt(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new qt(r*3));var c=function(ie){var le=t.length;if(ie>le){var ge=new qt(Math.max(le*2,ie));ge.set(t),t=ge}},f=e.f||0,d=e.p||0,h=e.b||0,u=e.l,m=e.d,g=e.m,p=e.n,D=r*8;do{if(!u){f=va(s,d,1);var A=va(s,d+1,3);if(d+=3,A)if(A==1)u=Pb,m=Vb,g=9,p=5;else if(A==2){var y=va(s,d,31)+257,S=va(s,d+10,15)+4,F=y+va(s,d+5,31)+1;d+=14;for(var C=new qt(F),w=new qt(19),E=0;E<S;++E)w[Qb[E]]=va(s,d+E*3,7);d+=S*3;for(var Q=Io(w),T=(1<<Q)-1,j=Pi(w,Q,1),E=0;E<F;){var ue=j[va(s,d,T)];d+=ue&15;var B=ue>>4;if(B<16)C[E++]=B;else{var ee=0,N=0;for(B==16?(N=3+va(s,d,3),d+=2,ee=C[E-1]):B==17?(N=3+va(s,d,7),d+=3):B==18&&(N=11+va(s,d,127),d+=7);N--;)C[E++]=ee}}var M=C.subarray(0,y),O=C.subarray(y);g=Io(M),p=Io(O),u=Pi(M,g,1),m=Pi(O,p,1)}else ca(1);else{var B=Ob(d)+4,v=s[B-4]|s[B-3]<<8,U=B+v;if(U>r){l&&ca(0);break}o&&c(h+v),t.set(s.subarray(B,U),h),e.b=h+=v,e.p=d=U*8,e.f=f;continue}if(d>D){l&&ca(0);break}}o&&c(h+131072);for(var W=(1<<g)-1,ae=(1<<p)-1,z=d;;z=d){var ee=u[Ro(s,d)&W],K=ee>>4;if(d+=ee&15,d>D){l&&ca(0);break}if(ee||ca(2),K<256)t[h++]=K;else if(K==256){z=d,u=null;break}else{var $=K-254;if(K>264){var E=K-257,re=ld[E];$=va(s,d,(1<<re)-1)+hd[E],d+=re}var ce=m[Ro(s,d)&ae],Ae=ce>>4;ce||ca(3),d+=ce&15;var O=Nb[Ae];if(Ae>3){var re=cd[Ae];O+=Ro(s,d)&(1<<re)-1,d+=re}if(d>D){l&&ca(0);break}o&&c(h+131072);var Qe=h+$;if(h<O){var Ve=i-O,H=Math.min(O,Qe);for(Ve+h<0&&ca(3);h<H;++h)t[h]=a[Ve+h]}for(;h<Qe;++h)t[h]=t[h-O]}}e.l=u,e.p=z,e.b=h,e.f=f,u&&(f=1,e.m=g,e.d=m,e.n=p)}while(!f);return h!=t.length&&n?Qo(t,0,h):t.subarray(0,h)},zb=new qt(0),Oa=function(s,e){return s[e]|s[e+1]<<8},xa=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},To=function(s,e){return xa(s,e)+xa(s,e+4)*4294967296};function Wb(s,e){return Gb(s,{i:2},e&&e.out,e&&e.dictionary)}var Mo=typeof TextDecoder<"u"&&new TextDecoder,Jb=0;try{Mo.decode(zb,{stream:!0}),Jb=1}catch{}var jb=function(s){for(var e="",t=0;;){var a=s[t++],r=(a>127)+(a>223)+(a>239);if(t+r>s.length)return{s:e,r:Qo(s,t-1)};r?r==3?(a=((a&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|s[t++]&63):e+=String.fromCharCode((a&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(a)}};function bd(s,e){if(e){for(var t="",a=0;a<s.length;a+=16384)t+=String.fromCharCode.apply(null,s.subarray(a,a+16384));return t}else{if(Mo)return Mo.decode(s);var r=jb(s),i=r.s,t=r.r;return t.length&&ca(8),i}}var Zb=function(s,e){return e+30+Oa(s,e+26)+Oa(s,e+28)},Yb=function(s,e,t){var a=Oa(s,e+28),r=bd(s.subarray(e+46,e+46+a),!(Oa(s,e+8)&2048)),i=e+46+a,n=xa(s,e+20),o=t&&n==4294967295?Xb(s,i):[n,xa(s,e+24),xa(s,e+42)],l=o[0],c=o[1],f=o[2];return[Oa(s,e+10),l,c,r,i+Oa(s,e+30)+Oa(s,e+32),f]},Xb=function(s,e){for(;Oa(s,e)!=1;e+=4+Oa(s,e+2));return[To(s,e+12),To(s,e+4),To(s,e+20)]};function Hb(s,e){for(var t={},a=s.length-22;xa(s,a)!=101010256;--a)(!a||s.length-a>65558)&&ca(13);var r=Oa(s,a+8);if(!r)return{};var i=xa(s,a+16),n=i==4294967295||r==65535;if(n){var o=xa(s,a-12);n=xa(s,o)==101075792,n&&(r=xa(s,o+32),i=xa(s,o+48))}for(var l=0;l<r;++l){var c=Yb(s,i,n),f=c[0],d=c[1],h=c[2],u=c[3],m=c[4],g=c[5],p=Zb(s,g);i=m,f?f==8?t[u]=Wb(s.subarray(p,p+d),{out:new qt(h)}):ca(14,"unknown compression type "+f):t[u]=Qo(s,p,p+d)}return t}class Bt extends vt{constructor(){super(),this.shader=new qi,this.baseMap=_.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 Nr extends Le{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,n,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=n,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,n=this.radius;var o=(r+1)*(i+1);let l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),d=new Uint16Array(i*r*2*3),h=0,u=0,m=0;for(t=0;t<=r;++t){var g=Math.PI*t/r,p=n*Math.cos(g),D=n*Math.sin(g);for(e=0;e<=i;++e){var A=2*Math.PI*e/i,B=D*Math.cos(A),v=D*Math.sin(A),U=1/Math.sqrt(B*B+p*p+v*v);if(l[h++]=B,l[h++]=p,l[h++]=v,c[u++]=B*U,c[u++]=p*U,c[u++]=v*U,f[m++]=e/i,f[m++]=t/r,e>0&&t>0){var y=(i+1)*t+e,S=(i+1)*t+e-1,F=(i+1)*(t-1)+e-1,C=(i+1)*(t-1)+e;t==r?(d[a++]=y,d[a++]=F,d[a++]=C):t==1?(d[a++]=y,d[a++]=S,d[a++]=F):(d[a++]=y,d[a++]=S,d[a++]=F,d[a++]=y,d[a++]=F,d[a++]=C)}}}this.setIndices(d),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:d.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Ce(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class _s extends ne{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new b(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),_s.register3DRepresentation)this.marker=_s.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new ne;const e=this.marker.addComponent(he);e.geometry=new Nr(.1,32,16),e.material=new Bt,e.material.baseColor=this.positionValid?new J(0,1,0,1):new J(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class Bs extends ne{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new _s(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),Bs.register3DRepresentation?(this.line=Bs.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new J(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Le,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 n=new ne,o=n.addComponent(he),l=new Bt;return l.topology="line-list",l.baseColor=t,l.blendMode=De.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class gd extends it{static format=je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Hb(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(bd(n),"application/xml"),c={};this.parseNode(l,c);const f=i.replace("wpmz/","").split(".")[0];Object.assign(t,{[f]:c["#document"].kml.Document})}const r=new Bs(t.waylines);this.data=r}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const a=["Placemark","actionGroup","action"],r=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[r]=void 0;else{let i=null,n=!1;for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];if(l.nodeType==Node.TEXT_NODE){const c=l.nodeValue?.trim();c&&c.length>0&&(i=c)}else l.nodeType==Node.ELEMENT_NODE&&(n=!0)}if(i&&!n)t[r]=i;else if(n){a.includes(r)?t[r]?.length?t[r].push({}):t[r]=[{}]:t[r]={};for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[r])?t[r].at(-1):t[r])}}else t[r]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class pd{_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 It().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 It;r==".gltf"?a=await i.load(e,xt,t):a=await i.load(e,_o,t);let n=a.data;return this._prefabPool.set(e,n),this._gltfPool.set(e,a.gltf),n}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new It;r==".obj"&&(a=await i.load(e,Ds,t));let n=a.data;return this._prefabPool.set(e,n),n}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new It().load(e,So,t,a)).data;return this._prefabPool.set(e,n),n}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new It().load(e,Eo,t,a)).data;return this._prefabPool.set(e,n),n}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new $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?ke.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,n)=>{let o=0,l=[];t==0&&i(l);for(let c=0;c<t;c++){const f=e.shift();this.loadTexture(f,a,r).then(d=>{l.push(d),o++,o==t&&i(l)})}})}async loadBitmapTextures(e,t=5,a,r){let i=[],n=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<n;l++){let c=await this.loadTextureCount(e,l==n-1?o:t,a,r);i.push(...c)}return i}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new xo;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 Os;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 Gs;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 Bo;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 Bo;return await a.loadStd(e),a}async loadJSON(e,t){return await new It().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new It().load(e,ir,t,a),n=i.data;return fi.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new It().load(e,od,t,e)).data}async loadKMZ(e,t){return(await new It().load(e,gd,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,n,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,n);let d=new Fi;return d.name=o,d.create(16,16,f,!0),o&&this.addTexture(o,d),d}fillColor(e,t,a,r,i,n,o){for(let l=0;l<t;l++)for(let c=0;c<a;c++){let f=c*t+l;e[f*4+0]=r,e[f*4+1]=i,e[f*4+2]=n,e[f*4+3]=o}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new td().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new Os,this.defaultSky.createFromTexture(128,this.blackTexture),ke.getInstance().attached(this.defaultSky,this),ke.getInstance().attached(t,this),ke.getInstance().attached(this.normalTexture,this),ke.getInstance().attached(this.maskTexture,this),ke.getInstance().attached(this.whiteTexture,this),ke.getInstance().attached(this.blackTexture,this),ke.getInstance().attached(this.redTexture,this),ke.getInstance().attached(this.blueTexture,this),ke.getInstance().attached(this.greenTexture,this),ke.getInstance().attached(this.yellowTexture,this),ke.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new Fr(this.whiteTexture),this.defaultGUISprite=new ci(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new ta}}class md extends et{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=_.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=_.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;_.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Kb="1.0.43";class _{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 J(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",Kb),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await Re.init(R.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,ve.getGBufferFrame(ve.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),Y.init(),Ha.init(),xe.init(),Mt.init(),jt.init(),this.res=new pd,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new Sl,this.inputSystem.initCanvas(I.canvas)}static startRenderJob(e){let t=new bf(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(md).addPost(so),(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){We.delta=e-We.time,We.time=e,We.frame+=1,Sr.tick(We.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=I.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of Oe.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}let r=I.device.createCommandEncoder();for(const n of Oe.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o,r)}}I.device.queue.submit([r.finish()]);for(const n of Oe.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}for(const n of Oe.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];o&&f.enable&&d(o)}}this._renderLoop&&await this._renderLoop(),Re.updateAllContinueTransform(0,R.useCount,16),xe.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of Oe.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}this._lateRender&&await this._lateRender()}}let zs=`
|
|
7920
7919
|
struct BloomCfg{
|
|
7921
7920
|
downSampleStep: f32,
|
|
7922
7921
|
downSampleBlurSize: f32,
|