From 237b127686584a7e56887cb92e89ce45fb90b3c6 Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Thu, 9 Nov 2023 08:04:13 -0600 Subject: [PATCH] Removed some unused code. Optimized export bundle. --- src/app.ts | 16 -- src/controllers/base.ts | 2 +- src/diagram/diagramEntityActionManager.ts | 28 --- src/diagram/diagramManager.ts | 16 +- .../functions/buildEntityActionManager.ts | 19 ++ .../{ => functions}/diagramEventHandler.ts | 12 +- src/diagram/functions/fromDiagramEntity.ts | 4 +- src/diagram/functions/toDiagramEntity.ts | 2 +- src/diagram/{ => types}/diagramEntity.ts | 2 +- src/diagram/types/diagramListing.ts | 18 ++ src/integration/drawioManager.ts | 2 +- src/integration/iNetworkConnection.ts | 20 -- src/integration/iPersistenceManager.ts | 61 ------ src/integration/indexdbPersistenceManager.ts | 201 ------------------ src/integration/peerjsNetworkConnection.ts | 70 ------ src/integration/pouchdbPersistenceManager.ts | 6 +- src/menus/editMenu.ts | 9 +- src/newrelic/newRelicData.ts | 6 +- src/{diagram => objects}/textLabel.ts | 0 src/server/ring/ringCamera.ts | 20 -- src/util/functions/exportGltf.ts | 13 ++ src/worker.ts | 51 ----- 22 files changed, 80 insertions(+), 498 deletions(-) delete mode 100644 src/diagram/diagramEntityActionManager.ts create mode 100644 src/diagram/functions/buildEntityActionManager.ts rename src/diagram/{ => functions}/diagramEventHandler.ts (88%) rename src/diagram/{ => types}/diagramEntity.ts (93%) create mode 100644 src/diagram/types/diagramListing.ts delete mode 100644 src/integration/iNetworkConnection.ts delete mode 100644 src/integration/iPersistenceManager.ts delete mode 100644 src/integration/indexdbPersistenceManager.ts delete mode 100644 src/integration/peerjsNetworkConnection.ts rename src/{diagram => objects}/textLabel.ts (100%) delete mode 100644 src/server/ring/ringCamera.ts create mode 100644 src/util/functions/exportGltf.ts delete mode 100644 src/worker.ts diff --git a/src/app.ts b/src/app.ts index 5d835d6..faec1d8 100644 --- a/src/app.ts +++ b/src/app.ts @@ -7,17 +7,11 @@ import {AppConfig} from "./util/appConfig"; import {GamepadManager} from "./controllers/gamepadManager"; import {CustomEnvironment} from "./util/customEnvironment"; import {Controllers} from "./controllers/controllers"; -// @ts-ignore -import workerUrl from "./worker?worker&url"; - -import {PeerjsNetworkConnection} from "./integration/peerjsNetworkConnection"; -import {DiagramExporter} from "./util/diagramExporter"; import {Spinner} from "./util/spinner"; import {PouchdbPersistenceManager} from "./integration/pouchdbPersistenceManager"; import {addSceneInspector} from "./util/functions/sceneInspctor"; import {groundMeshObserver} from "./util/functions/groundMeshObserver"; - export class App { //preTasks = [havokModule]; private logger: Logger = log.getLogger('App'); @@ -28,7 +22,6 @@ export class App { log.getLogger('App').setLevel('debug'); log.getLogger('DiagramManager').setLevel('debug'); - log.getLogger('PeerjsNetworkConnection').setLevel('debug'); const canvas = document.querySelector('#gameCanvas'); @@ -108,15 +101,6 @@ export class App { */ addSceneInspector(scene); - const exportLink = document.querySelector('#downloadLink'); - if (exportLink) { - exportLink.addEventListener('click', (ev) => { - ev.preventDefault(); - const exporter = new DiagramExporter(scene); - exporter.exportgltf(); - }); - } - this.logger.info('keydown event listener added, use Ctrl+Shift+Alt+I to toggle debug layer'); diff --git a/src/controllers/base.ts b/src/controllers/base.ts index f1a5014..09f9f30 100644 --- a/src/controllers/base.ts +++ b/src/controllers/base.ts @@ -10,7 +10,7 @@ import { WebXRInputSource } from "@babylonjs/core"; import {DiagramManager} from "../diagram/diagramManager"; -import {DiagramEvent, DiagramEventType} from "../diagram/diagramEntity"; +import {DiagramEvent, DiagramEventType} from "../diagram/types/diagramEntity"; import log from "loglevel"; import {ControllerEventType, Controllers} from "./controllers"; import {toDiagramEntity} from "../diagram/functions/toDiagramEntity"; diff --git a/src/diagram/diagramEntityActionManager.ts b/src/diagram/diagramEntityActionManager.ts deleted file mode 100644 index 50f397f..0000000 --- a/src/diagram/diagramEntityActionManager.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {ActionManager, ExecuteCodeAction, PlaySoundAction, Scene} from "@babylonjs/core"; -import {DiaSounds} from "../util/diaSounds"; -import {ControllerEventType, Controllers} from "../controllers/controllers"; -import log from "loglevel"; - -export class DiagramEntityActionManager { - _actionManager: ActionManager; - private readonly logger = log.getLogger('DiagramEntityActionManager'); - - constructor(scene: Scene, sounds: DiaSounds, controllers: Controllers) { - this._actionManager = new ActionManager(scene); - this._actionManager.registerAction( - new PlaySoundAction(ActionManager.OnPointerOverTrigger, sounds.tick)); - this._actionManager.registerAction( - new ExecuteCodeAction(ActionManager.OnPointerOverTrigger, (evt) => { - controllers.controllerObserver.notifyObservers({ - type: ControllerEventType.PULSE, - gripId: evt?.additionalData?.pickResult?.gripTransform?.id - }) - this.logger.debug(evt); - }) - ); - } - - public get manager() { - return this._actionManager; - } -} \ No newline at end of file diff --git a/src/diagram/diagramManager.ts b/src/diagram/diagramManager.ts index fd47382..a8c5b5d 100644 --- a/src/diagram/diagramManager.ts +++ b/src/diagram/diagramManager.ts @@ -1,18 +1,18 @@ -import {AbstractMesh, Color3, InstancedMesh, Mesh, Observable, Scene} from "@babylonjs/core"; -import {DiagramEvent, DiagramEventType} from "./diagramEntity"; +import {AbstractMesh, ActionManager, Color3, InstancedMesh, Mesh, Observable, Scene} from "@babylonjs/core"; +import {DiagramEvent, DiagramEventType} from "./types/diagramEntity"; import log from "loglevel"; import {Controllers} from "../controllers/controllers"; import {DiaSounds} from "../util/diaSounds"; import {AppConfig} from "../util/appConfig"; import {Toolbox} from "../toolbox/toolbox"; import {PresentationManager} from "./presentationManager"; -import {DiagramEntityActionManager} from "./diagramEntityActionManager"; -import {diagramEventHandler} from "./diagramEventHandler"; +import {diagramEventHandler} from "./functions/diagramEventHandler"; import {deepCopy} from "../util/functions/deepCopy"; import {applyPhysics} from "./functions/diagramShapePhysics"; import {applyScaling} from "./functions/applyScaling"; import {toDiagramEntity} from "./functions/toDiagramEntity"; import {v4 as uuidv4} from 'uuid'; +import {buildEntityActionManager} from "./functions/buildEntityActionManager"; export class DiagramManager { @@ -22,7 +22,7 @@ export class DiagramManager { private readonly scene: Scene; private readonly sounds: DiaSounds; private readonly controllers: Controllers; - private readonly diagramEntityActionManager: DiagramEntityActionManager + private readonly diagramEntityActionManager: ActionManager; private presentationManager: PresentationManager; public readonly config: AppConfig; @@ -33,7 +33,7 @@ export class DiagramManager { this.toolbox = toolbox; this.controllers = controllers; this.presentationManager = new PresentationManager(this.scene); - this.diagramEntityActionManager = new DiagramEntityActionManager(this.scene, this.sounds, this.controllers); + this.diagramEntityActionManager = buildEntityActionManager(this.scene, this.sounds, this.controllers); if (this.onDiagramEventObservable.hasObservers()) { this.logger.warn("onDiagramEventObservable already has Observers, you should be careful"); @@ -80,7 +80,7 @@ export class DiagramManager { } newMesh.id = 'id' + uuidv4(); - newMesh.actionManager = this.diagramEntityActionManager.manager; + newMesh.actionManager = this.diagramEntityActionManager; newMesh.position = mesh.absolutePosition.clone(); if (mesh.absoluteRotationQuaternion) { @@ -107,6 +107,6 @@ export class DiagramManager { private onDiagramEvent(event: DiagramEvent) { diagramEventHandler( event, this.scene, this.toolbox, this.config.current.physicsEnabled, - this.diagramEntityActionManager.manager, this.sounds); + this.diagramEntityActionManager, this.sounds); } } \ No newline at end of file diff --git a/src/diagram/functions/buildEntityActionManager.ts b/src/diagram/functions/buildEntityActionManager.ts new file mode 100644 index 0000000..21879eb --- /dev/null +++ b/src/diagram/functions/buildEntityActionManager.ts @@ -0,0 +1,19 @@ +import {ActionManager, ExecuteCodeAction, PlaySoundAction, Scene} from "@babylonjs/core"; +import {ControllerEventType, Controllers} from "../../controllers/controllers"; +import {DiaSounds} from "../../util/diaSounds"; + +export function buildEntityActionManager(scene: Scene, sounds: DiaSounds, controllers: Controllers) { + const actionManager = new ActionManager(scene); + actionManager.registerAction( + new PlaySoundAction(ActionManager.OnPointerOverTrigger, sounds.tick)); + actionManager.registerAction( + new ExecuteCodeAction(ActionManager.OnPointerOverTrigger, (evt) => { + controllers.controllerObserver.notifyObservers({ + type: ControllerEventType.PULSE, + gripId: evt?.additionalData?.pickResult?.gripTransform?.id + }) + this.logger.debug(evt); + }) + ); + return actionManager; +} \ No newline at end of file diff --git a/src/diagram/diagramEventHandler.ts b/src/diagram/functions/diagramEventHandler.ts similarity index 88% rename from src/diagram/diagramEventHandler.ts rename to src/diagram/functions/diagramEventHandler.ts index 20107c6..6c4242d 100644 --- a/src/diagram/diagramEventHandler.ts +++ b/src/diagram/functions/diagramEventHandler.ts @@ -1,12 +1,12 @@ -import {DiagramEvent, DiagramEventType} from "./diagramEntity"; +import {DiagramEvent, DiagramEventType} from "../types/diagramEntity"; import log from "loglevel"; -import {applyPhysics} from "./functions/diagramShapePhysics"; +import {applyPhysics} from "./diagramShapePhysics"; import {ActionManager, PhysicsMotionType, Scene} from "@babylonjs/core"; -import {TextLabel} from "./textLabel"; -import {Toolbox} from "../toolbox/toolbox"; -import {DiaSounds} from "../util/diaSounds"; +import {TextLabel} from "../../objects/textLabel"; +import {Toolbox} from "../../toolbox/toolbox"; +import {DiaSounds} from "../../util/diaSounds"; -import {fromDiagramEntity} from "./functions/fromDiagramEntity"; +import {fromDiagramEntity} from "./fromDiagramEntity"; export function diagramEventHandler(event: DiagramEvent, diff --git a/src/diagram/functions/fromDiagramEntity.ts b/src/diagram/functions/fromDiagramEntity.ts index db00f3d..6fc8e32 100644 --- a/src/diagram/functions/fromDiagramEntity.ts +++ b/src/diagram/functions/fromDiagramEntity.ts @@ -1,7 +1,7 @@ -import {DiagramEntity} from "../diagramEntity"; +import {DiagramEntity} from "../types/diagramEntity"; import {AbstractMesh, Color3, InstancedMesh, Mesh, Quaternion, Scene, StandardMaterial, Vector3} from "@babylonjs/core"; import {DiagramConnection} from "../diagramConnection"; -import {TextLabel} from "../textLabel"; +import {TextLabel} from "../../objects/textLabel"; import log from "loglevel"; import {v4 as uuidv4} from 'uuid'; diff --git a/src/diagram/functions/toDiagramEntity.ts b/src/diagram/functions/toDiagramEntity.ts index fc977ea..f14406e 100644 --- a/src/diagram/functions/toDiagramEntity.ts +++ b/src/diagram/functions/toDiagramEntity.ts @@ -1,5 +1,5 @@ import {AbstractMesh, Vector3} from "@babylonjs/core"; -import {DiagramEntity} from "../diagramEntity"; +import {DiagramEntity} from "../types/diagramEntity"; import log from "loglevel"; import {v4 as uuidv4} from 'uuid'; diff --git a/src/diagram/diagramEntity.ts b/src/diagram/types/diagramEntity.ts similarity index 93% rename from src/diagram/diagramEntity.ts rename to src/diagram/types/diagramEntity.ts index 94b5f7f..e72992b 100644 --- a/src/diagram/diagramEntity.ts +++ b/src/diagram/types/diagramEntity.ts @@ -1,5 +1,5 @@ import {Color3} from "@babylonjs/core"; -import {EditMenuState} from "../menus/editMenuState"; +import {EditMenuState} from "../../menus/editMenuState"; export enum DiagramEventType { ADD, diff --git a/src/diagram/types/diagramListing.ts b/src/diagram/types/diagramListing.ts new file mode 100644 index 0000000..ac78f6d --- /dev/null +++ b/src/diagram/types/diagramListing.ts @@ -0,0 +1,18 @@ +export enum DiagramListingEventType { + GET, + ADD, + REMOVE, + MODIFY +} + +export type DiagramListingEvent = { + type: DiagramListingEventType; + listing: DiagramListing; +} +export type DiagramListing = { + type: DiagramListingEvent; + id: string; + name: string; + description?: string; + sharekey?: string; +} \ No newline at end of file diff --git a/src/integration/drawioManager.ts b/src/integration/drawioManager.ts index 13b1462..b354fed 100644 --- a/src/integration/drawioManager.ts +++ b/src/integration/drawioManager.ts @@ -1,7 +1,7 @@ import log from "loglevel"; import {Color3, Scene, Vector3} from "@babylonjs/core"; import {DiagramManager} from "../diagram/diagramManager"; -import {DiagramEventType} from "../diagram/diagramEntity"; +import {DiagramEventType} from "../diagram/types/diagramEntity"; type DrawIOEntity = { text?: string, diff --git a/src/integration/iNetworkConnection.ts b/src/integration/iNetworkConnection.ts deleted file mode 100644 index 60bfcad..0000000 --- a/src/integration/iNetworkConnection.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {Observable} from "@babylonjs/core"; - -export enum NetworkMessageType { - DIAGRAM_EVENT = 'diagramEvent', - CONNECTION_EVENT = 'connectionEvent', -} - -class NetworkMessage { - type: NetworkMessageType; - data: any; -} - -export interface INetworkConnection { - onMessageObservable: Observable; - - connect(name: string, room: string); - - disconnect(); - -} \ No newline at end of file diff --git a/src/integration/iPersistenceManager.ts b/src/integration/iPersistenceManager.ts deleted file mode 100644 index 58c9661..0000000 --- a/src/integration/iPersistenceManager.ts +++ /dev/null @@ -1,61 +0,0 @@ -import {Color3, Observable} from "@babylonjs/core"; -import {DiagramEntity} from "../diagram/diagramEntity"; -import {AppConfigType} from "../util/appConfigType"; -import {DiagramManager} from "../diagram/diagramManager"; - -export enum DiagramListingEventType { - GET, - ADD, - REMOVE, - MODIFY -} - -export type DiagramListingEvent = { - type: DiagramListingEventType; - listing: DiagramListing; -} -export type DiagramListing = { - type: DiagramListingEvent; - id: string; - name: string; - description?: string; - sharekey?: string; - -} - -export interface IPersistenceManager { - diagramListingObserver: Observable; - - sync(); - - addDiagram(diagram: DiagramListing); - - getNewRelicData(): Promise; - - setNewRelicData(data: any): Promise; - - removeDiagram(diagram: DiagramListing); - - add(mesh: DiagramEntity); - - remove(id: string); - - modify(mesh: DiagramEntity); - - initialize(); - - setConfig(config: AppConfigType); - - getConfig(): Promise; - - modifyDiagram(diagram: DiagramListing); - - updateObserver: Observable; - configObserver: Observable; - - changeColor(oldColor: Color3, newColor: Color3); - - setCurrentDiagram(diagram: DiagramListing); - - setDiagramManager(diagramManager: DiagramManager); -} diff --git a/src/integration/indexdbPersistenceManager.ts b/src/integration/indexdbPersistenceManager.ts deleted file mode 100644 index b63c1b4..0000000 --- a/src/integration/indexdbPersistenceManager.ts +++ /dev/null @@ -1,201 +0,0 @@ -import {DiagramListing, DiagramListingEvent, DiagramListingEventType, IPersistenceManager} from "./iPersistenceManager"; -import {Observable} from "@babylonjs/core"; -import {DiagramEntity} from "../diagram/diagramEntity"; -import Dexie from "dexie"; -import log from "loglevel"; -import {AppConfigType} from "../util/appConfigType"; -import {DiagramManager} from "../diagram/diagramManager"; - - -export class IndexdbPersistenceManager implements IPersistenceManager { - private readonly logger = log.getLogger('IndexdbPersistenceManager'); - public readonly diagramListingObserver: Observable = new Observable(); - public readonly updateObserver: Observable = new Observable(); - public readonly configObserver: Observable = new Observable(); - private db: Dexie; - - private currentDiagramId: string; - - constructor(name: string) { - this.db = new Dexie(name); - const version = 7; - - - this.db.version(version).stores({config: "id,gridSnap,rotateSnap,createSnap"}); - this.db.version(version).stores({entities: "id,diagramlistingid,position,rotation,last_seen,template,text,scale,color"}); - this.db.version(version).stores({diagramlisting: "id,name,description,sharekey"}); - this.db.version(version).stores({newRelicData: "id,priority, incidentId"}); - this.logger.debug("IndexdbPersistenceManager constructed"); - } - - public setDiagramManager(diagramManager: DiagramManager) { - console.log(diagramManager.config); - } - - public setCurrentDiagram(diagram: DiagramListing) { - this.currentDiagramId = diagram.id; - } - - public add(entity: DiagramEntity) { - if (!entity) { - this.logger.error("Adding null mesh, early return"); - return; - } - entity.diagramlistingid = this.currentDiagramId; - this.db["entities"].add(entity); - this.logger.debug('add', entity); - } - - public addDiagram(diagram: DiagramListing) { - this.db["diagramlisting"].add(diagram); - const event = { - type: DiagramListingEventType.ADD, - listing: diagram - } - this.diagramListingObserver.notifyObservers(event); - } - - public remove(id: string) { - if (!id) { - this.logger.error("Removing null mesh, early return"); - return; - } - this.db["entities"].delete(id); - } - - public setConfig(config: AppConfigType) { - config.id = 1; - this.db["config"].put(config); - this.logger.debug('setConfig', config); - this.configObserver.notifyObservers(config); - } - - public removeDiagram(diagram: DiagramListing) { - this.db["diagramlisting"].delete(diagram.id); - const event = { - type: DiagramListingEventType.REMOVE, - listing: diagram - } - this.diagramListingObserver.notifyObservers(event); - } - - modifyDiagram(diagram: DiagramListing) { - this.db["diagramlisting"].update(diagram.id, diagram); - const event = { - type: DiagramListingEventType.MODIFY, - listing: diagram - } - this.diagramListingObserver.notifyObservers(event); - } - - public async setNewRelicData(data: any[]) { - this.db["newRelicData"].clear(); - data.forEach((d) => { - this.db["newRelicData"].add(d); - }); - } - - public async getNewRelicData(): Promise { - return this.db["newRelicData"].toArray(); - } - - public async getConfig(): Promise { - const configs = await this.db['config'].toArray(); - return configs[0]; - } - - public async initialize() { - this.logger.info('initialize', this.db['entities'].length); - const configs = await this.db['config'].toArray(); - const config = configs[0]; - if (config) { - this.logger.debug('initialize config', config); - this.configObserver.notifyObservers(config); - - if (config.currentDiagramId) { - this.logger.debug('initialize currentDiagramId', config.currentDiagramId); - const currentDiagram = await this.db['diagramlisting'].get(config.currentDiagramId); - if (currentDiagram) { - this.logger.debug('found currentDiagram', currentDiagram); - this.currentDiagramId = currentDiagram.id; - } else { - this.logger.error('could not find currentDiagram', config.currentDiagramId); - } - } else { - this.logger.warn('no currentDiagramId, using default'); - } - } else { - - this.configObserver.notifyObservers( - { - id: 1, - demoCompleted: false, - gridSnap: 1, - rotateSnap: 0, - createSnap: 0, - turnSnap: 0, - currentDiagramId: null - } - ); - } - this.getFilteredEntities().each((e) => { - this.logger.debug('adding', e); - this.updateObserver.notifyObservers(e); - }); - this.listDiagrams(); - this.logger.info("initialize finished"); - } - - public sync() { - this.getFilteredEntities().each((e) => { - this.logger.debug('adding', e); - this.updateObserver.notifyObservers(e); - }); - } - - public modify(entity: DiagramEntity) { - if (!entity) { - this.logger.error("Modifying null mesh, early return"); - return; - } - this.db["entities"].update(entity.id, entity); - this.logger.debug('modify', entity); - } - - public changeColor(oldColor, newColor) { - if (!oldColor) { - if (!newColor) { - this.logger.error("changeColor called with no new color, early return"); - } else { - this.logger.info("changeColor called with no old Color, new color added to diagram, early return"); - } - return; - } - this.logger.debug(`changeColor ${oldColor.toHexString()} to ${newColor.toHexString()}`); - this.getFilteredEntities().filter((e) => e.color == oldColor.toHexString()).modify({color: newColor.toHexString()}); - } - - private listDiagrams() { - return this.db["diagramlisting"].toArray((diagrams) => { - this.logger.debug('listDiagrams', diagrams); - for (const diagram of diagrams) { - const event = { - type: DiagramListingEventType.GET, - listing: diagram - } - this.diagramListingObserver.notifyObservers(event); - } - }); - } - - private getFilteredEntities() { - return this.db['entities'].filter((e) => { - if (!this.currentDiagramId && !e.diagramlistingid) { - return true; - } else { - return e.diagramlistingid == this.currentDiagramId; - } - } - ); - } -} \ No newline at end of file diff --git a/src/integration/peerjsNetworkConnection.ts b/src/integration/peerjsNetworkConnection.ts deleted file mode 100644 index 1e41182..0000000 --- a/src/integration/peerjsNetworkConnection.ts +++ /dev/null @@ -1,70 +0,0 @@ -import P2PDataChannel from 'p2p-data-channel'; -import log from "loglevel"; -import {Observable} from "@babylonjs/core"; -import {DiagramEvent} from "../diagram/diagramEntity"; - - -export class PeerjsNetworkConnection { - private logger: log.Logger = log.getLogger('PeerjsNetworkConnection'); - private dataChannel: P2PDataChannel; - public readonly connectionObservable: Observable = new Observable; - public readonly dataReplicationObservable: Observable = new Observable; - public readonly diagramEventObservable: Observable = new Observable; - - constructor() { - const config = { - debug: false, - dataChannel: 'deepSharedDiagram', - connectionTimeout: 5000, - pingInterval: 4000, - pingTimeout: 8000, - logLevel: 'debug', - } - - // @ts-ignore - const passphrase = window.niceware.generatePassphrase(6).join('-'); - this.logger.debug('Local Passphrase: ', passphrase); - this.dataChannel = new P2PDataChannel(passphrase, config); - this.dataChannel.onConnected((peerId) => { - this.logger.debug('Connected to ', peerId); - this.connectionObservable.notifyObservers(peerId); - }); - this.dataChannel.onMessage((message) => { - this.logger.debug(message); - if (message.sender !== this.dataChannel.localPeerId) { - this.logger.debug(message.payload, ' received from ', message.sender); - if (message.payload.request == 'join') { - this.dataChannel.send(message.sender, {type: 'join-ack'}); - this.logger.debug('Join ack sent to ', message.sender); - } - if (message.payload.diagramEvent) { - this.logger.debug('Received diagram event from ', message.sender, message.payload.diagramEvent); - this.diagramEventObservable.notifyObservers(message.payload.diagramEvent); - } - } - }); - const remote = window.location.pathname.replace('/', ''); - if (remote && remote.length > 0) { - this.connectToRemote(remote); - - } else { - const link = 'https://www.oculus.com/open_url/?url=https://cameras.immersiveidea.com/'; - const linkEl = document.querySelector('#questLaunch a'); - linkEl.setAttribute('href', link + passphrase); - } - this.dataReplicationObservable.add((evt) => { - this.logger.debug(evt); - this.dataChannel.broadcast({diagramEvent: evt}); - }); - } - - public connectToRemote(host: string) { - this.dataChannel.connect(host).then((peerId) => { - this.logger.debug('Broadcasting Join', peerId); - this.dataChannel.broadcast({request: 'join'}); - - }).catch((err) => { - this.logger.error(err); - }); - } -} \ No newline at end of file diff --git a/src/integration/pouchdbPersistenceManager.ts b/src/integration/pouchdbPersistenceManager.ts index 73a92b9..5644c2b 100644 --- a/src/integration/pouchdbPersistenceManager.ts +++ b/src/integration/pouchdbPersistenceManager.ts @@ -1,14 +1,14 @@ -import {DiagramListing, DiagramListingEvent, IPersistenceManager} from "./iPersistenceManager"; import PouchDB from 'pouchdb'; -import {DiagramEntity, DiagramEventType} from "../diagram/diagramEntity"; +import {DiagramEntity, DiagramEventType} from "../diagram/types/diagramEntity"; import {Color3, Observable} from "@babylonjs/core"; import {AppConfigType} from "../util/appConfigType"; import {v4 as uuidv4} from 'uuid'; import axios from "axios"; import {DiagramManager} from "../diagram/diagramManager"; import log, {Logger} from "loglevel"; +import {DiagramListing, DiagramListingEvent} from "../diagram/types/diagramListing"; -export class PouchdbPersistenceManager implements IPersistenceManager { +export class PouchdbPersistenceManager { configObserver: Observable = new Observable(); diagramListingObserver: Observable = new Observable(); updateObserver: Observable = new Observable(); diff --git a/src/menus/editMenu.ts b/src/menus/editMenu.ts index a6211ba..b0880bb 100644 --- a/src/menus/editMenu.ts +++ b/src/menus/editMenu.ts @@ -14,20 +14,20 @@ import { import {GUI3DManager, PlanePanel} from "@babylonjs/gui"; import {DiagramManager} from "../diagram/diagramManager"; import {EditMenuState} from "./editMenuState"; -import {DiagramEvent, DiagramEventType} from "../diagram/diagramEntity"; +import {DiagramEvent, DiagramEventType} from "../diagram/types/diagramEntity"; import log from "loglevel"; import {InputTextView} from "../information/inputTextView"; import {DiaSounds} from "../util/diaSounds"; -import {TextLabel} from "../diagram/textLabel"; +import {TextLabel} from "../objects/textLabel"; import {DiagramConnection} from "../diagram/diagramConnection"; import {toDiagramEntity} from "../diagram/functions/toDiagramEntity"; import {AbstractMenu} from "./abstractMenu"; import {Controllers} from "../controllers/controllers"; import {setMenuPosition} from "../util/functions/setMenuPosition"; -import {DiagramExporter} from "../util/diagramExporter"; import {SoccerMenu} from "../soccer/soccerMenu"; import {CameraMenu} from "./cameraMenu"; +import {exportGltf} from "../util/functions/exportGltf"; export class EditMenu extends AbstractMenu { private state: EditMenuState = EditMenuState.NONE; @@ -332,7 +332,6 @@ export class EditMenu extends AbstractMenu { } private downloadgltf() { - const exporter = new DiagramExporter(this.scene); - exporter.exportgltf(); + exportGltf(this.scene); } } \ No newline at end of file diff --git a/src/newrelic/newRelicData.ts b/src/newrelic/newRelicData.ts index c638de8..a45c622 100644 --- a/src/newrelic/newRelicData.ts +++ b/src/newrelic/newRelicData.ts @@ -1,4 +1,3 @@ -import {IPersistenceManager} from "../integration/iPersistenceManager"; import { AbstractMesh, Color3, @@ -9,16 +8,17 @@ import { StandardMaterial, Vector3 } from "@babylonjs/core"; +import {PouchdbPersistenceManager} from "../integration/pouchdbPersistenceManager"; export class NewRelicData { private key: string; private account: string; private data: any[]; private readonly scene: Scene; - private persistenceManager: IPersistenceManager; + private persistenceManager: PouchdbPersistenceManager; private policyLabels: AbstractMesh[] = []; - constructor(persistenceManager: IPersistenceManager, scene: Scene) { + constructor(persistenceManager: PouchdbPersistenceManager, scene: Scene) { this.persistenceManager = persistenceManager; this.scene = scene; this.persistenceManager.getNewRelicData() diff --git a/src/diagram/textLabel.ts b/src/objects/textLabel.ts similarity index 100% rename from src/diagram/textLabel.ts rename to src/objects/textLabel.ts diff --git a/src/server/ring/ringCamera.ts b/src/server/ring/ringCamera.ts deleted file mode 100644 index 7309bf9..0000000 --- a/src/server/ring/ringCamera.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {RingApi} from "ring-client-api"; - -export class RingCamera { - private ringApi: RingApi; - - constructor() { - this.ringApi = new RingApi({ - refreshToken: process.env.RING_TOKEN, - cameraStatusPollingSeconds: 30, - debug: true - }); - - } - - public async getCameras() { - const cams = await this.ringApi.getCameras(); - const camid = cams.map((value) => value.id); - return cams; - } -} \ No newline at end of file diff --git a/src/util/functions/exportGltf.ts b/src/util/functions/exportGltf.ts new file mode 100644 index 0000000..56d5eb9 --- /dev/null +++ b/src/util/functions/exportGltf.ts @@ -0,0 +1,13 @@ +import {Scene} from "@babylonjs/core"; + +export function exportGltf(scene: Scene) { + import("@babylonjs/serializers").then((serializers) => { + serializers.GLTF2Export.GLBAsync(scene, 'diagram.glb', { + shouldExportNode: function (node) { + return (node?.metadata?.exportable as boolean); + } + }).then((gltf) => { + gltf.downloadFiles(); + }); + }); +} \ No newline at end of file diff --git a/src/worker.ts b/src/worker.ts deleted file mode 100644 index 45b6e98..0000000 --- a/src/worker.ts +++ /dev/null @@ -1,51 +0,0 @@ -import {IndexdbPersistenceManager} from "./integration/indexdbPersistenceManager"; -import {DiagramEvent, DiagramEventType} from "./diagram/diagramEntity"; - -const persistenceManager = new IndexdbPersistenceManager("diagram"); - -const ctx: Worker = self as any; - - -ctx.onmessage = (event) => { - console.log(event); - if (event.data.type == 'sync') { - persistenceManager.sync(); - } - if (event.data.type == 'init') { - persistenceManager.updateObserver.add((event) => { - console.log(event); - ctx.postMessage({entity: event}); - }); - persistenceManager.configObserver.add((event) => { - console.log(event); - ctx.postMessage({config: event}); - }); - persistenceManager.initialize().then(() => { - - }); - } else { - if (event.data.entity) { - console.log(event.data); - const data = (event.data.entity as DiagramEvent); - switch (data.type) { - case DiagramEventType.ADD: - persistenceManager.add(data.entity); - break; - case DiagramEventType.DROP: - case DiagramEventType.MODIFY: - persistenceManager.modify(data.entity); - break; - case DiagramEventType.REMOVE: - persistenceManager.remove(data.entity.id); - break; - - } - } - if (event.data.config) { - - persistenceManager.setConfig(event.data.config); - } - - - } -};