@babylonjs/inspector 6.21.4 → 6.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57187,62 +57187,34 @@ __webpack_require__.r(__webpack_exports__);
|
|
57187
57187
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
57188
57188
|
/* harmony export */ TextureHelper: () => (/* binding */ TextureHelper)
|
57189
57189
|
/* harmony export */ });
|
57190
|
-
/* harmony import */ var
|
57191
|
-
/* harmony import */ var
|
57190
|
+
/* harmony import */ var core_Misc_textureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Misc/textureTools */ "core/Misc/observable");
|
57191
|
+
/* harmony import */ var core_Misc_textureTools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Misc_textureTools__WEBPACK_IMPORTED_MODULE_0__);
|
57192
57192
|
/* harmony import */ var _lod__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lod */ "../../../dev/inspector/dist/lod.js");
|
57193
57193
|
/* harmony import */ var _lodCube__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lodCube */ "../../../dev/inspector/dist/lodCube.js");
|
57194
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
57195
|
-
|
57196
|
-
|
57197
57194
|
|
57198
57195
|
|
57199
57196
|
|
57197
|
+
/**
|
57198
|
+
* Helper class for retrieving texture data.
|
57199
|
+
*/
|
57200
57200
|
class TextureHelper {
|
57201
|
-
|
57202
|
-
|
57203
|
-
|
57204
|
-
|
57205
|
-
|
57206
|
-
|
57207
|
-
|
57208
|
-
|
57209
|
-
|
57210
|
-
|
57211
|
-
|
57212
|
-
|
57213
|
-
// Try again later
|
57214
|
-
lodPostProcess.dispose();
|
57215
|
-
setTimeout(() => {
|
57216
|
-
this._ProcessAsync(texture, width, height, face, channels, lod, globalState, resolve, reject);
|
57217
|
-
}, 250);
|
57218
|
-
return;
|
57219
|
-
}
|
57201
|
+
/**
|
57202
|
+
* Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.
|
57203
|
+
* This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.
|
57204
|
+
* @param texture the source texture
|
57205
|
+
* @param width the width of the result, which does not have to match the source texture width
|
57206
|
+
* @param height the height of the result, which does not have to match the source texture height
|
57207
|
+
* @param face if the texture has multiple faces, the face index to use for the source
|
57208
|
+
* @param channels a filter for which of the RGBA channels to return in the result
|
57209
|
+
* @param lod if the texture has multiple LODs, the lod index to use for the source
|
57210
|
+
* @returns the 8-bit texture data
|
57211
|
+
*/
|
57212
|
+
static async GetTextureDataAsync(texture, width, height, face, channels, globalState, lod = 0) {
|
57220
57213
|
if (globalState) {
|
57221
57214
|
globalState.blockMutationUpdates = true;
|
57222
57215
|
}
|
57223
|
-
|
57224
|
-
|
57225
|
-
effect.setTexture("textureSampler", texture);
|
57226
|
-
effect.setFloat("lod", lod);
|
57227
|
-
effect.setBool("gamma", texture.gammaSpace);
|
57228
|
-
};
|
57229
|
-
const internalTexture = texture.getInternalTexture();
|
57230
|
-
if (rtt.renderTarget && internalTexture) {
|
57231
|
-
const samplingMode = internalTexture.samplingMode;
|
57232
|
-
if (lod !== 0) {
|
57233
|
-
texture.updateSamplingMode(core_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST);
|
57234
|
-
}
|
57235
|
-
else {
|
57236
|
-
texture.updateSamplingMode(core_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST);
|
57237
|
-
}
|
57238
|
-
scene.postProcessManager.directRender([lodPostProcess], rtt.renderTarget, true);
|
57239
|
-
texture.updateSamplingMode(samplingMode);
|
57240
|
-
// Read the contents of the framebuffer
|
57241
|
-
const numberOfChannelsByLine = width * 4;
|
57242
|
-
const halfHeight = height / 2;
|
57243
|
-
//Reading datas from WebGL
|
57244
|
-
const bufferView = await engine.readPixels(0, 0, width, height);
|
57245
|
-
const data = new Uint8Array(bufferView.buffer, 0, bufferView.byteLength);
|
57216
|
+
try {
|
57217
|
+
const data = await core_Misc_textureTools__WEBPACK_IMPORTED_MODULE_0__.TextureTools.GetTextureDataAsync(texture, width, height, face, lod);
|
57246
57218
|
if (!channels.R || !channels.G || !channels.B || !channels.A) {
|
57247
57219
|
for (let i = 0; i < width * height * 4; i += 4) {
|
57248
57220
|
// If alpha is the only channel, just display alpha across all channels
|
@@ -57300,6 +57272,8 @@ class TextureHelper {
|
|
57300
57272
|
}
|
57301
57273
|
//To flip image on Y axis.
|
57302
57274
|
if (texture.invertY || texture.isCube) {
|
57275
|
+
const numberOfChannelsByLine = width * 4;
|
57276
|
+
const halfHeight = height / 2;
|
57303
57277
|
for (let i = 0; i < halfHeight; i++) {
|
57304
57278
|
for (let j = 0; j < numberOfChannelsByLine; j++) {
|
57305
57279
|
const currentCell = j + i * numberOfChannelsByLine;
|
@@ -57311,29 +57285,13 @@ class TextureHelper {
|
|
57311
57285
|
}
|
57312
57286
|
}
|
57313
57287
|
}
|
57314
|
-
|
57315
|
-
// Unbind
|
57316
|
-
engine.unBindFramebuffer(rtt.renderTarget);
|
57288
|
+
return data;
|
57317
57289
|
}
|
57318
|
-
|
57319
|
-
|
57320
|
-
|
57321
|
-
rtt.dispose();
|
57322
|
-
lodPostProcess.dispose();
|
57323
|
-
if (globalState) {
|
57324
|
-
globalState.blockMutationUpdates = false;
|
57325
|
-
}
|
57326
|
-
}
|
57327
|
-
static GetTextureDataAsync(texture, width, height, face, channels, globalState, lod = 0) {
|
57328
|
-
return new Promise((resolve, reject) => {
|
57329
|
-
if (!texture.isReady() && texture._texture) {
|
57330
|
-
texture._texture.onLoadedObservable.addOnce(() => {
|
57331
|
-
this._ProcessAsync(texture, width, height, face, channels, lod, globalState || null, resolve, reject);
|
57332
|
-
});
|
57333
|
-
return;
|
57290
|
+
finally {
|
57291
|
+
if (globalState) {
|
57292
|
+
globalState.blockMutationUpdates = false;
|
57334
57293
|
}
|
57335
|
-
|
57336
|
-
});
|
57294
|
+
}
|
57337
57295
|
}
|
57338
57296
|
}
|
57339
57297
|
|