Skip to content

Commit

Permalink
Raycast to plane at arrow height when moving compare arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Jan 7, 2025
1 parent 9a56d1e commit 16302d7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/map3d/Compare3D.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,14 @@ class Compare3D extends React.Component {
if (!intersects) {
return;
}
const plane = new Plane(new Vector3(0, 0, 1), 0);
const plane = new Plane().setFromNormalAndCoplanarPoint(new Vector3(0, 0, 1), this.arrows.position);
const startPos = raycaster.ray.intersectPlane(plane, new Vector3());
const planePos = new Vector2(this.state.planeX, this.state.planeY);
const alpha = this.state.planeA / 180 * Math.PI;
const planeNormal = new Vector3(Math.sin(alpha), Math.cos(alpha), 0);
const moveArrows = (event) => {
raycaster.setFromCamera(mousePos(event), camera);
plane.setFromNormalAndCoplanarPoint(new Vector3(0, 0, 1), this.arrows.position);
const pos = raycaster.ray.intersectPlane(plane, new Vector3());
const delta = planeNormal.clone().multiplyScalar(
new Vector3().copy(pos.sub(startPos)).dot(planeNormal)
Expand Down

0 comments on commit 16302d7

Please sign in to comment.