(e)
| 436 | } |
| 437 | } |
| 438 | update(e) { |
| 439 | const { config: t, center: i, positionData: s, sizeData: n, velocityData: o } = this; |
| 440 | let r = 0; |
| 441 | if (t.controlSphere0) { |
| 442 | r = 1; |
| 443 | F.fromArray(s, 0); |
| 444 | F.lerp(i, 0.1).toArray(s, 0); |
| 445 | V.set(0, 0, 0).toArray(o, 0); |
| 446 | } |
| 447 | for (let idx = r; idx < t.count; idx++) { |
| 448 | const base = 3 * idx; |
| 449 | I.fromArray(s, base); |
| 450 | B.fromArray(o, base); |
| 451 | B.y -= e.delta * t.gravity * n[idx]; |
| 452 | B.multiplyScalar(t.friction); |
| 453 | B.clampLength(0, t.maxVelocity); |
| 454 | I.add(B); |
| 455 | I.toArray(s, base); |
| 456 | B.toArray(o, base); |
| 457 | } |
| 458 | for (let idx = r; idx < t.count; idx++) { |
| 459 | const base = 3 * idx; |
| 460 | I.fromArray(s, base); |
| 461 | B.fromArray(o, base); |
| 462 | const radius = n[idx]; |
| 463 | for (let jdx = idx + 1; jdx < t.count; jdx++) { |
| 464 | const otherBase = 3 * jdx; |
| 465 | O.fromArray(s, otherBase); |
| 466 | N.fromArray(o, otherBase); |
| 467 | const otherRadius = n[jdx]; |
| 468 | _.copy(O).sub(I); |
| 469 | const dist = _.length(); |
| 470 | const sumRadius = radius + otherRadius; |
| 471 | if (dist < sumRadius) { |
| 472 | const overlap = sumRadius - dist; |
| 473 | j.copy(_) |
| 474 | .normalize() |
| 475 | .multiplyScalar(0.5 * overlap); |
| 476 | H.copy(j).multiplyScalar(Math.max(B.length(), 1)); |
| 477 | T.copy(j).multiplyScalar(Math.max(N.length(), 1)); |
| 478 | I.sub(j); |
| 479 | B.sub(H); |
| 480 | I.toArray(s, base); |
| 481 | B.toArray(o, base); |
| 482 | O.add(j); |
| 483 | N.add(T); |
| 484 | O.toArray(s, otherBase); |
| 485 | N.toArray(o, otherBase); |
| 486 | } |
| 487 | } |
| 488 | if (t.controlSphere0) { |
| 489 | _.copy(F).sub(I); |
| 490 | const dist = _.length(); |
| 491 | const sumRadius0 = radius + n[0]; |
| 492 | if (dist < sumRadius0) { |
| 493 | const diff = sumRadius0 - dist; |
| 494 | j.copy(_.normalize()).multiplyScalar(diff); |
| 495 | H.copy(j).multiplyScalar(Math.max(B.length(), 2)); |
no test coverage detected