typegpu 0.2.0-alpha.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
package/data/index.d.cts CHANGED
@@ -1,7 +1,89 @@
1
- import { AnySchema, Schema, Unwrap, ISerialOutput, ParseUnwrapped, ISerialInput, MaxValue, IMeasurer, ISchema, UnwrapRecord } from 'typed-binary';
1
+ import { Unwrap, AnySchema, Schema, ISerialOutput, ParseUnwrapped, ISerialInput, MaxValue, IMeasurer, ISchema, UnwrapRecord } from 'typed-binary';
2
2
  export { Parsed, Unwrap } from 'typed-binary';
3
- import { r as TgpuData, R as ResolutionCtx, A as AnyTgpuData, a as TgpuNamable, x as AnyTgpuLooseData, y as TgpuLooseData, z as vec2f, o as vec3f, C as vec4f, N as NumberArrayView, D as Vec2u, V as Vec4u, G as Vec2i, i as Vec4i, H as Vec2f, j as Vec4f, F as F32, J as Vec3f, h as U32, K as Vec3u, I as I32, L as Vec3i, M as TgpuPointer } from '../types-qmW7FFqN.cjs';
4
- export { P as Bool, Z as VecKind, Q as bool, Y as f32, X as i32, W as u32, _ as vec2i, $ as vec2u, p as vec3i, q as vec3u, a0 as vec4i, a1 as vec4u, v as vecBase } from '../types-qmW7FFqN.cjs';
3
+ import { A as AnyTgpuData, x as AnyTgpuLooseData, r as TgpuData, y as TgpuLooseData, R as ResolutionCtx, a as TgpuNamable, z as vec2f, o as vec3f, C as vec4f, N as NumberArrayView, D as Vec2u, V as Vec4u, G as Vec2i, i as Vec4i, H as Vec2f, j as Vec4f, F as F32, J as Vec3f, h as U32, K as Vec3u, I as I32, L as Vec3i, M as TgpuPointer } from '../types-CGmVkuAt.cjs';
4
+ export { P as Bool, Z as VecKind, Q as bool, Y as f32, X as i32, W as u32, _ as vec2i, $ as vec2u, p as vec3i, q as vec3u, a0 as vec4i, a1 as vec4u, v as vecBase } from '../types-CGmVkuAt.cjs';
5
+
6
+ interface TgpuBaseArray<TElement extends AnyTgpuData | AnyTgpuLooseData = AnyTgpuData | AnyTgpuLooseData> {
7
+ readonly elementType: TElement;
8
+ readonly elementCount: number;
9
+ readonly stride: number;
10
+ }
11
+ /**
12
+ * Array schema constructed via `d.arrayOf` function.
13
+ *
14
+ * Responsible for handling reading and writing array values
15
+ * between binary and JS representation. Takes into account
16
+ * the `byteAlignment` requirement of its elementType.
17
+ */
18
+ interface TgpuArray<TElement extends AnyTgpuData> extends TgpuBaseArray<TElement>, TgpuData<Unwrap<TElement>[]> {
19
+ }
20
+ /**
21
+ * Creates an array schema that can be used to construct gpu buffers.
22
+ * Describes arrays with fixed-size length, storing elements of the same type.
23
+ *
24
+ * @example
25
+ * const LENGTH = 3;
26
+ * const array = d.arrayOf(d.u32, LENGTH);
27
+ *
28
+ * @param elementType The type of elements in the array.
29
+ * @param count The number of elements in the array.
30
+ */
31
+ declare const arrayOf: <TElement extends AnyTgpuData>(elementType: TElement, count: number) => TgpuArray<TElement>;
32
+ /**
33
+ * Array schema constructed via `d.looseArrayOf` function.
34
+ *
35
+ * Useful for defining vertex buffers.
36
+ * Elements in the schema are not aligned in respect to their `byteAlignment`,
37
+ * unless they are explicitly decorated with the custom align attribute
38
+ * via `d.align` function.
39
+ */
40
+ interface TgpuLooseArray<TElement extends AnyTgpuData | AnyTgpuLooseData> extends TgpuBaseArray<TElement>, TgpuLooseData<Unwrap<TElement>[]> {
41
+ }
42
+ /**
43
+ * Creates an array schema that can be used to construct vertex buffers.
44
+ * Describes arrays with fixed-size length, storing elements of the same type.
45
+ *
46
+ * Elements in the schema are not aligned in respect to their `byteAlignment`,
47
+ * unless they are explicitly decorated with the custom align attribute
48
+ * via `d.align` function.
49
+ *
50
+ * @example
51
+ * const looseArray = d.looseArrayOf(d.vec3f, 3); // packed array of vec3f
52
+ *
53
+ * @example
54
+ * const looseArray = d.looseArrayOf(d.align(16, d.vec3f), 3);
55
+ *
56
+ * @param elementType The type of elements in the array.
57
+ * @param count The number of elements in the array.
58
+ */
59
+ declare const looseArrayOf: <TElement extends AnyTgpuData | AnyTgpuLooseData>(elementType: TElement, count: number) => TgpuLooseArray<TElement>;
60
+ /**
61
+ * Checks whether passed in value is an array schema,
62
+ * as opposed to, e.g., a looseArray schema.
63
+ *
64
+ * Array schemas can be used to describe uniform and storage buffers,
65
+ * whereas looseArray schemas cannot.
66
+ *
67
+ * @example
68
+ * isArraySchema(d.arrayOf(d.u32, 4)) // true
69
+ * isArraySchema(d.looseArrayOf(d.u32, 4)) // false
70
+ * isArraySchema(d.vec3f) // false
71
+ */
72
+ declare function isArraySchema<T extends TgpuArray<AnyTgpuData>>(schema: T | unknown): schema is T;
73
+ /**
74
+ * Checks whether the passed in value is a looseArray schema,
75
+ * as opposed to, e.g., a regular array schema.
76
+ *
77
+ * Array schemas can be used to describe uniform and storage buffers,
78
+ * whereas looseArray schemas cannot. Loose arrays are useful for
79
+ * defining vertex buffers instead.
80
+ *
81
+ * @example
82
+ * isLooseArraySchema(d.arrayOf(d.u32, 4)) // false
83
+ * isLooseArraySchema(d.looseArrayOf(d.u32, 4)) // true
84
+ * isLooseArraySchema(d.vec3f) // false
85
+ */
86
+ declare function isLooseArraySchema<T extends TgpuLooseArray<AnyTgpuData>>(schema: T | unknown): schema is T;
5
87
 
6
88
  declare class SimpleTgpuData<TSchema extends AnySchema> extends Schema<Unwrap<TSchema>> implements TgpuData<Unwrap<TSchema>> {
7
89
  readonly size: number;
@@ -106,88 +188,6 @@ declare function isStructSchema<T extends TgpuStruct<Record<string, AnyTgpuData>
106
188
  */
107
189
  declare function isLooseStructSchema<T extends TgpuLooseStruct<Record<string, AnyTgpuData | AnyTgpuLooseData>>>(schema: T | unknown): schema is T;
108
190
 
109
- interface TgpuBaseArray<TElement extends AnyTgpuData | AnyTgpuLooseData = AnyTgpuData | AnyTgpuLooseData> {
110
- readonly elementType: TElement;
111
- readonly elementCount: number;
112
- readonly stride: number;
113
- }
114
- /**
115
- * Array schema constructed via `d.arrayOf` function.
116
- *
117
- * Responsible for handling reading and writing array values
118
- * between binary and JS representation. Takes into account
119
- * the `byteAlignment` requirement of its elementType.
120
- */
121
- interface TgpuArray<TElement extends AnyTgpuData> extends TgpuBaseArray<TElement>, TgpuData<Unwrap<TElement>[]> {
122
- }
123
- /**
124
- * Creates an array schema that can be used to construct gpu buffers.
125
- * Describes arrays with fixed-size length, storing elements of the same type.
126
- *
127
- * @example
128
- * const LENGTH = 3;
129
- * const array = d.arrayOf(d.u32, LENGTH);
130
- *
131
- * @param elementType The type of elements in the array.
132
- * @param count The number of elements in the array.
133
- */
134
- declare const arrayOf: <TElement extends AnyTgpuData>(elementType: TElement, count: number) => TgpuArray<TElement>;
135
- /**
136
- * Array schema constructed via `d.looseArrayOf` function.
137
- *
138
- * Useful for defining vertex buffers.
139
- * Elements in the schema are not aligned in respect to their `byteAlignment`,
140
- * unless they are explicitly decorated with the custom align attribute
141
- * via `d.align` function.
142
- */
143
- interface TgpuLooseArray<TElement extends AnyTgpuData | AnyTgpuLooseData> extends TgpuBaseArray<TElement>, TgpuLooseData<Unwrap<TElement>[]> {
144
- }
145
- /**
146
- * Creates an array schema that can be used to construct vertex buffers.
147
- * Describes arrays with fixed-size length, storing elements of the same type.
148
- *
149
- * Elements in the schema are not aligned in respect to their `byteAlignment`,
150
- * unless they are explicitly decorated with the custom align attribute
151
- * via `d.align` function.
152
- *
153
- * @example
154
- * const looseArray = d.looseArrayOf(d.vec3f, 3); // packed array of vec3f
155
- *
156
- * @example
157
- * const looseArray = d.looseArrayOf(d.align(16, d.vec3f), 3);
158
- *
159
- * @param elementType The type of elements in the array.
160
- * @param count The number of elements in the array.
161
- */
162
- declare const looseArrayOf: <TElement extends AnyTgpuData | AnyTgpuLooseData>(elementType: TElement, count: number) => TgpuLooseArray<TElement>;
163
- /**
164
- * Checks whether passed in value is an array schema,
165
- * as opposed to, e.g., a looseArray schema.
166
- *
167
- * Array schemas can be used to describe uniform and storage buffers,
168
- * whereas looseArray schemas cannot.
169
- *
170
- * @example
171
- * isArraySchema(d.arrayOf(d.u32, 4)) // true
172
- * isArraySchema(d.looseArrayOf(d.u32, 4)) // false
173
- * isArraySchema(d.vec3f) // false
174
- */
175
- declare function isArraySchema<T extends TgpuArray<AnyTgpuData>>(schema: T | unknown): schema is T;
176
- /**
177
- * Checks whether the passed in value is a looseArray schema,
178
- * as opposed to, e.g., a regular array schema.
179
- *
180
- * Array schemas can be used to describe uniform and storage buffers,
181
- * whereas looseArray schemas cannot. Loose arrays are useful for
182
- * defining vertex buffers instead.
183
- *
184
- * @example
185
- * isLooseArraySchema(d.arrayOf(d.u32, 4)) // false
186
- * isLooseArraySchema(d.looseArrayOf(d.u32, 4)) // true
187
- * isLooseArraySchema(d.vec3f) // false
188
- */
189
- declare function isLooseArraySchema<T extends TgpuLooseArray<AnyTgpuData>>(schema: T | unknown): schema is T;
190
-
191
191
  interface matBase<TColumn> extends NumberArrayView {
192
192
  readonly columns: readonly TColumn[];
193
193
  elements(): Iterable<number>;
package/data/index.d.ts CHANGED
@@ -1,7 +1,89 @@
1
- import { AnySchema, Schema, Unwrap, ISerialOutput, ParseUnwrapped, ISerialInput, MaxValue, IMeasurer, ISchema, UnwrapRecord } from 'typed-binary';
1
+ import { Unwrap, AnySchema, Schema, ISerialOutput, ParseUnwrapped, ISerialInput, MaxValue, IMeasurer, ISchema, UnwrapRecord } from 'typed-binary';
2
2
  export { Parsed, Unwrap } from 'typed-binary';
3
- import { r as TgpuData, R as ResolutionCtx, A as AnyTgpuData, a as TgpuNamable, x as AnyTgpuLooseData, y as TgpuLooseData, z as vec2f, o as vec3f, C as vec4f, N as NumberArrayView, D as Vec2u, V as Vec4u, G as Vec2i, i as Vec4i, H as Vec2f, j as Vec4f, F as F32, J as Vec3f, h as U32, K as Vec3u, I as I32, L as Vec3i, M as TgpuPointer } from '../types-qmW7FFqN.js';
4
- export { P as Bool, Z as VecKind, Q as bool, Y as f32, X as i32, W as u32, _ as vec2i, $ as vec2u, p as vec3i, q as vec3u, a0 as vec4i, a1 as vec4u, v as vecBase } from '../types-qmW7FFqN.js';
3
+ import { A as AnyTgpuData, x as AnyTgpuLooseData, r as TgpuData, y as TgpuLooseData, R as ResolutionCtx, a as TgpuNamable, z as vec2f, o as vec3f, C as vec4f, N as NumberArrayView, D as Vec2u, V as Vec4u, G as Vec2i, i as Vec4i, H as Vec2f, j as Vec4f, F as F32, J as Vec3f, h as U32, K as Vec3u, I as I32, L as Vec3i, M as TgpuPointer } from '../types-CGmVkuAt.js';
4
+ export { P as Bool, Z as VecKind, Q as bool, Y as f32, X as i32, W as u32, _ as vec2i, $ as vec2u, p as vec3i, q as vec3u, a0 as vec4i, a1 as vec4u, v as vecBase } from '../types-CGmVkuAt.js';
5
+
6
+ interface TgpuBaseArray<TElement extends AnyTgpuData | AnyTgpuLooseData = AnyTgpuData | AnyTgpuLooseData> {
7
+ readonly elementType: TElement;
8
+ readonly elementCount: number;
9
+ readonly stride: number;
10
+ }
11
+ /**
12
+ * Array schema constructed via `d.arrayOf` function.
13
+ *
14
+ * Responsible for handling reading and writing array values
15
+ * between binary and JS representation. Takes into account
16
+ * the `byteAlignment` requirement of its elementType.
17
+ */
18
+ interface TgpuArray<TElement extends AnyTgpuData> extends TgpuBaseArray<TElement>, TgpuData<Unwrap<TElement>[]> {
19
+ }
20
+ /**
21
+ * Creates an array schema that can be used to construct gpu buffers.
22
+ * Describes arrays with fixed-size length, storing elements of the same type.
23
+ *
24
+ * @example
25
+ * const LENGTH = 3;
26
+ * const array = d.arrayOf(d.u32, LENGTH);
27
+ *
28
+ * @param elementType The type of elements in the array.
29
+ * @param count The number of elements in the array.
30
+ */
31
+ declare const arrayOf: <TElement extends AnyTgpuData>(elementType: TElement, count: number) => TgpuArray<TElement>;
32
+ /**
33
+ * Array schema constructed via `d.looseArrayOf` function.
34
+ *
35
+ * Useful for defining vertex buffers.
36
+ * Elements in the schema are not aligned in respect to their `byteAlignment`,
37
+ * unless they are explicitly decorated with the custom align attribute
38
+ * via `d.align` function.
39
+ */
40
+ interface TgpuLooseArray<TElement extends AnyTgpuData | AnyTgpuLooseData> extends TgpuBaseArray<TElement>, TgpuLooseData<Unwrap<TElement>[]> {
41
+ }
42
+ /**
43
+ * Creates an array schema that can be used to construct vertex buffers.
44
+ * Describes arrays with fixed-size length, storing elements of the same type.
45
+ *
46
+ * Elements in the schema are not aligned in respect to their `byteAlignment`,
47
+ * unless they are explicitly decorated with the custom align attribute
48
+ * via `d.align` function.
49
+ *
50
+ * @example
51
+ * const looseArray = d.looseArrayOf(d.vec3f, 3); // packed array of vec3f
52
+ *
53
+ * @example
54
+ * const looseArray = d.looseArrayOf(d.align(16, d.vec3f), 3);
55
+ *
56
+ * @param elementType The type of elements in the array.
57
+ * @param count The number of elements in the array.
58
+ */
59
+ declare const looseArrayOf: <TElement extends AnyTgpuData | AnyTgpuLooseData>(elementType: TElement, count: number) => TgpuLooseArray<TElement>;
60
+ /**
61
+ * Checks whether passed in value is an array schema,
62
+ * as opposed to, e.g., a looseArray schema.
63
+ *
64
+ * Array schemas can be used to describe uniform and storage buffers,
65
+ * whereas looseArray schemas cannot.
66
+ *
67
+ * @example
68
+ * isArraySchema(d.arrayOf(d.u32, 4)) // true
69
+ * isArraySchema(d.looseArrayOf(d.u32, 4)) // false
70
+ * isArraySchema(d.vec3f) // false
71
+ */
72
+ declare function isArraySchema<T extends TgpuArray<AnyTgpuData>>(schema: T | unknown): schema is T;
73
+ /**
74
+ * Checks whether the passed in value is a looseArray schema,
75
+ * as opposed to, e.g., a regular array schema.
76
+ *
77
+ * Array schemas can be used to describe uniform and storage buffers,
78
+ * whereas looseArray schemas cannot. Loose arrays are useful for
79
+ * defining vertex buffers instead.
80
+ *
81
+ * @example
82
+ * isLooseArraySchema(d.arrayOf(d.u32, 4)) // false
83
+ * isLooseArraySchema(d.looseArrayOf(d.u32, 4)) // true
84
+ * isLooseArraySchema(d.vec3f) // false
85
+ */
86
+ declare function isLooseArraySchema<T extends TgpuLooseArray<AnyTgpuData>>(schema: T | unknown): schema is T;
5
87
 
6
88
  declare class SimpleTgpuData<TSchema extends AnySchema> extends Schema<Unwrap<TSchema>> implements TgpuData<Unwrap<TSchema>> {
7
89
  readonly size: number;
@@ -106,88 +188,6 @@ declare function isStructSchema<T extends TgpuStruct<Record<string, AnyTgpuData>
106
188
  */
107
189
  declare function isLooseStructSchema<T extends TgpuLooseStruct<Record<string, AnyTgpuData | AnyTgpuLooseData>>>(schema: T | unknown): schema is T;
108
190
 
109
- interface TgpuBaseArray<TElement extends AnyTgpuData | AnyTgpuLooseData = AnyTgpuData | AnyTgpuLooseData> {
110
- readonly elementType: TElement;
111
- readonly elementCount: number;
112
- readonly stride: number;
113
- }
114
- /**
115
- * Array schema constructed via `d.arrayOf` function.
116
- *
117
- * Responsible for handling reading and writing array values
118
- * between binary and JS representation. Takes into account
119
- * the `byteAlignment` requirement of its elementType.
120
- */
121
- interface TgpuArray<TElement extends AnyTgpuData> extends TgpuBaseArray<TElement>, TgpuData<Unwrap<TElement>[]> {
122
- }
123
- /**
124
- * Creates an array schema that can be used to construct gpu buffers.
125
- * Describes arrays with fixed-size length, storing elements of the same type.
126
- *
127
- * @example
128
- * const LENGTH = 3;
129
- * const array = d.arrayOf(d.u32, LENGTH);
130
- *
131
- * @param elementType The type of elements in the array.
132
- * @param count The number of elements in the array.
133
- */
134
- declare const arrayOf: <TElement extends AnyTgpuData>(elementType: TElement, count: number) => TgpuArray<TElement>;
135
- /**
136
- * Array schema constructed via `d.looseArrayOf` function.
137
- *
138
- * Useful for defining vertex buffers.
139
- * Elements in the schema are not aligned in respect to their `byteAlignment`,
140
- * unless they are explicitly decorated with the custom align attribute
141
- * via `d.align` function.
142
- */
143
- interface TgpuLooseArray<TElement extends AnyTgpuData | AnyTgpuLooseData> extends TgpuBaseArray<TElement>, TgpuLooseData<Unwrap<TElement>[]> {
144
- }
145
- /**
146
- * Creates an array schema that can be used to construct vertex buffers.
147
- * Describes arrays with fixed-size length, storing elements of the same type.
148
- *
149
- * Elements in the schema are not aligned in respect to their `byteAlignment`,
150
- * unless they are explicitly decorated with the custom align attribute
151
- * via `d.align` function.
152
- *
153
- * @example
154
- * const looseArray = d.looseArrayOf(d.vec3f, 3); // packed array of vec3f
155
- *
156
- * @example
157
- * const looseArray = d.looseArrayOf(d.align(16, d.vec3f), 3);
158
- *
159
- * @param elementType The type of elements in the array.
160
- * @param count The number of elements in the array.
161
- */
162
- declare const looseArrayOf: <TElement extends AnyTgpuData | AnyTgpuLooseData>(elementType: TElement, count: number) => TgpuLooseArray<TElement>;
163
- /**
164
- * Checks whether passed in value is an array schema,
165
- * as opposed to, e.g., a looseArray schema.
166
- *
167
- * Array schemas can be used to describe uniform and storage buffers,
168
- * whereas looseArray schemas cannot.
169
- *
170
- * @example
171
- * isArraySchema(d.arrayOf(d.u32, 4)) // true
172
- * isArraySchema(d.looseArrayOf(d.u32, 4)) // false
173
- * isArraySchema(d.vec3f) // false
174
- */
175
- declare function isArraySchema<T extends TgpuArray<AnyTgpuData>>(schema: T | unknown): schema is T;
176
- /**
177
- * Checks whether the passed in value is a looseArray schema,
178
- * as opposed to, e.g., a regular array schema.
179
- *
180
- * Array schemas can be used to describe uniform and storage buffers,
181
- * whereas looseArray schemas cannot. Loose arrays are useful for
182
- * defining vertex buffers instead.
183
- *
184
- * @example
185
- * isLooseArraySchema(d.arrayOf(d.u32, 4)) // false
186
- * isLooseArraySchema(d.looseArrayOf(d.u32, 4)) // true
187
- * isLooseArraySchema(d.vec3f) // false
188
- */
189
- declare function isLooseArraySchema<T extends TgpuLooseArray<AnyTgpuData>>(schema: T | unknown): schema is T;
190
-
191
191
  interface matBase<TColumn> extends NumberArrayView {
192
192
  readonly columns: readonly TColumn[];
193
193
  elements(): Iterable<number>;
package/index.cjs CHANGED
@@ -48,5 +48,5 @@ ${n}`}if("let"in e||"const"in e){let r=x(t,he(t,"let"in e?e.let:e.const)),n=e.eq
48
48
  fn main(${a}) {
49
49
  ${this.computeRoot}
50
50
  }
51
- `;return new $(this.root,u).build({bindingGroup:e.bindingGroup,shaderStage:GPUShaderStage.COMPUTE,nameRegistry:(m=e.nameRegistry)!=null?m:new S})}};var _typedbinary = require('typed-binary');function le(t,e,r){return new De(t,e,r)}function A(t){return t.resourceType==="buffer"}function de(t){return!!t.usableAsUniform}function ge(t){return!!t.usableAsStorage}function bt(t){return!!t.usableAsVertex}var De=class{constructor(e,r,n){this._group=e;this.dataType=r;this.initialOrBuffer=n;_chunkSBJR5ZQJcjs.d.call(void 0, this,"resourceType","buffer");_chunkSBJR5ZQJcjs.d.call(void 0, this,"flags",GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_device",null);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_buffer",null);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_destroyed",!1);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_subscription",null);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_label");_chunkSBJR5ZQJcjs.d.call(void 0, this,"initial");_chunkSBJR5ZQJcjs.d.call(void 0, this,"usableAsUniform",!1);_chunkSBJR5ZQJcjs.d.call(void 0, this,"usableAsStorage",!1);_chunkSBJR5ZQJcjs.d.call(void 0, this,"usableAsVertex",!1);_chunkSBJR5ZQJcjs.z.call(void 0, n)?this._buffer=n:this.initial=n}get label(){return this._label}get buffer(){if(!this._device)throw new Error("Create this buffer using `root.createBuffer` instead of `tgpu.createBuffer`.");if(this._destroyed)throw new Error("This buffer has been destroyed");if(!this._buffer&&(this._buffer=this._device.createBuffer({size:this.dataType.size,usage:this.flags,mappedAtCreation:!!this.initial}),this.initial)){let e=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());if(Xe(this.initial)){let r=this._group;if(!r)throw new Error("Create this buffer using `root.createBuffer` instead of `tgpu.createBuffer`.");let n=this.initial;this.dataType.write(e,r.readPlum(n)),this._subscription=r.onPlumChange(n,()=>{this.write(r.readPlum(n))})}else this.dataType.write(e,this.initial);this._buffer.unmap()}return this._buffer}get device(){if(!this._device)throw new Error("This buffer has not been assigned a device. Use .$device(device) to assign a device");return this._device}get destroyed(){return this._destroyed}$name(e){return this._label=e,this}$usage(...e){for(let r of e)this.flags|=r==="uniform"?GPUBufferUsage.UNIFORM:0,this.flags|=r==="storage"?GPUBufferUsage.STORAGE:0,this.flags|=r==="vertex"?GPUBufferUsage.VERTEX:0,this.usableAsUniform=this.usableAsUniform||r==="uniform",this.usableAsStorage=this.usableAsStorage||r==="storage",this.usableAsVertex=this.usableAsVertex||r==="vertex";return this}$addFlags(e){return this.flags|=e,this}$device(e){return this._device=e,this}write(e){let r=this.buffer,n=this.device;if(r.mapState==="mapped"){let i=r.getMappedRange();if(A(e))throw new Error("Cannot copy to a mapped buffer.");this.dataType.write(new (0, _typedbinary.BufferWriter)(i),e);return}let a=this.dataType.size;if(A(e)){let i=e.buffer;if(this._group)this._group.commandEncoder.copyBufferToBuffer(i,0,r,0,a);else{let u=n.createCommandEncoder();u.copyBufferToBuffer(i,0,r,0,a),n.queue.submit([u.finish()])}}else{this._group&&this._group.flush();let i=new ArrayBuffer(a);this.dataType.write(new (0, _typedbinary.BufferWriter)(i),e),n.queue.writeBuffer(r,0,i,0,a)}}async read(){this._group&&this._group.flush();let e=this.buffer,r=this.device;if(e.mapState==="mapped"){let u=e.getMappedRange();return this.dataType.read(new (0, _typedbinary.BufferReader)(u))}if(e.usage&GPUBufferUsage.MAP_READ){await e.mapAsync(GPUMapMode.READ);let u=e.getMappedRange(),s=this.dataType.read(new (0, _typedbinary.BufferReader)(u));return e.unmap(),s}let n=r.createBuffer({size:this.dataType.size,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(e,0,n,0,this.dataType.size),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,this.dataType.size);let i=this.dataType.read(new (0, _typedbinary.BufferReader)(n.getMappedRange()));return n.unmap(),n.destroy(),i}destroy(){var e;this._destroyed||(this._destroyed=!0,this._subscription&&this._subscription(),(e=this._buffer)==null||e.destroy())}toString(){var e;return`buffer:${(e=this._label)!=null?e:"<unnamed>"}`}};function Re(t){return!!t&&t.resourceType==="buffer-usage"}function rt(t){return new _e(t)}function nt(t){return!!t&&t.resourceType==="bind-group-layout"}function at(t){return!!t&&t.resourceType==="bind-group"}var Ge=class t extends Error{constructor(e,r){super(`Bind group '${e!=null?e:"<unnamed>"}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,t.prototype)}},tt=["compute"],k=["compute","vertex","fragment"],_e=class{constructor(e){this.entries=e;_chunkSBJR5ZQJcjs.d.call(void 0, this,"_label");_chunkSBJR5ZQJcjs.d.call(void 0, this,"resourceType","bind-group-layout");_chunkSBJR5ZQJcjs.d.call(void 0, this,"bound",{})}get label(){return this._label}$name(e){return this._label=e,this}unwrap(e){var n;return e.device.createBindGroupLayout({label:(n=this.label)!=null?n:"",entries:Object.values(this.entries).map((a,i)=>{var l,d,T,m;if(a===null)return null;let u=a.visibility,s={binding:i,visibility:0};if("uniform"in a)u=u!=null?u:k,s.buffer={type:"uniform"};else if("storage"in a)u=u!=null?u:a.access==="mutable"?tt:k,s.buffer={type:a.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in a)u=u!=null?u:k,s.sampler={type:a.sampler};else if("texture"in a)u=u!=null?u:k,s.texture={sampleType:a.texture,viewDimension:(l=a.viewDimension)!=null?l:"2d",multisampled:(d=a.multisampled)!=null?d:!1};else if("storageTexture"in a){let c=(T=a.access)!=null?T:"writeonly";u=u!=null?u:c==="readonly"?k:tt,s.storageTexture={format:a.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[c],viewDimension:(m=a.viewDimension)!=null?m:"2d"}}else"externalTexture"in a&&(u=u!=null?u:k,s.externalTexture={});return u!=null&&u.includes("compute")&&(s.visibility|=GPUShaderStage.COMPUTE),u!=null&&u.includes("vertex")&&(s.visibility|=GPUShaderStage.VERTEX),u!=null&&u.includes("fragment")&&(s.visibility|=GPUShaderStage.FRAGMENT),s}).filter(a=>a!==null)})}populate(e){return new Ae(this,e)}},Ae=class{constructor(e,r){this.layout=e;this.entries=r;_chunkSBJR5ZQJcjs.d.call(void 0, this,"resourceType","bind-group");for(let n of Object.keys(e.entries))if(e.entries[n]!==null&&!(n in r))throw new Ge(e.label,n)}unwrap(e){var n;return e.device.createBindGroup({label:(n=this.layout.label)!=null?n:"",layout:e.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([a,i],u)=>{var l;if(i===null)return null;let s=this.entries[a];if(s===void 0)throw new Error(`'${a}' is a resource required to populate bind group layout '${(l=this.layout.label)!=null?l:"<unnamed>"}'.`);if("uniform"in i){let d;if(A(s)){if(!de(s))throw new (0, _chunkSBJR5ZQJcjs.j)(s);d={buffer:e.unwrap(s)}}else if(Re(s)){if(!de(s.allocatable))throw new (0, _chunkSBJR5ZQJcjs.j)(s.allocatable);d={buffer:e.unwrap(s.allocatable)}}else d={buffer:s};return{binding:u,resource:d}}if("storage"in i){let d;if(A(s)){if(!ge(s))throw new (0, _chunkSBJR5ZQJcjs.j)(s);d={buffer:e.unwrap(s)}}else if(Re(s)){if(!ge(s.allocatable))throw new (0, _chunkSBJR5ZQJcjs.j)(s.allocatable);d={buffer:e.unwrap(s.allocatable)}}else d={buffer:s};return{binding:u,resource:d}}if("texture"in i||"storageTexture"in i||"externalTexture"in i||"sampler"in i)return{binding:u,resource:s};throw new Error(`Malformed bind group entry: ${s} (${JSON.stringify(s)})`)}).filter(a=>a!==null)})}};var ce=class{constructor(e,r){this.device=e;this.jitTranspiler=r;_chunkSBJR5ZQJcjs.d.call(void 0, this,"_buffers",[]);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_samplers",new WeakMap);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_textures",new WeakMap);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_textureViews",new WeakMap);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_externalTexturesStatus",new WeakMap);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_unwrappedBindGroupLayouts",new H(e=>e.unwrap(this)));_chunkSBJR5ZQJcjs.d.call(void 0, this,"_unwrappedBindGroups",new H(e=>e.unwrap(this)));_chunkSBJR5ZQJcjs.d.call(void 0, this,"_pipelineExecutors",[]);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_commandEncoder",null);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_plumStore",new ne)}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}createBuffer(e,r){let n=le(this,e,r).$device(this.device);return this._buffers.push(n),n}destroy(){for(let e of this._buffers)e.destroy()}unwrap(e){if(A(e))return e.buffer;if(nt(e))return this._unwrappedBindGroupLayouts.getOrMake(e);if(at(e))return this._unwrappedBindGroups.getOrMake(e);throw new Error(`Unknown resource type: ${e}`)}textureFor(e){let r;"texture"in e?r=e.texture:r=e;let n=this._textures.get(r);if(!n){let a=_chunkSBJR5ZQJcjs.b.call(void 0, _chunkSBJR5ZQJcjs.a.call(void 0, {},r.descriptor),{usage:r.flags});if(n=this.device.createTexture(a),!n)throw new Error(`Failed to create texture for ${e}`);this._textures.set(r,n)}return n}viewFor(e){let r=this._textureViews.get(e);return r||(r=this.textureFor(e.texture).createView(e.descriptor),this._textureViews.set(e,r)),r}externalTextureFor(e){if(this._externalTexturesStatus.set(e,"clean"),e.descriptor.source===void 0)throw new Error("External texture source needs to be defined before use");return this.device.importExternalTexture(e.descriptor)}samplerFor(e){let r=this._samplers.get(e);if(!r){if(r=this.device.createSampler(e.descriptor),!r)throw new Error(`Failed to create sampler for ${e}`);this._samplers.set(e,r)}return r}setSource(e,r){this._externalTexturesStatus.set(e,"dirty"),e.descriptor.source=r}isDirty(e){return this._externalTexturesStatus.get(e)==="dirty"}markClean(e){this._externalTexturesStatus.set(e,"clean")}readPlum(e){return this._plumStore.get(e)}setPlum(e,r){if(typeof r=="function"){let n=r;this._plumStore.set(e,n(this._plumStore.get(e)))}else this._plumStore.set(e,r)}onPlumChange(e,r){return this._plumStore.subscribe(e,r)}makeRenderPipeline(e){var d,T,m,c,w,U,fe,Q,Z;let{vertexProgram:r,fragmentProgram:n}=new se(this,e.vertex.code,e.fragment.code,e.vertex.output).build({bindingGroup:((d=e.externalLayouts)!=null?d:[]).length}),a=this.device.createShaderModule({code:r.code}),i=this.device.createShaderModule({code:n.code}),u=this.device.createPipelineLayout({label:(T=e.label)!=null?T:"",bindGroupLayouts:[...(m=e.externalLayouts)!=null?m:[],r.bindGroupResolver.getBindGroupLayout(),n.bindGroupResolver.getBindGroupLayout()]}),s=this.device.createRenderPipeline({label:(c=e.label)!=null?c:"",layout:u,vertex:{module:a,buffers:(w=r.bindGroupResolver.getVertexBufferDescriptors())!=null?w:[]},fragment:{module:i,targets:(fe=(U=e.fragment)==null?void 0:U.target)!=null?fe:[]},primitive:e.primitive}),l=new Ve(this,s,r,n,(Z=(Q=e.externalLayouts)==null?void 0:Q.length)!=null?Z:0);return this._pipelineExecutors.push(l),l}makeComputePipeline(e){var s,l,d,T,m;let r=_chunkSBJR5ZQJcjs.e.call(void 0, ()=>{var c,w;return new pe(this,e.code,(c=e.workgroupSize)!=null?c:[1]).build({bindingGroup:((w=e.externalLayouts)!=null?w:[]).length})}),n=this.device.createShaderModule({code:r.code}),a=this.device.createPipelineLayout({label:(s=e.label)!=null?s:"",bindGroupLayouts:[...(l=e.externalLayouts)!=null?l:[],r.bindGroupResolver.getBindGroupLayout()]}),i=this.device.createComputePipeline({label:(d=e.label)!=null?d:"",layout:a,compute:{module:n}}),u=new Le(this,i,[r],(m=(T=e.externalLayouts)==null?void 0:T.length)!=null?m:0);return this._pipelineExecutors.push(u),u}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}},Ve=class{constructor(e,r,n,a,i,u){this.root=e;this.pipeline=r;this.vertexProgram=n;this.fragmentProgram=a;this.externalLayoutCount=i;this.label=u}execute(e){var T,m,c;let d=e,{vertexCount:r,instanceCount:n,firstVertex:a,firstInstance:i,externalBindGroups:u}=d,s=_chunkSBJR5ZQJcjs.c.call(void 0, d,["vertexCount","instanceCount","firstVertex","firstInstance","externalBindGroups"]);if(((T=u==null?void 0:u.length)!=null?T:0)!==this.externalLayoutCount)throw new Error(`External bind group count doesn't match the external bind group layout configuration. Expected ${this.externalLayoutCount}, got: ${(m=u==null?void 0:u.length)!=null?m:0}`);let l=this.root.commandEncoder.beginRenderPass(_chunkSBJR5ZQJcjs.b.call(void 0, _chunkSBJR5ZQJcjs.a.call(void 0, {},s),{label:(c=this.label)!=null?c:""}));l.setPipeline(this.pipeline),(u!=null?u:[]).forEach((w,U)=>l.setBindGroup(U,w)),l.setBindGroup((u!=null?u:[]).length,this.vertexProgram.bindGroupResolver.getBindGroup()),l.setBindGroup((u!=null?u:[]).length+1,this.fragmentProgram.bindGroupResolver.getBindGroup());for(let[w,U]of this.vertexProgram.bindGroupResolver.getVertexBuffers())l.setVertexBuffer(U,w.allocatable.buffer);l.draw(r,n,a,i),l.end()}},Le=class{constructor(e,r,n,a,i){this.root=e;this.pipeline=r;this.programs=n;this.externalLayoutCount=a;this.label=i}execute(e){var i,u,s;let{workgroups:r=[1,1],externalBindGroups:n}=e!=null?e:{};if(((i=n==null?void 0:n.length)!=null?i:0)!==this.externalLayoutCount)throw new Error(`External bind group count doesn't match the external bind group layout configuration. Expected ${this.externalLayoutCount}, got: ${(u=n==null?void 0:n.length)!=null?u:0}`);let a=this.root.commandEncoder.beginComputePass({label:(s=this.label)!=null?s:""});a.setPipeline(this.pipeline),(n!=null?n:[]).forEach((l,d)=>a.setBindGroup(d,l)),this.programs.forEach((l,d)=>a.setBindGroup((n!=null?n:[]).length+d,l.bindGroupResolver.getBindGroup())),a.dispatchWorkgroups(...r),a.end()}};async function ut(t){if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let e=await navigator.gpu.requestAdapter(t==null?void 0:t.adapter);if(!e)throw new Error("Could not find a compatible GPU");return new ce(await e.requestDevice(t==null?void 0:t.device),t==null?void 0:t.unstable_jitTranspiler)}function it(t){return new ce(t.device,t.unstable_jitTranspiler)}function ot(t,e){return le(void 0,t,e)}function st(t,e){t.write(e)}async function pt(t){return t.read()}var I=t=>Math.sqrt(t.x**2+t.y**2),C=t=>Math.sqrt(t.x**2+t.y**2+t.z**2),F=t=>Math.sqrt(t.x**2+t.y**2+t.z**2+t.w**2),R={length:{vec2f:I,vec2i:I,vec2u:I,vec3f:C,vec3i:C,vec3u:C,vec4f:F,vec4i:F,vec4u:F},add:{vec2f:(t,e)=>_chunkSBJR5ZQJcjs.P.call(void 0, t.x+e.x,t.y+e.y),vec2i:(t,e)=>_chunkSBJR5ZQJcjs.Q.call(void 0, t.x+e.x,t.y+e.y),vec2u:(t,e)=>_chunkSBJR5ZQJcjs.R.call(void 0, t.x+e.x,t.y+e.y),vec3f:(t,e)=>_chunkSBJR5ZQJcjs.S.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z),vec3i:(t,e)=>_chunkSBJR5ZQJcjs.T.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z),vec3u:(t,e)=>_chunkSBJR5ZQJcjs.U.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z),vec4f:(t,e)=>_chunkSBJR5ZQJcjs.V.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z,t.w+e.w),vec4i:(t,e)=>_chunkSBJR5ZQJcjs.W.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z,t.w+e.w),vec4u:(t,e)=>_chunkSBJR5ZQJcjs.X.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z,t.w+e.w)},sub:{vec2f:(t,e)=>_chunkSBJR5ZQJcjs.P.call(void 0, t.x-e.x,t.y-e.y),vec2i:(t,e)=>_chunkSBJR5ZQJcjs.Q.call(void 0, t.x-e.x,t.y-e.y),vec2u:(t,e)=>_chunkSBJR5ZQJcjs.R.call(void 0, t.x-e.x,t.y-e.y),vec3f:(t,e)=>_chunkSBJR5ZQJcjs.S.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z),vec3i:(t,e)=>_chunkSBJR5ZQJcjs.T.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z),vec3u:(t,e)=>_chunkSBJR5ZQJcjs.U.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z),vec4f:(t,e)=>_chunkSBJR5ZQJcjs.V.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z,t.w-e.w),vec4i:(t,e)=>_chunkSBJR5ZQJcjs.W.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z,t.w-e.w),vec4u:(t,e)=>_chunkSBJR5ZQJcjs.X.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z,t.w-e.w)},mul:{vec2f:(t,e)=>_chunkSBJR5ZQJcjs.P.call(void 0, t*e.x,t*e.y),vec2i:(t,e)=>_chunkSBJR5ZQJcjs.Q.call(void 0, t*e.x,t*e.y),vec2u:(t,e)=>_chunkSBJR5ZQJcjs.R.call(void 0, t*e.x,t*e.y),vec3f:(t,e)=>_chunkSBJR5ZQJcjs.S.call(void 0, t*e.x,t*e.y,t*e.z),vec3i:(t,e)=>_chunkSBJR5ZQJcjs.T.call(void 0, t*e.x,t*e.y,t*e.z),vec3u:(t,e)=>_chunkSBJR5ZQJcjs.U.call(void 0, t*e.x,t*e.y,t*e.z),vec4f:(t,e)=>_chunkSBJR5ZQJcjs.V.call(void 0, t*e.x,t*e.y,t*e.z,t*e.w),vec4i:(t,e)=>_chunkSBJR5ZQJcjs.W.call(void 0, t*e.x,t*e.y,t*e.z,t*e.w),vec4u:(t,e)=>_chunkSBJR5ZQJcjs.X.call(void 0, t*e.x,t*e.y,t*e.z,t*e.w)},dot:{vec2f:(t,e)=>t.x*e.x+t.y*e.y,vec2i:(t,e)=>t.x*e.x+t.y*e.y,vec2u:(t,e)=>t.x*e.x+t.y*e.y,vec3f:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z,vec3i:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z,vec3u:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z,vec4f:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w,vec4i:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w,vec4u:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},normalize:{vec2f:t=>{let e=I(t);return _chunkSBJR5ZQJcjs.P.call(void 0, t.x/e,t.y/e)},vec2i:t=>{let e=I(t);return _chunkSBJR5ZQJcjs.Q.call(void 0, t.x/e,t.y/e)},vec2u:t=>{let e=I(t);return _chunkSBJR5ZQJcjs.R.call(void 0, t.x/e,t.y/e)},vec3f:t=>{let e=C(t);return _chunkSBJR5ZQJcjs.S.call(void 0, t.x/e,t.y/e,t.z/e)},vec3i:t=>{let e=C(t);return _chunkSBJR5ZQJcjs.T.call(void 0, t.x/e,t.y/e,t.z/e)},vec3u:t=>{let e=C(t);return _chunkSBJR5ZQJcjs.U.call(void 0, t.x/e,t.y/e,t.z/e)},vec4f:t=>{let e=F(t);return _chunkSBJR5ZQJcjs.V.call(void 0, t.x/e,t.y/e,t.z/e,t.w/e)},vec4i:t=>{let e=F(t);return _chunkSBJR5ZQJcjs.W.call(void 0, t.x/e,t.y/e,t.z/e,t.w/e)},vec4u:t=>{let e=F(t);return _chunkSBJR5ZQJcjs.X.call(void 0, t.x/e,t.y/e,t.z/e,t.w/e)}},cross:{vec3f:(t,e)=>_chunkSBJR5ZQJcjs.S.call(void 0, t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z,t.x*e.y-t.y*e.x),vec3i:(t,e)=>_chunkSBJR5ZQJcjs.T.call(void 0, t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z,t.x*e.y-t.y*e.x),vec3u:(t,e)=>_chunkSBJR5ZQJcjs.U.call(void 0, t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z,t.x*e.y-t.y*e.x)}};var wt={add(t,e){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`(${t} + ${e})`:R.add[t.kind](t,e)},sub(t,e){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`(${t} - ${e})`:R.sub[t.kind](t,e)},mul:(t,e)=>_chunkSBJR5ZQJcjs.f.call(void 0, )?`(${t} * ${e})`:R.mul[e.kind](t,e),dot(t,e){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`dot(${t}, ${e})`:R.dot[t.kind](t,e)},normalize:t=>_chunkSBJR5ZQJcjs.f.call(void 0, )?`normalize(${t})`:R.normalize[t.kind](t),cross(t,e){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`cross(${t}, ${e})`:R.cross[t.kind](t,e)},fract(t){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`fract(${t})`:t-Math.floor(t)},length(t){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`length(${t})`:R.length[t.kind](t)},sin(t){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`sin(${t})`:Math.sin(t)},cos(t){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`cos(${t})`:Math.cos(t)}};var Bt={Uniform:"uniform",Storage:"storage",Vertex:"vertex",bindGroupLayout:rt,init:ut,initFromDevice:it,createBuffer:ot,read:pt,write:st},Yr= exports.default =Bt;exports.RecursiveDataTypeError = _chunkSBJR5ZQJcjs.i; exports.default = Yr; exports.isUsableAsStorage = ge; exports.isUsableAsUniform = de; exports.isUsableAsVertex = bt; exports.std = wt; exports.tgpu = Bt;
51
+ `;return new $(this.root,u).build({bindingGroup:e.bindingGroup,shaderStage:GPUShaderStage.COMPUTE,nameRegistry:(m=e.nameRegistry)!=null?m:new S})}};var _typedbinary = require('typed-binary');function le(t,e,r){return new Re(t,e,r)}function A(t){return t.resourceType==="buffer"}function de(t){return!!t.usableAsUniform}function ge(t){return!!t.usableAsStorage}function bt(t){return!!t.usableAsVertex}var Re=class{constructor(e,r,n){this._group=e;this.dataType=r;this.initialOrBuffer=n;_chunkSBJR5ZQJcjs.d.call(void 0, this,"resourceType","buffer");_chunkSBJR5ZQJcjs.d.call(void 0, this,"flags",GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_device",null);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_buffer",null);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_destroyed",!1);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_subscription",null);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_label");_chunkSBJR5ZQJcjs.d.call(void 0, this,"initial");_chunkSBJR5ZQJcjs.d.call(void 0, this,"usableAsUniform",!1);_chunkSBJR5ZQJcjs.d.call(void 0, this,"usableAsStorage",!1);_chunkSBJR5ZQJcjs.d.call(void 0, this,"usableAsVertex",!1);_chunkSBJR5ZQJcjs.z.call(void 0, n)?this._buffer=n:this.initial=n}get label(){return this._label}get buffer(){if(!this._device)throw new Error("Create this buffer using `root.createBuffer` instead of `tgpu.createBuffer`.");if(this._destroyed)throw new Error("This buffer has been destroyed");if(!this._buffer&&(this._buffer=this._device.createBuffer({size:this.dataType.size,usage:this.flags,mappedAtCreation:!!this.initial}),this.initial)){let e=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());if(Xe(this.initial)){let r=this._group;if(!r)throw new Error("Create this buffer using `root.createBuffer` instead of `tgpu.createBuffer`.");let n=this.initial;this.dataType.write(e,r.readPlum(n)),this._subscription=r.onPlumChange(n,()=>{this.write(r.readPlum(n))})}else this.dataType.write(e,this.initial);this._buffer.unmap()}return this._buffer}get device(){if(!this._device)throw new Error("This buffer has not been assigned a device. Use .$device(device) to assign a device");return this._device}get destroyed(){return this._destroyed}$name(e){return this._label=e,this}$usage(...e){for(let r of e)this.flags|=r==="uniform"?GPUBufferUsage.UNIFORM:0,this.flags|=r==="storage"?GPUBufferUsage.STORAGE:0,this.flags|=r==="vertex"?GPUBufferUsage.VERTEX:0,this.usableAsUniform=this.usableAsUniform||r==="uniform",this.usableAsStorage=this.usableAsStorage||r==="storage",this.usableAsVertex=this.usableAsVertex||r==="vertex";return this}$addFlags(e){return this.flags|=e,this}$device(e){return this._device=e,this}write(e){let r=this.buffer,n=this.device;if(r.mapState==="mapped"){let i=r.getMappedRange();if(A(e))throw new Error("Cannot copy to a mapped buffer.");this.dataType.write(new (0, _typedbinary.BufferWriter)(i),e);return}let a=this.dataType.size;if(A(e)){let i=e.buffer;if(this._group)this._group.commandEncoder.copyBufferToBuffer(i,0,r,0,a);else{let u=n.createCommandEncoder();u.copyBufferToBuffer(i,0,r,0,a),n.queue.submit([u.finish()])}}else{this._group&&this._group.flush();let i=new ArrayBuffer(a);this.dataType.write(new (0, _typedbinary.BufferWriter)(i),e),n.queue.writeBuffer(r,0,i,0,a)}}async read(){this._group&&this._group.flush();let e=this.buffer,r=this.device;if(e.mapState==="mapped"){let u=e.getMappedRange();return this.dataType.read(new (0, _typedbinary.BufferReader)(u))}if(e.usage&GPUBufferUsage.MAP_READ){await e.mapAsync(GPUMapMode.READ);let u=e.getMappedRange(),s=this.dataType.read(new (0, _typedbinary.BufferReader)(u));return e.unmap(),s}let n=r.createBuffer({size:this.dataType.size,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(e,0,n,0,this.dataType.size),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,this.dataType.size);let i=this.dataType.read(new (0, _typedbinary.BufferReader)(n.getMappedRange()));return n.unmap(),n.destroy(),i}destroy(){var e;this._destroyed||(this._destroyed=!0,this._subscription&&this._subscription(),(e=this._buffer)==null||e.destroy())}toString(){var e;return`buffer:${(e=this._label)!=null?e:"<unnamed>"}`}};function De(t){return!!t&&t.resourceType==="buffer-usage"}function rt(t){return new _e(t)}function nt(t){return!!t&&t.resourceType==="bind-group-layout"}function at(t){return!!t&&t.resourceType==="bind-group"}var Ge=class t extends Error{constructor(e,r){super(`Bind group '${e!=null?e:"<unnamed>"}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,t.prototype)}},tt=["compute"],k=["compute","vertex","fragment"],_e=class{constructor(e){this.entries=e;_chunkSBJR5ZQJcjs.d.call(void 0, this,"_label");_chunkSBJR5ZQJcjs.d.call(void 0, this,"resourceType","bind-group-layout");_chunkSBJR5ZQJcjs.d.call(void 0, this,"bound",{})}get label(){return this._label}$name(e){return this._label=e,this}unwrap(e){var n;return e.device.createBindGroupLayout({label:(n=this.label)!=null?n:"",entries:Object.values(this.entries).map((a,i)=>{var l,d,T,m;if(a===null)return null;let u=a.visibility,s={binding:i,visibility:0};if("uniform"in a)u=u!=null?u:k,s.buffer={type:"uniform"};else if("storage"in a)u=u!=null?u:a.access==="mutable"?tt:k,s.buffer={type:a.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in a)u=u!=null?u:k,s.sampler={type:a.sampler};else if("texture"in a)u=u!=null?u:k,s.texture={sampleType:a.texture,viewDimension:(l=a.viewDimension)!=null?l:"2d",multisampled:(d=a.multisampled)!=null?d:!1};else if("storageTexture"in a){let c=(T=a.access)!=null?T:"writeonly";u=u!=null?u:c==="readonly"?k:tt,s.storageTexture={format:a.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[c],viewDimension:(m=a.viewDimension)!=null?m:"2d"}}else"externalTexture"in a&&(u=u!=null?u:k,s.externalTexture={});return u!=null&&u.includes("compute")&&(s.visibility|=GPUShaderStage.COMPUTE),u!=null&&u.includes("vertex")&&(s.visibility|=GPUShaderStage.VERTEX),u!=null&&u.includes("fragment")&&(s.visibility|=GPUShaderStage.FRAGMENT),s}).filter(a=>a!==null)})}populate(e){return new Ae(this,e)}},Ae=class{constructor(e,r){this.layout=e;this.entries=r;_chunkSBJR5ZQJcjs.d.call(void 0, this,"resourceType","bind-group");for(let n of Object.keys(e.entries))if(e.entries[n]!==null&&!(n in r))throw new Ge(e.label,n)}unwrap(e){var n;return e.device.createBindGroup({label:(n=this.layout.label)!=null?n:"",layout:e.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([a,i],u)=>{var l;if(i===null)return null;let s=this.entries[a];if(s===void 0)throw new Error(`'${a}' is a resource required to populate bind group layout '${(l=this.layout.label)!=null?l:"<unnamed>"}'.`);if("uniform"in i){let d;if(A(s)){if(!de(s))throw new (0, _chunkSBJR5ZQJcjs.j)(s);d={buffer:e.unwrap(s)}}else if(De(s)){if(!de(s.allocatable))throw new (0, _chunkSBJR5ZQJcjs.j)(s.allocatable);d={buffer:e.unwrap(s.allocatable)}}else d={buffer:s};return{binding:u,resource:d}}if("storage"in i){let d;if(A(s)){if(!ge(s))throw new (0, _chunkSBJR5ZQJcjs.j)(s);d={buffer:e.unwrap(s)}}else if(De(s)){if(!ge(s.allocatable))throw new (0, _chunkSBJR5ZQJcjs.j)(s.allocatable);d={buffer:e.unwrap(s.allocatable)}}else d={buffer:s};return{binding:u,resource:d}}if("texture"in i||"storageTexture"in i||"externalTexture"in i||"sampler"in i)return{binding:u,resource:s};throw new Error(`Malformed bind group entry: ${s} (${JSON.stringify(s)})`)}).filter(a=>a!==null)})}};var ce=class{constructor(e,r){this.device=e;this.jitTranspiler=r;_chunkSBJR5ZQJcjs.d.call(void 0, this,"_buffers",[]);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_samplers",new WeakMap);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_textures",new WeakMap);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_textureViews",new WeakMap);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_externalTexturesStatus",new WeakMap);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_unwrappedBindGroupLayouts",new H(e=>e.unwrap(this)));_chunkSBJR5ZQJcjs.d.call(void 0, this,"_unwrappedBindGroups",new H(e=>e.unwrap(this)));_chunkSBJR5ZQJcjs.d.call(void 0, this,"_pipelineExecutors",[]);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_commandEncoder",null);_chunkSBJR5ZQJcjs.d.call(void 0, this,"_plumStore",new ne)}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}createBuffer(e,r){let n=le(this,e,r).$device(this.device);return this._buffers.push(n),n}destroy(){for(let e of this._buffers)e.destroy()}unwrap(e){if(A(e))return e.buffer;if(nt(e))return this._unwrappedBindGroupLayouts.getOrMake(e);if(at(e))return this._unwrappedBindGroups.getOrMake(e);throw new Error(`Unknown resource type: ${e}`)}textureFor(e){let r;"texture"in e?r=e.texture:r=e;let n=this._textures.get(r);if(!n){let a=_chunkSBJR5ZQJcjs.b.call(void 0, _chunkSBJR5ZQJcjs.a.call(void 0, {},r.descriptor),{usage:r.flags});if(n=this.device.createTexture(a),!n)throw new Error(`Failed to create texture for ${e}`);this._textures.set(r,n)}return n}viewFor(e){let r=this._textureViews.get(e);return r||(r=this.textureFor(e.texture).createView(e.descriptor),this._textureViews.set(e,r)),r}externalTextureFor(e){if(this._externalTexturesStatus.set(e,"clean"),e.descriptor.source===void 0)throw new Error("External texture source needs to be defined before use");return this.device.importExternalTexture(e.descriptor)}samplerFor(e){let r=this._samplers.get(e);if(!r){if(r=this.device.createSampler(e.descriptor),!r)throw new Error(`Failed to create sampler for ${e}`);this._samplers.set(e,r)}return r}setSource(e,r){this._externalTexturesStatus.set(e,"dirty"),e.descriptor.source=r}isDirty(e){return this._externalTexturesStatus.get(e)==="dirty"}markClean(e){this._externalTexturesStatus.set(e,"clean")}readPlum(e){return this._plumStore.get(e)}setPlum(e,r){if(typeof r=="function"){let n=r;this._plumStore.set(e,n(this._plumStore.get(e)))}else this._plumStore.set(e,r)}onPlumChange(e,r){return this._plumStore.subscribe(e,r)}makeRenderPipeline(e){var d,T,m,c,w,U,fe,Q,Z;let{vertexProgram:r,fragmentProgram:n}=new se(this,e.vertex.code,e.fragment.code,e.vertex.output).build({bindingGroup:((d=e.externalLayouts)!=null?d:[]).length}),a=this.device.createShaderModule({code:r.code}),i=this.device.createShaderModule({code:n.code}),u=this.device.createPipelineLayout({label:(T=e.label)!=null?T:"",bindGroupLayouts:[...(m=e.externalLayouts)!=null?m:[],r.bindGroupResolver.getBindGroupLayout(),n.bindGroupResolver.getBindGroupLayout()]}),s=this.device.createRenderPipeline({label:(c=e.label)!=null?c:"",layout:u,vertex:{module:a,buffers:(w=r.bindGroupResolver.getVertexBufferDescriptors())!=null?w:[]},fragment:{module:i,targets:(fe=(U=e.fragment)==null?void 0:U.target)!=null?fe:[]},primitive:e.primitive}),l=new Ve(this,s,r,n,(Z=(Q=e.externalLayouts)==null?void 0:Q.length)!=null?Z:0);return this._pipelineExecutors.push(l),l}makeComputePipeline(e){var s,l,d,T,m;let r=_chunkSBJR5ZQJcjs.e.call(void 0, ()=>{var c,w;return new pe(this,e.code,(c=e.workgroupSize)!=null?c:[1]).build({bindingGroup:((w=e.externalLayouts)!=null?w:[]).length})}),n=this.device.createShaderModule({code:r.code}),a=this.device.createPipelineLayout({label:(s=e.label)!=null?s:"",bindGroupLayouts:[...(l=e.externalLayouts)!=null?l:[],r.bindGroupResolver.getBindGroupLayout()]}),i=this.device.createComputePipeline({label:(d=e.label)!=null?d:"",layout:a,compute:{module:n}}),u=new Le(this,i,[r],(m=(T=e.externalLayouts)==null?void 0:T.length)!=null?m:0);return this._pipelineExecutors.push(u),u}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}},Ve=class{constructor(e,r,n,a,i,u){this.root=e;this.pipeline=r;this.vertexProgram=n;this.fragmentProgram=a;this.externalLayoutCount=i;this.label=u}execute(e){var T,m,c;let d=e,{vertexCount:r,instanceCount:n,firstVertex:a,firstInstance:i,externalBindGroups:u}=d,s=_chunkSBJR5ZQJcjs.c.call(void 0, d,["vertexCount","instanceCount","firstVertex","firstInstance","externalBindGroups"]);if(((T=u==null?void 0:u.length)!=null?T:0)!==this.externalLayoutCount)throw new Error(`External bind group count doesn't match the external bind group layout configuration. Expected ${this.externalLayoutCount}, got: ${(m=u==null?void 0:u.length)!=null?m:0}`);let l=this.root.commandEncoder.beginRenderPass(_chunkSBJR5ZQJcjs.b.call(void 0, _chunkSBJR5ZQJcjs.a.call(void 0, {},s),{label:(c=this.label)!=null?c:""}));l.setPipeline(this.pipeline),(u!=null?u:[]).forEach((w,U)=>l.setBindGroup(U,w)),l.setBindGroup((u!=null?u:[]).length,this.vertexProgram.bindGroupResolver.getBindGroup()),l.setBindGroup((u!=null?u:[]).length+1,this.fragmentProgram.bindGroupResolver.getBindGroup());for(let[w,U]of this.vertexProgram.bindGroupResolver.getVertexBuffers())l.setVertexBuffer(U,w.allocatable.buffer);l.draw(r,n,a,i),l.end()}},Le=class{constructor(e,r,n,a,i){this.root=e;this.pipeline=r;this.programs=n;this.externalLayoutCount=a;this.label=i}execute(e){var i,u,s;let{workgroups:r=[1,1],externalBindGroups:n}=e!=null?e:{};if(((i=n==null?void 0:n.length)!=null?i:0)!==this.externalLayoutCount)throw new Error(`External bind group count doesn't match the external bind group layout configuration. Expected ${this.externalLayoutCount}, got: ${(u=n==null?void 0:n.length)!=null?u:0}`);let a=this.root.commandEncoder.beginComputePass({label:(s=this.label)!=null?s:""});a.setPipeline(this.pipeline),(n!=null?n:[]).forEach((l,d)=>a.setBindGroup(d,l)),this.programs.forEach((l,d)=>a.setBindGroup((n!=null?n:[]).length+d,l.bindGroupResolver.getBindGroup())),a.dispatchWorkgroups(...r),a.end()}};async function ut(t){if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let e=await navigator.gpu.requestAdapter(t==null?void 0:t.adapter);if(!e)throw new Error("Could not find a compatible GPU");return new ce(await e.requestDevice(t==null?void 0:t.device),t==null?void 0:t.unstable_jitTranspiler)}function it(t){return new ce(t.device,t.unstable_jitTranspiler)}function ot(t,e){return le(void 0,t,e)}function st(t,e){t.write(e)}async function pt(t){return t.read()}var I=t=>Math.sqrt(t.x**2+t.y**2),C=t=>Math.sqrt(t.x**2+t.y**2+t.z**2),F=t=>Math.sqrt(t.x**2+t.y**2+t.z**2+t.w**2),D={length:{vec2f:I,vec2i:I,vec2u:I,vec3f:C,vec3i:C,vec3u:C,vec4f:F,vec4i:F,vec4u:F},add:{vec2f:(t,e)=>_chunkSBJR5ZQJcjs.P.call(void 0, t.x+e.x,t.y+e.y),vec2i:(t,e)=>_chunkSBJR5ZQJcjs.Q.call(void 0, t.x+e.x,t.y+e.y),vec2u:(t,e)=>_chunkSBJR5ZQJcjs.R.call(void 0, t.x+e.x,t.y+e.y),vec3f:(t,e)=>_chunkSBJR5ZQJcjs.S.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z),vec3i:(t,e)=>_chunkSBJR5ZQJcjs.T.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z),vec3u:(t,e)=>_chunkSBJR5ZQJcjs.U.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z),vec4f:(t,e)=>_chunkSBJR5ZQJcjs.V.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z,t.w+e.w),vec4i:(t,e)=>_chunkSBJR5ZQJcjs.W.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z,t.w+e.w),vec4u:(t,e)=>_chunkSBJR5ZQJcjs.X.call(void 0, t.x+e.x,t.y+e.y,t.z+e.z,t.w+e.w)},sub:{vec2f:(t,e)=>_chunkSBJR5ZQJcjs.P.call(void 0, t.x-e.x,t.y-e.y),vec2i:(t,e)=>_chunkSBJR5ZQJcjs.Q.call(void 0, t.x-e.x,t.y-e.y),vec2u:(t,e)=>_chunkSBJR5ZQJcjs.R.call(void 0, t.x-e.x,t.y-e.y),vec3f:(t,e)=>_chunkSBJR5ZQJcjs.S.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z),vec3i:(t,e)=>_chunkSBJR5ZQJcjs.T.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z),vec3u:(t,e)=>_chunkSBJR5ZQJcjs.U.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z),vec4f:(t,e)=>_chunkSBJR5ZQJcjs.V.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z,t.w-e.w),vec4i:(t,e)=>_chunkSBJR5ZQJcjs.W.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z,t.w-e.w),vec4u:(t,e)=>_chunkSBJR5ZQJcjs.X.call(void 0, t.x-e.x,t.y-e.y,t.z-e.z,t.w-e.w)},mul:{vec2f:(t,e)=>_chunkSBJR5ZQJcjs.P.call(void 0, t*e.x,t*e.y),vec2i:(t,e)=>_chunkSBJR5ZQJcjs.Q.call(void 0, t*e.x,t*e.y),vec2u:(t,e)=>_chunkSBJR5ZQJcjs.R.call(void 0, t*e.x,t*e.y),vec3f:(t,e)=>_chunkSBJR5ZQJcjs.S.call(void 0, t*e.x,t*e.y,t*e.z),vec3i:(t,e)=>_chunkSBJR5ZQJcjs.T.call(void 0, t*e.x,t*e.y,t*e.z),vec3u:(t,e)=>_chunkSBJR5ZQJcjs.U.call(void 0, t*e.x,t*e.y,t*e.z),vec4f:(t,e)=>_chunkSBJR5ZQJcjs.V.call(void 0, t*e.x,t*e.y,t*e.z,t*e.w),vec4i:(t,e)=>_chunkSBJR5ZQJcjs.W.call(void 0, t*e.x,t*e.y,t*e.z,t*e.w),vec4u:(t,e)=>_chunkSBJR5ZQJcjs.X.call(void 0, t*e.x,t*e.y,t*e.z,t*e.w)},dot:{vec2f:(t,e)=>t.x*e.x+t.y*e.y,vec2i:(t,e)=>t.x*e.x+t.y*e.y,vec2u:(t,e)=>t.x*e.x+t.y*e.y,vec3f:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z,vec3i:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z,vec3u:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z,vec4f:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w,vec4i:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w,vec4u:(t,e)=>t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},normalize:{vec2f:t=>{let e=I(t);return _chunkSBJR5ZQJcjs.P.call(void 0, t.x/e,t.y/e)},vec2i:t=>{let e=I(t);return _chunkSBJR5ZQJcjs.Q.call(void 0, t.x/e,t.y/e)},vec2u:t=>{let e=I(t);return _chunkSBJR5ZQJcjs.R.call(void 0, t.x/e,t.y/e)},vec3f:t=>{let e=C(t);return _chunkSBJR5ZQJcjs.S.call(void 0, t.x/e,t.y/e,t.z/e)},vec3i:t=>{let e=C(t);return _chunkSBJR5ZQJcjs.T.call(void 0, t.x/e,t.y/e,t.z/e)},vec3u:t=>{let e=C(t);return _chunkSBJR5ZQJcjs.U.call(void 0, t.x/e,t.y/e,t.z/e)},vec4f:t=>{let e=F(t);return _chunkSBJR5ZQJcjs.V.call(void 0, t.x/e,t.y/e,t.z/e,t.w/e)},vec4i:t=>{let e=F(t);return _chunkSBJR5ZQJcjs.W.call(void 0, t.x/e,t.y/e,t.z/e,t.w/e)},vec4u:t=>{let e=F(t);return _chunkSBJR5ZQJcjs.X.call(void 0, t.x/e,t.y/e,t.z/e,t.w/e)}},cross:{vec3f:(t,e)=>_chunkSBJR5ZQJcjs.S.call(void 0, t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z,t.x*e.y-t.y*e.x),vec3i:(t,e)=>_chunkSBJR5ZQJcjs.T.call(void 0, t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z,t.x*e.y-t.y*e.x),vec3u:(t,e)=>_chunkSBJR5ZQJcjs.U.call(void 0, t.y*e.z-t.z*e.y,t.z*e.x-t.x*e.z,t.x*e.y-t.y*e.x)}};var wt={add(t,e){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`(${t} + ${e})`:D.add[t.kind](t,e)},sub(t,e){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`(${t} - ${e})`:D.sub[t.kind](t,e)},mul:(t,e)=>_chunkSBJR5ZQJcjs.f.call(void 0, )?`(${t} * ${e})`:D.mul[e.kind](t,e),dot(t,e){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`dot(${t}, ${e})`:D.dot[t.kind](t,e)},normalize:t=>_chunkSBJR5ZQJcjs.f.call(void 0, )?`normalize(${t})`:D.normalize[t.kind](t),cross(t,e){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`cross(${t}, ${e})`:D.cross[t.kind](t,e)},fract(t){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`fract(${t})`:t-Math.floor(t)},length(t){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`length(${t})`:D.length[t.kind](t)},sin(t){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`sin(${t})`:Math.sin(t)},cos(t){return _chunkSBJR5ZQJcjs.f.call(void 0, )?`cos(${t})`:Math.cos(t)}};var Bt={Uniform:"uniform",Storage:"storage",Vertex:"vertex",bindGroupLayout:rt,init:ut,initFromDevice:it,createBuffer:ot,read:pt,write:st},Yr= exports.default =Bt;exports.RecursiveDataTypeError = _chunkSBJR5ZQJcjs.i; exports.default = Yr; exports.isUsableAsStorage = ge; exports.isUsableAsUniform = de; exports.isUsableAsVertex = bt; exports.std = wt; exports.tgpu = Bt;
52
52
  //# sourceMappingURL=index.cjs.map