planeRotationGizmo.d.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import type { Observer } from "../Misc/observable";
  2. import { Observable } from "../Misc/observable";
  3. import type { Nullable } from "../types";
  4. import type { PointerInfo } from "../Events/pointerEvents";
  5. import { Vector3 } from "../Maths/math.vector";
  6. import { Color3 } from "../Maths/math.color";
  7. import "../Meshes/Builders/linesBuilder";
  8. import type { AbstractMesh } from "../Meshes/abstractMesh";
  9. import { Mesh } from "../Meshes/mesh";
  10. import type { Node } from "../node";
  11. import { PointerDragBehavior } from "../Behaviors/Meshes/pointerDragBehavior";
  12. import type { IGizmo } from "./gizmo";
  13. import { Gizmo } from "./gizmo";
  14. import { UtilityLayerRenderer } from "../Rendering/utilityLayerRenderer";
  15. import { StandardMaterial } from "../Materials/standardMaterial";
  16. import type { RotationGizmo } from "./rotationGizmo";
  17. import { ShaderMaterial } from "../Materials/shaderMaterial";
  18. /**
  19. * Interface for plane rotation gizmo
  20. */
  21. export interface IPlaneRotationGizmo extends IGizmo {
  22. /** Drag behavior responsible for the gizmos dragging interactions */
  23. dragBehavior: PointerDragBehavior;
  24. /** Drag distance in babylon units that the gizmo will snap to when dragged */
  25. snapDistance: number;
  26. /** Sensitivity factor for dragging */
  27. sensitivity: number;
  28. /**
  29. * Event that fires each time the gizmo snaps to a new location.
  30. * * snapDistance is the change in distance
  31. */
  32. onSnapObservable: Observable<{
  33. snapDistance: number;
  34. }>;
  35. /** Accumulated relative angle value for rotation on the axis. */
  36. angle: number;
  37. /** If the gizmo is enabled */
  38. isEnabled: boolean;
  39. /** Default material used to render when gizmo is not disabled or hovered */
  40. coloredMaterial: StandardMaterial;
  41. /** Material used to render when gizmo is hovered with mouse */
  42. hoverMaterial: StandardMaterial;
  43. /** Color used to render the drag angle sector when gizmo is rotated with mouse */
  44. rotationColor: Color3;
  45. /** Material used to render when gizmo is disabled. typically grey. */
  46. disableMaterial: StandardMaterial;
  47. }
  48. /**
  49. * Single plane rotation gizmo
  50. */
  51. export declare class PlaneRotationGizmo extends Gizmo implements IPlaneRotationGizmo {
  52. /**
  53. * Drag behavior responsible for the gizmos dragging interactions
  54. */
  55. dragBehavior: PointerDragBehavior;
  56. protected _pointerObserver: Nullable<Observer<PointerInfo>>;
  57. /**
  58. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59. */
  60. snapDistance: number;
  61. /**
  62. * Event that fires each time the gizmo snaps to a new location.
  63. * * snapDistance is the change in distance
  64. */
  65. onSnapObservable: Observable<{
  66. snapDistance: number;
  67. }>;
  68. /**
  69. * The maximum angle between the camera and the rotation allowed for interaction
  70. * If a rotation plane appears 'flat', a lower value allows interaction.
  71. */
  72. static MaxDragAngle: number;
  73. /**
  74. * Accumulated relative angle value for rotation on the axis. Reset to 0 when a dragStart occurs
  75. */
  76. angle: number;
  77. /**
  78. * Custom sensitivity value for the drag strength
  79. */
  80. sensitivity: number;
  81. /** Default material used to render when gizmo is not disabled or hovered */
  82. get coloredMaterial(): StandardMaterial;
  83. /** Material used to render when gizmo is hovered with mouse */
  84. get hoverMaterial(): StandardMaterial;
  85. /** Color used to render the drag angle sector when gizmo is rotated with mouse */
  86. set rotationColor(color: Color3);
  87. /** Material used to render when gizmo is disabled. typically grey. */
  88. get disableMaterial(): StandardMaterial;
  89. protected _isEnabled: boolean;
  90. protected _parent: Nullable<RotationGizmo>;
  91. protected _coloredMaterial: StandardMaterial;
  92. protected _hoverMaterial: StandardMaterial;
  93. protected _disableMaterial: StandardMaterial;
  94. protected _gizmoMesh: Mesh;
  95. protected _rotationDisplayPlane: Mesh;
  96. protected _dragging: boolean;
  97. protected _angles: Vector3;
  98. protected static _RotationGizmoVertexShader: string;
  99. protected static _RotationGizmoFragmentShader: string;
  100. protected _rotationShaderMaterial: ShaderMaterial;
  101. /**
  102. * Creates a PlaneRotationGizmo
  103. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  104. * @param color The color of the gizmo
  105. * @param gizmoLayer The utility layer the gizmo will be added to
  106. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107. * @param parent
  108. * @param useEulerRotation Use and update Euler angle instead of quaternion
  109. * @param thickness display gizmo axis thickness
  110. * @param hoverColor The color of the gizmo when hovering over and dragging
  111. * @param disableColor The Color of the gizmo when its disabled
  112. */
  113. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number, hoverColor?: Color3, disableColor?: Color3);
  114. /**
  115. * @internal
  116. * Create Geometry for Gizmo
  117. * @param parentMesh
  118. * @param thickness
  119. * @param tessellation
  120. * @returns
  121. */
  122. protected _createGizmoMesh(parentMesh: AbstractMesh, thickness: number, tessellation: number): {
  123. rotationMesh: Mesh;
  124. collider: Mesh;
  125. };
  126. protected _attachedNodeChanged(value: Nullable<Node>): void;
  127. /**
  128. * If the gizmo is enabled
  129. */
  130. set isEnabled(value: boolean);
  131. get isEnabled(): boolean;
  132. /**
  133. * Disposes of the gizmo
  134. */
  135. dispose(): void;
  136. }