|
@@ -121,9 +121,15 @@ export abstract class AbstractViewer {
|
|
return this.observablesManager.onFrameRenderedObservable;
|
|
return this.observablesManager.onFrameRenderedObservable;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Observers registered here will be executed when VR more is entered.
|
|
|
|
+ */
|
|
public get onEnteringVRObservable(): Observable<AbstractViewer> {
|
|
public get onEnteringVRObservable(): Observable<AbstractViewer> {
|
|
return this.observablesManager.onEnteringVRObservable;
|
|
return this.observablesManager.onEnteringVRObservable;
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * Observers registered here will be executed when VR mode is exited.
|
|
|
|
+ */
|
|
public get onExitingVRObservable(): Observable<AbstractViewer> {
|
|
public get onExitingVRObservable(): Observable<AbstractViewer> {
|
|
return this.observablesManager.onExitingVRObservable;
|
|
return this.observablesManager.onExitingVRObservable;
|
|
}
|
|
}
|
|
@@ -153,7 +159,6 @@ export abstract class AbstractViewer {
|
|
* This functions are also registered at the native scene. The reference can be used to unregister them.
|
|
* This functions are also registered at the native scene. The reference can be used to unregister them.
|
|
*/
|
|
*/
|
|
protected _registeredOnBeforeRenderFunctions: Array<() => void>;
|
|
protected _registeredOnBeforeRenderFunctions: Array<() => void>;
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* The configuration loader of this viewer
|
|
* The configuration loader of this viewer
|
|
*/
|
|
*/
|
|
@@ -272,45 +277,6 @@ export abstract class AbstractViewer {
|
|
|
|
|
|
protected _vrInit: boolean = false;
|
|
protected _vrInit: boolean = false;
|
|
|
|
|
|
- // private upscaleModelAndEnvironment() {
|
|
|
|
- // // scale the model
|
|
|
|
- // if (this.sceneManager.models.length) {
|
|
|
|
- // let boundingVectors = this.sceneManager.models[0].rootMesh.getHierarchyBoundingVectors();
|
|
|
|
- // let sizeVec = boundingVectors.max.subtract(boundingVectors.min);
|
|
|
|
- // let maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
|
|
|
|
- // this._vrScale = (1 / maxDimension);
|
|
|
|
- // if (this.configuration.vr && this.configuration.vr.objectScaleFactor) {
|
|
|
|
- // this._vrScale *= this.configuration.vr.objectScaleFactor;
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // this.sceneManager.models[0].rootMesh.scaling.scaleInPlace(this._vrScale);
|
|
|
|
-
|
|
|
|
- // // reposition the object to "float" in front of the user
|
|
|
|
- // this.sceneManager.models[0].rootMesh.position.y += this._vrModelRepositioning;
|
|
|
|
- // this.sceneManager.models[0].rootMesh.rotationQuaternion = null;
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // // scale the environment to match the model
|
|
|
|
- // if (this.sceneManager.environmentHelper) {
|
|
|
|
- // this.sceneManager.environmentHelper.ground && this.sceneManager.environmentHelper.ground.scaling.scaleInPlace(this._vrScale);
|
|
|
|
- // this.sceneManager.environmentHelper.skybox && this.sceneManager.environmentHelper.skybox.scaling.scaleInPlace(this._vrScale);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // private downscaleModelAndEnvironment() {
|
|
|
|
- // // undo the scaling of the model
|
|
|
|
- // if (this.sceneManager.models.length) {
|
|
|
|
- // this.sceneManager.models[0].rootMesh.scaling.scaleInPlace(1 / this._vrScale);
|
|
|
|
- // this.sceneManager.models[0].rootMesh.position.y -= this._vrModelRepositioning;
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // // undo the scaling of the environment
|
|
|
|
- // if (this.sceneManager.environmentHelper) {
|
|
|
|
- // this.sceneManager.environmentHelper.ground && this.sceneManager.environmentHelper.ground.scaling.scaleInPlace(1 / this._vrScale);
|
|
|
|
- // this.sceneManager.environmentHelper.skybox && this.sceneManager.environmentHelper.skybox.scaling.scaleInPlace(1 / this._vrScale);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
public toggleVR() {
|
|
public toggleVR() {
|
|
if (!this._vrInit) {
|
|
if (!this._vrInit) {
|
|
this._initVR();
|
|
this._initVR();
|
|
@@ -318,11 +284,6 @@ export abstract class AbstractViewer {
|
|
|
|
|
|
if (this.sceneManager.vrHelper && !this.sceneManager.vrHelper.isInVRMode) {
|
|
if (this.sceneManager.vrHelper && !this.sceneManager.vrHelper.isInVRMode) {
|
|
|
|
|
|
- //this.sceneManager.onEnteringVRObservable.remove(o)
|
|
|
|
- // this.sceneManager.onEnteringVRObservable.add(() => {
|
|
|
|
- // this.onEnteringVRObservable.notifyObservers(this);
|
|
|
|
- // });
|
|
|
|
-
|
|
|
|
// make sure the floor is set
|
|
// make sure the floor is set
|
|
if (this.sceneManager.environmentHelper && this.sceneManager.environmentHelper.ground) {
|
|
if (this.sceneManager.environmentHelper && this.sceneManager.environmentHelper.ground) {
|
|
this.sceneManager.vrHelper.addFloorMesh(this.sceneManager.environmentHelper.ground);
|
|
this.sceneManager.vrHelper.addFloorMesh(this.sceneManager.environmentHelper.ground);
|
|
@@ -350,8 +311,6 @@ export abstract class AbstractViewer {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- console.log("upscaling");
|
|
|
|
-
|
|
|
|
// scale the model
|
|
// scale the model
|
|
if (this.sceneManager.models.length) {
|
|
if (this.sceneManager.models.length) {
|
|
let boundingVectors = this.sceneManager.models[0].rootMesh.getHierarchyBoundingVectors();
|
|
let boundingVectors = this.sceneManager.models[0].rootMesh.getHierarchyBoundingVectors();
|
|
@@ -395,14 +354,6 @@ export abstract class AbstractViewer {
|
|
if (this.sceneManager.vrHelper) {
|
|
if (this.sceneManager.vrHelper) {
|
|
this.sceneManager.onExitingVRObservable.add(() => {
|
|
this.sceneManager.onExitingVRObservable.add(() => {
|
|
if (this._vrToggled) {
|
|
if (this._vrToggled) {
|
|
-
|
|
|
|
- //this.sceneManager.onExitingVRObservable.remove(o)
|
|
|
|
- // var o = this.sceneManager.onExitingVRObservable.add(() => {
|
|
|
|
- // this.onExitingVRObservable.notifyObservers(this);
|
|
|
|
- // });
|
|
|
|
-
|
|
|
|
- console.log("downscaling");
|
|
|
|
-
|
|
|
|
this._vrToggled = false;
|
|
this._vrToggled = false;
|
|
|
|
|
|
// undo the scaling of the model
|
|
// undo the scaling of the model
|
|
@@ -722,8 +673,7 @@ export abstract class AbstractViewer {
|
|
// create a new template manager for this viewer
|
|
// create a new template manager for this viewer
|
|
this.sceneManager = new SceneManager(this.engine, this._configurationContainer, this.observablesManager);
|
|
this.sceneManager = new SceneManager(this.engine, this._configurationContainer, this.observablesManager);
|
|
|
|
|
|
- // //this.sceneManager.onEnteringVRObservable.remove(o)
|
|
|
|
- var o = this.sceneManager.onEnteringVRObservable.add(() => {
|
|
|
|
|
|
+ this.sceneManager.onEnteringVRObservable.add(() => {
|
|
this.onEnteringVRObservable.notifyObservers(this);
|
|
this.onEnteringVRObservable.notifyObservers(this);
|
|
});
|
|
});
|
|
|
|
|