فهرست منبع

Merge pull request #20649 from gonnavis/webgl_gpgpu_birds_gltf_cohesion_0_error

Fix examples/webgl_gpgpu_birds_gltf.html cohesion 0 error
Mr.doob 4 سال پیش
والد
کامیت
6e7f3478f6
2فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 3 1
      examples/webgl_gpgpu_birds.html
  2. 3 1
      examples/webgl_gpgpu_birds_gltf.html

+ 3 - 1
examples/webgl_gpgpu_birds.html

@@ -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;
 

+ 3 - 1
examples/webgl_gpgpu_birds_gltf.html

@@ -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;