diff --git a/docs/assets/index-CcD6bekL.js b/docs/assets/index-BeB41sTJ.js similarity index 98% rename from docs/assets/index-CcD6bekL.js rename to docs/assets/index-BeB41sTJ.js index faba877..28b28e7 100644 --- a/docs/assets/index-CcD6bekL.js +++ b/docs/assets/index-BeB41sTJ.js @@ -638,7 +638,7 @@ EXPOSURE=1.0 #endif return color; } -`)),entryPoint:Rc,targets:t},layout:B.device.createPipelineLayout({label:`Debug Canvas ${e} Render PSO Layout`,bindGroupLayouts:[this.samplerTextureBindGroupLayout]})}),this.renderPassDescriptor={label:`Debug Canvas ${e} Render Pass Descriptor`,colorAttachments:[{loadOp:"load",storeOp:"store",view:null}]}}get isDepthTexture(){return this.type===Y.Depth||this.type===Y.ShadowDepthCascade0||this.type===Y.ShadowDepthCascade1}appendTo(e){e.appendChild(this.$rootEl)}setTexture(e,t=e.width,r=e.height){this.debugTexture=e,this.$canvas.width=t,this.$canvas.height=r;let n=0;this.type===Y.ShadowDepthCascade0?n=0:this.type===Y.ShadowDepthCascade1&&(n=1);const i=[{binding:0,resource:Xe.createSampler({magFilter:"linear",minFilter:"linear"})},{binding:1,resource:e.createView({aspect:this.isDepthTexture?"depth-only":"all",baseArrayLayer:n,dimension:"2d"})}];this.samplerTextureBindGroup=B.device.createBindGroup({layout:this.samplerTextureBindGroupLayout,entries:i})}render(e){if(!this.debugTexture)return;this.renderPassDescriptor.colorAttachments[0].view=this.ctx.getCurrentTexture().createView();const t=e.beginRenderPass(this.renderPassDescriptor);B.ENABLE_DEBUG_GROUPS&&t.pushDebugGroup(`Display Debug Texture ${this.type}`),t.setPipeline(this.renderPSO),t.setBindGroup(0,this.samplerTextureBindGroup),t.draw(3),B.ENABLE_DEBUG_GROUPS&&t.popDebugGroup(),t.end()}}var Yi=(s=>(s[s.GBuffer=0]="GBuffer",s[s.Shadow=1]="Shadow",s))(Yi||{});const Dp=new Map([[0,"G-Buffer Debug"],[1,"Shadows Debug"]]);class Qs{constructor(e){this.canvases=new Map,this.$root=Qs.createRootElement(),this.$main=document.createElement("div"),this.$main.classList.add("section");const t=document.createElement("h2");t.textContent=Dp.get(e),t.classList.add("section-headline"),this.$root.appendChild(t),this.$root.appendChild(this.$main)}static createRootElement(){const e=document.createElement("div");return e.classList.add("texture-debug-wrapper"),e}appendTo(e){e.appendChild(this.$root)}setTextureFor(e,t,r=.2*t.width,n=.2*t.height){return this.canvases.get(e).setTexture(t,r,n),this}render(e){for(const t of this.canvases.values())t.render(e)}}class Up extends Qs{constructor(){super(Yi.GBuffer);const e=new ct(Y.Albedo);e.appendTo(this.$main),this.canvases.set(Y.Albedo,e);const t=new ct(Y.Normal);t.appendTo(this.$main),this.canvases.set(Y.Normal,t);const r=new ct(Y.Metallic);r.appendTo(this.$main),this.canvases.set(Y.Metallic,r);const n=new ct(Y.Roughness);n.appendTo(this.$main),this.canvases.set(Y.Roughness,n);const i=new ct(Y.AO);i.appendTo(this.$main),this.canvases.set(Y.AO,i);const o=new ct(Y.Reflectance);o.appendTo(this.$main),this.canvases.set(Y.Reflectance,o);const u=new ct(Y.Depth);u.appendTo(this.$main),this.canvases.set(Y.Depth,u);const l=new ct(Y.Velocity);l.appendTo(this.$main),this.canvases.set(Y.Velocity,l)}}class kp extends Qs{constructor(){super(Yi.Shadow);const e=new ct(Y.ShadowDepthCascade0);e.appendTo(this.$main),this.canvases.set(Y.ShadowDepthCascade0,e);const t=new ct(Y.ShadowDepthCascade1);t.appendTo(this.$main),this.canvases.set(Y.ShadowDepthCascade1,t)}}const gn=class gn{constructor(){this.open=!1,this.$root=document.createElement("div"),this.$root.id=gn.ROOT_EL_ID,document.body.appendChild(this.$root),this.gbufferDebugSection=new Up,this.gbufferDebugSection.appendTo(this.$root),this.shadowDebugSection=new kp,this.shadowDebugSection.appendTo(this.$root)}reveal(){this.open=!0,this.$root.classList.add("open")}hide(){this.open=!1,this.$root.classList.remove("open")}scrollToShadowSection(){this.shadowDebugSection.$root.scrollIntoView({block:"start",inline:"nearest"})}scrollIntoGbufferSection(){this.gbufferDebugSection.$root.scrollIntoView({block:"start",inline:"nearest"})}setTextureGBufferSection(e,t,r=.2*t.width,n=.2*t.height){return this.open?(this.gbufferDebugSection.setTextureFor(e,t,r,n),this):this}setTextureShadowSection(e,t,r=.2*t.width,n=.2*t.height){return this.open?(this.shadowDebugSection.setTextureFor(e,t,r,n),this):this}render(e){this.open&&(this.gbufferDebugSection.render(e),this.shadowDebugSection.render(e))}};gn.ROOT_EL_ID="webgpu-debug-root";let qi=gn;const Np=new Map([[se.CPUTotal,"cpu-total"],[se.GPUTotal,"gpu-total"],[se.FPS,"fps"],[se.VRAM,"vram"],[se.VisibleMeshes,"culled-meshes"],[se.LightsCount,"lights-count"],[se.DeferredRenderPass,"deferred"],[se.DirectionalAmbientLightingRenderPass,"directional-ambient-light"],[se.PointLightsStencilMask,"point-lights-stencil-mask"],[se.PointLightsLighting,"point-lights-lighting"],[se.SSAORenderPass,"ssao"],[se.TransparentRenderPass,"transparent"],[se.ShadowRenderPass,"shadow"],[se.TAAResolveRenderPass,"taa-resolve"],[se.ReflectionRenderPass,"reflection"],[se.BlitRenderPass,"blit"]]),Vp=new Map([[se.CPUTotal,"CPU"],[se.GPUTotal,"GPU"],[se.FPS,"FPS"],[se.VRAM,"VRAM Usage"],[se.VisibleMeshes,"Visible Meshes"],[se.LightsCount,"Lights Count"],[se.DeferredRenderPass,"G-Buffer Render Pass"],[se.DirectionalAmbientLightingRenderPass,"Directional + Ambient Render Pass"],[se.PointLightsStencilMask,"Point Lights Stencil Mask Pass"],[se.PointLightsLighting,"Point Lights Render Pass"],[se.SSAORenderPass,"SSAO Render Pass"],[se.TransparentRenderPass,"Transparent Render Pass"],[se.ShadowRenderPass,"Directional Shadow Render Pass"],[se.TAAResolveRenderPass,"TAA Resolve Render Pass"],[se.ReflectionRenderPass,"Reflection Render Pass"],[se.BlitRenderPass,"Blit Render Pass"]]),Bo=class Bo{constructor(){this.$renderPassTimingDisplayEls=new Map,this.$root=document.createElement("div"),this.$root.id="timings-debug-container",this.$root.classList.add("fadable"),document.body.appendChild(this.$root);for(const e of Rd){const t=Np.get(e),r=document.createElement("div");r.id=`${t}-debug-timing`,r.classList.add("timing-container"),this.$root.appendChild(r);const n=document.createElement("div");n.classList.add("timing-label"),n.innerText=`${Vp.get(e)}:`,r.appendChild(n);const i=document.createElement("div");i.classList.add("timing-value"),r.appendChild(i);const o={root:r,label:n,value:i};this.$renderPassTimingDisplayEls.set(e,o)}}toggleVisibility(){this.$root.classList.toggle("hidden")}setDisplayValue(e,t){return this.$renderPassTimingDisplayEls.get(e).value.innerText=t,this}};Bo.NOT_AVAILABLE_STR="N/A";let Qi=Bo;const Hp=vt(kt(W.Light).structs.Light);class br extends ar{constructor(e){super(),this.lightType=e,this._color=D.create(1,1,0),this._intensity=1;const t=kt(W.Light);this.lightsStorageView=vt(t.structs.Light),this.lightsStorageView.set({color:this._color,position:this.position,lightType:Pd.get(e),intensity:1})}static get STRUCT_BYTE_SIZE(){return Hp.arrayBuffer.byteLength}get intensity(){return this._intensity}set intensity(e){this._intensity=e,this.lightsStorageView.set({intensity:e})}get color(){return this.getColor()}set color(e){this.setColor(e[0],e[1],e[2])}setColor(e,t,r){this._color[0]=e,this._color[1]=t,this._color[2]=r,this.lightsStorageView.set({color:this._color})}setColorAsVec3(e){D.copy(e,this._color),this.lightsStorageView.set({color:this._color})}getColor(){return this._color}setPosition(e,t,r){return super.setPosition(e,t,r),this.lightsStorageView.set({position:this.position}),this}setPositionAsVec3(e){return super.setPositionAsVec3(e),this.lightsStorageView.set({position:this.position}),this}setPositionX(e){return super.setPositionX(e),this.lightsStorageView.set({position:this.position}),this}setPositionY(e){return super.setPositionY(e),this.lightsStorageView.set({position:this.position}),this}setPositionZ(e){return super.setPositionZ(e),this.lightsStorageView.set({position:this.position}),this}}class Zi extends br{constructor(){super(Nt.Directional)}}class Yt extends br{get radius(){return this._radius}set radius(e){this._radius=e,this.lightsStorageView.set({radius:e})}constructor(){super(Nt.Point),this.intensity=1,this.radius=1}}class gt extends Yt{static get bindGroupLayout(){if(this._bindGroupLayout)return this._bindGroupLayout;const e=[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{}}];return this._bindGroupLayout=B.device.createBindGroupLayout({label:"Camera Face Culled Point Light Bind Group Layout",entries:e}),this._bindGroupLayout}updateGPUBuffer(){B.device.queue.writeBuffer(this.gpuBuffer,0,this.lightsStorageView.arrayBuffer)}constructor(){super(),this.gpuBuffer=B.device.createBuffer({label:"Camera Face Culled Point Light GPU Buffer",size:br.STRUCT_BYTE_SIZE,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),$.addBufferBytes(this.gpuBuffer),this.lightsStorageView.set({type:1,intensity:1,radius:1,color:D.create(1,1,1),position:D.create(0,1,0)}),this.updateGPUBuffer();const e=[{binding:0,resource:{buffer:this.gpuBuffer}}];this.bindGroup=B.device.createBindGroup({label:"Camera Face Culled Point Light Bind Group",entries:e,layout:gt.bindGroupLayout})}}class Jp{constructor(){this.pointLights=[],this.cameraFaceCulledPointLights=[],this.directionalLights=[],this.allLights=[]}get lightsCount(){return this.allLights.length}get pointLightsCount(){return this.pointLights.length}get directionalLightsCount(){return this.directionalLights.length}updateGPUBuffer(){if(!this.allLights.length)return void console.warn("No lights, skip creating GPUBuffer");this.gpuBuffer&&($.removeBufferBytes(this.gpuBuffer),this.gpuBuffer.destroy()),this.gpuBuffer=B.device.createBuffer({label:"Lights GPU Buffer",size:br.STRUCT_BYTE_SIZE*this.allLights.length,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE}),$.addBufferBytes(this.gpuBuffer);let e=0;for(let t=0;tr.id!==e.id;return e instanceof gt?this.cameraFaceCulledPointLights=this.cameraFaceCulledPointLights.filter(t):e instanceof Yt?this.pointLights=this.pointLights.filter(t):e instanceof Zi&&(this.directionalLights=this.directionalLights.filter(t)),this.allLights=this.allLights.filter(t),this}render(e){throw new Error("Needs implementation")}}const qt=vt(kt(W.Particle).structs.Particle),Ze=class Ze{constructor({radius:e,position:t,velocity:r,lifeSpeed:n,life:i}={radius:1,position:D.create(0,3,0),velocity:D.create(0,1,0),lifeSpeed:1,life:0}){this.radius=e,this.position=t,this.origPosition=t,this.velocity=r,this.lifeSpeed=n,this.life=i}};Ze.STRUCT_BYTE_SIZE=qt.arrayBuffer.byteLength,Ze.STRUCT_FLOATS_COUNT=Ze.STRUCT_BYTE_SIZE/Float32Array.BYTES_PER_ELEMENT,Ze.RADIUS_OFFSET=qt.views.radius.byteOffset/Float32Array.BYTES_PER_ELEMENT,Ze.POSITION_OFFSET=qt.views.position.byteOffset/Float32Array.BYTES_PER_ELEMENT,Ze.ORIG_POSITION_OFFSET=qt.views.origPosition.byteOffset/Float32Array.BYTES_PER_ELEMENT,Ze.VELOCITY_OFFSET=qt.views.velocity.byteOffset/Float32Array.BYTES_PER_ELEMENT,Ze.LIFE_OFFSET=qt.views.life.byteOffset/Float32Array.BYTES_PER_ELEMENT,Ze.LIFE_SPEED_OFFSET=qt.views.lifeSpeed.byteOffset/Float32Array.BYTES_PER_ELEMENT;let Qe=Ze;const Gc="vertexMain",Lc="fragMain",zp=` +`)),entryPoint:Rc,targets:t},layout:B.device.createPipelineLayout({label:`Debug Canvas ${e} Render PSO Layout`,bindGroupLayouts:[this.samplerTextureBindGroupLayout]})}),this.renderPassDescriptor={label:`Debug Canvas ${e} Render Pass Descriptor`,colorAttachments:[{loadOp:"load",storeOp:"store",view:null}]}}get isDepthTexture(){return this.type===Y.Depth||this.type===Y.ShadowDepthCascade0||this.type===Y.ShadowDepthCascade1}appendTo(e){e.appendChild(this.$rootEl)}setTexture(e,t=e.width,r=e.height){this.debugTexture=e,this.$canvas.width=t,this.$canvas.height=r;let n=0;this.type===Y.ShadowDepthCascade0?n=0:this.type===Y.ShadowDepthCascade1&&(n=1);const i=[{binding:0,resource:Xe.createSampler({magFilter:"linear",minFilter:"linear"})},{binding:1,resource:e.createView({aspect:this.isDepthTexture?"depth-only":"all",baseArrayLayer:n,dimension:"2d"})}];this.samplerTextureBindGroup=B.device.createBindGroup({layout:this.samplerTextureBindGroupLayout,entries:i})}render(e){if(!this.debugTexture)return;this.renderPassDescriptor.colorAttachments[0].view=this.ctx.getCurrentTexture().createView();const t=e.beginRenderPass(this.renderPassDescriptor);B.ENABLE_DEBUG_GROUPS&&t.pushDebugGroup(`Display Debug Texture ${this.type}`),t.setPipeline(this.renderPSO),t.setBindGroup(0,this.samplerTextureBindGroup),t.draw(3),B.ENABLE_DEBUG_GROUPS&&t.popDebugGroup(),t.end()}}var Yi=(s=>(s[s.GBuffer=0]="GBuffer",s[s.Shadow=1]="Shadow",s))(Yi||{});const Dp=new Map([[0,"G-Buffer Debug"],[1,"Shadows Debug"]]);class Qs{constructor(e){this.canvases=new Map,this.$root=Qs.createRootElement(),this.$main=document.createElement("div"),this.$main.classList.add("section");const t=document.createElement("h2");t.textContent=Dp.get(e),t.classList.add("section-headline"),this.$root.appendChild(t),this.$root.appendChild(this.$main)}static createRootElement(){const e=document.createElement("div");return e.classList.add("texture-debug-wrapper"),e}appendTo(e){e.appendChild(this.$root)}setTextureFor(e,t,r=.2*t.width,n=.2*t.height){return this.canvases.get(e).setTexture(t,r,n),this}render(e){for(const t of this.canvases.values())t.render(e)}}class Up extends Qs{constructor(){super(Yi.GBuffer);const e=new ct(Y.Albedo);e.appendTo(this.$main),this.canvases.set(Y.Albedo,e);const t=new ct(Y.Normal);t.appendTo(this.$main),this.canvases.set(Y.Normal,t);const r=new ct(Y.Metallic);r.appendTo(this.$main),this.canvases.set(Y.Metallic,r);const n=new ct(Y.Roughness);n.appendTo(this.$main),this.canvases.set(Y.Roughness,n);const i=new ct(Y.AO);i.appendTo(this.$main),this.canvases.set(Y.AO,i);const o=new ct(Y.Reflectance);o.appendTo(this.$main),this.canvases.set(Y.Reflectance,o);const u=new ct(Y.Depth);u.appendTo(this.$main),this.canvases.set(Y.Depth,u);const l=new ct(Y.Velocity);l.appendTo(this.$main),this.canvases.set(Y.Velocity,l)}}class kp extends Qs{constructor(){super(Yi.Shadow);const e=new ct(Y.ShadowDepthCascade0);e.appendTo(this.$main),this.canvases.set(Y.ShadowDepthCascade0,e);const t=new ct(Y.ShadowDepthCascade1);t.appendTo(this.$main),this.canvases.set(Y.ShadowDepthCascade1,t)}}const gn=class gn{constructor(){this.open=!1,this.$root=document.createElement("div"),this.$root.id=gn.ROOT_EL_ID,document.body.appendChild(this.$root),this.gbufferDebugSection=new Up,this.gbufferDebugSection.appendTo(this.$root),this.shadowDebugSection=new kp,this.shadowDebugSection.appendTo(this.$root)}reveal(){this.open=!0,this.$root.classList.add("open")}hide(){this.open=!1,this.$root.classList.remove("open")}scrollToShadowSection(){this.shadowDebugSection.$root.scrollIntoView({block:"start",inline:"nearest"})}scrollIntoGbufferSection(){this.gbufferDebugSection.$root.scrollIntoView({block:"start",inline:"nearest"})}setTextureGBufferSection(e,t,r=.2*t.width,n=.2*t.height){return this.open?(this.gbufferDebugSection.setTextureFor(e,t,r,n),this):this}setTextureShadowSection(e,t,r=.2*t.width,n=.2*t.height){return this.open?(this.shadowDebugSection.setTextureFor(e,t,r,n),this):this}render(e){this.open&&(this.gbufferDebugSection.render(e),this.shadowDebugSection.render(e))}};gn.ROOT_EL_ID="webgpu-debug-root";let qi=gn;const Np=new Map([[se.CPUTotal,"cpu-total"],[se.GPUTotal,"gpu-total"],[se.FPS,"fps"],[se.VRAM,"vram"],[se.VisibleMeshes,"culled-meshes"],[se.LightsCount,"lights-count"],[se.DeferredRenderPass,"deferred"],[se.DirectionalAmbientLightingRenderPass,"directional-ambient-light"],[se.PointLightsStencilMask,"point-lights-stencil-mask"],[se.PointLightsLighting,"point-lights-lighting"],[se.SSAORenderPass,"ssao"],[se.TransparentRenderPass,"transparent"],[se.ShadowRenderPass,"shadow"],[se.TAAResolveRenderPass,"taa-resolve"],[se.ReflectionRenderPass,"reflection"],[se.BlitRenderPass,"blit"]]),Vp=new Map([[se.CPUTotal,"CPU"],[se.GPUTotal,"GPU"],[se.FPS,"FPS"],[se.VRAM,"VRAM Usage"],[se.VisibleMeshes,"Visible Meshes"],[se.LightsCount,"Lights Count"],[se.DeferredRenderPass,"G-Buffer Render Pass"],[se.DirectionalAmbientLightingRenderPass,"Directional + Ambient Render Pass"],[se.PointLightsStencilMask,"Point Lights Stencil Mask Pass"],[se.PointLightsLighting,"Point Lights Render Pass"],[se.SSAORenderPass,"SSAO Render Pass"],[se.TransparentRenderPass,"Transparent Render Pass"],[se.ShadowRenderPass,"Directional Shadow Render Pass"],[se.TAAResolveRenderPass,"TAA Resolve Render Pass"],[se.ReflectionRenderPass,"Reflection Render Pass"],[se.BlitRenderPass,"Blit Render Pass"]]),Bo=class Bo{constructor(){this.$renderPassTimingDisplayEls=new Map,this.$root=document.createElement("div"),this.$root.id="timings-debug-container",this.$root.classList.add("fadable","hidden"),document.body.appendChild(this.$root);for(const e of Rd){const t=Np.get(e),r=document.createElement("div");r.id=`${t}-debug-timing`,r.classList.add("timing-container"),this.$root.appendChild(r);const n=document.createElement("div");n.classList.add("timing-label"),n.innerText=`${Vp.get(e)}:`,r.appendChild(n);const i=document.createElement("div");i.classList.add("timing-value"),r.appendChild(i);const o={root:r,label:n,value:i};this.$renderPassTimingDisplayEls.set(e,o)}}toggleVisibility(){this.$root.classList.toggle("hidden")}setDisplayValue(e,t){return this.$renderPassTimingDisplayEls.get(e).value.innerText=t,this}};Bo.NOT_AVAILABLE_STR="N/A";let Qi=Bo;const Hp=vt(kt(W.Light).structs.Light);class br extends ar{constructor(e){super(),this.lightType=e,this._color=D.create(1,1,0),this._intensity=1;const t=kt(W.Light);this.lightsStorageView=vt(t.structs.Light),this.lightsStorageView.set({color:this._color,position:this.position,lightType:Pd.get(e),intensity:1})}static get STRUCT_BYTE_SIZE(){return Hp.arrayBuffer.byteLength}get intensity(){return this._intensity}set intensity(e){this._intensity=e,this.lightsStorageView.set({intensity:e})}get color(){return this.getColor()}set color(e){this.setColor(e[0],e[1],e[2])}setColor(e,t,r){this._color[0]=e,this._color[1]=t,this._color[2]=r,this.lightsStorageView.set({color:this._color})}setColorAsVec3(e){D.copy(e,this._color),this.lightsStorageView.set({color:this._color})}getColor(){return this._color}setPosition(e,t,r){return super.setPosition(e,t,r),this.lightsStorageView.set({position:this.position}),this}setPositionAsVec3(e){return super.setPositionAsVec3(e),this.lightsStorageView.set({position:this.position}),this}setPositionX(e){return super.setPositionX(e),this.lightsStorageView.set({position:this.position}),this}setPositionY(e){return super.setPositionY(e),this.lightsStorageView.set({position:this.position}),this}setPositionZ(e){return super.setPositionZ(e),this.lightsStorageView.set({position:this.position}),this}}class Zi extends br{constructor(){super(Nt.Directional)}}class Yt extends br{get radius(){return this._radius}set radius(e){this._radius=e,this.lightsStorageView.set({radius:e})}constructor(){super(Nt.Point),this.intensity=1,this.radius=1}}class gt extends Yt{static get bindGroupLayout(){if(this._bindGroupLayout)return this._bindGroupLayout;const e=[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{}}];return this._bindGroupLayout=B.device.createBindGroupLayout({label:"Camera Face Culled Point Light Bind Group Layout",entries:e}),this._bindGroupLayout}updateGPUBuffer(){B.device.queue.writeBuffer(this.gpuBuffer,0,this.lightsStorageView.arrayBuffer)}constructor(){super(),this.gpuBuffer=B.device.createBuffer({label:"Camera Face Culled Point Light GPU Buffer",size:br.STRUCT_BYTE_SIZE,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),$.addBufferBytes(this.gpuBuffer),this.lightsStorageView.set({type:1,intensity:1,radius:1,color:D.create(1,1,1),position:D.create(0,1,0)}),this.updateGPUBuffer();const e=[{binding:0,resource:{buffer:this.gpuBuffer}}];this.bindGroup=B.device.createBindGroup({label:"Camera Face Culled Point Light Bind Group",entries:e,layout:gt.bindGroupLayout})}}class Jp{constructor(){this.pointLights=[],this.cameraFaceCulledPointLights=[],this.directionalLights=[],this.allLights=[]}get lightsCount(){return this.allLights.length}get pointLightsCount(){return this.pointLights.length}get directionalLightsCount(){return this.directionalLights.length}updateGPUBuffer(){if(!this.allLights.length)return void console.warn("No lights, skip creating GPUBuffer");this.gpuBuffer&&($.removeBufferBytes(this.gpuBuffer),this.gpuBuffer.destroy()),this.gpuBuffer=B.device.createBuffer({label:"Lights GPU Buffer",size:br.STRUCT_BYTE_SIZE*this.allLights.length,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE}),$.addBufferBytes(this.gpuBuffer);let e=0;for(let t=0;tr.id!==e.id;return e instanceof gt?this.cameraFaceCulledPointLights=this.cameraFaceCulledPointLights.filter(t):e instanceof Yt?this.pointLights=this.pointLights.filter(t):e instanceof Zi&&(this.directionalLights=this.directionalLights.filter(t)),this.allLights=this.allLights.filter(t),this}render(e){throw new Error("Needs implementation")}}const qt=vt(kt(W.Particle).structs.Particle),Ze=class Ze{constructor({radius:e,position:t,velocity:r,lifeSpeed:n,life:i}={radius:1,position:D.create(0,3,0),velocity:D.create(0,1,0),lifeSpeed:1,life:0}){this.radius=e,this.position=t,this.origPosition=t,this.velocity=r,this.lifeSpeed=n,this.life=i}};Ze.STRUCT_BYTE_SIZE=qt.arrayBuffer.byteLength,Ze.STRUCT_FLOATS_COUNT=Ze.STRUCT_BYTE_SIZE/Float32Array.BYTES_PER_ELEMENT,Ze.RADIUS_OFFSET=qt.views.radius.byteOffset/Float32Array.BYTES_PER_ELEMENT,Ze.POSITION_OFFSET=qt.views.position.byteOffset/Float32Array.BYTES_PER_ELEMENT,Ze.ORIG_POSITION_OFFSET=qt.views.origPosition.byteOffset/Float32Array.BYTES_PER_ELEMENT,Ze.VELOCITY_OFFSET=qt.views.velocity.byteOffset/Float32Array.BYTES_PER_ELEMENT,Ze.LIFE_OFFSET=qt.views.life.byteOffset/Float32Array.BYTES_PER_ELEMENT,Ze.LIFE_SPEED_OFFSET=qt.views.lifeSpeed.byteOffset/Float32Array.BYTES_PER_ELEMENT;let Qe=Ze;const Gc="vertexMain",Lc="fragMain",zp=` ${W.Particle} ${W.Light} ${W.Camera} diff --git a/docs/assets/index-CcD6bekL.js.gz b/docs/assets/index-BeB41sTJ.js.gz similarity index 78% rename from docs/assets/index-CcD6bekL.js.gz rename to docs/assets/index-BeB41sTJ.js.gz index 4133f25..2ef63a2 100644 Binary files a/docs/assets/index-CcD6bekL.js.gz and b/docs/assets/index-BeB41sTJ.js.gz differ diff --git a/docs/index.html b/docs/index.html index 3665cec..a66f213 100644 --- a/docs/index.html +++ b/docs/index.html @@ -21,7 +21,7 @@ - + diff --git a/docs/index.html.gz b/docs/index.html.gz index 74efaba..69ef2d2 100644 Binary files a/docs/index.html.gz and b/docs/index.html.gz differ