Standardise polytopes, tested more labelling, inverted colours
parent
4cc2b44e00
commit
55573bac0b
42
main.js
42
main.js
|
@ -4,8 +4,6 @@ import * as POLYTOPES from './polytopes.js';
|
|||
|
||||
import { FourDShape } from './fourDShape.js';
|
||||
|
||||
const NODE_OPACITY = 1.0;
|
||||
const LINK_OPACITY = 0.7;
|
||||
|
||||
|
||||
|
||||
|
@ -106,16 +104,28 @@ const renderer = new THREE.WebGLRenderer({antialias: true});
|
|||
renderer.setSize( window.innerWidth, window.innerHeight );
|
||||
document.body.appendChild( renderer.domElement );
|
||||
|
||||
const struct = POLYTOPES.cell24();
|
||||
|
||||
const NODE_OPACITY = 1.0;
|
||||
const LINK_OPACITY = 0.7;
|
||||
|
||||
// nodes. links
|
||||
// 0 R 0 (0-1) Y
|
||||
// 1 G 1 (1-2) C
|
||||
// 2 B 2 (0-2) M
|
||||
|
||||
// duals
|
||||
// 0 C 0 (0-1) G
|
||||
// 1 Y 1 (1-2) R
|
||||
// 2 M 2 (0-2) B
|
||||
|
||||
const node_ms = [
|
||||
new THREE.MeshStandardMaterial( { color: 0x990000 } ),
|
||||
new THREE.MeshStandardMaterial( { color: 0x009900 } ),
|
||||
new THREE.MeshStandardMaterial( { color: 0x000099 } ),
|
||||
new THREE.MeshStandardMaterial( { color: 0x20dddd } ),
|
||||
new THREE.MeshStandardMaterial( { color: 0xdddd20 } ),
|
||||
new THREE.MeshStandardMaterial( { color: 0xdd20dd } ),
|
||||
];
|
||||
|
||||
for( const node_m of node_ms ) {
|
||||
node_m.roughness = 0.2;
|
||||
node_m.roughness = 0.9;
|
||||
|
||||
if( NODE_OPACITY < 1.0 ) {
|
||||
node_m.transparent = true;
|
||||
|
@ -124,21 +134,23 @@ for( const node_m of node_ms ) {
|
|||
}
|
||||
|
||||
const link_ms = [
|
||||
new THREE.MeshStandardMaterial( { color: 0x999900 } ),
|
||||
new THREE.MeshStandardMaterial( { color: 0x009999 } ),
|
||||
new THREE.MeshStandardMaterial( { color: 0x990099 } ),
|
||||
new THREE.MeshStandardMaterial( { color: 0x20dd20 } ),
|
||||
new THREE.MeshStandardMaterial( { color: 0xdd2020 } ),
|
||||
new THREE.MeshStandardMaterial( { color: 0x2020dd } ),
|
||||
];
|
||||
|
||||
for( const link_m of link_ms ) {
|
||||
link_m.metalness = 0.4;
|
||||
link_m.roughness = 0.0;
|
||||
link_m.metalness = 0.8;
|
||||
link_m.roughness = 0.1;
|
||||
|
||||
if( NODE_OPACITY < 1.0 ) {
|
||||
node_m.transparent = true;
|
||||
node_m.opacity = NODE_OPACITY;
|
||||
if( LINK_OPACITY < 1.0 ) {
|
||||
link_m.transparent = true;
|
||||
link_m.opacity = LINK_OPACITY;
|
||||
}
|
||||
}
|
||||
|
||||
const struct = POLYTOPES.cell24();
|
||||
|
||||
|
||||
const shape = new FourDShape(node_ms, link_ms, struct);
|
||||
|
||||
|
|
236
polytopes.js
236
polytopes.js
|
@ -1,129 +1,131 @@
|
|||
const r5 = Math.sqrt(5);
|
||||
|
||||
// if nodes or links have no label, use the first material in the
|
||||
// list
|
||||
|
||||
export const CELL5 = {
|
||||
nodes: [
|
||||
{id:1, x: 1, y: 1, z: 1, w: -1 / r5 },
|
||||
{id:2, x: 1, y: -1, z: -1, w: -1 / r5 },
|
||||
{id:3, x: -1, y: 1, z: -1, w: -1 / r5 },
|
||||
{id:4, x: -1, y: -1, z: 1, w: -1 / r5 },
|
||||
{id:5, x: 0, y: 0, z: 0, w: 4 / r5 },
|
||||
],
|
||||
links: [
|
||||
{ id:1, source:1, target: 2},
|
||||
{ id:2, source:1, target: 3},
|
||||
{ id:3, source:1, target: 4},
|
||||
{ id:4, source:1, target: 5},
|
||||
{ id:5, source:2, target: 3},
|
||||
{ id:6, source:2, target: 4},
|
||||
{ id:7, source:2, target: 5},
|
||||
{ id:8, source:3, target: 4},
|
||||
{ id:9, source:3, target: 5},
|
||||
{ id:10, source:4, target: 5},
|
||||
export const cell5 = () => {
|
||||
const r5 = Math.sqrt(5);
|
||||
return {
|
||||
nodes: [
|
||||
{id:1, x: 1, y: 1, z: 1, w: -1 / r5 },
|
||||
{id:2, x: 1, y: -1, z: -1, w: -1 / r5 },
|
||||
{id:3, x: -1, y: 1, z: -1, w: -1 / r5 },
|
||||
{id:4, x: -1, y: -1, z: 1, w: -1 / r5 },
|
||||
{id:5, x: 0, y: 0, z: 0, w: 4 / r5 },
|
||||
],
|
||||
links: [
|
||||
{ id:1, source:1, target: 2},
|
||||
{ id:2, source:1, target: 3},
|
||||
{ id:3, source:1, target: 4},
|
||||
{ id:4, source:1, target: 5},
|
||||
{ id:5, source:2, target: 3},
|
||||
{ id:6, source:2, target: 4},
|
||||
{ id:7, source:2, target: 5},
|
||||
{ id:8, source:3, target: 4},
|
||||
{ id:9, source:3, target: 5},
|
||||
{ id:10, source:4, target: 5},
|
||||
]
|
||||
|
||||
};
|
||||
|
||||
|
||||
export const CELL16 = {
|
||||
nodes: [
|
||||
{ id: 1, x: 0, y: -1, z: 0, w: 0 },
|
||||
{ id: 2, x: 0, y: 0, z: -1, w: 0 },
|
||||
{ id: 3, x: -1, y: 0, z: 0, w: 0 },
|
||||
{ id: 4, x: 0, y: 0, z: 1, w: 0 },
|
||||
{ id: 5, x: 1, y: 0, z: 0, w: 0 },
|
||||
{ id: 6, x: 0, y: 1, z: 0, w: 0 },
|
||||
{ id: 7, x: 0, y: 0, z: 0, w: -1 },
|
||||
{ id: 8, x: 0, y: 0, z: 0, w: 1 },
|
||||
],
|
||||
links: [
|
||||
{ id: 1, source: 1, target: 2 },
|
||||
{ id: 2, source: 1, target: 3 },
|
||||
{ id: 3, source: 1, target: 4 },
|
||||
{ id: 4, source: 1, target: 5 },
|
||||
{ id: 5, source: 2, target: 3 },
|
||||
{ id: 6, source: 3, target: 4 },
|
||||
{ id: 7, source: 4, target: 5 },
|
||||
{ id: 8, source: 5, target: 2 },
|
||||
{ id: 9, source: 2, target: 6 },
|
||||
{ id: 10, source: 3, target: 6 },
|
||||
{ id: 11, source: 4, target: 6 },
|
||||
{ id: 12, source: 5, target: 6 },
|
||||
{ id: 13, source: 1, target: 7 },
|
||||
{ id: 14, source: 1, target: 8 },
|
||||
{ id: 15, source: 2, target: 7 },
|
||||
{ id: 16, source: 2, target: 8 },
|
||||
{ id: 17, source: 3, target: 7 },
|
||||
{ id: 18, source: 3, target: 8 },
|
||||
{ id: 19, source: 4, target: 7 },
|
||||
{ id: 20, source: 4, target: 8 },
|
||||
{ id: 21, source: 5, target: 7 },
|
||||
{ id: 22, source: 5, target: 8 },
|
||||
{ id: 23, source: 6, target: 7 },
|
||||
{ id: 25, source: 6, target: 8 },
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
export const TESSERACT = {
|
||||
nodes: [
|
||||
{ id: 1, x: -1, y: -1, z: -1, w: -1 },
|
||||
{ id: 2, x: 1, y: -1, z: -1, w: -1 },
|
||||
{ id: 3, x: -1, y: 1, z: -1, w: -1 },
|
||||
{ id: 4, x: 1, y: 1, z: -1, w: -1 },
|
||||
{ id: 5, x: -1, y: -1, z: 1, w: -1 },
|
||||
{ id: 6, x: 1, y: -1, z: 1, w: -1 },
|
||||
{ id: 7, x: -1, y: 1, z: 1, w: -1 },
|
||||
{ id: 8, x: 1, y: 1, z: 1, w: -1 },
|
||||
{ id: 9, x: -1, y: -1, z: -1, w: 1 },
|
||||
{ id: 10, x: 1, y: -1, z: -1, w: 1 },
|
||||
{ id: 11, x: -1, y: 1, z: -1, w: 1 },
|
||||
{ id: 12, x: 1, y: 1, z: -1, w: 1 },
|
||||
{ id: 13, x: -1, y: -1, z: 1, w: 1 },
|
||||
{ id: 14, x: 1, y: -1, z: 1, w: 1 },
|
||||
{ id: 15, x: -1, y: 1, z: 1, w: 1 },
|
||||
{ id: 16, x: 1, y: 1, z: 1, w: 1 },
|
||||
],
|
||||
links: [
|
||||
{ id: 1, source: 1, target: 2 },
|
||||
{ id: 2, source: 2, target: 4 },
|
||||
{ id: 3, source: 4, target: 3 },
|
||||
{ id: 4, source: 3, target: 1 },
|
||||
{ id: 5, source: 5, target: 6 },
|
||||
{ id: 6, source: 6, target: 8 },
|
||||
{ id: 7, source: 8, target: 7 },
|
||||
{ id: 8, source: 7, target: 5 },
|
||||
{ id: 9, source: 1, target: 5 },
|
||||
{ id: 10, source: 2, target: 6 },
|
||||
{ id: 11, source: 3, target: 7 },
|
||||
{ id: 12, source: 4, target: 8 },
|
||||
|
||||
{ id: 13, source: 9, target: 10 },
|
||||
{ id: 14, source: 10, target: 12 },
|
||||
{ id: 15, source: 12, target: 11 },
|
||||
{ id: 16, source: 11, target: 9 },
|
||||
{ id: 17, source: 13, target: 14 },
|
||||
{ id: 18, source: 14, target: 16 },
|
||||
{ id: 19, source: 16, target: 15 },
|
||||
{ id: 20, source: 15, target: 13 },
|
||||
{ id: 21, source: 9, target: 13 },
|
||||
{ id: 22, source: 10, target: 14 },
|
||||
{ id: 23, source: 11, target: 15 },
|
||||
{ id: 24, source: 12, target: 16 },
|
||||
|
||||
{ id: 25, source: 1, target: 9 },
|
||||
{ id: 26, source: 2, target: 10 },
|
||||
{ id: 27, source: 3, target: 11 },
|
||||
{ id: 28, source: 4, target: 12 },
|
||||
{ id: 29, source: 5, target: 13 },
|
||||
{ id: 30, source: 6, target: 14 },
|
||||
{ id: 31, source: 7, target: 15 },
|
||||
{ id: 32, source: 8, target: 16 },
|
||||
export const cell16 = () => {
|
||||
return {
|
||||
nodes: [
|
||||
{ id: 1, x: 0, y: -1, z: 0, w: 0 },
|
||||
{ id: 2, x: 0, y: 0, z: -1, w: 0 },
|
||||
{ id: 3, x: -1, y: 0, z: 0, w: 0 },
|
||||
{ id: 4, x: 0, y: 0, z: 1, w: 0 },
|
||||
{ id: 5, x: 1, y: 0, z: 0, w: 0 },
|
||||
{ id: 6, x: 0, y: 1, z: 0, w: 0 },
|
||||
{ id: 7, x: 0, y: 0, z: 0, w: -1 },
|
||||
{ id: 8, x: 0, y: 0, z: 0, w: 1 },
|
||||
],
|
||||
links: [
|
||||
{ id: 1, source: 1, target: 2 },
|
||||
{ id: 2, source: 1, target: 3 },
|
||||
{ id: 3, source: 1, target: 4 },
|
||||
{ id: 4, source: 1, target: 5 },
|
||||
{ id: 5, source: 2, target: 3 },
|
||||
{ id: 6, source: 3, target: 4 },
|
||||
{ id: 7, source: 4, target: 5 },
|
||||
{ id: 8, source: 5, target: 2 },
|
||||
{ id: 9, source: 2, target: 6 },
|
||||
{ id: 10, source: 3, target: 6 },
|
||||
{ id: 11, source: 4, target: 6 },
|
||||
{ id: 12, source: 5, target: 6 },
|
||||
{ id: 13, source: 1, target: 7 },
|
||||
{ id: 14, source: 1, target: 8 },
|
||||
{ id: 15, source: 2, target: 7 },
|
||||
{ id: 16, source: 2, target: 8 },
|
||||
{ id: 17, source: 3, target: 7 },
|
||||
{ id: 18, source: 3, target: 8 },
|
||||
{ id: 19, source: 4, target: 7 },
|
||||
{ id: 20, source: 4, target: 8 },
|
||||
{ id: 21, source: 5, target: 7 },
|
||||
{ id: 22, source: 5, target: 8 },
|
||||
{ id: 23, source: 6, target: 7 },
|
||||
{ id: 24, source: 6, target: 8 },
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
]
|
||||
export const tesseract = () => {
|
||||
return {
|
||||
nodes: [
|
||||
{ id: 1, label: 0, x: -0.5, y: -0.5, z: -0.5, w: -0.5 },
|
||||
{ id: 2, label: 1, x: 0.5, y: -0.5, z: -0.5, w: -0.5 },
|
||||
{ id: 3, label: 1, x: -0.5, y: 0.5, z: -0.5, w: -0.5 },
|
||||
{ id: 4, label: 0, x: 0.5, y: 0.5, z: -0.5, w: -0.5 },
|
||||
{ id: 5, label: 1, x: -0.5, y: -0.5, z: 0.5, w: -0.5 },
|
||||
{ id: 6, label: 0, x: 0.5, y: -0.5, z: 0.5, w: -0.5 },
|
||||
{ id: 7, label: 0, x: -0.5, y: 0.5, z: 0.5, w: -0.5 },
|
||||
{ id: 8, label: 1, x: 0.5, y: 0.5, z: 0.5, w: -0.5 },
|
||||
{ id: 9, label: 1, x: -0.5, y: -0.5, z: -0.5, w: 0.5 },
|
||||
{ id: 10, label: 0, x: 0.5, y: -0.5, z: -0.5, w: 0.5 },
|
||||
{ id: 11, label: 0, x: -0.5, y: 0.5, z: -0.5, w: 0.5 },
|
||||
{ id: 12, label: 1, x: 0.5, y: 0.5, z: -0.5, w: 0.5 },
|
||||
{ id: 13, label: 0, x: -0.5, y: -0.5, z: 0.5, w: 0.5 },
|
||||
{ id: 14, label: 1, x: 0.5, y: -0.5, z: 0.5, w: 0.5 },
|
||||
{ id: 15, label: 1, x: -0.5, y: 0.5, z: 0.5, w: 0.5 },
|
||||
{ id: 16, label: 0, x: 0.5, y: 0.5, z: 0.5, w: 0.5 },
|
||||
],
|
||||
links: [
|
||||
{ id: 1, source: 1, target: 2 },
|
||||
{ id: 2, source: 2, target: 4 },
|
||||
{ id: 3, source: 4, target: 3 },
|
||||
{ id: 4, source: 3, target: 1 },
|
||||
{ id: 5, source: 5, target: 6 },
|
||||
{ id: 6, source: 6, target: 8 },
|
||||
{ id: 7, source: 8, target: 7 },
|
||||
{ id: 8, source: 7, target: 5 },
|
||||
{ id: 9, source: 1, target: 5 },
|
||||
{ id: 10, source: 2, target: 6 },
|
||||
{ id: 11, source: 3, target: 7 },
|
||||
{ id: 12, source: 4, target: 8 },
|
||||
|
||||
{ id: 13, source: 9, target: 10 },
|
||||
{ id: 14, source: 10, target: 12 },
|
||||
{ id: 15, source: 12, target: 11 },
|
||||
{ id: 16, source: 11, target: 9 },
|
||||
{ id: 17, source: 13, target: 14 },
|
||||
{ id: 18, source: 14, target: 16 },
|
||||
{ id: 19, source: 16, target: 15 },
|
||||
{ id: 20, source: 15, target: 13 },
|
||||
{ id: 21, source: 9, target: 13 },
|
||||
{ id: 22, source: 10, target: 14 },
|
||||
{ id: 23, source: 11, target: 15 },
|
||||
{ id: 24, source: 12, target: 16 },
|
||||
|
||||
{ id: 25, source: 1, target: 9 },
|
||||
{ id: 26, source: 2, target: 10 },
|
||||
{ id: 27, source: 3, target: 11 },
|
||||
{ id: 28, source: 4, target: 12 },
|
||||
{ id: 29, source: 5, target: 13 },
|
||||
{ id: 30, source: 6, target: 14 },
|
||||
{ id: 31, source: 7, target: 15 },
|
||||
{ id: 32, source: 8, target: 16 },
|
||||
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
// this was done manually and I'm not sure if it's right
|
||||
|
|
Loading…
Reference in New Issue