OnAnalog mouse movement

I’m trying to move a model with my mouse, and what I have found on google is to use OnAnalog for this. So far, I have a boolean variable which set to true when the right click is first pressed. Then I check if this variable is true, and if it is I move the model according to the mouse position. Another click sets the variable to false, and the model stays in the place where I clicked.

            if(results.size() > 0){
            if(Statics.s_PlayerSettingModel == false){
            
            CollisionResult point = results.getClosestCollision();
            Vector3f destination = point.getContactPoint();
            Spatial target = results.getClosestCollision().getGeometry();
                 
            ObjectHelper.s_Model = ObjectHelper.AddModel(destination);
            
            Main.s_TreeNode.attachChild(ObjectHelper.s_Model);
            Statics.s_PlayerSettingModel = true;
            }
        }

All this does is create the model at the mouse position. When the boolean variable is true, I want to use the OnAnalog function to move the model according to postition which would mean getting the mouse x and z position. The y mouse vairable will be 0 so the model stays on the ground.

My question is, how do I get the mouse x and z variables within another binding of the input manager? From what I can see, I can grab the mouse x and y values and create a mapping and listener from those.

 Vector2f click2d = inputManager.getCursorPosition();
        Vector3f click3d = cam.getWorldCoordinates(new Vector2f(click2d.getX(), click2d.getY()), 0f);
        Vector3f dir = cam.getWorldCoordinates(new Vector2f(click2d.getX(), click2d.getY()), 1f).subtractLocal(click3d);

This is how get the mouse position according to every picking tutorial on this forum.

Can you explain more what you mean by this question?

Why does the code you supplied not work for that very thing?

My code now places the model in the node at the mouse position. But what I want to happen is to move the model I’m placing based on the mouse position, just like you would move a player with an update method.