From e4be2c0783c7439ea08d9e8d3818a7f1f3321abd Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 9 Jan 2023 16:10:22 +0100 Subject: [PATCH] Portal exit positioning --- protocols/schemas/scene.prs | 2 +- scene/05-common-scene.pr | 5 +++-- scene/10-lobby.pr | 2 +- scene/10-other.pr | 2 +- src/index.ts | 22 ++++++++++++++++++---- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/protocols/schemas/scene.prs b/protocols/schemas/scene.prs index a9fd37e..46a6f5d 100644 --- a/protocols/schemas/scene.prs +++ b/protocols/schemas/scene.prs @@ -1,6 +1,6 @@ version 1 . -Portal = . +Portal = . PortalDestination = / @local #!any / @remote @sturdyref sturdy.SturdyRef> diff --git a/scene/05-common-scene.pr b/scene/05-common-scene.pr index 4b863fd..28515b5 100644 --- a/scene/05-common-scene.pr +++ b/scene/05-common-scene.pr @@ -1,8 +1,9 @@ ? [ $scene [ - ? [ + ? > + ? [ $config ? [ - $scene + $scene ] ] ] diff --git a/scene/10-lobby.pr b/scene/10-lobby.pr index ac96396..b58a1e5 100644 --- a/scene/10-lobby.pr +++ b/scene/10-lobby.pr @@ -37,7 +37,7 @@ - >>>> ] >>>> - + > >>>> ] diff --git a/src/index.ts b/src/index.ts index 92179da..21c10df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -55,6 +55,7 @@ async function enterScene( runningEngine: RunningEngine, ds: Ref, sceneDs: Ref, + initialPosition: Vector3, email: Dataflow.Field, ) { const currentSceneFacet = Turn.activeFacet; @@ -65,7 +66,7 @@ async function enterScene( const camera = runningEngine.camera; camera.applyGravity = false; - camera.position = runningEngine.options.initialPos.clone(); + camera.position = initialPosition.clone(); interpretScene(id, runningEngine, rootMesh, sceneDs); @@ -130,7 +131,8 @@ async function enterScene( let needStop = true; on asserted SceneProtocol.Portal({ "name": o, - "destination": $dest: SceneProtocol.PortalDestination + "destination": $dest: SceneProtocol.PortalDestination, + "position": $targetPosition: Shapes.Vector3, }) => { needStop = false; switch (dest._variant) { @@ -138,7 +140,14 @@ async function enterScene( runningEngine.scene.removeMesh(rootMesh, true); Turn.active.stop(currentSceneFacet, () => { react { - enterScene(id, runningEngine, ds, dest.value, email); + enterScene(id, + runningEngine, + ds, + dest.value, + new Vector3(targetPosition.x, + targetPosition.y, + targetPosition.z), + email); } }); break; @@ -220,7 +229,12 @@ function bootApp(ds: Ref, runningEngine: RunningEngine) { at remoteDs { stop on asserted SceneHandle($sceneDs_e: Embedded) => { react { - enterScene(id, runningEngine, ds, sceneDs_e.embeddedValue, email); + enterScene(id, + runningEngine, + ds, + sceneDs_e.embeddedValue, + runningEngine.options.initialPos, + email); } } }