Documentation
¶
Index ¶
- func NodeDimensions(n *node.Node) (w, h float64)
- func ShouldCull(n *node.Node, viewWorld [6]float64, cullBounds types.Rect) bool
- func WorldAABB(transform [6]float64, w, h float64) types.Rect
- type Camera
- func (c *Camera) ClampToBounds()
- func (c *Camera) ClearBounds()
- func (c *Camera) ComputeViewMatrix() [6]float64
- func (c *Camera) Follow(n *node.Node, offsetX, offsetY, lerp float64)
- func (c *Camera) Invalidate()
- func (c *Camera) IsDirty() bool
- func (c *Camera) ScreenToWorld(sx, sy float64) (wx, wy float64)
- func (c *Camera) ScrollTo(x, y float64, cfg types.TweenConfig)
- func (c *Camera) ScrollToTile(tileX, tileY int, tileW, tileH float64, cfg types.TweenConfig)
- func (c *Camera) ScrollTweenActive() bool
- func (c *Camera) SetBounds(bounds types.Rect)
- func (c *Camera) Unfollow()
- func (c *Camera) Update(dt float32)
- func (c *Camera) VisibleBounds() types.Rect
- func (c *Camera) WorldToScreen(wx, wy float64) (sx, sy float64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NodeDimensions ¶
NodeDimensions returns the width and height used for AABB culling.
func ShouldCull ¶
ShouldCull returns true if the node should be skipped during rendering. viewWorld is the coordinate-space transform used for AABB computation (typically view * worldTransform for screen-space culling). Containers are never culled. Text nodes are culled when measured dimensions are available.
Types ¶
type Camera ¶
type Camera struct {
// X and Y are the world-space position the camera centers on.
X, Y float64
// Zoom is the scale factor (1.0 = no zoom, >1 = zoom in, <1 = zoom out).
Zoom float64
// Rotation is the camera rotation in radians (clockwise).
Rotation float64
// Viewport is the screen-space rectangle this camera renders into.
Viewport types.Rect
// CullEnabled skips nodes whose world AABB doesn't intersect the
// camera's visible bounds.
CullEnabled bool
// BoundsEnabled clamps the camera position so the visible area stays
// within Bounds.
BoundsEnabled bool
// Bounds is the world-space rectangle the camera is clamped to when
// BoundsEnabled is true.
Bounds types.Rect
// contains filtered or unexported fields
}
Camera controls the view into the scene: position, zoom, rotation, and viewport.
func (*Camera) ClampToBounds ¶
func (c *Camera) ClampToBounds()
ClampToBounds immediately clamps the camera position so the visible area stays within Bounds. Call this after modifying X/Y directly (e.g. in a drag callback) to prevent a single frame where the camera sees outside the bounds. No-op if BoundsEnabled is false.
func (*Camera) ClearBounds ¶
func (c *Camera) ClearBounds()
ClearBounds disables camera bounds clamping.
func (*Camera) ComputeViewMatrix ¶
ComputeViewMatrix recomputes the cached view matrix if dirty.
viewMatrix = Translate(cx, cy) * Scale(zoom) * Rotate(-rotation) * Translate(-X, -Y) where cx, cy = viewport center.
func (*Camera) Follow ¶
Follow makes the camera track a target node with the given offset and lerp factor. A lerp of 1.0 snaps immediately; lower values give smoother following.
func (*Camera) Invalidate ¶
func (c *Camera) Invalidate()
Invalidate forces a recomputation of the view matrix.
func (*Camera) ScreenToWorld ¶
ScreenToWorld converts screen coordinates to world coordinates.
func (*Camera) ScrollTo ¶
func (c *Camera) ScrollTo(x, y float64, cfg types.TweenConfig)
ScrollTo animates the camera to the given world position using the provided TweenConfig for duration and easing.
func (*Camera) ScrollToTile ¶
func (c *Camera) ScrollToTile(tileX, tileY int, tileW, tileH float64, cfg types.TweenConfig)
ScrollToTile scrolls to the center of the given tile in a tile-based layout.
func (*Camera) ScrollTweenActive ¶
ScrollTweenActive reports whether a scroll animation is in progress.
func (*Camera) Unfollow ¶
func (c *Camera) Unfollow()
Unfollow stops tracking the current target node.
func (*Camera) Update ¶
Update advances follow, scroll, and bounds clamping. Called from Scene.Update().
func (*Camera) VisibleBounds ¶
VisibleBounds returns the axis-aligned bounding rect of the camera's visible area in world space.
func (*Camera) WorldToScreen ¶
WorldToScreen converts world coordinates to screen coordinates.