boundingBoxRenderer.d.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import { Scene } from "../scene";
  2. import { AbstractMesh } from "../Meshes/abstractMesh";
  3. import { SmartArray } from "../Misc/smartArray";
  4. import type { ISceneComponent } from "../sceneComponent";
  5. import type { BoundingBox } from "../Culling/boundingBox";
  6. import { Color3 } from "../Maths/math.color";
  7. import { Observable } from "../Misc/observable";
  8. import "../Shaders/boundingBoxRenderer.fragment";
  9. import "../Shaders/boundingBoxRenderer.vertex";
  10. declare module "../scene" {
  11. interface Scene {
  12. /** @internal (Backing field) */
  13. _boundingBoxRenderer: BoundingBoxRenderer;
  14. /** @internal (Backing field) */
  15. _forceShowBoundingBoxes: boolean;
  16. /**
  17. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  18. */
  19. forceShowBoundingBoxes: boolean;
  20. /**
  21. * Gets the bounding box renderer associated with the scene
  22. * @returns a BoundingBoxRenderer
  23. */
  24. getBoundingBoxRenderer(): BoundingBoxRenderer;
  25. }
  26. }
  27. declare module "../Meshes/abstractMesh" {
  28. interface AbstractMesh {
  29. /** @internal (Backing field) */
  30. _showBoundingBox: boolean;
  31. /**
  32. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  33. */
  34. showBoundingBox: boolean;
  35. }
  36. }
  37. /**
  38. * Component responsible of rendering the bounding box of the meshes in a scene.
  39. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  40. */
  41. export declare class BoundingBoxRenderer implements ISceneComponent {
  42. /**
  43. * The component name helpful to identify the component in the list of scene components.
  44. */
  45. readonly name = "BoundingBoxRenderer";
  46. /**
  47. * The scene the component belongs to.
  48. */
  49. scene: Scene;
  50. /**
  51. * Color of the bounding box lines placed in front of an object
  52. */
  53. frontColor: Color3;
  54. /**
  55. * Color of the bounding box lines placed behind an object
  56. */
  57. backColor: Color3;
  58. /**
  59. * Defines if the renderer should show the back lines or not
  60. */
  61. showBackLines: boolean;
  62. /**
  63. * Observable raised before rendering a bounding box
  64. */
  65. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  66. /**
  67. * Observable raised after rendering a bounding box
  68. */
  69. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70. /**
  71. * Observable raised after resources are created
  72. */
  73. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  74. /**
  75. * When false, no bounding boxes will be rendered
  76. */
  77. enabled: boolean;
  78. /**
  79. * @internal
  80. */
  81. renderList: SmartArray<BoundingBox>;
  82. private _colorShader;
  83. private _colorShaderForOcclusionQuery;
  84. private _vertexBuffers;
  85. private _indexBuffer;
  86. private _fillIndexBuffer;
  87. private _fillIndexData;
  88. private _uniformBufferFront;
  89. private _uniformBufferBack;
  90. private _renderPassIdForOcclusionQuery;
  91. /**
  92. * Instantiates a new bounding box renderer in a scene.
  93. * @param scene the scene the renderer renders in
  94. */
  95. constructor(scene: Scene);
  96. private _buildUniformLayout;
  97. /**
  98. * Registers the component in a given scene
  99. */
  100. register(): void;
  101. private _evaluateSubMesh;
  102. private _preActiveMesh;
  103. private _prepareResources;
  104. private _createIndexBuffer;
  105. /**
  106. * Rebuilds the elements related to this component in case of
  107. * context lost for instance.
  108. */
  109. rebuild(): void;
  110. /**
  111. * @internal
  112. */
  113. reset(): void;
  114. /**
  115. * Render the bounding boxes of a specific rendering group
  116. * @param renderingGroupId defines the rendering group to render
  117. */
  118. render(renderingGroupId: number): void;
  119. private _createWrappersForBoundingBox;
  120. /**
  121. * In case of occlusion queries, we can render the occlusion bounding box through this method
  122. * @param mesh Define the mesh to render the occlusion bounding box for
  123. */
  124. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  125. /**
  126. * Dispose and release the resources attached to this renderer.
  127. */
  128. dispose(): void;
  129. }