From 9a8b38c18a1853cdb63c7245fa8cc19735d2b569 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 16 Sep 2021 16:29:20 +0200 Subject: refactor utils --- src/graph.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/graph.js') diff --git a/src/graph.js b/src/graph.js index 3a0e8a1..7381f49 100644 --- a/src/graph.js +++ b/src/graph.js @@ -2,6 +2,7 @@ import * as THREE from "three"; import ForceGraph3D from "3d-force-graph"; import SpriteText from "three-spritetext"; import { union } from "./utils/set_utils.js"; +import { randint, choice, pad } from "./utils/index.js"; const IMG_SCALE = 16; const MAIN_IMG_SCALE = 80; @@ -20,7 +21,7 @@ export default function buildGraph({ db, objects, handlers }) { db.page.forEach((item, index) => { const node = { - title: index + 1 + " " + item.title, + title: pad(index + 1) + " " + item.title, id: index, data: item, groups: [], @@ -210,6 +211,4 @@ export default function buildGraph({ db, objects, handlers }) { // stars(); } -const randint = (limit) => Math.floor(Math.random() * limit); -const choice = (list) => list[randint(list.length)]; const commonGroups = (a, b) => union(a.groups, b.groups); -- cgit v1.2.3-70-g09d2