"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StylusHoverOnAppObjectSC = void 0;
const core_1 = require("@vived/core");
const Stylus_1 = require("../../Stylus");
const HoverAppObjectUC_1 = require("../UC/HoverAppObjectUC");
class StylusHoverOnAppObjectSC extends core_1.AppObjectController {
    constructor(appObject) {
        super(appObject, StylusHoverOnAppObjectSC.type);
        this.allow = () => {
            return true;
        };
        this.onStylusMove = () => {
            if (!this.stylus)
                return;
            if (!this.hoverUC)
                return;
            if (!this.allow())
                return;
            const pointerRay = this.stylus.pickRay;
            this.hoverUC.tryHoverAppObject(pointerRay);
        };
        this.stylus = Stylus_1.StylusEntity.get(this.appObjects);
        if (!this.stylus) {
            this.warn("Unable to find StylusEntity");
            return;
        }
        this.hoverUC = appObject.getComponent(HoverAppObjectUC_1.HoverAppObjectUC.type);
        if (!this.stylus) {
            console.warn("StylusInputPointer Controller has been added to an app object that does not have a ZSpaceStylusEntity");
        }
        else if (!this.hoverUC) {
            console.warn("HoverAppObjectUC has not been found on any objects in the app object repo");
        }
        else {
            this.stylus.registerController(this);
        }
    }
}
exports.StylusHoverOnAppObjectSC = StylusHoverOnAppObjectSC;
StylusHoverOnAppObjectSC.type = "StylusHoverOnAppObjectSC";
//# sourceMappingURL=StylusHoverOnAppObjectSC.js.map