From b82fdea3c4a5635b1dfc1914664aa59d8ba1c506 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 10 Jan 2023 16:36:38 +0100 Subject: [PATCH] Repair (?) annoying gravity/loading quirk --- scene/boot/05-common-scene.pr | 2 +- src/index.ts | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/scene/boot/05-common-scene.pr b/scene/boot/05-common-scene.pr index 28515b5..f4c39cb 100644 --- a/scene/boot/05-common-scene.pr +++ b/scene/boot/05-common-scene.pr @@ -1,6 +1,6 @@ ? [ $scene [ - ? > + ? > ? [ $config ? [ $scene diff --git a/src/index.ts b/src/index.ts index 51de35a..b886dfe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -44,6 +44,15 @@ function spriteMain(spriteName: string, runningEngine: RunningEngine, rootMesh: currentShape = currentShape.reconcile(spriteName, spriteName, shape); currentShape.node.parent = rootMesh; } + + during SceneProtocol.Gravity($direction: Shapes.Vector3) => { + runningEngine.camera.applyGravity = true; + on stop runningEngine.camera.applyGravity = false; + const frameRate = 60; + runningEngine.scene.gravity = new Vector3(direction.x / frameRate, + direction.y / frameRate, + direction.z / frameRate); + } } } @@ -113,15 +122,6 @@ async function enterScene( } at sceneDs { - during SceneProtocol.Gravity($direction: Shapes.Vector3) => { - camera.applyGravity = true; - on stop camera.applyGravity = false; - const frameRate = 60; - runningEngine.scene.gravity = new Vector3(direction.x / frameRate, - direction.y / frameRate, - direction.z / frameRate); - } - on message SceneProtocol.Touch({ "subject": id, "object": $o }) => { console.log('touched', o); react { @@ -133,7 +133,8 @@ async function enterScene( }) => { const newPos = new Vector3(targetPosition.x, targetPosition.y, - targetPosition.z); + targetPosition.z) + .add(runningEngine.options.initialPos); needStop = false; switch (dest._variant) { case "local":