"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScaleTransformSC = void 0;
const core_1 = require("@vived/core");
const Stylus_1 = require("../../../Stylus");
const UC_1 = require("../../UC");
class ScaleTransformSC extends core_1.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 = Stylus_1.StylusEntity.get(this.appObjects);
        if (!this.stylus) {
            this.error("Unable to find StylusEntity");
            return;
        }
        this.uc = appObject.getComponent(UC_1.ScaleTransformUC.type);
        if (!this.uc) {
            this.error("App Object that does not have a RayScaleTransformUC");
            return;
        }
        this.stylus.registerController(this);
    }
}
exports.ScaleTransformSC = ScaleTransformSC;
ScaleTransformSC.type = "ScaleTransformSC";
//# sourceMappingURL=ScaleTransformSC.js.map