@forgeax/engine-scene 0.1.3 → 0.1.6
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/.tsbuildinfo +1 -1
- package/dist/collect-subtree.d.ts +4 -0
- package/dist/collect-subtree.d.ts.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +169 -605
- package/dist/index.mjs.map +1 -1
- package/dist/instances/scene-instances.d.ts +9 -8
- package/dist/instances/scene-instances.d.ts.map +1 -1
- package/package.json +4 -5
- package/src/__tests__/asset-owner.integration.test.ts +15 -203
- package/src/collect-subtree.ts +30 -0
- package/src/index.ts +3 -16
- package/src/instances/scene-instances.ts +26 -27
- package/dist/assets/instantiate-scene.d.ts +0 -7
- package/dist/assets/instantiate-scene.d.ts.map +0 -1
- package/dist/assets/publication-observer.d.ts +0 -13
- package/dist/assets/publication-observer.d.ts.map +0 -1
- package/dist/assets/scene-projection.d.ts +0 -70
- package/dist/assets/scene-projection.d.ts.map +0 -1
- package/src/assets/instantiate-scene.ts +0 -14
- package/src/assets/publication-observer.ts +0 -24
- package/src/assets/scene-projection.ts +0 -644
|
@@ -93,18 +93,10 @@ export interface SceneMembersSpawn {
|
|
|
93
93
|
readonly totalSlots: number;
|
|
94
94
|
}
|
|
95
95
|
export type SceneAssetResolver = (source: number | string, parentHandle: Handle<'SceneAsset', 'shared'>) => Result<Handle<'SceneAsset', 'shared'>, unknown>;
|
|
96
|
-
export type SceneInstantiateHook = (world: World, root: EntityHandle) => {
|
|
97
|
-
readonly ok: true;
|
|
98
|
-
} | {
|
|
99
|
-
readonly ok: false;
|
|
100
|
-
readonly error: unknown;
|
|
101
|
-
};
|
|
102
96
|
/** @internal */
|
|
103
97
|
export declare function worldSetSceneAssetResolver(world: World, resolver: SceneAssetResolver): void;
|
|
104
98
|
/** @internal */
|
|
105
99
|
export declare function worldGetSceneAssetResolver(world: World): SceneAssetResolver | null;
|
|
106
|
-
/** @internal Install the owner post-instantiate boundary for one World. */
|
|
107
|
-
export declare function worldSetSceneInstantiateHook(world: World, hook: SceneInstantiateHook | null): void;
|
|
108
100
|
/**
|
|
109
101
|
* Materialise a SceneAsset (and any nested SceneAsset references via
|
|
110
102
|
* `mounts[]`) into live entities. Returns the synthetic root Entity that
|
|
@@ -127,6 +119,15 @@ export declare function worldSetSceneInstantiateHook(world: World, hook: SceneIn
|
|
|
127
119
|
* const member = inst.mapping[0]; // first member entity
|
|
128
120
|
*/
|
|
129
121
|
export declare function worldInstantiateScene(world: World, handle: Handle<'SceneAsset', 'shared'>, parent?: EntityHandle): Result<SceneInstantiateOk, EcsError>;
|
|
122
|
+
/**
|
|
123
|
+
* Materialise a projected `SceneAsset` payload without exposing the temporary
|
|
124
|
+
* shared-ref handle to the caller. The World remains the owner of both the
|
|
125
|
+
* handle and the instantiated SceneInstance: the producer grant is released
|
|
126
|
+
* after the SceneInstance retains its source, including when instantiation
|
|
127
|
+
* fails. This is the payload-shaped counterpart to `worldInstantiateScene` for
|
|
128
|
+
* hosts that load a SceneAsset directly from the Engine AssetRegistry.
|
|
129
|
+
*/
|
|
130
|
+
export declare function worldInstantiateScenePayload(world: World, asset: SceneAsset, parent?: EntityHandle): Result<SceneInstantiateOk, EcsError>;
|
|
130
131
|
/**
|
|
131
132
|
* Materialise a SceneAsset FLAT — the "edit the scene itself" primitive.
|
|
132
133
|
* Unlike `instantiateScene`, this mints NO synthetic SceneInstance root and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene-instances.d.ts","sourceRoot":"","sources":["../../src/instances/scene-instances.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,QAAQ,EAEb,KAAK,YAAY,EAEjB,KAAK,OAAO,EACZ,KAAK,KAAK,EACX,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb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
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,10 +22,9 @@
|
|
|
22
22
|
"LICENSE"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@forgeax/engine-ecs": "0.1.
|
|
26
|
-
"@forgeax/engine-math": "0.1.
|
|
27
|
-
"@forgeax/engine-
|
|
28
|
-
"@forgeax/engine-plugin": "0.1.3"
|
|
25
|
+
"@forgeax/engine-ecs": "0.1.6",
|
|
26
|
+
"@forgeax/engine-math": "0.1.6",
|
|
27
|
+
"@forgeax/engine-plugin": "0.1.6"
|
|
29
28
|
},
|
|
30
29
|
"forgeax": {
|
|
31
30
|
"metrics": {
|
|
@@ -1,34 +1,17 @@
|
|
|
1
1
|
import { defineComponent, World } from '@forgeax/engine-ecs';
|
|
2
|
-
import {
|
|
3
|
-
import { err, ok, type SceneAsset } from '@forgeax/engine-types';
|
|
2
|
+
import type { SceneAsset } from '@forgeax/engine-types';
|
|
4
3
|
import { describe, expect, it } from 'vitest';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
projectSceneAsset,
|
|
8
|
-
SCENE_ASSET_MESH_DEFAULT_RESOLVER_RESOURCE_KEY,
|
|
9
|
-
type SceneAssetMeshDefaultResolver,
|
|
10
|
-
} from '../assets/scene-projection';
|
|
11
|
-
import { ChildOf, Children } from '../components/children';
|
|
12
|
-
import {
|
|
13
|
-
worldInstantiateScene,
|
|
14
|
-
worldInstantiateSceneFlat,
|
|
15
|
-
worldSetSceneInstantiateHook,
|
|
16
|
-
} from '../instances/scene-instances';
|
|
4
|
+
import { ChildOf, Children, worldDespawnScene, worldInstantiateScenePayload } from '../index';
|
|
17
5
|
|
|
18
6
|
const SceneInstance = defineComponent('SceneInstance', {
|
|
19
7
|
source: { type: 'shared<SceneAsset>' },
|
|
20
8
|
mapping: { type: 'array<entity>' },
|
|
21
9
|
state: { type: 'unique<SceneInstanceState>' },
|
|
22
10
|
});
|
|
23
|
-
const SceneMarker = defineComponent('
|
|
24
|
-
const SceneAssetRefs = defineComponent('M2SceneAssetRefs', {
|
|
25
|
-
mesh: 'shared<MeshAsset>',
|
|
26
|
-
materials: 'array<shared<MaterialAsset>>',
|
|
27
|
-
});
|
|
28
|
-
void SceneAssetRefs;
|
|
11
|
+
const SceneMarker = defineComponent('ScenePayloadMarker', { value: 'i32' });
|
|
29
12
|
|
|
30
13
|
function registerSceneWorld(world: World): void {
|
|
31
|
-
for (const component of [SceneInstance, ChildOf, Children, SceneMarker
|
|
14
|
+
for (const component of [SceneInstance, ChildOf, Children, SceneMarker]) {
|
|
32
15
|
world.components.register(component).unwrap();
|
|
33
16
|
}
|
|
34
17
|
}
|
|
@@ -39,207 +22,36 @@ function scene(): SceneAsset {
|
|
|
39
22
|
entities: [
|
|
40
23
|
{
|
|
41
24
|
localId: 0 as never,
|
|
42
|
-
components: {
|
|
25
|
+
components: { ScenePayloadMarker: { value: 7 } },
|
|
43
26
|
},
|
|
44
27
|
],
|
|
45
28
|
};
|
|
46
29
|
}
|
|
47
30
|
|
|
48
|
-
describe('scene
|
|
49
|
-
it('
|
|
31
|
+
describe('scene payload ownership', () => {
|
|
32
|
+
it('retains the payload for the mounted instance and releases it on despawn', () => {
|
|
50
33
|
const world = new World();
|
|
51
34
|
registerSceneWorld(world);
|
|
52
|
-
const handle = world.allocSharedRef('SceneAsset', scene());
|
|
53
35
|
|
|
54
|
-
const result =
|
|
36
|
+
const result = worldInstantiateScenePayload(world, scene());
|
|
55
37
|
|
|
56
38
|
expect(result.ok).toBe(true);
|
|
57
|
-
expect(world.sharedRefs.
|
|
39
|
+
expect(world.sharedRefs._liveCount()).toBe(1);
|
|
58
40
|
if (!result.ok) return;
|
|
59
|
-
expect(result.value.
|
|
60
|
-
expect(world.
|
|
61
|
-
ok: true,
|
|
62
|
-
value: { value: 7 },
|
|
63
|
-
});
|
|
41
|
+
expect(worldDespawnScene(world, result.value.root).ok).toBe(true);
|
|
42
|
+
expect(world.sharedRefs._liveCount()).toBe(0);
|
|
64
43
|
});
|
|
65
44
|
|
|
66
|
-
it('
|
|
45
|
+
it('releases the temporary producer grant when materialisation fails', () => {
|
|
67
46
|
const world = new World();
|
|
68
47
|
registerSceneWorld(world);
|
|
69
|
-
|
|
48
|
+
|
|
49
|
+
const result = worldInstantiateScenePayload(world, {
|
|
70
50
|
kind: 'scene',
|
|
71
51
|
entities: [{ localId: 0 as never, components: { MissingComponent: { value: 1 } } }],
|
|
72
52
|
} as SceneAsset);
|
|
73
53
|
|
|
74
|
-
const result = worldInstantiateSceneFlat(world, invalid);
|
|
75
|
-
|
|
76
54
|
expect(result.ok).toBe(false);
|
|
77
|
-
|
|
78
|
-
expect(query.ok ? Array.from(query.value) : []).toHaveLength(0);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('rolls back the materialized subtree when an owner hook fails', () => {
|
|
82
|
-
const world = new World();
|
|
83
|
-
registerSceneWorld(world);
|
|
84
|
-
const handle = world.allocSharedRef('SceneAsset', scene());
|
|
85
|
-
const expected = { code: 'scene-owner-hook-failed' };
|
|
86
|
-
worldSetSceneInstantiateHook(world, () => ({ ok: false, error: expected }));
|
|
87
|
-
|
|
88
|
-
const result = worldInstantiateScene(world, handle);
|
|
89
|
-
|
|
90
|
-
expect(result).toEqual({ ok: false, error: expected });
|
|
91
|
-
const query = world.query({ read: [SceneMarker] });
|
|
92
|
-
expect(query.ok ? Array.from(query.value) : []).toHaveLength(0);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('keeps Pack refs[] indices for World-local shared-field projection', async () => {
|
|
96
|
-
const decoded = await sceneAssetDecoder.decode({
|
|
97
|
-
envelope: {
|
|
98
|
-
guid: 'scene-guid',
|
|
99
|
-
kind: 'scene',
|
|
100
|
-
refs: ['mesh-guid', 'material-guid'],
|
|
101
|
-
artifacts: {},
|
|
102
|
-
payload: {
|
|
103
|
-
kind: 'scene',
|
|
104
|
-
entities: [
|
|
105
|
-
{
|
|
106
|
-
localId: 0 as never,
|
|
107
|
-
components: {
|
|
108
|
-
M2SceneAssetRefs: { mesh: 0, materials: [1] },
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
} as unknown as SceneAsset,
|
|
113
|
-
},
|
|
114
|
-
artifacts: { read: async () => err({ code: 'asset-artifact-missing' } as never) },
|
|
115
|
-
signal: new AbortController().signal,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
expect(decoded.ok).toBe(true);
|
|
119
|
-
if (!decoded.ok) return;
|
|
120
|
-
expect(decoded.value.entities[0]?.components.M2SceneAssetRefs).toEqual({
|
|
121
|
-
mesh: 0,
|
|
122
|
-
materials: [1],
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const world = new World();
|
|
126
|
-
registerSceneWorld(world);
|
|
127
|
-
const projected = await projectSceneAsset(world, decoded.value, async (guid, kind) =>
|
|
128
|
-
ok({ kind, guid }),
|
|
129
|
-
);
|
|
130
|
-
expect(projected.ok).toBe(true);
|
|
131
|
-
if (!projected.ok) return;
|
|
132
|
-
const fields = projected.value.entities[0]?.components.M2SceneAssetRefs as Record<
|
|
133
|
-
string,
|
|
134
|
-
unknown
|
|
135
|
-
>;
|
|
136
|
-
expect(world.sharedRefs.resolve(fields.mesh as never)).toMatchObject({
|
|
137
|
-
value: { kind: 'mesh', guid: 'mesh-guid' },
|
|
138
|
-
});
|
|
139
|
-
expect(world.sharedRefs.resolve((fields.materials as unknown[])[0] as never)).toMatchObject({
|
|
140
|
-
value: { kind: 'material', guid: 'material-guid' },
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('projects GUID fields and nested mounts into World-owned shared refs', async () => {
|
|
145
|
-
const world = new World();
|
|
146
|
-
registerSceneWorld(world);
|
|
147
|
-
const child: SceneAsset = {
|
|
148
|
-
kind: 'scene',
|
|
149
|
-
entities: [{ localId: 0 as never, components: { M2SceneOwnerMarker: { value: 1 } } }],
|
|
150
|
-
};
|
|
151
|
-
const root: SceneAsset = {
|
|
152
|
-
kind: 'scene',
|
|
153
|
-
entities: [
|
|
154
|
-
{
|
|
155
|
-
localId: 0 as never,
|
|
156
|
-
components: {
|
|
157
|
-
M2SceneAssetRefs: { mesh: 'mesh-guid', materials: ['material-guid'] },
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
mounts: [
|
|
162
|
-
{
|
|
163
|
-
localId: 1 as never,
|
|
164
|
-
source: 'child-guid',
|
|
165
|
-
memberFirst: 2 as never,
|
|
166
|
-
memberCount: 1,
|
|
167
|
-
components: { M2SceneOwnerMarker: { value: 2 } },
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
};
|
|
171
|
-
const payloads: Record<string, unknown> = {
|
|
172
|
-
'mesh-guid': { kind: 'mesh' },
|
|
173
|
-
'material-guid': { kind: 'material' },
|
|
174
|
-
'child-guid': child,
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const projected = await projectSceneAsset(world, root, async (guid, kind) => {
|
|
178
|
-
const payload = payloads[guid];
|
|
179
|
-
if (payload === undefined) return err({ code: 'asset-not-found' } as never);
|
|
180
|
-
expect((payload as { readonly kind: string }).kind).toBe(kind);
|
|
181
|
-
return ok(payload);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
expect(projected.ok).toBe(true);
|
|
185
|
-
if (!projected.ok) return;
|
|
186
|
-
const fields = projected.value.entities[0]?.components.M2SceneAssetRefs as Record<
|
|
187
|
-
string,
|
|
188
|
-
unknown
|
|
189
|
-
>;
|
|
190
|
-
expect(typeof fields.mesh).toBe('number');
|
|
191
|
-
expect(Array.isArray(fields.materials)).toBe(true);
|
|
192
|
-
const mountSource = projected.value.mounts?.[0]?.source;
|
|
193
|
-
expect(typeof mountSource).toBe('number');
|
|
194
|
-
expect(world.sharedRefs.resolve(fields.mesh as never)).toMatchObject({
|
|
195
|
-
value: { kind: 'mesh' },
|
|
196
|
-
});
|
|
197
|
-
expect(world.sharedRefs.resolve(mountSource as never)).toMatchObject({
|
|
198
|
-
value: { kind: 'scene' },
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
const sceneHandle = world.allocSharedRef('SceneAsset', projected.value);
|
|
202
|
-
const instantiated = worldInstantiateScene(world, sceneHandle);
|
|
203
|
-
expect(instantiated.ok).toBe(true);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('projects mesh-owned material defaults into the World render view', async () => {
|
|
207
|
-
const world = new World();
|
|
208
|
-
registerSceneWorld(world);
|
|
209
|
-
const materialGuid = '019eb2cf-0001-7000-8000-deadbeef0002';
|
|
210
|
-
const parsedGuid = AssetGuid.parse(materialGuid);
|
|
211
|
-
expect(parsedGuid.ok).toBe(true);
|
|
212
|
-
if (!parsedGuid.ok) return;
|
|
213
|
-
|
|
214
|
-
const root: SceneAsset = {
|
|
215
|
-
kind: 'scene',
|
|
216
|
-
entities: [
|
|
217
|
-
{
|
|
218
|
-
localId: 0 as never,
|
|
219
|
-
components: { M2SceneAssetRefs: { mesh: 'mesh-guid', materials: [] } },
|
|
220
|
-
},
|
|
221
|
-
],
|
|
222
|
-
};
|
|
223
|
-
const payloads: Record<string, unknown> = {
|
|
224
|
-
'mesh-guid': {
|
|
225
|
-
kind: 'mesh',
|
|
226
|
-
materialSlots: [{ slotName: 'Default', defaultMaterial: parsedGuid.value }],
|
|
227
|
-
},
|
|
228
|
-
[materialGuid]: { kind: 'material' },
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
const projected = await projectSceneAsset(world, root, async (guid, kind) => {
|
|
232
|
-
const payload = payloads[guid.toLowerCase()];
|
|
233
|
-
if (payload === undefined) return err({ code: 'asset-not-found' } as never);
|
|
234
|
-
expect((payload as { readonly kind: string }).kind).toBe(kind);
|
|
235
|
-
return ok(payload);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
expect(projected.ok).toBe(true);
|
|
239
|
-
if (!projected.ok) return;
|
|
240
|
-
const resolver = world.getResource<SceneAssetMeshDefaultResolver>(
|
|
241
|
-
SCENE_ASSET_MESH_DEFAULT_RESOLVER_RESOURCE_KEY,
|
|
242
|
-
);
|
|
243
|
-
expect(resolver.resolveMeshDefaultMaterial(materialGuid)).toBeGreaterThan(0);
|
|
55
|
+
expect(world.sharedRefs._liveCount()).toBe(0);
|
|
244
56
|
});
|
|
245
57
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Scene-owned hierarchy traversal shared by scene collection and render hooks.
|
|
2
|
+
|
|
3
|
+
import type { EntityHandle, World } from '@forgeax/engine-ecs';
|
|
4
|
+
|
|
5
|
+
import { Children } from './components/children';
|
|
6
|
+
|
|
7
|
+
/** Walk a Children hierarchy breadth-first, reusing an optional visited set. */
|
|
8
|
+
export function collectSubtree(
|
|
9
|
+
world: World,
|
|
10
|
+
spawnRoot: EntityHandle,
|
|
11
|
+
visited?: Set<number>,
|
|
12
|
+
): Set<number> {
|
|
13
|
+
if (visited === undefined) visited = new Set<number>();
|
|
14
|
+
if (visited.has(spawnRoot as number)) return visited;
|
|
15
|
+
const queue: number[] = [spawnRoot as number];
|
|
16
|
+
visited.add(spawnRoot as number);
|
|
17
|
+
while (queue.length > 0) {
|
|
18
|
+
const current = queue.shift() as number;
|
|
19
|
+
const children = world.get(current as EntityHandle, Children);
|
|
20
|
+
if (!children.ok) continue;
|
|
21
|
+
const entities = children.value.entities as ArrayLike<number>;
|
|
22
|
+
for (let index = 0; index < entities.length; index += 1) {
|
|
23
|
+
const child = entities[index] as number;
|
|
24
|
+
if (visited.has(child)) continue;
|
|
25
|
+
visited.add(child);
|
|
26
|
+
queue.push(child);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return visited;
|
|
30
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
sceneAssetDecoder,
|
|
4
|
-
sceneAssetKind,
|
|
5
|
-
} from './assets/scene-decoder';
|
|
6
|
-
export {
|
|
7
|
-
projectSceneAsset,
|
|
8
|
-
SCENE_ASSET_MESH_DEFAULT_RESOLVER_RESOURCE_KEY,
|
|
9
|
-
SCENE_ASSET_SKIN_RESOLVER_RESOURCE_KEY,
|
|
10
|
-
type SceneAssetMeshDefaultResolver,
|
|
11
|
-
type SceneAssetProjectionError,
|
|
12
|
-
type SceneAssetReferenceLoader,
|
|
13
|
-
type SceneAssetSkinResolver,
|
|
14
|
-
} from './assets/scene-projection';
|
|
1
|
+
export { sceneAssetContribution } from './assets/scene-decoder';
|
|
2
|
+
export { collectSubtree } from './collect-subtree';
|
|
15
3
|
export { ChildOf } from './components/child-of';
|
|
16
4
|
export { Children } from './components/children';
|
|
17
5
|
export { MorphWeights } from './components/morph-weights';
|
|
@@ -35,7 +23,6 @@ export {
|
|
|
35
23
|
type SceneInstanceStatePayload,
|
|
36
24
|
type SceneInstantiateDiagnostic,
|
|
37
25
|
type SceneInstantiateFlatOk,
|
|
38
|
-
type SceneInstantiateHook,
|
|
39
26
|
type SceneInstantiateOk,
|
|
40
27
|
type SceneMembersSpawn,
|
|
41
28
|
worldApplyMountOverride,
|
|
@@ -50,6 +37,7 @@ export {
|
|
|
50
37
|
worldInstantiateSceneAsset,
|
|
51
38
|
worldInstantiateSceneAssetFlat,
|
|
52
39
|
worldInstantiateSceneFlat,
|
|
40
|
+
worldInstantiateScenePayload,
|
|
53
41
|
worldInstantiateSceneRec,
|
|
54
42
|
worldMountOverridesToStateMap,
|
|
55
43
|
worldReattachSceneMember,
|
|
@@ -58,7 +46,6 @@ export {
|
|
|
58
46
|
worldResolveSceneAsset,
|
|
59
47
|
worldResolveSceneInstanceStatePayload,
|
|
60
48
|
worldSetSceneAssetResolver,
|
|
61
|
-
worldSetSceneInstantiateHook,
|
|
62
49
|
worldSetSceneOverride,
|
|
63
50
|
worldSpawnMountEntity,
|
|
64
51
|
worldSpawnSceneMembers,
|
|
@@ -139,24 +139,14 @@ export type SceneAssetResolver = (
|
|
|
139
139
|
interface SceneWorldState {
|
|
140
140
|
resolver: SceneAssetResolver | null;
|
|
141
141
|
readonly statePayloads: Map<number, unknown>;
|
|
142
|
-
instantiateHook: SceneInstantiateHook | null;
|
|
143
142
|
}
|
|
144
143
|
|
|
145
|
-
export type SceneInstantiateHook = (
|
|
146
|
-
world: World,
|
|
147
|
-
root: EntityHandle,
|
|
148
|
-
) => { readonly ok: true } | { readonly ok: false; readonly error: unknown };
|
|
149
|
-
|
|
150
144
|
const sceneWorldStates = new WeakMap<World, SceneWorldState>();
|
|
151
145
|
|
|
152
146
|
function sceneWorldState(world: World): SceneWorldState {
|
|
153
147
|
const current = sceneWorldStates.get(world);
|
|
154
148
|
if (current !== undefined) return current;
|
|
155
|
-
const created = {
|
|
156
|
-
resolver: null,
|
|
157
|
-
statePayloads: new Map<number, unknown>(),
|
|
158
|
-
instantiateHook: null,
|
|
159
|
-
};
|
|
149
|
+
const created = { resolver: null, statePayloads: new Map<number, unknown>() };
|
|
160
150
|
sceneWorldStates.set(world, created);
|
|
161
151
|
return created;
|
|
162
152
|
}
|
|
@@ -171,14 +161,6 @@ export function worldGetSceneAssetResolver(world: World): SceneAssetResolver | n
|
|
|
171
161
|
return sceneWorldState(world).resolver;
|
|
172
162
|
}
|
|
173
163
|
|
|
174
|
-
/** @internal Install the owner post-instantiate boundary for one World. */
|
|
175
|
-
export function worldSetSceneInstantiateHook(
|
|
176
|
-
world: World,
|
|
177
|
-
hook: SceneInstantiateHook | null,
|
|
178
|
-
): void {
|
|
179
|
-
sceneWorldState(world).instantiateHook = hook;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
164
|
/**
|
|
183
165
|
* Materialise a SceneAsset (and any nested SceneAsset references via
|
|
184
166
|
* `mounts[]`) into live entities. Returns the synthetic root Entity that
|
|
@@ -212,16 +194,33 @@ export function worldInstantiateScene(
|
|
|
212
194
|
const diagnostics: SceneInstantiateDiagnostic[] = [];
|
|
213
195
|
const r = worldInstantiateSceneRec(world, handle, parent, stack, diagnostics);
|
|
214
196
|
if (!r.ok) return r;
|
|
215
|
-
const hook = sceneWorldState(world).instantiateHook;
|
|
216
|
-
if (hook !== null) {
|
|
217
|
-
const hooked = hook(world, r.value);
|
|
218
|
-
if (!hooked.ok) {
|
|
219
|
-
worldDespawnScene(world, r.value);
|
|
220
|
-
return err(hooked.error as EcsError);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
197
|
return ok({ root: r.value, diagnostics });
|
|
224
198
|
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Materialise a projected `SceneAsset` payload without exposing the temporary
|
|
202
|
+
* shared-ref handle to the caller. The World remains the owner of both the
|
|
203
|
+
* handle and the instantiated SceneInstance: the producer grant is released
|
|
204
|
+
* after the SceneInstance retains its source, including when instantiation
|
|
205
|
+
* fails. This is the payload-shaped counterpart to `worldInstantiateScene` for
|
|
206
|
+
* hosts that load a SceneAsset directly from the Engine AssetRegistry.
|
|
207
|
+
*/
|
|
208
|
+
export function worldInstantiateScenePayload(
|
|
209
|
+
world: World,
|
|
210
|
+
asset: SceneAsset,
|
|
211
|
+
parent?: EntityHandle,
|
|
212
|
+
): Result<SceneInstantiateOk, EcsError> {
|
|
213
|
+
const handle = world.allocSharedRef('SceneAsset', asset);
|
|
214
|
+
try {
|
|
215
|
+
return worldInstantiateScene(world, handle, parent);
|
|
216
|
+
} finally {
|
|
217
|
+
// The SceneInstance source column retains the handle on success. On a
|
|
218
|
+
// failed materialisation there should be no remaining holder; either way
|
|
219
|
+
// release the producer grant owned by this convenience entrypoint.
|
|
220
|
+
world.sharedRefs.release(handle);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
225
224
|
/**
|
|
226
225
|
* Materialise a SceneAsset FLAT — the "edit the scene itself" primitive.
|
|
227
226
|
* Unlike `instantiateScene`, this mints NO synthetic SceneInstance root and
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { EntityHandle, World } from '@forgeax/engine-ecs';
|
|
2
|
-
import type { Handle, SceneAsset } from '@forgeax/engine-types';
|
|
3
|
-
import { worldInstantiateScene } from '../instances/scene-instances';
|
|
4
|
-
/** Scene-owned entry point for materialising a validated SceneAsset in a World. */
|
|
5
|
-
export declare function instantiateScene(world: World, handle: Handle<'SceneAsset', 'shared'>, parent?: EntityHandle): ReturnType<typeof worldInstantiateScene>;
|
|
6
|
-
export type SceneInstanceAsset = SceneAsset;
|
|
7
|
-
//# sourceMappingURL=instantiate-scene.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instantiate-scene.d.ts","sourceRoot":"","sources":["../../src/assets/instantiate-scene.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,mFAAmF;AACnF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,EACtC,MAAM,CAAC,EAAE,YAAY,GACpB,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAE1C;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type AssetPublicationTuple, type Result } from '@forgeax/engine-types';
|
|
2
|
-
export interface ScenePublicationObservation {
|
|
3
|
-
readonly guid: string;
|
|
4
|
-
readonly generation: number;
|
|
5
|
-
readonly digest: string;
|
|
6
|
-
}
|
|
7
|
-
/** Read-only projection of a published scene envelope for consumers. */
|
|
8
|
-
export declare function observeScenePublication(envelope: AssetPublicationTuple): Result<ScenePublicationObservation, {
|
|
9
|
-
readonly code: 'scene-publication-invalid';
|
|
10
|
-
readonly expected: string;
|
|
11
|
-
readonly hint: string;
|
|
12
|
-
}>;
|
|
13
|
-
//# sourceMappingURL=publication-observer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publication-observer.d.ts","sourceRoot":"","sources":["../../src/assets/publication-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEzF,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,wEAAwE;AACxE,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,qBAAqB,GAC9B,MAAM,CACP,2BAA2B,EAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,2BAA2B,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CACjG,CASA"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { World } from '@forgeax/engine-ecs';
|
|
2
|
-
import { type BuiltinAssetKind, type Result, type SceneAsset, type SkinAsset } from '@forgeax/engine-types';
|
|
3
|
-
/** World resource key for the scene projection's skin dependency view. */
|
|
4
|
-
export declare const SCENE_ASSET_SKIN_RESOLVER_RESOURCE_KEY = "SceneAssetSkinResolver";
|
|
5
|
-
/** World resource key for mesh-owned material default resolution. */
|
|
6
|
-
export declare const SCENE_ASSET_MESH_DEFAULT_RESOLVER_RESOURCE_KEY = "SceneAssetMeshDefaultResolver";
|
|
7
|
-
/**
|
|
8
|
-
* Scene projection output consumed by the renderer's post-instantiate hook.
|
|
9
|
-
* Scene owns the GUID-to-payload dependency view; ECS and Render only depend
|
|
10
|
-
* on this narrow resolver shape.
|
|
11
|
-
*/
|
|
12
|
-
export interface SceneAssetSkinResolver {
|
|
13
|
-
resolveSkinAsset(skeletonHandle: number): SkinAsset | undefined;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Render-facing view of material defaults loaded while projecting a scene.
|
|
17
|
-
* MeshAsset keeps these defaults as GUID facts; Render consumes World handles
|
|
18
|
-
* without importing the AssetRegistry or teaching the scene component about
|
|
19
|
-
* renderer policy.
|
|
20
|
-
*/
|
|
21
|
-
export interface SceneAssetMeshDefaultResolver {
|
|
22
|
-
resolveMeshDefaultMaterial(guid: string): number | undefined;
|
|
23
|
-
}
|
|
24
|
-
/** Errors raised while projecting a decoded SceneAsset into one World. */
|
|
25
|
-
export type SceneAssetProjectionError = {
|
|
26
|
-
readonly code: 'scene-reference-target-unsupported';
|
|
27
|
-
readonly expected: string;
|
|
28
|
-
readonly hint: string;
|
|
29
|
-
readonly detail: {
|
|
30
|
-
readonly guid: string;
|
|
31
|
-
readonly target: string;
|
|
32
|
-
readonly field: string;
|
|
33
|
-
};
|
|
34
|
-
} | {
|
|
35
|
-
readonly code: 'scene-reference-kind-mismatch';
|
|
36
|
-
readonly expected: string;
|
|
37
|
-
readonly hint: string;
|
|
38
|
-
readonly detail: {
|
|
39
|
-
readonly guid: string;
|
|
40
|
-
readonly target: string;
|
|
41
|
-
readonly expectedKind: BuiltinAssetKind;
|
|
42
|
-
readonly actualKind: string;
|
|
43
|
-
readonly field: string;
|
|
44
|
-
};
|
|
45
|
-
} | {
|
|
46
|
-
readonly code: 'scene-reference-cycle';
|
|
47
|
-
readonly expected: string;
|
|
48
|
-
readonly hint: string;
|
|
49
|
-
readonly detail: {
|
|
50
|
-
readonly cycle: readonly string[];
|
|
51
|
-
};
|
|
52
|
-
} | {
|
|
53
|
-
readonly code: 'scene-reference-unresolved';
|
|
54
|
-
readonly expected: string;
|
|
55
|
-
readonly hint: string;
|
|
56
|
-
readonly detail: {
|
|
57
|
-
readonly source: string;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
/** Loader seam supplied by the current App-owned AssetRegistry. */
|
|
61
|
-
export type SceneAssetReferenceLoader<E = unknown> = (guid: string, kind: BuiltinAssetKind) => Promise<Result<unknown, E>>;
|
|
62
|
-
type ProjectError<E> = E | SceneAssetProjectionError;
|
|
63
|
-
/**
|
|
64
|
-
* Convert decoded GUID fields and nested SceneAsset mounts into references
|
|
65
|
-
* owned by one World. The AssetRegistry remains a loader; this World-facing
|
|
66
|
-
* projection belongs to Scene and is intentionally explicit at each consumer.
|
|
67
|
-
*/
|
|
68
|
-
export declare function projectSceneAsset<E = unknown>(world: World, asset: SceneAsset, load: SceneAssetReferenceLoader<E>): Promise<Result<SceneAsset, ProjectError<E>>>;
|
|
69
|
-
export {};
|
|
70
|
-
//# sourceMappingURL=scene-projection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scene-projection.d.ts","sourceRoot":"","sources":["../../src/assets/scene-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGjD,OAAO,EACL,KAAK,gBAAgB,EAOrB,KAAK,MAAM,EACX,KAAK,UAAU,EAGf,KAAK,SAAS,EAEf,MAAM,uBAAuB,CAAC;AAI/B,0EAA0E;AAC1E,eAAO,MAAM,sCAAsC,2BAA2B,CAAC;AAE/E,qEAAqE;AACrE,eAAO,MAAM,8CAA8C,kCAAkC,CAAC;AAE9F;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CACjE;AAED;;;;;GAKG;AACH,MAAM,WAAW,6BAA6B;IAC5C,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC9D;AAED,0EAA0E;AAC1E,MAAM,MAAM,yBAAyB,GACjC;IACE,QAAQ,CAAC,IAAI,EAAE,oCAAoC,CAAC;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,C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AAC,CAAC;AAqBjC,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC;AAigBrD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EACjD,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,yBAAyB,CAAC,CAAC,CAAC,GACjC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAiB9C"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { EntityHandle, World } from '@forgeax/engine-ecs';
|
|
2
|
-
import type { Handle, SceneAsset } from '@forgeax/engine-types';
|
|
3
|
-
import { worldInstantiateScene } from '../instances/scene-instances';
|
|
4
|
-
|
|
5
|
-
/** Scene-owned entry point for materialising a validated SceneAsset in a World. */
|
|
6
|
-
export function instantiateScene(
|
|
7
|
-
world: World,
|
|
8
|
-
handle: Handle<'SceneAsset', 'shared'>,
|
|
9
|
-
parent?: EntityHandle,
|
|
10
|
-
): ReturnType<typeof worldInstantiateScene> {
|
|
11
|
-
return worldInstantiateScene(world, handle, parent);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type SceneInstanceAsset = SceneAsset;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type AssetPublicationTuple, err, ok, type Result } from '@forgeax/engine-types';
|
|
2
|
-
|
|
3
|
-
export interface ScenePublicationObservation {
|
|
4
|
-
readonly guid: string;
|
|
5
|
-
readonly generation: number;
|
|
6
|
-
readonly digest: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/** Read-only projection of a published scene envelope for consumers. */
|
|
10
|
-
export function observeScenePublication(
|
|
11
|
-
envelope: AssetPublicationTuple,
|
|
12
|
-
): Result<
|
|
13
|
-
ScenePublicationObservation,
|
|
14
|
-
{ readonly code: 'scene-publication-invalid'; readonly expected: string; readonly hint: string }
|
|
15
|
-
> {
|
|
16
|
-
if (!Number.isSafeInteger(envelope.generation) || envelope.generation < 1) {
|
|
17
|
-
return err({
|
|
18
|
-
code: 'scene-publication-invalid',
|
|
19
|
-
expected: 'a positive publication generation',
|
|
20
|
-
hint: 'publish the scene envelope with a monotonic generation',
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return ok({ guid: envelope.scopeId, generation: envelope.generation, digest: envelope.digest });
|
|
24
|
-
}
|