Skip to content

Educational iOS AR app that places a scaled solar system in the real world and shows scientific information when a planet is tapped.

Notifications You must be signed in to change notification settings

SahansilvaDev/Solar-System-AR-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Solar System AR

Educational iOS AR app that places a scaled solar system in the real world and shows scientific information when a planet is tapped.

image image image

Features

  • Splash screen with solarsystem.jpg and "Explore AR" button
  • Place solar system on a detected surface (raycast)
  • 10 celestial bodies (Sun, Mercury, Venus, Earth, Moon, Mars, Jupiter, Saturn, Uranus, Neptune)
  • Planet rotation (spin) and orbital motion
  • Tap a planet to view a detailed info card (name, description, key facts)
  • Parallel texture loading for faster placement

Requirements

  • macOS with Xcode 14+ (RealityKit / ARKit)
  • iOS device running iOS 15+ for AR testing (physical device required)
  • Assets in Assets.xcassets: solarsystem (background), SunMap, MercuryMap, VenusMap, EarthMap, MoonMap, MarsMap, JupiterMap, SaturnMap, UranusMap, NeptuneMap
  • Camera permission in Info.plist (NSCameraUsageDescription)

Install & Run

  1. Copy the project folder to your Mac and open ContentView.swift project in Xcode.
  2. Confirm all texture assets are present in Assets.xcassets with the exact names used above.
  3. Ensure Info.plist contains NSCameraUsageDescription.
  4. Connect an iPhone, select it as the run destination, then Build & Run.
  5. On first run allow camera access. Tap a real-world horizontal surface to place the solar system. Tap a planet to show info.

Key Code Locations

  • ContentView.swift
    • Splash: SplashScreenView
    • AR UI: ARSolarSystemView
    • Data: ARViewModel.getPlanetInfo(for:)
    • AR bridge: ARViewContainer.makeUIView(...)
    • AR logic: ARViewContainer.CoordinatorplaceSolarSystem, createPlanets, createPlanet, updatePlanets

Debug / Troubleshooting

  • EXC_BREAKPOINT on material or generateSphere:
    • Ensure RealityKit operations run on main thread: wrap entity creation inside await MainActor.run { ... }.
    • Use PhysicallyBasedMaterial and apply materials after creating the ModelEntity.
    • Use try? MeshResource.generateSphere(radius:) and guard fallback.
    • Use ShapeResource.generateSphere for collision shapes (fast).
  • Slow placement:
    • Confirm textures load in parallel via async let.
    • Use lower-res textures if device is slow.
  • Tap not detected:
    • Ensure CollisionComponent(shapes:) and InputTargetComponent() are set on the ModelEntity.

Getting planet positions (quick)

  • Local (relative to anchor): entity.position
  • World (AR world coordinates): entity.convert(position: entity.position, to: nil)

Example helper (add to ARViewModel or Coordinator for debugging):

func worldPosition(of name: String) -> SIMD3<Float>? {
    guard let entity = planetEntities[name] else { return nil }
    return entity.convert(position: entity.position, to: nil)
}

Known Issues & Notes

  • AR requires a physical iOS device; simulator will not show AR content.
  • Keep texture sizes reasonable to reduce memory and load time.
  • All RealityKit creation must happen on main thread to avoid crashes.

License

  • MIT

About

Educational iOS AR app that places a scaled solar system in the real world and shows scientific information when a planet is tapped.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages