Positioning and raycasting in the same function

I want to write a simple function what determine the position on a plane by given a position on screen(-1,1) and a distance from a camera.
I tried to update the position of the plane matrix, the log says it’s at the good position, but the raycasting always calculating with the prevous poition.

Here is my function:

const relativeposplanegeom = new THREE.PlaneBufferGeometry(2000,2000)
const relativeposplane  = new THREE.Mesh(relativeposplanegeom,basematerial)
relativeposplane.name = "relativeposplane";

async function getrelativeposition(distance,screenx,screeny){
    const pointer = new THREE.Vector2(screenx,screeny);
    const obj = cameragroup.getObjectByName("relativeposplane");
    if(typeof obj!=='undefined')
        obj.position.z = distance;
        //obj.matrix.setPosition( 0,0,distance );
        console.table(obj.position); //it says it's at 0,0,-0.2(good position)
        const positionhit = await raycaster.intersectObjects(cameragroup.children);
            return positionhit[0].point;
    console.log("relativeplane is undefined");
    return [100,100,100];

}export { getrelativeposition };

Here is the calling(from an another js file):

    let pos = await threeengine.getrelativeposition(-0.2,0.8,0);
    frameobject.position.x = pos.x;
    console.table(pos);//return [100,100,100], because it can't see the plane(It can see if the plane.pos.z is negative ) 

Sorry, for my amateur code,I am a beginner in js

Never mind I figured out.
If I call “await renderer.render(scene,camera)” after the transformation, it will work properly.