Skip to content

advait8/core-globe

Repository files navigation

core-globe

Maven Central License: MIT

A standalone Kotlin Multiplatform library that renders an interactive 3D globe inside a WebView using Three.js. Exposes a single GlobeView composable that any Android app can drop in.

Screenshots

Globe with SFO current location and destination markers     Globe auto-rotating showing destination markers

Features

  • Auto-rotating dark navy globe with lat/lon grid and star field
  • Country borders — 177-country outlines from Natural Earth 110m data
  • Current location marker — pulsing blue beacon with animated rings
  • Destination markers — amber dots
  • City labels — canvas-texture sprites that always face the camera
  • Arc support — animated great-circle flight paths between coordinates
  • Drag to rotate (touch + mouse), with rotation state fed back to Kotlin via bridge
  • Tap a marker to get a callback
  • Fully configurable colors, rotation speed, camera distance, atmosphere, grid, stars, borders
  • Self-contained — Three.js r128 and country GeoJSON bundled in library assets, no CDN required

Usage

GlobeView(
    markers = listOf(
        GlobeMarker(id = "sfo", lat = 37.77, lng = -122.41, style = MarkerStyle.Current),
        GlobeMarker(id = "tyo", lat = 35.68, lng =  139.69, style = MarkerStyle.Destination),
        GlobeMarker(id = "hnl", lat = 21.30, lng = -157.85, style = MarkerStyle.Destination),
    ),
    arcs = listOf(
        GlobeArc(
            from = Coordinates(37.77, -122.41),
            to   = Coordinates(35.68,  139.69),
        )
    ),
    onMarkerTapped = { marker -> Log.d("Globe", "tapped: ${marker.id}") },
    modifier = Modifier.fillMaxSize()
)

Configuration

GlobeView(
    config = GlobeConfig(
        globeColor           = "#0C1E3C",
        gridColor            = "#142D62",
        atmosphereColor      = "#1A4088",
        currentDotColor      = "#4A9EFF",
        destinationDotColor  = "#F5A623",
        arcColor             = "#4A9EFF",
        backgroundColor      = "#020B18",
        showGrid             = true,
        showAtmosphere       = true,
        showStars            = true,
        showBorders          = true,
        borderColor          = "#1E3A6E",
        autoRotate           = true,
        autoRotateSpeed      = 0.0022f,
        cameraDistance       = 5.0f,
    )
)

Setup

Maven Central (recommended)

Add the dependency to your app module:

// app/build.gradle.kts
dependencies {
    implementation("io.github.advait8:core-globe-android:0.1.0")
}

Make sure mavenCentral() is in your repository list (it is by default in new projects):

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        mavenCentral()
        google()
    }
}

Local module

// settings.gradle.kts
include(":core-globe")
// app/build.gradle.kts
dependencies {
    implementation(project(":core-globe"))
}

Add internet permission if loading anything remotely, and hardware acceleration on the Activity (required for WebView WebGL):

<activity
    android:name=".MainActivity"
    android:hardwareAccelerated="true" />

Stack

Layer Detail
Language Kotlin 2.1.0 · KMP
Android minSdk 24 · targetSdk 35
Renderer Three.js r128 (bundled in assets)
Bridge @JavascriptInterface + evaluateJavascript
UI Jetpack Compose · AndroidView

V2 Roadmap

  • flyTo(Coordinates) — animated camera rotation to a target
  • iOS actual (WKWebView) — expect/actual skeleton already in place
  • Arc animationProgress — animated draw-on effect
  • Cluster markers at high zoom-out

About

KMM 3D globe library — interactive WebGL globe in a single GlobeView Composable

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages