@babylonjs/core 9.8.0 → 9.9.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 (103) hide show
  1. package/Audio/audioSceneComponent.pure.js +17 -9
  2. package/Bones/bone.pure.js +39 -29
  3. package/Cameras/arcRotateCamera.pure.d.ts +0 -8
  4. package/Cameras/arcRotateCamera.pure.js +0 -12
  5. package/Cameras/arcRotateCamera.pure.js.map +1 -1
  6. package/Cameras/inputMapper.d.ts +29 -8
  7. package/Cameras/inputMapper.js +63 -10
  8. package/Cameras/inputMapper.js.map +1 -1
  9. package/Cameras/targetCamera.pure.js +40 -27
  10. package/Culling/Helper/transformFeedbackBoundingHelper.pure.js +17 -23
  11. package/Engines/abstractEngine.pure.js +4 -4
  12. package/Engines/abstractEngine.pure.js.map +1 -1
  13. package/Engines/thinEngine.pure.js +234 -280
  14. package/Materials/Background/backgroundMaterial.pure.js +5 -4
  15. package/Materials/Background/backgroundMaterial.pure.js.map +1 -1
  16. package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.d.ts +5 -0
  17. package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.js +8 -0
  18. package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.js.map +1 -0
  19. package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.d.ts +278 -0
  20. package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.js +718 -0
  21. package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.js.map +1 -0
  22. package/Materials/GaussianSplatting/pure.d.ts +1 -0
  23. package/Materials/GaussianSplatting/pure.js +1 -0
  24. package/Materials/GaussianSplatting/pure.js.map +1 -1
  25. package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.js +10 -14
  26. package/Materials/Node/Blocks/Dual/index.d.ts +0 -14
  27. package/Materials/Node/Blocks/Dual/index.js +0 -18
  28. package/Materials/Node/Blocks/Dual/index.js.map +1 -1
  29. package/Materials/Node/Blocks/Dual/textureBlock.pure.js +660 -662
  30. package/Materials/Node/Blocks/Fragment/index.d.ts +0 -10
  31. package/Materials/Node/Blocks/Fragment/index.js +0 -13
  32. package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
  33. package/Materials/Node/Blocks/GaussianSplatting/index.d.ts +12 -0
  34. package/Materials/Node/Blocks/GaussianSplatting/index.js +14 -1
  35. package/Materials/Node/Blocks/GaussianSplatting/index.js.map +1 -1
  36. package/Materials/Node/Blocks/Vertex/index.d.ts +0 -8
  37. package/Materials/Node/Blocks/Vertex/index.js +0 -10
  38. package/Materials/Node/Blocks/Vertex/index.js.map +1 -1
  39. package/Materials/PBR/openpbrMaterial.pure.js +6 -5
  40. package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
  41. package/Materials/PBR/pbrBaseMaterial.pure.js +6 -5
  42. package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
  43. package/Materials/Textures/index.d.ts +1 -0
  44. package/Materials/Textures/index.js +1 -0
  45. package/Materials/Textures/index.js.map +1 -1
  46. package/Materials/Textures/internalTexture.js +7 -0
  47. package/Materials/Textures/internalTexture.js.map +1 -1
  48. package/Materials/Textures/texture.pure.js +157 -255
  49. package/Materials/index.d.ts +30 -0
  50. package/Materials/index.js +31 -0
  51. package/Materials/index.js.map +1 -1
  52. package/Materials/material.pure.js +128 -69
  53. package/Materials/pure.d.ts +1 -0
  54. package/Materials/pure.js +1 -0
  55. package/Materials/pure.js.map +1 -1
  56. package/Materials/standardMaterial.pure.js +6 -5
  57. package/Materials/standardMaterial.pure.js.map +1 -1
  58. package/Maths/math.color.pure.js +55 -47
  59. package/Maths/math.vector.pure.js +118 -242
  60. package/Meshes/GaussianSplatting/gaussianSplattingDebugger.d.ts +7 -0
  61. package/Meshes/GaussianSplatting/gaussianSplattingDebugger.js +8 -0
  62. package/Meshes/GaussianSplatting/gaussianSplattingDebugger.js.map +1 -0
  63. package/Meshes/GaussianSplatting/gaussianSplattingDebugger.pure.d.ts +147 -0
  64. package/Meshes/GaussianSplatting/gaussianSplattingDebugger.pure.js +257 -0
  65. package/Meshes/GaussianSplatting/gaussianSplattingDebugger.pure.js.map +1 -0
  66. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +11 -0
  67. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +31 -0
  68. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  69. package/Meshes/GaussianSplatting/pure.d.ts +1 -0
  70. package/Meshes/GaussianSplatting/pure.js +1 -0
  71. package/Meshes/GaussianSplatting/pure.js.map +1 -1
  72. package/Meshes/GreasedLine/greasedLineMesh.pure.js +9 -14
  73. package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js +26 -27
  74. package/Meshes/index.d.ts +1 -0
  75. package/Meshes/index.js +1 -0
  76. package/Meshes/index.js.map +1 -1
  77. package/Meshes/meshSimplification.common.d.ts +53 -0
  78. package/Meshes/meshSimplification.common.js +34 -0
  79. package/Meshes/meshSimplification.common.js.map +1 -0
  80. package/Meshes/meshSimplification.d.ts +3 -53
  81. package/Meshes/meshSimplification.js +1 -33
  82. package/Meshes/meshSimplification.js.map +1 -1
  83. package/Meshes/meshSimplificationSceneComponent.pure.js.map +1 -1
  84. package/Meshes/meshSimplificationSceneComponent.types.d.ts +2 -1
  85. package/Meshes/meshSimplificationSceneComponent.types.js.map +1 -1
  86. package/Meshes/pure.d.ts +1 -0
  87. package/Meshes/pure.js +1 -0
  88. package/Meshes/pure.js.map +1 -1
  89. package/Meshes/transformNode.pure.js +82 -44
  90. package/Misc/tools.pure.js +124 -186
  91. package/Misc/tools.pure.js.map +1 -1
  92. package/Physics/v1/physicsImpostor.pure.js +43 -37
  93. package/Shaders/ShadersInclude/gaussianSplatting.js +33 -10
  94. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  95. package/Shaders/gaussianSplatting.vertex.js +20 -1
  96. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  97. package/Shaders/picking.fragment.js +4 -1
  98. package/Shaders/picking.fragment.js.map +1 -1
  99. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +33 -10
  100. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  101. package/ShadersWGSL/gaussianSplatting.vertex.js +21 -2
  102. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  103. package/package.json +3 -1
@@ -2,19 +2,7 @@
2
2
  var _a, _b, _c, _d, _e, _f, _g, _h;
3
3
  /* eslint-disable @typescript-eslint/no-unused-vars */
4
4
  import { Effect } from "../Materials/effect.pure.js";
5
- import {
6
- createPipelineContext,
7
- createRawShaderProgram,
8
- createShaderProgram,
9
- _finalizePipelineContext,
10
- _preparePipelineContext,
11
- _setProgram,
12
- _executeWhenRenderingStateIsCompiled,
13
- getStateObject,
14
- _createShaderProgram,
15
- deleteStateObject,
16
- _isRenderingStateCompiled,
17
- } from "./thinEngine.functions.js";
5
+ import { createPipelineContext, createRawShaderProgram, createShaderProgram, _finalizePipelineContext, _preparePipelineContext, _setProgram, _executeWhenRenderingStateIsCompiled, getStateObject, _createShaderProgram, deleteStateObject, _isRenderingStateCompiled, } from "./thinEngine.functions.js";
18
6
  import { AbstractEngine } from "./abstractEngine.pure.js";
19
7
  import { IsWrapper } from "../Materials/drawWrapper.functions.js";
20
8
  import { Logger } from "../Misc/logger.js";
@@ -33,7 +21,8 @@ import { AlphaState } from "../States/alphaCullingState.js";
33
21
  /**
34
22
  * Keeps track of all the buffer info used in engine.
35
23
  */
36
- class BufferPointer {}
24
+ class BufferPointer {
25
+ }
37
26
  /**
38
27
  * The base engine class (root of all engines)
39
28
  */
@@ -211,7 +200,8 @@ export class ThinEngine extends AbstractEngine {
211
200
  };
212
201
  canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
213
202
  options.powerPreference = options.powerPreference || "high-performance";
214
- } else {
203
+ }
204
+ else {
215
205
  this._onContextLost = () => {
216
206
  deleteStateObject(this._gl);
217
207
  };
@@ -223,7 +213,7 @@ export class ThinEngine extends AbstractEngine {
223
213
  // GL
224
214
  if (!options.disableWebGL2Support) {
225
215
  try {
226
- this._gl = canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options);
216
+ this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
227
217
  if (this._gl) {
228
218
  this._webGLVersion = 2.0;
229
219
  this._shaderPlatformName = "WEBGL2";
@@ -233,7 +223,8 @@ export class ThinEngine extends AbstractEngine {
233
223
  this._shaderPlatformName = "WEBGL1";
234
224
  }
235
225
  }
236
- } catch (e) {
226
+ }
227
+ catch (e) {
237
228
  // Do nothing
238
229
  }
239
230
  }
@@ -242,21 +233,24 @@ export class ThinEngine extends AbstractEngine {
242
233
  throw new Error("The provided canvas is null or undefined.");
243
234
  }
244
235
  try {
245
- this._gl = canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options);
246
- } catch (e) {
236
+ this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
237
+ }
238
+ catch (e) {
247
239
  throw new Error("WebGL not supported", { cause: e });
248
240
  }
249
241
  }
250
242
  if (!this._gl) {
251
243
  throw new Error("WebGL not supported");
252
244
  }
253
- } else {
245
+ }
246
+ else {
254
247
  this._gl = canvasOrContext;
255
248
  canvas = this._gl.canvas;
256
249
  if (this._gl.renderbufferStorageMultisample) {
257
250
  this._webGLVersion = 2.0;
258
251
  this._shaderPlatformName = "WEBGL2";
259
- } else {
252
+ }
253
+ else {
260
254
  this._shaderPlatformName = "WEBGL1";
261
255
  }
262
256
  const attributes = this._gl.getContextAttributes();
@@ -345,12 +339,10 @@ export class ThinEngine extends AbstractEngine {
345
339
  s3tc_srgb: this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),
346
340
  pvrtc: this._gl.getExtension("WEBGL_compressed_texture_pvrtc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
347
341
  etc1: this._gl.getExtension("WEBGL_compressed_texture_etc1") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),
348
- etc2:
349
- this._gl.getExtension("WEBGL_compressed_texture_etc") ||
342
+ etc2: this._gl.getExtension("WEBGL_compressed_texture_etc") ||
350
343
  this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc") ||
351
344
  this._gl.getExtension("WEBGL_compressed_texture_es3_0"), // also a requirement of OpenGL ES 3
352
- textureAnisotropicFilterExtension:
353
- this._gl.getExtension("EXT_texture_filter_anisotropic") ||
345
+ textureAnisotropicFilterExtension: this._gl.getExtension("EXT_texture_filter_anisotropic") ||
354
346
  this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") ||
355
347
  this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),
356
348
  uintIndices: this._webGLVersion > 1 || this._gl.getExtension("OES_element_index_uint") !== null,
@@ -500,7 +492,8 @@ export class ThinEngine extends AbstractEngine {
500
492
  this._caps.drawBuffersExtension = true;
501
493
  this._caps.maxMSAASamples = this._maxMSAASamplesOverride !== null ? this._maxMSAASamplesOverride : this._gl.getParameter(this._gl.MAX_SAMPLES);
502
494
  this._caps.maxDrawBuffers = this._gl.getParameter(this._gl.MAX_DRAW_BUFFERS);
503
- } else {
495
+ }
496
+ else {
504
497
  const drawBuffersExtension = this._gl.getExtension("WEBGL_draw_buffers");
505
498
  if (drawBuffersExtension !== null) {
506
499
  this._caps.drawBuffersExtension = true;
@@ -515,7 +508,8 @@ export class ThinEngine extends AbstractEngine {
515
508
  // Depth Texture
516
509
  if (this._webGLVersion > 1) {
517
510
  this._caps.depthTextureExtension = true;
518
- } else {
511
+ }
512
+ else {
519
513
  const depthTextureExtension = this._gl.getExtension("WEBGL_depth_texture");
520
514
  if (depthTextureExtension != null) {
521
515
  this._caps.depthTextureExtension = true;
@@ -525,9 +519,11 @@ export class ThinEngine extends AbstractEngine {
525
519
  // Vertex array object
526
520
  if (this.disableVertexArrayObjects) {
527
521
  this._caps.vertexArrayObject = false;
528
- } else if (this._webGLVersion > 1) {
522
+ }
523
+ else if (this._webGLVersion > 1) {
529
524
  this._caps.vertexArrayObject = true;
530
- } else {
525
+ }
526
+ else {
531
527
  const vertexArrayObjectExtension = this._gl.getExtension("OES_vertex_array_object");
532
528
  if (vertexArrayObjectExtension != null) {
533
529
  this._caps.vertexArrayObject = true;
@@ -539,14 +535,16 @@ export class ThinEngine extends AbstractEngine {
539
535
  // Instances count
540
536
  if (this._webGLVersion > 1) {
541
537
  this._caps.instancedArrays = true;
542
- } else {
538
+ }
539
+ else {
543
540
  const instanceExtension = this._gl.getExtension("ANGLE_instanced_arrays");
544
541
  if (instanceExtension != null) {
545
542
  this._caps.instancedArrays = true;
546
543
  this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
547
544
  this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
548
545
  this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
549
- } else {
546
+ }
547
+ else {
550
548
  this._caps.instancedArrays = false;
551
549
  }
552
550
  }
@@ -572,7 +570,8 @@ export class ThinEngine extends AbstractEngine {
572
570
  }
573
571
  if (this._webGLVersion > 1) {
574
572
  this._caps.blendMinMax = true;
575
- } else {
573
+ }
574
+ else {
576
575
  const blendMinMaxExtension = this._gl.getExtension("EXT_blend_minmax");
577
576
  if (blendMinMaxExtension != null) {
578
577
  this._caps.blendMinMax = true;
@@ -590,7 +589,8 @@ export class ThinEngine extends AbstractEngine {
590
589
  SRGB8: WebGL2RenderingContext.SRGB8,
591
590
  SRGB8_ALPHA8: WebGL2RenderingContext.SRGB8_ALPHA8,
592
591
  };
593
- } else {
592
+ }
593
+ else {
594
594
  const sRGBExtension = this._gl.getExtension("EXT_sRGB");
595
595
  if (sRGBExtension != null) {
596
596
  this._caps.supportSRGBBuffers = true;
@@ -744,7 +744,10 @@ export class ThinEngine extends AbstractEngine {
744
744
  let setBackBufferColor = true;
745
745
  if (this._currentRenderTarget) {
746
746
  const textureFormat = this._currentRenderTarget.texture?.format;
747
- if (textureFormat === 8 || textureFormat === 9 || textureFormat === 10 || textureFormat === 11) {
747
+ if (textureFormat === 8 ||
748
+ textureFormat === 9 ||
749
+ textureFormat === 10 ||
750
+ textureFormat === 11) {
748
751
  const textureType = this._currentRenderTarget.texture?.type;
749
752
  if (textureType === 7 || textureType === 5) {
750
753
  ThinEngine._TempClearColorUint32[0] = color.r * 255;
@@ -753,7 +756,8 @@ export class ThinEngine extends AbstractEngine {
753
756
  ThinEngine._TempClearColorUint32[3] = color.a * 255;
754
757
  this._gl.clearBufferuiv(this._gl.COLOR, 0, ThinEngine._TempClearColorUint32);
755
758
  setBackBufferColor = false;
756
- } else {
759
+ }
760
+ else {
757
761
  ThinEngine._TempClearColorInt32[0] = color.r * 255;
758
762
  ThinEngine._TempClearColorInt32[1] = color.g * 255;
759
763
  ThinEngine._TempClearColorInt32[2] = color.b * 255;
@@ -772,7 +776,8 @@ export class ThinEngine extends AbstractEngine {
772
776
  if (this.useReverseDepthBuffer) {
773
777
  this._depthCullingState.depthFunc = this._gl.GEQUAL;
774
778
  this._gl.clearDepth(0.0);
775
- } else {
779
+ }
780
+ else {
776
781
  this._gl.clearDepth(1.0);
777
782
  }
778
783
  mode |= this._gl.DEPTH_BUFFER_BIT;
@@ -834,15 +839,11 @@ export class ThinEngine extends AbstractEngine {
834
839
  if (rtWrapper.is2DArray || rtWrapper.is3D) {
835
840
  gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, rtWrapper.texture._hardwareTexture?.underlyingResource, lodLevel, layer);
836
841
  webglRtWrapper._currentLOD = lodLevel;
837
- } else if (rtWrapper.isCube) {
838
- gl.framebufferTexture2D(
839
- gl.FRAMEBUFFER,
840
- gl.COLOR_ATTACHMENT0,
841
- gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex,
842
- rtWrapper.texture._hardwareTexture?.underlyingResource,
843
- lodLevel
844
- );
845
- } else if (webglRtWrapper._currentLOD !== lodLevel) {
842
+ }
843
+ else if (rtWrapper.isCube) {
844
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, rtWrapper.texture._hardwareTexture?.underlyingResource, lodLevel);
845
+ }
846
+ else if (webglRtWrapper._currentLOD !== lodLevel) {
846
847
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, rtWrapper.texture._hardwareTexture?.underlyingResource, lodLevel);
847
848
  webglRtWrapper._currentLOD = lodLevel;
848
849
  }
@@ -850,20 +851,20 @@ export class ThinEngine extends AbstractEngine {
850
851
  const depthStencilTexture = rtWrapper._depthStencilTexture;
851
852
  if (depthStencilTexture) {
852
853
  if (rtWrapper.is3D) {
853
- if (
854
- rtWrapper.texture.width !== depthStencilTexture.width ||
854
+ if (rtWrapper.texture.width !== depthStencilTexture.width ||
855
855
  rtWrapper.texture.height !== depthStencilTexture.height ||
856
- rtWrapper.texture.depth !== depthStencilTexture.depth
857
- ) {
856
+ rtWrapper.texture.depth !== depthStencilTexture.depth) {
858
857
  Logger.Warn("Depth/Stencil attachment for 3D target must have same dimensions as color attachment");
859
858
  }
860
859
  }
861
860
  const attachment = rtWrapper._depthStencilTextureWithStencil ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;
862
861
  if (rtWrapper.is2DArray || rtWrapper.is3D) {
863
862
  gl.framebufferTextureLayer(gl.FRAMEBUFFER, attachment, depthStencilTexture._hardwareTexture?.underlyingResource, lodLevel, layer);
864
- } else if (rtWrapper.isCube) {
863
+ }
864
+ else if (rtWrapper.isCube) {
865
865
  gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._hardwareTexture?.underlyingResource, lodLevel);
866
- } else {
866
+ }
867
+ else {
867
868
  gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, depthStencilTexture._hardwareTexture?.underlyingResource, lodLevel);
868
869
  }
869
870
  }
@@ -872,7 +873,8 @@ export class ThinEngine extends AbstractEngine {
872
873
  }
873
874
  if (this._cachedViewport && !forceFullscreenViewport) {
874
875
  this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
875
- } else {
876
+ }
877
+ else {
876
878
  if (!requiredWidth) {
877
879
  requiredWidth = rtWrapper.width;
878
880
  if (lodLevel) {
@@ -927,14 +929,16 @@ export class ThinEngine extends AbstractEngine {
927
929
  if (!webglRtWrapper.disableAutomaticMSAAResolve) {
928
930
  if (texture.isMulti) {
929
931
  this.resolveMultiFramebuffer(texture);
930
- } else {
932
+ }
933
+ else {
931
934
  this.resolveFramebuffer(texture);
932
935
  }
933
936
  }
934
937
  if (!disableGenerateMipMaps) {
935
938
  if (texture.isMulti) {
936
939
  this.generateMipMapsMultiFramebuffer(texture);
937
- } else {
940
+ }
941
+ else {
938
942
  this.generateMipMapsFramebuffer(texture);
939
943
  }
940
944
  }
@@ -1020,7 +1024,8 @@ export class ThinEngine extends AbstractEngine {
1020
1024
  restoreDefaultFramebuffer() {
1021
1025
  if (this._currentRenderTarget) {
1022
1026
  this.unBindFramebuffer(this._currentRenderTarget);
1023
- } else {
1027
+ }
1028
+ else {
1024
1029
  this._bindUnboundFramebuffer(null);
1025
1030
  }
1026
1031
  if (this._cachedViewport) {
@@ -1055,11 +1060,13 @@ export class ThinEngine extends AbstractEngine {
1055
1060
  if (data instanceof Array) {
1056
1061
  this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), usage);
1057
1062
  dataBuffer.capacity = data.length * 4;
1058
- } else {
1063
+ }
1064
+ else {
1059
1065
  this._gl.bufferData(this._gl.ARRAY_BUFFER, data, usage);
1060
1066
  dataBuffer.capacity = data.byteLength;
1061
1067
  }
1062
- } else {
1068
+ }
1069
+ else {
1063
1070
  this._gl.bufferData(this._gl.ARRAY_BUFFER, new Uint8Array(data), usage);
1064
1071
  dataBuffer.capacity = data;
1065
1072
  }
@@ -1110,7 +1117,8 @@ export class ThinEngine extends AbstractEngine {
1110
1117
  if (this._caps.uintIndices) {
1111
1118
  if (indices instanceof Uint32Array) {
1112
1119
  return indices;
1113
- } else {
1120
+ }
1121
+ else {
1114
1122
  // number[] or Int32Array, check if 32 bit is necessary
1115
1123
  for (let index = 0; index < indices.length; index++) {
1116
1124
  if (indices[index] >= 65535) {
@@ -1180,7 +1188,8 @@ export class ThinEngine extends AbstractEngine {
1180
1188
  pointer.stride = stride;
1181
1189
  pointer.offset = offset;
1182
1190
  pointer.buffer = buffer;
1183
- } else {
1191
+ }
1192
+ else {
1184
1193
  if (pointer.buffer !== buffer) {
1185
1194
  pointer.buffer = buffer;
1186
1195
  changed = true;
@@ -1210,7 +1219,8 @@ export class ThinEngine extends AbstractEngine {
1210
1219
  this.bindArrayBuffer(buffer);
1211
1220
  if (type === this._gl.UNSIGNED_INT || type === this._gl.INT) {
1212
1221
  this._gl.vertexAttribIPointer(indx, size, type, stride, offset);
1213
- } else {
1222
+ }
1223
+ else {
1214
1224
  this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
1215
1225
  }
1216
1226
  }
@@ -1408,7 +1418,8 @@ export class ThinEngine extends AbstractEngine {
1408
1418
  }
1409
1419
  if (offsetLocations[0].index !== undefined) {
1410
1420
  this.bindInstancesBuffer(instancesBuffer, offsetLocations, true);
1411
- } else {
1421
+ }
1422
+ else {
1412
1423
  for (let index = 0; index < 4; index++) {
1413
1424
  const offsetLocation = offsetLocations[index];
1414
1425
  if (!this._vertexAttribArraysEnabled[offsetLocation]) {
@@ -1538,7 +1549,8 @@ export class ThinEngine extends AbstractEngine {
1538
1549
  const mult = this._uintIndicesCurrentlySet ? 4 : 2;
1539
1550
  if (instancesCount) {
1540
1551
  this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
1541
- } else {
1552
+ }
1553
+ else {
1542
1554
  this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
1543
1555
  }
1544
1556
  }
@@ -1556,7 +1568,8 @@ export class ThinEngine extends AbstractEngine {
1556
1568
  const drawMode = this._drawMode(fillMode);
1557
1569
  if (instancesCount) {
1558
1570
  this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
1559
- } else {
1571
+ }
1572
+ else {
1560
1573
  this._gl.drawArrays(drawMode, verticesStart, verticesCount);
1561
1574
  }
1562
1575
  }
@@ -1636,19 +1649,7 @@ export class ThinEngine extends AbstractEngine {
1636
1649
  * @param extraInitializationsAsync additional async code to run before preparing the effect
1637
1650
  * @returns the new Effect
1638
1651
  */
1639
- createEffect(
1640
- baseName,
1641
- attributesNamesOrOptions,
1642
- uniformsNamesOrEngine,
1643
- samplers,
1644
- defines,
1645
- fallbacks,
1646
- onCompiled,
1647
- onError,
1648
- indexParameters,
1649
- shaderLanguage = 0 /* ShaderLanguage.GLSL */,
1650
- extraInitializationsAsync
1651
- ) {
1652
+ createEffect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters, shaderLanguage = 0 /* ShaderLanguage.GLSL */, extraInitializationsAsync) {
1652
1653
  const vertex = typeof baseName === "string" ? baseName : baseName.vertexToken || baseName.vertexSource || baseName.vertexElement || baseName.vertex;
1653
1654
  const fragment = typeof baseName === "string" ? baseName : baseName.fragmentToken || baseName.fragmentSource || baseName.fragmentElement || baseName.fragment;
1654
1655
  const globalDefines = this._getGlobalDefines();
@@ -1669,21 +1670,7 @@ export class ThinEngine extends AbstractEngine {
1669
1670
  if (this._gl) {
1670
1671
  getStateObject(this._gl);
1671
1672
  }
1672
- const effect = new Effect(
1673
- baseName,
1674
- attributesNamesOrOptions,
1675
- isOptions ? this : uniformsNamesOrEngine,
1676
- samplers,
1677
- this,
1678
- defines,
1679
- fallbacks,
1680
- onCompiled,
1681
- onError,
1682
- indexParameters,
1683
- name,
1684
- attributesNamesOrOptions.shaderLanguage ?? shaderLanguage,
1685
- attributesNamesOrOptions.extraInitializationsAsync ?? extraInitializationsAsync
1686
- );
1673
+ const effect = new Effect(baseName, attributesNamesOrOptions, isOptions ? this : uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters, name, attributesNamesOrOptions.shaderLanguage ?? shaderLanguage, attributesNamesOrOptions.extraInitializationsAsync ?? extraInitializationsAsync);
1687
1674
  this._compiledEffects[name] = effect;
1688
1675
  return effect;
1689
1676
  }
@@ -1770,19 +1757,7 @@ export class ThinEngine extends AbstractEngine {
1770
1757
  */
1771
1758
  // named async but not actually an async function
1772
1759
  // eslint-disable-next-line no-restricted-syntax
1773
- _preparePipelineContextAsync(
1774
- pipelineContext,
1775
- vertexSourceCode,
1776
- fragmentSourceCode,
1777
- createAsRaw,
1778
- rawVertexSourceCode,
1779
- rawFragmentSourceCode,
1780
- rebuildRebind,
1781
- defines,
1782
- transformFeedbackVaryings,
1783
- key,
1784
- onReady
1785
- ) {
1760
+ _preparePipelineContextAsync(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, key, onReady) {
1786
1761
  const stateObject = getStateObject(this._gl);
1787
1762
  stateObject._contextWasLost = this._contextWasLost;
1788
1763
  stateObject.validateShaderPrograms = this.validateShaderPrograms;
@@ -1790,19 +1765,7 @@ export class ThinEngine extends AbstractEngine {
1790
1765
  stateObject.createRawShaderProgramInjection = this.createRawShaderProgram.bind(this);
1791
1766
  stateObject.createShaderProgramInjection = this.createShaderProgram.bind(this);
1792
1767
  stateObject.loadFileInjection = this._loadFile.bind(this);
1793
- return _preparePipelineContext(
1794
- pipelineContext,
1795
- vertexSourceCode,
1796
- fragmentSourceCode,
1797
- createAsRaw,
1798
- rawVertexSourceCode,
1799
- rawFragmentSourceCode,
1800
- rebuildRebind,
1801
- defines,
1802
- transformFeedbackVaryings,
1803
- key,
1804
- onReady
1805
- );
1768
+ return _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, key, onReady);
1806
1769
  }
1807
1770
  _createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings = null) {
1808
1771
  return _createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);
@@ -1848,7 +1811,8 @@ export class ThinEngine extends AbstractEngine {
1848
1811
  for (let index = 0; index < attributesNames.length; index++) {
1849
1812
  try {
1850
1813
  results.push(this._gl.getAttribLocation(webGLPipelineContext.program, attributesNames[index]));
1851
- } catch (e) {
1814
+ }
1815
+ catch (e) {
1852
1816
  results.push(-1);
1853
1817
  }
1854
1818
  }
@@ -2311,7 +2275,8 @@ export class ThinEngine extends AbstractEngine {
2311
2275
  magFilter = gl.LINEAR;
2312
2276
  if (generateMipMaps) {
2313
2277
  minFilter = gl.LINEAR_MIPMAP_NEAREST;
2314
- } else {
2278
+ }
2279
+ else {
2315
2280
  minFilter = gl.LINEAR;
2316
2281
  }
2317
2282
  break;
@@ -2320,7 +2285,8 @@ export class ThinEngine extends AbstractEngine {
2320
2285
  hasMipMaps = true;
2321
2286
  if (generateMipMaps) {
2322
2287
  minFilter = gl.LINEAR_MIPMAP_LINEAR;
2323
- } else {
2288
+ }
2289
+ else {
2324
2290
  minFilter = gl.LINEAR;
2325
2291
  }
2326
2292
  break;
@@ -2329,7 +2295,8 @@ export class ThinEngine extends AbstractEngine {
2329
2295
  magFilter = gl.NEAREST;
2330
2296
  if (generateMipMaps) {
2331
2297
  minFilter = gl.NEAREST_MIPMAP_LINEAR;
2332
- } else {
2298
+ }
2299
+ else {
2333
2300
  minFilter = gl.NEAREST;
2334
2301
  }
2335
2302
  break;
@@ -2337,7 +2304,8 @@ export class ThinEngine extends AbstractEngine {
2337
2304
  magFilter = gl.NEAREST;
2338
2305
  if (generateMipMaps) {
2339
2306
  minFilter = gl.NEAREST_MIPMAP_NEAREST;
2340
- } else {
2307
+ }
2308
+ else {
2341
2309
  minFilter = gl.NEAREST;
2342
2310
  }
2343
2311
  break;
@@ -2345,7 +2313,8 @@ export class ThinEngine extends AbstractEngine {
2345
2313
  magFilter = gl.NEAREST;
2346
2314
  if (generateMipMaps) {
2347
2315
  minFilter = gl.LINEAR_MIPMAP_NEAREST;
2348
- } else {
2316
+ }
2317
+ else {
2349
2318
  minFilter = gl.LINEAR;
2350
2319
  }
2351
2320
  break;
@@ -2354,7 +2323,8 @@ export class ThinEngine extends AbstractEngine {
2354
2323
  magFilter = gl.NEAREST;
2355
2324
  if (generateMipMaps) {
2356
2325
  minFilter = gl.LINEAR_MIPMAP_LINEAR;
2357
- } else {
2326
+ }
2327
+ else {
2358
2328
  minFilter = gl.LINEAR;
2359
2329
  }
2360
2330
  break;
@@ -2370,7 +2340,8 @@ export class ThinEngine extends AbstractEngine {
2370
2340
  magFilter = gl.LINEAR;
2371
2341
  if (generateMipMaps) {
2372
2342
  minFilter = gl.NEAREST_MIPMAP_NEAREST;
2373
- } else {
2343
+ }
2344
+ else {
2374
2345
  minFilter = gl.NEAREST;
2375
2346
  }
2376
2347
  break;
@@ -2379,7 +2350,8 @@ export class ThinEngine extends AbstractEngine {
2379
2350
  magFilter = gl.LINEAR;
2380
2351
  if (generateMipMaps) {
2381
2352
  minFilter = gl.NEAREST_MIPMAP_LINEAR;
2382
- } else {
2353
+ }
2354
+ else {
2383
2355
  minFilter = gl.NEAREST;
2384
2356
  }
2385
2357
  break;
@@ -2443,14 +2415,16 @@ export class ThinEngine extends AbstractEngine {
2443
2415
  createMSAATexture = !!options.createMSAATexture;
2444
2416
  comparisonFunction = options.comparisonFunction || 0;
2445
2417
  isCube = !!options.isCube;
2446
- } else {
2418
+ }
2419
+ else {
2447
2420
  generateMipMaps = !!options;
2448
2421
  }
2449
2422
  useSRGBBuffer && (useSRGBBuffer = this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU));
2450
2423
  if (type === 1 && !this._caps.textureFloatLinearFiltering) {
2451
2424
  // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
2452
2425
  samplingMode = 1;
2453
- } else if (type === 2 && !this._caps.textureHalfFloatLinearFiltering) {
2426
+ }
2427
+ else if (type === 2 && !this._caps.textureHalfFloatLinearFiltering) {
2454
2428
  // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
2455
2429
  samplingMode = 1;
2456
2430
  }
@@ -2478,15 +2452,18 @@ export class ThinEngine extends AbstractEngine {
2478
2452
  if (layers !== 0) {
2479
2453
  texture.is2DArray = true;
2480
2454
  gl.texImage3D(target, 0, sizedFormat, width, height, layers, 0, internalFormat, textureType, null);
2481
- } else if (depth !== 0) {
2455
+ }
2456
+ else if (depth !== 0) {
2482
2457
  texture.is3D = true;
2483
2458
  gl.texImage3D(target, 0, sizedFormat, width, height, depth, 0, internalFormat, textureType, null);
2484
- } else if (isCube) {
2459
+ }
2460
+ else if (isCube) {
2485
2461
  texture.isCube = true;
2486
2462
  for (let face = 0; face < 6; face++) {
2487
2463
  gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, sizedFormat, width, height, 0, internalFormat, textureType, null);
2488
2464
  }
2489
- } else {
2465
+ }
2466
+ else {
2490
2467
  gl.texImage2D(target, 0, sizedFormat, width, height, 0, internalFormat, textureType, null);
2491
2468
  }
2492
2469
  gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, filters.mag);
@@ -2497,7 +2474,8 @@ export class ThinEngine extends AbstractEngine {
2497
2474
  if (comparisonFunction === 0) {
2498
2475
  gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, 515);
2499
2476
  gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
2500
- } else {
2477
+ }
2478
+ else {
2501
2479
  gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
2502
2480
  gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
2503
2481
  }
@@ -2525,24 +2503,10 @@ export class ThinEngine extends AbstractEngine {
2525
2503
  if (createMSAATexture) {
2526
2504
  let renderBuffer;
2527
2505
  if (IsDepthTexture(texture.format)) {
2528
- renderBuffer = this._setupFramebufferDepthAttachments(
2529
- HasStencilAspect(texture.format),
2530
- texture.format !== 19,
2531
- texture.width,
2532
- texture.height,
2533
- samples,
2534
- texture.format,
2535
- true
2536
- );
2537
- } else {
2538
- renderBuffer = this._createRenderBuffer(
2539
- texture.width,
2540
- texture.height,
2541
- samples,
2542
- -1 /* not used */,
2543
- this._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer),
2544
- -1 /* attachment */
2545
- );
2506
+ renderBuffer = this._setupFramebufferDepthAttachments(HasStencilAspect(texture.format), texture.format !== 19, texture.width, texture.height, samples, texture.format, true);
2507
+ }
2508
+ else {
2509
+ renderBuffer = this._createRenderBuffer(texture.width, texture.height, samples, -1 /* not used */, this._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer), -1 /* attachment */);
2546
2510
  }
2547
2511
  if (!renderBuffer) {
2548
2512
  throw new Error("Unable to create render buffer");
@@ -2586,75 +2550,43 @@ export class ThinEngine extends AbstractEngine {
2586
2550
  * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
2587
2551
  * @returns a InternalTexture for assignment back into BABYLON.Texture
2588
2552
  */
2589
- createTexture(
2590
- url,
2591
- noMipmap,
2592
- invertY,
2593
- scene,
2594
- samplingMode = 3,
2595
- onLoad = null,
2596
- onError = null,
2597
- buffer = null,
2598
- fallback = null,
2599
- format = null,
2600
- forcedExtension = null,
2601
- mimeType,
2602
- loaderOptions,
2603
- creationFlags,
2604
- useSRGBBuffer
2605
- ) {
2606
- return this._createTextureBase(
2607
- url,
2608
- noMipmap,
2609
- invertY,
2610
- scene,
2611
- samplingMode,
2612
- onLoad,
2613
- onError,
2614
- (...args) => this._prepareWebGLTexture(...args, format),
2615
- (potWidth, potHeight, img, extension, texture, continuationCallback) => {
2616
- const gl = this._gl;
2617
- const isPot = img.width === potWidth && img.height === potHeight;
2618
- texture._creationFlags = creationFlags ?? 0;
2619
- const tip = this._getTexImageParametersForCreateTexture(texture.format, texture._useSRGBBuffer);
2620
- if (isPot) {
2621
- gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, img);
2622
- return false;
2623
- }
2624
- const maxTextureSize = this._caps.maxTextureSize;
2625
- if (img.width > maxTextureSize || img.height > maxTextureSize || !this._supportsHardwareTextureRescaling) {
2626
- this._prepareWorkingCanvas();
2627
- if (!this._workingCanvas || !this._workingContext) {
2628
- return false;
2629
- }
2630
- this._workingCanvas.width = potWidth;
2631
- this._workingCanvas.height = potHeight;
2632
- this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
2633
- gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, this._workingCanvas);
2634
- texture.width = potWidth;
2635
- texture.height = potHeight;
2553
+ createTexture(url, noMipmap, invertY, scene, samplingMode = 3, onLoad = null, onError = null, buffer = null, fallback = null, format = null, forcedExtension = null, mimeType, loaderOptions, creationFlags, useSRGBBuffer) {
2554
+ return this._createTextureBase(url, noMipmap, invertY, scene, samplingMode, onLoad, onError, (...args) => this._prepareWebGLTexture(...args, format), (potWidth, potHeight, img, extension, texture, continuationCallback) => {
2555
+ const gl = this._gl;
2556
+ const isPot = img.width === potWidth && img.height === potHeight;
2557
+ texture._creationFlags = creationFlags ?? 0;
2558
+ const tip = this._getTexImageParametersForCreateTexture(texture.format, texture._useSRGBBuffer);
2559
+ if (isPot) {
2560
+ gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, img);
2561
+ return false;
2562
+ }
2563
+ const maxTextureSize = this._caps.maxTextureSize;
2564
+ if (img.width > maxTextureSize || img.height > maxTextureSize || !this._supportsHardwareTextureRescaling) {
2565
+ this._prepareWorkingCanvas();
2566
+ if (!this._workingCanvas || !this._workingContext) {
2636
2567
  return false;
2637
- } else {
2638
- // Using shaders when possible to rescale because canvas.drawImage is lossy
2639
- const source = new InternalTexture(this, 2 /* InternalTextureSource.Temp */);
2640
- this._bindTextureDirectly(gl.TEXTURE_2D, source, true);
2641
- gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, img);
2642
- this._rescaleTexture(source, texture, scene, tip.format, () => {
2643
- this._releaseTexture(source);
2644
- this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
2645
- continuationCallback();
2646
- });
2647
2568
  }
2648
- return true;
2649
- },
2650
- buffer,
2651
- fallback,
2652
- format,
2653
- forcedExtension,
2654
- mimeType,
2655
- loaderOptions,
2656
- useSRGBBuffer
2657
- );
2569
+ this._workingCanvas.width = potWidth;
2570
+ this._workingCanvas.height = potHeight;
2571
+ this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
2572
+ gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, this._workingCanvas);
2573
+ texture.width = potWidth;
2574
+ texture.height = potHeight;
2575
+ return false;
2576
+ }
2577
+ else {
2578
+ // Using shaders when possible to rescale because canvas.drawImage is lossy
2579
+ const source = new InternalTexture(this, 2 /* InternalTextureSource.Temp */);
2580
+ this._bindTextureDirectly(gl.TEXTURE_2D, source, true);
2581
+ gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, img);
2582
+ this._rescaleTexture(source, texture, scene, tip.format, () => {
2583
+ this._releaseTexture(source);
2584
+ this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
2585
+ continuationCallback();
2586
+ });
2587
+ }
2588
+ return true;
2589
+ }, buffer, fallback, format, forcedExtension, mimeType, loaderOptions, useSRGBBuffer);
2658
2590
  }
2659
2591
  /**
2660
2592
  * Calls to the GL texImage2D and texImage3D functions require three arguments describing the pixel format of the texture.
@@ -2674,7 +2606,8 @@ export class ThinEngine extends AbstractEngine {
2674
2606
  // to getInternalFormat.
2675
2607
  format = this._getInternalFormat(babylonFormat, useSRGBBuffer);
2676
2608
  internalFormat = format;
2677
- } else {
2609
+ }
2610
+ else {
2678
2611
  // In WebGL 2, format has a wider range of values and internal format can be one of the sized formats, see
2679
2612
  // https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml.
2680
2613
  // SRGB is included in the sized format and should not be passed in "format", hence always passing useSRGBBuffer as false.
@@ -2690,7 +2623,7 @@ export class ThinEngine extends AbstractEngine {
2690
2623
  /**
2691
2624
  * @internal
2692
2625
  */
2693
- _rescaleTexture(source, destination, scene, internalFormat, onComplete) {}
2626
+ _rescaleTexture(source, destination, scene, internalFormat, onComplete) { }
2694
2627
  /**
2695
2628
  * @internal
2696
2629
  */
@@ -2710,9 +2643,11 @@ export class ThinEngine extends AbstractEngine {
2710
2643
  _getTextureTarget(texture) {
2711
2644
  if (texture.isCube) {
2712
2645
  return this._gl.TEXTURE_CUBE_MAP;
2713
- } else if (texture.is3D) {
2646
+ }
2647
+ else if (texture.is3D) {
2714
2648
  return this._gl.TEXTURE_3D;
2715
- } else if (texture.is2DArray || texture.isMultiview) {
2649
+ }
2650
+ else if (texture.is2DArray || texture.isMultiview) {
2716
2651
  return this._gl.TEXTURE_2D_ARRAY;
2717
2652
  }
2718
2653
  return this._gl.TEXTURE_2D;
@@ -2742,7 +2677,7 @@ export class ThinEngine extends AbstractEngine {
2742
2677
  * @param height new height of the texture
2743
2678
  * @param depth new depth of the texture
2744
2679
  */
2745
- updateTextureDimensions(texture, width, height, depth = 1) {}
2680
+ updateTextureDimensions(texture, width, height, depth = 1) { }
2746
2681
  /**
2747
2682
  * Update the sampling mode of a given texture
2748
2683
  * @param texture defines the texture to update
@@ -2782,14 +2717,16 @@ export class ThinEngine extends AbstractEngine {
2782
2717
  // Note, if using ETC1 and sRGB is requested, this will use ETC2 if available.
2783
2718
  if (this._caps.etc2) {
2784
2719
  internalFormat = gl.COMPRESSED_SRGB8_ETC2;
2785
- } else {
2720
+ }
2721
+ else {
2786
2722
  texture._useSRGBBuffer = false;
2787
2723
  }
2788
2724
  break;
2789
2725
  case 37496:
2790
2726
  if (this._caps.etc2) {
2791
2727
  internalFormat = gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
2792
- } else {
2728
+ }
2729
+ else {
2793
2730
  texture._useSRGBBuffer = false;
2794
2731
  }
2795
2732
  break;
@@ -2841,7 +2778,8 @@ export class ThinEngine extends AbstractEngine {
2841
2778
  case 33776:
2842
2779
  if (this._caps.s3tc_srgb) {
2843
2780
  internalFormat = gl.COMPRESSED_SRGB_S3TC_DXT1_EXT;
2844
- } else {
2781
+ }
2782
+ else {
2845
2783
  // S3TC sRGB extension not supported
2846
2784
  texture._useSRGBBuffer = false;
2847
2785
  }
@@ -2849,7 +2787,8 @@ export class ThinEngine extends AbstractEngine {
2849
2787
  case 33777:
2850
2788
  if (this._caps.s3tc_srgb) {
2851
2789
  internalFormat = gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
2852
- } else {
2790
+ }
2791
+ else {
2853
2792
  // S3TC sRGB extension not supported
2854
2793
  texture._useSRGBBuffer = false;
2855
2794
  }
@@ -2857,7 +2796,8 @@ export class ThinEngine extends AbstractEngine {
2857
2796
  case 33779:
2858
2797
  if (this._caps.s3tc_srgb) {
2859
2798
  internalFormat = gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
2860
- } else {
2799
+ }
2800
+ else {
2861
2801
  // S3TC sRGB extension not supported
2862
2802
  texture._useSRGBBuffer = false;
2863
2803
  }
@@ -2871,17 +2811,12 @@ export class ThinEngine extends AbstractEngine {
2871
2811
  if (texture.generateMipMaps) {
2872
2812
  const webGLHardwareTexture = texture._hardwareTexture;
2873
2813
  if (!webGLHardwareTexture.memoryAllocated) {
2874
- gl.texStorage2D(
2875
- texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D,
2876
- Math.floor(Math.log2(Math.max(width, height))) + 1,
2877
- internalFormat,
2878
- texture.width,
2879
- texture.height
2880
- );
2814
+ gl.texStorage2D(texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D, Math.floor(Math.log2(Math.max(width, height))) + 1, internalFormat, texture.width, texture.height);
2881
2815
  webGLHardwareTexture.memoryAllocated = true;
2882
2816
  }
2883
2817
  this._gl.compressedTexSubImage2D(target, lod, 0, 0, width, height, internalFormat, data);
2884
- } else {
2818
+ }
2819
+ else {
2885
2820
  this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
2886
2821
  }
2887
2822
  }
@@ -2892,10 +2827,9 @@ export class ThinEngine extends AbstractEngine {
2892
2827
  const gl = this._gl;
2893
2828
  const textureType = this._getWebGLTextureType(texture.type);
2894
2829
  const format = this._getInternalFormat(texture.format);
2895
- const internalFormat =
2896
- babylonInternalFormat === undefined
2897
- ? this._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer)
2898
- : this._getInternalFormat(babylonInternalFormat, texture._useSRGBBuffer);
2830
+ const internalFormat = babylonInternalFormat === undefined
2831
+ ? this._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer)
2832
+ : this._getInternalFormat(babylonInternalFormat, texture._useSRGBBuffer);
2899
2833
  this._unpackFlipY(texture.invertY);
2900
2834
  let target = gl.TEXTURE_2D;
2901
2835
  if (texture.isCube) {
@@ -2989,12 +2923,11 @@ export class ThinEngine extends AbstractEngine {
2989
2923
  texture.height = potHeight;
2990
2924
  texture.isReady = true;
2991
2925
  texture.type = texture.type !== -1 ? texture.type : 0;
2992
- texture.format = texture.format !== -1 ? texture.format : (format ?? (extension === ".jpg" && !texture._useSRGBBuffer ? 4 : 5));
2993
- if (
2994
- processFunction(potWidth, potHeight, img, extension, texture, () => {
2995
- this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
2996
- })
2997
- ) {
2926
+ texture.format =
2927
+ texture.format !== -1 ? texture.format : (format ?? (extension === ".jpg" && !texture._useSRGBBuffer ? 4 : 5));
2928
+ if (processFunction(potWidth, potHeight, img, extension, texture, () => {
2929
+ this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
2930
+ })) {
2998
2931
  // Returning as texture needs extra async steps
2999
2932
  return;
3000
2933
  }
@@ -3010,16 +2943,21 @@ export class ThinEngine extends AbstractEngine {
3010
2943
  if (this.webGLVersion > 1) {
3011
2944
  if (textureFormat === 15) {
3012
2945
  internalFormat = gl.DEPTH_COMPONENT16;
3013
- } else if (textureFormat === 16) {
2946
+ }
2947
+ else if (textureFormat === 16) {
3014
2948
  internalFormat = gl.DEPTH_COMPONENT24;
3015
- } else if (textureFormat === 17 || textureFormat === 13) {
2949
+ }
2950
+ else if (textureFormat === 17 || textureFormat === 13) {
3016
2951
  internalFormat = hasStencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;
3017
- } else if (textureFormat === 14) {
2952
+ }
2953
+ else if (textureFormat === 14) {
3018
2954
  internalFormat = gl.DEPTH_COMPONENT32F;
3019
- } else if (textureFormat === 18) {
2955
+ }
2956
+ else if (textureFormat === 18) {
3020
2957
  internalFormat = hasStencil ? gl.DEPTH32F_STENCIL8 : gl.DEPTH_COMPONENT32F;
3021
2958
  }
3022
- } else {
2959
+ }
2960
+ else {
3023
2961
  internalFormat = gl.DEPTH_COMPONENT16;
3024
2962
  }
3025
2963
  return internalFormat;
@@ -3029,13 +2967,17 @@ export class ThinEngine extends AbstractEngine {
3029
2967
  let type = gl.UNSIGNED_INT;
3030
2968
  if (textureFormat === 15) {
3031
2969
  type = gl.UNSIGNED_SHORT;
3032
- } else if (textureFormat === 17 || textureFormat === 13) {
2970
+ }
2971
+ else if (textureFormat === 17 || textureFormat === 13) {
3033
2972
  type = gl.UNSIGNED_INT_24_8;
3034
- } else if (textureFormat === 14) {
2973
+ }
2974
+ else if (textureFormat === 14) {
3035
2975
  type = gl.FLOAT;
3036
- } else if (textureFormat === 18) {
2976
+ }
2977
+ else if (textureFormat === 18) {
3037
2978
  type = gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
3038
- } else if (textureFormat === 19) {
2979
+ }
2980
+ else if (textureFormat === 19) {
3039
2981
  type = gl.UNSIGNED_BYTE;
3040
2982
  }
3041
2983
  return type;
@@ -3072,7 +3014,8 @@ export class ThinEngine extends AbstractEngine {
3072
3014
  gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer);
3073
3015
  if (samples > 1 && gl.renderbufferStorageMultisample) {
3074
3016
  gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, msInternalFormat, width, height);
3075
- } else {
3017
+ }
3018
+ else {
3076
3019
  gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);
3077
3020
  }
3078
3021
  if (attachment !== -1) {
@@ -3157,14 +3100,16 @@ export class ThinEngine extends AbstractEngine {
3157
3100
  Logger.Error(["_bindTextureDirectly called with a multiview texture!", target, texture]);
3158
3101
  // eslint-disable-next-line no-throw-literal
3159
3102
  throw "_bindTextureDirectly called with a multiview texture!";
3160
- } else {
3103
+ }
3104
+ else {
3161
3105
  this._gl.bindTexture(target, texture?._hardwareTexture?.underlyingResource ?? null);
3162
3106
  }
3163
3107
  this._boundTexturesCache[this._activeChannel] = texture;
3164
3108
  if (texture) {
3165
3109
  texture._associatedChannel = this._activeChannel;
3166
3110
  }
3167
- } else if (forTextureDataUpdate) {
3111
+ }
3112
+ else if (forTextureDataUpdate) {
3168
3113
  wasPreviouslyBound = true;
3169
3114
  this._activateCurrentTexture();
3170
3115
  }
@@ -3258,7 +3203,8 @@ export class ThinEngine extends AbstractEngine {
3258
3203
  videoInternalTexture._associatedChannel = channel;
3259
3204
  }
3260
3205
  texture.update();
3261
- } else if (texture.delayLoadState === 4) {
3206
+ }
3207
+ else if (texture.delayLoadState === 4) {
3262
3208
  // Delay loading
3263
3209
  texture.delayLoad();
3264
3210
  return false;
@@ -3266,15 +3212,20 @@ export class ThinEngine extends AbstractEngine {
3266
3212
  let internalTexture;
3267
3213
  if (depthStencilTexture) {
3268
3214
  internalTexture = texture.depthStencilTexture;
3269
- } else if (texture.isReady()) {
3215
+ }
3216
+ else if (texture.isReady()) {
3270
3217
  internalTexture = texture.getInternalTexture();
3271
- } else if (texture.isCube) {
3218
+ }
3219
+ else if (texture.isCube) {
3272
3220
  internalTexture = this.emptyCubeTexture;
3273
- } else if (texture.is3D) {
3221
+ }
3222
+ else if (texture.is3D) {
3274
3223
  internalTexture = this.emptyTexture3D;
3275
- } else if (texture.is2DArray) {
3224
+ }
3225
+ else if (texture.is2DArray) {
3276
3226
  internalTexture = this.emptyTexture2DArray;
3277
- } else {
3227
+ }
3228
+ else {
3278
3229
  internalTexture = this.emptyTexture;
3279
3230
  }
3280
3231
  if (!isPartOfTextureArray && internalTexture) {
@@ -3296,7 +3247,9 @@ export class ThinEngine extends AbstractEngine {
3296
3247
  // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
3297
3248
  if (internalTexture.isCube && internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
3298
3249
  internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
3299
- const textureWrapMode = texture.coordinatesMode !== 3 && texture.coordinatesMode !== 5 ? 1 : 0;
3250
+ const textureWrapMode = texture.coordinatesMode !== 3 && texture.coordinatesMode !== 5
3251
+ ? 1
3252
+ : 0;
3300
3253
  texture.wrapU = textureWrapMode;
3301
3254
  texture.wrapV = textureWrapMode;
3302
3255
  }
@@ -3335,7 +3288,8 @@ export class ThinEngine extends AbstractEngine {
3335
3288
  if (texture) {
3336
3289
  this._textureUnits[i] = channel + i;
3337
3290
  texture._associatedChannel = channel + i;
3338
- } else {
3291
+ }
3292
+ else {
3339
3293
  this._textureUnits[i] = -1;
3340
3294
  }
3341
3295
  }
@@ -3349,16 +3303,13 @@ export class ThinEngine extends AbstractEngine {
3349
3303
  */
3350
3304
  _setAnisotropicLevel(target, internalTexture, anisotropicFilteringLevel) {
3351
3305
  const anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
3352
- if (internalTexture.samplingMode !== 11 && internalTexture.samplingMode !== 3 && internalTexture.samplingMode !== 2) {
3306
+ if (internalTexture.samplingMode !== 11 &&
3307
+ internalTexture.samplingMode !== 3 &&
3308
+ internalTexture.samplingMode !== 2) {
3353
3309
  anisotropicFilteringLevel = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
3354
3310
  }
3355
3311
  if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== anisotropicFilteringLevel) {
3356
- this._setTextureParameterFloat(
3357
- target,
3358
- anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT,
3359
- Math.min(anisotropicFilteringLevel, this._caps.maxAnisotropy),
3360
- internalTexture
3361
- );
3312
+ this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(anisotropicFilteringLevel, this._caps.maxAnisotropy), internalTexture);
3362
3313
  internalTexture._cachedAnisotropicFilteringLevel = anisotropicFilteringLevel;
3363
3314
  }
3364
3315
  }
@@ -3471,7 +3422,7 @@ export class ThinEngine extends AbstractEngine {
3471
3422
  const gl = this._gl;
3472
3423
  //clear existing errors
3473
3424
  // eslint-disable-next-line no-empty
3474
- while (gl.getError() !== gl.NO_ERROR) {}
3425
+ while (gl.getError() !== gl.NO_ERROR) { }
3475
3426
  let successful = true;
3476
3427
  const texture = gl.createTexture();
3477
3428
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -3505,7 +3456,7 @@ export class ThinEngine extends AbstractEngine {
3505
3456
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
3506
3457
  //clear accumulated errors
3507
3458
  // eslint-disable-next-line no-empty
3508
- while (!successful && gl.getError() !== gl.NO_ERROR) {}
3459
+ while (!successful && gl.getError() !== gl.NO_ERROR) { }
3509
3460
  return successful;
3510
3461
  }
3511
3462
  /**
@@ -3820,7 +3771,8 @@ export class ThinEngine extends AbstractEngine {
3820
3771
  const dataLength = width * height * numChannels;
3821
3772
  if (!data) {
3822
3773
  data = new Uint8Array(dataLength);
3823
- } else if (data.length < dataLength) {
3774
+ }
3775
+ else if (data.length < dataLength) {
3824
3776
  Logger.Error(`Data buffer is too small to store the read pixels (${data.length} should be more than ${dataLength})`);
3825
3777
  return Promise.resolve(data);
3826
3778
  }
@@ -3857,7 +3809,8 @@ export class ThinEngine extends AbstractEngine {
3857
3809
  const tempcanvas = AbstractEngine._CreateCanvas(1, 1);
3858
3810
  const gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
3859
3811
  this._IsSupported = gl != null && !!globalThis.WebGLRenderingContext;
3860
- } catch (e) {
3812
+ }
3813
+ catch (e) {
3861
3814
  this._IsSupported = false;
3862
3815
  }
3863
3816
  }
@@ -3870,10 +3823,11 @@ export class ThinEngine extends AbstractEngine {
3870
3823
  if (this._HasMajorPerformanceCaveat === null) {
3871
3824
  try {
3872
3825
  const tempcanvas = AbstractEngine._CreateCanvas(1, 1);
3873
- const gl =
3874
- tempcanvas.getContext("webgl", { failIfMajorPerformanceCaveat: true }) || tempcanvas.getContext("experimental-webgl", { failIfMajorPerformanceCaveat: true });
3826
+ const gl = tempcanvas.getContext("webgl", { failIfMajorPerformanceCaveat: true }) ||
3827
+ tempcanvas.getContext("experimental-webgl", { failIfMajorPerformanceCaveat: true });
3875
3828
  this._HasMajorPerformanceCaveat = !gl;
3876
- } catch (e) {
3829
+ }
3830
+ catch (e) {
3877
3831
  this._HasMajorPerformanceCaveat = false;
3878
3832
  }
3879
3833
  }
@@ -3915,4 +3869,4 @@ import { _MissingSideEffect } from "../Misc/devTools.js";
3915
3869
  (_g = ThinEngine.prototype).bindUniformBufferBase ?? (_g.bindUniformBufferBase = _MissingSideEffect("ThinEngine", "bindUniformBufferBase"));
3916
3870
  (_h = ThinEngine.prototype).bindUniformBlock ?? (_h.bindUniformBlock = _MissingSideEffect("ThinEngine", "bindUniformBlock"));
3917
3871
  // #endregion GENERATED_SIDE_EFFECT_STUBS
3918
- //# sourceMappingURL=thinEngine.pure.js.map
3872
+ //# sourceMappingURL=thinEngine.pure.js.map