Collision detection by raycasting in player's direction

Hello, I recently have posted a lot of posts relating this issue and I believe it’s been just my mistake that I didn’t find an answer, this time, I’ll try my best.
Well, where do I start.
Right now I’m checking if x and z velocity is positive or not and based on that I add or remove a unit from a copied camera coordinates, point the raycaster down with Vector3(0, -1, 0) and set near to 0 and far to 10. Concept is easy, but I wasn’t able to actually make it happen. What I need to do here is to compensate for camera direction, and that’s where it falls apart for me. What I am asking for is a bit of help with calculating where to actually start casting the raycaster as so far I have only been able to make if work well with +z, -z (direction) but it wouldn’t work with +z, -z (velocity) and the other way around, same with +x, -x. Alternatively, if there is a better way to do this, I’d love to hear your opinion, cuz this thing keeps me up late for too long already.

  • Note: Im using PointerLockControls

Given that velocity is a combination of direction and speed, you just need to normalise your velocity vector to get the direction in which the player is moving.

const velocity = ???
const direction = velocity.clone().normalize()

Yeah, I based my original code on this idea, however this does not account for the camera rotation, which alters where you actually go, there is the issue