diff --git a/scene/10-lobby.pr b/scene/10-lobby.pr index 95311d1..d6c48c5 100644 --- a/scene/10-lobby.pr +++ b/scene/10-lobby.pr @@ -36,7 +36,7 @@ + >>>> diff --git a/scene/10-other.pr b/scene/10-other.pr index e3c30be..cbdb17e 100644 --- a/scene/10-other.pr +++ b/scene/10-other.pr @@ -8,5 +8,5 @@ >>>> - >>>> + >>>> ] diff --git a/src/index.ts b/src/index.ts index b395708..92179da 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,7 +24,7 @@ import { uuid } from './uuid.js'; assertion type SceneHandle(ds: Embedded); -function interpretScene(myId: string, scene: Scene, rootMesh: Mesh, sceneDs: Ref) { +function interpretScene(myId: string, runningEngine: RunningEngine, rootMesh: Mesh, sceneDs: Ref) { at sceneDs { during Shapes.Sprite({ "name": $name: string }) => spawn named `sprite:${name}` { if (name === myId) { @@ -32,15 +32,15 @@ function interpretScene(myId: string, scene: Scene, rootMesh: Mesh, sceneDs: Ref } else { console.log('+shape', name); on stop console.log('-shape', name); - spriteMain(name, scene, rootMesh, sceneDs); + spriteMain(name, runningEngine, rootMesh, sceneDs); } } } } -function spriteMain(spriteName: string, scene: Scene, rootMesh: Mesh, sceneDs: Ref) { +function spriteMain(spriteName: string, runningEngine: RunningEngine, rootMesh: Mesh, sceneDs: Ref) { at sceneDs { - let currentShape = ShapeTree.empty(spriteName, scene); + let currentShape = ShapeTree.empty(spriteName, runningEngine.scene); currentShape.node.parent = rootMesh; on stop currentShape.remove(); during Shapes.Sprite({ "name": spriteName, "shape": $shape: Shapes.Shape }) => { @@ -62,16 +62,18 @@ async function enterScene( console.log('enterScene', sceneDs); const rootMesh = new Mesh('--root-' + (+new Date()), runningEngine.scene); - interpretScene(id, runningEngine.scene, rootMesh, sceneDs); const camera = runningEngine.camera; camera.applyGravity = false; camera.position = runningEngine.options.initialPos.clone(); + interpretScene(id, runningEngine, rootMesh, sceneDs); + let lastTouchTime = 0; let lastTouchSpriteName = ""; camera.onCollide = (other: AbstractMesh) => { if (other.metadata?.touchable) { + console.log('collision', other.name, other.metadata); const now = +new Date(); const touched = other.metadata?.spriteName ?? ""; if ((now - lastTouchTime > 500) || (lastTouchSpriteName !== touched)) {