|
@@ -11649,7 +11649,21 @@ var BABYLON;
|
|
Engine.prototype.getVRDevice = function () {
|
|
Engine.prototype.getVRDevice = function () {
|
|
return this._vrDisplay;
|
|
return this._vrDisplay;
|
|
};
|
|
};
|
|
|
|
+ /**
|
|
|
|
+ * Initializes a webVR display and starts listening to display change events.
|
|
|
|
+ * The onVRDisplayChangedObservable will be notified upon these changes.
|
|
|
|
+ * @returns The onVRDisplayChangedObservable.
|
|
|
|
+ */
|
|
Engine.prototype.initWebVR = function () {
|
|
Engine.prototype.initWebVR = function () {
|
|
|
|
+ this.initWebVRAsync();
|
|
|
|
+ return this.onVRDisplayChangedObservable;
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Initializes a webVR display and starts listening to display change events.
|
|
|
|
+ * The onVRDisplayChangedObservable will be notified upon these changes.
|
|
|
|
+ * @returns A promise containing a VRDisplay and if vr is supported.
|
|
|
|
+ */
|
|
|
|
+ Engine.prototype.initWebVRAsync = function () {
|
|
var _this = this;
|
|
var _this = this;
|
|
var notifyObservers = function () {
|
|
var notifyObservers = function () {
|
|
var eventArgs = {
|
|
var eventArgs = {
|
|
@@ -11657,6 +11671,7 @@ var BABYLON;
|
|
vrSupported: _this._vrSupported
|
|
vrSupported: _this._vrSupported
|
|
};
|
|
};
|
|
_this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
|
|
_this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
|
|
|
|
+ _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
|
|
};
|
|
};
|
|
if (!this._onVrDisplayConnect) {
|
|
if (!this._onVrDisplayConnect) {
|
|
this._onVrDisplayConnect = function (event) {
|
|
this._onVrDisplayConnect = function (event) {
|
|
@@ -11676,8 +11691,9 @@ var BABYLON;
|
|
window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
|
|
window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
|
|
window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
|
|
window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
|
|
}
|
|
}
|
|
- this._getVRDisplays(notifyObservers);
|
|
|
|
- return this.onVRDisplayChangedObservable;
|
|
|
|
|
|
+ this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
|
|
|
|
+ this._webVRInitPromise.then(notifyObservers);
|
|
|
|
+ return this._webVRInitPromise;
|
|
};
|
|
};
|
|
Engine.prototype.enableVR = function () {
|
|
Engine.prototype.enableVR = function () {
|
|
var _this = this;
|
|
var _this = this;
|
|
@@ -11698,27 +11714,30 @@ var BABYLON;
|
|
this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
|
|
this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
- Engine.prototype._getVRDisplays = function (callback) {
|
|
|
|
|
|
+ Engine.prototype._getVRDisplaysAsync = function () {
|
|
var _this = this;
|
|
var _this = this;
|
|
- var getWebVRDevices = function (devices) {
|
|
|
|
- _this._vrSupported = true;
|
|
|
|
- // note that devices may actually be an empty array. This is fine;
|
|
|
|
- // we expect this._vrDisplay to be undefined in this case.
|
|
|
|
- return _this._vrDisplay = devices[0];
|
|
|
|
- };
|
|
|
|
- if (navigator.getVRDisplays) {
|
|
|
|
- navigator.getVRDisplays().then(getWebVRDevices).then(callback).catch(function (error) {
|
|
|
|
- // TODO: System CANNOT support WebVR, despite API presence.
|
|
|
|
|
|
+ return new Promise(function (res, rej) {
|
|
|
|
+ if (navigator.getVRDisplays) {
|
|
|
|
+ navigator.getVRDisplays().then(function (devices) {
|
|
|
|
+ _this._vrSupported = true;
|
|
|
|
+ // note that devices may actually be an empty array. This is fine;
|
|
|
|
+ // we expect this._vrDisplay to be undefined in this case.
|
|
|
|
+ _this._vrDisplay = devices[0];
|
|
|
|
+ res({
|
|
|
|
+ vrDisplay: _this._vrDisplay,
|
|
|
|
+ vrSupported: _this._vrSupported
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ _this._vrDisplay = undefined;
|
|
_this._vrSupported = false;
|
|
_this._vrSupported = false;
|
|
- callback();
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- // TODO: Browser does not support WebVR
|
|
|
|
- this._vrDisplay = undefined;
|
|
|
|
- this._vrSupported = false;
|
|
|
|
- callback();
|
|
|
|
- }
|
|
|
|
|
|
+ res({
|
|
|
|
+ vrDisplay: _this._vrDisplay,
|
|
|
|
+ vrSupported: _this._vrSupported
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
};
|
|
};
|
|
Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
|
|
Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
|
|
if (this._currentRenderTarget) {
|
|
if (this._currentRenderTarget) {
|
|
@@ -51612,7 +51631,7 @@ var BABYLON;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-//# sourceMappingURL=babylon.iParticleEmitterType.js.map
|
|
|
|
|
|
+//# sourceMappingURL=babylon.IParticleEmitterType.js.map
|
|
|
|
|
|
var BABYLON;
|
|
var BABYLON;
|
|
(function (BABYLON) {
|
|
(function (BABYLON) {
|
|
@@ -79160,11 +79179,11 @@ var BABYLON;
|
|
return _this;
|
|
return _this;
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
- * Gets the device distance from the ground.
|
|
|
|
- * @returns the distance from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
|
|
|
|
|
|
+ * Gets the device distance from the ground in meters.
|
|
|
|
+ * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
|
|
*/
|
|
*/
|
|
WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
|
|
WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
|
|
- if (this._standingMatrix && this._defaultHeight === undefined) {
|
|
|
|
|
|
+ if (this._standingMatrix) {
|
|
// Add standing matrix offset to get real offset from ground in room
|
|
// Add standing matrix offset to get real offset from ground in room
|
|
this._standingMatrix.getTranslationToRef(this._workingVector);
|
|
this._standingMatrix.getTranslationToRef(this._workingVector);
|
|
return this._deviceRoomPosition.y + this._workingVector.y;
|
|
return this._deviceRoomPosition.y + this._workingVector.y;
|
|
@@ -79180,28 +79199,35 @@ var BABYLON;
|
|
var _this = this;
|
|
var _this = this;
|
|
if (callback === void 0) { callback = function (bool) { }; }
|
|
if (callback === void 0) { callback = function (bool) { }; }
|
|
// Use standing matrix if available
|
|
// Use standing matrix if available
|
|
- if (!navigator || !navigator.getVRDisplays) {
|
|
|
|
- callback(false);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- navigator.getVRDisplays().then(function (displays) {
|
|
|
|
- if (!displays || !displays[0] || !displays[0].stageParameters || !displays[0].stageParameters.sittingToStandingTransform) {
|
|
|
|
- callback(false);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- _this._standingMatrix = new BABYLON.Matrix();
|
|
|
|
- BABYLON.Matrix.FromFloat32ArrayToRefScaled(displays[0].stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
|
|
|
|
- if (!_this.getScene().useRightHandedSystem) {
|
|
|
|
- [2, 6, 8, 9, 14].forEach(function (num) {
|
|
|
|
- if (_this._standingMatrix) {
|
|
|
|
- _this._standingMatrix.m[num] *= -1;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- callback(true);
|
|
|
|
|
|
+ this.getEngine().initWebVRAsync().then(function (result) {
|
|
|
|
+ if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform) {
|
|
|
|
+ callback(false);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ _this._standingMatrix = new BABYLON.Matrix();
|
|
|
|
+ BABYLON.Matrix.FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
|
|
|
|
+ if (!_this.getScene().useRightHandedSystem) {
|
|
|
|
+ [2, 6, 8, 9, 14].forEach(function (num) {
|
|
|
|
+ if (_this._standingMatrix) {
|
|
|
|
+ _this._standingMatrix.m[num] *= -1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
+ callback(true);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
|
|
|
|
+ * @returns A promise with a boolean set to if the standing matrix is supported.
|
|
|
|
+ */
|
|
|
|
+ WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
|
|
|
|
+ var _this = this;
|
|
|
|
+ return new Promise(function (res, rej) {
|
|
|
|
+ _this.useStandingMatrix(function (supported) {
|
|
|
|
+ res(supported);
|
|
});
|
|
});
|
|
- }
|
|
|
|
|
|
+ });
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Disposes the camera
|
|
* Disposes the camera
|
|
@@ -80209,14 +80235,13 @@ var BABYLON;
|
|
});
|
|
});
|
|
Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
|
|
Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
|
|
/**
|
|
/**
|
|
- * The mesh used to display where the user is selecting.
|
|
|
|
|
|
+ * The mesh used to display where the user is selecting,
|
|
|
|
+ * when set bakeCurrentTransformIntoVertices will be called on the mesh.
|
|
|
|
+ * See http://doc.babylonjs.com/resources/baking_transformations
|
|
*/
|
|
*/
|
|
get: function () {
|
|
get: function () {
|
|
return this._gazeTracker;
|
|
return this._gazeTracker;
|
|
},
|
|
},
|
|
- /**
|
|
|
|
- * Sets the mesh to be used to display where the user is selecting.
|
|
|
|
- */
|
|
|
|
set: function (value) {
|
|
set: function (value) {
|
|
if (value) {
|
|
if (value) {
|
|
this._gazeTracker = value;
|
|
this._gazeTracker = value;
|
|
@@ -85557,6 +85582,7 @@ var BABYLON;
|
|
this._waitingTasksCount = this._tasks.length;
|
|
this._waitingTasksCount = this._tasks.length;
|
|
this._totalTasksCount = this._tasks.length;
|
|
this._totalTasksCount = this._tasks.length;
|
|
if (this._waitingTasksCount === 0) {
|
|
if (this._waitingTasksCount === 0) {
|
|
|
|
+ this._isLoading = false;
|
|
if (this.onFinish) {
|
|
if (this.onFinish) {
|
|
this.onFinish(this._tasks);
|
|
this.onFinish(this._tasks);
|
|
}
|
|
}
|