Jelajahi Sumber

Fix webgl_gpgpu_birds references error (#20675)

* fix_webgl_gpgpu_birds_index_error

* screenshot

* Restore Left Right names

* Update webgl_gpgpu_birds.html

Co-authored-by: Michael Herzog <[email protected]>
Vis 4 tahun lalu
induk
melakukan
b36ce9e683
2 mengubah file dengan 6 tambahan dan 4 penghapusan
  1. TEMPAT SAMPAH
      examples/screenshots/webgl_gpgpu_birds.jpg
  2. 6 4
      examples/webgl_gpgpu_birds.html

TEMPAT SAMPAH
examples/screenshots/webgl_gpgpu_birds.jpg


+ 6 - 4
examples/webgl_gpgpu_birds.html

@@ -318,7 +318,8 @@
 
 					super();
 
-					const triangles = BIRDS * 3;
+					const trianglesPerBird = 3;
+					const triangles = BIRDS * trianglesPerBird;
 					const points = triangles * 3;
 
 					const vertices = new THREE.BufferAttribute( new Float32Array( points * 3 ), 3 );
@@ -375,9 +376,10 @@
 
 					for ( let v = 0; v < triangles * 3; v ++ ) {
 
-						const i = ~ ~ ( v / 3 );
-						const x = ( i % WIDTH ) / WIDTH;
-						const y = ~ ~ ( i / WIDTH ) / WIDTH;
+						const triangleIndex = ~ ~ ( v / 3 );
+						const birdIndex = ~ ~ ( triangleIndex / trianglesPerBird )
+						const x = ( birdIndex % WIDTH ) / WIDTH;
+						const y = ~ ~ ( birdIndex / WIDTH ) / WIDTH;
 
 						const c = new THREE.Color(
 							0x444444 +