diff --git a/main.js b/main.js index eedf7a9..e2ddddc 100644 --- a/main.js +++ b/main.js @@ -121,8 +121,12 @@ function changeShape() { function setVisibility(option_name) { const option = structure.options.filter((o) => o.name === option_name); - node_show = option[0].nodes; - link_show = option[0].links; + if( option.length ) { + node_show = option[0].nodes; + link_show = option[0].links; + } else { + console.log(`Error: option '${option_name}' not found`); + } } diff --git a/polytopes.js b/polytopes.js index f2a4d4e..fdc25c3 100644 --- a/polytopes.js +++ b/polytopes.js @@ -392,6 +392,8 @@ function link_labels(nodes, link) { } +// version of the 120-cell where nodes are partitioned by +// layer and the links follow that export const cell120_layered = (max) => { const nodes = make_120cell_vertices(); @@ -399,6 +401,27 @@ export const cell120_layered = (max) => { layered_120cell(nodes); + links.map((l) => { + const labels = link_labels(nodes, l); + if( labels[0] >= labels[1] ) { + l.label = labels[0]; + } else { + l.label = labels[1]; + } + }); + + const options = []; + const layers = []; + + for( const i of [ 0, 1, 2, 3, 4, 5, 6 ] ) { + layers.push(i); + options.push({ + name: "Layer " + String(i), + links: [...layers], + nodes: [...layers] + }) + } + return { name: '120-cell layered', nodes: nodes, @@ -407,8 +430,7 @@ export const cell120_layered = (max) => { node_size: 0.02, link_size: 0.02 }, - options: [ - ] + options: options } } @@ -720,6 +742,7 @@ export const build_all = () => { tesseract(), cell24(), cell600(), - cell120_inscribed() + cell120_inscribed(), + cell120_layered() ]; } \ No newline at end of file