import { AppObjectUC, getSingletonComponent, } from "@vived/core";
import { Vector3 } from "@vived/core";
import { scenePixelPick } from "../../Babylon";
import { dispatchStateChange } from "../../Dispatcher";
import { SceneRootEntity } from "../Entities/SceneRootEntity";
export class BumpSceneRootScaleAboutPixelPointUC extends AppObjectUC {
}
BumpSceneRootScaleAboutPixelPointUC.type = "BumpSceneRootScaleAboutPixelPoint";
BumpSceneRootScaleAboutPixelPointUC.get = (appObjects) => getSingletonComponent(BumpSceneRootScaleAboutPixelPointUC.type, appObjects);
export function makeBumpSceneRootScaleAboutPixelPointUC(appObject) {
    return new BumpSceneRootScaleAboutPixelPointImp(appObject);
}
class BumpSceneRootScaleAboutPixelPointImp extends BumpSceneRootScaleAboutPixelPointUC {
    constructor(appObject) {
        super(appObject, BumpSceneRootScaleAboutPixelPointUC.type);
        this.sensitivity = 0.1;
        this.allow = () => {
            return true;
        };
        this.bump = (direction, pixelPosition) => {
            if (!this.sceneRoot)
                return;
            if (!this.allow())
                return;
            let bumpDirection = -1;
            if (direction === "IN") {
                bumpDirection = 1;
            }
            const currentScale = this.sceneRoot.scale;
            const scaleDelta = bumpDirection * this.sensitivity * currentScale;
            const pick = scenePixelPick(pixelPosition, this.appObjects);
            const pickPoint = pick?.worldPickPoint ?? Vector3.Zero();
            this.sceneRoot.bumpScaleAboutPoint(scaleDelta, pickPoint);
            dispatchStateChange(this.appObjects);
        };
        this.sceneRoot = appObject.getComponent(SceneRootEntity.type);
        if (!this.sceneRoot) {
            this.warn("BumpSceneRootScaleAboutPixelPointImp UC has been added to an App Object that does not have a SceneRoot Entity");
            return;
        }
    }
}
//# sourceMappingURL=BumpSceneRootScaleAboutPixelPoint.js.map