From bf8824a43e302e7ea1ea22e7ec963243291d1ce6 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Wed, 2 Aug 2023 16:58:51 +1000 Subject: [PATCH] Added basic automatic colour schemes and colourised the first 24-cell of the 600-cell --- colours.js | 8 ++++++++ main.js | 4 +++- package-lock.json | 6 ++++++ package.json | 1 + polytopes.js | 6 +++--- 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 colours.js diff --git a/colours.js b/colours.js new file mode 100644 index 0000000..afe8ce2 --- /dev/null +++ b/colours.js @@ -0,0 +1,8 @@ +import ColorScheme from 'color-scheme'; + +export const get_colours = () => { + var scheme = new ColorScheme; + scheme.from_hue(21).scheme('triade').variation('soft'); + return scheme.colors().map((cs) => parseInt('0x' + cs)); +} + diff --git a/main.js b/main.js index 892aa68..03425e8 100644 --- a/main.js +++ b/main.js @@ -6,6 +6,7 @@ import * as POLYTOPES from './polytopes.js'; import { rotfn } from './rotation.js'; import { FourDGUI } from './gui.js'; import { FourDShape } from './fourDShape.js'; +import { get_colours } from './colours.js'; // scene, lights and camera @@ -30,8 +31,9 @@ document.body.appendChild( renderer.domElement ); scene.background = new THREE.Color(0x808080); const material = new THREE.MeshStandardMaterial({ color: 0x3293a9 }); +const node_colours = get_colours(); -const node_ms = [ material ]; +const node_ms = node_colours.map((c) => new THREE.MeshStandardMaterial({color: c})); const link_ms = [ material ]; diff --git a/package-lock.json b/package-lock.json index 643cdbd..6408437 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "packages": { "": { "dependencies": { + "color-scheme": "^1.0.1", "lil-gui": "^0.18.2", "three": "^0.154.0" }, @@ -364,6 +365,11 @@ "node": ">=12" } }, + "node_modules/color-scheme": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/color-scheme/-/color-scheme-1.0.1.tgz", + "integrity": "sha512-4x+ya6+z6g9DaTFSfVzTZc8TSjxHuDT40NB43N3XPUkQlF6uujhwH8aeMeq8HBgoQQog/vrYgJ16mt/eVTRXwQ==" + }, "node_modules/esbuild": { "version": "0.18.15", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.15.tgz", diff --git a/package.json b/package.json index 5bb9681..ef901da 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "color-scheme": "^1.0.1", "lil-gui": "^0.18.2", "three": "^0.154.0" }, diff --git a/polytopes.js b/polytopes.js index affc219..304caf7 100644 --- a/polytopes.js +++ b/polytopes.js @@ -176,9 +176,9 @@ function make_600cell_vertices() { const nodes = [ PERMUTE.coordinates([0, 0, 0, 2], 0), - PERMUTE.coordinates([1, 1, 1, 1], 0), + PERMUTE.coordinates([1, 1, 1, 1], 1), - PERMUTE.coordinates([phi, 1, 1 / phi, 0], 0, true) + PERMUTE.coordinates([phi, 1, 1 / phi, 0], 1, true) ].flat(); return scale_and_index(nodes, 0.75); } @@ -191,7 +191,7 @@ export const cell600 = () => { nodes: nodes, links: links, geometry: { - node_size: 0.02, + node_size: 0.08, link_size: 0.02 } }