Pixi3d 试图将光线投射到平面

Pixi3d trying to raycast to plane

我正在尝试让光线投射在 pixi3D 库中工作。但是文档不是很有帮助。

我想做的是在 space.

中使 3d 对象跟随 3d 平面上的鼠标坐标

黑框应该跟随鼠标,但我没有让它工作。

这是我想出的:

首先我创建了飞机:

let normalTest = new Float32Array(3);
normalTest[0] = 0;
normalTest[1] = 0;
normalTest[2] = 1;
planeTest = new Plane(normalTest, 100);

然后在我的循环中,我尝试让光线与平面相交:

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);
}

这里还有人熟悉pixi3D吗API谁能给我指路?

这应该有效:

let plane = new PIXI3D.Plane(new Float32Array([0, 1, 0]), 0.8)

document.addEventListener("mousemove", e => {
  let ray = PIXI3D.Camera.main.screenToRay(e.x, e.y)
  let distance = plane.rayCast(ray)
  let point = ray.getPoint(distance)
  // model is my 3d object
  model.position.array = point
})