export const DEFAULT_GIZMO_SETTINGS = {
    snapEnabled: false,
    positionSnap: 1,
    rotationSnapDegrees: 15,
    scaleSnap: 0.1,
    spaceMode: "world",
    pivotMode: "center"
};
export class Gizmo {
    history;
    enabled = true;
    target;
    settings = DEFAULT_GIZMO_SETTINGS;
    constructor(history, settings = {}) {
        this.history = history;
        this.configure(settings);
    }
    setTarget(target) {
        this.target = target;
    }
    configure(settings) {
        this.settings = normalizeGizmoSettings({ ...this.settings, ...settings });
    }
    snapshotSettings() {
        return this.settings;
    }
    hitTest(_ray) {
        return undefined;
    }
    dispose() {
        this.enabled = false;
        this.target = undefined;
    }
    snapPositionDelta(value) {
        return this.settings.snapEnabled ? snap(value, this.settings.positionSnap) : value;
    }
    snapRotationDelta(radians) {
        return this.settings.snapEnabled ? snap(radians, this.settings.rotationSnapDegrees * Math.PI / 180) : radians;
    }
    snapScaleFactor(value) {
        return this.settings.snapEnabled ? snap(value, this.settings.scaleSnap) : value;
    }
}
export function normalizeGizmoSettings(settings = {}) {
    return {
        snapEnabled: settings.snapEnabled ?? DEFAULT_GIZMO_SETTINGS.snapEnabled,
        positionSnap: positive(settings.positionSnap, DEFAULT_GIZMO_SETTINGS.positionSnap),
        rotationSnapDegrees: positive(settings.rotationSnapDegrees, DEFAULT_GIZMO_SETTINGS.rotationSnapDegrees),
        scaleSnap: positive(settings.scaleSnap, DEFAULT_GIZMO_SETTINGS.scaleSnap),
        spaceMode: settings.spaceMode ?? DEFAULT_GIZMO_SETTINGS.spaceMode,
        pivotMode: settings.pivotMode ?? DEFAULT_GIZMO_SETTINGS.pivotMode
    };
}
function positive(value, fallback) {
    return Number.isFinite(value) && Number(value) > 0 ? Number(value) : fallback;
}
function snap(value, increment) {
    return Math.round(value / increment) * increment;
}
//# sourceMappingURL=Gizmo.js.map