dcgrid 0.0.0-stage → 0.2.1
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/LICENSE.md +674 -0
- package/README.md +55 -2
- package/THIRD_PARTY_NOTICES.md +140 -0
- package/dist/dcgrid.d.mts +3 -0
- package/dist/dcgrid.mjs +2 -0
- package/dist/dcgrid.wasm +0 -0
- package/dist/index.d.ts +259 -0
- package/dist/index.js +333 -0
- package/package.json +50 -4
package/README.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dcgrid
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Adaptive-grid smoke simulation on WebGPU: [DCGrid](https://graphics.tudelft.nl/~klaus/papers/DCGrid.pdf) compiled to WebAssembly, on a `GPUDevice` you own.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { DCGrid } from "dcgrid";
|
|
7
|
+
|
|
8
|
+
const adapter = await navigator.gpu.requestAdapter();
|
|
9
|
+
const device = await adapter!.requestDevice({
|
|
10
|
+
requiredLimits: {
|
|
11
|
+
maxStorageBuffersPerShaderStage: adapter!.limits.maxStorageBuffersPerShaderStage,
|
|
12
|
+
maxStorageBufferBindingSize: adapter!.limits.maxStorageBufferBindingSize,
|
|
13
|
+
maxBufferSize: adapter!.limits.maxBufferSize,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const dcgrid = await DCGrid.load();
|
|
18
|
+
const sim = dcgrid.create(device, {
|
|
19
|
+
size: [128, 256, 128], // cells
|
|
20
|
+
cellSize: 40, // meters
|
|
21
|
+
maxBlocks: 20000, // memory budget of the adaptive grid (blocks of 4³ cells)
|
|
22
|
+
faces: { "-y": { type: "inflow", velocity: [0, 100, 0], density: 0.002 } },
|
|
23
|
+
});
|
|
24
|
+
await sim.whenReady();
|
|
25
|
+
|
|
26
|
+
for (;;) {
|
|
27
|
+
sim.poll();
|
|
28
|
+
if (sim.stepsInFlight < 2) sim.step();
|
|
29
|
+
await new Promise(requestAnimationFrame);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Scenes
|
|
34
|
+
|
|
35
|
+
- **Faces**: each of `-x`, `+x`, `-y`, `+y`, `-z`, `+z` is `no_slip` (default), `free_slip`, `inflow` or `outflow`. Inflow faces take a uniform velocity and density, or a value per cell with `sim.setInflowMap(face, Float32Array)`.
|
|
36
|
+
- **Solids**: `sim.setSolids({ size, data })`, a signed distance in meters (negative inside).
|
|
37
|
+
- **Sources**: `sim.setSources(density, velocity)`, rates per second added every step.
|
|
38
|
+
|
|
39
|
+
Volumes span the domain at any resolution, x fastest, with voxels on the domain's corners. `dcgrid.describeScene(i, resolution)` and `sim.applyScene(i)` load the five preset scenes of the demo (sphere obstacle, open plume, wind over hills, wildfire, clouds over mountains; the last two use the weather extension).
|
|
40
|
+
|
|
41
|
+
## Output
|
|
42
|
+
|
|
43
|
+
- `await sim.sampleField("density" | "velocity" | "fluidity" | "cell_size", texture)` resamples a field into a 3D `GPUTexture` (`r32float`, `rgba16float` or `rgba32float` with `STORAGE_BINDING`) for your own renderer.
|
|
44
|
+
- `sim.createRenderer()` is the optional raymarcher of the demo: `renderer.render(camera, settings, texture)` into an `rgba8unorm` texture with `STORAGE_BINDING`.
|
|
45
|
+
|
|
46
|
+
## Behavior
|
|
47
|
+
|
|
48
|
+
Nothing blocks. `create` and `reset` return at once; `whenReady()` resolves once the pipelines are compiled and the grid is initialized. `step()` submits to the device queue without waiting. The adaptive grid reads refinement scores back asynchronously and applies them in a later step; `stepsInFlight` counts a step until its readback has arrived. Errors are `DCGridError`s with a `code` (`invalid_argument`, `unsupported`, `not_ready`, `device`).
|
|
49
|
+
|
|
50
|
+
`dcgrid.wasm` is loaded from next to `dcgrid.mjs` (bundlers that handle `new URL(..., import.meta.url)` pick it up; Vite needs `optimizeDeps.exclude: ["dcgrid"]`). `DCGrid.load({ wasm })` takes another URL or the bytes.
|
|
51
|
+
|
|
52
|
+
## Building
|
|
53
|
+
|
|
54
|
+
`npm run build` compiles the library with Emscripten (installing the SDK into `../.emsdk` when `emcc` is not on the PATH) and the TypeScript wrapper into `dist/`. `npm test` runs the API checks on Dawn for Node (needs a GPU).
|
|
55
|
+
|
|
56
|
+
Licence: GPL-3.0.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The WebAssembly module and its JavaScript glue (dcgrid.wasm, dcgrid.mjs) include code from the projects below.
|
|
4
|
+
|
|
5
|
+
## nlohmann/json 3.11.3
|
|
6
|
+
|
|
7
|
+
https://github.com/nlohmann/json
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2013-2022 Niels Lohmann
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Emscripten and its WebGPU bindings (emdawnwebgpu)
|
|
34
|
+
|
|
35
|
+
https://github.com/emscripten-core/emscripten
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
Emscripten is available under 2 licenses, the MIT license and the
|
|
39
|
+
University of Illinois/NCSA Open Source License.
|
|
40
|
+
|
|
41
|
+
Both are permissive open source licenses, with little if any
|
|
42
|
+
practical difference between them.
|
|
43
|
+
|
|
44
|
+
The reason for offering both is that (1) the MIT license is
|
|
45
|
+
well-known, while (2) the University of Illinois/NCSA Open Source
|
|
46
|
+
License allows Emscripten's code to be integrated upstream into
|
|
47
|
+
LLVM, which uses that license, should the opportunity arise.
|
|
48
|
+
|
|
49
|
+
The full text of both licenses follows.
|
|
50
|
+
|
|
51
|
+
==============================================================================
|
|
52
|
+
|
|
53
|
+
Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file.
|
|
54
|
+
|
|
55
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
56
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
57
|
+
in the Software without restriction, including without limitation the rights
|
|
58
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
59
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
60
|
+
furnished to do so, subject to the following conditions:
|
|
61
|
+
|
|
62
|
+
The above copyright notice and this permission notice shall be included in
|
|
63
|
+
all copies or substantial portions of the Software.
|
|
64
|
+
|
|
65
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
66
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
67
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
68
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
69
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
70
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
71
|
+
THE SOFTWARE.
|
|
72
|
+
|
|
73
|
+
==============================================================================
|
|
74
|
+
|
|
75
|
+
Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file.
|
|
76
|
+
All rights reserved.
|
|
77
|
+
|
|
78
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
79
|
+
copy of this software and associated documentation files (the
|
|
80
|
+
"Software"), to deal with the Software without restriction, including
|
|
81
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
82
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
83
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
84
|
+
the following conditions:
|
|
85
|
+
|
|
86
|
+
Redistributions of source code must retain the above copyright
|
|
87
|
+
notice, this list of conditions and the following disclaimers.
|
|
88
|
+
|
|
89
|
+
Redistributions in binary form must reproduce the above
|
|
90
|
+
copyright notice, this list of conditions and the following disclaimers
|
|
91
|
+
in the documentation and/or other materials provided with the
|
|
92
|
+
distribution.
|
|
93
|
+
|
|
94
|
+
Neither the names of Mozilla,
|
|
95
|
+
nor the names of its contributors may be used to endorse
|
|
96
|
+
or promote products derived from this Software without specific prior
|
|
97
|
+
written permission.
|
|
98
|
+
|
|
99
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
100
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
101
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
102
|
+
IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
103
|
+
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
104
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
105
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
|
|
106
|
+
|
|
107
|
+
==============================================================================
|
|
108
|
+
|
|
109
|
+
This program uses portions of Node.js source code located in src/library_path.js,
|
|
110
|
+
in accordance with the terms of the MIT license. Node's license follows:
|
|
111
|
+
|
|
112
|
+
"""
|
|
113
|
+
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
114
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
115
|
+
of this software and associated documentation files (the "Software"), to
|
|
116
|
+
deal in the Software without restriction, including without limitation the
|
|
117
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
118
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
|
119
|
+
furnished to do so, subject to the following conditions:
|
|
120
|
+
|
|
121
|
+
The above copyright notice and this permission notice shall be included in
|
|
122
|
+
all copies or substantial portions of the Software.
|
|
123
|
+
|
|
124
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
125
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
126
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
127
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
128
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
129
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
130
|
+
IN THE SOFTWARE.
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
The musl libc project is bundled in this repo, and it has the MIT license, see
|
|
134
|
+
system/lib/libc/musl/COPYRIGHT
|
|
135
|
+
|
|
136
|
+
The third_party/ subdirectory contains code with other licenses. None of it is
|
|
137
|
+
used by default, but certain options use it (e.g., the optional closure compiler
|
|
138
|
+
flag will run closure compiler from third_party/).
|
|
139
|
+
|
|
140
|
+
```
|
package/dist/dcgrid.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
async function createDCGridModule(moduleArg={}){var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await(import("node:module"));var require=createRequire(import.meta.url)}var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"])return Module["locateFile"](path,scriptDirectory);return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:"))scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?void 0:"utf8");return ret};if(process.argv.length>1)thisProgram=process.argv[1].replace(/\\/g,"/");process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}if(ENVIRONMENT_IS_WORKER)readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)};readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok)return response.arrayBuffer();throw new Error(response.status+" : "+response.url)}}console.log.bind(console);var err=console.error.bind(console);var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition)abort(text)}var isFileURI=filename=>filename.startsWith("file://");var runtimeInitialized=false;function getMemoryBuffer(){return wasmMemory.buffer}function updateMemoryViews(){if(HEAP8?.buffer?.resizable)return;var b=getMemoryBuffer();HEAP8=new Int8Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b)}function preRun(){var preRun=Module["preRun"];if(preRun){if(typeof preRun==="function")preRun=[preRun];onPreRuns.push(...preRun)}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["W"]()}function postRun(){var postRun=Module["postRun"];if(postRun){if(typeof postRun==="function")postRun=[postRun];onPostRuns.push(...postRun)}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what=`Aborted(${what})`;err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";if(runtimeInitialized)___trap();throw new WebAssembly.RuntimeError(what)}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"])return locateFile("dcgrid.wasm");return new URL("dcgrid.wasm",import.meta.url).href}function getBinarySync(file){if(readBinary)return readBinary(file);throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(true)try{return await readAsync(binaryFile)}catch{}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!ENVIRONMENT_IS_NODE)try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var HEAP8;var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0)callbacks.shift()(Module)};var onPostRuns=[];var onPreRuns=[];var noExitRuntime=true;var HEAP32;var HEAPU32;var HEAPU8;var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var HEAP64;var bigintToI53Checked=num=>num<-9007199254740992||num>9007199254740992?NaN:Number(num);var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;var _emscripten_date_now=()=>Date.now();var _emscripten_get_now=()=>performance.now();var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var getHeapMax=()=>2147483648;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var HEAPF32;var HEAPF64;var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder)return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr));var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224)u0=(u0&15)<<12|u1<<6|u2;else u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63;if(u0<65536)str+=String.fromCharCode(u0);else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString_cache={};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>{var useCache=maxBytesToRead==null&&ptr>=1024&&ptr<148984;if(useCache){var rtn=UTF8ToString_cache[ptr];if(rtn!=null)return rtn}rtn=ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead,ignoreNul):"";if(useCache)UTF8ToString_cache[ptr]=rtn;return rtn};var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func)wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr);return func};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127)len++;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else{len+=4;i++}}return len};var readI53FromI64=ptr=>HEAPU32[ptr>>2]+HEAP32[ptr+4>>2]*4294967296;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var stringToNewUTF8=str=>{var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8(str,ret,size);return ret};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var writeI53ToI64=(ptr,num)=>{HEAPU32[ptr>>2]=num;var lower=HEAPU32[ptr>>2];HEAPU32[ptr+4>>2]=(num-lower)/4294967296};var WebGPU={Internals:{jsObjects:[],jsObjectInsert:(ptr,jsObject)=>{ptr>>>=0;WebGPU.Internals.jsObjects[ptr]=jsObject},bufferOnUnmaps:[],futures:[],futureInsert:()=>{}},getJsObject:ptr=>{if(!ptr)return;ptr>>>=0;return WebGPU.Internals.jsObjects[ptr]},importJsAdapter:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateAdapter(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsBindGroup:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateBindGroup(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsBindGroupLayout:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateBindGroupLayout(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsBuffer:(buffer,parentPtr=0)=>{assert(buffer.mapState==="unmapped");var bufferPtr=_emwgpuImportBuffer(parentPtr);WebGPU.Internals.jsObjectInsert(bufferPtr,buffer);return bufferPtr},importJsCommandBuffer:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateCommandBuffer(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsCommandEncoder:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateCommandEncoder(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsComputePassEncoder:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateComputePassEncoder(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsComputePipeline:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateComputePipeline(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsDevice:(device,parentPtr=0)=>{var queuePtr=_emwgpuCreateQueue(parentPtr);var devicePtr=_emwgpuCreateDevice(parentPtr,queuePtr);WebGPU.Internals.jsObjectInsert(queuePtr,device.queue);WebGPU.Internals.jsObjectInsert(devicePtr,device);return devicePtr},importJsExternalTexture:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateExternalTexture(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsPipelineLayout:(obj,parentPtr=0)=>{var ptr=_emwgpuCreatePipelineLayout(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsQuerySet:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateQuerySet(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsQueue:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateQueue(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsRenderBundle:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateRenderBundle(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsRenderBundleEncoder:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateRenderBundleEncoder(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsRenderPassEncoder:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateRenderPassEncoder(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsRenderPipeline:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateRenderPipeline(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsSampler:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateSampler(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsShaderModule:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateShaderModule(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsSurface:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateSurface(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsTexture:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateTexture(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},importJsTextureView:(obj,parentPtr=0)=>{var ptr=_emwgpuCreateTextureView(parentPtr);WebGPU.Internals.jsObjects[ptr]=obj;return ptr},errorCallback:(callback,type,message,userdata)=>{var sp=stackSave();var messagePtr=stringToUTF8OnStack(message);getWasmTableEntry(callback)(type,messagePtr,userdata);stackRestore(sp)},iterateExtensions:(root,handlers)=>{for(var ptr=HEAPU32[root>>2];ptr;ptr=HEAPU32[ptr>>2]){var sType=HEAP32[ptr+4>>2];handlers[sType](ptr)}},setStringView:(ptr,data,length)=>{HEAPU32[ptr>>2]=data;HEAPU32[ptr+4>>2]=length},makeStringFromStringView:stringViewPtr=>{var ptr=HEAPU32[stringViewPtr>>2];var length=HEAPU32[stringViewPtr+4>>2];return UTF8ToString(ptr,length)},makeStringFromOptionalStringView:stringViewPtr=>{var ptr=HEAPU32[stringViewPtr>>2];var length=HEAPU32[stringViewPtr+4>>2];if(!ptr){if(length===0)return"";return}return UTF8ToString(ptr,length)},makeColor:ptr=>({r:HEAPF64[ptr>>3],g:HEAPF64[ptr+8>>3],b:HEAPF64[ptr+16>>3],a:HEAPF64[ptr+24>>3]}),makeExtent3D:ptr=>({width:HEAPU32[ptr>>2],height:HEAPU32[ptr+4>>2],depthOrArrayLayers:HEAPU32[ptr+8>>2]}),makeOrigin3D:ptr=>({x:HEAPU32[ptr>>2],y:HEAPU32[ptr+4>>2],z:HEAPU32[ptr+8>>2]}),makeTexelCopyTextureInfo:ptr=>({texture:WebGPU.getJsObject(HEAPU32[ptr>>2]),mipLevel:HEAPU32[ptr+4>>2],origin:WebGPU.makeOrigin3D(ptr+8),aspect:WebGPU.TextureAspect[HEAP32[ptr+20>>2]]}),makeTexelCopyBufferLayout:ptr=>{var bytesPerRow=HEAPU32[ptr+8>>2];var rowsPerImage=HEAPU32[ptr+12>>2];return{offset:readI53FromI64(ptr),bytesPerRow:bytesPerRow===4294967295?void 0:bytesPerRow,rowsPerImage:rowsPerImage===4294967295?void 0:rowsPerImage}},makeTexelCopyBufferInfo:ptr=>{var layoutPtr=ptr+0;var bufferCopyView=WebGPU.makeTexelCopyBufferLayout(layoutPtr);bufferCopyView["buffer"]=WebGPU.getJsObject(HEAPU32[ptr+16>>2]);return bufferCopyView},makePassTimestampWrites:ptr=>{if(ptr===0)return;return{querySet:WebGPU.getJsObject(HEAPU32[ptr+4>>2]),beginningOfPassWriteIndex:HEAPU32[ptr+8>>2],endOfPassWriteIndex:HEAPU32[ptr+12>>2]}},makePipelineConstants:(constantCount,constantsPtr)=>{if(!constantCount)return;var constants={};for(var i=0;i<constantCount;++i){var entryPtr=constantsPtr+24*i;var key=WebGPU.makeStringFromStringView(entryPtr+4);constants[key]=HEAPF64[entryPtr+16>>3]}return constants},makePipelineLayout:layoutPtr=>{if(!layoutPtr)return"auto";return WebGPU.getJsObject(layoutPtr)},makeComputeState:ptr=>{if(!ptr)return;var desc={module:WebGPU.getJsObject(HEAPU32[ptr+4>>2]),constants:WebGPU.makePipelineConstants(HEAPU32[ptr+16>>2],HEAPU32[ptr+20>>2]),entryPoint:WebGPU.makeStringFromOptionalStringView(ptr+8)};return desc},makeComputePipelineDesc:descriptor=>{var desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),layout:WebGPU.makePipelineLayout(HEAPU32[descriptor+12>>2]),compute:WebGPU.makeComputeState(descriptor+16)};return desc},makeRenderPipelineDesc:descriptor=>{function makeBlendComponent(bdPtr){if(!bdPtr)return;return{operation:WebGPU.BlendOperation[HEAP32[bdPtr>>2]],srcFactor:WebGPU.BlendFactor[HEAP32[bdPtr+4>>2]],dstFactor:WebGPU.BlendFactor[HEAP32[bdPtr+8>>2]]}}function makeBlendState(bsPtr){if(!bsPtr)return;return{alpha:makeBlendComponent(bsPtr+12),color:makeBlendComponent(bsPtr+0)}}function makeColorState(csPtr){var format=WebGPU.TextureFormat[HEAP32[csPtr+4>>2]];return format?{format,blend:makeBlendState(HEAPU32[csPtr+8>>2]),writeMask:HEAPU32[csPtr+16>>2]}:void 0}function makeColorStates(count,csArrayPtr){var states=[];for(var i=0;i<count;++i)states.push(makeColorState(csArrayPtr+24*i));return states}function makeStencilStateFace(ssfPtr){return{compare:WebGPU.CompareFunction[HEAP32[ssfPtr>>2]],failOp:WebGPU.StencilOperation[HEAP32[ssfPtr+4>>2]],depthFailOp:WebGPU.StencilOperation[HEAP32[ssfPtr+8>>2]],passOp:WebGPU.StencilOperation[HEAP32[ssfPtr+12>>2]]}}function makeVertexAttribute(vaPtr){return{format:WebGPU.VertexFormat[HEAP32[vaPtr+4>>2]],offset:readI53FromI64(vaPtr+8),shaderLocation:HEAPU32[vaPtr+16>>2]}}function makeVertexAttributes(count,vaArrayPtr){var vas=[];for(var i=0;i<count;++i)vas.push(makeVertexAttribute(vaArrayPtr+i*24));return vas}function makeVertexBuffer(vbPtr){if(!vbPtr)return;var stepMode=WebGPU.VertexStepMode[HEAP32[vbPtr+4>>2]];var attributeCount=HEAPU32[vbPtr+16>>2];if(!stepMode&&!attributeCount)return null;return{arrayStride:readI53FromI64(vbPtr+8),stepMode,attributes:makeVertexAttributes(attributeCount,HEAPU32[vbPtr+20>>2])}}function makeVertexBuffers(count,vbArrayPtr){if(!count)return;var vbs=[];for(var i=0;i<count;++i)vbs.push(makeVertexBuffer(vbArrayPtr+i*24));return vbs}var desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),layout:WebGPU.makePipelineLayout(HEAPU32[descriptor+12>>2]),vertex:function(viPtr){if(!viPtr)return;var desc={module:WebGPU.getJsObject(HEAPU32[viPtr+4>>2]),constants:WebGPU.makePipelineConstants(HEAPU32[viPtr+16>>2],HEAPU32[viPtr+20>>2]),buffers:makeVertexBuffers(HEAPU32[viPtr+24>>2],HEAPU32[viPtr+28>>2]),entryPoint:WebGPU.makeStringFromOptionalStringView(viPtr+8)};return desc}(descriptor+16),primitive:function(psPtr){if(!psPtr)return;return{topology:WebGPU.PrimitiveTopology[HEAP32[psPtr+4>>2]],stripIndexFormat:WebGPU.IndexFormat[HEAP32[psPtr+8>>2]],frontFace:WebGPU.FrontFace[HEAP32[psPtr+12>>2]],cullMode:WebGPU.CullMode[HEAP32[psPtr+16>>2]],unclippedDepth:!!HEAPU32[psPtr+20>>2]}}(descriptor+48),depthStencil:function(dssPtr){if(!dssPtr)return;return{format:WebGPU.TextureFormat[HEAP32[dssPtr+4>>2]],depthWriteEnabled:!!HEAPU32[dssPtr+8>>2],depthCompare:WebGPU.CompareFunction[HEAP32[dssPtr+12>>2]],stencilFront:makeStencilStateFace(dssPtr+16),stencilBack:makeStencilStateFace(dssPtr+32),stencilReadMask:HEAPU32[dssPtr+48>>2],stencilWriteMask:HEAPU32[dssPtr+52>>2],depthBias:HEAP32[dssPtr+56>>2],depthBiasSlopeScale:HEAPF32[dssPtr+60>>2],depthBiasClamp:HEAPF32[dssPtr+64>>2]}}(HEAPU32[descriptor+72>>2]),multisample:function(msPtr){if(!msPtr)return;return{count:HEAPU32[msPtr+4>>2],mask:HEAPU32[msPtr+8>>2],alphaToCoverageEnabled:!!HEAPU32[msPtr+12>>2]}}(descriptor+76),fragment:function(fsPtr){if(!fsPtr)return;var desc={module:WebGPU.getJsObject(HEAPU32[fsPtr+4>>2]),constants:WebGPU.makePipelineConstants(HEAPU32[fsPtr+16>>2],HEAPU32[fsPtr+20>>2]),targets:makeColorStates(HEAPU32[fsPtr+24>>2],HEAPU32[fsPtr+28>>2]),entryPoint:WebGPU.makeStringFromOptionalStringView(fsPtr+8)};return desc}(HEAPU32[descriptor+92>>2])};return desc},fillLimitStruct:(limits,limitsOutPtr)=>{var nextInChainPtr=HEAPU32[limitsOutPtr>>2];function setLimitValueU32(name,basePtr,limitOffset,fallbackValue=0){var limitValue=limits[name]??fallbackValue;HEAPU32[basePtr+limitOffset>>2]=limitValue}function setLimitValueU64(name,basePtr,limitOffset,fallbackValue=0){var limitValue=limits[name]??fallbackValue;writeI53ToI64(basePtr+limitOffset,limitValue)}setLimitValueU32("maxTextureDimension1D",limitsOutPtr,4);setLimitValueU32("maxTextureDimension2D",limitsOutPtr,8);setLimitValueU32("maxTextureDimension3D",limitsOutPtr,12);setLimitValueU32("maxTextureArrayLayers",limitsOutPtr,16);setLimitValueU32("maxBindGroups",limitsOutPtr,20);setLimitValueU32("maxBindGroupsPlusVertexBuffers",limitsOutPtr,24);setLimitValueU32("maxBindingsPerBindGroup",limitsOutPtr,28);setLimitValueU32("maxDynamicUniformBuffersPerPipelineLayout",limitsOutPtr,32);setLimitValueU32("maxDynamicStorageBuffersPerPipelineLayout",limitsOutPtr,36);setLimitValueU32("maxSampledTexturesPerShaderStage",limitsOutPtr,40);setLimitValueU32("maxSamplersPerShaderStage",limitsOutPtr,44);setLimitValueU32("maxStorageBuffersPerShaderStage",limitsOutPtr,48);setLimitValueU32("maxStorageTexturesPerShaderStage",limitsOutPtr,52);setLimitValueU32("maxUniformBuffersPerShaderStage",limitsOutPtr,56);setLimitValueU32("minUniformBufferOffsetAlignment",limitsOutPtr,80);setLimitValueU32("minStorageBufferOffsetAlignment",limitsOutPtr,84);setLimitValueU64("maxUniformBufferBindingSize",limitsOutPtr,64);setLimitValueU64("maxStorageBufferBindingSize",limitsOutPtr,72);setLimitValueU32("maxVertexBuffers",limitsOutPtr,88);setLimitValueU64("maxBufferSize",limitsOutPtr,96);setLimitValueU32("maxVertexAttributes",limitsOutPtr,104);setLimitValueU32("maxVertexBufferArrayStride",limitsOutPtr,108);setLimitValueU32("maxInterStageShaderVariables",limitsOutPtr,112);setLimitValueU32("maxColorAttachments",limitsOutPtr,116);setLimitValueU32("maxColorAttachmentBytesPerSample",limitsOutPtr,120);setLimitValueU32("maxComputeWorkgroupStorageSize",limitsOutPtr,124);setLimitValueU32("maxComputeInvocationsPerWorkgroup",limitsOutPtr,128);setLimitValueU32("maxComputeWorkgroupSizeX",limitsOutPtr,132);setLimitValueU32("maxComputeWorkgroupSizeY",limitsOutPtr,136);setLimitValueU32("maxComputeWorkgroupSizeZ",limitsOutPtr,140);setLimitValueU32("maxComputeWorkgroupsPerDimension",limitsOutPtr,144);setLimitValueU32("maxImmediateSize",limitsOutPtr,148);if(nextInChainPtr!==0){HEAP32[nextInChainPtr+4>>2];var compatibilityModeLimitsPtr=nextInChainPtr;setLimitValueU32("maxStorageBuffersInVertexStage",compatibilityModeLimitsPtr,8,limits.maxStorageBuffersPerShaderStage);setLimitValueU32("maxStorageBuffersInFragmentStage",compatibilityModeLimitsPtr,16,limits.maxStorageBuffersPerShaderStage);setLimitValueU32("maxStorageTexturesInVertexStage",compatibilityModeLimitsPtr,12,limits.maxStorageTexturesPerShaderStage);setLimitValueU32("maxStorageTexturesInFragmentStage",compatibilityModeLimitsPtr,20,limits.maxStorageTexturesPerShaderStage)}},fillAdapterInfoStruct:(info,infoStruct)=>{HEAPU32[infoStruct+52>>2]=info.subgroupMinSize;HEAPU32[infoStruct+56>>2]=info.subgroupMaxSize;var strs=info.vendor+info.architecture+info.device+info.description;var strPtr=stringToNewUTF8(strs);var vendorLen=lengthBytesUTF8(info.vendor);WebGPU.setStringView(infoStruct+4,strPtr,vendorLen);strPtr+=vendorLen;var architectureLen=lengthBytesUTF8(info.architecture);WebGPU.setStringView(infoStruct+12,strPtr,architectureLen);strPtr+=architectureLen;var deviceLen=lengthBytesUTF8(info.device);WebGPU.setStringView(infoStruct+20,strPtr,deviceLen);strPtr+=deviceLen;var descriptionLen=lengthBytesUTF8(info.description);WebGPU.setStringView(infoStruct+28,strPtr,descriptionLen);strPtr+=descriptionLen;HEAP32[infoStruct+36>>2]=2;var adapterType=info.isFallbackAdapter?3:4;HEAP32[infoStruct+40>>2]=adapterType;HEAPU32[infoStruct+44>>2]=0;HEAPU32[infoStruct+48>>2]=0;WebGPU.iterateExtensions(infoStruct,{327739:ext=>{let configCount=0;let configsPtr=0;if(info.subgroupMatrixConfigs){configCount=info.subgroupMatrixConfigs.length;configsPtr=_malloc(configCount*28);for(const[i,cfg]of info.subgroupMatrixConfigs.entries()){const ptr=configsPtr+i*28;const componentType=WebGPU.SubgroupMatrixComponentType.indexOf(cfg.componentType);const resultComponentType=WebGPU.SubgroupMatrixComponentType.indexOf(cfg.resultComponentType);HEAP32[ptr>>2]=componentType;HEAP32[ptr+4>>2]=resultComponentType;HEAPU32[ptr+8>>2]=cfg.M;HEAPU32[ptr+12>>2]=cfg.N;HEAPU32[ptr+16>>2]=cfg.K}}HEAPU32[ext+12>>2]=configsPtr;HEAPU32[ext+8>>2]=configCount}})},AddressMode:[,"clamp-to-edge","repeat","mirror-repeat"],BlendFactor:[,"zero","one","src","one-minus-src","src-alpha","one-minus-src-alpha","dst","one-minus-dst","dst-alpha","one-minus-dst-alpha","src-alpha-saturated","constant","one-minus-constant","src1","one-minus-src1","src1-alpha","one-minus-src1-alpha"],BlendOperation:[,"add","subtract","reverse-subtract","min","max"],BufferBindingType:[,,"uniform","storage","read-only-storage"],BufferMapState:[,"unmapped","pending","mapped"],CompareFunction:[,"never","less","equal","less-equal","greater","not-equal","greater-equal","always"],CompilationInfoRequestStatus:[,"success","callback-cancelled"],ComponentSwizzle:[,"0","1","r","g","b","a"],CompositeAlphaMode:[,"opaque","premultiplied","unpremultiplied","inherit"],CullMode:[,"none","front","back"],ErrorFilter:[,"validation","out-of-memory","internal"],FeatureLevel:[,"compatibility","core"],FeatureName:{1:"core-features-and-limits",2:"depth-clip-control",3:"depth32float-stencil8",4:"texture-compression-bc",5:"texture-compression-bc-sliced-3d",6:"texture-compression-etc2",7:"texture-compression-astc",8:"texture-compression-astc-sliced-3d",9:"timestamp-query",10:"indirect-first-instance",11:"shader-f16",12:"rg11b10ufloat-renderable",13:"bgra8unorm-storage",14:"float32-filterable",15:"float32-blendable",16:"clip-distances",17:"dual-source-blending",18:"subgroups",19:"texture-formats-tier1",20:"texture-formats-tier2",21:"primitive-index",22:"texture-component-swizzle",23:"subgroup-size-control",24:"texture-compression-unaligned",25:"atomic-vec2u-min-max",327692:"chromium-experimental-unorm16-texture-formats",327729:"chromium-experimental-multi-draw-indirect",327732:"chromium-experimental-subgroup-matrix"},FilterMode:[,"nearest","linear"],FrontFace:[,"ccw","cw"],IndexFormat:[,"uint16","uint32"],InstanceFeatureName:[,"timed-wait-any","shader-source-spirv","multiple-devices-per-adapter"],LoadOp:[,"load","clear"],MipmapFilterMode:[,"nearest","linear"],OptionalBool:["false","true"],PowerPreference:[,"low-power","high-performance"],PredefinedColorSpace:[,"srgb","display-p3"],PrimitiveTopology:[,"point-list","line-list","line-strip","triangle-list","triangle-strip"],QueryType:[,"occlusion","timestamp"],SamplerBindingType:[,,"filtering","non-filtering","comparison"],Status:[,"success","error"],StencilOperation:[,"keep","zero","replace","invert","increment-clamp","decrement-clamp","increment-wrap","decrement-wrap"],StorageTextureAccess:[,,"write-only","read-only","read-write"],StoreOp:[,"store","discard"],SubgroupMatrixComponentType:[,"f32","f16","u32","i32","u8","i8"],SurfaceGetCurrentTextureStatus:[,"success-optimal","success-suboptimal","timeout","outdated","lost","error"],TextureAspect:[,"all","stencil-only","depth-only"],TextureDimension:[,"1d","2d","3d"],TextureFormat:[,"r8unorm","r8snorm","r8uint","r8sint","r16unorm","r16snorm","r16uint","r16sint","r16float","rg8unorm","rg8snorm","rg8uint","rg8sint","r32float","r32uint","r32sint","rg16unorm","rg16snorm","rg16uint","rg16sint","rg16float","rgba8unorm","rgba8unorm-srgb","rgba8snorm","rgba8uint","rgba8sint","bgra8unorm","bgra8unorm-srgb","rgb10a2uint","rgb10a2unorm","rg11b10ufloat","rgb9e5ufloat","rg32float","rg32uint","rg32sint","rgba16unorm","rgba16snorm","rgba16uint","rgba16sint","rgba16float","rgba32float","rgba32uint","rgba32sint","stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8","bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb","bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm","bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb","etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm","astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"],TextureSampleType:[,,"float","unfilterable-float","depth","sint","uint"],TextureViewDimension:[,"1d","2d","2d-array","cube","cube-array","3d"],ToneMappingMode:[,"standard","extended"],VertexFormat:[,"uint8","uint8x2","uint8x4","sint8","sint8x2","sint8x4","unorm8","unorm8x2","unorm8x4","snorm8","snorm8x2","snorm8x4","uint16","uint16x2","uint16x4","sint16","sint16x2","sint16x4","unorm16","unorm16x2","unorm16x4","snorm16","snorm16x2","snorm16x4","float16","float16x2","float16x4","float32","float32x2","float32x3","float32x4","uint32","uint32x2","uint32x3","uint32x4","sint32","sint32x2","sint32x3","sint32x4","unorm10-10-10-2","unorm8x4-bgra","snorm10-10-10-2"],VertexStepMode:[,"vertex","instance"],WGSLLanguageFeatureName:[,"readonly_and_readwrite_storage_textures","packed_4x8_integer_dot_product","unrestricted_pointer_parameters","pointer_composite_access","uniform_buffer_standard_layout","subgroup_id","texture_and_sampler_let","subgroup_uniformity","texture_formats_tier1","linear_indexing","immediate_address_space","buffer_view","swizzle_assignment","fragment_depth"]};var handleException=e=>{if(e instanceof ExitStatus||e=="unwind")return EXITSTATUS;quit_(1,e)};var keepRuntimeAlive=()=>noExitRuntime||0>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var maybeExit=()=>{if(!keepRuntimeAlive())try{_exit(EXITSTATUS)}catch(e){handleException(e)}};var callUserCallback=(func,...args)=>{if(ABORT)return;try{return func(...args)}catch(e){handleException(e)}finally{maybeExit()}};var emwgpuStringToInt_CompilationMessageType={error:1,warning:2,info:3};var ENV={};var getExecutableName=()=>thisProgram;var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV)if(ENV[x]===void 0)delete env[x];else env[x]=ENV[x];var strings=[];for(var x in env)strings.push(`${x}=${env[x]}`);getEnvStrings.strings=strings}return getEnvStrings.strings};var HEAPU16;var _exit=status=>{EXITSTATUS=status;_proc_exit(status)};if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["arguments"])Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var preInit=Module["preInit"];if(preInit){if(typeof preInit==="function")Module["preInit"]=preInit=[preInit];while(preInit.length>0)preInit.shift()()}Module["UTF8ToString"]=UTF8ToString;Module["stringToNewUTF8"]=stringToNewUTF8;var _malloc,_emwgpuCreateBindGroup,_emwgpuCreateBindGroupLayout,_emwgpuCreateCommandBuffer,_emwgpuCreateCommandEncoder,_emwgpuCreateComputePassEncoder,_emwgpuCreateComputePipeline,_emwgpuCreateExternalTexture,_emwgpuCreatePipelineLayout,_emwgpuCreateQuerySet,_emwgpuCreateRenderBundle,_emwgpuCreateRenderBundleEncoder,_emwgpuCreateRenderPassEncoder,_emwgpuCreateRenderPipeline,_emwgpuCreateSampler,_emwgpuCreateSurface,_emwgpuCreateTexture,_emwgpuCreateTextureView,_emwgpuCreateAdapter,_emwgpuImportBuffer,_emwgpuCreateDevice,_emwgpuCreateQueue,_emwgpuCreateShaderModule,_emwgpuOnCompilationInfoCompleted,_emwgpuOnCreateComputePipelineCompleted,_emwgpuOnMapAsyncCompleted,_emwgpuOnWorkDoneCompleted,_free,_memalign,___trap,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,wasmMemory,wasmTable;function assignWasmExports(wasmExports){Module["_dcgridJsInstance"]=wasmExports["X"];Module["_dcgridJsLastError"]=wasmExports["Y"];Module["_dcgridJsCreate"]=wasmExports["Z"];Module["_dcgridJsDefaults"]=wasmExports["$"];_malloc=Module["_malloc"]=wasmExports["aa"];Module["_dcgridJsDescribeScene"]=wasmExports["ba"];Module["_dcgridJsDesc"]=wasmExports["ca"];Module["_dcgridJsSetStepParams"]=wasmExports["da"];Module["_dcgridJsStats"]=wasmExports["ea"];Module["_dcgridJsSetVolume"]=wasmExports["fa"];Module["_dcgridJsCreateRenderer"]=wasmExports["ga"];Module["_dcgridJsRender"]=wasmExports["ha"];Module["_wgpuTextureRelease"]=wasmExports["ia"];Module["_wgpuDeviceRelease"]=wasmExports["ja"];Module["_dcgridSampleFieldWebGPU"]=wasmExports["ka"];Module["_dcgridFlush"]=wasmExports["la"];Module["_dcgridRendererDestroy"]=wasmExports["ma"];Module["_dcgridRendererIsReady"]=wasmExports["na"];Module["_dcgridRendererInvalidate"]=wasmExports["oa"];Module["_dcgridRendererBusy"]=wasmExports["pa"];Module["_dcgridDestroy"]=wasmExports["qa"];Module["_dcgridPoll"]=wasmExports["ra"];Module["_dcgridIsReady"]=wasmExports["sa"];Module["_dcgridGetStatus"]=wasmExports["ta"];Module["_dcgridReset"]=wasmExports["ua"];Module["_dcgridStep"]=wasmExports["va"];Module["_dcgridStepsInFlight"]=wasmExports["wa"];Module["_dcgridSetInflowMap"]=wasmExports["xa"];Module["_dcgridSceneCount"]=wasmExports["ya"];Module["_dcgridSceneName"]=wasmExports["za"];Module["_dcgridSceneApply"]=wasmExports["Aa"];_emwgpuCreateBindGroup=wasmExports["Ba"];_emwgpuCreateBindGroupLayout=wasmExports["Ca"];_emwgpuCreateCommandBuffer=wasmExports["Da"];_emwgpuCreateCommandEncoder=wasmExports["Ea"];_emwgpuCreateComputePassEncoder=wasmExports["Fa"];_emwgpuCreateComputePipeline=wasmExports["Ga"];_emwgpuCreateExternalTexture=wasmExports["Ha"];_emwgpuCreatePipelineLayout=wasmExports["Ia"];_emwgpuCreateQuerySet=wasmExports["Ja"];_emwgpuCreateRenderBundle=wasmExports["Ka"];_emwgpuCreateRenderBundleEncoder=wasmExports["La"];_emwgpuCreateRenderPassEncoder=wasmExports["Ma"];_emwgpuCreateRenderPipeline=wasmExports["Na"];_emwgpuCreateSampler=wasmExports["Oa"];_emwgpuCreateSurface=wasmExports["Pa"];_emwgpuCreateTexture=Module["_emwgpuCreateTexture"]=wasmExports["Qa"];_emwgpuCreateTextureView=wasmExports["Ra"];_emwgpuCreateAdapter=wasmExports["Sa"];_emwgpuImportBuffer=wasmExports["Ta"];_emwgpuCreateDevice=Module["_emwgpuCreateDevice"]=wasmExports["Ua"];_emwgpuCreateQueue=Module["_emwgpuCreateQueue"]=wasmExports["Va"];_emwgpuCreateShaderModule=wasmExports["Wa"];_emwgpuOnCompilationInfoCompleted=wasmExports["Xa"];_emwgpuOnCreateComputePipelineCompleted=wasmExports["Ya"];_emwgpuOnMapAsyncCompleted=wasmExports["Za"];_emwgpuOnWorkDoneCompleted=wasmExports["_a"];_free=Module["_free"]=wasmExports["$a"];_memalign=wasmExports["ab"];___trap=wasmExports["bb"];__emscripten_stack_restore=wasmExports["cb"];__emscripten_stack_alloc=wasmExports["db"];_emscripten_stack_get_current=wasmExports["eb"];wasmMemory=wasmExports["V"];wasmTable=wasmExports["_"]}var wasmImports={x:()=>abort(""),u:(timezone,daylight,std_name,dst_name)=>{var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);var extractZone=timezoneOffset=>{var sign=timezoneOffset>=0?"-":"+";var absOffset=Math.abs(timezoneOffset);var hours=String(Math.floor(absOffset/60)).padStart(2,"0");var minutes=String(absOffset%60).padStart(2,"0");return`UTC${sign}${hours}${minutes}`};var winterName=extractZone(winterOffset);var summerName=extractZone(summerOffset);if(summerOffset<winterOffset){stringToUTF8(winterName,std_name,17);stringToUTF8(summerName,dst_name,17)}else{stringToUTF8(winterName,dst_name,17);stringToUTF8(summerName,std_name,17)}},v:function(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);if(!checkWasiClock(clk_id))return 28;var now;if(clk_id===0)now=_emscripten_date_now();else if(1)now=_emscripten_get_now();else return 52;var nsec=Math.round(now*1e6);HEAP64[ptime>>3]=BigInt(nsec);return 0},w:requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize)return false;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement)return true}return false},I:bufferPtr=>{var buffer=WebGPU.getJsObject(bufferPtr);var onUnmap=WebGPU.Internals.bufferOnUnmaps[bufferPtr];if(onUnmap){for(var i=0;i<onUnmap.length;++i)onUnmap[i]();delete WebGPU.Internals.bufferOnUnmaps[bufferPtr]}buffer.destroy()},H:(bufferPtr,offset,size)=>{var buffer=WebGPU.getJsObject(bufferPtr);if(size==-1)size=void 0;var mapped;try{mapped=buffer.getMappedRange(offset,size)}catch(ex){return 0}var data=_memalign(16,mapped.byteLength);HEAPU8.set(new Uint8Array(mapped),data);WebGPU.Internals.bufferOnUnmaps[bufferPtr].push(()=>_free(data));return data},G:(bufferPtr,offset,size)=>{var buffer=WebGPU.getJsObject(bufferPtr);if(size==-1)size=void 0;var mapped;try{mapped=buffer.getMappedRange(offset,size)}catch(ex){return 0}var data=_memalign(16,mapped.byteLength);HEAPU8.fill(0,data,mapped.byteLength);WebGPU.Internals.bufferOnUnmaps[bufferPtr].push(()=>{new Uint8Array(mapped).set(HEAPU8.subarray(data,data+mapped.byteLength));_free(data)});return data},F:function(bufferPtr,futureId,mode,offset,size){futureId=bigintToI53Checked(futureId);mode=bigintToI53Checked(mode);var buffer=WebGPU.getJsObject(bufferPtr);WebGPU.Internals.bufferOnUnmaps[bufferPtr]=[];if(size==-1)size=void 0;WebGPU.Internals.futureInsert(futureId,buffer.mapAsync(mode,offset,size).then(()=>{callUserCallback(()=>{_emwgpuOnMapAsyncCompleted(futureId,1,0)})},ex=>{callUserCallback(()=>{stackSave();var messagePtr=stringToUTF8OnStack(ex.message);var status=ex.name==="AbortError"?4:ex.name==="OperationError"?3:0;_emwgpuOnMapAsyncCompleted(futureId,status,messagePtr);delete WebGPU.Internals.bufferOnUnmaps[bufferPtr]})}))},E:bufferPtr=>{var buffer=WebGPU.getJsObject(bufferPtr);var onUnmap=WebGPU.Internals.bufferOnUnmaps[bufferPtr];if(!onUnmap)return;for(var i=0;i<onUnmap.length;++i)onUnmap[i]();delete WebGPU.Internals.bufferOnUnmaps[bufferPtr];buffer.unmap()},a:ptr=>{delete WebGPU.Internals.jsObjects[ptr]},B:(devicePtr,descriptor,bufferPtr)=>{var mappedAtCreation=!!HEAPU32[descriptor+32>>2];var desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),usage:HEAPU32[descriptor+16>>2],size:readI53FromI64(descriptor+24),mappedAtCreation};var device=WebGPU.getJsObject(devicePtr);var buffer;try{buffer=device.createBuffer(desc)}catch(ex){return false}WebGPU.Internals.jsObjectInsert(bufferPtr,buffer);if(mappedAtCreation)WebGPU.Internals.bufferOnUnmaps[bufferPtr]=[];return true},A:function(devicePtr,futureId,descriptor,pipelinePtr){futureId=bigintToI53Checked(futureId);var desc=WebGPU.makeComputePipelineDesc(descriptor);var device=WebGPU.getJsObject(devicePtr);WebGPU.Internals.futureInsert(futureId,device.createComputePipelineAsync(desc).then(pipeline=>{callUserCallback(()=>{WebGPU.Internals.jsObjectInsert(pipelinePtr,pipeline);_emwgpuOnCreateComputePipelineCompleted(futureId,1,pipelinePtr,0)})},pipelineError=>{callUserCallback(()=>{var sp=stackSave();var messagePtr=stringToUTF8OnStack(pipelineError.message);var status=pipelineError.reason==="validation"?3:pipelineError.reason==="internal"?4:0;_emwgpuOnCreateComputePipelineCompleted(futureId,status,pipelinePtr,messagePtr);stackRestore(sp)})}))},z:(devicePtr,descriptor,shaderModulePtr)=>{var nextInChainPtr=HEAPU32[descriptor>>2];var sType=HEAP32[nextInChainPtr+4>>2];var desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),code:""};switch(sType){case 2:desc["code"]=WebGPU.makeStringFromStringView(nextInChainPtr+8);break}var device=WebGPU.getJsObject(devicePtr);WebGPU.Internals.jsObjectInsert(shaderModulePtr,device.createShaderModule(desc))},D:devicePtr=>{const device=WebGPU.getJsObject(devicePtr);device.onuncapturederror=null;device.destroy()},y:function(queuePtr,futureId){futureId=bigintToI53Checked(futureId);var queue=WebGPU.getJsObject(queuePtr);WebGPU.Internals.futureInsert(futureId,queue.onSubmittedWorkDone().then(()=>{callUserCallback(()=>{_emwgpuOnWorkDoneCompleted(futureId,1)})}))},C:function(shaderModulePtr,futureId,compilationInfoPtr){futureId=bigintToI53Checked(futureId);var shaderModule=WebGPU.getJsObject(shaderModulePtr);WebGPU.Internals.futureInsert(futureId,shaderModule.getCompilationInfo().then(compilationInfo=>{callUserCallback(()=>{const messageCount=compilationInfo.messages.length;HEAPU32[compilationInfoPtr+4>>2]=messageCount;if(messageCount){var totalMessagesSize=1;var messageLengths=[];for(var i=0;i<messageCount;++i){var messageLength=lengthBytesUTF8(compilationInfo.messages[i].message);totalMessagesSize+=messageLength;messageLengths.push(messageLength)}var messagesPtr=_malloc(totalMessagesSize);var compilationMessagesPtr=_malloc(48*messageCount);HEAPU32[compilationInfoPtr+8>>2]=compilationMessagesPtr;var utf16sPtr=_malloc(32*messageCount);for(i=0;i<messageCount;++i){var compilationMessage=compilationInfo.messages[i];var compilationMessagePtr=compilationMessagesPtr+48*i;var utf16Ptr=utf16sPtr+32*i;WebGPU.setStringView(compilationMessagePtr+4,messagesPtr,messageLengths[i]);HEAPU32[compilationMessagePtr>>2]=utf16Ptr;HEAP32[compilationMessagePtr+12>>2]=emwgpuStringToInt_CompilationMessageType[compilationMessage.type];HEAP64[compilationMessagePtr+16>>3]=BigInt(compilationMessage.lineNum);HEAP64[compilationMessagePtr+24>>3]=BigInt(compilationMessage.linePos);HEAP64[compilationMessagePtr+32>>3]=BigInt(compilationMessage.offset);HEAP64[compilationMessagePtr+40>>3]=BigInt(compilationMessage.length);HEAPU32[utf16Ptr>>2]=0;HEAP32[utf16Ptr+4>>2]=327743;HEAP64[utf16Ptr+8>>3]=BigInt(compilationMessage.linePos);HEAP64[utf16Ptr+16>>3]=BigInt(compilationMessage.offset);HEAP64[utf16Ptr+24>>3]=BigInt(compilationMessage.length);stringToUTF8(compilationMessage.message,messagesPtr,messageLengths[i]+1);messagesPtr+=messageLengths[i]}}_emwgpuOnCompilationInfoCompleted(futureId,1,compilationInfoPtr)})},()=>{abort("Unexpected failure in GPUShaderModule.getCompilationInfo().")}))},s:(__environ,environ_buf)=>{var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;HEAPU32[__environ+envp>>2]=ptr;bufSize+=stringToUTF8(string,ptr,1/0)+1;envp+=4}return 0},t:(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;for(var string of strings)bufSize+=lengthBytesUTF8(string)+1;HEAPU32[penviron_buf_size>>2]=bufSize;return 0},j:(encoderPtr,descriptor)=>{var desc;if(descriptor)desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),timestampWrites:WebGPU.makePassTimestampWrites(HEAPU32[descriptor+12>>2])};var commandEncoder=WebGPU.getJsObject(encoderPtr);var ptr=_emwgpuCreateComputePassEncoder(0);WebGPU.Internals.jsObjectInsert(ptr,commandEncoder.beginComputePass(desc));return ptr},S:function(encoderPtr,bufferPtr,offset,size){offset=bigintToI53Checked(offset);size=bigintToI53Checked(size);var commandEncoder=WebGPU.getJsObject(encoderPtr);if(size==-1)size=void 0;var buffer=WebGPU.getJsObject(bufferPtr);commandEncoder.clearBuffer(buffer,offset,size)},f:function(encoderPtr,srcPtr,srcOffset,dstPtr,dstOffset,size){srcOffset=bigintToI53Checked(srcOffset);dstOffset=bigintToI53Checked(dstOffset);size=bigintToI53Checked(size);var commandEncoder=WebGPU.getJsObject(encoderPtr);var src=WebGPU.getJsObject(srcPtr);var dst=WebGPU.getJsObject(dstPtr);commandEncoder.copyBufferToBuffer(src,srcOffset,dst,dstOffset,size)},P:encoderPtr=>{var commandEncoder=WebGPU.getJsObject(encoderPtr);var ptr=_emwgpuCreateCommandBuffer(0);WebGPU.Internals.jsObjectInsert(ptr,commandEncoder.finish());return ptr},R:function(encoderPtr,querySetPtr,firstQuery,queryCount,destinationPtr,destinationOffset){destinationOffset=bigintToI53Checked(destinationOffset);var commandEncoder=WebGPU.getJsObject(encoderPtr);var querySet=WebGPU.getJsObject(querySetPtr);var destination=WebGPU.getJsObject(destinationPtr);commandEncoder.resolveQuerySet(querySet,firstQuery,queryCount,destination,destinationOffset)},T:(passPtr,x,y,z)=>{var pass=WebGPU.getJsObject(passPtr);pass.dispatchWorkgroups(x,y,z)},e:passPtr=>{var pass=WebGPU.getJsObject(passPtr);pass.end()},i:(passPtr,groupIndex,groupPtr,dynamicOffsetCount,dynamicOffsetsPtr)=>{var pass=WebGPU.getJsObject(passPtr);var group=WebGPU.getJsObject(groupPtr);if(dynamicOffsetCount==0)pass.setBindGroup(groupIndex,group);else pass.setBindGroup(groupIndex,group,HEAPU32,dynamicOffsetsPtr>>2,dynamicOffsetCount)},q:(passPtr,pipelinePtr)=>{var pass=WebGPU.getJsObject(passPtr);var pipeline=WebGPU.getJsObject(pipelinePtr);pass.setPipeline(pipeline)},h:(devicePtr,descriptor)=>{function makeEntry(entryPtr){var bufferPtr=HEAPU32[entryPtr+8>>2];var samplerPtr=HEAPU32[entryPtr+32>>2];var textureViewPtr=HEAPU32[entryPtr+36>>2];var externalTexturePtr=0;WebGPU.iterateExtensions(entryPtr,{14:ptr=>{externalTexturePtr=HEAPU32[ptr+8>>2]}});var resource;if(bufferPtr){var size=readI53FromI64(entryPtr+24);if(size==-1)size=void 0;resource={buffer:WebGPU.getJsObject(bufferPtr),offset:readI53FromI64(entryPtr+16),size}}else resource=WebGPU.getJsObject(samplerPtr||textureViewPtr||externalTexturePtr);return{binding:HEAPU32[entryPtr+4>>2],resource}}var desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),layout:WebGPU.getJsObject(HEAPU32[descriptor+12>>2]),entries:function(count,entriesPtrs){var entries=[];for(var i=0;i<count;++i)entries.push(makeEntry(entriesPtrs+40*i));return entries}(HEAPU32[descriptor+16>>2],HEAPU32[descriptor+20>>2])};var device=WebGPU.getJsObject(devicePtr);var ptr=_emwgpuCreateBindGroup(0);WebGPU.Internals.jsObjectInsert(ptr,device.createBindGroup(desc));return ptr},c:(devicePtr,descriptor)=>{function makeBufferEntry(substructPtr){var typeInt=HEAPU32[substructPtr+4>>2];if(!typeInt)return;return{type:WebGPU.BufferBindingType[typeInt],hasDynamicOffset:!!HEAPU32[substructPtr+8>>2],minBindingSize:readI53FromI64(substructPtr+16)}}function makeSamplerEntry(substructPtr){var typeInt=HEAPU32[substructPtr+4>>2];if(!typeInt)return;return{type:WebGPU.SamplerBindingType[typeInt]}}function makeTextureEntry(substructPtr){var sampleTypeInt=HEAPU32[substructPtr+4>>2];if(!sampleTypeInt)return;return{sampleType:WebGPU.TextureSampleType[sampleTypeInt],viewDimension:WebGPU.TextureViewDimension[HEAP32[substructPtr+8>>2]],multisampled:!!HEAPU32[substructPtr+12>>2]}}function makeStorageTextureEntry(substructPtr){var accessInt=HEAPU32[substructPtr+4>>2];if(!accessInt)return;return{access:WebGPU.StorageTextureAccess[accessInt],format:WebGPU.TextureFormat[HEAP32[substructPtr+8>>2]],viewDimension:WebGPU.TextureViewDimension[HEAP32[substructPtr+12>>2]]}}function makeEntry(entryPtr){var entry={binding:HEAPU32[entryPtr+4>>2],visibility:HEAPU32[entryPtr+8>>2],buffer:makeBufferEntry(entryPtr+24),sampler:makeSamplerEntry(entryPtr+48),texture:makeTextureEntry(entryPtr+56),storageTexture:makeStorageTextureEntry(entryPtr+72)};WebGPU.iterateExtensions(entryPtr,{13:()=>{entry["externalTexture"]={}}});return entry}var desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),entries:function(count,entriesPtrs){var entries=[];for(var i=0;i<count;++i)entries.push(makeEntry(entriesPtrs+88*i));return entries}(HEAPU32[descriptor+12>>2],HEAPU32[descriptor+16>>2])};var device=WebGPU.getJsObject(devicePtr);var ptr=_emwgpuCreateBindGroupLayout(0);WebGPU.Internals.jsObjectInsert(ptr,device.createBindGroupLayout(desc));return ptr},d:(devicePtr,descriptor)=>{var desc;if(descriptor)desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4)};var device=WebGPU.getJsObject(devicePtr);var ptr=_emwgpuCreateCommandEncoder(0);WebGPU.Internals.jsObjectInsert(ptr,device.createCommandEncoder(desc));return ptr},p:(devicePtr,descriptor)=>{var bglCount=HEAPU32[descriptor+12>>2];var bglPtr=HEAPU32[descriptor+16>>2];var bgls=[];for(var i=0;i<bglCount;++i)bgls.push(WebGPU.getJsObject(HEAPU32[bglPtr+4*i>>2]));var desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),bindGroupLayouts:bgls,immediateSize:HEAPU32[descriptor+20>>2]};var device=WebGPU.getJsObject(devicePtr);var ptr=_emwgpuCreatePipelineLayout(0);WebGPU.Internals.jsObjectInsert(ptr,device.createPipelineLayout(desc));return ptr},r:(devicePtr,descriptor)=>{var desc={type:WebGPU.QueryType[HEAP32[descriptor+12>>2]],count:HEAPU32[descriptor+16>>2]};var device=WebGPU.getJsObject(devicePtr);var ptr=_emwgpuCreateQuerySet(0);WebGPU.Internals.jsObjectInsert(ptr,device.createQuerySet(desc));return ptr},o:(devicePtr,descriptor)=>{var desc;if(descriptor)desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),addressModeU:WebGPU.AddressMode[HEAP32[descriptor+12>>2]],addressModeV:WebGPU.AddressMode[HEAP32[descriptor+16>>2]],addressModeW:WebGPU.AddressMode[HEAP32[descriptor+20>>2]],magFilter:WebGPU.FilterMode[HEAP32[descriptor+24>>2]],minFilter:WebGPU.FilterMode[HEAP32[descriptor+28>>2]],mipmapFilter:WebGPU.MipmapFilterMode[HEAP32[descriptor+32>>2]],lodMinClamp:HEAPF32[descriptor+36>>2],lodMaxClamp:HEAPF32[descriptor+40>>2],compare:WebGPU.CompareFunction[HEAP32[descriptor+44>>2]],maxAnisotropy:HEAPU16[descriptor+48>>1]};var device=WebGPU.getJsObject(devicePtr);var ptr=_emwgpuCreateSampler(0);WebGPU.Internals.jsObjectInsert(ptr,device.createSampler(desc));return ptr},U:(devicePtr,descriptor)=>{var nextInChainPtr=HEAPU32[descriptor>>2];var textureBindingViewDimension;if(nextInChainPtr!==0){HEAP32[nextInChainPtr+4>>2];var textureBindingViewDimensionDescriptor=nextInChainPtr;textureBindingViewDimension=WebGPU.TextureViewDimension[HEAP32[textureBindingViewDimensionDescriptor+8>>2]]}var desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),size:WebGPU.makeExtent3D(descriptor+28),mipLevelCount:HEAPU32[descriptor+44>>2],sampleCount:HEAPU32[descriptor+48>>2],dimension:WebGPU.TextureDimension[HEAP32[descriptor+24>>2]],format:WebGPU.TextureFormat[HEAP32[descriptor+40>>2]],usage:HEAPU32[descriptor+16>>2],textureBindingViewDimension};var viewFormatCount=HEAPU32[descriptor+52>>2];if(viewFormatCount){var viewFormatsPtr=HEAPU32[descriptor+56>>2];desc["viewFormats"]=Array.from(HEAP32.subarray(viewFormatsPtr>>2,viewFormatsPtr+viewFormatCount*4>>2),format=>WebGPU.TextureFormat[format])}var device=WebGPU.getJsObject(devicePtr);var ptr=_emwgpuCreateTexture(0);WebGPU.Internals.jsObjectInsert(ptr,device.createTexture(desc));return ptr},M:(devicePtr,limitsOutPtr)=>{var device=WebGPU.getJsObject(devicePtr);WebGPU.fillLimitStruct(device.limits,limitsOutPtr);return 1},N:(devicePtr,featureEnumValue)=>{var device=WebGPU.getJsObject(devicePtr);return device.features.has(WebGPU.FeatureName[featureEnumValue])},O:(queuePtr,commandCount,commands)=>{var queue=WebGPU.getJsObject(queuePtr);var cmds=Array.from(HEAP32.subarray(commands>>2,commands+commandCount*4>>2),id=>WebGPU.getJsObject(id));queue.submit(cmds)},Q:function(queuePtr,bufferPtr,bufferOffset,data,size){bufferOffset=bigintToI53Checked(bufferOffset);var queue=WebGPU.getJsObject(queuePtr);var buffer=WebGPU.getJsObject(bufferPtr);var subarray=HEAPU8.subarray(data,data+size);queue.writeBuffer(buffer,bufferOffset,subarray,0,size)},b:(queuePtr,destinationPtr,data,dataSize,dataLayoutPtr,writeSizePtr)=>{var queue=WebGPU.getJsObject(queuePtr);var destination=WebGPU.makeTexelCopyTextureInfo(destinationPtr);var dataLayout=WebGPU.makeTexelCopyBufferLayout(dataLayoutPtr);var writeSize=WebGPU.makeExtent3D(writeSizePtr);var subarray=HEAPU8.subarray(data,data+dataSize);queue.writeTexture(destination,subarray,dataLayout,writeSize)},g:(texturePtr,descriptor)=>{var desc;if(descriptor){var swizzle;var nextInChainPtr=HEAPU32[descriptor>>2];if(nextInChainPtr!==0){HEAP32[nextInChainPtr+4>>2];var swizzleDescriptor=nextInChainPtr;var swizzlePtr=swizzleDescriptor+8;var r=WebGPU.ComponentSwizzle[HEAP32[swizzlePtr>>2]]||"r";var g=WebGPU.ComponentSwizzle[HEAP32[swizzlePtr+4>>2]]||"g";var b=WebGPU.ComponentSwizzle[HEAP32[swizzlePtr+8>>2]]||"b";var a=WebGPU.ComponentSwizzle[HEAP32[swizzlePtr+12>>2]]||"a";swizzle=`${r}${g}${b}${a}`}var mipLevelCount=HEAPU32[descriptor+24>>2];var arrayLayerCount=HEAPU32[descriptor+32>>2];desc={label:WebGPU.makeStringFromOptionalStringView(descriptor+4),format:WebGPU.TextureFormat[HEAP32[descriptor+12>>2]],dimension:WebGPU.TextureViewDimension[HEAP32[descriptor+16>>2]],baseMipLevel:HEAPU32[descriptor+20>>2],mipLevelCount:mipLevelCount===4294967295?void 0:mipLevelCount,baseArrayLayer:HEAPU32[descriptor+28>>2],arrayLayerCount:arrayLayerCount===4294967295?void 0:arrayLayerCount,aspect:WebGPU.TextureAspect[HEAP32[descriptor+36>>2]],usage:HEAPU32[descriptor+40>>2],swizzle}}var texture=WebGPU.getJsObject(texturePtr);var ptr=_emwgpuCreateTextureView(0);WebGPU.Internals.jsObjectInsert(ptr,texture.createView(desc));return ptr},L:texturePtr=>{WebGPU.getJsObject(texturePtr).destroy()},J:texturePtr=>{var texture=WebGPU.getJsObject(texturePtr);return texture.depthOrArrayLayers},K:texturePtr=>{var texture=WebGPU.getJsObject(texturePtr);return WebGPU.TextureDimension.indexOf(texture.dimension)},n:texturePtr=>{var texture=WebGPU.getJsObject(texturePtr);return WebGPU.TextureFormat.indexOf(texture.format)},k:texturePtr=>{var texture=WebGPU.getJsObject(texturePtr);return texture.height},m:function(texturePtr){var ret=(()=>{var texture=WebGPU.getJsObject(texturePtr);return texture.usage})();return BigInt(ret)},l:texturePtr=>{var texture=WebGPU.getJsObject(texturePtr);return texture.width}};var wasmExports;wasmExports=await async function(){function receiveInstance(instance){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}var info=getWasmImports();var instantiateWasm=Module["instantiateWasm"];if(instantiateWasm)return new Promise(resolve=>{instantiateWasm(info,inst=>resolve(receiveInstance(inst)))});wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(void 0,wasmBinaryFile,info);var exports=function(result){return receiveInstance(result["instance"])}(result);return exports}();await async function(){preRun();var setStatus=Module["setStatus"];if(setStatus){setStatus("Running...");await new Promise(resolve=>setTimeout(resolve,1));setTimeout(setStatus,1,"")}if(ABORT)return;initRuntime();Module["onRuntimeInitialized"]?.();postRun()}();Module["importDevice"]=(device,parent)=>WebGPU.importJsDevice(device,parent);Module["importTexture"]=(texture,parent)=>WebGPU.importJsTexture(texture,parent);
|
|
2
|
+
;return Module}export default createDCGridModule;
|
package/dist/dcgrid.wasm
ADDED
|
Binary file
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
export type Vec3 = [number, number, number];
|
|
2
|
+
export type FaceName = "-x" | "+x" | "-y" | "+y" | "-z" | "+z";
|
|
3
|
+
export declare const FACE_NAMES: readonly FaceName[];
|
|
4
|
+
/**
|
|
5
|
+
* no_slip: wall with zero velocity. free_slip: wall with zero normal velocity. inflow: prescribed
|
|
6
|
+
* velocity and density (uniform, or per cell with setInflowMap). outflow: values continue past the face.
|
|
7
|
+
*/
|
|
8
|
+
export type FaceType = "no_slip" | "free_slip" | "inflow" | "outflow";
|
|
9
|
+
export interface Face {
|
|
10
|
+
type: FaceType;
|
|
11
|
+
/** Inflow velocity in m/s. */
|
|
12
|
+
velocity?: Vec3;
|
|
13
|
+
/** Inflow density. */
|
|
14
|
+
density?: number;
|
|
15
|
+
}
|
|
16
|
+
/** What the adaptive grid refines towards: a fixed focus point, vorticity, or smoke density. */
|
|
17
|
+
export type Criterion = "static" | "vorticity" | "density";
|
|
18
|
+
/** Weather extension: clouds, rain, fire and ash over a terrain (adaptive grid only). */
|
|
19
|
+
export interface Weather {
|
|
20
|
+
terrain: "hill" | "mountain";
|
|
21
|
+
ignite: boolean;
|
|
22
|
+
/** Wind through the sides in m/s (x, z). */
|
|
23
|
+
wind: [number, number];
|
|
24
|
+
vorticityConfinement: number;
|
|
25
|
+
emitHeat: number;
|
|
26
|
+
emitRelativeHumidity: number;
|
|
27
|
+
}
|
|
28
|
+
export interface SimulationDesc {
|
|
29
|
+
/** Cells along x, y, z at the finest resolution. */
|
|
30
|
+
size: Vec3;
|
|
31
|
+
/** Cell size in meters. */
|
|
32
|
+
cellSize: number;
|
|
33
|
+
grid?: "adaptive" | "uniform";
|
|
34
|
+
/** Memory budget of the adaptive grid in blocks of 4³ cells. */
|
|
35
|
+
maxBlocks?: number;
|
|
36
|
+
criterion?: Criterion;
|
|
37
|
+
/** Static criterion: focus (fraction of the domain) and a radius without refinement (fraction of size[0]). */
|
|
38
|
+
focus?: [number, number, number, number];
|
|
39
|
+
/** Density at which the density criterion scores 1 per cell. */
|
|
40
|
+
densityScale?: number;
|
|
41
|
+
/** Time step in seconds. */
|
|
42
|
+
dt?: number;
|
|
43
|
+
/** Faces not listed are no-slip walls. */
|
|
44
|
+
faces?: Partial<Record<FaceName, Face>>;
|
|
45
|
+
weather?: Weather | null;
|
|
46
|
+
}
|
|
47
|
+
/** Settings that may change between steps. */
|
|
48
|
+
export interface StepParams {
|
|
49
|
+
dt: number;
|
|
50
|
+
criterion: Criterion;
|
|
51
|
+
focus: [number, number, number, number];
|
|
52
|
+
densityScale: number;
|
|
53
|
+
faces: Record<FaceName, Required<Face>>;
|
|
54
|
+
/** Weather extension only. */
|
|
55
|
+
wind: [number, number];
|
|
56
|
+
vorticityConfinement: number;
|
|
57
|
+
emitHeat: number;
|
|
58
|
+
emitRelativeHumidity: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A dense volume spanning the domain, x fastest, then y, then z. Voxels lie on the domain's corners:
|
|
62
|
+
* voxel 0 at the origin and voxel n - 1 at the far side along each axis.
|
|
63
|
+
*/
|
|
64
|
+
export interface Volume {
|
|
65
|
+
size: Vec3;
|
|
66
|
+
data: Float32Array;
|
|
67
|
+
/** 1 for scalars; 3 or 4 for vectors (w ignored). Defaults to data.length / voxels. */
|
|
68
|
+
channels?: number;
|
|
69
|
+
}
|
|
70
|
+
export type Field = "density" | "velocity" | "fluidity" | "cell_size";
|
|
71
|
+
export interface Stats {
|
|
72
|
+
grid: "adaptive" | "uniform";
|
|
73
|
+
size: Vec3;
|
|
74
|
+
blocks: number;
|
|
75
|
+
cells: number;
|
|
76
|
+
levels: number;
|
|
77
|
+
levelBlocks: number[];
|
|
78
|
+
levelMaxBlocks: number[];
|
|
79
|
+
moved: number;
|
|
80
|
+
refined: number;
|
|
81
|
+
steps: number;
|
|
82
|
+
}
|
|
83
|
+
export interface Camera {
|
|
84
|
+
/** Position in meters. */
|
|
85
|
+
eye: Vec3;
|
|
86
|
+
right: Vec3;
|
|
87
|
+
up: Vec3;
|
|
88
|
+
forward: Vec3;
|
|
89
|
+
/** sin of half the field of view along the longer image side. */
|
|
90
|
+
fovScale: number;
|
|
91
|
+
/** Direction the sunlight travels in. */
|
|
92
|
+
sunDirection: Vec3;
|
|
93
|
+
}
|
|
94
|
+
export type RenderChannel = "fluid" | "density" | "velocity" | "fluidity" | "cell_size";
|
|
95
|
+
export interface RenderSettings {
|
|
96
|
+
channel: RenderChannel;
|
|
97
|
+
solids: boolean;
|
|
98
|
+
shadows: boolean;
|
|
99
|
+
/** Trilinear sampling (otherwise nearest). */
|
|
100
|
+
precise: boolean;
|
|
101
|
+
antialiasing: number;
|
|
102
|
+
shadowSamples: number;
|
|
103
|
+
ambient: number;
|
|
104
|
+
backgroundColor: Vec3;
|
|
105
|
+
floorColor: Vec3;
|
|
106
|
+
smokeColor: Vec3;
|
|
107
|
+
solidColor: Vec3;
|
|
108
|
+
solidColorTop: Vec3;
|
|
109
|
+
/** Height (fraction of the domain) at which solids reach solidColorTop; 0: no blend. */
|
|
110
|
+
solidColorHeight: number;
|
|
111
|
+
/** Weather extension: sunlight and skylight colors. */
|
|
112
|
+
sunColor: Vec3;
|
|
113
|
+
ambientColor: Vec3;
|
|
114
|
+
}
|
|
115
|
+
export interface SceneInfo {
|
|
116
|
+
desc: Required<SimulationDesc>;
|
|
117
|
+
/** Domain extent in units of 10 km and an orbit camera (yaw, pitch in radians; zoom). */
|
|
118
|
+
view: {
|
|
119
|
+
shape: Vec3;
|
|
120
|
+
yaw: number;
|
|
121
|
+
pitch: number;
|
|
122
|
+
zoom: number;
|
|
123
|
+
};
|
|
124
|
+
render: RenderSettings;
|
|
125
|
+
}
|
|
126
|
+
export type ErrorCode = "invalid_argument" | "unsupported" | "not_ready" | "device";
|
|
127
|
+
export declare class DCGridError extends Error {
|
|
128
|
+
readonly code: ErrorCode;
|
|
129
|
+
constructor(message: string, code: ErrorCode);
|
|
130
|
+
}
|
|
131
|
+
interface Module {
|
|
132
|
+
HEAPF32: Float32Array;
|
|
133
|
+
HEAPU8: Uint8Array;
|
|
134
|
+
UTF8ToString(ptr: number): string;
|
|
135
|
+
stringToNewUTF8(s: string): number;
|
|
136
|
+
importDevice(device: GPUDevice, parent: number): number;
|
|
137
|
+
importTexture(texture: GPUTexture, parent: number): number;
|
|
138
|
+
[name: `_${string}`]: (...args: number[]) => number;
|
|
139
|
+
}
|
|
140
|
+
export declare class DCGrid {
|
|
141
|
+
private readonly m;
|
|
142
|
+
private devices;
|
|
143
|
+
/** Names of the preset scenes (sphere obstacle, open plume, wind over hills, wildfire, clouds). */
|
|
144
|
+
readonly scenes: readonly string[];
|
|
145
|
+
private constructor();
|
|
146
|
+
/**
|
|
147
|
+
* Loads the WebAssembly module. `wasm` overrides where dcgrid.wasm is fetched from (by default
|
|
148
|
+
* next to dcgrid.mjs) or passes its bytes.
|
|
149
|
+
*/
|
|
150
|
+
static load(options?: {
|
|
151
|
+
wasm?: string | URL | ArrayBuffer;
|
|
152
|
+
}): Promise<DCGrid>;
|
|
153
|
+
/** Default description and render settings: 128³ cells of 78 m, adaptive, 40000 blocks, no-slip walls. */
|
|
154
|
+
defaults(): {
|
|
155
|
+
desc: Required<SimulationDesc>;
|
|
156
|
+
render: RenderSettings;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* A preset scene at `resolution` cells per 10 km. `base` keeps grid, maxBlocks, criterion and
|
|
160
|
+
* densityScale (other settings come from the scene).
|
|
161
|
+
*/
|
|
162
|
+
describeScene(scene: number, resolution: number, base?: Partial<SimulationDesc>): SceneInfo;
|
|
163
|
+
/** Creates a simulation on `device`; it builds in the background (see Simulation.whenReady). */
|
|
164
|
+
create(device: GPUDevice, desc: SimulationDesc): Simulation;
|
|
165
|
+
/** @internal */
|
|
166
|
+
get module(): Module;
|
|
167
|
+
/** @internal */
|
|
168
|
+
importDevice(device: GPUDevice): number;
|
|
169
|
+
/** @internal Runs f with an imported texture handle. */
|
|
170
|
+
withTexture<T>(texture: GPUTexture, device: number, f: (ptr: number) => T): T;
|
|
171
|
+
/** @internal */
|
|
172
|
+
withString<T>(s: string, f: (ptr: number) => T): T;
|
|
173
|
+
/** @internal Copies floats into wasm memory for the duration of f (null passes a null pointer). */
|
|
174
|
+
withFloats<T>(data: Float32Array | null, f: (ptr: number) => T): T;
|
|
175
|
+
/** @internal Parses and frees a JSON string the shim returned. */
|
|
176
|
+
json<T>(ptr: number): T;
|
|
177
|
+
/** @internal */
|
|
178
|
+
error(code: number): DCGridError;
|
|
179
|
+
/** @internal Throws unless a call succeeded. */
|
|
180
|
+
check(code: number): void;
|
|
181
|
+
}
|
|
182
|
+
export declare class Simulation {
|
|
183
|
+
private readonly dcgrid;
|
|
184
|
+
/** @internal */ readonly ptr: number;
|
|
185
|
+
/** @internal */ readonly device: number;
|
|
186
|
+
private sources;
|
|
187
|
+
private destroyed;
|
|
188
|
+
/** @internal */
|
|
189
|
+
constructor(dcgrid: DCGrid,
|
|
190
|
+
/** @internal */ ptr: number,
|
|
191
|
+
/** @internal */ device: number);
|
|
192
|
+
private get m();
|
|
193
|
+
/** Processes finished GPU work: advances building, resetting and the adaptation. Call once per frame. */
|
|
194
|
+
poll(): void;
|
|
195
|
+
/** Built and reset: steps can be recorded. */
|
|
196
|
+
get ready(): boolean;
|
|
197
|
+
/** The error that stopped the simulation (shader compilation, device loss), or null. */
|
|
198
|
+
get error(): DCGridError | null;
|
|
199
|
+
/** Polls until ready; rejects if the simulation fails. */
|
|
200
|
+
whenReady(): Promise<void>;
|
|
201
|
+
/** Back to the initial state (zero fields, coarse grid). */
|
|
202
|
+
reset(): Promise<void>;
|
|
203
|
+
/** Records and submits one step; throws a "not_ready" DCGridError while building or resetting. */
|
|
204
|
+
step(): void;
|
|
205
|
+
/** Submitted steps the GPU has not finished. */
|
|
206
|
+
get stepsInFlight(): number;
|
|
207
|
+
/** Resolves once the GPU has finished every submitted step. */
|
|
208
|
+
idle(): Promise<void>;
|
|
209
|
+
getStepParams(): StepParams;
|
|
210
|
+
/** Changes settings between steps; omitted ones keep their values. */
|
|
211
|
+
setStepParams(params: Partial<StepParams>): void;
|
|
212
|
+
/** Solid signed distance in meters (negative inside); null removes solids. */
|
|
213
|
+
setSolids(sdf: Volume | null): void;
|
|
214
|
+
/** Density per second (scalar) and velocity in m/s² (vector) added every step; null removes one. */
|
|
215
|
+
setSources(density: Volume | null, velocity: Volume | null): void;
|
|
216
|
+
/**
|
|
217
|
+
* Per-cell inflow for an inflow face: 4 floats (velocity xyz in m/s, density) per finest cell of
|
|
218
|
+
* the face along its two other axes (x faces: y then z; y faces: x then z; z faces: x then y),
|
|
219
|
+
* first axis fastest. null returns to the face's uniform values.
|
|
220
|
+
*/
|
|
221
|
+
setInflowMap(face: FaceName, values: Float32Array | null): void;
|
|
222
|
+
/** Uploads a preset scene's solids, sources and inflow maps (for a simulation described by it). */
|
|
223
|
+
applyScene(scene: number): void;
|
|
224
|
+
stats(): Stats;
|
|
225
|
+
/**
|
|
226
|
+
* Resamples a field into a 3D texture (r32float, rgba16float or rgba32float with STORAGE_BINDING),
|
|
227
|
+
* texel centers spanning the domain, and submits it. The first call waits for the field
|
|
228
|
+
* pipelines to compile.
|
|
229
|
+
*/
|
|
230
|
+
sampleField(field: Field, target: GPUTexture): Promise<void>;
|
|
231
|
+
/** The optional render module; its pipelines compile in the background. */
|
|
232
|
+
createRenderer(): Renderer;
|
|
233
|
+
/** Releases the simulation (destroy its renderers first). GPU work in flight finishes on its own. */
|
|
234
|
+
destroy(): void;
|
|
235
|
+
private setVolume;
|
|
236
|
+
}
|
|
237
|
+
export declare class Renderer {
|
|
238
|
+
private readonly dcgrid;
|
|
239
|
+
private readonly sim;
|
|
240
|
+
private readonly ptr;
|
|
241
|
+
private destroyed;
|
|
242
|
+
/** @internal */
|
|
243
|
+
constructor(dcgrid: DCGrid, sim: Simulation, ptr: number);
|
|
244
|
+
private get m();
|
|
245
|
+
get ready(): boolean;
|
|
246
|
+
whenReady(): Promise<void>;
|
|
247
|
+
/**
|
|
248
|
+
* Records and submits a render into `target` (rgba8unorm with STORAGE_BINDING). Settings not given
|
|
249
|
+
* take their defaults. Throws a "not_ready" DCGridError until the simulation and the render
|
|
250
|
+
* pipelines are ready.
|
|
251
|
+
*/
|
|
252
|
+
render(camera: Camera, settings: Partial<RenderSettings>, target: GPUTexture): void;
|
|
253
|
+
/** The last submitted render is still running on the GPU. */
|
|
254
|
+
get busy(): boolean;
|
|
255
|
+
/** Recomputes the sun transmittance volume at the next render. */
|
|
256
|
+
invalidate(): void;
|
|
257
|
+
destroy(): void;
|
|
258
|
+
}
|
|
259
|
+
export {};
|