@carbonenginejs/runtime 0.1.0-alpha.1 → 0.1.0-alpha.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 (49) hide show
  1. package/dist/global/model/CjsModel.js +3 -1
  2. package/dist/global/model/CjsModel.js.map +1 -1
  3. package/dist/global/model/document/CjsDocumentHydrator.js +5 -1
  4. package/dist/global/model/document/CjsDocumentHydrator.js.map +1 -1
  5. package/dist/global/schema/CjsSchema.js +100 -2
  6. package/dist/global/schema/CjsSchema.js.map +1 -1
  7. package/dist/global/schema/hydration.js +16 -0
  8. package/dist/global/schema/hydration.js.map +1 -1
  9. package/dist/index.js +2 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/resource/CjsResMan.js +177 -4
  12. package/dist/resource/CjsResMan.js.map +1 -1
  13. package/dist/resource/format/CjsBlueReader.js +8 -1
  14. package/dist/resource/format/CjsBlueReader.js.map +1 -1
  15. package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js +23 -5
  16. package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
  17. package/dist/resource/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +12 -3
  18. package/dist/resource/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -1
  19. package/dist/resource/index.js +2 -0
  20. package/dist/resource/index.js.map +1 -1
  21. package/dist/resource/texture/SolidColorTextureConstructor.js +46 -0
  22. package/dist/resource/texture/SolidColorTextureConstructor.js.map +1 -0
  23. package/dist/resource/texture/TriTextureRes.js +43 -0
  24. package/dist/resource/texture/TriTextureRes.js.map +1 -1
  25. package/dist/resource/texture/index.js +2 -0
  26. package/dist/resource/texture/index.js.map +1 -1
  27. package/dist/resource/texture/solidColorTexture.js +111 -0
  28. package/dist/resource/texture/solidColorTexture.js.map +1 -0
  29. package/dist/trinity/eve/attachment/decal/EveSpaceObjectDecal.js +19 -8
  30. package/dist/trinity/eve/attachment/decal/EveSpaceObjectDecal.js.map +1 -1
  31. package/dist/trinity/eve/child/EveChildMesh.js +17 -3
  32. package/dist/trinity/eve/child/EveChildMesh.js.map +1 -1
  33. package/dist/trinity/eve/locator/EveLocatorSets.js +12 -3
  34. package/dist/trinity/eve/locator/EveLocatorSets.js.map +1 -1
  35. package/dist/trinity/eve/spaceObject/EveSpaceObject2.js +15 -2
  36. package/dist/trinity/eve/spaceObject/EveSpaceObject2.js.map +1 -1
  37. package/dist/trinity/eve/spaceObject/IEveSpaceObject2ParentData.js +44 -52
  38. package/dist/trinity/eve/spaceObject/IEveSpaceObject2ParentData.js.map +1 -1
  39. package/docs/resource/concepts/resource-lifecycle.md +10 -8
  40. package/docs/resource/formats/geometry-interchange.md +50 -0
  41. package/docs/resource/formats/webgl/decl-io.md +241 -397
  42. package/docs/resource/formats/webgl/memory-structured.md +91 -128
  43. package/docs/resource/formats/webgl/texture-sample.md +306 -469
  44. package/docs/resource/formats/webgpu/reference/wgsl-compatibility.md +54 -85
  45. package/docs/resource/reference/classes/texture.md +11 -1
  46. package/docs/resource/reference/motherlode-cache.md +24 -11
  47. package/docs/resource/reference/queues.md +23 -1
  48. package/docs/trinityal/reference/classes/dropped.md +11 -1
  49. package/package.json +1 -1
@@ -1282,93 +1282,62 @@ the all-body path initially omitted the particle-clear effect-profile
1282
1282
  preflight. The synthetic fixtures cannot express either condition, so an
1283
1283
  all-body corpus sweep is part of this feature's verification, not an optional
1284
1284
  extra.
1285
-
1286
- ## Consumer boundary: resource transforms
1287
-
1288
- The `trinityal/webgpu` layer accepts `CJS_WGSL_SET` versions 1, 2 and 3, and realizes
1289
- `texture-2d-array` resource transforms. The discriminator is the **feature**,
1290
- never the document version and never `texture.viewDimension`:
1291
-
1292
- - a **source-declared** `texture_2d_array` keeps every one of its bindings and
1293
- needs no assembly. Gating on `viewDimension` would reject the very packages
1294
- the exact draw gate renders — the selected Quad V5 body binds a plain
1295
- `texture_2d_array<f32>` with no transform, and both Quad families carry
1296
- `cube` bindings.
1297
- - a **transformed** binding carries `transformId` and `arrayLayerCount`, and its
1298
- merged-away inputs are absent from the layout. It cannot be fed from one
1299
- source texture, so the consumer assembles the layers.
1300
-
1301
- Only `kind: texture-2d-array`, `version: 1`,
1302
- `representation: native-or-rgba8`, and `missingLayer: reject` are realized.
1303
- Anything else throws a diagnostic naming the offending field, because the
1304
- failure mode of guessing is WGSL a device accepts and pixels that are quietly
1305
- wrong.
1306
-
1307
- Both halves of the claim are validated, not just the record: exactly one binding
1308
- must carry each declared transform, at the declared output identity, with a
1309
- matching `arrayLayerCount`, a `texture_2d_array<f32>` type, visibility to the
1310
- transform's stage, and **no surviving binding for any merged-away input**. A
1311
- survivor would still be bindable and would silently receive a texture the shader
1312
- never reads. Symmetrically, a binding claiming an undeclared transform, or
1313
- declaring array layers without one, is rejected.
1314
-
1315
- ### The analysis is pre-transform; the layout is post-transform
1316
-
1317
- This asymmetry is the one thing a consumer must not get wrong. The reflection
1318
- still lists every declared resource under its own register, including inputs the
1319
- producer merged away; the layout is shorter by exactly those inputs. Checking
1320
- one against the other reports the merge as drift. The merged array occupies the
1321
- **layer-0 input's slot**, which is required rather than assumed, so the binding a
1322
- consumer must fill is unambiguous.
1323
-
1324
- Layers are written in declared order, layer *i* from `inputs[i]`, and must agree
1325
- on size and format because one texture cannot hold layers that do not. A missing
1326
- input is rejected rather than substituted: any stand-in layer would change the
1327
- rendered result while still validating.
1328
-
1329
- Realized and drawn, all with zero WGSL warnings:
1330
-
1331
- | Family | Layers | Merged into | Evidence |
1285
+
1286
+ ## Consumer boundary: resource transforms
1287
+
1288
+ The [version-3 contract](../formats/carbon-webgpu.md#version-3-resource-transforms)
1289
+ owns supported recipes and record/layout validation; the
1290
+ [device API](../../../../trinityal/webgpu/reference/api.md#device-boundary)
1291
+ owns caller-supplied layer assembly. Unsupported fields fail with a diagnostic
1292
+ naming the field. Validation rejects undeclared transforms, orphan layer-count
1293
+ claims, and surviving bindings for merged-away inputs.
1294
+
1295
+ Discriminate by **feature**, not document version or `texture.viewDimension`:
1296
+
1297
+ - **Source-declared** arrays retain their bindings and need no assembly. The
1298
+ selected Quad V5 body binds `texture_2d_array<f32>` without a transform;
1299
+ both Quad families also carry `cube` bindings.
1300
+ - **Transformed** bindings carry `transformId` and `arrayLayerCount`; their
1301
+ merged-away inputs are absent. Supply the assembled layers, not one source.
1302
+
1303
+ ### The analysis is pre-transform; the layout is post-transform
1304
+
1305
+ Reflection retains each declared register, including merged-away inputs;
1306
+ physical layout omits those inputs. Comparing them as identical would report
1307
+ the intended merge as drift. The contract requires the array to reuse layer
1308
+ zero's slot, preserve declared input order, and reject missing or incompatible
1309
+ layers.
1310
+
1311
+ Realized and drawn, all with zero WGSL warnings:
1312
+
1313
+ | Family | Layers | Merged into | Evidence |
1332
1314
  | --- | --- | --- | --- |
1333
1315
  | `unpackedskinned_quadheatdetailv5` | 2 | `Detail1Map` slot | 22 over 22 bindings, 3 cases, detail changed 570/635 covered pixels |
1334
- | `unpacked_quaddetailv5` | 3 | `Detail1Map` slot | both detail controls changed 1116/1116 covered pixels |
1335
- | `unpackedskinned_quaddetailv5` | 3 | `Detail1Map` slot | 634/635 and 635/635, indexed non-identity bones observed |
1336
-
1337
- The `Detail1` and `Detail2` delta maps were **distinct** in every case. That is
1338
- the assertion that matters: a collapsed or misordered assembly would produce
1339
- identical deltas while still rendering and still validating.
1340
-
1341
- Source-declared array textures are now realized rather than merely accepted:
1342
- the engine creates a layered 2D texture with a `2d-array` view and binds it
1343
- through the same adapter, gated by a synthetic two-layer draw that asserts each
1344
- layer's pixels exactly. A single-layer array view is legal and distinct from a
1345
- plain 2D view, because a shader declaring `texture_2d_array<f32>` needs the
1346
- array view whatever its layer count. A layout asking for the dimension the view
1347
- was not created with fails closed, since a view's dimension is fixed at
1348
- creation and cannot be reinterpreted.
1349
-
1350
- This matters beyond the transform case: the High `.sm_depth` Quad V5 `Main`
1351
- pass binds `LightProfileArray` as a plain `texture_2d_array<f32>` with no
1352
- transform at all, so array-texture realization is a prerequisite for any
1353
- High-tier draw gate, not a detail of transform support.
1354
-
1355
- Array-texture realization is what made transform support possible: the engine
1356
- allocates the array itself and fills layer *i* from `inputs[i]`, which is the
1357
- only way a binding whose other inputs were removed can be filled at all. The
1358
- Detail and HeatDetail family gates draw under this contract. The Environment
1359
- family has not been exercised and should be treated as unverified rather than
1360
- working.
1361
-
1362
- Accepting version 3 also tightened three structural checks that were written
1363
- `=== 2` and would otherwise have silently downgraded every version-3 package to
1364
- version-1 semantics: shared binding identities must span at least two stages,
1365
- and explicit D3D and scope identities are both required. That downgrade would
1366
- have been invisible to the exact draw gate, because DX11 and DX12 downgrade
1367
- identically and the bit-exact comparison would have stayed green.
1368
-
1369
- ## Verification contract
1370
-
1371
- Every shader-emission, layout, or transform compatibility change requires the
1316
+ | `unpacked_quaddetailv5` | 3 | `Detail1Map` slot | both detail controls changed 1116/1116 covered pixels |
1317
+ | `unpackedskinned_quaddetailv5` | 3 | `Detail1Map` slot | 634/635 and 635/635, indexed non-identity bones observed |
1318
+
1319
+ `Detail1` and `Detail2` delta maps were **distinct** in every case: collapsed
1320
+ or misordered assembly could render and validate but produce identical deltas.
1321
+
1322
+ Source-declared arrays are also realized: a synthetic two-layer draw checks
1323
+ each layer's pixels exactly through the same adapter. A single-layer
1324
+ `2d-array` view remains distinct from plain 2D; a layout requesting a dimension
1325
+ other than the view's fixed creation dimension fails closed. High `.sm_depth`
1326
+ Quad V5 `Main` binds `LightProfileArray` without a transform, so this support
1327
+ is a prerequisite for High-tier draw gates.
1328
+
1329
+ The Detail and HeatDetail gates exercise layer assembly under this contract;
1330
+ **Environment remains unverified**.
1331
+
1332
+ Version 3 exposed three checks incorrectly gated by `=== 2`: shared identities
1333
+ must span at least two stages, and explicit D3D and scope identities are both
1334
+ required. Otherwise version 3 would silently acquire version-1 semantics. Exact
1335
+ DX11/DX12 draw comparison would miss that regression because both would downgrade
1336
+ identically.
1337
+
1338
+ ## Verification contract
1339
+
1340
+ Every shader-emission, layout, or transform compatibility change requires the
1372
1341
  package suite and a representative `trinityal/webgpu` browser gate on a real
1373
1342
  WebGPU device with zero WGSL warnings. Format-level qualification cannot detect
1374
1343
  every WGSL scoping or validator failure, so browser validation remains part of
@@ -3,7 +3,7 @@
3
3
  Status: Evolving
4
4
  Scope: `@carbonenginejs/runtime/resource` classes under `src/resource/texture`
5
5
  Audience: Users, maintainers, and automated readers
6
- Summary: Provides one-sentence purpose descriptors for the texture-array aggregation classes in src/resource/texture.
6
+ Summary: Provides one-sentence purpose descriptors for the texture-array aggregation and procedural texture constructor classes in src/resource/texture.
7
7
 
8
8
  <!-- class:CjsTextureArrayRes -->
9
9
  ## `CjsTextureArrayRes`
@@ -24,3 +24,13 @@ Mutable runtime aggregate resource for an ordered texture-array request that coa
24
24
  - Source: `src/resource/texture/CjsTextureArrayResParameterProxy.js`
25
25
  - Visibility: Public
26
26
  - Kind: Original CarbonEngineJS class
27
+
28
+ <!-- class:SolidColorTextureConstructor -->
29
+ ## `SolidColorTextureConstructor`
30
+
31
+ Carbon's `dynamic:/color` resource constructor, which builds the 1x1 `TriTextureRes` a `dynamic:/color/r,g,b,a` path names and is registered on a manager through `RegisterSolidColorTexture`.
32
+
33
+ - Export: `@carbonenginejs/runtime/resource`
34
+ - Source: `src/resource/texture/SolidColorTextureConstructor.js`
35
+ - Visibility: Public
36
+ - Kind: Faithful Carbon port
@@ -1,7 +1,7 @@
1
1
  # MotherLode identity, cache, and retention
2
2
 
3
3
  Status: Evolving
4
- Scope: `@carbonenginejs/runtime/resource`
4
+ Scope: `@carbonenginejs/runtime/resource`
5
5
  Audience: Users and integrators
6
6
  Summary: Defines canonical resource identity, ownership and replacement, the recorded-byte cache, payload retention, read-cache provenance, and purge contracts.
7
7
 
@@ -49,9 +49,9 @@ byte pressure.
49
49
  `PURGED` is not terminal for the handle. Purge deletes the payload, but the
50
50
  handle revives itself: `IsGood()` renews activity through `KeepAlive()`, and
51
51
  `KeepAlive()` reloads a purged resource along the ordinary first-load path. A
52
- consumer can recover through ordinary liveness checks: asking whether the
53
- resource is good keeps it or brings it back. Purge remains observable through
54
- `IsPurged()` and resource events; callers may also manage retention explicitly.
52
+ consumer can recover through ordinary liveness checks: asking whether the
53
+ resource is good keeps it or brings it back. Purge remains observable through
54
+ `IsPurged()` and resource events; callers may also manage retention explicitly.
55
55
 
56
56
  Liveness follows visibility. Something being drawn is asked about every frame
57
57
  and stays live; something that stops being drawn stops being renewed, ages out,
@@ -77,7 +77,7 @@ weak-reference and refcount transitions. JavaScript cannot reproduce that
77
77
  ownership test reliably, so `CjsMotherLode` budgets only entries that a caller
78
78
  explicitly classifies with `{ cached: true, bytes }`; JavaScript reachability
79
79
  is never inferred. The byte value is an exact caller-supplied safe-integer
80
- eviction weight, not a heuristic walk of the resource graph; the resource layer
80
+ eviction weight, not a heuristic walk of the resource graph; the resource layer
81
81
  does not walk arbitrary cyclic/shared object graphs or invoke payload getters
82
82
  to guess size.
83
83
 
@@ -99,11 +99,11 @@ remaining over-budget state. Trimming never reads, prepares, or reloads data.
99
99
 
100
100
  ## Payload retention
101
101
 
102
- Readers and converters return plain transient payloads, not resource classes
103
- or DTO models. Payloads may exceed a consumer's needs: each resource validates
104
- required fields before publication and retains needed scalars and references;
105
- adapters may retain additional references in adapter-owned state. Prefer referencing payload-owned
106
- typed arrays to copying them merely to change ownership.
102
+ Readers and converters return plain transient payloads, not resource classes
103
+ or DTO models. Payloads may exceed a consumer's needs: each resource validates
104
+ required fields before publication and retains needed scalars and references;
105
+ adapters may retain additional references in adapter-owned state. Prefer referencing payload-owned
106
+ typed arrays to copying them merely to change ownership.
107
107
 
108
108
  The lifecycle treats resource residency and payload residency independently:
109
109
 
@@ -178,9 +178,22 @@ WebGPU adapters side by side should normally pass the same payload to both
178
178
  consumers and retain it until both have finished. Copying is an explicit
179
179
  consumer operation, justified when a consumer must mutate data, transfer and
180
180
  detach an `ArrayBuffer`, or retain an independently writable snapshot. The
181
- consumer should copy only the fields it requires; the resource layer does not
181
+ consumer should copy only the fields it requires; the resource layer does not
182
182
  automatically deep-clone payload or typed-array bundles.
183
183
 
184
+ One kind of route is the exception, because it hands out objects rather than
185
+ data. An OBJECT-mode extension route that hydrates a `Target` (or an `Identify`
186
+ result) follows Carbon's `BlueResMan::LoadObject`, which caches a builder and
187
+ creates a new object on every call. Its payload is the decoded plain values,
188
+ and every `GetObject()`, `LoadObject()`, `FetchObject()` and `Ready()` caller
189
+ receives its own object hydrated from a structured copy of them, so no two
190
+ callers share a nested array or typed array. Nothing is re-read. Callers
191
+ joining an in-flight load also receive their own object, so for these routes
192
+ the operation's promise is not shared. Values that cannot be structured-copied
193
+ fail the load with `CJS_RESOURCE_EXTENSION_TARGET_FAILED`. Routes without a
194
+ Target, RESOURCE-mode routes, and `Identify` results of `true` keep the shared
195
+ read-only rule above.
196
+
184
197
  ## Read-cache provenance
185
198
 
186
199
  Source and parsed-format caches use explicit provenance, separate from
@@ -1,7 +1,7 @@
1
1
  # Queues, publication, and the Wait fence
2
2
 
3
3
  Status: Evolving
4
- Scope: `@carbonenginejs/runtime/resource`
4
+ Scope: `@carbonenginejs/runtime/resource`
5
5
  Audience: Users and integrators
6
6
  Summary: Defines the two manager-owned queues, publication budgeting, registration, and the `Wait()` fence semantics.
7
7
 
@@ -197,6 +197,28 @@ the same registered constructor.
197
197
  `RegisterObjectLoader` remains the direct legacy byte-to-value registration for
198
198
  an extension without an explicit route.
199
199
 
200
+ ## Dynamic resources
201
+
202
+ A `dynamic:/<name>/<query>` path is built by a registered constructor rather
203
+ than read from a source, as in Carbon's `BlueResMan::GetResourceHelper`.
204
+ `RegisterResourceConstructor(name, constructor)` registers an object whose
205
+ `GetResource(query)` returns a resource; names are lowercased, and
206
+ `UnregisterResourceConstructor(name)` removes one. The lookup sits below the
207
+ MotherLode lookup, so identical queries share one resource, and the resource is
208
+ inserted not cacheable (Carbon's `CACHING_NOT_ALLOWED`). A dynamic resource never
209
+ falls back to a source read. An unknown name raises
210
+ `CJS_RESMAN_DYNAMIC_CONSTRUCTOR_MISSING`, a constructor that returns no resource
211
+ raises `CJS_RESMAN_DYNAMIC_RESOURCE_UNAVAILABLE`, and `GetObject()` on a dynamic
212
+ resource without a payload rejects with that resource's error.
213
+
214
+ `RegisterSolidColorTexture(resMan)` registers Carbon's `color` constructor. It is
215
+ an explicit composition call, like `RegisterShaderResources`, rather than
216
+ Carbon's static registration. `dynamic:/color/r,g,b,a` is a 1x1 `TriTextureRes`
217
+ whose `rgba32float` payload holds the colour quantized through the half-float
218
+ codec, parsed exactly as Carbon's `ParseColor`; a malformed query fails the
219
+ texture with `CJS_TEXTURE_PROCEDURAL_PATH_INVALID`. The WebGPU device does not
220
+ yet upload `rgba32float` payloads, and `dynamic:/gradient_1d/` is not ported.
221
+
200
222
  ## Related documentation
201
223
 
202
224
  - [Resource lifecycle concepts](../concepts/resource-lifecycle.md)
@@ -7,7 +7,7 @@ Summary: Provides one-sentence purpose descriptors for abstraction-layer donor c
7
7
 
8
8
  Every class here comes from a backend Carbon compiles instead of ours. That is
9
9
  not on its own a reason to ignore one: `MetalWorkQueue` is the declared model
10
- for `CjsWebgpuWorkQueue`, and of the seven below, five describe behaviour this
10
+ for `CjsWebgpuWorkQueue`, and of the eight below, six describe behaviour this
11
11
  package already ports under different names. They are written so the
12
12
  correspondence is checkable rather than assumed.
13
13
 
@@ -71,6 +71,16 @@ Carbon's deferred render-pass attachment record, whose behaviour this package po
71
71
  - Visibility: Internal
72
72
  - Kind: Faithful Carbon port
73
73
 
74
+ <!-- class:MetalWorkQueue -->
75
+ ## `MetalWorkQueue`
76
+
77
+ Carbon's Metal command recorder, whose encoder-lifetime half this package ports as `CjsWebgpuWorkQueue` while the pipeline, resource sets and render context's draw verbs take the rest of its surface.
78
+
79
+ - Export: None
80
+ - Source: `src/trinityal/dropped/MetalWorkQueue.js`
81
+ - Visibility: Internal
82
+ - Kind: Faithful Carbon port
83
+
74
84
  <!-- class:ShaderResourceMask -->
75
85
  ## `ShaderResourceMask`
76
86
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonenginejs/runtime",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.3",
4
4
  "private": false,
5
5
  "description": "Browser-safe CarbonEngineJS runtime: resource and format readers, the Trinity/EVE object graph, SOF, audio, character, and the WebGPU renderer.",
6
6
  "type": "module",