@babylonjs/core 7.20.0 → 7.20.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 (117) hide show
  1. package/Bones/bone.js +3 -3
  2. package/Bones/bone.js.map +1 -1
  3. package/Bones/boneLookController.js +3 -3
  4. package/Bones/boneLookController.js.map +1 -1
  5. package/Compat/compatibilityOptions.d.ts +13 -6
  6. package/Compat/compatibilityOptions.js +20 -4
  7. package/Compat/compatibilityOptions.js.map +1 -1
  8. package/Compat/index.d.ts +1 -1
  9. package/Compat/index.js +1 -1
  10. package/Compat/index.js.map +1 -1
  11. package/Culling/boundingBox.js +5 -5
  12. package/Culling/boundingBox.js.map +1 -1
  13. package/Culling/boundingInfo.js +2 -2
  14. package/Culling/boundingInfo.js.map +1 -1
  15. package/Culling/boundingSphere.js +2 -2
  16. package/Culling/boundingSphere.js.map +1 -1
  17. package/Culling/ray.js +2 -2
  18. package/Culling/ray.js.map +1 -1
  19. package/Debug/debugLayer.d.ts +3 -0
  20. package/Debug/debugLayer.js +15 -0
  21. package/Debug/debugLayer.js.map +1 -1
  22. package/Engines/abstractEngine.js +2 -2
  23. package/Engines/abstractEngine.js.map +1 -1
  24. package/Engines/engine.js +11 -2
  25. package/Engines/engine.js.map +1 -1
  26. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +2 -2
  27. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +1 -1
  28. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
  29. package/Layers/highlightLayer.js +0 -1
  30. package/Layers/highlightLayer.js.map +1 -1
  31. package/Materials/Textures/Loaders/hdrTextureLoader.js +3 -3
  32. package/Materials/Textures/Loaders/hdrTextureLoader.js.map +1 -1
  33. package/Materials/Textures/hdrCubeTexture.js +2 -2
  34. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  35. package/Materials/Textures/renderTargetTexture.js +2 -2
  36. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  37. package/Materials/Textures/texture.js +3 -3
  38. package/Materials/Textures/texture.js.map +1 -1
  39. package/Maths/math.color.js +3 -3
  40. package/Maths/math.color.js.map +1 -1
  41. package/Maths/math.vector.js +13 -14
  42. package/Maths/math.vector.js.map +1 -1
  43. package/Meshes/Builders/boxBuilder.js +5 -5
  44. package/Meshes/Builders/boxBuilder.js.map +1 -1
  45. package/Meshes/Builders/capsuleBuilder.js +4 -4
  46. package/Meshes/Builders/capsuleBuilder.js.map +1 -1
  47. package/Meshes/Builders/cylinderBuilder.js +8 -8
  48. package/Meshes/Builders/cylinderBuilder.js.map +1 -1
  49. package/Meshes/Builders/decalBuilder.js +3 -3
  50. package/Meshes/Builders/decalBuilder.js.map +1 -1
  51. package/Meshes/Builders/discBuilder.js +3 -3
  52. package/Meshes/Builders/discBuilder.js.map +1 -1
  53. package/Meshes/Builders/goldbergBuilder.js +2 -2
  54. package/Meshes/Builders/goldbergBuilder.js.map +1 -1
  55. package/Meshes/Builders/groundBuilder.js +2 -2
  56. package/Meshes/Builders/groundBuilder.js.map +1 -1
  57. package/Meshes/Builders/icoSphereBuilder.js +2 -2
  58. package/Meshes/Builders/icoSphereBuilder.js.map +1 -1
  59. package/Meshes/Builders/planeBuilder.js +5 -5
  60. package/Meshes/Builders/planeBuilder.js.map +1 -1
  61. package/Meshes/Builders/polygonBuilder.js +4 -4
  62. package/Meshes/Builders/polygonBuilder.js.map +1 -1
  63. package/Meshes/Builders/polyhedronBuilder.js +3 -3
  64. package/Meshes/Builders/polyhedronBuilder.js.map +1 -1
  65. package/Meshes/Builders/ribbonBuilder.js +4 -4
  66. package/Meshes/Builders/ribbonBuilder.js.map +1 -1
  67. package/Meshes/Builders/sphereBuilder.js +2 -2
  68. package/Meshes/Builders/sphereBuilder.js.map +1 -1
  69. package/Meshes/Builders/tiledBoxBuilder.js +2 -2
  70. package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
  71. package/Meshes/Builders/torusBuilder.js +2 -2
  72. package/Meshes/Builders/torusBuilder.js.map +1 -1
  73. package/Meshes/Builders/torusKnotBuilder.js +2 -2
  74. package/Meshes/Builders/torusKnotBuilder.js.map +1 -1
  75. package/Meshes/geometry.js +7 -7
  76. package/Meshes/geometry.js.map +1 -1
  77. package/Misc/HighDynamicRange/hdr.d.ts +40 -42
  78. package/Misc/HighDynamicRange/hdr.js +209 -202
  79. package/Misc/HighDynamicRange/hdr.js.map +1 -1
  80. package/Misc/HighDynamicRange/index.d.ts +1 -1
  81. package/Misc/HighDynamicRange/index.js +1 -1
  82. package/Misc/HighDynamicRange/index.js.map +1 -1
  83. package/Misc/arrayTools.d.ts +12 -17
  84. package/Misc/arrayTools.js +18 -23
  85. package/Misc/arrayTools.js.map +1 -1
  86. package/Misc/dumpTools.d.ts +50 -47
  87. package/Misc/dumpTools.js +153 -143
  88. package/Misc/dumpTools.js.map +1 -1
  89. package/Misc/environmentTextureTools.js +2 -2
  90. package/Misc/environmentTextureTools.js.map +1 -1
  91. package/Misc/equirectangularCapture.js +2 -2
  92. package/Misc/equirectangularCapture.js.map +1 -1
  93. package/Misc/index.d.ts +2 -1
  94. package/Misc/index.js +2 -1
  95. package/Misc/index.js.map +1 -1
  96. package/Misc/rgbdTextureTools.js +1 -0
  97. package/Misc/rgbdTextureTools.js.map +1 -1
  98. package/Misc/screenshotTools.js +3 -3
  99. package/Misc/screenshotTools.js.map +1 -1
  100. package/Physics/v1/physicsImpostor.js +2 -2
  101. package/Physics/v1/physicsImpostor.js.map +1 -1
  102. package/Physics/v2/Plugins/havokPlugin.js +2 -2
  103. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  104. package/PostProcesses/blurPostProcess.js +0 -1
  105. package/PostProcesses/blurPostProcess.js.map +1 -1
  106. package/PostProcesses/passPostProcess.js +0 -2
  107. package/PostProcesses/passPostProcess.js.map +1 -1
  108. package/PostProcesses/postProcess.d.ts +6 -0
  109. package/PostProcesses/postProcess.js +22 -1
  110. package/PostProcesses/postProcess.js.map +1 -1
  111. package/Shaders/ShadersInclude/pbrDebug.js +1 -1
  112. package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
  113. package/ShadersWGSL/ShadersInclude/pbrDebug.js +1 -1
  114. package/ShadersWGSL/ShadersInclude/pbrDebug.js.map +1 -1
  115. package/ShadersWGSL/background.fragment.js +1 -1
  116. package/ShadersWGSL/background.fragment.js.map +1 -1
  117. package/package.json +1 -1
@@ -1,10 +1,26 @@
1
1
  /**
2
- * Options used to control default behaviors regarding compatibility support
2
+ * Defines if the system should use OpenGL convention for UVs when creating geometry or loading .babylon files (false by default)
3
+ */
4
+ export let useOpenGLOrientationForUV = false;
5
+ /**
6
+ * Sets whether to use OpenGL convention for UVs
7
+ * @param value the new value
3
8
  */
4
- export class CompatibilityOptions {
9
+ export function setOpenGLOrientationForUV(value) {
10
+ useOpenGLOrientationForUV = value;
5
11
  }
6
12
  /**
7
- * Defines if the system should use OpenGL convention for UVs when creating geometry or loading .babylon files (false by default)
13
+ * Options used to control default behaviors regarding compatibility support
14
+ * @deprecated please use named exports
8
15
  */
9
- CompatibilityOptions.UseOpenGLOrientationForUV = false;
16
+ export const CompatibilityOptions = {
17
+ /* eslint-disable @typescript-eslint/naming-convention */
18
+ get UseOpenGLOrientationForUV() {
19
+ return useOpenGLOrientationForUV;
20
+ },
21
+ set UseOpenGLOrientationForUV(value) {
22
+ useOpenGLOrientationForUV = value;
23
+ },
24
+ /* eslint-enable @typescript-eslint/naming-convention */
25
+ };
10
26
  //# sourceMappingURL=compatibilityOptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compatibilityOptions.js","sourceRoot":"","sources":["../../../../dev/core/src/Compat/compatibilityOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,oBAAoB;;AAC7B;;GAEG;AACW,8CAAyB,GAAG,KAAK,CAAC","sourcesContent":["/**\r\n * Options used to control default behaviors regarding compatibility support\r\n */\r\nexport class CompatibilityOptions {\r\n /**\r\n * Defines if the system should use OpenGL convention for UVs when creating geometry or loading .babylon files (false by default)\r\n */\r\n public static UseOpenGLOrientationForUV = false;\r\n}\r\n"]}
1
+ {"version":3,"file":"compatibilityOptions.js","sourceRoot":"","sources":["../../../../dev/core/src/Compat/compatibilityOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,IAAI,yBAAyB,GAAG,KAAK,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACpD,yBAAyB,GAAG,KAAK,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,yDAAyD;IACzD,IAAI,yBAAyB;QACzB,OAAO,yBAAyB,CAAC;IACrC,CAAC;IACD,IAAI,yBAAyB,CAAC,KAAK;QAC/B,yBAAyB,GAAG,KAAK,CAAC;IACtC,CAAC;IACD,wDAAwD;CAC3D,CAAC","sourcesContent":["/**\r\n * Defines if the system should use OpenGL convention for UVs when creating geometry or loading .babylon files (false by default)\r\n */\r\nexport let useOpenGLOrientationForUV = false;\r\n\r\n/**\r\n * Sets whether to use OpenGL convention for UVs\r\n * @param value the new value\r\n */\r\nexport function setOpenGLOrientationForUV(value: boolean) {\r\n useOpenGLOrientationForUV = value;\r\n}\r\n\r\n/**\r\n * Options used to control default behaviors regarding compatibility support\r\n * @deprecated please use named exports\r\n */\r\nexport const CompatibilityOptions = {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n get UseOpenGLOrientationForUV() {\r\n return useOpenGLOrientationForUV;\r\n },\r\n set UseOpenGLOrientationForUV(value) {\r\n useOpenGLOrientationForUV = value;\r\n },\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n};\r\n"]}
package/Compat/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./compatibilityOptions";
1
+ export { CompatibilityOptions } from "./compatibilityOptions";
package/Compat/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./compatibilityOptions.js";
1
+ export { CompatibilityOptions } from "./compatibilityOptions.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Compat/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC","sourcesContent":["export * from \"./compatibilityOptions\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Compat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { CompatibilityOptions } from \"./compatibilityOptions\";\r\n"]}
@@ -1,4 +1,4 @@
1
- import { ArrayTools } from "../Misc/arrayTools.js";
1
+ import { BuildArray } from "../Misc/arrayTools.js";
2
2
  import { Matrix, Vector3 } from "../Maths/math.vector.js";
3
3
  import { Epsilon } from "../Maths/math.constants.js";
4
4
  /**
@@ -15,7 +15,7 @@ export class BoundingBox {
15
15
  /**
16
16
  * Gets the 8 vectors representing the bounding box in local space
17
17
  */
18
- this.vectors = ArrayTools.BuildArray(8, Vector3.Zero);
18
+ this.vectors = BuildArray(8, Vector3.Zero);
19
19
  /**
20
20
  * Gets the center of the bounding box in local space
21
21
  */
@@ -35,11 +35,11 @@ export class BoundingBox {
35
35
  /**
36
36
  * Gets the OBB (object bounding box) directions
37
37
  */
38
- this.directions = ArrayTools.BuildArray(3, Vector3.Zero);
38
+ this.directions = BuildArray(3, Vector3.Zero);
39
39
  /**
40
40
  * Gets the 8 vectors representing the bounding box in world space
41
41
  */
42
- this.vectorsWorld = ArrayTools.BuildArray(8, Vector3.Zero);
42
+ this.vectorsWorld = BuildArray(8, Vector3.Zero);
43
43
  /**
44
44
  * Gets the minimum vector in world space
45
45
  */
@@ -288,5 +288,5 @@ export class BoundingBox {
288
288
  return true;
289
289
  }
290
290
  }
291
- BoundingBox._TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero);
291
+ BoundingBox._TmpVector3 = BuildArray(3, Vector3.Zero);
292
292
  //# sourceMappingURL=boundingBox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"boundingBox.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingBox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD;;GAEG;AACH,MAAM,OAAO,WAAW;IA2DpB;;;;;OAKG;IACH,YAAY,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAhEzG;;WAEG;QACa,YAAO,GAAc,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5E;;WAEG;QACa,WAAM,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACjD;;WAEG;QACa,gBAAW,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACtD;;WAEG;QACa,eAAU,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACrD;;WAEG;QACa,oBAAe,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1D;;WAEG;QACa,eAAU,GAAc,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/E;;WAEG;QACa,iBAAY,GAAc,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACjF;;WAEG;QACa,iBAAY,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACvD;;WAEG;QACa,iBAAY,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QACvD;;WAEG;QACa,YAAO,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAClD;;WAEG;QACa,YAAO,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAUlD,gBAAgB;QACT,sBAAiB,G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";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { BoundingSphere } from \"../Culling/boundingSphere\";\r\n\r\nimport type { ICullable } from \"./boundingInfo\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\nimport type { DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\n/**\r\n * Class used to store bounding box information\r\n */\r\nexport class BoundingBox implements ICullable {\r\n /**\r\n * Gets the 8 vectors representing the bounding box in local space\r\n */\r\n public readonly vectors: Vector3[] = ArrayTools.BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the center of the bounding box in local space\r\n */\r\n public readonly center: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the center of the bounding box in world space\r\n */\r\n public readonly centerWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSize: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSizeWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the OBB (object bounding box) directions\r\n */\r\n public readonly directions: Vector3[] = ArrayTools.BuildArray(3, Vector3.Zero);\r\n /**\r\n * Gets the 8 vectors representing the bounding box in world space\r\n */\r\n public readonly vectorsWorld: Vector3[] = ArrayTools.BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the minimum vector in world space\r\n */\r\n public readonly minimumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in world space\r\n */\r\n public readonly maximumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum: Vector3 = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * @internal\r\n */\r\n public _tag: number;\r\n\r\n /** @internal */\r\n public _drawWrapperFront: Nullable<DrawWrapper> = null;\r\n /** @internal */\r\n public _drawWrapperBack: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Creates a new bounding box\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Recreates the entire bounding box 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 const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const vectors = this.vectors;\r\n\r\n this.minimum.copyFromFloats(minX, minY, minZ);\r\n this.maximum.copyFromFloats(maxX, maxY, maxZ);\r\n vectors[0].copyFromFloats(minX, minY, minZ);\r\n vectors[1].copyFromFloats(maxX, maxY, maxZ);\r\n vectors[2].copyFromFloats(maxX, minY, minZ);\r\n vectors[3].copyFromFloats(minX, maxY, minZ);\r\n vectors[4].copyFromFloats(minX, minY, maxZ);\r\n vectors[5].copyFromFloats(maxX, maxY, minZ);\r\n vectors[6].copyFromFloats(minX, maxY, maxZ);\r\n vectors[7].copyFromFloats(maxX, minY, maxZ);\r\n\r\n // OBB\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);\r\n\r\n this._worldMatrix = worldMatrix || Matrix.IdentityReadOnly;\r\n\r\n this._update(this._worldMatrix);\r\n }\r\n\r\n /**\r\n * Scale the current bounding box by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingBox {\r\n const tmpVectors = BoundingBox._TmpVector3;\r\n const diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);\r\n const len = diff.length();\r\n diff.normalizeFromLength(len);\r\n const distance = len * factor;\r\n const newRadius = diff.scaleInPlace(distance * 0.5);\r\n\r\n const min = this.center.subtractToRef(newRadius, tmpVectors[1]);\r\n const max = this.center.addToRef(newRadius, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _update(world: DeepImmutable<Matrix>): void {\r\n const minWorld = this.minimumWorld;\r\n const maxWorld = this.maximumWorld;\r\n const directions = this.directions;\r\n const vectorsWorld = this.vectorsWorld;\r\n const vectors = this.vectors;\r\n\r\n if (!world.isIdentity()) {\r\n minWorld.setAll(Number.MAX_VALUE);\r\n maxWorld.setAll(-Number.MAX_VALUE);\r\n\r\n for (let index = 0; index < 8; ++index) {\r\n const v = vectorsWorld[index];\r\n Vector3.TransformCoordinatesToRef(vectors[index], world, v);\r\n minWorld.minimizeInPlace(v);\r\n maxWorld.maximizeInPlace(v);\r\n }\r\n\r\n // Extend\r\n maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);\r\n maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);\r\n } else {\r\n minWorld.copyFrom(this.minimum);\r\n maxWorld.copyFrom(this.maximum);\r\n for (let index = 0; index < 8; ++index) {\r\n vectorsWorld[index].copyFrom(vectors[index]);\r\n }\r\n\r\n // Extend\r\n this.extendSizeWorld.copyFrom(this.extendSize);\r\n this.centerWorld.copyFrom(this.center);\r\n }\r\n\r\n Vector3.FromArrayToRef(world.m, 0, directions[0]);\r\n Vector3.FromArrayToRef(world.m, 4, directions[1]);\r\n Vector3.FromArrayToRef(world.m, 8, directions[2]);\r\n\r\n this._worldMatrix = world;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is entirely inside the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding box\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding box\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const min = this.minimumWorld;\r\n const max = this.maximumWorld;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const pointX = point.x,\r\n pointY = point.y,\r\n pointZ = point.z;\r\n const delta = -Epsilon;\r\n\r\n if (maxX - pointX < delta || delta > pointX - minX) {\r\n return false;\r\n }\r\n\r\n if (maxY - pointY < delta || delta > pointY - minY) {\r\n return false;\r\n }\r\n\r\n if (maxZ - pointZ < delta || delta > pointZ - minZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a bounding sphere\r\n * @param sphere defines the sphere to test\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean {\r\n return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a box defined by a min and max vectors\r\n * @param min defines the min vector to use\r\n * @param max defines the max vector to use\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean {\r\n const myMin = this.minimumWorld;\r\n const myMax = this.maximumWorld;\r\n const myMinX = myMin.x,\r\n myMinY = myMin.y,\r\n myMinZ = myMin.z,\r\n myMaxX = myMax.x,\r\n myMaxY = myMax.y,\r\n myMaxZ = myMax.z;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n if (myMaxX < minX || myMinX > maxX) {\r\n return false;\r\n }\r\n\r\n if (myMaxY < minY || myMinY > maxY) {\r\n return false;\r\n }\r\n\r\n if (myMaxZ < minZ || myMinZ > maxZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes the resources of the class\r\n */\r\n public dispose(): void {\r\n this._drawWrapperFront?.dispose();\r\n this._drawWrapperBack?.dispose();\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Tests if two bounding boxes are intersections\r\n * @param box0 defines the first box to test\r\n * @param box1 defines the second box to test\r\n * @returns true if there is an intersection\r\n */\r\n public static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean {\r\n return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defines by a min/max vectors intersects a sphere\r\n * @param minPoint defines the minimum vector of the bounding box\r\n * @param maxPoint defines the maximum vector of the bounding box\r\n * @param sphereCenter defines the sphere center\r\n * @param sphereRadius defines the sphere radius\r\n * @returns true if there is an intersection\r\n */\r\n public static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean {\r\n const vector = BoundingBox._TmpVector3[0];\r\n Vector3.ClampToRef(sphereCenter, minPoint, maxPoint, vector);\r\n const num = Vector3.DistanceSquared(sphereCenter, vector);\r\n return num <= sphereRadius * sphereRadius;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors intersects frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n let canReturnFalse = true;\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {\r\n canReturnFalse = false;\r\n break;\r\n }\r\n }\r\n if (canReturnFalse) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"boundingBox.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingBox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,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C,CAAC,CAAC,CAAC;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;gBACxB,IAAI,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;oBACpD,OAAO,KAAK,CAAC;iBAChB;aACJ;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,WAAW,CAAC,eAA8C,EAAE,aAA0C;QAChH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;YACxB,IAAI,cAAc,GAAG,IAAI,CAAC;YAC1B,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;gBACxB,IAAI,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;oBACrD,cAAc,GAAG,KAAK,CAAC;oBACvB,MAAM;iBACT;aACJ;YACD,IAAI,cAAc,EAAE;gBAChB,OAAO,KAAK,CAAC;aAChB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;AA9SuB,uBAAW,GAAG,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAA9B,CAA+B","sourcesContent":["import type { DeepImmutable, Nullable } from \"../types\";\r\nimport { BuildArray } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { BoundingSphere } from \"../Culling/boundingSphere\";\r\n\r\nimport type { ICullable } from \"./boundingInfo\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\nimport type { DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\n/**\r\n * Class used to store bounding box information\r\n */\r\nexport class BoundingBox implements ICullable {\r\n /**\r\n * Gets the 8 vectors representing the bounding box in local space\r\n */\r\n public readonly vectors: Vector3[] = BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the center of the bounding box in local space\r\n */\r\n public readonly center: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the center of the bounding box in world space\r\n */\r\n public readonly centerWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSize: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!\r\n */\r\n public readonly extendSizeWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the OBB (object bounding box) directions\r\n */\r\n public readonly directions: Vector3[] = BuildArray(3, Vector3.Zero);\r\n /**\r\n * Gets the 8 vectors representing the bounding box in world space\r\n */\r\n public readonly vectorsWorld: Vector3[] = BuildArray(8, Vector3.Zero);\r\n /**\r\n * Gets the minimum vector in world space\r\n */\r\n public readonly minimumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in world space\r\n */\r\n public readonly maximumWorld: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum: Vector3 = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum: Vector3 = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * @internal\r\n */\r\n public _tag: number;\r\n\r\n /** @internal */\r\n public _drawWrapperFront: Nullable<DrawWrapper> = null;\r\n /** @internal */\r\n public _drawWrapperBack: Nullable<DrawWrapper> = null;\r\n\r\n /**\r\n * Creates a new bounding box\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Recreates the entire bounding box 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 const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const vectors = this.vectors;\r\n\r\n this.minimum.copyFromFloats(minX, minY, minZ);\r\n this.maximum.copyFromFloats(maxX, maxY, maxZ);\r\n vectors[0].copyFromFloats(minX, minY, minZ);\r\n vectors[1].copyFromFloats(maxX, maxY, maxZ);\r\n vectors[2].copyFromFloats(maxX, minY, minZ);\r\n vectors[3].copyFromFloats(minX, maxY, minZ);\r\n vectors[4].copyFromFloats(minX, minY, maxZ);\r\n vectors[5].copyFromFloats(maxX, maxY, minZ);\r\n vectors[6].copyFromFloats(minX, maxY, maxZ);\r\n vectors[7].copyFromFloats(maxX, minY, maxZ);\r\n\r\n // OBB\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);\r\n\r\n this._worldMatrix = worldMatrix || Matrix.IdentityReadOnly;\r\n\r\n this._update(this._worldMatrix);\r\n }\r\n\r\n /**\r\n * Scale the current bounding box by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingBox {\r\n const tmpVectors = BoundingBox._TmpVector3;\r\n const diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);\r\n const len = diff.length();\r\n diff.normalizeFromLength(len);\r\n const distance = len * factor;\r\n const newRadius = diff.scaleInPlace(distance * 0.5);\r\n\r\n const min = this.center.subtractToRef(newRadius, tmpVectors[1]);\r\n const max = this.center.addToRef(newRadius, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _update(world: DeepImmutable<Matrix>): void {\r\n const minWorld = this.minimumWorld;\r\n const maxWorld = this.maximumWorld;\r\n const directions = this.directions;\r\n const vectorsWorld = this.vectorsWorld;\r\n const vectors = this.vectors;\r\n\r\n if (!world.isIdentity()) {\r\n minWorld.setAll(Number.MAX_VALUE);\r\n maxWorld.setAll(-Number.MAX_VALUE);\r\n\r\n for (let index = 0; index < 8; ++index) {\r\n const v = vectorsWorld[index];\r\n Vector3.TransformCoordinatesToRef(vectors[index], world, v);\r\n minWorld.minimizeInPlace(v);\r\n maxWorld.maximizeInPlace(v);\r\n }\r\n\r\n // Extend\r\n maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);\r\n maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);\r\n } else {\r\n minWorld.copyFrom(this.minimum);\r\n maxWorld.copyFrom(this.maximum);\r\n for (let index = 0; index < 8; ++index) {\r\n vectorsWorld[index].copyFrom(vectors[index]);\r\n }\r\n\r\n // Extend\r\n this.extendSizeWorld.copyFrom(this.extendSize);\r\n this.centerWorld.copyFrom(this.center);\r\n }\r\n\r\n Vector3.FromArrayToRef(world.m, 0, directions[0]);\r\n Vector3.FromArrayToRef(world.m, 4, directions[1]);\r\n Vector3.FromArrayToRef(world.m, 8, directions[2]);\r\n\r\n this._worldMatrix = world;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box is entirely inside the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding box\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding box\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const min = this.minimumWorld;\r\n const max = this.maximumWorld;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n const pointX = point.x,\r\n pointY = point.y,\r\n pointZ = point.z;\r\n const delta = -Epsilon;\r\n\r\n if (maxX - pointX < delta || delta > pointX - minX) {\r\n return false;\r\n }\r\n\r\n if (maxY - pointY < delta || delta > pointY - minY) {\r\n return false;\r\n }\r\n\r\n if (maxZ - pointZ < delta || delta > pointZ - minZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a bounding sphere\r\n * @param sphere defines the sphere to test\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean {\r\n return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);\r\n }\r\n\r\n /**\r\n * Tests if the bounding box intersects with a box defined by a min and max vectors\r\n * @param min defines the min vector to use\r\n * @param max defines the max vector to use\r\n * @returns true if there is an intersection\r\n */\r\n public intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean {\r\n const myMin = this.minimumWorld;\r\n const myMax = this.maximumWorld;\r\n const myMinX = myMin.x,\r\n myMinY = myMin.y,\r\n myMinZ = myMin.z,\r\n myMaxX = myMax.x,\r\n myMaxY = myMax.y,\r\n myMaxZ = myMax.z;\r\n const minX = min.x,\r\n minY = min.y,\r\n minZ = min.z,\r\n maxX = max.x,\r\n maxY = max.y,\r\n maxZ = max.z;\r\n if (myMaxX < minX || myMinX > maxX) {\r\n return false;\r\n }\r\n\r\n if (myMaxY < minY || myMinY > maxY) {\r\n return false;\r\n }\r\n\r\n if (myMaxZ < minZ || myMinZ > maxZ) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Disposes the resources of the class\r\n */\r\n public dispose(): void {\r\n this._drawWrapperFront?.dispose();\r\n this._drawWrapperBack?.dispose();\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Tests if two bounding boxes are intersections\r\n * @param box0 defines the first box to test\r\n * @param box1 defines the second box to test\r\n * @returns true if there is an intersection\r\n */\r\n public static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean {\r\n return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defines by a min/max vectors intersects a sphere\r\n * @param minPoint defines the minimum vector of the bounding box\r\n * @param maxPoint defines the maximum vector of the bounding box\r\n * @param sphereCenter defines the sphere center\r\n * @param sphereRadius defines the sphere radius\r\n * @returns true if there is an intersection\r\n */\r\n public static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean {\r\n const vector = BoundingBox._TmpVector3[0];\r\n Vector3.ClampToRef(sphereCenter, minPoint, maxPoint, vector);\r\n const num = Vector3.DistanceSquared(sphereCenter, vector);\r\n return num <= sphereRadius * sphereRadius;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an inclusion\r\n */\r\n public static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a bounding box defined with 8 vectors intersects frustum planes\r\n * @param boundingVectors defines an array of 8 vectors representing a bounding box\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n for (let p = 0; p < 6; ++p) {\r\n let canReturnFalse = true;\r\n const frustumPlane = frustumPlanes[p];\r\n for (let i = 0; i < 8; ++i) {\r\n if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {\r\n canReturnFalse = false;\r\n break;\r\n }\r\n }\r\n if (canReturnFalse) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import { ArrayTools } from "../Misc/arrayTools.js";
1
+ import { BuildArray } from "../Misc/arrayTools.js";
2
2
  import { TmpVectors } from "../Maths/math.vector.js";
3
3
  import { Vector3 } from "../Maths/math.vector.js";
4
4
 
@@ -262,5 +262,5 @@ export class BoundingInfo {
262
262
  return true;
263
263
  }
264
264
  }
265
- BoundingInfo._TmpVector3 = ArrayTools.BuildArray(2, Vector3.Zero);
265
+ BoundingInfo._TmpVector3 = BuildArray(2, Vector3.Zero);
266
266
  //# sourceMappingURL=boundingInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"boundingInfo.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,U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I,CAAC,EAAE;YACjF,OAAO,KAAK,CAAC;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;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;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;;AAjRuB,wBAAW,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAAzC,CAA0C","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\nimport type { Collider } from \"../Collisions/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"]}
1
+ {"version":3,"file":"boundingInfo.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,UAAU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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;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;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;;AAjRuB,wBAAW,GAAG,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAA9B,CAA+B","sourcesContent":["import type { DeepImmutable } from \"../types\";\r\nimport { BuildArray } 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\nimport type { Collider } from \"../Collisions/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 = 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"]}
@@ -1,4 +1,4 @@
1
- import { ArrayTools } from "../Misc/arrayTools.js";
1
+ import { BuildArray } from "../Misc/arrayTools.js";
2
2
  import { Matrix, Vector3 } from "../Maths/math.vector.js";
3
3
  /**
4
4
  * Class used to store bounding sphere information
@@ -160,5 +160,5 @@ export class BoundingSphere {
160
160
  return sphere;
161
161
  }
162
162
  }
163
- BoundingSphere._TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero);
163
+ BoundingSphere._TmpVector3 = BuildArray(3, Vector3.Zero);
164
164
  //# sourceMappingURL=boundingSphere.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"boundingSphere.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingSphere.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,cAAc;IA6BvB;;;;;OAKG;IACH,YAAY,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAlCzG;;WAEG;QACa,WAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAKxC;;WAEG;QACa,gBAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAK7C;;WAEG;QACa,YAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QACzC;;WAEG;QACa,YAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAYrC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACI,WAAW,CAAC,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAC5G,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAE3B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAE5C,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,QAAQ,GAAG,GAAG,CAAC;QAE7B,IAAI,CAAC,OAAO,CAAC,WAAW,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AAW,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAAzC,CAA0C","sourcesContent":["import type { DeepImmutable } from \"../types\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\n/**\r\n * Class used to store bounding sphere information\r\n */\r\nexport class BoundingSphere {\r\n /**\r\n * Gets the center of the bounding sphere in local space\r\n */\r\n public readonly center = Vector3.Zero();\r\n /**\r\n * Radius of the bounding sphere in local space\r\n */\r\n public radius: number;\r\n /**\r\n * Gets the center of the bounding sphere in world space\r\n */\r\n public readonly centerWorld = Vector3.Zero();\r\n /**\r\n * Radius of the bounding sphere in world space\r\n */\r\n public radiusWorld: number;\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * Creates a new bounding sphere\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n /**\r\n * Recreates the entire bounding sphere 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.minimum.copyFrom(min);\r\n this.maximum.copyFrom(max);\r\n\r\n const distance = Vector3.Distance(min, max);\r\n\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n this.radius = distance * 0.5;\r\n\r\n this._update(worldMatrix || Matrix.IdentityReadOnly);\r\n }\r\n\r\n /**\r\n * Scale the current bounding sphere by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingSphere {\r\n const newRadius = this.radius * factor;\r\n const tmpVectors = BoundingSphere._TmpVector3;\r\n const tempRadiusVector = tmpVectors[0].setAll(newRadius);\r\n const min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);\r\n const max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n // Methods\r\n /**\r\n * @internal\r\n */\r\n public _update(worldMatrix: DeepImmutable<Matrix>): void {\r\n if (!worldMatrix.isIdentity()) {\r\n Vector3.TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);\r\n const tempVector = BoundingSphere._TmpVector3[0];\r\n Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);\r\n this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;\r\n } else {\r\n this.centerWorld.copyFrom(this.center);\r\n this.radiusWorld = this.radius;\r\n }\r\n }\r\n\r\n /**\r\n * Tests if the bounding sphere is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n const center = this.centerWorld;\r\n const radius = this.radiusWorld;\r\n for (let i = 0; i < 6; i++) {\r\n if (frustumPlanes[i].dotCoordinate(center) <= -radius) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding sphere center is in between the frustum planes.\r\n * Used for optimistic fast inclusion.\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if the sphere center is in between the frustum planes\r\n */\r\n public isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n const center = this.centerWorld;\r\n for (let i = 0; i < 6; i++) {\r\n if (frustumPlanes[i].dotCoordinate(center) < 0) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding sphere\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding sphere\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const squareDistance = Vector3.DistanceSquared(this.centerWorld, point);\r\n if (this.radiusWorld * this.radiusWorld < squareDistance) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Checks if two sphere intersect\r\n * @param sphere0 sphere 0\r\n * @param sphere1 sphere 1\r\n * @returns true if the spheres intersect\r\n */\r\n public static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean {\r\n const squareDistance = Vector3.DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);\r\n const radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;\r\n\r\n if (radiusSum * radiusSum < squareDistance) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates a sphere from a center and a radius\r\n * @param center The center\r\n * @param radius radius\r\n * @param matrix Optional worldMatrix\r\n * @returns The sphere\r\n */\r\n public static CreateFromCenterAndRadius(center: DeepImmutable<Vector3>, radius: number, matrix?: DeepImmutable<Matrix>): BoundingSphere {\r\n this._TmpVector3[0].copyFrom(center);\r\n this._TmpVector3[1].copyFromFloats(0, 0, radius);\r\n this._TmpVector3[2].copyFrom(center);\r\n this._TmpVector3[0].addInPlace(this._TmpVector3[1]);\r\n this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);\r\n\r\n const sphere = new BoundingSphere(this._TmpVector3[0], this._TmpVector3[2]);\r\n\r\n if (matrix) {\r\n sphere._worldMatrix = matrix;\r\n } else {\r\n sphere._worldMatrix = Matrix.Identity();\r\n }\r\n\r\n return sphere;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"boundingSphere.js","sourceRoot":"","sources":["../../../../dev/core/src/Culling/boundingSphere.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,cAAc;IA6BvB;;;;;OAKG;IACH,YAAY,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAlCzG;;WAEG;QACa,WAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAKxC;;WAEG;QACa,gBAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAK7C;;WAEG;QACa,YAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QACzC;;WAEG;QACa,YAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAYrC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACI,WAAW,CAAC,GAA2B,EAAE,GAA2B,EAAE,WAAmC;QAC5G,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAE3B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAE5C,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,QAA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AAC;SAC3C;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;;AA9JuB,0BAAW,GAAG,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,AAA9B,CAA+B","sourcesContent":["import type { DeepImmutable } from \"../types\";\r\nimport { BuildArray } from \"../Misc/arrayTools\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\n/**\r\n * Class used to store bounding sphere information\r\n */\r\nexport class BoundingSphere {\r\n /**\r\n * Gets the center of the bounding sphere in local space\r\n */\r\n public readonly center = Vector3.Zero();\r\n /**\r\n * Radius of the bounding sphere in local space\r\n */\r\n public radius: number;\r\n /**\r\n * Gets the center of the bounding sphere in world space\r\n */\r\n public readonly centerWorld = Vector3.Zero();\r\n /**\r\n * Radius of the bounding sphere in world space\r\n */\r\n public radiusWorld: number;\r\n /**\r\n * Gets the minimum vector in local space\r\n */\r\n public readonly minimum = Vector3.Zero();\r\n /**\r\n * Gets the maximum vector in local space\r\n */\r\n public readonly maximum = Vector3.Zero();\r\n\r\n private _worldMatrix: DeepImmutable<Matrix>;\r\n private static readonly _TmpVector3 = BuildArray(3, Vector3.Zero);\r\n\r\n /**\r\n * Creates a new bounding sphere\r\n * @param min defines the minimum vector (in local space)\r\n * @param max defines the maximum vector (in local space)\r\n * @param worldMatrix defines the new world matrix\r\n */\r\n constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>) {\r\n this.reConstruct(min, max, worldMatrix);\r\n }\r\n\r\n /**\r\n * Recreates the entire bounding sphere 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.minimum.copyFrom(min);\r\n this.maximum.copyFrom(max);\r\n\r\n const distance = Vector3.Distance(min, max);\r\n\r\n max.addToRef(min, this.center).scaleInPlace(0.5);\r\n this.radius = distance * 0.5;\r\n\r\n this._update(worldMatrix || Matrix.IdentityReadOnly);\r\n }\r\n\r\n /**\r\n * Scale the current bounding sphere by applying a scale factor\r\n * @param factor defines the scale factor to apply\r\n * @returns the current bounding box\r\n */\r\n public scale(factor: number): BoundingSphere {\r\n const newRadius = this.radius * factor;\r\n const tmpVectors = BoundingSphere._TmpVector3;\r\n const tempRadiusVector = tmpVectors[0].setAll(newRadius);\r\n const min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);\r\n const max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);\r\n\r\n this.reConstruct(min, max, this._worldMatrix);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the world matrix of the bounding box\r\n * @returns a matrix\r\n */\r\n public getWorldMatrix(): DeepImmutable<Matrix> {\r\n return this._worldMatrix;\r\n }\r\n\r\n // Methods\r\n /**\r\n * @internal\r\n */\r\n public _update(worldMatrix: DeepImmutable<Matrix>): void {\r\n if (!worldMatrix.isIdentity()) {\r\n Vector3.TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);\r\n const tempVector = BoundingSphere._TmpVector3[0];\r\n Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);\r\n this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;\r\n } else {\r\n this.centerWorld.copyFrom(this.center);\r\n this.radiusWorld = this.radius;\r\n }\r\n }\r\n\r\n /**\r\n * Tests if the bounding sphere is intersecting the frustum planes\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if there is an intersection\r\n */\r\n public isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n const center = this.centerWorld;\r\n const radius = this.radiusWorld;\r\n for (let i = 0; i < 6; i++) {\r\n if (frustumPlanes[i].dotCoordinate(center) <= -radius) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if the bounding sphere center is in between the frustum planes.\r\n * Used for optimistic fast inclusion.\r\n * @param frustumPlanes defines the frustum planes to test\r\n * @returns true if the sphere center is in between the frustum planes\r\n */\r\n public isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean {\r\n const center = this.centerWorld;\r\n for (let i = 0; i < 6; i++) {\r\n if (frustumPlanes[i].dotCoordinate(center) < 0) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Tests if a point is inside the bounding sphere\r\n * @param point defines the point to test\r\n * @returns true if the point is inside the bounding sphere\r\n */\r\n public intersectsPoint(point: DeepImmutable<Vector3>): boolean {\r\n const squareDistance = Vector3.DistanceSquared(this.centerWorld, point);\r\n if (this.radiusWorld * this.radiusWorld < squareDistance) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Checks if two sphere intersect\r\n * @param sphere0 sphere 0\r\n * @param sphere1 sphere 1\r\n * @returns true if the spheres intersect\r\n */\r\n public static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean {\r\n const squareDistance = Vector3.DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);\r\n const radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;\r\n\r\n if (radiusSum * radiusSum < squareDistance) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates a sphere from a center and a radius\r\n * @param center The center\r\n * @param radius radius\r\n * @param matrix Optional worldMatrix\r\n * @returns The sphere\r\n */\r\n public static CreateFromCenterAndRadius(center: DeepImmutable<Vector3>, radius: number, matrix?: DeepImmutable<Matrix>): BoundingSphere {\r\n this._TmpVector3[0].copyFrom(center);\r\n this._TmpVector3[1].copyFromFloats(0, 0, radius);\r\n this._TmpVector3[2].copyFrom(center);\r\n this._TmpVector3[0].addInPlace(this._TmpVector3[1]);\r\n this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);\r\n\r\n const sphere = new BoundingSphere(this._TmpVector3[0], this._TmpVector3[2]);\r\n\r\n if (matrix) {\r\n sphere._worldMatrix = matrix;\r\n } else {\r\n sphere._worldMatrix = Matrix.Identity();\r\n }\r\n\r\n return sphere;\r\n }\r\n}\r\n"]}
package/Culling/ray.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ArrayTools } from "../Misc/arrayTools.js";
1
+ import { BuildArray } from "../Misc/arrayTools.js";
2
2
  import { Matrix, Vector3, TmpVectors } from "../Maths/math.vector.js";
3
3
  import { PickingInfo } from "../Collisions/pickingInfo.js";
4
4
  import { IntersectionInfo } from "../Collisions/intersectionInfo.js";
@@ -558,7 +558,7 @@ export class Ray {
558
558
  this.direction.normalize();
559
559
  }
560
560
  }
561
- Ray._TmpVector3 = ArrayTools.BuildArray(6, Vector3.Zero);
561
+ Ray._TmpVector3 = BuildArray(6, Vector3.Zero);
562
562
  Ray._RayDistant = Ray.Zero();
563
563
  Ray._Smallnum = 0.00000001;
564
564
  Ray._Rayl = 10e8;