outlineRenderer.d.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import type { SubMesh } from "../Meshes/subMesh";
  2. import type { _InstancesBatch } from "../Meshes/mesh";
  3. import { Scene } from "../scene";
  4. import type { ISceneComponent } from "../sceneComponent";
  5. import "../Shaders/outline.fragment";
  6. import "../Shaders/outline.vertex";
  7. declare module "../scene" {
  8. interface Scene {
  9. /** @internal */
  10. _outlineRenderer: OutlineRenderer;
  11. /**
  12. * Gets the outline renderer associated with the scene
  13. * @returns a OutlineRenderer
  14. */
  15. getOutlineRenderer(): OutlineRenderer;
  16. }
  17. }
  18. declare module "../Meshes/abstractMesh" {
  19. interface AbstractMesh {
  20. /** @internal (Backing field) */
  21. _renderOutline: boolean;
  22. /**
  23. * Gets or sets a boolean indicating if the outline must be rendered as well
  24. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  25. */
  26. renderOutline: boolean;
  27. /** @internal (Backing field) */
  28. _renderOverlay: boolean;
  29. /**
  30. * Gets or sets a boolean indicating if the overlay must be rendered as well
  31. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  32. */
  33. renderOverlay: boolean;
  34. }
  35. }
  36. /**
  37. * This class is responsible to draw the outline/overlay of meshes.
  38. * It should not be used directly but through the available method on mesh.
  39. */
  40. export declare class OutlineRenderer implements ISceneComponent {
  41. /**
  42. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  43. */
  44. private static _StencilReference;
  45. /**
  46. * The name of the component. Each component must have a unique name.
  47. */
  48. name: string;
  49. /**
  50. * The scene the component belongs to.
  51. */
  52. scene: Scene;
  53. /**
  54. * Defines a zOffset default Factor to prevent zFighting between the overlay and the mesh.
  55. */
  56. zOffset: number;
  57. /**
  58. * Defines a zOffset default Unit to prevent zFighting between the overlay and the mesh.
  59. */
  60. zOffsetUnits: number;
  61. private _engine;
  62. private _savedDepthWrite;
  63. private _passIdForDrawWrapper;
  64. /**
  65. * Instantiates a new outline renderer. (There could be only one per scene).
  66. * @param scene Defines the scene it belongs to
  67. */
  68. constructor(scene: Scene);
  69. /**
  70. * Register the component to one instance of a scene.
  71. */
  72. register(): void;
  73. /**
  74. * Rebuilds the elements related to this component in case of
  75. * context lost for instance.
  76. */
  77. rebuild(): void;
  78. /**
  79. * Disposes the component and the associated resources.
  80. */
  81. dispose(): void;
  82. /**
  83. * Renders the outline in the canvas.
  84. * @param subMesh Defines the sumesh to render
  85. * @param batch Defines the batch of meshes in case of instances
  86. * @param useOverlay Defines if the rendering is for the overlay or the outline
  87. * @param renderPassId Render pass id to use to render the mesh
  88. */
  89. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean, renderPassId?: number): void;
  90. /**
  91. * Returns whether or not the outline renderer is ready for a given submesh.
  92. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  93. * @param subMesh Defines the submesh to check readiness for
  94. * @param useInstances Defines whether wee are trying to render instances or not
  95. * @param renderPassId Render pass id to use to render the mesh
  96. * @returns true if ready otherwise false
  97. */
  98. isReady(subMesh: SubMesh, useInstances: boolean, renderPassId?: number): boolean;
  99. private _beforeRenderingMesh;
  100. private _afterRenderingMesh;
  101. }