-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodelClick.js
35 lines (30 loc) · 1.07 KB
/
modelClick.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { getAllImages, createJSON } from "./interaction";
const MAX_DISTANCE = 0.1;
function openNearbyImages(object) {
const images = getAllImages();
let nearbyImages = [];
images.forEach((i) => {
if (isImageNearby(object.point, i.userData.intersectionPointsMatrix)) {
console.log("NearbyImage: ", i.name);
nearbyImages.push(i);
}
});
if (nearbyImages.length == 0) {
console.log("No nearby images found");
return;
}
openImagesToOpenSeaDragon(nearbyImages);
}
function isImageNearby(pointPressed, pointMatrix) {
for (let i = 0; i < pointMatrix.length; i++)
for (let j = 0; j < pointMatrix[0].length; j++)
if (pointPressed.distanceTo(pointMatrix[i][j]) < MAX_DISTANCE) return true;
return false;
}
function openImagesToOpenSeaDragon(imagesSelected) {
let jsonContent = JSON.stringify(createJSON(imagesSelected));
localStorage.setItem("images", jsonContent);
const url = "openseadragon.html?mode=multiple";
window.open(url, "blank");
}
export { openNearbyImages };