diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2021-09-16 16:29:20 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2021-09-16 16:29:20 +0200 |
| commit | 9a8b38c18a1853cdb63c7245fa8cc19735d2b569 (patch) | |
| tree | 6aad50a17e4ce55c5dab94bb4fab1475ca30648c /src/graph.js | |
| parent | 0885b9db9e264a666cd0fa656442569a953fb7f7 (diff) | |
refactor utils
Diffstat (limited to 'src/graph.js')
| -rw-r--r-- | src/graph.js | 5 |
1 files changed, 2 insertions, 3 deletions
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); |
