|
@@ -11556,6 +11556,7 @@ var BABYLON;
|
|
|
this.name = name;
|
|
|
this.id = name;
|
|
|
this._scene = scene || BABYLON.Engine.LastCreatedScene;
|
|
|
+ this.uniqueId = this._scene.getUniqueId();
|
|
|
this._initCache();
|
|
|
}
|
|
|
Object.defineProperty(Node.prototype, "parent", {
|
|
@@ -16869,7 +16870,6 @@ var BABYLON;
|
|
|
this._useAlternateCameraConfiguration = false;
|
|
|
this._alternateRendering = false;
|
|
|
this.requireLightSorting = false;
|
|
|
- this._uniqueIdCounter = 0;
|
|
|
this._activeMeshesFrozen = false;
|
|
|
this._engine = engine || BABYLON.Engine.LastCreatedEngine;
|
|
|
this._engine.scenes.push(this);
|
|
@@ -18212,12 +18212,11 @@ var BABYLON;
|
|
|
};
|
|
|
// Methods
|
|
|
Scene.prototype.getUniqueId = function () {
|
|
|
- var result = this._uniqueIdCounter;
|
|
|
- this._uniqueIdCounter++;
|
|
|
+ var result = Scene._uniqueIdCounter;
|
|
|
+ Scene._uniqueIdCounter++;
|
|
|
return result;
|
|
|
};
|
|
|
Scene.prototype.addMesh = function (newMesh) {
|
|
|
- newMesh.uniqueId = this.getUniqueId();
|
|
|
var position = this.meshes.push(newMesh);
|
|
|
//notify the collision coordinator
|
|
|
if (this.collisionCoordinator) {
|
|
@@ -18289,7 +18288,6 @@ var BABYLON;
|
|
|
return index;
|
|
|
};
|
|
|
Scene.prototype.addLight = function (newLight) {
|
|
|
- newLight.uniqueId = this.getUniqueId();
|
|
|
this.lights.push(newLight);
|
|
|
this.sortLightsByPriority();
|
|
|
this.onNewLightAddedObservable.notifyObservers(newLight);
|
|
@@ -18300,7 +18298,6 @@ var BABYLON;
|
|
|
}
|
|
|
};
|
|
|
Scene.prototype.addCamera = function (newCamera) {
|
|
|
- newCamera.uniqueId = this.getUniqueId();
|
|
|
var position = this.cameras.push(newCamera);
|
|
|
this.onNewCameraAddedObservable.notifyObservers(newCamera);
|
|
|
};
|
|
@@ -20026,8 +20023,9 @@ var BABYLON;
|
|
|
}
|
|
|
return hdrSkybox;
|
|
|
};
|
|
|
- Scene.prototype.createDefaultVRExperience = function () {
|
|
|
- this.VRHelper = new BABYLON.VRExperienceHelper(this, null);
|
|
|
+ Scene.prototype.createDefaultVRExperience = function (webVROptions) {
|
|
|
+ if (webVROptions === void 0) { webVROptions = {}; }
|
|
|
+ this.VRHelper = new BABYLON.VRExperienceHelper(this, webVROptions);
|
|
|
};
|
|
|
// Tags
|
|
|
Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
|
|
@@ -20104,6 +20102,7 @@ var BABYLON;
|
|
|
Scene._FOGMODE_EXP = 1;
|
|
|
Scene._FOGMODE_EXP2 = 2;
|
|
|
Scene._FOGMODE_LINEAR = 3;
|
|
|
+ Scene._uniqueIdCounter = 0;
|
|
|
Scene.MinDeltaTime = 1.0;
|
|
|
Scene.MaxDeltaTime = 1000.0;
|
|
|
/** The distance in pixel that you have to move to prevent some events */
|
|
@@ -67310,6 +67309,7 @@ var BABYLON;
|
|
|
_this.deviceScaleFactor = 1;
|
|
|
_this.controllers = [];
|
|
|
_this.onControllersAttachedObservable = new BABYLON.Observable();
|
|
|
+ _this.onControllerMeshLoadedObservable = new BABYLON.Observable();
|
|
|
_this.rigParenting = true; // should the rig cameras be used as parent instead of this camera.
|
|
|
_this.minZ = 0.1;
|
|
|
//legacy support - the compensation boolean was removed.
|
|
@@ -67554,14 +67554,15 @@ var BABYLON;
|
|
|
});
|
|
|
this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
|
|
|
if (gamepad.type === BABYLON.Gamepad.POSE_ENABLED) {
|
|
|
- var webVrController = gamepad;
|
|
|
+ var webVrController_1 = gamepad;
|
|
|
if (_this.webVROptions.controllerMeshes) {
|
|
|
- if (webVrController.defaultModel) {
|
|
|
- webVrController.defaultModel.setEnabled(true);
|
|
|
+ if (webVrController_1.defaultModel) {
|
|
|
+ webVrController_1.defaultModel.setEnabled(true);
|
|
|
}
|
|
|
else {
|
|
|
// Load the meshes
|
|
|
- webVrController.initControllerMesh(_this.getScene(), function (loadedMesh) {
|
|
|
+ webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
|
|
|
+ _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
|
|
|
if (_this.webVROptions.defaultLightingOnControllers) {
|
|
|
if (!_this._lightOnControllers) {
|
|
|
_this._lightOnControllers = new BABYLON.HemisphericLight("vrControllersLight", new BABYLON.Vector3(0, 1, 0), _this.getScene());
|
|
@@ -67581,11 +67582,11 @@ var BABYLON;
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- webVrController.attachToPoseControlledCamera(_this);
|
|
|
+ webVrController_1.attachToPoseControlledCamera(_this);
|
|
|
// since this is async - sanity check. Is the controller already stored?
|
|
|
- if (_this.controllers.indexOf(webVrController) === -1) {
|
|
|
+ if (_this.controllers.indexOf(webVrController_1) === -1) {
|
|
|
//add to the controllers array
|
|
|
- _this.controllers.push(webVrController);
|
|
|
+ _this.controllers.push(webVrController_1);
|
|
|
//did we find enough controllers? Great! let the developer know.
|
|
|
if (_this.controllers.length >= 2) {
|
|
|
// Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
|
|
@@ -67904,10 +67905,14 @@ var BABYLON;
|
|
|
window.addEventListener("resize", function () {
|
|
|
_this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
|
|
|
_this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
|
|
|
- if (_this._fullscreenVRpresenting) {
|
|
|
+ if (_this._fullscreenVRpresenting && _this._webVRready) {
|
|
|
_this.exitVR();
|
|
|
}
|
|
|
});
|
|
|
+ document.addEventListener("fullscreenchange", function () { _this._onFullscreenChange(); }, false);
|
|
|
+ document.addEventListener("mozfullscreenchange", function () { _this._onFullscreenChange(); }, false);
|
|
|
+ document.addEventListener("webkitfullscreenchange", function () { _this._onFullscreenChange(); }, false);
|
|
|
+ document.addEventListener("msfullscreenchange", function () { _this._onFullscreenChange(); }, false);
|
|
|
document.body.appendChild(this._btnVR);
|
|
|
// Exiting VR mode using 'ESC' key on desktop
|
|
|
this._onKeyDown = function (event) {
|
|
@@ -67920,6 +67925,9 @@ var BABYLON;
|
|
|
this._scene.onPrePointerObservable.add(function (pointerInfo, eventState) {
|
|
|
if (_this.isInVRMode()) {
|
|
|
_this.exitVR();
|
|
|
+ if (_this._fullscreenVRpresenting) {
|
|
|
+ _this._scene.getEngine().switchFullscreen(true);
|
|
|
+ }
|
|
|
}
|
|
|
}, BABYLON.PointerEventTypes.POINTERDOUBLETAP, false);
|
|
|
// Listen for WebVR display changes
|
|
@@ -67939,9 +67947,34 @@ var BABYLON;
|
|
|
window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
|
|
|
// Create the cameras
|
|
|
this._vrDeviceOrientationCamera = new BABYLON.VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper", this._position, this._scene);
|
|
|
- this._webVRCamera = new BABYLON.WebVRFreeCamera("WebVRHelper", this._position, this._scene);
|
|
|
+ this._webVRCamera = new BABYLON.WebVRFreeCamera("WebVRHelper", this._position, this._scene, webVROptions);
|
|
|
+ this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
|
|
|
this.updateButtonVisibility();
|
|
|
}
|
|
|
+ VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
|
|
|
+ if (this.onControllerMeshLoaded) {
|
|
|
+ this.onControllerMeshLoaded(webVRController);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ VRExperienceHelper.prototype._onFullscreenChange = function () {
|
|
|
+ if (document.fullscreen !== undefined) {
|
|
|
+ this._fullscreenVRpresenting = document.fullscreen;
|
|
|
+ }
|
|
|
+ else if (document.mozFullScreen !== undefined) {
|
|
|
+ this._fullscreenVRpresenting = document.mozFullScreen;
|
|
|
+ }
|
|
|
+ else if (document.webkitIsFullScreen !== undefined) {
|
|
|
+ this._fullscreenVRpresenting = document.webkitIsFullScreen;
|
|
|
+ }
|
|
|
+ else if (document.msIsFullScreen !== undefined) {
|
|
|
+ this._fullscreenVRpresenting = document.msIsFullScreen;
|
|
|
+ }
|
|
|
+ if (!this._fullscreenVRpresenting) {
|
|
|
+ this.exitVR();
|
|
|
+ this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
|
|
|
+ this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
|
|
|
+ }
|
|
|
+ };
|
|
|
VRExperienceHelper.prototype.isInVRMode = function () {
|
|
|
return this._webVRpresenting || this._fullscreenVRpresenting;
|
|
|
};
|
|
@@ -67987,6 +68020,9 @@ var BABYLON;
|
|
|
* Otherwise, will use the fullscreen API.
|
|
|
*/
|
|
|
VRExperienceHelper.prototype.enterVR = function () {
|
|
|
+ if (this.onEnteringVR) {
|
|
|
+ this.onEnteringVR();
|
|
|
+ }
|
|
|
if (this._webVRrequesting)
|
|
|
return;
|
|
|
// If WebVR is supported and a headset is connected
|
|
@@ -68000,7 +68036,6 @@ var BABYLON;
|
|
|
this._vrDeviceOrientationCamera.position = this._position;
|
|
|
this._scene.activeCamera = this._vrDeviceOrientationCamera;
|
|
|
this._scene.getEngine().switchFullscreen(true);
|
|
|
- this._fullscreenVRpresenting = true;
|
|
|
this.updateButtonVisibility();
|
|
|
}
|
|
|
this._scene.activeCamera.attachControl(this._canvas);
|
|
@@ -68009,6 +68044,9 @@ var BABYLON;
|
|
|
* Attempt to exit VR, or fullscreen.
|
|
|
*/
|
|
|
VRExperienceHelper.prototype.exitVR = function () {
|
|
|
+ if (this.onExitingVR) {
|
|
|
+ this.onExitingVR();
|
|
|
+ }
|
|
|
if (this._webVRpresenting) {
|
|
|
this._scene.getEngine().disableVR();
|
|
|
}
|
|
@@ -68018,7 +68056,6 @@ var BABYLON;
|
|
|
this._deviceOrientationCamera.position = this._position;
|
|
|
this._scene.activeCamera = this._deviceOrientationCamera;
|
|
|
this._scene.activeCamera.attachControl(this._canvas);
|
|
|
- this._fullscreenVRpresenting = false;
|
|
|
this.updateButtonVisibility();
|
|
|
};
|
|
|
Object.defineProperty(VRExperienceHelper.prototype, "position", {
|