Started generalising / unifying inscribed links and layers as different
ways of picking out parts of a structurefeature-120-cell-layers
parent
2f59c0b3a5
commit
06c1b074b3
|
@ -20,7 +20,8 @@ class FourDShape extends THREE.Group {
|
||||||
this.node_scale = 1;
|
this.node_scale = 1;
|
||||||
this.link_scale = 1;
|
this.link_scale = 1;
|
||||||
this.hyperplane = HYPERPLANE;
|
this.hyperplane = HYPERPLANE;
|
||||||
this.label_visible = () => true;
|
this.node_f = () => true;
|
||||||
|
this.link_f = () => true;
|
||||||
this.initShapes();
|
this.initShapes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ class FourDShape extends THREE.Group {
|
||||||
link.object.children[0].rotation.x = Math.PI / 2.0;
|
link.object.children[0].rotation.x = Math.PI / 2.0;
|
||||||
const l1 = this.nodes3[link.source].label;
|
const l1 = this.nodes3[link.source].label;
|
||||||
const l2 = this.nodes3[link.target].label;
|
const l2 = this.nodes3[link.target].label;
|
||||||
link.object.visible = this.label_visible(l1) && this.label_visible(l2);
|
link.object.visible = this.link_f(link.label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,19 +135,18 @@ class FourDShape extends THREE.Group {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
render3(rotations, visibility) {
|
render3(rotations, node_f, link_f) {
|
||||||
this.label_visible = visibility;
|
|
||||||
this.scalev3 = new THREE.Vector3(this.node_scale, this.node_scale, this.node_scale);
|
this.scalev3 = new THREE.Vector3(this.node_scale, this.node_scale, this.node_scale);
|
||||||
for( const n of this.nodes4 ) {
|
for( const n of this.nodes4 ) {
|
||||||
const v3 = this.fourDtoV3(n.x, n.y, n.z, n.w, rotations);
|
const v3 = this.fourDtoV3(n.x, n.y, n.z, n.w, rotations);
|
||||||
this.nodes3[n.id].v3 = v3;
|
this.nodes3[n.id].v3 = v3;
|
||||||
this.nodes3[n.id].object.position.copy(v3);
|
this.nodes3[n.id].object.position.copy(v3);
|
||||||
this.nodes3[n.id].object.scale.copy(this.scalev3);
|
this.nodes3[n.id].object.scale.copy(this.scalev3);
|
||||||
this.nodes3[n.id].object.visible = this.label_visible(n.label);
|
this.nodes3[n.id].object.visible = node_f(n.label);
|
||||||
}
|
}
|
||||||
|
this.link_f = link_f;
|
||||||
for( const l of this.links ) {
|
for( const l of this.links ) {
|
||||||
this.updateLink(l, visibility);
|
this.updateLink(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const f of this.faces ) {
|
for( const f of this.faces ) {
|
||||||
|
|
34
gui.js
34
gui.js
|
@ -1,5 +1,20 @@
|
||||||
import { GUI } from 'lil-gui';
|
import { GUI } from 'lil-gui';
|
||||||
|
|
||||||
|
const SHAPES = [
|
||||||
|
'dodecahedron', '5-cell', '16-cell', 'tesseract',
|
||||||
|
'24-cell', '600-cell', '120-cell',
|
||||||
|
'120-cell-layers', '120-cell-all-inscribed'
|
||||||
|
];
|
||||||
|
|
||||||
|
const SHAPE_OPTIONS = {
|
||||||
|
'dodecahedron': [ 'inscribed', 'all_inscribed'],
|
||||||
|
'tesseract': [ 'inscribed', 'all_inscribed'],
|
||||||
|
'16-cell': [ 'inscribed', 'all_inscribed'],
|
||||||
|
'24-cell': [ 'inscribed', 'all_inscribed'],
|
||||||
|
'600-cell': [ 'inscribed', 'all_inscribed'],
|
||||||
|
'120-cell': [ 'inscribed', 'all_inscribed'],
|
||||||
|
'120-cell-layers': [ '0', '1', '2', '3' ,'4', '5', '6' ]
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const DEFAULTS = {
|
const DEFAULTS = {
|
||||||
|
@ -45,14 +60,16 @@ class FourDGUI {
|
||||||
dpsi: this.link['dpsi'],
|
dpsi: this.link['dpsi'],
|
||||||
"copy link": function () { guiObj.copyUrl() }
|
"copy link": function () { guiObj.copyUrl() }
|
||||||
};
|
};
|
||||||
|
let options_ctrl;
|
||||||
this.gui.add(this.params, 'shape',
|
this.gui.add(this.params, 'shape', SHAPES).onChange((v) => {
|
||||||
[ 'dodecahedron', '5-cell', '16-cell', 'tesseract',
|
if( SHAPE_OPTIONS[v] ) {
|
||||||
'24-cell', '600-cell', '120-cell',
|
options_ctrl = options_ctrl.options(SHAPE_OPTIONS[v]);
|
||||||
'120-cell-a', '120-cell-b', '120-cell-c', '120-cell-d', '120-cell-e', '120-cell-f' ]
|
} else {
|
||||||
).onChange(changeShape)
|
options_ctrl = options_ctrl.options([])
|
||||||
this.gui.add(this.params, 'inscribed').onChange(changeShape);
|
}
|
||||||
this.gui.add(this.params, 'inscribe_all').onChange(changeShape);
|
changeShape(v)
|
||||||
|
});
|
||||||
|
options_ctrl = this.gui.add(this.params, 'options', []);
|
||||||
this.gui.add(this.params, 'hyperplane', 1.5, 2.25);
|
this.gui.add(this.params, 'hyperplane', 1.5, 2.25);
|
||||||
this.gui.add(this.params, 'thickness', 0.1, 2);
|
this.gui.add(this.params, 'thickness', 0.1, 2);
|
||||||
this.gui.add(this.params, 'linkopacity', 0, 1).onChange(
|
this.gui.add(this.params, 'linkopacity', 0, 1).onChange(
|
||||||
|
@ -62,7 +79,6 @@ class FourDGUI {
|
||||||
(v) => setLinkOpacity(v, false)
|
(v) => setLinkOpacity(v, false)
|
||||||
);
|
);
|
||||||
this.gui.add(this.params, 'nodesize', 0.1, 4);
|
this.gui.add(this.params, 'nodesize', 0.1, 4);
|
||||||
this.gui.add(this.params, 'visibility', [ 0, 1, 2, 3, 4, 5 ]).onChange((v) => setVisibility(v));
|
|
||||||
this.gui.addColor(this.params, 'color').onChange(setColor);
|
this.gui.addColor(this.params, 'color').onChange(setColor);
|
||||||
this.gui.addColor(this.params, 'background').onChange(setBackground);
|
this.gui.addColor(this.params, 'background').onChange(setBackground);
|
||||||
this.gui.add(this.params, 'rotation', [ 'rigid', 'tumbling', 'inside-out', 'axisymmetrical' ]);
|
this.gui.add(this.params, 'rotation', [ 'rigid', 'tumbling', 'inside-out', 'axisymmetrical' ]);
|
||||||
|
|
24
main.js
24
main.js
|
@ -61,10 +61,11 @@ for( const face_m of face_ms ) {
|
||||||
face_m.opacity = FACE_OPACITY;
|
face_m.opacity = FACE_OPACITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the best way to do this -
|
// generalisation of the inscription stuff
|
||||||
// each STRUCTURE should present a menu of OPTIONS which
|
|
||||||
// are say a set of inscribed shapes, or a subset etc
|
// structure - with labels on nodes and links
|
||||||
// ie 120-cell - inscribed, layers, hopf fibrations etc
|
// options - a set of menu items, each one has a node and link filter
|
||||||
|
|
||||||
|
|
||||||
const STRUCTURES = {
|
const STRUCTURES = {
|
||||||
'5-cell': POLYTOPES.cell5(),
|
'5-cell': POLYTOPES.cell5(),
|
||||||
|
@ -73,12 +74,8 @@ const STRUCTURES = {
|
||||||
'24-cell': POLYTOPES.cell24(),
|
'24-cell': POLYTOPES.cell24(),
|
||||||
'dodecahedron': POLYTOPES.dodecahedron(),
|
'dodecahedron': POLYTOPES.dodecahedron(),
|
||||||
'120-cell': POLYTOPES.cell120(),
|
'120-cell': POLYTOPES.cell120(),
|
||||||
'120-cell-a': POLYTOPES.cell120_layered(1),
|
'120-cell-layers': POLYTOPES.cell120_layered(),
|
||||||
'120-cell-b': POLYTOPES.cell120_layered(2),
|
'120-cell-all-inscribed': POLYTOPES.cell120_all_inscribed(),
|
||||||
'120-cell-c': POLYTOPES.cell120_layered(3),
|
|
||||||
'120-cell-d': POLYTOPES.cell120_layered(4),
|
|
||||||
'120-cell-e': POLYTOPES.cell120_layered(5),
|
|
||||||
'120-cell-f': POLYTOPES.cell120_layered(6),
|
|
||||||
'600-cell': POLYTOPES.cell600(),
|
'600-cell': POLYTOPES.cell600(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -150,6 +147,9 @@ function setLinkOpacity(o, primary) {
|
||||||
let gui; //
|
let gui; //
|
||||||
let visible_labels = 6;
|
let visible_labels = 6;
|
||||||
|
|
||||||
|
let node_prune = () => true;
|
||||||
|
let link_prune = () => true;
|
||||||
|
|
||||||
function changeShape() {
|
function changeShape() {
|
||||||
createShape(gui.params.shape, gui.params.inscribed, gui.params.inscribe_all);
|
createShape(gui.params.shape, gui.params.inscribed, gui.params.inscribe_all);
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,8 @@ function setVisibility(v) {
|
||||||
visible_labels = v;
|
visible_labels = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gui = new FourDGUI(changeShape, setColors, setBackground, setLinkOpacity, setVisibility);
|
gui = new FourDGUI(changeShape, setColors, setBackground, setLinkOpacity, setVisibility);
|
||||||
|
|
||||||
// these are here to pick up colour settings from the URL params
|
// these are here to pick up colour settings from the URL params
|
||||||
|
@ -221,7 +223,7 @@ function animate() {
|
||||||
shape.hyperplane = gui.params.hyperplane;
|
shape.hyperplane = gui.params.hyperplane;
|
||||||
shape.link_scale = gui.params.thickness;
|
shape.link_scale = gui.params.thickness;
|
||||||
shape.node_scale = gui.params.nodesize;
|
shape.node_scale = gui.params.nodesize;
|
||||||
shape.render3(rotations, (l) => l <= visible_labels);
|
shape.render3(rotations, node_prune, link_prune);
|
||||||
|
|
||||||
renderer.render( scene, camera );
|
renderer.render( scene, camera );
|
||||||
}
|
}
|
||||||
|
|
10
polytopes.js
10
polytopes.js
|
@ -422,15 +422,9 @@ export const cell120_layered = (max) => {
|
||||||
|
|
||||||
layered_120cell(nodes);
|
layered_120cell(nodes);
|
||||||
|
|
||||||
const layer_nodes = nodes.filter((n) => n.label < max);
|
|
||||||
const layer_links = links.filter((l) => {
|
|
||||||
const labels = link_labels(nodes, l);
|
|
||||||
return labels[0] < max && labels[1] < max
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
nodes: layer_nodes,
|
nodes: nodes,
|
||||||
links: layer_links,
|
links: links,
|
||||||
geometry: {
|
geometry: {
|
||||||
node_size: 0.02,
|
node_size: 0.02,
|
||||||
link_size: 0.02
|
link_size: 0.02
|
||||||
|
|
Loading…
Reference in New Issue