Having trouble with raycasting in the pixi3D library and finding the documentation lacking.
I'm attempting to make a 3D object track the mouse coordinates on a 3D plane in space.
https://i.sstatic.net/DiTzY.jpg
The goal is for the black box to follow the mouse, but so far it isn't working as expected.
This is my approach:
Firstly, creating the plane:
let normalTest = new Float32Array(3);
normalTest[0] = 0;
normalTest[1] = 0;
normalTest[2] = 1;
planeTest = new Plane(normalTest, 100);
Then in my loop, I attempt to intersect a ray with the plane:
let ray = Camera.main.screenToRay(l.mouseX(), l.mouseY(), {height: 1920, width: 1080 });
if (ray != undefined) {
let rayRes = planeTest.rayCast(ray);
let rayPoint = ray.getPoint(planeTest.rayCast(ray));
myBlackBox.x = rayPoint[0];
myBlackBox.y = (-l.mouseY() / 100);
}
Seeking guidance from someone experienced with the pixi3D API who can help me out?