import { AppObjectController } from "@vived/core";
import { pixelToSceneRay } from "../../Babylon";
import { MouseInputEntity, } from "../../MouseInput";
import { ZSpaceEntity } from "../../zSpace/Entities/ZSpaceEntity";
import { HoverAppObjectUC } from "../UC/HoverAppObjectUC";
export class MouseHoverOnAppObject extends AppObjectController {
    constructor(appObject) {
        super(appObject, MouseHoverOnAppObject.type);
        this.zSpaceEntity = undefined;
        this.allow = (e) => {
            return true;
        };
        this.onMove = (e) => {
            if (!this.hoverUC)
                return;
            if (this.zSpaceEntity && this.zSpaceEntity.emulate)
                return;
            if (!this.allow(e))
                return;
            const ray = pixelToSceneRay(e.position, this.appObjects);
            this.hoverUC.tryHoverAppObject(ray);
        };
        this.zSpaceEntity = ZSpaceEntity.get(this.appObjects);
        this.hoverUC = appObject.getComponent(HoverAppObjectUC.type);
        if (!this.hoverUC) {
            console.warn("MouseHover has been added to an App Object that does not have a HoverAppObjectUC. Add an HoverAppObjectUC before adding the Controller");
            return;
        }
        const mouseInput = MouseInputEntity.get(this.appObjects);
        if (mouseInput) {
            mouseInput.registerController(this);
        }
        else {
            this.warn("Unable to find MouseInputEntity");
        }
    }
}
MouseHoverOnAppObject.type = "MouseHoverOnAppObject";
//# sourceMappingURL=MouseHoverOnAppObject.js.map