From fb9c78d82fb981855b531067126397f53c115016 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Fri, 26 Apr 2024 08:59:26 +1000 Subject: [PATCH] Fixed some scale problems --- fourDShape.js | 10 ++++------ gui.js | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/fourDShape.js b/fourDShape.js index bbf4269..7716066 100644 --- a/fourDShape.js +++ b/fourDShape.js @@ -15,10 +15,8 @@ class FourDShape extends THREE.Group { this.nodes3 = {}; this.links = structure.links; this.faces = ( "faces" in structure ) ? structure.faces : []; - this.node_size = structure.geometry.node_size; - this.link_size = structure.geometry.link_size; - this.node_scale = 1; - this.link_scale = 1; + this.node_scale = structure.geometry.node_size; + this.link_scale = structure.geometry.link_size; this.hyperplane = HYPERPLANE; this.initShapes(); } @@ -51,7 +49,7 @@ class FourDShape extends THREE.Group { const length = n1.v3.distanceTo(n2.v3); const centre = new THREE.Vector3(); centre.lerpVectors(n1.v3, n2.v3, 0.5); - const geometry = new THREE.CylinderGeometry(this.link_size * s2, this.link_size * s1, 1); + const geometry = new THREE.CylinderGeometry(this.link_scale * s2, this.link_scale * s1, 1); const cyl = new THREE.Mesh(geometry, material); const edge = new THREE.Group(); edge.add(cyl); @@ -71,7 +69,7 @@ class FourDShape extends THREE.Group { const length = n1.v3.distanceTo(n2.v3); const centre = new THREE.Vector3(); centre.lerpVectors(n1.v3, n2.v3, 0.5); - link.object.scale.copy(new THREE.Vector3(this.link_size * s2, this.link_size * s1, length)); + link.object.scale.copy(new THREE.Vector3(this.link_scale * s2, this.link_scale * s1, length)); link.object.position.copy(centre); link.object.lookAt(n2.v3); link.object.children[0].rotation.x = Math.PI / 2.0; diff --git a/gui.js b/gui.js index 475be10..effa87e 100644 --- a/gui.js +++ b/gui.js @@ -2,8 +2,8 @@ import { GUI } from 'lil-gui'; const DEFAULTS = { - thickness: 0.5, - nodesize: 1.5, + thickness: 0.02, + nodesize: 0.02, linkopacity: 0.5, link2opacity: 0.5, shape: '120-cell', @@ -74,7 +74,7 @@ class FourDGUI { this.gui.add(this.params, 'link2opacity', 0, 1).onChange( (v) => setLinkOpacity(v, false) ); - this.gui.add(this.params, 'nodesize', 0.1, 4); + this.gui.add(this.params, 'nodesize', 0, 1); this.gui.addColor(this.params, 'color').onChange(setColor); this.gui.addColor(this.params, 'background').onChange(setBackground); this.gui.add(this.params, 'xRotate', [ 'YW', 'YZ', 'ZW' ]);