Set gravity survives a re-read of the model during play: World.setSceneProp remembers what the run itself set on the scene and syncFromModel lays it back over the copied scene props, so a project event mid-play no longer resets the gravity to the saved 980; the unit test re-reads the model mid-run and e2e 41c forces a project event right after play starts (#147)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ff3c8b742
commit
328f978d3c
4 files changed
+22
-5
No files matched your search
@@ -586,13 +586,19 @@ describe('physics from the graph (#147)', () => {
|
||||
|
||||
it('Set gravity turns the fall around for the rest of the run; the scene in the project keeps its own', () => {
|
||||
const f = physicsScene();
|
||||
f.gravity(0, 980);
|
||||
const box = f.add(0, 0, { w: 32, body: {} });
|
||||
onOwner(f, box, 'OnStart', 'SetGravity', { x: 0, y: -980 }, true);
|
||||
const { seconds, entity, world } = run(f);
|
||||
seconds(0.5);
|
||||
seconds(0.25);
|
||||
// A model event while playing re-reads the scene, after the tick wrote back (as in PlaySession);
|
||||
// the run's own gravity outlives it.
|
||||
world.syncToModel();
|
||||
world.syncFromModel();
|
||||
seconds(0.25);
|
||||
expect(entity(box).y).toBeLessThan(-100);
|
||||
expect(world.sceneProps.gravityY).toBe(-980);
|
||||
expect(findAsset(f.project, f.sceneId)!.props.gravityY ?? 980).toBe(980);
|
||||
expect(findAsset(f.project, f.sceneId)!.props.gravityY).toBe(980);
|
||||
});
|
||||
|
||||
it('moving a dynamic body directly keeps its speed and says so once; a physics node on an object without one says so once', () => {
|
||||
|
||||
Reference in new issue
Block a user