Fixed node colours from params

experiments-120-cell
Mike Lynch 2023-08-04 15:28:08 +10:00
parent db5630cf5a
commit b96fa62a08
1 changed files with 17 additions and 13 deletions

20
main.js
View File

@ -62,20 +62,24 @@ function createShape(name) {
// callbacks to do things which are triggered by controls: reset the shape, // callbacks to do things which are triggered by controls: reset the shape,
// change the colors. Otherwise we just read stuff from gui.params. // change the colors. Otherwise we just read stuff from gui.params.
const gui = new FourDGUI( function setColors(c) {
createShape,
(c) => {
const nc = get_colours(c); const nc = get_colours(c);
for( let i = 0; i < node_ms.length; i++ ) { for( let i = 0; i < node_ms.length; i++ ) {
node_ms[i].color = new THREE.Color(nc[i]); node_ms[i].color = new THREE.Color(nc[i]);
} }
material.color = new THREE.Color(c); material.color = new THREE.Color(c);
}, }
(c) => { scene.background = new THREE.Color(c) },
);
material.color = new THREE.Color(gui.params.color); function setBackground(c) {
scene.background = new THREE.Color(gui.params.background); scene.background = new THREE.Color(c)
}
const gui = new FourDGUI(createShape, setColors, setBackground);
// these are here to pick up colour settings from the URL params
setColors(gui.params.color);
setBackground(gui.params.background);
const dragK = 0.005; const dragK = 0.005;
const damping = 0.99; const damping = 0.99;