@luma.gl/webgpu 9.0.0-alpha.26 → 9.0.0-alpha.27

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.
@@ -1,5 +1,5 @@
1
1
  /// <reference types="dist" />
2
- import type { Binding, RenderPass } from '@luma.gl/api';
2
+ import type { Binding, RenderPass, TypedArray } from '@luma.gl/api';
3
3
  import { Buffer, RenderPipeline, RenderPipelineProps } from '@luma.gl/api';
4
4
  import type { WebGPUDevice } from '../webgpu-device';
5
5
  import type { WebGPUShader } from './webgpu-shader';
@@ -21,6 +21,8 @@ export declare class WebGPURenderPipeline extends RenderPipeline {
21
21
  destroy(): void;
22
22
  setIndexBuffer(indexBuffer: Buffer): void;
23
23
  setAttributes(attributes: Record<string, Buffer>): void;
24
+ /** Constant attributes are not available in WebGPU */
25
+ setConstantAttributes(attributes: Record<string, TypedArray>): void;
24
26
  /** Set the bindings */
25
27
  setBindings(bindings: Record<string, Binding>): void;
26
28
  setUniforms(uniforms: Record<string, any>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AACtD,OAAO,EAAC,MAAM,EAAE,cAAc,EAAE,mBAAmB,EAA2B,MAAM,cAAc,CAAC;AASnG,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAI3D,2DAA2D;AAC3D,qBAAa,oBAAqB,SAAQ,cAAc;IACtD,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,iBAAiB,CAAC;IAE1B,EAAE,EAAE,YAAY,CAAC;IACjB,EAAE,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Kb,8DAA8D;IAC9D,SAAS,CAAC,4BAA4B;IA+CtC,IAAI,CAAC,OAAO,EAAE;QACZ,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI;IAmCR,oBAAoB,CAAC,gBAAgB,EAAE,gBAAgB;CAwCxD"}
@@ -47,6 +47,9 @@ export class WebGPURenderPipeline extends RenderPipeline {
47
47
  }
48
48
  }
49
49
  }
50
+ setConstantAttributes(attributes) {
51
+ console.error('not implemented');
52
+ }
50
53
  setBindings(bindings) {
51
54
  if (!isObjectEmpty(this.props.bindings)) {
52
55
  Object.assign(this.props.bindings, bindings);
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pipeline.js","names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","_defineProperty","handle","createHandle","label","id","vs","fs","_bufferSlots","layout","bufferMap","_buffers","Array","Object","keys","length","fill","_bindGroupLayout","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","concat","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","_indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setBindings","bindings","assign","_bindGroup","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","_this$device","fsEntryPoint","targets","format","canvasContext","topology","primitive","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","bindGroup","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer"],"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"sourcesContent":["import type {Binding, RenderPass} from '@luma.gl/api';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/api';\nimport {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport {getBindGroup} from '../helpers/get-bind-group';\nimport {getVertexBufferLayout, getBufferSlots} from '../helpers/get-vertex-buffer-layout';\n// import {convertAttributesVertexBufferToLayout} from '../helpers/get-vertex-buffer-layout';\n// import {mapAccessorToWebGPUFormat} from './helpers/accessor-to-format';\n// import type {BufferAccessors} from './webgpu-pipeline';\n\nimport type {WebGPUDevice} from '../webgpu-device';\nimport type {WebGPUBuffer} from './webgpu-buffer';\nimport type {WebGPUShader} from './webgpu-shader';\nimport type {WebGPURenderPass} from './webgpu-render-pass';\n\n// RENDER PIPELINE\n\n/** Creates a new render pipeline when parameters change */\nexport class WebGPURenderPipeline extends RenderPipeline {\n device: WebGPUDevice;\n handle: GPURenderPipeline;\n\n vs: WebGPUShader;\n fs: WebGPUShader | null = null;\n\n private _bufferSlots: Record<string, number>;\n private _buffers: Buffer[];\n private _indexBuffer: WebGPUBuffer | null = null;\n // private _firstIndex: number;\n // private _lastIndex: number;\n\n /** For internal use to create BindGroups */\n private _bindGroupLayout: GPUBindGroupLayout;\n private _bindGroup: GPUBindGroup | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = (this.props.handle as GPURenderPipeline) || this.createHandle();\n this.handle.label = this.props.id;\n\n this.vs = cast<WebGPUShader>(props.vs);\n this.fs = cast<WebGPUShader>(props.fs);\n\n this._bufferSlots = getBufferSlots(this.props.layout, this.props.bufferMap);\n this._buffers = new Array<Buffer>(Object.keys(this._bufferSlots).length).fill(null);\n this._bindGroupLayout = this.handle.getBindGroupLayout(0);\n }\n\n protected createHandle(): GPURenderPipeline {\n const descriptor = this._getRenderPipelineDescriptor();\n const renderPipeline = this.device.handle.createRenderPipeline(descriptor);\n log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();\n log.log(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n return renderPipeline;\n }\n\n override destroy(): void {\n // WebGPURenderPipeline has no destroy method.\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n this._indexBuffer = cast<WebGPUBuffer>(indexBuffer);\n }\n\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const bufferIndex = this._bufferSlots[name];\n if (bufferIndex >= 0) {\n this._buffers[bufferIndex] = buffer;\n } else {\n throw new Error(\n `Setting attribute '${name}' not listed in shader layout for program ${this.id}`\n );\n }\n }\n // for (let i = 0; i < this._bufferSlots.length; ++i) {\n // const bufferName = this._bufferSlots[i];\n // if (attributes[bufferName]) {\n // this.handle\n // }\n // }\n }\n\n /** Set the bindings */\n setBindings(bindings: Record<string, Binding>): void {\n if (!isObjectEmpty(this.props.bindings)) {\n Object.assign(this.props.bindings, bindings);\n // Set up the bindings\n this._bindGroup = getBindGroup(\n this.device.handle,\n this._bindGroupLayout,\n this.props.layout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, any>): void {\n if (!isObjectEmpty(uniforms)) {\n throw new Error('WebGPU does not support uniforms');\n }\n }\n\n _getBuffers() {\n return this._buffers;\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // assert(this._bindGroup);\n return this._bindGroup;\n }\n\n /** Populate the complex WebGPU GPURenderPipelineDescriptor */\n protected _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex: GPUVertexState = {\n module: cast<WebGPUShader>(this.props.vs).handle,\n entryPoint: this.props.vsEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.props.layout, this.props.bufferMap)\n };\n\n // Set up the fragment stage\n let fragment: GPUFragmentState | undefined;\n if (this.props.fs) {\n fragment = {\n module: cast<WebGPUShader>(this.props.fs).handle,\n entryPoint: this.props.fsEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device?.canvasContext?.format)\n }\n ]\n };\n }\n\n // WebGPU has more restrictive topology support than WebGL\n switch (this.props.topology) {\n case 'triangle-fan':\n case 'line-loop':\n throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);\n default:\n }\n\n // Create a partially populated descriptor\n const descriptor: GPURenderPipelineDescriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n },\n layout: 'auto'\n };\n\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n\n return descriptor;\n }\n\n draw(options: {\n renderPass?: RenderPass;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n const webgpuRenderPass: WebGPURenderPass =\n cast<WebGPURenderPass>(options.renderPass) || this.device.getDefaultRenderPass();\n\n // Set pipeline\n webgpuRenderPass.handle.setPipeline(this.handle);\n\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n\n // Set attributes\n this._setAttributeBuffers(webgpuRenderPass);\n\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n webgpuRenderPass.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n _setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.props.layout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferMap)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n */\n }\n}\n"],"mappings":";AACA,SAAgBA,cAAc,EAAuBC,IAAI,EAAEC,GAAG,EAAEC,aAAa,QAAO,cAAc;AAAC,SAC3FC,yCAAyC;AAAA,SACzCC,sBAAsB;AAAA,SACtBC,YAAY;AAAA,SACZC,qBAAqB,EAAEC,cAAc;AAa7C,OAAO,MAAMC,oBAAoB,SAAST,cAAc,CAAC;EAiBvDU,WAAWA,CAACC,MAAoB,EAAEC,KAA0B,EAAE;IAC5D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,aAbG,IAAI;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,uBAIc,IAAI;IAAAA,eAAA;IAAAA,eAAA,qBAMN,IAAI;IAI5C,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,MAAM,GAAI,IAAI,CAACF,KAAK,CAACE,MAA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IAAI,CAAC3C,MAAM,EAAE;QACX,MAAM4C,SAAS,GAAG,IAAI,CAAC/E,KAAK,CAACS,MAAM,CAACwB,UAAU,CAAC+C,IAAI,CAChDD,SAAS,IAAKA,SAAS,CAACE,QAAQ,KAAKH,CACxC,CAAC;QACD,MAAM,IAAIxC,KAAK,sCAAAd,MAAA,CACwB,CAAAuD,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAE7C,IAAI,KAAI,EAAE,kBAAAV,MAAA,CAAe,IAAI,CAACxB,KAAK,CAACK,EAAE,MACxF,CAAC;MACH;MACA0D,gBAAgB,CAAC7D,MAAM,CAACgF,eAAe,CAACJ,CAAC,EAAE3C,MAAM,CAACjC,MAAM,CAAC;IAC3D;EAsBF;AACF"}
1
+ {"version":3,"file":"webgpu-render-pipeline.js","names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","_defineProperty","handle","createHandle","label","id","vs","fs","_bufferSlots","layout","bufferMap","_buffers","Array","Object","keys","length","fill","_bindGroupLayout","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","concat","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","_indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setConstantAttributes","console","error","setBindings","bindings","assign","_bindGroup","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","_this$device","fsEntryPoint","targets","format","canvasContext","topology","primitive","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","bindGroup","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer"],"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"sourcesContent":["// luma.gl MIT license\n\nimport type {Binding, RenderPass, TypedArray} from '@luma.gl/api';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/api';\nimport {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport {getBindGroup} from '../helpers/get-bind-group';\nimport {getVertexBufferLayout, getBufferSlots} from '../helpers/get-vertex-buffer-layout';\n// import {convertAttributesVertexBufferToLayout} from '../helpers/get-vertex-buffer-layout';\n// import {mapAccessorToWebGPUFormat} from './helpers/accessor-to-format';\n// import type {BufferAccessors} from './webgpu-pipeline';\n\nimport type {WebGPUDevice} from '../webgpu-device';\nimport type {WebGPUBuffer} from './webgpu-buffer';\nimport type {WebGPUShader} from './webgpu-shader';\nimport type {WebGPURenderPass} from './webgpu-render-pass';\n\n// RENDER PIPELINE\n\n/** Creates a new render pipeline when parameters change */\nexport class WebGPURenderPipeline extends RenderPipeline {\n device: WebGPUDevice;\n handle: GPURenderPipeline;\n\n vs: WebGPUShader;\n fs: WebGPUShader | null = null;\n\n private _bufferSlots: Record<string, number>;\n private _buffers: Buffer[];\n private _indexBuffer: WebGPUBuffer | null = null;\n // private _firstIndex: number;\n // private _lastIndex: number;\n\n /** For internal use to create BindGroups */\n private _bindGroupLayout: GPUBindGroupLayout;\n private _bindGroup: GPUBindGroup | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = (this.props.handle as GPURenderPipeline) || this.createHandle();\n this.handle.label = this.props.id;\n\n this.vs = cast<WebGPUShader>(props.vs);\n this.fs = cast<WebGPUShader>(props.fs);\n\n this._bufferSlots = getBufferSlots(this.props.layout, this.props.bufferMap);\n this._buffers = new Array<Buffer>(Object.keys(this._bufferSlots).length).fill(null);\n this._bindGroupLayout = this.handle.getBindGroupLayout(0);\n }\n\n protected createHandle(): GPURenderPipeline {\n const descriptor = this._getRenderPipelineDescriptor();\n const renderPipeline = this.device.handle.createRenderPipeline(descriptor);\n log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();\n log.log(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n return renderPipeline;\n }\n\n override destroy(): void {\n // WebGPURenderPipeline has no destroy method.\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n this._indexBuffer = cast<WebGPUBuffer>(indexBuffer);\n }\n\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const bufferIndex = this._bufferSlots[name];\n if (bufferIndex >= 0) {\n this._buffers[bufferIndex] = buffer;\n } else {\n throw new Error(\n `Setting attribute '${name}' not listed in shader layout for program ${this.id}`\n );\n }\n }\n // for (let i = 0; i < this._bufferSlots.length; ++i) {\n // const bufferName = this._bufferSlots[i];\n // if (attributes[bufferName]) {\n // this.handle\n // }\n // }\n }\n\n /** Constant attributes are not available in WebGPU */\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n console.error('not implemented');\n }\n\n /** Set the bindings */\n setBindings(bindings: Record<string, Binding>): void {\n if (!isObjectEmpty(this.props.bindings)) {\n Object.assign(this.props.bindings, bindings);\n // Set up the bindings\n this._bindGroup = getBindGroup(\n this.device.handle,\n this._bindGroupLayout,\n this.props.layout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, any>): void {\n if (!isObjectEmpty(uniforms)) {\n throw new Error('WebGPU does not support uniforms');\n }\n }\n\n _getBuffers() {\n return this._buffers;\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // assert(this._bindGroup);\n return this._bindGroup;\n }\n\n /** Populate the complex WebGPU GPURenderPipelineDescriptor */\n protected _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex: GPUVertexState = {\n module: cast<WebGPUShader>(this.props.vs).handle,\n entryPoint: this.props.vsEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.props.layout, this.props.bufferMap)\n };\n\n // Set up the fragment stage\n let fragment: GPUFragmentState | undefined;\n if (this.props.fs) {\n fragment = {\n module: cast<WebGPUShader>(this.props.fs).handle,\n entryPoint: this.props.fsEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device?.canvasContext?.format)\n }\n ]\n };\n }\n\n // WebGPU has more restrictive topology support than WebGL\n switch (this.props.topology) {\n case 'triangle-fan':\n case 'line-loop':\n throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);\n default:\n }\n\n // Create a partially populated descriptor\n const descriptor: GPURenderPipelineDescriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n },\n layout: 'auto'\n };\n\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n\n return descriptor;\n }\n\n draw(options: {\n renderPass?: RenderPass;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n const webgpuRenderPass: WebGPURenderPass =\n cast<WebGPURenderPass>(options.renderPass) || this.device.getDefaultRenderPass();\n\n // Set pipeline\n webgpuRenderPass.handle.setPipeline(this.handle);\n\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n\n // Set attributes\n this._setAttributeBuffers(webgpuRenderPass);\n\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n webgpuRenderPass.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n _setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.props.layout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferMap)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n */\n }\n}\n"],"mappings":";AAGA,SAAgBA,cAAc,EAAuBC,IAAI,EAAEC,GAAG,EAAEC,aAAa,QAAO,cAAc;AAAC,SAC3FC,yCAAyC;AAAA,SACzCC,sBAAsB;AAAA,SACtBC,YAAY;AAAA,SACZC,qBAAqB,EAAEC,cAAc;AAa7C,OAAO,MAAMC,oBAAoB,SAAST,cAAc,CAAC;EAiBvDU,WAAWA,CAACC,MAAoB,EAAEC,KAA0B,EAAE;IAC5D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,aAbG,IAAI;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,uBAIc,IAAI;IAAAA,eAAA;IAAAA,eAAA,qBAMN,IAAI;IAI5C,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,MAAM,GAAI,IAAI,CAACF,KAAK,CAACE,MAAM,IAA0B,IAAI,CAACC,YAAY,CAAC,CAAC;IAC7E,IAAI,CAACD,MAAM,C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AC,CAAC,CAAC;MAC7C,IAAI,CAAC9C,MAAM,EAAE;QACX,MAAM+C,SAAS,GAAG,IAAI,CAAClF,KAAK,CAACS,MAAM,CAACwB,UAAU,CAACkD,IAAI,CAChDD,SAAS,IAAKA,SAAS,CAACE,QAAQ,KAAKH,CACxC,CAAC;QACD,MAAM,IAAI3C,KAAK,sCAAAd,MAAA,CACwB,CAAA0D,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEhD,IAAI,KAAI,EAAE,kBAAAV,MAAA,CAAe,IAAI,CAACxB,KAAK,CAACK,EAAE,MACxF,CAAC;MACH;MACA6D,gBAAgB,CAAChE,MAAM,CAACmF,eAAe,CAACJ,CAAC,EAAE9C,MAAM,CAACjC,MAAM,CAAC;IAC3D;EAsBF;AACF"}
package/dist/dist.dev.js CHANGED
@@ -1757,6 +1757,7 @@ var __exports__ = (() => {
1757
1757
  };
1758
1758
  /** Set attributes (stored on pipeline and set before each call) */
1759
1759
  /** Set attributes (stored on pipeline and set before each call) */
1760
+ /** Set constant attributes (WebGL only) */
1760
1761
  /** Set bindings (stored on pipeline and set before each call) */
1761
1762
  /** Uniforms (only supported on WebGL devices. Reset before each call to enable pipeline sharing) */
1762
1763
  /** Draw call */
@@ -2634,6 +2635,10 @@ var __exports__ = (() => {
2634
2635
  }
2635
2636
  }
2636
2637
  }
2638
+ /** Constant attributes are not available in WebGPU */
2639
+ setConstantAttributes(attributes) {
2640
+ console.error("not implemented");
2641
+ }
2637
2642
  /** Set the bindings */
2638
2643
  setBindings(bindings) {
2639
2644
  if (!isObjectEmpty(this.props.bindings)) {
package/dist/index.cjs CHANGED
@@ -795,6 +795,10 @@ var WebGPURenderPipeline = class extends import_api8.RenderPipeline {
795
795
  }
796
796
  }
797
797
  }
798
+ /** Constant attributes are not available in WebGPU */
799
+ setConstantAttributes(attributes) {
800
+ console.error("not implemented");
801
+ }
798
802
  /** Set the bindings */
799
803
  setBindings(bindings) {
800
804
  if (!(0, import_api8.isObjectEmpty)(this.props.bindings)) {
package/dist.min.js CHANGED
@@ -7,7 +7,7 @@
7
7
  var __exports__=(()=>{var Er=Object.create;var Ce=Object.defineProperty;var Tr=Object.getOwnPropertyDescriptor;var Ar=Object.getOwnPropertyNames;var kr=Object.getPrototypeOf,Br=Object.prototype.hasOwnProperty;var Ve=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),jr=(t,n)=>{for(var e in n)Ce(t,e,{get:n[e],enumerable:!0})},ft=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of Ar(n))!Br.call(t,o)&&o!==e&&Ce(t,o,{get:()=>n[o],enumerable:!(r=Tr(n,o))||r.enumerable});return t};var $e=(t,n,e)=>(e=t!=null?Er(kr(t)):{},ft(n||!t||!t.__esModule?Ce(e,"default",{value:t,enumerable:!0}):e,t)),Dr=t=>ft(Ce({},"__esModule",{value:!0}),t);var dt=Ve((Mo,X)=>{function Ke(t){return X.exports=Ke=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},X.exports.__esModule=!0,X.exports.default=X.exports,Ke(t)}X.exports=Ke,X.exports.__esModule=!0,X.exports.default=X.exports});var gt=Ve((Uo,J)=>{var Ir=dt().default;function mt(){"use strict";J.exports=mt=function(){return t},J.exports.__esModule=!0,J.exports.default=J.exports;var t={},n=Object.prototype,e=n.hasOwnProperty,r=Object.defineProperty||function(h,l,p){h[l]=p.value},o=typeof Symbol=="function"?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(h,l,p){return Object.defineProperty(h,l,{value:p,enumerable:!0,configurable:!0,writable:!0}),h[l]}try{u({},"")}catch{u=function(p,b,x){return p[b]=x}}function m(h,l,p,b){var x=l&&l.prototype instanceof S?l:S,_=Object.create(x.prototype),A=new re(b||[]);return r(_,"_invoke",{value:ve(h,p,A)}),_}function y(h,l,p){try{return{type:"normal",arg:h.call(l,p)}}catch(b){return{type:"throw",arg:b}}}t.wrap=m;var O={};function S(){}function C(){}function E(){}var U={};u(U,i,function(){return this});var L=Object.getPrototypeOf,V=L&&L(L(Z([])));V&&V!==n&&e.call(V,i)&&(U=V);var j=E.prototype=S.prototype=Object.create(U);function F(h){["next","throw","return"].forEach(function(l){u(h,l,function(p){return this._invoke(l,p)})})}function $(h,l){function p(x,_,A,G){var N=y(h[x],h,_);if(N.type!=="throw"){var ne=N.arg,ee=ne.value;return ee&&Ir(ee)=="object"&&e.call(ee,"__await")?l.resolve(ee.__await).then(function(oe){p("next",oe,A,G)},function(oe){p("throw",oe,A,G)}):l.resolve(ee).then(function(oe){ne.value=oe,A(ne)},function(oe){return p("throw",oe,A,G)})}G(N.arg)}var b;r(this,"_invoke",{value:function(_,A){function G(){return new l(function(N,ne){p(_,A,N,ne)})}return b=b?b.then(G,G):G()}})}function ve(h,l,p){var b="suspendedStart";return function(x,_){if(b==="executing")throw new Error("Generator is already running");if(b==="completed"){if(x==="throw")throw _;return Re()}for(p.method=x,p.arg=_;;){var A=p.delegate;if(A){var G=Q(A,p);if(G){if(G===O)continue;return G}}if(p.method==="next")p.sent=p._sent=p.arg;else if(p.method==="throw"){if(b==="suspendedStart")throw b="completed",p.arg;p.dispatchException(p.arg)}else p.method==="return"&&p.abrupt("return",p.arg);b="executing";var N=y(h,l,p);if(N.type==="normal"){if(b=p.done?"completed":"suspendedYield",N.arg===O)continue;return{value:N.arg,done:p.done}}N.type==="throw"&&(b="completed",p.method="throw",p.arg=N.arg)}}}function Q(h,l){var p=l.method,b=h.iterator[p];if(b===void 0)return l.delegate=null,p==="throw"&&h.iterator.return&&(l.method="return",l.arg=void 0,Q(h,l),l.method==="throw")||p!=="return"&&(l.method="throw",l.arg=new TypeError("The iterator does not provide a '"+p+"' method")),O;var x=y(b,h.iterator,l.arg);if(x.type==="throw")return l.method="throw",l.arg=x.arg,l.delegate=null,O;var _=x.arg;return _?_.done?(l[h.resultName]=_.value,l.next=h.nextLoc,l.method!=="return"&&(l.method="next",l.arg=void 0),l.delegate=null,O):_:(l.method="throw",l.arg=new TypeError("iterator result is not an object"),l.delegate=null,O)}function ye(h){var l={tryLoc:h[0]};1 in h&&(l.catchLoc=h[1]),2 in h&&(l.finallyLoc=h[2],l.afterLoc=h[3]),this.tryEntries.push(l)}function K(h){var l=h.completion||{};l.type="normal",delete l.arg,h.completion=l}function re(h){this.tryEntries=[{tryLoc:"root"}],h.forEach(ye,this),this.reset(!0)}function Z(h){if(h){var l=h[i];if(l)return l.call(h);if(typeof h.next=="function")return h;if(!isNaN(h.length)){var p=-1,b=function x(){for(;++p<h.length;)if(e.call(h,p))return x.value=h[p],x.done=!1,x;return x.value=void 0,x.done=!0,x};return b.next=b}}return{next:Re}}function Re(){return{value:void 0,done:!0}}return C.prototype=E,r(j,"constructor",{value:E,configurable:!0}),r(E,"constructor",{value:C,configurable:!0}),C.displayName=u(E,c,"GeneratorFunction"),t.isGeneratorFunction=function(h){var l=typeof h=="function"&&h.constructor;return!!l&&(l===C||(l.displayName||l.name)==="GeneratorFunction")},t.mark=function(h){return Object.setPrototypeOf?Object.setPrototypeOf(h,E):(h.__proto__=E,u(h,c,"GeneratorFunction")),h.prototype=Object.create(j),h},t.awrap=function(h){return{__await:h}},F($.prototype),u($.prototype,a,function(){return this}),t.AsyncIterator=$,t.async=function(h,l,p,b,x){x===void 0&&(x=Promise);var _=new $(m(h,l,p,b),x);return t.isGeneratorFunction(l)?_:_.next().then(function(A){return A.done?A.value:_.next()})},F(j),u(j,c,"Generator"),u(j,i,function(){return this}),u(j,"toString",function(){return"[object Generator]"}),t.keys=function(h){var l=Object(h),p=[];for(var b in l)p.push(b);return p.reverse(),function x(){for(;p.length;){var _=p.pop();if(_ in l)return x.value=_,x.done=!1,x}return x.done=!0,x}},t.values=Z,re.prototype={constructor:re,reset:function(l){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(K),!l)for(var p in this)p.charAt(0)==="t"&&e.call(this,p)&&!isNaN(+p.slice(1))&&(this[p]=void 0)},stop:function(){this.done=!0;var l=this.tryEntries[0].completion;if(l.type==="throw")throw l.arg;return this.rval},dispatchException:function(l){if(this.done)throw l;var p=this;function b(ne,ee){return A.type="throw",A.arg=l,p.next=ne,ee&&(p.method="next",p.arg=void 0),!!ee}for(var x=this.tryEntries.length-1;x>=0;--x){var _=this.tryEntries[x],A=_.completion;if(_.tryLoc==="root")return b("end");if(_.tryLoc<=this.prev){var G=e.call(_,"catchLoc"),N=e.call(_,"finallyLoc");if(G&&N){if(this.prev<_.catchLoc)return b(_.catchLoc,!0);if(this.prev<_.finallyLoc)return b(_.finallyLoc)}else if(G){if(this.prev<_.catchLoc)return b(_.catchLoc,!0)}else{if(!N)throw new Error("try statement without catch or finally");if(this.prev<_.finallyLoc)return b(_.finallyLoc)}}}},abrupt:function(l,p){for(var b=this.tryEntries.length-1;b>=0;--b){var x=this.tryEntries[b];if(x.tryLoc<=this.prev&&e.call(x,"finallyLoc")&&this.prev<x.finallyLoc){var _=x;break}}_&&(l==="break"||l==="continue")&&_.tryLoc<=p&&p<=_.finallyLoc&&(_=null);var A=_?_.completion:{};return A.type=l,A.arg=p,_?(this.method="next",this.next=_.finallyLoc,O):this.complete(A)},complete:function(l,p){if(l.type==="throw")throw l.arg;return l.type==="break"||l.type==="continue"?this.next=l.arg:l.type==="return"?(this.rval=this.arg=l.arg,this.method="return",this.next="end"):l.type==="normal"&&p&&(this.next=p),O},finish:function(l){for(var p=this.tryEntries.length-1;p>=0;--p){var b=this.tryEntries[p];if(b.finallyLoc===l)return this.complete(b.completion,b.afterLoc),K(b),O}},catch:function(l){for(var p=this.tryEntries.length-1;p>=0;--p){var b=this.tryEntries[p];if(b.tryLoc===l){var x=b.completion;if(x.type==="throw"){var _=x.arg;K(b)}return _}}throw new Error("illegal catch attempt")},delegateYield:function(l,p,b){return this.delegate={iterator:Z(l),resultName:p,nextLoc:b},this.method==="next"&&(this.arg=void 0),O}},t}J.exports=mt,J.exports.__esModule=!0,J.exports.default=J.exports});var Te=Ve((Fo,vt)=>{var Ee=gt()();vt.exports=Ee;try{regeneratorRuntime=Ee}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Ee:Function("r","regeneratorRuntime = r")(Ee)}});var vo={};jr(vo,{WebGPUBuffer:()=>Fe,WebGPUDevice:()=>lt,WebGPUSampler:()=>W,WebGPUShader:()=>We,WebGPUTexture:()=>ze});function pt(t,n,e,r,o,i,a){try{var c=t[i](a),u=c.value}catch(m){e(m);return}c.done?n(u):Promise.resolve(u).then(r,o)}function q(t){return function(){var n=this,e=arguments;return new Promise(function(r,o){var i=t.apply(n,e);function a(u){pt(i,r,o,a,c,"next",u)}function c(u){pt(i,r,o,a,c,"throw",u)}a(void 0)})}}function g(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function Y(t){return Y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Y(t)}function Ye(t,n){if(Y(t)!=="object"||t===null)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var r=e.call(t,n||"default");if(Y(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function be(t){var n=Ye(t,"string");return Y(n)==="symbol"?n:String(n)}function ht(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,be(r.key),r)}}function v(t,n,e){return n&&ht(t.prototype,n),e&&ht(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _e(t,n){return _e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},_e(t,n)}function w(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&_e(t,n)}function P(t,n){if(n&&(Y(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return f(t)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(t)}function s(t,n,e){return n=be(n),n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}var xe=$e(Te(),1);function qe(t){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let n=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,e=t||n;return!!(e&&e.indexOf("Electron")>=0)}function I(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||qe()}var Gr=globalThis.self||globalThis.window||globalThis.global,ce=globalThis.window||globalThis.self||globalThis.global,Lr=globalThis.document||{},ie=globalThis.process||{},Nr=globalThis.console,Vo=globalThis.navigator||{};var Ae=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",Ko=I();function Mr(t){try{let n=window[t],e="__storage_test__";return n.setItem(e,e),n.removeItem(e),n}catch{return null}}var ke=class{constructor(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"sessionStorage";this.storage=void 0,this.id=void 0,this.config=void 0,this.storage=Mr(r),this.id=n,this.config=e,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(n){if(Object.assign(this.config,n),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let n={};if(this.storage){let e=this.storage.getItem(this.id);n=e?JSON.parse(e):{}}return Object.assign(this.config,n),this}};function yt(t){let n;return t<10?n="".concat(t.toFixed(2),"ms"):t<100?n="".concat(t.toFixed(1),"ms"):t<1e3?n="".concat(t.toFixed(0),"ms"):n="".concat((t/1e3).toFixed(2),"s"),n}function bt(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,e=Math.max(n-t.length,0);return"".concat(" ".repeat(e)).concat(t)}function Be(t,n,e){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:600,o=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>r&&(e=Math.min(e,r/t.width));let i=t.width*e,a=t.height*e,c=["font-size:1px;","padding:".concat(Math.floor(a/2),"px ").concat(Math.floor(i/2),"px;"),"line-height:".concat(a,"px;"),"background:url(".concat(o,");"),"background-size:".concat(i,"px ").concat(a,"px;"),"color:transparent;"].join("");return["".concat(n," %c+"),c]}var je;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(je||(je={}));var Ur=10;function _t(t){return typeof t!="string"?t:(t=t.toUpperCase(),je[t]||je.WHITE)}function wt(t,n,e){if(!I&&typeof t=="string"){if(n){let r=_t(n);t="\x1B[".concat(r,"m").concat(t,"\x1B[39m")}if(e){let r=_t(e);t="\x1B[".concat(r+Ur,"m").concat(t,"\x1B[49m")}}return t}function Pt(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["constructor"],e=Object.getPrototypeOf(t),r=Object.getOwnPropertyNames(e),o=t;for(let i of r){let a=o[i];typeof a=="function"&&(n.find(c=>i===c)||(o[i]=a.bind(t)))}}function le(t,n){if(!t)throw new Error(n||"Assertion failed")}function ae(){let t;if(I()&&ce.performance){var n,e;t=ce===null||ce===void 0||(n=ce.performance)===null||n===void 0||(e=n.now)===null||e===void 0?void 0:e.call(n)}else if("hrtime"in ie){var r;let o=ie===null||ie===void 0||(r=ie.hrtime)===null||r===void 0?void 0:r.call(ie);t=o[0]*1e3+o[1]/1e6}else t=Date.now();return t}var fe={debug:I()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Fr={enabled:!0,level:0};function z(){}var St={},Ot={once:!0},te=class{constructor(){let{id:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};this.id=void 0,this.VERSION=Ae,this._startTs=ae(),this._deltaTs=ae(),this._storage=void 0,this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=n,this.userData={},this._storage=new ke("__probe-".concat(this.id,"__"),Fr),this.timeStamp("".concat(this.id," started")),Pt(this),Object.seal(this)}set level(n){this.setLevel(n)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((ae()-this._startTs).toPrecision(10))}getDelta(){return Number((ae()-this._deltaTs).toPrecision(10))}set priority(n){this.level=n}get priority(){return this.level}getPriority(){return this.level}enable(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this._storage.setConfiguration({enabled:n}),this}setLevel(n){return this._storage.setConfiguration({level:n}),this}get(n){return this._storage.config[n]}set(n,e){this._storage.setConfiguration({[n]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(n,e){le(n,e)}warn(n){return this._getLogFunction(0,n,fe.warn,arguments,Ot)}error(n){return this._getLogFunction(0,n,fe.error,arguments)}deprecated(n,e){return this.warn("`".concat(n,"` is deprecated and will be removed in a later version. Use `").concat(e,"` instead"))}removed(n,e){return this.error("`".concat(n,"` has been removed. Use `").concat(e,"` instead"))}probe(n,e){return this._getLogFunction(n,e,fe.log,arguments,{time:!0,once:!0})}log(n,e){return this._getLogFunction(n,e,fe.debug,arguments)}info(n,e){return this._getLogFunction(n,e,console.info,arguments)}once(n,e){return this._getLogFunction(n,e,fe.debug||fe.info,arguments,Ot)}table(n,e,r){return e?this._getLogFunction(n,e,console.table||z,r&&[r],{tag:Vr(e)}):z}image(n){let{logLevel:e,priority:r,image:o,message:i="",scale:a=1}=n;return this._shouldLog(e||r)?I()?Hr({image:o,message:i,scale:a}):Wr({image:o,message:i,scale:a}):z}time(n,e){return this._getLogFunction(n,e,console.time?console.time:console.info)}timeEnd(n,e){return this._getLogFunction(n,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(n,e){return this._getLogFunction(n,e,console.timeStamp||z)}group(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{collapsed:!1},o=xt({logLevel:n,message:e,opts:r}),{collapsed:i}=r;return o.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(o)}groupCollapsed(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.group(n,e,Object.assign({},r,{collapsed:!0}))}groupEnd(n){return this._getLogFunction(n,"",console.groupEnd||z)}withGroup(n,e,r){this.group(n,e)();try{r()}finally{this.groupEnd(n)()}}trace(){console.trace&&console.trace()}_shouldLog(n){return this.isEnabled()&&this.getLevel()>=Rt(n)}_getLogFunction(n,e,r,o,i){if(this._shouldLog(n)){i=xt({logLevel:n,message:e,args:o,opts:i}),r=r||i.method,le(r),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=ae();let a=i.tag||i.message;if(i.once&&a)if(!St[a])St[a]=ae();else return z;return e=zr(this.id,i.message,i),r.bind(console,e,...i.args)}return z}};te.VERSION=Ae;function Rt(t){if(!t)return 0;let n;switch(typeof t){case"number":n=t;break;case"object":n=t.logLevel||t.priority||0;break;default:return 0}return le(Number.isFinite(n)&&n>=0),n}function xt(t){let{logLevel:n,message:e}=t;t.logLevel=Rt(n);let r=t.args?Array.from(t.args):[];for(;r.length&&r.shift()!==e;);switch(typeof n){case"string":case"function":e!==void 0&&r.unshift(e),t.message=n;break;case"object":Object.assign(t,n);break;default:}typeof t.message=="function"&&(t.message=t.message());let o=typeof t.message;return le(o==="string"||o==="object"),Object.assign(t,{args:r},t.opts)}function zr(t,n,e){if(typeof n=="string"){let r=e.time?bt(yt(e.total)):"";n=e.time?"".concat(t,": ").concat(r," ").concat(n):"".concat(t,": ").concat(n),n=wt(n,e.color,e.background)}return n}function Wr(t){let{image:n,message:e="",scale:r=1}=t;return console.warn("removed"),z}function Hr(t){let{image:n,message:e="",scale:r=1}=t;if(typeof n=="string"){let i=new Image;return i.onload=()=>{let a=Be(i,e,r);console.log(...a)},i.src=n,z}let o=n.nodeName||"";if(o.toLowerCase()==="img")return console.log(...Be(n,e,r)),z;if(o.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...Be(i,e,r)),i.src=n.toDataURL(),z}return z}function Vr(t){for(let n in t)for(let e in t[n])return e||"untitled";return"empty"}var bi=new te({id:"@probe.gl/log"});var R=new te({id:"luma.gl"});function we(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let n=process.hrtime();t=n[0]*1e3+n[1]/1e6}else t=Date.now();return t}var se=class{constructor(n,e){this.name=void 0,this.type=void 0,this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=n,this.type=e,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(n){return this.sampleSize=n,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(n){return this._count+=n,this._samples++,this._checkSampling(),this}subtractCount(n){return this._count-=n,this._samples++,this._checkSampling(),this}addTime(n){return this._time+=n,this.lastTiming=n,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=we(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(we()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var pe=class{constructor(n){this.id=void 0,this.stats={},this.id=n.id,this.stats={},this._initializeStats(n.stats),Object.seal(this)}get(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"count";return this._getOrCreate({name:n,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(let n of Object.values(this.stats))n.reset();return this}forEach(n){for(let e of Object.values(this.stats))n(e)}getTable(){let n={};return this.forEach(e=>{n[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),n}_initializeStats(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(e=>this._getOrCreate(e))}_getOrCreate(n){let{name:e,type:r}=n,o=this.stats[e];return o||(n instanceof se?o=n:o=new se(e,r),this.stats[e]=o),o}};var $r=function(){function t(){g(this,t),s(this,"stats",new Map)}return v(t,[{key:"getStats",value:function(e){return this.get(e)}},{key:"get",value:function(e){return this.stats.has(e)||this.stats.set(e,new pe({id:e})),this.stats.get(e)}}]),t}(),De=new $r;function Yr(){var t=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",n="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==t)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat(t));return globalThis.luma||(I()&&R.log(1,"luma.gl ".concat(t," - ").concat(n))(),globalThis.luma=globalThis.luma||{VERSION:t,version:t,log:R,stats:De}),t}var Ct=Yr();var Xe={};function ue(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"id";Xe[t]=Xe[t]||1;var n=Xe[t]++;return"".concat(t,"-").concat(n)}function Ie(t){var n=!0;for(var e in t){n=!1;break}return n}function Et(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Kr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Et(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Et(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var k={id:"undefined",handle:void 0,userData:void 0},T=function(){function t(n,e,r){if(g(this,t),s(this,"id",void 0),s(this,"props",void 0),s(this,"userData",{}),s(this,"device",void 0),s(this,"_device",void 0),s(this,"destroyed",!1),s(this,"allocatedBytes",0),s(this,"_attachedResources",new Set),!n)throw new Error("no device");this._device=n,this.props=qr(e,r);var o=this.props.id!=="undefined"?this.props.id:ue(this[Symbol.toStringTag]);this.props.id=o,this.id=o,this.userData=this.props.userData||{},this.addStats()}return v(t,[{key:"destroy",value:function(){this.destroyResource()}},{key:"delete",value:function(){return this.destroy(),this}},{key:"toString",value:function(){return"".concat(this[Symbol.toStringTag]||this.constructor.name,"(").concat(this.id,")")}},{key:"getProps",value:function(){return this.props}},{key:"attachResource",value:function(e){this._attachedResources.add(e)}},{key:"detachResource",value:function(e){this._attachedResources.delete(e)}},{key:"destroyAttachedResource",value:function(e){this._attachedResources.delete(e)&&e.destroy()}},{key:"destroyAttachedResources",value:function(){for(var e=0,r=Object.values(this._attachedResources);e<r.length;e++){var o=r[e];o.destroy()}this._attachedResources=new Set}},{key:"destroyResource",value:function(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}},{key:"removeStats",value:function(){var e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("".concat(r,"s Active")).decrementCount()}},{key:"trackAllocatedMemory",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[Symbol.toStringTag],o=this._device.statsManager.getStats("Resource Counts");o.get("GPU Memory").addCount(e),o.get("".concat(r," Memory")).addCount(e),this.allocatedBytes=e}},{key:"trackDeallocatedMemory",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this[Symbol.toStringTag],r=this._device.statsManager.getStats("Resource Counts");r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get("".concat(e," Memory")).subtractCount(this.allocatedBytes),this.allocatedBytes=0}},{key:"addStats",value:function(){var e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get("".concat(r,"s Created")).incrementCount(),e.get("".concat(r,"s Active")).incrementCount()}}]),t}();s(T,"defaultProps",k);function qr(t,n){var e=Kr({},n);for(var r in t)t[r]!==void 0&&(e[r]=t[r]);return e}var At;function Xr(t){var n=Jr();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Jr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Tt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Je(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Tt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Tt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var Qr=Je(Je({},k),{},{usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1});At=Symbol.toStringTag;var B=function(t){w(e,t);var n=Xr(e);function e(r,o){var i;g(this,e);var a=Je({},o);return(o.usage||0)&e.INDEX&&!o.indexType&&(o.data instanceof Uint32Array?a.indexType="uint32":o.data instanceof Uint16Array&&(a.indexType="uint16")),i=n.call(this,r,a,Qr),s(f(i),"byteLength",void 0),i}return v(e,[{key:At,get:function(){return"Buffer"}},{key:"write",value:function(o,i){throw new Error("not implemented")}},{key:"readAsync",value:function(o,i){throw new Error("not implemented")}},{key:"getData",value:function(){throw new Error("not implemented")}}]),e}(T);s(B,"MAP_READ",1);s(B,"MAP_WRITE",2);s(B,"COPY_SRC",4);s(B,"COPY_DST",8);s(B,"INDEX",16);s(B,"VERTEX",32);s(B,"UNIFORM",64);s(B,"STORAGE",128);s(B,"INDIRECT",256);s(B,"QUERY_RESOLVE",512);var Bt;function kt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Qe(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?kt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):kt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var Zr={id:null,type:"best-available",canvas:null,container:null,webgl2:!0,webgl1:!0,manageState:!0,width:800,height:600,debug:Boolean(R.get("debug")),break:[],gl:null};Bt=Symbol.toStringTag;var Ge=function(){function t(n){g(this,t),s(this,"id",void 0),s(this,"statsManager",De),s(this,"props",void 0),s(this,"userData",{}),s(this,"info",void 0),s(this,"lost",void 0),s(this,"canvasContext",void 0),this.props=Qe(Qe({},Zr),n),this.id=this.props.id||ue(this[Symbol.toStringTag].toLowerCase())}return v(t,[{key:Bt,get:function(){return"Device"}},{key:"loseDevice",value:function(){return!1}},{key:"createTexture",value:function(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}},{key:"createCommandEncoder",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};throw new Error("not implemented")}},{key:"_getBufferProps",value:function(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{data:e};var r=Qe({},e);return(e.usage||0)&B.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array&&(r.indexType="uint16")),r}}]),t}();s(Ge,"VERSION",Ct);function Ze(t){if(Array.isArray(t))return t}function et(t,n){var e=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(e!=null){var r,o,i,a,c=[],u=!0,m=!1;try{if(i=(e=e.call(t)).next,n===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(r=i.call(e)).done)&&(c.push(r.value),c.length!==n);u=!0);}catch(y){m=!0,o=y}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(m)throw o}}return c}}function Le(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function tt(t,n){if(t){if(typeof t=="string")return Le(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Le(t,n)}}function rt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
8
8
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function D(t,n){return Ze(t)||et(t,n)||tt(t,n)||rt()}function en(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=tn(t))||n&&t&&typeof t.length=="number"){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(m){throw m},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
9
9
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,a=!1,c;return{s:function(){e=e.call(t)},n:function(){var m=e.next();return i=m.done,m},e:function(m){a=!0,c=m},f:function(){try{!i&&e.return!=null&&e.return()}finally{if(a)throw c}}}}function tn(t,n){if(t){if(typeof t=="string")return jt(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return jt(t,n)}}function jt(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function Dt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function It(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Dt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Dt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var rn=I()&&typeof document<"u",Ne=function(){return rn&&document.readyState==="complete"},nn={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},he=function(){function t(n){var e=this;if(g(this,t),s(this,"device",void 0),s(this,"id",void 0),s(this,"props",void 0),s(this,"canvas",void 0),s(this,"htmlCanvas",void 0),s(this,"offscreenCanvas",void 0),s(this,"type",void 0),s(this,"width",1),s(this,"height",1),s(this,"resizeObserver",void 0),s(this,"_canvasSizeInfo",{clientWidth:0,clientHeight:0,devicePixelRatio:1}),this.props=It(It({},nn),n),n=this.props,!I()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(n.canvas)typeof n.canvas=="string"?this.canvas=sn(n.canvas):this.canvas=n.canvas;else{var r,o,i=un(n),a=an(((r=n)===null||r===void 0?void 0:r.container)||null);a.insertBefore(i,a.firstChild),this.canvas=i,(o=n)!==null&&o!==void 0&&o.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&n.autoResize&&(this.resizeObserver=new ResizeObserver(function(c){var u=en(c),m;try{for(u.s();!(m=u.n()).done;){var y=m.value;y.target===e.canvas&&e.update()}}catch(O){u.e(O)}finally{u.f()}}),this.resizeObserver.observe(this.canvas))}return v(t,[{key:"getDevicePixelRatio",value:function(e){if(typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0))return 1;if(e===!0){var r=typeof window<"u"&&window.devicePixelRatio;return r||1}return e}},{key:"getPixelSize",value:function(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":var e=this.getDevicePixelRatio(),r=this.canvas;return r.parentElement?[r.clientWidth*e,r.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}},{key:"getAspect",value:function(){var e=this.getPixelSize(),r=D(e,2),o=r[0],i=r[1];return o/i}},{key:"cssToDeviceRatio",value:function(){try{var e=this.getDrawingBufferSize(),r=D(e,1),o=r[0],i=this._canvasSizeInfo.clientWidth;return i?o/i:1}catch{return 1}}},{key:"cssToDevicePixels",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,o=this.cssToDeviceRatio(),i=this.getDrawingBufferSize(),a=D(i,2),c=a[0],u=a[1];return cn(e,o,c,u,r)}},{key:"setDevicePixelRatio",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.htmlCanvas){var o="width"in r?r.width:this.htmlCanvas.clientWidth,i="height"in r?r.height:this.htmlCanvas.clientHeight;(!o||!i)&&(R.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,o=this.htmlCanvas.width||1,i=this.htmlCanvas.height||1);var a=this._canvasSizeInfo;if(a.clientWidth!==o||a.clientHeight!==i||a.devicePixelRatio!==e){var c=e,u=Math.floor(o*c),m=Math.floor(i*c);this.htmlCanvas.width=u,this.htmlCanvas.height=m;var y=this.getDrawingBufferSize(),O=D(y,2),S=O[0],C=O[1];(S!==u||C!==m)&&(c=Math.min(S/o,C/i),this.htmlCanvas.width=Math.floor(o*c),this.htmlCanvas.height=Math.floor(i*c),R.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=o,this._canvasSizeInfo.clientHeight=i,this._canvasSizeInfo.devicePixelRatio=e}}}},{key:"getDrawingBufferSize",value:function(){var e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}},{key:"_setAutoCreatedCanvasId",value:function(e){var r;((r=this.htmlCanvas)===null||r===void 0?void 0:r.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}}],[{key:"isPageLoaded",get:function(){return Ne()}}]),t}();s(he,"pageLoaded",on());function on(){return Ne()||typeof window>"u"?Promise.resolve():new Promise(function(t){window.addEventListener("load",function(){return t()})})}function an(t){if(typeof t=="string"){var n=document.getElementById(t);if(!n&&!Ne())throw new Error("Accessing '".concat(t,"' before page was loaded"));if(!n)throw new Error("".concat(t," is not an HTML element"));return n}else if(t)return t;return document.body}function sn(t){var n=document.getElementById(t);if(!n&&!Ne())throw new Error("Accessing '".concat(t,"' before page was loaded"));if(!(n instanceof HTMLCanvasElement))throw new Error("'".concat(n,"' is not a canvas element"));return n}function un(t){var n=t.width,e=t.height,r=document.createElement("canvas");return r.id="lumagl-auto-created-canvas",r.width=n||1,r.height=e||1,r.style.width=Number.isFinite(n)?"".concat(n,"px"):"100%",r.style.height=Number.isFinite(e)?"".concat(e,"px"):"100%",r}function cn(t,n,e,r,o){var i=t,a=Gt(i[0],n,e),c=Lt(i[1],n,r,o),u=Gt(i[0]+1,n,e),m=u===e-1?u:u-1;u=Lt(i[1]+1,n,r,o);var y;return o?(u=u===0?u:u+1,y=c,c=u):y=u===r-1?u:u-1,{x:a,y:c,width:Math.max(m-a+1,1),height:Math.max(y-c+1,1)}}function Gt(t,n,e){var r=Math.min(Math.round(t*n),e-1);return r}function Lt(t,n,e,r){return r?Math.max(0,e-1-Math.round(t*n)):Math.min(Math.round(t*n),e-1)}var Ut;function ln(t){var n=fn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function fn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Nt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Mt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Nt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Nt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var pn=Mt(Mt({},k),{},{data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,sampler:{},compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0});Ut=Symbol.toStringTag;var M=function(t){w(e,t);var n=ln(e);function e(r,o){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pn;return g(this,e),i=n.call(this,r,o,a),s(f(i),"dimension",void 0),s(f(i),"format",void 0),s(f(i),"width",void 0),s(f(i),"height",void 0),s(f(i),"depth",void 0),s(f(i),"sampler",void 0),i.dimension=i.props.dimension,i.format=i.props.format,i.width=i.props.width,i.height=i.props.height,i.depth=i.props.depth,i}return v(e,[{key:Ut,get:function(){return"Texture"}}]),e}(T);s(M,"COPY_SRC",1);s(M,"COPY_DST",2);s(M,"TEXTURE_BINDING",4);s(M,"STORAGE_BINDING",8);s(M,"RENDER_ATTACHMENT",16);function hn(t){var n=dn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function dn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ft(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function zt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Ft(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ft(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var mn=zt(zt({},k),{},{source:null,colorSpace:"srgb"}),nt=function(t,n){w(r,t);var e=hn(r);function r(o,i){return g(this,r),e.call(this,o,i,mn)}return v(r,[{key:n,get:function(){return"ExternalTexture"}}]),r}(T,Symbol.toStringTag);var Vt;function gn(t){var n=vn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function vn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Wt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Ht(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Wt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Wt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var yn=Ht(Ht({},k),{},{stage:"vertex",source:"",sourceMap:null,language:"glsl",shaderType:0});Vt=Symbol.toStringTag;var ot=function(t){w(e,t);var n=gn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,yn),s(f(i),"stage",void 0),s(f(i),"source",void 0),i.stage=i.props.stage,i.source=i.props.source,i}return v(e,[{key:Vt,get:function(){return"Shader"}}]),e}(T);function bn(t){var n=_n();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function _n(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function $t(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Yt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?$t(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):$t(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var wn=Yt(Yt({},k),{},{type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1}),Pe=function(t,n){w(r,t);var e=bn(r);function r(o,i){return g(this,r),e.call(this,o,i,wn)}return v(r,[{key:n,get:function(){return"Sampler"}}]),r}(T,Symbol.toStringTag);var qt;function Pn(t){var n=Sn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Sn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Kt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function de(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Kt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Kt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var On=de(de({},k),{},{width:1,height:1,colorAttachments:[],depthStencilAttachment:null});qt=Symbol.toStringTag;var it=function(t){w(e,t);var n=Pn(e);function e(r){var o,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return g(this,e),o=n.call(this,r,i,On),s(f(o),"width",void 0),s(f(o),"height",void 0),s(f(o),"colorAttachments",[]),s(f(o),"depthStencilAttachment",null),o.width=o.props.width,o.height=o.props.height,o}return v(e,[{key:qt,get:function(){return"Framebuffer"}},{key:"resize",value:function(o){var i=!o;if(o){var a=Array.isArray(o)?o:[o.width,o.height],c=D(a,2),u=c[0],m=c[1];i=i||m!==this.height||u!==this.width,this.width=u,this.height=m}i&&(R.log(2,"Resizing framebuffer ".concat(this.id," to ").concat(this.width,"x").concat(this.height))(),this.resizeAttachments(this.width,this.height))}},{key:"autoCreateAttachmentTextures",value:function(){var o=this;if(this.colorAttachments=this.props.colorAttachments.map(function(a){if(typeof a=="string"){var c=o.createColorTexture(a);return o.attachResource(c),c}return a}),this.props.depthStencilAttachment)if(typeof this.props.depthStencilAttachment=="string"){var i=this.createDepthStencilTexture(this.props.depthStencilAttachment);this.attachResource(i),this.depthStencilAttachment=i}else this.depthStencilAttachment=this.props.depthStencilAttachment}},{key:"createColorTexture",value:function(o){return this.device.createTexture({id:"color-attachment",usage:M.RENDER_ATTACHMENT,format:o,width:this.width,height:this.height})}},{key:"createDepthStencilTexture",value:function(o){return this.device.createTexture({id:"depth-stencil-attachment",usage:M.RENDER_ATTACHMENT,format:o,width:this.width,height:this.height})}},{key:"resizeAttachments",value:function(o,i){for(var a=0;a<this.colorAttachments.length;++a)if(this.colorAttachments[a]){var c=this.device._createTexture(de(de({},this.colorAttachments[a].props),{},{width:o,height:i}));this.destroyAttachedResource(this.colorAttachments[a]),this.colorAttachments[a]=c,this.attachResource(c)}if(this.depthStencilAttachment){var u=this.device._createTexture(de(de({},this.depthStencilAttachment.props),{},{width:o,height:i}));this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=u,this.attachResource(u)}}}]),e}(T);var Qt;function xn(t){var n=Rn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Rn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Xt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Jt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Xt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Xt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var Zt=Jt(Jt({},k),{},{vs:null,vsEntryPoint:"",vsConstants:{},fs:null,fsEntryPoint:"",fsConstants:{},layout:null,topology:"triangle-list",parameters:{},bufferMap:[],vertexCount:0,instanceCount:0,indices:null,attributes:{},bindings:{},uniforms:{}});Qt=Symbol.toStringTag;var Me=function(t){w(e,t);var n=xn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,Zt),s(f(i),"hash",""),s(f(i),"vs",void 0),s(f(i),"fs",void 0),i}return v(e,[{key:Qt,get:function(){return"RenderPipeline"}}]),e}(T);s(Me,"_DEFAULT_PROPS",Zt);var rr;function Cn(t){var n=En();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function En(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function er(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function tr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?er(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):er(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var Tn=tr(tr({},k),{},{csConstants:{},layout:[]});rr=Symbol.toStringTag;var at=function(t){w(e,t);var n=Cn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,Tn),s(f(i),"hash",""),i}return v(e,[{key:rr,get:function(){return"ComputePipeline"}}]),e}(T);var ir;function nr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function or(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?nr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):nr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function An(t){var n=kn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function kn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}ir=Symbol.toStringTag;var Ue=function(t){w(e,t);var n=An(e);function e(r,o){return g(this,e),n.call(this,r,o,e.defaultProps)}return v(e,[{key:ir,get:function(){return"RenderPass"}}]),e}(T);s(Ue,"defaultProps",or(or({},T.defaultProps),{},{framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1}));function Bn(t){var n=jn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function jn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var st=function(t,n){w(r,t);var e=Bn(r);function r(o,i){return g(this,r),e.call(this,o,i,k)}return v(r,[{key:n,get:function(){return"ComputePass"}}]),r}(T,Symbol.toStringTag);function sr(t){var n=ar[t],e=Dn(n),r=!t.startsWith("float"),o=t.includes("norm"),i=t.startsWith("s");return{dataType:ar[t],byteLength:e,integer:r,signed:i,normalized:o}}function Dn(t){var n=In[t];return n}var ar={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},In={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};function Se(t){var n=t.split("x"),e=D(n,2),r=e[0],o=e[1],i=r,a=o?parseInt(o):1,c=sr(i);return{type:i,components:a,byteLength:c.byteLength*a,integer:c.integer,signed:c.signed,normalized:c.normalized}}var ut=$e(Te(),1);function Gn(t){var n=Ln();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Ln(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Nn(t){var n;return t.byteLength||((n=t.data)===null||n===void 0?void 0:n.byteLength)||0}var Fe=function(t){w(e,t);var n=Gn(e);function e(r,o){var i;g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),s(f(i),"byteLength",void 0),i.device=r,i.byteLength=Nn(o);var a=Boolean(o.data);return i.handle=i.props.handle||i.device.handle.createBuffer({size:i.byteLength,usage:i.props.usage||GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:i.props.mappedAtCreation||a,label:i.props.id}),o.data&&i._writeMapped(o.data),a&&!o.mappedAtCreation&&i.handle.unmap(),i}return v(e,[{key:"destroy",value:function(){this.handle.destroy()}},{key:"write",value:function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.device.handle.queue.writeBuffer(this.handle,i,o.buffer,o.byteOffset,o.byteLength)}},{key:"readAsync",value:function(){var r=q(ut.default.mark(function i(){var a,c,u,m,y,O=arguments;return ut.default.wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return a=O.length>0&&O[0]!==void 0?O[0]:0,c=O.length>1&&O[1]!==void 0?O[1]:this.byteLength,u=new e(this.device,{usage:B.MAP_READ|B.COPY_DST,byteLength:c}),m=this.device.handle.createCommandEncoder(),m.copyBufferToBuffer(this.handle,a,u.handle,0,c),this.device.handle.queue.submit([m.finish()]),C.next=8,u.handle.mapAsync(GPUMapMode.READ,a,c);case 8:return y=u.handle.getMappedRange().slice(0),u.handle.unmap(),u.destroy(),C.abrupt("return",y);case 12:case"end":return C.stop()}},i,this)}));function o(){return r.apply(this,arguments)}return o}()},{key:"_writeMapped",value:function(o){var i=this.handle.getMappedRange();new o.constructor(i).set(o)}},{key:"mapAsync",value:function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2?arguments[2]:void 0;return this.handle.mapAsync(o,i,a)}},{key:"getMappedRange",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,i=arguments.length>1?arguments[1]:void 0;return this.handle.getMappedRange(o,i)}},{key:"unmap",value:function(){this.handle.unmap()}}]),e}(B);function me(t){if(t.includes("webgl"))throw new Error("webgl-only format");return t}function ur(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Mn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?ur(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):ur(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Un(t){var n=Fn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Fn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var W=function(t){w(e,t);var n=Un(e);function e(r,o){var i;g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),i.device=r;var a=Mn({},i.props);return a.type!=="comparison-sampler"&&delete a.compare,i.handle=i.handle||i.device.handle.createSampler(a),i.handle.label=i.props.id,i}return v(e,[{key:"destroy",value:function(){}}]),e}(Pe);function zn(t){var n=Wn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Wn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Hn={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},ze=function(t){w(e,t);var n=zn(e);function e(r,o){var i;if(g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),s(f(i),"view",void 0),s(f(i),"sampler",void 0),s(f(i),"height",void 0),s(f(i),"width",void 0),typeof i.props.format=="number")throw new Error("number format");return i.device=r,i.handle=i.props.handle||i.createHandle(),i.props.data&&i.setData({data:i.props.data}),i.width=i.handle.width,i.height=i.handle.height,i.sampler=o.sampler instanceof W?o.sampler:new W(i.device,o.sampler),i.view=i.handle.createView({}),i}return v(e,[{key:"createHandle",value:function(){var o,i;if(typeof this.props.format=="number")throw new Error("number format");var a=this.props.width||((o=this.props.data)===null||o===void 0?void 0:o.width)||1,c=this.props.height||((i=this.props.data)===null||i===void 0?void 0:i.height)||1;return this.device.handle.createTexture({size:{width:a,height:c,depthOrArrayLayers:this.props.depth},dimension:Hn[this.props.dimension],format:me(this.props.format),usage:this.props.usage,mipLevelCount:this.props.mipLevels,sampleCount:this.props.samples})}},{key:"destroy",value:function(){this.handle.destroy()}},{key:"setSampler",value:function(o){return this.sampler=o instanceof W?o:new W(this.device,o),this}},{key:"setData",value:function(o){return this.setImage({source:o.data})}},{key:"setImage",value:function(o){var i=o.source,a=o.width,c=a===void 0?o.source.width:a,u=o.height,m=u===void 0?o.source.height:u,y=o.depth,O=y===void 0?1:y,S=o.sourceX,C=S===void 0?0:S,E=o.sourceY,U=E===void 0?0:E,L=o.mipLevel,V=L===void 0?0:L,j=o.x,F=j===void 0?0:j,$=o.y,ve=$===void 0?0:$,Q=o.z,ye=Q===void 0?0:Q,K=o.aspect,re=K===void 0?"all":K,Z=o.colorSpace,Re=Z===void 0?"srgb":Z,h=o.premultipliedAlpha,l=h===void 0?!1:h;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[C,U]},{texture:this.handle,origin:[F,ve,ye],mipLevel:V,aspect:re,colorSpace:Re,premultipliedAlpha:l},[c,m,O]),{width:c,height:m}}}]),e}(M);function Vn(t){var n=$n();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function $n(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var cr=function(t){w(e,t);var n=Vn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),s(f(i),"sampler",void 0),i.device=r,i.handle=i.props.handle||i.device.handle.importExternalTexture({source:o.source,colorSpace:o.colorSpace}),i.sampler=null,i}return v(e,[{key:"destroy",value:function(){}},{key:"setSampler",value:function(o){return this.sampler=o instanceof W?o:new W(this.device,o),this}}]),e}(nt);var Oe=$e(Te(),1);function Yn(t){var n=Kn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Kn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var We=function(t){w(e,t);var n=Yn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),i.device=r,i.device.handle.pushErrorScope("validation"),i.handle=i.props.handle||i.createHandle(),i.handle.label=i.props.id,i._checkCompilationError(i.device.handle.popErrorScope()),i}return v(e,[{key:"_checkCompilationError",value:function(){var r=q(Oe.default.mark(function i(a){var c,u;return Oe.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,a;case 2:if(c=y.sent,!c){y.next=9;break}return y.next=6,this.compilationInfo();case 6:throw u=y.sent,R.error("Shader compilation error: ".concat(c.message),u)(),new Error("Shader compilation error: ".concat(c.message));case 9:case"end":return y.stop()}},i,this)}));function o(i){return r.apply(this,arguments)}return o}()},{key:"destroy",value:function(){}},{key:"createHandle",value:function(){var o=this,i=this.props,a=i.source,c=i.stage,u=this.props.language;switch(u||(u=a.includes("->")?"wgsl":"glsl"),u){case"wgsl":return this.device.handle.createShaderModule({code:a});case"glsl":return this.device.handle.createShaderModule({code:a,transform:function(y){return o.device.glslang.compileGLSL(y,c)}});default:throw new Error(u)}}},{key:"compilationInfo",value:function(){var r=q(Oe.default.mark(function i(){var a;return Oe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.handle.getCompilationInfo();case 2:return a=u.sent,u.abrupt("return",a.messages);case 4:case"end":return u.stop()}},i,this)}));function o(){return r.apply(this,arguments)}return o}()}]),e}(ot);function lr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function fr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?lr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):lr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function H(t){return t.depthStencil=t.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:void 0,depthCompare:void 0},t.depthStencil}var qn={cullMode:function(n,e,r){r.primitive=r.primitive||{},r.primitive.cullMode=e},frontFace:function(n,e,r){r.primitive=r.primitive||{},r.primitive.frontFace=e},depthWriteEnabled:function(n,e,r){var o=H(r);o.depthWriteEnabled=e},depthCompare:function(n,e,r){var o=H(r);o.depthCompare=e},depthFormat:function(n,e,r){var o=H(r);o.format=e},depthBias:function(n,e,r){var o=H(r);o.depthBias=e},depthBiasSlopeScale:function(n,e,r){var o=H(r);o.depthBiasSlopeScale=e},depthBiasClamp:function(n,e,r){var o=H(r);o.depthBiasClamp=e},stencilReadMask:function(n,e,r){var o=H(r);o.stencilReadMask=e},stencilWriteMask:function(n,e,r){var o=H(r);o.stencilWriteMask=e},stencilCompare:function(n,e,r){var o=H(r);o.stencilFront.compare=e,o.stencilBack.compare=e},stencilPassOperation:function(n,e,r){var o=H(r);o.stencilFront.passOp=e,o.stencilBack.passOp=e},stencilFailOperation:function(n,e,r){var o=H(r);o.stencilFront.failOp=e,o.stencilBack.failOp=e},stencilDepthFailOperation:function(n,e,r){var o=H(r);o.stencilFront.depthFailOp=e,o.stencilBack.depthFailOp=e},sampleCount:function(n,e,r){r.multisample=r.multisample||{},r.multisample.count=e},sampleMask:function(n,e,r){r.multisample=r.multisample||{},r.multisample.mask=e},sampleAlphaToCoverageEnabled:function(n,e,r){r.multisample=r.multisample||{},r.multisample.alphaToCoverageEnabled=e},colorMask:function(n,e,r){var o=pr(r);o[0].writeMask=e},blendColorOperation:function(n,e,r){pr(r)}},Xn={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function hr(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Object.assign(t,fr(fr({},Xn),t)),Jn(t,n)}function Jn(t,n){for(var e=0,r=Object.entries(n);e<r.length;e++){var o=D(r[e],2),i=o[0],a=o[1],c=qn[i];if(!c)throw new Error("Illegal parameter ".concat(i));c(i,a,t)}}function pr(t){var n,e,r,o;if(t.fragment.targets=((n=t.fragment)===null||n===void 0?void 0:n.targets)||[],!Array.isArray((e=t.fragment)===null||e===void 0?void 0:e.targets))throw new Error("colorstate");if(((r=t.fragment)===null||r===void 0||(r=r.targets)===null||r===void 0?void 0:r.length)===0){var i;(i=t.fragment.targets)===null||i===void 0||i.push({})}return(o=t.fragment)===null||o===void 0?void 0:o.targets}function dr(t,n,e,r){var o=Zn(r,e);return t.createBindGroup({layout:n,entries:o})}function Qn(t,n){var e=t.bindings.find(function(r){return r.name===n});return e||R.warn("Binding ".concat(n," not set: Not found in shader layout."))(),e}function Zn(t,n){for(var e=[],r=0,o=Object.entries(t);r<o.length;r++){var i=D(o[r],2),a=i[0],c=i[1],u=Qn(n,a);u&&e.push(eo(c,u.location))}return e}function eo(t,n){if(t instanceof B)return{binding:n,resource:{buffer:t.handle}};if(t instanceof Pe)return{binding:n,resource:t.handle};if(t instanceof M)return{binding:n,resource:t.handle.createView()};throw new Error("invalid binding")}function ge(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=to(t))||n&&t&&typeof t.length=="number"){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(m){throw m},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
10
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,a=!1,c;return{s:function(){e=e.call(t)},n:function(){var m=e.next();return i=m.done,m},e:function(m){a=!0,c=m},f:function(){try{!i&&e.return!=null&&e.return()}finally{if(a)throw c}}}}function to(t,n){if(t){if(typeof t=="string")return mr(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return mr(t,n)}}function mr(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function vr(t,n){var e=[],r=new Set,o=ge(n),i;try{for(o.s();!(i=o.n()).done;){var a=i.value,c=[],u="vertex",m=0,y=a.byteOffset||0;if("attributes"in a){var O=ge(a.attributes),S;try{for(O.s();!(S=O.n()).done;){var C=S.value,E=gr(t,C.name,r);u=E.stepMode||"vertex",c.push({format:E.format,offset:y+m,shaderLocation:E.location}),m+=Se(E.format).byteLength}}catch(F){O.e(F)}finally{O.f()}}else{var U=gr(t,a.name,r);m=Se(U.format).byteLength,u=U.stepMode||"vertex",c.push({format:U.format,offset:y,shaderLocation:U.location})}e.push({arrayStride:a.byteStride||m,stepMode:u||"vertex",attributes:c})}}catch(F){o.e(F)}finally{o.f()}var L=ge(t.attributes),V;try{for(L.s();!(V=L.n()).done;){var j=V.value;r.has(j.name)||e.push({arrayStride:Se(j.format).byteLength,stepMode:j.stepMode||"vertex",attributes:[{format:j.format,offset:0,shaderLocation:j.location}]})}}catch(F){L.e(F)}finally{L.f()}return e}function yr(t,n){var e=new Set,r=0,o={},i=ge(n),a;try{for(i.s();!(a=i.n()).done;){var c=a.value;if("attributes"in c){var u=ge(c.attributes),m;try{for(u.s();!(m=u.n()).done;){var y=m.value;e.add(y.name)}}catch(E){u.e(E)}finally{u.f()}}else e.add(c.name);o[c.name]=r++}}catch(E){i.e(E)}finally{i.f()}var O=ge(t.attributes),S;try{for(O.s();!(S=O.n()).done;){var C=S.value;e.has(C.name)||(o[C.name]=r++)}}catch(E){O.e(E)}finally{O.f()}return o}function gr(t,n,e){var r=t.attributes.find(function(o){return o.name===n});if(!r)throw new Error("Unknown attribute ".concat(n));if(e.has(n))throw new Error("Duplicate attribute ".concat(n));return e.add(n),r}function ro(t){var n=no();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function no(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var br=function(t){w(e,t);var n=ro(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),s(f(i),"vs",void 0),s(f(i),"fs",null),s(f(i),"_bufferSlots",void 0),s(f(i),"_buffers",void 0),s(f(i),"_indexBuffer",null),s(f(i),"_bindGroupLayout",void 0),s(f(i),"_bindGroup",null),i.device=r,i.handle=i.props.handle||i.createHandle(),i.handle.label=i.props.id,i.vs=o.vs,i.fs=o.fs,i._bufferSlots=yr(i.props.layout,i.props.bufferMap),i._buffers=new Array(Object.keys(i._bufferSlots).length).fill(null),i._bindGroupLayout=i.handle.getBindGroupLayout(0),i}return v(e,[{key:"createHandle",value:function(){var o=this._getRenderPipelineDescriptor(),i=this.device.handle.createRenderPipeline(o);return R.groupCollapsed(1,"new WebGPRenderPipeline(".concat(this.id,")"))(),R.log(1,JSON.stringify(o,null,2))(),R.groupEnd(1)(),i}},{key:"destroy",value:function(){}},{key:"setIndexBuffer",value:function(o){this._indexBuffer=o}},{key:"setAttributes",value:function(o){for(var i=0,a=Object.entries(o);i<a.length;i++){var c=D(a[i],2),u=c[0],m=c[1],y=this._bufferSlots[u];if(y>=0)this._buffers[y]=m;else throw new Error("Setting attribute '".concat(u,"' not listed in shader layout for program ").concat(this.id))}}},{key:"setBindings",value:function(o){Ie(this.props.bindings)||(Object.assign(this.props.bindings,o),this._bindGroup=dr(this.device.handle,this._bindGroupLayout,this.props.layout,this.props.bindings))}},{key:"setUniforms",value:function(o){if(!Ie(o))throw new Error("WebGPU does not support uniforms")}},{key:"_getBuffers",value:function(){return this._buffers}},{key:"_getBindGroup",value:function(){return this._bindGroup}},{key:"_getRenderPipelineDescriptor",value:function(){var o={module:this.props.vs.handle,entryPoint:this.props.vsEntryPoint||"main",buffers:vr(this.props.layout,this.props.bufferMap)},i;if(this.props.fs){var a;i={module:this.props.fs.handle,entryPoint:this.props.fsEntryPoint||"main",targets:[{format:me((a=this.device)===null||a===void 0||(a=a.canvasContext)===null||a===void 0?void 0:a.format)}]}}switch(this.props.topology){case"triangle-fan":case"line-loop":throw new Error("WebGPU does not support primitive topology ".concat(this.props.topology));default:}var c={vertex:o,fragment:i,primitive:{topology:this.props.topology},layout:"auto"};return hr(c,this.props.parameters),c}},{key:"draw",value:function(o){var i=o.renderPass||this.device.getDefaultRenderPass();i.handle.setPipeline(this.handle);var a=this._getBindGroup();a&&i.handle.setBindGroup(0,a),this._setAttributeBuffers(i),o.indexCount?i.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):i.handle.draw(o.vertexCount||0,o.instanceCount,o.firstIndex,o.firstInstance)}},{key:"_setAttributeBuffers",value:function(o){var i=this;this._indexBuffer&&o.handle.setIndexBuffer(this._indexBuffer.handle,this._indexBuffer.props.indexType);for(var a=this._getBuffers(),c=function(y){var O=a[y];if(!O){var S=i.props.layout.attributes.find(function(C){return C.location===y});throw new Error("No buffer provided for attribute '".concat(S?.name||"","' in Model '").concat(i.props.id,"'"))}o.handle.setVertexBuffer(y,O.handle)},u=0;u<a.length;++u)c(u)}}]),e}(Me);function oo(t){var n=io();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function io(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var _r=function(t){w(e,t);var n=oo(e);function e(r,o){var i;g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),i.device=r;var a=i.props.cs.handle;return i.handle=i.props.handle||i.device.handle.createComputePipeline({label:i.props.id,compute:{module:a,entryPoint:i.props.csEntryPoint},layout:"auto"}),i}return v(e,[{key:"_getBindGroupLayout",value:function(){return this.handle.getBindGroupLayout(0)}}]),e}(at);function wr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Pr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?wr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):wr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function ao(t){var n=so();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function so(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Sr=function(t){w(e,t);var n=ao(e);function e(r){var o,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};g(this,e),o=n.call(this,r,i),s(f(o),"device",void 0),s(f(o),"handle",void 0),s(f(o),"pipeline",null),o.device=r;var a=i.framebuffer||r.canvasContext.getCurrentFramebuffer(),c=o.getRenderPassDescriptor(a);return o.handle=o.props.handle||r.commandEncoder.beginRenderPass(c),o.handle.label=o.props.id,o}return v(e,[{key:"destroy",value:function(){}},{key:"end",value:function(){this.handle.end()}},{key:"setPipeline",value:function(o){this.pipeline=o,this.handle.setPipeline(this.pipeline.handle)}},{key:"setBindings",value:function(o){var i,a;(i=this.pipeline)===null||i===void 0||i.setBindings(o);var c=(a=this.pipeline)===null||a===void 0?void 0:a._getBindGroup();c&&this.handle.setBindGroup(0,c)}},{key:"setIndexBuffer",value:function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,c=arguments.length>3?arguments[3]:void 0;this.handle.setIndexBuffer(o.handle,i,a,c)}},{key:"setVertexBuffer",value:function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;this.handle.setVertexBuffer(o,i.handle,a)}},{key:"draw",value:function(o){o.indexCount?this.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):this.handle.draw(o.vertexCount||0,o.instanceCount,o.firstIndex,o.firstInstance)}},{key:"drawIndirect",value:function(){}},{key:"setParameters",value:function(o){var i=o.blendConstant,a=o.stencilReference,c=o.scissorRect,u=o.viewport;i&&this.handle.setBlendConstant(i),a&&this.handle.setStencilReference(a),c&&this.handle.setScissorRect(c[0],c[1],c[2],c[3]),u&&this.handle.setViewport(u[0],u[1],u[2],u[3],u[4],u[5])}},{key:"pushDebugGroup",value:function(o){this.handle.pushDebugGroup(o)}},{key:"popDebugGroup",value:function(){this.handle.popDebugGroup()}},{key:"insertDebugMarker",value:function(o){this.handle.insertDebugMarker(o)}},{key:"getRenderPassDescriptor",value:function(o){var i=this,a={colorAttachments:[]};return a.colorAttachments=o.colorAttachments.map(function(c){return{loadOp:"clear",colorClearValue:i.props.clearColor||[0,0,0,0],storeOp:i.props.discard?"discard":"store",view:c.handle.createView()}}),o.depthStencilAttachment&&(a.depthStencilAttachment=Pr(Pr({},this.props),{},{view:o.depthStencilAttachment.handle.createView()})),a}}]),e}(Ue);function uo(t){var n=co();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function co(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Or=function(t){w(e,t);var n=uo(e);function e(r,o){var i,a;return g(this,e),a=n.call(this,r,o),s(f(a),"device",void 0),s(f(a),"handle",void 0),s(f(a),"_bindGroupLayout",null),a.device=r,a.handle=a.props.handle||((i=r.commandEncoder)===null||i===void 0?void 0:i.beginComputePass({label:a.props.id})),a}return v(e,[{key:"destroy",value:function(){}},{key:"end",value:function(){this.handle.end()}},{key:"setPipeline",value:function(o){var i=o;this.handle.setPipeline(i.handle),this._bindGroupLayout=i._getBindGroupLayout()}},{key:"setBindings",value:function(o){throw new Error("fix me")}},{key:"dispatch",value:function(o,i,a){this.handle.dispatchWorkgroups(o,i,a)}},{key:"dispatchIndirect",value:function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.handle.dispatchWorkgroupsIndirect(o.handle,i)}},{key:"pushDebugGroup",value:function(o){this.handle.pushDebugGroup(o)}},{key:"popDebugGroup",value:function(){this.handle.popDebugGroup()}},{key:"insertDebugMarker",value:function(o){this.handle.insertDebugMarker(o)}}]),e}(st);function lo(t){var n=fo();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function fo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var xr=function(t){w(e,t);var n=lo(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),i.device=r,i.autoCreateAttachmentTextures(),i}return v(e)}(it);function po(t){var n=ho();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function ho(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ct=function(t){w(e,t);var n=po(e);function e(r,o,i){var a;return g(this,e),a=n.call(this,i),s(f(a),"device",void 0),s(f(a),"gpuCanvasContext",void 0),s(f(a),"format",void 0),s(f(a),"depthStencilFormat","depth24plus"),s(f(a),"sampleCount",1),s(f(a),"depthStencilAttachment",null),a.device=r,a.width=-1,a.height=-1,a._setAutoCreatedCanvasId("".concat(a.device.id,"-canvas")),a.gpuCanvasContext=a.canvas.getContext("webgpu"),a.format=a.gpuCanvasContext.getPreferredFormat(o),a}return v(e,[{key:"destroy",value:function(){this.gpuCanvasContext.unconfigure()}},{key:"getCurrentFramebuffer",value:function(){this.update();var o=this.device.createTexture({id:"default-render-target",handle:this.gpuCanvasContext.getCurrentTexture(),format:this.format,width:this.width,height:this.height});return this._createDepthStencilAttachment(),new xr(this.device,{colorAttachments:[o],depthStencilAttachment:this.depthStencilAttachment})}},{key:"update",value:function(){var o=this.getPixelSize(),i=D(o,2),a=i[0],c=i[1],u=a!==this.width||c!==this.height;u&&(this.width=a,this.height=c,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:me(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),R.log(1,"Resized to ".concat(this.width,"x").concat(this.height,"px"))())}},{key:"resize",value:function(o){this.update()}},{key:"_createDepthStencilAttachment",value:function(){return this.depthStencilAttachment||(this.depthStencilAttachment=this.device.createTexture({id:"depth-stencil-target",format:this.depthStencilFormat,width:this.width,height:this.height,usage:GPUTextureUsage.RENDER_ATTACHMENT})),this.depthStencilAttachment}}]),e}(he);function Rr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Cr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Rr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Rr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function mo(t){var n=go();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function go(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var lt=function(t){w(e,t);var n=mo(e);function e(r,o,i){var a;return g(this,e),a=n.call(this,Cr(Cr({},i),{},{id:i.id||ue("webgpu-device")})),s(f(a),"handle",void 0),s(f(a),"adapter",void 0),s(f(a),"lost",void 0),s(f(a),"canvasContext",null),s(f(a),"commandEncoder",null),s(f(a),"renderPass",null),s(f(a),"_info",void 0),s(f(a),"_isLost",!1),s(f(a),"features",void 0),a.handle=r,a.adapter=o,a._info={type:"webgpu",vendor:a.adapter.__brand,renderer:"",version:"",gpu:"unknown",shadingLanguages:["glsl","wgsl"],shadingLanguageVersions:{glsl:"450",wgsl:"100"},vendorMasked:"",rendererMasked:""},a.lost=new Promise(function(){var c=q(xe.default.mark(function u(m){var y;return xe.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,a.handle.lost;case 2:y=S.sent,a._isLost=!0,m({reason:"destroyed",message:y.message});case 5:case"end":return S.stop()}},u)}));return function(u){return c.apply(this,arguments)}}()),i.canvas&&(a.canvasContext=new ct(f(a),a.adapter,{canvas:i.canvas})),a.features=a._getFeatures(),a}return v(e,[{key:"destroy",value:function(){this.handle.destroy()}},{key:"info",get:function(){return this._info}},{key:"limits",get:function(){return this.handle.limits}},{key:"isTextureFormatSupported",value:function(o){return!o.includes("webgl")}},{key:"isTextureFormatFilterable",value:function(o){return this.isTextureFormatSupported(o)}},{key:"isTextureFormatRenderable",value:function(o){return this.isTextureFormatSupported(o)}},{key:"isLost",get:function(){return this._isLost}},{key:"createBuffer",value:function(o){var i=this._getBufferProps(o);return new Fe(this,i)}},{key:"_createTexture",value:function(o){return new ze(this,o)}},{key:"createExternalTexture",value:function(o){return new cr(this,o)}},{key:"createShader",value:function(o){return new We(this,o)}},{key:"createSampler",value:function(o){return new W(this,o)}},{key:"createRenderPipeline",value:function(o){return new br(this,o)}},{key:"createFramebuffer",value:function(o){throw new Error("Not implemented")}},{key:"createComputePipeline",value:function(o){return new _r(this,o)}},{key:"beginRenderPass",value:function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Sr(this,o)}},{key:"beginComputePass",value:function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Or(this,o)}},{key:"createCanvasContext",value:function(o){return new ct(this,this.adapter,o)}},{key:"getDefaultRenderPass",value:function(){var o;return this.renderPass=this.renderPass||this.beginRenderPass({framebuffer:(o=this.canvasContext)===null||o===void 0?void 0:o.getCurrentFramebuffer()}),this.renderPass}},{key:"submit",value:function(){var o,i;(o=this.renderPass)===null||o===void 0||o.end();var a=(i=this.commandEncoder)===null||i===void 0?void 0:i.finish();a&&this.handle.queue.submit([a]),this.commandEncoder=null,this.renderPass=null}},{key:"_getFeatures",value:function(){var o=new Set(this.handle.features);return o.has("depth-clamping")&&(o.delete("depth-clamping"),o.add("depth-clip-control")),o.has("texture-compression-bc")&&o.add("texture-compression-bc5-webgl"),o.add("webgpu"),o.add("timer-query-webgl"),o.add("vertex-array-object-webgl1"),o.add("instanced-rendering-webgl1"),o.add("multiple-render-targets-webgl1"),o.add("index-uint32-webgl1"),o.add("blend-minmax-webgl1"),o.add("texture-blend-float-webgl1"),o.add("texture-formats-srgb-webgl1"),o.add("texture-formats-depth-webgl1"),o.add("texture-formats-float32-webgl1"),o.add("texture-formats-float16-webgl1"),o.add("texture-filter-linear-float32-webgl"),o.add("texture-filter-linear-float16-webgl"),o.add("texture-filter-anisotropic-webgl"),o.add("texture-renderable-rgba32float-webgl"),o.add("texture-renderable-float32-webgl"),o.add("texture-renderable-float16-webgl"),o.add("glsl-frag-data"),o.add("glsl-frag-depth"),o.add("glsl-derivatives"),o.add("glsl-texture-lod"),o}},{key:"copyExternalImageToTexture",value:function(o){var i,a=o.source,c=o.sourceX,u=c===void 0?0:c,m=o.sourceY,y=m===void 0?0:m,O=o.texture,S=o.mipLevel,C=S===void 0?0:S,E=o.aspect,U=E===void 0?"all":E,L=o.colorSpace,V=L===void 0?"display-p3":L,j=o.premultipliedAlpha,F=j===void 0?!1:j,$=o.width,ve=$===void 0?O.width:$,Q=o.height,ye=Q===void 0?O.height:Q,K=o.depth,re=K===void 0?1:K,Z=O;(i=this.handle)===null||i===void 0||i.queue.copyExternalImageToTexture({source:a,origin:[u,y]},{texture:Z.handle,origin:[0,0,0],mipLevel:C,aspect:U,colorSpace:V,premultipliedAlpha:F},[ve,ye,re])}}],[{key:"isSupported",value:function(){return Boolean(typeof navigator<"u"&&navigator.gpu)}},{key:"create",value:function(){var r=q(xe.default.mark(function i(a){var c,u,m,y;return xe.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(navigator.gpu){S.next=2;break}throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");case 2:return R.groupCollapsed(1,"WebGPUDevice created")(),S.next=5,navigator.gpu.requestAdapter({powerPreference:"high-performance"});case 5:if(c=S.sent,c){S.next=8;break}throw new Error("Failed to request WebGPU adapter");case 8:return S.next=10,c.requestAdapterInfo();case 10:return u=S.sent,R.probe(1,"Adapter available",u)(),S.next=14,c.requestDevice({requiredFeatures:c.features});case 14:if(m=S.sent,R.probe(1,"GPUDevice available")(),typeof a.canvas!="string"){S.next=20;break}return S.next=19,he.pageLoaded;case 19:R.probe(1,"DOM is loaded")();case 20:return y=new e(m,c,a),R.probe(1,"Device created",y.info)(),R.table(1,y.info)(),R.groupEnd(1)(),S.abrupt("return",y);case 25:case"end":return S.stop()}},i)}));function o(i){return r.apply(this,arguments)}return o}()}]),e}(Ge);s(lt,"type","webgpu");return Dr(vo);})();
10
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,a=!1,c;return{s:function(){e=e.call(t)},n:function(){var m=e.next();return i=m.done,m},e:function(m){a=!0,c=m},f:function(){try{!i&&e.return!=null&&e.return()}finally{if(a)throw c}}}}function to(t,n){if(t){if(typeof t=="string")return mr(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return mr(t,n)}}function mr(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function vr(t,n){var e=[],r=new Set,o=ge(n),i;try{for(o.s();!(i=o.n()).done;){var a=i.value,c=[],u="vertex",m=0,y=a.byteOffset||0;if("attributes"in a){var O=ge(a.attributes),S;try{for(O.s();!(S=O.n()).done;){var C=S.value,E=gr(t,C.name,r);u=E.stepMode||"vertex",c.push({format:E.format,offset:y+m,shaderLocation:E.location}),m+=Se(E.format).byteLength}}catch(F){O.e(F)}finally{O.f()}}else{var U=gr(t,a.name,r);m=Se(U.format).byteLength,u=U.stepMode||"vertex",c.push({format:U.format,offset:y,shaderLocation:U.location})}e.push({arrayStride:a.byteStride||m,stepMode:u||"vertex",attributes:c})}}catch(F){o.e(F)}finally{o.f()}var L=ge(t.attributes),V;try{for(L.s();!(V=L.n()).done;){var j=V.value;r.has(j.name)||e.push({arrayStride:Se(j.format).byteLength,stepMode:j.stepMode||"vertex",attributes:[{format:j.format,offset:0,shaderLocation:j.location}]})}}catch(F){L.e(F)}finally{L.f()}return e}function yr(t,n){var e=new Set,r=0,o={},i=ge(n),a;try{for(i.s();!(a=i.n()).done;){var c=a.value;if("attributes"in c){var u=ge(c.attributes),m;try{for(u.s();!(m=u.n()).done;){var y=m.value;e.add(y.name)}}catch(E){u.e(E)}finally{u.f()}}else e.add(c.name);o[c.name]=r++}}catch(E){i.e(E)}finally{i.f()}var O=ge(t.attributes),S;try{for(O.s();!(S=O.n()).done;){var C=S.value;e.has(C.name)||(o[C.name]=r++)}}catch(E){O.e(E)}finally{O.f()}return o}function gr(t,n,e){var r=t.attributes.find(function(o){return o.name===n});if(!r)throw new Error("Unknown attribute ".concat(n));if(e.has(n))throw new Error("Duplicate attribute ".concat(n));return e.add(n),r}function ro(t){var n=no();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function no(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var br=function(t){w(e,t);var n=ro(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),s(f(i),"vs",void 0),s(f(i),"fs",null),s(f(i),"_bufferSlots",void 0),s(f(i),"_buffers",void 0),s(f(i),"_indexBuffer",null),s(f(i),"_bindGroupLayout",void 0),s(f(i),"_bindGroup",null),i.device=r,i.handle=i.props.handle||i.createHandle(),i.handle.label=i.props.id,i.vs=o.vs,i.fs=o.fs,i._bufferSlots=yr(i.props.layout,i.props.bufferMap),i._buffers=new Array(Object.keys(i._bufferSlots).length).fill(null),i._bindGroupLayout=i.handle.getBindGroupLayout(0),i}return v(e,[{key:"createHandle",value:function(){var o=this._getRenderPipelineDescriptor(),i=this.device.handle.createRenderPipeline(o);return R.groupCollapsed(1,"new WebGPRenderPipeline(".concat(this.id,")"))(),R.log(1,JSON.stringify(o,null,2))(),R.groupEnd(1)(),i}},{key:"destroy",value:function(){}},{key:"setIndexBuffer",value:function(o){this._indexBuffer=o}},{key:"setAttributes",value:function(o){for(var i=0,a=Object.entries(o);i<a.length;i++){var c=D(a[i],2),u=c[0],m=c[1],y=this._bufferSlots[u];if(y>=0)this._buffers[y]=m;else throw new Error("Setting attribute '".concat(u,"' not listed in shader layout for program ").concat(this.id))}}},{key:"setConstantAttributes",value:function(o){console.error("not implemented")}},{key:"setBindings",value:function(o){Ie(this.props.bindings)||(Object.assign(this.props.bindings,o),this._bindGroup=dr(this.device.handle,this._bindGroupLayout,this.props.layout,this.props.bindings))}},{key:"setUniforms",value:function(o){if(!Ie(o))throw new Error("WebGPU does not support uniforms")}},{key:"_getBuffers",value:function(){return this._buffers}},{key:"_getBindGroup",value:function(){return this._bindGroup}},{key:"_getRenderPipelineDescriptor",value:function(){var o={module:this.props.vs.handle,entryPoint:this.props.vsEntryPoint||"main",buffers:vr(this.props.layout,this.props.bufferMap)},i;if(this.props.fs){var a;i={module:this.props.fs.handle,entryPoint:this.props.fsEntryPoint||"main",targets:[{format:me((a=this.device)===null||a===void 0||(a=a.canvasContext)===null||a===void 0?void 0:a.format)}]}}switch(this.props.topology){case"triangle-fan":case"line-loop":throw new Error("WebGPU does not support primitive topology ".concat(this.props.topology));default:}var c={vertex:o,fragment:i,primitive:{topology:this.props.topology},layout:"auto"};return hr(c,this.props.parameters),c}},{key:"draw",value:function(o){var i=o.renderPass||this.device.getDefaultRenderPass();i.handle.setPipeline(this.handle);var a=this._getBindGroup();a&&i.handle.setBindGroup(0,a),this._setAttributeBuffers(i),o.indexCount?i.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):i.handle.draw(o.vertexCount||0,o.instanceCount,o.firstIndex,o.firstInstance)}},{key:"_setAttributeBuffers",value:function(o){var i=this;this._indexBuffer&&o.handle.setIndexBuffer(this._indexBuffer.handle,this._indexBuffer.props.indexType);for(var a=this._getBuffers(),c=function(y){var O=a[y];if(!O){var S=i.props.layout.attributes.find(function(C){return C.location===y});throw new Error("No buffer provided for attribute '".concat(S?.name||"","' in Model '").concat(i.props.id,"'"))}o.handle.setVertexBuffer(y,O.handle)},u=0;u<a.length;++u)c(u)}}]),e}(Me);function oo(t){var n=io();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function io(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var _r=function(t){w(e,t);var n=oo(e);function e(r,o){var i;g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),i.device=r;var a=i.props.cs.handle;return i.handle=i.props.handle||i.device.handle.createComputePipeline({label:i.props.id,compute:{module:a,entryPoint:i.props.csEntryPoint},layout:"auto"}),i}return v(e,[{key:"_getBindGroupLayout",value:function(){return this.handle.getBindGroupLayout(0)}}]),e}(at);function wr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Pr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?wr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):wr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function ao(t){var n=so();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function so(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Sr=function(t){w(e,t);var n=ao(e);function e(r){var o,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};g(this,e),o=n.call(this,r,i),s(f(o),"device",void 0),s(f(o),"handle",void 0),s(f(o),"pipeline",null),o.device=r;var a=i.framebuffer||r.canvasContext.getCurrentFramebuffer(),c=o.getRenderPassDescriptor(a);return o.handle=o.props.handle||r.commandEncoder.beginRenderPass(c),o.handle.label=o.props.id,o}return v(e,[{key:"destroy",value:function(){}},{key:"end",value:function(){this.handle.end()}},{key:"setPipeline",value:function(o){this.pipeline=o,this.handle.setPipeline(this.pipeline.handle)}},{key:"setBindings",value:function(o){var i,a;(i=this.pipeline)===null||i===void 0||i.setBindings(o);var c=(a=this.pipeline)===null||a===void 0?void 0:a._getBindGroup();c&&this.handle.setBindGroup(0,c)}},{key:"setIndexBuffer",value:function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,c=arguments.length>3?arguments[3]:void 0;this.handle.setIndexBuffer(o.handle,i,a,c)}},{key:"setVertexBuffer",value:function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;this.handle.setVertexBuffer(o,i.handle,a)}},{key:"draw",value:function(o){o.indexCount?this.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):this.handle.draw(o.vertexCount||0,o.instanceCount,o.firstIndex,o.firstInstance)}},{key:"drawIndirect",value:function(){}},{key:"setParameters",value:function(o){var i=o.blendConstant,a=o.stencilReference,c=o.scissorRect,u=o.viewport;i&&this.handle.setBlendConstant(i),a&&this.handle.setStencilReference(a),c&&this.handle.setScissorRect(c[0],c[1],c[2],c[3]),u&&this.handle.setViewport(u[0],u[1],u[2],u[3],u[4],u[5])}},{key:"pushDebugGroup",value:function(o){this.handle.pushDebugGroup(o)}},{key:"popDebugGroup",value:function(){this.handle.popDebugGroup()}},{key:"insertDebugMarker",value:function(o){this.handle.insertDebugMarker(o)}},{key:"getRenderPassDescriptor",value:function(o){var i=this,a={colorAttachments:[]};return a.colorAttachments=o.colorAttachments.map(function(c){return{loadOp:"clear",colorClearValue:i.props.clearColor||[0,0,0,0],storeOp:i.props.discard?"discard":"store",view:c.handle.createView()}}),o.depthStencilAttachment&&(a.depthStencilAttachment=Pr(Pr({},this.props),{},{view:o.depthStencilAttachment.handle.createView()})),a}}]),e}(Ue);function uo(t){var n=co();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function co(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Or=function(t){w(e,t);var n=uo(e);function e(r,o){var i,a;return g(this,e),a=n.call(this,r,o),s(f(a),"device",void 0),s(f(a),"handle",void 0),s(f(a),"_bindGroupLayout",null),a.device=r,a.handle=a.props.handle||((i=r.commandEncoder)===null||i===void 0?void 0:i.beginComputePass({label:a.props.id})),a}return v(e,[{key:"destroy",value:function(){}},{key:"end",value:function(){this.handle.end()}},{key:"setPipeline",value:function(o){var i=o;this.handle.setPipeline(i.handle),this._bindGroupLayout=i._getBindGroupLayout()}},{key:"setBindings",value:function(o){throw new Error("fix me")}},{key:"dispatch",value:function(o,i,a){this.handle.dispatchWorkgroups(o,i,a)}},{key:"dispatchIndirect",value:function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.handle.dispatchWorkgroupsIndirect(o.handle,i)}},{key:"pushDebugGroup",value:function(o){this.handle.pushDebugGroup(o)}},{key:"popDebugGroup",value:function(){this.handle.popDebugGroup()}},{key:"insertDebugMarker",value:function(o){this.handle.insertDebugMarker(o)}}]),e}(st);function lo(t){var n=fo();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function fo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var xr=function(t){w(e,t);var n=lo(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),i.device=r,i.autoCreateAttachmentTextures(),i}return v(e)}(it);function po(t){var n=ho();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function ho(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ct=function(t){w(e,t);var n=po(e);function e(r,o,i){var a;return g(this,e),a=n.call(this,i),s(f(a),"device",void 0),s(f(a),"gpuCanvasContext",void 0),s(f(a),"format",void 0),s(f(a),"depthStencilFormat","depth24plus"),s(f(a),"sampleCount",1),s(f(a),"depthStencilAttachment",null),a.device=r,a.width=-1,a.height=-1,a._setAutoCreatedCanvasId("".concat(a.device.id,"-canvas")),a.gpuCanvasContext=a.canvas.getContext("webgpu"),a.format=a.gpuCanvasContext.getPreferredFormat(o),a}return v(e,[{key:"destroy",value:function(){this.gpuCanvasContext.unconfigure()}},{key:"getCurrentFramebuffer",value:function(){this.update();var o=this.device.createTexture({id:"default-render-target",handle:this.gpuCanvasContext.getCurrentTexture(),format:this.format,width:this.width,height:this.height});return this._createDepthStencilAttachment(),new xr(this.device,{colorAttachments:[o],depthStencilAttachment:this.depthStencilAttachment})}},{key:"update",value:function(){var o=this.getPixelSize(),i=D(o,2),a=i[0],c=i[1],u=a!==this.width||c!==this.height;u&&(this.width=a,this.height=c,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:me(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),R.log(1,"Resized to ".concat(this.width,"x").concat(this.height,"px"))())}},{key:"resize",value:function(o){this.update()}},{key:"_createDepthStencilAttachment",value:function(){return this.depthStencilAttachment||(this.depthStencilAttachment=this.device.createTexture({id:"depth-stencil-target",format:this.depthStencilFormat,width:this.width,height:this.height,usage:GPUTextureUsage.RENDER_ATTACHMENT})),this.depthStencilAttachment}}]),e}(he);function Rr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Cr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Rr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Rr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function mo(t){var n=go();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function go(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var lt=function(t){w(e,t);var n=mo(e);function e(r,o,i){var a;return g(this,e),a=n.call(this,Cr(Cr({},i),{},{id:i.id||ue("webgpu-device")})),s(f(a),"handle",void 0),s(f(a),"adapter",void 0),s(f(a),"lost",void 0),s(f(a),"canvasContext",null),s(f(a),"commandEncoder",null),s(f(a),"renderPass",null),s(f(a),"_info",void 0),s(f(a),"_isLost",!1),s(f(a),"features",void 0),a.handle=r,a.adapter=o,a._info={type:"webgpu",vendor:a.adapter.__brand,renderer:"",version:"",gpu:"unknown",shadingLanguages:["glsl","wgsl"],shadingLanguageVersions:{glsl:"450",wgsl:"100"},vendorMasked:"",rendererMasked:""},a.lost=new Promise(function(){var c=q(xe.default.mark(function u(m){var y;return xe.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,a.handle.lost;case 2:y=S.sent,a._isLost=!0,m({reason:"destroyed",message:y.message});case 5:case"end":return S.stop()}},u)}));return function(u){return c.apply(this,arguments)}}()),i.canvas&&(a.canvasContext=new ct(f(a),a.adapter,{canvas:i.canvas})),a.features=a._getFeatures(),a}return v(e,[{key:"destroy",value:function(){this.handle.destroy()}},{key:"info",get:function(){return this._info}},{key:"limits",get:function(){return this.handle.limits}},{key:"isTextureFormatSupported",value:function(o){return!o.includes("webgl")}},{key:"isTextureFormatFilterable",value:function(o){return this.isTextureFormatSupported(o)}},{key:"isTextureFormatRenderable",value:function(o){return this.isTextureFormatSupported(o)}},{key:"isLost",get:function(){return this._isLost}},{key:"createBuffer",value:function(o){var i=this._getBufferProps(o);return new Fe(this,i)}},{key:"_createTexture",value:function(o){return new ze(this,o)}},{key:"createExternalTexture",value:function(o){return new cr(this,o)}},{key:"createShader",value:function(o){return new We(this,o)}},{key:"createSampler",value:function(o){return new W(this,o)}},{key:"createRenderPipeline",value:function(o){return new br(this,o)}},{key:"createFramebuffer",value:function(o){throw new Error("Not implemented")}},{key:"createComputePipeline",value:function(o){return new _r(this,o)}},{key:"beginRenderPass",value:function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Sr(this,o)}},{key:"beginComputePass",value:function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Or(this,o)}},{key:"createCanvasContext",value:function(o){return new ct(this,this.adapter,o)}},{key:"getDefaultRenderPass",value:function(){var o;return this.renderPass=this.renderPass||this.beginRenderPass({framebuffer:(o=this.canvasContext)===null||o===void 0?void 0:o.getCurrentFramebuffer()}),this.renderPass}},{key:"submit",value:function(){var o,i;(o=this.renderPass)===null||o===void 0||o.end();var a=(i=this.commandEncoder)===null||i===void 0?void 0:i.finish();a&&this.handle.queue.submit([a]),this.commandEncoder=null,this.renderPass=null}},{key:"_getFeatures",value:function(){var o=new Set(this.handle.features);return o.has("depth-clamping")&&(o.delete("depth-clamping"),o.add("depth-clip-control")),o.has("texture-compression-bc")&&o.add("texture-compression-bc5-webgl"),o.add("webgpu"),o.add("timer-query-webgl"),o.add("vertex-array-object-webgl1"),o.add("instanced-rendering-webgl1"),o.add("multiple-render-targets-webgl1"),o.add("index-uint32-webgl1"),o.add("blend-minmax-webgl1"),o.add("texture-blend-float-webgl1"),o.add("texture-formats-srgb-webgl1"),o.add("texture-formats-depth-webgl1"),o.add("texture-formats-float32-webgl1"),o.add("texture-formats-float16-webgl1"),o.add("texture-filter-linear-float32-webgl"),o.add("texture-filter-linear-float16-webgl"),o.add("texture-filter-anisotropic-webgl"),o.add("texture-renderable-rgba32float-webgl"),o.add("texture-renderable-float32-webgl"),o.add("texture-renderable-float16-webgl"),o.add("glsl-frag-data"),o.add("glsl-frag-depth"),o.add("glsl-derivatives"),o.add("glsl-texture-lod"),o}},{key:"copyExternalImageToTexture",value:function(o){var i,a=o.source,c=o.sourceX,u=c===void 0?0:c,m=o.sourceY,y=m===void 0?0:m,O=o.texture,S=o.mipLevel,C=S===void 0?0:S,E=o.aspect,U=E===void 0?"all":E,L=o.colorSpace,V=L===void 0?"display-p3":L,j=o.premultipliedAlpha,F=j===void 0?!1:j,$=o.width,ve=$===void 0?O.width:$,Q=o.height,ye=Q===void 0?O.height:Q,K=o.depth,re=K===void 0?1:K,Z=O;(i=this.handle)===null||i===void 0||i.queue.copyExternalImageToTexture({source:a,origin:[u,y]},{texture:Z.handle,origin:[0,0,0],mipLevel:C,aspect:U,colorSpace:V,premultipliedAlpha:F},[ve,ye,re])}}],[{key:"isSupported",value:function(){return Boolean(typeof navigator<"u"&&navigator.gpu)}},{key:"create",value:function(){var r=q(xe.default.mark(function i(a){var c,u,m,y;return xe.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(navigator.gpu){S.next=2;break}throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");case 2:return R.groupCollapsed(1,"WebGPUDevice created")(),S.next=5,navigator.gpu.requestAdapter({powerPreference:"high-performance"});case 5:if(c=S.sent,c){S.next=8;break}throw new Error("Failed to request WebGPU adapter");case 8:return S.next=10,c.requestAdapterInfo();case 10:return u=S.sent,R.probe(1,"Adapter available",u)(),S.next=14,c.requestDevice({requiredFeatures:c.features});case 14:if(m=S.sent,R.probe(1,"GPUDevice available")(),typeof a.canvas!="string"){S.next=20;break}return S.next=19,he.pageLoaded;case 19:R.probe(1,"DOM is loaded")();case 20:return y=new e(m,c,a),R.probe(1,"Device created",y.info)(),R.table(1,y.info)(),R.groupEnd(1)(),S.abrupt("return",y);case 25:case"end":return S.stop()}},i)}));function o(i){return r.apply(this,arguments)}return o}()}]),e}(Ge);s(lt,"type","webgpu");return Dr(vo);})();
11
11
  /*! Bundled license information:
12
12
 
13
13
  @babel/runtime/helpers/regeneratorRuntime.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/webgpu",
3
- "version": "9.0.0-alpha.26",
3
+ "version": "9.0.0-alpha.27",
4
4
  "description": "WebGPU adapter for the luma.gl API",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,9 +37,9 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@babel/runtime": "^7.0.0",
40
- "@luma.gl/api": "9.0.0-alpha.26",
40
+ "@luma.gl/api": "9.0.0-alpha.27",
41
41
  "@probe.gl/env": "^4.0.2",
42
42
  "@webgpu/types": "^0.1.34"
43
43
  },
44
- "gitHead": "e255f78c1c0a4555808c6e9282bcecb6accd147b"
44
+ "gitHead": "4052244031cb80c27fa0e3fd4c3d5514daa08b78"
45
45
  }
@@ -1,4 +1,6 @@
1
- import type {Binding, RenderPass} from '@luma.gl/api';
1
+ // luma.gl MIT license
2
+
3
+ import type {Binding, RenderPass, TypedArray} from '@luma.gl/api';
2
4
  import {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/api';
3
5
  import {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';
4
6
  import {getWebGPUTextureFormat} from '../helpers/convert-texture-format';
@@ -83,6 +85,11 @@ export class WebGPURenderPipeline extends RenderPipeline {
83
85
  // }
84
86
  }
85
87
 
88
+ /** Constant attributes are not available in WebGPU */
89
+ setConstantAttributes(attributes: Record<string, TypedArray>): void {
90
+ console.error('not implemented');
91
+ }
92
+
86
93
  /** Set the bindings */
87
94
  setBindings(bindings: Record<string, Binding>): void {
88
95
  if (!isObjectEmpty(this.props.bindings)) {