From 469542393116ebb0bfe5cb7fef95a7aba414efc8 Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Sun, 9 Nov 2025 11:20:16 +1100 Subject: [PATCH] Weirdness - the glitchiness is coming and going depending on whether the clipping plane is enabled, or the cylinders added? --- gui.js | 6 +++--- polytopes.js | 4 ++-- taperedLink.js | 40 +++++++++++++++++++++++++++++++--------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/gui.js b/gui.js index 5c0d57e..c7fc05b 100644 --- a/gui.js +++ b/gui.js @@ -2,12 +2,12 @@ import { GUI } from 'lil-gui'; const DEFAULTS = { - nodesize: 4, + nodesize: 1, nodeopacity: 1, linksize: 1.0, - linkopacity: 0.75, + linkopacity: 1, link2opacity: 0.75, - shape: 'linky', + shape: '5-cell', option: 'none', visibility: 5, inscribed: false, diff --git a/polytopes.js b/polytopes.js index fe69529..d39a834 100644 --- a/polytopes.js +++ b/polytopes.js @@ -865,7 +865,7 @@ export const icosahedron = () => { export const build_all = () => { return [ linkTest(), -/* tetrahedron(), + tetrahedron(), octahedron(), cube(), icosahedron(), @@ -879,7 +879,7 @@ export const build_all = () => { cell600_layered(), cell120_inscribed(), cell120_layered() - */ ]; + ]; } export const radii = (shape) => { diff --git a/taperedLink.js b/taperedLink.js index 24cb729..0d6a6f3 100644 --- a/taperedLink.js +++ b/taperedLink.js @@ -6,16 +6,28 @@ class TaperedLink extends THREE.Group { constructor(baseMaterial, n1, n2, r1, r2) { super(); - const geometry = new THREE.ConeGeometry( 0.75, 1, 32, true ); + const cone = new THREE.ConeGeometry( 0.75, 1, 32, true ); const cplane = new THREE.Plane(new THREE.Vector3(0, -1, 0), 0.5); const material = baseMaterial.clone(); - material.clippingPlanes = [ cplane ]; - this.cone = new THREE.Mesh( geometry, material ); + //material.clippingPlanes = [ cplane ]; + this.cone = new THREE.Mesh( cone, material ); this.add( this.cone ); + const cylinder = new THREE.CylinderGeometry(1, 1, 1, 16, 1, true); + const cyl_material = baseMaterial.clone(); + cyl_material.color = new THREE.Color(0xff0000); + this.cylinder = new THREE.Mesh(cylinder, cyl_material); + this.add( this.cylinder ); this.update(n1, n2, r1, r2); - } + } - update(n1, n2, r1, r2) { +// mystery - commenting out the cylinder stuff makes the glitchiness return! + + update(n1, n2, r1, r2) { + this.update_cone(n1, n2, r1, r2); + this.update_cylinder(n1, n2, r1, r2); + } + + update_cone(n1, n2, r1, r2) { const kraw = r1 - r2; let k = ( kraw == 0 ) ? 0.001 : kraw; let nbase = n1.v3; @@ -54,11 +66,21 @@ class TaperedLink extends THREE.Group { clipnorm.sub(nbase); clipnorm.negate(); clipnorm.normalize(); - this.cone.material.clippingPlanes[0].setFromNormalAndCoplanarPoint( - clipnorm, napex - ); + //this.cone.material.clippingPlanes[0].setFromNormalAndCoplanarPoint( + // clipnorm, napex + // ); } + update_cylinder(n1, n2, r1, r2) { + const length = n1.v3.distanceTo(n2.v3); + const centre = new THREE.Vector3(); + centre.lerpVectors(n1.v3, n2.v3, 0.5); + const link_mean = (r1 + r2) * 0.5; + this.cylinder.scale.copy(new THREE.Vector3(link_mean, link_mean, length)); + this.cylinder.position.copy(centre); + this.lookAt(n2.v3); + this.cylinder.rotation.x = Math.PI / 2.0; + + } } - export { TaperedLink };