[SOLVED] Grab and Move entity within area

Hello,

I have making pool game.
I added click and grab ball then even i am able to move ball.
But my concern is about the range. Well i want ball get dragged with in pool table area.

Is there any way i can do this?

Looking for help. Thanx in advance.


Solution:

    var mouseDragPosition = this._mousePos_3d;

    mouseDragPosition = new pc.Vec3(
        pc.math.clamp(this._mousePos_3d.x, this.leftBoundary.getPosition().x, this.rightBoundary.getPosition().x),
        this._mousePos_3d.y,
        pc.math.clamp(this._mousePos_3d.z, this.topBoundary.getPosition().z, this.bottomBoundary.getPosition().z)
    );
    this.white_ball.rigidbody.teleport(mouseDragPosition);