"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SceneRootMoveSC = void 0;
const core_1 = require("@vived/core");
const Stylus_1 = require("../../Stylus");
const StylusMoveTransformUC_1 = require("../../Transform3D/UC/StylusMoveTransformUC");
class SceneRootMoveSC extends core_1.AppObjectController {
    get stylus() {
        return this.getCachedSingleton(Stylus_1.StylusEntity.type);
    }
    get stylusRootMovementUC() {
        return this.getCachedLocalComponent(StylusMoveTransformUC_1.StylusMoveTransformUC.type);
    }
    constructor(appObject) {
        super(appObject, SceneRootMoveSC.type);
        this.isMoving = false;
        this.allow = (button) => {
            if (button === 2)
                return true;
            return false;
        };
        this.onButtonDown = (button) => {
            this.isMoving = false;
            if (!this.stylus)
                return;
            if (!this.allow(button))
                return;
            this.stylusRootMovementUC?.initialize();
            this.isMoving = true;
        };
        this.onButtonUp = () => {
            this.isMoving = true;
            if (!this.stylus)
                return;
            this.stylusRootMovementUC?.stop();
        };
        this.onStylusMove = () => {
            if (!this.stylus || !this.isMoving)
                return;
            this.stylusRootMovementUC?.move();
        };
        this.stylus?.registerController(this);
    }
}
exports.SceneRootMoveSC = SceneRootMoveSC;
SceneRootMoveSC.type = "SceneRootMoveSC";
//# sourceMappingURL=SceneRootMoveSC.js.map