@carbonenginejs/runtime-utils 0.1.1 → 0.1.3

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 (104) hide show
  1. package/LICENSE +21 -21
  2. package/NOTICE +23 -23
  3. package/README.md +69 -69
  4. package/THIRD-PARTY-NOTICES.md +64 -64
  5. package/docs/README.md +74 -73
  6. package/docs/architecture.md +101 -101
  7. package/docs/concepts/foundation-consolidation.md +85 -85
  8. package/docs/concepts/model-lifecycle.md +111 -0
  9. package/docs/const-kb.md +85 -87
  10. package/docs/core-types/DECORATOR-TODOS.md +25 -25
  11. package/docs/core-types/README.md +229 -168
  12. package/docs/reference/api.md +105 -102
  13. package/docs/reference/classes/README.md +135 -135
  14. package/package.json +139 -139
  15. package/src/arrays.js +5 -5
  16. package/src/audio/audioFormats.js +34 -34
  17. package/src/audio/index.js +1 -1
  18. package/src/box3.js +331 -331
  19. package/src/bytes.js +56 -56
  20. package/src/compression.js +56 -56
  21. package/src/constants/index.js +7 -7
  22. package/src/constants/trinity.js +13 -13
  23. package/src/constants.js +15 -15
  24. package/src/curve.js +79 -79
  25. package/src/d3d/dxgiFormats.js +46 -46
  26. package/src/d3d/index.js +2 -2
  27. package/src/d3d/primitiveTopology.js +11 -11
  28. package/src/document/CjsCarbonDocument.js +212 -212
  29. package/src/document/CjsClassRegistry.js +373 -373
  30. package/src/document/CjsDocumentDehydrator.js +142 -142
  31. package/src/document/CjsDocumentHydrator.js +156 -156
  32. package/src/document/CjsStructRegistry.js +348 -348
  33. package/src/document/hydrationAdapter.js +129 -129
  34. package/src/document/index.js +6 -6
  35. package/src/errors/CjsError.js +286 -286
  36. package/src/errors/index.js +5 -5
  37. package/src/geometry/box.js +22 -22
  38. package/src/geometry/cylinder.js +22 -22
  39. package/src/geometry/helpers/earcut.js +1 -1
  40. package/src/geometry/helpers/misc.js +3 -3
  41. package/src/geometry/index.js +8 -8
  42. package/src/geometry/json.js +67 -67
  43. package/src/geometry/lathe.js +44 -44
  44. package/src/geometry/plane.js +14 -14
  45. package/src/geometry/shape.js +4 -4
  46. package/src/geometry/sphere.js +24 -24
  47. package/src/geometry/torus.js +14 -14
  48. package/src/graphics/colorSpaces.js +22 -22
  49. package/src/graphics/index.js +4 -4
  50. package/src/graphics/pixelFormats.js +158 -158
  51. package/src/graphics/textureDimensions.js +22 -22
  52. package/src/graphics/trinityEnums.js +87 -87
  53. package/src/index.js +62 -62
  54. package/src/is.js +108 -46
  55. package/src/json.js +23 -23
  56. package/src/lifecycle/CjsLifecycleState.js +77 -77
  57. package/src/lifecycle/index.js +1 -1
  58. package/src/lne3.js +70 -70
  59. package/src/lookup.js +48 -48
  60. package/src/mat3.js +51 -51
  61. package/src/mat4.js +699 -699
  62. package/src/math/index.js +25 -25
  63. package/src/math/scalar.js +63 -63
  64. package/src/media/index.js +1 -1
  65. package/src/media/mediaTypes.js +50 -50
  66. package/src/mesh.js +424 -424
  67. package/src/model/CjsEventEmitter.js +333 -333
  68. package/src/model/CjsModel.js +1589 -1544
  69. package/src/model/CjsModelState.js +72 -72
  70. package/src/model/index.js +4 -4
  71. package/src/model/sourceRecordUtils.js +54 -54
  72. package/src/noise.js +310 -310
  73. package/src/num.js +827 -827
  74. package/src/object.js +39 -39
  75. package/src/path.js +53 -53
  76. package/src/pln.js +125 -125
  77. package/src/pool.js +9 -9
  78. package/src/quat.js +144 -144
  79. package/src/ray3.js +188 -188
  80. package/src/renderContext/formats.js +145 -145
  81. package/src/renderContext/index.js +5 -5
  82. package/src/renderContext/presentation.js +125 -125
  83. package/src/renderContext/resources.js +27 -27
  84. package/src/renderContext/upscaling.js +22 -22
  85. package/src/renderContext/window.js +20 -20
  86. package/src/runtime/CjsRuntimeState.js +50 -50
  87. package/src/schema/CjsSchema.js +555 -318
  88. package/src/schema/index.js +4 -4
  89. package/src/shader/index.js +1 -1
  90. package/src/shader/shaderStages.js +37 -37
  91. package/src/sph3.js +181 -181
  92. package/src/tangent.js +288 -288
  93. package/src/text.js +40 -40
  94. package/src/tri3.js +98 -98
  95. package/src/types/carbonTypes.js +635 -635
  96. package/src/types/index.js +2 -2
  97. package/src/utils.js +58 -58
  98. package/src/validation.js +46 -46
  99. package/src/vec2.js +229 -229
  100. package/src/vec3.js +1188 -1172
  101. package/src/vec4.js +347 -347
  102. package/src/vertex.js +108 -108
  103. package/src/webgpu/index.js +1 -1
  104. package/src/webgpu/textureFormats.js +121 -121
package/src/bytes.js CHANGED
@@ -1,56 +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
- }
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
+ }
@@ -1,56 +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
- }
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
+ }
@@ -1,7 +1,7 @@
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";
7
- export * from "./trinity.js";
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";
7
+ export * from "./trinity.js";
@@ -1,13 +1,13 @@
1
- // Source: trinity/trinity/Resources/Tr2LodResource.h
2
-
3
- /**
4
- * Shared Trinity level-of-detail values.
5
- */
6
- export const Tr2Lod = Object.freeze({
7
- TR2_LOD_UNSPECIFIED: -1,
8
- TR2_LOD_LOW: 0,
9
- TR2_LOD_MEDIUM: 1,
10
- TR2_LOD_HIGH: 2,
11
- TR2_LOD_ULTRA: 3,
12
- TR2_LOD_COUNT: 4
13
- });
1
+ // Source: trinity/trinity/Resources/Tr2LodResource.h
2
+
3
+ /**
4
+ * Shared Trinity level-of-detail values.
5
+ */
6
+ export const Tr2Lod = Object.freeze({
7
+ TR2_LOD_UNSPECIFIED: -1,
8
+ TR2_LOD_LOW: 0,
9
+ TR2_LOD_MEDIUM: 1,
10
+ TR2_LOD_HIGH: 2,
11
+ TR2_LOD_ULTRA: 3,
12
+ TR2_LOD_COUNT: 4
13
+ });
package/src/constants.js CHANGED
@@ -1,15 +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;
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 CHANGED
@@ -13,42 +13,42 @@ export const curve = {};
13
13
  * @param {Boolean} cycle
14
14
  * @param {number} duration
15
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;
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
52
  }
53
53
  }
54
54
 
@@ -59,32 +59,32 @@ curve.evaluate = function(curve, time, value, cycle, duration)
59
59
  value[i] = curve.controls[knot * curve.dimension + i];
60
60
  }
61
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)
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
81
  {
82
82
  value[i] = curve.controls[knot0 * curve.dimension + i] * (1 - t) + curve.controls[knot * curve.dimension + i] * t;
83
83
  }
84
84
  }
85
- else
86
- {
87
- let k_2 = cycle ? (knot + count - 2) % count : knot === 0 ? 0 : Math.max(0, knot - 2);
85
+ else
86
+ {
87
+ let k_2 = cycle ? (knot + count - 2) % count : knot === 0 ? 0 : Math.max(0, knot - 2);
88
88
  let k_1 = cycle ? (knot + count - 1) % count : knot === 0 ? 0 : knot - 1;
89
89
 
90
90
  let p1 = (k_2) * curve.dimension;
@@ -121,9 +121,9 @@ curve.evaluate = function(curve, time, value, cycle, duration)
121
121
  let dL1_1 = ti - ti_2;
122
122
  let dL1_2 = ti1 - ti_1;
123
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;
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
127
 
128
128
  let ci_2 = (L1_1 + L0) - L0 * L1_1;
129
129
  let ci = L0 * L1_2;
@@ -132,11 +132,11 @@ curve.evaluate = function(curve, time, value, cycle, duration)
132
132
 
133
133
  for (let i = 0; i < curve.dimension; ++i)
134
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
- };
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
140
 
141
141
  /**
142
142
  * ag_horner1
@@ -294,8 +294,8 @@ curve.ag_zeroin = function(a, b, tol, pars)
294
294
  * @param Roots
295
295
  * @returns {*}
296
296
  */
297
- curve.polyZeroes = function(Poly, deg, a, a_closed, b, b_closed, Roots)
298
- {
297
+ curve.polyZeroes = function(Poly, deg, a, a_closed, b, b_closed, Roots)
298
+ {
299
299
  let i, left_ok, right_ok, nr, ndr, skip;
300
300
 
301
301
  let e, f, s, pe, ps, tol, p, p_x = new Array(22),
@@ -406,14 +406,14 @@ curve.polyZeroes = function(Poly, deg, a, a_closed, b, b_closed, Roots)
406
406
  }
407
407
  }
408
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;
409
+
410
+ return (nr);
411
+ };
412
+
413
+ export const {
414
+ evaluate,
415
+ ag_horner1,
416
+ ag_zeroin2,
417
+ ag_zeroin,
418
+ polyZeroes
419
+ } = curve;
@@ -1,46 +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
- }
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
+ }
package/src/d3d/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./dxgiFormats.js";
2
- export * from "./primitiveTopology.js";
1
+ export * from "./dxgiFormats.js";
2
+ export * from "./primitiveTopology.js";
@@ -1,11 +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
- });
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
+ });