import { AppObjectController } from "@vived/core";
import { StylusEntity } from "../../../Stylus";
import { ScaleTransformUC } from "../../UC";
export class ScaleTransformSC extends AppObjectController {
    constructor(appObject) {
        super(appObject, ScaleTransformSC.type);
        this.doUpdate = false;
        this.allow = (button) => {
            if (button === 0)
                return true;
            return false;
        };
        this.onButtonDown = (button) => {
            this.doUpdate = false;
            if (!this.stylus || !this.uc)
                return;
            if (!this.allow(button))
                return;
            this.uc.initializeRay(this.stylus.pickRay);
            this.doUpdate = true;
        };
        this.onButtonUp = () => {
            if (!this.doUpdate)
                return;
            this.doUpdate = false;
            if (!this.uc)
                return;
            this.uc.finish();
        };
        this.onStylusMove = () => {
            if (!this.stylus || !this.uc)
                return;
            if (!this.doUpdate)
                return;
            this.uc.updateRay(this.stylus.pickRay);
        };
        this.stylus = StylusEntity.get(this.appObjects);
        if (!this.stylus) {
            this.error("Unable to find StylusEntity");
            return;
        }
        this.uc = appObject.getComponent(ScaleTransformUC.type);
        if (!this.uc) {
            this.error("App Object that does not have a RayScaleTransformUC");
            return;
        }
        this.stylus.registerController(this);
    }
}
ScaleTransformSC.type = "ScaleTransformSC";
//# sourceMappingURL=ScaleTransformSC.js.map