boundingBox.d.ts 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. import type { DeepImmutable, Nullable } from "../types";
  2. import { Matrix, Vector3 } from "../Maths/math.vector";
  3. import type { BoundingSphere } from "../Culling/boundingSphere";
  4. import type { ICullable } from "./boundingInfo";
  5. import type { Plane } from "../Maths/math.plane";
  6. import type { DrawWrapper } from "../Materials/drawWrapper";
  7. /**
  8. * Class used to store bounding box information
  9. */
  10. export declare class BoundingBox implements ICullable {
  11. /**
  12. * Gets the 8 vectors representing the bounding box in local space
  13. */
  14. readonly vectors: Vector3[];
  15. /**
  16. * Gets the center of the bounding box in local space
  17. */
  18. readonly center: Vector3;
  19. /**
  20. * Gets the center of the bounding box in world space
  21. */
  22. readonly centerWorld: Vector3;
  23. /**
  24. * Gets the extend size in local space
  25. */
  26. readonly extendSize: Vector3;
  27. /**
  28. * Gets the extend size in world space
  29. */
  30. readonly extendSizeWorld: Vector3;
  31. /**
  32. * Gets the OBB (object bounding box) directions
  33. */
  34. readonly directions: Vector3[];
  35. /**
  36. * Gets the 8 vectors representing the bounding box in world space
  37. */
  38. readonly vectorsWorld: Vector3[];
  39. /**
  40. * Gets the minimum vector in world space
  41. */
  42. readonly minimumWorld: Vector3;
  43. /**
  44. * Gets the maximum vector in world space
  45. */
  46. readonly maximumWorld: Vector3;
  47. /**
  48. * Gets the minimum vector in local space
  49. */
  50. readonly minimum: Vector3;
  51. /**
  52. * Gets the maximum vector in local space
  53. */
  54. readonly maximum: Vector3;
  55. private _worldMatrix;
  56. private static readonly _TmpVector3;
  57. /**
  58. * @internal
  59. */
  60. _tag: number;
  61. /** @internal */
  62. _drawWrapperFront: Nullable<DrawWrapper>;
  63. /** @internal */
  64. _drawWrapperBack: Nullable<DrawWrapper>;
  65. /**
  66. * Creates a new bounding box
  67. * @param min defines the minimum vector (in local space)
  68. * @param max defines the maximum vector (in local space)
  69. * @param worldMatrix defines the new world matrix
  70. */
  71. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72. /**
  73. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74. * @param min defines the new minimum vector (in local space)
  75. * @param max defines the new maximum vector (in local space)
  76. * @param worldMatrix defines the new world matrix
  77. */
  78. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79. /**
  80. * Scale the current bounding box by applying a scale factor
  81. * @param factor defines the scale factor to apply
  82. * @returns the current bounding box
  83. */
  84. scale(factor: number): BoundingBox;
  85. /**
  86. * Gets the world matrix of the bounding box
  87. * @returns a matrix
  88. */
  89. getWorldMatrix(): DeepImmutable<Matrix>;
  90. /**
  91. * @internal
  92. */
  93. _update(world: DeepImmutable<Matrix>): void;
  94. /**
  95. * Tests if the bounding box is intersecting the frustum planes
  96. * @param frustumPlanes defines the frustum planes to test
  97. * @returns true if there is an intersection
  98. */
  99. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  100. /**
  101. * Tests if the bounding box is entirely inside the frustum planes
  102. * @param frustumPlanes defines the frustum planes to test
  103. * @returns true if there is an inclusion
  104. */
  105. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  106. /**
  107. * Tests if a point is inside the bounding box
  108. * @param point defines the point to test
  109. * @returns true if the point is inside the bounding box
  110. */
  111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  112. /**
  113. * Tests if the bounding box intersects with a bounding sphere
  114. * @param sphere defines the sphere to test
  115. * @returns true if there is an intersection
  116. */
  117. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  118. /**
  119. * Tests if the bounding box intersects with a box defined by a min and max vectors
  120. * @param min defines the min vector to use
  121. * @param max defines the max vector to use
  122. * @returns true if there is an intersection
  123. */
  124. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  125. /**
  126. * Disposes the resources of the class
  127. */
  128. dispose(): void;
  129. /**
  130. * Tests if two bounding boxes are intersections
  131. * @param box0 defines the first box to test
  132. * @param box1 defines the second box to test
  133. * @returns true if there is an intersection
  134. */
  135. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  136. /**
  137. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  138. * @param minPoint defines the minimum vector of the bounding box
  139. * @param maxPoint defines the maximum vector of the bounding box
  140. * @param sphereCenter defines the sphere center
  141. * @param sphereRadius defines the sphere radius
  142. * @returns true if there is an intersection
  143. */
  144. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  145. /**
  146. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  147. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  148. * @param frustumPlanes defines the frustum planes to test
  149. * @returns true if there is an inclusion
  150. */
  151. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  152. /**
  153. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  154. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  155. * @param frustumPlanes defines the frustum planes to test
  156. * @returns true if there is an intersection
  157. */
  158. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  159. }