From 9c76c7537d8d2f5228a0427d72a2ec8d47ced30c Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Mon, 15 Apr 2024 08:42:36 -0500 Subject: [PATCH] Fixed up logging, changed connector to use material from "from" mesh. --- package-lock.json | 8 ++++---- package.json | 2 +- src/diagram/diagramConnection.ts | 13 +++++++++---- src/diagram/functions/diagramEventHandler.ts | 2 +- src/integration/pouchdbPersistenceManager.ts | 1 - src/vrApp.ts | 7 ++++--- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index a91945d..1d70bcc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,7 @@ "events": "^3.3.0", "file-saver": "^2.0.5", "hls.js": "^1.1.4", - "loglevel": "^1.8.1", + "loglevel": "^1.9.1", "niceware": "^4.0.0", "pouchdb": "^8.0.1", "pouchdb-find": "^8.0.1", @@ -1936,9 +1936,9 @@ } }, "node_modules/loglevel": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.8.1.tgz", - "integrity": "sha512-tCRIJM51SHjAayKwC+QAg8hT8vg6z7GSgLJKGvzuPb1Wc+hLzqtuVLxp6/HzSPOozuK+8ErAhy7U/sVzw8Dgfg==", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.1.tgz", + "integrity": "sha512-hP3I3kCrDIMuRwAwHltphhDM1r8i55H33GgqjXbrisuJhF4kRhW1dNuxsRklp4bXl8DSdLaNLuiL4A/LWRfxvg==", "engines": { "node": ">= 0.6.0" }, diff --git a/package.json b/package.json index 604faef..2cd7751 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@picovoice/web-voice-processor": "^4.0.9", "@picovoice/cobra-web": "^2.0.3", "hls.js": "^1.1.4", - "loglevel": "^1.8.1", + "loglevel": "^1.9.1", "niceware": "^4.0.0", "pouchdb": "^8.0.1", "pouchdb-find": "^8.0.1", diff --git a/src/diagram/diagramConnection.ts b/src/diagram/diagramConnection.ts index 1573df8..62a6892 100644 --- a/src/diagram/diagramConnection.ts +++ b/src/diagram/diagramConnection.ts @@ -1,4 +1,4 @@ -import {AbstractMesh, MeshBuilder, Scene, TransformNode, Vector3} from "@babylonjs/core"; +import {AbstractMesh, MeshBuilder, Scene, StandardMaterial, TransformNode, Vector3} from "@babylonjs/core"; import {v4 as uuidv4} from 'uuid'; import log, {Logger} from "loglevel"; import {buildStandardMaterial} from "../materials/functions/buildStandardMaterial"; @@ -45,7 +45,7 @@ export class DiagramConnection { this.toAnchor = to; } else { - this.logger.error("no fromMesh"); + this.logger.info("no fromMesh yet, will build when toMesh is available"); } } this.buildConnection(); @@ -111,6 +111,12 @@ export class DiagramConnection { }); } + if (this.fromAnchor && (this.fromAnchor as AbstractMesh).material) { + this._mesh.material = (((this.fromAnchor as AbstractMesh).material as StandardMaterial)); + } else { + this._mesh.material = buildStandardMaterial(this.id + "_material", this.scene, "#FFFFFF"); + } + } } @@ -121,7 +127,7 @@ export class DiagramConnection { private buildConnection() { this.logger.debug(`buildConnection from ${this._from} to ${this._to}`); this._mesh = MeshBuilder.CreateCylinder(this.id + "_connection", {diameter: .02, height: 1}, this.scene); - this._mesh.material = buildStandardMaterial(this.id + "_material", this.scene, "#FFFFFF"); + this.transformNode = new TransformNode(this.id + "_transform", this.scene); this.transformNode.metadata = {exportable: true}; this._mesh.setParent(this.transformNode); @@ -156,7 +162,6 @@ export class DiagramConnection { this.logger.debug("removeConnection"); this.scene.onBeforeRenderObservable.removeCallback(this.beforeRender); this._mesh.onDisposeObservable.removeCallback(this.removeConnection); - this.removeObserver(); if (this.toAnchor) { this.toAnchor = null; diff --git a/src/diagram/functions/diagramEventHandler.ts b/src/diagram/functions/diagramEventHandler.ts index a3a1d0e..7ecae92 100644 --- a/src/diagram/functions/diagramEventHandler.ts +++ b/src/diagram/functions/diagramEventHandler.ts @@ -58,7 +58,7 @@ export function diagramEventHandler(event: DiagramEvent, } break; case DiagramEventType.ADD: - if (!mesh.actionManager) { + if (mesh && !mesh.actionManager) { mesh.actionManager = actionManager; } if (physicsEnabled) { diff --git a/src/integration/pouchdbPersistenceManager.ts b/src/integration/pouchdbPersistenceManager.ts index 2addf7c..02f0264 100644 --- a/src/integration/pouchdbPersistenceManager.ts +++ b/src/integration/pouchdbPersistenceManager.ts @@ -22,7 +22,6 @@ export class PouchdbPersistenceManager { private user: string; constructor() { - logger.setLevel('debug'); this.diagramListings = new PouchDB("diagramListings"); } diff --git a/src/vrApp.ts b/src/vrApp.ts index 8ef1a26..f8e437c 100644 --- a/src/vrApp.ts +++ b/src/vrApp.ts @@ -19,10 +19,11 @@ export class VrApp { private logger: Logger = log.getLogger('App'); constructor() { + //log.getLogger('App').setLevel('debug'); + //log.getLogger('DiagramManager').setLevel('debug'); + log.resetLevel(); + log.setDefaultLevel('error'); - log.setDefaultLevel('warn'); - log.getLogger('App').setLevel('debug'); - log.getLogger('DiagramManager').setLevel('debug'); const canvas = document.querySelector('#gameCanvas'); this.logger.debug('App', 'gameCanvas created'); }