@carbonenginejs/runtime-utils 0.1.0

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.
Files changed (101) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +23 -0
  3. package/README.md +56 -0
  4. package/THIRD-PARTY-NOTICES.md +38 -0
  5. package/docs/README.md +81 -0
  6. package/docs/architecture.md +101 -0
  7. package/docs/concepts/foundation-consolidation.md +86 -0
  8. package/docs/const-kb.md +92 -0
  9. package/docs/core-types/DECORATOR-TODOS.md +25 -0
  10. package/docs/core-types/README.md +203 -0
  11. package/docs/reference/api.md +70 -0
  12. package/docs/reference/classes/README.md +115 -0
  13. package/package.json +132 -0
  14. package/src/arrays.js +5 -0
  15. package/src/audio/audioFormats.js +34 -0
  16. package/src/audio/index.js +1 -0
  17. package/src/box3.js +1385 -0
  18. package/src/bytes.js +56 -0
  19. package/src/compression.js +56 -0
  20. package/src/constants/index.js +6 -0
  21. package/src/constants.js +15 -0
  22. package/src/curve.js +419 -0
  23. package/src/d3d/dxgiFormats.js +46 -0
  24. package/src/d3d/index.js +2 -0
  25. package/src/d3d/primitiveTopology.js +11 -0
  26. package/src/document/CjsCarbonDocument.js +212 -0
  27. package/src/document/CjsClassRegistry.js +373 -0
  28. package/src/document/CjsDocumentDehydrator.js +142 -0
  29. package/src/document/CjsDocumentHydrator.js +156 -0
  30. package/src/document/CjsStructRegistry.js +348 -0
  31. package/src/document/hydrationAdapter.js +129 -0
  32. package/src/document/index.js +6 -0
  33. package/src/geometry/box.js +137 -0
  34. package/src/geometry/cylinder.js +244 -0
  35. package/src/geometry/helpers/LICENSE +15 -0
  36. package/src/geometry/helpers/earcut.js +766 -0
  37. package/src/geometry/helpers/misc.js +103 -0
  38. package/src/geometry/index.js +8 -0
  39. package/src/geometry/json.js +165 -0
  40. package/src/geometry/lathe.js +172 -0
  41. package/src/geometry/octahedron.js +0 -0
  42. package/src/geometry/plane.js +81 -0
  43. package/src/geometry/shape.js +95 -0
  44. package/src/geometry/sphere.js +123 -0
  45. package/src/geometry/torus.js +96 -0
  46. package/src/graphics/colorSpaces.js +22 -0
  47. package/src/graphics/index.js +4 -0
  48. package/src/graphics/pixelFormats.js +158 -0
  49. package/src/graphics/textureDimensions.js +22 -0
  50. package/src/graphics/trinityEnums.js +87 -0
  51. package/src/index.js +58 -0
  52. package/src/is.js +524 -0
  53. package/src/json.js +23 -0
  54. package/src/lifecycle/CjsLifecycleState.js +77 -0
  55. package/src/lifecycle/index.js +1 -0
  56. package/src/lne3.js +497 -0
  57. package/src/lookup.js +48 -0
  58. package/src/mat3.js +131 -0
  59. package/src/mat4.js +699 -0
  60. package/src/math/index.js +25 -0
  61. package/src/math/scalar.js +63 -0
  62. package/src/media/index.js +1 -0
  63. package/src/media/mediaTypes.js +50 -0
  64. package/src/mesh.js +394 -0
  65. package/src/model/CjsEventEmitter.js +333 -0
  66. package/src/model/CjsModel.js +1544 -0
  67. package/src/model/CjsModelState.js +72 -0
  68. package/src/model/index.js +4 -0
  69. package/src/model/sourceRecordUtils.js +54 -0
  70. package/src/noise.js +310 -0
  71. package/src/num.js +827 -0
  72. package/src/path.js +21 -0
  73. package/src/pln.js +762 -0
  74. package/src/pool.js +160 -0
  75. package/src/quat.js +144 -0
  76. package/src/ray3.js +1085 -0
  77. package/src/renderContext/formats.js +145 -0
  78. package/src/renderContext/index.js +5 -0
  79. package/src/renderContext/presentation.js +125 -0
  80. package/src/renderContext/resources.js +27 -0
  81. package/src/renderContext/upscaling.js +22 -0
  82. package/src/renderContext/window.js +20 -0
  83. package/src/runtime/CjsRuntimeState.js +50 -0
  84. package/src/schema/CjsSchema.js +1009 -0
  85. package/src/schema/index.js +17 -0
  86. package/src/shader/index.js +1 -0
  87. package/src/shader/shaderStages.js +37 -0
  88. package/src/sph3.js +754 -0
  89. package/src/tangent.js +288 -0
  90. package/src/text.js +40 -0
  91. package/src/tri3.js +650 -0
  92. package/src/types/carbonTypes.js +635 -0
  93. package/src/types/index.js +2 -0
  94. package/src/utils.js +58 -0
  95. package/src/validation.js +46 -0
  96. package/src/vec2.js +229 -0
  97. package/src/vec3.js +1172 -0
  98. package/src/vec4.js +347 -0
  99. package/src/vertex.js +108 -0
  100. package/src/webgpu/index.js +1 -0
  101. package/src/webgpu/textureFormats.js +121 -0
package/src/bytes.js ADDED
@@ -0,0 +1,56 @@
1
+ /** Returns a zero-copy Uint8Array view over supported byte input. */
2
+ export function asUint8Array(value, label = "value")
3
+ {
4
+ if (value instanceof Uint8Array)
5
+ {
6
+ return value;
7
+ }
8
+
9
+ if (value instanceof ArrayBuffer)
10
+ {
11
+ return new Uint8Array(value);
12
+ }
13
+
14
+ if (ArrayBuffer.isView(value))
15
+ {
16
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
17
+ }
18
+
19
+ throw new TypeError(`${label} must be a Uint8Array, ArrayBuffer, or ArrayBuffer view.`);
20
+ }
21
+
22
+ /** Returns an owned copy of supported byte input. */
23
+ export function copyBytes(value, label = "value")
24
+ {
25
+ return asUint8Array(value, label).slice();
26
+ }
27
+
28
+ /** Copies exactly the visible byte range into a standalone ArrayBuffer. */
29
+ export function toArrayBuffer(value, label = "value")
30
+ {
31
+ const bytes = asUint8Array(value, label);
32
+
33
+ return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
34
+ }
35
+
36
+ /** Tests whether byte input starts with the complete supplied prefix. */
37
+ export function hasBytePrefix(value, prefix)
38
+ {
39
+ const bytes = asUint8Array(value, "value");
40
+ const expected = asUint8Array(prefix, "prefix");
41
+
42
+ if (bytes.byteLength < expected.byteLength)
43
+ {
44
+ return false;
45
+ }
46
+
47
+ for (let index = 0; index < expected.byteLength; index++)
48
+ {
49
+ if (bytes[index] !== expected[index])
50
+ {
51
+ return false;
52
+ }
53
+ }
54
+
55
+ return true;
56
+ }
@@ -0,0 +1,56 @@
1
+ import { asUint8Array, hasBytePrefix } from "./bytes.js";
2
+
3
+ const GZIP_PREFIX = new Uint8Array([ 0x1f, 0x8b ]);
4
+
5
+ /** Returns whether byte input has the gzip magic prefix. */
6
+ export function isGzip(value)
7
+ {
8
+ return hasBytePrefix(value, GZIP_PREFIX);
9
+ }
10
+
11
+ /** Decompresses bytes with the platform DecompressionStream API. */
12
+ export async function decompressBytes(value, format, options = {})
13
+ {
14
+ const DecompressionStreamClass = Object.hasOwn(options, "decompressionStreamClass")
15
+ ? options.decompressionStreamClass
16
+ : globalThis.DecompressionStream;
17
+ const ResponseClass = Object.hasOwn(options, "responseClass")
18
+ ? options.responseClass
19
+ : globalThis.Response;
20
+
21
+ if (typeof DecompressionStreamClass !== "function" || typeof ResponseClass !== "function")
22
+ {
23
+ const error = new Error(
24
+ `DecompressionStream support for ${JSON.stringify(format)} is unavailable in this environment.`
25
+ );
26
+
27
+ error.code = "CJS_DECOMPRESSION_UNSUPPORTED";
28
+ throw error;
29
+ }
30
+
31
+ const source = new ResponseClass(asUint8Array(value, "compressed input"));
32
+
33
+ if (!source.body)
34
+ {
35
+ throw new Error("The platform Response did not expose a readable byte stream.");
36
+ }
37
+
38
+ const stream = source.body.pipeThrough(new DecompressionStreamClass(String(format)));
39
+ const output = await new ResponseClass(stream).arrayBuffer();
40
+
41
+ return new Uint8Array(output);
42
+ }
43
+
44
+ /** Decompresses one gzip byte sequence. */
45
+ export function decompressGzip(value, options = {})
46
+ {
47
+ return decompressBytes(value, "gzip", options);
48
+ }
49
+
50
+ /** Decompresses gzip input and returns an unchanged view for plain bytes. */
51
+ export function decompressGzipIfNeeded(value, options = {})
52
+ {
53
+ const bytes = asUint8Array(value, "input");
54
+
55
+ return isGzip(bytes) ? decompressGzip(bytes, options) : Promise.resolve(bytes);
56
+ }
@@ -0,0 +1,6 @@
1
+ export * from "../media/index.js";
2
+ export * from "../graphics/index.js";
3
+ export * from "../audio/index.js";
4
+ export * from "../shader/index.js";
5
+ export * from "../d3d/index.js";
6
+ export * from "../webgpu/index.js";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Small WebGL numeric constants used by the typed-array pool helpers.
3
+ *
4
+ * These stay local to keep the math subpaths independently browser-friendly:
5
+ * importing the old ccpwgl `constant` alias would pull the package back toward
6
+ * an application-specific module graph.
7
+ */
8
+
9
+ export const GL_BYTE = 5120;
10
+ export const GL_UNSIGNED_BYTE = 5121;
11
+ export const GL_SHORT = 5122;
12
+ export const GL_UNSIGNED_SHORT = 5123;
13
+ export const GL_INT = 5124;
14
+ export const GL_UNSIGNED_INT = 5125;
15
+ export const GL_FLOAT = 5126;
package/src/curve.js ADDED
@@ -0,0 +1,419 @@
1
+ export const curve = {};
2
+
3
+ /**
4
+ * Evaluates a curve
5
+ *
6
+ * @param {{}|Tw2GeometryCurve} curve
7
+ * @param {Array} curve.knots
8
+ * @param {number} curve.degree
9
+ * @param {Array} curve.controls
10
+ * @param {number} curve.dimension
11
+ * @param {number} time
12
+ * @param {*} value
13
+ * @param {Boolean} cycle
14
+ * @param {number} duration
15
+ */
16
+ curve.evaluate = function(curve, time, value, cycle, duration)
17
+ {
18
+ let count = curve.knots.length;
19
+ if (!count || !curve.dimension || !curve.controls.length) return value;
20
+
21
+ const lastKnot = curve.knots[count - 1];
22
+ if (cycle)
23
+ {
24
+ duration = duration > 0 ? duration : lastKnot;
25
+ if (duration > 0)
26
+ {
27
+ time = ((time % duration) + duration) % duration;
28
+ }
29
+ }
30
+ else if (time <= curve.knots[0] || time >= lastKnot)
31
+ {
32
+ const control = time <= curve.knots[0] ? 0 : count - 1;
33
+ for (let i = 0; i < curve.dimension; ++i)
34
+ {
35
+ value[i] = curve.controls[control * curve.dimension + i];
36
+ }
37
+ return value;
38
+ }
39
+
40
+ let knot = count - 1;
41
+ let t = 0;
42
+ if (cycle && (time < curve.knots[0] || time >= lastKnot))
43
+ {
44
+ knot = 0;
45
+ }
46
+ else for (let i = 0; i < curve.knots.length; ++i)
47
+ {
48
+ if (curve.knots[i] > time)
49
+ {
50
+ knot = i;
51
+ break;
52
+ }
53
+ }
54
+
55
+ if (curve.degree === 0)
56
+ {
57
+ for (let i = 0; i < curve.dimension; ++i)
58
+ {
59
+ value[i] = curve.controls[knot * curve.dimension + i];
60
+ }
61
+ }
62
+ else if (curve.degree === 1)
63
+ {
64
+ const knot0 = cycle ? (knot + count - 1) % count : knot === 0 ? 0 : knot - 1;
65
+ let
66
+ start = curve.knots[knot0],
67
+ end = curve.knots[knot],
68
+ localTime = time;
69
+
70
+ if (cycle && end < start)
71
+ {
72
+ end += duration;
73
+ }
74
+ if (cycle && localTime < start)
75
+ {
76
+ localTime += duration;
77
+ }
78
+ t = end !== start ? (localTime - start) / (end - start) : 0;
79
+
80
+ for (let i = 0; i < curve.dimension; ++i)
81
+ {
82
+ value[i] = curve.controls[knot0 * curve.dimension + i] * (1 - t) + curve.controls[knot * curve.dimension + i] * t;
83
+ }
84
+ }
85
+ else
86
+ {
87
+ let k_2 = cycle ? (knot + count - 2) % count : knot === 0 ? 0 : Math.max(0, knot - 2);
88
+ let k_1 = cycle ? (knot + count - 1) % count : knot === 0 ? 0 : knot - 1;
89
+
90
+ let p1 = (k_2) * curve.dimension;
91
+ let p2 = (k_1) * curve.dimension;
92
+ let p3 = knot * curve.dimension;
93
+
94
+ let ti_2 = curve.knots[k_2];
95
+ let ti_1 = curve.knots[k_1];
96
+ let ti = curve.knots[knot];
97
+ let ti1 = curve.knots[(knot + 1) % count];
98
+
99
+ if (ti_2 > ti)
100
+ {
101
+ ti += duration;
102
+ ti1 += duration;
103
+ time += duration;
104
+ }
105
+
106
+ if (ti_1 > ti)
107
+ {
108
+ ti += duration;
109
+ ti1 += duration;
110
+ time += duration;
111
+ }
112
+
113
+ if (ti1 < ti)
114
+ {
115
+ ti1 += duration;
116
+ }
117
+
118
+ let tmti_1 = (time - ti_1);
119
+ let tmti_2 = (time - ti_2);
120
+ let dL0 = ti - ti_1;
121
+ let dL1_1 = ti - ti_2;
122
+ let dL1_2 = ti1 - ti_1;
123
+
124
+ let L0 = dL0 !== 0 ? tmti_1 / dL0 : 0;
125
+ let L1_1 = dL1_1 !== 0 ? tmti_2 / dL1_1 : 0;
126
+ let L1_2 = dL1_2 !== 0 ? tmti_1 / dL1_2 : 0;
127
+
128
+ let ci_2 = (L1_1 + L0) - L0 * L1_1;
129
+ let ci = L0 * L1_2;
130
+ let ci_1 = ci_2 - ci;
131
+ ci_2 = 1 - ci_2;
132
+
133
+ for (let i = 0; i < curve.dimension; ++i)
134
+ {
135
+ value[i] = ci_2 * curve.controls[p1 + i] + ci_1 * curve.controls[p2 + i] + ci * curve.controls[p3 + i];
136
+ }
137
+ }
138
+ return value;
139
+ };
140
+
141
+ /**
142
+ * ag_horner1
143
+ *
144
+ * @param P
145
+ * @param deg
146
+ * @param s
147
+ * @returns {*}
148
+ */
149
+ curve.ag_horner1 = function(P, deg, s)
150
+ {
151
+ let h = P[deg];
152
+ while (--deg >= 0) h = (s * h) + P[deg];
153
+ return (h);
154
+ };
155
+
156
+ /**
157
+ * ag_zeroin2
158
+ *
159
+ * @param a
160
+ * @param b
161
+ * @param fa
162
+ * @param fb
163
+ * @param tol
164
+ * @param pars
165
+ * @returns {*}
166
+ */
167
+ curve.ag_zeroin2 = function(a, b, fa, fb, tol, pars)
168
+ {
169
+ let test;
170
+ let c, d, e, fc, del, m, machtol, p, q, r, s;
171
+
172
+ /* initialization */
173
+ machtol = 1.192092896e-07;
174
+ let label1 = true;
175
+
176
+ /* start iteration */
177
+ while (true)
178
+ {
179
+ if (label1)
180
+ {
181
+ c = a;
182
+ fc = fa;
183
+ d = b - a;
184
+ e = d;
185
+ }
186
+
187
+ if (Math.abs(fc) < Math.abs(fb))
188
+ {
189
+ a = b;
190
+ b = c;
191
+ c = a;
192
+ fa = fb;
193
+ fb = fc;
194
+ fc = fa;
195
+ }
196
+ label1 = false;
197
+
198
+ /* convergence test */
199
+ del = 2.0 * machtol * Math.abs(b) + 0.5 * tol;
200
+ m = 0.5 * (c - b);
201
+ test = ((Math.abs(m) > del) && (fb !== 0.0));
202
+ if (test)
203
+ {
204
+ if ((Math.abs(e) < del) || (Math.abs(fa) <= Math.abs(fb)))
205
+ {
206
+ /* bisection */
207
+ d = m;
208
+ e = d;
209
+ }
210
+ else
211
+ {
212
+ s = fb / fa;
213
+ if (a === c)
214
+ {
215
+ /* linear interpolation */
216
+ p = 2.0 * m * s;
217
+ q = 1.0 - s;
218
+ }
219
+ else
220
+ {
221
+ /* inverse quadratic interpolation */
222
+ q = fa / fc;
223
+ r = fb / fc;
224
+ p = s * (2.0 * m * q * (q - r) - (b - a) * (r - 1.0));
225
+ q = (q - 1.0) * (r - 1.0) * (s - 1.0);
226
+ }
227
+ /* adjust the sign */
228
+ if (p > 0.0) q = -q;
229
+ else p = -p;
230
+ /* check if interpolation is acceptable */
231
+ s = e;
232
+ e = d;
233
+ if ((2.0 * p < 3.0 * m * q - Math.abs(del * q)) && (p < Math.abs(0.5 * s * q)))
234
+ {
235
+ d = p / q;
236
+ }
237
+ else
238
+ {
239
+ d = m;
240
+ e = d;
241
+ }
242
+ }
243
+ /* complete step */
244
+ a = b;
245
+ fa = fb;
246
+ if (Math.abs(d) > del) b += d;
247
+ else if (m > 0.0) b += del;
248
+ else b -= del;
249
+ fb = curve.ag_horner1(pars.p, pars.deg, b);
250
+ if (fb * (fc / Math.abs(fc)) > 0.0)
251
+ {
252
+ label1 = true;
253
+ }
254
+ }
255
+ else
256
+ {
257
+ break;
258
+ }
259
+ }
260
+ return (b);
261
+ };
262
+
263
+ /**
264
+ * ag_zeroin
265
+ *
266
+ * @param a
267
+ * @param b
268
+ * @param tol
269
+ * @param pars
270
+ * @returns {*}
271
+ */
272
+ curve.ag_zeroin = function(a, b, tol, pars)
273
+ {
274
+ let fa, fb;
275
+
276
+ fa = curve.ag_horner1(pars.p, pars.deg, a);
277
+ if (Math.abs(fa) < 1.192092896e-07) return (a);
278
+
279
+ fb = curve.ag_horner1(pars.p, pars.deg, b);
280
+ if (Math.abs(fb) < 1.192092896e-07) return (b);
281
+
282
+ return (curve.ag_zeroin2(a, b, fa, fb, tol, pars));
283
+ };
284
+
285
+ /**
286
+ * polyZeroes
287
+ *
288
+ * @param Poly
289
+ * @param deg
290
+ * @param a
291
+ * @param a_closed
292
+ * @param b
293
+ * @param b_closed
294
+ * @param Roots
295
+ * @returns {*}
296
+ */
297
+ curve.polyZeroes = function(Poly, deg, a, a_closed, b, b_closed, Roots)
298
+ {
299
+ let i, left_ok, right_ok, nr, ndr, skip;
300
+
301
+ let e, f, s, pe, ps, tol, p, p_x = new Array(22),
302
+ d, d_x = new Array(22),
303
+ dr, dr_x = new Array(22);
304
+
305
+ let ply = {
306
+ p: [],
307
+ deg: 0
308
+ };
309
+
310
+ e = pe = 0.0;
311
+ f = 0.0;
312
+
313
+ for (i = 0; i < deg + 1; ++i)
314
+ {
315
+ f += Math.abs(Poly[i]);
316
+ }
317
+ tol = (Math.abs(a) + Math.abs(b)) * (deg + 1) * 1.192092896e-07;
318
+
319
+ /* Zero polynomial to tolerance? */
320
+ if (f <= tol) return (-1);
321
+
322
+ p = p_x;
323
+ d = d_x;
324
+ dr = dr_x;
325
+ for (i = 0; i < deg + 1; ++i)
326
+ {
327
+ p[i] = 1.0 / f * Poly[i];
328
+ }
329
+
330
+ /* determine true degree */
331
+ while (Math.abs(p[deg]) < tol) deg--;
332
+
333
+ /* Identically zero poly already caught so constant fn !== 0 */
334
+ nr = 0;
335
+ if (deg === 0) return (nr);
336
+
337
+ /* check for linear case */
338
+ if (deg === 1)
339
+ {
340
+ Roots[0] = -p[0] / p[1];
341
+ left_ok = (a_closed) ? (a < Roots[0] + tol) : (a < Roots[0] - tol);
342
+ right_ok = (b_closed) ? (b > Roots[0] - tol) : (b > Roots[0] + tol);
343
+ nr = (left_ok && right_ok) ? 1 : 0;
344
+ if (nr)
345
+ {
346
+ if (a_closed && Roots[0] < a) Roots[0] = a;
347
+ else if (b_closed && Roots[0] > b) Roots[0] = b;
348
+ }
349
+ return nr;
350
+ }
351
+ /* handle non-linear case */
352
+ else
353
+ {
354
+ ply.p = p;
355
+ ply.deg = deg;
356
+
357
+ /* compute derivative */
358
+ for (i = 1; i <= deg; i++) d[i - 1] = i * p[i];
359
+
360
+ /* find roots of derivative */
361
+ ndr = curve.polyZeroes(d, deg - 1, a, 0, b, 0, dr);
362
+ if (ndr.length === 0) return (0);
363
+
364
+ /* find roots between roots of the derivative */
365
+ for (i = skip = 0; i <= ndr; i++)
366
+ {
367
+ if (nr > deg) return (nr);
368
+ if (i === 0)
369
+ {
370
+ s = a;
371
+ ps = curve.ag_horner1(p, deg, s);
372
+ if (Math.abs(ps) <= tol && a_closed) Roots[nr++] = a;
373
+ }
374
+ else
375
+ {
376
+ s = e;
377
+ ps = pe;
378
+ }
379
+ if (i === ndr)
380
+ {
381
+ e = b;
382
+ skip = 0;
383
+ }
384
+ else e = dr[i];
385
+ pe = curve.ag_horner1(p, deg, e);
386
+ if (skip) skip = 0;
387
+ else
388
+ {
389
+ if (Math.abs(pe) < tol)
390
+ {
391
+ if (i !== ndr || b_closed)
392
+ {
393
+ Roots[nr++] = e;
394
+ skip = 1;
395
+ }
396
+ }
397
+ else if ((ps < 0 && pe > 0) || (ps > 0 && pe < 0))
398
+ {
399
+ Roots[nr++] = curve.ag_zeroin(s, e, 0.0, ply);
400
+ if ((nr > 1) && Roots[nr - 2] >= Roots[nr - 1] - tol)
401
+ {
402
+ Roots[nr - 2] = (Roots[nr - 2] + Roots[nr - 1]) * 0.5;
403
+ nr--;
404
+ }
405
+ }
406
+ }
407
+ }
408
+ }
409
+
410
+ return (nr);
411
+ };
412
+
413
+ export const {
414
+ evaluate,
415
+ ag_horner1,
416
+ ag_zeroin2,
417
+ ag_zeroin,
418
+ polyZeroes
419
+ } = curve;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Small DXGI_FORMAT numeric mirror for formats currently needed by readers.
3
+ *
4
+ * Values match the public DXGI_FORMAT enum.
5
+ */
6
+ export const DxgiFormat = Object.freeze({
7
+ UNKNOWN: 0,
8
+ R32G32B32A32_FLOAT: 2,
9
+ R32G32_FLOAT: 16,
10
+ R32_FLOAT: 41,
11
+ R16G16B16A16_FLOAT: 10,
12
+ R8G8_UNORM: 49,
13
+ R8G8B8A8_UNORM: 28,
14
+ R8G8B8A8_UNORM_SRGB: 29,
15
+ R16_FLOAT: 54,
16
+ R8_UNORM: 61,
17
+ BC1_UNORM: 71,
18
+ BC1_UNORM_SRGB: 72,
19
+ BC2_UNORM: 74,
20
+ BC2_UNORM_SRGB: 75,
21
+ BC3_UNORM: 77,
22
+ BC3_UNORM_SRGB: 78,
23
+ BC4_UNORM: 80,
24
+ BC4_SNORM: 81,
25
+ BC5_UNORM: 83,
26
+ BC5_SNORM: 84,
27
+ B8G8R8A8_UNORM: 87,
28
+ B8G8R8X8_UNORM: 88,
29
+ B8G8R8A8_UNORM_SRGB: 91,
30
+ B8G8R8X8_UNORM_SRGB: 93,
31
+ BC6H_UF16: 95,
32
+ BC6H_SF16: 96,
33
+ BC7_UNORM: 98,
34
+ BC7_UNORM_SRGB: 99
35
+ });
36
+
37
+ /**
38
+ * Normalize a DXGI numeric value.
39
+ *
40
+ * @param {number} value Candidate DXGI value.
41
+ * @returns {number} Integer DXGI value or UNKNOWN.
42
+ */
43
+ export function normalizeDxgiFormat(value)
44
+ {
45
+ return Number.isInteger(value) ? value : DxgiFormat.UNKNOWN;
46
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./dxgiFormats.js";
2
+ export * from "./primitiveTopology.js";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * D3D primitive topology numeric mirror for common geometry payloads.
3
+ */
4
+ export const D3dPrimitiveTopology = Object.freeze({
5
+ UNDEFINED: 0,
6
+ POINTLIST: 1,
7
+ LINELIST: 2,
8
+ LINESTRIP: 3,
9
+ TRIANGLELIST: 4,
10
+ TRIANGLESTRIP: 5
11
+ });