/** * Handles for moving {@link Entity}s: arrows along the X, Y and Z axes, planes between them and a * center sphere that moves in the view plane. Works with mouse, keyboard and touch input. * * ```javascript * // Create a layer for rendering all gizmos * const gizmoLayer = Gizmo.createLayer(app); * * // Create a translate gizmo * const gizmo = new TranslateGizmo(cameraComponent, gizmoLayer); * * // Create an entity to attach the gizmo to * const entity = new Entity(); * entity.addComponent('render', { * type: 'box' * }); * app.root.addChild(entity); * * // Attach the gizmo to the entity * gizmo.attach([entity]); * ``` * * Relevant Engine API examples: * * - [Translate Gizmo](https://playcanvas.github.io/#/gizmos/transform-translate) * - [Editor](https://playcanvas.github.io/#/misc/editor) * * @category Gizmo */ export class TranslateGizmo extends TransformGizmo { /** * Creates a new TranslateGizmo object. Use {@link Gizmo.createLayer} to create its layer. * * @param {CameraComponent} camera - The camera component. * @param {Layer} layer - The layer responsible for rendering the gizmo. * @example * const gizmo = new TranslateGizmo(camera, layer); */ constructor(camera: CameraComponent, layer: Layer); _shapes: { xyz: SphereShape; yz: PlaneShape; xz: PlaneShape; xy: PlaneShape; x: ArrowShape; y: ArrowShape; z: ArrowShape; }; /** * The local position of each attached node at the start of a drag. * * @type {Map} * @private */ private _nodeLocalPositions; /** * The world position of each attached node at the start of a drag. * * @type {Map} * @private */ private _nodePositions; /** * Flips the planes to face the camera. */ flipPlanes: boolean; /** * Sets the axis gap. * * @type {number} */ set axisGap(value: number); /** * Gets the axis gap. * * @type {number} */ get axisGap(): number; /** * Sets the axis line thickness. * * @type {number} */ set axisLineThickness(value: number); /** * Gets the axis line thickness. * * @type {number} */ get axisLineThickness(): number; /** * Sets the axis line length. * * @type {number} */ set axisLineLength(value: number); /** * Gets the axis line length. * * @type {number} */ get axisLineLength(): number; /** * Sets the axis line tolerance. * * @type {number} */ set axisLineTolerance(value: number); /** * Gets the axis line tolerance. * * @type {number} */ get axisLineTolerance(): number; /** * Sets the arrow thickness. * * @type {number} */ set axisArrowThickness(value: number); /** * Gets the arrow thickness. * * @type {number} */ get axisArrowThickness(): number; /** * Sets the arrow length. * * @type {number} */ set axisArrowLength(value: number); /** * Gets the arrow length. * * @type {number} */ get axisArrowLength(): number; /** * Sets the plane size. * * @type {number} */ set axisPlaneSize(value: number); /** * Gets the plane size. * * @type {number} */ get axisPlaneSize(): number; /** * Sets the plane gap. * * @type {number} */ set axisPlaneGap(value: number); /** * Gets the plane gap. * * @type {number} */ get axisPlaneGap(): number; /** * Sets the plane fill opacity, as a factor of the theme color alpha. Defaults to 0.35. * * @type {number} */ set axisPlaneOpacity(value: number); /** * Gets the plane fill opacity. * * @type {number} */ get axisPlaneOpacity(): number; /** * Sets the plane outline thickness; 0 hides the outline. Defaults to 0.01. * * @type {number} */ set axisPlaneOutlineThickness(value: number); /** * Gets the plane outline thickness. * * @type {number} */ get axisPlaneOutlineThickness(): number; /** * Sets the view angle in degrees below which an axis or plane fades out, hiding at about 8 * degrees. Defaults to 25. * * @type {number} */ set axisFadeAngle(value: number); /** * Gets the angle in degrees below which an axis or plane fades out. * * @type {number} */ get axisFadeAngle(): number; /** * Sets the axis center size. * * @type {number} */ set axisCenterSize(value: number); /** * Gets the axis center size. * * @type {number} */ get axisCenterSize(): number; /** * @type {boolean} * @deprecated Use {@link flipPlanes} instead. * @ignore */ set flipShapes(value: boolean); /** * @type {boolean} * @deprecated Use {@link flipPlanes} instead. * @ignore */ get flipShapes(): boolean; /** * @param {string} prop - The property to set. * @param {any} value - The value to set. * @private */ private _setArrowProp; /** * @param {string} prop - The property to set. * @param {any} value - The value to set. * @private */ private _setPlaneProp; /** * @private */ private _shapesLookAtCamera; /** * @param {boolean} state - The state. * @private */ private _drag; /** * @private */ private _storeNodePositions; /** * @param {Vec3} translateDelta - The offset from the start positions. * @private */ private _setNodePositions; /** * @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} 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 { SphereShape } from '../shape/sphere-shape.js'; import { PlaneShape } from '../shape/plane-shape.js'; import { ArrowShape } from '../shape/arrow-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';