|
@@ -31365,6 +31365,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
/* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
|
|
|
/* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
|
|
|
/* harmony import */ var _Misc_fileTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/fileTools */ "./Misc/fileTools.ts");
|
|
|
+/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../constants */ "./Engines/constants.ts");
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -31453,15 +31455,16 @@ _Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype._partia
|
|
|
scene._addPendingData(img);
|
|
|
}
|
|
|
};
|
|
|
-_Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype._setCubeMapTextureParams = function (loadMipmap) {
|
|
|
+_Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype._setCubeMapTextureParams = function (texture, loadMipmap) {
|
|
|
var gl = this._gl;
|
|
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
|
|
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
|
+ texture.samplingMode = loadMipmap ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_LINEAR_LINEAR;
|
|
|
this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
|
|
|
};
|
|
|
-_Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback) {
|
|
|
+_Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, loaderOptions) {
|
|
|
var _this = this;
|
|
|
if (onLoad === void 0) { onLoad = null; }
|
|
|
if (onError === void 0) { onError = null; }
|
|
@@ -31504,7 +31507,7 @@ _Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype.createC
|
|
|
else {
|
|
|
// fall back to the original url if the transformed url fails to load
|
|
|
_Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("Failed to load " + rootUrl + ", falling back to the " + originalRootUrl);
|
|
|
- _this.createCubeTexture(originalRootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, texture);
|
|
|
+ _this.createCubeTexture(originalRootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, texture, loaderOptions);
|
|
|
}
|
|
|
};
|
|
|
if (loader) {
|
|
@@ -31562,7 +31565,7 @@ _Engines_thinEngine__WEBPACK_IMPORTED_MODULE_1__["ThinEngine"].prototype.createC
|
|
|
if (!noMipmap) {
|
|
|
gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
|
|
|
}
|
|
|
- _this._setCubeMapTextureParams(!noMipmap);
|
|
|
+ _this._setCubeMapTextureParams(texture, !noMipmap);
|
|
|
texture.width = width;
|
|
|
texture.height = height;
|
|
|
texture.isReady = true;
|
|
@@ -38072,9 +38075,10 @@ var NativeEngine = /** @class */ (function (_super) {
|
|
|
* @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
|
|
|
* @param forcedExtension defines the extension to use to pick the right loader
|
|
|
* @param mimeType defines an optional mime type
|
|
|
+ * @param loaderOptions options to be passed to the loader
|
|
|
* @returns a InternalTexture for assignment back into BABYLON.Texture
|
|
|
*/
|
|
|
- NativeEngine.prototype.createTexture = function (url, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, mimeType) {
|
|
|
+ NativeEngine.prototype.createTexture = function (url, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, mimeType, loaderOptions) {
|
|
|
var _this = this;
|
|
|
if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
|
|
|
if (onLoad === void 0) { onLoad = null; }
|
|
@@ -38139,7 +38143,7 @@ var NativeEngine = /** @class */ (function (_super) {
|
|
|
else {
|
|
|
// fall back to the original url if the transformed url fails to load
|
|
|
_Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("Failed to load " + url + ", falling back to " + originalUrl);
|
|
|
- _this.createTexture(originalUrl, noMipmap, texture.invertY, scene, samplingMode, onLoad, onError, buffer, texture, format, forcedExtension, mimeType);
|
|
|
+ _this.createTexture(originalUrl, noMipmap, texture.invertY, scene, samplingMode, onLoad, onError, buffer, texture, format, forcedExtension, mimeType, loaderOptions);
|
|
|
}
|
|
|
};
|
|
|
// processing for non-image formats
|
|
@@ -41921,9 +41925,10 @@ var ThinEngine = /** @class */ (function () {
|
|
|
* @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
|
|
|
* @param forcedExtension defines the extension to use to pick the right loader
|
|
|
* @param mimeType defines an optional mime type
|
|
|
+ * @param loaderOptions options to be passed to the loader
|
|
|
* @returns a InternalTexture for assignment back into BABYLON.Texture
|
|
|
*/
|
|
|
- ThinEngine.prototype.createTexture = function (url, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, mimeType) {
|
|
|
+ ThinEngine.prototype.createTexture = function (url, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, mimeType, loaderOptions) {
|
|
|
var _this = this;
|
|
|
if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
|
|
|
if (onLoad === void 0) { onLoad = null; }
|
|
@@ -41993,7 +41998,7 @@ var ThinEngine = /** @class */ (function () {
|
|
|
else {
|
|
|
// fall back to the original url if the transformed url fails to load
|
|
|
_Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("Failed to load " + url + ", falling back to " + originalUrl);
|
|
|
- _this.createTexture(originalUrl, noMipmap, texture.invertY, scene, samplingMode, onLoad, onError, buffer, texture, format, forcedExtension, mimeType);
|
|
|
+ _this.createTexture(originalUrl, noMipmap, texture.invertY, scene, samplingMode, onLoad, onError, buffer, texture, format, forcedExtension, mimeType, loaderOptions);
|
|
|
}
|
|
|
};
|
|
|
// processing for non-image formats
|
|
@@ -42009,7 +42014,7 @@ var ThinEngine = /** @class */ (function () {
|
|
|
return false;
|
|
|
}, samplingMode);
|
|
|
}
|
|
|
- });
|
|
|
+ }, loaderOptions);
|
|
|
};
|
|
|
if (!buffer) {
|
|
|
this._loadFile(url, function (data) { return callback_1(new Uint8Array(data)); }, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
|
|
@@ -88877,7 +88882,7 @@ var _BasisTextureLoader = /** @class */ (function () {
|
|
|
_Misc_basis__WEBPACK_IMPORTED_MODULE_1__["BasisTools"].TranscodeAsync(data, transcodeConfig).then(function (result) {
|
|
|
var hasMipmap = result.fileInfo.images[0].levels.length > 1 && texture.generateMipMaps;
|
|
|
_Misc_basis__WEBPACK_IMPORTED_MODULE_1__["BasisTools"].LoadTextureFromTranscodeResult(texture, result);
|
|
|
- texture.getEngine()._setCubeMapTextureParams(hasMipmap);
|
|
|
+ texture.getEngine()._setCubeMapTextureParams(texture, hasMipmap);
|
|
|
texture.isReady = true;
|
|
|
texture.onLoadedObservable.notifyObservers(texture);
|
|
|
texture.onLoadedObservable.clear();
|
|
@@ -89005,7 +89010,7 @@ var _DDSTextureLoader = /** @class */ (function () {
|
|
|
engine.generateMipMapsForCubemap(texture, false);
|
|
|
}
|
|
|
}
|
|
|
- engine._setCubeMapTextureParams(loadMipmap);
|
|
|
+ engine._setCubeMapTextureParams(texture, loadMipmap);
|
|
|
texture.isReady = true;
|
|
|
texture.onLoadedObservable.notifyObservers(texture);
|
|
|
texture.onLoadedObservable.clear();
|
|
@@ -89213,7 +89218,7 @@ var _KTXTextureLoader = /** @class */ (function () {
|
|
|
ktx.uploadLevels(texture, texture.generateMipMaps);
|
|
|
texture.width = ktx.pixelWidth;
|
|
|
texture.height = ktx.pixelHeight;
|
|
|
- engine._setCubeMapTextureParams(loadMipmap);
|
|
|
+ engine._setCubeMapTextureParams(texture, loadMipmap);
|
|
|
texture.isReady = true;
|
|
|
texture.onLoadedObservable.notifyObservers(texture);
|
|
|
texture.onLoadedObservable.clear();
|
|
@@ -89227,7 +89232,7 @@ var _KTXTextureLoader = /** @class */ (function () {
|
|
|
* @param texture defines the BabylonJS internal texture
|
|
|
* @param callback defines the method to call once ready to upload
|
|
|
*/
|
|
|
- _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
|
|
|
+ _KTXTextureLoader.prototype.loadData = function (data, texture, callback, options) {
|
|
|
if (_Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"].IsValid(data)) {
|
|
|
// Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
|
|
|
texture._invertVScale = !texture.invertY;
|
|
@@ -89238,7 +89243,7 @@ var _KTXTextureLoader = /** @class */ (function () {
|
|
|
}
|
|
|
else if (_Misc_khronosTextureContainer2__WEBPACK_IMPORTED_MODULE_1__["KhronosTextureContainer2"].IsValid(data)) {
|
|
|
var ktx2 = new _Misc_khronosTextureContainer2__WEBPACK_IMPORTED_MODULE_1__["KhronosTextureContainer2"](texture.getEngine());
|
|
|
- ktx2.uploadAsync(data, texture).then(function () {
|
|
|
+ ktx2.uploadAsync(data, texture, options).then(function () {
|
|
|
callback(texture.width, texture.height, texture.generateMipMaps, true, function () { }, false);
|
|
|
}, function (error) {
|
|
|
_Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Failed to load KTX2 texture data: " + error.message);
|
|
@@ -92216,9 +92221,10 @@ var CubeTexture = /** @class */ (function (_super) {
|
|
|
* @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
|
|
|
* @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
|
|
|
* @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
|
|
|
+ * @param loaderOptions options to be passed to the loader
|
|
|
* @return the cube texture
|
|
|
*/
|
|
|
- function CubeTexture(rootUrl, sceneOrEngine, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
|
|
|
+ function CubeTexture(rootUrl, sceneOrEngine, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset, loaderOptions) {
|
|
|
if (extensions === void 0) { extensions = null; }
|
|
|
if (noMipmap === void 0) { noMipmap = false; }
|
|
|
if (files === void 0) { files = null; }
|
|
@@ -92258,6 +92264,7 @@ var CubeTexture = /** @class */ (function (_super) {
|
|
|
_this._extensions = extensions;
|
|
|
_this._files = files;
|
|
|
_this._forcedExtension = forcedExtension;
|
|
|
+ _this._loaderOptions = loaderOptions;
|
|
|
if (!rootUrl && !files) {
|
|
|
return _this;
|
|
|
}
|
|
@@ -92303,7 +92310,7 @@ var CubeTexture = /** @class */ (function (_super) {
|
|
|
_this._texture = _this._getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
|
|
|
}
|
|
|
else {
|
|
|
- _this._texture = _this._getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
|
|
|
+ _this._texture = _this._getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset, null, loaderOptions);
|
|
|
}
|
|
|
(_a = _this._texture) === null || _a === void 0 ? void 0 : _a.onLoadedObservable.add(function () { return _this.onLoadObservable.notifyObservers(_this); });
|
|
|
}
|
|
@@ -92459,7 +92466,7 @@ var CubeTexture = /** @class */ (function (_super) {
|
|
|
this._texture = this._getEngine().createPrefilteredCubeTexture(this.url, scene, 0.8, 0, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
|
|
|
}
|
|
|
else {
|
|
|
- this._texture = this._getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, null, this._format, forcedExtension);
|
|
|
+ this._texture = this._getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, null, this._format, forcedExtension, false, 0, 0, null, this._loaderOptions);
|
|
|
}
|
|
|
(_a = this._texture) === null || _a === void 0 ? void 0 : _a.onLoadedObservable.add(function () { return _this.onLoadObservable.notifyObservers(_this); });
|
|
|
}
|
|
@@ -96161,8 +96168,9 @@ var Texture = /** @class */ (function (_super) {
|
|
|
* @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
|
|
|
* @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
|
|
|
* @param mimeType defines an optional mime type information
|
|
|
+ * @param loaderOptions options to be passed to the loader
|
|
|
*/
|
|
|
- function Texture(url, sceneOrEngine, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format, mimeType) {
|
|
|
+ function Texture(url, sceneOrEngine, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format, mimeType, loaderOptions) {
|
|
|
if (noMipmap === void 0) { noMipmap = false; }
|
|
|
if (invertY === void 0) { invertY = true; }
|
|
|
if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
|
|
@@ -96274,6 +96282,7 @@ var Texture = /** @class */ (function (_super) {
|
|
|
_this._buffer = buffer;
|
|
|
_this._deleteBuffer = deleteBuffer;
|
|
|
_this._mimeType = mimeType;
|
|
|
+ _this._loaderOptions = loaderOptions;
|
|
|
if (format) {
|
|
|
_this._format = format;
|
|
|
}
|
|
@@ -96321,7 +96330,7 @@ var Texture = /** @class */ (function (_super) {
|
|
|
_this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
|
|
|
if (!_this._texture) {
|
|
|
if (!scene || !scene.useDelayedTextureLoading) {
|
|
|
- _this._texture = engine.createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format, null, mimeType);
|
|
|
+ _this._texture = engine.createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format, null, mimeType, loaderOptions);
|
|
|
if (deleteBuffer) {
|
|
|
_this._buffer = null;
|
|
|
}
|
|
@@ -96435,7 +96444,7 @@ var Texture = /** @class */ (function (_super) {
|
|
|
this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].DELAYLOADSTATE_LOADED;
|
|
|
this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
|
|
|
if (!this._texture) {
|
|
|
- this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format, null, this._mimeType);
|
|
|
+ this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format, null, this._mimeType, this._loaderOptions);
|
|
|
if (this._deleteBuffer) {
|
|
|
this._buffer = null;
|
|
|
}
|
|
@@ -139983,6 +139992,7 @@ _Engines_thinEngine__WEBPACK_IMPORTED_MODULE_8__["ThinEngine"].prototype.createP
|
|
|
glTextureFromLod.height = glTextureFromLod.width;
|
|
|
glTextureFromLod.isCube = true;
|
|
|
_this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
|
|
|
+ glTextureFromLod.samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_LINEAR_LINEAR;
|
|
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
@@ -142974,7 +142984,7 @@ var KhronosTextureContainer2 = /** @class */ (function () {
|
|
|
}
|
|
|
};
|
|
|
/** @hidden */
|
|
|
- KhronosTextureContainer2.prototype.uploadAsync = function (data, internalTexture) {
|
|
|
+ KhronosTextureContainer2.prototype.uploadAsync = function (data, internalTexture, options) {
|
|
|
var _this = this;
|
|
|
var caps = this._engine.getCaps();
|
|
|
var compressedTexturesCaps = {
|
|
@@ -143017,7 +143027,7 @@ var KhronosTextureContainer2 = /** @class */ (function () {
|
|
|
worker.addEventListener("error", onError);
|
|
|
worker.addEventListener("message", onMessage);
|
|
|
// note: we can't transfer the ownership of data.buffer because if using a fallback texture the data.buffer buffer will be used by the current thread
|
|
|
- worker.postMessage({ action: "decode", data: data, caps: compressedTexturesCaps } /*, [data.buffer]*/);
|
|
|
+ worker.postMessage({ action: "decode", data: data, caps: compressedTexturesCaps, options: options } /*, [data.buffer]*/);
|
|
|
});
|
|
|
});
|
|
|
});
|
|
@@ -143045,7 +143055,7 @@ var KhronosTextureContainer2 = /** @class */ (function () {
|
|
|
}
|
|
|
delete KhronosTextureContainer2._WorkerPoolPromise;
|
|
|
};
|
|
|
- KhronosTextureContainer2.prototype._createTexture = function (data /* IEncodedData */, internalTexture) {
|
|
|
+ KhronosTextureContainer2.prototype._createTexture = function (data /* IDecodedData */, internalTexture) {
|
|
|
this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D, internalTexture);
|
|
|
if (data.transcodedFormat === 0x8058 /* RGBA8 */) {
|
|
|
internalTexture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
|
|
@@ -143144,7 +143154,7 @@ function workerFunc() {
|
|
|
postMessage({ action: "init" });
|
|
|
break;
|
|
|
case "decode":
|
|
|
- ktx2Decoder.decode(event.data.data, event.data.caps).then(function (data) {
|
|
|
+ ktx2Decoder.decode(event.data.data, event.data.caps, event.data.options).then(function (data) {
|
|
|
var buffers = [];
|
|
|
for (var mip = 0; mip < data.mipmaps.length; ++mip) {
|
|
|
var mipmap = data.mipmaps[mip];
|