Skip to content

Commit

Permalink
Merge pull request #20649 from gonnavis/webgl_gpgpu_birds_gltf_cohesi…
Browse files Browse the repository at this point in the history
…on_0_error

Fix examples/webgl_gpgpu_birds_gltf.html cohesion 0 error
  • Loading branch information
mrdoob committed Nov 10, 2020
2 parents 4be008d + 5780351 commit 6e7f347
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion examples/webgl_gpgpu_birds.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@

// Attraction / Cohesion - move closer
float threshDelta = 1.0 - alignmentThresh;
float adjustedPercent = ( percent - alignmentThresh ) / threshDelta;
float adjustedPercent;
if( threshDelta == 0. ) adjustedPercent = 1.;
else adjustedPercent = ( percent - alignmentThresh ) / threshDelta;

f = ( 0.5 - ( cos( adjustedPercent * PI_2 ) * -0.5 + 0.5 ) ) * delta;

Expand Down
4 changes: 3 additions & 1 deletion examples/webgl_gpgpu_birds_gltf.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@

// Attraction / Cohesion - move closer
float threshDelta = 1.0 - alignmentThresh;
float adjustedPercent = ( percent - alignmentThresh ) / threshDelta;
float adjustedPercent;
if( threshDelta == 0. ) adjustedPercent = 1.;
else adjustedPercent = ( percent - alignmentThresh ) / threshDelta;

f = ( 0.5 - ( cos( adjustedPercent * PI_2 ) * -0.5 + 0.5 ) ) * delta;

Expand Down

0 comments on commit 6e7f347

Please sign in to comment.