@carbonenginejs/runtime-resource 0.11.1 → 0.12.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.
- package/dist/formats/bnk/CjsBnkFormat.js +12 -2
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/graph.js +3 -6
- package/dist/formats/bnk/core/graph.js.map +1 -1
- package/dist/formats/bnk/core/helpers.js +53 -11
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/sfxNodes.js +532 -0
- package/dist/formats/bnk/core/sfxNodes.js.map +1 -0
- package/dist/formats/bnk/core/soundbanksInfo.js +59 -51
- package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -1
- package/dist/formats/gr2/CjsGr2Format.js +256 -13
- package/dist/formats/gr2/CjsGr2Format.js.map +1 -1
- package/dist/formats/gr2/core/helpers.js +15 -15
- package/dist/formats/gr2/core/helpers.js.map +1 -1
- package/dist/formats/gr2/core/json.js +1 -1
- package/dist/formats/gr2/core/json.js.map +1 -1
- package/dist/formats/gr2/core/targets.js +1 -1
- package/dist/formats/gr2/core/targets.js.map +1 -1
- package/dist/formats/gr2/index.js +0 -1
- package/dist/formats/gr2/index.js.map +1 -1
- package/dist/formats/hlsl/core/analysis.js +1 -1
- package/dist/formats/hlsl/index.js +1 -0
- package/dist/formats/hlsl/index.js.map +1 -1
- package/dist/formats/index.js +3 -6
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/webgl/core/cewg/binary.js +3 -3
- package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
- package/dist/formats/webgl/core/effectPackage.js +4 -1
- package/dist/formats/webgl/core/effectPackage.js.map +1 -1
- package/dist/formats/webgl/core/errors.js +3 -3
- package/dist/formats/webgl/core/errors.js.map +1 -1
- package/docs/formats/dxbc/README.md +68 -0
- package/docs/formats/dxbc/architecture.md +80 -0
- package/docs/formats/dxbc/reference/api.md +77 -0
- package/docs/formats/dxbc/reference/classes/README.md +76 -0
- package/docs/formats/dxbc/reference/decoded-output.md +122 -0
- package/docs/formats/gr2.md +3 -4
- package/docs/formats/hlsl/README.md +54 -0
- package/docs/formats/hlsl/architecture.md +67 -0
- package/docs/formats/hlsl/guides/hydrating-json-output.md +62 -0
- package/docs/formats/hlsl/guides/reading-effects.md +64 -0
- package/docs/formats/hlsl/reference/advanced-analysis.md +66 -0
- package/docs/formats/hlsl/reference/api.md +97 -0
- package/docs/formats/hlsl/reference/classes/README.md +16 -0
- package/docs/formats/hlsl/reference/classes/carbon-compatibility.md +66 -0
- package/docs/formats/hlsl/reference/classes/public-api.md +26 -0
- package/docs/formats/hlsl/reference/classes/tr2-effect-model.md +150 -0
- package/docs/formats/hlsl/reference/json-graph.md +100 -0
- package/docs/formats/hlsl/reference/portable-reflection.md +141 -0
- package/docs/formats/provenance.md +9 -4
- package/docs/formats/webgl/README.md +57 -0
- package/docs/formats/webgl/architecture.md +70 -0
- package/docs/formats/webgl/carbon-constant-layouts.md +326 -0
- package/docs/formats/webgl/decl-io.md +1234 -0
- package/docs/formats/webgl/effect-reflection.md +127 -0
- package/docs/formats/webgl/memory-structured.md +871 -0
- package/docs/formats/webgl/reference/classes/README.md +96 -0
- package/docs/formats/webgl/texture-sample.md +964 -0
- package/docs/formats/webgpu/README.md +81 -0
- package/docs/formats/webgpu/architecture.md +93 -0
- package/docs/formats/webgpu/formats/cewgpu.md +479 -0
- package/docs/formats/webgpu/guides/effect-packaging.md +199 -0
- package/docs/formats/webgpu/reference/api.md +197 -0
- package/docs/formats/webgpu/reference/classes/README.md +66 -0
- package/docs/formats/webgpu/reference/wgsl-compatibility.md +1442 -0
- package/docs/formats/wwise.md +16 -1
- package/docs/reference/classes/formats.md +10 -10
- package/format-notices/bnk/NOTICE +5 -4
- package/format-notices/webgl/NOTICE +1 -1
- package/package.json +1 -1
- package/dist/formats/gr2/core/CjsFormatGr2.js +0 -273
- package/dist/formats/gr2/core/CjsFormatGr2.js.map +0 -1
package/docs/formats/wwise.md
CHANGED
|
@@ -19,7 +19,7 @@ names, and the HIRC listing with version-stable typed fields (event action
|
|
|
19
19
|
lists, action type/target, sound and music-track source ids; pinned against
|
|
20
20
|
bank generator version 150). The Wwise-domain toolkit is grouped under the
|
|
21
21
|
`CjsBnkFormat.wwise` static: the SoundbanksInfo catalog helpers, the FNV-1
|
|
22
|
-
id hash,
|
|
22
|
+
id hash, event-to-media resolution, and typed authored-SFX nodes:
|
|
23
23
|
|
|
24
24
|
```js
|
|
25
25
|
import { CjsBnkFormat } from "@carbonenginejs/runtime-resource/formats/bnk";
|
|
@@ -30,6 +30,13 @@ const { eventMedia } = CjsBnkFormat.wwise.eventMediaFromBanks(inspections);
|
|
|
30
30
|
// eventMedia: Map<eventObjectId, Set<wemId>> - banks may split events from
|
|
31
31
|
// their target sounds, so pass every related bank to one call.
|
|
32
32
|
|
|
33
|
+
const {
|
|
34
|
+
nodes,
|
|
35
|
+
events,
|
|
36
|
+
actions,
|
|
37
|
+
diagnostics
|
|
38
|
+
} = CjsBnkFormat.wwise.sfxNodesFromBanks(inspections);
|
|
39
|
+
|
|
33
40
|
const ogg = CjsWemFormat.toOgg(wemBytes); // Wwise Vorbis -> Ogg (lossless)
|
|
34
41
|
const pcm = CjsWemFormat.toPcm(wemBytes); // PTADPCM / 16-bit PCM -> float32
|
|
35
42
|
```
|
|
@@ -38,6 +45,14 @@ The read/inspect path stays a pure container reader;
|
|
|
38
45
|
`wwise.eventMediaFromBanks` is graph interpretation offered for consumers
|
|
39
46
|
with their own engines — the resource lifecycle never calls it.
|
|
40
47
|
|
|
48
|
+
Typed authored-SFX tail decoding is deliberately pinned to bank generator
|
|
49
|
+
version 150. It preserves Random/Sequence, Switch/State, and Layer fields
|
|
50
|
+
without deciding how an audio runtime should lower them. Unsupported versions,
|
|
51
|
+
failed exact-end anchors, ambiguities, and duplicate object identities are
|
|
52
|
+
reported through `diagnostics` instead of being guessed. Like
|
|
53
|
+
`eventMediaFromBanks`, `sfxNodesFromBanks` is consumer-facing graph
|
|
54
|
+
interpretation; the resource lifecycle never calls it.
|
|
55
|
+
|
|
41
56
|
## Related documentation
|
|
42
57
|
|
|
43
58
|
- [Format subpaths](README.md)
|
|
@@ -79,6 +79,16 @@ Little-endian byte cursor over HIRC payload bytes used to decode Wwise interacti
|
|
|
79
79
|
- Visibility: Internal
|
|
80
80
|
- Kind: Internal implementation class
|
|
81
81
|
|
|
82
|
+
<!-- class:SfxCursor -->
|
|
83
|
+
## `SfxCursor`
|
|
84
|
+
|
|
85
|
+
Bounds-aware little-endian cursor used for exact-end Wwise SFX-tail validation.
|
|
86
|
+
|
|
87
|
+
- Export: `None`
|
|
88
|
+
- Source: `src/formats/bnk/core/sfxNodes.js`
|
|
89
|
+
- Visibility: Internal
|
|
90
|
+
- Kind: Internal implementation class
|
|
91
|
+
|
|
82
92
|
### cmf
|
|
83
93
|
|
|
84
94
|
<!-- class:CjsCmfFormat -->
|
|
@@ -285,16 +295,6 @@ Runtime GR2/GSF format class that wraps the migrated `format-gr2` engine under c
|
|
|
285
295
|
- Visibility: Public
|
|
286
296
|
- Kind: Original CarbonEngineJS class
|
|
287
297
|
|
|
288
|
-
<!-- class:CjsFormatGr2 -->
|
|
289
|
-
## `CjsFormatGr2`
|
|
290
|
-
|
|
291
|
-
Migrated GR2/GSF reader that parses Granny files with section decompression, reflected type-tree walking, JSON emission, curve decompression, and caller-class hydration through its core helper modules.
|
|
292
|
-
|
|
293
|
-
- Export: `@carbonenginejs/runtime-resource/formats/gr2`
|
|
294
|
-
- Source: `src/formats/gr2/core/CjsFormatGr2.js`
|
|
295
|
-
- Visibility: Public
|
|
296
|
-
- Kind: Original CarbonEngineJS class
|
|
297
|
-
|
|
298
298
|
<!-- class:Decoder -->
|
|
299
299
|
## `Decoder`
|
|
300
300
|
|
|
@@ -9,10 +9,11 @@ Wwise and the Wwise soundbank format are property of Audiokinetic Inc.
|
|
|
9
9
|
|
|
10
10
|
This reader is original CarbonEngineJS code authored directly in
|
|
11
11
|
runtime-resource; no legacy package was copied. The soundbank chunk layout,
|
|
12
|
-
HIRC object field layouts,
|
|
13
|
-
`eventMediaFromBanks
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
HIRC object field layouts, the event-graph resolution exposed as
|
|
13
|
+
`eventMediaFromBanks`, and the typed version-150 authored-SFX node tails
|
|
14
|
+
exposed as `sfxNodesFromBanks` were implemented from publicly documented
|
|
15
|
+
community knowledge of the format (ww2ogg, vgmstream, wwiser documentation)
|
|
16
|
+
and independently verified by hexdump against EVE Online soundbanks (bank
|
|
16
17
|
generator version 150); no code was copied from those projects and no
|
|
17
18
|
Audiokinetic SDK material was used.
|
|
18
19
|
Audiokinetic, CarbonEngine, and Fenris Creations (CCP Games) are mentioned for
|
|
@@ -9,7 +9,7 @@ Contains no Microsoft, CarbonEngine, or Fenris Creations (CCP Games) code. The C
|
|
|
9
9
|
four-byte-tagged chunk layout: `INFO`/`META`/`GLSL`/...) is a CarbonEngineJS
|
|
10
10
|
invention, not a Microsoft, CarbonEngine, or Fenris Creations (CCP Games) one. The DXBC token-stream layout follows
|
|
11
11
|
Microsoft's public d3d11TokenizedProgramFormat documentation (consumed here
|
|
12
|
-
only through
|
|
12
|
+
only through the sibling `formats/dxbc` public format; this format
|
|
13
13
|
decodes no DXBC bytes itself). Unity Technologies' HLSLcc (MIT) was used as
|
|
14
14
|
a behavioral reference while auditing the GLSL lowering rules this emitter
|
|
15
15
|
implements; no HLSLcc source is included in this repository.
|
package/package.json
CHANGED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import { curves } from './curves.js';
|
|
2
|
-
import { tangents } from './tangents.js';
|
|
3
|
-
import { isGsfRaw, projectGsf, inspectGsfRaw } from './gsf.js';
|
|
4
|
-
import { DEFAULT_VALUES, normalizeValues, validateClassKey, validateClass, readWithValues, readRawInput, inspectRawGr2Result, toJsonValue, OUTPUT_JSON, OUTPUT_GR2, OUTPUT_GR2_JSON, OUTPUT_CMF, OUTPUT_RAW, CLASS_KEYS } from './helpers.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Exposed CarbonEngineJS-facing GR2 format class.
|
|
8
|
-
*
|
|
9
|
-
* Keep this file small and reviewable: parsing, conversion, rebuild, and JSON
|
|
10
|
-
* helper glue live in core/helpers.js.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* CarbonEngineJS-facing GR2 reader.
|
|
16
|
-
*
|
|
17
|
-
* The Cjs prefix marks this as a JavaScript format/construction boundary. It
|
|
18
|
-
* can emit plain GR2 JSON data or hydrate caller-supplied CarbonEngineJS-style
|
|
19
|
-
* classes without pretending those classes are the engine runtime itself.
|
|
20
|
-
*/
|
|
21
|
-
class CjsFormatGr2 {
|
|
22
|
-
#emit = DEFAULT_VALUES.emit;
|
|
23
|
-
#decompressCurves = DEFAULT_VALUES.decompressCurves;
|
|
24
|
-
#unpackTangents = DEFAULT_VALUES.unpackTangents;
|
|
25
|
-
#rebuildMissingNormals = DEFAULT_VALUES.rebuildMissingNormals;
|
|
26
|
-
#rebuildMissingTangents = DEFAULT_VALUES.rebuildMissingTangents;
|
|
27
|
-
#rebuildMissingBiNormals = DEFAULT_VALUES.rebuildMissingBiNormals;
|
|
28
|
-
#classes = {};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Create a reusable format profile.
|
|
32
|
-
*
|
|
33
|
-
* @param {object} [options] Default format/build values.
|
|
34
|
-
*/
|
|
35
|
-
constructor(options = {}) {
|
|
36
|
-
this.SetValues(options);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Set format values for this reusable profile.
|
|
41
|
-
*
|
|
42
|
-
* @param {object} [options] Values to merge into the profile.
|
|
43
|
-
* @returns {CjsFormatGr2} This format profile.
|
|
44
|
-
*/
|
|
45
|
-
SetValues(options = {}) {
|
|
46
|
-
const values = normalizeValues(this.GetValues(), options);
|
|
47
|
-
this.#emit = values.emit;
|
|
48
|
-
this.#decompressCurves = values.decompressCurves;
|
|
49
|
-
this.#unpackTangents = values.unpackTangents;
|
|
50
|
-
this.#rebuildMissingNormals = values.rebuildMissingNormals;
|
|
51
|
-
this.#rebuildMissingTangents = values.rebuildMissingTangents;
|
|
52
|
-
this.#rebuildMissingBiNormals = values.rebuildMissingBiNormals;
|
|
53
|
-
this.#classes = values.classes;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Get this profile's current values, optionally with per-call overrides.
|
|
59
|
-
*
|
|
60
|
-
* @param {object} [options] Optional values to merge into a copy.
|
|
61
|
-
* @returns {object} A copy of the effective values.
|
|
62
|
-
*/
|
|
63
|
-
GetValues(options = {}) {
|
|
64
|
-
return normalizeValues({
|
|
65
|
-
emit: this.#emit,
|
|
66
|
-
decompressCurves: this.#decompressCurves,
|
|
67
|
-
unpackTangents: this.#unpackTangents,
|
|
68
|
-
rebuildMissingNormals: this.#rebuildMissingNormals,
|
|
69
|
-
rebuildMissingTangents: this.#rebuildMissingTangents,
|
|
70
|
-
rebuildMissingBiNormals: this.#rebuildMissingBiNormals,
|
|
71
|
-
classes: this.#classes
|
|
72
|
-
}, options);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Set multiple GR2 JSON node constructors for this profile.
|
|
77
|
-
*
|
|
78
|
-
* @param {object} [classes] Map of node class keys to constructors.
|
|
79
|
-
* @returns {CjsFormatGr2} This format profile.
|
|
80
|
-
*/
|
|
81
|
-
SetClasses(classes = {}) {
|
|
82
|
-
return this.SetValues({
|
|
83
|
-
classes
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Set a GR2 JSON node constructor for this profile.
|
|
89
|
-
*
|
|
90
|
-
* @param {string} type Node class key.
|
|
91
|
-
* @param {Function|null|undefined} Class Constructor to use, or nullish to delete.
|
|
92
|
-
* @returns {CjsFormatGr2} This format profile.
|
|
93
|
-
*/
|
|
94
|
-
SetClass(type, Class) {
|
|
95
|
-
validateClassKey(type);
|
|
96
|
-
if (Class === null || Class === undefined) {
|
|
97
|
-
delete this.#classes[type];
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
validateClass(type, Class);
|
|
101
|
-
this.#classes = {
|
|
102
|
-
...this.#classes,
|
|
103
|
-
[type]: Class
|
|
104
|
-
};
|
|
105
|
-
return this;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Get a configured GR2 JSON node constructor.
|
|
110
|
-
*
|
|
111
|
-
* @param {string} type Node class key.
|
|
112
|
-
* @returns {Function|undefined}
|
|
113
|
-
*/
|
|
114
|
-
GetClass(type) {
|
|
115
|
-
validateClassKey(type);
|
|
116
|
-
return this.#classes[type];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Whether this reader has a constructor for a GR2 JSON node key.
|
|
121
|
-
*
|
|
122
|
-
* @param {string} type Node class key.
|
|
123
|
-
* @returns {boolean}
|
|
124
|
-
*/
|
|
125
|
-
HasClass(type) {
|
|
126
|
-
return !!this.GetClass(type);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Parse a .gr2 buffer and return JSON by default, classes when configured,
|
|
131
|
-
* or raw reflection data when `emit` is "raw".
|
|
132
|
-
*
|
|
133
|
-
* @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.
|
|
134
|
-
* @param {object} [options] Per-call values.
|
|
135
|
-
* @returns {object}
|
|
136
|
-
*/
|
|
137
|
-
Read(input, options = {}) {
|
|
138
|
-
return readWithValues(this, input, this.GetValues(options));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Parse a .gr2 buffer into the reflected Granny object graph.
|
|
143
|
-
*
|
|
144
|
-
* @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.
|
|
145
|
-
* @returns {object}
|
|
146
|
-
*/
|
|
147
|
-
ReadRaw(input) {
|
|
148
|
-
return readRawInput(input);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Return a stable, lightweight summary for a GR2 buffer or raw result.
|
|
153
|
-
*
|
|
154
|
-
* @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.
|
|
155
|
-
* @returns {object}
|
|
156
|
-
*/
|
|
157
|
-
Inspect(input) {
|
|
158
|
-
return inspectRawGr2Result(this.ReadRaw(input));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** Whether input is a Granny State document carried by the GR2 container. */
|
|
162
|
-
IsGSF(input) {
|
|
163
|
-
return isGsfRaw(this.ReadRaw(input));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/** Read the GState semantic projection, or raw reflected data with `emit: "raw"`. */
|
|
167
|
-
ReadGSF(input, options = {}) {
|
|
168
|
-
const raw = this.ReadRaw(input);
|
|
169
|
-
return options.emit === "raw" ? raw : projectGsf(raw);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** Inspect a GSF document and its referenced GR2 animations. */
|
|
173
|
-
InspectGSF(input) {
|
|
174
|
-
return inspectGsfRaw(this.ReadRaw(input));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Convert format output to plain JSON-compatible data.
|
|
179
|
-
*
|
|
180
|
-
* @param {object} value Format output to convert.
|
|
181
|
-
* @returns {any} Plain JSON-compatible data.
|
|
182
|
-
*/
|
|
183
|
-
ToJSON(value) {
|
|
184
|
-
return toJsonValue(value);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Static one-shot read. Static methods use camelCase by convention.
|
|
189
|
-
*
|
|
190
|
-
* @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.
|
|
191
|
-
* @param {object} [options] Reader and post-processing values.
|
|
192
|
-
* @returns {object}
|
|
193
|
-
*/
|
|
194
|
-
static read(input, options = {}) {
|
|
195
|
-
return readWithValues(CjsFormatGr2, input, normalizeValues(DEFAULT_VALUES, options));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Static one-shot raw read.
|
|
200
|
-
*
|
|
201
|
-
* @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.
|
|
202
|
-
* @returns {object}
|
|
203
|
-
*/
|
|
204
|
-
static readRaw(input) {
|
|
205
|
-
return readRawInput(input);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Static one-shot inspection.
|
|
210
|
-
*
|
|
211
|
-
* @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.
|
|
212
|
-
* @returns {object}
|
|
213
|
-
*/
|
|
214
|
-
static inspect(input) {
|
|
215
|
-
return inspectRawGr2Result(readRawInput(input));
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/** Whether input is a Granny State document carried by the GR2 container. */
|
|
219
|
-
static isGsf(input) {
|
|
220
|
-
try {
|
|
221
|
-
return isGsfRaw(readRawInput(input));
|
|
222
|
-
} catch {
|
|
223
|
-
return false;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/** Read the GState semantic projection, or raw reflected data with `emit: "raw"`. */
|
|
228
|
-
static readGsf(input, options = {}) {
|
|
229
|
-
const raw = readRawInput(input);
|
|
230
|
-
return options.emit === "raw" ? raw : projectGsf(raw);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/** Async one-shot GSF read for standard format API compatibility. */
|
|
234
|
-
static readGsfAsync(input, options = {}) {
|
|
235
|
-
return Promise.resolve(this.readGsf(input, options));
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/** Inspect a GSF document and its referenced GR2 animations. */
|
|
239
|
-
static inspectGsf(input) {
|
|
240
|
-
return inspectGsfRaw(readRawInput(input));
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Static JSON-compatible conversion.
|
|
245
|
-
*
|
|
246
|
-
* @param {object} value Format output to convert.
|
|
247
|
-
* @returns {any} Plain JSON-compatible data.
|
|
248
|
-
*/
|
|
249
|
-
static toJSON(value) {
|
|
250
|
-
return toJsonValue(value);
|
|
251
|
-
}
|
|
252
|
-
static OUTPUT_JSON = OUTPUT_JSON;
|
|
253
|
-
static OUTPUT_GR2 = OUTPUT_GR2;
|
|
254
|
-
static OUTPUT_GR2_JSON = OUTPUT_GR2_JSON;
|
|
255
|
-
static OUTPUT_CMF = OUTPUT_CMF;
|
|
256
|
-
static OUTPUT_RAW = OUTPUT_RAW;
|
|
257
|
-
static CLASS_KEYS = CLASS_KEYS;
|
|
258
|
-
static type = Object.freeze(["geometry"]);
|
|
259
|
-
static mediaTypes = Object.freeze(["geometry"]);
|
|
260
|
-
static inputTypes = Object.freeze(["gr2", "gsf"]);
|
|
261
|
-
static outputTypes = Object.freeze([OUTPUT_GR2, OUTPUT_CMF]);
|
|
262
|
-
static debugOutputTypes = Object.freeze([OUTPUT_JSON, OUTPUT_GR2_JSON, OUTPUT_RAW]);
|
|
263
|
-
static curves = curves;
|
|
264
|
-
static tangents = tangents;
|
|
265
|
-
static gsf = Object.freeze({
|
|
266
|
-
isRaw: isGsfRaw,
|
|
267
|
-
project: projectGsf,
|
|
268
|
-
inspectRaw: inspectGsfRaw
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export { CjsFormatGr2 };
|
|
273
|
-
//# sourceMappingURL=CjsFormatGr2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CjsFormatGr2.js","sources":["../../../../../src/formats/gr2/core/CjsFormatGr2.js"],"sourcesContent":["/**\n * Exposed CarbonEngineJS-facing GR2 format class.\n *\n * Keep this file small and reviewable: parsing, conversion, rebuild, and JSON\n * helper glue live in core/helpers.js.\n */\n\nimport { curves } from \"./curves.js\";\nimport { tangents } from \"./tangents.js\";\nimport { inspectGsfRaw, isGsfRaw, projectGsf } from \"./gsf.js\";\nimport {\n CLASS_KEYS,\n DEFAULT_VALUES,\n OUTPUT_CMF,\n OUTPUT_GR2,\n OUTPUT_GR2_JSON,\n OUTPUT_JSON,\n OUTPUT_RAW,\n inspectRawGr2Result,\n normalizeValues,\n readRawInput,\n readWithValues,\n toJsonValue,\n validateClass,\n validateClassKey\n} from \"./helpers.js\";\n\n/**\n * CarbonEngineJS-facing GR2 reader.\n *\n * The Cjs prefix marks this as a JavaScript format/construction boundary. It\n * can emit plain GR2 JSON data or hydrate caller-supplied CarbonEngineJS-style\n * classes without pretending those classes are the engine runtime itself.\n */\nexport class CjsFormatGr2\n{\n\n #emit = DEFAULT_VALUES.emit;\n #decompressCurves = DEFAULT_VALUES.decompressCurves;\n #unpackTangents = DEFAULT_VALUES.unpackTangents;\n #rebuildMissingNormals = DEFAULT_VALUES.rebuildMissingNormals;\n #rebuildMissingTangents = DEFAULT_VALUES.rebuildMissingTangents;\n #rebuildMissingBiNormals = DEFAULT_VALUES.rebuildMissingBiNormals;\n #classes = {};\n\n /**\n * Create a reusable format profile.\n *\n * @param {object} [options] Default format/build values.\n */\n constructor(options = {})\n {\n this.SetValues(options);\n }\n\n /**\n * Set format values for this reusable profile.\n *\n * @param {object} [options] Values to merge into the profile.\n * @returns {CjsFormatGr2} This format profile.\n */\n SetValues(options = {})\n {\n const values = normalizeValues(this.GetValues(), options);\n\n this.#emit = values.emit;\n this.#decompressCurves = values.decompressCurves;\n this.#unpackTangents = values.unpackTangents;\n this.#rebuildMissingNormals = values.rebuildMissingNormals;\n this.#rebuildMissingTangents = values.rebuildMissingTangents;\n this.#rebuildMissingBiNormals = values.rebuildMissingBiNormals;\n this.#classes = values.classes;\n\n return this;\n }\n\n /**\n * Get this profile's current values, optionally with per-call overrides.\n *\n * @param {object} [options] Optional values to merge into a copy.\n * @returns {object} A copy of the effective values.\n */\n GetValues(options = {})\n {\n return normalizeValues({\n emit: this.#emit,\n decompressCurves: this.#decompressCurves,\n unpackTangents: this.#unpackTangents,\n rebuildMissingNormals: this.#rebuildMissingNormals,\n rebuildMissingTangents: this.#rebuildMissingTangents,\n rebuildMissingBiNormals: this.#rebuildMissingBiNormals,\n classes: this.#classes\n }, options);\n }\n\n /**\n * Set multiple GR2 JSON node constructors for this profile.\n *\n * @param {object} [classes] Map of node class keys to constructors.\n * @returns {CjsFormatGr2} This format profile.\n */\n SetClasses(classes = {})\n {\n return this.SetValues({ classes });\n }\n\n /**\n * Set a GR2 JSON node constructor for this profile.\n *\n * @param {string} type Node class key.\n * @param {Function|null|undefined} Class Constructor to use, or nullish to delete.\n * @returns {CjsFormatGr2} This format profile.\n */\n SetClass(type, Class)\n {\n validateClassKey(type);\n if (Class === null || Class === undefined)\n {\n delete this.#classes[type];\n return this;\n }\n\n validateClass(type, Class);\n this.#classes = { ...this.#classes, [type]: Class };\n return this;\n }\n\n /**\n * Get a configured GR2 JSON node constructor.\n *\n * @param {string} type Node class key.\n * @returns {Function|undefined}\n */\n GetClass(type)\n {\n validateClassKey(type);\n return this.#classes[type];\n }\n\n /**\n * Whether this reader has a constructor for a GR2 JSON node key.\n *\n * @param {string} type Node class key.\n * @returns {boolean}\n */\n HasClass(type)\n {\n return !!this.GetClass(type);\n }\n\n /**\n * Parse a .gr2 buffer and return JSON by default, classes when configured,\n * or raw reflection data when `emit` is \"raw\".\n *\n * @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.\n * @param {object} [options] Per-call values.\n * @returns {object}\n */\n Read(input, options = {})\n {\n return readWithValues(this, input, this.GetValues(options));\n }\n\n /**\n * Parse a .gr2 buffer into the reflected Granny object graph.\n *\n * @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.\n * @returns {object}\n */\n ReadRaw(input)\n {\n return readRawInput(input);\n }\n\n /**\n * Return a stable, lightweight summary for a GR2 buffer or raw result.\n *\n * @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.\n * @returns {object}\n */\n Inspect(input)\n {\n return inspectRawGr2Result(this.ReadRaw(input));\n }\n\n /** Whether input is a Granny State document carried by the GR2 container. */\n IsGSF(input)\n {\n return isGsfRaw(this.ReadRaw(input));\n }\n\n /** Read the GState semantic projection, or raw reflected data with `emit: \"raw\"`. */\n ReadGSF(input, options = {})\n {\n const raw = this.ReadRaw(input);\n return options.emit === \"raw\" ? raw : projectGsf(raw);\n }\n\n /** Inspect a GSF document and its referenced GR2 animations. */\n InspectGSF(input)\n {\n return inspectGsfRaw(this.ReadRaw(input));\n }\n\n /**\n * Convert format output to plain JSON-compatible data.\n *\n * @param {object} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n ToJSON(value)\n {\n return toJsonValue(value);\n }\n\n /**\n * Static one-shot read. Static methods use camelCase by convention.\n *\n * @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.\n * @param {object} [options] Reader and post-processing values.\n * @returns {object}\n */\n static read(input, options = {})\n {\n return readWithValues(CjsFormatGr2, input, normalizeValues(DEFAULT_VALUES, options));\n }\n\n /**\n * Static one-shot raw read.\n *\n * @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.\n * @returns {object}\n */\n static readRaw(input)\n {\n return readRawInput(input);\n }\n\n /**\n * Static one-shot inspection.\n *\n * @param {Uint8Array|Buffer|object} input Raw .gr2 bytes or an existing raw read result.\n * @returns {object}\n */\n static inspect(input)\n {\n return inspectRawGr2Result(readRawInput(input));\n }\n\n /** Whether input is a Granny State document carried by the GR2 container. */\n static isGsf(input)\n {\n try\n {\n return isGsfRaw(readRawInput(input));\n }\n catch\n {\n return false;\n }\n }\n\n /** Read the GState semantic projection, or raw reflected data with `emit: \"raw\"`. */\n static readGsf(input, options = {})\n {\n const raw = readRawInput(input);\n return options.emit === \"raw\" ? raw : projectGsf(raw);\n }\n\n /** Async one-shot GSF read for standard format API compatibility. */\n static readGsfAsync(input, options = {})\n {\n return Promise.resolve(this.readGsf(input, options));\n }\n\n /** Inspect a GSF document and its referenced GR2 animations. */\n static inspectGsf(input)\n {\n return inspectGsfRaw(readRawInput(input));\n }\n\n /**\n * Static JSON-compatible conversion.\n *\n * @param {object} value Format output to convert.\n * @returns {any} Plain JSON-compatible data.\n */\n static toJSON(value)\n {\n return toJsonValue(value);\n }\n\n static OUTPUT_JSON = OUTPUT_JSON;\n static OUTPUT_GR2 = OUTPUT_GR2;\n static OUTPUT_GR2_JSON = OUTPUT_GR2_JSON;\n static OUTPUT_CMF = OUTPUT_CMF;\n static OUTPUT_RAW = OUTPUT_RAW;\n static CLASS_KEYS = CLASS_KEYS;\n static type = Object.freeze([ \"geometry\" ]);\n static mediaTypes = Object.freeze([ \"geometry\" ]);\n static inputTypes = Object.freeze([ \"gr2\", \"gsf\" ]);\n static outputTypes = Object.freeze([ OUTPUT_GR2, OUTPUT_CMF ]);\n static debugOutputTypes = Object.freeze([ OUTPUT_JSON, OUTPUT_GR2_JSON, OUTPUT_RAW ]);\n static curves = curves;\n static tangents = tangents;\n static gsf = Object.freeze({ isRaw: isGsfRaw, project: projectGsf, inspectRaw: inspectGsfRaw });\n\n}\n\nexport default CjsFormatGr2;\n"],"names":["CjsFormatGr2","DEFAULT_VALUES","emit","decompressCurves","unpackTangents","rebuildMissingNormals","rebuildMissingTangents","rebuildMissingBiNormals","constructor","options","SetValues","values","normalizeValues","GetValues","classes","SetClasses","SetClass","type","Class","validateClassKey","undefined","validateClass","GetClass","HasClass","Read","input","readWithValues","ReadRaw","readRawInput","Inspect","inspectRawGr2Result","IsGSF","isGsfRaw","ReadGSF","raw","projectGsf","InspectGSF","inspectGsfRaw","ToJSON","value","toJsonValue","read","readRaw","inspect","isGsf","readGsf","readGsfAsync","Promise","resolve","inspectGsf","toJSON","OUTPUT_JSON","OUTPUT_GR2","OUTPUT_GR2_JSON","OUTPUT_CMF","OUTPUT_RAW","CLASS_KEYS","Object","freeze","mediaTypes","inputTypes","outputTypes","debugOutputTypes","curves","tangents","gsf","isRaw","project","inspectRaw"],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