@luma.gl/webgpu 9.0.0-alpha.31 → 9.0.0-alpha.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +2 -4
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/dist.dev.js +9 -3
- package/dist/index.cjs +0 -2
- package/dist.min.js +4 -4
- package/package.json +3 -3
- package/src/adapter/resources/webgpu-render-pipeline.ts +2 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
import type { Binding,
|
|
2
|
+
import type { TypedArray, Binding, UniformValue, RenderPass } from '@luma.gl/core';
|
|
3
3
|
import { Buffer, RenderPipeline, RenderPipelineProps } from '@luma.gl/core';
|
|
4
4
|
import type { WebGPUDevice } from '../webgpu-device';
|
|
5
5
|
import type { WebGPUShader } from './webgpu-shader';
|
|
@@ -21,11 +21,9 @@ 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
24
|
setConstantAttributes(attributes: Record<string, TypedArray>): void;
|
|
26
|
-
/** Set the bindings */
|
|
27
25
|
setBindings(bindings: Record<string, Binding>): void;
|
|
28
|
-
setUniforms(uniforms: Record<string,
|
|
26
|
+
setUniforms(uniforms: Record<string, UniformValue>): void;
|
|
29
27
|
_getBuffers(): Buffer[];
|
|
30
28
|
/** Return a bind group created by setBindings */
|
|
31
29
|
_getBindGroup(): GPUBindGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"webgpu-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AACjF,OAAO,EAAC,MAAM,EAAE,cAAc,EAAE,mBAAmB,EAA2B,MAAM,eAAe,CAAC;AASpG,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,EAAE,YAAY,GAAG,IAAI,CAAQ;IAE/B,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,YAAY,CAA6B;IAIjD,4CAA4C;IAC5C,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,UAAU,CAA6B;gBAEnC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB;IAc5D,SAAS,CAAC,YAAY,IAAI,iBAAiB;IASlC,OAAO,IAAI,IAAI;IAIxB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAIzC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAmBvD,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAInE,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAapD,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI;IAMzD,WAAW;IAIX,iDAAiD;IACjD,aAAa;IAKb,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"}
|
|
@@ -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","shaderLayout","bufferLayout","_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","setBindings","bindings","assign","_bindGroup","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","_this$device","fsEntryPoint","targets","format","canvasContext","topology","primitive","layout","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/core';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/core';\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.shaderLayout, this.props.bufferLayout);\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 throw new 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.shaderLayout,\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.shaderLayout, this.props.bufferLayout)\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-webgl':\n case 'line-loop-webgl':\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.shaderLayout.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.bufferLayout)) {\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":"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"}
|
|
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","shaderLayout","bufferLayout","_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","setBindings","bindings","assign","_bindGroup","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","_this$device","fsEntryPoint","targets","format","canvasContext","topology","primitive","layout","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 {TypedArray, Binding, UniformValue, RenderPass} from '@luma.gl/core';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/core';\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.shaderLayout, this.props.bufferLayout);\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 setConstantAttributes(attributes: Record<string, TypedArray>): void {\n throw new Error('not implemented');\n }\n\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.shaderLayout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, UniformValue>): 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.shaderLayout, this.props.bufferLayout)\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-webgl':\n case 'line-loop-webgl':\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.shaderLayout.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.bufferLayout)) {\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":"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"}
|
package/dist/dist.dev.js
CHANGED
|
@@ -953,6 +953,8 @@ var __exports__ = (() => {
|
|
|
953
953
|
get [Symbol.toStringTag]() {
|
|
954
954
|
return "Buffer";
|
|
955
955
|
}
|
|
956
|
+
/** The usage with which this buffer was created */
|
|
957
|
+
/** For index buffers, whether indices are 16 or 32 bit */
|
|
956
958
|
/** Length of buffer in bytes */
|
|
957
959
|
constructor(device, props) {
|
|
958
960
|
const deducedProps = {
|
|
@@ -966,6 +968,8 @@ var __exports__ = (() => {
|
|
|
966
968
|
}
|
|
967
969
|
}
|
|
968
970
|
super(device, deducedProps, _Buffer.defaultProps);
|
|
971
|
+
this.usage = props.usage || 0;
|
|
972
|
+
this.indexType = deducedProps.indexType;
|
|
969
973
|
}
|
|
970
974
|
write(data, byteOffset) {
|
|
971
975
|
throw new Error("not implemented");
|
|
@@ -1746,7 +1750,11 @@ var __exports__ = (() => {
|
|
|
1746
1750
|
/** Set attributes (stored on pipeline and set before each call) */
|
|
1747
1751
|
/** Set constant attributes (WebGL only) */
|
|
1748
1752
|
/** Set bindings (stored on pipeline and set before each call) */
|
|
1749
|
-
/** Uniforms
|
|
1753
|
+
/** Uniforms
|
|
1754
|
+
* @deprecated Only supported on WebGL devices.
|
|
1755
|
+
* @note textures, samplers and uniform buffers should be set via `setBindings()`, these are not considered uniforms.
|
|
1756
|
+
* @note In WebGL uniforms have a performance penalty, they are reset before each call to enable pipeline sharing.
|
|
1757
|
+
*/
|
|
1750
1758
|
/** Draw call */
|
|
1751
1759
|
};
|
|
1752
1760
|
var RenderPipeline = _RenderPipeline;
|
|
@@ -2662,11 +2670,9 @@ var __exports__ = (() => {
|
|
|
2662
2670
|
}
|
|
2663
2671
|
}
|
|
2664
2672
|
}
|
|
2665
|
-
/** Constant attributes are not available in WebGPU */
|
|
2666
2673
|
setConstantAttributes(attributes) {
|
|
2667
2674
|
throw new Error("not implemented");
|
|
2668
2675
|
}
|
|
2669
|
-
/** Set the bindings */
|
|
2670
2676
|
setBindings(bindings) {
|
|
2671
2677
|
if (!isObjectEmpty(this.props.bindings)) {
|
|
2672
2678
|
Object.assign(this.props.bindings, bindings);
|
package/dist/index.cjs
CHANGED
|
@@ -803,11 +803,9 @@ var WebGPURenderPipeline = class extends import_core8.RenderPipeline {
|
|
|
803
803
|
}
|
|
804
804
|
}
|
|
805
805
|
}
|
|
806
|
-
/** Constant attributes are not available in WebGPU */
|
|
807
806
|
setConstantAttributes(attributes) {
|
|
808
807
|
throw new Error("not implemented");
|
|
809
808
|
}
|
|
810
|
-
/** Set the bindings */
|
|
811
809
|
setBindings(bindings) {
|
|
812
810
|
if (!(0, import_core8.isObjectEmpty)(this.props.bindings)) {
|
|
813
811
|
Object.assign(this.props.bindings, bindings);
|
package/dist.min.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
6
|
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
-
var __exports__=(()=>{var jr=Object.create;var Ce=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var Ir=Object.getPrototypeOf,Dr=Object.prototype.hasOwnProperty;var qe=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),Gr=(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 Br(n))!Dr.call(t,o)&&o!==e&&Ce(t,o,{get:()=>n[o],enumerable:!(r=Ar(n,o))||r.enumerable});return t};var Xe=(t,n,e)=>(e=t!=null?jr(Ir(t)):{},ft(n||!t||!t.__esModule?Ce(e,"default",{value:t,enumerable:!0}):e,t)),Lr=t=>ft(Ce({},"__esModule",{value:!0}),t);var dt=qe((Go,q)=>{function Qe(t){return q.exports=Qe=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},q.exports.__esModule=!0,q.exports.default=q.exports,Qe(t)}q.exports=Qe,q.exports.__esModule=!0,q.exports.default=q.exports});var gt=qe((Lo,X)=>{var Nr=dt().default;function mt(){"use strict";X.exports=mt=function(){return t},X.exports.__esModule=!0,X.exports.default=X.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),k=new te(b||[]);return r(_,"_invoke",{value:ve(h,p,k)}),_}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 T(){}function E(){}var H={};u(H,i,function(){return this});var G=Object.getPrototypeOf,z=G&&G(G(Q([])));z&&z!==n&&e.call(z,i)&&(H=z);var B=E.prototype=S.prototype=Object.create(H);function M(h){["next","throw","return"].forEach(function(l){u(h,l,function(p){return this._invoke(l,p)})})}function V(h,l){function p(x,_,k,D){var L=y(h[x],h,_);if(L.type!=="throw"){var re=L.arg,Z=re.value;return Z&&Nr(Z)=="object"&&e.call(Z,"__await")?l.resolve(Z.__await).then(function(ne){p("next",ne,k,D)},function(ne){p("throw",ne,k,D)}):l.resolve(Z).then(function(ne){re.value=ne,k(re)},function(ne){return p("throw",ne,k,D)})}D(L.arg)}var b;r(this,"_invoke",{value:function(_,k){function D(){return new l(function(L,re){p(_,k,L,re)})}return b=b?b.then(D,D):D()}})}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 xe()}for(p.method=x,p.arg=_;;){var k=p.delegate;if(k){var D=J(k,p);if(D){if(D===O)continue;return D}}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 L=y(h,l,p);if(L.type==="normal"){if(b=p.done?"completed":"suspendedYield",L.arg===O)continue;return{value:L.arg,done:p.done}}L.type==="throw"&&(b="completed",p.method="throw",p.arg=L.arg)}}}function J(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,J(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 Y(h){var l=h.completion||{};l.type="normal",delete l.arg,h.completion=l}function te(h){this.tryEntries=[{tryLoc:"root"}],h.forEach(ye,this),this.reset(!0)}function Q(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:xe}}function xe(){return{value:void 0,done:!0}}return T.prototype=E,r(B,"constructor",{value:E,configurable:!0}),r(E,"constructor",{value:T,configurable:!0}),T.displayName=u(E,c,"GeneratorFunction"),t.isGeneratorFunction=function(h){var l=typeof h=="function"&&h.constructor;return!!l&&(l===T||(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(B),h},t.awrap=function(h){return{__await:h}},M(V.prototype),u(V.prototype,a,function(){return this}),t.AsyncIterator=V,t.async=function(h,l,p,b,x){x===void 0&&(x=Promise);var _=new V(m(h,l,p,b),x);return t.isGeneratorFunction(l)?_:_.next().then(function(k){return k.done?k.value:_.next()})},M(B),u(B,c,"Generator"),u(B,i,function(){return this}),u(B,"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=Q,te.prototype={constructor:te,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(Y),!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(re,Z){return k.type="throw",k.arg=l,p.next=re,Z&&(p.method="next",p.arg=void 0),!!Z}for(var x=this.tryEntries.length-1;x>=0;--x){var _=this.tryEntries[x],k=_.completion;if(_.tryLoc==="root")return b("end");if(_.tryLoc<=this.prev){var D=e.call(_,"catchLoc"),L=e.call(_,"finallyLoc");if(D&&L){if(this.prev<_.catchLoc)return b(_.catchLoc,!0);if(this.prev<_.finallyLoc)return b(_.finallyLoc)}else if(D){if(this.prev<_.catchLoc)return b(_.catchLoc,!0)}else{if(!L)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 k=_?_.completion:{};return k.type=l,k.arg=p,_?(this.method="next",this.next=_.finallyLoc,O):this.complete(k)},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),Y(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;Y(b)}return _}}throw new Error("illegal catch attempt")},delegateYield:function(l,p,b){return this.delegate={iterator:Q(l),resultName:p,nextLoc:b},this.method==="next"&&(this.arg=void 0),O}},t}X.exports=mt,X.exports.__esModule=!0,X.exports.default=X.exports});var Te=qe((No,vt)=>{var Re=gt()();vt.exports=Re;try{regeneratorRuntime=Re}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Re:Function("r","regeneratorRuntime = r")(Re)}});var ho={};Gr(ho,{WebGPUBuffer:()=>Ve,WebGPUDevice:()=>lt,WebGPUSampler:()=>F,WebGPUShader:()=>Ye,WebGPUTexture:()=>$e});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 K(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 $(t){return $=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},$(t)}function Je(t,n){if($(t)!=="object"||t===null)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var r=e.call(t,n||"default");if($(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function be(t){var n=Je(t,"string");return $(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&&($(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 Oe=Xe(Te(),1);function Ze(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)||Ze()}var Mr=globalThis.self||globalThis.window||globalThis.global,ue=globalThis.window||globalThis.self||globalThis.global,Ur=globalThis.document||{},oe=globalThis.process||{},Fr=globalThis.console,Wo=globalThis.navigator||{};var Ee=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",Vo=I();function Wr(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=Wr(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 je(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 Ae;(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"})(Ae||(Ae={}));var zr=10;function _t(t){return typeof t!="string"?t:(t=t.toUpperCase(),Ae[t]||Ae.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+zr,"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 ce(t,n){if(!t)throw new Error(n||"Assertion failed")}function ie(){let t;if(I()&&ue.performance){var n,e;t=ue===null||ue===void 0||(n=ue.performance)===null||n===void 0||(e=n.now)===null||e===void 0?void 0:e.call(n)}else if("hrtime"in oe){var r;let o=oe===null||oe===void 0||(r=oe.hrtime)===null||r===void 0?void 0:r.call(oe);t=o[0]*1e3+o[1]/1e6}else t=Date.now();return t}var le={debug:I()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Hr={enabled:!0,level:0};function U(){}var St={},Ot={once:!0},ee=class{constructor(){let{id:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};this.id=void 0,this.VERSION=Ee,this._startTs=ie(),this._deltaTs=ie(),this._storage=void 0,this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=n,this.userData={},this._storage=new ke("__probe-".concat(this.id,"__"),Hr),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((ie()-this._startTs).toPrecision(10))}getDelta(){return Number((ie()-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){ce(n,e)}warn(n){return this._getLogFunction(0,n,le.warn,arguments,Ot)}error(n){return this._getLogFunction(0,n,le.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,le.log,arguments,{time:!0,once:!0})}log(n,e){return this._getLogFunction(n,e,le.debug,arguments)}info(n,e){return this._getLogFunction(n,e,console.info,arguments)}once(n,e){return this._getLogFunction(n,e,le.debug||le.info,arguments,Ot)}table(n,e,r){return e?this._getLogFunction(n,e,console.table||U,r&&[r],{tag:Kr(e)}):U}image(n){let{logLevel:e,priority:r,image:o,message:i="",scale:a=1}=n;return this._shouldLog(e||r)?I()?Yr({image:o,message:i,scale:a}):$r({image:o,message:i,scale:a}):U}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||U)}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||U)}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()>=Ct(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,ce(r),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=ie();let a=i.tag||i.message;if(i.once&&a)if(!St[a])St[a]=ie();else return U;return e=Vr(this.id,i.message,i),r.bind(console,e,...i.args)}return U}};ee.VERSION=Ee;function Ct(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 ce(Number.isFinite(n)&&n>=0),n}function xt(t){let{logLevel:n,message:e}=t;t.logLevel=Ct(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 ce(o==="string"||o==="object"),Object.assign(t,{args:r},t.opts)}function Vr(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 $r(t){let{image:n,message:e="",scale:r=1}=t;return console.warn("removed"),U}function Yr(t){let{image:n,message:e="",scale:r=1}=t;if(typeof n=="string"){let i=new Image;return i.onload=()=>{let a=je(i,e,r);console.log(...a)},i.src=n,U}let o=n.nodeName||"";if(o.toLowerCase()==="img")return console.log(...je(n,e,r)),U;if(o.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...je(i,e,r)),i.src=n.toDataURL(),U}return U}function Kr(t){for(let n in t)for(let e in t[n])return e||"untitled";return"empty"}var gi=new ee({id:"@probe.gl/log"});var R=new ee({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 ae=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 fe=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 ae?o=n:o=new ae(e,r),this.stats[e]=o),o}};var qr=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 fe({id:e})),this.stats.get(e)}}]),t}(),Be=new qr;function Xr(){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:Be}),t}var Rt=Xr();var et={};function se(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"id";et[t]=et[t]||1;var n=et[t]++;return"".concat(t,"-").concat(n)}function Ie(t){var n=!0;for(var e in t){n=!1;break}return n}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 Jr(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 C=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:se(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(C,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Qr(t,n){var e=Jr({},n);for(var r in t)t[r]!==void 0&&(e[r]=t[r]);return e}var kt;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 tt(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}function Zr(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}}kt=Symbol.toStringTag;var j=function(t){w(e,t);var n=Zr(e);function e(r,o){var i;g(this,e);var a=tt({},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,e.defaultProps),s(f(i),"byteLength",void 0),i}return v(e,[{key:kt,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}(C);s(j,"defaultProps",tt(tt({},C.defaultProps),{},{usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}));s(j,"MAP_READ",1);s(j,"MAP_WRITE",2);s(j,"COPY_SRC",4);s(j,"COPY_DST",8);s(j,"INDEX",16);s(j,"VERTEX",32);s(j,"UNIFORM",64);s(j,"STORAGE",128);s(j,"INDIRECT",256);s(j,"QUERY_RESOLVE",512);var At;function jt(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 rt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?jt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):jt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var tn={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};At=Symbol.toStringTag;var De=function(){function t(n){g(this,t),s(this,"id",void 0),s(this,"statsManager",Be),s(this,"props",void 0),s(this,"userData",{}),s(this,"_lumaData",{}),s(this,"info",void 0),s(this,"lost",void 0),s(this,"canvasContext",void 0),this.props=rt(rt({},tn),n),this.id=this.props.id||se(this[Symbol.toStringTag].toLowerCase())}return v(t,[{key:At,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=rt({},e);return(e.usage||0)&j.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array&&(r.indexType="uint16")),r}}]),t}();s(De,"VERSION",Rt);function nt(t){if(Array.isArray(t))return t}function ot(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 Ge(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 it(t,n){if(t){if(typeof t=="string")return Ge(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 Ge(t,n)}}function at(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function A(t,n){return
|
|
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 nn(t,n){if(t){if(typeof t=="string")return Bt(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 Bt(t,n)}}function Bt(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 It(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 Dt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?It(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):It(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var on=I()&&typeof document<"u",Le=function(){return on&&document.readyState==="complete"},an={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},pe=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=Dt(Dt({},an),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=cn(n.canvas):this.canvas=n.canvas;else{var r,o,i=ln(n),a=un(((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=rn(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=A(e,2),o=r[0],i=r[1];return o/i}},{key:"cssToDeviceRatio",value:function(){try{var e=this.getDrawingBufferSize(),r=A(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=A(i,2),c=a[0],u=a[1];return fn(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=A(y,2),S=O[0],T=O[1];(S!==u||T!==m)&&(c=Math.min(S/o,T/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 Le()}}]),t}();s(pe,"pageLoaded",sn());function sn(){return Le()||typeof window>"u"?Promise.resolve():new Promise(function(t){window.addEventListener("load",function(){return t()})})}function un(t){if(typeof t=="string"){var n=document.getElementById(t);if(!n&&!Le())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 cn(t){var n=document.getElementById(t);if(!n&&!Le())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 ln(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 fn(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 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}function pn(t){var n=hn();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 hn(){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}}Ut=Symbol.toStringTag;var N=function(t){w(e,t);var n=pn(e);function e(r,o){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.defaultProps;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}(C);s(N,"defaultProps",Mt(Mt({},C.defaultProps),{},{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}));s(N,"COPY_SRC",1);s(N,"COPY_DST",2);s(N,"TEXTURE_BINDING",4);s(N,"STORAGE_BINDING",8);s(N,"RENDER_ATTACHMENT",16);var zt;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 Wt(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}function dn(t){var n=mn();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 mn(){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}}zt=Symbol.toStringTag;var Ne=function(t){w(e,t);var n=dn(e);function e(r,o){return g(this,e),n.call(this,r,o,e.defaultProps)}return v(e,[{key:zt,get:function(){return"ExternalTexture"}}]),e}(C);s(Ne,"defaultProps",Wt(Wt({},C.defaultProps),{},{source:null,colorSpace:"srgb"}));var $t;function Ht(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 Vt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Ht(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ht(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}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}}$t=Symbol.toStringTag;var Me=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,e.defaultProps),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:$t,get:function(){return"Shader"}}]),e}(C);s(Me,"defaultProps",Vt(Vt({},C.defaultProps),{},{stage:"vertex",source:"",sourceMap:null,language:"glsl",shaderType:0}));var qt;function Yt(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 Kt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Yt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Yt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function yn(t){var n=bn();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 bn(){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}}qt=Symbol.toStringTag;var he=function(t){w(e,t);var n=yn(e);function e(r,o){return g(this,e),n.call(this,r,o,e.defaultProps)}return v(e,[{key:qt,get:function(){return"Sampler"}}]),e}(C);s(he,"defaultProps",Kt(Kt({},C.defaultProps),{},{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}));var Jt;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 de(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}function _n(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}}Jt=Symbol.toStringTag;var Ue=function(t){w(e,t);var n=_n(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,e.defaultProps),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:Jt,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=A(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:N.RENDER_ATTACHMENT,format:o,width:this.width,height:this.height})}},{key:"createDepthStencilTexture",value:function(o){return this.device.createTexture({id:"depth-stencil-attachment",usage:N.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}(C);s(Ue,"defaultProps",de(de({},C.defaultProps),{},{width:1,height:1,colorAttachments:[],depthStencilAttachment:null}));var er;function Qt(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?Qt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Qt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}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}}er=Symbol.toStringTag;var Fe=function(t){w(e,t);var n=Pn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,e.defaultProps),s(f(i),"hash",""),s(f(i),"vs",void 0),s(f(i),"fs",void 0),i}return v(e,[{key:er,get:function(){return"RenderPipeline"}}]),e}(C);s(Fe,"defaultProps",Zt(Zt({},C.defaultProps),{},{vs:null,vsEntryPoint:"",vsConstants:{},fs:null,fsEntryPoint:"",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,indices:null,attributes:{},bindings:{},uniforms:{}}));var nr;function tr(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 rr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?tr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):tr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function On(t){var n=xn();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 xn(){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}}nr=Symbol.toStringTag;var We=function(t){w(e,t);var n=On(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,e.defaultProps),s(f(i),"hash",""),i}return v(e,[{key:nr,get:function(){return"ComputePipeline"}}]),e}(C);s(We,"defaultProps",rr(rr({},C.defaultProps),{},{cs:void 0,csEntryPoint:void 0,csConstants:{},shaderLayout:[]}));var ar;function or(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 ir(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?or(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):or(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Cn(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}}ar=Symbol.toStringTag;var ze=function(t){w(e,t);var n=Cn(e);function e(r,o){return g(this,e),n.call(this,r,o,e.defaultProps)}return v(e,[{key:ar,get:function(){return"RenderPass"}}]),e}(C);s(ze,"defaultProps",ir(ir({},C.defaultProps),{},{framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1}));var ur;function sr(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 Tn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?sr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):sr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function En(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}}ur=Symbol.toStringTag;var He=function(t){w(e,t);var n=En(e);function e(r,o){return g(this,e),n.call(this,r,o,C.defaultProps)}return v(e,[{key:ur,get:function(){return"ComputePass"}}]),e}(C);s(He,"defaultProps",Tn({},C.defaultProps));function lr(t){var n=cr[t],e=jn(n),r=t.includes("norm"),o=!r&&!t.startsWith("float"),i=t.startsWith("s");return{dataType:cr[t],byteLength:e,integer:o,signed:i,normalized:r}}function jn(t){var n=An[t];return n}var cr={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},An={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};function Pe(t){var n;t.endsWith("-webgl")&&(t.replace("-webgl",""),n=!0);var e=t.split("x"),r=A(e,2),o=r[0],i=r[1],a=o,c=i?parseInt(i):1,u=lr(a),m={type:a,components:c,byteLength:u.byteLength*c,integer:u.integer,signed:u.signed,normalized:u.normalized};return n&&(m.webglOnly=!0),m}var st=Xe(Te(),1);function Bn(t){var n=In();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 In(){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 Dn(t){var n;return t.byteLength||((n=t.data)===null||n===void 0?void 0:n.byteLength)||0}var Ve=function(t){w(e,t);var n=Bn(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=Dn(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=K(st.default.mark(function i(){var a,c,u,m,y,O=arguments;return st.default.wrap(function(T){for(;;)switch(T.prev=T.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:j.MAP_READ|j.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()]),T.next=8,u.handle.mapAsync(GPUMapMode.READ,a,c);case 8:return y=u.handle.getMappedRange().slice(0),u.handle.unmap(),u.destroy(),T.abrupt("return",y);case 12:case"end":return T.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}(j);function me(t){if(t.includes("webgl"))throw new Error("webgl-only format");return t}function fr(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 Gn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?fr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):fr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Ln(t){var n=Nn();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 Nn(){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 F=function(t){w(e,t);var n=Ln(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=Gn({},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}(he);function Mn(t){var n=Un();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 Un(){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 Fn={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},$e=function(t){w(e,t);var n=Mn(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 F?o.sampler:new F(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:Fn[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 F?o:new F(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,T=S===void 0?0:S,E=o.sourceY,H=E===void 0?0:E,G=o.mipLevel,z=G===void 0?0:G,B=o.x,M=B===void 0?0:B,V=o.y,ve=V===void 0?0:V,J=o.z,ye=J===void 0?0:J,Y=o.aspect,te=Y===void 0?"all":Y,Q=o.colorSpace,xe=Q===void 0?"srgb":Q,h=o.premultipliedAlpha,l=h===void 0?!1:h;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[T,H]},{texture:this.handle,origin:[M,ve,ye],mipLevel:z,aspect:te,colorSpace:xe,premultipliedAlpha:l},[c,m,O]),{width:c,height:m}}}]),e}(N);function Wn(t){var n=zn();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 zn(){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 pr=function(t){w(e,t);var n=Wn(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 F?o:new F(this.device,o),this}}]),e}(Ne);var Se=Xe(Te(),1);function Hn(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}}var Ye=function(t){w(e,t);var n=Hn(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=K(Se.default.mark(function i(a){var c,u;return Se.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=K(Se.default.mark(function i(){var a;return Se.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}(Me);function hr(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 dr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?hr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):hr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function W(t){return t.depthStencil=t.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:void 0,depthCompare:void 0},t.depthStencil}var $n={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=W(r);o.depthWriteEnabled=e},depthCompare:function(n,e,r){var o=W(r);o.depthCompare=e},depthFormat:function(n,e,r){var o=W(r);o.format=e},depthBias:function(n,e,r){var o=W(r);o.depthBias=e},depthBiasSlopeScale:function(n,e,r){var o=W(r);o.depthBiasSlopeScale=e},depthBiasClamp:function(n,e,r){var o=W(r);o.depthBiasClamp=e},stencilReadMask:function(n,e,r){var o=W(r);o.stencilReadMask=e},stencilWriteMask:function(n,e,r){var o=W(r);o.stencilWriteMask=e},stencilCompare:function(n,e,r){var o=W(r);o.stencilFront.compare=e,o.stencilBack.compare=e},stencilPassOperation:function(n,e,r){var o=W(r);o.stencilFront.passOp=e,o.stencilBack.passOp=e},stencilFailOperation:function(n,e,r){var o=W(r);o.stencilFront.failOp=e,o.stencilBack.failOp=e},stencilDepthFailOperation:function(n,e,r){var o=W(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=mr(r);o[0].writeMask=e},blendColorOperation:function(n,e,r){mr(r)}},Yn={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function gr(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Object.assign(t,dr(dr({},Yn),t)),Kn(t,n)}function Kn(t,n){for(var e=0,r=Object.entries(n);e<r.length;e++){var o=A(r[e],2),i=o[0],a=o[1],c=$n[i];if(!c)throw new Error("Illegal parameter ".concat(i));c(i,a,t)}}function mr(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 vr(t,n,e,r){var o=Xn(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 Xn(t,n){for(var e=[],r=0,o=Object.entries(t);r<o.length;r++){var i=A(o[r],2),a=i[0],c=i[1],u=qn(n,a);u&&e.push(Jn(c,u.location))}return e}function Jn(t,n){if(t instanceof j)return{binding:n,resource:{buffer:t.handle}};if(t instanceof he)return{binding:n,resource:t.handle};if(t instanceof N)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=Qn(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 Qn(t,n){if(t){if(typeof t=="string")return yr(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 yr(t,n)}}function yr(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 ut(t){if(t.endsWith("-webgl"))throw new Error("WebGPU does not support vertex format ".concat(t));return t}function _r(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(a.attributes){var O=ge(a.attributes),S;try{for(O.s();!(S=O.n()).done;){var T=S.value,E=br(t,T.name,r);u=E.stepMode||"vertex",c.push({format:ut(T.format||a.format),offset:y+m,shaderLocation:E.location}),m+=Pe(a.format).byteLength}}catch(M){O.e(M)}finally{O.f()}}else{var H=br(t,a.name,r);m=Pe(a.format).byteLength,u=H.stepMode||"vertex",c.push({format:ut(a.format),offset:y,shaderLocation:H.location})}e.push({arrayStride:a.byteStride||m,stepMode:u||"vertex",attributes:c})}}catch(M){o.e(M)}finally{o.f()}var G=ge(t.attributes),z;try{for(G.s();!(z=G.n()).done;){var B=z.value;r.has(B.name)||e.push({arrayStride:Pe("float32x3").byteLength,stepMode:B.stepMode||"vertex",attributes:[{format:ut("float32x3"),offset:0,shaderLocation:B.location}]})}}catch(M){G.e(M)}finally{G.f()}return e}function wr(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 T=S.value;e.has(T.name)||(o[T.name]=r++)}}catch(E){O.e(E)}finally{O.f()}return o}function br(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 Zn(t){var n=eo();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 eo(){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 Pr=function(t){w(e,t);var n=Zn(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=wr(i.props.shaderLayout,i.props.bufferLayout),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=A(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){throw new Error("not implemented")}},{key:"setBindings",value:function(o){Ie(this.props.bindings)||(Object.assign(this.props.bindings,o),this._bindGroup=vr(this.device.handle,this._bindGroupLayout,this.props.shaderLayout,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:_r(this.props.shaderLayout,this.props.bufferLayout)},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-webgl":case"line-loop-webgl":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 gr(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.shaderLayout.attributes.find(function(T){return T.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}(Fe);function to(t){var n=ro();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 ro(){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=to(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}(We);function Or(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 xr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Or(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Or(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function no(t){var n=oo();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 oo(){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=no(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=xr(xr({},this.props),{},{view:o.depthStencilAttachment.handle.createView()})),a}}]),e}(ze);function io(t){var n=ao();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 ao(){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 Rr=function(t){w(e,t);var n=io(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}(He);function so(t){var n=uo();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 uo(){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 Tr=function(t){w(e,t);var n=so(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)}(Ue);function co(t){var n=lo();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 lo(){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=co(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 Tr(this.device,{colorAttachments:[o],depthStencilAttachment:this.depthStencilAttachment})}},{key:"update",value:function(){var o=this.getPixelSize(),i=A(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}(pe);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 kr(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}function fo(t){var n=po();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 po(){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=fo(e);function e(r,o,i){var a;return g(this,e),a=n.call(this,kr(kr({},i),{},{id:i.id||se("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=K(Oe.default.mark(function u(m){var y;return Oe.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 Ve(this,i)}},{key:"_createTexture",value:function(o){return new $e(this,o)}},{key:"createExternalTexture",value:function(o){return new pr(this,o)}},{key:"createShader",value:function(o){return new Ye(this,o)}},{key:"createSampler",value:function(o){return new F(this,o)}},{key:"createRenderPipeline",value:function(o){return new Pr(this,o)}},{key:"createFramebuffer",value:function(o){throw new Error("Not implemented")}},{key:"createComputePipeline",value:function(o){return new Sr(this,o)}},{key:"beginRenderPass",value:function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Cr(this,o)}},{key:"beginComputePass",value:function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Rr(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,T=S===void 0?0:S,E=o.aspect,H=E===void 0?"all":E,G=o.colorSpace,z=G===void 0?"display-p3":G,B=o.premultipliedAlpha,M=B===void 0?!1:B,V=o.width,ve=V===void 0?O.width:V,J=o.height,ye=J===void 0?O.height:J,Y=o.depth,te=Y===void 0?1:Y,Q=O;(i=this.handle)===null||i===void 0||i.queue.copyExternalImageToTexture({source:a,origin:[u,y]},{texture:Q.handle,origin:[0,0,0],mipLevel:T,aspect:H,colorSpace:z,premultipliedAlpha:M},[ve,ye,te])}}],[{key:"isSupported",value:function(){return Boolean(typeof navigator<"u"&&navigator.gpu)}},{key:"create",value:function(){var r=K(Oe.default.mark(function i(a){var c,u,m,y;return Oe.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,pe.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}(De);s(lt,"type","webgpu");return Lr(ho);})();
|
|
7
|
+
var __exports__=(()=>{var jr=Object.create;var xe=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var Ir=Object.getPrototypeOf,Dr=Object.prototype.hasOwnProperty;var Ke=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),Gr=(t,n)=>{for(var e in n)xe(t,e,{get:n[e],enumerable:!0})},lt=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of Br(n))!Dr.call(t,o)&&o!==e&&xe(t,o,{get:()=>n[o],enumerable:!(r=Ar(n,o))||r.enumerable});return t};var qe=(t,n,e)=>(e=t!=null?jr(Ir(t)):{},lt(n||!t||!t.__esModule?xe(e,"default",{value:t,enumerable:!0}):e,t)),Lr=t=>lt(xe({},"__esModule",{value:!0}),t);var ht=Ke((Do,q)=>{function Je(t){return q.exports=Je=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},q.exports.__esModule=!0,q.exports.default=q.exports,Je(t)}q.exports=Je,q.exports.__esModule=!0,q.exports.default=q.exports});var gt=Ke((Go,X)=>{var dt=ht().default;function mt(){"use strict";X.exports=mt=function(){return t},X.exports.__esModule=!0,X.exports.default=X.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),k=new te(b||[]);return r(_,"_invoke",{value:ve(h,p,k)}),_}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 T(){}function E(){}var H={};u(H,i,function(){return this});var G=Object.getPrototypeOf,z=G&&G(G(Q([])));z&&z!==n&&e.call(z,i)&&(H=z);var B=E.prototype=S.prototype=Object.create(H);function M(h){["next","throw","return"].forEach(function(l){u(h,l,function(p){return this._invoke(l,p)})})}function V(h,l){function p(x,_,k,D){var L=y(h[x],h,_);if(L.type!=="throw"){var re=L.arg,Z=re.value;return Z&&dt(Z)=="object"&&e.call(Z,"__await")?l.resolve(Z.__await).then(function(ne){p("next",ne,k,D)},function(ne){p("throw",ne,k,D)}):l.resolve(Z).then(function(ne){re.value=ne,k(re)},function(ne){return p("throw",ne,k,D)})}D(L.arg)}var b;r(this,"_invoke",{value:function(_,k){function D(){return new l(function(L,re){p(_,k,L,re)})}return b=b?b.then(D,D):D()}})}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{value:void 0,done:!0}}for(p.method=x,p.arg=_;;){var k=p.delegate;if(k){var D=J(k,p);if(D){if(D===O)continue;return D}}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 L=y(h,l,p);if(L.type==="normal"){if(b=p.done?"completed":"suspendedYield",L.arg===O)continue;return{value:L.arg,done:p.done}}L.type==="throw"&&(b="completed",p.method="throw",p.arg=L.arg)}}}function J(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,J(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 Y(h){var l=h.completion||{};l.type="normal",delete l.arg,h.completion=l}function te(h){this.tryEntries=[{tryLoc:"root"}],h.forEach(ye,this),this.reset(!0)}function Q(h){if(h||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}}throw new TypeError(dt(h)+" is not iterable")}return T.prototype=E,r(B,"constructor",{value:E,configurable:!0}),r(E,"constructor",{value:T,configurable:!0}),T.displayName=u(E,c,"GeneratorFunction"),t.isGeneratorFunction=function(h){var l=typeof h=="function"&&h.constructor;return!!l&&(l===T||(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(B),h},t.awrap=function(h){return{__await:h}},M(V.prototype),u(V.prototype,a,function(){return this}),t.AsyncIterator=V,t.async=function(h,l,p,b,x){x===void 0&&(x=Promise);var _=new V(m(h,l,p,b),x);return t.isGeneratorFunction(l)?_:_.next().then(function(k){return k.done?k.value:_.next()})},M(B),u(B,c,"Generator"),u(B,i,function(){return this}),u(B,"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=Q,te.prototype={constructor:te,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(Y),!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(re,Z){return k.type="throw",k.arg=l,p.next=re,Z&&(p.method="next",p.arg=void 0),!!Z}for(var x=this.tryEntries.length-1;x>=0;--x){var _=this.tryEntries[x],k=_.completion;if(_.tryLoc==="root")return b("end");if(_.tryLoc<=this.prev){var D=e.call(_,"catchLoc"),L=e.call(_,"finallyLoc");if(D&&L){if(this.prev<_.catchLoc)return b(_.catchLoc,!0);if(this.prev<_.finallyLoc)return b(_.finallyLoc)}else if(D){if(this.prev<_.catchLoc)return b(_.catchLoc,!0)}else{if(!L)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 k=_?_.completion:{};return k.type=l,k.arg=p,_?(this.method="next",this.next=_.finallyLoc,O):this.complete(k)},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),Y(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;Y(b)}return _}}throw new Error("illegal catch attempt")},delegateYield:function(l,p,b){return this.delegate={iterator:Q(l),resultName:p,nextLoc:b},this.method==="next"&&(this.arg=void 0),O}},t}X.exports=mt,X.exports.__esModule=!0,X.exports.default=X.exports});var Re=Ke((Lo,vt)=>{var Ce=gt()();vt.exports=Ce;try{regeneratorRuntime=Ce}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Ce:Function("r","regeneratorRuntime = r")(Ce)}});var po={};Gr(po,{WebGPUBuffer:()=>He,WebGPUDevice:()=>ct,WebGPUSampler:()=>F,WebGPUShader:()=>$e,WebGPUTexture:()=>Ve});function ft(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 K(t){return function(){var n=this,e=arguments;return new Promise(function(r,o){var i=t.apply(n,e);function a(u){ft(i,r,o,a,c,"next",u)}function c(u){ft(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 $(t){return $=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},$(t)}function Xe(t,n){if($(t)!=="object"||t===null)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var r=e.call(t,n||"default");if($(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function be(t){var n=Xe(t,"string");return $(n)==="symbol"?n:String(n)}function pt(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&&pt(t.prototype,n),e&&pt(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&&($(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 Oe=qe(Re(),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 Nr=globalThis.self||globalThis.window||globalThis.global,ue=globalThis.window||globalThis.self||globalThis.global,Mr=globalThis.document||{},oe=globalThis.process||{},Ur=globalThis.console,Fo=globalThis.navigator||{};var Te=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",Ho=I();function Fr(t){try{let n=window[t],e="__storage_test__";return n.setItem(e,e),n.removeItem(e),n}catch{return null}}var Ee=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=Fr(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 ke(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 Wr=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+Wr,"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 ce(t,n){if(!t)throw new Error(n||"Assertion failed")}function ie(){let t;if(I()&&ue.performance){var n,e;t=ue===null||ue===void 0||(n=ue.performance)===null||n===void 0||(e=n.now)===null||e===void 0?void 0:e.call(n)}else if("hrtime"in oe){var r;let o=oe===null||oe===void 0||(r=oe.hrtime)===null||r===void 0?void 0:r.call(oe);t=o[0]*1e3+o[1]/1e6}else t=Date.now();return t}var le={debug:I()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},zr={enabled:!0,level:0};function U(){}var St={},Ot={once:!0},ee=class{constructor(){let{id:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};this.id=void 0,this.VERSION=Te,this._startTs=ie(),this._deltaTs=ie(),this._storage=void 0,this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=n,this.userData={},this._storage=new Ee("__probe-".concat(this.id,"__"),zr),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((ie()-this._startTs).toPrecision(10))}getDelta(){return Number((ie()-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){ce(n,e)}warn(n){return this._getLogFunction(0,n,le.warn,arguments,Ot)}error(n){return this._getLogFunction(0,n,le.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,le.log,arguments,{time:!0,once:!0})}log(n,e){return this._getLogFunction(n,e,le.debug,arguments)}info(n,e){return this._getLogFunction(n,e,console.info,arguments)}once(n,e){return this._getLogFunction(n,e,le.debug||le.info,arguments,Ot)}table(n,e,r){return e?this._getLogFunction(n,e,console.table||U,r&&[r],{tag:Yr(e)}):U}image(n){let{logLevel:e,priority:r,image:o,message:i="",scale:a=1}=n;return this._shouldLog(e||r)?I()?$r({image:o,message:i,scale:a}):Vr({image:o,message:i,scale:a}):U}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||U)}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||U)}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()>=Ct(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,ce(r),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=ie();let a=i.tag||i.message;if(i.once&&a)if(!St[a])St[a]=ie();else return U;return e=Hr(this.id,i.message,i),r.bind(console,e,...i.args)}return U}};ee.VERSION=Te;function Ct(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 ce(Number.isFinite(n)&&n>=0),n}function xt(t){let{logLevel:n,message:e}=t;t.logLevel=Ct(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 ce(o==="string"||o==="object"),Object.assign(t,{args:r},t.opts)}function Hr(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 Vr(t){let{image:n,message:e="",scale:r=1}=t;return console.warn("removed"),U}function $r(t){let{image:n,message:e="",scale:r=1}=t;if(typeof n=="string"){let i=new Image;return i.onload=()=>{let a=ke(i,e,r);console.log(...a)},i.src=n,U}let o=n.nodeName||"";if(o.toLowerCase()==="img")return console.log(...ke(n,e,r)),U;if(o.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...ke(i,e,r)),i.src=n.toDataURL(),U}return U}function Yr(t){for(let n in t)for(let e in t[n])return e||"untitled";return"empty"}var mi=new ee({id:"@probe.gl/log"});var R=new ee({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 ae=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 fe=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 ae?o=n:o=new ae(e,r),this.stats[e]=o),o}};var Kr=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 fe({id:e})),this.stats.get(e)}}]),t}(),Ae=new Kr;function qr(){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:Ae}),t}var Rt=qr();var Ze={};function se(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"id";Ze[t]=Ze[t]||1;var n=Ze[t]++;return"".concat(t,"-").concat(n)}function Be(t){var n=!0;for(var e in t){n=!1;break}return n}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 Xr(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 C=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=Jr(e,r);var o=this.props.id!=="undefined"?this.props.id:se(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(C,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Jr(t,n){var e=Xr({},n);for(var r in t)t[r]!==void 0&&(e[r]=t[r]);return e}var kt;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 et(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}function Qr(t){var n=Zr();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 Zr(){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}}kt=Symbol.toStringTag;var j=function(t){w(e,t);var n=Qr(e);function e(r,o){var i;g(this,e);var a=et({},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,e.defaultProps),s(f(i),"usage",void 0),s(f(i),"indexType",void 0),s(f(i),"byteLength",void 0),i.usage=o.usage||0,i.indexType=a.indexType,i}return v(e,[{key:kt,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}(C);s(j,"defaultProps",et(et({},C.defaultProps),{},{usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}));s(j,"MAP_READ",1);s(j,"MAP_WRITE",2);s(j,"COPY_SRC",4);s(j,"COPY_DST",8);s(j,"INDEX",16);s(j,"VERTEX",32);s(j,"UNIFORM",64);s(j,"STORAGE",128);s(j,"INDIRECT",256);s(j,"QUERY_RESOLVE",512);var At;function jt(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 tt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?jt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):jt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var en={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};At=Symbol.toStringTag;var Ie=function(){function t(n){g(this,t),s(this,"id",void 0),s(this,"statsManager",Ae),s(this,"props",void 0),s(this,"userData",{}),s(this,"_lumaData",{}),s(this,"info",void 0),s(this,"lost",void 0),s(this,"canvasContext",void 0),this.props=tt(tt({},en),n),this.id=this.props.id||se(this[Symbol.toStringTag].toLowerCase())}return v(t,[{key:At,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=tt({},e);return(e.usage||0)&j.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array&&(r.indexType="uint16")),r}}]),t}();s(Ie,"VERSION",Rt);function rt(t){if(Array.isArray(t))return t}function nt(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 De(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 ot(t,n){if(t){if(typeof t=="string")return De(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 De(t,n)}}function it(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function A(t,n){return rt(t)||nt(t,n)||ot(t,n)||it()}function tn(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=rn(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
|
+
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 rn(t,n){if(t){if(typeof t=="string")return Bt(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 Bt(t,n)}}function Bt(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 It(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 Dt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?It(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):It(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var nn=I()&&typeof document<"u",Ge=function(){return nn&&document.readyState==="complete"},on={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},pe=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=Dt(Dt({},on),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=un(n.canvas):this.canvas=n.canvas;else{var r,o,i=cn(n),a=sn(((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=tn(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=A(e,2),o=r[0],i=r[1];return o/i}},{key:"cssToDeviceRatio",value:function(){try{var e=this.getDrawingBufferSize(),r=A(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=A(i,2),c=a[0],u=a[1];return ln(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=A(y,2),S=O[0],T=O[1];(S!==u||T!==m)&&(c=Math.min(S/o,T/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 Ge()}}]),t}();s(pe,"pageLoaded",an());function an(){return Ge()||typeof window>"u"?Promise.resolve():new Promise(function(t){window.addEventListener("load",function(){return t()})})}function sn(t){if(typeof t=="string"){var n=document.getElementById(t);if(!n&&!Ge())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 un(t){var n=document.getElementById(t);if(!n&&!Ge())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 cn(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 ln(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 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}function fn(t){var n=pn();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 pn(){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}}Ut=Symbol.toStringTag;var N=function(t){w(e,t);var n=fn(e);function e(r,o){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.defaultProps;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}(C);s(N,"defaultProps",Mt(Mt({},C.defaultProps),{},{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}));s(N,"COPY_SRC",1);s(N,"COPY_DST",2);s(N,"TEXTURE_BINDING",4);s(N,"STORAGE_BINDING",8);s(N,"RENDER_ATTACHMENT",16);var zt;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 Wt(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}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}}zt=Symbol.toStringTag;var Le=function(t){w(e,t);var n=hn(e);function e(r,o){return g(this,e),n.call(this,r,o,e.defaultProps)}return v(e,[{key:zt,get:function(){return"ExternalTexture"}}]),e}(C);s(Le,"defaultProps",Wt(Wt({},C.defaultProps),{},{source:null,colorSpace:"srgb"}));var $t;function Ht(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 Vt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Ht(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ht(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function mn(t){var n=gn();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 gn(){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}}$t=Symbol.toStringTag;var Ne=function(t){w(e,t);var n=mn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,e.defaultProps),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:$t,get:function(){return"Shader"}}]),e}(C);s(Ne,"defaultProps",Vt(Vt({},C.defaultProps),{},{stage:"vertex",source:"",sourceMap:null,language:"glsl",shaderType:0}));var qt;function Yt(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 Kt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Yt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Yt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function vn(t){var n=yn();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 yn(){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}}qt=Symbol.toStringTag;var he=function(t){w(e,t);var n=vn(e);function e(r,o){return g(this,e),n.call(this,r,o,e.defaultProps)}return v(e,[{key:qt,get:function(){return"Sampler"}}]),e}(C);s(he,"defaultProps",Kt(Kt({},C.defaultProps),{},{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}));var Jt;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 de(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}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}}Jt=Symbol.toStringTag;var Me=function(t){w(e,t);var n=bn(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,e.defaultProps),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:Jt,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=A(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:N.RENDER_ATTACHMENT,format:o,width:this.width,height:this.height})}},{key:"createDepthStencilTexture",value:function(o){return this.device.createTexture({id:"depth-stencil-attachment",usage:N.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}(C);s(Me,"defaultProps",de(de({},C.defaultProps),{},{width:1,height:1,colorAttachments:[],depthStencilAttachment:null}));var er;function Qt(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?Qt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Qt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function wn(t){var n=Pn();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 Pn(){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}}er=Symbol.toStringTag;var Ue=function(t){w(e,t);var n=wn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,e.defaultProps),s(f(i),"hash",""),s(f(i),"vs",void 0),s(f(i),"fs",void 0),i}return v(e,[{key:er,get:function(){return"RenderPipeline"}}]),e}(C);s(Ue,"defaultProps",Zt(Zt({},C.defaultProps),{},{vs:null,vsEntryPoint:"",vsConstants:{},fs:null,fsEntryPoint:"",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,indices:null,attributes:{},bindings:{},uniforms:{}}));var nr;function tr(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 rr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?tr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):tr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Sn(t){var n=On();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 On(){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}}nr=Symbol.toStringTag;var Fe=function(t){w(e,t);var n=Sn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,e.defaultProps),s(f(i),"hash",""),i}return v(e,[{key:nr,get:function(){return"ComputePipeline"}}]),e}(C);s(Fe,"defaultProps",rr(rr({},C.defaultProps),{},{cs:void 0,csEntryPoint:void 0,csConstants:{},shaderLayout:[]}));var ar;function or(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 ir(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?or(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):or(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function xn(t){var n=Cn();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 Cn(){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}}ar=Symbol.toStringTag;var We=function(t){w(e,t);var n=xn(e);function e(r,o){return g(this,e),n.call(this,r,o,e.defaultProps)}return v(e,[{key:ar,get:function(){return"RenderPass"}}]),e}(C);s(We,"defaultProps",ir(ir({},C.defaultProps),{},{framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1}));var ur;function sr(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 Rn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?sr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):sr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Tn(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}}ur=Symbol.toStringTag;var ze=function(t){w(e,t);var n=Tn(e);function e(r,o){return g(this,e),n.call(this,r,o,C.defaultProps)}return v(e,[{key:ur,get:function(){return"ComputePass"}}]),e}(C);s(ze,"defaultProps",Rn({},C.defaultProps));function lr(t){var n=cr[t],e=kn(n),r=t.includes("norm"),o=!r&&!t.startsWith("float"),i=t.startsWith("s");return{dataType:cr[t],byteLength:e,integer:o,signed:i,normalized:r}}function kn(t){var n=jn[t];return n}var cr={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},jn={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};function Pe(t){var n;t.endsWith("-webgl")&&(t.replace("-webgl",""),n=!0);var e=t.split("x"),r=A(e,2),o=r[0],i=r[1],a=o,c=i?parseInt(i):1,u=lr(a),m={type:a,components:c,byteLength:u.byteLength*c,integer:u.integer,signed:u.signed,normalized:u.normalized};return n&&(m.webglOnly=!0),m}var at=qe(Re(),1);function An(t){var n=Bn();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 Bn(){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 In(t){var n;return t.byteLength||((n=t.data)===null||n===void 0?void 0:n.byteLength)||0}var He=function(t){w(e,t);var n=An(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=In(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=K(at.default.mark(function i(){var a,c,u,m,y,O=arguments;return at.default.wrap(function(T){for(;;)switch(T.prev=T.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:j.MAP_READ|j.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()]),T.next=8,u.handle.mapAsync(GPUMapMode.READ,a,c);case 8:return y=u.handle.getMappedRange().slice(0),u.handle.unmap(),u.destroy(),T.abrupt("return",y);case 12:case"end":return T.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}(j);function me(t){if(t.includes("webgl"))throw new Error("webgl-only format");return t}function fr(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 Dn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?fr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):fr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}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}}var F=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),i.device=r;var a=Dn({},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}(he);function Nn(t){var n=Mn();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 Mn(){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 Un={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Ve=function(t){w(e,t);var n=Nn(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 F?o.sampler:new F(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:Un[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 F?o:new F(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,T=S===void 0?0:S,E=o.sourceY,H=E===void 0?0:E,G=o.mipLevel,z=G===void 0?0:G,B=o.x,M=B===void 0?0:B,V=o.y,ve=V===void 0?0:V,J=o.z,ye=J===void 0?0:J,Y=o.aspect,te=Y===void 0?"all":Y,Q=o.colorSpace,h=Q===void 0?"srgb":Q,l=o.premultipliedAlpha,p=l===void 0?!1:l;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[T,H]},{texture:this.handle,origin:[M,ve,ye],mipLevel:z,aspect:te,colorSpace:h,premultipliedAlpha:p},[c,m,O]),{width:c,height:m}}}]),e}(N);function Fn(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 pr=function(t){w(e,t);var n=Fn(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 F?o:new F(this.device,o),this}}]),e}(Le);var Se=qe(Re(),1);function zn(t){var n=Hn();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 Hn(){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 $e=function(t){w(e,t);var n=zn(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=K(Se.default.mark(function i(a){var c,u;return Se.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=K(Se.default.mark(function i(){var a;return Se.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}(Ne);function hr(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 dr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?hr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):hr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function W(t){return t.depthStencil=t.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:void 0,depthCompare:void 0},t.depthStencil}var Vn={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=W(r);o.depthWriteEnabled=e},depthCompare:function(n,e,r){var o=W(r);o.depthCompare=e},depthFormat:function(n,e,r){var o=W(r);o.format=e},depthBias:function(n,e,r){var o=W(r);o.depthBias=e},depthBiasSlopeScale:function(n,e,r){var o=W(r);o.depthBiasSlopeScale=e},depthBiasClamp:function(n,e,r){var o=W(r);o.depthBiasClamp=e},stencilReadMask:function(n,e,r){var o=W(r);o.stencilReadMask=e},stencilWriteMask:function(n,e,r){var o=W(r);o.stencilWriteMask=e},stencilCompare:function(n,e,r){var o=W(r);o.stencilFront.compare=e,o.stencilBack.compare=e},stencilPassOperation:function(n,e,r){var o=W(r);o.stencilFront.passOp=e,o.stencilBack.passOp=e},stencilFailOperation:function(n,e,r){var o=W(r);o.stencilFront.failOp=e,o.stencilBack.failOp=e},stencilDepthFailOperation:function(n,e,r){var o=W(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=mr(r);o[0].writeMask=e},blendColorOperation:function(n,e,r){mr(r)}},$n={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function gr(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Object.assign(t,dr(dr({},$n),t)),Yn(t,n)}function Yn(t,n){for(var e=0,r=Object.entries(n);e<r.length;e++){var o=A(r[e],2),i=o[0],a=o[1],c=Vn[i];if(!c)throw new Error("Illegal parameter ".concat(i));c(i,a,t)}}function mr(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 vr(t,n,e,r){var o=qn(r,e);return t.createBindGroup({layout:n,entries:o})}function Kn(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 qn(t,n){for(var e=[],r=0,o=Object.entries(t);r<o.length;r++){var i=A(o[r],2),a=i[0],c=i[1],u=Kn(n,a);u&&e.push(Xn(c,u.location))}return e}function Xn(t,n){if(t instanceof j)return{binding:n,resource:{buffer:t.handle}};if(t instanceof he)return{binding:n,resource:t.handle};if(t instanceof N)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=Jn(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 Jn(t,n){if(t){if(typeof t=="string")return yr(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 yr(t,n)}}function yr(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 st(t){if(t.endsWith("-webgl"))throw new Error("WebGPU does not support vertex format ".concat(t));return t}function _r(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(a.attributes){var O=ge(a.attributes),S;try{for(O.s();!(S=O.n()).done;){var T=S.value,E=br(t,T.name,r);u=E.stepMode||"vertex",c.push({format:st(T.format||a.format),offset:y+m,shaderLocation:E.location}),m+=Pe(a.format).byteLength}}catch(M){O.e(M)}finally{O.f()}}else{var H=br(t,a.name,r);m=Pe(a.format).byteLength,u=H.stepMode||"vertex",c.push({format:st(a.format),offset:y,shaderLocation:H.location})}e.push({arrayStride:a.byteStride||m,stepMode:u||"vertex",attributes:c})}}catch(M){o.e(M)}finally{o.f()}var G=ge(t.attributes),z;try{for(G.s();!(z=G.n()).done;){var B=z.value;r.has(B.name)||e.push({arrayStride:Pe("float32x3").byteLength,stepMode:B.stepMode||"vertex",attributes:[{format:st("float32x3"),offset:0,shaderLocation:B.location}]})}}catch(M){G.e(M)}finally{G.f()}return e}function wr(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 T=S.value;e.has(T.name)||(o[T.name]=r++)}}catch(E){O.e(E)}finally{O.f()}return o}function br(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 Qn(t){var n=Zn();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 Zn(){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 Pr=function(t){w(e,t);var n=Qn(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=wr(i.props.shaderLayout,i.props.bufferLayout),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=A(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){throw new Error("not implemented")}},{key:"setBindings",value:function(o){Be(this.props.bindings)||(Object.assign(this.props.bindings,o),this._bindGroup=vr(this.device.handle,this._bindGroupLayout,this.props.shaderLayout,this.props.bindings))}},{key:"setUniforms",value:function(o){if(!Be(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:_r(this.props.shaderLayout,this.props.bufferLayout)},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-webgl":case"line-loop-webgl":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 gr(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.shaderLayout.attributes.find(function(T){return T.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}(Ue);function eo(t){var n=to();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 to(){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=eo(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}(Fe);function Or(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 xr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Or(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Or(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}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 Cr=function(t){w(e,t);var n=ro(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=xr(xr({},this.props),{},{view:o.depthStencilAttachment.handle.createView()})),a}}]),e}(We);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 Rr=function(t){w(e,t);var n=oo(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}(ze);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 Tr=function(t){w(e,t);var n=ao(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)}(Me);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 ut=function(t){w(e,t);var n=uo(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 Tr(this.device,{colorAttachments:[o],depthStencilAttachment:this.depthStencilAttachment})}},{key:"update",value:function(){var o=this.getPixelSize(),i=A(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}(pe);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 kr(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}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 ct=function(t){w(e,t);var n=lo(e);function e(r,o,i){var a;return g(this,e),a=n.call(this,kr(kr({},i),{},{id:i.id||se("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=K(Oe.default.mark(function u(m){var y;return Oe.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 ut(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 He(this,i)}},{key:"_createTexture",value:function(o){return new Ve(this,o)}},{key:"createExternalTexture",value:function(o){return new pr(this,o)}},{key:"createShader",value:function(o){return new $e(this,o)}},{key:"createSampler",value:function(o){return new F(this,o)}},{key:"createRenderPipeline",value:function(o){return new Pr(this,o)}},{key:"createFramebuffer",value:function(o){throw new Error("Not implemented")}},{key:"createComputePipeline",value:function(o){return new Sr(this,o)}},{key:"beginRenderPass",value:function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Cr(this,o)}},{key:"beginComputePass",value:function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Rr(this,o)}},{key:"createCanvasContext",value:function(o){return new ut(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,T=S===void 0?0:S,E=o.aspect,H=E===void 0?"all":E,G=o.colorSpace,z=G===void 0?"display-p3":G,B=o.premultipliedAlpha,M=B===void 0?!1:B,V=o.width,ve=V===void 0?O.width:V,J=o.height,ye=J===void 0?O.height:J,Y=o.depth,te=Y===void 0?1:Y,Q=O;(i=this.handle)===null||i===void 0||i.queue.copyExternalImageToTexture({source:a,origin:[u,y]},{texture:Q.handle,origin:[0,0,0],mipLevel:T,aspect:H,colorSpace:z,premultipliedAlpha:M},[ve,ye,te])}}],[{key:"isSupported",value:function(){return Boolean(typeof navigator<"u"&&navigator.gpu)}},{key:"create",value:function(){var r=K(Oe.default.mark(function i(a){var c,u,m,y;return Oe.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,pe.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}(Ie);s(ct,"type","webgpu");return Lr(po);})();
|
|
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.
|
|
3
|
+
"version": "9.0.0-alpha.32",
|
|
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/core": "9.0.0-alpha.
|
|
40
|
+
"@luma.gl/core": "9.0.0-alpha.32",
|
|
41
41
|
"@probe.gl/env": "^4.0.2",
|
|
42
42
|
"@webgpu/types": "^0.1.34"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "08b30dcae4aee321738cf05b509cef6b3b24c880"
|
|
45
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// luma.gl MIT license
|
|
2
2
|
|
|
3
|
-
import type {Binding,
|
|
3
|
+
import type {TypedArray, Binding, UniformValue, RenderPass} from '@luma.gl/core';
|
|
4
4
|
import {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/core';
|
|
5
5
|
import {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';
|
|
6
6
|
import {getWebGPUTextureFormat} from '../helpers/convert-texture-format';
|
|
@@ -85,12 +85,10 @@ export class WebGPURenderPipeline extends RenderPipeline {
|
|
|
85
85
|
// }
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
/** Constant attributes are not available in WebGPU */
|
|
89
88
|
setConstantAttributes(attributes: Record<string, TypedArray>): void {
|
|
90
89
|
throw new Error('not implemented');
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
/** Set the bindings */
|
|
94
92
|
setBindings(bindings: Record<string, Binding>): void {
|
|
95
93
|
if (!isObjectEmpty(this.props.bindings)) {
|
|
96
94
|
Object.assign(this.props.bindings, bindings);
|
|
@@ -104,7 +102,7 @@ export class WebGPURenderPipeline extends RenderPipeline {
|
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
|
|
107
|
-
setUniforms(uniforms: Record<string,
|
|
105
|
+
setUniforms(uniforms: Record<string, UniformValue>): void {
|
|
108
106
|
if (!isObjectEmpty(uniforms)) {
|
|
109
107
|
throw new Error('WebGPU does not support uniforms');
|
|
110
108
|
}
|