@forgeax/engine-assets-runtime 0.1.4 → 0.1.7
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/README.md +453 -175
- package/dist/.tsbuildinfo +1 -1
- package/dist/__tests__/aabb.unit.test.d.ts +2 -0
- package/dist/__tests__/aabb.unit.test.d.ts.map +1 -0
- package/dist/__tests__/artifact-integrity.unit.test.d.ts +2 -0
- package/dist/__tests__/artifact-integrity.unit.test.d.ts.map +1 -0
- package/dist/__tests__/artifact-io.unit.test.d.ts +2 -0
- package/dist/__tests__/artifact-io.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-evidence-sdk.integration.test.d.ts +2 -0
- package/dist/__tests__/asset-evidence-sdk.integration.test.d.ts.map +1 -0
- package/dist/__tests__/asset-evidence.unit.test.d.ts +2 -0
- package/dist/__tests__/asset-evidence.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-kind.unit.test.d.ts +2 -0
- package/dist/__tests__/asset-kind.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-registry-catalog-reconcile.integration.test.d.ts +2 -0
- package/dist/__tests__/asset-registry-catalog-reconcile.integration.test.d.ts.map +1 -0
- package/dist/__tests__/asset-registry-catalog-reconcile.unit.test.d.ts +2 -0
- package/dist/__tests__/asset-registry-catalog-reconcile.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-registry-catalog.unit.test.d.ts +2 -0
- package/dist/__tests__/asset-registry-catalog.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-registry.pack-cache.test.d.ts +2 -0
- package/dist/__tests__/asset-registry.pack-cache.test.d.ts.map +1 -0
- package/dist/__tests__/asset-registry.unit.test.d.ts +2 -0
- package/dist/__tests__/asset-registry.unit.test.d.ts.map +1 -0
- package/dist/__tests__/asset-runtime-error-code-owner.test-d.d.ts +2 -0
- package/dist/__tests__/asset-runtime-error-code-owner.test-d.d.ts.map +1 -0
- package/dist/__tests__/catalog-replica.unit.test.d.ts +2 -0
- package/dist/__tests__/catalog-replica.unit.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-source-v2.unit.test.d.ts +2 -0
- package/dist/__tests__/catalog-source-v2.unit.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-source.unit.test.d.ts +2 -0
- package/dist/__tests__/catalog-source.unit.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-subscription-order.unit.test.d.ts +2 -0
- package/dist/__tests__/catalog-subscription-order.unit.test.d.ts.map +1 -0
- package/dist/__tests__/catalog-subscription.unit.test.d.ts +2 -0
- package/dist/__tests__/catalog-subscription.unit.test.d.ts.map +1 -0
- package/dist/__tests__/decode-image-bytes-pass-through.test.d.ts +2 -0
- package/dist/__tests__/decode-image-bytes-pass-through.test.d.ts.map +1 -0
- package/dist/__tests__/decode-image-bytes.browser.test.d.ts +2 -0
- package/dist/__tests__/decode-image-bytes.browser.test.d.ts.map +1 -0
- package/dist/__tests__/decode-image-bytes.test-d.d.ts +2 -0
- package/dist/__tests__/decode-image-bytes.test-d.d.ts.map +1 -0
- package/dist/__tests__/decode-image-bytes.test.d.ts +2 -0
- package/dist/__tests__/decode-image-bytes.test.d.ts.map +1 -0
- package/dist/__tests__/dynamic-texture-store.unit.test.d.ts +2 -0
- package/dist/__tests__/dynamic-texture-store.unit.test.d.ts.map +1 -0
- package/dist/__tests__/errors-asset.unit.test.d.ts +2 -0
- package/dist/__tests__/errors-asset.unit.test.d.ts.map +1 -0
- package/dist/__tests__/inline-pack-loaders.unit.test.d.ts +2 -0
- package/dist/__tests__/inline-pack-loaders.unit.test.d.ts.map +1 -0
- package/dist/__tests__/instantiate-context.unit.test.d.ts +2 -0
- package/dist/__tests__/instantiate-context.unit.test.d.ts.map +1 -0
- package/dist/__tests__/instantiate-publication-fence.unit.test.d.ts +2 -0
- package/dist/__tests__/instantiate-publication-fence.unit.test.d.ts.map +1 -0
- package/dist/__tests__/instantiate.unit.test.d.ts +2 -0
- package/dist/__tests__/instantiate.unit.test.d.ts.map +1 -0
- package/dist/__tests__/loader-input-contract.unit.test.d.ts +2 -0
- package/dist/__tests__/loader-input-contract.unit.test.d.ts.map +1 -0
- package/dist/__tests__/loader-registry.unit.test.d.ts +2 -0
- package/dist/__tests__/loader-registry.unit.test.d.ts.map +1 -0
- package/dist/__tests__/material-dependency-invalidation.unit.test.d.ts +2 -0
- package/dist/__tests__/material-dependency-invalidation.unit.test.d.ts.map +1 -0
- package/dist/__tests__/material-generation-cache.unit.test.d.ts +2 -0
- package/dist/__tests__/material-generation-cache.unit.test.d.ts.map +1 -0
- package/dist/__tests__/material-load-consumer.test-d.d.ts +2 -0
- package/dist/__tests__/material-load-consumer.test-d.d.ts.map +1 -0
- package/dist/__tests__/material-ready.integration.test.d.ts +2 -0
- package/dist/__tests__/material-ready.integration.test.d.ts.map +1 -0
- package/dist/__tests__/material-stale-generation.unit.test.d.ts +2 -0
- package/dist/__tests__/material-stale-generation.unit.test.d.ts.map +1 -0
- package/dist/__tests__/mesh-bin-morph-v3.test.d.ts +2 -0
- package/dist/__tests__/mesh-bin-morph-v3.test.d.ts.map +1 -0
- package/dist/__tests__/mesh-bin.unit.test.d.ts +2 -0
- package/dist/__tests__/mesh-bin.unit.test.d.ts.map +1 -0
- package/dist/__tests__/mipmap-generator.unit.test.d.ts +2 -0
- package/dist/__tests__/mipmap-generator.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pack-artifact-transcode-model-owner.test.d.ts +2 -0
- package/dist/__tests__/pack-artifact-transcode-model-owner.test.d.ts.map +1 -0
- package/dist/__tests__/pack-basis-load.integration.test.d.ts +2 -0
- package/dist/__tests__/pack-basis-load.integration.test.d.ts.map +1 -0
- package/dist/__tests__/payload-validate.unit.test.d.ts +2 -0
- package/dist/__tests__/payload-validate.unit.test.d.ts.map +1 -0
- package/dist/__tests__/plugin.test.d.ts +2 -0
- package/dist/__tests__/plugin.test.d.ts.map +1 -0
- package/dist/__tests__/registry-concurrency.bench.test.d.ts +2 -0
- package/dist/__tests__/registry-concurrency.bench.test.d.ts.map +1 -0
- package/dist/__tests__/registry-failure-retry.integration.test.d.ts +2 -0
- package/dist/__tests__/registry-failure-retry.integration.test.d.ts.map +1 -0
- package/dist/__tests__/registry-load-graph.integration.test.d.ts +2 -0
- package/dist/__tests__/registry-load-graph.integration.test.d.ts.map +1 -0
- package/dist/__tests__/registry-load-state.unit.test.d.ts +2 -0
- package/dist/__tests__/registry-load-state.unit.test.d.ts.map +1 -0
- package/dist/__tests__/registry-package-cache.unit.test.d.ts +2 -0
- package/dist/__tests__/registry-package-cache.unit.test.d.ts.map +1 -0
- package/dist/__tests__/registry-public-ready.unit.test.d.ts +2 -0
- package/dist/__tests__/registry-public-ready.unit.test.d.ts.map +1 -0
- package/dist/__tests__/resolve-asset-handle.unit.test.d.ts +2 -0
- package/dist/__tests__/resolve-asset-handle.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scene-handle-fields.unit.test.d.ts +2 -0
- package/dist/__tests__/scene-handle-fields.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scene-payload.unit.test.d.ts +2 -0
- package/dist/__tests__/scene-payload.unit.test.d.ts.map +1 -0
- package/dist/__tests__/scene-publication-fence.test.d.ts +2 -0
- package/dist/__tests__/scene-publication-fence.test.d.ts.map +1 -0
- package/dist/__tests__/scriptable-pack-public-surface.test-d.d.ts +2 -0
- package/dist/__tests__/scriptable-pack-public-surface.test-d.d.ts.map +1 -0
- package/dist/__tests__/static-rig.integration.test.d.ts +2 -0
- package/dist/__tests__/static-rig.integration.test.d.ts.map +1 -0
- package/dist/__tests__/validate-material.unit.test.d.ts +2 -0
- package/dist/__tests__/validate-material.unit.test.d.ts.map +1 -0
- package/dist/__tests__/video-pack-loader.integration.test.d.ts +2 -0
- package/dist/__tests__/video-pack-loader.integration.test.d.ts.map +1 -0
- package/dist/aabb.d.ts +3 -0
- package/dist/aabb.d.ts.map +1 -0
- package/dist/asset-registry.d.ts +554 -0
- package/dist/asset-registry.d.ts.map +1 -0
- package/dist/builtin-asset-registry.d.ts +22 -0
- package/dist/builtin-asset-registry.d.ts.map +1 -0
- package/dist/catalog-source.d.ts +2 -1
- package/dist/catalog-source.d.ts.map +1 -1
- package/dist/decode-image-bytes.d.ts +57 -0
- package/dist/decode-image-bytes.d.ts.map +1 -0
- package/dist/dynamic-texture-store.d.ts +89 -0
- package/dist/dynamic-texture-store.d.ts.map +1 -0
- package/dist/errors/asset.d.ts +201 -0
- package/dist/errors/asset.d.ts.map +1 -0
- package/dist/handles.d.ts +143 -0
- package/dist/handles.d.ts.map +1 -0
- package/dist/image-error.d.ts +6 -0
- package/dist/image-error.d.ts.map +1 -0
- package/dist/index.d.ts +32 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +7233 -114
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/loader-registry.d.ts +63 -0
- package/dist/loader-registry.d.ts.map +1 -0
- package/dist/loaders/inline-pack.d.ts +72 -0
- package/dist/loaders/inline-pack.d.ts.map +1 -0
- package/dist/loaders/mesh-bin.d.ts +21 -0
- package/dist/loaders/mesh-bin.d.ts.map +1 -0
- package/dist/loaders/pack-artifact.d.ts +20 -0
- package/dist/loaders/pack-artifact.d.ts.map +1 -0
- package/dist/material/dependency-graph.d.ts +9 -0
- package/dist/material/dependency-graph.d.ts.map +1 -0
- package/dist/material/generation-cache.d.ts +24 -0
- package/dist/material/generation-cache.d.ts.map +1 -0
- package/dist/material/inspection.d.ts +24 -0
- package/dist/material/inspection.d.ts.map +1 -0
- package/dist/material/loader.d.ts +59 -0
- package/dist/material/loader.d.ts.map +1 -0
- package/dist/material/runtime-shader.d.ts +14 -0
- package/dist/material/runtime-shader.d.ts.map +1 -0
- package/dist/mesh-bin.d.ts +3 -0
- package/dist/mesh-bin.d.ts.map +1 -0
- package/dist/mipmap-generator.d.ts +132 -0
- package/dist/mipmap-generator.d.ts.map +1 -0
- package/dist/payload-validate.d.ts +60 -0
- package/dist/payload-validate.d.ts.map +1 -0
- package/dist/plugin.d.ts +16 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/registry/artifact-io.d.ts +16 -0
- package/dist/registry/artifact-io.d.ts.map +1 -0
- package/dist/registry/asset-evidence.d.ts +13 -0
- package/dist/registry/asset-evidence.d.ts.map +1 -0
- package/dist/registry/catalog-state.d.ts +47 -0
- package/dist/registry/catalog-state.d.ts.map +1 -0
- package/dist/registry/catalog.d.ts +48 -0
- package/dist/registry/catalog.d.ts.map +1 -0
- package/dist/registry/instantiate.d.ts +153 -0
- package/dist/registry/instantiate.d.ts.map +1 -0
- package/dist/registry/load-by-guid.d.ts +247 -0
- package/dist/registry/load-by-guid.d.ts.map +1 -0
- package/dist/registry/load-state.d.ts +26 -0
- package/dist/registry/load-state.d.ts.map +1 -0
- package/dist/registry/runtime-projection.d.ts +16 -0
- package/dist/registry/runtime-projection.d.ts.map +1 -0
- package/dist/registry/scene-publication-fence.d.ts +38 -0
- package/dist/registry/scene-publication-fence.d.ts.map +1 -0
- package/dist/registry/validate-material.d.ts +77 -0
- package/dist/registry/validate-material.d.ts.map +1 -0
- package/dist/resolve-asset-handle.d.ts +43 -0
- package/dist/resolve-asset-handle.d.ts.map +1 -0
- package/dist/resolve-tileset-runtime.d.ts +23 -0
- package/dist/resolve-tileset-runtime.d.ts.map +1 -0
- package/dist/scene-handle-fields.d.ts +88 -0
- package/dist/scene-handle-fields.d.ts.map +1 -0
- package/dist/scene-payload.d.ts +15 -0
- package/dist/scene-payload.d.ts.map +1 -0
- package/dist/wire-default-loaders.d.ts +29 -0
- package/dist/wire-default-loaders.d.ts.map +1 -0
- package/package.json +22 -9
- package/src/__tests__/aabb.unit.test.ts +97 -0
- package/src/__tests__/artifact-integrity.unit.test.ts +99 -0
- package/src/__tests__/artifact-io.unit.test.ts +127 -0
- package/src/__tests__/asset-evidence-sdk.integration.test.ts +32 -0
- package/src/__tests__/asset-evidence.unit.test.ts +32 -0
- package/src/__tests__/{asset-kind.test.ts → asset-kind.unit.test.ts} +1 -1
- package/src/__tests__/asset-registry-catalog-reconcile.integration.test.ts +74 -0
- package/src/__tests__/asset-registry-catalog-reconcile.unit.test.ts +89 -0
- package/src/__tests__/asset-registry-catalog.unit.test.ts +170 -0
- package/src/__tests__/asset-registry.pack-cache.test.ts +96 -0
- package/src/__tests__/asset-registry.unit.test.ts +511 -0
- package/src/__tests__/asset-runtime-error-code-owner.test-d.ts +63 -0
- package/src/__tests__/catalog-replica.unit.test.ts +196 -0
- package/src/__tests__/catalog-source-v2.unit.test.ts +158 -0
- package/src/__tests__/catalog-source.unit.test.ts +126 -0
- package/src/__tests__/catalog-subscription-order.unit.test.ts +65 -0
- package/src/__tests__/catalog-subscription.unit.test.ts +28 -0
- package/src/__tests__/decode-image-bytes-pass-through.test.ts +34 -0
- package/src/__tests__/decode-image-bytes.browser.test.ts +102 -0
- package/src/__tests__/decode-image-bytes.test-d.ts +108 -0
- package/src/__tests__/decode-image-bytes.test.ts +90 -0
- package/src/__tests__/decode-image-mime-owner.test.ts +2 -5
- package/src/__tests__/dynamic-texture-store.unit.test.ts +115 -0
- package/src/__tests__/errors-asset.unit.test.ts +92 -0
- package/src/__tests__/inline-pack-loaders.unit.test.ts +548 -0
- package/src/__tests__/instantiate-context.unit.test.ts +65 -0
- package/src/__tests__/instantiate-publication-fence.unit.test.ts +158 -0
- package/src/__tests__/instantiate.unit.test.ts +684 -0
- package/src/__tests__/loader-input-contract.unit.test.ts +89 -0
- package/src/__tests__/loader-registry.unit.test.ts +101 -0
- package/src/__tests__/material-dependency-invalidation.unit.test.ts +14 -0
- package/src/__tests__/material-generation-cache.unit.test.ts +46 -0
- package/src/__tests__/material-load-consumer.test-d.ts +42 -0
- package/src/__tests__/material-ready.integration.test.ts +508 -0
- package/src/__tests__/material-stale-generation.unit.test.ts +147 -0
- package/src/__tests__/mesh-bin-morph-v3.test.ts +22 -0
- package/src/__tests__/mesh-bin.unit.test.ts +152 -0
- package/src/__tests__/mipmap-generator.unit.test.ts +202 -0
- package/src/__tests__/pack-artifact-transcode-model-owner.test.ts +32 -0
- package/src/__tests__/pack-basis-load.integration.test.ts +168 -0
- package/src/__tests__/payload-validate.unit.test.ts +285 -0
- package/src/__tests__/plugin.test.ts +55 -0
- package/src/__tests__/registry-concurrency.bench.test.ts +40 -0
- package/src/__tests__/registry-failure-retry.integration.test.ts +69 -0
- package/src/__tests__/registry-load-graph.integration.test.ts +246 -0
- package/src/__tests__/registry-load-state.unit.test.ts +35 -0
- package/src/__tests__/registry-package-cache.unit.test.ts +53 -0
- package/src/__tests__/registry-public-ready.unit.test.ts +38 -0
- package/src/__tests__/resolve-asset-handle.unit.test.ts +238 -0
- package/src/__tests__/scene-handle-fields.unit.test.ts +129 -0
- package/src/__tests__/scene-payload.unit.test.ts +151 -0
- package/src/__tests__/scene-publication-fence.test.ts +129 -0
- package/src/__tests__/scriptable-pack-public-surface.test-d.ts +27 -0
- package/src/__tests__/static-rig.integration.test.ts +8 -0
- package/src/__tests__/validate-material.unit.test.ts +359 -0
- package/src/__tests__/video-pack-loader.integration.test.ts +83 -0
- package/src/aabb.ts +107 -0
- package/src/asset-registry.ts +2045 -0
- package/src/builtin-asset-registry.ts +164 -0
- package/src/catalog-source.ts +14 -70
- package/src/decode-image-bytes.ts +126 -0
- package/src/dynamic-texture-store.ts +234 -0
- package/src/errors/asset.ts +347 -0
- package/src/handles.ts +186 -0
- package/src/image-error.ts +45 -0
- package/src/index.ts +183 -16
- package/src/internal.ts +1 -0
- package/src/loader-registry.ts +157 -0
- package/src/loaders/inline-pack.ts +837 -0
- package/src/loaders/mesh-bin.ts +304 -0
- package/src/loaders/pack-artifact.ts +665 -0
- package/src/material/dependency-graph.ts +46 -0
- package/src/material/generation-cache.ts +177 -0
- package/src/material/inspection.ts +46 -0
- package/src/material/loader.ts +326 -0
- package/src/material/runtime-shader.ts +133 -0
- package/src/mesh-bin.ts +5 -0
- package/src/mipmap-generator.ts +450 -0
- package/src/payload-validate.ts +573 -0
- package/src/plugin.ts +48 -0
- package/src/registry/artifact-io.ts +259 -0
- package/src/registry/asset-evidence.ts +51 -0
- package/src/registry/catalog-state.ts +409 -0
- package/src/registry/catalog.ts +369 -0
- package/src/registry/instantiate.ts +1056 -0
- package/src/registry/load-by-guid.ts +1657 -0
- package/src/registry/load-state.ts +115 -0
- package/src/registry/runtime-projection.ts +63 -0
- package/src/registry/scene-publication-fence.ts +256 -0
- package/src/registry/validate-material.ts +385 -0
- package/src/resolve-asset-handle.ts +147 -0
- package/src/resolve-tileset-runtime.ts +72 -0
- package/src/scene-handle-fields.ts +221 -0
- package/src/scene-payload.ts +207 -0
- package/src/wire-default-loaders.ts +79 -0
- package/dist/__tests__/asset-graph-red.integration.test.d.ts +0 -2
- package/dist/__tests__/asset-graph-red.integration.test.d.ts.map +0 -1
- package/dist/__tests__/asset-kind.test.d.ts +0 -2
- package/dist/__tests__/asset-kind.test.d.ts.map +0 -1
- package/dist/__tests__/asset-registry-core.integration.test.d.ts +0 -2
- package/dist/__tests__/asset-registry-core.integration.test.d.ts.map +0 -1
- package/dist/__tests__/asset-registry-public-api.test-d.d.ts +0 -2
- package/dist/__tests__/asset-registry-public-api.test-d.d.ts.map +0 -1
- package/dist/__tests__/asset-runtime-core-lifecycle.integration.test.d.ts +0 -2
- package/dist/__tests__/asset-runtime-core-lifecycle.integration.test.d.ts.map +0 -1
- package/dist/__tests__/asset-runtime-snapshot.unit.test.d.ts +0 -2
- package/dist/__tests__/asset-runtime-snapshot.unit.test.d.ts.map +0 -1
- package/dist/__tests__/catalog-session-red.unit.test.d.ts +0 -2
- package/dist/__tests__/catalog-session-red.unit.test.d.ts.map +0 -1
- package/dist/__tests__/registry-lifecycle-red.integration.test.d.ts +0 -2
- package/dist/__tests__/registry-lifecycle-red.integration.test.d.ts.map +0 -1
- package/src/__tests__/asset-graph-red.integration.test.ts +0 -113
- package/src/__tests__/asset-registry-core.integration.test.ts +0 -161
- package/src/__tests__/asset-registry-public-api.test-d.ts +0 -31
- package/src/__tests__/asset-runtime-core-lifecycle.integration.test.ts +0 -79
- package/src/__tests__/asset-runtime-snapshot.unit.test.ts +0 -23
- package/src/__tests__/catalog-session-red.unit.test.ts +0 -276
- package/src/__tests__/registry-lifecycle-red.integration.test.ts +0 -80
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
// @forgeax/engine-assets-runtime -- inline pack-payload loader coverage
|
|
2
|
+
// (fix issue #709). Each loader is a pure (payload, refs, ctx) -> Asset|undefined
|
|
3
|
+
// function; exercise the accept + reject arms of all eight, plus the
|
|
4
|
+
// wireDefaultLoaders / createDefaultLoaderRegistry seed-table helpers.
|
|
5
|
+
|
|
6
|
+
import type { LoadContext, MaterialAsset } from '@forgeax/engine-types';
|
|
7
|
+
import { describe, expect, it } from 'vitest';
|
|
8
|
+
import { LoaderRegistry } from '../loader-registry';
|
|
9
|
+
import {
|
|
10
|
+
animationClipLoader,
|
|
11
|
+
animationGraphLoader,
|
|
12
|
+
INLINE_PACK_LOADERS,
|
|
13
|
+
materialLoader,
|
|
14
|
+
meshLoader,
|
|
15
|
+
samplerLoader,
|
|
16
|
+
sceneLoader,
|
|
17
|
+
skeletonLoader,
|
|
18
|
+
skinLoader,
|
|
19
|
+
} from '../loaders/inline-pack';
|
|
20
|
+
import { createDefaultLoaderRegistry, wireDefaultLoaders } from '../wire-default-loaders';
|
|
21
|
+
|
|
22
|
+
const emptyCtx = {} as LoadContext;
|
|
23
|
+
|
|
24
|
+
describe('meshLoader', () => {
|
|
25
|
+
it('rejects legacy mesh binaries without a white/default fallback', () => {
|
|
26
|
+
const output = meshLoader.loadPack?.(
|
|
27
|
+
{
|
|
28
|
+
guid: 'mesh-legacy',
|
|
29
|
+
payload: {},
|
|
30
|
+
artifacts: { body: { bytes: new Uint8Array([2, 0, 0]) } },
|
|
31
|
+
} as never,
|
|
32
|
+
emptyCtx,
|
|
33
|
+
);
|
|
34
|
+
expect(output).toMatchObject({ ok: false, error: { sourceKey: 'mesh-legacy' } });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('normalises Array vertices/indices into typed arrays with a default submesh', () => {
|
|
38
|
+
const out = meshLoader.load(
|
|
39
|
+
{ vertices: new Array(12).fill(0), indices: [0, 0, 0] },
|
|
40
|
+
undefined,
|
|
41
|
+
emptyCtx,
|
|
42
|
+
);
|
|
43
|
+
expect(out).toBeDefined();
|
|
44
|
+
const mesh = out as {
|
|
45
|
+
kind: string;
|
|
46
|
+
vertices: Float32Array;
|
|
47
|
+
indices?: Uint16Array;
|
|
48
|
+
submeshes: unknown[];
|
|
49
|
+
};
|
|
50
|
+
expect(mesh.kind).toBe('mesh');
|
|
51
|
+
expect(mesh.vertices).toBeInstanceOf(Float32Array);
|
|
52
|
+
expect(mesh.indices).toBeInstanceOf(Uint16Array);
|
|
53
|
+
expect(mesh.submeshes).toHaveLength(1);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('drops an empty index array (vertex-only path)', () => {
|
|
57
|
+
const out = meshLoader.load(
|
|
58
|
+
{ vertices: new Float32Array(12), indices: [] },
|
|
59
|
+
undefined,
|
|
60
|
+
emptyCtx,
|
|
61
|
+
) as {
|
|
62
|
+
indices?: unknown;
|
|
63
|
+
};
|
|
64
|
+
expect(out.indices).toBeUndefined();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('accepts skinIndex/skinWeight as arrays', () => {
|
|
68
|
+
const out = meshLoader.load(
|
|
69
|
+
{
|
|
70
|
+
vertices: new Float32Array(18),
|
|
71
|
+
attributes: { skinIndex: [0, 1, 2, 3], skinWeight: [1, 0, 0, 0] },
|
|
72
|
+
},
|
|
73
|
+
undefined,
|
|
74
|
+
emptyCtx,
|
|
75
|
+
) as { attributes: { skinIndex: unknown; skinWeight: unknown } };
|
|
76
|
+
expect(out.attributes.skinIndex).toBeInstanceOf(Uint16Array);
|
|
77
|
+
expect(out.attributes.skinWeight).toBeInstanceOf(Float32Array);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('rejects a non-array/non-typed vertices payload', () => {
|
|
81
|
+
expect(meshLoader.load({ vertices: 'bad' }, undefined, emptyCtx)).toBeUndefined();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('rejects a malformed skinIndex', () => {
|
|
85
|
+
expect(
|
|
86
|
+
meshLoader.load(
|
|
87
|
+
{ vertices: new Float32Array(12), attributes: { skinIndex: 'bad' } },
|
|
88
|
+
undefined,
|
|
89
|
+
emptyCtx,
|
|
90
|
+
),
|
|
91
|
+
).toBeUndefined();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('meshLoader strict v4 inline artifact', () => {
|
|
96
|
+
it('routes a malformed inline mesh artifact as a structured error and publishes no asset', () => {
|
|
97
|
+
const output = meshLoader.loadPack?.(
|
|
98
|
+
{
|
|
99
|
+
guid: 'mesh-guid',
|
|
100
|
+
kind: 'mesh',
|
|
101
|
+
payload: {},
|
|
102
|
+
refs: [],
|
|
103
|
+
artifacts: {
|
|
104
|
+
body: {
|
|
105
|
+
descriptor: {
|
|
106
|
+
path: 'mesh.bin',
|
|
107
|
+
mediaType: 'application/x-forgeax-mesh',
|
|
108
|
+
assetCodec: { name: 'mesh-binary', version: '4' },
|
|
109
|
+
},
|
|
110
|
+
bytes: new Uint8Array([3, 0, 0]),
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
} as never,
|
|
114
|
+
emptyCtx,
|
|
115
|
+
);
|
|
116
|
+
expect(output).toMatchObject({
|
|
117
|
+
ok: false,
|
|
118
|
+
error: { sourceKey: 'mesh-guid', recovery: expect.stringContaining('re-cook') },
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('sceneLoader', () => {
|
|
124
|
+
it('parses a scene payload into a SceneAsset', () => {
|
|
125
|
+
const out = sceneLoader.load(
|
|
126
|
+
{ entities: [{ localId: 0, components: {} }] },
|
|
127
|
+
undefined,
|
|
128
|
+
emptyCtx,
|
|
129
|
+
);
|
|
130
|
+
expect((out as { kind?: string }).kind).toBe('scene');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('returns undefined for a malformed scene payload', () => {
|
|
134
|
+
expect(sceneLoader.load({ entities: 'bad' }, undefined, emptyCtx)).toBeUndefined();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('routes an out-of-bounds ref error inline as { ok:false, error }', () => {
|
|
138
|
+
const out = sceneLoader.load(
|
|
139
|
+
{ entities: [{ localId: 0, components: { MeshFilter: { assetHandle: 9 } } }] },
|
|
140
|
+
['only-one-guid'],
|
|
141
|
+
emptyCtx,
|
|
142
|
+
);
|
|
143
|
+
expect(out).toMatchObject({ ok: false });
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('materialLoader', () => {
|
|
148
|
+
it('builds a material from passes + values', () => {
|
|
149
|
+
const out = materialLoader.load(
|
|
150
|
+
{
|
|
151
|
+
passes: [{ name: 'main', program: { module: 'forgeax::standard' } }],
|
|
152
|
+
values: { roughness: 0.5 },
|
|
153
|
+
},
|
|
154
|
+
undefined,
|
|
155
|
+
emptyCtx,
|
|
156
|
+
);
|
|
157
|
+
expect((out as { kind?: string }).kind).toBe('material');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('preserves the authored parameter schema and color space', () => {
|
|
161
|
+
const parameters = [
|
|
162
|
+
{ name: 'tint', type: 'color', colorSpace: 'linear' },
|
|
163
|
+
{ name: 'flowTexture', type: 'texture' },
|
|
164
|
+
] as const;
|
|
165
|
+
const out = materialLoader.load(
|
|
166
|
+
{
|
|
167
|
+
passes: [{ name: 'particle-billboard', program: { module: 'sample::flow' } }],
|
|
168
|
+
parameters,
|
|
169
|
+
values: { tint: [0.2, 0.6, 1, 1] },
|
|
170
|
+
colorSpace: 'linear',
|
|
171
|
+
},
|
|
172
|
+
undefined,
|
|
173
|
+
emptyCtx,
|
|
174
|
+
) as MaterialAsset;
|
|
175
|
+
|
|
176
|
+
expect(out.parameters).toEqual(parameters);
|
|
177
|
+
expect(out.colorSpace).toBe('linear');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('resolves a numeric parent ref-index to a parentGuid string', () => {
|
|
181
|
+
const out = materialLoader.load(
|
|
182
|
+
{ passes: [{ name: 'main', program: { module: 'x' } }], parent: 1 },
|
|
183
|
+
['g0', 'g1'],
|
|
184
|
+
emptyCtx,
|
|
185
|
+
) as { parentGuid?: string };
|
|
186
|
+
expect(out.parentGuid).toBe('g1');
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('preserves an authored parent GUID without requiring a refs index', () => {
|
|
190
|
+
const out = materialLoader.load(
|
|
191
|
+
{ values: { baseColor: [1, 0, 0, 1] }, parent: '01935b00-0000-7000-8000-000000000001' },
|
|
192
|
+
undefined,
|
|
193
|
+
emptyCtx,
|
|
194
|
+
) as { parentGuid?: string };
|
|
195
|
+
expect(out.parentGuid).toBe('01935b00-0000-7000-8000-000000000001');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('returns undefined when a parent ref-index is out of bounds', () => {
|
|
199
|
+
expect(
|
|
200
|
+
materialLoader.load(
|
|
201
|
+
{ passes: [{ name: 'm', program: { module: 'x' } }], parent: 9 },
|
|
202
|
+
['g0'],
|
|
203
|
+
emptyCtx,
|
|
204
|
+
),
|
|
205
|
+
).toBeUndefined();
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('resolves shader-declared texture paramValue ref-indices to GUIDs', () => {
|
|
209
|
+
const ctx = {
|
|
210
|
+
getMaterialShaderTextureFieldNames: (id: string) =>
|
|
211
|
+
id === 'forgeax::pbr' ? new Set(['baseColorTexture']) : undefined,
|
|
212
|
+
} as unknown as LoadContext;
|
|
213
|
+
const out = materialLoader.load(
|
|
214
|
+
{
|
|
215
|
+
passes: [{ name: 'm', program: { module: 'forgeax::pbr' } }],
|
|
216
|
+
values: { baseColorTexture: 0, roughness: 5 },
|
|
217
|
+
},
|
|
218
|
+
['tex-guid'],
|
|
219
|
+
ctx,
|
|
220
|
+
) as { values: Record<string, unknown> };
|
|
221
|
+
expect(out.values.baseColorTexture).toEqual({ texture: 'tex-guid' });
|
|
222
|
+
expect(out.values.roughness).toBe(5); // non-texture int untouched
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('uses authored parameters to distinguish texture refs from zero-valued scalars', () => {
|
|
226
|
+
const out = materialLoader.load(
|
|
227
|
+
{
|
|
228
|
+
passes: [{ name: 'main', program: { module: 'late::standard' } }],
|
|
229
|
+
parameters: [
|
|
230
|
+
{ name: 'metallic', type: 'f32' },
|
|
231
|
+
{ name: 'baseColorTexture', type: 'texture', optional: true },
|
|
232
|
+
],
|
|
233
|
+
values: { metallic: 0, baseColorTexture: 0 },
|
|
234
|
+
},
|
|
235
|
+
['texture-guid'],
|
|
236
|
+
emptyCtx,
|
|
237
|
+
) as MaterialAsset;
|
|
238
|
+
|
|
239
|
+
expect(out.values?.metallic).toBe(0);
|
|
240
|
+
expect(out.values?.baseColorTexture).toEqual({ texture: 'texture-guid' });
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('treats an authored all-scalar parameter schema as authoritative', () => {
|
|
244
|
+
const out = materialLoader.load(
|
|
245
|
+
{
|
|
246
|
+
passes: [{ name: 'main', program: { module: 'late::standard' } }],
|
|
247
|
+
parameters: [{ name: 'metallic', type: 'f32' }],
|
|
248
|
+
values: { metallic: 0 },
|
|
249
|
+
},
|
|
250
|
+
['texture-guid'],
|
|
251
|
+
emptyCtx,
|
|
252
|
+
) as MaterialAsset;
|
|
253
|
+
|
|
254
|
+
expect(out.values?.metallic).toBe(0);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('resolves nested texture and sampler ref-indices while preserving authored fields', () => {
|
|
258
|
+
const ctx = {
|
|
259
|
+
getMaterialShaderTextureFieldNames: () => new Set(['baseColorTexture']),
|
|
260
|
+
} as unknown as LoadContext;
|
|
261
|
+
const out = materialLoader.load(
|
|
262
|
+
{
|
|
263
|
+
passes: [{ name: 'm', program: { module: 'forgeax::pbr' } }],
|
|
264
|
+
values: {
|
|
265
|
+
baseColorTexture: {
|
|
266
|
+
texture: 0,
|
|
267
|
+
sampler: 1,
|
|
268
|
+
coordinates: { set: 1, transform: { scale: [2, 3] } },
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
['tex-guid', 'sampler-guid'],
|
|
273
|
+
ctx,
|
|
274
|
+
) as { values: Record<string, unknown> };
|
|
275
|
+
expect(out.values.baseColorTexture).toEqual({
|
|
276
|
+
texture: 'tex-guid',
|
|
277
|
+
sampler: 'sampler-guid',
|
|
278
|
+
coordinates: { set: 1, transform: { scale: [2, 3] } },
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('resolves nested texture values when the shader schema is present but empty', () => {
|
|
283
|
+
const out = materialLoader.load(
|
|
284
|
+
{
|
|
285
|
+
passes: [{ program: { module: 'forgeax::pbr-skin' } }],
|
|
286
|
+
values: { baseColor: [1, 1, 1, 1], metallic: 0, baseColorTexture: { texture: 0 } },
|
|
287
|
+
},
|
|
288
|
+
['tex-guid'],
|
|
289
|
+
{
|
|
290
|
+
...emptyCtx,
|
|
291
|
+
getMaterialShaderTextureFieldNames: () => new Set(),
|
|
292
|
+
},
|
|
293
|
+
) as MaterialAsset;
|
|
294
|
+
|
|
295
|
+
expect(out.values).toBeDefined();
|
|
296
|
+
if (!out.values) throw new Error('material loader must preserve material values');
|
|
297
|
+
expect(out.values.baseColorTexture).toEqual({ texture: 'tex-guid' });
|
|
298
|
+
expect(out.values.metallic).toBe(0);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it('removes identity coordinates from structured texture references', () => {
|
|
302
|
+
const ctx = {
|
|
303
|
+
getMaterialShaderTextureFieldNames: () => new Set(['baseColorTexture']),
|
|
304
|
+
} as unknown as LoadContext;
|
|
305
|
+
const out = materialLoader.load(
|
|
306
|
+
{
|
|
307
|
+
passes: [{ program: { module: 'forgeax::pbr' } }],
|
|
308
|
+
values: {
|
|
309
|
+
baseColorTexture: {
|
|
310
|
+
texture: 0,
|
|
311
|
+
coordinates: { set: 0, transform: { offset: [0, 0], scale: [1, 1], rotation: 0 } },
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
['tex-guid'],
|
|
316
|
+
ctx,
|
|
317
|
+
) as MaterialAsset;
|
|
318
|
+
|
|
319
|
+
expect(out.values?.baseColorTexture).toEqual({ texture: 'tex-guid' });
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it('preserves coordinate extension metadata instead of treating it as identity', () => {
|
|
323
|
+
const ctx = {
|
|
324
|
+
getMaterialShaderTextureFieldNames: () => new Set(['baseColorTexture']),
|
|
325
|
+
} as unknown as LoadContext;
|
|
326
|
+
const out = materialLoader.load(
|
|
327
|
+
{
|
|
328
|
+
passes: [{ program: { module: 'forgeax::pbr' } }],
|
|
329
|
+
values: {
|
|
330
|
+
baseColorTexture: {
|
|
331
|
+
texture: 0,
|
|
332
|
+
coordinates: { transform: { metadata: 'keep' } },
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
['tex-guid'],
|
|
337
|
+
ctx,
|
|
338
|
+
) as { values: Record<string, unknown> };
|
|
339
|
+
|
|
340
|
+
expect(out.values.baseColorTexture).toEqual({
|
|
341
|
+
texture: 'tex-guid',
|
|
342
|
+
coordinates: { transform: { metadata: 'keep' } },
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it('returns undefined for a passes-less, parent-less material', () => {
|
|
347
|
+
expect(materialLoader.load({}, undefined, emptyCtx)).toBeUndefined();
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
describe('inline ordinary asset matrix', () => {
|
|
352
|
+
it('loads render-pipeline and tileset descriptors after a JSON roundtrip', () => {
|
|
353
|
+
const registry = createDefaultLoaderRegistry();
|
|
354
|
+
expect(registry.get('render-pipeline')).toBeDefined();
|
|
355
|
+
expect(registry.get('tileset')).toBeDefined();
|
|
356
|
+
|
|
357
|
+
const renderPipeline = registry
|
|
358
|
+
.get('render-pipeline')
|
|
359
|
+
?.load({ kind: 'render-pipeline', pipelineId: 'forgeax::urp' }, undefined, emptyCtx);
|
|
360
|
+
const tileset = registry.get('tileset')?.load(
|
|
361
|
+
{
|
|
362
|
+
kind: 'tileset',
|
|
363
|
+
atlases: ['019d0000-0000-7000-8000-000000000001'],
|
|
364
|
+
tileWidth: 1,
|
|
365
|
+
tileHeight: 1,
|
|
366
|
+
columns: 1,
|
|
367
|
+
rows: 1,
|
|
368
|
+
regions: [{ x: 0, y: 0, width: 1, height: 1 }],
|
|
369
|
+
tiles: [{ regionIndex: 0 }],
|
|
370
|
+
},
|
|
371
|
+
undefined,
|
|
372
|
+
emptyCtx,
|
|
373
|
+
);
|
|
374
|
+
expect(renderPipeline).toMatchObject({ kind: 'render-pipeline' });
|
|
375
|
+
expect(tileset).toMatchObject({ kind: 'tileset' });
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
describe('skeletonLoader', () => {
|
|
380
|
+
it('accepts a valid inverseBindMatrices/jointCount pair', () => {
|
|
381
|
+
const out = skeletonLoader.load(
|
|
382
|
+
{ inverseBindMatrices: new Array(16).fill(0), jointCount: 1 },
|
|
383
|
+
undefined,
|
|
384
|
+
emptyCtx,
|
|
385
|
+
);
|
|
386
|
+
expect((out as { kind?: string }).kind).toBe('skeleton');
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
it('rejects a stride mismatch (byteLength !== jointCount*64)', () => {
|
|
390
|
+
expect(
|
|
391
|
+
skeletonLoader.load(
|
|
392
|
+
{ inverseBindMatrices: new Array(16).fill(0), jointCount: 2 },
|
|
393
|
+
undefined,
|
|
394
|
+
emptyCtx,
|
|
395
|
+
),
|
|
396
|
+
).toBeUndefined();
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('rejects a non-array inverseBindMatrices', () => {
|
|
400
|
+
expect(
|
|
401
|
+
skeletonLoader.load({ inverseBindMatrices: 'bad', jointCount: 0 }, undefined, emptyCtx),
|
|
402
|
+
).toBeUndefined();
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
describe('skinLoader', () => {
|
|
407
|
+
it('accepts a valid skeletonGuid + jointPaths', () => {
|
|
408
|
+
const out = skinLoader.load({ skeletonGuid: 'g', jointPaths: ['a', 'b'] }, undefined, emptyCtx);
|
|
409
|
+
expect((out as { kind?: string }).kind).toBe('skin');
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it('rejects a missing skeletonGuid or non-string joint path', () => {
|
|
413
|
+
expect(skinLoader.load({ jointPaths: [] }, undefined, emptyCtx)).toBeUndefined();
|
|
414
|
+
expect(
|
|
415
|
+
skinLoader.load({ skeletonGuid: 'g', jointPaths: [1] }, undefined, emptyCtx),
|
|
416
|
+
).toBeUndefined();
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
describe('animationClipLoader', () => {
|
|
421
|
+
it('accepts a valid channel with LINEAR sampler arrays', () => {
|
|
422
|
+
const out = animationClipLoader.load(
|
|
423
|
+
{
|
|
424
|
+
duration: 1,
|
|
425
|
+
channels: [
|
|
426
|
+
{
|
|
427
|
+
targetId: 'a95da0ec669189f98273e8f86d8ad9f2',
|
|
428
|
+
property: 'translation',
|
|
429
|
+
sampler: { input: [0, 1], output: [0, 0, 0, 1, 1, 1], interpolation: 'LINEAR' },
|
|
430
|
+
},
|
|
431
|
+
],
|
|
432
|
+
},
|
|
433
|
+
undefined,
|
|
434
|
+
emptyCtx,
|
|
435
|
+
);
|
|
436
|
+
expect((out as { kind?: string }).kind).toBe('animation-clip');
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it('rejects legacy, dual, and malformed target wires', () => {
|
|
440
|
+
const sampler = { input: [0], output: [0, 0, 0], interpolation: 'LINEAR' };
|
|
441
|
+
const loadChannel = (channel: Record<string, unknown>) =>
|
|
442
|
+
animationClipLoader.load(
|
|
443
|
+
{ channels: [{ ...channel, property: 'translation', sampler }] },
|
|
444
|
+
undefined,
|
|
445
|
+
emptyCtx,
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
expect(loadChannel({ targetPath: ['root'] })).toBeUndefined();
|
|
449
|
+
expect(
|
|
450
|
+
loadChannel({
|
|
451
|
+
targetId: 'a95da0ec669189f98273e8f86d8ad9f2',
|
|
452
|
+
targetPath: ['root'],
|
|
453
|
+
}),
|
|
454
|
+
).toBeUndefined();
|
|
455
|
+
expect(loadChannel({ targetId: 'A95DA0EC669159F98273E8F86D8AD9F2' })).toBeUndefined();
|
|
456
|
+
expect(loadChannel({ targetId: 'a95da0ec669159f98273e8f86d8ad9f' })).toBeUndefined();
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
it('rejects a bad property / missing sampler / bad interpolation', () => {
|
|
460
|
+
expect(
|
|
461
|
+
animationClipLoader.load(
|
|
462
|
+
{ channels: [{ targetId: 'a95da0ec669189f98273e8f86d8ad9f2', property: 'bogus' }] },
|
|
463
|
+
undefined,
|
|
464
|
+
emptyCtx,
|
|
465
|
+
),
|
|
466
|
+
).toBeUndefined();
|
|
467
|
+
expect(
|
|
468
|
+
animationClipLoader.load(
|
|
469
|
+
{ channels: [{ targetId: 'a95da0ec669189f98273e8f86d8ad9f2', property: 'scale' }] },
|
|
470
|
+
undefined,
|
|
471
|
+
emptyCtx,
|
|
472
|
+
),
|
|
473
|
+
).toBeUndefined();
|
|
474
|
+
expect(
|
|
475
|
+
animationClipLoader.load(
|
|
476
|
+
{
|
|
477
|
+
channels: [
|
|
478
|
+
{
|
|
479
|
+
targetId: 'a95da0ec669189f98273e8f86d8ad9f2',
|
|
480
|
+
property: 'scale',
|
|
481
|
+
sampler: { input: [0], output: [0], interpolation: 'CUBIC' },
|
|
482
|
+
},
|
|
483
|
+
],
|
|
484
|
+
},
|
|
485
|
+
undefined,
|
|
486
|
+
emptyCtx,
|
|
487
|
+
),
|
|
488
|
+
).toBeUndefined();
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
it('rejects a non-array channels payload', () => {
|
|
492
|
+
expect(animationClipLoader.load({ channels: 'bad' }, undefined, emptyCtx)).toBeUndefined();
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
describe('wireDefaultLoaders / createDefaultLoaderRegistry', () => {
|
|
497
|
+
it('loads a serialised sampler descriptor', () => {
|
|
498
|
+
expect(
|
|
499
|
+
samplerLoader.load(
|
|
500
|
+
{ addressModeU: 'repeat', magFilter: 'linear', maxAnisotropy: 16 },
|
|
501
|
+
undefined,
|
|
502
|
+
emptyCtx,
|
|
503
|
+
),
|
|
504
|
+
).toEqual({
|
|
505
|
+
kind: 'sampler',
|
|
506
|
+
addressModeU: 'repeat',
|
|
507
|
+
magFilter: 'linear',
|
|
508
|
+
maxAnisotropy: 16,
|
|
509
|
+
});
|
|
510
|
+
expect(samplerLoader.load({ addressModeU: 'invalid' }, undefined, emptyCtx)).toBeUndefined();
|
|
511
|
+
expect(samplerLoader.load({ maxAnisotropy: '16' }, undefined, emptyCtx)).toBeUndefined();
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
it('keeps animation graph loader in assets-runtime', () => {
|
|
515
|
+
expect(animationGraphLoader.kind).toBe('animation-graph');
|
|
516
|
+
});
|
|
517
|
+
it('wires the engine default kinds and leaves shader unregistered', () => {
|
|
518
|
+
const reg = wireDefaultLoaders(new LoaderRegistry());
|
|
519
|
+
for (const kind of [
|
|
520
|
+
'mesh',
|
|
521
|
+
'scene',
|
|
522
|
+
'sampler',
|
|
523
|
+
'material',
|
|
524
|
+
'skeleton',
|
|
525
|
+
'skin',
|
|
526
|
+
'animation-clip',
|
|
527
|
+
'texture',
|
|
528
|
+
'font',
|
|
529
|
+
'equirect',
|
|
530
|
+
'video',
|
|
531
|
+
]) {
|
|
532
|
+
expect(reg.get(kind)).toBeDefined();
|
|
533
|
+
}
|
|
534
|
+
expect(reg.get('shader')).toBeUndefined();
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
it('selects an explicit host owner before default seeding', () => {
|
|
538
|
+
const audio = { kind: 'audio', load: () => undefined } as never;
|
|
539
|
+
const reg = wireDefaultLoaders(new LoaderRegistry(), [audio]);
|
|
540
|
+
expect(reg.get('audio')).toBe(audio);
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
it('createDefaultLoaderRegistry returns a fresh pre-wired registry', () => {
|
|
544
|
+
const reg = createDefaultLoaderRegistry();
|
|
545
|
+
expect(reg.get('mesh')).toBeDefined();
|
|
546
|
+
expect(INLINE_PACK_LOADERS.length).toBe(12); // ordinary inline loader matrix
|
|
547
|
+
});
|
|
548
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @forgeax/engine-assets-runtime -- buildSceneChildContext coverage (fix issue
|
|
2
|
+
// #709). The breadcrumb-provenance resolver walks the recursing scene's
|
|
3
|
+
// envelope.refs edges (prod) or falls back to the entity component walk (dev
|
|
4
|
+
// catalog()) to recover the (entityLocalId, component.field) path for a
|
|
5
|
+
// sub-asset GUID. Driven through an AssetRegistry with a mock ShaderRegistry.
|
|
6
|
+
|
|
7
|
+
import { defineComponent } from '@forgeax/engine-ecs';
|
|
8
|
+
import type { Asset } from '@forgeax/engine-types';
|
|
9
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
10
|
+
import { AssetRegistry } from '../asset-registry';
|
|
11
|
+
import { buildSceneChildContext } from '../registry/instantiate';
|
|
12
|
+
|
|
13
|
+
const T709CtxMeshFilter = defineComponent('T709CtxMeshFilter', {
|
|
14
|
+
assetHandle: 'shared<MeshAsset>',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
function makeRegistry(): AssetRegistry {
|
|
18
|
+
return new AssetRegistry(
|
|
19
|
+
{
|
|
20
|
+
getMaterialShaderManifest: vi.fn().mockReturnValue(undefined),
|
|
21
|
+
findMaterialArtifact: vi.fn().mockReturnValue({ ok: false, error: new Error('mock') }),
|
|
22
|
+
getPipeline: vi.fn().mockReturnValue(undefined),
|
|
23
|
+
installMaterialArtifact: vi.fn(),
|
|
24
|
+
inspect: vi.fn().mockReturnValue({ materialShaders: [] }),
|
|
25
|
+
} as unknown as import('@forgeax/engine-shader').ShaderRegistry,
|
|
26
|
+
undefined,
|
|
27
|
+
undefined,
|
|
28
|
+
undefined,
|
|
29
|
+
undefined,
|
|
30
|
+
new Map([[T709CtxMeshFilter.name, T709CtxMeshFilter]]),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const SUB_GUID = 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa';
|
|
35
|
+
|
|
36
|
+
function sceneWithMeshRef(): Asset & { kind: 'scene' } {
|
|
37
|
+
return {
|
|
38
|
+
kind: 'scene',
|
|
39
|
+
entities: [{ localId: 7, components: { T709CtxMeshFilter: { assetHandle: SUB_GUID } } }],
|
|
40
|
+
mounts: [],
|
|
41
|
+
} as unknown as Asset & { kind: 'scene' };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
describe('buildSceneChildContext', () => {
|
|
45
|
+
it('recovers entityLocalId + component.field via the entity walk fallback', () => {
|
|
46
|
+
const reg = makeRegistry();
|
|
47
|
+
const ctx = buildSceneChildContext(reg, sceneWithMeshRef(), SUB_GUID.toLowerCase());
|
|
48
|
+
expect(ctx?.sceneEntityId).toBe(7);
|
|
49
|
+
expect(ctx?.componentField).toBe('T709CtxMeshFilter.assetHandle');
|
|
50
|
+
expect(ctx?.sourceField).toMatchObject({
|
|
51
|
+
componentName: 'T709CtxMeshFilter',
|
|
52
|
+
fieldName: 'assetHandle',
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('returns undefined when the sub-asset GUID is not referenced by any entity', () => {
|
|
57
|
+
const reg = makeRegistry();
|
|
58
|
+
const ctx = buildSceneChildContext(
|
|
59
|
+
reg,
|
|
60
|
+
sceneWithMeshRef(),
|
|
61
|
+
'ffffffff-ffff-4fff-8fff-ffffffffffff',
|
|
62
|
+
);
|
|
63
|
+
expect(ctx).toBeUndefined();
|
|
64
|
+
});
|
|
65
|
+
});
|