/** * Rotates the attached {@link Entity}s with a ring for each axis, plus a ring in the camera's view * plane. Works with mouse, keyboard and touch input. * * ```javascript * const gizmoLayer = Gizmo.createLayer(app); * const gizmo = new RotateGizmo(cameraComponent, gizmoLayer); * gizmo.attach([entity]); * ``` * * Relevant Engine API examples: * * - [Rotate Gizmo](https://playcanvas.github.io/#/gizmos/transform-rotate) * - [Editor](https://playcanvas.github.io/#/misc/editor) * * @category Gizmo */ export class RotateGizmo extends TransformGizmo { /** * Creates a new RotateGizmo object. Use {@link Gizmo.createLayer} to create its layer. * * @param {CameraComponent} camera - The camera component. * @param {Layer} layer - The render layer. * @example * const gizmo = new RotateGizmo(camera, layer); */ constructor(camera: CameraComponent, layer: Layer); _shapes: { z: ArcShape; x: ArcShape; y: ArcShape; f: ArcShape; xyz: SphereShape; }; /** * The angle at the start of a drag. * * @private */ private _selectionStartAngle; /** * The local rotation of each node at the start of a drag. * * @type {Map} * @private */ private _nodeLocalRotations; /** * The world rotation of each node at the start of a drag. * * @type {Map} * @private */ private _nodeRotations; /** * The offset of each node from the gizmo at the start of a drag. * * @type {Map} * @private */ private _nodeOffsets; /** * The pointer position on screen. * * @private */ private _screenPos; /** * The pointer position on screen at the start of a drag. * * @private */ private _screenStartPos; /** * The start point of the angle guide. * * @private */ private _guideAngleStart; /** * The end point of the angle guide. * * @private */ private _guideAngleEnd; /** * The angle guide lines. * * @type {[MeshLine, MeshLine]} * @private */ private _guideAngleLines; /** * The sectors filling the swept angle and, past a full turn, the rest of the circle. * * @type {MeshSector[]} * @private */ private _guideAngleSectors; /** * The world axis the angle guide sweeps around. * * @private */ private _guideAngleAxis; /** * The swept angle in degrees. * * @private */ private _guideAngle; /** * The last facing direction, to skip unneeded updates. * * @private */ private _facingDir; /** * The rotation mode: 'absolute' rotates by the pointer movement from the initial click, and * 'orbit' by the pointer's angle around the gizmo. Defaults to 'absolute'. * * @type {'absolute' | 'orbit'} */ rotationMode: "absolute" | "orbit"; /** * Sets the XYZ tube radius. * * @type {number} */ set xyzTubeRadius(value: number); /** * Gets the XYZ tube radius. * * @type {number} */ get xyzTubeRadius(): number; /** * Sets the XYZ ring radius. * * @type {number} */ set xyzRingRadius(value: number); /** * Gets the XYZ ring radius. * * @type {number} */ get xyzRingRadius(): number; /** * Sets the face tube radius. * * @type {number} */ set faceTubeRadius(value: number); /** * Gets the face tube radius. * * @type {number} */ get faceTubeRadius(): number; /** * Sets the face ring radius. * * @type {number} */ set faceRingRadius(value: number); /** * Gets the face ring radius. * * @type {number} */ get faceRingRadius(): number; /** * Sets the center radius. * * @type {number} */ set centerRadius(value: number); /** * Gets the center radius. * * @type {number} */ get centerRadius(): number; /** * Sets the ring tolerance. * * @type {number} */ set ringTolerance(value: number); /** * Gets the ring tolerance. * * @type {number} */ get ringTolerance(): number; /** * Sets the angle guide line thickness. * * @type {number} */ set angleGuideThickness(value: number); /** * Gets the angle guide line thickness. * * @type {number} */ get angleGuideThickness(): number; /** * @type {boolean} * @deprecated Use {@link rotationMode} instead. * @ignore */ set orbitRotation(value: boolean); /** * @type {boolean} * @deprecated Use {@link rotationMode} instead. * @ignore */ get orbitRotation(): boolean; /** * @param {string} prop - The property. * @param {any} value - The value. * @private */ private _setDiskProp; /** * Shows the angle in the readout, below a sphere around the rings since the rings turn while * dragging. * * @param {number} angle - The angle in degrees. * @private */ private _showAngleReadout; /** * @private */ private _storeGuidePoints; /** * @param {number} angleDelta - The angle delta. * @private */ private _updateGuidePoints; /** * @param {boolean} state - The state. * @private */ private _angleGuide; /** * @private */ private _shapesLookAtCamera; /** * @param {boolean} state - The state. * @private */ private _drag; /** * @private */ private _storeNodeRotations; /** * @param {GizmoAxis} axis - The axis. * @param {Vec3} angleAxis - The angle axis. * @param {number} angleDelta - The angle delta. * @private */ private _setNodeRotations; /** * @param {number} x - The x coordinate. * @param {number} y - The y coordinate. * @returns {Vec3} The point (space is {@link TransformGizmo#coordSpace}). * @protected */ protected _screenToPoint(x: number, y: number): Vec3; /** * @param {Vec3} point - The point. * @param {number} x - The x coordinate. * @param {number} y - The y coordinate. * @returns {number} The angle. * @protected */ protected _calculateArcAngle(point: Vec3, x: number, y: number): number; /** * @param {Vec3} pos - The position. * @param {Quat} rot - The rotation. * @param {GizmoAxis} activeAxis - The active axis. * @param {boolean} activeIsPlane - Whether the active axis is a plane. * @override */ override _drawGuideLines(pos: Vec3, rot: Quat, activeAxis: GizmoAxis, activeIsPlane: boolean): void; } import { TransformGizmo } from './transform-gizmo.js'; import { ArcShape } from '../shape/arc-shape.js'; import { SphereShape } from '../shape/sphere-shape.js'; import { Vec3 } from '../../../core/math/vec3.js'; import { Quat } from '../../../core/math/quat.js'; import type { GizmoAxis } from '../constants.js'; import type { CameraComponent } from '../../../framework/components/camera/component.js'; import type { Layer } from '../../../scene/layer.js';