import { AppObjectController } from "@vived/core";
import { StylusEntity } from "../../Stylus";
import { ScaleSceneRootWithRay } from "../UC/ScaleSceneRootWithRay";
export class ScaleSceneRootSC extends AppObjectController {
    get stylus() {
        return this.getCachedSingleton(StylusEntity.type);
    }
    get scaleSceneRootWithRay() {
        return this.getCachedLocalComponent(ScaleSceneRootWithRay.type);
    }
    constructor(appObject) {
        super(appObject, ScaleSceneRootSC.type);
        this.isScaling = false;
        this.allow = (button) => {
            if (button === 1)
                return true;
            return false;
        };
        this.onButtonDown = (button) => {
            this.isScaling = false;
            if (!this.stylus)
                return;
            if (!this.allow(button))
                return;
            const pointerRay = this.stylus.pickRay;
            const rayStart = this.stylus.transform.localPosition;
            this.scaleSceneRootWithRay?.initializeScale(pointerRay, rayStart);
            this.isScaling = true;
        };
        this.onStylusMove = () => {
            if (!this.stylus)
                return;
            if (!this.isScaling)
                return;
            const pointerRay = this.stylus.pickRay;
            const rayStart = this.stylus.transform.localPosition;
            this.scaleSceneRootWithRay?.doScale(pointerRay, rayStart);
        };
        this.onButtonUp = () => {
            this.isScaling = false;
        };
        this.stylus?.registerController(this);
    }
}
ScaleSceneRootSC.type = "ScaleSceneRootSC";
//# sourceMappingURL=ScaleSceneRootSC.js.map