boundingSphere.d.ts 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import type { DeepImmutable } from "../types";
  2. import { Matrix, Vector3 } from "../Maths/math.vector";
  3. import type { Plane } from "../Maths/math.plane";
  4. /**
  5. * Class used to store bounding sphere information
  6. */
  7. export declare class BoundingSphere {
  8. /**
  9. * Gets the center of the bounding sphere in local space
  10. */
  11. readonly center: Vector3;
  12. /**
  13. * Radius of the bounding sphere in local space
  14. */
  15. radius: number;
  16. /**
  17. * Gets the center of the bounding sphere in world space
  18. */
  19. readonly centerWorld: Vector3;
  20. /**
  21. * Radius of the bounding sphere in world space
  22. */
  23. radiusWorld: number;
  24. /**
  25. * Gets the minimum vector in local space
  26. */
  27. readonly minimum: Vector3;
  28. /**
  29. * Gets the maximum vector in local space
  30. */
  31. readonly maximum: Vector3;
  32. private _worldMatrix;
  33. private static readonly _TmpVector3;
  34. /**
  35. * Creates a new bounding sphere
  36. * @param min defines the minimum vector (in local space)
  37. * @param max defines the maximum vector (in local space)
  38. * @param worldMatrix defines the new world matrix
  39. */
  40. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  41. /**
  42. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  43. * @param min defines the new minimum vector (in local space)
  44. * @param max defines the new maximum vector (in local space)
  45. * @param worldMatrix defines the new world matrix
  46. */
  47. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  48. /**
  49. * Scale the current bounding sphere by applying a scale factor
  50. * @param factor defines the scale factor to apply
  51. * @returns the current bounding box
  52. */
  53. scale(factor: number): BoundingSphere;
  54. /**
  55. * Gets the world matrix of the bounding box
  56. * @returns a matrix
  57. */
  58. getWorldMatrix(): DeepImmutable<Matrix>;
  59. /**
  60. * @internal
  61. */
  62. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63. /**
  64. * Tests if the bounding sphere is intersecting the frustum planes
  65. * @param frustumPlanes defines the frustum planes to test
  66. * @returns true if there is an intersection
  67. */
  68. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69. /**
  70. * Tests if the bounding sphere center is in between the frustum planes.
  71. * Used for optimistic fast inclusion.
  72. * @param frustumPlanes defines the frustum planes to test
  73. * @returns true if the sphere center is in between the frustum planes
  74. */
  75. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76. /**
  77. * Tests if a point is inside the bounding sphere
  78. * @param point defines the point to test
  79. * @returns true if the point is inside the bounding sphere
  80. */
  81. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82. /**
  83. * Checks if two sphere intersect
  84. * @param sphere0 sphere 0
  85. * @param sphere1 sphere 1
  86. * @returns true if the spheres intersect
  87. */
  88. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  89. /**
  90. * Creates a sphere from a center and a radius
  91. * @param center The center
  92. * @param radius radius
  93. * @param matrix Optional worldMatrix
  94. * @returns The sphere
  95. */
  96. static CreateFromCenterAndRadius(center: DeepImmutable<Vector3>, radius: number, matrix?: DeepImmutable<Matrix>): BoundingSphere;
  97. }