|
@@ -7437,6 +7437,8 @@ var BABYLON;
|
|
|
function Matrix() {
|
|
|
this._isIdentity = false;
|
|
|
this._isIdentityDirty = true;
|
|
|
+ this._isIdentity3x2 = true;
|
|
|
+ this._isIdentity3x2Dirty = true;
|
|
|
/**
|
|
|
* Gets or sets the internal data of the matrix
|
|
|
*/
|
|
@@ -7447,18 +7449,17 @@ var BABYLON;
|
|
|
Matrix.prototype._markAsUpdated = function () {
|
|
|
this.updateFlag = Matrix._updateFlagSeed++;
|
|
|
this._isIdentityDirty = true;
|
|
|
+ this._isIdentity3x2Dirty = true;
|
|
|
};
|
|
|
// Properties
|
|
|
/**
|
|
|
- * Check if the current matrix is indentity
|
|
|
- * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
|
|
|
+ * Check if the current matrix is identity
|
|
|
* @returns true is the matrix is the identity matrix
|
|
|
*/
|
|
|
- Matrix.prototype.isIdentity = function (considerAsTextureMatrix) {
|
|
|
- if (considerAsTextureMatrix === void 0) { considerAsTextureMatrix = false; }
|
|
|
+ Matrix.prototype.isIdentity = function () {
|
|
|
if (this._isIdentityDirty) {
|
|
|
this._isIdentityDirty = false;
|
|
|
- if (this.m[0] !== 1.0 || this.m[5] !== 1.0 || this.m[15] !== 1.0) {
|
|
|
+ if (this.m[0] !== 1.0 || this.m[5] !== 1.0 || this.m[10] !== 1.0 || this.m[15] !== 1.0) {
|
|
|
this._isIdentity = false;
|
|
|
}
|
|
|
else if (this.m[1] !== 0.0 || this.m[2] !== 0.0 || this.m[3] !== 0.0 ||
|
|
@@ -7470,13 +7471,32 @@ var BABYLON;
|
|
|
else {
|
|
|
this._isIdentity = true;
|
|
|
}
|
|
|
- if (!considerAsTextureMatrix && this.m[10] !== 1.0) {
|
|
|
- this._isIdentity = false;
|
|
|
- }
|
|
|
}
|
|
|
return this._isIdentity;
|
|
|
};
|
|
|
/**
|
|
|
+ * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
|
|
|
+ * @returns true is the matrix is the identity matrix
|
|
|
+ */
|
|
|
+ Matrix.prototype.isIdentityAs3x2 = function () {
|
|
|
+ if (this._isIdentity3x2Dirty) {
|
|
|
+ this._isIdentity3x2Dirty = false;
|
|
|
+ if (this.m[0] !== 1.0 || this.m[5] !== 1.0 || this.m[15] !== 1.0) {
|
|
|
+ this._isIdentity3x2 = false;
|
|
|
+ }
|
|
|
+ else if (this.m[1] !== 0.0 || this.m[2] !== 0.0 || this.m[3] !== 0.0 ||
|
|
|
+ this.m[4] !== 0.0 || this.m[6] !== 0.0 || this.m[7] !== 0.0 ||
|
|
|
+ this.m[8] !== 0.0 || this.m[9] !== 0.0 || this.m[10] !== 0.0 || this.m[11] !== 0.0 ||
|
|
|
+ this.m[12] !== 0.0 || this.m[13] !== 0.0 || this.m[14] !== 0.0) {
|
|
|
+ this._isIdentity3x2 = false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._isIdentity3x2 = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this._isIdentity3x2;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Gets the determinant of the matrix
|
|
|
* @returns the matrix determinant
|
|
|
*/
|
|
@@ -7997,6 +8017,24 @@ var BABYLON;
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Toggles model matrix from being right handed to left handed in place and vice versa
|
|
|
+ */
|
|
|
+ Matrix.prototype.toggleModelMatrixHandInPlace = function () {
|
|
|
+ var _this = this;
|
|
|
+ [2, 6, 8, 9, 14].forEach(function (num) {
|
|
|
+ _this.m[num] *= -1;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Toggles projection matrix from being right handed to left handed in place and vice versa
|
|
|
+ */
|
|
|
+ Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
|
|
|
+ var _this = this;
|
|
|
+ [8, 9, 10, 11].forEach(function (num) {
|
|
|
+ _this.m[num] *= -1;
|
|
|
+ });
|
|
|
+ };
|
|
|
// Statics
|
|
|
/**
|
|
|
* Creates a matrix from an array
|
|
@@ -10031,7 +10069,7 @@ var BABYLON;
|
|
|
Tmp.Vector3 = BABYLON.Tools.BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
|
|
|
Tmp.Vector4 = BABYLON.Tools.BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
|
|
|
Tmp.Quaternion = BABYLON.Tools.BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
|
|
|
- Tmp.Matrix = BABYLON.Tools.BuildArray(6, Matrix.Identity); // 6 temp Matrices at once should be enough
|
|
|
+ Tmp.Matrix = BABYLON.Tools.BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
|
|
|
return Tmp;
|
|
|
}());
|
|
|
BABYLON.Tmp = Tmp;
|
|
@@ -10355,7 +10393,12 @@ var BABYLON;
|
|
|
|
|
|
//# sourceMappingURL=babylon.math.scalar.js.map
|
|
|
|
|
|
-
|
|
|
+var XRFrameOfReferenceType;
|
|
|
+(function (XRFrameOfReferenceType) {
|
|
|
+ XRFrameOfReferenceType[XRFrameOfReferenceType["head-model"] = 0] = "head-model";
|
|
|
+ XRFrameOfReferenceType[XRFrameOfReferenceType["eye-level"] = 1] = "eye-level";
|
|
|
+ XRFrameOfReferenceType[XRFrameOfReferenceType["stage"] = 2] = "stage";
|
|
|
+})(XRFrameOfReferenceType || (XRFrameOfReferenceType = {}));
|
|
|
|
|
|
//# sourceMappingURL=babylon.mixins.js.map
|
|
|
|
|
@@ -12643,7 +12686,7 @@ var BABYLON;
|
|
|
this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
|
|
|
// Detect if we are running on a faulty buggy desktop OS.
|
|
|
this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
|
- console.log("Babylon.js engine (v" + Engine.Version + ") launched");
|
|
|
+ console.log("Babylon.js v" + Engine.Version + " - " + this.description);
|
|
|
this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
|
|
|
}
|
|
|
Object.defineProperty(Engine, "LastCreatedEngine", {
|
|
@@ -12694,7 +12737,21 @@ var BABYLON;
|
|
|
* Returns the current version of the framework
|
|
|
*/
|
|
|
get: function () {
|
|
|
- return "4.0.0-alpha.1";
|
|
|
+ return "4.0.0-alpha.2";
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
+ Object.defineProperty(Engine.prototype, "description", {
|
|
|
+ /**
|
|
|
+ * Returns a string describing the current engine
|
|
|
+ */
|
|
|
+ get: function () {
|
|
|
+ var description = "WebGL" + this.webGLVersion;
|
|
|
+ if (this._caps.parallelShaderCompile) {
|
|
|
+ description += " - Parallel shader compilation";
|
|
|
+ }
|
|
|
+ return description;
|
|
|
},
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
@@ -23466,7 +23523,7 @@ var BABYLON;
|
|
|
*/
|
|
|
_this.cameraRigMode = Camera.RIG_MODE_NONE;
|
|
|
/**
|
|
|
- * Defines the list of custom render target the camera should render to.
|
|
|
+ * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
|
|
|
* This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
|
|
|
* else in the scene.
|
|
|
*/
|
|
@@ -23474,7 +23531,7 @@ var BABYLON;
|
|
|
/**
|
|
|
* When set, the camera will render to this render target instead of the default canvas
|
|
|
*/
|
|
|
- _this.customDefaultRenderTarget = null;
|
|
|
+ _this.outputRenderTarget = null;
|
|
|
/**
|
|
|
* Observable triggered when the camera view matrix has changed.
|
|
|
*/
|
|
@@ -23503,6 +23560,7 @@ var BABYLON;
|
|
|
/** @hidden */
|
|
|
_this._activeMeshes = new BABYLON.SmartArray(256);
|
|
|
_this._globalPosition = BABYLON.Vector3.Zero();
|
|
|
+ /** hidden */
|
|
|
_this._computedViewMatrix = BABYLON.Matrix.Identity();
|
|
|
_this._doNotComputeProjectionMatrix = false;
|
|
|
_this._transformMatrix = BABYLON.Matrix.Zero();
|
|
@@ -25777,6 +25835,7 @@ var BABYLON;
|
|
|
_this._transformMatrix = BABYLON.Matrix.Zero();
|
|
|
_this._useAlternateCameraConfiguration = false;
|
|
|
_this._alternateRendering = false;
|
|
|
+ _this._wheelEventName = "";
|
|
|
/**
|
|
|
* Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
|
|
|
* This is useful if there are more lights that the maximum simulteanous authorized
|
|
@@ -26705,7 +26764,7 @@ var BABYLON;
|
|
|
pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
|
|
|
}
|
|
|
if (pickResult) {
|
|
|
- var type = evt.type === "mousewheel" || evt.type === "DOMMouseScroll" ? BABYLON.PointerEventTypes.POINTERWHEEL : BABYLON.PointerEventTypes.POINTERMOVE;
|
|
|
+ var type = evt.type === this._wheelEventName ? BABYLON.PointerEventTypes.POINTERWHEEL : BABYLON.PointerEventTypes.POINTERMOVE;
|
|
|
if (this.onPointerMove) {
|
|
|
this.onPointerMove(evt, pickResult, type);
|
|
|
}
|
|
@@ -26808,8 +26867,6 @@ var BABYLON;
|
|
|
Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit) {
|
|
|
var evt = new PointerEvent("pointerup", pointerEventInit);
|
|
|
var clickInfo = new ClickInfo();
|
|
|
- clickInfo.singleClick = true;
|
|
|
- clickInfo.ignore = true;
|
|
|
if (this._checkPrePointerObservable(pickResult, evt, BABYLON.PointerEventTypes.POINTERUP)) {
|
|
|
return this;
|
|
|
}
|
|
@@ -26857,27 +26914,17 @@ var BABYLON;
|
|
|
}
|
|
|
var type = BABYLON.PointerEventTypes.POINTERUP;
|
|
|
if (this.onPointerObservable.hasObservers()) {
|
|
|
- if (!clickInfo.ignore) {
|
|
|
- if (!clickInfo.hasSwiped) {
|
|
|
- if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(BABYLON.PointerEventTypes.POINTERTAP)) {
|
|
|
- var type_2 = BABYLON.PointerEventTypes.POINTERTAP;
|
|
|
- var pi = new BABYLON.PointerInfo(type_2, evt, pickResult);
|
|
|
- this._setRayOnPointerInfo(pi);
|
|
|
- this.onPointerObservable.notifyObservers(pi, type_2);
|
|
|
- }
|
|
|
- if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(BABYLON.PointerEventTypes.POINTERDOUBLETAP)) {
|
|
|
- var type_3 = BABYLON.PointerEventTypes.POINTERDOUBLETAP;
|
|
|
- var pi = new BABYLON.PointerInfo(type_3, evt, pickResult);
|
|
|
- this._setRayOnPointerInfo(pi);
|
|
|
- this.onPointerObservable.notifyObservers(pi, type_3);
|
|
|
- }
|
|
|
+ if (!clickInfo.ignore && !clickInfo.hasSwiped) {
|
|
|
+ if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(BABYLON.PointerEventTypes.POINTERTAP)) {
|
|
|
+ type = BABYLON.PointerEventTypes.POINTERTAP;
|
|
|
+ }
|
|
|
+ else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(BABYLON.PointerEventTypes.POINTERDOUBLETAP)) {
|
|
|
+ type = BABYLON.PointerEventTypes.POINTERDOUBLETAP;
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
- var pi = new BABYLON.PointerInfo(type, evt, pickResult);
|
|
|
- this._setRayOnPointerInfo(pi);
|
|
|
- this.onPointerObservable.notifyObservers(pi, type);
|
|
|
- }
|
|
|
+ var pi = new BABYLON.PointerInfo(type, evt, pickResult);
|
|
|
+ this._setRayOnPointerInfo(pi);
|
|
|
+ this.onPointerObservable.notifyObservers(pi, type);
|
|
|
}
|
|
|
if (this.onPointerUp && !clickInfo.ignore) {
|
|
|
this.onPointerUp(evt, pickResult, type);
|
|
@@ -26943,7 +26990,6 @@ var BABYLON;
|
|
|
checkPicking = act.hasPickTriggers;
|
|
|
}
|
|
|
}
|
|
|
- var eventRaised = false;
|
|
|
if (checkPicking) {
|
|
|
var btn = evt.button;
|
|
|
clickInfo.hasSwiped = _this._isPointerSwiping();
|
|
@@ -27035,7 +27081,7 @@ var BABYLON;
|
|
|
this._onPointerMove = function (evt) {
|
|
|
_this._updatePointerPosition(evt);
|
|
|
// PreObservable support
|
|
|
- if (_this._checkPrePointerObservable(null, evt, evt.type === "mousewheel" || evt.type === "DOMMouseScroll" ? BABYLON.PointerEventTypes.POINTERWHEEL : BABYLON.PointerEventTypes.POINTERMOVE)) {
|
|
|
+ if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? BABYLON.PointerEventTypes.POINTERWHEEL : BABYLON.PointerEventTypes.POINTERMOVE)) {
|
|
|
return;
|
|
|
}
|
|
|
if (!_this.cameraToUseForPointers && !_this.activeCamera) {
|
|
@@ -27190,8 +27236,10 @@ var BABYLON;
|
|
|
if (attachMove) {
|
|
|
canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
|
|
|
// Wheel
|
|
|
- canvas.addEventListener('mousewheel', this._onPointerMove, false);
|
|
|
- canvas.addEventListener('DOMMouseScroll', this._onPointerMove, false);
|
|
|
+ this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
|
|
|
+ document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
|
|
|
+ "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
|
|
|
+ canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
|
|
|
}
|
|
|
if (attachDown) {
|
|
|
canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
|
|
@@ -27219,8 +27267,7 @@ var BABYLON;
|
|
|
engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
|
|
|
}
|
|
|
// Wheel
|
|
|
- canvas.removeEventListener('mousewheel', this._onPointerMove);
|
|
|
- canvas.removeEventListener('DOMMouseScroll', this._onPointerMove);
|
|
|
+ canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
|
|
|
// Keyboard
|
|
|
canvas.removeEventListener("keydown", this._onKeyDown);
|
|
|
canvas.removeEventListener("keyup", this._onKeyUp);
|
|
@@ -29100,8 +29147,8 @@ var BABYLON;
|
|
|
step.action(this.activeCamera);
|
|
|
}
|
|
|
this._intermediateRendering = false;
|
|
|
- if (this.activeCamera.customDefaultRenderTarget) {
|
|
|
- var internalTexture = this.activeCamera.customDefaultRenderTarget.getInternalTexture();
|
|
|
+ if (this.activeCamera.outputRenderTarget) {
|
|
|
+ var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
|
|
|
if (internalTexture) {
|
|
|
engine.bindFramebuffer(internalTexture);
|
|
|
}
|
|
@@ -30097,6 +30144,11 @@ var BABYLON;
|
|
|
function AssetContainer(scene) {
|
|
|
var _this = _super.call(this) || this;
|
|
|
_this.scene = scene;
|
|
|
+ _this["sounds"] = [];
|
|
|
+ _this["effectLayers"] = [];
|
|
|
+ _this["layers"] = [];
|
|
|
+ _this["lensFlareSystems"] = [];
|
|
|
+ _this["proceduralTextures"] = [];
|
|
|
return _this;
|
|
|
}
|
|
|
/**
|
|
@@ -30145,7 +30197,7 @@ var BABYLON;
|
|
|
});
|
|
|
for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
|
|
|
var component = _a[_i];
|
|
|
- component.addFromContainer(this.scene);
|
|
|
+ component.addFromContainer(this);
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
@@ -30194,7 +30246,7 @@ var BABYLON;
|
|
|
});
|
|
|
for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
|
|
|
var component = _a[_i];
|
|
|
- component.removeFromContainer(this.scene);
|
|
|
+ component.removeFromContainer(this);
|
|
|
}
|
|
|
};
|
|
|
AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
|
|
@@ -30874,8 +30926,10 @@ var BABYLON;
|
|
|
* Creates a new InternalTexture
|
|
|
* @param engine defines the engine to use
|
|
|
* @param dataSource defines the type of data that will be used
|
|
|
+ * @param delayAllocation if the texture allocation should be delayed (default: false)
|
|
|
*/
|
|
|
- function InternalTexture(engine, dataSource) {
|
|
|
+ function InternalTexture(engine, dataSource, delayAllocation) {
|
|
|
+ if (delayAllocation === void 0) { delayAllocation = false; }
|
|
|
/**
|
|
|
* Observable called when the texture is loaded
|
|
|
*/
|
|
@@ -30909,7 +30963,9 @@ var BABYLON;
|
|
|
this._references = 1;
|
|
|
this._engine = engine;
|
|
|
this._dataSource = dataSource;
|
|
|
- this._webGLTexture = engine._createTexture();
|
|
|
+ if (!delayAllocation) {
|
|
|
+ this._webGLTexture = engine._createTexture();
|
|
|
+ }
|
|
|
}
|
|
|
/**
|
|
|
* Gets the Engine the texture belongs to.
|
|
@@ -36569,7 +36625,7 @@ var BABYLON;
|
|
|
if (!doNotAdd) {
|
|
|
this._scene.addMaterial(this);
|
|
|
}
|
|
|
- if (scene.useMaterialMeshMap) {
|
|
|
+ if (this._scene.useMaterialMeshMap) {
|
|
|
this.meshMap = {};
|
|
|
}
|
|
|
}
|
|
@@ -42799,7 +42855,7 @@ var BABYLON;
|
|
|
MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
|
|
|
defines._needUVs = true;
|
|
|
defines[key] = true;
|
|
|
- if (texture.getTextureMatrix().isIdentity(true)) {
|
|
|
+ if (texture.getTextureMatrix().isIdentityAs3x2()) {
|
|
|
defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
|
|
|
if (texture.coordinatesIndex === 0) {
|
|
|
defines["MAINUV1"] = true;
|
|
@@ -42820,7 +42876,7 @@ var BABYLON;
|
|
|
*/
|
|
|
MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
|
|
|
var matrix = texture.getTextureMatrix();
|
|
|
- if (!matrix.isIdentity(true)) {
|
|
|
+ if (!matrix.isIdentityAs3x2()) {
|
|
|
uniformBuffer.updateMatrix(key + "Matrix", matrix);
|
|
|
}
|
|
|
};
|
|
@@ -50725,8 +50781,9 @@ var BABYLON;
|
|
|
delta = event.wheelDelta / (_this.wheelPrecision * 40);
|
|
|
}
|
|
|
}
|
|
|
- else if (event.detail) {
|
|
|
- delta = -event.detail / _this.wheelPrecision;
|
|
|
+ else {
|
|
|
+ var deltaValue = event.deltaY || event.detail;
|
|
|
+ delta = -deltaValue / _this.wheelPrecision;
|
|
|
}
|
|
|
if (delta) {
|
|
|
_this.camera.inertialRadiusOffset += delta;
|
|
@@ -73387,8 +73444,9 @@ var BABYLON;
|
|
|
* @param generateStencilBuffer True to generate a stencil buffer
|
|
|
* @param isMulti True if multiple textures need to be created (Draw Buffers)
|
|
|
* @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
|
|
|
+ * @param delayAllocation if the texture allocation should be delayed (default: false)
|
|
|
*/
|
|
|
- function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format) {
|
|
|
+ function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
|
|
|
if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
|
|
|
if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
|
|
|
if (isCube === void 0) { isCube = false; }
|
|
@@ -73397,6 +73455,7 @@ var BABYLON;
|
|
|
if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
|
|
|
if (isMulti === void 0) { isMulti = false; }
|
|
|
if (format === void 0) { format = BABYLON.Engine.TEXTUREFORMAT_RGBA; }
|
|
|
+ if (delayAllocation === void 0) { delayAllocation = false; }
|
|
|
var _this = _super.call(this, null, scene, !generateMipMaps) || this;
|
|
|
_this.isCube = isCube;
|
|
|
/**
|
|
@@ -73475,13 +73534,15 @@ var BABYLON;
|
|
|
_this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
|
|
|
_this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
|
|
|
}
|
|
|
- if (isCube) {
|
|
|
- _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
|
|
|
- _this.coordinatesMode = BABYLON.Texture.INVCUBIC_MODE;
|
|
|
- _this._textureMatrix = BABYLON.Matrix.Identity();
|
|
|
- }
|
|
|
- else {
|
|
|
- _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
|
|
|
+ if (!delayAllocation) {
|
|
|
+ if (isCube) {
|
|
|
+ _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
|
|
|
+ _this.coordinatesMode = BABYLON.Texture.INVCUBIC_MODE;
|
|
|
+ _this._textureMatrix = BABYLON.Matrix.Identity();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
|
|
|
+ }
|
|
|
}
|
|
|
return _this;
|
|
|
}
|
|
@@ -73871,7 +73932,7 @@ var BABYLON;
|
|
|
// Is predicate defined?
|
|
|
if (this.renderListPredicate) {
|
|
|
if (this.renderList) {
|
|
|
- this.renderList.splice(0); // Clear previous renderList
|
|
|
+ this.renderList.length = 0; // Clear previous renderList
|
|
|
}
|
|
|
else {
|
|
|
this.renderList = [];
|
|
@@ -105553,7 +105614,7 @@ var BABYLON;
|
|
|
this._beta = 0;
|
|
|
this._gamma = 0;
|
|
|
this._orientationChanged = function () {
|
|
|
- _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && window.screen.orientation['angle'] ? window.screen.orientation.angle : 0));
|
|
|
+ _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
|
|
|
_this._screenOrientationAngle = -BABYLON.Tools.ToRadians(_this._screenOrientationAngle / 2);
|
|
|
_this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
|
|
|
};
|
|
@@ -108395,11 +108456,57 @@ var BABYLON;
|
|
|
this._updateNumberOfRigCameras(2);
|
|
|
this.rigCameras[0].viewport = new BABYLON.Viewport(0, 0, 0.5, 1.0);
|
|
|
this.rigCameras[0].position.x = -pupilDistance / 2;
|
|
|
- this.rigCameras[0].customDefaultRenderTarget = null;
|
|
|
+ this.rigCameras[0].outputRenderTarget = null;
|
|
|
this.rigCameras[1].viewport = new BABYLON.Viewport(0.5, 0, 0.5, 1.0);
|
|
|
this.rigCameras[1].position.x = pupilDistance / 2;
|
|
|
- this.rigCameras[1].customDefaultRenderTarget = null;
|
|
|
+ this.rigCameras[1].outputRenderTarget = null;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Updates the cameras position from the current pose information of the XR session
|
|
|
+ * @param xrSessionManager the session containing pose information
|
|
|
+ */
|
|
|
+ WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
|
|
|
+ var _this = this;
|
|
|
+ // Ensure all frame data is available
|
|
|
+ if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
|
|
|
+ if (!pose || !pose.poseModelMatrix) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // Update the parent cameras matrix
|
|
|
+ BABYLON.Matrix.FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
|
|
|
+ if (!this._scene.useRightHandedSystem) {
|
|
|
+ WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
|
|
|
+ }
|
|
|
+ WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
|
|
|
+ WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
|
|
|
+ BABYLON.Quaternion.FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
|
|
|
+ this.computeWorldMatrix();
|
|
|
+ // Update camera rigs
|
|
|
+ this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
|
|
|
+ xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
|
|
|
+ // Update view/projection matrix
|
|
|
+ BABYLON.Matrix.FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
|
|
|
+ BABYLON.Matrix.FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
|
|
|
+ if (!_this._scene.useRightHandedSystem) {
|
|
|
+ _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
|
|
|
+ _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
|
|
|
+ }
|
|
|
+ // Update viewport
|
|
|
+ var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
|
|
|
+ var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
|
|
|
+ var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
|
|
|
+ _this.rigCameras[i].viewport.width = viewport.width / width;
|
|
|
+ _this.rigCameras[i].viewport.height = viewport.height / height;
|
|
|
+ _this.rigCameras[i].viewport.x = viewport.x / width;
|
|
|
+ _this.rigCameras[i].viewport.y = viewport.y / height;
|
|
|
+ // Set cameras to render to the session's render target
|
|
|
+ _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
|
|
|
+ });
|
|
|
+ };
|
|
|
+ WebXRCamera._TmpMatrix = new BABYLON.Matrix();
|
|
|
return WebXRCamera;
|
|
|
}(BABYLON.FreeCamera));
|
|
|
BABYLON.WebXRCamera = WebXRCamera;
|
|
@@ -108407,6 +108514,141 @@ var BABYLON;
|
|
|
|
|
|
//# sourceMappingURL=babylon.webXRCamera.js.map
|
|
|
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * Manages an XRSession
|
|
|
+ * @see https://doc.babylonjs.com/how_to/webxr
|
|
|
+ */
|
|
|
+ var WebXRSessionManager = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
|
|
|
+ * @param scene The scene which the session should be created for
|
|
|
+ */
|
|
|
+ function WebXRSessionManager(scene) {
|
|
|
+ this.scene = scene;
|
|
|
+ this._tmpMatrix = new BABYLON.Matrix();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Initializes the manager, this must be done with a user action (eg. button click event)
|
|
|
+ * After initialization enterXR can be called to start an XR session
|
|
|
+ * @returns Promise which resolves after it is initialized
|
|
|
+ */
|
|
|
+ WebXRSessionManager.prototype.initialize = function () {
|
|
|
+ var _this = this;
|
|
|
+ // Check if the browser supports webXR
|
|
|
+ this._xrNavigator = navigator;
|
|
|
+ if (!this._xrNavigator.xr) {
|
|
|
+ return Promise.reject("webXR not supported by this browser");
|
|
|
+ }
|
|
|
+ // Request the webXR device
|
|
|
+ return this._xrNavigator.xr.requestDevice().then(function (device) {
|
|
|
+ _this._xrDevice = device;
|
|
|
+ return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Enters XR with the desired XR session options
|
|
|
+ * @param sessionCreationOptions xr options to create the session with
|
|
|
+ * @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) {
|
|
|
+ var _this = this;
|
|
|
+ // initialize session
|
|
|
+ return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
|
|
|
+ _this._xrSession = session;
|
|
|
+ _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
|
|
|
+ return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
|
|
|
+ }).then(function (frameOfRef) {
|
|
|
+ _this._frameOfReference = frameOfRef;
|
|
|
+ // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
|
|
|
+ _this.scene.getEngine().customAnimationFrameRequester = {
|
|
|
+ requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
|
|
|
+ renderFunction: function (timestamp, xrFrame) {
|
|
|
+ // Store the XR frame in the manager to be consumed by the XR camera to update pose
|
|
|
+ _this._currentXRFrame = xrFrame;
|
|
|
+ _this.scene.getEngine()._renderLoop();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ // Create render target texture from xr's webgl render target
|
|
|
+ _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Stops the xrSession and restores the renderloop
|
|
|
+ * @returns Promise which resolves after it exits XR
|
|
|
+ */
|
|
|
+ WebXRSessionManager.prototype.exitXR = function () {
|
|
|
+ var _this = this;
|
|
|
+ return new Promise(function (res) {
|
|
|
+ _this.scene.getEngine().customAnimationFrameRequester = null;
|
|
|
+ _this._xrSession.end();
|
|
|
+ // Restore frame buffer to avoid clear on xr framebuffer after session end
|
|
|
+ _this.scene.getEngine().restoreDefaultFramebuffer();
|
|
|
+ // Need to restart render loop as after calling session.end the last request for new frame will never call callback
|
|
|
+ _this.scene.getEngine()._renderLoop();
|
|
|
+ res();
|
|
|
+ });
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * 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
|
|
|
+ */
|
|
|
+ WebXRSessionManager.prototype.environmentPointHitTest = function (ray) {
|
|
|
+ var _this = this;
|
|
|
+ return new Promise(function (res, rej) {
|
|
|
+ // Compute left handed inputs to request hit test
|
|
|
+ var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
|
|
|
+ var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
|
|
|
+ if (!_this.scene.useRightHandedSystem) {
|
|
|
+ origin[2] *= -1;
|
|
|
+ direction[2] *= -1;
|
|
|
+ }
|
|
|
+ // Fire hittest
|
|
|
+ _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
|
|
|
+ .then(function (hits) {
|
|
|
+ if (hits.length > 0) {
|
|
|
+ BABYLON.Matrix.FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
|
|
|
+ var hitPoint = _this._tmpMatrix.getTranslation();
|
|
|
+ if (!_this.scene.useRightHandedSystem) {
|
|
|
+ hitPoint.z *= -1;
|
|
|
+ }
|
|
|
+ res(hitPoint);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ res(null);
|
|
|
+ }
|
|
|
+ }).catch(function (e) {
|
|
|
+ res(null);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ * Converts the render layer of xrSession to a render target
|
|
|
+ * @param session session to create render target for
|
|
|
+ * @param scene scene the new render target should be created for
|
|
|
+ */
|
|
|
+ WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
|
|
|
+ // Create internal texture
|
|
|
+ var internalTexture = new BABYLON.InternalTexture(scene.getEngine(), BABYLON.InternalTexture.DATASOURCE_UNKNOWN, true);
|
|
|
+ internalTexture.width = session.baseLayer.framebufferWidth;
|
|
|
+ internalTexture.height = session.baseLayer.framebufferHeight;
|
|
|
+ internalTexture._framebuffer = session.baseLayer.framebuffer;
|
|
|
+ // Create render target texture from the internal texture
|
|
|
+ var renderTargetTexture = new BABYLON.RenderTargetTexture("XR renderTargetTexture", { width: internalTexture.width, height: internalTexture.height }, scene, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, true);
|
|
|
+ renderTargetTexture._texture = internalTexture;
|
|
|
+ return renderTargetTexture;
|
|
|
+ };
|
|
|
+ return WebXRSessionManager;
|
|
|
+ }());
|
|
|
+ BABYLON.WebXRSessionManager = WebXRSessionManager;
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
+//# sourceMappingURL=babylon.webXRSessionManager.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/
|
|
@@ -115550,7 +115792,7 @@ var BABYLON;
|
|
|
_this._caps.depthTextureExtension = false;
|
|
|
_this._caps.vertexArrayObject = false;
|
|
|
_this._caps.instancedArrays = false;
|
|
|
- BABYLON.Tools.Log("Babylon.js null engine (v" + BABYLON.Engine.Version + ") launched");
|
|
|
+ BABYLON.Tools.Log("Babylon.js v" + BABYLON.Engine.Version + " - Null engine");
|
|
|
// Wrappers
|
|
|
if (typeof URL === "undefined") {
|
|
|
URL = {
|