Raycasting issue with strafe right

I am having problems with clipping and raycasting. I have cobbled together my own controls from various sources and I am mostly satisfied; although I do need to do a major refactor and make the controls a class etc…

The movement all works great except for strafe right. Strafe right clips into the mesh. I would really appreciate an extra set of eyes on this.

You can run it here: https://zekenaulty.github.io/maze-quest/wwwroot/experiments/basic_room/

The movement code is from line: 185 to the end of file. I think it must be something about the keyboard movement I’ve added today, because the previous joysticks for mobile didn’t have this issue (anymore).

And you can see the code here:
https://raw.githubusercontent.com/zekenaulty/maze-quest/main/wwwroot/experiments/basic_room/script.js

a.k.a here: maze-quest/script.js at b4099e60e17a3d321a44884728b8e302b2de495c · zekenaulty/maze-quest · GitHub

I’m still learning threejs and a lot of other related concepts; so any and all help/info is appreciated.

const getRightVector = () => {
    const v = getLeftVector();
    v.applyMatrix4(rmr);
    return v;
};

As far as I could guess, this code calculates forward vector, not right vector. Possible solutions are

  • use getForwardVector instead of getLeftVector

or

  • use rmb instead of rmr

If you want to use both getLeftVector and rmr, then apply rmr twice.

Extra set of eyes ftw. Thanks.

Any thoughts or input on the rest of the code are also welcome.