(camera, target, dampingValue, dt)
| 1583 | */ |
| 1584 | describe("smooth-follow frame-rate independence", () => { |
| 1585 | const runOneFrame = (camera, target, dampingValue, dt) => { |
| 1586 | // Widen bounds past camera dimensions — `_followH` clamps to |
| 1587 | // `bounds.width - camera.width`, which is 0 for the setup |
| 1588 | // default (1000 bounds, 1000 camera). Then nuke the deadzone: |
| 1589 | // `setDeadzone(0, 0)` zeroes its size but still positions it |
| 1590 | // at camera-center (~500, 500), which makes _followH compare |
| 1591 | // against half-camera offsets. We want a clean math test, so |
| 1592 | // override `deadzone.pos` to (0, 0) too — that way _followH |
| 1593 | // becomes `targetX = min(target.x, bounds.right)` and the |
| 1594 | // gap the camera closes is exactly `target.x - camera.pos.x`. |
| 1595 | camera.setBounds(0, 0, 5000, 5000); |
| 1596 | camera.setDeadzone(0, 0); |
| 1597 | camera.deadzone.pos.set(0, 0); |
| 1598 | camera.pos.set(0, 0, 0); |
| 1599 | camera.follow(target, camera.AXIS.BOTH, dampingValue); |
| 1600 | // follow() runs one updateTarget() internally; reset position |
| 1601 | // so the test's explicit updateTarget() runs against the |
| 1602 | // known starting state, not the post-follow snapshot. |
| 1603 | camera.pos.set(0, 0, 0); |
| 1604 | camera.updateTarget(dt); |
| 1605 | return camera.pos.x; |
| 1606 | }; |
| 1607 | |
| 1608 | it("preserves the legacy per-frame fraction at the configured target framerate (60fps default)", () => { |
| 1609 | const { camera } = setup(); |
no test coverage detected