Fixed up logging, changed connector to use material from "from" mesh.

This commit is contained in:
Michael Mainguy 2024-04-15 08:42:36 -05:00
parent f148805e80
commit 9c76c7537d
6 changed files with 19 additions and 14 deletions

8
package-lock.json generated
View File

@ -29,7 +29,7 @@
"events": "^3.3.0", "events": "^3.3.0",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"hls.js": "^1.1.4", "hls.js": "^1.1.4",
"loglevel": "^1.8.1", "loglevel": "^1.9.1",
"niceware": "^4.0.0", "niceware": "^4.0.0",
"pouchdb": "^8.0.1", "pouchdb": "^8.0.1",
"pouchdb-find": "^8.0.1", "pouchdb-find": "^8.0.1",
@ -1936,9 +1936,9 @@
} }
}, },
"node_modules/loglevel": { "node_modules/loglevel": {
"version": "1.8.1", "version": "1.9.1",
"resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.8.1.tgz", "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.1.tgz",
"integrity": "sha512-tCRIJM51SHjAayKwC+QAg8hT8vg6z7GSgLJKGvzuPb1Wc+hLzqtuVLxp6/HzSPOozuK+8ErAhy7U/sVzw8Dgfg==", "integrity": "sha512-hP3I3kCrDIMuRwAwHltphhDM1r8i55H33GgqjXbrisuJhF4kRhW1dNuxsRklp4bXl8DSdLaNLuiL4A/LWRfxvg==",
"engines": { "engines": {
"node": ">= 0.6.0" "node": ">= 0.6.0"
}, },

View File

@ -35,7 +35,7 @@
"@picovoice/web-voice-processor": "^4.0.9", "@picovoice/web-voice-processor": "^4.0.9",
"@picovoice/cobra-web": "^2.0.3", "@picovoice/cobra-web": "^2.0.3",
"hls.js": "^1.1.4", "hls.js": "^1.1.4",
"loglevel": "^1.8.1", "loglevel": "^1.9.1",
"niceware": "^4.0.0", "niceware": "^4.0.0",
"pouchdb": "^8.0.1", "pouchdb": "^8.0.1",
"pouchdb-find": "^8.0.1", "pouchdb-find": "^8.0.1",

View File

@ -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 {v4 as uuidv4} from 'uuid';
import log, {Logger} from "loglevel"; import log, {Logger} from "loglevel";
import {buildStandardMaterial} from "../materials/functions/buildStandardMaterial"; import {buildStandardMaterial} from "../materials/functions/buildStandardMaterial";
@ -45,7 +45,7 @@ export class DiagramConnection {
this.toAnchor = to; this.toAnchor = to;
} else { } else {
this.logger.error("no fromMesh"); this.logger.info("no fromMesh yet, will build when toMesh is available");
} }
} }
this.buildConnection(); 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() { private buildConnection() {
this.logger.debug(`buildConnection from ${this._from} to ${this._to}`); 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 = 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 = new TransformNode(this.id + "_transform", this.scene);
this.transformNode.metadata = {exportable: true}; this.transformNode.metadata = {exportable: true};
this._mesh.setParent(this.transformNode); this._mesh.setParent(this.transformNode);
@ -156,7 +162,6 @@ export class DiagramConnection {
this.logger.debug("removeConnection"); this.logger.debug("removeConnection");
this.scene.onBeforeRenderObservable.removeCallback(this.beforeRender); this.scene.onBeforeRenderObservable.removeCallback(this.beforeRender);
this._mesh.onDisposeObservable.removeCallback(this.removeConnection); this._mesh.onDisposeObservable.removeCallback(this.removeConnection);
this.removeObserver(); this.removeObserver();
if (this.toAnchor) { if (this.toAnchor) {
this.toAnchor = null; this.toAnchor = null;

View File

@ -58,7 +58,7 @@ export function diagramEventHandler(event: DiagramEvent,
} }
break; break;
case DiagramEventType.ADD: case DiagramEventType.ADD:
if (!mesh.actionManager) { if (mesh && !mesh.actionManager) {
mesh.actionManager = actionManager; mesh.actionManager = actionManager;
} }
if (physicsEnabled) { if (physicsEnabled) {

View File

@ -22,7 +22,6 @@ export class PouchdbPersistenceManager {
private user: string; private user: string;
constructor() { constructor() {
logger.setLevel('debug');
this.diagramListings = new PouchDB("diagramListings"); this.diagramListings = new PouchDB("diagramListings");
} }

View File

@ -19,10 +19,11 @@ export class VrApp {
private logger: Logger = log.getLogger('App'); private logger: Logger = log.getLogger('App');
constructor() { 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'); const canvas = document.querySelector('#gameCanvas');
this.logger.debug('App', 'gameCanvas created'); this.logger.debug('App', 'gameCanvas created');
} }