typegpu 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.md +1 -1
- package/chunk-2CMWQRQC.cjs +2 -0
- package/chunk-2CMWQRQC.cjs.map +1 -0
- package/chunk-2ZAQFPSX.js +1266 -0
- package/chunk-2ZAQFPSX.js.map +1 -0
- package/chunk-35UVS2JJ.cjs +591 -0
- package/chunk-35UVS2JJ.cjs.map +1 -0
- package/chunk-A2QB4MSZ.js +4 -0
- package/{chunk-47YH5LQ7.cjs.map → chunk-A2QB4MSZ.js.map} +1 -1
- package/chunk-CMYXKKUP.cjs +1266 -0
- package/chunk-CMYXKKUP.cjs.map +1 -0
- package/chunk-DDEF2Y4S.js +591 -0
- package/chunk-DDEF2Y4S.js.map +1 -0
- package/chunk-KYBPSQX5.js +2 -0
- package/chunk-KYBPSQX5.js.map +1 -0
- package/chunk-VRYGOFCW.cjs +4 -0
- package/chunk-VRYGOFCW.cjs.map +1 -0
- package/data/index.cjs +192 -1
- package/data/index.d.cts +2 -2
- package/data/index.d.ts +2 -2
- package/data/index.js +192 -1
- package/{index-CopjPGJg.d.cts → index-CuzbyKXg.d.cts} +5 -3
- package/{index-BM7ZTN7E.d.ts → index-FHKuURMs.d.ts} +5 -3
- package/index.cjs +4269 -14
- package/index.cjs.map +1 -1
- package/index.d.cts +80 -11
- package/index.d.ts +80 -11
- package/index.js +4269 -14
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/std/index.cjs +490 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +1 -1
- package/std/index.d.ts +1 -1
- package/std/index.js +490 -1
- package/std/index.js.map +1 -1
- package/{vector-BSez01sn.d.cts → vector-CDD2FV2v.d.cts} +19 -3
- package/{vector-BSez01sn.d.ts → vector-CDD2FV2v.d.ts} +19 -3
- package/chunk-47YH5LQ7.cjs +0 -4
- package/chunk-BGPVBIFN.js +0 -4
- package/chunk-BGPVBIFN.js.map +0 -1
- package/chunk-MCUGRE3S.js +0 -2
- package/chunk-MCUGRE3S.js.map +0 -1
- package/chunk-OHFPIYFY.cjs +0 -2
- package/chunk-OHFPIYFY.cjs.map +0 -1
@@ -0,0 +1,591 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __spreadValues = (a, b) => {
|
9
|
+
for (var prop in b || (b = {}))
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
12
|
+
if (__getOwnPropSymbols)
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
+
if (__propIsEnum.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
}
|
17
|
+
return a;
|
18
|
+
};
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
20
|
+
var __publicField = (obj, key, value) => {
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
22
|
+
return value;
|
23
|
+
};
|
24
|
+
|
25
|
+
// src/errors.ts
|
26
|
+
var prefix = "Invariant failed";
|
27
|
+
function invariant(condition, message) {
|
28
|
+
if (condition) {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
if (false) {
|
32
|
+
throw new Error(prefix);
|
33
|
+
}
|
34
|
+
const provided = typeof message === "function" ? message() : message;
|
35
|
+
const value = provided ? `${prefix}: ${provided}` : prefix;
|
36
|
+
throw new Error(value);
|
37
|
+
}
|
38
|
+
var ResolutionError = class _ResolutionError extends Error {
|
39
|
+
constructor(cause, trace) {
|
40
|
+
let entries = trace.map((ancestor) => `- ${ancestor}`);
|
41
|
+
if (entries.length > 20) {
|
42
|
+
entries = [...entries.slice(0, 11), "...", ...entries.slice(-10)];
|
43
|
+
}
|
44
|
+
super(`Resolution of the following tree failed:
|
45
|
+
${entries.join("\n")}`);
|
46
|
+
this.cause = cause;
|
47
|
+
this.trace = trace;
|
48
|
+
Object.setPrototypeOf(this, _ResolutionError.prototype);
|
49
|
+
}
|
50
|
+
appendToTrace(ancestor) {
|
51
|
+
const newTrace = [ancestor, ...this.trace];
|
52
|
+
return new _ResolutionError(this.cause, newTrace);
|
53
|
+
}
|
54
|
+
};
|
55
|
+
var MissingSlotValueError = class _MissingSlotValueError extends Error {
|
56
|
+
constructor(slot) {
|
57
|
+
super(`Missing value for '${slot}'`);
|
58
|
+
this.slot = slot;
|
59
|
+
Object.setPrototypeOf(this, _MissingSlotValueError.prototype);
|
60
|
+
}
|
61
|
+
};
|
62
|
+
var NotUniformError = class _NotUniformError extends Error {
|
63
|
+
constructor(value) {
|
64
|
+
var _a;
|
65
|
+
super(
|
66
|
+
`Buffer '${(_a = value.label) != null ? _a : "<unnamed>"}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`
|
67
|
+
);
|
68
|
+
Object.setPrototypeOf(this, _NotUniformError.prototype);
|
69
|
+
}
|
70
|
+
};
|
71
|
+
var MissingLinksError = class _MissingLinksError extends Error {
|
72
|
+
constructor(fnLabel, externalNames) {
|
73
|
+
super(
|
74
|
+
`The function '${fnLabel != null ? fnLabel : "<unnamed>"}' is missing links to the following external values: ${externalNames}.`
|
75
|
+
);
|
76
|
+
Object.setPrototypeOf(this, _MissingLinksError.prototype);
|
77
|
+
}
|
78
|
+
};
|
79
|
+
var MissingBindGroupsError = class _MissingBindGroupsError extends Error {
|
80
|
+
constructor(layouts) {
|
81
|
+
super(
|
82
|
+
`Missing bind groups for layouts: '${[...layouts].map((layout) => {
|
83
|
+
var _a;
|
84
|
+
return (_a = layout.label) != null ? _a : "<unnamed>";
|
85
|
+
}).join(", ")}'. Please provide it using pipeline.with(layout, bindGroup).(...)`
|
86
|
+
);
|
87
|
+
Object.setPrototypeOf(this, _MissingBindGroupsError.prototype);
|
88
|
+
}
|
89
|
+
};
|
90
|
+
var MissingVertexBuffersError = class _MissingVertexBuffersError extends Error {
|
91
|
+
constructor(layouts) {
|
92
|
+
super(
|
93
|
+
`Missing vertex buffers for layouts: '${[...layouts].map((layout) => {
|
94
|
+
var _a;
|
95
|
+
return (_a = layout.label) != null ? _a : "<unnamed>";
|
96
|
+
}).join(", ")}'. Please provide it using pipeline.with(layout, buffer).(...)`
|
97
|
+
);
|
98
|
+
Object.setPrototypeOf(this, _MissingVertexBuffersError.prototype);
|
99
|
+
}
|
100
|
+
};
|
101
|
+
|
102
|
+
// src/gpuMode.ts
|
103
|
+
var resolutionCtx = null;
|
104
|
+
function provideCtx(ctx, callback) {
|
105
|
+
invariant(resolutionCtx === null, "Cannot nest context providers");
|
106
|
+
resolutionCtx = ctx;
|
107
|
+
try {
|
108
|
+
return callback();
|
109
|
+
} finally {
|
110
|
+
resolutionCtx = null;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
function getResolutionCtx() {
|
114
|
+
return resolutionCtx;
|
115
|
+
}
|
116
|
+
var inGPUMode = () => resolutionCtx !== null;
|
117
|
+
|
118
|
+
// src/data/vector.ts
|
119
|
+
function makeVecSchema(options) {
|
120
|
+
const VecSchema = {
|
121
|
+
/** Type-token, not available at runtime */
|
122
|
+
"~repr": void 0,
|
123
|
+
type: options.type
|
124
|
+
};
|
125
|
+
const construct = (...args) => {
|
126
|
+
var _a;
|
127
|
+
const values = args;
|
128
|
+
if (inGPUMode()) {
|
129
|
+
return `${VecSchema.type}(${values.join(", ")})`;
|
130
|
+
}
|
131
|
+
if (values.length <= 1) {
|
132
|
+
return options.makeFromScalar((_a = values[0]) != null ? _a : 0);
|
133
|
+
}
|
134
|
+
if (values.length === options.length) {
|
135
|
+
return options.make(...values);
|
136
|
+
}
|
137
|
+
throw new Error(
|
138
|
+
`'${options.type}' constructor called with invalid number of arguments.`
|
139
|
+
);
|
140
|
+
};
|
141
|
+
return Object.assign(construct, VecSchema);
|
142
|
+
}
|
143
|
+
var vec2Impl = class {
|
144
|
+
constructor(x, y) {
|
145
|
+
this.x = x;
|
146
|
+
this.y = y;
|
147
|
+
__publicField(this, "length", 2);
|
148
|
+
}
|
149
|
+
*[Symbol.iterator]() {
|
150
|
+
yield this.x;
|
151
|
+
yield this.y;
|
152
|
+
}
|
153
|
+
get [0]() {
|
154
|
+
return this.x;
|
155
|
+
}
|
156
|
+
get [1]() {
|
157
|
+
return this.y;
|
158
|
+
}
|
159
|
+
set [0](value) {
|
160
|
+
this.x = value;
|
161
|
+
}
|
162
|
+
set [1](value) {
|
163
|
+
this.y = value;
|
164
|
+
}
|
165
|
+
"~resolve"() {
|
166
|
+
return `${this.kind}(${this.x}, ${this.y})`;
|
167
|
+
}
|
168
|
+
toString() {
|
169
|
+
return this["~resolve"]();
|
170
|
+
}
|
171
|
+
};
|
172
|
+
var vec2fImpl = class _vec2fImpl extends vec2Impl {
|
173
|
+
constructor() {
|
174
|
+
super(...arguments);
|
175
|
+
__publicField(this, "kind", "vec2f");
|
176
|
+
}
|
177
|
+
make2(x, y) {
|
178
|
+
return new _vec2fImpl(x, y);
|
179
|
+
}
|
180
|
+
make3(x, y, z) {
|
181
|
+
return new vec3fImpl(x, y, z);
|
182
|
+
}
|
183
|
+
make4(x, y, z, w) {
|
184
|
+
return new vec4fImpl(x, y, z, w);
|
185
|
+
}
|
186
|
+
};
|
187
|
+
var vec2hImpl = class _vec2hImpl extends vec2Impl {
|
188
|
+
constructor() {
|
189
|
+
super(...arguments);
|
190
|
+
__publicField(this, "kind", "vec2h");
|
191
|
+
}
|
192
|
+
make2(x, y) {
|
193
|
+
return new _vec2hImpl(x, y);
|
194
|
+
}
|
195
|
+
make3(x, y, z) {
|
196
|
+
return new vec3hImpl(x, y, z);
|
197
|
+
}
|
198
|
+
make4(x, y, z, w) {
|
199
|
+
return new vec4hImpl(x, y, z, w);
|
200
|
+
}
|
201
|
+
};
|
202
|
+
var vec2iImpl = class _vec2iImpl extends vec2Impl {
|
203
|
+
constructor() {
|
204
|
+
super(...arguments);
|
205
|
+
__publicField(this, "kind", "vec2i");
|
206
|
+
}
|
207
|
+
make2(x, y) {
|
208
|
+
return new _vec2iImpl(x, y);
|
209
|
+
}
|
210
|
+
make3(x, y, z) {
|
211
|
+
return new vec3iImpl(x, y, z);
|
212
|
+
}
|
213
|
+
make4(x, y, z, w) {
|
214
|
+
return new vec4iImpl(x, y, z, w);
|
215
|
+
}
|
216
|
+
};
|
217
|
+
var vec2uImpl = class _vec2uImpl extends vec2Impl {
|
218
|
+
constructor() {
|
219
|
+
super(...arguments);
|
220
|
+
__publicField(this, "kind", "vec2u");
|
221
|
+
}
|
222
|
+
make2(x, y) {
|
223
|
+
return new _vec2uImpl(x, y);
|
224
|
+
}
|
225
|
+
make3(x, y, z) {
|
226
|
+
return new vec3uImpl(x, y, z);
|
227
|
+
}
|
228
|
+
make4(x, y, z, w) {
|
229
|
+
return new vec4uImpl(x, y, z, w);
|
230
|
+
}
|
231
|
+
};
|
232
|
+
var vec3Impl = class {
|
233
|
+
constructor(x, y, z) {
|
234
|
+
this.x = x;
|
235
|
+
this.y = y;
|
236
|
+
this.z = z;
|
237
|
+
__publicField(this, "length", 3);
|
238
|
+
}
|
239
|
+
*[Symbol.iterator]() {
|
240
|
+
yield this.x;
|
241
|
+
yield this.y;
|
242
|
+
yield this.z;
|
243
|
+
}
|
244
|
+
get [0]() {
|
245
|
+
return this.x;
|
246
|
+
}
|
247
|
+
get [1]() {
|
248
|
+
return this.y;
|
249
|
+
}
|
250
|
+
get [2]() {
|
251
|
+
return this.z;
|
252
|
+
}
|
253
|
+
set [0](value) {
|
254
|
+
this.x = value;
|
255
|
+
}
|
256
|
+
set [1](value) {
|
257
|
+
this.y = value;
|
258
|
+
}
|
259
|
+
set [2](value) {
|
260
|
+
this.z = value;
|
261
|
+
}
|
262
|
+
"~resolve"() {
|
263
|
+
return `${this.kind}(${this.x}, ${this.y}, ${this.z})`;
|
264
|
+
}
|
265
|
+
toString() {
|
266
|
+
return this["~resolve"]();
|
267
|
+
}
|
268
|
+
};
|
269
|
+
var vec3fImpl = class _vec3fImpl extends vec3Impl {
|
270
|
+
constructor() {
|
271
|
+
super(...arguments);
|
272
|
+
__publicField(this, "kind", "vec3f");
|
273
|
+
}
|
274
|
+
make2(x, y) {
|
275
|
+
return new vec2fImpl(x, y);
|
276
|
+
}
|
277
|
+
make3(x, y, z) {
|
278
|
+
return new _vec3fImpl(x, y, z);
|
279
|
+
}
|
280
|
+
make4(x, y, z, w) {
|
281
|
+
return new vec4fImpl(x, y, z, w);
|
282
|
+
}
|
283
|
+
};
|
284
|
+
var vec3hImpl = class _vec3hImpl extends vec3Impl {
|
285
|
+
constructor() {
|
286
|
+
super(...arguments);
|
287
|
+
__publicField(this, "kind", "vec3h");
|
288
|
+
}
|
289
|
+
make2(x, y) {
|
290
|
+
return new vec2hImpl(x, y);
|
291
|
+
}
|
292
|
+
make3(x, y, z) {
|
293
|
+
return new _vec3hImpl(x, y, z);
|
294
|
+
}
|
295
|
+
make4(x, y, z, w) {
|
296
|
+
return new vec4hImpl(x, y, z, w);
|
297
|
+
}
|
298
|
+
};
|
299
|
+
var vec3iImpl = class _vec3iImpl extends vec3Impl {
|
300
|
+
constructor() {
|
301
|
+
super(...arguments);
|
302
|
+
__publicField(this, "kind", "vec3i");
|
303
|
+
}
|
304
|
+
make2(x, y) {
|
305
|
+
return new vec2iImpl(x, y);
|
306
|
+
}
|
307
|
+
make3(x, y, z) {
|
308
|
+
return new _vec3iImpl(x, y, z);
|
309
|
+
}
|
310
|
+
make4(x, y, z, w) {
|
311
|
+
return new vec4iImpl(x, y, z, w);
|
312
|
+
}
|
313
|
+
};
|
314
|
+
var vec3uImpl = class _vec3uImpl extends vec3Impl {
|
315
|
+
constructor() {
|
316
|
+
super(...arguments);
|
317
|
+
__publicField(this, "kind", "vec3u");
|
318
|
+
}
|
319
|
+
make2(x, y) {
|
320
|
+
return new vec2uImpl(x, y);
|
321
|
+
}
|
322
|
+
make3(x, y, z) {
|
323
|
+
return new _vec3uImpl(x, y, z);
|
324
|
+
}
|
325
|
+
make4(x, y, z, w) {
|
326
|
+
return new vec4uImpl(x, y, z, w);
|
327
|
+
}
|
328
|
+
};
|
329
|
+
var vec4Impl = class {
|
330
|
+
constructor(x, y, z, w) {
|
331
|
+
this.x = x;
|
332
|
+
this.y = y;
|
333
|
+
this.z = z;
|
334
|
+
this.w = w;
|
335
|
+
__publicField(this, "length", 4);
|
336
|
+
}
|
337
|
+
*[Symbol.iterator]() {
|
338
|
+
yield this.x;
|
339
|
+
yield this.y;
|
340
|
+
yield this.z;
|
341
|
+
yield this.w;
|
342
|
+
}
|
343
|
+
get [0]() {
|
344
|
+
return this.x;
|
345
|
+
}
|
346
|
+
get [1]() {
|
347
|
+
return this.y;
|
348
|
+
}
|
349
|
+
get [2]() {
|
350
|
+
return this.z;
|
351
|
+
}
|
352
|
+
get [3]() {
|
353
|
+
return this.w;
|
354
|
+
}
|
355
|
+
set [0](value) {
|
356
|
+
this.x = value;
|
357
|
+
}
|
358
|
+
set [1](value) {
|
359
|
+
this.y = value;
|
360
|
+
}
|
361
|
+
set [2](value) {
|
362
|
+
this.z = value;
|
363
|
+
}
|
364
|
+
set [3](value) {
|
365
|
+
this.w = value;
|
366
|
+
}
|
367
|
+
"~resolve"() {
|
368
|
+
return `${this.kind}(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
|
369
|
+
}
|
370
|
+
toString() {
|
371
|
+
return this["~resolve"]();
|
372
|
+
}
|
373
|
+
};
|
374
|
+
var vec4fImpl = class _vec4fImpl extends vec4Impl {
|
375
|
+
constructor() {
|
376
|
+
super(...arguments);
|
377
|
+
__publicField(this, "kind", "vec4f");
|
378
|
+
}
|
379
|
+
make2(x, y) {
|
380
|
+
return new vec2fImpl(x, y);
|
381
|
+
}
|
382
|
+
make3(x, y, z) {
|
383
|
+
return new vec3fImpl(x, y, z);
|
384
|
+
}
|
385
|
+
make4(x, y, z, w) {
|
386
|
+
return new _vec4fImpl(x, y, z, w);
|
387
|
+
}
|
388
|
+
};
|
389
|
+
var vec4hImpl = class _vec4hImpl extends vec4Impl {
|
390
|
+
constructor() {
|
391
|
+
super(...arguments);
|
392
|
+
__publicField(this, "kind", "vec4h");
|
393
|
+
}
|
394
|
+
make2(x, y) {
|
395
|
+
return new vec2hImpl(x, y);
|
396
|
+
}
|
397
|
+
make3(x, y, z) {
|
398
|
+
return new vec3hImpl(x, y, z);
|
399
|
+
}
|
400
|
+
make4(x, y, z, w) {
|
401
|
+
return new _vec4hImpl(x, y, z, w);
|
402
|
+
}
|
403
|
+
};
|
404
|
+
var vec4iImpl = class _vec4iImpl extends vec4Impl {
|
405
|
+
constructor() {
|
406
|
+
super(...arguments);
|
407
|
+
__publicField(this, "kind", "vec4i");
|
408
|
+
}
|
409
|
+
make2(x, y) {
|
410
|
+
return new vec2iImpl(x, y);
|
411
|
+
}
|
412
|
+
make3(x, y, z) {
|
413
|
+
return new vec3iImpl(x, y, z);
|
414
|
+
}
|
415
|
+
make4(x, y, z, w) {
|
416
|
+
return new _vec4iImpl(x, y, z, w);
|
417
|
+
}
|
418
|
+
};
|
419
|
+
var vec4uImpl = class _vec4uImpl extends vec4Impl {
|
420
|
+
constructor() {
|
421
|
+
super(...arguments);
|
422
|
+
__publicField(this, "kind", "vec4u");
|
423
|
+
}
|
424
|
+
make2(x, y) {
|
425
|
+
return new vec2uImpl(x, y);
|
426
|
+
}
|
427
|
+
make3(x, y, z) {
|
428
|
+
return new vec3uImpl(x, y, z);
|
429
|
+
}
|
430
|
+
make4(x, y, z, w) {
|
431
|
+
return new _vec4uImpl(x, y, z, w);
|
432
|
+
}
|
433
|
+
};
|
434
|
+
var vecProxyHandler = {
|
435
|
+
get: (target, prop) => {
|
436
|
+
if (typeof prop === "symbol" || !Number.isNaN(Number.parseInt(prop))) {
|
437
|
+
return Reflect.get(target, prop);
|
438
|
+
}
|
439
|
+
const targetAsVec4 = target;
|
440
|
+
const values = new Array(prop.length);
|
441
|
+
let idx = 0;
|
442
|
+
for (const char of prop) {
|
443
|
+
switch (char) {
|
444
|
+
case "x":
|
445
|
+
values[idx] = targetAsVec4.x;
|
446
|
+
break;
|
447
|
+
case "y":
|
448
|
+
values[idx] = targetAsVec4.y;
|
449
|
+
break;
|
450
|
+
case "z":
|
451
|
+
values[idx] = targetAsVec4.z;
|
452
|
+
break;
|
453
|
+
case "w":
|
454
|
+
values[idx] = targetAsVec4.w;
|
455
|
+
break;
|
456
|
+
default:
|
457
|
+
return Reflect.get(targetAsVec4, prop);
|
458
|
+
}
|
459
|
+
idx++;
|
460
|
+
}
|
461
|
+
if (prop.length === 4) {
|
462
|
+
return new Proxy(
|
463
|
+
targetAsVec4.make4(
|
464
|
+
values[0],
|
465
|
+
values[1],
|
466
|
+
values[2],
|
467
|
+
values[3]
|
468
|
+
),
|
469
|
+
vecProxyHandler
|
470
|
+
);
|
471
|
+
}
|
472
|
+
if (prop.length === 3) {
|
473
|
+
return new Proxy(
|
474
|
+
targetAsVec4.make3(
|
475
|
+
values[0],
|
476
|
+
values[1],
|
477
|
+
values[2]
|
478
|
+
),
|
479
|
+
vecProxyHandler
|
480
|
+
);
|
481
|
+
}
|
482
|
+
if (prop.length === 2) {
|
483
|
+
return new Proxy(
|
484
|
+
targetAsVec4.make2(values[0], values[1]),
|
485
|
+
vecProxyHandler
|
486
|
+
);
|
487
|
+
}
|
488
|
+
return Reflect.get(target, prop);
|
489
|
+
}
|
490
|
+
};
|
491
|
+
var vec2f = makeVecSchema({
|
492
|
+
type: "vec2f",
|
493
|
+
length: 2,
|
494
|
+
make: (x, y) => new Proxy(new vec2fImpl(x, y), vecProxyHandler),
|
495
|
+
makeFromScalar: (x) => new Proxy(new vec2fImpl(x, x), vecProxyHandler)
|
496
|
+
});
|
497
|
+
var vec2h = makeVecSchema({
|
498
|
+
type: "vec2h",
|
499
|
+
length: 2,
|
500
|
+
make: (x, y) => new Proxy(new vec2hImpl(x, y), vecProxyHandler),
|
501
|
+
makeFromScalar: (x) => new Proxy(new vec2hImpl(x, x), vecProxyHandler)
|
502
|
+
});
|
503
|
+
var vec2i = makeVecSchema({
|
504
|
+
type: "vec2i",
|
505
|
+
length: 2,
|
506
|
+
make: (x, y) => new Proxy(new vec2iImpl(x, y), vecProxyHandler),
|
507
|
+
makeFromScalar: (x) => new Proxy(new vec2iImpl(x, x), vecProxyHandler)
|
508
|
+
});
|
509
|
+
var vec2u = makeVecSchema({
|
510
|
+
type: "vec2u",
|
511
|
+
length: 2,
|
512
|
+
make: (x, y) => new Proxy(new vec2uImpl(x, y), vecProxyHandler),
|
513
|
+
makeFromScalar: (x) => new Proxy(new vec2uImpl(x, x), vecProxyHandler)
|
514
|
+
});
|
515
|
+
var vec3f = makeVecSchema({
|
516
|
+
type: "vec3f",
|
517
|
+
length: 3,
|
518
|
+
make: (x, y, z) => new Proxy(new vec3fImpl(x, y, z), vecProxyHandler),
|
519
|
+
makeFromScalar: (x) => new Proxy(new vec3fImpl(x, x, x), vecProxyHandler)
|
520
|
+
});
|
521
|
+
var vec3h = makeVecSchema({
|
522
|
+
type: "vec3h",
|
523
|
+
length: 3,
|
524
|
+
make: (x, y, z) => new Proxy(new vec3hImpl(x, y, z), vecProxyHandler),
|
525
|
+
makeFromScalar: (x) => new Proxy(new vec3hImpl(x, x, x), vecProxyHandler)
|
526
|
+
});
|
527
|
+
var vec3i = makeVecSchema({
|
528
|
+
type: "vec3i",
|
529
|
+
length: 3,
|
530
|
+
make: (x, y, z) => new Proxy(new vec3iImpl(x, y, z), vecProxyHandler),
|
531
|
+
makeFromScalar: (x) => new Proxy(new vec3iImpl(x, x, x), vecProxyHandler)
|
532
|
+
});
|
533
|
+
var vec3u = makeVecSchema({
|
534
|
+
type: "vec3u",
|
535
|
+
length: 3,
|
536
|
+
make: (x, y, z) => new Proxy(new vec3uImpl(x, y, z), vecProxyHandler),
|
537
|
+
makeFromScalar: (x) => new Proxy(new vec3uImpl(x, x, x), vecProxyHandler)
|
538
|
+
});
|
539
|
+
var vec4f = makeVecSchema({
|
540
|
+
type: "vec4f",
|
541
|
+
length: 4,
|
542
|
+
make: (x, y, z, w) => new Proxy(new vec4fImpl(x, y, z, w), vecProxyHandler),
|
543
|
+
makeFromScalar: (x) => new Proxy(new vec4fImpl(x, x, x, x), vecProxyHandler)
|
544
|
+
});
|
545
|
+
var vec4h = makeVecSchema({
|
546
|
+
type: "vec4h",
|
547
|
+
length: 4,
|
548
|
+
make: (x, y, z, w) => new Proxy(new vec4hImpl(x, y, z, w), vecProxyHandler),
|
549
|
+
makeFromScalar: (x) => new Proxy(new vec4hImpl(x, x, x, x), vecProxyHandler)
|
550
|
+
});
|
551
|
+
var vec4i = makeVecSchema({
|
552
|
+
type: "vec4i",
|
553
|
+
length: 4,
|
554
|
+
make: (x, y, z, w) => new Proxy(new vec4iImpl(x, y, z, w), vecProxyHandler),
|
555
|
+
makeFromScalar: (x) => new Proxy(new vec4iImpl(x, x, x, x), vecProxyHandler)
|
556
|
+
});
|
557
|
+
var vec4u = makeVecSchema({
|
558
|
+
length: 4,
|
559
|
+
type: "vec4u",
|
560
|
+
make: (x, y, z, w) => new Proxy(new vec4uImpl(x, y, z, w), vecProxyHandler),
|
561
|
+
makeFromScalar: (x) => new Proxy(new vec4uImpl(x, x, x, x), vecProxyHandler)
|
562
|
+
});
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
|
590
|
+
exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps; exports.__publicField = __publicField; exports.invariant = invariant; exports.ResolutionError = ResolutionError; exports.MissingSlotValueError = MissingSlotValueError; exports.NotUniformError = NotUniformError; exports.MissingLinksError = MissingLinksError; exports.MissingBindGroupsError = MissingBindGroupsError; exports.MissingVertexBuffersError = MissingVertexBuffersError; exports.provideCtx = provideCtx; exports.getResolutionCtx = getResolutionCtx; exports.inGPUMode = inGPUMode; exports.vec2f = vec2f; exports.vec2h = vec2h; exports.vec2i = vec2i; exports.vec2u = vec2u; exports.vec3f = vec3f; exports.vec3h = vec3h; exports.vec3i = vec3i; exports.vec3u = vec3u; exports.vec4f = vec4f; exports.vec4h = vec4h; exports.vec4i = vec4i; exports.vec4u = vec4u;
|
591
|
+
//# sourceMappingURL=chunk-35UVS2JJ.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/gpuMode.ts","../src/data/vector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAM,SAAS;AAKR,SAAS,UACd,WACA,SACmB;AACnB,MAAI,WAAW;AAEb;AAAA,EACF;AAGA,MAAI,OAAuC;AACzC,UAAM,IAAI,MAAM,MAAM;AAAA,EACxB;AAKA,QAAM,WAAW,OAAO,YAAY,aAAa,QAAQ,IAAI;AAK7D,QAAM,QAAQ,WAAW,GAAG,MAAM,KAAK,QAAQ,KAAK;AACpD,QAAM,IAAI,MAAM,KAAK;AACvB;AASO,IAAM,kBAAN,MAAM,yBAAwB,MAAM;AAAA,EACzC,YACkB,OACA,OAChB;AACA,QAAI,UAAU,MAAM,IAAI,CAAC,aAAa,KAAK,QAAQ,EAAE;AAGrD,QAAI,QAAQ,SAAS,IAAI;AACvB,gBAAU,CAAC,GAAG,QAAQ,MAAM,GAAG,EAAE,GAAG,OAAO,GAAG,QAAQ,MAAM,GAAG,CAAC;AAAA,IAClE;AAEA,UAAM;AAAA,EAA8C,QAAQ,KAAK,IAAI,CAAC,EAAE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,IAAI,MAAM,IAAI,UAAU,GAAG,GAAG,GAAG,CAAC,GAAG,eAAe;AAAA,EACtD,gBAAgB,CAAC,MACf,IAAI,MAAM,IAAI,UAAU,GAAG,GAAG,GAAG,CAAC,GAAG,eAAe;AACxD,CAAC;AA2BM,IAAM,QAAQ,cAAc;AAAA,EACjC,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM,CAAC,GAAG,GAAG,GAAG,MACd,IAAI,MAAM,IAAI,UAAU,GAAG,GAAG,GAAG,CAAC,GAAG,eAAe;AAAA,EACtD,gBAAgB,CAAC,MACf,IAAI,MAAM,IAAI,UAAU,GAAG,GAAG,GAAG,CAAC,GAAG,eAAe;AACxD,CAAC;AA2BM,IAAM,QAAQ,cAAc;AAAA,EACjC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM,CAAC,GAAG,GAAG,GAAG,MACd,IAAI,MAAM,IAAI,UAAU,GAAG,GAAG,GAAG,CAAC,GAAG,eAAe;AAAA,EACtD,gBAAgB,CAAC,MACf,IAAI,MAAM,IAAI,UAAU,GAAG,GAAG,GAAG,CAAC,GAAG,eAAe;AACxD,CAAC","sourcesContent":["import type { TgpuBuffer } from './core/buffer/buffer';\nimport type { TgpuSlot } from './core/slot/slotTypes';\nimport type { TgpuVertexLayout } from './core/vertexLayout/vertexLayout';\nimport type { AnyData, Disarray } from './data/dataTypes';\nimport type { WgslArray } from './data/wgslTypes';\nimport type { TgpuBindGroupLayout } from './tgpuBindGroupLayout';\n\nconst prefix = 'Invariant failed';\n\n/**\n * Inspired by: https://github.com/alexreardon/tiny-invariant/blob/master/src/tiny-invariant.ts\n */\nexport function invariant(\n condition: unknown,\n message?: string | (() => string),\n): asserts condition {\n if (condition) {\n // Condition passed\n return;\n }\n\n // In production we strip the message but still throw\n if (process.env.NODE_ENV === 'production') {\n throw new Error(prefix);\n }\n\n // When not in production we allow the message to pass through\n // *This block will be removed in production builds*\n\n const provided = typeof message === 'function' ? message() : message;\n\n // Options:\n // 1. message provided: `${prefix}: ${provided}`\n // 2. message not provided: prefix\n const value = provided ? `${prefix}: ${provided}` : prefix;\n throw new Error(value);\n}\n\n/**\n * An error that happens during resolution of WGSL code.\n * Contains a trace of all ancestor resolvables in\n * which this error originated.\n *\n * @category Errors\n */\nexport class ResolutionError extends Error {\n constructor(\n public readonly cause: unknown,\n public readonly trace: unknown[],\n ) {\n let entries = trace.map((ancestor) => `- ${ancestor}`);\n\n // Showing only the root and leaf nodes.\n if (entries.length > 20) {\n entries = [...entries.slice(0, 11), '...', ...entries.slice(-10)];\n }\n\n super(`Resolution of the following tree failed: \\n${entries.join('\\n')}`);\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, ResolutionError.prototype);\n }\n\n appendToTrace(ancestor: unknown): ResolutionError {\n const newTrace = [ancestor, ...this.trace];\n\n return new ResolutionError(this.cause, newTrace);\n }\n}\n\n/**\n * @category Errors\n */\nexport class MissingSlotValueError extends Error {\n constructor(public readonly slot: TgpuSlot<unknown>) {\n super(`Missing value for '${slot}'`);\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingSlotValueError.prototype);\n }\n}\n\n/**\n * @category Errors\n */\nexport class NotUniformError extends Error {\n constructor(value: TgpuBuffer<AnyData>) {\n super(\n `Buffer '${value.label ?? '<unnamed>'}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, NotUniformError.prototype);\n }\n}\n\nexport class MissingLinksError extends Error {\n constructor(fnLabel: string | undefined, externalNames: string[]) {\n super(\n `The function '${fnLabel ?? '<unnamed>'}' is missing links to the following external values: ${externalNames}.`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingLinksError.prototype);\n }\n}\n\nexport class MissingBindGroupsError extends Error {\n constructor(layouts: Iterable<TgpuBindGroupLayout>) {\n super(\n `Missing bind groups for layouts: '${[...layouts].map((layout) => layout.label ?? '<unnamed>').join(', ')}'. Please provide it using pipeline.with(layout, bindGroup).(...)`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingBindGroupsError.prototype);\n }\n}\n\nexport class MissingVertexBuffersError extends Error {\n constructor(layouts: Iterable<TgpuVertexLayout<WgslArray | Disarray>>) {\n super(\n `Missing vertex buffers for layouts: '${[...layouts].map((layout) => layout.label ?? '<unnamed>').join(', ')}'. Please provide it using pipeline.with(layout, buffer).(...)`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingVertexBuffersError.prototype);\n }\n}\n","import { invariant } from './errors';\nimport type { ResolutionCtx } from './types';\n\nlet resolutionCtx: ResolutionCtx | null = null;\n\nexport function provideCtx<T>(ctx: ResolutionCtx, callback: () => T): T {\n invariant(resolutionCtx === null, 'Cannot nest context providers');\n\n resolutionCtx = ctx;\n try {\n return callback();\n } finally {\n resolutionCtx = null;\n }\n}\n\nexport function getResolutionCtx(): ResolutionCtx | null {\n return resolutionCtx;\n}\n\nexport const inGPUMode = () => resolutionCtx !== null;\n","import { inGPUMode } from '../gpuMode';\nimport type { SelfResolvable } from '../types';\nimport type {\n Vec2f,\n Vec2h,\n Vec2i,\n Vec2u,\n Vec3f,\n Vec3h,\n Vec3i,\n Vec3u,\n Vec4f,\n Vec4h,\n Vec4i,\n Vec4u,\n v2f,\n v2h,\n v2i,\n v2u,\n v3f,\n v3h,\n v3i,\n v3u,\n v4f,\n v4h,\n v4i,\n v4u,\n} from './wgslTypes';\n\n// --------------\n// Implementation\n// --------------\n\ninterface VecSchemaOptions<TType extends string, TValue> {\n type: TType;\n length: number;\n make: (...args: number[]) => TValue;\n makeFromScalar: (value: number) => TValue;\n}\n\ntype VecSchemaBase<TValue> = {\n readonly type: string;\n readonly '~repr': TValue;\n};\n\nfunction makeVecSchema<TType extends string, TValue>(\n options: VecSchemaOptions<TType, TValue>,\n): VecSchemaBase<TValue> & ((...args: number[]) => TValue) {\n const VecSchema: VecSchemaBase<TValue> = {\n /** Type-token, not available at runtime */\n '~repr': undefined as unknown as TValue,\n type: options.type,\n };\n\n const construct = (...args: number[]): TValue => {\n const values = args; // TODO: Allow users to pass in vectors that fill part of the values.\n\n if (inGPUMode()) {\n return `${VecSchema.type}(${values.join(', ')})` as unknown as TValue;\n }\n\n if (values.length <= 1) {\n return options.makeFromScalar(values[0] ?? 0);\n }\n\n if (values.length === options.length) {\n return options.make(...values);\n }\n\n throw new Error(\n `'${options.type}' constructor called with invalid number of arguments.`,\n );\n };\n\n return Object.assign(construct, VecSchema);\n}\n\nabstract class vec2Impl implements SelfResolvable {\n public readonly length = 2;\n abstract readonly kind: `vec2${'f' | 'u' | 'i' | 'h'}`;\n\n [n: number]: number;\n\n constructor(\n public x: number,\n public y: number,\n ) {}\n\n *[Symbol.iterator]() {\n yield this.x;\n yield this.y;\n }\n\n get [0]() {\n return this.x;\n }\n\n get [1]() {\n return this.y;\n }\n\n set [0](value: number) {\n this.x = value;\n }\n\n set [1](value: number) {\n this.y = value;\n }\n\n '~resolve'(): string {\n return `${this.kind}(${this.x}, ${this.y})`;\n }\n\n toString() {\n return this['~resolve']();\n }\n}\n\nclass vec2fImpl extends vec2Impl {\n readonly kind = 'vec2f';\n\n make2(x: number, y: number): v2f {\n return new vec2fImpl(x, y) as unknown as v2f;\n }\n\n make3(x: number, y: number, z: number): v3f {\n return new vec3fImpl(x, y, z) as unknown as v3f;\n }\n\n make4(x: number, y: number, z: number, w: number): v4f {\n return new vec4fImpl(x, y, z, w) as unknown as v4f;\n }\n}\n\nclass vec2hImpl extends vec2Impl {\n readonly kind = 'vec2h';\n\n make2(x: number, y: number): v2h {\n return new vec2hImpl(x, y) as unknown as v2h;\n }\n\n make3(x: number, y: number, z: number): v3h {\n return new vec3hImpl(x, y, z) as unknown as v3h;\n }\n\n make4(x: number, y: number, z: number, w: number): v4h {\n return new vec4hImpl(x, y, z, w) as unknown as v4h;\n }\n}\n\nclass vec2iImpl extends vec2Impl {\n readonly kind = 'vec2i';\n\n make2(x: number, y: number): v2i {\n return new vec2iImpl(x, y) as unknown as v2i;\n }\n\n make3(x: number, y: number, z: number): v3i {\n return new vec3iImpl(x, y, z) as unknown as v3i;\n }\n\n make4(x: number, y: number, z: number, w: number): v4i {\n return new vec4iImpl(x, y, z, w) as unknown as v4i;\n }\n}\n\nclass vec2uImpl extends vec2Impl {\n readonly kind = 'vec2u';\n\n make2(x: number, y: number): v2u {\n return new vec2uImpl(x, y) as unknown as v2u;\n }\n\n make3(x: number, y: number, z: number): v3u {\n return new vec3uImpl(x, y, z) as unknown as v3u;\n }\n\n make4(x: number, y: number, z: number, w: number): v4u {\n return new vec4uImpl(x, y, z, w) as unknown as v4u;\n }\n}\n\nabstract class vec3Impl implements SelfResolvable {\n public readonly length = 3;\n abstract readonly kind: `vec3${'f' | 'u' | 'i' | 'h'}`;\n [n: number]: number;\n\n constructor(\n public x: number,\n public y: number,\n public z: number,\n ) {}\n\n *[Symbol.iterator]() {\n yield this.x;\n yield this.y;\n yield this.z;\n }\n\n get [0]() {\n return this.x;\n }\n\n get [1]() {\n return this.y;\n }\n\n get [2]() {\n return this.z;\n }\n\n set [0](value: number) {\n this.x = value;\n }\n\n set [1](value: number) {\n this.y = value;\n }\n\n set [2](value: number) {\n this.z = value;\n }\n\n '~resolve'(): string {\n return `${this.kind}(${this.x}, ${this.y}, ${this.z})`;\n }\n\n toString() {\n return this['~resolve']();\n }\n}\n\nclass vec3fImpl extends vec3Impl {\n readonly kind = 'vec3f';\n\n make2(x: number, y: number): v2f {\n return new vec2fImpl(x, y) as unknown as v2f;\n }\n\n make3(x: number, y: number, z: number): v3f {\n return new vec3fImpl(x, y, z) as unknown as v3f;\n }\n\n make4(x: number, y: number, z: number, w: number): v4f {\n return new vec4fImpl(x, y, z, w) as unknown as v4f;\n }\n}\n\nclass vec3hImpl extends vec3Impl {\n readonly kind = 'vec3h';\n\n make2(x: number, y: number): v2h {\n return new vec2hImpl(x, y) as unknown as v2h;\n }\n\n make3(x: number, y: number, z: number): v3h {\n return new vec3hImpl(x, y, z) as unknown as v3h;\n }\n\n make4(x: number, y: number, z: number, w: number): v4h {\n return new vec4hImpl(x, y, z, w) as unknown as v4h;\n }\n}\n\nclass vec3iImpl extends vec3Impl {\n readonly kind = 'vec3i';\n\n make2(x: number, y: number): v2i {\n return new vec2iImpl(x, y) as unknown as v2i;\n }\n\n make3(x: number, y: number, z: number): v3i {\n return new vec3iImpl(x, y, z) as unknown as v3i;\n }\n\n make4(x: number, y: number, z: number, w: number): v4i {\n return new vec4iImpl(x, y, z, w) as unknown as v4i;\n }\n}\n\nclass vec3uImpl extends vec3Impl {\n readonly kind = 'vec3u';\n\n make2(x: number, y: number): v2u {\n return new vec2uImpl(x, y) as unknown as v2u;\n }\n\n make3(x: number, y: number, z: number): v3u {\n return new vec3uImpl(x, y, z) as unknown as v3u;\n }\n\n make4(x: number, y: number, z: number, w: number): v4u {\n return new vec4uImpl(x, y, z, w) as unknown as v4u;\n }\n}\n\nabstract class vec4Impl implements SelfResolvable {\n public readonly length = 4;\n abstract readonly kind: `vec4${'f' | 'u' | 'i' | 'h'}`;\n [n: number]: number;\n\n constructor(\n public x: number,\n public y: number,\n public z: number,\n public w: number,\n ) {}\n\n *[Symbol.iterator]() {\n yield this.x;\n yield this.y;\n yield this.z;\n yield this.w;\n }\n\n get [0]() {\n return this.x;\n }\n\n get [1]() {\n return this.y;\n }\n\n get [2]() {\n return this.z;\n }\n\n get [3]() {\n return this.w;\n }\n\n set [0](value: number) {\n this.x = value;\n }\n\n set [1](value: number) {\n this.y = value;\n }\n\n set [2](value: number) {\n this.z = value;\n }\n\n set [3](value: number) {\n this.w = value;\n }\n\n '~resolve'(): string {\n return `${this.kind}(${this.x}, ${this.y}, ${this.z}, ${this.w})`;\n }\n\n toString() {\n return this['~resolve']();\n }\n}\n\nclass vec4fImpl extends vec4Impl {\n readonly kind = 'vec4f';\n\n make2(x: number, y: number): v2f {\n return new vec2fImpl(x, y) as unknown as v2f;\n }\n\n make3(x: number, y: number, z: number): v3f {\n return new vec3fImpl(x, y, z) as unknown as v3f;\n }\n\n make4(x: number, y: number, z: number, w: number): v4f {\n return new vec4fImpl(x, y, z, w) as unknown as v4f;\n }\n}\n\nclass vec4hImpl extends vec4Impl {\n readonly kind = 'vec4h';\n\n make2(x: number, y: number): v2h {\n return new vec2hImpl(x, y) as unknown as v2h;\n }\n\n make3(x: number, y: number, z: number): v3h {\n return new vec3hImpl(x, y, z) as unknown as v3h;\n }\n\n make4(x: number, y: number, z: number, w: number): v4h {\n return new vec4hImpl(x, y, z, w) as unknown as v4h;\n }\n}\n\nclass vec4iImpl extends vec4Impl {\n readonly kind = 'vec4i';\n\n make2(x: number, y: number): v2i {\n return new vec2iImpl(x, y) as unknown as v2i;\n }\n\n make3(x: number, y: number, z: number): v3i {\n return new vec3iImpl(x, y, z) as unknown as v3i;\n }\n\n make4(x: number, y: number, z: number, w: number): v4i {\n return new vec4iImpl(x, y, z, w) as unknown as v4i;\n }\n}\n\nclass vec4uImpl extends vec4Impl {\n readonly kind = 'vec4u';\n\n make2(x: number, y: number): v2u {\n return new vec2uImpl(x, y) as unknown as v2u;\n }\n\n make3(x: number, y: number, z: number): v3u {\n return new vec3uImpl(x, y, z) as unknown as v3u;\n }\n\n make4(x: number, y: number, z: number, w: number): v4u {\n return new vec4uImpl(x, y, z, w) as unknown as v4u;\n }\n}\n\nconst vecProxyHandler: ProxyHandler<{ kind: VecKind }> = {\n get: (target, prop) => {\n if (typeof prop === 'symbol' || !Number.isNaN(Number.parseInt(prop))) {\n return Reflect.get(target, prop);\n }\n\n const targetAsVec4 = target as unknown as vec4uImpl;\n const values = new Array(prop.length) as number[];\n\n let idx = 0;\n for (const char of prop as string) {\n switch (char) {\n case 'x':\n values[idx] = targetAsVec4.x;\n break;\n case 'y':\n values[idx] = targetAsVec4.y;\n break;\n case 'z':\n values[idx] = targetAsVec4.z;\n break;\n case 'w':\n values[idx] = targetAsVec4.w;\n break;\n default:\n return Reflect.get(targetAsVec4, prop);\n }\n idx++;\n }\n\n if (prop.length === 4) {\n return new Proxy(\n targetAsVec4.make4(\n values[0] as number,\n values[1] as number,\n values[2] as number,\n values[3] as number,\n ),\n vecProxyHandler,\n );\n }\n\n if (prop.length === 3) {\n return new Proxy(\n targetAsVec4.make3(\n values[0] as number,\n values[1] as number,\n values[2] as number,\n ),\n vecProxyHandler,\n );\n }\n\n if (prop.length === 2) {\n return new Proxy(\n targetAsVec4.make2(values[0] as number, values[1] as number),\n vecProxyHandler,\n );\n }\n\n return Reflect.get(target, prop);\n },\n};\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Type encompassing all available kinds of vector.\n */\nexport type VecKind =\n | 'vec2f'\n | 'vec2i'\n | 'vec2u'\n | 'vec2h'\n | 'vec3f'\n | 'vec3i'\n | 'vec3u'\n | 'vec3h'\n | 'vec4f'\n | 'vec4i'\n | 'vec4u'\n | 'vec4h';\n\n/**\n * Type of the `d.vec2f` object/function: vector data type schema/constructor\n */\nexport type NativeVec2f = Vec2f & { '~exotic': Vec2f } & ((\n x: number,\n y: number,\n ) => v2f) &\n ((xy: number) => v2f) &\n (() => v2f);\n\n/**\n *\n * Schema representing vec2f - a vector with 2 elements of type f32.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec2f(); // (0.0, 0.0)\n * const vector = d.vec2f(1); // (1.0, 1.0)\n * const vector = d.vec2f(0.5, 0.1); // (0.5, 0.1)\n *\n * @example\n * const buffer = root.createBuffer(d.vec2f, d.vec2f(0, 1)); // buffer holding a d.vec2f value, with an initial value of vec2f(0, 1);\n */\nexport const vec2f = makeVecSchema({\n type: 'vec2f',\n length: 2,\n make: (x: number, y: number) =>\n new Proxy(new vec2fImpl(x, y), vecProxyHandler) as v2f,\n makeFromScalar: (x) => new Proxy(new vec2fImpl(x, x), vecProxyHandler) as v2f,\n}) as NativeVec2f;\n\n/**\n * Type of the `d.vec2h` object/function: vector data type schema/constructor\n */\nexport type NativeVec2h = Vec2h & { '~exotic': Vec2h } & ((\n x: number,\n y: number,\n ) => v2h) &\n ((xy: number) => v2h) &\n (() => v2h);\n\n/**\n *\n * Schema representing vec2h - a vector with 2 elements of type f16.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec2h(); // (0.0, 0.0)\n * const vector = d.vec2h(1); // (1.0, 1.0)\n * const vector = d.vec2h(0.5, 0.1); // (0.5, 0.1)\n *\n * @example\n * const buffer = root.createBuffer(d.vec2h, d.vec2h(0, 1)); // buffer holding a d.vec2h value, with an initial value of vec2h(0, 1);\n */\nexport const vec2h = makeVecSchema({\n type: 'vec2h',\n length: 2,\n make: (x: number, y: number) =>\n new Proxy(new vec2hImpl(x, y), vecProxyHandler) as v2h,\n makeFromScalar: (x) => new Proxy(new vec2hImpl(x, x), vecProxyHandler) as v2h,\n}) as NativeVec2h;\n\n/**\n * Type of the `d.vec2i` object/function: vector data type schema/constructor\n */\nexport type NativeVec2i = Vec2i & { '~exotic': Vec2i } & ((\n x: number,\n y: number,\n ) => v2i) &\n ((xy: number) => v2i) &\n (() => v2i);\n\n/**\n *\n * Schema representing vec2i - a vector with 2 elements of type i32.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec2i(); // (0, 0)\n * const vector = d.vec2i(1); // (1, 1)\n * const vector = d.vec2i(-1, 1); // (-1, 1)\n *\n * @example\n * const buffer = root.createBuffer(d.vec2i, d.vec2i(0, 1)); // buffer holding a d.vec2i value, with an initial value of vec2i(0, 1);\n */\nexport const vec2i = makeVecSchema({\n type: 'vec2i',\n length: 2,\n make: (x: number, y: number) =>\n new Proxy(new vec2iImpl(x, y), vecProxyHandler) as v2i,\n makeFromScalar: (x) => new Proxy(new vec2iImpl(x, x), vecProxyHandler) as v2i,\n}) as NativeVec2i;\n\n/**\n * Type of the `d.vec2u` object/function: vector data type schema/constructor\n */\nexport type NativeVec2u = Vec2u & { '~exotic': Vec2u } & ((\n x: number,\n y: number,\n ) => v2u) &\n ((xy: number) => v2u) &\n (() => v2u);\n\n/**\n *\n * Schema representing vec2u - a vector with 2 elements of type u32.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec2u(); // (0, 0)\n * const vector = d.vec2u(1); // (1, 1)\n * const vector = d.vec2u(1, 2); // (1, 2)\n *\n * @example\n * const buffer = root.createBuffer(d.vec2u, d.vec2u(0, 1)); // buffer holding a d.vec2u value, with an initial value of vec2u(0, 1);\n */\nexport const vec2u = makeVecSchema({\n type: 'vec2u',\n length: 2,\n make: (x: number, y: number) =>\n new Proxy(new vec2uImpl(x, y), vecProxyHandler) as v2u,\n makeFromScalar: (x) => new Proxy(new vec2uImpl(x, x), vecProxyHandler) as v2u,\n}) as NativeVec2u;\n\n/**\n * Type of the `d.vec3f` object/function: vector data type schema/constructor\n */\nexport type NativeVec3f = Vec3f & { '~exotic': Vec3f } & ((\n x: number,\n y: number,\n z: number,\n ) => v3f) &\n ((xyz: number) => v3f) &\n (() => v3f);\n\n/**\n *\n * Schema representing vec3f - a vector with 3 elements of type f32.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec3f(); // (0.0, 0.0, 0.0)\n * const vector = d.vec3f(1); // (1.0, 1.0, 1.0)\n * const vector = d.vec3f(1, 2, 3.5); // (1.0, 2.0, 3.5)\n *\n * @example\n * const buffer = root.createBuffer(d.vec3f, d.vec3f(0, 1, 2)); // buffer holding a d.vec3f value, with an initial value of vec3f(0, 1, 2);\n */\nexport const vec3f = makeVecSchema({\n type: 'vec3f',\n length: 3,\n make: (x, y, z) => new Proxy(new vec3fImpl(x, y, z), vecProxyHandler) as v3f,\n makeFromScalar: (x) =>\n new Proxy(new vec3fImpl(x, x, x), vecProxyHandler) as v3f,\n}) as NativeVec3f;\n\n/**\n * Type of the `d.vec3h` object/function: vector data type schema/constructor\n */\nexport type NativeVec3h = Vec3h & { '~exotic': Vec3h } & ((\n x: number,\n y: number,\n z: number,\n ) => v3h) &\n ((xyz: number) => v3h) &\n (() => v3h);\n\n/**\n *\n * Schema representing vec3h - a vector with 3 elements of type f16.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec3h(); // (0.0, 0.0, 0.0)\n * const vector = d.vec3h(1); // (1.0, 1.0, 1.0)\n * const vector = d.vec3h(1, 2, 3.5); // (1.0, 2.0, 3.5)\n *\n * @example\n * const buffer = root.createBuffer(d.vec3h, d.vec3h(0, 1, 2)); // buffer holding a d.vec3h value, with an initial value of vec3h(0, 1, 2);\n */\nexport const vec3h = makeVecSchema({\n type: 'vec3h',\n length: 3,\n make: (x, y, z) => new Proxy(new vec3hImpl(x, y, z), vecProxyHandler) as v3h,\n makeFromScalar: (x) =>\n new Proxy(new vec3hImpl(x, x, x), vecProxyHandler) as v3h,\n}) as NativeVec3h;\n\n/**\n * Type of the `d.vec3i` object/function: vector data type schema/constructor\n */\nexport type NativeVec3i = Vec3i & { '~exotic': Vec3i } & ((\n x: number,\n y: number,\n z: number,\n ) => v3i) &\n ((xyz: number) => v3i) &\n (() => v3i);\n\n/**\n *\n * Schema representing vec3i - a vector with 3 elements of type i32.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec3i(); // (0, 0, 0)\n * const vector = d.vec3i(1); // (1, 1, 1)\n * const vector = d.vec3i(1, 2, -3); // (1, 2, -3)\n *\n * @example\n * const buffer = root.createBuffer(d.vec3i, d.vec3i(0, 1, 2)); // buffer holding a d.vec3i value, with an initial value of vec3i(0, 1, 2);\n */\nexport const vec3i = makeVecSchema({\n type: 'vec3i',\n length: 3,\n make: (x, y, z) => new Proxy(new vec3iImpl(x, y, z), vecProxyHandler) as v3i,\n makeFromScalar: (x) =>\n new Proxy(new vec3iImpl(x, x, x), vecProxyHandler) as v3i,\n}) as NativeVec3i;\n\n/**\n * Type of the `d.vec3u` object/function: vector data type schema/constructor\n */\nexport type NativeVec3u = Vec3u & { '~exotic': Vec3u } & ((\n x: number,\n y: number,\n z: number,\n ) => v3u) &\n ((xyz: number) => v3u) &\n (() => v3u);\n\n/**\n *\n * Schema representing vec3u - a vector with 3 elements of type u32.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec3u(); // (0, 0, 0)\n * const vector = d.vec3u(1); // (1, 1, 1)\n * const vector = d.vec3u(1, 2, 3); // (1, 2, 3)\n *\n * @example\n * const buffer = root.createBuffer(d.vec3u, d.vec3u(0, 1, 2)); // buffer holding a d.vec3u value, with an initial value of vec3u(0, 1, 2);\n */\nexport const vec3u = makeVecSchema({\n type: 'vec3u',\n length: 3,\n make: (x, y, z) => new Proxy(new vec3uImpl(x, y, z), vecProxyHandler) as v3u,\n makeFromScalar: (x) =>\n new Proxy(new vec3uImpl(x, x, x), vecProxyHandler) as v3u,\n}) as NativeVec3u;\n\n/**\n * Type of the `d.vec4f` object/function: vector data type schema/constructor\n */\nexport type NativeVec4f = Vec4f & { '~exotic': Vec4f } & ((\n x: number,\n y: number,\n z: number,\n w: number,\n ) => v4f) &\n ((xyzw: number) => v4f) &\n (() => v4f);\n\n/**\n *\n * Schema representing vec4f - a vector with 4 elements of type f32.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec4f(); // (0.0, 0.0, 0.0, 0.0)\n * const vector = d.vec4f(1); // (1.0, 1.0, 1.0, 1.0)\n * const vector = d.vec4f(1, 2, 3, 4.5); // (1.0, 2.0, 3.0, 4.5)\n *\n * @example\n * const buffer = root.createBuffer(d.vec4f, d.vec4f(0, 1, 2, 3)); // buffer holding a d.vec4f value, with an initial value of vec4f(0, 1, 2, 3);\n */\nexport const vec4f = makeVecSchema({\n type: 'vec4f',\n length: 4,\n make: (x, y, z, w) =>\n new Proxy(new vec4fImpl(x, y, z, w), vecProxyHandler) as v4f,\n makeFromScalar: (x) =>\n new Proxy(new vec4fImpl(x, x, x, x), vecProxyHandler) as v4f,\n}) as NativeVec4f;\n\n/**\n * Type of the `d.vec4h` object/function: vector data type schema/constructor\n */\nexport type NativeVec4h = Vec4h & { '~exotic': Vec4h } & ((\n x: number,\n y: number,\n z: number,\n w: number,\n ) => v4h) &\n ((xyzw: number) => v4h) &\n (() => v4h);\n\n/**\n *\n * Schema representing vec4h - a vector with 4 elements of type f16.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec4h(); // (0.0, 0.0, 0.0, 0.0)\n * const vector = d.vec4h(1); // (1.0, 1.0, 1.0, 1.0)\n * const vector = d.vec4h(1, 2, 3, 4.5); // (1.0, 2.0, 3.0, 4.5)\n *\n * @example\n * const buffer = root.createBuffer(d.vec4h, d.vec4h(0, 1, 2, 3)); // buffer holding a d.vec4h value, with an initial value of vec4h(0, 1, 2, 3);\n */\nexport const vec4h = makeVecSchema({\n type: 'vec4h',\n length: 4,\n make: (x, y, z, w) =>\n new Proxy(new vec4hImpl(x, y, z, w), vecProxyHandler) as v4h,\n makeFromScalar: (x) =>\n new Proxy(new vec4hImpl(x, x, x, x), vecProxyHandler) as v4h,\n}) as NativeVec4h;\n\n/**\n * Type of the `d.vec4i` object/function: vector data type schema/constructor\n */\nexport type NativeVec4i = Vec4i & { '~exotic': Vec4i } & ((\n x: number,\n y: number,\n z: number,\n w: number,\n ) => v4i) &\n ((xyzw: number) => v4i) &\n (() => v4i);\n\n/**\n *\n * Schema representing vec4i - a vector with 4 elements of type i32.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec4i(); // (0, 0, 0, 0)\n * const vector = d.vec4i(1); // (1, 1, 1, 1)\n * const vector = d.vec4i(1, 2, 3, -4); // (1, 2, 3, -4)\n *\n * @example\n * const buffer = root.createBuffer(d.vec4i, d.vec4i(0, 1, 2, 3)); // buffer holding a d.vec4i value, with an initial value of vec4i(0, 1, 2, 3);\n */\nexport const vec4i = makeVecSchema({\n type: 'vec4i',\n length: 4,\n make: (x, y, z, w) =>\n new Proxy(new vec4iImpl(x, y, z, w), vecProxyHandler) as v4i,\n makeFromScalar: (x) =>\n new Proxy(new vec4iImpl(x, x, x, x), vecProxyHandler) as v4i,\n}) as NativeVec4i;\n\n/**\n * Type of the `d.vec4u` object/function: vector data type schema/constructor\n */\nexport type NativeVec4u = Vec4u & { '~exotic': Vec4u } & ((\n x: number,\n y: number,\n z: number,\n w: number,\n ) => v4u) &\n ((xyzw: number) => v4u) &\n (() => v4u);\n\n/**\n *\n * Schema representing vec4u - a vector with 4 elements of type u32.\n * Also a constructor function for this vector value.\n *\n * @example\n * const vector = d.vec4u(); // (0, 0, 0, 0)\n * const vector = d.vec4u(1); // (1, 1, 1, 1)\n * const vector = d.vec4u(1, 2, 3, 4); // (1, 2, 3, 4)\n *\n * @example\n * const buffer = root.createBuffer(d.vec4u, d.vec4u(0, 1, 2, 3)); // buffer holding a d.vec4u value, with an initial value of vec4u(0, 1, 2, 3);\n */\nexport const vec4u = makeVecSchema({\n length: 4,\n type: 'vec4u',\n make: (x, y, z, w) =>\n new Proxy(new vec4uImpl(x, y, z, w), vecProxyHandler) as v4u,\n makeFromScalar: (x) =>\n new Proxy(new vec4uImpl(x, x, x, x), vecProxyHandler) as v4u,\n}) as NativeVec4u;\n"]}
|