@babylonjs/core 5.52.0 → 5.53.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 (168) hide show
  1. package/Animations/animatable.js +1 -1
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/animationGroup.js +8 -1
  4. package/Animations/animationGroup.js.map +1 -1
  5. package/Collisions/pickingInfo.d.ts +2 -1
  6. package/Collisions/pickingInfo.js +4 -3
  7. package/Collisions/pickingInfo.js.map +1 -1
  8. package/DeviceInput/eventFactory.js +4 -0
  9. package/DeviceInput/eventFactory.js.map +1 -1
  10. package/DeviceInput/webDeviceInputSystem.js +17 -9
  11. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  12. package/Engines/Extensions/engine.cubeTexture.js +3 -0
  13. package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
  14. package/Engines/Extensions/engine.multiRender.js +74 -19
  15. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  16. package/Engines/Extensions/engine.renderTarget.js +2 -5
  17. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  18. package/Engines/WebGL/webGLHardwareTexture.d.ts +3 -1
  19. package/Engines/WebGL/webGLHardwareTexture.js +19 -7
  20. package/Engines/WebGL/webGLHardwareTexture.js.map +1 -1
  21. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +14 -1
  22. package/Engines/WebGL/webGLRenderTargetWrapper.js +76 -6
  23. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  24. package/Engines/WebGPU/Extensions/engine.multiRender.js +20 -0
  25. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  26. package/Engines/WebGPU/Extensions/engine.renderTarget.js +3 -1
  27. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  28. package/Engines/WebGPU/webgpuConstants.d.ts +22 -7
  29. package/Engines/WebGPU/webgpuConstants.js +24 -8
  30. package/Engines/WebGPU/webgpuConstants.js.map +1 -1
  31. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +0 -3
  32. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +20 -53
  33. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  34. package/Engines/WebGPU/webgpuTextureHelper.d.ts +3 -2
  35. package/Engines/WebGPU/webgpuTextureHelper.js +33 -14
  36. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  37. package/Engines/WebGPU/webgpuTintWASM.d.ts +3 -2
  38. package/Engines/WebGPU/webgpuTintWASM.js +10 -8
  39. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  40. package/Engines/constants.d.ts +12 -0
  41. package/Engines/constants.js +12 -0
  42. package/Engines/constants.js.map +1 -1
  43. package/Engines/engine.d.ts +130 -72
  44. package/Engines/engine.js +5 -0
  45. package/Engines/engine.js.map +1 -1
  46. package/Engines/nativeEngine.d.ts +1 -0
  47. package/Engines/nativeEngine.js +16 -5
  48. package/Engines/nativeEngine.js.map +1 -1
  49. package/Engines/renderTargetWrapper.d.ts +28 -4
  50. package/Engines/renderTargetWrapper.js +107 -10
  51. package/Engines/renderTargetWrapper.js.map +1 -1
  52. package/Engines/thinEngine.d.ts +6 -6
  53. package/Engines/thinEngine.js +29 -21
  54. package/Engines/thinEngine.js.map +1 -1
  55. package/Engines/webgpuEngine.d.ts +25 -8
  56. package/Engines/webgpuEngine.js +112 -48
  57. package/Engines/webgpuEngine.js.map +1 -1
  58. package/Inputs/scene.inputManager.js +5 -12
  59. package/Inputs/scene.inputManager.js.map +1 -1
  60. package/Materials/PBR/pbrAnisotropicConfiguration.js +0 -1
  61. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  62. package/Materials/PBR/pbrBaseMaterial.js +3 -0
  63. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  64. package/Materials/Textures/Filtering/hdrFiltering.js +4 -0
  65. package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
  66. package/Materials/Textures/internalTexture.d.ts +4 -0
  67. package/Materials/Textures/internalTexture.js.map +1 -1
  68. package/Materials/Textures/multiRenderTarget.d.ts +40 -0
  69. package/Materials/Textures/multiRenderTarget.js +143 -4
  70. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  71. package/Materials/Textures/renderTargetTexture.d.ts +4 -0
  72. package/Materials/Textures/renderTargetTexture.js +10 -2
  73. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  74. package/Materials/Textures/texture.d.ts +4 -2
  75. package/Materials/Textures/texture.js +1 -0
  76. package/Materials/Textures/texture.js.map +1 -1
  77. package/Materials/Textures/textureCreationOptions.d.ts +4 -0
  78. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  79. package/Materials/materialPluginBase.d.ts +3 -2
  80. package/Materials/materialPluginBase.js.map +1 -1
  81. package/Materials/materialPluginManager.js +13 -3
  82. package/Materials/materialPluginManager.js.map +1 -1
  83. package/Materials/uniformBuffer.d.ts +2 -0
  84. package/Materials/uniformBuffer.js +4 -0
  85. package/Materials/uniformBuffer.js.map +1 -1
  86. package/Maths/math.frustum.d.ts +8 -1
  87. package/Maths/math.frustum.js +14 -0
  88. package/Maths/math.frustum.js.map +1 -1
  89. package/Meshes/instancedMesh.d.ts +2 -1
  90. package/Meshes/instancedMesh.js +3 -2
  91. package/Meshes/instancedMesh.js.map +1 -1
  92. package/Meshes/mesh.d.ts +10 -5
  93. package/Meshes/mesh.js +40 -16
  94. package/Meshes/mesh.js.map +1 -1
  95. package/Misc/filesInput.d.ts +5 -2
  96. package/Misc/filesInput.js +39 -20
  97. package/Misc/filesInput.js.map +1 -1
  98. package/Misc/interfaces/screenshotSize.d.ts +17 -3
  99. package/Misc/interfaces/screenshotSize.js.map +1 -1
  100. package/Misc/sceneOptimizer.js +3 -0
  101. package/Misc/sceneOptimizer.js.map +1 -1
  102. package/Misc/screenshotTools.d.ts +2 -2
  103. package/Misc/screenshotTools.js +49 -9
  104. package/Misc/screenshotTools.js.map +1 -1
  105. package/Misc/textureTools.d.ts +1 -1
  106. package/Misc/textureTools.js +4 -2
  107. package/Misc/textureTools.js.map +1 -1
  108. package/Physics/v2/physicsAggregate.js +3 -3
  109. package/Physics/v2/physicsAggregate.js.map +1 -1
  110. package/Physics/v2/physicsBody.d.ts +27 -16
  111. package/Physics/v2/physicsBody.js +31 -16
  112. package/Physics/v2/physicsBody.js.map +1 -1
  113. package/Physics/v2/physicsConstraint.d.ts +6 -6
  114. package/Physics/v2/physicsConstraint.js +6 -6
  115. package/Physics/v2/physicsConstraint.js.map +1 -1
  116. package/Physics/v2/physicsShape.d.ts +7 -7
  117. package/Physics/v2/physicsShape.js +7 -7
  118. package/Physics/v2/physicsShape.js.map +1 -1
  119. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +1 -0
  120. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  121. package/PostProcesses/RenderPipeline/postProcessRenderPipelineManager.d.ts +5 -0
  122. package/PostProcesses/RenderPipeline/postProcessRenderPipelineManager.js +7 -0
  123. package/PostProcesses/RenderPipeline/postProcessRenderPipelineManager.js.map +1 -1
  124. package/PostProcesses/depthOfFieldMergePostProcess.d.ts +0 -23
  125. package/PostProcesses/depthOfFieldMergePostProcess.js +0 -5
  126. package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
  127. package/PostProcesses/postProcess.js +1 -0
  128. package/PostProcesses/postProcess.js.map +1 -1
  129. package/Probes/reflectionProbe.js +1 -0
  130. package/Probes/reflectionProbe.js.map +1 -1
  131. package/Rendering/depthPeelingRenderer.js +3 -1
  132. package/Rendering/depthPeelingRenderer.js.map +1 -1
  133. package/Rendering/fluidRenderer/fluidRenderer.js +1 -1
  134. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  135. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js +2 -1
  136. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js.map +1 -1
  137. package/Rendering/fluidRenderer/fluidRenderingTextures.js +2 -0
  138. package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
  139. package/Shaders/default.fragment.js +1 -1
  140. package/Shaders/default.fragment.js.map +1 -1
  141. package/Shaders/depthOfFieldMerge.fragment.js +10 -5
  142. package/Shaders/depthOfFieldMerge.fragment.js.map +1 -1
  143. package/Shaders/fluidRenderingRender.fragment.js +3 -3
  144. package/Shaders/fluidRenderingRender.fragment.js.map +1 -1
  145. package/Shaders/motionBlur.fragment.js +8 -2
  146. package/Shaders/motionBlur.fragment.js.map +1 -1
  147. package/Shaders/screenSpaceReflection2.fragment.js +11 -4
  148. package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
  149. package/Shaders/screenSpaceReflection2Blur.fragment.js +6 -1
  150. package/Shaders/screenSpaceReflection2Blur.fragment.js.map +1 -1
  151. package/Shaders/ssao2.fragment.js +1 -0
  152. package/Shaders/ssao2.fragment.js.map +1 -1
  153. package/ShadersWGSL/ShadersInclude/bakedVertexAnimation.js +9 -9
  154. package/ShadersWGSL/ShadersInclude/bakedVertexAnimation.js.map +1 -1
  155. package/ShadersWGSL/ShadersInclude/bonesVertex.js +16 -16
  156. package/ShadersWGSL/ShadersInclude/bonesVertex.js.map +1 -1
  157. package/ShadersWGSL/ShadersInclude/clipPlaneFragment.js +6 -6
  158. package/ShadersWGSL/ShadersInclude/clipPlaneFragment.js.map +1 -1
  159. package/ShadersWGSL/ShadersInclude/clipPlaneVertex.js +6 -6
  160. package/ShadersWGSL/ShadersInclude/clipPlaneVertex.js.map +1 -1
  161. package/ShadersWGSL/ShadersInclude/instancesVertex.js +1 -1
  162. package/ShadersWGSL/ShadersInclude/instancesVertex.js.map +1 -1
  163. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +8 -8
  164. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
  165. package/XR/features/WebXRControllerTeleportation.d.ts +9 -0
  166. package/XR/features/WebXRControllerTeleportation.js +28 -4
  167. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  168. package/package.json +1 -1
@@ -20,6 +20,8 @@ export declare class RenderTargetWrapper {
20
20
  private _isCube;
21
21
  private _isMulti;
22
22
  private _textures;
23
+ private _faceIndices;
24
+ private _layerIndices;
23
25
  /** @internal */
24
26
  _samples: number;
25
27
  /** @internal */
@@ -65,7 +67,7 @@ export declare class RenderTargetWrapper {
65
67
  */
66
68
  get height(): number;
67
69
  /**
68
- * Gets the number of layers of the render target wrapper (only used if is2DArray is true)
70
+ * Gets the number of layers of the render target wrapper (only used if is2DArray is true and wrapper is not a multi render target)
69
71
  */
70
72
  get layers(): number;
71
73
  /**
@@ -76,6 +78,14 @@ export declare class RenderTargetWrapper {
76
78
  * Gets the list of render textures. If we are not in a multi render target, the list will be null (use the texture getter instead)
77
79
  */
78
80
  get textures(): Nullable<InternalTexture[]>;
81
+ /**
82
+ * Gets the face indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null
83
+ */
84
+ get faceIndices(): Nullable<number[]>;
85
+ /**
86
+ * Gets the layer indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null
87
+ */
88
+ get layerIndices(): Nullable<number[]>;
79
89
  /**
80
90
  * Gets the sample count of the render target
81
91
  */
@@ -103,11 +113,24 @@ export declare class RenderTargetWrapper {
103
113
  setTextures(textures: Nullable<InternalTexture> | Nullable<InternalTexture[]>): void;
104
114
  /**
105
115
  * Set a texture in the textures array
106
- * @param texture the texture to set
107
- * @param index the index in the textures array to set
116
+ * @param texture The texture to set
117
+ * @param index The index in the textures array to set
108
118
  * @param disposePrevious If this function should dispose the previous texture
109
119
  */
110
120
  setTexture(texture: InternalTexture, index?: number, disposePrevious?: boolean): void;
121
+ /**
122
+ * Sets the layer and face indices of every render target texture bound to each color attachment
123
+ * @param layers The layers of each texture to be set
124
+ * @param faces The faces of each texture to be set
125
+ */
126
+ setLayerAndFaceIndices(layers: number[], faces: number[]): void;
127
+ /**
128
+ * Sets the layer and face indices of a texture in the textures array that should be bound to each color attachment
129
+ * @param index The index of the texture in the textures array to modify
130
+ * @param layer The layer of the texture to be set
131
+ * @param face The face of the texture to be set
132
+ */
133
+ setLayerAndFaceIndex(index?: number, layer?: number, face?: number): void;
111
134
  /**
112
135
  * Creates the depth/stencil texture
113
136
  * @param comparisonFunction Comparison function to use for the texture
@@ -115,9 +138,10 @@ export declare class RenderTargetWrapper {
115
138
  * @param generateStencil true if the stencil aspect should also be created
116
139
  * @param samples sample count to use when creating the texture
117
140
  * @param format format of the depth texture
141
+ * @param label defines the label to use for the texture (for debugging purpose only)
118
142
  * @returns the depth/stencil created texture
119
143
  */
120
- createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number, format?: number): InternalTexture;
144
+ createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number, format?: number, label?: string): InternalTexture;
121
145
  /**
122
146
  * Shares the depth buffer of this render target with another render target.
123
147
  * @internal
@@ -53,7 +53,7 @@ export class RenderTargetWrapper {
53
53
  return this._size.height || this._size;
54
54
  }
55
55
  /**
56
- * Gets the number of layers of the render target wrapper (only used if is2DArray is true)
56
+ * Gets the number of layers of the render target wrapper (only used if is2DArray is true and wrapper is not a multi render target)
57
57
  */
58
58
  get layers() {
59
59
  return this._size.layers || 0;
@@ -71,6 +71,18 @@ export class RenderTargetWrapper {
71
71
  get textures() {
72
72
  return this._textures;
73
73
  }
74
+ /**
75
+ * Gets the face indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null
76
+ */
77
+ get faceIndices() {
78
+ return this._faceIndices;
79
+ }
80
+ /**
81
+ * Gets the layer indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null
82
+ */
83
+ get layerIndices() {
84
+ return this._layerIndices;
85
+ }
74
86
  /**
75
87
  * Gets the sample count of the render target
76
88
  */
@@ -103,6 +115,8 @@ export class RenderTargetWrapper {
103
115
  */
104
116
  constructor(isMulti, isCube, size, engine) {
105
117
  this._textures = null;
118
+ this._faceIndices = null;
119
+ this._layerIndices = null;
106
120
  /** @internal */
107
121
  this._samples = 1;
108
122
  /** @internal */
@@ -136,8 +150,8 @@ export class RenderTargetWrapper {
136
150
  }
137
151
  /**
138
152
  * Set a texture in the textures array
139
- * @param texture the texture to set
140
- * @param index the index in the textures array to set
153
+ * @param texture The texture to set
154
+ * @param index The index in the textures array to set
141
155
  * @param disposePrevious If this function should dispose the previous texture
142
156
  */
143
157
  setTexture(texture, index = 0, disposePrevious = true) {
@@ -149,6 +163,35 @@ export class RenderTargetWrapper {
149
163
  }
150
164
  this._textures[index] = texture;
151
165
  }
166
+ /**
167
+ * Sets the layer and face indices of every render target texture bound to each color attachment
168
+ * @param layers The layers of each texture to be set
169
+ * @param faces The faces of each texture to be set
170
+ */
171
+ setLayerAndFaceIndices(layers, faces) {
172
+ this._layerIndices = layers;
173
+ this._faceIndices = faces;
174
+ }
175
+ /**
176
+ * Sets the layer and face indices of a texture in the textures array that should be bound to each color attachment
177
+ * @param index The index of the texture in the textures array to modify
178
+ * @param layer The layer of the texture to be set
179
+ * @param face The face of the texture to be set
180
+ */
181
+ setLayerAndFaceIndex(index = 0, layer, face) {
182
+ if (!this._layerIndices) {
183
+ this._layerIndices = [];
184
+ }
185
+ if (!this._faceIndices) {
186
+ this._faceIndices = [];
187
+ }
188
+ if (layer !== undefined && layer >= 0) {
189
+ this._layerIndices[index] = layer;
190
+ }
191
+ if (face !== undefined && face >= 0) {
192
+ this._faceIndices[index] = face;
193
+ }
194
+ }
152
195
  /**
153
196
  * Creates the depth/stencil texture
154
197
  * @param comparisonFunction Comparison function to use for the texture
@@ -156,9 +199,10 @@ export class RenderTargetWrapper {
156
199
  * @param generateStencil true if the stencil aspect should also be created
157
200
  * @param samples sample count to use when creating the texture
158
201
  * @param format format of the depth texture
202
+ * @param label defines the label to use for the texture (for debugging purpose only)
159
203
  * @returns the depth/stencil created texture
160
204
  */
161
- createDepthStencilTexture(comparisonFunction = 0, bilinearFiltering = true, generateStencil = false, samples = 1, format = 14) {
205
+ createDepthStencilTexture(comparisonFunction = 0, bilinearFiltering = true, generateStencil = false, samples = 1, format = 14, label) {
162
206
  var _a;
163
207
  (_a = this._depthStencilTexture) === null || _a === void 0 ? void 0 : _a.dispose();
164
208
  this._depthStencilTextureWithStencil = generateStencil;
@@ -169,6 +213,7 @@ export class RenderTargetWrapper {
169
213
  isCube: this._isCube,
170
214
  samples,
171
215
  depthTextureFormat: format,
216
+ label,
172
217
  }, this);
173
218
  return this._depthStencilTexture;
174
219
  }
@@ -197,7 +242,7 @@ export class RenderTargetWrapper {
197
242
  this.dispose(true);
198
243
  }
199
244
  _cloneRenderTargetWrapper() {
200
- var _a, _b, _c, _d, _e, _f;
245
+ var _a, _b, _c, _d, _e, _f, _g, _h;
201
246
  let rtw = null;
202
247
  if (this._isMulti) {
203
248
  const textureArray = this.textures;
@@ -211,10 +256,50 @@ export class RenderTargetWrapper {
211
256
  }
212
257
  const samplingModes = [];
213
258
  const types = [];
259
+ const formats = [];
260
+ const targetTypes = [];
261
+ const faceIndex = [];
262
+ const layerIndex = [];
263
+ const layerCounts = [];
264
+ const internalTexture2Index = {};
214
265
  for (let i = 0; i < textureCount; ++i) {
215
266
  const texture = textureArray[i];
216
267
  samplingModes.push(texture.samplingMode);
217
268
  types.push(texture.type);
269
+ formats.push(texture.format);
270
+ const index = internalTexture2Index[texture.uniqueId];
271
+ if (index !== undefined) {
272
+ targetTypes.push(-1);
273
+ layerCounts.push(0);
274
+ }
275
+ else {
276
+ internalTexture2Index[texture.uniqueId] = i;
277
+ if (texture.is2DArray) {
278
+ targetTypes.push(35866);
279
+ layerCounts.push(texture.depth);
280
+ }
281
+ else if (texture.isCube) {
282
+ targetTypes.push(34067);
283
+ layerCounts.push(0);
284
+ } /*else if (texture.isCubeArray) {
285
+ targetTypes.push(3735928559);
286
+ layerCounts.push(texture.depth);
287
+ }*/
288
+ else if (texture.is3D) {
289
+ targetTypes.push(32879);
290
+ layerCounts.push(texture.depth);
291
+ }
292
+ else {
293
+ targetTypes.push(3553);
294
+ layerCounts.push(0);
295
+ }
296
+ }
297
+ if (this._faceIndices) {
298
+ faceIndex.push((_a = this._faceIndices[i]) !== null && _a !== void 0 ? _a : 0);
299
+ }
300
+ if (this._layerIndices) {
301
+ layerIndex.push((_b = this._layerIndices[i]) !== null && _b !== void 0 ? _b : 0);
302
+ }
218
303
  }
219
304
  const optionsMRT = {
220
305
  samplingModes,
@@ -223,23 +308,35 @@ export class RenderTargetWrapper {
223
308
  generateStencilBuffer: this._generateStencilBuffer,
224
309
  generateDepthTexture,
225
310
  types,
311
+ formats,
226
312
  textureCount,
313
+ targetTypes,
314
+ faceIndex,
315
+ layerIndex,
316
+ layerCounts,
227
317
  };
228
318
  const size = {
229
319
  width: this.width,
230
320
  height: this.height,
231
321
  };
232
322
  rtw = this._engine.createMultipleRenderTarget(size, optionsMRT);
323
+ for (let i = 0; i < textureCount; ++i) {
324
+ if (targetTypes[i] !== -1) {
325
+ continue;
326
+ }
327
+ const index = internalTexture2Index[textureArray[i].uniqueId];
328
+ rtw.setTexture(rtw.textures[index], i);
329
+ }
233
330
  }
234
331
  }
235
332
  else {
236
333
  const options = {};
237
334
  options.generateDepthBuffer = this._generateDepthBuffer;
238
- options.generateMipMaps = (_b = (_a = this.texture) === null || _a === void 0 ? void 0 : _a.generateMipMaps) !== null && _b !== void 0 ? _b : false;
335
+ options.generateMipMaps = (_d = (_c = this.texture) === null || _c === void 0 ? void 0 : _c.generateMipMaps) !== null && _d !== void 0 ? _d : false;
239
336
  options.generateStencilBuffer = this._generateStencilBuffer;
240
- options.samplingMode = (_c = this.texture) === null || _c === void 0 ? void 0 : _c.samplingMode;
241
- options.type = (_d = this.texture) === null || _d === void 0 ? void 0 : _d.type;
242
- options.format = (_e = this.texture) === null || _e === void 0 ? void 0 : _e.format;
337
+ options.samplingMode = (_e = this.texture) === null || _e === void 0 ? void 0 : _e.samplingMode;
338
+ options.type = (_f = this.texture) === null || _f === void 0 ? void 0 : _f.type;
339
+ options.format = (_g = this.texture) === null || _g === void 0 ? void 0 : _g.format;
243
340
  if (this.isCube) {
244
341
  rtw = this._engine.createRenderTargetCubeTexture(this.width, options);
245
342
  }
@@ -247,7 +344,7 @@ export class RenderTargetWrapper {
247
344
  const size = {
248
345
  width: this.width,
249
346
  height: this.height,
250
- layers: this.is2DArray ? (_f = this.texture) === null || _f === void 0 ? void 0 : _f.depth : undefined,
347
+ layers: this.is2DArray ? (_h = this.texture) === null || _h === void 0 ? void 0 : _h.depth : undefined,
251
348
  };
252
349
  rtw = this._engine.createRenderTargetTexture(size, options);
253
350
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderTargetWrapper.js","sourceRoot":"","sources":["../../../../lts/core/generated/Engines/renderTargetWrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAG9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAaxC;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAqB5B;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAW,8BAA8B;QACrC,OAAO,IAAI,CAAC,+BAA+B,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAA2C,IAAI,CAAC,KAAM,CAAC,KAAK,IAAY,IAAI,CAAC,KAAK,CAAC;IACvF,CAAC;IAED;;OAEG;I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C;aAC/B;SACJ;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,uBAAuB,GAAG,KAAK;;QAC1C,IAAI,CAAC,uBAAuB,EAAE;YAC1B,MAAA,IAAI,CAAC,oBAAoB,0CAAE,OAAO,EAAE,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,eAAe,EAAE,CAAC;SAC1B;QAED,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Constants } from \"./constants\";\r\nimport type { ThinEngine } from \"./thinEngine\";\r\n\r\n/**\r\n * An interface enforcing the renderTarget accessor to used by render target textures.\r\n */\r\nexport interface IRenderTargetTexture {\r\n /**\r\n * Entry point to access the wrapper on a texture.\r\n */\r\n renderTarget: Nullable<RenderTargetWrapper>;\r\n}\r\n\r\n/**\r\n * Wrapper around a render target (either single or multi textures)\r\n */\r\nexport class RenderTargetWrapper {\r\n protected _engine: ThinEngine;\r\n private _size: TextureSize;\r\n private _isCube: boolean;\r\n private _isMulti: boolean;\r\n private _textures: Nullable<InternalTexture[]> = null;\r\n /** @internal */\r\n public _samples = 1;\r\n\r\n /** @internal */\r\n public _attachments: Nullable<number[]> = null;\r\n /** @internal */\r\n public _generateStencilBuffer: boolean = false;\r\n /** @internal */\r\n public _generateDepthBuffer: boolean = false;\r\n\r\n /** @internal */\r\n public _depthStencilTexture: Nullable<InternalTexture>;\r\n /** @internal */\r\n public _depthStencilTextureWithStencil: boolean = false;\r\n\r\n /**\r\n * Gets the depth/stencil texture (if created by a createDepthStencilTexture() call)\r\n */\r\n public get depthStencilTexture() {\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Indicates if the depth/stencil texture has a stencil aspect\r\n */\r\n public get depthStencilTextureWithStencil() {\r\n return this._depthStencilTextureWithStencil;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a cube texture or if false a 2d texture\r\n */\r\n public get isCube(): boolean {\r\n return this._isCube;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or multi target render wrapper\r\n */\r\n public get isMulti(): boolean {\r\n return this._isMulti;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or an array of textures\r\n */\r\n public get is2DArray(): boolean {\r\n return this.layers > 0;\r\n }\r\n\r\n /**\r\n * Gets the size of the render target wrapper (used for cubes, as width=height in this case)\r\n */\r\n public get size(): number {\r\n return this.width;\r\n }\r\n\r\n /**\r\n * Gets the width of the render target wrapper\r\n */\r\n public get width(): number {\r\n return (<{ width: number; height: number }>this._size).width || <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the height of the render target wrapper\r\n */\r\n public get height(): number {\r\n return (<{ width: number; height: number }>this._size).height || <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the number of layers of the render target wrapper (only used if is2DArray is true)\r\n */\r\n public get layers(): number {\r\n return (<{ width: number; height: number; layers?: number }>this._size).layers || 0;\r\n }\r\n\r\n /**\r\n * Gets the render texture. If this is a multi render target, gets the first texture\r\n */\r\n public get texture(): Nullable<InternalTexture> {\r\n return this._textures?.[0] ?? null;\r\n }\r\n\r\n /**\r\n * Gets the list of render textures. If we are not in a multi render target, the list will be null (use the texture getter instead)\r\n */\r\n public get textures(): Nullable<InternalTexture[]> {\r\n return this._textures;\r\n }\r\n\r\n /**\r\n * Gets the sample count of the render target\r\n */\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n /**\r\n * Sets the sample count of the render target\r\n * @param value sample count\r\n * @param initializeBuffers If set to true, the engine will make an initializing call to drawBuffers (only used when isMulti=true).\r\n * @param force true to force calling the update sample count engine function even if the current sample count is equal to value\r\n * @returns the sample count that has been set\r\n */\r\n public setSamples(value: number, initializeBuffers = true, force = false): number {\r\n if (this.samples === value && !force) {\r\n return value;\r\n }\r\n\r\n const result = this._isMulti\r\n ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, value, initializeBuffers)\r\n : this._engine.updateRenderTargetTextureSampleCount(this, value);\r\n this._samples = value;\r\n return result;\r\n }\r\n\r\n /**\r\n * Initializes the render target wrapper\r\n * @param isMulti true if the wrapper is a multi render target\r\n * @param isCube true if the wrapper should render to a cube texture\r\n * @param size size of the render target (width/height/layers)\r\n * @param engine engine used to create the render target\r\n */\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: ThinEngine) {\r\n this._isMulti = isMulti;\r\n this._isCube = isCube;\r\n this._size = size;\r\n this._engine = engine;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /**\r\n * Sets the render target texture(s)\r\n * @param textures texture(s) to set\r\n */\r\n public setTextures(textures: Nullable<InternalTexture> | Nullable<InternalTexture[]>): void {\r\n if (Array.isArray(textures)) {\r\n this._textures = textures;\r\n } else if (textures) {\r\n this._textures = [textures];\r\n } else {\r\n this._textures = null;\r\n }\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture the texture to set\r\n * @param index the index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true): void {\r\n if (!this._textures) {\r\n this._textures = [];\r\n }\r\n if (this._textures[index] && disposePrevious) {\r\n this._textures[index].dispose();\r\n }\r\n\r\n this._textures[index] = texture;\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil true if the stencil aspect should also be created\r\n * @param samples sample count to use when creating the texture\r\n * @param format format of the depth texture\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT\r\n ): InternalTexture {\r\n this._depthStencilTexture?.dispose();\r\n\r\n this._depthStencilTextureWithStencil = generateStencil;\r\n this._depthStencilTexture = this._engine.createDepthStencilTexture(\r\n this._size,\r\n {\r\n bilinearFiltering,\r\n comparisonFunction,\r\n generateStencil,\r\n isCube: this._isCube,\r\n samples,\r\n depthTextureFormat: format,\r\n },\r\n this\r\n );\r\n\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @internal\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public _shareDepth(renderTarget: RenderTargetWrapper): void {\r\n if (this._depthStencilTexture) {\r\n if (renderTarget._depthStencilTexture) {\r\n renderTarget._depthStencilTexture.dispose();\r\n }\r\n\r\n renderTarget._depthStencilTexture = this._depthStencilTexture;\r\n this._depthStencilTexture.incrementReferences();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture): void {\r\n if (this.texture) {\r\n this.texture._swapAndDie(target);\r\n }\r\n this._textures = null;\r\n this.dispose(true);\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._isMulti) {\r\n const textureArray = this.textures;\r\n if (textureArray && textureArray.length > 0) {\r\n let generateDepthTexture = false;\r\n let textureCount = textureArray.length;\r\n\r\n const lastTextureSource = textureArray[textureArray.length - 1]._source;\r\n if (lastTextureSource === InternalTextureSource.Depth || lastTextureSource === InternalTextureSource.DepthStencil) {\r\n generateDepthTexture = true;\r\n textureCount--;\r\n }\r\n\r\n const samplingModes: number[] = [];\r\n const types: number[] = [];\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n const texture = textureArray[i];\r\n\r\n samplingModes.push(texture.samplingMode);\r\n types.push(texture.type);\r\n }\r\n\r\n const optionsMRT = {\r\n samplingModes,\r\n generateMipMaps: textureArray[0].generateMipMaps,\r\n generateDepthBuffer: this._generateDepthBuffer,\r\n generateStencilBuffer: this._generateStencilBuffer,\r\n generateDepthTexture,\r\n types,\r\n textureCount,\r\n };\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n };\r\n\r\n rtw = this._engine.createMultipleRenderTarget(size, optionsMRT);\r\n }\r\n } else {\r\n const options: RenderTargetCreationOptions = {};\r\n\r\n options.generateDepthBuffer = this._generateDepthBuffer;\r\n options.generateMipMaps = this.texture?.generateMipMaps ?? false;\r\n options.generateStencilBuffer = this._generateStencilBuffer;\r\n options.samplingMode = this.texture?.samplingMode;\r\n options.type = this.texture?.type;\r\n options.format = this.texture?.format;\r\n\r\n if (this.isCube) {\r\n rtw = this._engine.createRenderTargetCubeTexture(this.width, options);\r\n } else {\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n layers: this.is2DArray ? this.texture?.depth : undefined,\r\n };\r\n\r\n rtw = this._engine.createRenderTargetTexture(size, options);\r\n }\r\n rtw.texture!.isReady = true;\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: RenderTargetWrapper): void {\r\n if (this._textures && target._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i]._swapAndDie(target._textures[i], false);\r\n target._textures[i].isReady = true;\r\n }\r\n }\r\n if (this._depthStencilTexture && target._depthStencilTexture) {\r\n this._depthStencilTexture._swapAndDie(target._depthStencilTexture);\r\n target._depthStencilTexture.isReady = true;\r\n }\r\n\r\n this._textures = null;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n const rtw = this._cloneRenderTargetWrapper();\r\n if (!rtw) {\r\n return;\r\n }\r\n\r\n if (this._depthStencilTexture) {\r\n const samplingMode = this._depthStencilTexture.samplingMode;\r\n const bilinear =\r\n samplingMode === Constants.TEXTURE_BILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST;\r\n rtw.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, bilinear, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples);\r\n }\r\n\r\n if (this.samples > 1) {\r\n rtw.setSamples(this.samples);\r\n }\r\n\r\n rtw._swapRenderTargetWrapper(this);\r\n rtw.dispose();\r\n }\r\n\r\n /**\r\n * Releases the internal render textures\r\n */\r\n public releaseTextures(): void {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures?.length ?? 0; ++i) {\r\n this._textures[i].dispose();\r\n }\r\n }\r\n this._textures = null;\r\n }\r\n\r\n /**\r\n * Disposes the whole render target wrapper\r\n * @param disposeOnlyFramebuffers true if only the frame buffers should be released (used for the WebGL engine). If false, all the textures will also be released\r\n */\r\n public dispose(disposeOnlyFramebuffers = false): void {\r\n if (!disposeOnlyFramebuffers) {\r\n this._depthStencilTexture?.dispose();\r\n this._depthStencilTexture = null;\r\n this.releaseTextures();\r\n }\r\n\r\n this._engine._releaseRenderTargetWrapper(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"renderTargetWrapper.js","sourceRoot":"","sources":["../../../../lts/core/generated/Engines/renderTargetWrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAG9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAcxC;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAuB5B;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAW,8BAA8B;QACrC,OAAO,IAAI,CAAC,+BAA+B,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb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{ InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Constants } from \"./constants\";\r\nimport type { ThinEngine } from \"./thinEngine\";\r\nimport type { IMultiRenderTargetOptions } from \"../Materials/Textures/multiRenderTarget\";\r\n\r\n/**\r\n * An interface enforcing the renderTarget accessor to used by render target textures.\r\n */\r\nexport interface IRenderTargetTexture {\r\n /**\r\n * Entry point to access the wrapper on a texture.\r\n */\r\n renderTarget: Nullable<RenderTargetWrapper>;\r\n}\r\n\r\n/**\r\n * Wrapper around a render target (either single or multi textures)\r\n */\r\nexport class RenderTargetWrapper {\r\n protected _engine: ThinEngine;\r\n private _size: TextureSize;\r\n private _isCube: boolean;\r\n private _isMulti: boolean;\r\n private _textures: Nullable<InternalTexture[]> = null;\r\n private _faceIndices: Nullable<number[]> = null;\r\n private _layerIndices: Nullable<number[]> = null;\r\n /** @internal */\r\n public _samples = 1;\r\n\r\n /** @internal */\r\n public _attachments: Nullable<number[]> = null;\r\n /** @internal */\r\n public _generateStencilBuffer: boolean = false;\r\n /** @internal */\r\n public _generateDepthBuffer: boolean = false;\r\n\r\n /** @internal */\r\n public _depthStencilTexture: Nullable<InternalTexture>;\r\n /** @internal */\r\n public _depthStencilTextureWithStencil: boolean = false;\r\n\r\n /**\r\n * Gets the depth/stencil texture (if created by a createDepthStencilTexture() call)\r\n */\r\n public get depthStencilTexture() {\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Indicates if the depth/stencil texture has a stencil aspect\r\n */\r\n public get depthStencilTextureWithStencil() {\r\n return this._depthStencilTextureWithStencil;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a cube texture or if false a 2d texture\r\n */\r\n public get isCube(): boolean {\r\n return this._isCube;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or multi target render wrapper\r\n */\r\n public get isMulti(): boolean {\r\n return this._isMulti;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or an array of textures\r\n */\r\n public get is2DArray(): boolean {\r\n return this.layers > 0;\r\n }\r\n\r\n /**\r\n * Gets the size of the render target wrapper (used for cubes, as width=height in this case)\r\n */\r\n public get size(): number {\r\n return this.width;\r\n }\r\n\r\n /**\r\n * Gets the width of the render target wrapper\r\n */\r\n public get width(): number {\r\n return (<{ width: number; height: number }>this._size).width || <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the height of the render target wrapper\r\n */\r\n public get height(): number {\r\n return (<{ width: number; height: number }>this._size).height || <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the number of layers of the render target wrapper (only used if is2DArray is true and wrapper is not a multi render target)\r\n */\r\n public get layers(): number {\r\n return (<{ width: number; height: number; layers?: number }>this._size).layers || 0;\r\n }\r\n\r\n /**\r\n * Gets the render texture. If this is a multi render target, gets the first texture\r\n */\r\n public get texture(): Nullable<InternalTexture> {\r\n return this._textures?.[0] ?? null;\r\n }\r\n\r\n /**\r\n * Gets the list of render textures. If we are not in a multi render target, the list will be null (use the texture getter instead)\r\n */\r\n public get textures(): Nullable<InternalTexture[]> {\r\n return this._textures;\r\n }\r\n\r\n /**\r\n * Gets the face indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null\r\n */\r\n public get faceIndices(): Nullable<number[]> {\r\n return this._faceIndices;\r\n }\r\n\r\n /**\r\n * Gets the layer indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null\r\n */\r\n public get layerIndices(): Nullable<number[]> {\r\n return this._layerIndices;\r\n }\r\n\r\n /**\r\n * Gets the sample count of the render target\r\n */\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n /**\r\n * Sets the sample count of the render target\r\n * @param value sample count\r\n * @param initializeBuffers If set to true, the engine will make an initializing call to drawBuffers (only used when isMulti=true).\r\n * @param force true to force calling the update sample count engine function even if the current sample count is equal to value\r\n * @returns the sample count that has been set\r\n */\r\n public setSamples(value: number, initializeBuffers = true, force = false): number {\r\n if (this.samples === value && !force) {\r\n return value;\r\n }\r\n\r\n const result = this._isMulti\r\n ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, value, initializeBuffers)\r\n : this._engine.updateRenderTargetTextureSampleCount(this, value);\r\n this._samples = value;\r\n return result;\r\n }\r\n\r\n /**\r\n * Initializes the render target wrapper\r\n * @param isMulti true if the wrapper is a multi render target\r\n * @param isCube true if the wrapper should render to a cube texture\r\n * @param size size of the render target (width/height/layers)\r\n * @param engine engine used to create the render target\r\n */\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: ThinEngine) {\r\n this._isMulti = isMulti;\r\n this._isCube = isCube;\r\n this._size = size;\r\n this._engine = engine;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /**\r\n * Sets the render target texture(s)\r\n * @param textures texture(s) to set\r\n */\r\n public setTextures(textures: Nullable<InternalTexture> | Nullable<InternalTexture[]>): void {\r\n if (Array.isArray(textures)) {\r\n this._textures = textures;\r\n } else if (textures) {\r\n this._textures = [textures];\r\n } else {\r\n this._textures = null;\r\n }\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture The texture to set\r\n * @param index The index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true): void {\r\n if (!this._textures) {\r\n this._textures = [];\r\n }\r\n if (this._textures[index] && disposePrevious) {\r\n this._textures[index].dispose();\r\n }\r\n\r\n this._textures[index] = texture;\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of every render target texture bound to each color attachment\r\n * @param layers The layers of each texture to be set\r\n * @param faces The faces of each texture to be set\r\n */\r\n public setLayerAndFaceIndices(layers: number[], faces: number[]) {\r\n this._layerIndices = layers;\r\n this._faceIndices = faces;\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of a texture in the textures array that should be bound to each color attachment\r\n * @param index The index of the texture in the textures array to modify\r\n * @param layer The layer of the texture to be set\r\n * @param face The face of the texture to be set\r\n */\r\n public setLayerAndFaceIndex(index: number = 0, layer?: number, face?: number): void {\r\n if (!this._layerIndices) {\r\n this._layerIndices = [];\r\n }\r\n if (!this._faceIndices) {\r\n this._faceIndices = [];\r\n }\r\n\r\n if (layer !== undefined && layer >= 0) {\r\n this._layerIndices[index] = layer;\r\n }\r\n if (face !== undefined && face >= 0) {\r\n this._faceIndices[index] = face;\r\n }\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil true if the stencil aspect should also be created\r\n * @param samples sample count to use when creating the texture\r\n * @param format format of the depth texture\r\n * @param label defines the label to use for the texture (for debugging purpose only)\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n label?: string\r\n ): InternalTexture {\r\n this._depthStencilTexture?.dispose();\r\n\r\n this._depthStencilTextureWithStencil = generateStencil;\r\n this._depthStencilTexture = this._engine.createDepthStencilTexture(\r\n this._size,\r\n {\r\n bilinearFiltering,\r\n comparisonFunction,\r\n generateStencil,\r\n isCube: this._isCube,\r\n samples,\r\n depthTextureFormat: format,\r\n label,\r\n },\r\n this\r\n );\r\n\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @internal\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public _shareDepth(renderTarget: RenderTargetWrapper): void {\r\n if (this._depthStencilTexture) {\r\n if (renderTarget._depthStencilTexture) {\r\n renderTarget._depthStencilTexture.dispose();\r\n }\r\n\r\n renderTarget._depthStencilTexture = this._depthStencilTexture;\r\n this._depthStencilTexture.incrementReferences();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture): void {\r\n if (this.texture) {\r\n this.texture._swapAndDie(target);\r\n }\r\n this._textures = null;\r\n this.dispose(true);\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._isMulti) {\r\n const textureArray = this.textures;\r\n if (textureArray && textureArray.length > 0) {\r\n let generateDepthTexture = false;\r\n let textureCount = textureArray.length;\r\n\r\n const lastTextureSource = textureArray[textureArray.length - 1]._source;\r\n if (lastTextureSource === InternalTextureSource.Depth || lastTextureSource === InternalTextureSource.DepthStencil) {\r\n generateDepthTexture = true;\r\n textureCount--;\r\n }\r\n\r\n const samplingModes: number[] = [];\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const targetTypes: number[] = [];\r\n const faceIndex: number[] = [];\r\n const layerIndex: number[] = [];\r\n const layerCounts: number[] = [];\r\n const internalTexture2Index: { [id: number]: number } = {};\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n const texture = textureArray[i];\r\n\r\n samplingModes.push(texture.samplingMode);\r\n types.push(texture.type);\r\n formats.push(texture.format);\r\n\r\n const index = internalTexture2Index[texture.uniqueId];\r\n if (index !== undefined) {\r\n targetTypes.push(-1);\r\n layerCounts.push(0);\r\n } else {\r\n internalTexture2Index[texture.uniqueId] = i;\r\n if (texture.is2DArray) {\r\n targetTypes.push(Constants.TEXTURE_2D_ARRAY);\r\n layerCounts.push(texture.depth);\r\n } else if (texture.isCube) {\r\n targetTypes.push(Constants.TEXTURE_CUBE_MAP);\r\n layerCounts.push(0);\r\n } /*else if (texture.isCubeArray) {\r\n targetTypes.push(Constants.TEXTURE_CUBE_MAP_ARRAY);\r\n layerCounts.push(texture.depth);\r\n }*/ else if (texture.is3D) {\r\n targetTypes.push(Constants.TEXTURE_3D);\r\n layerCounts.push(texture.depth);\r\n } else {\r\n targetTypes.push(Constants.TEXTURE_2D);\r\n layerCounts.push(0);\r\n }\r\n }\r\n\r\n if (this._faceIndices) {\r\n faceIndex.push(this._faceIndices[i] ?? 0);\r\n }\r\n if (this._layerIndices) {\r\n layerIndex.push(this._layerIndices[i] ?? 0);\r\n }\r\n }\r\n\r\n const optionsMRT: IMultiRenderTargetOptions = {\r\n samplingModes,\r\n generateMipMaps: textureArray[0].generateMipMaps,\r\n generateDepthBuffer: this._generateDepthBuffer,\r\n generateStencilBuffer: this._generateStencilBuffer,\r\n generateDepthTexture,\r\n types,\r\n formats,\r\n textureCount,\r\n targetTypes,\r\n faceIndex,\r\n layerIndex,\r\n layerCounts,\r\n };\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n };\r\n\r\n rtw = this._engine.createMultipleRenderTarget(size, optionsMRT);\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n if (targetTypes[i] !== -1) {\r\n continue;\r\n }\r\n const index = internalTexture2Index[textureArray[i].uniqueId];\r\n rtw.setTexture(rtw.textures![index], i);\r\n }\r\n }\r\n } else {\r\n const options: RenderTargetCreationOptions = {};\r\n\r\n options.generateDepthBuffer = this._generateDepthBuffer;\r\n options.generateMipMaps = this.texture?.generateMipMaps ?? false;\r\n options.generateStencilBuffer = this._generateStencilBuffer;\r\n options.samplingMode = this.texture?.samplingMode;\r\n options.type = this.texture?.type;\r\n options.format = this.texture?.format;\r\n\r\n if (this.isCube) {\r\n rtw = this._engine.createRenderTargetCubeTexture(this.width, options);\r\n } else {\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n layers: this.is2DArray ? this.texture?.depth : undefined,\r\n };\r\n\r\n rtw = this._engine.createRenderTargetTexture(size, options);\r\n }\r\n rtw.texture!.isReady = true;\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: RenderTargetWrapper): void {\r\n if (this._textures && target._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i]._swapAndDie(target._textures[i], false);\r\n target._textures[i].isReady = true;\r\n }\r\n }\r\n if (this._depthStencilTexture && target._depthStencilTexture) {\r\n this._depthStencilTexture._swapAndDie(target._depthStencilTexture);\r\n target._depthStencilTexture.isReady = true;\r\n }\r\n\r\n this._textures = null;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n const rtw = this._cloneRenderTargetWrapper();\r\n if (!rtw) {\r\n return;\r\n }\r\n\r\n if (this._depthStencilTexture) {\r\n const samplingMode = this._depthStencilTexture.samplingMode;\r\n const bilinear =\r\n samplingMode === Constants.TEXTURE_BILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST;\r\n rtw.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, bilinear, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples);\r\n }\r\n\r\n if (this.samples > 1) {\r\n rtw.setSamples(this.samples);\r\n }\r\n\r\n rtw._swapRenderTargetWrapper(this);\r\n rtw.dispose();\r\n }\r\n\r\n /**\r\n * Releases the internal render textures\r\n */\r\n public releaseTextures(): void {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures?.length ?? 0; ++i) {\r\n this._textures[i].dispose();\r\n }\r\n }\r\n this._textures = null;\r\n }\r\n\r\n /**\r\n * Disposes the whole render target wrapper\r\n * @param disposeOnlyFramebuffers true if only the frame buffers should be released (used for the WebGL engine). If false, all the textures will also be released\r\n */\r\n public dispose(disposeOnlyFramebuffers = false): void {\r\n if (!disposeOnlyFramebuffers) {\r\n this._depthStencilTexture?.dispose();\r\n this._depthStencilTexture = null;\r\n this.releaseTextures();\r\n }\r\n\r\n this._engine._releaseRenderTargetWrapper(this);\r\n }\r\n}\r\n"]}
@@ -189,7 +189,7 @@ export declare class ThinEngine {
189
189
  * Returns the version of the engine
190
190
  */
191
191
  get version(): number;
192
- private _isDisposed;
192
+ protected _isDisposed: boolean;
193
193
  get isDisposed(): boolean;
194
194
  /**
195
195
  * Gets or sets the epsilon value used by collision engine
@@ -700,15 +700,15 @@ export declare class ThinEngine {
700
700
  setSize(width: number, height: number, forceSetSize?: boolean): boolean;
701
701
  /**
702
702
  * Binds the frame buffer to the specified texture.
703
- * @param texture The render target wrapper to render to
704
- * @param faceIndex The face of the texture to render to in case of cube texture
703
+ * @param rtWrapper The render target wrapper to render to
704
+ * @param faceIndex The face of the texture to render to in case of cube texture and if the render target wrapper is not a multi render target
705
705
  * @param requiredWidth The width of the target to render to
706
706
  * @param requiredHeight The height of the target to render to
707
707
  * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
708
- * @param lodLevel defines the lod level to bind to the frame buffer
709
- * @param layer defines the 2d array index to bind to frame buffer to
708
+ * @param lodLevel Defines the lod level to bind to the frame buffer
709
+ * @param layer Defines the 2d array index to bind to the frame buffer if the render target wrapper is not a multi render target
710
710
  */
711
- bindFramebuffer(texture: RenderTargetWrapper, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
711
+ bindFramebuffer(rtWrapper: RenderTargetWrapper, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
712
712
  /**
713
713
  * Set various states to the webGL context
714
714
  * @param culling defines culling state: true to enable culling, false to disable it
@@ -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.52.0";
37
+ return "babylonjs@5.53.1";
38
38
  }
39
39
  /**
40
40
  * Returns the current version of the framework
41
41
  */
42
42
  static get Version() {
43
- return "5.52.0";
43
+ return "5.53.1";
44
44
  }
45
45
  /**
46
46
  * Returns a string describing the current engine
@@ -521,7 +521,7 @@ export class ThinEngine {
521
521
  };
522
522
  canvas.addEventListener("webglcontextlost", this._onContextLost, false);
523
523
  canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
524
- options.powerPreference = "high-performance";
524
+ options.powerPreference = options.powerPreference || "high-performance";
525
525
  }
526
526
  // Detect if we are running on a faulty buggy desktop OS.
527
527
  this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
@@ -1307,36 +1307,38 @@ export class ThinEngine {
1307
1307
  }
1308
1308
  /**
1309
1309
  * Binds the frame buffer to the specified texture.
1310
- * @param texture The render target wrapper to render to
1311
- * @param faceIndex The face of the texture to render to in case of cube texture
1310
+ * @param rtWrapper The render target wrapper to render to
1311
+ * @param faceIndex The face of the texture to render to in case of cube texture and if the render target wrapper is not a multi render target
1312
1312
  * @param requiredWidth The width of the target to render to
1313
1313
  * @param requiredHeight The height of the target to render to
1314
1314
  * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
1315
- * @param lodLevel defines the lod level to bind to the frame buffer
1316
- * @param layer defines the 2d array index to bind to frame buffer to
1315
+ * @param lodLevel Defines the lod level to bind to the frame buffer
1316
+ * @param layer Defines the 2d array index to bind to the frame buffer if the render target wrapper is not a multi render target
1317
1317
  */
1318
- bindFramebuffer(texture, faceIndex = 0, requiredWidth, requiredHeight, forceFullscreenViewport, lodLevel = 0, layer = 0) {
1318
+ bindFramebuffer(rtWrapper, faceIndex = 0, requiredWidth, requiredHeight, forceFullscreenViewport, lodLevel = 0, layer = 0) {
1319
1319
  var _a, _b, _c, _d, _e;
1320
- const webglRTWrapper = texture;
1320
+ const webglRTWrapper = rtWrapper;
1321
1321
  if (this._currentRenderTarget) {
1322
1322
  this.unBindFramebuffer(this._currentRenderTarget);
1323
1323
  }
1324
- this._currentRenderTarget = texture;
1324
+ this._currentRenderTarget = rtWrapper;
1325
1325
  this._bindUnboundFramebuffer(webglRTWrapper._MSAAFramebuffer ? webglRTWrapper._MSAAFramebuffer : webglRTWrapper._framebuffer);
1326
1326
  const gl = this._gl;
1327
- if (texture.is2DArray) {
1328
- gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, (_a = texture.texture._hardwareTexture) === null || _a === void 0 ? void 0 : _a.underlyingResource, lodLevel, layer);
1329
- }
1330
- else if (texture.isCube) {
1331
- gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, (_b = texture.texture._hardwareTexture) === null || _b === void 0 ? void 0 : _b.underlyingResource, lodLevel);
1327
+ if (!rtWrapper.isMulti) {
1328
+ if (rtWrapper.is2DArray) {
1329
+ gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, (_a = rtWrapper.texture._hardwareTexture) === null || _a === void 0 ? void 0 : _a.underlyingResource, lodLevel, layer);
1330
+ }
1331
+ else if (rtWrapper.isCube) {
1332
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, (_b = rtWrapper.texture._hardwareTexture) === null || _b === void 0 ? void 0 : _b.underlyingResource, lodLevel);
1333
+ }
1332
1334
  }
1333
- const depthStencilTexture = texture._depthStencilTexture;
1335
+ const depthStencilTexture = rtWrapper._depthStencilTexture;
1334
1336
  if (depthStencilTexture) {
1335
- const attachment = texture._depthStencilTextureWithStencil ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;
1336
- if (texture.is2DArray) {
1337
+ const attachment = rtWrapper._depthStencilTextureWithStencil ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;
1338
+ if (rtWrapper.is2DArray) {
1337
1339
  gl.framebufferTextureLayer(gl.FRAMEBUFFER, attachment, (_c = depthStencilTexture._hardwareTexture) === null || _c === void 0 ? void 0 : _c.underlyingResource, lodLevel, layer);
1338
1340
  }
1339
- else if (texture.isCube) {
1341
+ else if (rtWrapper.isCube) {
1340
1342
  gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, (_d = depthStencilTexture._hardwareTexture) === null || _d === void 0 ? void 0 : _d.underlyingResource, lodLevel);
1341
1343
  }
1342
1344
  else {
@@ -1348,13 +1350,13 @@ export class ThinEngine {
1348
1350
  }
1349
1351
  else {
1350
1352
  if (!requiredWidth) {
1351
- requiredWidth = texture.width;
1353
+ requiredWidth = rtWrapper.width;
1352
1354
  if (lodLevel) {
1353
1355
  requiredWidth = requiredWidth / Math.pow(2, lodLevel);
1354
1356
  }
1355
1357
  }
1356
1358
  if (!requiredHeight) {
1357
- requiredHeight = texture.height;
1359
+ requiredHeight = rtWrapper.height;
1358
1360
  if (lodLevel) {
1359
1361
  requiredHeight = requiredHeight / Math.pow(2, lodLevel);
1360
1362
  }
@@ -3040,6 +3042,7 @@ export class ThinEngine {
3040
3042
  let format = 5;
3041
3043
  let useSRGBBuffer = false;
3042
3044
  let samples = 1;
3045
+ let label;
3043
3046
  if (options !== undefined && typeof options === "object") {
3044
3047
  generateMipMaps = !!options.generateMipMaps;
3045
3048
  type = options.type === undefined ? 0 : options.type;
@@ -3047,6 +3050,7 @@ export class ThinEngine {
3047
3050
  format = options.format === undefined ? 5 : options.format;
3048
3051
  useSRGBBuffer = options.useSRGBBuffer === undefined ? false : options.useSRGBBuffer;
3049
3052
  samples = (_a = options.samples) !== null && _a !== void 0 ? _a : 1;
3053
+ label = options.label;
3050
3054
  }
3051
3055
  else {
3052
3056
  generateMipMaps = !!options;
@@ -3104,6 +3108,7 @@ export class ThinEngine {
3104
3108
  texture.samplingMode = samplingMode;
3105
3109
  texture.type = type;
3106
3110
  texture.format = format;
3111
+ texture.label = label;
3107
3112
  this._internalTexturesCache.push(texture);
3108
3113
  return texture;
3109
3114
  }
@@ -3120,6 +3125,9 @@ export class ThinEngine {
3120
3125
  const fromBlob = url.substr(0, 5) === "blob:";
3121
3126
  const isBase64 = fromData && url.indexOf(";base64,") !== -1;
3122
3127
  const texture = fallback ? fallback : new InternalTexture(this, InternalTextureSource.Url);
3128
+ if (texture !== fallback) {
3129
+ texture.label = url.substring(0, 60); // default label, can be overriden by the caller
3130
+ }
3123
3131
  const originalUrl = url;
3124
3132
  if (this._transformTextureUrl && !isBase64 && !fallback && !buffer) {
3125
3133
  url = this._transformTextureUrl(url);