typegpu 0.5.3 → 0.5.4
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/README.md +1 -1
- package/attributes-BdU8hyQq.d.cts +435 -0
- package/attributes-CAsvE5Z9.d.ts +435 -0
- package/{chunk-RMXVIINO.js → chunk-5PJ3H5OR.js} +2 -2
- package/chunk-5PJ3H5OR.js.map +1 -0
- package/chunk-7UUBX6MC.cjs +4 -0
- package/chunk-7UUBX6MC.cjs.map +1 -0
- package/chunk-AKBL6GDL.js +4 -0
- package/chunk-AKBL6GDL.js.map +1 -0
- package/{chunk-FM3TKZFZ.cjs → chunk-URJCMUTT.cjs} +2 -2
- package/chunk-URJCMUTT.cjs.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.cjs.map +1 -1
- package/data/index.d.cts +51 -4
- package/data/index.d.ts +51 -4
- package/data/index.js +1 -1
- package/index.cjs +16 -16
- package/index.cjs.map +1 -1
- package/index.d.cts +92 -53
- package/index.d.ts +92 -53
- package/index.js +16 -16
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/std/index.cjs +1 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +141 -33
- package/std/index.d.ts +141 -33
- package/std/index.js +1 -1
- package/std/index.js.map +1 -1
- package/{wgslTypes-VtSRoe90.d.cts → wgslTypes-Bh2dG5qv.d.cts} +213 -405
- package/{wgslTypes-VtSRoe90.d.ts → wgslTypes-Bh2dG5qv.d.ts} +213 -405
- package/attributes-B4JpvOTz.d.ts +0 -159
- package/attributes-DSOqT8yA.d.cts +0 -159
- package/chunk-DVZNNZFQ.js +0 -2
- package/chunk-DVZNNZFQ.js.map +0 -1
- package/chunk-FM3TKZFZ.cjs.map +0 -1
- package/chunk-M4VUFFPZ.cjs +0 -4
- package/chunk-M4VUFFPZ.cjs.map +0 -1
- package/chunk-RMXVIINO.js.map +0 -1
- package/chunk-UHU5Z2IS.js +0 -4
- package/chunk-UHU5Z2IS.js.map +0 -1
- package/chunk-UPPJES6W.cjs +0 -2
- package/chunk-UPPJES6W.cjs.map +0 -1
package/std/index.d.cts
CHANGED
@@ -1,102 +1,210 @@
|
|
1
|
-
import {
|
1
|
+
import { as as AnyNumericVecInstance, y as AnyMatInstance, at as vBaseForMat, au as AnyFloatVecInstance, af as v3f, av as v3h, x as AnyVecInstance, aw as AnyVec2Instance, ax as v2b, ay as AnyVec3Instance, az as v3b, aA as v4b, aB as AnyBooleanVecInstance, aC as ScalarData, aD as atomicI32, aE as atomicU32 } from '../wgslTypes-Bh2dG5qv.cjs';
|
2
2
|
|
3
3
|
declare const discard: () => never;
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
};
|
8
|
-
declare const add: <T extends vBase>(lhs: T, rhs: T) => T;
|
9
|
-
declare const sub: <T extends vBase>(lhs: T, rhs: T) => T;
|
5
|
+
declare const add: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T;
|
6
|
+
declare const sub: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T;
|
10
7
|
type MulOverload = {
|
11
8
|
<T extends AnyMatInstance, TVec extends vBaseForMat<T>>(s: T, v: TVec): TVec;
|
12
9
|
<T extends AnyMatInstance, TVec extends vBaseForMat<T>>(s: TVec, v: T): TVec;
|
13
|
-
<T extends
|
10
|
+
<T extends AnyNumericVecInstance | AnyMatInstance>(s: number | T, v: T): T;
|
14
11
|
};
|
15
12
|
declare const mul: MulOverload;
|
16
|
-
declare const abs: <T extends
|
17
|
-
declare const atan2: <T extends
|
18
|
-
declare const acos: <T extends
|
19
|
-
declare const asin: <T extends
|
13
|
+
declare const abs: <T extends AnyNumericVecInstance | number>(value: T) => T;
|
14
|
+
declare const atan2: <T extends AnyFloatVecInstance | number>(y: T, x: T) => T;
|
15
|
+
declare const acos: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
16
|
+
declare const asin: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
20
17
|
/**
|
21
18
|
* @privateRemarks
|
22
19
|
* https://www.w3.org/TR/WGSL/#ceil-builtin
|
23
20
|
*/
|
24
|
-
declare const ceil: <T extends
|
21
|
+
declare const ceil: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
25
22
|
/**
|
26
23
|
* @privateRemarks
|
27
24
|
* https://www.w3.org/TR/WGSL/#clamp
|
28
25
|
*/
|
29
|
-
declare const clamp: <T extends
|
26
|
+
declare const clamp: <T extends AnyNumericVecInstance | number>(value: T, low: T, high: T) => T;
|
30
27
|
/**
|
31
28
|
* @privateRemarks
|
32
29
|
* https://www.w3.org/TR/WGSL/#cos-builtin
|
33
30
|
*/
|
34
|
-
declare const cos: <T extends
|
31
|
+
declare const cos: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
35
32
|
/**
|
36
33
|
* @privateRemarks
|
37
34
|
* https://www.w3.org/TR/WGSL/#cross-builtin
|
38
35
|
*/
|
39
|
-
declare const cross: <T extends v3f |
|
36
|
+
declare const cross: <T extends v3f | v3h>(a: T, b: T) => T;
|
40
37
|
/**
|
41
38
|
* @privateRemarks
|
42
39
|
* https://www.w3.org/TR/WGSL/#dot-builtin
|
43
40
|
*/
|
44
|
-
declare const dot: <T extends
|
45
|
-
declare const normalize: <T extends
|
41
|
+
declare const dot: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => number;
|
42
|
+
declare const normalize: <T extends AnyFloatVecInstance>(v: T) => T;
|
46
43
|
/**
|
47
44
|
* @privateRemarks
|
48
45
|
* https://www.w3.org/TR/WGSL/#floor-builtin
|
49
46
|
*/
|
50
|
-
declare const floor: <T extends
|
51
|
-
declare const fract: <T extends
|
47
|
+
declare const floor: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
48
|
+
declare const fract: <T extends AnyFloatVecInstance | number>(a: T) => T;
|
52
49
|
/**
|
53
50
|
* @privateRemarks
|
54
51
|
* https://www.w3.org/TR/WGSL/#length-builtin
|
55
52
|
*/
|
56
|
-
declare const length: <T extends
|
53
|
+
declare const length: <T extends AnyFloatVecInstance | number>(value: T) => number;
|
57
54
|
/**
|
58
55
|
* @privateRemarks
|
59
56
|
* https://www.w3.org/TR/WGSL/#max-float-builtin
|
60
57
|
*/
|
61
|
-
declare const max: <T extends
|
58
|
+
declare const max: <T extends AnyNumericVecInstance | number>(a: T, b: T) => T;
|
62
59
|
/**
|
63
60
|
* @privateRemarks
|
64
61
|
* https://www.w3.org/TR/WGSL/#min-float-builtin
|
65
62
|
*/
|
66
|
-
declare const min: <T extends
|
63
|
+
declare const min: <T extends AnyNumericVecInstance | number>(a: T, b: T) => T;
|
67
64
|
/**
|
68
65
|
* @privateRemarks
|
69
66
|
* https://www.w3.org/TR/WGSL/#sin-builtin
|
70
67
|
*/
|
71
|
-
declare const sin: <T extends
|
68
|
+
declare const sin: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
72
69
|
/**
|
73
70
|
* @privateRemarks
|
74
71
|
* https://www.w3.org/TR/WGSL/#exp-builtin
|
75
72
|
*/
|
76
|
-
declare const exp: <T extends
|
73
|
+
declare const exp: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
77
74
|
type PowOverload = {
|
78
75
|
(base: number, exponent: number): number;
|
79
|
-
<T extends
|
76
|
+
<T extends AnyFloatVecInstance>(base: T, exponent: T): T;
|
80
77
|
};
|
81
78
|
declare const pow: PowOverload;
|
82
79
|
type MixOverload = {
|
83
80
|
(e1: number, e2: number, e3: number): number;
|
84
|
-
<T extends
|
85
|
-
<T extends
|
81
|
+
<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: number): T;
|
82
|
+
<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: T): T;
|
86
83
|
};
|
87
84
|
declare const mix: MixOverload;
|
88
|
-
declare const reflect: <T extends
|
89
|
-
declare const distance: <T extends
|
85
|
+
declare const reflect: <T extends AnyFloatVecInstance>(e1: T, e2: T) => T;
|
86
|
+
declare const distance: <T extends AnyFloatVecInstance | number>(a: T, b: T) => number;
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Checks whether `lhs == rhs` on all components.
|
90
|
+
* Equivalent to `all(eq(lhs, rhs))`.
|
91
|
+
* @example
|
92
|
+
* allEq(vec2f(0.0, 1.0), vec2f(0.0, 2.0)) // returns false
|
93
|
+
* allEq(vec3u(0, 1, 2), vec3u(0, 1, 2)) // returns true
|
94
|
+
*/
|
95
|
+
declare const allEq: <T extends AnyVecInstance>(lhs: T, rhs: T) => boolean;
|
96
|
+
/**
|
97
|
+
* Checks **component-wise** whether `lhs == rhs`.
|
98
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `all`, or use `allEq`.
|
99
|
+
* @example
|
100
|
+
* eq(vec2f(0.0, 1.0), vec2f(0.0, 2.0)) // returns vec2b(true, false)
|
101
|
+
* eq(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(false, true, false)
|
102
|
+
* all(eq(vec4i(4, 3, 2, 1), vec4i(4, 3, 2, 1))) // returns true
|
103
|
+
* allEq(vec4i(4, 3, 2, 1), vec4i(4, 3, 2, 1)) // returns true
|
104
|
+
*/
|
105
|
+
declare const eq: <T extends AnyVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
106
|
+
/**
|
107
|
+
* Checks **component-wise** whether `lhs != rhs`.
|
108
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `any`.
|
109
|
+
* @example
|
110
|
+
* ne(vec2f(0.0, 1.0), vec2f(0.0, 2.0)) // returns vec2b(false, true)
|
111
|
+
* ne(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, false, true)
|
112
|
+
* any(ne(vec4i(4, 3, 2, 1), vec4i(4, 2, 2, 1))) // returns true
|
113
|
+
*/
|
114
|
+
declare const ne: <T extends AnyVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
115
|
+
/**
|
116
|
+
* Checks **component-wise** whether `lhs < rhs`.
|
117
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
118
|
+
* @example
|
119
|
+
* lt(vec2f(0.0, 0.0), vec2f(0.0, 1.0)) // returns vec2b(false, true)
|
120
|
+
* lt(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, false, false)
|
121
|
+
* all(lt(vec4i(1, 2, 3, 4), vec4i(2, 3, 4, 5))) // returns true
|
122
|
+
*/
|
123
|
+
declare const lt: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
124
|
+
/**
|
125
|
+
* Checks **component-wise** whether `lhs <= rhs`.
|
126
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
127
|
+
* @example
|
128
|
+
* le(vec2f(0.0, 0.0), vec2f(0.0, 1.0)) // returns vec2b(true, true)
|
129
|
+
* le(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, true, false)
|
130
|
+
* all(le(vec4i(1, 2, 3, 4), vec4i(2, 3, 3, 5))) // returns true
|
131
|
+
*/
|
132
|
+
declare const le: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
133
|
+
/**
|
134
|
+
* Checks **component-wise** whether `lhs > rhs`.
|
135
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
136
|
+
* @example
|
137
|
+
* gt(vec2f(0.0, 0.0), vec2f(0.0, 1.0)) // returns vec2b(false, false)
|
138
|
+
* gt(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(false, false, true)
|
139
|
+
* all(gt(vec4i(2, 3, 4, 5), vec4i(1, 2, 3, 4))) // returns true
|
140
|
+
*/
|
141
|
+
declare const gt: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
142
|
+
/**
|
143
|
+
* Checks **component-wise** whether `lhs >= rhs`.
|
144
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
145
|
+
* @example
|
146
|
+
* ge(vec2f(0.0, 0.0), vec2f(0.0, 1.0)) // returns vec2b(true, false)
|
147
|
+
* ge(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(false, true, true)
|
148
|
+
* all(ge(vec4i(2, 2, 4, 5), vec4i(1, 2, 3, 4))) // returns true
|
149
|
+
*/
|
150
|
+
declare const ge: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
151
|
+
/**
|
152
|
+
* Returns **component-wise** `!value`.
|
153
|
+
* @example
|
154
|
+
* not(vec2b(false, true)) // returns vec2b(true, false)
|
155
|
+
* not(vec3b(true, true, false)) // returns vec3b(false, false, true)
|
156
|
+
*/
|
157
|
+
declare const not: <T extends AnyBooleanVecInstance>(value: T) => T;
|
158
|
+
/**
|
159
|
+
* Returns **component-wise** logical `or` result.
|
160
|
+
* @example
|
161
|
+
* or(vec2b(false, true), vec2b(false, false)) // returns vec2b(false, true)
|
162
|
+
* or(vec3b(true, true, false), vec3b(false, true, false)) // returns vec3b(true, true, false)
|
163
|
+
*/
|
164
|
+
declare const or: <T extends AnyBooleanVecInstance>(lhs: T, rhs: T) => T;
|
165
|
+
/**
|
166
|
+
* Returns **component-wise** logical `and` result.
|
167
|
+
* @example
|
168
|
+
* and(vec2b(false, true), vec2b(true, true)) // returns vec2b(false, true)
|
169
|
+
* and(vec3b(true, true, false), vec3b(false, true, false)) // returns vec3b(false, true, false)
|
170
|
+
*/
|
171
|
+
declare const and: <T extends AnyBooleanVecInstance>(lhs: T, rhs: T) => T;
|
90
172
|
/**
|
91
|
-
*
|
92
|
-
*
|
173
|
+
* Returns `true` if each component of `value` is true.
|
174
|
+
* @example
|
175
|
+
* all(vec2b(false, true)) // returns false
|
176
|
+
* all(vec3b(true, true, true)) // returns true
|
177
|
+
*/
|
178
|
+
declare const all: (value: AnyBooleanVecInstance) => boolean;
|
179
|
+
/**
|
180
|
+
* Returns `true` if any component of `value` is true.
|
181
|
+
* @example
|
182
|
+
* any(vec2b(false, true)) // returns true
|
183
|
+
* any(vec3b(false, false, false)) // returns false
|
184
|
+
*/
|
185
|
+
declare const any: (value: AnyBooleanVecInstance) => boolean;
|
186
|
+
/**
|
187
|
+
* Checks whether the given elements differ by at most the `precision` value.
|
188
|
+
* Checks all elements of `lhs` and `rhs` if arguments are vectors.
|
93
189
|
* @example
|
94
190
|
* isCloseTo(0, 0.1) // returns false
|
95
191
|
* isCloseTo(vec3f(0, 0, 0), vec3f(0.002, -0.009, 0)) // returns true
|
96
192
|
*
|
97
193
|
* @param {number} precision argument that specifies the maximum allowed difference, 0.01 by default.
|
98
194
|
*/
|
99
|
-
declare const isCloseTo: <T extends
|
195
|
+
declare const isCloseTo: <T extends AnyFloatVecInstance | number>(lhs: T, rhs: T, precision?: number) => boolean;
|
196
|
+
type SelectOverload = {
|
197
|
+
<T extends ScalarData | AnyVecInstance>(f: T, t: T, cond: boolean): T;
|
198
|
+
<T extends AnyVecInstance>(f: T, t: T, cond: T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b): T;
|
199
|
+
};
|
200
|
+
/**
|
201
|
+
* Returns `t` if `cond` is `true`, and `f` otherwise.
|
202
|
+
* Component-wise if `cond` is a vector.
|
203
|
+
* @example
|
204
|
+
* select(vec2i(1, 2), vec2i(3, 4), true) // returns vec2i(3, 4)
|
205
|
+
* select(vec2i(1, 2), vec2i(3, 4), vec2b(false, true)) // returns vec2i(1, 4)
|
206
|
+
*/
|
207
|
+
declare const select: SelectOverload;
|
100
208
|
|
101
209
|
type AnyAtomic = atomicI32 | atomicU32;
|
102
210
|
declare const workgroupBarrier: () => void;
|
@@ -114,4 +222,4 @@ declare const atomicXor: <T extends AnyAtomic>(a: T, value: number) => number;
|
|
114
222
|
|
115
223
|
declare const arrayLength: (a: unknown[]) => number;
|
116
224
|
|
117
|
-
export { abs, acos, add, arrayLength, asin, atan2, atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, ceil, clamp, cos, cross, discard, distance, dot, exp, floor, fract, isCloseTo, length, max, min, mix, mul, normalize, pow, reflect, sin, storageBarrier, sub, textureBarrier, workgroupBarrier };
|
225
|
+
export { abs, acos, add, all, allEq, and, any, arrayLength, asin, atan2, atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, ceil, clamp, cos, cross, discard, distance, dot, eq, exp, floor, fract, ge, gt, isCloseTo, le, length, lt, max, min, mix, mul, ne, normalize, not, or, pow, reflect, select, sin, storageBarrier, sub, textureBarrier, workgroupBarrier };
|
package/std/index.d.ts
CHANGED
@@ -1,102 +1,210 @@
|
|
1
|
-
import {
|
1
|
+
import { as as AnyNumericVecInstance, y as AnyMatInstance, at as vBaseForMat, au as AnyFloatVecInstance, af as v3f, av as v3h, x as AnyVecInstance, aw as AnyVec2Instance, ax as v2b, ay as AnyVec3Instance, az as v3b, aA as v4b, aB as AnyBooleanVecInstance, aC as ScalarData, aD as atomicI32, aE as atomicU32 } from '../wgslTypes-Bh2dG5qv.js';
|
2
2
|
|
3
3
|
declare const discard: () => never;
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
};
|
8
|
-
declare const add: <T extends vBase>(lhs: T, rhs: T) => T;
|
9
|
-
declare const sub: <T extends vBase>(lhs: T, rhs: T) => T;
|
5
|
+
declare const add: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T;
|
6
|
+
declare const sub: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T;
|
10
7
|
type MulOverload = {
|
11
8
|
<T extends AnyMatInstance, TVec extends vBaseForMat<T>>(s: T, v: TVec): TVec;
|
12
9
|
<T extends AnyMatInstance, TVec extends vBaseForMat<T>>(s: TVec, v: T): TVec;
|
13
|
-
<T extends
|
10
|
+
<T extends AnyNumericVecInstance | AnyMatInstance>(s: number | T, v: T): T;
|
14
11
|
};
|
15
12
|
declare const mul: MulOverload;
|
16
|
-
declare const abs: <T extends
|
17
|
-
declare const atan2: <T extends
|
18
|
-
declare const acos: <T extends
|
19
|
-
declare const asin: <T extends
|
13
|
+
declare const abs: <T extends AnyNumericVecInstance | number>(value: T) => T;
|
14
|
+
declare const atan2: <T extends AnyFloatVecInstance | number>(y: T, x: T) => T;
|
15
|
+
declare const acos: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
16
|
+
declare const asin: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
20
17
|
/**
|
21
18
|
* @privateRemarks
|
22
19
|
* https://www.w3.org/TR/WGSL/#ceil-builtin
|
23
20
|
*/
|
24
|
-
declare const ceil: <T extends
|
21
|
+
declare const ceil: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
25
22
|
/**
|
26
23
|
* @privateRemarks
|
27
24
|
* https://www.w3.org/TR/WGSL/#clamp
|
28
25
|
*/
|
29
|
-
declare const clamp: <T extends
|
26
|
+
declare const clamp: <T extends AnyNumericVecInstance | number>(value: T, low: T, high: T) => T;
|
30
27
|
/**
|
31
28
|
* @privateRemarks
|
32
29
|
* https://www.w3.org/TR/WGSL/#cos-builtin
|
33
30
|
*/
|
34
|
-
declare const cos: <T extends
|
31
|
+
declare const cos: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
35
32
|
/**
|
36
33
|
* @privateRemarks
|
37
34
|
* https://www.w3.org/TR/WGSL/#cross-builtin
|
38
35
|
*/
|
39
|
-
declare const cross: <T extends v3f |
|
36
|
+
declare const cross: <T extends v3f | v3h>(a: T, b: T) => T;
|
40
37
|
/**
|
41
38
|
* @privateRemarks
|
42
39
|
* https://www.w3.org/TR/WGSL/#dot-builtin
|
43
40
|
*/
|
44
|
-
declare const dot: <T extends
|
45
|
-
declare const normalize: <T extends
|
41
|
+
declare const dot: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => number;
|
42
|
+
declare const normalize: <T extends AnyFloatVecInstance>(v: T) => T;
|
46
43
|
/**
|
47
44
|
* @privateRemarks
|
48
45
|
* https://www.w3.org/TR/WGSL/#floor-builtin
|
49
46
|
*/
|
50
|
-
declare const floor: <T extends
|
51
|
-
declare const fract: <T extends
|
47
|
+
declare const floor: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
48
|
+
declare const fract: <T extends AnyFloatVecInstance | number>(a: T) => T;
|
52
49
|
/**
|
53
50
|
* @privateRemarks
|
54
51
|
* https://www.w3.org/TR/WGSL/#length-builtin
|
55
52
|
*/
|
56
|
-
declare const length: <T extends
|
53
|
+
declare const length: <T extends AnyFloatVecInstance | number>(value: T) => number;
|
57
54
|
/**
|
58
55
|
* @privateRemarks
|
59
56
|
* https://www.w3.org/TR/WGSL/#max-float-builtin
|
60
57
|
*/
|
61
|
-
declare const max: <T extends
|
58
|
+
declare const max: <T extends AnyNumericVecInstance | number>(a: T, b: T) => T;
|
62
59
|
/**
|
63
60
|
* @privateRemarks
|
64
61
|
* https://www.w3.org/TR/WGSL/#min-float-builtin
|
65
62
|
*/
|
66
|
-
declare const min: <T extends
|
63
|
+
declare const min: <T extends AnyNumericVecInstance | number>(a: T, b: T) => T;
|
67
64
|
/**
|
68
65
|
* @privateRemarks
|
69
66
|
* https://www.w3.org/TR/WGSL/#sin-builtin
|
70
67
|
*/
|
71
|
-
declare const sin: <T extends
|
68
|
+
declare const sin: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
72
69
|
/**
|
73
70
|
* @privateRemarks
|
74
71
|
* https://www.w3.org/TR/WGSL/#exp-builtin
|
75
72
|
*/
|
76
|
-
declare const exp: <T extends
|
73
|
+
declare const exp: <T extends AnyFloatVecInstance | number>(value: T) => T;
|
77
74
|
type PowOverload = {
|
78
75
|
(base: number, exponent: number): number;
|
79
|
-
<T extends
|
76
|
+
<T extends AnyFloatVecInstance>(base: T, exponent: T): T;
|
80
77
|
};
|
81
78
|
declare const pow: PowOverload;
|
82
79
|
type MixOverload = {
|
83
80
|
(e1: number, e2: number, e3: number): number;
|
84
|
-
<T extends
|
85
|
-
<T extends
|
81
|
+
<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: number): T;
|
82
|
+
<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: T): T;
|
86
83
|
};
|
87
84
|
declare const mix: MixOverload;
|
88
|
-
declare const reflect: <T extends
|
89
|
-
declare const distance: <T extends
|
85
|
+
declare const reflect: <T extends AnyFloatVecInstance>(e1: T, e2: T) => T;
|
86
|
+
declare const distance: <T extends AnyFloatVecInstance | number>(a: T, b: T) => number;
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Checks whether `lhs == rhs` on all components.
|
90
|
+
* Equivalent to `all(eq(lhs, rhs))`.
|
91
|
+
* @example
|
92
|
+
* allEq(vec2f(0.0, 1.0), vec2f(0.0, 2.0)) // returns false
|
93
|
+
* allEq(vec3u(0, 1, 2), vec3u(0, 1, 2)) // returns true
|
94
|
+
*/
|
95
|
+
declare const allEq: <T extends AnyVecInstance>(lhs: T, rhs: T) => boolean;
|
96
|
+
/**
|
97
|
+
* Checks **component-wise** whether `lhs == rhs`.
|
98
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `all`, or use `allEq`.
|
99
|
+
* @example
|
100
|
+
* eq(vec2f(0.0, 1.0), vec2f(0.0, 2.0)) // returns vec2b(true, false)
|
101
|
+
* eq(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(false, true, false)
|
102
|
+
* all(eq(vec4i(4, 3, 2, 1), vec4i(4, 3, 2, 1))) // returns true
|
103
|
+
* allEq(vec4i(4, 3, 2, 1), vec4i(4, 3, 2, 1)) // returns true
|
104
|
+
*/
|
105
|
+
declare const eq: <T extends AnyVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
106
|
+
/**
|
107
|
+
* Checks **component-wise** whether `lhs != rhs`.
|
108
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `any`.
|
109
|
+
* @example
|
110
|
+
* ne(vec2f(0.0, 1.0), vec2f(0.0, 2.0)) // returns vec2b(false, true)
|
111
|
+
* ne(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, false, true)
|
112
|
+
* any(ne(vec4i(4, 3, 2, 1), vec4i(4, 2, 2, 1))) // returns true
|
113
|
+
*/
|
114
|
+
declare const ne: <T extends AnyVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
115
|
+
/**
|
116
|
+
* Checks **component-wise** whether `lhs < rhs`.
|
117
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
118
|
+
* @example
|
119
|
+
* lt(vec2f(0.0, 0.0), vec2f(0.0, 1.0)) // returns vec2b(false, true)
|
120
|
+
* lt(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, false, false)
|
121
|
+
* all(lt(vec4i(1, 2, 3, 4), vec4i(2, 3, 4, 5))) // returns true
|
122
|
+
*/
|
123
|
+
declare const lt: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
124
|
+
/**
|
125
|
+
* Checks **component-wise** whether `lhs <= rhs`.
|
126
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
127
|
+
* @example
|
128
|
+
* le(vec2f(0.0, 0.0), vec2f(0.0, 1.0)) // returns vec2b(true, true)
|
129
|
+
* le(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(true, true, false)
|
130
|
+
* all(le(vec4i(1, 2, 3, 4), vec4i(2, 3, 3, 5))) // returns true
|
131
|
+
*/
|
132
|
+
declare const le: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
133
|
+
/**
|
134
|
+
* Checks **component-wise** whether `lhs > rhs`.
|
135
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
136
|
+
* @example
|
137
|
+
* gt(vec2f(0.0, 0.0), vec2f(0.0, 1.0)) // returns vec2b(false, false)
|
138
|
+
* gt(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(false, false, true)
|
139
|
+
* all(gt(vec4i(2, 3, 4, 5), vec4i(1, 2, 3, 4))) // returns true
|
140
|
+
*/
|
141
|
+
declare const gt: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
142
|
+
/**
|
143
|
+
* Checks **component-wise** whether `lhs >= rhs`.
|
144
|
+
* This function does **not** return `bool`, for that use-case, wrap the result in `all`.
|
145
|
+
* @example
|
146
|
+
* ge(vec2f(0.0, 0.0), vec2f(0.0, 1.0)) // returns vec2b(true, false)
|
147
|
+
* ge(vec3u(0, 1, 2), vec3u(2, 1, 0)) // returns vec3b(false, true, true)
|
148
|
+
* all(ge(vec4i(2, 2, 4, 5), vec4i(1, 2, 3, 4))) // returns true
|
149
|
+
*/
|
150
|
+
declare const ge: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) => T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b;
|
151
|
+
/**
|
152
|
+
* Returns **component-wise** `!value`.
|
153
|
+
* @example
|
154
|
+
* not(vec2b(false, true)) // returns vec2b(true, false)
|
155
|
+
* not(vec3b(true, true, false)) // returns vec3b(false, false, true)
|
156
|
+
*/
|
157
|
+
declare const not: <T extends AnyBooleanVecInstance>(value: T) => T;
|
158
|
+
/**
|
159
|
+
* Returns **component-wise** logical `or` result.
|
160
|
+
* @example
|
161
|
+
* or(vec2b(false, true), vec2b(false, false)) // returns vec2b(false, true)
|
162
|
+
* or(vec3b(true, true, false), vec3b(false, true, false)) // returns vec3b(true, true, false)
|
163
|
+
*/
|
164
|
+
declare const or: <T extends AnyBooleanVecInstance>(lhs: T, rhs: T) => T;
|
165
|
+
/**
|
166
|
+
* Returns **component-wise** logical `and` result.
|
167
|
+
* @example
|
168
|
+
* and(vec2b(false, true), vec2b(true, true)) // returns vec2b(false, true)
|
169
|
+
* and(vec3b(true, true, false), vec3b(false, true, false)) // returns vec3b(false, true, false)
|
170
|
+
*/
|
171
|
+
declare const and: <T extends AnyBooleanVecInstance>(lhs: T, rhs: T) => T;
|
90
172
|
/**
|
91
|
-
*
|
92
|
-
*
|
173
|
+
* Returns `true` if each component of `value` is true.
|
174
|
+
* @example
|
175
|
+
* all(vec2b(false, true)) // returns false
|
176
|
+
* all(vec3b(true, true, true)) // returns true
|
177
|
+
*/
|
178
|
+
declare const all: (value: AnyBooleanVecInstance) => boolean;
|
179
|
+
/**
|
180
|
+
* Returns `true` if any component of `value` is true.
|
181
|
+
* @example
|
182
|
+
* any(vec2b(false, true)) // returns true
|
183
|
+
* any(vec3b(false, false, false)) // returns false
|
184
|
+
*/
|
185
|
+
declare const any: (value: AnyBooleanVecInstance) => boolean;
|
186
|
+
/**
|
187
|
+
* Checks whether the given elements differ by at most the `precision` value.
|
188
|
+
* Checks all elements of `lhs` and `rhs` if arguments are vectors.
|
93
189
|
* @example
|
94
190
|
* isCloseTo(0, 0.1) // returns false
|
95
191
|
* isCloseTo(vec3f(0, 0, 0), vec3f(0.002, -0.009, 0)) // returns true
|
96
192
|
*
|
97
193
|
* @param {number} precision argument that specifies the maximum allowed difference, 0.01 by default.
|
98
194
|
*/
|
99
|
-
declare const isCloseTo: <T extends
|
195
|
+
declare const isCloseTo: <T extends AnyFloatVecInstance | number>(lhs: T, rhs: T, precision?: number) => boolean;
|
196
|
+
type SelectOverload = {
|
197
|
+
<T extends ScalarData | AnyVecInstance>(f: T, t: T, cond: boolean): T;
|
198
|
+
<T extends AnyVecInstance>(f: T, t: T, cond: T extends AnyVec2Instance ? v2b : T extends AnyVec3Instance ? v3b : v4b): T;
|
199
|
+
};
|
200
|
+
/**
|
201
|
+
* Returns `t` if `cond` is `true`, and `f` otherwise.
|
202
|
+
* Component-wise if `cond` is a vector.
|
203
|
+
* @example
|
204
|
+
* select(vec2i(1, 2), vec2i(3, 4), true) // returns vec2i(3, 4)
|
205
|
+
* select(vec2i(1, 2), vec2i(3, 4), vec2b(false, true)) // returns vec2i(1, 4)
|
206
|
+
*/
|
207
|
+
declare const select: SelectOverload;
|
100
208
|
|
101
209
|
type AnyAtomic = atomicI32 | atomicU32;
|
102
210
|
declare const workgroupBarrier: () => void;
|
@@ -114,4 +222,4 @@ declare const atomicXor: <T extends AnyAtomic>(a: T, value: number) => number;
|
|
114
222
|
|
115
223
|
declare const arrayLength: (a: unknown[]) => number;
|
116
224
|
|
117
|
-
export { abs, acos, add, arrayLength, asin, atan2, atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, ceil, clamp, cos, cross, discard, distance, dot, exp, floor, fract, isCloseTo, length, max, min, mix, mul, normalize, pow, reflect, sin, storageBarrier, sub, textureBarrier, workgroupBarrier };
|
225
|
+
export { abs, acos, add, all, allEq, and, any, arrayLength, asin, atan2, atomicAdd, atomicAnd, atomicLoad, atomicMax, atomicMin, atomicOr, atomicStore, atomicSub, atomicXor, ceil, clamp, cos, cross, discard, distance, dot, eq, exp, floor, fract, ge, gt, isCloseTo, le, length, lt, max, min, mix, mul, ne, normalize, not, or, pow, reflect, select, sin, storageBarrier, sub, textureBarrier, workgroupBarrier };
|
package/std/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{g as W}from"../chunk-RMXVIINO.js";import{A as h,B as F,C as N,D as J,H as C,I as ne,K as E,S as f,o as n,p as y,q as l,r as m,s as T,t as v,u as x,v as i,w,x as o,y as u,z as d}from"../chunk-UHU5Z2IS.js";var ye=n(()=>{throw new Error("discard() can only be used on the GPU.")},()=>({value:"discard;",dataType:W}));var K=e=>Math.sqrt(e.x**2+e.y**2),R=e=>Math.sqrt(e.x**2+e.y**2+e.z**2),U=e=>Math.sqrt(e.x**2+e.y**2+e.z**2+e.w**2),P=(e,t)=>e.x*t.x+e.y*t.y,_=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,G=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,r=(e,t,a)=>Math.min(Math.max(t,e),a),g=e=>t=>y(e(t.x),e(t.y)),p=e=>t=>l(e(t.x),e(t.y)),z=e=>t=>m(e(t.x),e(t.y)),M=e=>t=>T(e(t.x),e(t.y)),B=e=>t=>v(e(t.x),e(t.y),e(t.z)),b=e=>t=>x(e(t.x),e(t.y),e(t.z)),$=e=>t=>i(e(t.x),e(t.y),e(t.z)),A=e=>t=>w(e(t.x),e(t.y),e(t.z)),V=e=>t=>o(e(t.x),e(t.y),e(t.z),e(t.w)),O=e=>t=>u(e(t.x),e(t.y),e(t.z),e(t.w)),k=e=>t=>d(e(t.x),e(t.y),e(t.z),e(t.w)),I=e=>t=>h(e(t.x),e(t.y),e(t.z),e(t.w)),L=e=>(t,a)=>y(e(t.x,a.x),e(t.y,a.y)),j=e=>(t,a)=>l(e(t.x,a.x),e(t.y,a.y)),q=e=>(t,a)=>m(e(t.x,a.x),e(t.y,a.y)),X=e=>(t,a)=>T(e(t.x,a.x),e(t.y,a.y)),Z=e=>(t,a)=>v(e(t.x,a.x),e(t.y,a.y),e(t.z,a.z)),H=e=>(t,a)=>x(e(t.x,a.x),e(t.y,a.y),e(t.z,a.z)),Q=e=>(t,a)=>i(e(t.x,a.x),e(t.y,a.y),e(t.z,a.z)),Y=e=>(t,a)=>w(e(t.x,a.x),e(t.y,a.y),e(t.z,a.z)),ee=e=>(t,a)=>o(e(t.x,a.x),e(t.y,a.y),e(t.z,a.z),e(t.w,a.w)),te=e=>(t,a)=>u(e(t.x,a.x),e(t.y,a.y),e(t.z,a.z),e(t.w,a.w)),ae=e=>(t,a)=>d(e(t.x,a.x),e(t.y,a.y),e(t.z,a.z),e(t.w,a.w)),se=e=>(t,a)=>h(e(t.x,a.x),e(t.y,a.y),e(t.z,a.z),e(t.w,a.w)),c={abs:{vec2f:g(Math.abs),vec2h:p(Math.abs),vec2i:z(Math.abs),vec2u:M(Math.abs),vec3f:B(Math.abs),vec3h:b(Math.abs),vec3i:$(Math.abs),vec3u:A(Math.abs),vec4f:V(Math.abs),vec4h:O(Math.abs),vec4i:k(Math.abs),vec4u:I(Math.abs)},atan2:{vec2f:L(Math.atan2),vec2h:j(Math.atan2),vec2i:q(Math.atan2),vec2u:X(Math.atan2),vec3f:Z(Math.atan2),vec3h:H(Math.atan2),vec3i:Q(Math.atan2),vec3u:Y(Math.atan2),vec4f:ee(Math.atan2),vec4h:te(Math.atan2),vec4i:ae(Math.atan2),vec4u:se(Math.atan2)},acos:{vec2f:g(Math.acos),vec2h:p(Math.acos),vec2i:z(Math.acos),vec2u:M(Math.acos),vec3f:B(Math.acos),vec3h:b(Math.acos),vec3i:$(Math.acos),vec3u:A(Math.acos),vec4f:V(Math.acos),vec4h:O(Math.acos),vec4i:k(Math.acos),vec4u:I(Math.acos)},asin:{vec2f:g(Math.asin),vec2h:p(Math.asin),vec2i:z(Math.asin),vec2u:M(Math.asin),vec3f:B(Math.asin),vec3h:b(Math.asin),vec3i:$(Math.asin),vec3u:A(Math.asin),vec4f:V(Math.asin),vec4h:O(Math.asin),vec4i:k(Math.asin),vec4u:I(Math.asin)},ceil:{vec2f:g(Math.ceil),vec2h:p(Math.ceil),vec2i:z(Math.ceil),vec2u:M(Math.ceil),vec3f:B(Math.ceil),vec3h:b(Math.ceil),vec3i:$(Math.ceil),vec3u:A(Math.ceil),vec4f:V(Math.ceil),vec4h:O(Math.ceil),vec4i:k(Math.ceil),vec4u:I(Math.ceil)},clamp:{vec2f:(e,t,a)=>y(r(e.x,t.x,a.x),r(e.y,t.y,a.y)),vec2h:(e,t,a)=>l(r(e.x,t.x,a.x),r(e.y,t.y,a.y)),vec2i:(e,t,a)=>m(r(e.x,t.x,a.x),r(e.y,t.y,a.y)),vec2u:(e,t,a)=>T(r(e.x,t.x,a.x),r(e.y,t.y,a.y)),vec3f:(e,t,a)=>v(r(e.x,t.x,a.x),r(e.y,t.y,a.y),r(e.z,t.z,a.z)),vec3h:(e,t,a)=>x(r(e.x,t.x,a.x),r(e.y,t.y,a.y),r(e.z,t.z,a.z)),vec3i:(e,t,a)=>i(r(e.x,t.x,a.x),r(e.y,t.y,a.y),r(e.z,t.z,a.z)),vec3u:(e,t,a)=>w(r(e.x,t.x,a.x),r(e.y,t.y,a.y),r(e.z,t.z,a.z)),vec4f:(e,t,a)=>o(r(e.x,t.x,a.x),r(e.y,t.y,a.y),r(e.z,t.z,a.z),r(e.w,t.w,a.w)),vec4h:(e,t,a)=>u(r(e.x,t.x,a.x),r(e.y,t.y,a.y),r(e.z,t.z,a.z),r(e.w,t.w,a.w)),vec4i:(e,t,a)=>d(r(e.x,t.x,a.x),r(e.y,t.y,a.y),r(e.z,t.z,a.z),r(e.w,t.w,a.w)),vec4u:(e,t,a)=>h(r(e.x,t.x,a.x),r(e.y,t.y,a.y),r(e.z,t.z,a.z),r(e.w,t.w,a.w))},length:{vec2f:K,vec2h:K,vec2i:K,vec2u:K,vec3f:R,vec3h:R,vec3i:R,vec3u:R,vec4f:U,vec4h:U,vec4i:U,vec4u:U},add:{vec2f:(e,t)=>y(e.x+t.x,e.y+t.y),vec2h:(e,t)=>l(e.x+t.x,e.y+t.y),vec2i:(e,t)=>m(e.x+t.x,e.y+t.y),vec2u:(e,t)=>T(e.x+t.x,e.y+t.y),vec3f:(e,t)=>v(e.x+t.x,e.y+t.y,e.z+t.z),vec3h:(e,t)=>x(e.x+t.x,e.y+t.y,e.z+t.z),vec3i:(e,t)=>i(e.x+t.x,e.y+t.y,e.z+t.z),vec3u:(e,t)=>w(e.x+t.x,e.y+t.y,e.z+t.z),vec4f:(e,t)=>o(e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w),vec4h:(e,t)=>u(e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w),vec4i:(e,t)=>d(e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w),vec4u:(e,t)=>h(e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w)},sub:{vec2f:(e,t)=>y(e.x-t.x,e.y-t.y),vec2h:(e,t)=>l(e.x-t.x,e.y-t.y),vec2i:(e,t)=>m(e.x-t.x,e.y-t.y),vec2u:(e,t)=>T(e.x-t.x,e.y-t.y),vec3f:(e,t)=>v(e.x-t.x,e.y-t.y,e.z-t.z),vec3h:(e,t)=>x(e.x-t.x,e.y-t.y,e.z-t.z),vec3i:(e,t)=>i(e.x-t.x,e.y-t.y,e.z-t.z),vec3u:(e,t)=>w(e.x-t.x,e.y-t.y,e.z-t.z),vec4f:(e,t)=>o(e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w),vec4h:(e,t)=>u(e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w),vec4i:(e,t)=>d(e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w),vec4u:(e,t)=>h(e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w)},mulSxV:{vec2f:(e,t)=>y(e*t.x,e*t.y),vec2h:(e,t)=>l(e*t.x,e*t.y),vec2i:(e,t)=>m(e*t.x,e*t.y),vec2u:(e,t)=>T(e*t.x,e*t.y),vec3f:(e,t)=>v(e*t.x,e*t.y,e*t.z),vec3h:(e,t)=>x(e*t.x,e*t.y,e*t.z),vec3i:(e,t)=>i(e*t.x,e*t.y,e*t.z),vec3u:(e,t)=>w(e*t.x,e*t.y,e*t.z),vec4f:(e,t)=>o(e*t.x,e*t.y,e*t.z,e*t.w),vec4h:(e,t)=>u(e*t.x,e*t.y,e*t.z,e*t.w),vec4i:(e,t)=>d(e*t.x,e*t.y,e*t.z,e*t.w),vec4u:(e,t)=>h(e*t.x,e*t.y,e*t.z,e*t.w),mat2x2f:(e,t)=>{let a=t.columns;return F(e*a[0].x,e*a[0].y,e*a[1].x,e*a[1].y)},mat3x3f:(e,t)=>{let a=t.columns;return N(e*a[0].x,e*a[0].y,e*a[0].z,e*a[1].x,e*a[1].y,e*a[1].z,e*a[2].x,e*a[2].y,e*a[2].z)},mat4x4f:(e,t)=>{let a=t.columns;return J(e*a[0].x,e*a[0].y,e*a[0].z,e*a[0].w,e*a[1].x,e*a[1].y,e*a[1].z,e*a[1].w,e*a[2].x,e*a[2].y,e*a[2].z,e*a[2].w,e*a[3].x,e*a[3].y,e*a[3].z,e*a[3].w)}},mulVxV:{vec2f:(e,t)=>y(e.x*t.x,e.y*t.y),vec2h:(e,t)=>l(e.x*t.x,e.y*t.y),vec2i:(e,t)=>m(e.x*t.x,e.y*t.y),vec2u:(e,t)=>T(e.x*t.x,e.y*t.y),vec3f:(e,t)=>v(e.x*t.x,e.y*t.y,e.z*t.z),vec3h:(e,t)=>x(e.x*t.x,e.y*t.y,e.z*t.z),vec3i:(e,t)=>i(e.x*t.x,e.y*t.y,e.z*t.z),vec3u:(e,t)=>w(e.x*t.x,e.y*t.y,e.z*t.z),vec4f:(e,t)=>o(e.x*t.x,e.y*t.y,e.z*t.z,e.w*t.w),vec4h:(e,t)=>u(e.x*t.x,e.y*t.y,e.z*t.z,e.w*t.w),vec4i:(e,t)=>d(e.x*t.x,e.y*t.y,e.z*t.z,e.w*t.w),vec4u:(e,t)=>h(e.x*t.x,e.y*t.y,e.z*t.z,e.w*t.w),mat2x2f:(e,t)=>{let a=e.columns,s=t.columns;return F(a[0].x*s[0].x+a[1].x*s[0].y,a[0].y*s[0].x+a[1].y*s[0].y,a[0].x*s[1].x+a[1].x*s[1].y,a[0].y*s[1].x+a[1].y*s[1].y)},mat3x3f:(e,t)=>{let a=e.columns,s=t.columns;return N(a[0].x*s[0].x+a[1].x*s[0].y+a[2].x*s[0].z,a[0].y*s[0].x+a[1].y*s[0].y+a[2].y*s[0].z,a[0].z*s[0].x+a[1].z*s[0].y+a[2].z*s[0].z,a[0].x*s[1].x+a[1].x*s[1].y+a[2].x*s[1].z,a[0].y*s[1].x+a[1].y*s[1].y+a[2].y*s[1].z,a[0].z*s[1].x+a[1].z*s[1].y+a[2].z*s[1].z,a[0].x*s[2].x+a[1].x*s[2].y+a[2].x*s[2].z,a[0].y*s[2].x+a[1].y*s[2].y+a[2].y*s[2].z,a[0].z*s[2].x+a[1].z*s[2].y+a[2].z*s[2].z)},mat4x4f:(e,t)=>{let a=e.columns,s=t.columns;return J(a[0].x*s[0].x+a[1].x*s[0].y+a[2].x*s[0].z+a[3].x*s[0].w,a[0].y*s[0].x+a[1].y*s[0].y+a[2].y*s[0].z+a[3].y*s[0].w,a[0].z*s[0].x+a[1].z*s[0].y+a[2].z*s[0].z+a[3].z*s[0].w,a[0].w*s[0].x+a[1].w*s[0].y+a[2].w*s[0].z+a[3].w*s[0].w,a[0].x*s[1].x+a[1].x*s[1].y+a[2].x*s[1].z+a[3].x*s[1].w,a[0].y*s[1].x+a[1].y*s[1].y+a[2].y*s[1].z+a[3].y*s[1].w,a[0].z*s[1].x+a[1].z*s[1].y+a[2].z*s[1].z+a[3].z*s[1].w,a[0].w*s[1].x+a[1].w*s[1].y+a[2].w*s[1].z+a[3].w*s[1].w,a[0].x*s[2].x+a[1].x*s[2].y+a[2].x*s[2].z+a[3].x*s[2].w,a[0].y*s[2].x+a[1].y*s[2].y+a[2].y*s[2].z+a[3].y*s[2].w,a[0].z*s[2].x+a[1].z*s[2].y+a[2].z*s[2].z+a[3].z*s[2].w,a[0].w*s[2].x+a[1].w*s[2].y+a[2].w*s[2].z+a[3].w*s[2].w,a[0].x*s[3].x+a[1].x*s[3].y+a[2].x*s[3].z+a[3].x*s[3].w,a[0].y*s[3].x+a[1].y*s[3].y+a[2].y*s[3].z+a[3].y*s[3].w,a[0].z*s[3].x+a[1].z*s[3].y+a[2].z*s[3].z+a[3].z*s[3].w,a[0].w*s[3].x+a[1].w*s[3].y+a[2].w*s[3].z+a[3].w*s[3].w)}},mulMxV:{mat2x2f:(e,t)=>{let a=e.columns;return y(a[0].x*t.x+a[1].x*t.y,a[0].y*t.x+a[1].y*t.y)},mat3x3f:(e,t)=>{let a=e.columns;return v(a[0].x*t.x+a[1].x*t.y+a[2].x*t.z,a[0].y*t.x+a[1].y*t.y+a[2].y*t.z,a[0].z*t.x+a[1].z*t.y+a[2].z*t.z)},mat4x4f:(e,t)=>{let a=e.columns;return o(a[0].x*t.x+a[1].x*t.y+a[2].x*t.z+a[3].x*t.w,a[0].y*t.x+a[1].y*t.y+a[2].y*t.z+a[3].y*t.w,a[0].z*t.x+a[1].z*t.y+a[2].z*t.z+a[3].z*t.w,a[0].w*t.x+a[1].w*t.y+a[2].w*t.z+a[3].w*t.w)}},mulVxM:{mat2x2f:(e,t)=>{let a=t.columns;return y(e.x*a[0].x+e.y*a[0].y,e.x*a[1].x+e.y*a[1].y)},mat3x3f:(e,t)=>{let a=t.columns;return v(e.x*a[0].x+e.y*a[0].y+e.z*a[0].z,e.x*a[1].x+e.y*a[1].y+e.z*a[1].z,e.x*a[2].x+e.y*a[2].y+e.z*a[2].z)},mat4x4f:(e,t)=>{let a=t.columns;return o(e.x*a[0].x+e.y*a[0].y+e.z*a[0].z+e.w*a[0].w,e.x*a[1].x+e.y*a[1].y+e.z*a[1].z+e.w*a[1].w,e.x*a[2].x+e.y*a[2].y+e.z*a[2].z+e.w*a[2].w,e.x*a[3].x+e.y*a[3].y+e.z*a[3].z+e.w*a[3].w)}},dot:{vec2f:P,vec2h:P,vec2i:P,vec2u:P,vec3f:_,vec3h:_,vec3i:_,vec3u:_,vec4f:G,vec4h:G,vec4i:G,vec4u:G},normalize:{vec2f:e=>{let t=K(e);return y(e.x/t,e.y/t)},vec2h:e=>{let t=K(e);return l(e.x/t,e.y/t)},vec2i:e=>{let t=K(e);return m(e.x/t,e.y/t)},vec2u:e=>{let t=K(e);return T(e.x/t,e.y/t)},vec3f:e=>{let t=R(e);return v(e.x/t,e.y/t,e.z/t)},vec3h:e=>{let t=R(e);return x(e.x/t,e.y/t,e.z/t)},vec3i:e=>{let t=R(e);return i(e.x/t,e.y/t,e.z/t)},vec3u:e=>{let t=R(e);return w(e.x/t,e.y/t,e.z/t)},vec4f:e=>{let t=U(e);return o(e.x/t,e.y/t,e.z/t,e.w/t)},vec4h:e=>{let t=U(e);return u(e.x/t,e.y/t,e.z/t,e.w/t)},vec4i:e=>{let t=U(e);return d(e.x/t,e.y/t,e.z/t,e.w/t)},vec4u:e=>{let t=U(e);return h(e.x/t,e.y/t,e.z/t,e.w/t)}},cross:{vec3f:(e,t)=>v(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),vec3h:(e,t)=>x(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),vec3i:(e,t)=>i(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),vec3u:(e,t)=>w(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x)},floor:{vec2f:g(Math.floor),vec2h:p(Math.floor),vec2i:z(Math.floor),vec2u:M(Math.floor),vec3f:B(Math.floor),vec3h:b(Math.floor),vec3i:$(Math.floor),vec3u:A(Math.floor),vec4f:V(Math.floor),vec4h:O(Math.floor),vec4i:k(Math.floor),vec4u:I(Math.floor)},max:{vec2f:L(Math.max),vec2h:j(Math.max),vec2i:q(Math.max),vec2u:X(Math.max),vec3f:Z(Math.max),vec3h:H(Math.max),vec3i:Q(Math.max),vec3u:Y(Math.max),vec4f:ee(Math.max),vec4h:te(Math.max),vec4i:ae(Math.max),vec4u:se(Math.max)},min:{vec2f:L(Math.min),vec2h:j(Math.min),vec2i:q(Math.min),vec2u:X(Math.min),vec3f:Z(Math.min),vec3h:H(Math.min),vec3i:Q(Math.min),vec3u:Y(Math.min),vec4f:ee(Math.min),vec4h:te(Math.min),vec4i:ae(Math.min),vec4u:se(Math.min)},pow:{vec2f:(e,t)=>y(e.x**t.x,e.y**t.y),vec2h:(e,t)=>l(e.x**t.x,e.y**t.y),vec3f:(e,t)=>v(e.x**t.x,e.y**t.y,e.z**t.z),vec3h:(e,t)=>x(e.x**t.x,e.y**t.y,e.z**t.z),vec4f:(e,t)=>o(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w),vec4h:(e,t)=>u(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w)},mix:{vec2f:(e,t,a)=>typeof a=="number"?y(e.x*(1-a)+t.x*a,e.y*(1-a)+t.y*a):y(e.x*(1-a.x)+t.x*a.x,e.y*(1-a.y)+t.y*a.y),vec2h:(e,t,a)=>typeof a=="number"?l(e.x*(1-a)+t.x*a,e.y*(1-a)+t.y*a):l(e.x*(1-a.x)+t.x*a.x,e.y*(1-a.y)+t.y*a.y),vec3f:(e,t,a)=>typeof a=="number"?v(e.x*(1-a)+t.x*a,e.y*(1-a)+t.y*a,e.z*(1-a)+t.z*a):v(e.x*(1-a.x)+t.x*a.x,e.y*(1-a.y)+t.y*a.y,e.z*(1-a.z)+t.z*a.z),vec3h:(e,t,a)=>typeof a=="number"?x(e.x*(1-a)+t.x*a,e.y*(1-a)+t.y*a,e.z*(1-a)+t.z*a):x(e.x*(1-a.x)+t.x*a.x,e.y*(1-a.y)+t.y*a.y,e.z*(1-a.z)+t.z*a.z),vec4f:(e,t,a)=>typeof a=="number"?o(e.x*(1-a)+t.x*a,e.y*(1-a)+t.y*a,e.z*(1-a)+t.z*a,e.w*(1-a)+t.w*a):o(e.x*(1-a.x)+t.x*a.x,e.y*(1-a.y)+t.y*a.y,e.z*(1-a.z)+t.z*a.z,e.w*(1-a.w)+t.w*a.w),vec4h:(e,t,a)=>typeof a=="number"?u(e.x*(1-a)+t.x*a,e.y*(1-a)+t.y*a,e.z*(1-a)+t.z*a,e.w*(1-a)+t.w*a):u(e.x*(1-a.x)+t.x*a.x,e.y*(1-a.y)+t.y*a.y,e.z*(1-a.z)+t.z*a.z,e.w*(1-a.w)+t.w*a.w)},sin:{vec2f:g(Math.sin),vec2h:p(Math.sin),vec2i:z(Math.sin),vec2u:M(Math.sin),vec3f:B(Math.sin),vec3h:b(Math.sin),vec3i:$(Math.sin),vec3u:A(Math.sin),vec4f:V(Math.sin),vec4h:O(Math.sin),vec4i:k(Math.sin),vec4u:I(Math.sin)},cos:{vec2f:g(Math.cos),vec2h:p(Math.cos),vec2i:z(Math.cos),vec2u:M(Math.cos),vec3f:B(Math.cos),vec3h:b(Math.cos),vec3i:$(Math.cos),vec3u:A(Math.cos),vec4f:V(Math.cos),vec4h:O(Math.cos),vec4i:k(Math.cos),vec4u:I(Math.cos)},exp:{vec2f:g(Math.exp),vec2h:p(Math.exp),vec2i:z(Math.exp),vec2u:M(Math.exp),vec3f:B(Math.exp),vec3h:b(Math.exp),vec3i:$(Math.exp),vec3u:A(Math.exp),vec4f:V(Math.exp),vec4h:O(Math.exp),vec4i:k(Math.exp),vec4u:I(Math.exp)},fract:{vec2f:g(e=>e-Math.floor(e)),vec2h:p(e=>e-Math.floor(e)),vec2i:z(e=>e-Math.floor(e)),vec2u:M(e=>e-Math.floor(e)),vec3f:B(e=>e-Math.floor(e)),vec3h:b(e=>e-Math.floor(e)),vec3i:$(e=>e-Math.floor(e)),vec3u:A(e=>e-Math.floor(e)),vec4f:V(e=>e-Math.floor(e)),vec4h:O(e=>e-Math.floor(e)),vec4i:k(e=>e-Math.floor(e)),vec4u:I(e=>e-Math.floor(e))},isCloseToZero:{vec2f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t,vec2h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t,vec3f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t,vec3h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t,vec4f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t&&Math.abs(e.w)<=t,vec4h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t&&Math.abs(e.w)<=t}};function S(e){let t=e.dataType.type;return t==="abstractInt"||t==="abstractFloat"||t==="f32"||t==="f16"||t==="i32"||t==="u32"}var oe=n((e,t)=>c.add[e.kind](e,t),(e,t)=>({value:`(${e.value} + ${t.value})`,dataType:e.dataType})),D=n((e,t)=>c.sub[e.kind](e,t),(e,t)=>({value:`(${e.value} - ${t.value})`,dataType:e.dataType})),re=n((e,t)=>{if(typeof e=="number")return c.mulSxV[t.kind](e,t);if(typeof e=="object"&&typeof t=="object"&&"kind"in e&&"kind"in t){let a=!e.kind.startsWith("mat"),s=!t.kind.startsWith("mat");if(!a&&s)return c.mulMxV[e.kind](e,t);if(a&&!s)return c.mulVxM[t.kind](e,t)}return c.mulVxV[t.kind](e,t)},(e,t)=>{let a=S(e)?t.dataType:e.dataType.type.startsWith("mat")?t.dataType.type.startsWith("mat")?e.dataType:t.dataType:e.dataType;return{value:`(${e.value} * ${t.value})`,dataType:a}}),xe=n(e=>typeof e=="number"?Math.abs(e):c.abs[e.kind](e),e=>({value:`abs(${e.value})`,dataType:e.dataType})),le=n((e,t)=>typeof e=="number"&&typeof t=="number"?Math.atan2(e,t):c.atan2[e.kind](e,t),(e,t)=>({value:`atan2(${e.value}, ${t.value})`,dataType:e.dataType})),ue=n(e=>typeof e=="number"?Math.acos(e):c.acos[e.kind](e),e=>({value:`acos(${e.value})`,dataType:e.dataType})),ie=n(e=>typeof e=="number"?Math.asin(e):c.asin[e.kind](e),e=>({value:`asin(${e.value})`,dataType:e.dataType})),we=n(e=>typeof e=="number"?Math.ceil(e):c.ceil[e.kind](e),e=>({value:`ceil(${e.value})`,dataType:e.dataType})),fe=n((e,t,a)=>typeof e=="number"?Math.min(Math.max(t,e),a):c.clamp[e.kind](e,t,a),(e,t,a)=>({value:`clamp(${e.value}, ${t.value}, ${a.value})`,dataType:e.dataType})),me=n(e=>typeof e=="number"?Math.cos(e):c.cos[e.kind](e),e=>({value:`cos(${e.value})`,dataType:e.dataType})),Te=n((e,t)=>c.cross[e.kind](e,t),(e,t)=>({value:`cross(${e.value}, ${t.value})`,dataType:e.dataType})),ce=n((e,t)=>c.dot[e.kind](e,t),(e,t)=>({value:`dot(${e.value}, ${t.value})`,dataType:E})),de=n(e=>c.normalize[e.kind](e),e=>({value:`normalize(${e.value})`,dataType:e.dataType})),he=n(e=>typeof e=="number"?Math.floor(e):c.floor[e.kind](e),e=>({value:`floor(${e.value})`,dataType:e.dataType})),ge=n(e=>typeof e=="number"?e-Math.floor(e):c.fract[e.kind](e),e=>({value:`fract(${e.value})`,dataType:e.dataType})),ve=n(e=>typeof e=="number"?Math.abs(e):c.length[e.kind](e),e=>({value:`length(${e.value})`,dataType:E})),pe=n((e,t)=>typeof e=="number"?Math.max(e,t):c.max[e.kind](e,t),(e,t)=>({value:`max(${e.value}, ${t.value})`,dataType:e.dataType})),ze=n((e,t)=>typeof e=="number"?Math.min(e,t):c.min[e.kind](e,t),(e,t)=>({value:`min(${e.value}, ${t.value})`,dataType:e.dataType})),Me=n(e=>typeof e=="number"?Math.sin(e):c.sin[e.kind](e),e=>({value:`sin(${e.value})`,dataType:e.dataType})),Be=n(e=>typeof e=="number"?Math.exp(e):c.exp[e.kind](e),e=>({value:`exp(${e.value})`,dataType:e.dataType})),be=n((e,t)=>{if(typeof e=="number"&&typeof t=="number")return e**t;if(typeof e=="object"&&typeof t=="object"&&"kind"in e&&"kind"in t)return c.pow[e.kind](e,t);throw new Error("Invalid arguments to pow()")},(e,t)=>({value:`pow(${e.value}, ${t.value})`,dataType:e.dataType})),$e=n((e,t,a)=>{if(typeof e=="number"){if(typeof a!="number"||typeof t!="number")throw new Error("When e1 and e2 are numbers, the blend factor must be a number.");return e*(1-a)+t*a}if(typeof e=="number"||typeof t=="number")throw new Error("e1 and e2 need to both be vectors of the same kind.");return c.mix[e.kind](e,t,a)},(e,t,a)=>({value:`mix(${e.value}, ${t.value}, ${a.value})`,dataType:e.dataType})),Ae=n((e,t)=>D(e,re(2*ce(t,e),t)),(e,t)=>({value:`reflect(${e.value}, ${t.value})`,dataType:e.dataType})),Ve=n((e,t)=>typeof e=="number"&&typeof t=="number"?Math.abs(e-t):ve(D(e,t)),(e,t)=>({value:`distance(${e.value}, ${t.value})`,dataType:E})),Oe=n((e,t,a=.01)=>typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<a:typeof e!="number"&&typeof t!="number"?c.isCloseToZero[e.kind](D(e,t),a):!1,(e,t,a={value:.01,dataType:E})=>S(e)&&S(t)?{value:`abs(f32(${e.value})-f32(${t.value})) <= ${a.value}`,dataType:C}:!S(e)&&!S(t)?{value:`all(abs(${e.value}-${t.value}) <= (${e.value} - ${e.value})+${a.value})`,dataType:C}:{value:"false",dataType:C});var ke=n(()=>console.warn("workgroupBarrier is a no-op outside of GPU mode."),()=>({value:"workgroupBarrier()",dataType:W})),Ie=n(()=>console.warn("storageBarrier is a no-op outside of GPU mode."),()=>({value:"storageBarrier()",dataType:W})),Ke=n(()=>console.warn("textureBarrier is a no-op outside of GPU mode."),()=>({value:"textureBarrier()",dataType:W})),Re=n(e=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},e=>{if(f(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicLoad(&${e.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),Ue=n((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(!f(e.dataType)||e.dataType.type!=="atomic")throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`);return{value:`atomicStore(&${e.value}, ${t.value})`,dataType:W}}),We=n((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(f(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicAdd(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),Ee=n((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(f(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicSub(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),Se=n((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(f(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicMax(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),Ce=n((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(f(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicMin(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),Pe=n((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(f(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicAnd(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),_e=n((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(f(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicOr(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),Ge=n((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(f(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicXor(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)});var De=n(e=>e.length,e=>({value:`arrayLength(&${e.value})`,dataType:ne}));export{xe as abs,ue as acos,oe as add,De as arrayLength,ie as asin,le as atan2,We as atomicAdd,Pe as atomicAnd,Re as atomicLoad,Se as atomicMax,Ce as atomicMin,_e as atomicOr,Ue as atomicStore,Ee as atomicSub,Ge as atomicXor,we as ceil,fe as clamp,me as cos,Te as cross,ye as discard,Ve as distance,ce as dot,Be as exp,he as floor,ge as fract,Oe as isCloseTo,ve as length,pe as max,ze as min,$e as mix,re as mul,de as normalize,be as pow,Ae as reflect,Me as sin,Ie as storageBarrier,D as sub,Ke as textureBarrier,ke as workgroupBarrier};
|
1
|
+
import{g as k}from"../chunk-5PJ3H5OR.js";import{A as x,B as g,C as p,D as z,E as w,F as G,G as q,H as J,L as O,M as ye,O as F,W as h,o as s,q as l,r as i,s as T,t as m,u as v,v as y,w as u,x as d,y as f,z as o}from"../chunk-AKBL6GDL.js";var de=s(()=>{throw new Error("discard() can only be used on the GPU.")},()=>({value:"discard;",dataType:k}));var R=e=>Math.sqrt(e.x**2+e.y**2),K=e=>Math.sqrt(e.x**2+e.y**2+e.z**2),N=e=>Math.sqrt(e.x**2+e.y**2+e.z**2+e.w**2),C=(e,t)=>e.x*t.x+e.y*t.y,P=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,_=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,c=(e,t,n)=>Math.min(Math.max(t,e),n),M=e=>t=>l(e(t.x),e(t.y)),b=e=>t=>i(e(t.x),e(t.y)),L=e=>t=>T(e(t.x),e(t.y)),j=e=>t=>m(e(t.x),e(t.y)),V=e=>t=>y(e(t.x),e(t.y),e(t.z)),A=e=>t=>u(e(t.x),e(t.y),e(t.z)),X=e=>t=>d(e(t.x),e(t.y),e(t.z)),Z=e=>t=>f(e(t.x),e(t.y),e(t.z)),I=e=>t=>x(e(t.x),e(t.y),e(t.z),e(t.w)),$=e=>t=>g(e(t.x),e(t.y),e(t.z),e(t.w)),H=e=>t=>p(e(t.x),e(t.y),e(t.z),e(t.w)),Q=e=>t=>z(e(t.x),e(t.y),e(t.z),e(t.w)),Y=e=>(t,n)=>l(e(t.x,n.x),e(t.y,n.y)),ee=e=>(t,n)=>i(e(t.x,n.x),e(t.y,n.y)),le=e=>(t,n)=>T(e(t.x,n.x),e(t.y,n.y)),ve=e=>(t,n)=>m(e(t.x,n.x),e(t.y,n.y)),te=e=>(t,n)=>y(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),ne=e=>(t,n)=>u(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),oe=e=>(t,n)=>d(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),xe=e=>(t,n)=>f(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),ae=e=>(t,n)=>x(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),se=e=>(t,n)=>g(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),we=e=>(t,n)=>p(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),ue=e=>(t,n)=>z(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),r={eq:{vec2f:(e,t)=>v(e.x===t.x,e.y===t.y),vec2h:(e,t)=>v(e.x===t.x,e.y===t.y),vec2i:(e,t)=>v(e.x===t.x,e.y===t.y),vec2u:(e,t)=>v(e.x===t.x,e.y===t.y),"vec2<bool>":(e,t)=>v(e.x===t.x,e.y===t.y),vec3f:(e,t)=>o(e.x===t.x,e.y===t.y,e.z===t.z),vec3h:(e,t)=>o(e.x===t.x,e.y===t.y,e.z===t.z),vec3i:(e,t)=>o(e.x===t.x,e.y===t.y,e.z===t.z),vec3u:(e,t)=>o(e.x===t.x,e.y===t.y,e.z===t.z),"vec3<bool>":(e,t)=>o(e.x===t.x,e.y===t.y,e.z===t.z),vec4f:(e,t)=>w(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4h:(e,t)=>w(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4i:(e,t)=>w(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4u:(e,t)=>w(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),"vec4<bool>":(e,t)=>w(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w)},lt:{vec2f:(e,t)=>v(e.x<t.x,e.y<t.y),vec2h:(e,t)=>v(e.x<t.x,e.y<t.y),vec2i:(e,t)=>v(e.x<t.x,e.y<t.y),vec2u:(e,t)=>v(e.x<t.x,e.y<t.y),vec3f:(e,t)=>o(e.x<t.x,e.y<t.y,e.z<t.z),vec3h:(e,t)=>o(e.x<t.x,e.y<t.y,e.z<t.z),vec3i:(e,t)=>o(e.x<t.x,e.y<t.y,e.z<t.z),vec3u:(e,t)=>o(e.x<t.x,e.y<t.y,e.z<t.z),vec4f:(e,t)=>w(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4h:(e,t)=>w(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4i:(e,t)=>w(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4u:(e,t)=>w(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w)},neg:{"vec2<bool>":e=>v(!e.x,!e.y),"vec3<bool>":e=>o(!e.x,!e.y,!e.z),"vec4<bool>":e=>w(!e.x,!e.y,!e.z,!e.w)},or:{"vec2<bool>":(e,t)=>v(e.x||t.x,e.y||t.y),"vec3<bool>":(e,t)=>o(e.x||t.x,e.y||t.y,e.z||t.z),"vec4<bool>":(e,t)=>w(e.x||t.x,e.y||t.y,e.z||t.z,e.w||t.w)},all:{"vec2<bool>":e=>e.x&&e.y,"vec3<bool>":e=>e.x&&e.y&&e.z,"vec4<bool>":e=>e.x&&e.y&&e.z&&e.w},abs:{vec2f:M(Math.abs),vec2h:b(Math.abs),vec2i:L(Math.abs),vec2u:j(Math.abs),vec3f:V(Math.abs),vec3h:A(Math.abs),vec3i:X(Math.abs),vec3u:Z(Math.abs),vec4f:I(Math.abs),vec4h:$(Math.abs),vec4i:H(Math.abs),vec4u:Q(Math.abs)},atan2:{vec2f:Y(Math.atan2),vec2h:ee(Math.atan2),vec3f:te(Math.atan2),vec3h:ne(Math.atan2),vec4f:ae(Math.atan2),vec4h:se(Math.atan2)},acos:{vec2f:M(Math.acos),vec2h:b(Math.acos),vec2i:L(Math.acos),vec2u:j(Math.acos),vec3f:V(Math.acos),vec3h:A(Math.acos),vec3i:X(Math.acos),vec3u:Z(Math.acos),vec4f:I(Math.acos),vec4h:$(Math.acos),vec4i:H(Math.acos),vec4u:Q(Math.acos)},asin:{vec2f:M(Math.asin),vec2h:b(Math.asin),vec2i:L(Math.asin),vec2u:j(Math.asin),vec3f:V(Math.asin),vec3h:A(Math.asin),vec3i:X(Math.asin),vec3u:Z(Math.asin),vec4f:I(Math.asin),vec4h:$(Math.asin),vec4i:H(Math.asin),vec4u:Q(Math.asin)},ceil:{vec2f:M(Math.ceil),vec2h:b(Math.ceil),vec3f:V(Math.ceil),vec3h:A(Math.ceil),vec4f:I(Math.ceil),vec4h:$(Math.ceil)},clamp:{vec2f:(e,t,n)=>l(c(e.x,t.x,n.x),c(e.y,t.y,n.y)),vec2h:(e,t,n)=>i(c(e.x,t.x,n.x),c(e.y,t.y,n.y)),vec2i:(e,t,n)=>T(c(e.x,t.x,n.x),c(e.y,t.y,n.y)),vec2u:(e,t,n)=>m(c(e.x,t.x,n.x),c(e.y,t.y,n.y)),vec3f:(e,t,n)=>y(c(e.x,t.x,n.x),c(e.y,t.y,n.y),c(e.z,t.z,n.z)),vec3h:(e,t,n)=>u(c(e.x,t.x,n.x),c(e.y,t.y,n.y),c(e.z,t.z,n.z)),vec3i:(e,t,n)=>d(c(e.x,t.x,n.x),c(e.y,t.y,n.y),c(e.z,t.z,n.z)),vec3u:(e,t,n)=>f(c(e.x,t.x,n.x),c(e.y,t.y,n.y),c(e.z,t.z,n.z)),vec4f:(e,t,n)=>x(c(e.x,t.x,n.x),c(e.y,t.y,n.y),c(e.z,t.z,n.z),c(e.w,t.w,n.w)),vec4h:(e,t,n)=>g(c(e.x,t.x,n.x),c(e.y,t.y,n.y),c(e.z,t.z,n.z),c(e.w,t.w,n.w)),vec4i:(e,t,n)=>p(c(e.x,t.x,n.x),c(e.y,t.y,n.y),c(e.z,t.z,n.z),c(e.w,t.w,n.w)),vec4u:(e,t,n)=>z(c(e.x,t.x,n.x),c(e.y,t.y,n.y),c(e.z,t.z,n.z),c(e.w,t.w,n.w))},length:{vec2f:R,vec2h:R,vec3f:K,vec3h:K,vec4f:N,vec4h:N},add:{vec2f:(e,t)=>l(e.x+t.x,e.y+t.y),vec2h:(e,t)=>i(e.x+t.x,e.y+t.y),vec2i:(e,t)=>T(e.x+t.x,e.y+t.y),vec2u:(e,t)=>m(e.x+t.x,e.y+t.y),vec3f:(e,t)=>y(e.x+t.x,e.y+t.y,e.z+t.z),vec3h:(e,t)=>u(e.x+t.x,e.y+t.y,e.z+t.z),vec3i:(e,t)=>d(e.x+t.x,e.y+t.y,e.z+t.z),vec3u:(e,t)=>f(e.x+t.x,e.y+t.y,e.z+t.z),vec4f:(e,t)=>x(e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w),vec4h:(e,t)=>g(e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w),vec4i:(e,t)=>p(e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w),vec4u:(e,t)=>z(e.x+t.x,e.y+t.y,e.z+t.z,e.w+t.w)},sub:{vec2f:(e,t)=>l(e.x-t.x,e.y-t.y),vec2h:(e,t)=>i(e.x-t.x,e.y-t.y),vec2i:(e,t)=>T(e.x-t.x,e.y-t.y),vec2u:(e,t)=>m(e.x-t.x,e.y-t.y),vec3f:(e,t)=>y(e.x-t.x,e.y-t.y,e.z-t.z),vec3h:(e,t)=>u(e.x-t.x,e.y-t.y,e.z-t.z),vec3i:(e,t)=>d(e.x-t.x,e.y-t.y,e.z-t.z),vec3u:(e,t)=>f(e.x-t.x,e.y-t.y,e.z-t.z),vec4f:(e,t)=>x(e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w),vec4h:(e,t)=>g(e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w),vec4i:(e,t)=>p(e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w),vec4u:(e,t)=>z(e.x-t.x,e.y-t.y,e.z-t.z,e.w-t.w)},mulSxV:{vec2f:(e,t)=>l(e*t.x,e*t.y),vec2h:(e,t)=>i(e*t.x,e*t.y),vec2i:(e,t)=>T(e*t.x,e*t.y),vec2u:(e,t)=>m(e*t.x,e*t.y),vec3f:(e,t)=>y(e*t.x,e*t.y,e*t.z),vec3h:(e,t)=>u(e*t.x,e*t.y,e*t.z),vec3i:(e,t)=>d(e*t.x,e*t.y,e*t.z),vec3u:(e,t)=>f(e*t.x,e*t.y,e*t.z),vec4f:(e,t)=>x(e*t.x,e*t.y,e*t.z,e*t.w),vec4h:(e,t)=>g(e*t.x,e*t.y,e*t.z,e*t.w),vec4i:(e,t)=>p(e*t.x,e*t.y,e*t.z,e*t.w),vec4u:(e,t)=>z(e*t.x,e*t.y,e*t.z,e*t.w),mat2x2f:(e,t)=>{let n=t.columns;return G(e*n[0].x,e*n[0].y,e*n[1].x,e*n[1].y)},mat3x3f:(e,t)=>{let n=t.columns;return q(e*n[0].x,e*n[0].y,e*n[0].z,e*n[1].x,e*n[1].y,e*n[1].z,e*n[2].x,e*n[2].y,e*n[2].z)},mat4x4f:(e,t)=>{let n=t.columns;return J(e*n[0].x,e*n[0].y,e*n[0].z,e*n[0].w,e*n[1].x,e*n[1].y,e*n[1].z,e*n[1].w,e*n[2].x,e*n[2].y,e*n[2].z,e*n[2].w,e*n[3].x,e*n[3].y,e*n[3].z,e*n[3].w)}},mulVxV:{vec2f:(e,t)=>l(e.x*t.x,e.y*t.y),vec2h:(e,t)=>i(e.x*t.x,e.y*t.y),vec2i:(e,t)=>T(e.x*t.x,e.y*t.y),vec2u:(e,t)=>m(e.x*t.x,e.y*t.y),vec3f:(e,t)=>y(e.x*t.x,e.y*t.y,e.z*t.z),vec3h:(e,t)=>u(e.x*t.x,e.y*t.y,e.z*t.z),vec3i:(e,t)=>d(e.x*t.x,e.y*t.y,e.z*t.z),vec3u:(e,t)=>f(e.x*t.x,e.y*t.y,e.z*t.z),vec4f:(e,t)=>x(e.x*t.x,e.y*t.y,e.z*t.z,e.w*t.w),vec4h:(e,t)=>g(e.x*t.x,e.y*t.y,e.z*t.z,e.w*t.w),vec4i:(e,t)=>p(e.x*t.x,e.y*t.y,e.z*t.z,e.w*t.w),vec4u:(e,t)=>z(e.x*t.x,e.y*t.y,e.z*t.z,e.w*t.w),mat2x2f:(e,t)=>{let n=e.columns,a=t.columns;return G(n[0].x*a[0].x+n[1].x*a[0].y,n[0].y*a[0].x+n[1].y*a[0].y,n[0].x*a[1].x+n[1].x*a[1].y,n[0].y*a[1].x+n[1].y*a[1].y)},mat3x3f:(e,t)=>{let n=e.columns,a=t.columns;return q(n[0].x*a[0].x+n[1].x*a[0].y+n[2].x*a[0].z,n[0].y*a[0].x+n[1].y*a[0].y+n[2].y*a[0].z,n[0].z*a[0].x+n[1].z*a[0].y+n[2].z*a[0].z,n[0].x*a[1].x+n[1].x*a[1].y+n[2].x*a[1].z,n[0].y*a[1].x+n[1].y*a[1].y+n[2].y*a[1].z,n[0].z*a[1].x+n[1].z*a[1].y+n[2].z*a[1].z,n[0].x*a[2].x+n[1].x*a[2].y+n[2].x*a[2].z,n[0].y*a[2].x+n[1].y*a[2].y+n[2].y*a[2].z,n[0].z*a[2].x+n[1].z*a[2].y+n[2].z*a[2].z)},mat4x4f:(e,t)=>{let n=e.columns,a=t.columns;return J(n[0].x*a[0].x+n[1].x*a[0].y+n[2].x*a[0].z+n[3].x*a[0].w,n[0].y*a[0].x+n[1].y*a[0].y+n[2].y*a[0].z+n[3].y*a[0].w,n[0].z*a[0].x+n[1].z*a[0].y+n[2].z*a[0].z+n[3].z*a[0].w,n[0].w*a[0].x+n[1].w*a[0].y+n[2].w*a[0].z+n[3].w*a[0].w,n[0].x*a[1].x+n[1].x*a[1].y+n[2].x*a[1].z+n[3].x*a[1].w,n[0].y*a[1].x+n[1].y*a[1].y+n[2].y*a[1].z+n[3].y*a[1].w,n[0].z*a[1].x+n[1].z*a[1].y+n[2].z*a[1].z+n[3].z*a[1].w,n[0].w*a[1].x+n[1].w*a[1].y+n[2].w*a[1].z+n[3].w*a[1].w,n[0].x*a[2].x+n[1].x*a[2].y+n[2].x*a[2].z+n[3].x*a[2].w,n[0].y*a[2].x+n[1].y*a[2].y+n[2].y*a[2].z+n[3].y*a[2].w,n[0].z*a[2].x+n[1].z*a[2].y+n[2].z*a[2].z+n[3].z*a[2].w,n[0].w*a[2].x+n[1].w*a[2].y+n[2].w*a[2].z+n[3].w*a[2].w,n[0].x*a[3].x+n[1].x*a[3].y+n[2].x*a[3].z+n[3].x*a[3].w,n[0].y*a[3].x+n[1].y*a[3].y+n[2].y*a[3].z+n[3].y*a[3].w,n[0].z*a[3].x+n[1].z*a[3].y+n[2].z*a[3].z+n[3].z*a[3].w,n[0].w*a[3].x+n[1].w*a[3].y+n[2].w*a[3].z+n[3].w*a[3].w)}},mulMxV:{mat2x2f:(e,t)=>{let n=e.columns;return l(n[0].x*t.x+n[1].x*t.y,n[0].y*t.x+n[1].y*t.y)},mat3x3f:(e,t)=>{let n=e.columns;return y(n[0].x*t.x+n[1].x*t.y+n[2].x*t.z,n[0].y*t.x+n[1].y*t.y+n[2].y*t.z,n[0].z*t.x+n[1].z*t.y+n[2].z*t.z)},mat4x4f:(e,t)=>{let n=e.columns;return x(n[0].x*t.x+n[1].x*t.y+n[2].x*t.z+n[3].x*t.w,n[0].y*t.x+n[1].y*t.y+n[2].y*t.z+n[3].y*t.w,n[0].z*t.x+n[1].z*t.y+n[2].z*t.z+n[3].z*t.w,n[0].w*t.x+n[1].w*t.y+n[2].w*t.z+n[3].w*t.w)}},mulVxM:{mat2x2f:(e,t)=>{let n=t.columns;return l(e.x*n[0].x+e.y*n[0].y,e.x*n[1].x+e.y*n[1].y)},mat3x3f:(e,t)=>{let n=t.columns;return y(e.x*n[0].x+e.y*n[0].y+e.z*n[0].z,e.x*n[1].x+e.y*n[1].y+e.z*n[1].z,e.x*n[2].x+e.y*n[2].y+e.z*n[2].z)},mat4x4f:(e,t)=>{let n=t.columns;return x(e.x*n[0].x+e.y*n[0].y+e.z*n[0].z+e.w*n[0].w,e.x*n[1].x+e.y*n[1].y+e.z*n[1].z+e.w*n[1].w,e.x*n[2].x+e.y*n[2].y+e.z*n[2].z+e.w*n[2].w,e.x*n[3].x+e.y*n[3].y+e.z*n[3].z+e.w*n[3].w)}},dot:{vec2f:C,vec2h:C,vec2i:C,vec2u:C,vec3f:P,vec3h:P,vec3i:P,vec3u:P,vec4f:_,vec4h:_,vec4i:_,vec4u:_},normalize:{vec2f:e=>{let t=R(e);return l(e.x/t,e.y/t)},vec2h:e=>{let t=R(e);return i(e.x/t,e.y/t)},vec2i:e=>{let t=R(e);return T(e.x/t,e.y/t)},vec2u:e=>{let t=R(e);return m(e.x/t,e.y/t)},vec3f:e=>{let t=K(e);return y(e.x/t,e.y/t,e.z/t)},vec3h:e=>{let t=K(e);return u(e.x/t,e.y/t,e.z/t)},vec3i:e=>{let t=K(e);return d(e.x/t,e.y/t,e.z/t)},vec3u:e=>{let t=K(e);return f(e.x/t,e.y/t,e.z/t)},vec4f:e=>{let t=N(e);return x(e.x/t,e.y/t,e.z/t,e.w/t)},vec4h:e=>{let t=N(e);return g(e.x/t,e.y/t,e.z/t,e.w/t)},vec4i:e=>{let t=N(e);return p(e.x/t,e.y/t,e.z/t,e.w/t)},vec4u:e=>{let t=N(e);return z(e.x/t,e.y/t,e.z/t,e.w/t)}},cross:{vec3f:(e,t)=>y(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),vec3h:(e,t)=>u(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x)},floor:{vec2f:M(Math.floor),vec2h:b(Math.floor),vec3f:V(Math.floor),vec3h:A(Math.floor),vec4f:I(Math.floor),vec4h:$(Math.floor)},max:{vec2f:Y(Math.max),vec2h:ee(Math.max),vec2i:le(Math.max),vec2u:ve(Math.max),vec3f:te(Math.max),vec3h:ne(Math.max),vec3i:oe(Math.max),vec3u:xe(Math.max),vec4f:ae(Math.max),vec4h:se(Math.max),vec4i:we(Math.max),vec4u:ue(Math.max)},min:{vec2f:Y(Math.min),vec2h:ee(Math.min),vec2i:le(Math.min),vec2u:ve(Math.min),vec3f:te(Math.min),vec3h:ne(Math.min),vec3i:oe(Math.min),vec3u:xe(Math.min),vec4f:ae(Math.min),vec4h:se(Math.min),vec4i:we(Math.min),vec4u:ue(Math.min)},pow:{vec2f:(e,t)=>l(e.x**t.x,e.y**t.y),vec2h:(e,t)=>i(e.x**t.x,e.y**t.y),vec3f:(e,t)=>y(e.x**t.x,e.y**t.y,e.z**t.z),vec3h:(e,t)=>u(e.x**t.x,e.y**t.y,e.z**t.z),vec4f:(e,t)=>x(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w),vec4h:(e,t)=>g(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w)},mix:{vec2f:(e,t,n)=>typeof n=="number"?l(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n):l(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y),vec2h:(e,t,n)=>typeof n=="number"?i(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n):i(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y),vec3f:(e,t,n)=>typeof n=="number"?y(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n):y(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z),vec3h:(e,t,n)=>typeof n=="number"?u(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n):u(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z),vec4f:(e,t,n)=>typeof n=="number"?x(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n,e.w*(1-n)+t.w*n):x(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z,e.w*(1-n.w)+t.w*n.w),vec4h:(e,t,n)=>typeof n=="number"?g(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n,e.w*(1-n)+t.w*n):g(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z,e.w*(1-n.w)+t.w*n.w)},sin:{vec2f:M(Math.sin),vec2h:b(Math.sin),vec3f:V(Math.sin),vec3h:A(Math.sin),vec4f:I(Math.sin),vec4h:$(Math.sin)},cos:{vec2f:M(Math.cos),vec2h:b(Math.cos),vec3f:V(Math.cos),vec3h:A(Math.cos),vec4f:I(Math.cos),vec4h:$(Math.cos)},exp:{vec2f:M(Math.exp),vec2h:b(Math.exp),vec3f:V(Math.exp),vec3h:A(Math.exp),vec4f:I(Math.exp),vec4h:$(Math.exp)},fract:{vec2f:M(e=>e-Math.floor(e)),vec2h:b(e=>e-Math.floor(e)),vec3f:V(e=>e-Math.floor(e)),vec3h:A(e=>e-Math.floor(e)),vec4f:I(e=>e-Math.floor(e)),vec4h:$(e=>e-Math.floor(e))},isCloseToZero:{vec2f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t,vec2h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t,vec3f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t,vec3h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t,vec4f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t&&Math.abs(e.w)<=t,vec4h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t&&Math.abs(e.w)<=t},select:{vec2f:(e,t,n)=>l(n.x?t.x:e.x,n.y?t.y:e.y),vec2h:(e,t,n)=>i(n.x?t.x:e.x,n.y?t.y:e.y),vec2i:(e,t,n)=>T(n.x?t.x:e.x,n.y?t.y:e.y),vec2u:(e,t,n)=>m(n.x?t.x:e.x,n.y?t.y:e.y),"vec2<bool>":(e,t,n)=>v(n.x?t.x:e.x,n.y?t.y:e.y),vec3f:(e,t,n)=>y(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3h:(e,t,n)=>u(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3i:(e,t,n)=>d(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3u:(e,t,n)=>f(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),"vec3<bool>":(e,t,n)=>o(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec4f:(e,t,n)=>x(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),vec4h:(e,t,n)=>g(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),vec4i:(e,t,n)=>p(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),vec4u:(e,t,n)=>z(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),"vec4<bool>":(e,t,n)=>w(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w)}};function U(e){let t=e.dataType.type;return t==="abstractInt"||t==="abstractFloat"||t==="f32"||t==="f16"||t==="i32"||t==="u32"}var fe=s((e,t)=>r.add[e.kind](e,t),(e,t)=>({value:`(${e.value} + ${t.value})`,dataType:e.dataType})),S=s((e,t)=>r.sub[e.kind](e,t),(e,t)=>({value:`(${e.value} - ${t.value})`,dataType:e.dataType})),ie=s((e,t)=>{if(typeof e=="number")return r.mulSxV[t.kind](e,t);if(typeof e=="object"&&typeof t=="object"&&"kind"in e&&"kind"in t){let n=!e.kind.startsWith("mat"),a=!t.kind.startsWith("mat");if(!n&&a)return r.mulMxV[e.kind](e,t);if(n&&!a)return r.mulVxM[t.kind](e,t)}return r.mulVxV[t.kind](e,t)},(e,t)=>{let n=U(e)?t.dataType:e.dataType.type.startsWith("mat")?t.dataType.type.startsWith("mat")?e.dataType:t.dataType:e.dataType;return{value:`(${e.value} * ${t.value})`,dataType:n}}),pe=s(e=>typeof e=="number"?Math.abs(e):r.abs[e.kind](e),e=>({value:`abs(${e.value})`,dataType:e.dataType})),ze=s((e,t)=>typeof e=="number"&&typeof t=="number"?Math.atan2(e,t):r.atan2[e.kind](e,t),(e,t)=>({value:`atan2(${e.value}, ${t.value})`,dataType:e.dataType})),he=s(e=>typeof e=="number"?Math.acos(e):r.acos[e.kind](e),e=>({value:`acos(${e.value})`,dataType:e.dataType})),Me=s(e=>typeof e=="number"?Math.asin(e):r.asin[e.kind](e),e=>({value:`asin(${e.value})`,dataType:e.dataType})),be=s(e=>typeof e=="number"?Math.ceil(e):r.ceil[e.kind](e),e=>({value:`ceil(${e.value})`,dataType:e.dataType})),Ve=s((e,t,n)=>typeof e=="number"?Math.min(Math.max(t,e),n):r.clamp[e.kind](e,t,n),(e,t,n)=>({value:`clamp(${e.value}, ${t.value}, ${n.value})`,dataType:e.dataType})),Ae=s(e=>typeof e=="number"?Math.cos(e):r.cos[e.kind](e),e=>({value:`cos(${e.value})`,dataType:e.dataType})),Ie=s((e,t)=>r.cross[e.kind](e,t),(e,t)=>({value:`cross(${e.value}, ${t.value})`,dataType:e.dataType})),ge=s((e,t)=>r.dot[e.kind](e,t),(e,t)=>({value:`dot(${e.value}, ${t.value})`,dataType:F})),$e=s(e=>r.normalize[e.kind](e),e=>({value:`normalize(${e.value})`,dataType:e.dataType})),Be=s(e=>typeof e=="number"?Math.floor(e):r.floor[e.kind](e),e=>({value:`floor(${e.value})`,dataType:e.dataType})),Oe=s(e=>typeof e=="number"?e-Math.floor(e):r.fract[e.kind](e),e=>({value:`fract(${e.value})`,dataType:e.dataType})),Te=s(e=>typeof e=="number"?Math.abs(e):r.length[e.kind](e),e=>({value:`length(${e.value})`,dataType:F})),ke=s((e,t)=>typeof e=="number"?Math.max(e,t):r.max[e.kind](e,t),(e,t)=>({value:`max(${e.value}, ${t.value})`,dataType:e.dataType})),Fe=s((e,t)=>typeof e=="number"?Math.min(e,t):r.min[e.kind](e,t),(e,t)=>({value:`min(${e.value}, ${t.value})`,dataType:e.dataType})),Re=s(e=>typeof e=="number"?Math.sin(e):r.sin[e.kind](e),e=>({value:`sin(${e.value})`,dataType:e.dataType})),Ke=s(e=>typeof e=="number"?Math.exp(e):r.exp[e.kind](e),e=>({value:`exp(${e.value})`,dataType:e.dataType})),Ne=s((e,t)=>{if(typeof e=="number"&&typeof t=="number")return e**t;if(typeof e=="object"&&typeof t=="object"&&"kind"in e&&"kind"in t)return r.pow[e.kind](e,t);throw new Error("Invalid arguments to pow()")},(e,t)=>({value:`pow(${e.value}, ${t.value})`,dataType:e.dataType})),Ue=s((e,t,n)=>{if(typeof e=="number"){if(typeof n!="number"||typeof t!="number")throw new Error("When e1 and e2 are numbers, the blend factor must be a number.");return e*(1-n)+t*n}if(typeof e=="number"||typeof t=="number")throw new Error("e1 and e2 need to both be vectors of the same kind.");return r.mix[e.kind](e,t,n)},(e,t,n)=>({value:`mix(${e.value}, ${t.value}, ${n.value})`,dataType:e.dataType})),Ee=s((e,t)=>S(e,ie(2*ge(t,e),t)),(e,t)=>({value:`reflect(${e.value}, ${t.value})`,dataType:e.dataType})),Se=s((e,t)=>typeof e=="number"&&typeof t=="number"?Math.abs(e-t):Te(S(e,t)),(e,t)=>({value:`distance(${e.value}, ${t.value})`,dataType:F}));function E(e){return e.dataType.type.includes("2")?v:e.dataType.type.includes("3")?o:w}var We=s((e,t)=>re(W(e,t)),(e,t)=>({value:`all(${e.value} == ${t.value})`,dataType:O})),W=s((e,t)=>r.eq[e.kind](e,t),(e,t)=>({value:`(${e.value} == ${t.value})`,dataType:E(e)})),Ce=s((e,t)=>B(W(e,t)),(e,t)=>({value:`(${e.value} != ${t.value})`,dataType:E(e)})),D=s((e,t)=>r.lt[e.kind](e,t),(e,t)=>({value:`(${e.value} < ${t.value})`,dataType:E(e)})),Pe=s((e,t)=>ce(D(e,t),W(e,t)),(e,t)=>({value:`(${e.value} <= ${t.value})`,dataType:E(e)})),_e=s((e,t)=>me(B(D(e,t)),B(W(e,t))),(e,t)=>({value:`(${e.value} > ${t.value})`,dataType:E(e)})),De=s((e,t)=>B(D(e,t)),(e,t)=>({value:`(${e.value} >= ${t.value})`,dataType:E(e)})),B=s(e=>r.neg[e.kind](e),e=>({value:`!(${e.value})`,dataType:e.dataType})),ce=s((e,t)=>r.or[e.kind](e,t),(e,t)=>({value:`(${e.value} | ${t.value})`,dataType:e.dataType})),me=s((e,t)=>B(ce(B(e),B(t))),(e,t)=>({value:`(${e.value} & ${t.value})`,dataType:e.dataType})),re=s(e=>r.all[e.kind](e),e=>({value:`all(${e.value})`,dataType:O})),Ge=s(e=>!re(B(e)),e=>({value:`any(${e.value})`,dataType:O})),qe=s((e,t,n=.01)=>typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<n:typeof e!="number"&&typeof t!="number"?r.isCloseToZero[e.kind](S(e,t),n):!1,(e,t,n={value:.01,dataType:F})=>U(e)&&U(t)?{value:`(abs(f32(${e.value}) - f32(${t.value})) <= ${n.value})`,dataType:O}:!U(e)&&!U(t)?{value:`all(abs(${e.value} - ${t.value}) <= (${e.value} - ${e.value}) + ${n.value})`,dataType:O}:{value:"false",dataType:O}),Je=s((e,t,n)=>typeof n=="boolean"?n?t:e:r.select[e.kind](e,t,n),(e,t,n)=>({value:`select(${e.value}, ${t.value}, ${n.value})`,dataType:e.dataType}));var Le=s(()=>console.warn("workgroupBarrier is a no-op outside of GPU mode."),()=>({value:"workgroupBarrier()",dataType:k})),je=s(()=>console.warn("storageBarrier is a no-op outside of GPU mode."),()=>({value:"storageBarrier()",dataType:k})),Xe=s(()=>console.warn("textureBarrier is a no-op outside of GPU mode."),()=>({value:"textureBarrier()",dataType:k})),Ze=s(e=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},e=>{if(h(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicLoad(&${e.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),He=s((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(!h(e.dataType)||e.dataType.type!=="atomic")throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`);return{value:`atomicStore(&${e.value}, ${t.value})`,dataType:k}}),Qe=s((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(h(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicAdd(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),Ye=s((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(h(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicSub(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),et=s((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(h(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicMax(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),tt=s((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(h(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicMin(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),nt=s((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(h(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicAnd(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),at=s((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(h(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicOr(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)}),st=s((e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(h(e.dataType)&&e.dataType.type==="atomic")return{value:`atomicXor(&${e.value}, ${t.value})`,dataType:e.dataType.inner};throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)});var ct=s(e=>e.length,e=>({value:`arrayLength(&${e.value})`,dataType:ye}));export{pe as abs,he as acos,fe as add,re as all,We as allEq,me as and,Ge as any,ct as arrayLength,Me as asin,ze as atan2,Qe as atomicAdd,nt as atomicAnd,Ze as atomicLoad,et as atomicMax,tt as atomicMin,at as atomicOr,He as atomicStore,Ye as atomicSub,st as atomicXor,be as ceil,Ve as clamp,Ae as cos,Ie as cross,de as discard,Se as distance,ge as dot,W as eq,Ke as exp,Be as floor,Oe as fract,De as ge,_e as gt,qe as isCloseTo,Pe as le,Te as length,D as lt,ke as max,Fe as min,Ue as mix,ie as mul,Ce as ne,$e as normalize,B as not,ce as or,Ne as pow,Ee as reflect,Je as select,Re as sin,je as storageBarrier,S as sub,Xe as textureBarrier,Le as workgroupBarrier};
|
2
2
|
//# sourceMappingURL=index.js.map
|