Standardise polytopes, tested more labelling, inverted colours

feature-big-polytopes
Mike Lynch 2023-07-25 09:55:33 +10:00
parent 4cc2b44e00
commit 55573bac0b
2 changed files with 146 additions and 132 deletions

42
main.js
View File

@ -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);

View File

@ -1,9 +1,8 @@
export const cell5 = () => {
const r5 = Math.sqrt(5);
// if nodes or links have no label, use the first material in the
// list
export const CELL5 = {
return {
nodes: [
{id:1, x: 1, y: 1, z: 1, w: -1 / r5 },
{id:2, x: 1, y: -1, z: -1, w: -1 / r5 },
@ -23,11 +22,12 @@ export const CELL5 = {
{ id:9, source:3, target: 5},
{ id:10, source:4, target: 5},
]
};
};
export const CELL16 = {
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 },
@ -62,29 +62,31 @@ export const CELL16 = {
{ id: 21, source: 5, target: 7 },
{ id: 22, source: 5, target: 8 },
{ id: 23, source: 6, target: 7 },
{ id: 25, source: 6, target: 8 },
{ id: 24, source: 6, target: 8 },
]
}
};
export const TESSERACT = {
export const tesseract = () => {
return {
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 },
{ 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 },
@ -122,8 +124,8 @@ export const TESSERACT = {
{ 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