Skip to content

Commit b36ce9e

Browse files
gonnavisMugen87
andauthored
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]>
1 parent 1dd66f3 commit b36ce9e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed
-686 Bytes
Loading

examples/webgl_gpgpu_birds.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@
318318

319319
super();
320320

321-
const triangles = BIRDS * 3;
321+
const trianglesPerBird = 3;
322+
const triangles = BIRDS * trianglesPerBird;
322323
const points = triangles * 3;
323324

324325
const vertices = new THREE.BufferAttribute( new Float32Array( points * 3 ), 3 );
@@ -375,9 +376,10 @@
375376

376377
for ( let v = 0; v < triangles * 3; v ++ ) {
377378

378-
const i = ~ ~ ( v / 3 );
379-
const x = ( i % WIDTH ) / WIDTH;
380-
const y = ~ ~ ( i / WIDTH ) / WIDTH;
379+
const triangleIndex = ~ ~ ( v / 3 );
380+
const birdIndex = ~ ~ ( triangleIndex / trianglesPerBird )
381+
const x = ( birdIndex % WIDTH ) / WIDTH;
382+
const y = ~ ~ ( birdIndex / WIDTH ) / WIDTH;
381383

382384
const c = new THREE.Color(
383385
0x444444 +

0 commit comments

Comments
 (0)