From 16d949a394f06bd78f9bb13ec008c0e54abbefb1 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Mon, 24 Jul 2023 10:39:11 +1000 Subject: [PATCH] Generated the vertices of the 24-cell --- main.js | 5 ++--- shapes.js | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 4487800..52ac2d4 100644 --- a/main.js +++ b/main.js @@ -192,7 +192,6 @@ scene.add(amblight); scene.background = new THREE.Color(0xdddddd); const renderer = new THREE.WebGLRenderer({antialias: true}); -//renderer.physicallyCorrectLights = true; renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); @@ -210,9 +209,9 @@ link_m.roughness = 0.0; link_m.transparent = true; link_m.opacity = 0.5; -console.log(SHAPES.TESSERACT); +const struct = SHAPES.cell24(); -const shape = new FourDShape(node_m, link_m, SHAPES.TESSERACT); +const shape = new FourDShape(node_m, link_m, struct); scene.add(shape); diff --git a/shapes.js b/shapes.js index 17a0b80..144a352 100644 --- a/shapes.js +++ b/shapes.js @@ -124,4 +124,28 @@ export const TESSERACT = { ] }; +export const cell24 = () => { + const structure = { + nodes: [], + links: [] + }; + const axes = [ 'x', 'y', 'z', 'w' ]; + let i = 1; + for ( let p = 0; p < 3; p++ ) { + for ( let q = p + 1; q < 4; q++ ) { + const a1 = axes[p]; + const a2 = axes[q]; + for ( const v1 of [ -1, 1 ] ) { + for ( const v2 of [ -1, 1 ] ) { + const node = { id: i, x: 0, y: 0, z: 0, w:0 }; + node[a1] = v1; + node[a2] = v2; + structure.nodes.push(node); + i++; + } + } + } + } + return structure; +}