"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PanScaleTransformSC = void 0;
const core_1 = require("@vived/core");
const Stylus_1 = require("../../../Stylus");
const UC_1 = require("../../UC");
class PanScaleTransformSC extends core_1.AppObjectController {
    constructor(appObject) {
        super(appObject, PanScaleTransformSC.type);
        this.doPan = false;
        this.allow = (button) => {
            if (button === 1)
                return true;
            return false;
        };
        this.onButtonDown = (button) => {
            this.doPan = false;
            if (!this.stylus || !this.uc)
                return;
            if (!this.allow(button))
                return;
            this.uc.initialize(this.stylus.pickRay);
            this.doPan = true;
        };
        this.onButtonUp = () => {
            if (!this.doPan)
                return;
            this.doPan = false;
            if (!this.uc)
                return;
            this.uc.finish();
        };
        this.onStylusMove = () => {
            if (!this.stylus || !this.uc)
                return;
            if (!this.doPan)
                return;
            this.uc.update(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.RayPanScaleTransformUC.type);
        if (!this.uc) {
            this.error("App Object that does not have a StylusDragScaleTransformUC");
            return;
        }
        this.stylus.registerController(this);
    }
}
exports.PanScaleTransformSC = PanScaleTransformSC;
PanScaleTransformSC.type = "PanScaleTransformSC";
//# sourceMappingURL=PanScaleTransformSC.js.map