axisScaleGizmo.d.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 type { AbstractMesh } from "../Meshes/abstractMesh";
  7. import type { Node } from "../node";
  8. import { Mesh } from "../Meshes/mesh";
  9. import { StandardMaterial } from "../Materials/standardMaterial";
  10. import { PointerDragBehavior } from "../Behaviors/Meshes/pointerDragBehavior";
  11. import type { IGizmo } from "./gizmo";
  12. import { Gizmo } from "./gizmo";
  13. import { UtilityLayerRenderer } from "../Rendering/utilityLayerRenderer";
  14. import type { ScaleGizmo } from "./scaleGizmo";
  15. import { Color3 } from "../Maths/math.color";
  16. /**
  17. * Interface for axis scale gizmo
  18. */
  19. export interface IAxisScaleGizmo extends IGizmo {
  20. /** Drag behavior responsible for the gizmos dragging interactions */
  21. dragBehavior: PointerDragBehavior;
  22. /** Drag distance in babylon units that the gizmo will snap to when dragged */
  23. snapDistance: number;
  24. /** Incremental snap scaling. When true, with a snapDistance of 0.1, scaling will be 1.1,1.2,1.3 instead of, when false: 1.1,1.21,1.33,... */
  25. incrementalSnap: boolean;
  26. /**
  27. * Event that fires each time the gizmo snaps to a new location.
  28. * * snapDistance is the change in distance
  29. */
  30. onSnapObservable: Observable<{
  31. snapDistance: number;
  32. }>;
  33. /** If the scaling operation should be done on all axis */
  34. uniformScaling: boolean;
  35. /** Custom sensitivity value for the drag strength */
  36. sensitivity: number;
  37. /** The magnitude of the drag strength (scaling factor) */
  38. dragScale: number;
  39. /** If the gizmo is enabled */
  40. isEnabled: boolean;
  41. /** Default material used to render when gizmo is not disabled or hovered */
  42. coloredMaterial: StandardMaterial;
  43. /** Material used to render when gizmo is hovered with mouse*/
  44. hoverMaterial: StandardMaterial;
  45. /** Material used to render when gizmo is disabled. typically grey.*/
  46. disableMaterial: StandardMaterial;
  47. }
  48. /**
  49. * Single axis scale gizmo
  50. */
  51. export declare class AxisScaleGizmo extends Gizmo implements IAxisScaleGizmo {
  52. /**
  53. * Drag behavior responsible for the gizmos dragging interactions
  54. */
  55. dragBehavior: PointerDragBehavior;
  56. protected _pointerObserver: Nullable<Observer<PointerInfo>>;
  57. /**
  58. * Scale distance in babylon units that the gizmo will snap to when dragged (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. * If the scaling operation should be done on all axis (default: false)
  70. */
  71. uniformScaling: boolean;
  72. /**
  73. * Custom sensitivity value for the drag strength
  74. */
  75. sensitivity: number;
  76. /**
  77. * The magnitude of the drag strength (scaling factor)
  78. */
  79. dragScale: number;
  80. /**
  81. * The minimal absolute scale per component. can be positive or negative but never smaller.
  82. */
  83. static MinimumAbsoluteScale: number;
  84. /**
  85. * Incremental snap scaling (default is false). When true, with a snapDistance of 0.1, scaling will be 1.1,1.2,1.3 instead of, when false: 1.1,1.21,1.33,...
  86. */
  87. incrementalSnap: boolean;
  88. protected _isEnabled: boolean;
  89. protected _parent: Nullable<ScaleGizmo>;
  90. protected _gizmoMesh: Mesh;
  91. protected _coloredMaterial: StandardMaterial;
  92. protected _hoverMaterial: StandardMaterial;
  93. protected _disableMaterial: StandardMaterial;
  94. protected _dragging: boolean;
  95. private _tmpVector;
  96. private _incrementalStartupValue;
  97. /** Default material used to render when gizmo is not disabled or hovered */
  98. get coloredMaterial(): StandardMaterial;
  99. /** Material used to render when gizmo is hovered with mouse*/
  100. get hoverMaterial(): StandardMaterial;
  101. /** Material used to render when gizmo is disabled. typically grey.*/
  102. get disableMaterial(): StandardMaterial;
  103. /**
  104. * Creates an AxisScaleGizmo
  105. * @param dragAxis The axis which the gizmo will be able to scale on
  106. * @param color The color of the gizmo
  107. * @param gizmoLayer The utility layer the gizmo will be added to
  108. * @param parent
  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(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number, hoverColor?: Color3, disableColor?: Color3);
  114. /**
  115. * @internal
  116. * Create Geometry for Gizmo
  117. * @param parentMesh
  118. * @param thickness
  119. * @param isCollider
  120. * @returns the gizmo mesh
  121. */
  122. protected _createGizmoMesh(parentMesh: AbstractMesh, thickness: number, isCollider?: boolean): {
  123. arrowMesh: Mesh;
  124. arrowTail: 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. /**
  137. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  138. * @param mesh The mesh to replace the default mesh of the gizmo
  139. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  140. */
  141. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  142. }