Fixed code inspections.
This commit is contained in:
parent
c945423954
commit
88668c3d64
@ -9,11 +9,11 @@ import {
|
|||||||
WebXRDefaultExperience,
|
WebXRDefaultExperience,
|
||||||
WebXRInputSource
|
WebXRInputSource
|
||||||
} from "@babylonjs/core";
|
} from "@babylonjs/core";
|
||||||
import {MeshConverter} from "../diagram/meshConverter";
|
|
||||||
import {DiagramManager} from "../diagram/diagramManager";
|
import {DiagramManager} from "../diagram/diagramManager";
|
||||||
import {DiagramEvent, DiagramEventType} from "../diagram/diagramEntity";
|
import {DiagramEvent, DiagramEventType} from "../diagram/diagramEntity";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {Controllers} from "./controllers";
|
import {Controllers} from "./controllers";
|
||||||
|
import {toDiagramEntity} from "../diagram/functions/toDiagramEntity";
|
||||||
|
|
||||||
export class Base {
|
export class Base {
|
||||||
static stickVector = Vector3.Zero();
|
static stickVector = Vector3.Zero();
|
||||||
@ -73,7 +73,10 @@ export class Base {
|
|||||||
if (event.type == 'pulse') {
|
if (event.type == 'pulse') {
|
||||||
this.logger.debug(event);
|
this.logger.debug(event);
|
||||||
if (event.gripId == this?.controller?.grip?.id) {
|
if (event.gripId == this?.controller?.grip?.id) {
|
||||||
this.controller?.motionController?.pulse(.25, 30);
|
this.controller?.motionController?.pulse(.25, 30)
|
||||||
|
.then(() => {
|
||||||
|
this.logger.debug("pulse done");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -152,7 +155,7 @@ export class Base {
|
|||||||
this.previousParentId = null;
|
this.previousParentId = null;
|
||||||
const event: DiagramEvent = {
|
const event: DiagramEvent = {
|
||||||
type: DiagramEventType.ADD,
|
type: DiagramEventType.ADD,
|
||||||
entity: MeshConverter.toDiagramEntity(newMesh)
|
entity: toDiagramEntity(newMesh)
|
||||||
}
|
}
|
||||||
this.diagramManager.onDiagramEventObservable.notifyObservers(event);
|
this.diagramManager.onDiagramEventObservable.notifyObservers(event);
|
||||||
|
|
||||||
@ -215,7 +218,7 @@ export class Base {
|
|||||||
if (mesh?.metadata?.template.indexOf('#') == -1) {
|
if (mesh?.metadata?.template.indexOf('#') == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const entity = MeshConverter.toDiagramEntity(mesh);
|
const entity = toDiagramEntity(mesh);
|
||||||
const event: DiagramEvent = {
|
const event: DiagramEvent = {
|
||||||
type: DiagramEventType.DROP,
|
type: DiagramEventType.DROP,
|
||||||
entity: entity
|
entity: entity
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import {DiagramEvent, DiagramEventType} from "./diagramEntity";
|
import {DiagramEvent, DiagramEventType} from "./diagramEntity";
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {MeshConverter} from "./meshConverter";
|
|
||||||
import {applyPhysics} from "./functions/diagramShapePhysics";
|
import {applyPhysics} from "./functions/diagramShapePhysics";
|
||||||
import {ActionManager, Color3, PhysicsMotionType, Scene} from "@babylonjs/core";
|
import {ActionManager, Color3, PhysicsMotionType, Scene} from "@babylonjs/core";
|
||||||
import {TextLabel} from "./textLabel";
|
import {TextLabel} from "./textLabel";
|
||||||
import {Toolbox} from "../toolbox/toolbox";
|
import {Toolbox} from "../toolbox/toolbox";
|
||||||
import {DiaSounds} from "../util/diaSounds";
|
import {DiaSounds} from "../util/diaSounds";
|
||||||
import {IPersistenceManager} from "../integration/iPersistenceManager";
|
import {IPersistenceManager} from "../integration/iPersistenceManager";
|
||||||
|
import {fromDiagramEntity} from "./functions/fromDiagramEntity";
|
||||||
|
|
||||||
|
|
||||||
export function diagramEventHandler(event: DiagramEvent,
|
export function diagramEventHandler(event: DiagramEvent,
|
||||||
@ -27,7 +27,7 @@ export function diagramEventHandler(event: DiagramEvent,
|
|||||||
log.debug('no mesh found for ' + event.entity.template + "-" + event.entity.color, 'adding it');
|
log.debug('no mesh found for ' + event.entity.template + "-" + event.entity.color, 'adding it');
|
||||||
toolbox.updateToolbox(event.entity.color);
|
toolbox.updateToolbox(event.entity.color);
|
||||||
}
|
}
|
||||||
mesh = MeshConverter.fromDiagramEntity(event.entity, scene);
|
mesh = fromDiagramEntity(event.entity, scene);
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
mesh.actionManager = actionManager;
|
mesh.actionManager = actionManager;
|
||||||
if (physicsEnabled) {
|
if (physicsEnabled) {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import {AbstractMesh, Color3, InstancedMesh, Mesh, Observable, PhysicsMotionType, Scene} from "@babylonjs/core";
|
import {AbstractMesh, Color3, InstancedMesh, Mesh, Observable, PhysicsMotionType, Scene} from "@babylonjs/core";
|
||||||
import {DiagramEntity, DiagramEvent, DiagramEventType} from "./diagramEntity";
|
import {DiagramEntity, DiagramEvent, DiagramEventType} from "./diagramEntity";
|
||||||
import {IPersistenceManager} from "../integration/iPersistenceManager";
|
import {IPersistenceManager} from "../integration/iPersistenceManager";
|
||||||
import {MeshConverter} from "./meshConverter";
|
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {Controllers} from "../controllers/controllers";
|
import {Controllers} from "../controllers/controllers";
|
||||||
import {DiaSounds} from "../util/diaSounds";
|
import {DiaSounds} from "../util/diaSounds";
|
||||||
@ -13,6 +12,8 @@ import {diagramEventHandler} from "./diagramEventHandler";
|
|||||||
import {deepCopy} from "../util/deepCopy";
|
import {deepCopy} from "../util/deepCopy";
|
||||||
import {applyPhysics} from "./functions/diagramShapePhysics";
|
import {applyPhysics} from "./functions/diagramShapePhysics";
|
||||||
import {applyScaling} from "./functions/applyScaling";
|
import {applyScaling} from "./functions/applyScaling";
|
||||||
|
import {toDiagramEntity} from "./functions/toDiagramEntity";
|
||||||
|
import {fromDiagramEntity} from "./functions/fromDiagramEntity";
|
||||||
|
|
||||||
|
|
||||||
export class DiagramManager {
|
export class DiagramManager {
|
||||||
@ -52,7 +53,7 @@ export class DiagramManager {
|
|||||||
this.logger.debug("removing connection", m.id);
|
this.logger.debug("removing connection", m.id);
|
||||||
this.onDiagramEventObservable.notifyObservers({
|
this.onDiagramEventObservable.notifyObservers({
|
||||||
type: DiagramEventType.REMOVE,
|
type: DiagramEventType.REMOVE,
|
||||||
entity: MeshConverter.toDiagramEntity(m)
|
entity: toDiagramEntity(m)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -100,7 +101,7 @@ export class DiagramManager {
|
|||||||
log.debug('no mesh found for ' + event.template + "-" + event.color, 'adding it');
|
log.debug('no mesh found for ' + event.template + "-" + event.color, 'adding it');
|
||||||
this.toolbox.updateToolbox(event.color);
|
this.toolbox.updateToolbox(event.color);
|
||||||
}
|
}
|
||||||
const mesh = MeshConverter.fromDiagramEntity(event, this.scene);
|
const mesh = fromDiagramEntity(event, this.scene);
|
||||||
mesh.actionManager = this.diagramEntityActionManager.manager;
|
mesh.actionManager = this.diagramEntityActionManager.manager;
|
||||||
if (event.parent) {
|
if (event.parent) {
|
||||||
mesh.parent = this.scene.getMeshById(event.parent);
|
mesh.parent = this.scene.getMeshById(event.parent);
|
||||||
|
|||||||
@ -0,0 +1,77 @@
|
|||||||
|
import {DiagramEntity} from "../diagramEntity";
|
||||||
|
import {AbstractMesh, Color3, InstancedMesh, Mesh, Quaternion, Scene, StandardMaterial} from "@babylonjs/core";
|
||||||
|
import {DiagramConnection} from "../diagramConnection";
|
||||||
|
import {TextLabel} from "../textLabel";
|
||||||
|
import log from "loglevel";
|
||||||
|
import {v4 as uuidv4} from 'uuid';
|
||||||
|
|
||||||
|
const logger = log.getLogger('fromDiagramEntity');
|
||||||
|
|
||||||
|
export function fromDiagramEntity(entity: DiagramEntity, scene: Scene): AbstractMesh {
|
||||||
|
if (!entity) {
|
||||||
|
logger.error("fromDiagramEntity: entity is null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!entity.id) {
|
||||||
|
entity.id = "id" + uuidv4();
|
||||||
|
}
|
||||||
|
let mesh: AbstractMesh = scene.getMeshById(entity.id);
|
||||||
|
if (mesh) {
|
||||||
|
logger.debug(`mesh ${mesh.id} already exists`);
|
||||||
|
} else {
|
||||||
|
if (entity.template == "#connection-template") {
|
||||||
|
const connection: DiagramConnection = new DiagramConnection(entity.from, entity.to, scene);
|
||||||
|
logger.debug(`connection.mesh = ${connection.mesh.id}`);
|
||||||
|
mesh = connection.mesh;
|
||||||
|
} else {
|
||||||
|
mesh = scene.getMeshById("tool-" + entity.template + "-" + entity.color);
|
||||||
|
if (mesh) {
|
||||||
|
if (mesh.isAnInstance) {
|
||||||
|
logger.error(`mesh ${mesh.id} is an instance`);
|
||||||
|
} else {
|
||||||
|
mesh = new InstancedMesh(entity.id, (mesh as Mesh));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn('no mesh found for ' + entity.template + "-" + entity.color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (mesh) {
|
||||||
|
mesh.metadata = {template: entity.template};
|
||||||
|
if (entity.position) {
|
||||||
|
mesh.position = entity.position;
|
||||||
|
}
|
||||||
|
if (entity.rotation) {
|
||||||
|
if (mesh.rotationQuaternion) {
|
||||||
|
mesh.rotationQuaternion = Quaternion.FromEulerAngles(entity.rotation.x, entity.rotation.y, entity.rotation.z);
|
||||||
|
} else {
|
||||||
|
mesh.rotation = entity.rotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entity.parent) {
|
||||||
|
mesh.parent = scene.getNodeById(entity.parent);
|
||||||
|
}
|
||||||
|
if (entity.scale) {
|
||||||
|
mesh.scaling = entity.scale;
|
||||||
|
}
|
||||||
|
if (!mesh.material) {
|
||||||
|
const material = new StandardMaterial("material-" + entity.id, scene);
|
||||||
|
material.diffuseColor = Color3.FromHexString(entity.color);
|
||||||
|
mesh.material = material;
|
||||||
|
}
|
||||||
|
if (entity.text) {
|
||||||
|
mesh.metadata.text = entity.text;
|
||||||
|
TextLabel.updateTextNode(mesh, entity.text);
|
||||||
|
}
|
||||||
|
if (entity.from) {
|
||||||
|
mesh.metadata.from = entity.from;
|
||||||
|
}
|
||||||
|
if (entity.to) {
|
||||||
|
mesh.metadata.to = entity.to;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("fromDiagramEntity: mesh is null after it should have been created");
|
||||||
|
}
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
import {AbstractMesh} from "@babylonjs/core";
|
||||||
|
import {DiagramEntity} from "../diagramEntity";
|
||||||
|
import log from "loglevel";
|
||||||
|
import {v4 as uuidv4} from 'uuid';
|
||||||
|
|
||||||
|
const logger = log.getLogger('toDiagramEntity');
|
||||||
|
|
||||||
|
export function toDiagramEntity(mesh: AbstractMesh): DiagramEntity {
|
||||||
|
|
||||||
|
if (!mesh) {
|
||||||
|
logger.error("toDiagramEntity: mesh is null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const entity = <DiagramEntity>{};
|
||||||
|
if ("new" == mesh?.id) {
|
||||||
|
mesh.id = "id" + uuidv4();
|
||||||
|
}
|
||||||
|
entity.id = mesh.id;
|
||||||
|
entity.position = mesh.position;
|
||||||
|
entity.rotation = mesh.rotation;
|
||||||
|
entity.last_seen = new Date();
|
||||||
|
entity.template = mesh?.metadata?.template;
|
||||||
|
entity.text = mesh?.metadata?.text;
|
||||||
|
entity.from = mesh?.metadata?.from;
|
||||||
|
entity.to = mesh?.metadata?.to;
|
||||||
|
entity.scale = mesh.scaling;
|
||||||
|
if (mesh.material) {
|
||||||
|
entity.color = (mesh.material as any).diffuseColor.toHexString();
|
||||||
|
} else {
|
||||||
|
logger.error("toDiagramEntity: mesh.material is null");
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
@ -1,105 +0,0 @@
|
|||||||
import {DiagramEntity} from "./diagramEntity";
|
|
||||||
import {AbstractMesh, Color3, InstancedMesh, Mesh, Quaternion, Scene, StandardMaterial} from "@babylonjs/core";
|
|
||||||
import {v4 as uuidv4} from 'uuid';
|
|
||||||
import log from "loglevel";
|
|
||||||
import {TextLabel} from "./textLabel";
|
|
||||||
import {DiagramConnection} from "./diagramConnection";
|
|
||||||
|
|
||||||
export class MeshConverter {
|
|
||||||
private static logger = log.getLogger('MeshConverter');
|
|
||||||
|
|
||||||
public static toDiagramEntity(mesh: AbstractMesh): DiagramEntity {
|
|
||||||
if (!mesh) {
|
|
||||||
this.logger.error("toDiagramEntity: mesh is null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const entity = <DiagramEntity>{};
|
|
||||||
if ("new" == mesh?.id) {
|
|
||||||
mesh.id = "id" + uuidv4();
|
|
||||||
}
|
|
||||||
entity.id = mesh.id;
|
|
||||||
entity.position = mesh.position;
|
|
||||||
|
|
||||||
entity.rotation = mesh.rotation;
|
|
||||||
entity.last_seen = new Date();
|
|
||||||
entity.template = mesh?.metadata?.template;
|
|
||||||
entity.text = mesh?.metadata?.text;
|
|
||||||
entity.from = mesh?.metadata?.from;
|
|
||||||
entity.to = mesh?.metadata?.to;
|
|
||||||
entity.scale = mesh.scaling;
|
|
||||||
if (mesh.material) {
|
|
||||||
entity.color = (mesh.material as any).diffuseColor.toHexString();
|
|
||||||
} else {
|
|
||||||
this.logger.error("toDiagramEntity: mesh.material is null");
|
|
||||||
}
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
public static fromDiagramEntity(entity: DiagramEntity, scene: Scene): AbstractMesh {
|
|
||||||
if (!entity) {
|
|
||||||
this.logger.error("fromDiagramEntity: entity is null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!entity.id) {
|
|
||||||
entity.id = "id" + uuidv4();
|
|
||||||
}
|
|
||||||
let mesh: AbstractMesh = scene.getMeshById(entity.id);
|
|
||||||
if (mesh) {
|
|
||||||
this.logger.debug(`mesh ${mesh.id} already exists`);
|
|
||||||
} else {
|
|
||||||
if (entity.template == "#connection-template") {
|
|
||||||
const connection: DiagramConnection = new DiagramConnection(entity.from, entity.to, scene);
|
|
||||||
this.logger.debug(`connection.mesh = ${connection.mesh.id}`);
|
|
||||||
mesh = connection.mesh;
|
|
||||||
} else {
|
|
||||||
mesh = scene.getMeshById("tool-" + entity.template + "-" + entity.color);
|
|
||||||
if (mesh) {
|
|
||||||
if (mesh.isAnInstance) {
|
|
||||||
this.logger.error(`mesh ${mesh.id} is an instance`);
|
|
||||||
} else {
|
|
||||||
mesh = new InstancedMesh(entity.id, (mesh as Mesh));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.logger.warn('no mesh found for ' + entity.template + "-" + entity.color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (mesh) {
|
|
||||||
mesh.metadata = {template: entity.template};
|
|
||||||
if (entity.position) {
|
|
||||||
mesh.position = entity.position;
|
|
||||||
}
|
|
||||||
if (entity.rotation) {
|
|
||||||
if (mesh.rotationQuaternion) {
|
|
||||||
mesh.rotationQuaternion = Quaternion.FromEulerAngles(entity.rotation.x, entity.rotation.y, entity.rotation.z);
|
|
||||||
} else {
|
|
||||||
mesh.rotation = entity.rotation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entity.parent) {
|
|
||||||
mesh.parent = scene.getNodeById(entity.parent);
|
|
||||||
}
|
|
||||||
if (entity.scale) {
|
|
||||||
mesh.scaling = entity.scale;
|
|
||||||
}
|
|
||||||
if (!mesh.material) {
|
|
||||||
const material = new StandardMaterial("material-" + entity.id, scene);
|
|
||||||
material.diffuseColor = Color3.FromHexString(entity.color);
|
|
||||||
mesh.material = material;
|
|
||||||
}
|
|
||||||
if (entity.text) {
|
|
||||||
mesh.metadata.text = entity.text;
|
|
||||||
TextLabel.updateTextNode(mesh, entity.text);
|
|
||||||
}
|
|
||||||
if (entity.from) {
|
|
||||||
mesh.metadata.from = entity.from;
|
|
||||||
}
|
|
||||||
if (entity.to) {
|
|
||||||
mesh.metadata.to = entity.to;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.logger.error("fromDiagramEntity: mesh is null after it should have been created");
|
|
||||||
}
|
|
||||||
return mesh;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -186,7 +186,7 @@ export class DrawioManager {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
const geo = cell.querySelector('[id="' + id + '"] > mxGeometry');
|
const geo = cell.querySelector('[id="' + id + '"] > mxGeometry');
|
||||||
let geometry = null;
|
let geometry;
|
||||||
if (geo) {
|
if (geo) {
|
||||||
geometry = {
|
geometry = {
|
||||||
x: Number.parseFloat(geo.getAttribute('x')),
|
x: Number.parseFloat(geo.getAttribute('x')),
|
||||||
|
|||||||
@ -2,9 +2,10 @@ import {DiagramListing, DiagramListingEvent, DiagramListingEventType, IPersisten
|
|||||||
import {AbstractMesh, Observable, Vector3} from "@babylonjs/core";
|
import {AbstractMesh, Observable, Vector3} from "@babylonjs/core";
|
||||||
import {DiagramEntity} from "../diagram/diagramEntity";
|
import {DiagramEntity} from "../diagram/diagramEntity";
|
||||||
import Dexie from "dexie";
|
import Dexie from "dexie";
|
||||||
import {MeshConverter} from "../diagram/meshConverter";
|
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {AppConfigType} from "../util/appConfigType";
|
import {AppConfigType} from "../util/appConfigType";
|
||||||
|
import {toDiagramEntity} from "../diagram/functions/toDiagramEntity";
|
||||||
|
|
||||||
export class IndexdbPersistenceManager implements IPersistenceManager {
|
export class IndexdbPersistenceManager implements IPersistenceManager {
|
||||||
private readonly logger = log.getLogger('IndexdbPersistenceManager');
|
private readonly logger = log.getLogger('IndexdbPersistenceManager');
|
||||||
@ -33,7 +34,7 @@ export class IndexdbPersistenceManager implements IPersistenceManager {
|
|||||||
this.logger.error("Adding null mesh, early return");
|
this.logger.error("Adding null mesh, early return");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const entity = <any>MeshConverter.toDiagramEntity(mesh);
|
const entity = <any>toDiagramEntity(mesh);
|
||||||
entity.position = this.vectoxys(mesh.position);
|
entity.position = this.vectoxys(mesh.position);
|
||||||
entity.rotation = this.vectoxys(mesh.rotation);
|
entity.rotation = this.vectoxys(mesh.rotation);
|
||||||
entity.scale = this.vectoxys(mesh.scaling);
|
entity.scale = this.vectoxys(mesh.scaling);
|
||||||
@ -97,8 +98,7 @@ export class IndexdbPersistenceManager implements IPersistenceManager {
|
|||||||
|
|
||||||
public async getConfig(): Promise<AppConfigType> {
|
public async getConfig(): Promise<AppConfigType> {
|
||||||
const configs = await this.db['config'].toArray();
|
const configs = await this.db['config'].toArray();
|
||||||
const config = configs[0];
|
return configs[0];
|
||||||
return config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initialize() {
|
public async initialize() {
|
||||||
@ -151,7 +151,7 @@ export class IndexdbPersistenceManager implements IPersistenceManager {
|
|||||||
this.logger.error("Modifying null mesh, early return");
|
this.logger.error("Modifying null mesh, early return");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const entity = <any>MeshConverter.toDiagramEntity(mesh);
|
const entity = <any>toDiagramEntity(mesh);
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
this.logger.error("Modifying null mesh, early return");
|
this.logger.error("Modifying null mesh, early return");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export class NewRelicData {
|
|||||||
private key: string;
|
private key: string;
|
||||||
private account: string;
|
private account: string;
|
||||||
private data: any[];
|
private data: any[];
|
||||||
private scene: Scene;
|
private readonly scene: Scene;
|
||||||
private persistenceManager: IPersistenceManager;
|
private persistenceManager: IPersistenceManager;
|
||||||
private policyLabels: AbstractMesh[] = [];
|
private policyLabels: AbstractMesh[] = [];
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ export class NewRelicData {
|
|||||||
const policies: Map<String, { x: number, y: number }> = new Map<string, { x: number, y: number }>();
|
const policies: Map<String, { x: number, y: number }> = new Map<string, { x: number, y: number }>();
|
||||||
this.data.forEach((item) => {
|
this.data.forEach((item) => {
|
||||||
const policy = item.policyName ? item.policyName : "No Policy";
|
const policy = item.policyName ? item.policyName : "No Policy";
|
||||||
let x = 0;
|
let x;
|
||||||
let y: number = 0;
|
let y: number = 0;
|
||||||
if (policies.has(policy)) {
|
if (policies.has(policy)) {
|
||||||
const value = policies.get(policy);
|
const value = policies.get(policy);
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import {Button3D, GUI3DManager, PlanePanel, TextBlock} from "@babylonjs/gui";
|
|||||||
import {DiagramManager} from "../diagram/diagramManager";
|
import {DiagramManager} from "../diagram/diagramManager";
|
||||||
import {EditMenuState} from "./editMenuState";
|
import {EditMenuState} from "./editMenuState";
|
||||||
import {DiagramEvent, DiagramEventType} from "../diagram/diagramEntity";
|
import {DiagramEvent, DiagramEventType} from "../diagram/diagramEntity";
|
||||||
import {MeshConverter} from "../diagram/meshConverter";
|
|
||||||
import log from "loglevel";
|
import log from "loglevel";
|
||||||
import {InputTextView} from "../information/inputTextView";
|
import {InputTextView} from "../information/inputTextView";
|
||||||
import {DiaSounds} from "../util/diaSounds";
|
import {DiaSounds} from "../util/diaSounds";
|
||||||
@ -23,6 +22,7 @@ import {CameraHelper} from "../util/cameraHelper";
|
|||||||
import {TextLabel} from "../diagram/textLabel";
|
import {TextLabel} from "../diagram/textLabel";
|
||||||
import {DiagramConnection} from "../diagram/diagramConnection";
|
import {DiagramConnection} from "../diagram/diagramConnection";
|
||||||
import {GLTF2Export} from "@babylonjs/serializers";
|
import {GLTF2Export} from "@babylonjs/serializers";
|
||||||
|
import {toDiagramEntity} from "../diagram/functions/toDiagramEntity";
|
||||||
|
|
||||||
export class EditMenu {
|
export class EditMenu {
|
||||||
private state: EditMenuState = EditMenuState.NONE;
|
private state: EditMenuState = EditMenuState.NONE;
|
||||||
@ -118,7 +118,7 @@ export class EditMenu {
|
|||||||
}
|
}
|
||||||
this.diagramManager.onDiagramEventObservable.notifyObservers({
|
this.diagramManager.onDiagramEventObservable.notifyObservers({
|
||||||
type: DiagramEventType.MODIFY,
|
type: DiagramEventType.MODIFY,
|
||||||
entity: MeshConverter.toDiagramEntity(mesh),
|
entity: toDiagramEntity(mesh),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ export class EditMenu {
|
|||||||
mesh.dispose();
|
mesh.dispose();
|
||||||
this.diagramManager.onDiagramEventObservable.notifyObservers({
|
this.diagramManager.onDiagramEventObservable.notifyObservers({
|
||||||
type: DiagramEventType.MODIFY,
|
type: DiagramEventType.MODIFY,
|
||||||
entity: MeshConverter.toDiagramEntity(newMesh)
|
entity: toDiagramEntity(newMesh)
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -199,7 +199,7 @@ export class EditMenu {
|
|||||||
this.connection.to = mesh.id;
|
this.connection.to = mesh.id;
|
||||||
this.diagramManager.onDiagramEventObservable.notifyObservers({
|
this.diagramManager.onDiagramEventObservable.notifyObservers({
|
||||||
type: DiagramEventType.ADD,
|
type: DiagramEventType.ADD,
|
||||||
entity: MeshConverter.toDiagramEntity(this.connection.mesh)
|
entity: toDiagramEntity(this.connection.mesh)
|
||||||
});
|
});
|
||||||
this.connection = null;
|
this.connection = null;
|
||||||
} else {
|
} else {
|
||||||
@ -212,7 +212,7 @@ export class EditMenu {
|
|||||||
const event: DiagramEvent = {
|
const event: DiagramEvent = {
|
||||||
type: DiagramEventType.REMOVE,
|
type: DiagramEventType.REMOVE,
|
||||||
entity:
|
entity:
|
||||||
MeshConverter.toDiagramEntity(mesh)
|
toDiagramEntity(mesh)
|
||||||
}
|
}
|
||||||
this.diagramManager.onDiagramEventObservable.notifyObservers(event);
|
this.diagramManager.onDiagramEventObservable.notifyObservers(event);
|
||||||
}
|
}
|
||||||
@ -226,8 +226,8 @@ export class EditMenu {
|
|||||||
this.gizmoManager.attachToMesh(mesh);
|
this.gizmoManager.attachToMesh(mesh);
|
||||||
this.gizmoManager.gizmos.boundingBoxGizmo.onScaleBoxDragObservable.add(() => {
|
this.gizmoManager.gizmos.boundingBoxGizmo.onScaleBoxDragObservable.add(() => {
|
||||||
this.diagramManager.onDiagramEventObservable.notifyObservers({
|
this.diagramManager.onDiagramEventObservable.notifyObservers({
|
||||||
type: DiagramEventType.MODIFY,
|
type: DiagramEventType.MODIFY,
|
||||||
entity: MeshConverter.toDiagramEntity(mesh),
|
entity: toDiagramEntity(mesh),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this.logger.debug(mesh.scaling);
|
this.logger.debug(mesh.scaling);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ export class Toolbox {
|
|||||||
private readonly gridsize = 5;
|
private readonly gridsize = 5;
|
||||||
private readonly addPanel: StackPanel3D;
|
private readonly addPanel: StackPanel3D;
|
||||||
private readonly controllers: Controllers;
|
private readonly controllers: Controllers;
|
||||||
private xObserver;
|
private readonly xObserver;
|
||||||
public readonly colorChangeObservable: Observable<{ oldColor: string, newColor: string }> =
|
public readonly colorChangeObservable: Observable<{ oldColor: string, newColor: string }> =
|
||||||
new Observable<{ oldColor: string; newColor: string }>()
|
new Observable<{ oldColor: string; newColor: string }>()
|
||||||
|
|
||||||
@ -103,28 +103,27 @@ export class Toolbox {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case ToolType.BOX:
|
case ToolType.BOX:
|
||||||
return MeshBuilder.CreateBox(toolname, {width: 1, height: 1, depth: 1}, this.scene);
|
return MeshBuilder.CreateBox(toolname, {width: 1, height: 1, depth: 1}, this.scene);
|
||||||
break;
|
|
||||||
case ToolType.SPHERE:
|
case ToolType.SPHERE:
|
||||||
return MeshBuilder.CreateSphere(toolname, {diameter: 1}, this.scene);
|
return MeshBuilder.CreateSphere(toolname, {diameter: 1}, this.scene);
|
||||||
break;
|
|
||||||
case ToolType.CYLINDER:
|
case ToolType.CYLINDER:
|
||||||
return MeshBuilder.CreateCylinder(toolname, {height: 1, diameter: 1}, this.scene);
|
return MeshBuilder.CreateCylinder(toolname, {height: 1, diameter: 1}, this.scene);
|
||||||
break;
|
|
||||||
case ToolType.CONE:
|
case ToolType.CONE:
|
||||||
return MeshBuilder.CreateCylinder(toolname, {
|
return MeshBuilder.CreateCylinder(toolname, {
|
||||||
diameterTop: 0,
|
diameterTop: 0,
|
||||||
height: 1,
|
height: 1,
|
||||||
diameterBottom: 1
|
diameterBottom: 1
|
||||||
}, this.scene);
|
}, this.scene);
|
||||||
break;
|
|
||||||
case ToolType.PLANE:
|
case ToolType.PLANE:
|
||||||
return MeshBuilder.CreatePlane(toolname, {width: 1, height: 1}, this.scene);
|
return MeshBuilder.CreatePlane(toolname, {width: 1, height: 1}, this.scene);
|
||||||
break;
|
|
||||||
case ToolType.OBJECT:
|
case ToolType.OBJECT:
|
||||||
return null;
|
return null;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private toolId(tool: ToolType, color: Color3) {
|
private toolId(tool: ToolType, color: Color3) {
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import Hls from "hls.js";
|
|||||||
|
|
||||||
|
|
||||||
export class Introduction {
|
export class Introduction {
|
||||||
private scene: Scene;
|
private readonly scene: Scene;
|
||||||
private manager: GUI3DManager;
|
private manager: GUI3DManager;
|
||||||
private physicsHelper: PhysicsHelper;
|
private physicsHelper: PhysicsHelper;
|
||||||
private current: AbstractMesh[] = [];
|
private current: AbstractMesh[] = [];
|
||||||
|
|||||||
@ -4,11 +4,6 @@ import round from "round";
|
|||||||
import {IPersistenceManager} from "../integration/iPersistenceManager";
|
import {IPersistenceManager} from "../integration/iPersistenceManager";
|
||||||
import {AppConfigType} from "./appConfigType";
|
import {AppConfigType} from "./appConfigType";
|
||||||
|
|
||||||
export type SnapValue = {
|
|
||||||
value: number,
|
|
||||||
label: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export class AppConfig {
|
export class AppConfig {
|
||||||
private readonly logger = log.getLogger('AppConfig');
|
private readonly logger = log.getLogger('AppConfig');
|
||||||
public readonly onConfigChangedObservable = new Observable<AppConfigType>();
|
public readonly onConfigChangedObservable = new Observable<AppConfigType>();
|
||||||
@ -24,7 +19,7 @@ export class AppConfig {
|
|||||||
if (!this._currentConfig) {
|
if (!this._currentConfig) {
|
||||||
this.persistenceManager.getConfig().then((config) => {
|
this.persistenceManager.getConfig().then((config) => {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
const newconfig = {
|
this._currentConfig = {
|
||||||
id: 1,
|
id: 1,
|
||||||
gridSnap: .1,
|
gridSnap: .1,
|
||||||
rotateSnap: 45,
|
rotateSnap: 45,
|
||||||
@ -35,7 +30,6 @@ export class AppConfig {
|
|||||||
physicsEnabled: false,
|
physicsEnabled: false,
|
||||||
demoCompleted: false,
|
demoCompleted: false,
|
||||||
}
|
}
|
||||||
this._currentConfig = newconfig;
|
|
||||||
this.save();
|
this.save();
|
||||||
} else {
|
} else {
|
||||||
this._currentConfig = config;
|
this._currentConfig = config;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import HavokPhysics from "@babylonjs/havok";
|
|||||||
import {AppConfig} from "./appConfig";
|
import {AppConfig} from "./appConfig";
|
||||||
|
|
||||||
export class CustomPhysics {
|
export class CustomPhysics {
|
||||||
private scene: Scene;
|
private readonly scene: Scene;
|
||||||
private config: AppConfig;
|
private config: AppConfig;
|
||||||
|
|
||||||
constructor(scene: Scene, config: AppConfig) {
|
constructor(scene: Scene, config: AppConfig) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user