|
@@ -1,6 +1,6 @@
|
|
import { TemplateManager } from './../templateManager';
|
|
import { TemplateManager } from './../templateManager';
|
|
import configurationLoader from './../configuration/loader';
|
|
import configurationLoader from './../configuration/loader';
|
|
-import { Observable, Engine, Scene, ArcRotateCamera, Vector3, SceneLoader, Mesh, HemisphericLight } from 'babylonjs';
|
|
|
|
|
|
+import { Observable, Engine, Scene, ArcRotateCamera, Vector3, SceneLoader, AbstractMesh, Mesh, HemisphericLight } from 'babylonjs';
|
|
import { ViewerConfiguration } from '../configuration/configuration';
|
|
import { ViewerConfiguration } from '../configuration/configuration';
|
|
|
|
|
|
export abstract class AbstractViewer {
|
|
export abstract class AbstractViewer {
|
|
@@ -51,6 +51,8 @@ export abstract class AbstractViewer {
|
|
}).then(() => {
|
|
}).then(() => {
|
|
return this.initLights();
|
|
return this.initLights();
|
|
}).then(() => {
|
|
}).then(() => {
|
|
|
|
+ return this.initEnvironment();
|
|
|
|
+ }).then(() => {
|
|
return this.loadModel();
|
|
return this.loadModel();
|
|
}).then(() => {
|
|
}).then(() => {
|
|
return this;
|
|
return this;
|
|
@@ -75,11 +77,17 @@ export abstract class AbstractViewer {
|
|
this.engine.resize();
|
|
this.engine.resize();
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ var scale = Math.max(0.5, 1 / (window.devicePixelRatio || 2));
|
|
|
|
+ this.engine.setHardwareScalingLevel(scale);
|
|
|
|
+
|
|
return Promise.resolve(this.engine);
|
|
return Promise.resolve(this.engine);
|
|
}
|
|
}
|
|
|
|
|
|
protected initScene(): Promise<Scene> {
|
|
protected initScene(): Promise<Scene> {
|
|
this.scene = new Scene(this.engine);
|
|
this.scene = new Scene(this.engine);
|
|
|
|
+ this.engine.runRenderLoop(() => {
|
|
|
|
+ this.scene.render();
|
|
|
|
+ });
|
|
return Promise.resolve(this.scene);
|
|
return Promise.resolve(this.scene);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -89,4 +97,11 @@ export abstract class AbstractViewer {
|
|
|
|
|
|
public abstract loadModel(model?: string): Promise<Scene>;
|
|
public abstract loadModel(model?: string): Promise<Scene>;
|
|
|
|
|
|
|
|
+ protected onModelLoaded(meshes: Array<AbstractMesh>): Promise<Scene> {
|
|
|
|
+ console.log("model loaded");
|
|
|
|
+ return Promise.resolve(this.scene);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public abstract initEnvironment(): Promise<Scene>;
|
|
|
|
+
|
|
}
|
|
}
|