Documentation
¶
Index ¶
- func ClampZoom(c *Camera)
- func MustRegisterECS(w *ecs.World) ecs.Comp[Camera]
- func RegisterECS(w *ecs.World) (ecs.Comp[Camera], error)
- func ViewProj(c Camera, vpW, vpH float32) [16]float32
- type Camera
- func (c *Camera) ClampToBounds(worldW, worldH, vpW, vpH float32)
- func (c *Camera) Fit(worldW, worldH, vpW, vpH float32)
- func (c *Camera) LocalToWorld(lx, ly, vpW, vpH float32) (float32, float32)
- func (c *Camera) Pan(dx, dy float32)
- func (c *Camera) WorldToLocal(wx, wy, vpW, vpH float32) (float32, float32)
- func (c *Camera) ZoomAt(factor, cursorX, cursorY, vpW, vpH float32)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRegisterECS ¶
MustRegisterECS is RegisterECS, panicking on error.
func RegisterECS ¶
RegisterECS registers the Camera component type and returns the handle used to reach it. The handle is the only way to read or write a Camera, so a caller keeps what this returns.
Types ¶
type Camera ¶
type Camera struct {
X, Y float32
Zoom float32
MinZoom float32
MaxZoom float32
Active uint8 // 1 = primary camera
}
Camera is an ECS 2D camera component and the single source of truth for all view state (position, zoom, limits).
func (*Camera) ClampToBounds ¶
ClampToBounds keeps the visible region from drifting off the world.
func (*Camera) Fit ¶
Fit centres the camera on the world and picks a zoom that shows the whole world inside the viewport, clamped to [MinZoom, MaxZoom].
func (*Camera) LocalToWorld ¶
LocalToWorld converts a local viewport pixel to world coordinates.
func (*Camera) Pan ¶
Pan moves the view by (dx, dy) in local viewport pixels. Dragging right (positive dx) shifts the world left. Dragging down (positive dy) shifts the world down (camera Y decreases).
func (*Camera) WorldToLocal ¶
WorldToLocal converts a world point to local viewport pixels.