@forgeax/engine-scene 0.1.20 → 0.1.23
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 +37 -9
- package/dist/__tests__/flat-propagation.contract.test.d.ts +2 -0
- package/dist/__tests__/flat-propagation.contract.test.d.ts.map +1 -0
- package/dist/__tests__/flat-propagation.derived-writer.contract.test.d.ts +2 -0
- package/dist/__tests__/flat-propagation.derived-writer.contract.test.d.ts.map +1 -0
- package/dist/__tests__/flat-propagation.perf.test.d.ts +2 -0
- package/dist/__tests__/flat-propagation.perf.test.d.ts.map +1 -0
- package/dist/__tests__/scene-binding.integration.test.d.ts +2 -0
- package/dist/__tests__/scene-binding.integration.test.d.ts.map +1 -0
- package/dist/__tests__/schedule-order.contract.test.d.ts +2 -0
- package/dist/__tests__/schedule-order.contract.test.d.ts.map +1 -0
- package/dist/__tests__/structural.test.d.ts +2 -0
- package/dist/__tests__/structural.test.d.ts.map +1 -0
- package/dist/__tests__/transform-carrier-consumers.test-d.d.ts +2 -0
- package/dist/__tests__/transform-carrier-consumers.test-d.d.ts.map +1 -0
- package/dist/__tests__/transform-carrier-prototype.bench.d.ts +39 -0
- package/dist/__tests__/transform-carrier-prototype.bench.d.ts.map +1 -0
- package/dist/__tests__/transform-carrier-prototype.test-d.d.ts +2 -0
- package/dist/__tests__/transform-carrier-prototype.test-d.d.ts.map +1 -0
- package/dist/__tests__/transform-carrier-prototype.test.d.ts +2 -0
- package/dist/__tests__/transform-carrier-prototype.test.d.ts.map +1 -0
- package/dist/__tests__/transform-component-version.unit.test.d.ts +2 -0
- package/dist/__tests__/transform-component-version.unit.test.d.ts.map +1 -0
- package/dist/assets/scene-decoder.d.ts.map +1 -1
- package/dist/components/child-of.d.ts +15 -8
- package/dist/components/child-of.d.ts.map +1 -1
- package/dist/components/children.d.ts.map +1 -1
- package/dist/components/transform.d.ts +7 -43
- package/dist/components/transform.d.ts.map +1 -1
- package/dist/errors.d.ts +23 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +616 -372
- package/dist/index.mjs.map +1 -1
- package/dist/instances/binding.d.ts +29 -0
- package/dist/instances/binding.d.ts.map +1 -0
- package/dist/instances/externalization.d.ts.map +1 -1
- package/dist/instances/scene-instances.d.ts +5 -17
- package/dist/instances/scene-instances.d.ts.map +1 -1
- package/dist/instances/state.d.ts +28 -0
- package/dist/instances/state.d.ts.map +1 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/systems/hierarchy-projection.d.ts.map +1 -1
- package/dist/systems/index.d.ts +1 -1
- package/dist/systems/index.d.ts.map +1 -1
- package/dist/systems/propagate-transforms.d.ts +1 -2
- package/dist/systems/propagate-transforms.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/components.unit.test.ts +34 -2
- package/src/__tests__/flat-propagation.contract.test.ts +128 -0
- package/src/__tests__/flat-propagation.derived-writer.contract.test.ts +39 -0
- package/src/__tests__/flat-propagation.perf.test.ts +336 -0
- package/src/__tests__/plugin.integration.test.ts +2 -2
- package/src/__tests__/propagation.unit.test.ts +207 -91
- package/src/__tests__/scene-binding.integration.test.ts +124 -0
- package/src/__tests__/schedule-order.contract.test.ts +43 -0
- package/src/__tests__/structural.test.ts +23 -0
- package/src/__tests__/transform-carrier-consumers.test-d.ts +156 -0
- package/src/__tests__/transform-carrier-prototype.bench.ts +168 -0
- package/src/__tests__/transform-carrier-prototype.test-d.ts +71 -0
- package/src/__tests__/transform-carrier-prototype.test.ts +170 -0
- package/src/__tests__/{transform-change-journal.unit.test.ts → transform-component-version.unit.test.ts} +32 -39
- package/src/assets/scene-decoder.ts +6 -1
- package/src/components/child-of.ts +15 -8
- package/src/components/children.ts +6 -0
- package/src/components/transform.ts +23 -81
- package/src/errors.ts +26 -2
- package/src/index.ts +10 -1
- package/src/instances/binding.ts +77 -0
- package/src/instances/externalization.ts +7 -1
- package/src/instances/scene-instances.ts +47 -76
- package/src/instances/state.ts +62 -0
- package/src/plugin.ts +9 -2
- package/src/systems/hierarchy-projection.ts +25 -8
- package/src/systems/index.ts +3 -0
- package/src/systems/propagate-transforms.ts +376 -245
- package/dist/.tsbuildinfo +0 -1
- package/dist/__tests__/transform-change-journal.unit.test.d.ts +0 -2
- package/dist/__tests__/transform-change-journal.unit.test.d.ts.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Entity, type EntityHandle, type World } from '@forgeax/engine-ecs';
|
|
2
|
-
import { createWorldProjection } from '@forgeax/engine-ecs/projection';
|
|
1
|
+
import { Entity, type EntityHandle, type Query, type World } from '@forgeax/engine-ecs';
|
|
3
2
|
import { ChildOf } from '../components/child-of';
|
|
4
3
|
import type { SceneErrorCode, SceneErrorDetail } from '../errors';
|
|
5
4
|
|
|
@@ -17,7 +16,8 @@ export interface SceneHierarchySnapshot {
|
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
interface HierarchyProjectionCacheEntry {
|
|
20
|
-
readonly
|
|
19
|
+
readonly structureEpoch: number;
|
|
20
|
+
readonly childOfChanges: Query;
|
|
21
21
|
readonly snapshot: SceneHierarchySnapshot;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -30,6 +30,18 @@ interface HierarchyProjectionCacheEntry {
|
|
|
30
30
|
// writes are internal-only and must not mutate authored hierarchy state.
|
|
31
31
|
const HIERARCHY_PROJECTION_CACHE = new WeakMap<World, HierarchyProjectionCacheEntry>();
|
|
32
32
|
|
|
33
|
+
function createChildOfChangeQuery(world: World): Query {
|
|
34
|
+
const result = world.query({ changed: [ChildOf] });
|
|
35
|
+
if (!result.ok) throw result.error;
|
|
36
|
+
return result.value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function drainChanges(query: Query): boolean {
|
|
40
|
+
let changed = false;
|
|
41
|
+
for (const span of query.spans().unwrap()) changed ||= span.length > 0;
|
|
42
|
+
return changed;
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
function diagnostic(
|
|
34
46
|
code: SceneErrorCode,
|
|
35
47
|
entity: EntityHandle,
|
|
@@ -54,10 +66,12 @@ function diagnostic(
|
|
|
54
66
|
/** Build the only World-local projection of ChildOf parent facts. */
|
|
55
67
|
export function projectHierarchy(world: World): SceneHierarchySnapshot {
|
|
56
68
|
const cached = HIERARCHY_PROJECTION_CACHE.get(world);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
if (
|
|
70
|
+
cached !== undefined &&
|
|
71
|
+
cached.structureEpoch === world.getStructureEpoch() &&
|
|
72
|
+
!drainChanges(cached.childOfChanges)
|
|
73
|
+
) {
|
|
74
|
+
return cached.snapshot;
|
|
61
75
|
}
|
|
62
76
|
const liveEntities = new Set<EntityHandle>();
|
|
63
77
|
const authoredParents = new Map<EntityHandle, EntityHandle>();
|
|
@@ -126,8 +140,11 @@ export function projectHierarchy(world: World): SceneHierarchySnapshot {
|
|
|
126
140
|
return stableParentOf.get(entity);
|
|
127
141
|
},
|
|
128
142
|
};
|
|
143
|
+
const childOfChanges = createChildOfChangeQuery(world);
|
|
144
|
+
drainChanges(childOfChanges);
|
|
129
145
|
HIERARCHY_PROJECTION_CACHE.set(world, {
|
|
130
|
-
|
|
146
|
+
structureEpoch: world.getStructureEpoch(),
|
|
147
|
+
childOfChanges,
|
|
131
148
|
snapshot,
|
|
132
149
|
});
|
|
133
150
|
return snapshot;
|
package/src/systems/index.ts
CHANGED
|
@@ -4,8 +4,11 @@ export {
|
|
|
4
4
|
type SceneHierarchySnapshot,
|
|
5
5
|
} from './hierarchy-projection';
|
|
6
6
|
export {
|
|
7
|
+
PROPAGATE_TRANSFORMS_FIXED_SYSTEM,
|
|
7
8
|
PROPAGATE_TRANSFORMS_SYSTEM,
|
|
9
|
+
PropagateTransformsFixed,
|
|
8
10
|
propagateTransforms,
|
|
9
11
|
registerPropagateTransforms,
|
|
12
|
+
TransformFixedSet,
|
|
10
13
|
TransformSet,
|
|
11
14
|
} from './propagate-transforms';
|