Accuracy of raycaster pickup

I created raymaster directly in the person and camera.Raymaster is pointing to the camera, Raymaster picks up objects in the same position, sometimes it can pick up objects, and sometimes it returns to empty.



This is part of my code

this.raycaster = new THREE.Raycaster();
this.raycaster.far = this.player.position.clone().distanceTo(this.camera.position.clone()
this.raycaster.near = 0

update(){
    const dir = this.camera.position.clone().sub(this.player.position.clone()).normalize()
    this.raycaster.set(this.player.position.clone(), dir)
    const ob = this.raycaster.intersectObject(this.MonitoredObjects)
    console.info(ob)
}

@Qiumeng12 Just for testing do not change the raycaster.far parameter.

Check the css aspect ratio of the canvas its the same as the aspect ration of the camera.

I checked the CSS aspect ratio and the camera aspect ratio. They are the same :smile:

This is my sample code. You can use the mouse and w s keys to operate characters


Picking fails when moving to this position