small change to formatting/fixed problem with mesh removal removing shared materials.
This commit is contained in:
parent
e85adc1386
commit
cdaff97614
@ -10,6 +10,7 @@ export function grabAndClone(diagramManager: DiagramManager, mesh: AbstractMesh,
|
||||
return null;
|
||||
}
|
||||
diagramObject.baseTransform.setParent(parent);
|
||||
diagramManager.addObject(diagramObject);
|
||||
return diagramObject;
|
||||
} else {
|
||||
const entity = {
|
||||
@ -20,8 +21,12 @@ export function grabAndClone(diagramManager: DiagramManager, mesh: AbstractMesh,
|
||||
scale: vectoxys(mesh.scaling)
|
||||
|
||||
}
|
||||
const obj = new DiagramObject(parent.getScene(), {diagramEntity: entity});
|
||||
const obj = new DiagramObject(parent.getScene(), {
|
||||
diagramEntity: entity,
|
||||
actionManager: diagramManager.actionManager
|
||||
});
|
||||
obj.baseTransform.setParent(parent);
|
||||
diagramManager.addObject(obj);
|
||||
return obj;
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {AbstractMesh, ActionManager, Observable, Scene} from "@babylonjs/core";
|
||||
import {AbstractActionManager, AbstractMesh, ActionManager, Observable, Scene} from "@babylonjs/core";
|
||||
import {DiagramEntity, DiagramEvent, DiagramEventType} from "./types/diagramEntity";
|
||||
import log from "loglevel";
|
||||
import {Controllers} from "../controllers/controllers";
|
||||
@ -54,6 +54,10 @@ export class DiagramManager {
|
||||
this.logger.debug("DiagramManager constructed");
|
||||
}
|
||||
|
||||
public get actionManager(): AbstractActionManager {
|
||||
return this._diagramEntityActionManager;
|
||||
}
|
||||
|
||||
public get diagramMenuManager(): DiagramMenuManager {
|
||||
return this._diagramMenuManager;
|
||||
}
|
||||
@ -66,6 +70,7 @@ export class DiagramManager {
|
||||
return this._diagramObjects.has(mesh?.id)
|
||||
}
|
||||
|
||||
|
||||
public get controllers(): Controllers {
|
||||
return this._controllers;
|
||||
}
|
||||
@ -75,9 +80,13 @@ export class DiagramManager {
|
||||
if (!diagramObject) {
|
||||
return null;
|
||||
}
|
||||
return diagramObject.clone();
|
||||
const obj = diagramObject.clone();
|
||||
return obj;
|
||||
}
|
||||
|
||||
public addObject(diagramObject: DiagramObject) {
|
||||
this._diagramObjects.set(diagramObject.diagramEntity.id, diagramObject);
|
||||
}
|
||||
public get config(): AppConfig {
|
||||
return this._config;
|
||||
}
|
||||
|
||||
@ -148,10 +148,12 @@ export class DiagramObject {
|
||||
public dispose() {
|
||||
this._scene.onAfterRenderObservable.remove(this._sceneObserver);
|
||||
this._sceneObserver = null;
|
||||
this._mesh?.dispose(false, true);
|
||||
this._mesh.setParent(null);
|
||||
this._mesh?.dispose(true, false);
|
||||
this._mesh = null;
|
||||
this._label?.dispose();
|
||||
this._label = null;
|
||||
this._baseTransform.dispose();
|
||||
this._diagramEntity = null;
|
||||
this._scene = null;
|
||||
}
|
||||
@ -160,6 +162,7 @@ export class DiagramObject {
|
||||
this._baseTransform.position = Vector3.Center(fromMesh.getAbsolutePosition().clone(), toMesh.getAbsolutePosition().clone());
|
||||
this._baseTransform.lookAt(toMesh.getAbsolutePosition());
|
||||
this._mesh.scaling.y = Vector3.Distance(fromMesh.getAbsolutePosition(), toMesh.getAbsolutePosition());
|
||||
this._mesh.material = fromMesh.material;
|
||||
if (!this._mesh.parent) {
|
||||
this._mesh.parent = this._baseTransform;
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ export async function groundMeshObserver(ground: AbstractMesh,
|
||||
disableNearInteraction: true,
|
||||
outputCanvasOptions: {
|
||||
canvasOptions: {
|
||||
|
||||
framebufferScaleFactor: 1
|
||||
}
|
||||
},
|
||||
|
||||
@ -34,10 +34,12 @@ export class VrApp {
|
||||
if (webGpu) {
|
||||
engine = new WebGPUEngine(canvas);
|
||||
await (engine as WebGPUEngine).initAsync();
|
||||
console.log("WebGPU enabled");
|
||||
} else {
|
||||
engine = new Engine(canvas, true);
|
||||
}
|
||||
engine.setHardwareScalingLevel(1 / window.devicePixelRatio);
|
||||
console.log(engine.getCaps().multiview);
|
||||
window.onresize = () => {
|
||||
engine.resize();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user