Weirdness - the glitchiness is coming and going depending on whether
the clipping plane is enabled, or the cylinders added?
This commit is contained in:
parent
bf55db9f75
commit
4695423931
6
gui.js
6
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,
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -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 };
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user