Skip to content

Commit

Permalink
fixed a bug in rendering of forces
Browse files Browse the repository at this point in the history
  • Loading branch information
benjym committed Aug 4, 2023
1 parent 693e275 commit 339b923
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions libs/SphereHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,8 @@ export async function draw_force_network(S, params, scene) {
else {

var F = await S.simu_getContactInfos(0x80 | 0x100);

let width = radii[0] / 2.;
console.log(F.length)
let width = params.r_min;
if ('F_mag_max' in params) {
F_mag_max = params.F_mag_max;
} else {
Expand Down Expand Up @@ -670,14 +670,17 @@ export async function draw_force_network(S, params, scene) {
let b = spheres.children[F[i][1]].position;
let distance = a.distanceTo(b);

if ( (F[i][0] == 0) || (F[i][1] == 0) ) { // first particle
console.log(F_mag);
}

if (spheres.children[F[i][0]].visible && spheres.children[F[i][1]].visible) {
if (distance < (radii[F[i][0]] + radii[F[i][1]])) { // ignore periodic boundaries
let mid_point = new THREE.Vector3();
mid_point.addVectors(a, b);
mid_point.divideScalar(2);
c.position.copy(mid_point);
let scale = width
// if (F_mag > F_mag_max) { scale = width }
let scale = width; // nothing bigger than this
if (F_mag < F_mag_max) { scale = width * F_mag / F_mag_max; }
if ( scale > 0. ) {
c.scale.set(scale,
Expand All @@ -688,7 +691,7 @@ export async function draw_force_network(S, params, scene) {

// c.material.emissiveIntensity = F_mag/F_mag_max;
c.visible = true;
forces.add(c);
// forces.add(c);
// console.log(scale)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/isotropic.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function animate() {
if (AUDIO.listener !== undefined) {
SPHERES.update_fixed_sounds(S, params);
}

// console.log(params.r_min)
SPHERES.draw_force_network(S, params, scene);

if ( params.loading_active ) { start_button.visible = false; stop_button.visible = true; }
Expand Down

0 comments on commit 339b923

Please sign in to comment.