|
@@ -64734,6 +64734,11 @@ var BABYLON;
|
|
|
_this._stillImageCaptured = false;
|
|
|
_this._createInternalTexture = function () {
|
|
|
if (_this._texture != null) {
|
|
|
+ if (!_this.isReady) {
|
|
|
+ _this._texture.isReady = true;
|
|
|
+ _this._updateInternalTexture();
|
|
|
+ _this._createInternalTexture();
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
if (!_this._engine.needPOTTextures ||
|
|
@@ -64747,8 +64752,11 @@ var BABYLON;
|
|
|
_this._generateMipMaps = false;
|
|
|
}
|
|
|
_this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this._samplingMode);
|
|
|
- _this._texture.isReady = true;
|
|
|
- _this._updateInternalTexture();
|
|
|
+ if (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA) {
|
|
|
+ _this._texture.isReady = true;
|
|
|
+ _this._updateInternalTexture();
|
|
|
+ _this._createInternalTexture();
|
|
|
+ }
|
|
|
if (_this._onLoadObservable && _this._onLoadObservable.hasObservers()) {
|
|
|
_this.onLoadObservable.notifyObservers(_this);
|
|
|
}
|
|
@@ -64781,6 +64789,7 @@ var BABYLON;
|
|
|
if (settings.loop !== undefined) {
|
|
|
_this.video.loop = settings.loop;
|
|
|
}
|
|
|
+ _this.video.addEventListener("canplay", _this._createInternalTexture);
|
|
|
_this.video.addEventListener("canplaythrough", _this._createInternalTexture);
|
|
|
_this.video.addEventListener("paused", _this._updateInternalTexture);
|
|
|
_this.video.addEventListener("seeked", _this._updateInternalTexture);
|
|
@@ -64860,6 +64869,7 @@ var BABYLON;
|
|
|
};
|
|
|
VideoTexture.prototype.dispose = function () {
|
|
|
_super.prototype.dispose.call(this);
|
|
|
+ this.video.removeEventListener("canplay", this._createInternalTexture);
|
|
|
this.video.removeEventListener("canplaythrough", this._createInternalTexture);
|
|
|
this.video.removeEventListener("paused", this._updateInternalTexture);
|
|
|
this.video.removeEventListener("seeked", this._updateInternalTexture);
|
|
@@ -89140,14 +89150,14 @@ var BABYLON;
|
|
|
});
|
|
|
this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
|
|
|
};
|
|
|
- VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer) {
|
|
|
+ VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
|
|
|
if (hit.pickedPoint) {
|
|
|
if (gazer._teleportationRequestInitiated) {
|
|
|
this._displayTeleportationTarget();
|
|
|
this._haloCenter.copyFrom(hit.pickedPoint);
|
|
|
this._teleportationTarget.position.copyFrom(hit.pickedPoint);
|
|
|
}
|
|
|
- var pickNormal = hit.getNormal(true, false);
|
|
|
+ var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
|
|
|
if (pickNormal) {
|
|
|
var axis1 = BABYLON.Vector3.Cross(BABYLON.Axis.Y, pickNormal);
|
|
|
var axis2 = BABYLON.Vector3.Cross(pickNormal, axis1);
|
|
@@ -89238,11 +89248,21 @@ var BABYLON;
|
|
|
});
|
|
|
this._hideTeleportationTarget();
|
|
|
};
|
|
|
+ VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
|
|
|
+ if (normal) {
|
|
|
+ var angle = Math.acos(BABYLON.Vector3.Dot(normal, ray.direction));
|
|
|
+ if (angle < Math.PI / 2) {
|
|
|
+ normal.scaleInPlace(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return normal;
|
|
|
+ };
|
|
|
VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
|
|
|
if (!(this.currentVRCamera instanceof BABYLON.FreeCamera)) {
|
|
|
return;
|
|
|
}
|
|
|
- var hit = this._scene.pickWithRay(gazer._getForwardRay(this._rayLength), this._raySelectionPredicate);
|
|
|
+ var ray = gazer._getForwardRay(this._rayLength);
|
|
|
+ var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
|
|
|
// Moving the gazeTracker on the mesh face targetted
|
|
|
if (hit && hit.pickedPoint) {
|
|
|
if (this._displayGaze) {
|
|
@@ -89254,7 +89274,7 @@ var BABYLON;
|
|
|
gazer._gazeTracker.scaling.x = hit.distance * multiplier;
|
|
|
gazer._gazeTracker.scaling.y = hit.distance * multiplier;
|
|
|
gazer._gazeTracker.scaling.z = hit.distance * multiplier;
|
|
|
- var pickNormal = hit.getNormal();
|
|
|
+ var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
|
|
|
// To avoid z-fighting
|
|
|
var deltaFighting = 0.002;
|
|
|
if (pickNormal) {
|
|
@@ -89302,7 +89322,7 @@ var BABYLON;
|
|
|
}
|
|
|
gazer._currentMeshSelected = null;
|
|
|
if (gazer._teleportationRequestInitiated) {
|
|
|
- this._moveTeleportationSelectorTo(hit, gazer);
|
|
|
+ this._moveTeleportationSelectorTo(hit, gazer, ray);
|
|
|
}
|
|
|
return;
|
|
|
}
|