"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScaleSceneRootSC = void 0;
const core_1 = require("@vived/core");
const Stylus_1 = require("../../Stylus");
const ScaleSceneRootWithRay_1 = require("../UC/ScaleSceneRootWithRay");
class ScaleSceneRootSC extends core_1.AppObjectController {
    get stylus() {
        return this.getCachedSingleton(Stylus_1.StylusEntity.type);
    }
    get scaleSceneRootWithRay() {
        return this.getCachedLocalComponent(ScaleSceneRootWithRay_1.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);
    }
}
exports.ScaleSceneRootSC = ScaleSceneRootSC;
ScaleSceneRootSC.type = "ScaleSceneRootSC";
//# sourceMappingURL=ScaleSceneRootSC.js.map