-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
62 lines (53 loc) · 1.73 KB
/
index.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import * as Primitives from "../index.js";
import { modeOptions, setGeometries, computeEdges } from "./render.js";
const params = new URLSearchParams(window.location.search);
// I don't like performances, just give me the biggest you've got
// Primitives.utils.setTypedArrayType(Uint32Array);
const box = Primitives.box();
box.edges = computeEdges(box.positions, box.cells, 4);
const quadsPlane = Primitives.plane({ nx: 10, quads: true });
quadsPlane.edges = computeEdges(quadsPlane.positions, quadsPlane.cells, 4);
quadsPlane.quads = true;
const circle = Primitives.circle({ closed: true });
circle.edges = circle.cells;
// Box and plane of quads are rendered as lines
const geometries =
params.has("geometry") && Primitives[params.get("geometry")]
? [Primitives[params.get("geometry")]()]
: [
box,
circle,
quadsPlane,
Primitives.quad(),
null,
Primitives.plane(),
Primitives.roundedRectangle(),
Primitives.stadium(),
null,
Primitives.ellipse(),
Primitives.disc(),
Primitives.superellipse(),
Primitives.squircle(),
Primitives.annulus(),
Primitives.reuleux(),
null,
Primitives.cube(),
Primitives.roundedCube(),
null,
Primitives.sphere(),
Primitives.icosphere(),
Primitives.ellipsoid(),
null,
Primitives.cylinder(),
Primitives.cone(),
Primitives.capsule(),
Primitives.torus(),
null,
Primitives.tetrahedron(),
Primitives.icosahedron(),
];
setGeometries(geometries);
if (params.has("screenshot")) {
window.screenshotItems = [...modeOptions, "bbox"];
window.dispatchEvent(new CustomEvent("screenshot"));
}