pickingInfo.d.ts 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import type { Nullable } from "../types";
  2. import { Vector3, Vector2 } from "../Maths/math.vector";
  3. import type { AbstractMesh } from "../Meshes/abstractMesh";
  4. import type { TransformNode } from "../Meshes/transformNode";
  5. import type { Sprite } from "../Sprites/sprite";
  6. import type { Ray } from "../Culling/ray";
  7. /**
  8. * Information about the result of picking within a scene
  9. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/picking_collisions
  10. */
  11. export declare class PickingInfo {
  12. /**
  13. * If the pick collided with an object
  14. */
  15. hit: boolean;
  16. /**
  17. * Distance away where the pick collided
  18. */
  19. distance: number;
  20. /**
  21. * The location of pick collision
  22. */
  23. pickedPoint: Nullable<Vector3>;
  24. /**
  25. * The mesh corresponding the pick collision
  26. */
  27. pickedMesh: Nullable<AbstractMesh>;
  28. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  29. bu: number;
  30. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  31. bv: number;
  32. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  33. faceId: number;
  34. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  35. subMeshFaceId: number;
  36. /** Id of the submesh that was picked */
  37. subMeshId: number;
  38. /** If a sprite was picked, this will be the sprite the pick collided with */
  39. pickedSprite: Nullable<Sprite>;
  40. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  41. thinInstanceIndex: number;
  42. /**
  43. * The ray that was used to perform the picking.
  44. */
  45. ray: Nullable<Ray>;
  46. /**
  47. * If a mesh was used to do the picking (eg. 6dof controller) as a "near interaction", this will be populated.
  48. */
  49. originMesh: Nullable<AbstractMesh>;
  50. /**
  51. * The aim-space transform of the input used for picking, if it is an XR input source.
  52. */
  53. aimTransform: Nullable<TransformNode>;
  54. /**
  55. * The grip-space transform of the input used for picking, if it is an XR input source.
  56. * Some XR sources, such as input coming from head mounted displays, do not have this.
  57. */
  58. gripTransform: Nullable<TransformNode>;
  59. /**
  60. * Gets the normal corresponding to the face the pick collided with
  61. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  62. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map (default: true)
  63. * @returns The normal corresponding to the face the pick collided with
  64. * @remarks Note that the returned normal will always point towards the picking ray.
  65. */
  66. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  67. /**
  68. * Gets the texture coordinates of where the pick occurred
  69. * @param uvSet The UV set to use to calculate the texture coordinates (default: VertexBuffer.UVKind)
  70. * @returns The vector containing the coordinates of the texture
  71. */
  72. getTextureCoordinates(uvSet?: string): Nullable<Vector2>;
  73. }