@shopware-ag/dive
Version:
Shopware Spatial Framework
79 lines (78 loc) • 2.44 kB
TypeScript
import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
import { Object3D, EventDispatcher } from 'three/webgpu';
import { DIVEMovable, DIVEScene } from '../../../../index.ts';
import { OrbitController } from '../../../orbitcontroller/index.ts';
import { Tool } from '../Tool.ts';
import { PointerContext } from '../PointerContext.ts';
import { SelectionState } from '../SelectionState.ts';
/**
* Type guard to check if a tool is a TransformTool.
*/
export declare const isTransformTool: (tool: Tool) => tool is TransformTool;
type TransformToolEvents = {
'object-change': {
object: Object3D & DIVEMovable;
};
'object-position-change': {
object: Object3D & DIVEMovable;
};
'object-rotation-change': {
object: Object3D & DIVEMovable;
};
'object-scale-change': {
object: Object3D & DIVEMovable;
};
};
/**
* Tool for transforming objects with a gizmo.
*
* Manages TransformControls gizmo and reacts to selection changes.
* Has highest priority to block model-hover when gizmo is being interacted with.
*
* @module
*/
export declare class TransformTool extends EventDispatcher<TransformToolEvents> implements Tool {
readonly name = "transform";
readonly priority = 5;
private _scene;
private _controller;
private _selectionState;
private _gizmo;
private _gizmoHelper;
private _scaleLinked;
private _gizmoVisible;
private _selectionChangeHandler;
constructor(scene: DIVEScene, controller: OrbitController, selectionState: SelectionState);
/**
* Get the TransformControls gizmo.
*/
get gizmo(): TransformControls;
/**
* Whether a drag operation is currently in progress.
*/
get isDragging(): boolean;
onActivate(): void;
onDeactivate(): void;
onPointerMove(ctx: PointerContext): boolean | void;
/**
* Set the gizmo transformation mode.
*/
setGizmoMode(mode: 'translate' | 'rotate' | 'scale'): void;
/**
* Set whether the gizmo is visible.
*/
setGizmoVisible(visible: boolean): void;
/**
* Set whether scale operations are linked (uniform scaling).
*/
setGizmoScaleLinked(linked: boolean): void;
/**
* Dispose of the tool and clean up resources.
*/
dispose(): void;
private onSelectionChange;
private attachGizmo;
private isGizmoChild;
private initGizmo;
}
export {};