Automatically adjusts camera zoom to keep multiple targets in frame. Useful for arena brawlers, co-op, and boss fights.
Usage:
const zoom = new DynamicZoom(scene, { minZoom: 0.5, maxZoom: 2, padding: 100 });zoom.addTarget(player);zoom.addTarget(boss);zoom.update(); // call each frame Copy
const zoom = new DynamicZoom(scene, { minZoom: 0.5, maxZoom: 2, padding: 100 });zoom.addTarget(player);zoom.addTarget(boss);zoom.update(); // call each frame
Optional
Add a zoom target
Remove all targets
Get the weighted center of all targets
Get the current computed zoom level
Set targets directly
Update zoom and camera position to frame all targets. Call each frame.
Automatically adjusts camera zoom to keep multiple targets in frame. Useful for arena brawlers, co-op, and boss fights.
Usage: