rayHelper.d.ts 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import type { Nullable } from "../types";
  2. import type { Ray } from "../Culling/ray";
  3. import { Vector3 } from "../Maths/math.vector";
  4. import type { Color3 } from "../Maths/math.color";
  5. import type { Scene } from "../scene";
  6. import type { AbstractMesh } from "../Meshes/abstractMesh";
  7. /**
  8. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9. * in order to better appreciate the issue one might have.
  10. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/picking_collisions#debugging
  11. */
  12. export declare class RayHelper {
  13. /**
  14. * Defines the ray we are currently trying to visualize.
  15. */
  16. ray: Nullable<Ray>;
  17. private _renderPoints;
  18. private _renderLine;
  19. private _renderFunction;
  20. private _scene;
  21. private _onAfterRenderObserver;
  22. private _onAfterStepObserver;
  23. private _attachedToMesh;
  24. private _meshSpaceDirection;
  25. private _meshSpaceOrigin;
  26. /**
  27. * Helper function to create a colored helper in a scene in one line.
  28. * @param ray Defines the ray we are currently trying to visualize
  29. * @param scene Defines the scene the ray is used in
  30. * @param color Defines the color we want to see the ray in
  31. * @returns The newly created ray helper.
  32. */
  33. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  34. /**
  35. * Instantiate a new ray helper.
  36. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  37. * in order to better appreciate the issue one might have.
  38. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/picking_collisions#debugging
  39. * @param ray Defines the ray we are currently trying to visualize
  40. */
  41. constructor(ray: Ray);
  42. /**
  43. * Shows the ray we are willing to debug.
  44. * @param scene Defines the scene the ray needs to be rendered in
  45. * @param color Defines the color the ray needs to be rendered in
  46. */
  47. show(scene: Scene, color?: Color3): void;
  48. /**
  49. * Hides the ray we are debugging.
  50. */
  51. hide(): void;
  52. private _render;
  53. /**
  54. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55. * @param mesh Defines the mesh we want the helper attached to
  56. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  57. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58. * @param length Defines the length of the ray
  59. */
  60. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  61. /**
  62. * Detach the ray helper from the mesh it has previously been attached to.
  63. */
  64. detachFromMesh(): void;
  65. private _updateToMesh;
  66. /**
  67. * Dispose the helper and release its associated resources.
  68. */
  69. dispose(): void;
  70. }