threepipe
Version:
A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.
153 lines • 6.2 kB
TypeScript
import { Object3D } from 'three';
import { Class } from 'ts-browser-helpers';
import { AViewerPluginEventMap, AViewerPluginSync, ThreeViewer } from '../../viewer';
import { ObjectPicker } from '../../three';
import { IGeometry, IMaterial, IObject3D, ITexture, LineMaterial2, PhysicalMaterial, UnlitLineMaterial, UnlitMaterial } from '../../core';
import { UiObjectConfig } from 'uiconfig.js';
import { ObjectPickerEventMap, SelectionObject } from '../../three/utils/ObjectPicker';
import { CameraViewPlugin } from '../animation/CameraViewPlugin';
import { SelectionWidget } from '../../three/widgets';
import { DuplicateMode } from './DuplicateTracker';
export interface PickingPluginEventMap extends AViewerPluginEventMap, ObjectPickerEventMap {
}
export declare class PickingPlugin extends AViewerPluginSync<PickingPluginEventMap> {
enabled: boolean;
get picker(): ObjectPicker | undefined;
static readonly PluginType = "Picking";
static readonly OldPluginType = "PickingPlugin";
private _picker?;
private _widget?;
private _extraWidgets;
private _selectionWidgetClass?;
private _hoverWidget?;
private _pickUi;
private _clipboard;
private _undoManager?;
private _duplicateTracker;
/**
* Duplicate offset mode:
* - `simple`: position/rotation/scale applied independently (Figma-style, straight lines)
* - `compound`: full matrix delta (circular arrays, spirals)
*/
duplicateMode: DuplicateMode;
dependencies: (typeof CameraViewPlugin)[];
get hoverEnabled(): boolean;
set hoverEnabled(v: boolean);
selectionMode: 'object' | 'material' | 'geometry' | 'texture';
autoFocus: boolean;
autoFocusHover: boolean;
autoApplyMaterialOnDrop: boolean;
/**
* Note: this is for runtime use only, not serialized
*/
widgetEnabled: boolean;
multiSelectEnabled: boolean;
protected _widgetEnabledChange(): void;
private _updateExtraWidgets;
setDirty(): void;
constructor(selection?: Class<SelectionWidget> | undefined, pickUi?: boolean, autoFocus?: boolean);
getSelectedObject<T extends SelectionObject = SelectionObject>(): T | undefined;
getSelectedObjects<T extends SelectionObject = SelectionObject>(): T[];
toggleSelectedObject(object: SelectionObject): void;
selectAll(): void;
clearSelection(): void;
private _onKeyDown;
/** Helper to setSelected from an array without recording undo */
private _setSelectedFromArray;
/**
* Delete selected objects. Always shows a confirmation dialog.
*/
deleteSelected(): Promise<void>;
/**
* Duplicate selected objects with smart offset support.
* @param mode - override the duplicateMode setting for this operation
*/
duplicateSelected(mode?: DuplicateMode): void;
/**
* Copy selected objects to internal clipboard. No scene mutation.
*/
copySelected(): void;
/**
* Cut selected objects to internal clipboard. No scene mutation.
*/
cutSelected(): void;
/**
* Paste from internal clipboard.
*/
pasteFromClipboard(): void;
/**
* Determine where pasted objects should go based on the current selection.
* - Container selected (no material, no geometry, not light/camera) → paste into it
* - Leaf object selected (mesh, light, camera) → paste as sibling (selected's parent)
* - Nothing selected → null (use source parents)
*/
private _getPasteDestination;
private _isContainer;
/**
* Toggle visibility of selected objects based on primary selected object's state.
* If primary is visible → hide all selected. If primary is hidden → show all selected.
*/
toggleVisibilitySelected(): void;
/**
* Unhide all hidden objects in the model root.
*/
unhideAll(): void;
/**
* Focus/zoom camera to fit the selected object(s).
* When multiple objects are selected, fits the camera to encompass all of them.
*/
focusSelected(): void;
/**
* Reset position, rotation, or scale of selected objects to identity.
* All resets are in local space and undoable.
*/
resetTransform(component: 'position' | 'rotation' | 'scale'): void;
setSelectedObject(object: SelectionObject | undefined, focusCamera?: boolean, trackUndo?: boolean): void;
onAdded(viewer: ThreeViewer): void;
onRemove(viewer: ThreeViewer): void;
dispose(): void;
private _mainCameraChange;
private _addSceneObject;
private _sceneUpdate;
private _objCompChange;
private _onObjectSelectEvent;
private _selectedObjectChanged;
private _hoverObjectChanged;
private _onObjectHit;
private _selectionModeChanged;
private _multiSelectChanged;
focusObject(selected?: Object3D | Object3D[] | null): Promise<void>;
private _onDrop;
private _pickPromptUi;
private _uiConfigChildren;
uiConfig: UiObjectConfig;
get widget(): SelectionWidget | undefined;
refreshUiChildren(selected: IObject3D | IMaterial | ITexture | IGeometry | undefined): void;
objectSelectionUiConfig(obj: IObject3D): UiObjectConfig[];
objectMaterialManageUiConfig(obj: IObject3D): UiObjectConfig[];
canRemoveMaterial: (obj: IObject3D) => boolean | 0;
removeMaterial: (obj: IObject3D) => (() => IMaterial<import('../../core').IMaterialEventMap> | IMaterial<import('../../core').IMaterialEventMap>[]) | undefined;
getPlaceholderMaterial(obj: IObject3D): IMaterial;
materialTypes: ({
cls: typeof UnlitMaterial;
def: UnlitMaterial<import('../../core').IMaterialEventMap>;
name: string;
line?: undefined;
} | {
cls: typeof UnlitLineMaterial;
def: UnlitLineMaterial<import('../../core').IMaterialEventMap>;
line: boolean;
name: string;
} | {
cls: typeof LineMaterial2;
def: LineMaterial2<import('../../core').IMaterialEventMap>;
line: boolean;
name: string;
} | {
cls: typeof PhysicalMaterial;
name: string;
def?: undefined;
line?: undefined;
})[];
}
//# sourceMappingURL=../../src/plugins/interaction/PickingPlugin.d.ts.map