|
@@ -1438,10 +1438,10 @@ var BABYLON;
|
|
Vector3.prototype.lengthSquared = function () {
|
|
Vector3.prototype.lengthSquared = function () {
|
|
return (this.x * this.x + this.y * this.y + this.z * this.z);
|
|
return (this.x * this.x + this.y * this.y + this.z * this.z);
|
|
};
|
|
};
|
|
- // Methods
|
|
|
|
/**
|
|
/**
|
|
* Normalize the current Vector3.
|
|
* Normalize the current Vector3.
|
|
* Returns the updated Vector3.
|
|
* Returns the updated Vector3.
|
|
|
|
+ * /!\ In place operation.
|
|
*/
|
|
*/
|
|
Vector3.prototype.normalize = function () {
|
|
Vector3.prototype.normalize = function () {
|
|
var len = this.length();
|
|
var len = this.length();
|
|
@@ -1454,6 +1454,30 @@ var BABYLON;
|
|
return this;
|
|
return this;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
|
|
+ * Normalize the current Vector3 to a new vector.
|
|
|
|
+ * @returns the new Vector3.
|
|
|
|
+ */
|
|
|
|
+ Vector3.prototype.normalizeToNew = function () {
|
|
|
|
+ var normalized = new Vector3(0, 0, 0);
|
|
|
|
+ this.normalizeToRef(normalized);
|
|
|
|
+ return normalized;
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Normalize the current Vector3 to the reference.
|
|
|
|
+ * @param the reference to update.
|
|
|
|
+ * @returns the updated Vector3.
|
|
|
|
+ */
|
|
|
|
+ Vector3.prototype.normalizeToRef = function (reference) {
|
|
|
|
+ var len = this.length();
|
|
|
|
+ if (len === 0 || len === 1.0) {
|
|
|
|
+ reference.set(this.x, this.y, this.z);
|
|
|
|
+ return reference;
|
|
|
|
+ }
|
|
|
|
+ var scale = 1.0 / len;
|
|
|
|
+ this.scaleToRef(scale, reference);
|
|
|
|
+ return reference;
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
* Returns a new Vector3 copied from the current Vector3.
|
|
* Returns a new Vector3 copied from the current Vector3.
|
|
*/
|
|
*/
|
|
Vector3.prototype.clone = function () {
|
|
Vector3.prototype.clone = function () {
|
|
@@ -10478,17 +10502,21 @@ var BABYLON;
|
|
}
|
|
}
|
|
return internalFormat;
|
|
return internalFormat;
|
|
};
|
|
};
|
|
- Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression) {
|
|
|
|
|
|
+ Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
|
|
if (compression === void 0) { compression = null; }
|
|
if (compression === void 0) { compression = null; }
|
|
|
|
+ if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
|
|
if (!texture) {
|
|
if (!texture) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var internalFormat = this._getInternalFormat(format);
|
|
var internalFormat = this._getInternalFormat(format);
|
|
|
|
+ var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
|
|
|
|
+ var textureType = this._getWebGLTextureType(type);
|
|
this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
|
|
this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
|
|
this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
|
|
this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
|
|
if (!this._doNotHandleContextLost) {
|
|
if (!this._doNotHandleContextLost) {
|
|
texture._bufferView = data;
|
|
texture._bufferView = data;
|
|
texture.format = format;
|
|
texture.format = format;
|
|
|
|
+ texture.type = type;
|
|
texture.invertY = invertY;
|
|
texture.invertY = invertY;
|
|
texture._compression = compression;
|
|
texture._compression = compression;
|
|
}
|
|
}
|
|
@@ -10499,7 +10527,7 @@ var BABYLON;
|
|
this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
|
|
this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, texture.width, texture.height, 0, internalFormat, this._gl.UNSIGNED_BYTE, data);
|
|
|
|
|
|
+ this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
|
|
}
|
|
}
|
|
if (texture.generateMipMaps) {
|
|
if (texture.generateMipMaps) {
|
|
this._gl.generateMipmap(this._gl.TEXTURE_2D);
|
|
this._gl.generateMipmap(this._gl.TEXTURE_2D);
|
|
@@ -10508,8 +10536,9 @@ var BABYLON;
|
|
this.resetTextureCache();
|
|
this.resetTextureCache();
|
|
texture.isReady = true;
|
|
texture.isReady = true;
|
|
};
|
|
};
|
|
- Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression) {
|
|
|
|
|
|
+ Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
|
|
if (compression === void 0) { compression = null; }
|
|
if (compression === void 0) { compression = null; }
|
|
|
|
+ if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
|
|
var texture = new BABYLON.InternalTexture(this, BABYLON.InternalTexture.DATASOURCE_RAW);
|
|
var texture = new BABYLON.InternalTexture(this, BABYLON.InternalTexture.DATASOURCE_RAW);
|
|
texture.baseWidth = width;
|
|
texture.baseWidth = width;
|
|
texture.baseHeight = height;
|
|
texture.baseHeight = height;
|
|
@@ -10520,10 +10549,11 @@ var BABYLON;
|
|
texture.samplingMode = samplingMode;
|
|
texture.samplingMode = samplingMode;
|
|
texture.invertY = invertY;
|
|
texture.invertY = invertY;
|
|
texture._compression = compression;
|
|
texture._compression = compression;
|
|
|
|
+ texture.type = type;
|
|
if (!this._doNotHandleContextLost) {
|
|
if (!this._doNotHandleContextLost) {
|
|
texture._bufferView = data;
|
|
texture._bufferView = data;
|
|
}
|
|
}
|
|
- this.updateRawTexture(texture, data, format, invertY, compression);
|
|
|
|
|
|
+ this.updateRawTexture(texture, data, format, invertY, compression, type);
|
|
this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
|
|
this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
|
|
// Filters
|
|
// Filters
|
|
var filters = getSamplingParameters(samplingMode, generateMipMaps, this._gl);
|
|
var filters = getSamplingParameters(samplingMode, generateMipMaps, this._gl);
|
|
@@ -18379,7 +18409,7 @@ var BABYLON;
|
|
Object.defineProperty(Scene.prototype, "gamepadManager", {
|
|
Object.defineProperty(Scene.prototype, "gamepadManager", {
|
|
get: function () {
|
|
get: function () {
|
|
if (!this._gamepadManager) {
|
|
if (!this._gamepadManager) {
|
|
- this._gamepadManager = new BABYLON.GamepadManager();
|
|
|
|
|
|
+ this._gamepadManager = new BABYLON.GamepadManager(this);
|
|
}
|
|
}
|
|
return this._gamepadManager;
|
|
return this._gamepadManager;
|
|
},
|
|
},
|
|
@@ -20676,6 +20706,10 @@ var BABYLON;
|
|
this.onAfterPhysicsObservable.notifyObservers(this);
|
|
this.onAfterPhysicsObservable.notifyObservers(this);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // update gamepad manager
|
|
|
|
+ if (this._gamepadManager && this._gamepadManager._isMonitoring) {
|
|
|
|
+ this._gamepadManager._checkGamepadsStatus();
|
|
|
|
+ }
|
|
// Before render
|
|
// Before render
|
|
this.onBeforeRenderObservable.notifyObservers(this);
|
|
this.onBeforeRenderObservable.notifyObservers(this);
|
|
// Customs render targets
|
|
// Customs render targets
|
|
@@ -23669,10 +23703,13 @@ var BABYLON;
|
|
* Returns the Mesh.
|
|
* Returns the Mesh.
|
|
*/
|
|
*/
|
|
Mesh.prototype.refreshBoundingInfo = function () {
|
|
Mesh.prototype.refreshBoundingInfo = function () {
|
|
|
|
+ return this._refreshBoundingInfo(false);
|
|
|
|
+ };
|
|
|
|
+ Mesh.prototype._refreshBoundingInfo = function (applySkeleton) {
|
|
if (this._boundingInfo && this._boundingInfo.isLocked) {
|
|
if (this._boundingInfo && this._boundingInfo.isLocked) {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
- var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
|
|
|
|
|
|
+ var data = this._getPositionData(applySkeleton);
|
|
if (data) {
|
|
if (data) {
|
|
var extend = BABYLON.Tools.ExtractMinAndMax(data, 0, this.getTotalVertices());
|
|
var extend = BABYLON.Tools.ExtractMinAndMax(data, 0, this.getTotalVertices());
|
|
this._boundingInfo = new BABYLON.BoundingInfo(extend.minimum, extend.maximum);
|
|
this._boundingInfo = new BABYLON.BoundingInfo(extend.minimum, extend.maximum);
|
|
@@ -23685,6 +23722,48 @@ var BABYLON;
|
|
this._updateBoundingInfo();
|
|
this._updateBoundingInfo();
|
|
return this;
|
|
return this;
|
|
};
|
|
};
|
|
|
|
+ Mesh.prototype._getPositionData = function (applySkeleton) {
|
|
|
|
+ var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
|
|
|
|
+ if (data && applySkeleton && this.skeleton) {
|
|
|
|
+ data = data.slice();
|
|
|
|
+ var matricesIndicesData = this.getVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind);
|
|
|
|
+ var matricesWeightsData = this.getVerticesData(BABYLON.VertexBuffer.MatricesWeightsKind);
|
|
|
|
+ if (matricesWeightsData && matricesIndicesData) {
|
|
|
|
+ var needExtras = this.numBoneInfluencers > 4;
|
|
|
|
+ var matricesIndicesExtraData = needExtras ? this.getVerticesData(BABYLON.VertexBuffer.MatricesIndicesExtraKind) : null;
|
|
|
|
+ var matricesWeightsExtraData = needExtras ? this.getVerticesData(BABYLON.VertexBuffer.MatricesWeightsExtraKind) : null;
|
|
|
|
+ var skeletonMatrices = this.skeleton.getTransformMatrices(this);
|
|
|
|
+ var tempVector = BABYLON.Tmp.Vector3[0];
|
|
|
|
+ var finalMatrix = BABYLON.Tmp.Matrix[0];
|
|
|
|
+ var tempMatrix = BABYLON.Tmp.Matrix[1];
|
|
|
|
+ var matWeightIdx = 0;
|
|
|
|
+ for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
|
|
|
|
+ finalMatrix.reset();
|
|
|
|
+ var inf;
|
|
|
|
+ var weight;
|
|
|
|
+ for (inf = 0; inf < 4; inf++) {
|
|
|
|
+ weight = matricesWeightsData[matWeightIdx + inf];
|
|
|
|
+ if (weight <= 0)
|
|
|
|
+ break;
|
|
|
|
+ BABYLON.Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesData[matWeightIdx + inf] * 16, weight, tempMatrix);
|
|
|
|
+ finalMatrix.addToSelf(tempMatrix);
|
|
|
|
+ }
|
|
|
|
+ if (needExtras) {
|
|
|
|
+ for (inf = 0; inf < 4; inf++) {
|
|
|
|
+ weight = matricesWeightsExtraData[matWeightIdx + inf];
|
|
|
|
+ if (weight <= 0)
|
|
|
|
+ break;
|
|
|
|
+ BABYLON.Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, matricesIndicesExtraData[matWeightIdx + inf] * 16, weight, tempMatrix);
|
|
|
|
+ finalMatrix.addToSelf(tempMatrix);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ BABYLON.Vector3.TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
|
|
|
|
+ tempVector.toArray(data, index);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return data;
|
|
|
|
+ };
|
|
Mesh.prototype._createGlobalSubMesh = function (force) {
|
|
Mesh.prototype._createGlobalSubMesh = function (force) {
|
|
var totalVertices = this.getTotalVertices();
|
|
var totalVertices = this.getTotalVertices();
|
|
if (!totalVertices || !this.getIndices()) {
|
|
if (!totalVertices || !this.getIndices()) {
|
|
@@ -25802,9 +25881,6 @@ var BABYLON;
|
|
var needExtras = this.numBoneInfluencers > 4;
|
|
var needExtras = this.numBoneInfluencers > 4;
|
|
var matricesIndicesExtraData = needExtras ? this.getVerticesData(BABYLON.VertexBuffer.MatricesIndicesExtraKind) : null;
|
|
var matricesIndicesExtraData = needExtras ? this.getVerticesData(BABYLON.VertexBuffer.MatricesIndicesExtraKind) : null;
|
|
var matricesWeightsExtraData = needExtras ? this.getVerticesData(BABYLON.VertexBuffer.MatricesWeightsExtraKind) : null;
|
|
var matricesWeightsExtraData = needExtras ? this.getVerticesData(BABYLON.VertexBuffer.MatricesWeightsExtraKind) : null;
|
|
- if (!matricesWeightsExtraData || !matricesIndicesExtraData) {
|
|
|
|
- return this;
|
|
|
|
- }
|
|
|
|
var skeletonMatrices = skeleton.getTransformMatrices(this);
|
|
var skeletonMatrices = skeleton.getTransformMatrices(this);
|
|
var tempVector3 = BABYLON.Vector3.Zero();
|
|
var tempVector3 = BABYLON.Vector3.Zero();
|
|
var finalMatrix = new BABYLON.Matrix();
|
|
var finalMatrix = new BABYLON.Matrix();
|
|
@@ -35694,12 +35770,12 @@ var BABYLON;
|
|
* This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
|
|
* This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
|
|
* makes the reflect vector face the model (under horizon).
|
|
* makes the reflect vector face the model (under horizon).
|
|
*/
|
|
*/
|
|
- _this._useHorizonOcclusion = false; // USEHORIZONOCCLUSION
|
|
|
|
|
|
+ _this._useHorizonOcclusion = true;
|
|
/**
|
|
/**
|
|
* This parameters will enable/disable radiance occlusion by preventing the radiance to lit
|
|
* This parameters will enable/disable radiance occlusion by preventing the radiance to lit
|
|
* too much the area relying on ambient texture to define their ambient occlusion.
|
|
* too much the area relying on ambient texture to define their ambient occlusion.
|
|
*/
|
|
*/
|
|
- _this._useRadianceOcclusion = false;
|
|
|
|
|
|
+ _this._useRadianceOcclusion = true;
|
|
/**
|
|
/**
|
|
* Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
|
|
* Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
|
|
*/
|
|
*/
|
|
@@ -37098,12 +37174,12 @@ var BABYLON;
|
|
* This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
|
|
* This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
|
|
* makes the reflect vector face the model (under horizon).
|
|
* makes the reflect vector face the model (under horizon).
|
|
*/
|
|
*/
|
|
- _this.useHorizonOcclusion = false;
|
|
|
|
|
|
+ _this.useHorizonOcclusion = true;
|
|
/**
|
|
/**
|
|
* This parameters will enable/disable radiance occlusion by preventing the radiance to lit
|
|
* This parameters will enable/disable radiance occlusion by preventing the radiance to lit
|
|
* too much the area relying on ambient texture to define their ambient occlusion.
|
|
* too much the area relying on ambient texture to define their ambient occlusion.
|
|
*/
|
|
*/
|
|
- _this.useRadianceOcclusion = false;
|
|
|
|
|
|
+ _this.useRadianceOcclusion = true;
|
|
_this._environmentBRDFTexture = BABYLON.TextureTools.GetEnvironmentBRDFTexture(scene);
|
|
_this._environmentBRDFTexture = BABYLON.TextureTools.GetEnvironmentBRDFTexture(scene);
|
|
return _this;
|
|
return _this;
|
|
}
|
|
}
|
|
@@ -51566,14 +51642,15 @@ var BABYLON;
|
|
(function (BABYLON) {
|
|
(function (BABYLON) {
|
|
var RawTexture = /** @class */ (function (_super) {
|
|
var RawTexture = /** @class */ (function (_super) {
|
|
__extends(RawTexture, _super);
|
|
__extends(RawTexture, _super);
|
|
- function RawTexture(data, width, height, format, scene, generateMipMaps, invertY, samplingMode) {
|
|
|
|
|
|
+ function RawTexture(data, width, height, format, scene, generateMipMaps, invertY, samplingMode, type) {
|
|
if (generateMipMaps === void 0) { generateMipMaps = true; }
|
|
if (generateMipMaps === void 0) { generateMipMaps = true; }
|
|
if (invertY === void 0) { invertY = false; }
|
|
if (invertY === void 0) { invertY = false; }
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
|
|
+ if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
|
|
var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
|
|
var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
|
|
_this.format = format;
|
|
_this.format = format;
|
|
_this._engine = scene.getEngine();
|
|
_this._engine = scene.getEngine();
|
|
- _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode);
|
|
|
|
|
|
+ _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
|
|
_this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
|
|
_this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
|
|
_this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
|
|
_this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
|
|
return _this;
|
|
return _this;
|
|
@@ -51600,17 +51677,19 @@ var BABYLON;
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
|
|
return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
|
|
};
|
|
};
|
|
- RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
|
|
|
|
|
|
+ RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
|
|
if (generateMipMaps === void 0) { generateMipMaps = true; }
|
|
if (generateMipMaps === void 0) { generateMipMaps = true; }
|
|
if (invertY === void 0) { invertY = false; }
|
|
if (invertY === void 0) { invertY = false; }
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
- return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode);
|
|
|
|
|
|
+ if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
|
|
|
|
+ return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
|
|
};
|
|
};
|
|
- RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
|
|
|
|
|
|
+ RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
|
|
if (generateMipMaps === void 0) { generateMipMaps = true; }
|
|
if (generateMipMaps === void 0) { generateMipMaps = true; }
|
|
if (invertY === void 0) { invertY = false; }
|
|
if (invertY === void 0) { invertY = false; }
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
|
|
- return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode);
|
|
|
|
|
|
+ if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
|
|
|
|
+ return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
|
|
};
|
|
};
|
|
return RawTexture;
|
|
return RawTexture;
|
|
}(BABYLON.Texture));
|
|
}(BABYLON.Texture));
|
|
@@ -56120,8 +56199,9 @@ var BABYLON;
|
|
var BABYLON;
|
|
var BABYLON;
|
|
(function (BABYLON) {
|
|
(function (BABYLON) {
|
|
var GamepadManager = /** @class */ (function () {
|
|
var GamepadManager = /** @class */ (function () {
|
|
- function GamepadManager() {
|
|
|
|
|
|
+ function GamepadManager(_scene) {
|
|
var _this = this;
|
|
var _this = this;
|
|
|
|
+ this._scene = _scene;
|
|
this._babylonGamepads = [];
|
|
this._babylonGamepads = [];
|
|
this._oneGamepadConnected = false;
|
|
this._oneGamepadConnected = false;
|
|
this._isMonitoring = false;
|
|
this._isMonitoring = false;
|
|
@@ -56248,7 +56328,10 @@ var BABYLON;
|
|
GamepadManager.prototype._startMonitoringGamepads = function () {
|
|
GamepadManager.prototype._startMonitoringGamepads = function () {
|
|
if (!this._isMonitoring) {
|
|
if (!this._isMonitoring) {
|
|
this._isMonitoring = true;
|
|
this._isMonitoring = true;
|
|
- this._checkGamepadsStatus();
|
|
|
|
|
|
+ //back-comp
|
|
|
|
+ if (!this._scene) {
|
|
|
|
+ this._checkGamepadsStatus();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
GamepadManager.prototype._stopMonitoringGamepads = function () {
|
|
GamepadManager.prototype._stopMonitoringGamepads = function () {
|
|
@@ -56265,7 +56348,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
gamepad.update();
|
|
gamepad.update();
|
|
}
|
|
}
|
|
- if (this._isMonitoring) {
|
|
|
|
|
|
+ if (this._isMonitoring && !this._scene) {
|
|
BABYLON.Tools.QueueNewFrame(function () { _this._checkGamepadsStatus(); });
|
|
BABYLON.Tools.QueueNewFrame(function () { _this._checkGamepadsStatus(); });
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -72141,57 +72224,77 @@ var BABYLON;
|
|
};
|
|
};
|
|
VRExperienceHelper.prototype._onNewGamepadConnected = function (gamepad) {
|
|
VRExperienceHelper.prototype._onNewGamepadConnected = function (gamepad) {
|
|
var _this = this;
|
|
var _this = this;
|
|
- if (gamepad.leftStick && gamepad.type !== BABYLON.Gamepad.POSE_ENABLED) {
|
|
|
|
- gamepad.onleftstickchanged(function (stickValues) {
|
|
|
|
- // Listening to classic/xbox gamepad only if no VR controller is active
|
|
|
|
- if ((!_this._leftLaserPointer && !_this._rightLaserPointer) ||
|
|
|
|
- ((_this._leftLaserPointer && !_this._leftLaserPointer.isVisible) &&
|
|
|
|
- (_this._rightLaserPointer && !_this._rightLaserPointer.isVisible))) {
|
|
|
|
- if (!_this._teleportationRequestInitiated) {
|
|
|
|
- if (stickValues.y < -_this._padSensibilityUp) {
|
|
|
|
- _this._teleportationRequestInitiated = true;
|
|
|
|
|
|
+ if (gamepad.type !== BABYLON.Gamepad.POSE_ENABLED) {
|
|
|
|
+ if (gamepad.leftStick) {
|
|
|
|
+ gamepad.onleftstickchanged(function (stickValues) {
|
|
|
|
+ // Listening to classic/xbox gamepad only if no VR controller is active
|
|
|
|
+ if ((!_this._leftLaserPointer && !_this._rightLaserPointer) ||
|
|
|
|
+ ((_this._leftLaserPointer && !_this._leftLaserPointer.isVisible) &&
|
|
|
|
+ (_this._rightLaserPointer && !_this._rightLaserPointer.isVisible))) {
|
|
|
|
+ if (!_this._teleportationRequestInitiated) {
|
|
|
|
+ if (stickValues.y < -_this._padSensibilityUp) {
|
|
|
|
+ _this._teleportationRequestInitiated = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if (stickValues.y > -_this._padSensibilityDown) {
|
|
|
|
+ if (_this._teleportationAllowed) {
|
|
|
|
+ _this._teleportCamera();
|
|
|
|
+ }
|
|
|
|
+ _this._teleportationRequestInitiated = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else {
|
|
|
|
- if (stickValues.y > -_this._padSensibilityDown) {
|
|
|
|
- if (_this._teleportationAllowed) {
|
|
|
|
- _this._teleportCamera();
|
|
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (gamepad.rightStick) {
|
|
|
|
+ gamepad.onrightstickchanged(function (stickValues) {
|
|
|
|
+ if (!_this._rotationLeftAsked) {
|
|
|
|
+ if (stickValues.x < -_this._padSensibilityUp) {
|
|
|
|
+ _this._rotationLeftAsked = true;
|
|
|
|
+ if (_this._rotationAllowed) {
|
|
|
|
+ _this._rotateCamera(false);
|
|
}
|
|
}
|
|
- _this._teleportationRequestInitiated = false;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- if (gamepad.rightStick) {
|
|
|
|
- gamepad.onrightstickchanged(function (stickValues) {
|
|
|
|
- if (!_this._rotationLeftAsked) {
|
|
|
|
- if (stickValues.x < -_this._padSensibilityUp) {
|
|
|
|
- _this._rotationLeftAsked = true;
|
|
|
|
- if (_this._rotationAllowed) {
|
|
|
|
- _this._rotateCamera(false);
|
|
|
|
|
|
+ else {
|
|
|
|
+ if (stickValues.x > -_this._padSensibilityDown) {
|
|
|
|
+ _this._rotationLeftAsked = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- else {
|
|
|
|
- if (stickValues.x > -_this._padSensibilityDown) {
|
|
|
|
- _this._rotationLeftAsked = false;
|
|
|
|
|
|
+ if (!_this._rotationRightAsked) {
|
|
|
|
+ if (stickValues.x > _this._padSensibilityUp) {
|
|
|
|
+ _this._rotationRightAsked = true;
|
|
|
|
+ if (_this._rotationAllowed) {
|
|
|
|
+ _this._rotateCamera(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (!_this._rotationRightAsked) {
|
|
|
|
- if (stickValues.x > _this._padSensibilityUp) {
|
|
|
|
- _this._rotationRightAsked = true;
|
|
|
|
- if (_this._rotationAllowed) {
|
|
|
|
- _this._rotateCamera(true);
|
|
|
|
|
|
+ else {
|
|
|
|
+ if (stickValues.x < _this._padSensibilityDown) {
|
|
|
|
+ _this._rotationRightAsked = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- else {
|
|
|
|
- if (stickValues.x < _this._padSensibilityDown) {
|
|
|
|
- _this._rotationRightAsked = false;
|
|
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (gamepad.type === BABYLON.Gamepad.XBOX) {
|
|
|
|
+ gamepad.onbuttondown(function (buttonPressed) {
|
|
|
|
+ if (buttonPressed === BABYLON.Xbox360Button.A) {
|
|
|
|
+ _this._pointerDownOnMeshAsked = true;
|
|
|
|
+ if (_this._currentMeshSelected && _this._currentHit) {
|
|
|
|
+ _this._scene.simulatePointerDown(_this._currentHit);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ });
|
|
|
|
+ gamepad.onbuttonup(function (buttonPressed) {
|
|
|
|
+ if (buttonPressed === BABYLON.Xbox360Button.A) {
|
|
|
|
+ if (_this._currentMeshSelected && _this._currentHit) {
|
|
|
|
+ _this._scene.simulatePointerUp(_this._currentHit);
|
|
|
|
+ }
|
|
|
|
+ _this._pointerDownOnMeshAsked = false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
VRExperienceHelper.prototype._enableTeleportationOnController = function (webVRController) {
|
|
VRExperienceHelper.prototype._enableTeleportationOnController = function (webVRController) {
|
|
@@ -72546,6 +72649,7 @@ var BABYLON;
|
|
var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
|
|
var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
|
|
// Moving the gazeTracker on the mesh face targetted
|
|
// Moving the gazeTracker on the mesh face targetted
|
|
if (hit && hit.pickedPoint) {
|
|
if (hit && hit.pickedPoint) {
|
|
|
|
+ this._gazeTracker.isVisible = true;
|
|
var multiplier = 1;
|
|
var multiplier = 1;
|
|
if (this._isActionableMesh) {
|
|
if (this._isActionableMesh) {
|
|
multiplier = 3;
|
|
multiplier = 3;
|
|
@@ -72590,8 +72694,14 @@ var BABYLON;
|
|
this._leftLaserPointer.position.z = -hit.distance / 2;
|
|
this._leftLaserPointer.position.z = -hit.distance / 2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ else {
|
|
|
|
+ this._gazeTracker.isVisible = false;
|
|
|
|
+ }
|
|
if (hit && hit.pickedMesh) {
|
|
if (hit && hit.pickedMesh) {
|
|
this._currentHit = hit;
|
|
this._currentHit = hit;
|
|
|
|
+ if (this._pointerDownOnMeshAsked) {
|
|
|
|
+ this._scene.simulatePointerMove(this._currentHit);
|
|
|
|
+ }
|
|
// The object selected is the floor, we're in a teleportation scenario
|
|
// The object selected is the floor, we're in a teleportation scenario
|
|
if (hit.pickedMesh.name.indexOf(this._floorMeshName) !== -1 && hit.pickedPoint) {
|
|
if (hit.pickedMesh.name.indexOf(this._floorMeshName) !== -1 && hit.pickedPoint) {
|
|
// Moving the teleportation area to this targetted point
|
|
// Moving the teleportation area to this targetted point
|
|
@@ -74690,6 +74800,10 @@ var BABYLON;
|
|
if (!material) {
|
|
if (!material) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ // Do not block in blend mode.
|
|
|
|
+ if (material.needAlphaBlendingForMesh(mesh)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
// Culling
|
|
// Culling
|
|
engine.setState(material.backFaceCulling);
|
|
engine.setState(material.backFaceCulling);
|
|
// Managing instances
|
|
// Managing instances
|
|
@@ -78848,6 +78962,9 @@ var BABYLON;
|
|
var groundSize = this._options.groundSize;
|
|
var groundSize = this._options.groundSize;
|
|
var skyboxSize = this._options.skyboxSize;
|
|
var skyboxSize = this._options.skyboxSize;
|
|
var rootPosition = this._options.rootPosition;
|
|
var rootPosition = this._options.rootPosition;
|
|
|
|
+ if (!this._scene.meshes || this._scene.meshes.length === 1) {
|
|
|
|
+ return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
|
|
|
|
+ }
|
|
var sceneExtends = this._scene.getWorldExtends();
|
|
var sceneExtends = this._scene.getWorldExtends();
|
|
var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
|
|
var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
|
|
var bias = 0.0001;
|
|
var bias = 0.0001;
|
|
@@ -81910,8 +82027,9 @@ var BABYLON;
|
|
switch (this._parent.coordinateSystemMode) {
|
|
switch (this._parent.coordinateSystemMode) {
|
|
case BABYLON.GLTFLoaderCoordinateSystemMode.AUTO: {
|
|
case BABYLON.GLTFLoaderCoordinateSystemMode.AUTO: {
|
|
if (!this._babylonScene.useRightHandedSystem) {
|
|
if (!this._babylonScene.useRightHandedSystem) {
|
|
- this._rootNode.babylonMesh.rotation = new BABYLON.Vector3(0, Math.PI, 0);
|
|
|
|
- this._rootNode.babylonMesh.scaling = new BABYLON.Vector3(1, 1, -1);
|
|
|
|
|
|
+ this._rootNode.rotation = [0, 1, 0, 0];
|
|
|
|
+ this._rootNode.scale = [1, 1, -1];
|
|
|
|
+ this._loadTransform(this._rootNode);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -81975,15 +82093,22 @@ var BABYLON;
|
|
}
|
|
}
|
|
this._loadMesh("#/meshes/" + node.mesh, node, mesh);
|
|
this._loadMesh("#/meshes/" + node.mesh, node, mesh);
|
|
}
|
|
}
|
|
- node.babylonMesh.parent = node.parent ? node.parent.babylonMesh : null;
|
|
|
|
|
|
+ node.babylonMesh.parent = node.parent.babylonMesh;
|
|
node.babylonAnimationTargets = node.babylonAnimationTargets || [];
|
|
node.babylonAnimationTargets = node.babylonAnimationTargets || [];
|
|
node.babylonAnimationTargets.push(node.babylonMesh);
|
|
node.babylonAnimationTargets.push(node.babylonMesh);
|
|
if (node.skin != null) {
|
|
if (node.skin != null) {
|
|
- var skin = GLTFLoader._GetProperty(this._gltf.skins, node.skin);
|
|
|
|
- if (!skin) {
|
|
|
|
|
|
+ var skin_1 = GLTFLoader._GetProperty(this._gltf.skins, node.skin);
|
|
|
|
+ if (!skin_1) {
|
|
throw new Error(context + ": Failed to find skin " + node.skin);
|
|
throw new Error(context + ": Failed to find skin " + node.skin);
|
|
}
|
|
}
|
|
- node.babylonMesh.skeleton = this._loadSkin("#/skins/" + node.skin, skin);
|
|
|
|
|
|
+ this._loadSkinAsync("#/skins/" + node.skin, skin_1, function () {
|
|
|
|
+ node.babylonMesh.skeleton = skin_1.babylonSkeleton;
|
|
|
|
+ node.babylonMesh._refreshBoundingInfo(true);
|
|
|
|
+ });
|
|
|
|
+ node.babylonMesh.parent = this._rootNode.babylonMesh;
|
|
|
|
+ node.babylonMesh.position = BABYLON.Vector3.Zero();
|
|
|
|
+ node.babylonMesh.rotationQuaternion = BABYLON.Quaternion.Identity();
|
|
|
|
+ node.babylonMesh.scaling = BABYLON.Vector3.One();
|
|
}
|
|
}
|
|
if (node.camera != null) {
|
|
if (node.camera != null) {
|
|
// TODO: handle cameras
|
|
// TODO: handle cameras
|
|
@@ -82377,15 +82502,17 @@ var BABYLON;
|
|
node.babylonMesh.rotationQuaternion = rotation;
|
|
node.babylonMesh.rotationQuaternion = rotation;
|
|
node.babylonMesh.scaling = scaling;
|
|
node.babylonMesh.scaling = scaling;
|
|
};
|
|
};
|
|
- GLTFLoader.prototype._loadSkin = function (context, skin) {
|
|
|
|
|
|
+ GLTFLoader.prototype._loadSkinAsync = function (context, skin, onSuccess) {
|
|
var _this = this;
|
|
var _this = this;
|
|
if (skin.babylonSkeleton) {
|
|
if (skin.babylonSkeleton) {
|
|
- return skin.babylonSkeleton;
|
|
|
|
|
|
+ onSuccess();
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
var skeletonId = "skeleton" + skin.index;
|
|
var skeletonId = "skeleton" + skin.index;
|
|
skin.babylonSkeleton = new BABYLON.Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene);
|
|
skin.babylonSkeleton = new BABYLON.Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene);
|
|
if (skin.inverseBindMatrices == null) {
|
|
if (skin.inverseBindMatrices == null) {
|
|
this._loadBones(context, skin, null);
|
|
this._loadBones(context, skin, null);
|
|
|
|
+ onSuccess();
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
var accessor = GLTFLoader._GetProperty(this._gltf.accessors, skin.inverseBindMatrices);
|
|
var accessor = GLTFLoader._GetProperty(this._gltf.accessors, skin.inverseBindMatrices);
|
|
@@ -82394,14 +82521,12 @@ var BABYLON;
|
|
}
|
|
}
|
|
this._loadAccessorAsync("#/accessors/" + accessor.index, accessor, function (data) {
|
|
this._loadAccessorAsync("#/accessors/" + accessor.index, accessor, function (data) {
|
|
_this._loadBones(context, skin, data);
|
|
_this._loadBones(context, skin, data);
|
|
|
|
+ onSuccess();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- return skin.babylonSkeleton;
|
|
|
|
};
|
|
};
|
|
GLTFLoader.prototype._createBone = function (node, skin, parent, localMatrix, baseMatrix, index) {
|
|
GLTFLoader.prototype._createBone = function (node, skin, parent, localMatrix, baseMatrix, index) {
|
|
var babylonBone = new BABYLON.Bone(node.name || "bone" + node.index, skin.babylonSkeleton, parent, localMatrix, null, baseMatrix, index);
|
|
var babylonBone = new BABYLON.Bone(node.name || "bone" + node.index, skin.babylonSkeleton, parent, localMatrix, null, baseMatrix, index);
|
|
- node.babylonBones = node.babylonBones || {};
|
|
|
|
- node.babylonBones[skin.index] = babylonBone;
|
|
|
|
node.babylonAnimationTargets = node.babylonAnimationTargets || [];
|
|
node.babylonAnimationTargets = node.babylonAnimationTargets || [];
|
|
node.babylonAnimationTargets.push(babylonBone);
|
|
node.babylonAnimationTargets.push(babylonBone);
|
|
return babylonBone;
|
|
return babylonBone;
|
|
@@ -82429,7 +82554,7 @@ var BABYLON;
|
|
baseMatrix.invertToRef(baseMatrix);
|
|
baseMatrix.invertToRef(baseMatrix);
|
|
}
|
|
}
|
|
var babylonParentBone = null;
|
|
var babylonParentBone = null;
|
|
- if (node.index !== skin.skeleton && node.parent && node.parent !== this._rootNode) {
|
|
|
|
|
|
+ if (node.parent !== this._rootNode) {
|
|
babylonParentBone = this._loadBone(node.parent, skin, inverseBindMatrixData, babylonBones);
|
|
babylonParentBone = this._loadBone(node.parent, skin, inverseBindMatrixData, babylonBones);
|
|
baseMatrix.multiplyToRef(babylonParentBone.getInvertedAbsoluteTransform(), baseMatrix);
|
|
baseMatrix.multiplyToRef(babylonParentBone.getInvertedAbsoluteTransform(), baseMatrix);
|
|
}
|
|
}
|
|
@@ -82443,7 +82568,6 @@ var BABYLON;
|
|
BABYLON.Matrix.Compose(node.scale ? BABYLON.Vector3.FromArray(node.scale) : BABYLON.Vector3.One(), node.rotation ? BABYLON.Quaternion.FromArray(node.rotation) : BABYLON.Quaternion.Identity(), node.translation ? BABYLON.Vector3.FromArray(node.translation) : BABYLON.Vector3.Zero());
|
|
BABYLON.Matrix.Compose(node.scale ? BABYLON.Vector3.FromArray(node.scale) : BABYLON.Vector3.One(), node.rotation ? BABYLON.Quaternion.FromArray(node.rotation) : BABYLON.Quaternion.Identity(), node.translation ? BABYLON.Vector3.FromArray(node.translation) : BABYLON.Vector3.Zero());
|
|
};
|
|
};
|
|
GLTFLoader.prototype._traverseNodes = function (context, indices, action, parentNode) {
|
|
GLTFLoader.prototype._traverseNodes = function (context, indices, action, parentNode) {
|
|
- if (parentNode === void 0) { parentNode = null; }
|
|
|
|
for (var _i = 0, indices_1 = indices; _i < indices_1.length; _i++) {
|
|
for (var _i = 0, indices_1 = indices; _i < indices_1.length; _i++) {
|
|
var index = indices_1[_i];
|
|
var index = indices_1[_i];
|
|
var node = GLTFLoader._GetProperty(this._gltf.nodes, index);
|
|
var node = GLTFLoader._GetProperty(this._gltf.nodes, index);
|
|
@@ -82454,7 +82578,6 @@ var BABYLON;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
GLTFLoader.prototype._traverseNode = function (context, node, action, parentNode) {
|
|
GLTFLoader.prototype._traverseNode = function (context, node, action, parentNode) {
|
|
- if (parentNode === void 0) { parentNode = null; }
|
|
|
|
if (GLTF2.GLTFLoaderExtension.TraverseNode(this, context, node, action, parentNode)) {
|
|
if (GLTF2.GLTFLoaderExtension.TraverseNode(this, context, node, action, parentNode)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|