Skip to content

Commit fcad0c7

Browse files
committed
feat: improve boids implem in JS
1 parent 604bb0e commit fcad0c7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

demos/src/three/gpgpu.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function computeVelocities(
8181
const diff = subtract(selfPosition, otherPosition);
8282
const distance = length(diff);
8383

84-
const isInFieldOfView = dot(normalize(selfVelocity), normalize(subtract(otherPosition, selfPosition))) > 0.5;
84+
const isInFieldOfView = dot(normalize(selfVelocity), normalize(subtract(otherPosition, selfPosition))) > 0;
8585

8686
if (isInFieldOfView && (!skipFirst || i > 0)) {
8787
// Alignment - align with the direction of other boids
@@ -120,7 +120,7 @@ export function computeVelocities(
120120

121121
// Keep boids within bounds
122122
const distToCenter = length(selfPosition);
123-
acceleration = add(acceleration, scale(selfPosition, -distToCenter * 0.0003));
123+
acceleration = add(acceleration, scale(selfPosition, -distToCenter * 0.0004));
124124

125125
velocity = add(velocity, scale(acceleration, deltaTime));
126126

0 commit comments

Comments
 (0)