UNPKG

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.

50 lines 2.01 kB
import { Matrix4 } from 'three'; import { IObject3D } from '../../core'; export type DuplicateMode = 'simple' | 'compound'; /** * Tracks the transform delta after a duplicate operation to enable * smart duplicate chaining — pressing Ctrl+D repeatedly places copies * at consistent offsets. * * Supports two modes (only position application differs): * - **simple**: translation in constant parent-space direction (Figma-style, grids) * - **compound**: translation rotates with the object (circular arrays, spirals) * * Stores no object references — only the initial matrix and chain state. * The source object's current transform is passed in at apply time. * * The offset only applies when the selection has not changed since the last * duplicate. Any selection change (even reselecting the same objects) breaks the chain. */ export declare class DuplicateTracker { private _initialMatrix; private _chainActive; private static _iP; private static _iQ; private static _iS; private static _rel; /** Any selection change breaks the duplicate chain. */ onSelectionChanged(): void; /** * Record the baseline matrix for the next delta computation. * Call AFTER setSelected(clones) so it runs after the selection change event. */ onDuplicated(initialMatrix: Matrix4): void; /** * Compute and apply the transform delta to new clones. * @param source - the first source object (previous clone) to read current transform from * @param mode - 'simple' for independent component offsets, 'compound' for coupled transforms * @returns true if an offset was applied */ applyOffset(clones: IObject3D[], source: IObject3D, mode?: DuplicateMode): boolean; saveState(): { matrix: Matrix4; active: boolean; }; restoreState(state: { matrix: Matrix4; active: boolean; }): void; reset(): void; } //# sourceMappingURL=../../src/plugins/interaction/DuplicateTracker.d.ts.map