@babylonjs/core 5.56.0 → 5.57.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 (71) hide show
  1. package/Compute/computeShader.d.ts +3 -3
  2. package/Compute/computeShader.js +22 -12
  3. package/Compute/computeShader.js.map +1 -1
  4. package/Culling/boundingInfo.d.ts +1 -1
  5. package/Culling/boundingInfo.js +9 -3
  6. package/Culling/boundingInfo.js.map +1 -1
  7. package/Engines/thinEngine.js +2 -2
  8. package/Engines/thinEngine.js.map +1 -1
  9. package/Layers/effectLayer.js +2 -2
  10. package/Layers/effectLayer.js.map +1 -1
  11. package/Lights/Shadows/shadowGenerator.d.ts +2 -0
  12. package/Lights/Shadows/shadowGenerator.js +13 -24
  13. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  14. package/Materials/clipPlaneMaterialHelper.d.ts +3 -1
  15. package/Materials/clipPlaneMaterialHelper.js +53 -32
  16. package/Materials/clipPlaneMaterialHelper.js.map +1 -1
  17. package/Materials/shaderMaterial.js +2 -2
  18. package/Materials/shaderMaterial.js.map +1 -1
  19. package/Maths/math.vector.js +4 -2
  20. package/Maths/math.vector.js.map +1 -1
  21. package/Meshes/abstractMesh.d.ts +13 -0
  22. package/Meshes/abstractMesh.js +20 -0
  23. package/Meshes/abstractMesh.js.map +1 -1
  24. package/Meshes/instancedMesh.d.ts +9 -0
  25. package/Meshes/instancedMesh.js +30 -0
  26. package/Meshes/instancedMesh.js.map +1 -1
  27. package/Meshes/thinInstanceMesh.js +4 -1
  28. package/Meshes/thinInstanceMesh.js.map +1 -1
  29. package/Particles/gpuParticleSystem.js +2 -2
  30. package/Particles/gpuParticleSystem.js.map +1 -1
  31. package/Particles/particleSystem.js +2 -2
  32. package/Particles/particleSystem.js.map +1 -1
  33. package/Particles/solidParticleSystem.d.ts +1 -1
  34. package/Particles/solidParticleSystem.js +1 -1
  35. package/Particles/solidParticleSystem.js.map +1 -1
  36. package/Physics/physicsEngineComponent.d.ts +1 -0
  37. package/Physics/physicsEngineComponent.js +1 -0
  38. package/Physics/physicsEngineComponent.js.map +1 -1
  39. package/Physics/physicsHelper.d.ts +12 -5
  40. package/Physics/physicsHelper.js +160 -90
  41. package/Physics/physicsHelper.js.map +1 -1
  42. package/Physics/physicsRaycastResult.d.ts +3 -0
  43. package/Physics/physicsRaycastResult.js.map +1 -1
  44. package/Physics/v2/IPhysicsEnginePlugin.d.ts +119 -76
  45. package/Physics/v2/IPhysicsEnginePlugin.js +119 -48
  46. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  47. package/Physics/v2/physicsAggregate.d.ts +6 -2
  48. package/Physics/v2/physicsAggregate.js +65 -30
  49. package/Physics/v2/physicsAggregate.js.map +1 -1
  50. package/Physics/v2/physicsBody.d.ts +48 -62
  51. package/Physics/v2/physicsBody.js +100 -128
  52. package/Physics/v2/physicsBody.js.map +1 -1
  53. package/Physics/v2/physicsConstraint.d.ts +34 -25
  54. package/Physics/v2/physicsConstraint.js +32 -15
  55. package/Physics/v2/physicsConstraint.js.map +1 -1
  56. package/Physics/v2/physicsEngine.d.ts +0 -1
  57. package/Physics/v2/physicsEngine.js +0 -1
  58. package/Physics/v2/physicsEngine.js.map +1 -1
  59. package/Physics/v2/physicsEngineComponent.d.ts +0 -10
  60. package/Physics/v2/physicsEngineComponent.js +0 -29
  61. package/Physics/v2/physicsEngineComponent.js.map +1 -1
  62. package/Physics/v2/physicsShape.d.ts +37 -8
  63. package/Physics/v2/physicsShape.js +52 -18
  64. package/Physics/v2/physicsShape.js.map +1 -1
  65. package/Rendering/depthRenderer.js +2 -2
  66. package/Rendering/depthRenderer.js.map +1 -1
  67. package/Rendering/geometryBufferRenderer.js +2 -2
  68. package/Rendering/geometryBufferRenderer.js.map +1 -1
  69. package/Rendering/outlineRenderer.js +2 -2
  70. package/Rendering/outlineRenderer.js.map +1 -1
  71. package/package.json +1 -1
@@ -72,9 +72,9 @@ export declare class ComputeShader {
72
72
  * @param name Defines the name of the compute shader in the scene
73
73
  * @param engine Defines the engine the compute shader belongs to
74
74
  * @param shaderPath Defines the route to the shader code in one of three ways:
75
- * * object: { compute: "custom" }, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
76
- * * object: { computeElement: "HTMLElementId" }, used with shader code in script tags
77
- * * object: { computeSource: "compute shader code string" using with string containing the shader code
75
+ * * object: \{ compute: "custom" \}, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
76
+ * * object: \{ computeElement: "HTMLElementId" \}, used with shader code in script tags
77
+ * * object: \{ computeSource: "compute shader code string" \}, where the string contains the shader code
78
78
  * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + "ComputeShader"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.
79
79
  * @param options Define the options used to create the shader
80
80
  */
@@ -27,9 +27,9 @@ export class ComputeShader {
27
27
  * @param name Defines the name of the compute shader in the scene
28
28
  * @param engine Defines the engine the compute shader belongs to
29
29
  * @param shaderPath Defines the route to the shader code in one of three ways:
30
- * * object: { compute: "custom" }, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
31
- * * object: { computeElement: "HTMLElementId" }, used with shader code in script tags
32
- * * object: { computeSource: "compute shader code string" using with string containing the shader code
30
+ * * object: \{ compute: "custom" \}, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
31
+ * * object: \{ computeElement: "HTMLElementId" \}, used with shader code in script tags
32
+ * * object: \{ computeSource: "compute shader code string" \}, where the string contains the shader code
33
33
  * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + "ComputeShader"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.
34
34
  * @param options Define the options used to create the shader
35
35
  */
@@ -199,20 +199,30 @@ export class ComputeShader {
199
199
  return false;
200
200
  }
201
201
  // If the sampling parameters of a texture bound to the shader have changed, we must clear the compute context so that it is recreated with the updated values
202
+ // Also, if the actual (gpu) buffer used by a uniform buffer has changed, we must clear the compute context so that it is recreated with the updated value
202
203
  for (const key in this._bindings) {
203
204
  const binding = this._bindings[key];
204
- // TODO: remove this when browsers support reflection for wgsl shaders
205
205
  if (!this._options.bindingsMapping[key]) {
206
206
  throw new Error("ComputeShader ('" + this.name + "'): No binding mapping has been provided for the property '" + key + "'");
207
207
  }
208
- if (binding.type !== ComputeBindingType.Texture) {
209
- continue;
210
- }
211
- const sampler = this._samplers[key];
212
- const texture = binding.object;
213
- if (!sampler || !texture._texture || !sampler.compareSampler(texture._texture)) {
214
- this._samplers[key] = new TextureSampler().setParameters(texture.wrapU, texture.wrapV, texture.wrapR, texture.anisotropicFilteringLevel, texture._texture.samplingMode, (_a = texture._texture) === null || _a === void 0 ? void 0 : _a._comparisonFunction);
215
- this._contextIsDirty = true;
208
+ switch (binding.type) {
209
+ case ComputeBindingType.Texture: {
210
+ const sampler = this._samplers[key];
211
+ const texture = binding.object;
212
+ if (!sampler || !texture._texture || !sampler.compareSampler(texture._texture)) {
213
+ this._samplers[key] = new TextureSampler().setParameters(texture.wrapU, texture.wrapV, texture.wrapR, texture.anisotropicFilteringLevel, texture._texture.samplingMode, (_a = texture._texture) === null || _a === void 0 ? void 0 : _a._comparisonFunction);
214
+ this._contextIsDirty = true;
215
+ }
216
+ break;
217
+ }
218
+ case ComputeBindingType.UniformBuffer: {
219
+ const ubo = binding.object;
220
+ if (ubo.getBuffer() !== binding.buffer) {
221
+ binding.buffer = ubo.getBuffer();
222
+ this._contextIsDirty = true;
223
+ }
224
+ break;
225
+ }
216
226
  }
217
227
  }
218
228
  if (this._contextIsDirty) {
@@ -1 +1 @@
1
- {"version":3,"file":"computeShader.js","sourceRoot":"","sources":["../../../../lts/core/generated/Compute/computeShader.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAEhF,OAAO,EA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AAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAE7E,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,CAAC,OAAO,EAAE;gBAC7C,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;aACpC;iBAAM,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,CAAC,qBAAqB,EAAE;gBAClE,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;aAC3C;iBAAM;gBACH,OAAO,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;aAC3C;SACJ;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA7VG;IADC,SAAS,EAAE;2CACQ;AA+VxB,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import type { UniformBuffer } from \"../Materials/uniformBuffer\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Nullable } from \"../types\";\r\nimport { SerializationHelper, serialize } from \"../Misc/decorators\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport type { ComputeEffect, IComputeEffectCreationOptions } from \"./computeEffect\";\r\nimport type { ComputeBindingList, ComputeBindingMapping } from \"../Engines/Extensions/engine.computeShader\";\r\nimport { ComputeBindingType } from \"../Engines/Extensions/engine.computeShader\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { UniqueIdGenerator } from \"../Misc/uniqueIdGenerator\";\r\nimport type { IComputeContext } from \"./IComputeContext\";\r\nimport type { StorageBuffer } from \"../Buffers/storageBuffer\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { TextureSampler } from \"../Materials/Textures/textureSampler\";\r\n\r\n/**\r\n * Defines the options associated with the creation of a compute shader.\r\n */\r\nexport interface IComputeShaderOptions {\r\n /**\r\n * list of bindings mapping (key is property name, value is binding location)\r\n * Must be provided because browsers don't support reflection for wgsl shaders yet (so there's no way to query the binding/group from a variable name)\r\n * TODO: remove this when browsers support reflection for wgsl shaders\r\n */\r\n bindingsMapping: ComputeBindingMapping;\r\n\r\n /**\r\n * The list of defines used in the shader\r\n */\r\n defines?: string[];\r\n\r\n /**\r\n * The name of the entry point in the shader source (default: \"main\")\r\n */\r\n entryPoint?: string;\r\n\r\n /**\r\n * If provided, will be called with the shader code so that this code can be updated before it is compiled by the GPU\r\n */\r\n processFinalCode?: Nullable<(code: string) => string>;\r\n}\r\n\r\n/**\r\n * The ComputeShader object lets you execute a compute shader on your GPU (if supported by the engine)\r\n */\r\nexport class ComputeShader {\r\n private _engine: ThinEngine;\r\n private _shaderPath: any;\r\n private _options: IComputeShaderOptions;\r\n private _effect: ComputeEffect;\r\n private _cachedDefines: string;\r\n private _bindings: ComputeBindingList = {};\r\n private _samplers: { [key: string]: TextureSampler } = {};\r\n private _context: IComputeContext;\r\n private _contextIsDirty = false;\r\n\r\n /**\r\n * Gets the unique id of the compute shader\r\n */\r\n public readonly uniqueId: number;\r\n\r\n /**\r\n * The name of the shader\r\n */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * The options used to create the shader\r\n */\r\n public get options() {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * The shaderPath used to create the shader\r\n */\r\n public get shaderPath() {\r\n return this._shaderPath;\r\n }\r\n\r\n /**\r\n * Callback triggered when the shader is compiled\r\n */\r\n public onCompiled: Nullable<(effect: ComputeEffect) => void> = null;\r\n\r\n /**\r\n * Callback triggered when an error occurs\r\n */\r\n public onError: Nullable<(effect: ComputeEffect, errors: string) => void> = null;\r\n\r\n /**\r\n * Instantiates a new compute shader.\r\n * @param name Defines the name of the compute shader in the scene\r\n * @param engine Defines the engine the compute shader belongs to\r\n * @param shaderPath Defines the route to the shader code in one of three ways:\r\n * * object: { compute: \"custom\" }, used with ShaderStore.ShadersStoreWGSL[\"customComputeShader\"]\r\n * * object: { computeElement: \"HTMLElementId\" }, used with shader code in script tags\r\n * * object: { computeSource: \"compute shader code string\" using with string containing the shader code\r\n * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + \"ComputeShader\"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.\r\n * @param options Define the options used to create the shader\r\n */\r\n constructor(name: string, engine: ThinEngine, shaderPath: any, options: Partial<IComputeShaderOptions> = {}) {\r\n this.name = name;\r\n this._engine = engine;\r\n this.uniqueId = UniqueIdGenerator.UniqueId;\r\n\r\n if (!this._engine.getCaps().supportComputeShaders) {\r\n Logger.Error(\"This engine does not support compute shaders!\");\r\n return;\r\n }\r\n if (!options.bindingsMapping) {\r\n Logger.Error(\"You must provide the binding mappings as browsers don't support reflection for wgsl shaders yet!\");\r\n return;\r\n }\r\n\r\n this._context = engine.createComputeContext()!;\r\n this._shaderPath = shaderPath;\r\n this._options = {\r\n bindingsMapping: {},\r\n defines: [],\r\n ...options,\r\n };\r\n }\r\n\r\n /**\r\n * Gets the current class name of the material e.g. \"ComputeShader\"\r\n * Mainly use in serialization.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"ComputeShader\";\r\n }\r\n\r\n /**\r\n * Binds a texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n * @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture\r\n */\r\n public setTexture(name: string, texture: BaseTexture, bindSampler = true): void {\r\n const current = this._bindings[name];\r\n\r\n this._bindings[name] = {\r\n type: bindSampler ? ComputeBindingType.Texture : ComputeBindingType.TextureWithoutSampler,\r\n object: texture,\r\n indexInGroupEntries: current?.indexInGroupEntries,\r\n };\r\n\r\n this._contextIsDirty ||= !current || current.object !== texture || current.type !== this._bindings[name].type;\r\n }\r\n\r\n /**\r\n * Binds a storage texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setStorageTexture(name: string, texture: BaseTexture): void {\r\n const current = this._bindings[name];\r\n\r\n this._contextIsDirty ||= !current || current.object !== texture;\r\n\r\n this._bindings[name] = {\r\n type: ComputeBindingType.StorageTexture,\r\n object: texture,\r\n indexInGroupEntries: current?.indexInGroupEntries,\r\n };\r\n }\r\n\r\n /**\r\n * Binds a uniform buffer to the shader\r\n * @param name Binding name of the buffer\r\n * @param buffer Buffer to bind\r\n */\r\n public setUniformBuffer(name: string, buffer: UniformBuffer): void {\r\n const current = this._bindings[name];\r\n\r\n this._contextIsDirty ||= !current || current.object !== buffer;\r\n\r\n this._bindings[name] = {\r\n type: ComputeBindingType.UniformBuffer,\r\n object: buffer,\r\n indexInGroupEntries: current?.indexInGroupEntries,\r\n };\r\n }\r\n\r\n /**\r\n * Binds a storage buffer to the shader\r\n * @param name Binding name of the buffer\r\n * @param buffer Buffer to bind\r\n */\r\n public setStorageBuffer(name: string, buffer: StorageBuffer): void {\r\n const current = this._bindings[name];\r\n\r\n this._contextIsDirty ||= !current || current.object !== buffer;\r\n\r\n this._bindings[name] = {\r\n type: ComputeBindingType.StorageBuffer,\r\n object: buffer,\r\n indexInGroupEntries: current?.indexInGroupEntries,\r\n };\r\n }\r\n\r\n /**\r\n * Binds a texture sampler to the shader\r\n * @param name Binding name of the sampler\r\n * @param sampler Sampler to bind\r\n */\r\n public setTextureSampler(name: string, sampler: TextureSampler): void {\r\n const current = this._bindings[name];\r\n\r\n this._contextIsDirty ||= !current || !sampler.compareSampler(current.object);\r\n\r\n this._bindings[name] = {\r\n type: ComputeBindingType.Sampler,\r\n object: sampler,\r\n indexInGroupEntries: current?.indexInGroupEntries,\r\n };\r\n }\r\n\r\n /**\r\n * Specifies that the compute shader is ready to be executed (the compute effect and all the resources are ready)\r\n * @returns true if the compute shader is ready to be executed\r\n */\r\n public isReady(): boolean {\r\n let effect = this._effect;\r\n\r\n for (const key in this._bindings) {\r\n const binding = this._bindings[key],\r\n type = binding.type,\r\n object = binding.object;\r\n\r\n switch (type) {\r\n case ComputeBindingType.Texture:\r\n case ComputeBindingType.TextureWithoutSampler:\r\n case ComputeBindingType.StorageTexture: {\r\n const texture = object as BaseTexture;\r\n if (!texture.isReady()) {\r\n return false;\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n const defines = [];\r\n\r\n const shaderName = this._shaderPath;\r\n\r\n if (this._options.defines) {\r\n for (let index = 0; index < this._options.defines.length; index++) {\r\n defines.push(this._options.defines[index]);\r\n }\r\n }\r\n\r\n const join = defines.join(\"\\n\");\r\n\r\n if (this._cachedDefines !== join) {\r\n this._cachedDefines = join;\r\n\r\n effect = this._engine.createComputeEffect(shaderName, <IComputeEffectCreationOptions>{\r\n defines: join,\r\n entryPoint: this._options.entryPoint,\r\n onCompiled: this.onCompiled,\r\n onError: this.onError,\r\n });\r\n\r\n this._effect = effect;\r\n }\r\n\r\n if (!effect.isReady()) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Dispatches (executes) the compute shader\r\n * @param x Number of workgroups to execute on the X dimension\r\n * @param y Number of workgroups to execute on the Y dimension (default: 1)\r\n * @param z Number of workgroups to execute on the Z dimension (default: 1)\r\n * @returns True if the dispatch could be done, else false (meaning either the compute effect or at least one of the bound resources was not ready)\r\n */\r\n public dispatch(x: number, y?: number, z?: number): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n // If the sampling parameters of a texture bound to the shader have changed, we must clear the compute context so that it is recreated with the updated values\r\n for (const key in this._bindings) {\r\n const binding = this._bindings[key];\r\n\r\n // TODO: remove this when browsers support reflection for wgsl shaders\r\n if (!this._options.bindingsMapping[key]) {\r\n throw new Error(\"ComputeShader ('\" + this.name + \"'): No binding mapping has been provided for the property '\" + key + \"'\");\r\n }\r\n\r\n if (binding.type !== ComputeBindingType.Texture) {\r\n continue;\r\n }\r\n\r\n const sampler = this._samplers[key];\r\n const texture = binding.object as BaseTexture;\r\n\r\n if (!sampler || !texture._texture || !sampler.compareSampler(texture._texture)) {\r\n this._samplers[key] = new TextureSampler().setParameters(\r\n texture.wrapU,\r\n texture.wrapV,\r\n texture.wrapR,\r\n texture.anisotropicFilteringLevel,\r\n texture._texture!.samplingMode,\r\n texture._texture?._comparisonFunction\r\n );\r\n this._contextIsDirty = true;\r\n }\r\n }\r\n\r\n if (this._contextIsDirty) {\r\n this._contextIsDirty = false;\r\n this._context.clear();\r\n }\r\n\r\n this._engine.computeDispatch(this._effect, this._context, this._bindings, x, y, z, this._options.bindingsMapping);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Waits for the compute shader to be ready and executes it\r\n * @param x Number of workgroups to execute on the X dimension\r\n * @param y Number of workgroups to execute on the Y dimension (default: 1)\r\n * @param z Number of workgroups to execute on the Z dimension (default: 1)\r\n * @param delay Delay between the retries while the shader is not ready (in milliseconds - 10 by default)\r\n * @returns A promise that is resolved once the shader has been sent to the GPU. Note that it does not mean that the shader execution itself is finished!\r\n */\r\n public dispatchWhenReady(x: number, y?: number, z?: number, delay = 10): Promise<void> {\r\n return new Promise((resolve) => {\r\n const check = () => {\r\n if (!this.dispatch(x, y, z)) {\r\n setTimeout(check, delay);\r\n } else {\r\n resolve();\r\n }\r\n };\r\n\r\n check();\r\n });\r\n }\r\n\r\n /**\r\n * Serializes this compute shader in a JSON representation\r\n * @returns the serialized compute shader object\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n\r\n serializationObject.options = this._options;\r\n serializationObject.shaderPath = this._shaderPath;\r\n serializationObject.bindings = {};\r\n serializationObject.textures = {};\r\n\r\n for (const key in this._bindings) {\r\n const binding = this._bindings[key];\r\n const object = binding.object;\r\n\r\n switch (binding.type) {\r\n case ComputeBindingType.Texture:\r\n case ComputeBindingType.TextureWithoutSampler:\r\n case ComputeBindingType.StorageTexture: {\r\n const serializedData = (object as BaseTexture).serialize();\r\n if (serializedData) {\r\n serializationObject.textures[key] = serializedData;\r\n serializationObject.bindings[key] = {\r\n type: binding.type,\r\n };\r\n }\r\n break;\r\n }\r\n\r\n case ComputeBindingType.UniformBuffer: {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a compute shader from parsed compute shader data\r\n * @param source defines the JSON representation of the compute shader\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a new compute shader\r\n */\r\n public static Parse(source: any, scene: Scene, rootUrl: string): ComputeShader {\r\n const compute = SerializationHelper.Parse(() => new ComputeShader(source.name, scene.getEngine(), source.shaderPath, source.options), source, scene, rootUrl);\r\n\r\n for (const key in source.textures) {\r\n const binding = source.bindings[key];\r\n const texture = <Texture>Texture.Parse(source.textures[key], scene, rootUrl);\r\n\r\n if (binding.type === ComputeBindingType.Texture) {\r\n compute.setTexture(key, texture);\r\n } else if (binding.type === ComputeBindingType.TextureWithoutSampler) {\r\n compute.setTexture(key, texture, false);\r\n } else {\r\n compute.setStorageTexture(key, texture);\r\n }\r\n }\r\n\r\n return compute;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ComputeShader\", ComputeShader);\r\n"]}
1
+ {"version":3,"file":"computeShader.js","sourceRoot":"","sources":["../../../../lts/core/generated/Compute/computeShader.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAEhF,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAgCtE;;GAEG;AACH,MAAM,OAAO,aAAa;IAsBtB;;OAEG;IACH,IAAW,OAAO;Q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AG,CAAC,CAAC;YACrC,MAAM,OAAO,GAAY,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAE7E,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,CAAC,OAAO,EAAE;gBAC7C,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;aACpC;iBAAM,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,CAAC,qBAAqB,EAAE;gBAClE,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;aAC3C;iBAAM;gBACH,OAAO,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;aAC3C;SACJ;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAtWG;IADC,SAAS,EAAE;2CACQ;AAwWxB,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import type { UniformBuffer } from \"../Materials/uniformBuffer\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Nullable } from \"../types\";\r\nimport { SerializationHelper, serialize } from \"../Misc/decorators\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport type { ComputeEffect, IComputeEffectCreationOptions } from \"./computeEffect\";\r\nimport type { ComputeBindingMapping } from \"../Engines/Extensions/engine.computeShader\";\r\nimport { ComputeBindingType } from \"../Engines/Extensions/engine.computeShader\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { UniqueIdGenerator } from \"../Misc/uniqueIdGenerator\";\r\nimport type { IComputeContext } from \"./IComputeContext\";\r\nimport type { StorageBuffer } from \"../Buffers/storageBuffer\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { TextureSampler } from \"../Materials/Textures/textureSampler\";\r\nimport type { DataBuffer } from \"core/Buffers/dataBuffer\";\r\n\r\n/**\r\n * Defines the options associated with the creation of a compute shader.\r\n */\r\nexport interface IComputeShaderOptions {\r\n /**\r\n * list of bindings mapping (key is property name, value is binding location)\r\n * Must be provided because browsers don't support reflection for wgsl shaders yet (so there's no way to query the binding/group from a variable name)\r\n * TODO: remove this when browsers support reflection for wgsl shaders\r\n */\r\n bindingsMapping: ComputeBindingMapping;\r\n\r\n /**\r\n * The list of defines used in the shader\r\n */\r\n defines?: string[];\r\n\r\n /**\r\n * The name of the entry point in the shader source (default: \"main\")\r\n */\r\n entryPoint?: string;\r\n\r\n /**\r\n * If provided, will be called with the shader code so that this code can be updated before it is compiled by the GPU\r\n */\r\n processFinalCode?: Nullable<(code: string) => string>;\r\n}\r\n\r\ntype ComputeBindingListInternal = { [key: string]: { type: ComputeBindingType; object: any; indexInGroupEntries?: number; buffer?: Nullable<DataBuffer> } };\r\n\r\n/**\r\n * The ComputeShader object lets you execute a compute shader on your GPU (if supported by the engine)\r\n */\r\nexport class ComputeShader {\r\n private _engine: ThinEngine;\r\n private _shaderPath: any;\r\n private _options: IComputeShaderOptions;\r\n private _effect: ComputeEffect;\r\n private _cachedDefines: string;\r\n private _bindings: ComputeBindingListInternal = {};\r\n private _samplers: { [key: string]: TextureSampler } = {};\r\n private _context: IComputeContext;\r\n private _contextIsDirty = false;\r\n\r\n /**\r\n * Gets the unique id of the compute shader\r\n */\r\n public readonly uniqueId: number;\r\n\r\n /**\r\n * The name of the shader\r\n */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * The options used to create the shader\r\n */\r\n public get options() {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * The shaderPath used to create the shader\r\n */\r\n public get shaderPath() {\r\n return this._shaderPath;\r\n }\r\n\r\n /**\r\n * Callback triggered when the shader is compiled\r\n */\r\n public onCompiled: Nullable<(effect: ComputeEffect) => void> = null;\r\n\r\n /**\r\n * Callback triggered when an error occurs\r\n */\r\n public onError: Nullable<(effect: ComputeEffect, errors: string) => void> = null;\r\n\r\n /**\r\n * Instantiates a new compute shader.\r\n * @param name Defines the name of the compute shader in the scene\r\n * @param engine Defines the engine the compute shader belongs to\r\n * @param shaderPath Defines the route to the shader code in one of three ways:\r\n * * object: \\{ compute: \"custom\" \\}, used with ShaderStore.ShadersStoreWGSL[\"customComputeShader\"]\r\n * * object: \\{ computeElement: \"HTMLElementId\" \\}, used with shader code in script tags\r\n * * object: \\{ computeSource: \"compute shader code string\" \\}, where the string contains the shader code\r\n * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + \"ComputeShader\"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.\r\n * @param options Define the options used to create the shader\r\n */\r\n constructor(name: string, engine: ThinEngine, shaderPath: any, options: Partial<IComputeShaderOptions> = {}) {\r\n this.name = name;\r\n this._engine = engine;\r\n this.uniqueId = UniqueIdGenerator.UniqueId;\r\n\r\n if (!this._engine.getCaps().supportComputeShaders) {\r\n Logger.Error(\"This engine does not support compute shaders!\");\r\n return;\r\n }\r\n if (!options.bindingsMapping) {\r\n Logger.Error(\"You must provide the binding mappings as browsers don't support reflection for wgsl shaders yet!\");\r\n return;\r\n }\r\n\r\n this._context = engine.createComputeContext()!;\r\n this._shaderPath = shaderPath;\r\n this._options = {\r\n bindingsMapping: {},\r\n defines: [],\r\n ...options,\r\n };\r\n }\r\n\r\n /**\r\n * Gets the current class name of the material e.g. \"ComputeShader\"\r\n * Mainly use in serialization.\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"ComputeShader\";\r\n }\r\n\r\n /**\r\n * Binds a texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n * @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture\r\n */\r\n public setTexture(name: string, texture: BaseTexture, bindSampler = true): void {\r\n const current = this._bindings[name];\r\n\r\n this._bindings[name] = {\r\n type: bindSampler ? ComputeBindingType.Texture : ComputeBindingType.TextureWithoutSampler,\r\n object: texture,\r\n indexInGroupEntries: current?.indexInGroupEntries,\r\n };\r\n\r\n this._contextIsDirty ||= !current || current.object !== texture || current.type !== this._bindings[name].type;\r\n }\r\n\r\n /**\r\n * Binds a storage texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setStorageTexture(name: string, texture: BaseTexture): void {\r\n const current = this._bindings[name];\r\n\r\n this._contextIsDirty ||= !current || current.object !== texture;\r\n\r\n this._bindings[name] = {\r\n type: ComputeBindingType.StorageTexture,\r\n object: texture,\r\n indexInGroupEntries: current?.indexInGroupEntries,\r\n };\r\n }\r\n\r\n /**\r\n * Binds a uniform buffer to the shader\r\n * @param name Binding name of the buffer\r\n * @param buffer Buffer to bind\r\n */\r\n public setUniformBuffer(name: string, buffer: UniformBuffer): void {\r\n const current = this._bindings[name];\r\n\r\n this._contextIsDirty ||= !current || current.object !== buffer;\r\n\r\n this._bindings[name] = {\r\n type: ComputeBindingType.UniformBuffer,\r\n object: buffer,\r\n indexInGroupEntries: current?.indexInGroupEntries,\r\n };\r\n }\r\n\r\n /**\r\n * Binds a storage buffer to the shader\r\n * @param name Binding name of the buffer\r\n * @param buffer Buffer to bind\r\n */\r\n public setStorageBuffer(name: string, buffer: StorageBuffer): void {\r\n const current = this._bindings[name];\r\n\r\n this._contextIsDirty ||= !current || current.object !== buffer;\r\n\r\n this._bindings[name] = {\r\n type: ComputeBindingType.StorageBuffer,\r\n object: buffer,\r\n indexInGroupEntries: current?.indexInGroupEntries,\r\n };\r\n }\r\n\r\n /**\r\n * Binds a texture sampler to the shader\r\n * @param name Binding name of the sampler\r\n * @param sampler Sampler to bind\r\n */\r\n public setTextureSampler(name: string, sampler: TextureSampler): void {\r\n const current = this._bindings[name];\r\n\r\n this._contextIsDirty ||= !current || !sampler.compareSampler(current.object);\r\n\r\n this._bindings[name] = {\r\n type: ComputeBindingType.Sampler,\r\n object: sampler,\r\n indexInGroupEntries: current?.indexInGroupEntries,\r\n };\r\n }\r\n\r\n /**\r\n * Specifies that the compute shader is ready to be executed (the compute effect and all the resources are ready)\r\n * @returns true if the compute shader is ready to be executed\r\n */\r\n public isReady(): boolean {\r\n let effect = this._effect;\r\n\r\n for (const key in this._bindings) {\r\n const binding = this._bindings[key],\r\n type = binding.type,\r\n object = binding.object;\r\n\r\n switch (type) {\r\n case ComputeBindingType.Texture:\r\n case ComputeBindingType.TextureWithoutSampler:\r\n case ComputeBindingType.StorageTexture: {\r\n const texture = object as BaseTexture;\r\n if (!texture.isReady()) {\r\n return false;\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n const defines = [];\r\n\r\n const shaderName = this._shaderPath;\r\n\r\n if (this._options.defines) {\r\n for (let index = 0; index < this._options.defines.length; index++) {\r\n defines.push(this._options.defines[index]);\r\n }\r\n }\r\n\r\n const join = defines.join(\"\\n\");\r\n\r\n if (this._cachedDefines !== join) {\r\n this._cachedDefines = join;\r\n\r\n effect = this._engine.createComputeEffect(shaderName, <IComputeEffectCreationOptions>{\r\n defines: join,\r\n entryPoint: this._options.entryPoint,\r\n onCompiled: this.onCompiled,\r\n onError: this.onError,\r\n });\r\n\r\n this._effect = effect;\r\n }\r\n\r\n if (!effect.isReady()) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Dispatches (executes) the compute shader\r\n * @param x Number of workgroups to execute on the X dimension\r\n * @param y Number of workgroups to execute on the Y dimension (default: 1)\r\n * @param z Number of workgroups to execute on the Z dimension (default: 1)\r\n * @returns True if the dispatch could be done, else false (meaning either the compute effect or at least one of the bound resources was not ready)\r\n */\r\n public dispatch(x: number, y?: number, z?: number): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n // If the sampling parameters of a texture bound to the shader have changed, we must clear the compute context so that it is recreated with the updated values\r\n // Also, if the actual (gpu) buffer used by a uniform buffer has changed, we must clear the compute context so that it is recreated with the updated value\r\n for (const key in this._bindings) {\r\n const binding = this._bindings[key];\r\n\r\n if (!this._options.bindingsMapping[key]) {\r\n throw new Error(\"ComputeShader ('\" + this.name + \"'): No binding mapping has been provided for the property '\" + key + \"'\");\r\n }\r\n\r\n switch (binding.type) {\r\n case ComputeBindingType.Texture: {\r\n const sampler = this._samplers[key];\r\n const texture = binding.object as BaseTexture;\r\n\r\n if (!sampler || !texture._texture || !sampler.compareSampler(texture._texture)) {\r\n this._samplers[key] = new TextureSampler().setParameters(\r\n texture.wrapU,\r\n texture.wrapV,\r\n texture.wrapR,\r\n texture.anisotropicFilteringLevel,\r\n texture._texture!.samplingMode,\r\n texture._texture?._comparisonFunction\r\n );\r\n this._contextIsDirty = true;\r\n }\r\n break;\r\n }\r\n case ComputeBindingType.UniformBuffer: {\r\n const ubo = binding.object as UniformBuffer;\r\n if (ubo.getBuffer() !== binding.buffer) {\r\n binding.buffer = ubo.getBuffer();\r\n this._contextIsDirty = true;\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (this._contextIsDirty) {\r\n this._contextIsDirty = false;\r\n this._context.clear();\r\n }\r\n\r\n this._engine.computeDispatch(this._effect, this._context, this._bindings, x, y, z, this._options.bindingsMapping);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Waits for the compute shader to be ready and executes it\r\n * @param x Number of workgroups to execute on the X dimension\r\n * @param y Number of workgroups to execute on the Y dimension (default: 1)\r\n * @param z Number of workgroups to execute on the Z dimension (default: 1)\r\n * @param delay Delay between the retries while the shader is not ready (in milliseconds - 10 by default)\r\n * @returns A promise that is resolved once the shader has been sent to the GPU. Note that it does not mean that the shader execution itself is finished!\r\n */\r\n public dispatchWhenReady(x: number, y?: number, z?: number, delay = 10): Promise<void> {\r\n return new Promise((resolve) => {\r\n const check = () => {\r\n if (!this.dispatch(x, y, z)) {\r\n setTimeout(check, delay);\r\n } else {\r\n resolve();\r\n }\r\n };\r\n\r\n check();\r\n });\r\n }\r\n\r\n /**\r\n * Serializes this compute shader in a JSON representation\r\n * @returns the serialized compute shader object\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n\r\n serializationObject.options = this._options;\r\n serializationObject.shaderPath = this._shaderPath;\r\n serializationObject.bindings = {};\r\n serializationObject.textures = {};\r\n\r\n for (const key in this._bindings) {\r\n const binding = this._bindings[key];\r\n const object = binding.object;\r\n\r\n switch (binding.type) {\r\n case ComputeBindingType.Texture:\r\n case ComputeBindingType.TextureWithoutSampler:\r\n case ComputeBindingType.StorageTexture: {\r\n const serializedData = (object as BaseTexture).serialize();\r\n if (serializedData) {\r\n serializationObject.textures[key] = serializedData;\r\n serializationObject.bindings[key] = {\r\n type: binding.type,\r\n };\r\n }\r\n break;\r\n }\r\n\r\n case ComputeBindingType.UniformBuffer: {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a compute shader from parsed compute shader data\r\n * @param source defines the JSON representation of the compute shader\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a new compute shader\r\n */\r\n public static Parse(source: any, scene: Scene, rootUrl: string): ComputeShader {\r\n const compute = SerializationHelper.Parse(() => new ComputeShader(source.name, scene.getEngine(), source.shaderPath, source.options), source, scene, rootUrl);\r\n\r\n for (const key in source.textures) {\r\n const binding = source.bindings[key];\r\n const texture = <Texture>Texture.Parse(source.textures[key], scene, rootUrl);\r\n\r\n if (binding.type === ComputeBindingType.Texture) {\r\n compute.setTexture(key, texture);\r\n } else if (binding.type === ComputeBindingType.TextureWithoutSampler) {\r\n compute.setTexture(key, texture, false);\r\n } else {\r\n compute.setStorageTexture(key, texture);\r\n }\r\n }\r\n\r\n return compute;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ComputeShader\", ComputeShader);\r\n"]}
@@ -79,7 +79,7 @@ export declare class BoundingInfo implements ICullable {
79
79
  centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
80
80
  /**
81
81
  * Grows the bounding info to include the given point.
82
- * @param point The point that will be included in the current bounding info
82
+ * @param point The point that will be included in the current bounding info (in local space)
83
83
  * @returns the current bounding info
84
84
  */
85
85
  encapsulate(point: Vector3): BoundingInfo;
@@ -1,4 +1,5 @@
1
1
  import { ArrayTools } from "../Misc/arrayTools.js";
2
+ import { TmpVectors } from "../Maths/math.vector.js";
2
3
  import { Vector3 } from "../Maths/math.vector.js";
3
4
 
4
5
  import { BoundingBox } from "./boundingBox.js";
@@ -92,7 +93,7 @@ export class BoundingInfo {
92
93
  }
93
94
  /**
94
95
  * Grows the bounding info to include the given point.
95
- * @param point The point that will be included in the current bounding info
96
+ * @param point The point that will be included in the current bounding info (in local space)
96
97
  * @returns the current bounding info
97
98
  */
98
99
  encapsulate(point) {
@@ -107,8 +108,13 @@ export class BoundingInfo {
107
108
  * @returns the current bounding info
108
109
  */
109
110
  encapsulateBoundingInfo(toEncapsulate) {
110
- this.encapsulate(toEncapsulate.boundingBox.centerWorld.subtract(toEncapsulate.boundingBox.extendSizeWorld));
111
- this.encapsulate(toEncapsulate.boundingBox.centerWorld.add(toEncapsulate.boundingBox.extendSizeWorld));
111
+ const invw = TmpVectors.Matrix[0];
112
+ this.boundingBox.getWorldMatrix().invertToRef(invw);
113
+ const v = TmpVectors.Vector3[0];
114
+ Vector3.TransformCoordinatesToRef(toEncapsulate.boundingBox.minimumWorld, invw, v);
115
+ this.encapsulate(v);
116
+ Vector3.TransformCoordinatesToRef(toEncapsulate.boundingBox.maximumWorld, invw, v);
117
+ this.encapsulate(v);
112
118
  return this;
113
119
  }
114
120
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"boundingInfo.js","sourceRoot":"","sources":["../../../../lts/core/generated/Culling/boundingInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,O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SAChB;QACD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;YACjF,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;;AAzQuB,wBAAW,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import type { DeepImmutable } from \"../types\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport type { Matrix } from \"../Maths/math.vector\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { BoundingBox } from \"./boundingBox\";\r\nimport { BoundingSphere } from \"./boundingSphere\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\ndeclare type Collider = import(\"../Collisions/collider\").Collider;\r\n\r\nconst _result0 = { min: 0, max: 0 };\r\nconst _result1 = { min: 0, max: 0 };\r\nconst computeBoxExtents = (axis: DeepImmutable<Vector3>, box: DeepImmutable<BoundingBox>, result: { min: number; max: number }) => {\r\n const p = Vector3.Dot(box.centerWorld, axis);\r\n\r\n const r0 = Math.abs(Vector3.Dot(box.directions[0], axis)) * box.extendSize.x;\r\n const r1 = Math.abs(Vector3.Dot(box.directions[1], axis)) * box.extendSize.y;\r\n const r2 = Math.abs(Vector3.Dot(box.directions[2], axis)) * box.extendSize.z;\r\n\r\n const r = r0 + r1 + r2;\r\n result.min = p - r;\r\n result.max = p + r;\r\n};\r\n\r\nconst axisOverlap = (axis: DeepImmutable<Vector3>, box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean => {\r\n computeBoxExtents(axis, box0, _result0);\r\n computeBoxExtents(axis, box1, _result1);\r\n return !(_result0.min > _result1.max || _result1.min > _result0.max);\r\n};\r\n\r\n/**\r\n * Interface for cullable objects\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/materials_introduction#back-face-culling\r\n */\r\nexport interface ICullable {\r\n /**\r\n * Checks if the object or part of the object is in the frustum\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n isInFrustum(frustumPlanes: Plane[]): boolean;\r\n /**\r\n * Checks if a cullable object (mesh...) is in the camera frustum\r\n * Unlike isInFrustum this checks the full bounding box\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;\r\n}\r\n\r\n/**\r\n * Info for a bounding data of a mesh\r\n */\r\nexport class BoundingInfo implements ICullable {\r\n /**\r\n * Bounding box for the mesh\r\n */\r\n public readonly boundingBox: BoundingBox;\r\n /**\r\n * Bounding sphere for the mesh\r\n */\r\n public readonly boundingSphere: BoundingSphere;\r\n\r\n private _isLocked = false;\r\n\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(2, Vector3.Zero);\r\n\r\n /**\r\n * Constructs bounding info\r\n * @param minimum min vector of the bounding box/sphere\r\n * @param maximum max vector of the bounding box/sphere\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.boundingBox = new BoundingBox(minimum, maximum, worldMatrix);\r\n this.boundingSphere = new BoundingSphere(minimum, maximum, worldMatrix);\r\n }\r\n\r\n /**\r\n * Recreates the entire bounding info from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.boundingBox.reConstruct(min, max, worldMatrix);\r\n this.boundingSphere.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n /**\r\n * min vector of the bounding box/sphere\r\n */\r\n public get minimum(): Vector3 {\r\n return this.boundingBox.minimum;\r\n }\r\n\r\n /**\r\n * max vector of the bounding box/sphere\r\n */\r\n public get maximum(): Vector3 {\r\n return this.boundingBox.maximum;\r\n }\r\n\r\n /**\r\n * If the info is locked and won't be updated to avoid perf overhead\r\n */\r\n public get isLocked(): boolean {\r\n return this._isLocked;\r\n }\r\n\r\n public set isLocked(value: boolean) {\r\n this._isLocked = value;\r\n }\r\n\r\n // Methods\r\n /**\r\n * Updates the bounding sphere and box\r\n * @param world world matrix to be used to update\r\n */\r\n public update(world: DeepImmutable<Matrix>) {\r\n if (this._isLocked) {\r\n return;\r\n }\r\n this.boundingBox._update(world);\r\n this.boundingSphere._update(world);\r\n }\r\n\r\n /**\r\n * Recreate the bounding info to be centered around a specific point given a specific extend.\r\n * @param center New center of the bounding info\r\n * @param extend New extend of the bounding info\r\n * @returns the current bounding info\r\n */\r\n public centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo {\r\n const minimum = BoundingInfo._TmpVector3[0].copyFrom(center).subtractInPlace(extend);\r\n const maximum = BoundingInfo._TmpVector3[1].copyFrom(center).addInPlace(extend);\r\n\r\n this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Grows the bounding info to include the given point.\r\n * @param point The point that will be included in the current bounding info\r\n * @returns the current bounding info\r\n */\r\n public encapsulate(point: Vector3): BoundingInfo {\r\n const minimum = Vector3.Minimize(this.minimum, point);\r\n const maximum = Vector3.Maximize(this.maximum, point);\r\n this.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Grows the bounding info to encapsulate the given bounding info.\r\n * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info\r\n * @returns the current bounding info\r\n */\r\n public encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo {\r\n this.encapsulate(toEncapsulate.boundingBox.centerWorld.subtract(toEncapsulate.boundingBox.extendSizeWorld));\r\n this.encapsulate(toEncapsulate.boundingBox.centerWorld.add(toEncapsulate.boundingBox.extendSizeWorld));\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Scale the current bounding info by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding info\r\n */\r\n public scale(factor: number): BoundingInfo {\r\n this.boundingBox.scale(factor);\r\n this.boundingSphere.scale(factor);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.\r\n * @param frustumPlanes defines the frustum to test\r\n * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)\r\n * The different strategies available are:\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD most accurate but slower @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_STANDARD\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY faster but less accurate @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION can be faster if always visible @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_OPTIMISTIC_INCLUSION\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY can be faster if always visible @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY\r\n * @returns true if the bounding info is in the frustum planes\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy: number = Constants.MESHES_CULLINGSTRATEGY_STANDARD): boolean {\r\n const inclusionTest =\r\n strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION || strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;\r\n if (inclusionTest) {\r\n if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!this.boundingSphere.isInFrustum(frustumPlanes)) {\r\n return false;\r\n }\r\n\r\n const bSphereOnlyTest =\r\n strategy === Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY || strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;\r\n if (bSphereOnlyTest) {\r\n return true;\r\n }\r\n\r\n return this.boundingBox.isInFrustum(frustumPlanes);\r\n }\r\n\r\n /**\r\n * Gets the world distance between the min and max points of the bounding box\r\n */\r\n public get diagonalLength(): number {\r\n const boundingBox = this.boundingBox;\r\n const diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo._TmpVector3[0]);\r\n return diag.length();\r\n }\r\n\r\n /**\r\n * Checks if a cullable object (mesh...) is in the camera frustum\r\n * Unlike isInFrustum this checks the full bounding box\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return this.boundingBox.isCompletelyInFrustum(frustumPlanes);\r\n }\r\n /**\r\n * @internal\r\n */\r\n public _checkCollision(collider: Collider): boolean {\r\n return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);\r\n }\r\n\r\n /**\r\n * Checks if a point is inside the bounding box and bounding sphere or the mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect\r\n * @param point the point to check intersection with\r\n * @returns if the point intersects\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n if (!this.boundingSphere.centerWorld) {\r\n return false;\r\n }\r\n\r\n if (!this.boundingSphere.intersectsPoint(point)) {\r\n return false;\r\n }\r\n\r\n if (!this.boundingBox.intersectsPoint(point)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect\r\n * @param boundingInfo the bounding info to check intersection with\r\n * @param precise if the intersection should be done using OBB\r\n * @returns if the bounding info intersects\r\n */\r\n public intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean {\r\n if (!BoundingSphere.Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {\r\n return false;\r\n }\r\n\r\n if (!BoundingBox.Intersects(this.boundingBox, boundingInfo.boundingBox)) {\r\n return false;\r\n }\r\n\r\n if (!precise) {\r\n return true;\r\n }\r\n\r\n const box0 = this.boundingBox;\r\n const box1 = boundingInfo.boundingBox;\r\n\r\n if (!axisOverlap(box0.directions[0], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(box0.directions[1], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(box0.directions[2], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(box1.directions[0], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(box1.directions[1], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(box1.directions[2], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[0], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[0], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[0], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[1], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[1], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[1], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[2], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[2], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[2], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"boundingInfo.js","sourceRoot":"","sources":["../../../../lts/core/generated/Culling/boundingInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKlD,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AACpC,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AACpC,MAAM,iBAAiB,GAAG,CAAC,IAA4B,EAAE,GAA+B,EAAE,MAAoC,EAAE,EAAE;IAC9H,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAE7C,MAAM,EAAE,GAAG,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B;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;;AAjRuB,wBAAW,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import type { DeepImmutable } from \"../types\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport type { Matrix } from \"../Maths/math.vector\";\r\nimport { TmpVectors } from \"../Maths/math.vector\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { BoundingBox } from \"./boundingBox\";\r\nimport { BoundingSphere } from \"./boundingSphere\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\ndeclare type Collider = import(\"../Collisions/collider\").Collider;\r\n\r\nconst _result0 = { min: 0, max: 0 };\r\nconst _result1 = { min: 0, max: 0 };\r\nconst computeBoxExtents = (axis: DeepImmutable<Vector3>, box: DeepImmutable<BoundingBox>, result: { min: number; max: number }) => {\r\n const p = Vector3.Dot(box.centerWorld, axis);\r\n\r\n const r0 = Math.abs(Vector3.Dot(box.directions[0], axis)) * box.extendSize.x;\r\n const r1 = Math.abs(Vector3.Dot(box.directions[1], axis)) * box.extendSize.y;\r\n const r2 = Math.abs(Vector3.Dot(box.directions[2], axis)) * box.extendSize.z;\r\n\r\n const r = r0 + r1 + r2;\r\n result.min = p - r;\r\n result.max = p + r;\r\n};\r\n\r\nconst axisOverlap = (axis: DeepImmutable<Vector3>, box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean => {\r\n computeBoxExtents(axis, box0, _result0);\r\n computeBoxExtents(axis, box1, _result1);\r\n return !(_result0.min > _result1.max || _result1.min > _result0.max);\r\n};\r\n\r\n/**\r\n * Interface for cullable objects\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/materials_introduction#back-face-culling\r\n */\r\nexport interface ICullable {\r\n /**\r\n * Checks if the object or part of the object is in the frustum\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n isInFrustum(frustumPlanes: Plane[]): boolean;\r\n /**\r\n * Checks if a cullable object (mesh...) is in the camera frustum\r\n * Unlike isInFrustum this checks the full bounding box\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;\r\n}\r\n\r\n/**\r\n * Info for a bounding data of a mesh\r\n */\r\nexport class BoundingInfo implements ICullable {\r\n /**\r\n * Bounding box for the mesh\r\n */\r\n public readonly boundingBox: BoundingBox;\r\n /**\r\n * Bounding sphere for the mesh\r\n */\r\n public readonly boundingSphere: BoundingSphere;\r\n\r\n private _isLocked = false;\r\n\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(2, Vector3.Zero);\r\n\r\n /**\r\n * Constructs bounding info\r\n * @param minimum min vector of the bounding box/sphere\r\n * @param maximum max vector of the bounding box/sphere\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.boundingBox = new BoundingBox(minimum, maximum, worldMatrix);\r\n this.boundingSphere = new BoundingSphere(minimum, maximum, worldMatrix);\r\n }\r\n\r\n /**\r\n * Recreates the entire bounding info from scratch as if we call the constructor in place\r\n * @param min defines the new minimum vector (in local space)\r\n * @param max defines the new maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n public reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.boundingBox.reConstruct(min, max, worldMatrix);\r\n this.boundingSphere.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n /**\r\n * min vector of the bounding box/sphere\r\n */\r\n public get minimum(): Vector3 {\r\n return this.boundingBox.minimum;\r\n }\r\n\r\n /**\r\n * max vector of the bounding box/sphere\r\n */\r\n public get maximum(): Vector3 {\r\n return this.boundingBox.maximum;\r\n }\r\n\r\n /**\r\n * If the info is locked and won't be updated to avoid perf overhead\r\n */\r\n public get isLocked(): boolean {\r\n return this._isLocked;\r\n }\r\n\r\n public set isLocked(value: boolean) {\r\n this._isLocked = value;\r\n }\r\n\r\n // Methods\r\n /**\r\n * Updates the bounding sphere and box\r\n * @param world world matrix to be used to update\r\n */\r\n public update(world: DeepImmutable<Matrix>) {\r\n if (this._isLocked) {\r\n return;\r\n }\r\n this.boundingBox._update(world);\r\n this.boundingSphere._update(world);\r\n }\r\n\r\n /**\r\n * Recreate the bounding info to be centered around a specific point given a specific extend.\r\n * @param center New center of the bounding info\r\n * @param extend New extend of the bounding info\r\n * @returns the current bounding info\r\n */\r\n public centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo {\r\n const minimum = BoundingInfo._TmpVector3[0].copyFrom(center).subtractInPlace(extend);\r\n const maximum = BoundingInfo._TmpVector3[1].copyFrom(center).addInPlace(extend);\r\n\r\n this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Grows the bounding info to include the given point.\r\n * @param point The point that will be included in the current bounding info (in local space)\r\n * @returns the current bounding info\r\n */\r\n public encapsulate(point: Vector3): BoundingInfo {\r\n const minimum = Vector3.Minimize(this.minimum, point);\r\n const maximum = Vector3.Maximize(this.maximum, point);\r\n this.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Grows the bounding info to encapsulate the given bounding info.\r\n * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info\r\n * @returns the current bounding info\r\n */\r\n public encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo {\r\n const invw = TmpVectors.Matrix[0];\r\n this.boundingBox.getWorldMatrix().invertToRef(invw);\r\n\r\n const v = TmpVectors.Vector3[0];\r\n\r\n Vector3.TransformCoordinatesToRef(toEncapsulate.boundingBox.minimumWorld, invw, v);\r\n this.encapsulate(v);\r\n\r\n Vector3.TransformCoordinatesToRef(toEncapsulate.boundingBox.maximumWorld, invw, v);\r\n this.encapsulate(v);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Scale the current bounding info by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding info\r\n */\r\n public scale(factor: number): BoundingInfo {\r\n this.boundingBox.scale(factor);\r\n this.boundingSphere.scale(factor);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.\r\n * @param frustumPlanes defines the frustum to test\r\n * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)\r\n * The different strategies available are:\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD most accurate but slower @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_STANDARD\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY faster but less accurate @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION can be faster if always visible @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_OPTIMISTIC_INCLUSION\r\n * * BABYLON.AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY can be faster if always visible @see https://doc.babylonjs.com/typedoc/classes/BABYLON.AbstractMesh#CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY\r\n * @returns true if the bounding info is in the frustum planes\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy: number = Constants.MESHES_CULLINGSTRATEGY_STANDARD): boolean {\r\n const inclusionTest =\r\n strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION || strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;\r\n if (inclusionTest) {\r\n if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!this.boundingSphere.isInFrustum(frustumPlanes)) {\r\n return false;\r\n }\r\n\r\n const bSphereOnlyTest =\r\n strategy === Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY || strategy === Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;\r\n if (bSphereOnlyTest) {\r\n return true;\r\n }\r\n\r\n return this.boundingBox.isInFrustum(frustumPlanes);\r\n }\r\n\r\n /**\r\n * Gets the world distance between the min and max points of the bounding box\r\n */\r\n public get diagonalLength(): number {\r\n const boundingBox = this.boundingBox;\r\n const diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo._TmpVector3[0]);\r\n return diag.length();\r\n }\r\n\r\n /**\r\n * Checks if a cullable object (mesh...) is in the camera frustum\r\n * Unlike isInFrustum this checks the full bounding box\r\n * @param frustumPlanes Camera near/planes\r\n * @returns true if the object is in frustum otherwise false\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return this.boundingBox.isCompletelyInFrustum(frustumPlanes);\r\n }\r\n /**\r\n * @internal\r\n */\r\n public _checkCollision(collider: Collider): boolean {\r\n return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);\r\n }\r\n\r\n /**\r\n * Checks if a point is inside the bounding box and bounding sphere or the mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect\r\n * @param point the point to check intersection with\r\n * @returns if the point intersects\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n if (!this.boundingSphere.centerWorld) {\r\n return false;\r\n }\r\n\r\n if (!this.boundingSphere.intersectsPoint(point)) {\r\n return false;\r\n }\r\n\r\n if (!this.boundingBox.intersectsPoint(point)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/mesh_intersect\r\n * @param boundingInfo the bounding info to check intersection with\r\n * @param precise if the intersection should be done using OBB\r\n * @returns if the bounding info intersects\r\n */\r\n public intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean {\r\n if (!BoundingSphere.Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {\r\n return false;\r\n }\r\n\r\n if (!BoundingBox.Intersects(this.boundingBox, boundingInfo.boundingBox)) {\r\n return false;\r\n }\r\n\r\n if (!precise) {\r\n return true;\r\n }\r\n\r\n const box0 = this.boundingBox;\r\n const box1 = boundingInfo.boundingBox;\r\n\r\n if (!axisOverlap(box0.directions[0], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(box0.directions[1], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(box0.directions[2], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(box1.directions[0], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(box1.directions[1], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(box1.directions[2], box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[0], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[0], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[0], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[1], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[1], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[1], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[2], box1.directions[0]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[2], box1.directions[1]), box0, box1)) {\r\n return false;\r\n }\r\n if (!axisOverlap(Vector3.Cross(box0.directions[2], box1.directions[2]), box0, box1)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
@@ -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.56.0";
37
+ return "babylonjs@5.57.1";
38
38
  }
39
39
  /**
40
40
  * Returns the current version of the framework
41
41
  */
42
42
  static get Version() {
43
- return "5.56.0";
43
+ return "5.57.1";
44
44
  }
45
45
  /**
46
46
  * Returns a string describing the current engine