Very cursed but entertaining bug as I try to get links scaling well
parent
6f4d4cc633
commit
3f83bde533
|
@ -71,16 +71,35 @@ class FourDShape extends THREE.Group {
|
|||
const centre = new THREE.Vector3();
|
||||
centre.lerpVectors(n1.v3, n2.v3, 0.5);
|
||||
// is this really the only way to do this?
|
||||
const geometry = new THREE.CylinderGeometry(this.link_scale * s2, this.link_scale * s1, 1);
|
||||
link.object.children[0].geometry.dispose();
|
||||
link.object.children[0].geometry = geometry;
|
||||
//const geometry = new THREE.CylinderGeometry(this.link_scale * s2, this.link_scale * s1, 1);
|
||||
//link.object.children[0].geometry.dispose();
|
||||
this.forshortenLink(link.object.children[0].geometry, this.link_scale * s2, this.link_scale * s1);
|
||||
//const link_hack = this.link_scale * (s1 + s2) * 0.5;
|
||||
link.object.scale.copy(new THREE.Vector3(1, 1, length));
|
||||
link.object.position.copy(centre);
|
||||
link.object.lookAt(n2.v3);
|
||||
link.object.children[0].rotation.x = Math.PI / 2.0;
|
||||
// link.object.children[0].geometry.needsUpdate = true;
|
||||
// link.object.children[0].geometry.computeVertexNormals();
|
||||
link.object.visible = (!links_show || link.label in links_show);
|
||||
}
|
||||
|
||||
forshortenLink(geometry, top, bottom) {
|
||||
const count = geometry.attributes.position.count;
|
||||
for( let i = 0; i < count; i++ ) {
|
||||
const x = geometry.attributes.position.getX(i);
|
||||
const y = geometry.attributes.position.getY(i);
|
||||
const z = geometry.attributes.position.getZ(i);
|
||||
if( z == 0 ) {
|
||||
geometry.attributes.position.setX(i, x * top);
|
||||
geometry.attributes.position.setY(i, y * top);
|
||||
} else {
|
||||
geometry.attributes.position.setX(i, x * bottom);
|
||||
geometry.attributes.position.setY(i, y * bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setFaceGeometry(face, geometry) {
|
||||
const values = [];
|
||||
|
|
Loading…
Reference in New Issue