UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

76 lines (75 loc) 2.82 kB
import { TransformControls } from "three/examples/jsm/controls/TransformControls.js"; import { Behaviour } from "./Component.js"; /** * TransformGizmo displays manipulation controls for translating, rotating, and scaling objects in the scene. * It wraps three.js {@link TransformControls} and provides keyboard shortcuts for changing modes and settings. * @category Helpers * @group Components */ export declare class TransformGizmo extends Behaviour { /** * When true, this is considered a helper gizmo and will only be shown if showGizmos is enabled in engine parameters. */ isGizmo: boolean; /** * Specifies the translation grid snap value in world units. * Applied when holding Shift while translating an object. */ translationSnap: number; /** * Specifies the rotation snap angle in degrees. * Applied when holding Shift while rotating an object. */ rotationSnapAngle: number; /** * Specifies the scale snapping value. * Applied when holding Shift while scaling an object. */ scaleSnap: number; /** * Gets the underlying three.js {@link TransformControls} instance. * @returns The TransformControls instance or undefined if not initialized. */ get control(): TransformControls | undefined; private _control?; private orbit?; /** @internal */ onEnable(): void; /** @internal */ onDisable(): void; /** * Enables grid snapping for transform operations according to set snap values. * This applies the translationSnap, rotationSnapAngle, and scaleSnap properties to the controls. */ enableSnapping(): void; /** * Disables grid snapping for transform operations. * Removes all snapping constraints from the transform controls. */ disableSnapping(): void; /** * Event handler for when dragging state changes. * Disables orbit controls during dragging and requests ownership of the transform if it's synchronized. * @param event The drag change event */ private onControlChangedEvent; /** * Handles keyboard shortcuts for transform operations: * - Q: Toggle local/world space * - W: Translation mode * - E: Rotation mode * - R: Scale mode * - Shift: Enable snapping (while held) * - +/-: Adjust gizmo size * - X/Y/Z: Toggle visibility of respective axis * - Spacebar: Toggle controls enabled state * @param event The keyboard event */ private windowKeyDownListener; /** * Handles keyboard key release events. * Currently only handles releasing Shift key to disable snapping. * @param event The keyboard event */ private windowKeyUpListener; }