|
@@ -5477,7 +5477,7 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Returns a new Vector3 set from the index "offset" of the given Float32Array
|
|
|
- * This function is deprecated. Use FromArray instead
|
|
|
+ * This function is deprecated. Use FromArray instead
|
|
|
* @param array defines the source array
|
|
|
* @param offset defines the offset in the source array
|
|
|
* @returns the new Vector3
|
|
@@ -5825,6 +5825,15 @@ var BABYLON;
|
|
|
matrix.multiplyToRef(viewportMatrix, matrix);
|
|
|
return Vector3.TransformCoordinates(vector, matrix);
|
|
|
};
|
|
|
+ /** @hidden */
|
|
|
+ Vector3.UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
|
|
|
+ Vector3.TransformCoordinatesToRef(source, matrix, result);
|
|
|
+ var m = matrix.m;
|
|
|
+ var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
|
|
|
+ if (BABYLON.Scalar.WithinEpsilon(num, 1.0)) {
|
|
|
+ result.scaleInPlace(1.0 / num);
|
|
|
+ }
|
|
|
+ };
|
|
|
/**
|
|
|
* Unproject from screen space to object space
|
|
|
* @param source defines the screen space Vector3 to use
|
|
@@ -5840,12 +5849,8 @@ var BABYLON;
|
|
|
matrix.invert();
|
|
|
source.x = source.x / viewportWidth * 2 - 1;
|
|
|
source.y = -(source.y / viewportHeight * 2 - 1);
|
|
|
- var vector = Vector3.TransformCoordinates(source, matrix);
|
|
|
- var m = matrix.m;
|
|
|
- var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
|
|
|
- if (BABYLON.Scalar.WithinEpsilon(num, 1.0)) {
|
|
|
- vector = vector.scale(1.0 / num);
|
|
|
- }
|
|
|
+ var vector = new Vector3();
|
|
|
+ Vector3.UnprojectFromInvertedMatrixToRef(source, matrix, vector);
|
|
|
return vector;
|
|
|
};
|
|
|
/**
|
|
@@ -5897,12 +5902,36 @@ var BABYLON;
|
|
|
screenSource.x = sourceX / viewportWidth * 2 - 1;
|
|
|
screenSource.y = -(sourceY / viewportHeight * 2 - 1);
|
|
|
screenSource.z = 2 * sourceZ - 1.0;
|
|
|
- Vector3.TransformCoordinatesToRef(screenSource, matrix, result);
|
|
|
- var m = matrix.m;
|
|
|
- var num = screenSource.x * m[3] + screenSource.y * m[7] + screenSource.z * m[11] + m[15];
|
|
|
- if (BABYLON.Scalar.WithinEpsilon(num, 1.0)) {
|
|
|
- result.scaleInPlace(1.0 / num);
|
|
|
- }
|
|
|
+ Vector3.UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Unproject a ray from screen space to object space
|
|
|
+ * @param sourceX defines the screen space x coordinate to use
|
|
|
+ * @param sourceY defines the screen space y coordinate to use
|
|
|
+ * @param viewportWidth defines the current width of the viewport
|
|
|
+ * @param viewportHeight defines the current height of the viewport
|
|
|
+ * @param world defines the world matrix to use (can be set to Identity to go to world space)
|
|
|
+ * @param view defines the view matrix to use
|
|
|
+ * @param projection defines the projection matrix to use
|
|
|
+ * @param ray defines the Ray where to store the result
|
|
|
+ */
|
|
|
+ Vector3.UnprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection, ray) {
|
|
|
+ var matrix = MathTmp.Matrix[0];
|
|
|
+ world.multiplyToRef(view, matrix);
|
|
|
+ matrix.multiplyToRef(projection, matrix);
|
|
|
+ matrix.invert();
|
|
|
+ var nearScreenSource = MathTmp.Vector3[0];
|
|
|
+ nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
|
|
|
+ nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
|
|
|
+ nearScreenSource.z = -1.0;
|
|
|
+ var farScreenSource = MathTmp.Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
|
|
|
+ var nearVec3 = MathTmp.Vector3[2];
|
|
|
+ var farVec3 = MathTmp.Vector3[3];
|
|
|
+ Vector3.UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
|
|
|
+ Vector3.UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
|
|
|
+ ray.origin.copyFrom(nearVec3);
|
|
|
+ farVec3.subtractToRef(nearVec3, ray.direction);
|
|
|
+ ray.direction.normalize();
|
|
|
};
|
|
|
/**
|
|
|
* Gets the minimal coordinate values between two Vector3
|
|
@@ -13236,24 +13265,6 @@ var BABYLON;
|
|
|
Engine.prototype.getCaps = function () {
|
|
|
return this._caps;
|
|
|
};
|
|
|
- Object.defineProperty(Engine.prototype, "drawCalls", {
|
|
|
- /** @hidden */
|
|
|
- get: function () {
|
|
|
- BABYLON.Tools.Warn("drawCalls is deprecated. Please use SceneInstrumentation class");
|
|
|
- return 0;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
- Object.defineProperty(Engine.prototype, "drawCallsPerfCounter", {
|
|
|
- /** @hidden */
|
|
|
- get: function () {
|
|
|
- BABYLON.Tools.Warn("drawCallsPerfCounter is deprecated. Please use SceneInstrumentation class");
|
|
|
- return null;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
/**
|
|
|
* Gets the current depth function
|
|
|
* @returns a number defining the depth function
|
|
@@ -25614,6 +25625,10 @@ var BABYLON;
|
|
|
*/
|
|
|
_this.onAfterStepObservable = new BABYLON.Observable();
|
|
|
/**
|
|
|
+ * An event triggered when the activeCamera property is updated
|
|
|
+ */
|
|
|
+ _this.onActiveCameraChanged = new BABYLON.Observable();
|
|
|
+ /**
|
|
|
* This Observable will be triggered before rendering each renderingGroup of each rendered camera.
|
|
|
* The RenderinGroupInfo class contains all the information about the context in which the observable is called
|
|
|
* If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
|
|
@@ -26252,6 +26267,21 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ Object.defineProperty(Scene.prototype, "activeCamera", {
|
|
|
+ /** Gets or sets the current active camera */
|
|
|
+ get: function () {
|
|
|
+ return this._activeCamera;
|
|
|
+ },
|
|
|
+ set: function (value) {
|
|
|
+ if (value === this._activeCamera) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._activeCamera = value;
|
|
|
+ this.onActiveCameraChanged.notifyObservers(this);
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
Object.defineProperty(Scene.prototype, "defaultMaterial", {
|
|
|
/** The default material used on meshes when no material is affected */
|
|
|
get: function () {
|
|
@@ -26553,48 +26583,6 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
- /** @hidden */
|
|
|
- Scene.prototype.getInterFramePerfCounter = function () {
|
|
|
- BABYLON.Tools.Warn("getInterFramePerfCounter is deprecated. Please use SceneInstrumentation class");
|
|
|
- return 0;
|
|
|
- };
|
|
|
- Object.defineProperty(Scene.prototype, "interFramePerfCounter", {
|
|
|
- /** @hidden */
|
|
|
- get: function () {
|
|
|
- BABYLON.Tools.Warn("interFramePerfCounter is deprecated. Please use SceneInstrumentation class");
|
|
|
- return null;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
- /** @hidden */
|
|
|
- Scene.prototype.getLastFrameDuration = function () {
|
|
|
- BABYLON.Tools.Warn("getLastFrameDuration is deprecated. Please use SceneInstrumentation class");
|
|
|
- return 0;
|
|
|
- };
|
|
|
- Object.defineProperty(Scene.prototype, "lastFramePerfCounter", {
|
|
|
- /** @hidden */
|
|
|
- get: function () {
|
|
|
- BABYLON.Tools.Warn("lastFramePerfCounter is deprecated. Please use SceneInstrumentation class");
|
|
|
- return null;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
- /** @hidden */
|
|
|
- Scene.prototype.getEvaluateActiveMeshesDuration = function () {
|
|
|
- BABYLON.Tools.Warn("getEvaluateActiveMeshesDuration is deprecated. Please use SceneInstrumentation class");
|
|
|
- return 0;
|
|
|
- };
|
|
|
- Object.defineProperty(Scene.prototype, "evaluateActiveMeshesDurationPerfCounter", {
|
|
|
- /** @hidden */
|
|
|
- get: function () {
|
|
|
- BABYLON.Tools.Warn("evaluateActiveMeshesDurationPerfCounter is deprecated. Please use SceneInstrumentation class");
|
|
|
- return null;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
/**
|
|
|
* Gets the array of active meshes
|
|
|
* @returns an array of AbstractMesh
|
|
@@ -26602,53 +26590,6 @@ var BABYLON;
|
|
|
Scene.prototype.getActiveMeshes = function () {
|
|
|
return this._activeMeshes;
|
|
|
};
|
|
|
- /** @hidden */
|
|
|
- Scene.prototype.getRenderTargetsDuration = function () {
|
|
|
- BABYLON.Tools.Warn("getRenderTargetsDuration is deprecated. Please use SceneInstrumentation class");
|
|
|
- return 0;
|
|
|
- };
|
|
|
- /** @hidden */
|
|
|
- Scene.prototype.getRenderDuration = function () {
|
|
|
- BABYLON.Tools.Warn("getRenderDuration is deprecated. Please use SceneInstrumentation class");
|
|
|
- return 0;
|
|
|
- };
|
|
|
- Object.defineProperty(Scene.prototype, "renderDurationPerfCounter", {
|
|
|
- /** @hidden */
|
|
|
- get: function () {
|
|
|
- BABYLON.Tools.Warn("renderDurationPerfCounter is deprecated. Please use SceneInstrumentation class");
|
|
|
- return null;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
- /** @hidden */
|
|
|
- Scene.prototype.getParticlesDuration = function () {
|
|
|
- BABYLON.Tools.Warn("getParticlesDuration is deprecated. Please use SceneInstrumentation class");
|
|
|
- return 0;
|
|
|
- };
|
|
|
- Object.defineProperty(Scene.prototype, "particlesDurationPerfCounter", {
|
|
|
- /** @hidden */
|
|
|
- get: function () {
|
|
|
- BABYLON.Tools.Warn("particlesDurationPerfCounter is deprecated. Please use SceneInstrumentation class");
|
|
|
- return null;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
- /** @hidden */
|
|
|
- Scene.prototype.getSpritesDuration = function () {
|
|
|
- BABYLON.Tools.Warn("getSpritesDuration is deprecated. Please use SceneInstrumentation class");
|
|
|
- return 0;
|
|
|
- };
|
|
|
- Object.defineProperty(Scene.prototype, "spriteDuractionPerfCounter", {
|
|
|
- /** @hidden */
|
|
|
- get: function () {
|
|
|
- BABYLON.Tools.Warn("spriteDuractionPerfCounter is deprecated. Please use SceneInstrumentation class");
|
|
|
- return null;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
/**
|
|
|
* Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
|
|
|
* @returns a number
|
|
@@ -27135,6 +27076,7 @@ var BABYLON;
|
|
|
canvas.focus();
|
|
|
}
|
|
|
_this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
|
|
|
+ _this._pointerCaptures[evt.pointerId] = false;
|
|
|
// PreObservable support
|
|
|
if (_this.onPrePointerObservable.hasObservers()) {
|
|
|
if (!clickInfo.ignore) {
|
|
@@ -27158,7 +27100,6 @@ var BABYLON;
|
|
|
if (!_this.cameraToUseForPointers && !_this.activeCamera) {
|
|
|
return;
|
|
|
}
|
|
|
- _this._pointerCaptures[evt.pointerId] = false;
|
|
|
if (!_this.pointerUpPredicate) {
|
|
|
_this.pointerUpPredicate = function (mesh) {
|
|
|
return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
|
|
@@ -29530,6 +29471,7 @@ var BABYLON;
|
|
|
this.onPointerObservable.clear();
|
|
|
this.onPreKeyboardObservable.clear();
|
|
|
this.onKeyboardObservable.clear();
|
|
|
+ this.onActiveCameraChanged.clear();
|
|
|
this.detachControl();
|
|
|
// Detach cameras
|
|
|
var canvas = this._engine.getRenderingCanvas();
|
|
@@ -29703,7 +29645,7 @@ var BABYLON;
|
|
|
// Moving coordinates to local viewport world
|
|
|
x = x / this._engine.getHardwareScalingLevel() - viewport.x;
|
|
|
y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
|
|
|
- result.update(x, y, viewport.width, viewport.height, world ? world : BABYLON.Matrix.Identity(), cameraViewSpace ? BABYLON.Matrix.Identity() : camera.getViewMatrix(), camera.getProjectionMatrix());
|
|
|
+ result.update(x, y, viewport.width, viewport.height, world ? world : BABYLON.Matrix.IdentityReadOnly, cameraViewSpace ? BABYLON.Matrix.IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix());
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
@@ -37295,20 +37237,27 @@ var BABYLON;
|
|
|
* @param flag defines a flag used to determine which parts of the material have to be marked as dirty
|
|
|
*/
|
|
|
Material.prototype.markAsDirty = function (flag) {
|
|
|
+ if (this.getScene().blockMaterialDirtyMechanism) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Material._DirtyCallbackArray.length = 0;
|
|
|
if (flag & Material.TextureDirtyFlag) {
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
+ Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
|
|
|
}
|
|
|
if (flag & Material.LightDirtyFlag) {
|
|
|
- this._markAllSubMeshesAsLightsDirty();
|
|
|
+ Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
|
|
|
}
|
|
|
if (flag & Material.FresnelDirtyFlag) {
|
|
|
- this._markAllSubMeshesAsFresnelDirty();
|
|
|
+ Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
|
|
|
}
|
|
|
if (flag & Material.AttributesDirtyFlag) {
|
|
|
- this._markAllSubMeshesAsAttributesDirty();
|
|
|
+ Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
|
|
|
}
|
|
|
if (flag & Material.MiscDirtyFlag) {
|
|
|
- this._markAllSubMeshesAsMiscDirty();
|
|
|
+ Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
|
|
|
+ }
|
|
|
+ if (Material._DirtyCallbackArray.length) {
|
|
|
+ this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
|
|
|
}
|
|
|
this.getScene().resetCachedMaterial();
|
|
|
};
|
|
@@ -37317,13 +37266,17 @@ var BABYLON;
|
|
|
* @param func defines a function which checks material defines against the submeshes
|
|
|
*/
|
|
|
Material.prototype._markAllSubMeshesAsDirty = function (func) {
|
|
|
- for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
|
|
|
- var mesh = _a[_i];
|
|
|
+ if (this.getScene().blockMaterialDirtyMechanism) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var meshes = this.getScene().meshes;
|
|
|
+ for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
|
|
|
+ var mesh = meshes_1[_i];
|
|
|
if (!mesh.subMeshes) {
|
|
|
continue;
|
|
|
}
|
|
|
- for (var _b = 0, _c = mesh.subMeshes; _b < _c.length; _b++) {
|
|
|
- var subMesh = _c[_b];
|
|
|
+ for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
|
|
|
+ var subMesh = _b[_a];
|
|
|
if (subMesh.getMaterial() !== this) {
|
|
|
continue;
|
|
|
}
|
|
@@ -37338,55 +37291,49 @@ var BABYLON;
|
|
|
* Indicates that image processing needs to be re-calculated for all submeshes
|
|
|
*/
|
|
|
Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
|
|
|
- this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsImageProcessingDirty(); });
|
|
|
+ this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
|
|
|
};
|
|
|
/**
|
|
|
* Indicates that textures need to be re-calculated for all submeshes
|
|
|
*/
|
|
|
Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
|
|
|
- this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsTexturesDirty(); });
|
|
|
+ this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
|
|
|
};
|
|
|
/**
|
|
|
* Indicates that fresnel needs to be re-calculated for all submeshes
|
|
|
*/
|
|
|
Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
|
|
|
- this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsFresnelDirty(); });
|
|
|
+ this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
|
|
|
};
|
|
|
/**
|
|
|
* Indicates that fresnel and misc need to be re-calculated for all submeshes
|
|
|
*/
|
|
|
Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
|
|
|
- this._markAllSubMeshesAsDirty(function (defines) {
|
|
|
- defines.markAsFresnelDirty();
|
|
|
- defines.markAsMiscDirty();
|
|
|
- });
|
|
|
+ this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
|
|
|
};
|
|
|
/**
|
|
|
* Indicates that lights need to be re-calculated for all submeshes
|
|
|
*/
|
|
|
Material.prototype._markAllSubMeshesAsLightsDirty = function () {
|
|
|
- this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
|
|
|
+ this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
|
|
|
};
|
|
|
/**
|
|
|
* Indicates that attributes need to be re-calculated for all submeshes
|
|
|
*/
|
|
|
Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
|
|
|
- this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
|
|
|
+ this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
|
|
|
};
|
|
|
/**
|
|
|
* Indicates that misc needs to be re-calculated for all submeshes
|
|
|
*/
|
|
|
Material.prototype._markAllSubMeshesAsMiscDirty = function () {
|
|
|
- this._markAllSubMeshesAsDirty(function (defines) { return defines.markAsMiscDirty(); });
|
|
|
+ this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
|
|
|
};
|
|
|
/**
|
|
|
* Indicates that textures and misc need to be re-calculated for all submeshes
|
|
|
*/
|
|
|
Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
|
|
|
- this._markAllSubMeshesAsDirty(function (defines) {
|
|
|
- defines.markAsTexturesDirty();
|
|
|
- defines.markAsMiscDirty();
|
|
|
- });
|
|
|
+ this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
|
|
|
};
|
|
|
/**
|
|
|
* Disposes the material
|
|
@@ -37414,8 +37361,8 @@ var BABYLON;
|
|
|
}
|
|
|
else {
|
|
|
var meshes = scene.meshes;
|
|
|
- for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
|
|
|
- var mesh = meshes_1[_i];
|
|
|
+ for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
|
|
|
+ var mesh = meshes_2[_i];
|
|
|
if (mesh.material === this) {
|
|
|
mesh.material = null;
|
|
|
this.releaseVertexArrayObject(mesh, forceDisposeEffect);
|
|
@@ -37554,6 +37501,27 @@ var BABYLON;
|
|
|
* The all dirty flag value
|
|
|
*/
|
|
|
Material.AllDirtyFlag = 31;
|
|
|
+ Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
|
|
|
+ Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
|
|
|
+ Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
|
|
|
+ Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
|
|
|
+ Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
|
|
|
+ Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
|
|
|
+ Material._FresnelAndMiscDirtyCallBack = function (defines) {
|
|
|
+ Material._FresnelDirtyCallBack(defines);
|
|
|
+ Material._MiscDirtyCallBack(defines);
|
|
|
+ };
|
|
|
+ Material._TextureAndMiscDirtyCallBack = function (defines) {
|
|
|
+ Material._TextureDirtyCallBack(defines);
|
|
|
+ Material._MiscDirtyCallBack(defines);
|
|
|
+ };
|
|
|
+ Material._DirtyCallbackArray = [];
|
|
|
+ Material._RunDirtyCallBacks = function (defines) {
|
|
|
+ for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
|
|
|
+ var cb = _a[_i];
|
|
|
+ cb(defines);
|
|
|
+ }
|
|
|
+ };
|
|
|
__decorate([
|
|
|
BABYLON.serialize()
|
|
|
], Material.prototype, "id", void 0);
|
|
@@ -58848,8 +58816,8 @@ var BABYLON;
|
|
|
*/
|
|
|
Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
|
|
|
if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
|
|
|
- var newMinimum = Ray._min.copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
|
|
|
- var newMaximum = Ray._max.copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
|
|
|
+ var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
|
|
|
+ var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
|
|
|
var d = 0.0;
|
|
|
var maxValue = Number.MAX_VALUE;
|
|
|
var inv;
|
|
@@ -58969,26 +58937,31 @@ var BABYLON;
|
|
|
* @returns intersection information if hit
|
|
|
*/
|
|
|
Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
|
|
|
- vertex1.subtractToRef(vertex0, Ray._edge1);
|
|
|
- vertex2.subtractToRef(vertex0, Ray._edge2);
|
|
|
- BABYLON.Vector3.CrossToRef(this.direction, Ray._edge2, Ray._pvec);
|
|
|
- var det = BABYLON.Vector3.Dot(Ray._edge1, Ray._pvec);
|
|
|
+ var edge1 = Ray.TmpVector3[0];
|
|
|
+ var edge2 = Ray.TmpVector3[1];
|
|
|
+ var pvec = Ray.TmpVector3[2];
|
|
|
+ var tvec = Ray.TmpVector3[3];
|
|
|
+ var qvec = Ray.TmpVector3[4];
|
|
|
+ vertex1.subtractToRef(vertex0, edge1);
|
|
|
+ vertex2.subtractToRef(vertex0, edge2);
|
|
|
+ BABYLON.Vector3.CrossToRef(this.direction, edge2, pvec);
|
|
|
+ var det = BABYLON.Vector3.Dot(edge1, pvec);
|
|
|
if (det === 0) {
|
|
|
return null;
|
|
|
}
|
|
|
var invdet = 1 / det;
|
|
|
- this.origin.subtractToRef(vertex0, Ray._tvec);
|
|
|
- var bu = BABYLON.Vector3.Dot(Ray._tvec, Ray._pvec) * invdet;
|
|
|
+ this.origin.subtractToRef(vertex0, tvec);
|
|
|
+ var bu = BABYLON.Vector3.Dot(tvec, pvec) * invdet;
|
|
|
if (bu < 0 || bu > 1.0) {
|
|
|
return null;
|
|
|
}
|
|
|
- BABYLON.Vector3.CrossToRef(Ray._tvec, Ray._edge1, Ray._qvec);
|
|
|
- var bv = BABYLON.Vector3.Dot(this.direction, Ray._qvec) * invdet;
|
|
|
+ BABYLON.Vector3.CrossToRef(tvec, edge1, qvec);
|
|
|
+ var bv = BABYLON.Vector3.Dot(this.direction, qvec) * invdet;
|
|
|
if (bv < 0 || bu + bv > 1.0) {
|
|
|
return null;
|
|
|
}
|
|
|
//check if the distance is longer than the predefined length.
|
|
|
- var distance = BABYLON.Vector3.Dot(Ray._edge2, Ray._qvec) * invdet;
|
|
|
+ var distance = BABYLON.Vector3.Dot(edge2, qvec) * invdet;
|
|
|
if (distance > this.length) {
|
|
|
return null;
|
|
|
}
|
|
@@ -59078,10 +59051,15 @@ var BABYLON;
|
|
|
* @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
|
|
|
*/
|
|
|
Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
|
|
|
- var rsegb = this.origin.add(this.direction.multiplyByFloats(Ray.rayl, Ray.rayl, Ray.rayl));
|
|
|
- var u = segb.subtract(sega);
|
|
|
- var v = rsegb.subtract(this.origin);
|
|
|
- var w = sega.subtract(this.origin);
|
|
|
+ var o = this.origin;
|
|
|
+ var u = BABYLON.Tmp.Vector3[0];
|
|
|
+ var rsegb = BABYLON.Tmp.Vector3[1];
|
|
|
+ var v = BABYLON.Tmp.Vector3[2];
|
|
|
+ var w = BABYLON.Tmp.Vector3[3];
|
|
|
+ segb.subtractToRef(sega, u);
|
|
|
+ this.direction.scaleToRef(Ray.rayl, v);
|
|
|
+ o.addToRef(v, rsegb);
|
|
|
+ sega.subtractToRef(o, w);
|
|
|
var a = BABYLON.Vector3.Dot(u, u); // always >= 0
|
|
|
var b = BABYLON.Vector3.Dot(u, v);
|
|
|
var c = BABYLON.Vector3.Dot(v, v); // always >= 0
|
|
@@ -59143,8 +59121,11 @@ var BABYLON;
|
|
|
sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
|
|
|
tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
|
|
|
// get the difference of the two closest points
|
|
|
- var qtc = v.multiplyByFloats(tc, tc, tc);
|
|
|
- var dP = w.add(u.multiplyByFloats(sc, sc, sc)).subtract(qtc); // = S1(sc) - S2(tc)
|
|
|
+ var qtc = BABYLON.Tmp.Vector3[4];
|
|
|
+ v.scaleToRef(tc, qtc);
|
|
|
+ var dP = BABYLON.Tmp.Vector3[5];
|
|
|
+ u.scaleToRef(sc, dP);
|
|
|
+ dP.addInPlace(w).subtractInPlace(qtc); // = S1(sc) - S2(tc)
|
|
|
var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
|
|
|
if (isIntersected) {
|
|
|
return qtc.length();
|
|
@@ -59163,10 +59144,7 @@ var BABYLON;
|
|
|
* @returns this ray updated
|
|
|
*/
|
|
|
Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
|
|
|
- BABYLON.Vector3.UnprojectFloatsToRef(x, y, 0, viewportWidth, viewportHeight, world, view, projection, this.origin);
|
|
|
- BABYLON.Vector3.UnprojectFloatsToRef(x, y, 1, viewportWidth, viewportHeight, world, view, projection, BABYLON.Tmp.Vector3[0]);
|
|
|
- BABYLON.Tmp.Vector3[0].subtractToRef(this.origin, this.direction);
|
|
|
- this.direction.normalize();
|
|
|
+ BABYLON.Vector3.UnprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection, this);
|
|
|
return this;
|
|
|
};
|
|
|
// Statics
|
|
@@ -59238,13 +59216,7 @@ var BABYLON;
|
|
|
result.length *= len;
|
|
|
}
|
|
|
};
|
|
|
- Ray._edge1 = BABYLON.Vector3.Zero();
|
|
|
- Ray._edge2 = BABYLON.Vector3.Zero();
|
|
|
- Ray._pvec = BABYLON.Vector3.Zero();
|
|
|
- Ray._tvec = BABYLON.Vector3.Zero();
|
|
|
- Ray._qvec = BABYLON.Vector3.Zero();
|
|
|
- Ray._min = BABYLON.Vector3.Zero();
|
|
|
- Ray._max = BABYLON.Vector3.Zero();
|
|
|
+ Ray.TmpVector3 = BABYLON.Tools.BuildArray(6, BABYLON.Vector3.Zero);
|
|
|
Ray.smallnum = 0.00000001;
|
|
|
Ray.rayl = 10e8;
|
|
|
return Ray;
|
|
@@ -66902,7 +66874,6 @@ var BABYLON;
|
|
|
_this._started = false;
|
|
|
_this._stopped = false;
|
|
|
_this._timeDelta = 0;
|
|
|
- _this._attributesStrideSize = 21;
|
|
|
_this._actualFrame = 0;
|
|
|
_this._rawTextureWidth = 256;
|
|
|
/**
|
|
@@ -67518,6 +67489,8 @@ var BABYLON;
|
|
|
}
|
|
|
var engine = this._scene.getEngine();
|
|
|
var data = new Array();
|
|
|
+ this._attributesStrideSize = 21;
|
|
|
+ this._targetIndex = 0;
|
|
|
if (!this.isBillboardBased) {
|
|
|
this._attributesStrideSize += 3;
|
|
|
}
|
|
@@ -76609,46 +76582,6 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
- Object.defineProperty(ShadowGenerator.prototype, "useVarianceShadowMap", {
|
|
|
- /**
|
|
|
- * Gets if the current filter is set to VSM.
|
|
|
- * DEPRECATED. Should use useExponentialShadowMap instead.
|
|
|
- */
|
|
|
- get: function () {
|
|
|
- BABYLON.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead.");
|
|
|
- return this.useExponentialShadowMap;
|
|
|
- },
|
|
|
- /**
|
|
|
- * Sets the current filter is to VSM.
|
|
|
- * DEPRECATED. Should use useExponentialShadowMap instead.
|
|
|
- */
|
|
|
- set: function (value) {
|
|
|
- BABYLON.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead.");
|
|
|
- this.useExponentialShadowMap = value;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
- Object.defineProperty(ShadowGenerator.prototype, "useBlurVarianceShadowMap", {
|
|
|
- /**
|
|
|
- * Gets if the current filter is set to blurred VSM.
|
|
|
- * DEPRECATED. Should use useBlurExponentialShadowMap instead.
|
|
|
- */
|
|
|
- get: function () {
|
|
|
- BABYLON.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead.");
|
|
|
- return this.useBlurExponentialShadowMap;
|
|
|
- },
|
|
|
- /**
|
|
|
- * Sets the current filter is to blurred VSM.
|
|
|
- * DEPRECATED. Should use useBlurExponentialShadowMap instead.
|
|
|
- */
|
|
|
- set: function (value) {
|
|
|
- BABYLON.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead.");
|
|
|
- this.useBlurExponentialShadowMap = value;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
|
|
|
/**
|
|
|
* Gets if the current filter is set to ESM.
|
|
@@ -77037,7 +76970,7 @@ var BABYLON;
|
|
|
var scene = this._scene;
|
|
|
var engine = scene.getEngine();
|
|
|
var material = subMesh.getMaterial();
|
|
|
- if (!material) {
|
|
|
+ if (!material || subMesh.verticesCount === 0) {
|
|
|
return;
|
|
|
}
|
|
|
// Culling
|
|
@@ -77075,6 +77008,9 @@ var BABYLON;
|
|
|
var skeleton = mesh.skeleton;
|
|
|
if (skeleton.isUsingTextureForMatrices) {
|
|
|
var boneTexture = skeleton.getTransformMatrixTexture();
|
|
|
+ if (!boneTexture) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
this._effect.setTexture("boneSampler", boneTexture);
|
|
|
this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
|
|
|
}
|
|
@@ -108609,7 +108545,7 @@ var BABYLON;
|
|
|
* After initialization enterXR can be called to start an XR session
|
|
|
* @returns Promise which resolves after it is initialized
|
|
|
*/
|
|
|
- WebXRSessionManager.prototype.initialize = function () {
|
|
|
+ WebXRSessionManager.prototype.initializeAsync = function () {
|
|
|
var _this = this;
|
|
|
// Check if the browser supports webXR
|
|
|
this._xrNavigator = navigator;
|
|
@@ -108628,7 +108564,7 @@ var BABYLON;
|
|
|
* @param frameOfReferenceType option to configure how the xr pose is expressed
|
|
|
* @returns Promise which resolves after it enters XR
|
|
|
*/
|
|
|
- WebXRSessionManager.prototype.enterXR = function (sessionCreationOptions, frameOfReferenceType) {
|
|
|
+ WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
|
|
|
var _this = this;
|
|
|
// initialize session
|
|
|
return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
|
|
@@ -108669,7 +108605,7 @@ var BABYLON;
|
|
|
* Stops the xrSession and restores the renderloop
|
|
|
* @returns Promise which resolves after it exits XR
|
|
|
*/
|
|
|
- WebXRSessionManager.prototype.exitXR = function () {
|
|
|
+ WebXRSessionManager.prototype.exitXRAsync = function () {
|
|
|
return this._xrSession.end();
|
|
|
};
|
|
|
/**
|
|
@@ -108677,7 +108613,7 @@ var BABYLON;
|
|
|
* @param ray ray to cast into the environment
|
|
|
* @returns Promise which resolves with a collision point in the environment if it exists
|
|
|
*/
|
|
|
- WebXRSessionManager.prototype.environmentPointHitTest = function (ray) {
|
|
|
+ WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
|
|
|
var _this = this;
|
|
|
return new Promise(function (res, rej) {
|
|
|
// Compute left handed inputs to request hit test
|
|
@@ -108711,7 +108647,7 @@ var BABYLON;
|
|
|
* @param options creation options to check if they are supported
|
|
|
* @returns true if supported
|
|
|
*/
|
|
|
- WebXRSessionManager.prototype.supportsSession = function (options) {
|
|
|
+ WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
|
|
|
return this._xrDevice.supportsSession(options).then(function () {
|
|
|
return true;
|
|
|
}).catch(function (e) {
|
|
@@ -108810,7 +108746,7 @@ var BABYLON;
|
|
|
*/
|
|
|
WebXRExperienceHelper.CreateAsync = function (scene) {
|
|
|
var helper = new WebXRExperienceHelper(scene);
|
|
|
- return helper._sessionManager.initialize().then(function () {
|
|
|
+ return helper._sessionManager.initializeAsync().then(function () {
|
|
|
helper._supported = true;
|
|
|
return helper;
|
|
|
}).catch(function () {
|
|
@@ -108821,9 +108757,9 @@ var BABYLON;
|
|
|
* Exits XR mode and returns the scene to its original state
|
|
|
* @returns promise that resolves after xr mode has exited
|
|
|
*/
|
|
|
- WebXRExperienceHelper.prototype.exitXR = function () {
|
|
|
+ WebXRExperienceHelper.prototype.exitXRAsync = function () {
|
|
|
this._setState(WebXRState.EXITING_XR);
|
|
|
- return this._sessionManager.exitXR();
|
|
|
+ return this._sessionManager.exitXRAsync();
|
|
|
};
|
|
|
/**
|
|
|
* Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
|
|
@@ -108831,10 +108767,10 @@ var BABYLON;
|
|
|
* @param frameOfReference frame of reference of the XR session
|
|
|
* @returns promise that resolves after xr mode has entered
|
|
|
*/
|
|
|
- WebXRExperienceHelper.prototype.enterXR = function (sessionCreationOptions, frameOfReference) {
|
|
|
+ WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
|
|
|
var _this = this;
|
|
|
this._setState(WebXRState.ENTERING_XR);
|
|
|
- return this._sessionManager.enterXR(sessionCreationOptions, frameOfReference).then(function () {
|
|
|
+ return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
|
|
|
// Cache pre xr scene settings
|
|
|
_this._originalSceneAutoClear = _this.scene.autoClear;
|
|
|
_this._nonVRCamera = _this.scene.activeCamera;
|
|
@@ -108859,15 +108795,23 @@ var BABYLON;
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
|
+ * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
|
|
|
+ * @param ray ray to cast into the environment
|
|
|
+ * @returns Promise which resolves with a collision point in the environment if it exists
|
|
|
+ */
|
|
|
+ WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
|
|
|
+ return this._sessionManager.environmentPointHitTestAsync(ray);
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Checks if the creation options are supported by the xr session
|
|
|
* @param options creation options
|
|
|
* @returns true if supported
|
|
|
*/
|
|
|
- WebXRExperienceHelper.prototype.supportsSession = function (options) {
|
|
|
+ WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
|
|
|
if (!this._supported) {
|
|
|
return Promise.resolve(false);
|
|
|
}
|
|
|
- return this._sessionManager.supportsSession(options);
|
|
|
+ return this._sessionManager.supportsSessionAsync(options);
|
|
|
};
|
|
|
/**
|
|
|
* Disposes of the experience helper
|
|
@@ -108923,6 +108867,32 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
/**
|
|
|
+ * Button which can be used to enter a different mode of XR
|
|
|
+ */
|
|
|
+ var WebXREnterExitUIButton = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Creates a WebXREnterExitUIButton
|
|
|
+ * @param element button element
|
|
|
+ * @param initializationOptions XR initialization options for the button
|
|
|
+ */
|
|
|
+ function WebXREnterExitUIButton(
|
|
|
+ /** button element */
|
|
|
+ element,
|
|
|
+ /** XR initialization options for the button */
|
|
|
+ initializationOptions) {
|
|
|
+ this.element = element;
|
|
|
+ this.initializationOptions = initializationOptions;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Overwritable function which can be used to update the button's visuals when the state changes
|
|
|
+ * @param activeButton the current active button in the UI
|
|
|
+ */
|
|
|
+ WebXREnterExitUIButton.prototype.update = function (activeButton) {
|
|
|
+ };
|
|
|
+ return WebXREnterExitUIButton;
|
|
|
+ }());
|
|
|
+ BABYLON.WebXREnterExitUIButton = WebXREnterExitUIButton;
|
|
|
+ /**
|
|
|
* Options to create the webXR UI
|
|
|
*/
|
|
|
var WebXREnterExitUIOptions = /** @class */ (function () {
|
|
@@ -108939,6 +108909,7 @@ var BABYLON;
|
|
|
var _this = this;
|
|
|
this.scene = scene;
|
|
|
this._buttons = [];
|
|
|
+ this._activeButton = null;
|
|
|
this._overlay = document.createElement("div");
|
|
|
this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
|
|
|
if (options.customButtons) {
|
|
@@ -108948,11 +108919,20 @@ var BABYLON;
|
|
|
var hmdBtn = document.createElement("button");
|
|
|
hmdBtn.style.cssText = "color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-repeat:no-repeat; background-position: center; outline: none;";
|
|
|
hmdBtn.innerText = "HMD";
|
|
|
- this._buttons.push({ element: hmdBtn, initializationOptions: { immersive: true } });
|
|
|
+ this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
|
|
|
+ this._buttons[this._buttons.length - 1].update = function (activeButton) {
|
|
|
+ this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
|
|
|
+ this.element.innerText = activeButton === this ? "EXIT" : "HMD";
|
|
|
+ };
|
|
|
var windowBtn = document.createElement("button");
|
|
|
windowBtn.style.cssText = hmdBtn.style.cssText;
|
|
|
windowBtn.innerText = "Window";
|
|
|
- this._buttons.push({ element: windowBtn, initializationOptions: { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext } });
|
|
|
+ this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
|
|
|
+ this._buttons[this._buttons.length - 1].update = function (activeButton) {
|
|
|
+ this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
|
|
|
+ this.element.innerText = activeButton === this ? "EXIT" : "Window";
|
|
|
+ };
|
|
|
+ this._updateButtons(null);
|
|
|
}
|
|
|
var renderCanvas = scene.getEngine().getRenderingCanvas();
|
|
|
if (renderCanvas && renderCanvas.parentNode) {
|
|
@@ -108973,7 +108953,12 @@ var BABYLON;
|
|
|
var _this = this;
|
|
|
var ui = new WebXREnterExitUI(scene, options);
|
|
|
var supportedPromises = ui._buttons.map(function (btn) {
|
|
|
- return helper.supportsSession(btn.initializationOptions);
|
|
|
+ return helper.supportsSessionAsync(btn.initializationOptions);
|
|
|
+ });
|
|
|
+ helper.onStateChangedObservable.add(function (state) {
|
|
|
+ if (state == BABYLON.WebXRState.NOT_IN_XR) {
|
|
|
+ ui._updateButtons(null);
|
|
|
+ }
|
|
|
});
|
|
|
return Promise.all(supportedPromises).then(function (results) {
|
|
|
results.forEach(function (supported, i) {
|
|
@@ -108984,13 +108969,15 @@ var BABYLON;
|
|
|
switch (_a.label) {
|
|
|
case 0:
|
|
|
if (!(helper.state == BABYLON.WebXRState.IN_XR)) return [3 /*break*/, 2];
|
|
|
- return [4 /*yield*/, helper.exitXR()];
|
|
|
+ ui._updateButtons(null);
|
|
|
+ return [4 /*yield*/, helper.exitXRAsync()];
|
|
|
case 1:
|
|
|
_a.sent();
|
|
|
return [2 /*return*/];
|
|
|
case 2:
|
|
|
if (!(helper.state == BABYLON.WebXRState.NOT_IN_XR)) return [3 /*break*/, 4];
|
|
|
- return [4 /*yield*/, helper.enterXR(ui._buttons[i].initializationOptions, "eye-level")];
|
|
|
+ ui._updateButtons(ui._buttons[i]);
|
|
|
+ return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
|
|
|
case 3:
|
|
|
_a.sent();
|
|
|
_a.label = 4;
|
|
@@ -109002,6 +108989,13 @@ var BABYLON;
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
+ WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
|
|
|
+ var _this = this;
|
|
|
+ this._activeButton = activeButton;
|
|
|
+ this._buttons.forEach(function (b) {
|
|
|
+ b.update(_this._activeButton);
|
|
|
+ });
|
|
|
+ };
|
|
|
/**
|
|
|
* Disposes of the object
|
|
|
*/
|
|
@@ -109038,7 +109032,7 @@ var BABYLON;
|
|
|
this.canvasContext = null;
|
|
|
if (!canvas) {
|
|
|
canvas = document.createElement('canvas');
|
|
|
- canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #48989e;";
|
|
|
+ canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
|
|
|
}
|
|
|
this._setManagedOutputCanvas(canvas);
|
|
|
helper.onStateChangedObservable.add(function (stateInfo) {
|
|
@@ -109086,6 +109080,104 @@ var BABYLON;
|
|
|
|
|
|
//# sourceMappingURL=babylon.webXRManagedOutputCanvas.js.map
|
|
|
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * Represents an XR input
|
|
|
+ */
|
|
|
+ var WebXRController = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Creates the controller
|
|
|
+ * @see https://doc.babylonjs.com/how_to/webxr
|
|
|
+ * @param scene the scene which the controller should be associated to
|
|
|
+ */
|
|
|
+ function WebXRController(scene) {
|
|
|
+ this.pointer = new BABYLON.AbstractMesh("controllerPointer", scene);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Disposes of the object
|
|
|
+ */
|
|
|
+ WebXRController.prototype.dispose = function () {
|
|
|
+ if (this.grip) {
|
|
|
+ this.grip.dispose();
|
|
|
+ }
|
|
|
+ this.pointer.dispose();
|
|
|
+ };
|
|
|
+ return WebXRController;
|
|
|
+ }());
|
|
|
+ BABYLON.WebXRController = WebXRController;
|
|
|
+ /**
|
|
|
+ * XR input used to track XR inputs such as controllers/rays
|
|
|
+ */
|
|
|
+ var WebXRInput = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Initializes the WebXRInput
|
|
|
+ * @param helper experience helper which the input should be created for
|
|
|
+ */
|
|
|
+ function WebXRInput(helper) {
|
|
|
+ var _this = this;
|
|
|
+ this.helper = helper;
|
|
|
+ /**
|
|
|
+ * XR controllers being tracked
|
|
|
+ */
|
|
|
+ this.controllers = [];
|
|
|
+ this._tmpMatrix = new BABYLON.Matrix();
|
|
|
+ this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
|
|
|
+ if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var xrFrame = helper._sessionManager._currentXRFrame;
|
|
|
+ var inputSources = helper._sessionManager._xrSession.getInputSources();
|
|
|
+ inputSources.forEach(function (input, i) {
|
|
|
+ var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
|
|
|
+ if (inputPose) {
|
|
|
+ if (_this.controllers.length <= i) {
|
|
|
+ _this.controllers.push(new WebXRController(helper.container.getScene()));
|
|
|
+ }
|
|
|
+ var controller = _this.controllers[i];
|
|
|
+ // Manage the grip if it exists
|
|
|
+ if (inputPose.gripMatrix) {
|
|
|
+ if (!controller.grip) {
|
|
|
+ controller.grip = new BABYLON.AbstractMesh("controllerGrip", helper.container.getScene());
|
|
|
+ }
|
|
|
+ BABYLON.Matrix.FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
|
|
|
+ if (!controller.grip.getScene().useRightHandedSystem) {
|
|
|
+ _this._tmpMatrix.toggleModelMatrixHandInPlace();
|
|
|
+ }
|
|
|
+ if (!controller.grip.rotationQuaternion) {
|
|
|
+ controller.grip.rotationQuaternion = new BABYLON.Quaternion();
|
|
|
+ }
|
|
|
+ _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
|
|
|
+ }
|
|
|
+ // Manager pointer of controller
|
|
|
+ BABYLON.Matrix.FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
|
|
|
+ if (!controller.pointer.getScene().useRightHandedSystem) {
|
|
|
+ _this._tmpMatrix.toggleModelMatrixHandInPlace();
|
|
|
+ }
|
|
|
+ if (!controller.pointer.rotationQuaternion) {
|
|
|
+ controller.pointer.rotationQuaternion = new BABYLON.Quaternion();
|
|
|
+ }
|
|
|
+ _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Disposes of the object
|
|
|
+ */
|
|
|
+ WebXRInput.prototype.dispose = function () {
|
|
|
+ this.controllers.forEach(function (c) {
|
|
|
+ c.dispose();
|
|
|
+ });
|
|
|
+ this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
|
|
|
+ };
|
|
|
+ return WebXRInput;
|
|
|
+ }());
|
|
|
+ BABYLON.WebXRInput = WebXRInput;
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
+//# sourceMappingURL=babylon.webXRInput.js.map
|
|
|
+
|
|
|
// Mainly based on these 2 articles :
|
|
|
// Creating an universal virtual touch joystick working for all Touch models thanks to Hand.JS : http://blogs.msdn.com/b/davrous/archive/2013/02/22/creating-an-universal-virtual-touch-joystick-working-for-all-touch-models-thanks-to-hand-js.aspx
|
|
|
// & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
|
|
@@ -119986,7 +120078,9 @@ var BABYLON;
|
|
|
var _this = this;
|
|
|
return BABYLON.WebXRExperienceHelper.CreateAsync(this).then(function (helper) {
|
|
|
var outputCanvas = new BABYLON.WebXRManagedOutputCanvas(helper);
|
|
|
- return BABYLON.WebXREnterExitUI.CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext }).then(function (ui) {
|
|
|
+ return BABYLON.WebXREnterExitUI.CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
|
|
|
+ .then(function (ui) {
|
|
|
+ new BABYLON.WebXRInput(helper);
|
|
|
return helper;
|
|
|
});
|
|
|
});
|