Skip to content

Add satellite names system - Entity hierarchy with animations - #23

Open
wannerdev wants to merge 1 commit into
mainfrom
feature/satellite-names-entity-hierarchy
Open

Add satellite names system - Entity hierarchy with animations#23
wannerdev wants to merge 1 commit into
mainfrom
feature/satellite-names-entity-hierarchy

Conversation

@wannerdev

Copy link
Copy Markdown
Owner

Description

Alternative implementation of satellite naming system with fade animations, zoom-based visibility, and enhanced visual polish.

Implementation Approach

This is Implementation B - Entity Hierarchy approach with animations and dynamic visibility.

Key Differences from Implementation A

  • Fade Animations: Labels fade in over 0.5 seconds when spawned
  • Zoom-Based Visibility: Labels hide when zoomed out (levels 3-4)
  • Orphan Cleanup: Automatic cleanup of labels when satellites despawn
  • Smooth Transitions: Visual polish with animated appearance

Changes

  • Created satellite_names_advanced module
  • Added LabelFade component for animation state
  • Implemented animate_label_fade system for smooth transitions
  • Added update_label_visibility system for zoom-based hiding
  • Implemented cleanup_orphaned_labels for automatic cleanup
  • Labels start at 0% alpha and fade to 90% over 0.5 seconds
  • Integrated into both mouse and touch launch functions

Animation System

Fade-In Animation

LabelFade {
    elapsed: 0.0,
    duration: 0.5,
    fade_in: true,
}
  • Labels spawn with 0% alpha (transparent)
  • Fade to 90% alpha over 0.5 seconds
  • Smooth transition using linear interpolation
  • Component removed after animation completes

Zoom-Based Visibility

  • Zoom Levels 0-2: Labels visible (zoomed in)
  • Zoom Levels 3-4: Labels hidden (zoomed out)
  • Prevents label clutter when viewing full solar system
  • Automatic visibility updates based on camera zoom

Orphan Cleanup

  • Checks if parent satellite still exists
  • Automatically despawns labels of destroyed satellites
  • Prevents memory leaks from orphaned entities
  • Runs every frame for immediate cleanup

Technical Implementation

Fade Animation System

  • Queries labels with LabelFade component
  • Updates alpha based on elapsed time
  • Uses clamp(0.0, 1.0) for safe interpolation
  • Removes component when animation completes
  • Supports both fade-in and fade-out (extensible)

Visibility Management

  • Queries camera zoom level
  • Updates all label visibility based on zoom
  • Uses Bevy's Visibility component
  • Efficient: Only updates when zoom changes

Cleanup System

  • Queries labels with Parent component
  • Checks if parent exists in satellite query
  • Despawns orphaned labels immediately
  • Prevents entity buildup over time

Benefits Over Implementation A

  • Smoother UX: Fade-in animations feel more polished
  • Better Performance: Labels hide when not needed (zoomed out)
  • Cleaner Code: Automatic cleanup prevents bugs
  • More Professional: Animated transitions enhance game feel
  • Scalable: Works well with many satellites

Visual Design

  • Animation: 0.5 second fade-in from transparent
  • Final Alpha: 90% (subtle but readable)
  • Zoom Threshold: Levels 0-2 visible, 3-4 hidden
  • Position: Same as Implementation A (below satellite)
  • Font: Same retro aesthetic

Performance

  • Minimal impact: Animations only on labeled satellites
  • Efficient: Visibility system reduces rendering when zoomed out
  • Clean: Automatic cleanup prevents entity accumulation
  • Scalable: Works with unlimited satellites

Testing

  • Launch satellites and verify labels fade in smoothly
  • Zoom out (levels 3-4) and verify labels disappear
  • Zoom in (levels 0-2) and verify labels reappear
  • Destroy satellites and verify labels cleanup automatically
  • Launch 10+ satellites and check no performance issues
  • Verify animations don't stutter or lag

Comparison with Implementation A

Feature Implementation A Implementation B
Label Spawning Instant Fade-in animation
Visibility Always on Zoom-based
Cleanup Automatic (parent-child) Explicit orphan check
Visual Polish Basic Enhanced
Performance Good Better (zoom hiding)
Complexity Simple Moderate

Future Enhancements

  • Label pool system for reusing entities
  • Fade-out animation when satellites despawn
  • Dynamic label updates based on satellite state
  • Color-coded labels by satellite type
  • Text outline for better readability

Related Feature

Implements: Satellite Names System (Entity Hierarchy with Animations)

- Created satellite_names_advanced module with enhanced features
- Implemented fade-in/fade-out animations for labels (0.5s duration)
- Added zoom-based label visibility (only show when zoomed in)
- Implemented orphaned label cleanup system
- Labels start transparent and fade in smoothly
- Zoom level 0-2 shows labels, 3-4 hides them
- Same naming rules as Implementation A (fixed + Japanese)
- Automatic cleanup when satellites are destroyed
- Smooth visual transitions for better UX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant