|
@@ -15450,7 +15450,7 @@ var BABYLON;
|
|
|
this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
|
|
|
};
|
|
|
/** @hidden */
|
|
|
- Engine.prototype._uploadDataToTextureDirectly = function (texture, width, height, imageData, faceIndex, lod) {
|
|
|
+ Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
|
|
|
if (faceIndex === void 0) { faceIndex = 0; }
|
|
|
if (lod === void 0) { lod = 0; }
|
|
|
var gl = this._gl;
|
|
@@ -15462,6 +15462,10 @@ var BABYLON;
|
|
|
if (texture.isCube) {
|
|
|
target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
|
|
|
}
|
|
|
+ var lodMaxWidth = Math.round(BABYLON.Scalar.Log2(texture.width));
|
|
|
+ var lodMaxHeight = Math.round(BABYLON.Scalar.Log2(texture.height));
|
|
|
+ var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
|
|
|
+ var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
|
|
|
gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
|
|
|
};
|
|
|
/** @hidden */
|
|
@@ -15471,7 +15475,7 @@ var BABYLON;
|
|
|
var gl = this._gl;
|
|
|
var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
|
|
|
this._bindTextureDirectly(bindTarget, texture, true);
|
|
|
- this._uploadDataToTextureDirectly(texture, texture.width, texture.height, imageData, faceIndex, lod);
|
|
|
+ this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
|
|
|
this._bindTextureDirectly(bindTarget, null, true);
|
|
|
};
|
|
|
/** @hidden */
|
|
@@ -15740,6 +15744,9 @@ var BABYLON;
|
|
|
for (var index = 0; index < imgs.length; index++) {
|
|
|
var data = imgs[index];
|
|
|
info = BABYLON.DDSTools.GetDDSInfo(data);
|
|
|
+ texture.width = info.width;
|
|
|
+ texture.height = info.height;
|
|
|
+ width = info.width;
|
|
|
loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap;
|
|
|
_this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
|
|
|
_this._unpackFlipY(info.isCompressed);
|
|
@@ -15747,10 +15754,6 @@ var BABYLON;
|
|
|
if (!noMipmap && !info.isFourCC && info.mipmapCount === 1) {
|
|
|
gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
|
|
|
}
|
|
|
- texture.width = info.width;
|
|
|
- texture.height = info.height;
|
|
|
- texture.type = info.textureType;
|
|
|
- width = info.width;
|
|
|
}
|
|
|
_this.setCubeMapTextureParams(gl, loadMipmap);
|
|
|
texture.isReady = true;
|
|
@@ -15762,6 +15765,8 @@ var BABYLON;
|
|
|
else {
|
|
|
this._loadFile(rootUrl, function (data) {
|
|
|
var info = BABYLON.DDSTools.GetDDSInfo(data);
|
|
|
+ texture.width = info.width;
|
|
|
+ texture.height = info.height;
|
|
|
if (createPolynomials) {
|
|
|
info.sphericalPolynomial = new BABYLON.SphericalPolynomial();
|
|
|
}
|
|
@@ -15773,10 +15778,7 @@ var BABYLON;
|
|
|
gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
|
|
|
}
|
|
|
_this.setCubeMapTextureParams(gl, loadMipmap);
|
|
|
- texture.width = info.width;
|
|
|
- texture.height = info.height;
|
|
|
texture.isReady = true;
|
|
|
- texture.type = info.textureType;
|
|
|
if (onLoad) {
|
|
|
onLoad({ isDDS: true, width: info.width, info: info, data: data, texture: texture });
|
|
|
}
|
|
@@ -18239,6 +18241,19 @@ var BABYLON;
|
|
|
this.centerWorld = BABYLON.Vector3.Zero();
|
|
|
this._update(BABYLON.Matrix.Identity());
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Scale the current bounding sphere by applying a scale factor
|
|
|
+ * @param factor defines the scale factor to apply
|
|
|
+ * @returns the current bounding box
|
|
|
+ */
|
|
|
+ BoundingSphere.prototype.scale = function (factor) {
|
|
|
+ var newRadius = this.radius * factor;
|
|
|
+ var newRadiusVector = new BABYLON.Vector3(newRadius, newRadius, newRadius);
|
|
|
+ var min = this.center.subtract(newRadiusVector);
|
|
|
+ var max = this.center.add(newRadiusVector);
|
|
|
+ this.reConstruct(min, max);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
// Methods
|
|
|
BoundingSphere.prototype._update = function (world) {
|
|
|
BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
|
|
@@ -18329,6 +18344,21 @@ var BABYLON;
|
|
|
this.extendSizeWorld = BABYLON.Vector3.Zero();
|
|
|
this._update(this._worldMatrix || BABYLON.Matrix.Identity());
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Scale the current bounding box by applying a scale factor
|
|
|
+ * @param factor defines the scale factor to apply
|
|
|
+ * @returns the current bounding box
|
|
|
+ */
|
|
|
+ BoundingBox.prototype.scale = function (factor) {
|
|
|
+ var diff = this.maximum.subtract(this.minimum);
|
|
|
+ var distance = diff.length() * factor;
|
|
|
+ diff.normalize();
|
|
|
+ var newRadius = diff.scale(distance / 2);
|
|
|
+ var min = this.center.subtract(newRadius);
|
|
|
+ var max = this.center.add(newRadius);
|
|
|
+ this.reConstruct(min, max);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
BoundingBox.prototype.getWorldMatrix = function () {
|
|
|
return this._worldMatrix;
|
|
|
};
|
|
@@ -18499,6 +18529,16 @@ var BABYLON;
|
|
|
this.boundingSphere = new BABYLON.BoundingSphere(this.minimum, this.maximum);
|
|
|
return this;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Scale the current bounding info by applying a scale factor
|
|
|
+ * @param factor defines the scale factor to apply
|
|
|
+ * @returns the current bounding info
|
|
|
+ */
|
|
|
+ BoundingInfo.prototype.scale = function (factor) {
|
|
|
+ this.boundingBox.scale(factor);
|
|
|
+ this.boundingSphere.scale(factor);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
BoundingInfo.prototype.isInFrustum = function (frustumPlanes) {
|
|
|
if (!this.boundingSphere.isInFrustum(frustumPlanes))
|
|
|
return false;
|
|
@@ -65380,9 +65420,16 @@ var BABYLON;
|
|
|
var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
|
|
|
_this._onUserActionRequestedObservable = null;
|
|
|
_this._stillImageCaptured = false;
|
|
|
+ _this._poster = false;
|
|
|
_this._createInternalTexture = function () {
|
|
|
if (_this._texture != null) {
|
|
|
- return;
|
|
|
+ if (_this._poster) {
|
|
|
+ _this._texture.dispose();
|
|
|
+ _this._poster = false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
if (!_this._engine.needPOTTextures ||
|
|
|
(BABYLON.Tools.IsExponentOfTwo(_this.video.videoWidth) && BABYLON.Tools.IsExponentOfTwo(_this.video.videoHeight))) {
|
|
@@ -65443,8 +65490,10 @@ var BABYLON;
|
|
|
if (_this._texture == null) {
|
|
|
return;
|
|
|
}
|
|
|
- _this._texture.dispose();
|
|
|
- _this._texture = null;
|
|
|
+ if (!_this._poster) {
|
|
|
+ _this._texture.dispose();
|
|
|
+ _this._texture = null;
|
|
|
+ }
|
|
|
};
|
|
|
_this._updateInternalTexture = function (e) {
|
|
|
if (_this._texture == null || !_this._texture.isReady) {
|
|
@@ -65478,6 +65527,10 @@ var BABYLON;
|
|
|
if (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA) {
|
|
|
_this._createInternalTexture();
|
|
|
}
|
|
|
+ if (settings.poster) {
|
|
|
+ _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
|
|
|
+ _this._poster = true;
|
|
|
+ }
|
|
|
return _this;
|
|
|
}
|
|
|
Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
|
|
@@ -83363,6 +83416,8 @@ var BABYLON;
|
|
|
if (manifest.specular) {
|
|
|
// Extend the header with the position of the payload.
|
|
|
manifest.specular.specularDataPosition = pos;
|
|
|
+ // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
|
|
|
+ manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
|
|
|
}
|
|
|
return manifest;
|
|
|
};
|
|
@@ -83455,7 +83510,8 @@ var BABYLON;
|
|
|
width: cubeWidth,
|
|
|
irradiance: _this._CreateEnvTextureIrradiance(texture),
|
|
|
specular: {
|
|
|
- mipmaps: []
|
|
|
+ mipmaps: [],
|
|
|
+ lodGenerationScale: texture.lodGenerationScale
|
|
|
}
|
|
|
};
|
|
|
// Sets the specular image data information
|
|
@@ -83535,7 +83591,7 @@ var BABYLON;
|
|
|
*/
|
|
|
EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
|
|
|
if (info.version !== 1) {
|
|
|
- BABYLON.Tools.Warn('Unsupported babylon environment map version "' + info.version + '"');
|
|
|
+ throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
|
|
|
}
|
|
|
var specularInfo = info.specular;
|
|
|
if (!specularInfo) {
|
|
@@ -83546,8 +83602,9 @@ var BABYLON;
|
|
|
var mipmapsCount = BABYLON.Scalar.Log2(info.width);
|
|
|
mipmapsCount = Math.round(mipmapsCount) + 1;
|
|
|
if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
|
|
|
- BABYLON.Tools.Warn('Unsupported specular mipmaps number "' + specularInfo.mipmaps.length + '"');
|
|
|
+ throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
|
|
|
}
|
|
|
+ texture._lodGenerationScale = specularInfo.lodGenerationScale;
|
|
|
var imageData = new Array(mipmapsCount);
|
|
|
for (var i = 0; i < mipmapsCount; i++) {
|
|
|
imageData[i] = new Array(6);
|
|
@@ -83565,7 +83622,10 @@ var BABYLON;
|
|
|
* @returns a promise
|
|
|
*/
|
|
|
EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
|
|
|
- var mipmapsCount = imageData.length;
|
|
|
+ if (!BABYLON.Tools.IsExponentOfTwo(texture.width)) {
|
|
|
+ throw new Error("Texture size must be a power of two");
|
|
|
+ }
|
|
|
+ var mipmapsCount = Math.round(BABYLON.Scalar.Log2(texture.width)) + 1;
|
|
|
// Gets everything ready.
|
|
|
var engine = texture.getEngine();
|
|
|
var expandTexture = false;
|
|
@@ -83576,7 +83636,8 @@ var BABYLON;
|
|
|
var caps = engine.getCaps();
|
|
|
texture.format = BABYLON.Engine.TEXTUREFORMAT_RGBA;
|
|
|
texture.type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT;
|
|
|
- texture.samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
|
|
|
+ texture.generateMipMaps = true;
|
|
|
+ engine.updateTextureSamplingMode(BABYLON.Texture.TRILINEAR_SAMPLINGMODE, texture);
|
|
|
// Add extra process if texture lod is not supported
|
|
|
if (!caps.textureLOD) {
|
|
|
expandTexture = false;
|
|
@@ -83684,7 +83745,7 @@ var BABYLON;
|
|
|
}
|
|
|
else {
|
|
|
engine._uploadImageToTexture(texture, image, face, i);
|
|
|
- // Upload the face to the none lod texture support
|
|
|
+ // Upload the face to the non lod texture support
|
|
|
if (generateNonLODTextures) {
|
|
|
var lodTexture = lodTextures[i];
|
|
|
if (lodTexture) {
|
|
@@ -83705,18 +83766,43 @@ var BABYLON;
|
|
|
_loop_4(face);
|
|
|
}
|
|
|
};
|
|
|
- // All mipmaps
|
|
|
- for (var i = 0; i < mipmapsCount; i++) {
|
|
|
+ // All mipmaps up to provided number of images
|
|
|
+ for (var i = 0; i < imageData.length; i++) {
|
|
|
_loop_3(i);
|
|
|
}
|
|
|
+ // Fill remaining mipmaps with black textures.
|
|
|
+ if (imageData.length < mipmapsCount) {
|
|
|
+ var data = void 0;
|
|
|
+ var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
|
|
|
+ var dataLength = size * size * 4;
|
|
|
+ switch (texture.type) {
|
|
|
+ case BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT: {
|
|
|
+ data = new Uint8Array(dataLength);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case BABYLON.Engine.TEXTURETYPE_HALF_FLOAT: {
|
|
|
+ data = new Uint16Array(dataLength);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case BABYLON.Engine.TEXTURETYPE_FLOAT: {
|
|
|
+ data = new Float32Array(dataLength);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (var i = imageData.length; i < mipmapsCount; i++) {
|
|
|
+ for (var face = 0; face < 6; face++) {
|
|
|
+ engine._uploadArrayBufferViewToTexture(texture, data, face, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// Once all done, finishes the cleanup and return
|
|
|
return Promise.all(promises).then(function () {
|
|
|
- // Relase temp RTT.
|
|
|
+ // Release temp RTT.
|
|
|
if (cubeRtt) {
|
|
|
engine._releaseFramebufferObjects(cubeRtt);
|
|
|
cubeRtt._swapAndDie(texture);
|
|
|
}
|
|
|
- // Relase temp Post Process.
|
|
|
+ // Release temp Post Process.
|
|
|
if (rgbdPostProcess) {
|
|
|
rgbdPostProcess.dispose();
|
|
|
}
|
|
@@ -87820,7 +87906,7 @@ var BABYLON;
|
|
|
var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
|
|
|
var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
|
|
|
var engine = texture.getEngine();
|
|
|
- engine._uploadDataToTextureDirectly(texture, texture.width, texture.height, imageData);
|
|
|
+ engine._uploadDataToTextureDirectly(texture, imageData);
|
|
|
};
|
|
|
TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
|
|
|
var image = pixel_data, colormap = palettes;
|
|
@@ -88382,7 +88468,7 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
if (floatArray) {
|
|
|
- engine._uploadDataToTextureDirectly(texture, width, height, floatArray, face, i);
|
|
|
+ engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
|
|
|
}
|
|
|
}
|
|
|
else if (info.isRGB) {
|
|
@@ -88391,13 +88477,13 @@ var BABYLON;
|
|
|
texture.format = BABYLON.Engine.TEXTUREFORMAT_RGB;
|
|
|
dataLength = width * height * 3;
|
|
|
byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
|
|
|
- engine._uploadDataToTextureDirectly(texture, width, height, byteArray, face, i);
|
|
|
+ engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
|
|
|
}
|
|
|
else { // 32
|
|
|
texture.format = BABYLON.Engine.TEXTUREFORMAT_RGBA;
|
|
|
dataLength = width * height * 4;
|
|
|
byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
|
|
|
- engine._uploadDataToTextureDirectly(texture, width, height, byteArray, face, i);
|
|
|
+ engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
|
|
|
}
|
|
|
}
|
|
|
else if (info.isLuminance) {
|
|
@@ -88408,7 +88494,7 @@ var BABYLON;
|
|
|
byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
|
|
|
texture.format = BABYLON.Engine.TEXTUREFORMAT_LUMINANCE;
|
|
|
texture.type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT;
|
|
|
- engine._uploadDataToTextureDirectly(texture, width, height, byteArray, face, i);
|
|
|
+ engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
|
|
|
}
|
|
|
else {
|
|
|
dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
|
|
@@ -92827,6 +92913,11 @@ var BABYLON;
|
|
|
*/
|
|
|
_this.onControllerMeshLoadedObservable = new BABYLON.Observable();
|
|
|
/**
|
|
|
+ * Emits an event when the HMD's pose has been updated.
|
|
|
+ */
|
|
|
+ _this.onPoseUpdatedFromDeviceObservable = new BABYLON.Observable();
|
|
|
+ _this._poseSet = false;
|
|
|
+ /**
|
|
|
* If the rig cameras be used as parent instead of this camera.
|
|
|
*/
|
|
|
_this.rigParenting = true;
|
|
@@ -93053,6 +93144,7 @@ var BABYLON;
|
|
|
this._deviceRoomPosition.z *= -1;
|
|
|
}
|
|
|
}
|
|
|
+ this._poseSet = true;
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
@@ -93157,6 +93249,9 @@ var BABYLON;
|
|
|
BABYLON.Matrix.FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
|
|
|
this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
|
|
|
BABYLON.Quaternion.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
|
|
|
+ if (this._poseSet) {
|
|
|
+ this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
|
|
|
+ }
|
|
|
_super.prototype.update.call(this);
|
|
|
};
|
|
|
/**
|
|
@@ -101854,7 +101949,7 @@ var BABYLON;
|
|
|
if (lod === void 0) { lod = 0; }
|
|
|
};
|
|
|
/** @hidden */
|
|
|
- NullEngine.prototype._uploadDataToTextureDirectly = function (texture, width, height, imageData, faceIndex, lod) {
|
|
|
+ NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
|
|
|
if (faceIndex === void 0) { faceIndex = 0; }
|
|
|
if (lod === void 0) { lod = 0; }
|
|
|
};
|
|
@@ -113707,8 +113802,7 @@ var BABYLON;
|
|
|
}
|
|
|
this._loader._parent._logClose();
|
|
|
light._loaded = Promise.all(promises).then(function () {
|
|
|
- var size = Math.pow(2, imageData_1.length - 1);
|
|
|
- var babylonTexture = new BABYLON.RawCubeTexture(_this._loader._babylonScene, null, size);
|
|
|
+ var babylonTexture = new BABYLON.RawCubeTexture(_this._loader._babylonScene, null, light.specularImageSize);
|
|
|
light._babylonTexture = babylonTexture;
|
|
|
if (light.intensity != undefined) {
|
|
|
babylonTexture.level = light.intensity;
|
|
@@ -113725,7 +113819,9 @@ var BABYLON;
|
|
|
sphericalHarmonics.scale(light.intensity);
|
|
|
sphericalHarmonics.convertIrradianceToLambertianRadiance();
|
|
|
var sphericalPolynomial = BABYLON.SphericalPolynomial.FromHarmonics(sphericalHarmonics);
|
|
|
- return babylonTexture.updateRGBDAsync(imageData_1, sphericalPolynomial);
|
|
|
+ // Compute the lod generation scale to fit exactly to the number of levels available.
|
|
|
+ var lodGenerationScale = (imageData_1.length - 1) / BABYLON.Scalar.Log2(light.specularImageSize);
|
|
|
+ return babylonTexture.updateRGBDAsync(imageData_1, sphericalPolynomial, lodGenerationScale);
|
|
|
});
|
|
|
}
|
|
|
return light._loaded.then(function () {
|