performance optimization, user manager + afterRender were slowing things down.
This commit is contained in:
parent
9e7833b149
commit
ffe8f60f38
@ -33,8 +33,11 @@ export class DiagramObject {
|
|||||||
private _eventObservable: Observable<DiagramEvent>;
|
private _eventObservable: Observable<DiagramEvent>;
|
||||||
private _mesh: AbstractMesh;
|
private _mesh: AbstractMesh;
|
||||||
private _label: AbstractMesh;
|
private _label: AbstractMesh;
|
||||||
|
private _meshesPresent: boolean = false;
|
||||||
|
private _positionHash: string;
|
||||||
|
|
||||||
public grabbed: boolean = false;
|
public grabbed: boolean = false;
|
||||||
|
|
||||||
public get mesh(): AbstractMesh {
|
public get mesh(): AbstractMesh {
|
||||||
return this._mesh;
|
return this._mesh;
|
||||||
}
|
}
|
||||||
@ -106,6 +109,7 @@ export class DiagramObject {
|
|||||||
temp.dispose();
|
temp.dispose();
|
||||||
this._label.position.y = y + .06;
|
this._label.position.y = y + .06;
|
||||||
this._label.billboardMode = Mesh.BILLBOARDMODE_Y;
|
this._label.billboardMode = Mesh.BILLBOARDMODE_Y;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,19 +152,37 @@ export class DiagramObject {
|
|||||||
if (this._from && this._to) {
|
if (this._from && this._to) {
|
||||||
if (!this._sceneObserver) {
|
if (!this._sceneObserver) {
|
||||||
this._observingStart = Date.now();
|
this._observingStart = Date.now();
|
||||||
|
let tick = 0;
|
||||||
this._sceneObserver = this._scene.onAfterRenderObservable.add(() => {
|
this._sceneObserver = this._scene.onAfterRenderObservable.add(() => {
|
||||||
const fromMesh = this._scene.getMeshById(this._from);
|
tick++;
|
||||||
const toMesh = this._scene.getMeshById(this._to);
|
if (tick % 5 === 0) {
|
||||||
if (fromMesh && toMesh) {
|
if (this._meshesPresent) {
|
||||||
this.updateConnection(fromMesh, toMesh);
|
|
||||||
} else {
|
const fromMesh = this._scene.getMeshById(this._from);
|
||||||
if (Date.now() - this._observingStart > 5000) {
|
const toMesh = this._scene.getMeshById(this._to);
|
||||||
this._logger.warn('DiagramObject connection timeout for: ', this._from, this._to, ' removing');
|
|
||||||
this._eventObservable.notifyObservers({
|
if (fromMesh && toMesh) {
|
||||||
type: DiagramEventType.REMOVE,
|
this.updateConnection(fromMesh, toMesh);
|
||||||
entity: this._diagramEntity
|
}
|
||||||
}, DiagramEventObserverMask.ALL);
|
|
||||||
this.dispose();
|
} else {
|
||||||
|
const fromMesh = this._scene.getMeshById(this._from);
|
||||||
|
const toMesh = this._scene.getMeshById(this._to);
|
||||||
|
if (fromMesh && toMesh) {
|
||||||
|
this.updateConnection(fromMesh, toMesh);
|
||||||
|
this._meshesPresent = true;
|
||||||
|
} else {
|
||||||
|
if (Date.now() - this._observingStart > 5000) {
|
||||||
|
this._logger.warn('DiagramObject connection timeout for: ', this._from, this._to, ' removing');
|
||||||
|
this._eventObservable.notifyObservers({
|
||||||
|
type: DiagramEventType.REMOVE,
|
||||||
|
entity: this._diagramEntity
|
||||||
|
}, DiagramEventObserverMask.ALL);
|
||||||
|
this._scene.onAfterRenderObservable.remove(this._sceneObserver);
|
||||||
|
this.dispose();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, -1, false, this);
|
}, -1, false, this);
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import {buildQuestLink} from "./util/functions/buildQuestLink";
|
|||||||
import {exportGltf} from "./util/functions/exportGltf";
|
import {exportGltf} from "./util/functions/exportGltf";
|
||||||
import {DefaultScene} from "./defaultScene";
|
import {DefaultScene} from "./defaultScene";
|
||||||
import {Introduction} from "./tutorial/introduction";
|
import {Introduction} from "./tutorial/introduction";
|
||||||
import {UserManager} from "./users/userManager";
|
|
||||||
|
|
||||||
|
|
||||||
const webGpu = false;
|
const webGpu = false;
|
||||||
@ -95,7 +94,7 @@ function setMainCamera(scene: Scene) {
|
|||||||
|
|
||||||
async function initDb(diagramManager: DiagramManager) {
|
async function initDb(diagramManager: DiagramManager) {
|
||||||
const db = new PouchdbPersistenceManager();
|
const db = new PouchdbPersistenceManager();
|
||||||
const userManager = new UserManager(db.onUserObservable);
|
//const userManager = new UserManager(db.onUserObservable);
|
||||||
db.setDiagramManager(diagramManager);
|
db.setDiagramManager(diagramManager);
|
||||||
|
|
||||||
await db.initialize();
|
await db.initialize();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user