@babylonjs/core 5.2.0 → 5.5.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 (139) hide show
  1. package/Animations/animatable.js +1 -1
  2. package/Animations/animatable.js.map +1 -1
  3. package/Behaviors/Cameras/autoRotationBehavior.d.ts +7 -0
  4. package/Behaviors/Cameras/autoRotationBehavior.js +15 -0
  5. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  6. package/Behaviors/Meshes/pointerDragBehavior.js +1 -0
  7. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  8. package/Bones/skeleton.js +2 -0
  9. package/Bones/skeleton.js.map +1 -1
  10. package/Cameras/camera.d.ts +2 -1
  11. package/Cameras/camera.js +4 -1
  12. package/Cameras/camera.js.map +1 -1
  13. package/DeviceInput/Helpers/eventFactory.js +14 -3
  14. package/DeviceInput/Helpers/eventFactory.js.map +1 -1
  15. package/DeviceInput/InputDevices/deviceTypes.d.ts +1 -1
  16. package/DeviceInput/InputDevices/deviceTypes.js.map +1 -1
  17. package/DeviceInput/InputDevices/nativeDeviceInputSystem.js +2 -8
  18. package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +1 -1
  19. package/Engines/Extensions/engine.renderTarget.js +4 -2
  20. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  21. package/Engines/Processors/shaderProcessor.js +1 -1
  22. package/Engines/Processors/shaderProcessor.js.map +1 -1
  23. package/Engines/WebGPU/Extensions/engine.renderTarget.js +13 -9
  24. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  25. package/Engines/WebGPU/webgpuBundleList.d.ts +1 -1
  26. package/Engines/WebGPU/webgpuBundleList.js.map +1 -1
  27. package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +2 -2
  28. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +28 -17
  29. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  30. package/Engines/WebGPU/webgpuClearQuad.d.ts +1 -1
  31. package/Engines/WebGPU/webgpuClearQuad.js +3 -3
  32. package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
  33. package/Engines/WebGPU/webgpuRenderPassWrapper.d.ts +1 -1
  34. package/Engines/WebGPU/webgpuRenderPassWrapper.js.map +1 -1
  35. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +1 -1
  36. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  37. package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -0
  38. package/Engines/WebGPU/webgpuTextureHelper.js +16 -3
  39. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  40. package/Engines/constants.d.ts +4 -0
  41. package/Engines/constants.js +4 -0
  42. package/Engines/constants.js.map +1 -1
  43. package/Engines/engine.d.ts +2 -2
  44. package/Engines/engine.js +1 -0
  45. package/Engines/engine.js.map +1 -1
  46. package/Engines/thinEngine.js +2 -2
  47. package/Engines/thinEngine.js.map +1 -1
  48. package/Engines/webgpuEngine.js +48 -32
  49. package/Engines/webgpuEngine.js.map +1 -1
  50. package/Gizmos/axisDragGizmo.js +1 -0
  51. package/Gizmos/axisDragGizmo.js.map +1 -1
  52. package/Gizmos/axisScaleGizmo.js +4 -2
  53. package/Gizmos/axisScaleGizmo.js.map +1 -1
  54. package/Gizmos/boundingBoxGizmo.js +5 -5
  55. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  56. package/Gizmos/gizmo.js +3 -2
  57. package/Gizmos/gizmo.js.map +1 -1
  58. package/Gizmos/planeRotationGizmo.js +3 -3
  59. package/Gizmos/planeRotationGizmo.js.map +1 -1
  60. package/Layers/effectLayer.js +1 -1
  61. package/Layers/effectLayer.js.map +1 -1
  62. package/Lights/Shadows/shadowGenerator.d.ts +4 -0
  63. package/Lights/Shadows/shadowGenerator.js +5 -1
  64. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  65. package/Loading/Plugins/babylonFileLoader.js +3 -3
  66. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  67. package/Materials/Background/backgroundMaterial.js +1 -1
  68. package/Materials/Background/backgroundMaterial.js.map +1 -1
  69. package/Materials/Node/Blocks/Dual/TBNBlock.d.ts +47 -0
  70. package/Materials/Node/Blocks/Dual/TBNBlock.js +154 -0
  71. package/Materials/Node/Blocks/Dual/TBNBlock.js.map +1 -0
  72. package/Materials/Node/Blocks/Dual/index.d.ts +1 -0
  73. package/Materials/Node/Blocks/Dual/index.js +1 -0
  74. package/Materials/Node/Blocks/Dual/index.js.map +1 -1
  75. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +5 -1
  76. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +20 -1
  77. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
  78. package/Materials/Node/Blocks/Input/inputBlock.js +1 -1
  79. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  80. package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +4 -0
  81. package/Materials/Node/Blocks/PBR/anisotropyBlock.js +18 -1
  82. package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
  83. package/Materials/Node/Blocks/PBR/clearCoatBlock.d.ts +4 -0
  84. package/Materials/Node/Blocks/PBR/clearCoatBlock.js +18 -1
  85. package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
  86. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +2 -1
  87. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  88. package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +6 -5
  89. package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
  90. package/Materials/PBR/pbrMaterial.d.ts +9 -9
  91. package/Materials/PBR/pbrMaterial.js.map +1 -1
  92. package/Materials/PBR/pbrMetallicRoughnessMaterial.d.ts +3 -2
  93. package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
  94. package/Materials/PBR/pbrSpecularGlossinessMaterial.d.ts +3 -2
  95. package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
  96. package/Materials/Textures/cubeTexture.js +3 -0
  97. package/Materials/Textures/cubeTexture.js.map +1 -1
  98. package/Materials/Textures/renderTargetTexture.d.ts +2 -1
  99. package/Materials/Textures/renderTargetTexture.js +24 -20
  100. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  101. package/Materials/Textures/textureCreationOptions.d.ts +2 -0
  102. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  103. package/Materials/materialHelper.js +1 -1
  104. package/Materials/materialHelper.js.map +1 -1
  105. package/Materials/shaderMaterial.js +1 -0
  106. package/Materials/shaderMaterial.js.map +1 -1
  107. package/Materials/uniformBuffer.d.ts +2 -1
  108. package/Materials/uniformBuffer.js +2 -1
  109. package/Materials/uniformBuffer.js.map +1 -1
  110. package/Maths/math.vector.d.ts +4 -0
  111. package/Maths/math.vector.js +12 -0
  112. package/Maths/math.vector.js.map +1 -1
  113. package/Meshes/instancedMesh.js +0 -1
  114. package/Meshes/instancedMesh.js.map +1 -1
  115. package/Meshes/subMesh.js +1 -1
  116. package/Meshes/subMesh.js.map +1 -1
  117. package/Meshes/thinInstanceMesh.js +34 -5
  118. package/Meshes/thinInstanceMesh.js.map +1 -1
  119. package/Misc/sceneOptimizer.d.ts +3 -2
  120. package/Misc/sceneOptimizer.js +4 -1
  121. package/Misc/sceneOptimizer.js.map +1 -1
  122. package/Misc/screenshotTools.js +6 -6
  123. package/Misc/screenshotTools.js.map +1 -1
  124. package/Physics/Plugins/oimoJSPlugin.js +1 -1
  125. package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
  126. package/PostProcesses/volumetricLightScatteringPostProcess.js +6 -1
  127. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  128. package/Rendering/renderingGroup.js +8 -0
  129. package/Rendering/renderingGroup.js.map +1 -1
  130. package/Shaders/pbr.vertex.js +1 -1
  131. package/Shaders/pbr.vertex.js.map +1 -1
  132. package/Shaders/spriteMap.fragment.js +1 -1
  133. package/Shaders/spriteMap.fragment.js.map +1 -1
  134. package/XR/features/WebXRControllerPointerSelection.js +1 -0
  135. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  136. package/package.json +1 -1
  137. package/scene.d.ts +3 -1
  138. package/scene.js +9 -5
  139. package/scene.js.map +1 -1
@@ -675,8 +675,8 @@ var WebGPUEngine = /** @class */ (function (_super) {
675
675
  depthLoadOp: WebGPUConstants.LoadOp.Clear,
676
676
  depthStoreOp: WebGPUConstants.StoreOp.Store,
677
677
  stencilClearValue: this._clearStencilValue,
678
- stencilLoadOp: WebGPUConstants.LoadOp.Clear,
679
- stencilStoreOp: WebGPUConstants.StoreOp.Store,
678
+ stencilLoadOp: !this.isStencilEnable ? undefined : WebGPUConstants.LoadOp.Clear,
679
+ stencilStoreOp: !this.isStencilEnable ? undefined : WebGPUConstants.StoreOp.Store,
680
680
  };
681
681
  this._mainRenderPassWrapper.renderPassDescriptor = {
682
682
  colorAttachments: mainColorAttachments,
@@ -1952,8 +1952,13 @@ var WebGPUEngine = /** @class */ (function (_super) {
1952
1952
  if (hasAlpha === void 0) { hasAlpha = true; }
1953
1953
  if (flushRenderer === void 0) { flushRenderer = true; }
1954
1954
  var renderPassWrapper = this._rttRenderPassWrapper.renderPass ? this._rttRenderPassWrapper : this._mainRenderPassWrapper;
1955
- var gpuTexture = renderPassWrapper.colorAttachmentGPUTextures[0].underlyingResource;
1956
- var gpuTextureFormat = renderPassWrapper.colorAttachmentGPUTextures[0].format;
1955
+ var hardwareTexture = renderPassWrapper.colorAttachmentGPUTextures[0];
1956
+ if (!hardwareTexture) {
1957
+ // we are calling readPixels for a render pass with no color texture bound
1958
+ return Promise.resolve(new Uint8Array(0));
1959
+ }
1960
+ var gpuTexture = hardwareTexture.underlyingResource;
1961
+ var gpuTextureFormat = hardwareTexture.format;
1957
1962
  if (!gpuTexture) {
1958
1963
  // we are calling readPixels before startMainRenderPass has been called and no RTT is bound, so swapChainTexture is not setup yet!
1959
1964
  return Promise.resolve(new Uint8Array(0));
@@ -2089,6 +2094,7 @@ var WebGPUEngine = /** @class */ (function (_super) {
2089
2094
  var gpuDepthStencilMSAATexture = gpuDepthStencilWrapper === null || gpuDepthStencilWrapper === void 0 ? void 0 : gpuDepthStencilWrapper.msaaTexture;
2090
2095
  var depthTextureView = gpuDepthStencilTexture === null || gpuDepthStencilTexture === void 0 ? void 0 : gpuDepthStencilTexture.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2091
2096
  var depthMSAATextureView = gpuDepthStencilMSAATexture === null || gpuDepthStencilMSAATexture === void 0 ? void 0 : gpuDepthStencilMSAATexture.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2097
+ var depthTextureHasStencil = gpuDepthStencilWrapper ? WebGPUTextureHelper.HasStencilAspect(gpuDepthStencilWrapper.format) : false;
2092
2098
  var colorAttachments = [];
2093
2099
  if (this.useReverseDepthBuffer) {
2094
2100
  this.setDepthFunctionToGreaterOrEqual();
@@ -2126,18 +2132,23 @@ var WebGPUEngine = /** @class */ (function (_super) {
2126
2132
  else {
2127
2133
  // single render target
2128
2134
  var internalTexture = rtWrapper.texture;
2129
- var gpuWrapper = internalTexture._hardwareTexture;
2130
- var gpuTexture = gpuWrapper.underlyingResource;
2131
- var gpuMSAATexture = gpuWrapper.msaaTexture;
2132
- var colorTextureView = gpuTexture.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);
2133
- var colorMSAATextureView = gpuMSAATexture === null || gpuMSAATexture === void 0 ? void 0 : gpuMSAATexture.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);
2134
- colorAttachments.push({
2135
- view: colorMSAATextureView ? colorMSAATextureView : colorTextureView,
2136
- resolveTarget: gpuMSAATexture ? colorTextureView : undefined,
2137
- clearValue: mustClearColor ? clearColor : undefined,
2138
- loadOp: mustClearColor ? WebGPUConstants.LoadOp.Clear : WebGPUConstants.LoadOp.Load,
2139
- storeOp: WebGPUConstants.StoreOp.Store,
2140
- });
2135
+ if (internalTexture) {
2136
+ var gpuWrapper = internalTexture._hardwareTexture;
2137
+ var gpuTexture = gpuWrapper.underlyingResource;
2138
+ var gpuMSAATexture = gpuWrapper.msaaTexture;
2139
+ var colorTextureView = gpuTexture.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);
2140
+ var colorMSAATextureView = gpuMSAATexture === null || gpuMSAATexture === void 0 ? void 0 : gpuMSAATexture.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);
2141
+ colorAttachments.push({
2142
+ view: colorMSAATextureView ? colorMSAATextureView : colorTextureView,
2143
+ resolveTarget: gpuMSAATexture ? colorTextureView : undefined,
2144
+ clearValue: mustClearColor ? clearColor : undefined,
2145
+ loadOp: mustClearColor ? WebGPUConstants.LoadOp.Clear : WebGPUConstants.LoadOp.Load,
2146
+ storeOp: WebGPUConstants.StoreOp.Store,
2147
+ });
2148
+ }
2149
+ else {
2150
+ colorAttachments.push(null);
2151
+ }
2141
2152
  }
2142
2153
  (_a = this._debugPushGroup) === null || _a === void 0 ? void 0 : _a.call(this, "render target pass", 1);
2143
2154
  this._rttRenderPassWrapper.renderPassDescriptor = {
@@ -2149,8 +2160,12 @@ var WebGPUEngine = /** @class */ (function (_super) {
2149
2160
  depthLoadOp: mustClearDepth ? WebGPUConstants.LoadOp.Clear : WebGPUConstants.LoadOp.Load,
2150
2161
  depthStoreOp: WebGPUConstants.StoreOp.Store,
2151
2162
  stencilClearValue: rtWrapper._depthStencilTextureWithStencil && mustClearStencil ? this._clearStencilValue : undefined,
2152
- stencilLoadOp: rtWrapper._depthStencilTextureWithStencil && mustClearStencil ? WebGPUConstants.LoadOp.Clear : WebGPUConstants.LoadOp.Load,
2153
- stencilStoreOp: WebGPUConstants.StoreOp.Store,
2163
+ stencilLoadOp: !depthTextureHasStencil
2164
+ ? undefined
2165
+ : rtWrapper._depthStencilTextureWithStencil && mustClearStencil
2166
+ ? WebGPUConstants.LoadOp.Clear
2167
+ : WebGPUConstants.LoadOp.Load,
2168
+ stencilStoreOp: !depthTextureHasStencil ? undefined : WebGPUConstants.StoreOp.Store,
2154
2169
  }
2155
2170
  : undefined,
2156
2171
  occlusionQuerySet: ((_b = this._occlusionQuery) === null || _b === void 0 ? void 0 : _b.hasQueries) ? this._occlusionQuery.querySet : undefined,
@@ -2177,10 +2192,10 @@ var WebGPUEngine = /** @class */ (function (_super) {
2177
2192
  };
2178
2193
  /** @hidden */
2179
2194
  WebGPUEngine.prototype._endRenderTargetRenderPass = function () {
2180
- var _a, _b, _c;
2195
+ var _a, _b, _c, _d;
2181
2196
  if (this._currentRenderPass) {
2182
- var gpuWrapper = this._currentRenderTarget.texture._hardwareTexture;
2183
- if (!this._snapshotRendering.endRenderTargetPass(this._currentRenderPass, gpuWrapper) && !this.compatibilityMode) {
2197
+ var gpuWrapper = (_a = this._currentRenderTarget.texture) === null || _a === void 0 ? void 0 : _a._hardwareTexture;
2198
+ if (gpuWrapper && !this._snapshotRendering.endRenderTargetPass(this._currentRenderPass, gpuWrapper) && !this.compatibilityMode) {
2184
2199
  this._bundleListRenderTarget.run(this._currentRenderPass);
2185
2200
  this._bundleListRenderTarget.reset();
2186
2201
  }
@@ -2190,10 +2205,10 @@ var WebGPUEngine = /** @class */ (function (_super) {
2190
2205
  this._count = 0;
2191
2206
  }
2192
2207
  if (!this._count || this._count < this.dbgVerboseLogsNumFrames) {
2193
- console.log("frame #" + this._count + " - render target end pass - internalTexture.uniqueId=", (_b = (_a = this._currentRenderTarget) === null || _a === void 0 ? void 0 : _a.texture) === null || _b === void 0 ? void 0 : _b.uniqueId);
2208
+ console.log("frame #" + this._count + " - render target end pass - internalTexture.uniqueId=", (_c = (_b = this._currentRenderTarget) === null || _b === void 0 ? void 0 : _b.texture) === null || _c === void 0 ? void 0 : _c.uniqueId);
2194
2209
  }
2195
2210
  }
2196
- (_c = this._debugPopGroup) === null || _c === void 0 ? void 0 : _c.call(this, 1);
2211
+ (_d = this._debugPopGroup) === null || _d === void 0 ? void 0 : _d.call(this, 1);
2197
2212
  this._resetCurrentViewport(1);
2198
2213
  this._resetCurrentScissor(1);
2199
2214
  this._resetCurrentStencilRef(1);
@@ -2236,7 +2251,11 @@ var WebGPUEngine = /** @class */ (function (_super) {
2236
2251
  : undefined;
2237
2252
  this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadOp = mustClearDepth ? WebGPUConstants.LoadOp.Clear : WebGPUConstants.LoadOp.Load;
2238
2253
  this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilClearValue = mustClearStencil ? this._clearStencilValue : undefined;
2239
- this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp = mustClearStencil ? WebGPUConstants.LoadOp.Clear : WebGPUConstants.LoadOp.Load;
2254
+ this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp = !this.isStencilEnable
2255
+ ? undefined
2256
+ : mustClearStencil
2257
+ ? WebGPUConstants.LoadOp.Clear
2258
+ : WebGPUConstants.LoadOp.Load;
2240
2259
  this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet = ((_a = this._occlusionQuery) === null || _a === void 0 ? void 0 : _a.hasQueries) ? this._occlusionQuery.querySet : undefined;
2241
2260
  this._swapChainTexture = this._context.getCurrentTexture();
2242
2261
  this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].set(this._swapChainTexture);
@@ -2311,17 +2330,13 @@ var WebGPUEngine = /** @class */ (function (_super) {
2311
2330
  if (lodLevel === void 0) { lodLevel = 0; }
2312
2331
  if (layer === void 0) { layer = 0; }
2313
2332
  var hardwareTexture = (_a = texture.texture) === null || _a === void 0 ? void 0 : _a._hardwareTexture;
2314
- if (!hardwareTexture) {
2315
- if (this.dbgSanityChecks) {
2316
- console.error("bindFramebuffer: Trying to bind a texture that does not have a hardware texture!", texture, hardwareTexture);
2317
- }
2318
- return;
2319
- }
2320
2333
  if (this._currentRenderTarget) {
2321
2334
  this.unBindFramebuffer(this._currentRenderTarget);
2322
2335
  }
2323
2336
  this._currentRenderTarget = texture;
2324
- hardwareTexture._currentLayer = texture.isCube ? layer * 6 + faceIndex : layer;
2337
+ if (hardwareTexture) {
2338
+ hardwareTexture._currentLayer = texture.isCube ? layer * 6 + faceIndex : layer;
2339
+ }
2325
2340
  this._rttRenderPassWrapper.colorAttachmentGPUTextures[0] = hardwareTexture;
2326
2341
  this._rttRenderPassWrapper.depthTextureFormat = this._currentRenderTarget._depthStencilTexture
2327
2342
  ? WebGPUTextureHelper.GetWebGPUTextureFormat(-1, this._currentRenderTarget._depthStencilTexture.format)
@@ -2444,7 +2459,8 @@ var WebGPUEngine = /** @class */ (function (_super) {
2444
2459
  * @hidden
2445
2460
  */
2446
2461
  WebGPUEngine.prototype._setColorFormat = function (wrapper) {
2447
- var format = wrapper.colorAttachmentGPUTextures[0].format;
2462
+ var _a, _b;
2463
+ var format = (_b = (_a = wrapper.colorAttachmentGPUTextures[0]) === null || _a === void 0 ? void 0 : _a.format) !== null && _b !== void 0 ? _b : null;
2448
2464
  this._cacheRenderPipeline.setColorFormat(format);
2449
2465
  if (this._colorFormat === format) {
2450
2466
  return;