@babylonjs/core 5.13.3 → 5.15.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.
Files changed (63) hide show
  1. package/Cameras/Inputs/BaseCameraMouseWheelInput.d.ts +1 -1
  2. package/Cameras/Inputs/BaseCameraMouseWheelInput.js +2 -9
  3. package/Cameras/Inputs/BaseCameraMouseWheelInput.js.map +1 -1
  4. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.d.ts +1 -0
  5. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +2 -9
  6. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  7. package/Cameras/Inputs/followCameraMouseWheelInput.d.ts +1 -0
  8. package/Cameras/Inputs/followCameraMouseWheelInput.js +2 -8
  9. package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
  10. package/Cameras/arcRotateCamera.js +5 -0
  11. package/Cameras/arcRotateCamera.js.map +1 -1
  12. package/Cameras/camera.d.ts +15 -5
  13. package/Cameras/camera.js +76 -20
  14. package/Cameras/camera.js.map +1 -1
  15. package/Cameras/targetCamera.js +5 -0
  16. package/Cameras/targetCamera.js.map +1 -1
  17. package/DeviceInput/InputDevices/deviceSourceManager.js +4 -0
  18. package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
  19. package/DeviceInput/InputDevices/internalDeviceSourceManager.d.ts +2 -1
  20. package/DeviceInput/InputDevices/internalDeviceSourceManager.js.map +1 -1
  21. package/DeviceInput/InputDevices/webDeviceInputSystem.js +1 -3
  22. package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
  23. package/Engines/thinEngine.d.ts +5 -1
  24. package/Engines/thinEngine.js +13 -7
  25. package/Engines/thinEngine.js.map +1 -1
  26. package/Legacy/legacy.js +10 -6
  27. package/Legacy/legacy.js.map +1 -1
  28. package/Materials/Node/Blocks/elbowBlock.js +5 -3
  29. package/Materials/Node/Blocks/elbowBlock.js.map +1 -1
  30. package/Materials/PBR/pbrClearCoatConfiguration.d.ts +1 -1
  31. package/Materials/PBR/pbrClearCoatConfiguration.js +1 -1
  32. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  33. package/Materials/PBR/pbrIridescenceConfiguration.d.ts +1 -1
  34. package/Materials/PBR/pbrIridescenceConfiguration.js +1 -1
  35. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  36. package/Materials/PBR/pbrSheenConfiguration.d.ts +1 -1
  37. package/Materials/PBR/pbrSheenConfiguration.js +1 -1
  38. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  39. package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +1 -1
  40. package/Materials/PBR/pbrSubSurfaceConfiguration.js +1 -1
  41. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  42. package/Materials/Textures/Loaders/basisTextureLoader.js +6 -1
  43. package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
  44. package/Maths/math.color.d.ts +15 -3
  45. package/Maths/math.color.js +26 -3
  46. package/Maths/math.color.js.map +1 -1
  47. package/Meshes/Builders/discBuilder.d.ts +26 -0
  48. package/Meshes/Builders/discBuilder.js +1 -1
  49. package/Meshes/Builders/discBuilder.js.map +1 -1
  50. package/Meshes/transformNode.d.ts +1 -1
  51. package/Meshes/transformNode.js +1 -1
  52. package/Meshes/transformNode.js.map +1 -1
  53. package/Misc/basis.d.ts +8 -0
  54. package/Misc/basis.js +74 -32
  55. package/Misc/basis.js.map +1 -1
  56. package/Misc/screenshotTools.js +3 -0
  57. package/Misc/screenshotTools.js.map +1 -1
  58. package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +0 -2
  59. package/PostProcesses/volumetricLightScatteringPostProcess.js +22 -15
  60. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  61. package/XR/webXREnterExitUI.js +1 -1
  62. package/XR/webXREnterExitUI.js.map +1 -1
  63. package/package.json +1 -1
package/Misc/basis.js CHANGED
@@ -35,13 +35,26 @@ export { BasisTranscodeConfiguration };
35
35
  var BASIS_FORMATS;
36
36
  (function (BASIS_FORMATS) {
37
37
  BASIS_FORMATS[BASIS_FORMATS["cTFETC1"] = 0] = "cTFETC1";
38
- BASIS_FORMATS[BASIS_FORMATS["cTFBC1"] = 1] = "cTFBC1";
39
- BASIS_FORMATS[BASIS_FORMATS["cTFBC4"] = 2] = "cTFBC4";
40
- BASIS_FORMATS[BASIS_FORMATS["cTFPVRTC1_4_OPAQUE_ONLY"] = 3] = "cTFPVRTC1_4_OPAQUE_ONLY";
41
- BASIS_FORMATS[BASIS_FORMATS["cTFBC7_M6_OPAQUE_ONLY"] = 4] = "cTFBC7_M6_OPAQUE_ONLY";
42
- BASIS_FORMATS[BASIS_FORMATS["cTFETC2"] = 5] = "cTFETC2";
43
- BASIS_FORMATS[BASIS_FORMATS["cTFBC3"] = 6] = "cTFBC3";
44
- BASIS_FORMATS[BASIS_FORMATS["cTFBC5"] = 7] = "cTFBC5";
38
+ BASIS_FORMATS[BASIS_FORMATS["cTFETC2"] = 1] = "cTFETC2";
39
+ BASIS_FORMATS[BASIS_FORMATS["cTFBC1"] = 2] = "cTFBC1";
40
+ BASIS_FORMATS[BASIS_FORMATS["cTFBC3"] = 3] = "cTFBC3";
41
+ BASIS_FORMATS[BASIS_FORMATS["cTFBC4"] = 4] = "cTFBC4";
42
+ BASIS_FORMATS[BASIS_FORMATS["cTFBC5"] = 5] = "cTFBC5";
43
+ BASIS_FORMATS[BASIS_FORMATS["cTFBC7"] = 6] = "cTFBC7";
44
+ BASIS_FORMATS[BASIS_FORMATS["cTFPVRTC1_4_RGB"] = 8] = "cTFPVRTC1_4_RGB";
45
+ BASIS_FORMATS[BASIS_FORMATS["cTFPVRTC1_4_RGBA"] = 9] = "cTFPVRTC1_4_RGBA";
46
+ BASIS_FORMATS[BASIS_FORMATS["cTFASTC_4x4"] = 10] = "cTFASTC_4x4";
47
+ BASIS_FORMATS[BASIS_FORMATS["cTFATC_RGB"] = 11] = "cTFATC_RGB";
48
+ BASIS_FORMATS[BASIS_FORMATS["cTFATC_RGBA_INTERPOLATED_ALPHA"] = 12] = "cTFATC_RGBA_INTERPOLATED_ALPHA";
49
+ BASIS_FORMATS[BASIS_FORMATS["cTFRGBA32"] = 13] = "cTFRGBA32";
50
+ BASIS_FORMATS[BASIS_FORMATS["cTFRGB565"] = 14] = "cTFRGB565";
51
+ BASIS_FORMATS[BASIS_FORMATS["cTFBGR565"] = 15] = "cTFBGR565";
52
+ BASIS_FORMATS[BASIS_FORMATS["cTFRGBA4444"] = 16] = "cTFRGBA4444";
53
+ BASIS_FORMATS[BASIS_FORMATS["cTFFXT1_RGB"] = 17] = "cTFFXT1_RGB";
54
+ BASIS_FORMATS[BASIS_FORMATS["cTFPVRTC2_4_RGB"] = 18] = "cTFPVRTC2_4_RGB";
55
+ BASIS_FORMATS[BASIS_FORMATS["cTFPVRTC2_4_RGBA"] = 19] = "cTFPVRTC2_4_RGBA";
56
+ BASIS_FORMATS[BASIS_FORMATS["cTFETC2_EAC_R11"] = 20] = "cTFETC2_EAC_R11";
57
+ BASIS_FORMATS[BASIS_FORMATS["cTFETC2_EAC_RG11"] = 21] = "cTFETC2_EAC_RG11";
45
58
  })(BASIS_FORMATS || (BASIS_FORMATS = {}));
46
59
  /**
47
60
  * Used to load .Basis files
@@ -51,11 +64,11 @@ export var BasisToolsOptions = {
51
64
  /**
52
65
  * URL to use when loading the basis transcoder
53
66
  */
54
- JSModuleURL: "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.js",
67
+ JSModuleURL: "https://cdn.babylonjs.com/basisTranscoder/1/basis_transcoder.js",
55
68
  /**
56
69
  * URL to use when loading the wasm module for the transcoder
57
70
  */
58
- WasmModuleURL: "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.wasm",
71
+ WasmModuleURL: "https://cdn.babylonjs.com/basisTranscoder/1/basis_transcoder.wasm",
59
72
  };
60
73
  /**
61
74
  * Get the internal format to be passed to texImage2D corresponding to the .basis format value
@@ -76,6 +89,15 @@ export var GetInternalFormatFromBasisFormat = function (basisFormat, engine) {
76
89
  case BASIS_FORMATS.cTFBC4:
77
90
  format = 33779;
78
91
  break;
92
+ case BASIS_FORMATS.cTFASTC_4x4:
93
+ format = 37808;
94
+ break;
95
+ case BASIS_FORMATS.cTFETC2:
96
+ format = 37496;
97
+ break;
98
+ case BASIS_FORMATS.cTFBC7:
99
+ format = 36492;
100
+ break;
79
101
  }
80
102
  if (format === undefined) {
81
103
  throw "The chosen Basis transcoder format is not currently supported";
@@ -243,21 +265,32 @@ export var BasisTools = {
243
265
  function workerFunc() {
244
266
  var _BASIS_FORMAT = {
245
267
  cTFETC1: 0,
246
- cTFBC1: 1,
247
- cTFBC4: 2,
248
- cTFPVRTC1_4_OPAQUE_ONLY: 3,
249
- cTFBC7_M6_OPAQUE_ONLY: 4,
250
- cTFETC2: 5,
251
- cTFBC3: 6,
252
- cTFBC5: 7,
268
+ cTFETC2: 1,
269
+ cTFBC1: 2,
270
+ cTFBC3: 3,
271
+ cTFBC4: 4,
272
+ cTFBC5: 5,
273
+ cTFBC7: 6,
274
+ cTFPVRTC1_4_RGB: 8,
275
+ cTFPVRTC1_4_RGBA: 9,
276
+ cTFASTC_4x4: 10,
277
+ cTFATC_RGB: 11,
278
+ cTFATC_RGBA_INTERPOLATED_ALPHA: 12,
279
+ cTFRGBA32: 13,
280
+ cTFRGB565: 14,
281
+ cTFBGR565: 15,
282
+ cTFRGBA4444: 16,
283
+ cTFFXT1_RGB: 17,
284
+ cTFPVRTC2_4_RGB: 18,
285
+ cTFPVRTC2_4_RGBA: 19,
286
+ cTFETC2_EAC_R11: 20,
287
+ cTFETC2_EAC_RG11: 21,
253
288
  };
254
289
  var transcoderModulePromise = null;
255
290
  onmessage = function (event) {
256
291
  if (event.data.action === "init") {
257
292
  // Load the transcoder if it hasn't been yet
258
293
  if (!transcoderModulePromise) {
259
- // Override wasm binary
260
- Module = { wasmBinary: event.data.wasmBinary };
261
294
  // make sure we loaded the script correctly
262
295
  try {
263
296
  importScripts(event.data.url);
@@ -265,22 +298,24 @@ function workerFunc() {
265
298
  catch (e) {
266
299
  postMessage({ action: "error", error: e });
267
300
  }
268
- transcoderModulePromise = new Promise(function (res) {
269
- Module.onRuntimeInitialized = function () {
270
- Module.initializeBasis();
271
- res();
272
- };
301
+ transcoderModulePromise = BASIS({
302
+ // Override wasm binary
303
+ wasmBinary: event.data.wasmBinary,
304
+ });
305
+ }
306
+ if (transcoderModulePromise !== null) {
307
+ transcoderModulePromise.then(function (m) {
308
+ BASIS = m;
309
+ m.initializeBasis();
310
+ postMessage({ action: "init" });
273
311
  });
274
312
  }
275
- transcoderModulePromise.then(function () {
276
- postMessage({ action: "init" });
277
- });
278
313
  }
279
314
  else if (event.data.action === "transcode") {
280
315
  // Transcode the basis image and return the resulting pixels
281
316
  var config = event.data.config;
282
317
  var imgData = event.data.imageData;
283
- var loadedFile = new Module.BasisFile(imgData);
318
+ var loadedFile = new BASIS.BasisFile(imgData);
284
319
  var fileInfo = GetFileInfo(loadedFile);
285
320
  var format = event.data.ignoreSupportedFormats ? null : GetSupportedTranscodeFormat(event.data.config, fileInfo);
286
321
  var needsConversion = false;
@@ -339,20 +374,27 @@ function workerFunc() {
339
374
  function GetSupportedTranscodeFormat(config, fileInfo) {
340
375
  var format = null;
341
376
  if (config.supportedCompressionFormats) {
342
- if (config.supportedCompressionFormats.etc1) {
343
- format = _BASIS_FORMAT.cTFETC1;
377
+ if (config.supportedCompressionFormats.astc) {
378
+ format = _BASIS_FORMAT.cTFASTC_4x4;
379
+ }
380
+ else if (config.supportedCompressionFormats.bc7) {
381
+ format = _BASIS_FORMAT.cTFBC7;
344
382
  }
345
383
  else if (config.supportedCompressionFormats.s3tc) {
346
384
  format = fileInfo.hasAlpha ? _BASIS_FORMAT.cTFBC3 : _BASIS_FORMAT.cTFBC1;
347
385
  }
348
386
  else if (config.supportedCompressionFormats.pvrtc) {
349
- // TODO uncomment this after pvrtc bug is fixed is basis transcoder
350
- // See discussion here: https://github.com/mrdoob/three.js/issues/16524#issuecomment-498929924
351
- // format = _BASIS_FORMAT.cTFPVRTC1_4_OPAQUE_ONLY;
387
+ format = fileInfo.hasAlpha ? _BASIS_FORMAT.cTFPVRTC1_4_RGBA : _BASIS_FORMAT.cTFPVRTC1_4_RGB;
352
388
  }
353
389
  else if (config.supportedCompressionFormats.etc2) {
354
390
  format = _BASIS_FORMAT.cTFETC2;
355
391
  }
392
+ else if (config.supportedCompressionFormats.etc1) {
393
+ format = _BASIS_FORMAT.cTFETC1;
394
+ }
395
+ else {
396
+ format = _BASIS_FORMAT.cTFRGB565;
397
+ }
356
398
  }
357
399
  return format;
358
400
  }
package/Misc/basis.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"basis.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/basis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD;;GAEG;AACH;IAAA;IASA,CAAC;IAAD,oBAAC;AAAD,CAAC,AATD,IASC;AAED;;GAEG;AACH;IAAA;IASA,CAAC;IAAD,sBAAC;AAAD,CAAC,AATD,IASC;AAED;;GAEG;AACH;IAAA;IA8BA,CAAC;IAAD,kCAAC;AAAD,CAAC,AA9BD,IA8BC;;AAED;;;GAGG;AACH,IAAK,aASJ;AATD,WAAK,aAAa;IACd,uDAAW,CAAA;IACX,qDAAU,CAAA;IACV,qDAAU,CAAA;IACV,uFAA2B,CAAA;IAC3B,mFAAyB,CAAA;IACzB,uDAAW,CAAA;IACX,qDAAU,CAAA;IACV,qDAAU,CAAA;AACd,C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AAC;IACD,GAAG,EAAE,UAAsB,KAAa;QACpC,iBAAiB,CAAC,aAAa,GAAG,KAAK,CAAC;IAC5C,CAAC;CACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport { Tools } from \"./tools\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { InternalTexture, InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport { Scalar } from \"../Maths/math.scalar\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\n/**\r\n * Info about the .basis files\r\n */\r\nclass BasisFileInfo {\r\n /**\r\n * If the file has alpha\r\n */\r\n public hasAlpha: boolean;\r\n /**\r\n * Info about each image of the basis file\r\n */\r\n public images: Array<{ levels: Array<{ width: number; height: number; transcodedPixels: ArrayBufferView }> }>;\r\n}\r\n\r\n/**\r\n * Result of transcoding a basis file\r\n */\r\nclass TranscodeResult {\r\n /**\r\n * Info about the .basis file\r\n */\r\n public fileInfo: BasisFileInfo;\r\n /**\r\n * Format to use when loading the file\r\n */\r\n public format: number;\r\n}\r\n\r\n/**\r\n * Configuration options for the Basis transcoder\r\n */\r\nexport class BasisTranscodeConfiguration {\r\n /**\r\n * Supported compression formats used to determine the supported output format of the transcoder\r\n */\r\n supportedCompressionFormats?: {\r\n /**\r\n * etc1 compression format\r\n */\r\n etc1?: boolean;\r\n /**\r\n * s3tc compression format\r\n */\r\n s3tc?: boolean;\r\n /**\r\n * pvrtc compression format\r\n */\r\n pvrtc?: boolean;\r\n /**\r\n * etc2 compression format\r\n */\r\n etc2?: boolean;\r\n };\r\n /**\r\n * If mipmap levels should be loaded for transcoded images (Default: true)\r\n */\r\n loadMipmapLevels?: boolean;\r\n /**\r\n * Index of a single image to load (Default: all images)\r\n */\r\n loadSingleImage?: number;\r\n}\r\n\r\n/**\r\n * @hidden\r\n * Enum of basis transcoder formats\r\n */\r\nenum BASIS_FORMATS {\r\n cTFETC1 = 0,\r\n cTFBC1 = 1,\r\n cTFBC4 = 2,\r\n cTFPVRTC1_4_OPAQUE_ONLY = 3,\r\n cTFBC7_M6_OPAQUE_ONLY = 4,\r\n cTFETC2 = 5,\r\n cTFBC3 = 6,\r\n cTFBC5 = 7,\r\n}\r\n\r\n/**\r\n * Used to load .Basis files\r\n * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl\r\n */\r\nexport const BasisToolsOptions = {\r\n /**\r\n * URL to use when loading the basis transcoder\r\n */\r\n JSModuleURL: \"https://preview.babylonjs.com/basisTranscoder/basis_transcoder.js\",\r\n /**\r\n * URL to use when loading the wasm module for the transcoder\r\n */\r\n WasmModuleURL: \"https://preview.babylonjs.com/basisTranscoder/basis_transcoder.wasm\",\r\n};\r\n\r\n/**\r\n * Get the internal format to be passed to texImage2D corresponding to the .basis format value\r\n * @param basisFormat format chosen from GetSupportedTranscodeFormat\r\n * @param engine\r\n * @returns internal format corresponding to the Basis format\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nexport const GetInternalFormatFromBasisFormat = (basisFormat: number, engine: Engine) => {\r\n let format;\r\n switch (basisFormat) {\r\n case BASIS_FORMATS.cTFETC1:\r\n format = Constants.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL;\r\n break;\r\n case BASIS_FORMATS.cTFBC1:\r\n format = Constants.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;\r\n break;\r\n case BASIS_FORMATS.cTFBC4:\r\n format = Constants.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;\r\n break;\r\n }\r\n\r\n if (format === undefined) {\r\n throw \"The chosen Basis transcoder format is not currently supported\";\r\n }\r\n\r\n return format;\r\n};\r\n\r\nlet _WorkerPromise: Nullable<Promise<Worker>> = null;\r\nlet _Worker: Nullable<Worker> = null;\r\nlet _actionId = 0;\r\nconst _IgnoreSupportedFormats = false;\r\nconst _CreateWorkerAsync = () => {\r\n if (!_WorkerPromise) {\r\n _WorkerPromise = new Promise((res, reject) => {\r\n if (_Worker) {\r\n res(_Worker);\r\n } else {\r\n Tools.LoadFileAsync(BasisToolsOptions.WasmModuleURL)\r\n .then((wasmBinary) => {\r\n const workerBlobUrl = URL.createObjectURL(new Blob([`(${workerFunc})()`], { type: \"application/javascript\" }));\r\n _Worker = new Worker(workerBlobUrl);\r\n\r\n const initHandler = (msg: any) => {\r\n if (msg.data.action === \"init\") {\r\n _Worker!.removeEventListener(\"message\", initHandler);\r\n res(_Worker!);\r\n } else if (msg.data.action === \"error\") {\r\n reject(msg.data.error || \"error initializing worker\");\r\n }\r\n };\r\n _Worker.addEventListener(\"message\", initHandler);\r\n _Worker.postMessage({ action: \"init\", url: BasisToolsOptions.JSModuleURL, wasmBinary: wasmBinary });\r\n })\r\n .catch(reject);\r\n }\r\n });\r\n }\r\n return _WorkerPromise;\r\n};\r\n\r\n/**\r\n * Transcodes a loaded image file to compressed pixel data\r\n * @param data image data to transcode\r\n * @param config configuration options for the transcoding\r\n * @returns a promise resulting in the transcoded image\r\n */\r\nexport const TranscodeAsync = (data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult> => {\r\n const dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;\r\n\r\n return new Promise((res, rej) => {\r\n _CreateWorkerAsync().then(\r\n () => {\r\n const actionId = _actionId++;\r\n const messageHandler = (msg: any) => {\r\n if (msg.data.action === \"transcode\" && msg.data.id === actionId) {\r\n _Worker!.removeEventListener(\"message\", messageHandler);\r\n if (!msg.data.success) {\r\n rej(\"Transcode is not supported on this device\");\r\n } else {\r\n res(msg.data);\r\n }\r\n }\r\n };\r\n _Worker!.addEventListener(\"message\", messageHandler);\r\n\r\n const dataViewCopy = new Uint8Array(dataView.byteLength);\r\n dataViewCopy.set(new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength));\r\n _Worker!.postMessage({ action: \"transcode\", id: actionId, imageData: dataViewCopy, config: config, ignoreSupportedFormats: _IgnoreSupportedFormats }, [\r\n dataViewCopy.buffer,\r\n ]);\r\n },\r\n (error) => {\r\n rej(error);\r\n }\r\n );\r\n });\r\n};\r\n\r\n/**\r\n * Loads a texture from the transcode result\r\n * @param texture texture load to\r\n * @param transcodeResult the result of transcoding the basis file to load from\r\n */\r\nexport const LoadTextureFromTranscodeResult = (texture: InternalTexture, transcodeResult: TranscodeResult) => {\r\n const engine = texture.getEngine() as Engine;\r\n for (let i = 0; i < transcodeResult.fileInfo.images.length; i++) {\r\n const rootImage = transcodeResult.fileInfo.images[i].levels[0];\r\n texture._invertVScale = texture.invertY;\r\n if (transcodeResult.format === -1) {\r\n // No compatable compressed format found, fallback to RGB\r\n texture.type = Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5;\r\n texture.format = Constants.TEXTUREFORMAT_RGB;\r\n\r\n if (engine._features.basisNeedsPOT && (Scalar.Log2(rootImage.width) % 1 !== 0 || Scalar.Log2(rootImage.height) % 1 !== 0)) {\r\n // Create non power of two texture\r\n const source = new InternalTexture(engine, InternalTextureSource.Temp);\r\n\r\n texture._invertVScale = texture.invertY;\r\n source.type = Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5;\r\n source.format = Constants.TEXTUREFORMAT_RGB;\r\n // Fallback requires aligned width/height\r\n source.width = (rootImage.width + 3) & ~3;\r\n source.height = (rootImage.height + 3) & ~3;\r\n engine._bindTextureDirectly(engine._gl.TEXTURE_2D, source, true);\r\n engine._uploadDataToTextureDirectly(source, rootImage.transcodedPixels, i, 0, Constants.TEXTUREFORMAT_RGB, true);\r\n\r\n // Resize to power of two\r\n engine._rescaleTexture(source, texture, engine.scenes[0], engine._getInternalFormat(Constants.TEXTUREFORMAT_RGB), () => {\r\n engine._releaseTexture(source);\r\n engine._bindTextureDirectly(engine._gl.TEXTURE_2D, texture, true);\r\n });\r\n } else {\r\n // Fallback is already inverted\r\n texture._invertVScale = !texture.invertY;\r\n\r\n // Upload directly\r\n texture.width = (rootImage.width + 3) & ~3;\r\n texture.height = (rootImage.height + 3) & ~3;\r\n engine._uploadDataToTextureDirectly(texture, rootImage.transcodedPixels, i, 0, Constants.TEXTUREFORMAT_RGB, true);\r\n }\r\n } else {\r\n texture.width = rootImage.width;\r\n texture.height = rootImage.height;\r\n texture.generateMipMaps = transcodeResult.fileInfo.images[i].levels.length > 1;\r\n\r\n // Upload all mip levels in the file\r\n transcodeResult.fileInfo.images[i].levels.forEach((level: any, index: number) => {\r\n engine._uploadCompressedDataToTextureDirectly(\r\n texture,\r\n BasisTools.GetInternalFormatFromBasisFormat(transcodeResult.format!, engine),\r\n level.width,\r\n level.height,\r\n level.transcodedPixels,\r\n i,\r\n index\r\n );\r\n });\r\n\r\n if (engine._features.basisNeedsPOT && (Scalar.Log2(texture.width) % 1 !== 0 || Scalar.Log2(texture.height) % 1 !== 0)) {\r\n Tools.Warn(\r\n \"Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1.\"\r\n );\r\n texture._cachedWrapU = Texture.CLAMP_ADDRESSMODE;\r\n texture._cachedWrapV = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Used to load .Basis files\r\n * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl\r\n */\r\nexport const BasisTools = {\r\n /**\r\n * URL to use when loading the basis transcoder\r\n */\r\n JSModuleURL: BasisToolsOptions.JSModuleURL,\r\n /**\r\n * URL to use when loading the wasm module for the transcoder\r\n */\r\n WasmModuleURL: BasisToolsOptions.WasmModuleURL,\r\n\r\n /**\r\n * Get the internal format to be passed to texImage2D corresponding to the .basis format value\r\n * @param basisFormat format chosen from GetSupportedTranscodeFormat\r\n * @returns internal format corresponding to the Basis format\r\n */\r\n GetInternalFormatFromBasisFormat,\r\n\r\n /**\r\n * Transcodes a loaded image file to compressed pixel data\r\n * @param data image data to transcode\r\n * @param config configuration options for the transcoding\r\n * @returns a promise resulting in the transcoded image\r\n */\r\n TranscodeAsync,\r\n\r\n /**\r\n * Loads a texture from the transcode result\r\n * @param texture texture load to\r\n * @param transcodeResult the result of transcoding the basis file to load from\r\n */\r\n LoadTextureFromTranscodeResult,\r\n};\r\n\r\n// WorkerGlobalScope\r\ndeclare function importScripts(...urls: string[]): void;\r\ndeclare function postMessage(message: any, transfer?: any[]): void;\r\ndeclare let Module: any;\r\nfunction workerFunc(): void {\r\n const _BASIS_FORMAT = {\r\n cTFETC1: 0,\r\n cTFBC1: 1,\r\n cTFBC4: 2,\r\n cTFPVRTC1_4_OPAQUE_ONLY: 3,\r\n cTFBC7_M6_OPAQUE_ONLY: 4,\r\n cTFETC2: 5,\r\n cTFBC3: 6,\r\n cTFBC5: 7,\r\n };\r\n let transcoderModulePromise: Nullable<Promise<any>> = null;\r\n onmessage = (event) => {\r\n if (event.data.action === \"init\") {\r\n // Load the transcoder if it hasn't been yet\r\n if (!transcoderModulePromise) {\r\n // Override wasm binary\r\n Module = { wasmBinary: event.data.wasmBinary };\r\n // make sure we loaded the script correctly\r\n try {\r\n importScripts(event.data.url);\r\n } catch (e) {\r\n postMessage({ action: \"error\", error: e });\r\n }\r\n transcoderModulePromise = new Promise<void>((res) => {\r\n Module.onRuntimeInitialized = () => {\r\n Module.initializeBasis();\r\n res();\r\n };\r\n });\r\n }\r\n transcoderModulePromise.then(() => {\r\n postMessage({ action: \"init\" });\r\n });\r\n } else if (event.data.action === \"transcode\") {\r\n // Transcode the basis image and return the resulting pixels\r\n const config: BasisTranscodeConfiguration = event.data.config;\r\n const imgData = event.data.imageData;\r\n const loadedFile = new Module.BasisFile(imgData);\r\n const fileInfo = GetFileInfo(loadedFile);\r\n let format = event.data.ignoreSupportedFormats ? null : GetSupportedTranscodeFormat(event.data.config, fileInfo);\r\n\r\n let needsConversion = false;\r\n if (format === null) {\r\n needsConversion = true;\r\n format = fileInfo.hasAlpha ? _BASIS_FORMAT.cTFBC3 : _BASIS_FORMAT.cTFBC1;\r\n }\r\n\r\n // Begin transcode\r\n let success = true;\r\n if (!loadedFile.startTranscoding()) {\r\n success = false;\r\n }\r\n\r\n const buffers: Array<any> = [];\r\n for (let imageIndex = 0; imageIndex < fileInfo.images.length; imageIndex++) {\r\n if (!success) {\r\n break;\r\n }\r\n const image = fileInfo.images[imageIndex];\r\n if (config.loadSingleImage === undefined || config.loadSingleImage === imageIndex) {\r\n let mipCount = image.levels.length;\r\n if (config.loadMipmapLevels === false) {\r\n mipCount = 1;\r\n }\r\n for (let levelIndex = 0; levelIndex < mipCount; levelIndex++) {\r\n const levelInfo = image.levels[levelIndex];\r\n\r\n const pixels = TranscodeLevel(loadedFile, imageIndex, levelIndex, format!, needsConversion);\r\n if (!pixels) {\r\n success = false;\r\n break;\r\n }\r\n levelInfo.transcodedPixels = pixels;\r\n buffers.push(levelInfo.transcodedPixels.buffer);\r\n }\r\n }\r\n }\r\n // Close file\r\n loadedFile.close();\r\n loadedFile.delete();\r\n\r\n if (needsConversion) {\r\n format = -1;\r\n }\r\n if (!success) {\r\n postMessage({ action: \"transcode\", success: success, id: event.data.id });\r\n } else {\r\n postMessage({ action: \"transcode\", success: success, id: event.data.id, fileInfo: fileInfo, format: format }, buffers);\r\n }\r\n }\r\n };\r\n\r\n /**\r\n * Detects the supported transcode format for the file\r\n * @param config transcode config\r\n * @param fileInfo info about the file\r\n * @returns the chosed format or null if none are supported\r\n */\r\n function GetSupportedTranscodeFormat(config: BasisTranscodeConfiguration, fileInfo: BasisFileInfo): Nullable<number> {\r\n let format = null;\r\n if (config.supportedCompressionFormats) {\r\n if (config.supportedCompressionFormats.etc1) {\r\n format = _BASIS_FORMAT.cTFETC1;\r\n } else if (config.supportedCompressionFormats.s3tc) {\r\n format = fileInfo.hasAlpha ? _BASIS_FORMAT.cTFBC3 : _BASIS_FORMAT.cTFBC1;\r\n } else if (config.supportedCompressionFormats.pvrtc) {\r\n // TODO uncomment this after pvrtc bug is fixed is basis transcoder\r\n // See discussion here: https://github.com/mrdoob/three.js/issues/16524#issuecomment-498929924\r\n // format = _BASIS_FORMAT.cTFPVRTC1_4_OPAQUE_ONLY;\r\n } else if (config.supportedCompressionFormats.etc2) {\r\n format = _BASIS_FORMAT.cTFETC2;\r\n }\r\n }\r\n return format;\r\n }\r\n\r\n /**\r\n * Retrieves information about the basis file eg. dimensions\r\n * @param basisFile the basis file to get the info from\r\n * @returns information about the basis file\r\n */\r\n function GetFileInfo(basisFile: any): BasisFileInfo {\r\n const hasAlpha = basisFile.getHasAlpha();\r\n const imageCount = basisFile.getNumImages();\r\n const images = [];\r\n for (let i = 0; i < imageCount; i++) {\r\n const imageInfo = {\r\n levels: [] as Array<any>,\r\n };\r\n const levelCount = basisFile.getNumLevels(i);\r\n for (let level = 0; level < levelCount; level++) {\r\n const levelInfo = {\r\n width: basisFile.getImageWidth(i, level),\r\n height: basisFile.getImageHeight(i, level),\r\n };\r\n imageInfo.levels.push(levelInfo);\r\n }\r\n images.push(imageInfo);\r\n }\r\n const info = { hasAlpha, images };\r\n return info;\r\n }\r\n\r\n function TranscodeLevel(loadedFile: any, imageIndex: number, levelIndex: number, format: number, convertToRgb565: boolean): Nullable<Uint8Array | Uint16Array> {\r\n const dstSize = loadedFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, format);\r\n let dst: Uint8Array | Uint16Array = new Uint8Array(dstSize);\r\n if (!loadedFile.transcodeImage(dst, imageIndex, levelIndex, format, 1, 0)) {\r\n return null;\r\n }\r\n // If no supported format is found, load as dxt and convert to rgb565\r\n if (convertToRgb565) {\r\n const alignedWidth = (loadedFile.getImageWidth(imageIndex, levelIndex) + 3) & ~3;\r\n const alignedHeight = (loadedFile.getImageHeight(imageIndex, levelIndex) + 3) & ~3;\r\n dst = ConvertDxtToRgb565(dst, 0, alignedWidth, alignedHeight);\r\n }\r\n return dst;\r\n }\r\n\r\n /**\r\n * From https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture/dxt-to-rgb565.js\r\n * An unoptimized version of dxtToRgb565. Also, the floating\r\n * point math used to compute the colors actually results in\r\n * slightly different colors compared to hardware DXT decoders.\r\n * @param src dxt src pixels\r\n * @param srcByteOffset offset for the start of src\r\n * @param width aligned width of the image\r\n * @param height aligned height of the image\r\n * @return the converted pixels\r\n */\r\n function ConvertDxtToRgb565(src: Uint8Array, srcByteOffset: number, width: number, height: number): Uint16Array {\r\n const c = new Uint16Array(4);\r\n const dst = new Uint16Array(width * height);\r\n\r\n const blockWidth = width / 4;\r\n const blockHeight = height / 4;\r\n for (let blockY = 0; blockY < blockHeight; blockY++) {\r\n for (let blockX = 0; blockX < blockWidth; blockX++) {\r\n const i = srcByteOffset + 8 * (blockY * blockWidth + blockX);\r\n c[0] = src[i] | (src[i + 1] << 8);\r\n c[1] = src[i + 2] | (src[i + 3] << 8);\r\n c[2] =\r\n ((2 * (c[0] & 0x1f) + 1 * (c[1] & 0x1f)) / 3) |\r\n (((2 * (c[0] & 0x7e0) + 1 * (c[1] & 0x7e0)) / 3) & 0x7e0) |\r\n (((2 * (c[0] & 0xf800) + 1 * (c[1] & 0xf800)) / 3) & 0xf800);\r\n c[3] =\r\n ((2 * (c[1] & 0x1f) + 1 * (c[0] & 0x1f)) / 3) |\r\n (((2 * (c[1] & 0x7e0) + 1 * (c[0] & 0x7e0)) / 3) & 0x7e0) |\r\n (((2 * (c[1] & 0xf800) + 1 * (c[0] & 0xf800)) / 3) & 0xf800);\r\n for (let row = 0; row < 4; row++) {\r\n const m = src[i + 4 + row];\r\n let dstI = (blockY * 4 + row) * width + blockX * 4;\r\n dst[dstI++] = c[m & 0x3];\r\n dst[dstI++] = c[(m >> 2) & 0x3];\r\n dst[dstI++] = c[(m >> 4) & 0x3];\r\n dst[dstI++] = c[(m >> 6) & 0x3];\r\n }\r\n }\r\n }\r\n return dst;\r\n }\r\n}\r\n\r\nObject.defineProperty(BasisTools, \"JSModuleURL\", {\r\n get: function (this: null) {\r\n return BasisToolsOptions.JSModuleURL;\r\n },\r\n set: function (this: null, value: string) {\r\n BasisToolsOptions.JSModuleURL = value;\r\n },\r\n});\r\n\r\nObject.defineProperty(BasisTools, \"WasmModuleURL\", {\r\n get: function (this: null) {\r\n return BasisToolsOptions.WasmModuleURL;\r\n },\r\n set: function (this: null, value: string) {\r\n BasisToolsOptions.WasmModuleURL = value;\r\n },\r\n});\r\n"]}
1
+ {"version":3,"file":"basis.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/basis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD;;GAEG;AACH;IAAA;IASA,CAAC;IAAD,oBAAC;AAAD,CAAC,AATD,IASC;AAED;;GAEG;AACH;IAAA;IASA,CAAC;IAAD,sBAAC;AAAD,CAAC,AATD,IASC;AAED;;GAEG;AACH;IAAA;IAsCA,CAAC;IAAD,kCAAC;AAAD,CAAC,AAtCD,IAsCC;;AAED;;;GAGG;AACH,IAAK,aAsBJ;AAtBD,WAAK,aAAa;IACd,uDAAW,CAAA;IACX,uDAAW,CAAA;IACX,qDAAU,CAAA;IACV,qDAAU,CAAA;IACV,qDAAU,CAAA;IACV,qDAAU,CAAA;IACV,qDAAU,CAAA;IACV,uEAAmB,CAAA;IACnB,yEAAoB,CAAA;IACpB,gEAAgB,CAAA;IAChB,8DAAe,CAAA;IACf,sGAAmC,CAAA;IACnC,4DAAc,CAAA;IACd,4DAAc,CAAA;IACd,4DAAc,CAAA;IACd,gEAAgB,CAAA;IAChB,gEAAgB,CAAA;IAChB,wEAAoB,CAAA;IACpB,0EAAqB,CAAA;IACrB,wEAAoB,CAAA;IACpB,0EAAqB,CAAA;AACzB,CAAC,E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K,GAAG,MAAM,GAAG,CAAC,CAAC;oBACnD,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;oBACzB,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;oBAChC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;oBAChC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;iBACnC;aACJ;SACJ;QACD,OAAO,GAAG,CAAC;IACf,CAAC;AACL,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,aAAa,EAAE;IAC7C,GAAG,EAAE;QACD,OAAO,iBAAiB,CAAC,WAAW,CAAC;IACzC,CAAC;IACD,GAAG,EAAE,UAAsB,KAAa;QACpC,iBAAiB,CAAC,WAAW,GAAG,KAAK,CAAC;IAC1C,CAAC;CACJ,CAAC,CAAC;AAEH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,eAAe,EAAE;IAC/C,GAAG,EAAE;QACD,OAAO,iBAAiB,CAAC,aAAa,CAAC;IAC3C,CAAC;IACD,GAAG,EAAE,UAAsB,KAAa;QACpC,iBAAiB,CAAC,aAAa,GAAG,KAAK,CAAC;IAC5C,CAAC;CACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport { Tools } from \"./tools\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { InternalTexture, InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport { Scalar } from \"../Maths/math.scalar\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\n/**\r\n * Info about the .basis files\r\n */\r\nclass BasisFileInfo {\r\n /**\r\n * If the file has alpha\r\n */\r\n public hasAlpha: boolean;\r\n /**\r\n * Info about each image of the basis file\r\n */\r\n public images: Array<{ levels: Array<{ width: number; height: number; transcodedPixels: ArrayBufferView }> }>;\r\n}\r\n\r\n/**\r\n * Result of transcoding a basis file\r\n */\r\nclass TranscodeResult {\r\n /**\r\n * Info about the .basis file\r\n */\r\n public fileInfo: BasisFileInfo;\r\n /**\r\n * Format to use when loading the file\r\n */\r\n public format: number;\r\n}\r\n\r\n/**\r\n * Configuration options for the Basis transcoder\r\n */\r\nexport class BasisTranscodeConfiguration {\r\n /**\r\n * Supported compression formats used to determine the supported output format of the transcoder\r\n */\r\n supportedCompressionFormats?: {\r\n /**\r\n * etc1 compression format\r\n */\r\n etc1?: boolean;\r\n /**\r\n * s3tc compression format\r\n */\r\n s3tc?: boolean;\r\n /**\r\n * pvrtc compression format\r\n */\r\n pvrtc?: boolean;\r\n /**\r\n * etc2 compression format\r\n */\r\n etc2?: boolean;\r\n /**\r\n * astc compression format\r\n */\r\n astc?: boolean;\r\n /**\r\n * bc7 compression format\r\n */\r\n bc7?: boolean;\r\n };\r\n /**\r\n * If mipmap levels should be loaded for transcoded images (Default: true)\r\n */\r\n loadMipmapLevels?: boolean;\r\n /**\r\n * Index of a single image to load (Default: all images)\r\n */\r\n loadSingleImage?: number;\r\n}\r\n\r\n/**\r\n * @hidden\r\n * Enum of basis transcoder formats\r\n */\r\nenum BASIS_FORMATS {\r\n cTFETC1 = 0,\r\n cTFETC2 = 1,\r\n cTFBC1 = 2,\r\n cTFBC3 = 3,\r\n cTFBC4 = 4,\r\n cTFBC5 = 5,\r\n cTFBC7 = 6,\r\n cTFPVRTC1_4_RGB = 8,\r\n cTFPVRTC1_4_RGBA = 9,\r\n cTFASTC_4x4 = 10,\r\n cTFATC_RGB = 11,\r\n cTFATC_RGBA_INTERPOLATED_ALPHA = 12,\r\n cTFRGBA32 = 13,\r\n cTFRGB565 = 14,\r\n cTFBGR565 = 15,\r\n cTFRGBA4444 = 16,\r\n cTFFXT1_RGB = 17,\r\n cTFPVRTC2_4_RGB = 18,\r\n cTFPVRTC2_4_RGBA = 19,\r\n cTFETC2_EAC_R11 = 20,\r\n cTFETC2_EAC_RG11 = 21,\r\n}\r\n\r\n/**\r\n * Used to load .Basis files\r\n * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl\r\n */\r\nexport const BasisToolsOptions = {\r\n /**\r\n * URL to use when loading the basis transcoder\r\n */\r\n JSModuleURL: \"https://cdn.babylonjs.com/basisTranscoder/1/basis_transcoder.js\",\r\n /**\r\n * URL to use when loading the wasm module for the transcoder\r\n */\r\n WasmModuleURL: \"https://cdn.babylonjs.com/basisTranscoder/1/basis_transcoder.wasm\",\r\n};\r\n\r\n/**\r\n * Get the internal format to be passed to texImage2D corresponding to the .basis format value\r\n * @param basisFormat format chosen from GetSupportedTranscodeFormat\r\n * @param engine\r\n * @returns internal format corresponding to the Basis format\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nexport const GetInternalFormatFromBasisFormat = (basisFormat: number, engine: Engine) => {\r\n let format;\r\n switch (basisFormat) {\r\n case BASIS_FORMATS.cTFETC1:\r\n format = Constants.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL;\r\n break;\r\n case BASIS_FORMATS.cTFBC1:\r\n format = Constants.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;\r\n break;\r\n case BASIS_FORMATS.cTFBC4:\r\n format = Constants.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;\r\n break;\r\n case BASIS_FORMATS.cTFASTC_4x4:\r\n format = Constants.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4;\r\n break;\r\n case BASIS_FORMATS.cTFETC2:\r\n format = Constants.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC;\r\n break;\r\n case BASIS_FORMATS.cTFBC7:\r\n format = Constants.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM;\r\n break;\r\n }\r\n\r\n if (format === undefined) {\r\n throw \"The chosen Basis transcoder format is not currently supported\";\r\n }\r\n\r\n return format;\r\n};\r\n\r\nlet _WorkerPromise: Nullable<Promise<Worker>> = null;\r\nlet _Worker: Nullable<Worker> = null;\r\nlet _actionId = 0;\r\nconst _IgnoreSupportedFormats = false;\r\nconst _CreateWorkerAsync = () => {\r\n if (!_WorkerPromise) {\r\n _WorkerPromise = new Promise((res, reject) => {\r\n if (_Worker) {\r\n res(_Worker);\r\n } else {\r\n Tools.LoadFileAsync(BasisToolsOptions.WasmModuleURL)\r\n .then((wasmBinary) => {\r\n const workerBlobUrl = URL.createObjectURL(new Blob([`(${workerFunc})()`], { type: \"application/javascript\" }));\r\n _Worker = new Worker(workerBlobUrl);\r\n\r\n const initHandler = (msg: any) => {\r\n if (msg.data.action === \"init\") {\r\n _Worker!.removeEventListener(\"message\", initHandler);\r\n res(_Worker!);\r\n } else if (msg.data.action === \"error\") {\r\n reject(msg.data.error || \"error initializing worker\");\r\n }\r\n };\r\n _Worker.addEventListener(\"message\", initHandler);\r\n _Worker.postMessage({ action: \"init\", url: BasisToolsOptions.JSModuleURL, wasmBinary: wasmBinary });\r\n })\r\n .catch(reject);\r\n }\r\n });\r\n }\r\n return _WorkerPromise;\r\n};\r\n\r\n/**\r\n * Transcodes a loaded image file to compressed pixel data\r\n * @param data image data to transcode\r\n * @param config configuration options for the transcoding\r\n * @returns a promise resulting in the transcoded image\r\n */\r\nexport const TranscodeAsync = (data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult> => {\r\n const dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;\r\n\r\n return new Promise((res, rej) => {\r\n _CreateWorkerAsync().then(\r\n () => {\r\n const actionId = _actionId++;\r\n const messageHandler = (msg: any) => {\r\n if (msg.data.action === \"transcode\" && msg.data.id === actionId) {\r\n _Worker!.removeEventListener(\"message\", messageHandler);\r\n if (!msg.data.success) {\r\n rej(\"Transcode is not supported on this device\");\r\n } else {\r\n res(msg.data);\r\n }\r\n }\r\n };\r\n _Worker!.addEventListener(\"message\", messageHandler);\r\n\r\n const dataViewCopy = new Uint8Array(dataView.byteLength);\r\n dataViewCopy.set(new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength));\r\n _Worker!.postMessage({ action: \"transcode\", id: actionId, imageData: dataViewCopy, config: config, ignoreSupportedFormats: _IgnoreSupportedFormats }, [\r\n dataViewCopy.buffer,\r\n ]);\r\n },\r\n (error) => {\r\n rej(error);\r\n }\r\n );\r\n });\r\n};\r\n\r\n/**\r\n * Loads a texture from the transcode result\r\n * @param texture texture load to\r\n * @param transcodeResult the result of transcoding the basis file to load from\r\n */\r\nexport const LoadTextureFromTranscodeResult = (texture: InternalTexture, transcodeResult: TranscodeResult) => {\r\n const engine = texture.getEngine() as Engine;\r\n for (let i = 0; i < transcodeResult.fileInfo.images.length; i++) {\r\n const rootImage = transcodeResult.fileInfo.images[i].levels[0];\r\n texture._invertVScale = texture.invertY;\r\n if (transcodeResult.format === -1) {\r\n // No compatable compressed format found, fallback to RGB\r\n texture.type = Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5;\r\n texture.format = Constants.TEXTUREFORMAT_RGB;\r\n\r\n if (engine._features.basisNeedsPOT && (Scalar.Log2(rootImage.width) % 1 !== 0 || Scalar.Log2(rootImage.height) % 1 !== 0)) {\r\n // Create non power of two texture\r\n const source = new InternalTexture(engine, InternalTextureSource.Temp);\r\n\r\n texture._invertVScale = texture.invertY;\r\n source.type = Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5;\r\n source.format = Constants.TEXTUREFORMAT_RGB;\r\n // Fallback requires aligned width/height\r\n source.width = (rootImage.width + 3) & ~3;\r\n source.height = (rootImage.height + 3) & ~3;\r\n engine._bindTextureDirectly(engine._gl.TEXTURE_2D, source, true);\r\n engine._uploadDataToTextureDirectly(source, rootImage.transcodedPixels, i, 0, Constants.TEXTUREFORMAT_RGB, true);\r\n\r\n // Resize to power of two\r\n engine._rescaleTexture(source, texture, engine.scenes[0], engine._getInternalFormat(Constants.TEXTUREFORMAT_RGB), () => {\r\n engine._releaseTexture(source);\r\n engine._bindTextureDirectly(engine._gl.TEXTURE_2D, texture, true);\r\n });\r\n } else {\r\n // Fallback is already inverted\r\n texture._invertVScale = !texture.invertY;\r\n\r\n // Upload directly\r\n texture.width = (rootImage.width + 3) & ~3;\r\n texture.height = (rootImage.height + 3) & ~3;\r\n engine._uploadDataToTextureDirectly(texture, rootImage.transcodedPixels, i, 0, Constants.TEXTUREFORMAT_RGB, true);\r\n }\r\n } else {\r\n texture.width = rootImage.width;\r\n texture.height = rootImage.height;\r\n texture.generateMipMaps = transcodeResult.fileInfo.images[i].levels.length > 1;\r\n\r\n // Upload all mip levels in the file\r\n transcodeResult.fileInfo.images[i].levels.forEach((level: any, index: number) => {\r\n engine._uploadCompressedDataToTextureDirectly(\r\n texture,\r\n BasisTools.GetInternalFormatFromBasisFormat(transcodeResult.format!, engine),\r\n level.width,\r\n level.height,\r\n level.transcodedPixels,\r\n i,\r\n index\r\n );\r\n });\r\n\r\n if (engine._features.basisNeedsPOT && (Scalar.Log2(texture.width) % 1 !== 0 || Scalar.Log2(texture.height) % 1 !== 0)) {\r\n Tools.Warn(\r\n \"Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1.\"\r\n );\r\n texture._cachedWrapU = Texture.CLAMP_ADDRESSMODE;\r\n texture._cachedWrapV = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Used to load .Basis files\r\n * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl\r\n */\r\nexport const BasisTools = {\r\n /**\r\n * URL to use when loading the basis transcoder\r\n */\r\n JSModuleURL: BasisToolsOptions.JSModuleURL,\r\n /**\r\n * URL to use when loading the wasm module for the transcoder\r\n */\r\n WasmModuleURL: BasisToolsOptions.WasmModuleURL,\r\n\r\n /**\r\n * Get the internal format to be passed to texImage2D corresponding to the .basis format value\r\n * @param basisFormat format chosen from GetSupportedTranscodeFormat\r\n * @returns internal format corresponding to the Basis format\r\n */\r\n GetInternalFormatFromBasisFormat,\r\n\r\n /**\r\n * Transcodes a loaded image file to compressed pixel data\r\n * @param data image data to transcode\r\n * @param config configuration options for the transcoding\r\n * @returns a promise resulting in the transcoded image\r\n */\r\n TranscodeAsync,\r\n\r\n /**\r\n * Loads a texture from the transcode result\r\n * @param texture texture load to\r\n * @param transcodeResult the result of transcoding the basis file to load from\r\n */\r\n LoadTextureFromTranscodeResult,\r\n};\r\n\r\n// WorkerGlobalScope\r\ndeclare function importScripts(...urls: string[]): void;\r\ndeclare function postMessage(message: any, transfer?: any[]): void;\r\ndeclare let BASIS: any;\r\nfunction workerFunc(): void {\r\n const _BASIS_FORMAT = {\r\n cTFETC1: 0,\r\n cTFETC2: 1,\r\n cTFBC1: 2,\r\n cTFBC3: 3,\r\n cTFBC4: 4,\r\n cTFBC5: 5,\r\n cTFBC7: 6,\r\n cTFPVRTC1_4_RGB: 8,\r\n cTFPVRTC1_4_RGBA: 9,\r\n cTFASTC_4x4: 10,\r\n cTFATC_RGB: 11,\r\n cTFATC_RGBA_INTERPOLATED_ALPHA: 12,\r\n cTFRGBA32: 13,\r\n cTFRGB565: 14,\r\n cTFBGR565: 15,\r\n cTFRGBA4444: 16,\r\n cTFFXT1_RGB: 17,\r\n cTFPVRTC2_4_RGB: 18,\r\n cTFPVRTC2_4_RGBA: 19,\r\n cTFETC2_EAC_R11: 20,\r\n cTFETC2_EAC_RG11: 21,\r\n };\r\n let transcoderModulePromise: Nullable<PromiseLike<any>> = null;\r\n onmessage = (event) => {\r\n if (event.data.action === \"init\") {\r\n // Load the transcoder if it hasn't been yet\r\n if (!transcoderModulePromise) {\r\n // make sure we loaded the script correctly\r\n try {\r\n importScripts(event.data.url);\r\n } catch (e) {\r\n postMessage({ action: \"error\", error: e });\r\n }\r\n transcoderModulePromise = BASIS({\r\n // Override wasm binary\r\n wasmBinary: event.data.wasmBinary,\r\n });\r\n }\r\n if (transcoderModulePromise !== null) {\r\n transcoderModulePromise.then((m) => {\r\n BASIS = m;\r\n m.initializeBasis();\r\n postMessage({ action: \"init\" });\r\n });\r\n }\r\n } else if (event.data.action === \"transcode\") {\r\n // Transcode the basis image and return the resulting pixels\r\n const config: BasisTranscodeConfiguration = event.data.config;\r\n const imgData = event.data.imageData;\r\n const loadedFile = new BASIS.BasisFile(imgData);\r\n const fileInfo = GetFileInfo(loadedFile);\r\n let format = event.data.ignoreSupportedFormats ? null : GetSupportedTranscodeFormat(event.data.config, fileInfo);\r\n\r\n let needsConversion = false;\r\n if (format === null) {\r\n needsConversion = true;\r\n format = fileInfo.hasAlpha ? _BASIS_FORMAT.cTFBC3 : _BASIS_FORMAT.cTFBC1;\r\n }\r\n\r\n // Begin transcode\r\n let success = true;\r\n if (!loadedFile.startTranscoding()) {\r\n success = false;\r\n }\r\n\r\n const buffers: Array<any> = [];\r\n for (let imageIndex = 0; imageIndex < fileInfo.images.length; imageIndex++) {\r\n if (!success) {\r\n break;\r\n }\r\n const image = fileInfo.images[imageIndex];\r\n if (config.loadSingleImage === undefined || config.loadSingleImage === imageIndex) {\r\n let mipCount = image.levels.length;\r\n if (config.loadMipmapLevels === false) {\r\n mipCount = 1;\r\n }\r\n for (let levelIndex = 0; levelIndex < mipCount; levelIndex++) {\r\n const levelInfo = image.levels[levelIndex];\r\n\r\n const pixels = TranscodeLevel(loadedFile, imageIndex, levelIndex, format!, needsConversion);\r\n if (!pixels) {\r\n success = false;\r\n break;\r\n }\r\n levelInfo.transcodedPixels = pixels;\r\n buffers.push(levelInfo.transcodedPixels.buffer);\r\n }\r\n }\r\n }\r\n // Close file\r\n loadedFile.close();\r\n loadedFile.delete();\r\n\r\n if (needsConversion) {\r\n format = -1;\r\n }\r\n if (!success) {\r\n postMessage({ action: \"transcode\", success: success, id: event.data.id });\r\n } else {\r\n postMessage({ action: \"transcode\", success: success, id: event.data.id, fileInfo: fileInfo, format: format }, buffers);\r\n }\r\n }\r\n };\r\n\r\n /**\r\n * Detects the supported transcode format for the file\r\n * @param config transcode config\r\n * @param fileInfo info about the file\r\n * @returns the chosed format or null if none are supported\r\n */\r\n function GetSupportedTranscodeFormat(config: BasisTranscodeConfiguration, fileInfo: BasisFileInfo): Nullable<number> {\r\n let format = null;\r\n if (config.supportedCompressionFormats) {\r\n if (config.supportedCompressionFormats.astc) {\r\n format = _BASIS_FORMAT.cTFASTC_4x4;\r\n } else if (config.supportedCompressionFormats.bc7) {\r\n format = _BASIS_FORMAT.cTFBC7;\r\n } else if (config.supportedCompressionFormats.s3tc) {\r\n format = fileInfo.hasAlpha ? _BASIS_FORMAT.cTFBC3 : _BASIS_FORMAT.cTFBC1;\r\n } else if (config.supportedCompressionFormats.pvrtc) {\r\n format = fileInfo.hasAlpha ? _BASIS_FORMAT.cTFPVRTC1_4_RGBA : _BASIS_FORMAT.cTFPVRTC1_4_RGB;\r\n } else if (config.supportedCompressionFormats.etc2) {\r\n format = _BASIS_FORMAT.cTFETC2;\r\n } else if (config.supportedCompressionFormats.etc1) {\r\n format = _BASIS_FORMAT.cTFETC1;\r\n } else {\r\n format = _BASIS_FORMAT.cTFRGB565;\r\n }\r\n }\r\n return format;\r\n }\r\n\r\n /**\r\n * Retrieves information about the basis file eg. dimensions\r\n * @param basisFile the basis file to get the info from\r\n * @returns information about the basis file\r\n */\r\n function GetFileInfo(basisFile: any): BasisFileInfo {\r\n const hasAlpha = basisFile.getHasAlpha();\r\n const imageCount = basisFile.getNumImages();\r\n const images = [];\r\n for (let i = 0; i < imageCount; i++) {\r\n const imageInfo = {\r\n levels: [] as Array<any>,\r\n };\r\n const levelCount = basisFile.getNumLevels(i);\r\n for (let level = 0; level < levelCount; level++) {\r\n const levelInfo = {\r\n width: basisFile.getImageWidth(i, level),\r\n height: basisFile.getImageHeight(i, level),\r\n };\r\n imageInfo.levels.push(levelInfo);\r\n }\r\n images.push(imageInfo);\r\n }\r\n const info = { hasAlpha, images };\r\n return info;\r\n }\r\n\r\n function TranscodeLevel(loadedFile: any, imageIndex: number, levelIndex: number, format: number, convertToRgb565: boolean): Nullable<Uint8Array | Uint16Array> {\r\n const dstSize = loadedFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, format);\r\n let dst: Uint8Array | Uint16Array = new Uint8Array(dstSize);\r\n if (!loadedFile.transcodeImage(dst, imageIndex, levelIndex, format, 1, 0)) {\r\n return null;\r\n }\r\n // If no supported format is found, load as dxt and convert to rgb565\r\n if (convertToRgb565) {\r\n const alignedWidth = (loadedFile.getImageWidth(imageIndex, levelIndex) + 3) & ~3;\r\n const alignedHeight = (loadedFile.getImageHeight(imageIndex, levelIndex) + 3) & ~3;\r\n dst = ConvertDxtToRgb565(dst, 0, alignedWidth, alignedHeight);\r\n }\r\n return dst;\r\n }\r\n\r\n /**\r\n * From https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture/dxt-to-rgb565.js\r\n * An unoptimized version of dxtToRgb565. Also, the floating\r\n * point math used to compute the colors actually results in\r\n * slightly different colors compared to hardware DXT decoders.\r\n * @param src dxt src pixels\r\n * @param srcByteOffset offset for the start of src\r\n * @param width aligned width of the image\r\n * @param height aligned height of the image\r\n * @return the converted pixels\r\n */\r\n function ConvertDxtToRgb565(src: Uint8Array, srcByteOffset: number, width: number, height: number): Uint16Array {\r\n const c = new Uint16Array(4);\r\n const dst = new Uint16Array(width * height);\r\n\r\n const blockWidth = width / 4;\r\n const blockHeight = height / 4;\r\n for (let blockY = 0; blockY < blockHeight; blockY++) {\r\n for (let blockX = 0; blockX < blockWidth; blockX++) {\r\n const i = srcByteOffset + 8 * (blockY * blockWidth + blockX);\r\n c[0] = src[i] | (src[i + 1] << 8);\r\n c[1] = src[i + 2] | (src[i + 3] << 8);\r\n c[2] =\r\n ((2 * (c[0] & 0x1f) + 1 * (c[1] & 0x1f)) / 3) |\r\n (((2 * (c[0] & 0x7e0) + 1 * (c[1] & 0x7e0)) / 3) & 0x7e0) |\r\n (((2 * (c[0] & 0xf800) + 1 * (c[1] & 0xf800)) / 3) & 0xf800);\r\n c[3] =\r\n ((2 * (c[1] & 0x1f) + 1 * (c[0] & 0x1f)) / 3) |\r\n (((2 * (c[1] & 0x7e0) + 1 * (c[0] & 0x7e0)) / 3) & 0x7e0) |\r\n (((2 * (c[1] & 0xf800) + 1 * (c[0] & 0xf800)) / 3) & 0xf800);\r\n for (let row = 0; row < 4; row++) {\r\n const m = src[i + 4 + row];\r\n let dstI = (blockY * 4 + row) * width + blockX * 4;\r\n dst[dstI++] = c[m & 0x3];\r\n dst[dstI++] = c[(m >> 2) & 0x3];\r\n dst[dstI++] = c[(m >> 4) & 0x3];\r\n dst[dstI++] = c[(m >> 6) & 0x3];\r\n }\r\n }\r\n }\r\n return dst;\r\n }\r\n}\r\n\r\nObject.defineProperty(BasisTools, \"JSModuleURL\", {\r\n get: function (this: null) {\r\n return BasisToolsOptions.JSModuleURL;\r\n },\r\n set: function (this: null, value: string) {\r\n BasisToolsOptions.JSModuleURL = value;\r\n },\r\n});\r\n\r\nObject.defineProperty(BasisTools, \"WasmModuleURL\", {\r\n get: function (this: null) {\r\n return BasisToolsOptions.WasmModuleURL;\r\n },\r\n set: function (this: null, value: string) {\r\n BasisToolsOptions.WasmModuleURL = value;\r\n },\r\n});\r\n"]}
@@ -158,6 +158,8 @@ export function CreateScreenshotUsingRenderTarget(engine, camera, size, successC
158
158
  Logger.Error("Invalid 'size' parameter !");
159
159
  return;
160
160
  }
161
+ var originalSize = { width: engine.getRenderWidth(), height: engine.getRenderHeight() };
162
+ engine.setSize(width, height); // we need this call to trigger onResizeObservable with the screenshot width/height on all the subsystems that are observing this event and that needs to (re)create some resources with the right dimensions
161
163
  var scene = camera.getScene();
162
164
  var previousCamera = null;
163
165
  var previousCameras = scene.activeCameras;
@@ -191,6 +193,7 @@ export function CreateScreenshotUsingRenderTarget(engine, camera, size, successC
191
193
  scene.activeCamera = previousCamera;
192
194
  }
193
195
  scene.activeCameras = previousCameras;
196
+ engine.setSize(originalSize.width, originalSize.height);
194
197
  camera.getProjectionMatrix(true); // Force cache refresh;
195
198
  scene.render();
196
199
  };
@@ -1 +1 @@
1
- {"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/screenshotTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKhC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAc,EACd,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAA8B,EAC9B,aAAqB;IADrB,yBAAA,EAAA,sBAA8B;IAC9B,8BAAA,EAAA,qBAAqB;IAEf,IAAA,KAAoB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAA1D,MAAM,YAAA,EAAE,KAAK,WAA6C,CAAC;IAEnE,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE;QACpB,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC3C,OAAO;KACV;IAED,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE;QAC1B,KAAK,CAAC,iBAAiB,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;KAC9D;IAED,KAAK,CAAC,iBAAiB,CAAC,KAAK,GAAG,KAAK,CAAC;IACtC,KAAK,CAAC,iBAAiB,CAAC,MAAM,G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;IACvE,IAAI,KAAK,EAAE;QACP,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KAC7B;IACD,IAAI,MAAM,EAAE;QACR,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC/B;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,IAAM,eAAe,GAAG;IAC3B;;;;;;;;;;;;;;;;OAgBG;IACH,gBAAgB,kBAAA;IAEhB;;;;;;;;;;;;;;OAcG;IACH,qBAAqB,uBAAA;IAErB;;;;;;;;;;;OAWG;IACH,+BAA+B,iCAAA;IAE/B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,iCAAiC,mCAAA;IAEjC;;;;;;;;;;;;;;;;;;OAkBG;IACH,sCAAsC,wCAAA;CACzC,CAAC;AAEF;;;;;GAKG;AACH,IAAM,eAAe,GAAG;IACpB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\n\r\ndeclare type Engine = import(\"../Engines/engine\").Engine;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n */\r\nexport function CreateScreenshot(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType: string = \"image/png\",\r\n forceDownload = false\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n if (!Tools._ScreenshotCanvas) {\r\n Tools._ScreenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n\r\n Tools._ScreenshotCanvas.width = width;\r\n Tools._ScreenshotCanvas.height = height;\r\n\r\n const renderContext = Tools._ScreenshotCanvas.getContext(\"2d\");\r\n\r\n const ratio = engine.getRenderWidth() / engine.getRenderHeight();\r\n let newWidth = width;\r\n let newHeight = newWidth / ratio;\r\n if (newHeight > height) {\r\n newHeight = height;\r\n newWidth = newHeight * ratio;\r\n }\r\n\r\n const offsetX = Math.max(0, width - newWidth) / 2;\r\n const offsetY = Math.max(0, height - newHeight) / 2;\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1,\r\n engine.getCreationOptions().antialias\r\n );\r\n } else {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (renderContext && renderingCanvas) {\r\n renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);\r\n }\r\n\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(undefined, mimeType);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(successCallback, mimeType);\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType: string = \"image/png\"): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType: string = \"image/png\"): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType: string = \"image/png\",\r\n samples: number = 1,\r\n antialiasing: boolean = false,\r\n fileName?: string,\r\n renderSprites: boolean = false,\r\n enableStencilBuffer: boolean = false\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const scene = camera.getScene();\r\n let previousCamera: Nullable<Camera> = null;\r\n const previousCameras = scene.activeCameras;\r\n\r\n scene.activeCameras = null;\r\n\r\n if (scene.activeCamera !== camera) {\r\n previousCamera = scene.activeCamera;\r\n scene.activeCamera = camera;\r\n }\r\n\r\n scene.render(); // make sure the scene is ready to be rendered in the RTT with the right list of active meshes (which depends on the camera, that may have been changed above)\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT,\r\n false,\r\n Texture.NEAREST_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = null;\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n\r\n const renderToTexture = () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n Tools.DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true);\r\n texture.dispose();\r\n });\r\n });\r\n\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n texture.render(true);\r\n\r\n // re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur\r\n // if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n if (previousCamera) {\r\n scene.activeCamera = previousCamera;\r\n }\r\n scene.activeCameras = previousCameras;\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n if (!fxaaPostProcess.getEffect().isReady()) {\r\n fxaaPostProcess.getEffect().onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotUsingRenderTargetAsync(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType: string = \"image/png\",\r\n samples: number = 1,\r\n antialiasing: boolean = false,\r\n fileName?: string,\r\n renderSprites: boolean = false\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine\r\n * @param camera\r\n * @param size\r\n * @private\r\n */\r\nfunction _GetScreenshotSize(engine: Engine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number } {\r\n let height = 0;\r\n let width = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n\r\n return { height: height | 0, width: width | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @hidden\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
1
+ {"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Misc/screenshotTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKhC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAc,EACd,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAA8B,EAC9B,aAAqB;IADrB,yBAAA,EAAA,sBAA8B;IAC9B,8BAAA,EAAA,qBAAqB;IAEf,IAAA,KAAoB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAA1D,MAAM,YAAA,EAAE,KAAK,WAA6C,CAAC;IAEnE,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE;QACpB,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC3C,OAAO;KACV;IAED,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE;QAC1B,KAAK,CAAC,iBAAiB,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;KAC9D;IAED,KAAK,CAAC,iBAAiB,CAAC,KAAK,GAAG,KAAK,CAAC;IACtC,KAAK,CAAC,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convention */\r\nimport type { Nullable } from \"../types\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\n\r\ndeclare type Engine = import(\"../Engines/engine\").Engine;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n */\r\nexport function CreateScreenshot(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType: string = \"image/png\",\r\n forceDownload = false\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n if (!Tools._ScreenshotCanvas) {\r\n Tools._ScreenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n\r\n Tools._ScreenshotCanvas.width = width;\r\n Tools._ScreenshotCanvas.height = height;\r\n\r\n const renderContext = Tools._ScreenshotCanvas.getContext(\"2d\");\r\n\r\n const ratio = engine.getRenderWidth() / engine.getRenderHeight();\r\n let newWidth = width;\r\n let newHeight = newWidth / ratio;\r\n if (newHeight > height) {\r\n newHeight = height;\r\n newWidth = newHeight * ratio;\r\n }\r\n\r\n const offsetX = Math.max(0, width - newWidth) / 2;\r\n const offsetY = Math.max(0, height - newHeight) / 2;\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1,\r\n engine.getCreationOptions().antialias\r\n );\r\n } else {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (renderContext && renderingCanvas) {\r\n renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);\r\n }\r\n\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(undefined, mimeType);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(successCallback, mimeType);\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType: string = \"image/png\"): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType: string = \"image/png\"): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType: string = \"image/png\",\r\n samples: number = 1,\r\n antialiasing: boolean = false,\r\n fileName?: string,\r\n renderSprites: boolean = false,\r\n enableStencilBuffer: boolean = false\r\n): void {\r\n const { height, width } = _GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const originalSize = { width: engine.getRenderWidth(), height: engine.getRenderHeight() };\r\n engine.setSize(width, height); // we need this call to trigger onResizeObservable with the screenshot width/height on all the subsystems that are observing this event and that needs to (re)create some resources with the right dimensions\r\n\r\n const scene = camera.getScene();\r\n let previousCamera: Nullable<Camera> = null;\r\n const previousCameras = scene.activeCameras;\r\n\r\n scene.activeCameras = null;\r\n\r\n if (scene.activeCamera !== camera) {\r\n previousCamera = scene.activeCamera;\r\n scene.activeCamera = camera;\r\n }\r\n\r\n scene.render(); // make sure the scene is ready to be rendered in the RTT with the right list of active meshes (which depends on the camera, that may have been changed above)\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT,\r\n false,\r\n Texture.NEAREST_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = null;\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n\r\n const renderToTexture = () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n Tools.DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true);\r\n texture.dispose();\r\n });\r\n });\r\n\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n texture.render(true);\r\n\r\n // re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur\r\n // if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n if (previousCamera) {\r\n scene.activeCamera = previousCamera;\r\n }\r\n scene.activeCameras = previousCameras;\r\n engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n if (!fxaaPostProcess.getEffect().isReady()) {\r\n fxaaPostProcess.getEffect().onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport function CreateScreenshotUsingRenderTargetAsync(\r\n engine: Engine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType: string = \"image/png\",\r\n samples: number = 1,\r\n antialiasing: boolean = false,\r\n fileName?: string,\r\n renderSprites: boolean = false\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine\r\n * @param camera\r\n * @param size\r\n * @private\r\n */\r\nfunction _GetScreenshotSize(engine: Engine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number } {\r\n let height = 0;\r\n let width = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n\r\n return { height: height | 0, width: width | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @hidden\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
@@ -14,11 +14,9 @@ declare type Engine = import("../Engines/engine").Engine;
14
14
  * Inspired by https://developer.nvidia.com/gpugems/gpugems3/part-ii-light-and-shadows/chapter-13-volumetric-light-scattering-post-process
15
15
  */
16
16
  export declare class VolumetricLightScatteringPostProcess extends PostProcess {
17
- private _volumetricLightScatteringPass;
18
17
  private _volumetricLightScatteringRTT;
19
18
  private _viewPort;
20
19
  private _screenCoordinates;
21
- private _cachedDefines;
22
20
  /**
23
21
  * If not undefined, the mesh position is computed from the attached node position
24
22
  */