UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

137 lines (136 loc) 5.69 kB
import type { Observer } from "../Misc/observable.js"; import { Observable } from "../Misc/observable.js"; import type { Nullable } from "../types.js"; import type { PointerInfo } from "../Events/pointerEvents.js"; import { Vector3 } from "../Maths/math.vector.js"; import { Color3 } from "../Maths/math.color.js"; import "../Meshes/Builders/linesBuilder.js"; import type { AbstractMesh } from "../Meshes/abstractMesh.js"; import { Mesh } from "../Meshes/mesh.js"; import type { Node } from "../node.js"; import { PointerDragBehavior } from "../Behaviors/Meshes/pointerDragBehavior.js"; import type { IGizmo } from "./gizmo.js"; import { Gizmo } from "./gizmo.js"; import { UtilityLayerRenderer } from "../Rendering/utilityLayerRenderer.js"; import { StandardMaterial } from "../Materials/standardMaterial.js"; import type { RotationGizmo } from "./rotationGizmo.js"; import { ShaderMaterial } from "../Materials/shaderMaterial.js"; /** * Interface for plane rotation gizmo */ export interface IPlaneRotationGizmo extends IGizmo { /** Drag behavior responsible for the gizmos dragging interactions */ dragBehavior: PointerDragBehavior; /** Drag distance in babylon units that the gizmo will snap to when dragged */ snapDistance: number; /** Sensitivity factor for dragging */ sensitivity: number; /** * Event that fires each time the gizmo snaps to a new location. * * snapDistance is the change in distance */ onSnapObservable: Observable<{ snapDistance: number; }>; /** Accumulated relative angle value for rotation on the axis. */ angle: number; /** If the gizmo is enabled */ isEnabled: boolean; /** Default material used to render when gizmo is not disabled or hovered */ coloredMaterial: StandardMaterial; /** Material used to render when gizmo is hovered with mouse */ hoverMaterial: StandardMaterial; /** Color used to render the drag angle sector when gizmo is rotated with mouse */ rotationColor: Color3; /** Material used to render when gizmo is disabled. typically grey. */ disableMaterial: StandardMaterial; } /** * Single plane rotation gizmo */ export declare class PlaneRotationGizmo extends Gizmo implements IPlaneRotationGizmo { /** * Drag behavior responsible for the gizmos dragging interactions */ dragBehavior: PointerDragBehavior; protected _pointerObserver: Nullable<Observer<PointerInfo>>; /** * Rotation distance in radians that the gizmo will snap to (Default: 0) */ snapDistance: number; /** * Event that fires each time the gizmo snaps to a new location. * * snapDistance is the change in distance */ onSnapObservable: Observable<{ snapDistance: number; }>; /** * The maximum angle between the camera and the rotation allowed for interaction * If a rotation plane appears 'flat', a lower value allows interaction. */ static MaxDragAngle: number; /** * Accumulated relative angle value for rotation on the axis. Reset to 0 when a dragStart occurs */ angle: number; /** * Custom sensitivity value for the drag strength */ sensitivity: number; /** Default material used to render when gizmo is not disabled or hovered */ get coloredMaterial(): StandardMaterial; /** Material used to render when gizmo is hovered with mouse */ get hoverMaterial(): StandardMaterial; /** Color used to render the drag angle sector when gizmo is rotated with mouse */ set rotationColor(color: Color3); /** Material used to render when gizmo is disabled. typically grey. */ get disableMaterial(): StandardMaterial; protected _isEnabled: boolean; protected _parent: Nullable<RotationGizmo>; protected _coloredMaterial: StandardMaterial; protected _hoverMaterial: StandardMaterial; protected _disableMaterial: StandardMaterial; protected _gizmoMesh: Mesh; protected _rotationDisplayPlane: Mesh; protected _dragging: boolean; protected _angles: Vector3; protected static _RotationGizmoVertexShader: string; protected static _RotationGizmoFragmentShader: string; protected _rotationShaderMaterial: ShaderMaterial; /** * Creates a PlaneRotationGizmo * @param planeNormal The normal of the plane which the gizmo will be able to rotate on * @param color The color of the gizmo * @param gizmoLayer The utility layer the gizmo will be added to * @param tessellation Amount of tessellation to be used when creating rotation circles * @param parent * @param useEulerRotation Use and update Euler angle instead of quaternion * @param thickness display gizmo axis thickness * @param hoverColor The color of the gizmo when hovering over and dragging * @param disableColor The Color of the gizmo when its disabled */ constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number, hoverColor?: Color3, disableColor?: Color3); /** * @internal * Create Geometry for Gizmo * @param parentMesh * @param thickness * @param tessellation * @returns */ protected _createGizmoMesh(parentMesh: AbstractMesh, thickness: number, tessellation: number): { rotationMesh: Mesh; collider: Mesh; }; protected _attachedNodeChanged(value: Nullable<Node>): void; /** * If the gizmo is enabled */ set isEnabled(value: boolean); get isEnabled(): boolean; /** * Disposes of the gizmo */ dispose(): void; }