@babylonjs/core 8.45.4 → 8.45.5

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 (56) hide show
  1. package/AudioV2/webAudio/components/webAudioParameterComponent.js +5 -1
  2. package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
  3. package/Engines/AbstractEngine/abstractEngine.loadFile.d.ts +11 -0
  4. package/Engines/AbstractEngine/abstractEngine.loadFile.js +12 -0
  5. package/Engines/AbstractEngine/abstractEngine.loadFile.js.map +1 -0
  6. package/Engines/AbstractEngine/abstractEngine.textureLoaders.d.ts +1 -0
  7. package/Engines/AbstractEngine/abstractEngine.textureLoaders.js +4 -0
  8. package/Engines/AbstractEngine/abstractEngine.textureLoaders.js.map +1 -0
  9. package/Engines/AbstractEngine/index.d.ts +2 -0
  10. package/Engines/AbstractEngine/index.js +2 -0
  11. package/Engines/AbstractEngine/index.js.map +1 -1
  12. package/Engines/Native/Extensions/index.d.ts +1 -0
  13. package/Engines/Native/Extensions/index.js +2 -0
  14. package/Engines/Native/Extensions/index.js.map +1 -0
  15. package/Engines/Native/Extensions/nativeEngine.cubeTexture.d.ts +27 -0
  16. package/Engines/Native/Extensions/nativeEngine.cubeTexture.js +96 -0
  17. package/Engines/Native/Extensions/nativeEngine.cubeTexture.js.map +1 -0
  18. package/Engines/Native/nativePipelineContext.d.ts +2 -2
  19. package/Engines/Native/nativePipelineContext.js.map +1 -1
  20. package/Engines/Native/nativeRenderTargetWrapper.d.ts +3 -3
  21. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
  22. package/Engines/Native/validatedNativeDataStream.js +2 -2
  23. package/Engines/Native/validatedNativeDataStream.js.map +1 -1
  24. package/Engines/abstractEngine.d.ts +9 -0
  25. package/Engines/abstractEngine.js +13 -4
  26. package/Engines/abstractEngine.js.map +1 -1
  27. package/Engines/engine.d.ts +2 -6
  28. package/Engines/engine.js +2 -13
  29. package/Engines/engine.js.map +1 -1
  30. package/Engines/index.d.ts +1 -0
  31. package/Engines/index.js +1 -0
  32. package/Engines/index.js.map +1 -1
  33. package/Engines/nativeEngine.d.ts +19 -536
  34. package/Engines/nativeEngine.js +27 -2127
  35. package/Engines/nativeEngine.js.map +1 -1
  36. package/Engines/nullEngine.d.ts +2 -0
  37. package/Engines/nullEngine.js +2 -0
  38. package/Engines/nullEngine.js.map +1 -1
  39. package/Engines/thinNativeEngine.d.ts +537 -0
  40. package/Engines/thinNativeEngine.js +2033 -0
  41. package/Engines/thinNativeEngine.js.map +1 -0
  42. package/Engines/webgpuEngine.d.ts +2 -0
  43. package/Engines/webgpuEngine.js +2 -0
  44. package/Engines/webgpuEngine.js.map +1 -1
  45. package/Misc/tools.d.ts +3 -1
  46. package/Misc/tools.js +76 -59
  47. package/Misc/tools.js.map +1 -1
  48. package/Particles/Node/Blocks/index.d.ts +2 -0
  49. package/Particles/Node/Blocks/index.js +2 -0
  50. package/Particles/Node/Blocks/index.js.map +1 -1
  51. package/Particles/Node/Blocks/particleClampBlock.d.ts +42 -0
  52. package/Particles/Node/Blocks/particleClampBlock.js +114 -0
  53. package/Particles/Node/Blocks/particleClampBlock.js.map +1 -0
  54. package/XR/native/nativeXRFrame.js +1 -1
  55. package/XR/native/nativeXRFrame.js.map +1 -1
  56. package/package.json +1 -1
package/Misc/tools.d.ts CHANGED
@@ -276,6 +276,8 @@ export declare class Tools {
276
276
  * @returns a promise request object
277
277
  */
278
278
  static LoadBabylonScriptAsync(scriptUrl: string): Promise<void>;
279
+ private static _LoadScriptNative;
280
+ private static _LoadScriptWeb;
279
281
  /**
280
282
  * This function is used internally by babylon components to load a script (identified by an url). When the url returns, the
281
283
  * content of this file is added into a new script element, attached to the DOM (body element)
@@ -285,7 +287,7 @@ export declare class Tools {
285
287
  * @param scriptId defines the id of the script element
286
288
  * @param useModule defines if we should use the module strategy to load the script
287
289
  */
288
- static LoadScript(scriptUrl: string, onSuccess?: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string, useModule?: boolean): void;
290
+ static LoadScript: (scriptUrl: string, onSuccess?: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string, useModule?: boolean) => void;
289
291
  /**
290
292
  * Load an asynchronous script (identified by an url). When the url returns, the
291
293
  * content of this file is added into a new script element, attached to the DOM (body element)
package/Misc/tools.js CHANGED
@@ -1,3 +1,4 @@
1
+ var _a;
1
2
  import { Observable } from "./observable.js";
2
3
  import { GetDOMTextContent, IsNavigatorAvailable, IsWindowObjectExist } from "./domManagement.js";
3
4
  import { Logger } from "./logger.js";
@@ -86,8 +87,8 @@ export class Tools {
86
87
  */
87
88
  // eslint-disable-next-line @typescript-eslint/naming-convention
88
89
  static set CDNBaseUrl(value) {
89
- Tools.ScriptBaseUrl = value;
90
- Tools.AssetBaseUrl = value;
90
+ _a.ScriptBaseUrl = value;
91
+ _a.AssetBaseUrl = value;
91
92
  }
92
93
  /**
93
94
  * Sets a preprocessing function to run on a source URL before importing it
@@ -369,10 +370,10 @@ export class Tools {
369
370
  if (!url) {
370
371
  return "";
371
372
  }
372
- if (Tools.AssetBaseUrl && url.startsWith(Tools._DefaultAssetsUrl)) {
373
+ if (_a.AssetBaseUrl && url.startsWith(_a._DefaultAssetsUrl)) {
373
374
  // normalize the baseUrl
374
- const baseUrl = Tools.AssetBaseUrl[Tools.AssetBaseUrl.length - 1] === "/" ? Tools.AssetBaseUrl.substring(0, Tools.AssetBaseUrl.length - 1) : Tools.AssetBaseUrl;
375
- return url.replace(Tools._DefaultAssetsUrl, baseUrl);
375
+ const baseUrl = _a.AssetBaseUrl[_a.AssetBaseUrl.length - 1] === "/" ? _a.AssetBaseUrl.substring(0, _a.AssetBaseUrl.length - 1) : _a.AssetBaseUrl;
376
+ return url.replace(_a._DefaultAssetsUrl, baseUrl);
376
377
  }
377
378
  return url;
378
379
  }
@@ -387,16 +388,16 @@ export class Tools {
387
388
  return "";
388
389
  }
389
390
  // if the base URL was set, and the script Url is an absolute path change the default path
390
- if (Tools.ScriptBaseUrl && scriptUrl.startsWith(Tools._DefaultCdnUrl)) {
391
+ if (_a.ScriptBaseUrl && scriptUrl.startsWith(_a._DefaultCdnUrl)) {
391
392
  // change the default host, which is https://cdn.babylonjs.com with the one defined
392
393
  // make sure no trailing slash is present
393
- const baseUrl = Tools.ScriptBaseUrl[Tools.ScriptBaseUrl.length - 1] === "/" ? Tools.ScriptBaseUrl.substring(0, Tools.ScriptBaseUrl.length - 1) : Tools.ScriptBaseUrl;
394
- scriptUrl = scriptUrl.replace(Tools._DefaultCdnUrl, baseUrl);
394
+ const baseUrl = _a.ScriptBaseUrl[_a.ScriptBaseUrl.length - 1] === "/" ? _a.ScriptBaseUrl.substring(0, _a.ScriptBaseUrl.length - 1) : _a.ScriptBaseUrl;
395
+ scriptUrl = scriptUrl.replace(_a._DefaultCdnUrl, baseUrl);
395
396
  }
396
397
  // run the preprocessor
397
- scriptUrl = Tools.ScriptPreprocessUrl(scriptUrl);
398
- if (forceAbsoluteUrl && !Tools.IsAbsoluteUrl(scriptUrl)) {
399
- scriptUrl = Tools.GetAbsoluteUrl(scriptUrl);
398
+ scriptUrl = _a.ScriptPreprocessUrl(scriptUrl);
399
+ if (forceAbsoluteUrl && !_a.IsAbsoluteUrl(scriptUrl)) {
400
+ scriptUrl = _a.GetAbsoluteUrl(scriptUrl);
400
401
  }
401
402
  return scriptUrl;
402
403
  }
@@ -409,8 +410,8 @@ export class Tools {
409
410
  * @param scriptId defines the id of the script element
410
411
  */
411
412
  static LoadBabylonScript(scriptUrl, onSuccess, onError, scriptId) {
412
- scriptUrl = Tools.GetBabylonScriptURL(scriptUrl);
413
- Tools.LoadScript(scriptUrl, onSuccess, onError);
413
+ scriptUrl = _a.GetBabylonScriptURL(scriptUrl);
414
+ _a.LoadScript(scriptUrl, onSuccess, onError);
414
415
  }
415
416
  /**
416
417
  * Load an asynchronous script (identified by an url). When the url returns, the
@@ -419,19 +420,24 @@ export class Tools {
419
420
  * @returns a promise request object
420
421
  */
421
422
  static async LoadBabylonScriptAsync(scriptUrl) {
422
- scriptUrl = Tools.GetBabylonScriptURL(scriptUrl);
423
- return await Tools.LoadScriptAsync(scriptUrl);
423
+ scriptUrl = _a.GetBabylonScriptURL(scriptUrl);
424
+ return await _a.LoadScriptAsync(scriptUrl);
424
425
  }
425
- /**
426
- * This function is used internally by babylon components to load a script (identified by an url). When the url returns, the
427
- * content of this file is added into a new script element, attached to the DOM (body element)
428
- * @param scriptUrl defines the url of the script to load
429
- * @param onSuccess defines the callback called when the script is loaded
430
- * @param onError defines the callback to call if an error occurs
431
- * @param scriptId defines the id of the script element
432
- * @param useModule defines if we should use the module strategy to load the script
433
- */
434
- static LoadScript(scriptUrl, onSuccess, onError, scriptId, useModule = false) {
426
+ static _LoadScriptNative(scriptUrl, onSuccess, onError) {
427
+ if (_native) {
428
+ _a.LoadFile(scriptUrl, (data) => {
429
+ Function(data).apply(null);
430
+ if (onSuccess) {
431
+ onSuccess();
432
+ }
433
+ }, undefined, undefined, false, (_request, exception) => {
434
+ if (onError) {
435
+ onError("LoadScript Error", exception);
436
+ }
437
+ });
438
+ }
439
+ }
440
+ static _LoadScriptWeb(scriptUrl, onSuccess, onError, scriptId, useModule = false) {
435
441
  if (typeof importScripts === "function") {
436
442
  try {
437
443
  importScripts(scriptUrl);
@@ -668,7 +674,7 @@ export class Tools {
668
674
  */
669
675
  static ToBlob(canvas, successCallback, mimeType = "image/png", quality) {
670
676
  // We need HTMLCanvasElement.toBlob for HD screenshots
671
- if (!Tools._IsOffScreenCanvas(canvas) && !canvas.toBlob) {
677
+ if (!_a._IsOffScreenCanvas(canvas) && !canvas.toBlob) {
672
678
  // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
673
679
  canvas.toBlob = function (callback, type, quality) {
674
680
  setTimeout(() => {
@@ -680,7 +686,7 @@ export class Tools {
680
686
  });
681
687
  };
682
688
  }
683
- if (Tools._IsOffScreenCanvas(canvas)) {
689
+ if (_a._IsOffScreenCanvas(canvas)) {
684
690
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
685
691
  canvas
686
692
  .convertToBlob({
@@ -709,7 +715,7 @@ export class Tools {
709
715
  const stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ("0" + date.getMinutes()).slice(-2);
710
716
  fileName = "screenshot_" + stringDate + ".png";
711
717
  }
712
- Tools.Download(blob, fileName);
718
+ _a.Download(blob, fileName);
713
719
  }
714
720
  else {
715
721
  if (blob && typeof URL !== "undefined") {
@@ -740,7 +746,7 @@ export class Tools {
740
746
  if (typeof fileName === "string" || !successCallback) {
741
747
  this.ToBlob(canvas, function (blob) {
742
748
  if (blob) {
743
- Tools.DownloadBlob(blob, fileName);
749
+ _a.DownloadBlob(blob, fileName);
744
750
  }
745
751
  if (successCallback) {
746
752
  successCallback("");
@@ -748,7 +754,7 @@ export class Tools {
748
754
  }, mimeType, quality);
749
755
  }
750
756
  else if (successCallback) {
751
- if (Tools._IsOffScreenCanvas(canvas)) {
757
+ if (_a._IsOffScreenCanvas(canvas)) {
752
758
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
753
759
  canvas
754
760
  .convertToBlob({
@@ -987,32 +993,32 @@ export class Tools {
987
993
  * Sets the current performance log level
988
994
  */
989
995
  static set PerformanceLogLevel(level) {
990
- if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
996
+ if ((level & _a.PerformanceUserMarkLogLevel) === _a.PerformanceUserMarkLogLevel) {
991
997
  if (_native?.enablePerformanceLogging) {
992
998
  _native.enablePerformanceLogging(1 /* NativeTraceLevel.Mark */);
993
- Tools.StartPerformanceCounter = Tools._StartMarkNative;
994
- Tools.EndPerformanceCounter = Tools._EndMarkNative;
999
+ _a.StartPerformanceCounter = _a._StartMarkNative;
1000
+ _a.EndPerformanceCounter = _a._EndMarkNative;
995
1001
  }
996
1002
  else {
997
- Tools.StartPerformanceCounter = Tools._StartUserMark;
998
- Tools.EndPerformanceCounter = Tools._EndUserMark;
1003
+ _a.StartPerformanceCounter = _a._StartUserMark;
1004
+ _a.EndPerformanceCounter = _a._EndUserMark;
999
1005
  }
1000
1006
  return;
1001
1007
  }
1002
- if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
1008
+ if ((level & _a.PerformanceConsoleLogLevel) === _a.PerformanceConsoleLogLevel) {
1003
1009
  if (_native?.enablePerformanceLogging) {
1004
1010
  _native.enablePerformanceLogging(2 /* NativeTraceLevel.Log */);
1005
- Tools.StartPerformanceCounter = Tools._StartMarkNative;
1006
- Tools.EndPerformanceCounter = Tools._EndMarkNative;
1011
+ _a.StartPerformanceCounter = _a._StartMarkNative;
1012
+ _a.EndPerformanceCounter = _a._EndMarkNative;
1007
1013
  }
1008
1014
  else {
1009
- Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
1010
- Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
1015
+ _a.StartPerformanceCounter = _a._StartPerformanceConsole;
1016
+ _a.EndPerformanceCounter = _a._EndPerformanceConsole;
1011
1017
  }
1012
1018
  return;
1013
1019
  }
1014
- Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
1015
- Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
1020
+ _a.StartPerformanceCounter = _a._StartPerformanceCounterDisabled;
1021
+ _a.EndPerformanceCounter = _a._EndPerformanceCounterDisabled;
1016
1022
  _native?.disablePerformanceLogging?.();
1017
1023
  }
1018
1024
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1020,29 +1026,29 @@ export class Tools {
1020
1026
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1021
1027
  static _EndPerformanceCounterDisabled(counterName, condition) { }
1022
1028
  static _StartUserMark(counterName, condition = true) {
1023
- if (!Tools._Performance) {
1029
+ if (!_a._Performance) {
1024
1030
  if (!IsWindowObjectExist()) {
1025
1031
  return;
1026
1032
  }
1027
- Tools._Performance = window.performance;
1033
+ _a._Performance = window.performance;
1028
1034
  }
1029
- if (!condition || !Tools._Performance.mark) {
1035
+ if (!condition || !_a._Performance.mark) {
1030
1036
  return;
1031
1037
  }
1032
- Tools._Performance.mark(counterName + "-Begin");
1038
+ _a._Performance.mark(counterName + "-Begin");
1033
1039
  }
1034
1040
  static _EndUserMark(counterName, condition = true) {
1035
- if (!condition || !Tools._Performance.mark) {
1041
+ if (!condition || !_a._Performance.mark) {
1036
1042
  return;
1037
1043
  }
1038
- Tools._Performance.mark(counterName + "-End");
1039
- Tools._Performance.measure(counterName, counterName + "-Begin", counterName + "-End");
1044
+ _a._Performance.mark(counterName + "-End");
1045
+ _a._Performance.measure(counterName, counterName + "-Begin", counterName + "-End");
1040
1046
  }
1041
1047
  static _StartPerformanceConsole(counterName, condition = true) {
1042
1048
  if (!condition) {
1043
1049
  return;
1044
1050
  }
1045
- Tools._StartUserMark(counterName, condition);
1051
+ _a._StartUserMark(counterName, condition);
1046
1052
  if (console.time) {
1047
1053
  console.time(counterName);
1048
1054
  }
@@ -1051,29 +1057,29 @@ export class Tools {
1051
1057
  if (!condition) {
1052
1058
  return;
1053
1059
  }
1054
- Tools._EndUserMark(counterName, condition);
1060
+ _a._EndUserMark(counterName, condition);
1055
1061
  console.timeEnd(counterName);
1056
1062
  }
1057
1063
  static _StartMarkNative(counterName, condition = true) {
1058
1064
  if (condition && _native?.startPerformanceCounter) {
1059
- if (Tools._NativePerformanceCounterHandles.has(counterName)) {
1060
- Tools.Warn(`Performance counter with name ${counterName} is already started.`);
1065
+ if (_a._NativePerformanceCounterHandles.has(counterName)) {
1066
+ _a.Warn(`Performance counter with name ${counterName} is already started.`);
1061
1067
  }
1062
1068
  else {
1063
1069
  const handle = _native.startPerformanceCounter(counterName);
1064
- Tools._NativePerformanceCounterHandles.set(counterName, handle);
1070
+ _a._NativePerformanceCounterHandles.set(counterName, handle);
1065
1071
  }
1066
1072
  }
1067
1073
  }
1068
1074
  static _EndMarkNative(counterName, condition = true) {
1069
1075
  if (condition && _native?.endPerformanceCounter) {
1070
- const handle = Tools._NativePerformanceCounterHandles.get(counterName);
1076
+ const handle = _a._NativePerformanceCounterHandles.get(counterName);
1071
1077
  if (handle) {
1072
1078
  _native.endPerformanceCounter(handle);
1073
- Tools._NativePerformanceCounterHandles.delete(counterName);
1079
+ _a._NativePerformanceCounterHandles.delete(counterName);
1074
1080
  }
1075
1081
  else {
1076
- Tools.Warn(`Performance counter with name ${counterName} was not started.`);
1082
+ _a.Warn(`Performance counter with name ${counterName} was not started.`);
1077
1083
  }
1078
1084
  }
1079
1085
  }
@@ -1173,6 +1179,7 @@ export class Tools {
1173
1179
  return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
1174
1180
  }
1175
1181
  }
1182
+ _a = Tools;
1176
1183
  /**
1177
1184
  * The base URL to use to load assets. If empty the default base url is used.
1178
1185
  */
@@ -1201,6 +1208,16 @@ Tools._DefaultCdnUrl = "https://cdn.babylonjs.com";
1201
1208
  * @internal
1202
1209
  */
1203
1210
  Tools._DefaultAssetsUrl = "https://assets.babylonjs.com/core";
1211
+ /**
1212
+ * This function is used internally by babylon components to load a script (identified by an url). When the url returns, the
1213
+ * content of this file is added into a new script element, attached to the DOM (body element)
1214
+ * @param scriptUrl defines the url of the script to load
1215
+ * @param onSuccess defines the callback called when the script is loaded
1216
+ * @param onError defines the callback to call if an error occurs
1217
+ * @param scriptId defines the id of the script element
1218
+ * @param useModule defines if we should use the module strategy to load the script
1219
+ */
1220
+ Tools.LoadScript = typeof _native === "undefined" ? _a._LoadScriptWeb : _a._LoadScriptNative;
1204
1221
  // eslint-disable-next-line jsdoc/require-returns-check, jsdoc/require-param
1205
1222
  /**
1206
1223
  * @returns the absolute URL of a given (relative) url
@@ -1259,11 +1276,11 @@ Tools._NativePerformanceCounterHandles = new Map();
1259
1276
  /**
1260
1277
  * Starts a performance counter
1261
1278
  */
1262
- Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
1279
+ Tools.StartPerformanceCounter = _a._StartPerformanceCounterDisabled;
1263
1280
  /**
1264
1281
  * Ends a specific performance counter
1265
1282
  */
1266
- Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
1283
+ Tools.EndPerformanceCounter = _a._EndPerformanceCounterDisabled;
1267
1284
  /**
1268
1285
  * Use this className as a decorator on a given class definition to add it a name and optionally its module.
1269
1286
  * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.