summaryrefslogtreecommitdiff
path: root/src/graph.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/graph.js')
-rw-r--r--src/graph.js33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/graph.js b/src/graph.js
index 0b2917c..a210f23 100644
--- a/src/graph.js
+++ b/src/graph.js
@@ -5,7 +5,7 @@ import { union } from "./utils/set_utils.js";
const IMG_SCALE = 20;
-export default function buildGraph(db, handlers) {
+export default function buildGraph({ db, objects, handlers }) {
const linkable = {};
const groups = {};
const data = { nodes: [], links: [] };
@@ -56,7 +56,6 @@ export default function buildGraph(db, handlers) {
/**
* find common links
*/
-
data.links.forEach((link) => {
const a = data.nodes[link.source];
const b = data.nodes[link.target];
@@ -79,14 +78,30 @@ export default function buildGraph(db, handlers) {
.showNavInfo(false)
.nodeLabel((node) => node.title)
.nodeThreeObject((node) => {
- let sprite;
- if (node.data.thumbnail?.uri) {
- const imgTexture = new THREE.TextureLoader().load(
- node.data.thumbnail.uri
- );
+ let sprite, material, texture, video;
+ if (node.data.object) {
+ const object = node.data.object;
+ var box = new THREE.Box3().setFromObject(object);
+ var center = new THREE.Vector3();
+ box.getCenter(center);
+ object.position.sub(center);
+ object.scale.set(100, 100, 100);
+ return object;
+ } else if (node.data.thumbnail?.uri) {
+ if (node.data.thumbnail.type === "video") {
+ video = document.createElement("video");
+ video.src = node.data.thumbnail.uri;
+ video.muted = true;
+ video.loop = true;
+ video.autoplay = true;
+ video.play();
+ texture = new THREE.VideoTexture(video);
+ } else {
+ texture = new THREE.TextureLoader().load(node.data.thumbnail.uri);
+ }
// console.log(imgTexture);
const aspect = node.data.thumbnail.width / node.data.thumbnail.height;
- const material = new THREE.SpriteMaterial({ map: imgTexture });
+ material = new THREE.SpriteMaterial({ map: texture });
sprite = new THREE.Sprite(material);
sprite.scale.set(IMG_SCALE, IMG_SCALE / aspect);
return sprite;
@@ -113,7 +128,7 @@ export default function buildGraph(db, handlers) {
{ x: 0, y: 0, z: 0 },
0
);
- setTimeout(() => zoomOut(1000));
+ setTimeout(() => zoomOut(1000), 1000);
};
const zoomOut = (duration = 1000) => {