export type Shape = import("./shape/shape.js").Shape; export type CameraComponent = import("../../framework/components/camera/component.js").CameraComponent; export type Layer = import("../../scene/layer.js").Layer; export type MeshInstance = import("../../scene/mesh-instance.js").MeshInstance; /** * The base class for all transform gizmos. * * @category Gizmo */ export class TransformGizmo extends Gizmo { /** * Fired when when the transformation has started. * * @event * @example * const gizmo = new pc.TransformGizmo(camera, layer); * gizmo.on('transform:start', () => { * console.log('Transformation started'); * }); */ static EVENT_TRANSFORMSTART: string; /** * Fired during the transformation. * * @event * @example * const gizmo = new pc.TransformGizmo(camera, layer); * gizmo.on('transform:move', (pointDelta, angleDelta) => { * console.log('Transformation moved by ${pointDelta} (angle: ${angleDelta})'); * }); */ static EVENT_TRANSFORMMOVE: string; /** * Fired when when the transformation has ended. * * @event * @example * const gizmo = new pc.TransformGizmo(camera, layer); * gizmo.on('transform:end', () => { * console.log('Transformation ended'); * }); */ static EVENT_TRANSFORMEND: string; /** * Internal color alpha value. * * @type {number} * @private */ private _colorAlpha; /** * Internal color for meshes. * * @type {{ axis: Record, hover: Record, disabled: Color }} * @protected */ protected _meshColors: { axis: Record; hover: Record; disabled: Color; }; /** * Internal version of the guide line color. * * @type {Record} * @protected */ protected _guideColors: Record; /** * Internal gizmo starting rotation in world space. * * @type {Vec3} * @protected */ protected _rootStartPos: Vec3; /** * Internal gizmo starting rotation in world space. * * @type {Quat} * @protected */ protected _rootStartRot: Quat; /** * Internal state of if shading is enabled. Defaults to true. * * @type {boolean} * @protected */ protected _shading: boolean; /** * Internal object containing the gizmo shapes to render. * * @type {Object.} * @protected */ protected _shapes: { [x: string]: import("./shape/shape.js").Shape; }; /** * Internal mapping of mesh instances to gizmo shapes. * * @type {Map} * @private */ private _shapeMap; /** * Internal currently hovered shape. * * @type {Shape | null} * @private */ private _hoverShape; /** * Internal currently hovered axis. * * @type {string} * @private */ private _hoverAxis; /** * Internal state of if currently hovered shape is a plane. * * @type {boolean} * @private */ private _hoverIsPlane; /** * Internal state of if there is no selection. * * @type {boolean} * @private */ private _noSelection; /** * Internal currently selected axis. * * @type {string} * @protected */ protected _selectedAxis: string; /** * Internal state of if currently selected shape is a plane. * * @type {boolean} * @protected */ protected _selectedIsPlane: boolean; /** * Internal selection starting coordinates in world space. * * @type {Vec3} * @protected */ protected _selectionStartPoint: Vec3; /** * Internal state for if the gizmo is being dragged. * * @type {boolean} * @protected */ protected _dragging: boolean; /** * Internal state for if snapping is enabled. Defaults to false. * * @type {boolean} * @private */ private _snap; /** * Snapping increment. Defaults to 1. * * @type {number} */ snapIncrement: number; /** * Sets whether snapping is enabled. Defaults to false. * * @type {boolean} */ set snap(value: boolean); /** * Gets whether snapping is enabled. Defaults to false. * * @type {boolean} */ get snap(): boolean; /** * Sets whether shading are enabled. Defaults to true. * * @type {boolean} */ set shading(value: boolean); /** * Gets whether shading are enabled. Defaults to true. * * @type {boolean} */ get shading(): boolean; /** * Sets the X axis color. * * @type {Color} */ set xAxisColor(value: Color); /** * Gets the X axis color. * * @type {Color} */ get xAxisColor(): Color; /** * Sets the Y axis color. * * @type {Color} */ set yAxisColor(value: Color); /** * Gets the Y axis color. * * @type {Color} */ get yAxisColor(): Color; /** * Sets the Z axis color. * * @type {Color} */ set zAxisColor(value: Color); /** * Gets the Z axis color. * * @type {Color} */ get zAxisColor(): Color; /** * Sets the color alpha for all axes. * * @type {number} */ set colorAlpha(value: number); /** * Gets the color alpha for all axes. * * @type {number} */ get colorAlpha(): number; /** * @param {Color} color - The color to set. * @returns {Color} - The color with alpha applied. * @private */ private _colorSemi; /** * @param {string} axis - The axis to update. * @param {any} value - The value to set. * @private */ private _updateAxisColor; /** * @param {MeshInstance} [meshInstance] - The mesh instance. * @returns {string} - The axis. * @private */ private _getAxis; /** * @param {MeshInstance} [meshInstance] - The mesh instance. * @returns {boolean} - Whether the mesh instance is a plane. * @private */ private _getIsPlane; /** * @param {MeshInstance} [meshInstance] - The mesh instance. * @private */ private _hover; /** * @param {Vec3} mouseWPos - The mouse world position. * @returns {Ray} - The ray. * @protected */ protected _createRay(mouseWPos: Vec3): Ray; /** * @param {string} axis - The axis to create the plane for. * @param {boolean} isFacing - Whether the axis is facing the camera. * @param {boolean} isLine - Whether the axis is a line. * @returns {Plane} - The plane. * @protected */ protected _createPlane(axis: string, isFacing: boolean, isLine: boolean): Plane; /** * @param {string} axis - The axis * @param {Vec3} dir - The direction * @returns {Vec3} - The direction * @protected */ protected _dirFromAxis(axis: string, dir: Vec3): Vec3; /** * @param {Vec3} point - The point to project. * @param {string} axis - The axis to project to. * @protected */ protected _projectToAxis(point: Vec3, axis: string): void; /** * @param {number} x - The x coordinate. * @param {number} y - The y coordinate. * @param {boolean} isFacing - Whether the axis is facing the camera. * @param {boolean} isLine - Whether the axis is a line. * @returns {Vec3} - The point. * @protected */ protected _screenToPoint(x: number, y: number, isFacing?: boolean, isLine?: boolean): Vec3; /** * @private */ private _drawGuideLines; /** * @param {Vec3} pos - The position. * @param {Quat} rot - The rotation. * @param {string} axis - The axis. * @private */ private _drawSpanLine; /** * @protected */ protected _createTransform(): void; /** * Set the shape to be enabled or disabled. * * @param {string} shapeAxis - The shape axis. Can be: * * - {@link GIZMOAXIS_X} * - {@link GIZMOAXIS_Y} * - {@link GIZMOAXIS_Z} * - {@link GIZMOAXIS_YZ} * - {@link GIZMOAXIS_XZ} * - {@link GIZMOAXIS_XY} * - {@link GIZMOAXIS_XYZ} * - {@link GIZMOAXIS_FACE} * * @param {boolean} enabled - The enabled state of shape. */ enableShape(shapeAxis: string, enabled: boolean): void; /** * Get the enabled state of the shape. * * @param {string} shapeAxis - The shape axis. Can be: * * - {@link GIZMOAXIS_X} * - {@link GIZMOAXIS_Y} * - {@link GIZMOAXIS_Z} * - {@link GIZMOAXIS_YZ} * - {@link GIZMOAXIS_XZ} * - {@link GIZMOAXIS_XY} * - {@link GIZMOAXIS_XYZ} * - {@link GIZMOAXIS_FACE} * * @returns {boolean} - Then enabled state of the shape */ isShapeEnabled(shapeAxis: string): boolean; } import { Gizmo } from './gizmo.js'; import { Color } from '../../core/math/color.js'; import { Vec3 } from '../../core/math/vec3.js'; import { Quat } from '../../core/math/quat.js'; import { Ray } from '../../core/shape/ray.js'; import { Plane } from '../../core/shape/plane.js';