import {} from "./ControlTypes.js";
export class ThirdPersonFollowControls {
    camera;
    enabled = true;
    target;
    offset;
    damping;
    constructor(camera, target, options = {}) {
        this.camera = camera;
        this.target = target;
        this.offset = { ...(options.offset ?? { x: 0, y: 2, z: 6 }) };
        this.damping = options.damping ?? 12;
    }
    update(deltaSeconds) {
        if (!this.enabled || !this.target)
            return;
        const desired = {
            x: this.target.position.x + this.offset.x,
            y: this.target.position.y + this.offset.y,
            z: this.target.position.z + this.offset.z
        };
        const alpha = 1 - Math.exp(-this.damping * Math.max(0, deltaSeconds));
        this.camera.position.x += (desired.x - this.camera.position.x) * alpha;
        this.camera.position.y += (desired.y - this.camera.position.y) * alpha;
        this.camera.position.z += (desired.z - this.camera.position.z) * alpha;
        this.camera.lookAt?.(this.target.position);
    }
    dispose() {
        this.enabled = false;
        this.target = undefined;
    }
}
//# sourceMappingURL=ThirdPersonFollowControls.js.map