diff --git a/functions/api/voice/token.ts b/functions/api/voice/token.ts deleted file mode 100644 index 75bce88..0000000 --- a/functions/api/voice/token.ts +++ /dev/null @@ -1,11 +0,0 @@ -interface Env { - VOICE_TOKEN: string; -} - -const handler: ExportedHandler = { - async fetch(request, context) { - console.log(context.VOICE_TOKEN); - return new Response('Hello World 2!'); - } -} -export default handler; \ No newline at end of file diff --git a/index.html b/index.html index cd24058..0820a0b 100644 --- a/index.html +++ b/index.html @@ -25,7 +25,7 @@ -
Loading...
+
Loading...
diff --git a/src/app.ts b/src/app.ts index 23051bd..10ef5cc 100644 --- a/src/app.ts +++ b/src/app.ts @@ -13,8 +13,6 @@ import {DiagramManager} from "./diagram/diagramManager"; import {Toolbox} from "./toolbox/toolbox"; import log from "loglevel"; import {AppConfig} from "./util/appConfig"; -import {PeerjsNetworkConnection} from "./integration/peerjsNetworkConnection"; -import {InputTextView} from "./information/inputTextView"; import {GamepadManager} from "./controllers/gamepadManager"; import {CustomEnvironment} from "./util/customEnvironment"; import {DrawioManager} from "./integration/drawioManager"; @@ -46,6 +44,10 @@ export class App { log.debug('App', 'gameCanvas created'); this.initialize(canvas).then(() => { logger.debug('App', 'Scene Initialized'); + const loader = document.querySelector('#loader'); + if (loader) { + loader.remove(); + } }); } @@ -56,24 +58,6 @@ export class App { const scene = new Scene(engine); const environment = new CustomEnvironment(scene); - const query = Object.fromEntries(new URLSearchParams(window.location.search)); - logger.debug('Query', query); - if (query.shareCode) { - scene.onReadyObservable.addOnce(() => { - logger.debug('Scene ready'); - const identityView = new InputTextView({scene: scene, text: ""}); - identityView.onTextObservable.add((text) => { - if (text?.text?.trim() != "") { - logger.debug('Identity', text.text); - const network = new PeerjsNetworkConnection(query.shareCode, text.text); - if (query.host) { - network.connect(query.host); - } - } - }); - identityView.show(); - }); - } const camera: ArcRotateCamera = new ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 2, new Vector3(0, 1.6, 0), scene); @@ -111,7 +95,7 @@ export class App { const diagramManager = new DiagramManager(scene, xr.baseExperience); const rig = new Rigplatform(scene, xr, diagramManager); const toolbox = new Toolbox(scene, xr.baseExperience, diagramManager); - const dioManager = new DrawioManager(scene, diagramManager); + //const dioManager = new DrawioManager(scene, diagramManager); import ('./integration/indexdbPersistenceManager').then((module) => { const persistenceManager = new module.IndexdbPersistenceManager("diagram"); diagramManager.setPersistenceManager(persistenceManager); @@ -168,6 +152,7 @@ export class App { logger.info('keydown event listener added, use Ctrl+Shift+Alt+I to toggle debug layer'); + engine.runRenderLoop(() => { scene.render(); }); diff --git a/src/diagram/diagramConnection.ts b/src/diagram/diagramConnection.ts index 27022cc..bd7d04d 100644 --- a/src/diagram/diagramConnection.ts +++ b/src/diagram/diagramConnection.ts @@ -24,6 +24,7 @@ export class DiagramConnection { if (fromMesh) { this.fromAnchor = fromMesh; } + const toMesh = this.scene.getMeshById(to); if (toMesh) { this.toAnchor = toMesh; @@ -142,6 +143,7 @@ export class DiagramConnection { this.fromAnchor = null; } if (this._mesh) { + this._mesh.dispose(); this._mesh = null; } if (this.scene) { diff --git a/src/diagram/diagramManager.ts b/src/diagram/diagramManager.ts index 599336a..4aac521 100644 --- a/src/diagram/diagramManager.ts +++ b/src/diagram/diagramManager.ts @@ -66,6 +66,21 @@ export class DiagramManager { } this.onDiagramEventObservable.add(this.onDiagramEvent, -1, true, this); this.logger.debug("DiagramManager constructed"); + scene.onMeshRemovedObservable.add((mesh) => { + if (mesh?.metadata?.template) { + if (mesh.metadata.template != '#connection-template') { + scene.meshes.forEach((m) => { + if (m?.metadata?.to == mesh.id || m?.metadata?.from == mesh.id) { + this.logger.debug("removing connection", m.id); + this.onDiagramEventObservable.notifyObservers({ + type: DiagramEventType.REMOVE, + entity: MeshConverter.toDiagramEntity(m) + }); + } + }); + } + } + }); } public createCopy(mesh: AbstractMesh, copy: boolean = false): AbstractMesh { let newMesh; @@ -114,7 +129,7 @@ export class DiagramManager { private onRemoteEvent(event: DiagramEntity) { this.logger.debug(event); const toolMesh = this.scene.getMeshById("tool-" + event.template + "-" + event.color); - if (!toolMesh) { + if (!toolMesh && (event.template != '#connection-template')) { log.debug('no mesh found for ' + event.template + "-" + event.color, 'adding it'); this.onDiagramEventObservable.notifyObservers({ type: DiagramEventType.CHANGECOLOR, @@ -203,6 +218,7 @@ export class DiagramManager { mesh?.physicsBody?.dispose(); mesh.dispose(); DiaSounds.instance.exit.play(); + } break; } diff --git a/src/diagram/meshConverter.ts b/src/diagram/meshConverter.ts index 51a2be9..bf71cfa 100644 --- a/src/diagram/meshConverter.ts +++ b/src/diagram/meshConverter.ts @@ -35,10 +35,10 @@ export class MeshConverter { return entity; } public static fromDiagramEntity(entity: DiagramEntity, scene: Scene): AbstractMesh { - if (!entity) { - this.logger.error("fromDiagramEntity: entity is null"); - return null; - } + if (!entity) { + this.logger.error("fromDiagramEntity: entity is null"); + return null; + } if (!entity.id) { entity.id = "id" + uuidv4(); } diff --git a/src/integration/peerjsNetworkConnection.ts b/src/integration/peerjsNetworkConnection.ts index ce91e6b..e9b3622 100644 --- a/src/integration/peerjsNetworkConnection.ts +++ b/src/integration/peerjsNetworkConnection.ts @@ -6,7 +6,6 @@ export class PeerjsNetworkConnection { private dataChannel: P2PDataChannel; constructor(dataChannel: string, identity: string) { - const config = { debug: false, dataChannel: dataChannel, @@ -15,7 +14,6 @@ export class PeerjsNetworkConnection { pingTimeout: 8000 } this.dataChannel = new P2PDataChannel(identity, config); - this.dataChannel.onConnected((peerId) => { this.logger.debug(peerId, ' connected'); }); diff --git a/src/menus/editMenu.ts b/src/menus/editMenu.ts index 2359bc9..b57b969 100644 --- a/src/menus/editMenu.ts +++ b/src/menus/editMenu.ts @@ -34,6 +34,7 @@ export class EditMenu { private readonly xr: WebXRExperienceHelper; private readonly diagramManager: DiagramManager; private connection: DiagramConnection = null; + private panel: StackPanel3D; constructor(scene: Scene, xr: WebXRExperienceHelper, diagramManager: DiagramManager) { this.scene = scene; @@ -46,7 +47,20 @@ export class EditMenu { this.gizmoManager.gizmos.boundingBoxGizmo.scaleDragSpeed = 2; this.gizmoManager.clearGizmoOnEmptyPointerEvent = true; this.gizmoManager.usePointerToAttachGizmos = false; + this.manager = new GUI3DManager(this.scene); + const panel = new StackPanel3D(); + this.manager.addControl(panel); + panel.addControl(this.makeButton("Modify", "modify")); + panel.addControl(this.makeButton("Remove", "remove")); + panel.addControl(this.makeButton("Add Label", "label")); + panel.addControl(this.makeButton("Copy", "copy")); + panel.addControl(this.makeButton("Connect", "connect")); + panel.addControl(this.makeButton("Export", "export")); + panel.addControl(this.makeButton("Recolor", "recolor")); + + //panel.addControl(this.makeButton("Add Ring Cameras", "addRingCameras")); + this.manager.controlScaling = .5; this.scene.onPointerObservable.add((pointerInfo) => { switch (pointerInfo.type) { case PointerEventTypes.POINTERPICK: @@ -71,32 +85,32 @@ export class EditMenu { } } }); + this.panel = panel; + this.isVisible = false; + } + + private get isVisible(): boolean { + return this.panel.isVisible; + } + + private set isVisible(visible: boolean) { + this.panel.isVisible = visible; + this.panel.children.forEach((child) => { + child.isVisible = visible; + }); } toggle() { - if (this.manager) { + if (this.isVisible) { DiaSounds.instance.exit.play(); - this.manager.dispose(); - this.manager = null; + this.isVisible = false; + } else { DiaSounds.instance.enter.play(); - this.manager = new GUI3DManager(this.scene); - const panel = new StackPanel3D(); - this.manager.addControl(panel); - panel.addControl(this.makeButton("Modify", "modify")); - panel.addControl(this.makeButton("Remove", "remove")); - panel.addControl(this.makeButton("Add Label", "label")); - panel.addControl(this.makeButton("Copy", "copy")); - panel.addControl(this.makeButton("Connect", "connect")); - panel.addControl(this.makeButton("Export", "export")); - panel.addControl(this.makeButton("Recolor", "recolor")); - - //panel.addControl(this.makeButton("Add Ring Cameras", "addRingCameras")); - this.manager.controlScaling = .5; - CameraHelper.setMenuPosition(panel.node, this.scene); + CameraHelper.setMenuPosition(this.manager.rootContainer.children[0].node, this.scene); + this.isVisible = true; } } - private getTool(template: string, color: Color3): Mesh { const baseMeshId = 'tool-' + template + '-' + color.toHexString(); return (this.scene.getMeshById(baseMeshId) as Mesh); @@ -275,7 +289,7 @@ export class EditMenu { return; } - this.manager.dispose(); - this.manager = null; + + this.isVisible = false; } } \ No newline at end of file