Skip to content

Commit

Permalink
Merge pull request #132 from BernatBC/fix-intersection
Browse files Browse the repository at this point in the history
Fix intersection
  • Loading branch information
BernatBC authored Jun 8, 2024
2 parents ec652f0 + 8336332 commit 6ecaf09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ function createJSON(objectArray) {

objectArray.forEach((object) => {
const real_pos = get2DCoords(C, object.position);
if (object.userData.intersection == null) intersection_pos = real_pos;
const intersection_pos = get2DCoords(C, object.userData.intersection);
if (intersection_pos == null) return;
json.push({
name: object.name,
x_real: real_pos.x,
Expand Down
7 changes: 3 additions & 4 deletions single-image-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,18 @@ function setIntersectionPosition(scene) {
i.position,
i.userData.direction
);
if (intersectionPosition == null) i.userData.intersection = null;
else i.userData.intersection = new THREE.Vector3().copy(intersectionPosition);
i.userData.intersection = new THREE.Vector3().copy(intersectionPosition);
});
}

function getIntersectionPosition(scene, position, direction) {
raycaster.set(position, direction);
var intersections = raycaster.intersectObject(scene, true);
if (intersections.length == 0) return null;
if (intersections.length == 0) return position;
for (let i = 0; i < intersections.length; i++) {
if (intersections[i].object.name != "wireframe") return intersections[i].point;
}
return null;
return position;
}

export { loadImage, setSize, setOffset, getAllImages, setWireframe, setIntersectionPosition };

0 comments on commit 6ecaf09

Please sign in to comment.