@babylonjs/core 5.46.0 → 5.47.1

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 (73) hide show
  1. package/Actions/actionManager.js +6 -1
  2. package/Actions/actionManager.js.map +1 -1
  3. package/Debug/physicsViewer.js +3 -3
  4. package/Debug/physicsViewer.js.map +1 -1
  5. package/DeviceInput/eventFactory.d.ts +1 -1
  6. package/DeviceInput/eventFactory.js +4 -4
  7. package/DeviceInput/eventFactory.js.map +1 -1
  8. package/DeviceInput/webDeviceInputSystem.js +2 -2
  9. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  10. package/Engines/Extensions/engine.alpha.js +7 -0
  11. package/Engines/Extensions/engine.alpha.js.map +1 -1
  12. package/Engines/WebGPU/Extensions/engine.alpha.js +8 -0
  13. package/Engines/WebGPU/Extensions/engine.alpha.js.map +1 -1
  14. package/Engines/engine.d.ts +1 -3
  15. package/Engines/engine.js +27 -33
  16. package/Engines/engine.js.map +1 -1
  17. package/Engines/thinEngine.d.ts +44 -30
  18. package/Engines/thinEngine.js +42 -57
  19. package/Engines/thinEngine.js.map +1 -1
  20. package/Engines/webgpuEngine.d.ts +10 -56
  21. package/Engines/webgpuEngine.js +15 -31
  22. package/Engines/webgpuEngine.js.map +1 -1
  23. package/Events/pointerEvents.js +1 -1
  24. package/Events/pointerEvents.js.map +1 -1
  25. package/Inputs/scene.inputManager.d.ts +4 -3
  26. package/Inputs/scene.inputManager.js +12 -11
  27. package/Inputs/scene.inputManager.js.map +1 -1
  28. package/Materials/PBR/pbrBaseMaterial.js +1 -3
  29. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  30. package/Materials/Textures/videoTexture.js +1 -1
  31. package/Materials/Textures/videoTexture.js.map +1 -1
  32. package/Maths/math.vector.d.ts +21 -0
  33. package/Maths/math.vector.js +27 -0
  34. package/Maths/math.vector.js.map +1 -1
  35. package/Meshes/mesh.js +1 -1
  36. package/Meshes/mesh.js.map +1 -1
  37. package/Particles/particleSystemComponent.js +5 -0
  38. package/Particles/particleSystemComponent.js.map +1 -1
  39. package/Physics/index.d.ts +1 -0
  40. package/Physics/index.js +1 -0
  41. package/Physics/index.js.map +1 -1
  42. package/Physics/v2/IPhysicsEnginePlugin.d.ts +12 -14
  43. package/Physics/v2/IPhysicsEnginePlugin.js +6 -5
  44. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  45. package/Physics/v2/physicsBody.d.ts +14 -5
  46. package/Physics/v2/physicsBody.js +19 -7
  47. package/Physics/v2/physicsBody.js.map +1 -1
  48. package/Physics/v2/physicsConstraint.d.ts +139 -66
  49. package/Physics/v2/physicsConstraint.js +146 -79
  50. package/Physics/v2/physicsConstraint.js.map +1 -1
  51. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +9 -1
  52. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  53. package/Rendering/fluidRenderer/fluidRenderingObject.js +3 -0
  54. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
  55. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +3 -0
  56. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
  57. package/Rendering/geometryBufferRenderer.js +129 -124
  58. package/Rendering/geometryBufferRenderer.js.map +1 -1
  59. package/Shaders/ShadersInclude/pbrBlockClearcoat.js +1 -3
  60. package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
  61. package/Shaders/ShadersInclude/pbrBlockSubSurface.js +1 -1
  62. package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
  63. package/Shaders/fluidRenderingParticleDepth.fragment.js +5 -1
  64. package/Shaders/fluidRenderingParticleDepth.fragment.js.map +1 -1
  65. package/Shaders/fluidRenderingRender.fragment.js +7 -2
  66. package/Shaders/fluidRenderingRender.fragment.js.map +1 -1
  67. package/Shaders/geometry.fragment.d.ts +2 -0
  68. package/Shaders/geometry.fragment.js +5 -1
  69. package/Shaders/geometry.fragment.js.map +1 -1
  70. package/Shaders/geometry.vertex.d.ts +2 -0
  71. package/Shaders/geometry.vertex.js +8 -4
  72. package/Shaders/geometry.vertex.js.map +1 -1
  73. package/package.json +1 -1
@@ -56,23 +56,13 @@ export interface HostInformation {
56
56
  */
57
57
  isMobile: boolean;
58
58
  }
59
- /** Interface defining initialization parameters for Engine class */
60
- export interface EngineOptions extends WebGLContextAttributes {
59
+ /** Interface defining initialization parameters for ThinEngine class */
60
+ export interface ThinEngineOptions {
61
61
  /**
62
62
  * Defines if the engine should no exceed a specified device ratio
63
63
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
64
64
  */
65
65
  limitDeviceRatio?: number;
66
- /**
67
- * Defines if webvr should be enabled automatically
68
- * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/webVRCamera
69
- */
70
- autoEnableWebVR?: boolean;
71
- /**
72
- * Defines if webgl2 should be turned off even if supported
73
- * @see https://doc.babylonjs.com/setup/support/webGL2
74
- */
75
- disableWebGL2Support?: boolean;
76
66
  /**
77
67
  * Defines if webaudio should be initialized as well
78
68
  * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic
@@ -101,6 +91,44 @@ export interface EngineOptions extends WebGLContextAttributes {
101
91
  * If not handle, you might need to set it up on your side for expected touch devices behavior.
102
92
  */
103
93
  doNotHandleTouchAction?: boolean;
94
+ /**
95
+ * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
96
+ */
97
+ useHighPrecisionMatrix?: boolean;
98
+ /**
99
+ * Defines whether to adapt to the device's viewport characteristics (default: false)
100
+ */
101
+ adaptToDeviceRatio?: boolean;
102
+ /**
103
+ * True if the more expensive but exact conversions should be used for transforming colors to and from linear space within shaders.
104
+ * Otherwise, the default is to use a cheaper approximation.
105
+ */
106
+ useExactSrgbConversions?: boolean;
107
+ /**
108
+ * Defines whether MSAA is enabled on the canvas.
109
+ */
110
+ antialias?: boolean;
111
+ /**
112
+ * Defines whether the stencil buffer should be enabled.
113
+ */
114
+ stencil?: boolean;
115
+ /**
116
+ * Defines whether the canvas should be created in "premultiplied" mode (if false, the canvas is created in the "opaque" mode) (true by default)
117
+ */
118
+ premultipliedAlpha?: boolean;
119
+ }
120
+ /** Interface defining initialization parameters for Engine class */
121
+ export interface EngineOptions extends ThinEngineOptions, WebGLContextAttributes {
122
+ /**
123
+ * Defines if webvr should be enabled automatically
124
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/webVRCamera
125
+ */
126
+ autoEnableWebVR?: boolean;
127
+ /**
128
+ * Defines if webgl2 should be turned off even if supported
129
+ * @see https://doc.babylonjs.com/setup/support/webGL2
130
+ */
131
+ disableWebGL2Support?: boolean;
104
132
  /**
105
133
  * Defines that engine should compile shaders with high precision floats (if supported). True by default
106
134
  */
@@ -109,29 +137,16 @@ export interface EngineOptions extends WebGLContextAttributes {
109
137
  * Make the canvas XR Compatible for XR sessions
110
138
  */
111
139
  xrCompatible?: boolean;
112
- /**
113
- * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
114
- */
115
- useHighPrecisionMatrix?: boolean;
116
140
  /**
117
141
  * Will prevent the system from falling back to software implementation if a hardware device cannot be created
118
142
  */
119
143
  failIfMajorPerformanceCaveat?: boolean;
120
- /**
121
- * Defines whether to adapt to the device's viewport characteristics (default: false)
122
- */
123
- adaptToDeviceRatio?: boolean;
124
144
  /**
125
145
  * If sRGB Buffer support is not set during construction, use this value to force a specific state
126
146
  * This is added due to an issue when processing textures in chrome/edge/firefox
127
147
  * This will not influence NativeEngine and WebGPUEngine which set the behavior to true during construction.
128
148
  */
129
149
  forceSRGBBufferSupportState?: boolean;
130
- /**
131
- * True if the more expensive but exact conversions should be used for transforming colors to and from linear space within shaders.
132
- * Otherwise, the default is to use a cheaper approximation.
133
- */
134
- useExactSrgbConversions?: boolean;
135
150
  }
136
151
  /**
137
152
  * The base engine class (root of all engines)
@@ -221,11 +236,11 @@ export declare class ThinEngine {
221
236
  /**
222
237
  * Indicates if the z range in NDC space is 0..1 (value: true) or -1..1 (value: false)
223
238
  */
224
- readonly isNDCHalfZRange = false;
239
+ readonly isNDCHalfZRange: boolean;
225
240
  /**
226
241
  * Indicates that the origin of the texture/framebuffer space is the bottom left corner. If false, the origin is top left
227
242
  */
228
- readonly hasOriginBottomLeft = true;
243
+ readonly hasOriginBottomLeft: boolean;
229
244
  /**
230
245
  * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
231
246
  */
@@ -503,14 +518,13 @@ export declare class ThinEngine {
503
518
  * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
504
519
  */
505
520
  constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
521
+ protected _setupMobileChecks(): void;
506
522
  protected _restoreEngineAfterContextLost(initEngine: () => void): void;
507
523
  /**
508
524
  * Shared initialization across engines types.
509
525
  * @param canvas The canvas associated with this instance of the engine.
510
- * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
511
- * @param audioEngine Defines if an audio engine should be created by default
512
526
  */
513
- protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
527
+ protected _sharedInit(canvas: HTMLCanvasElement): void;
514
528
  /**
515
529
  * @internal
516
530
  */
@@ -34,13 +34,13 @@ export class ThinEngine {
34
34
  */
35
35
  // Not mixed with Version for tooling purpose.
36
36
  static get NpmPackage() {
37
- return "babylonjs@5.46.0";
37
+ return "babylonjs@5.47.1";
38
38
  }
39
39
  /**
40
40
  * Returns the current version of the framework
41
41
  */
42
42
  static get Version() {
43
- return "5.46.0";
43
+ return "5.47.1";
44
44
  }
45
45
  /**
46
46
  * Returns a string describing the current engine
@@ -280,6 +280,7 @@ export class ThinEngine {
280
280
  * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
281
281
  */
282
282
  constructor(canvasOrContext, antialias, options, adaptToDeviceRatio) {
283
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
283
284
  /** @internal */
284
285
  this._name = "WebGL";
285
286
  /**
@@ -440,66 +441,39 @@ export class ThinEngine {
440
441
  this.adaptToDeviceRatio = adaptToDeviceRatio !== null && adaptToDeviceRatio !== void 0 ? adaptToDeviceRatio : false;
441
442
  this._stencilStateComposer.stencilGlobal = this._stencilState;
442
443
  PerformanceConfigurator.SetMatrixPrecision(!!options.useHighPrecisionMatrix);
444
+ options.antialias = antialias !== null && antialias !== void 0 ? antialias : options.antialias;
445
+ options.deterministicLockstep = (_a = options.deterministicLockstep) !== null && _a !== void 0 ? _a : false;
446
+ options.lockstepMaxSteps = (_b = options.lockstepMaxSteps) !== null && _b !== void 0 ? _b : 4;
447
+ options.timeStep = (_c = options.timeStep) !== null && _c !== void 0 ? _c : 1 / 60;
448
+ options.audioEngine = (_d = options.audioEngine) !== null && _d !== void 0 ? _d : true;
449
+ options.stencil = (_e = options.stencil) !== null && _e !== void 0 ? _e : true;
450
+ this._audioContext = (_g = (_f = options.audioEngineOptions) === null || _f === void 0 ? void 0 : _f.audioContext) !== null && _g !== void 0 ? _g : null;
451
+ this._audioDestination = (_j = (_h = options.audioEngineOptions) === null || _h === void 0 ? void 0 : _h.audioDestination) !== null && _j !== void 0 ? _j : null;
452
+ this.premultipliedAlpha = (_k = options.premultipliedAlpha) !== null && _k !== void 0 ? _k : true;
453
+ this._useExactSrgbConversions = (_l = options.useExactSrgbConversions) !== null && _l !== void 0 ? _l : false;
454
+ this._doNotHandleContextLost = !!options.doNotHandleContextLost;
455
+ this._isStencilEnable = options.stencil ? true : false;
456
+ // Viewport
457
+ adaptToDeviceRatio = adaptToDeviceRatio || options.adaptToDeviceRatio || false;
458
+ const devicePixelRatio = IsWindowObjectExist() ? window.devicePixelRatio || 1.0 : 1.0;
459
+ const limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
460
+ this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
461
+ this._lastDevicePixelRatio = devicePixelRatio;
443
462
  if (!canvasOrContext) {
444
463
  return;
445
464
  }
446
- adaptToDeviceRatio = adaptToDeviceRatio || options.adaptToDeviceRatio || false;
447
465
  if (canvasOrContext.getContext) {
448
466
  canvas = canvasOrContext;
449
467
  this._renderingCanvas = canvas;
450
- if (antialias !== undefined) {
451
- options.antialias = antialias;
452
- }
453
- if (options.deterministicLockstep === undefined) {
454
- options.deterministicLockstep = false;
455
- }
456
- if (options.lockstepMaxSteps === undefined) {
457
- options.lockstepMaxSteps = 4;
458
- }
459
- if (options.timeStep === undefined) {
460
- options.timeStep = 1 / 60;
461
- }
462
468
  if (options.preserveDrawingBuffer === undefined) {
463
469
  options.preserveDrawingBuffer = false;
464
470
  }
465
- if (options.audioEngine === undefined) {
466
- options.audioEngine = true;
467
- }
468
- if (options.audioEngineOptions !== undefined && options.audioEngineOptions.audioContext !== undefined) {
469
- this._audioContext = options.audioEngineOptions.audioContext;
470
- }
471
- if (options.audioEngineOptions !== undefined && options.audioEngineOptions.audioDestination !== undefined) {
472
- this._audioDestination = options.audioEngineOptions.audioDestination;
473
- }
474
- if (options.stencil === undefined) {
475
- options.stencil = true;
476
- }
477
- if (options.premultipliedAlpha === false) {
478
- this.premultipliedAlpha = false;
479
- }
480
471
  if (options.xrCompatible === undefined) {
481
472
  options.xrCompatible = true;
482
473
  }
483
- if (options.useExactSrgbConversions !== undefined) {
484
- this._useExactSrgbConversions = options.useExactSrgbConversions;
485
- }
486
- this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
487
474
  // Exceptions
488
475
  if (navigator && navigator.userAgent) {
489
- // Function to check if running on mobile device
490
- this._checkForMobile = () => {
491
- const currentUA = navigator.userAgent;
492
- this.hostInformation.isMobile =
493
- currentUA.indexOf("Mobile") !== -1 ||
494
- // Needed for iOS 13+ detection on iPad (inspired by solution from https://stackoverflow.com/questions/9038625/detect-if-device-is-ios)
495
- (currentUA.indexOf("Mac") !== -1 && IsDocumentAvailable() && "ontouchend" in document);
496
- };
497
- // Set initial isMobile value
498
- this._checkForMobile();
499
- // Set up event listener to check when window is resized (used to get emulator activation to work properly)
500
- if (IsWindowObjectExist()) {
501
- window.addEventListener("resize", this._checkForMobile);
502
- }
476
+ this._setupMobileChecks();
503
477
  const ua = navigator.userAgent;
504
478
  for (const exception of ThinEngine.ExceptionList) {
505
479
  const key = exception.key;
@@ -610,13 +584,7 @@ export class ThinEngine {
610
584
  if (options.useHighPrecisionFloats !== undefined) {
611
585
  this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;
612
586
  }
613
- // Viewport
614
- const devicePixelRatio = IsWindowObjectExist() ? window.devicePixelRatio || 1.0 : 1.0;
615
- const limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
616
- this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
617
- this._lastDevicePixelRatio = devicePixelRatio;
618
587
  this.resize();
619
- this._isStencilEnable = options.stencil ? true : false;
620
588
  this._initGLContext();
621
589
  this._initFeatures();
622
590
  // Prepare buffer pointers
@@ -641,6 +609,25 @@ export class ThinEngine {
641
609
  this._renderingCanvas.setAttribute("data-engine", versionToLog);
642
610
  }
643
611
  }
612
+ _setupMobileChecks() {
613
+ if (!(navigator && navigator.userAgent)) {
614
+ return;
615
+ }
616
+ // Function to check if running on mobile device
617
+ this._checkForMobile = () => {
618
+ const currentUA = navigator.userAgent;
619
+ this.hostInformation.isMobile =
620
+ currentUA.indexOf("Mobile") !== -1 ||
621
+ // Needed for iOS 13+ detection on iPad (inspired by solution from https://stackoverflow.com/questions/9038625/detect-if-device-is-ios)
622
+ (currentUA.indexOf("Mac") !== -1 && IsDocumentAvailable() && "ontouchend" in document);
623
+ };
624
+ // Set initial isMobile value
625
+ this._checkForMobile();
626
+ // Set up event listener to check when window is resized (used to get emulator activation to work properly)
627
+ if (IsWindowObjectExist()) {
628
+ window.addEventListener("resize", this._checkForMobile);
629
+ }
630
+ }
644
631
  _restoreEngineAfterContextLost(initEngine) {
645
632
  // Adding a timeout to avoid race condition at browser level
646
633
  setTimeout(async () => {
@@ -680,10 +667,8 @@ export class ThinEngine {
680
667
  /**
681
668
  * Shared initialization across engines types.
682
669
  * @param canvas The canvas associated with this instance of the engine.
683
- * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
684
- * @param audioEngine Defines if an audio engine should be created by default
685
670
  */
686
- _sharedInit(canvas, doNotHandleTouchAction, audioEngine) {
671
+ _sharedInit(canvas) {
687
672
  this._renderingCanvas = canvas;
688
673
  }
689
674
  /**