Skip to content

SceneView is a 3D and AR Android View with Google Filament and ARCore. This is a Sceneform replacement in Kotlin

License

Notifications You must be signed in to change notification settings

hshapley/sceneview-android

 
 

Repository files navigation

logo

3D and AR Android Jetpack Compose and Layout View based on Google Filament and ARCore

Sceneview ARSceneview

Filament ARCore

Discord Open Collective

3D Scene (Filament)

Dependency

app/build.gradle

dependencies {
    // Sceneview
    implementation("io.github.sceneview:sceneview:2.1.1")
}

API

https://sceneview.github.io/api/sceneview-android/sceneview/

Usage

https://github.com/SceneView/sceneview-android/blob/2bed398b3e10e8e9737d6e4a38933e783c1ee75e/samples/model-viewer-compose/src/main/java/io/github/sceneview/sample/modelviewer/compose/MainActivity.kt#L50-L89

Current Version

https://github.com/SceneView/sceneview-android/blob/2bed398b3e10e8e9737d6e4a38933e783c1ee75e/sceneview/gradle.properties#L6

Filament

Included Dependencies

https://github.com/SceneView/sceneview-android/blob/3abb70cc4362100a2232a2fd1ade9f850fe83096/sceneview/build.gradle#L113-L117

AR ARScene (Scene + ARCore)

Dependency

app/build.gradle

dependencies {
    // ARSceneview
    implementation 'io.github.sceneview:arsceneview:2.1.1'
}

API Reference

Usage

val engine = rememberEngine()
val modelLoader = rememberModelLoader(engine)
val environmentLoader = rememberEnvironmentLoader(engine)
Scene(
    modifier = Modifier.fillMaxSize(),
    engine = engine,
    modelLoader = modelLoader,
    childNodes = rememberNodes {
        add(ModelNode(modelLoader.createModelInstance("model.glb")).apply {
            // Move the node 4 units in Camera front direction
            position = Position(z = -4.0f)
        })
    },
    environment = environmentLoader.createHDREnvironment("environment.hdr")!!
)

Sample

AR Model Viewer

val engine = rememberEngine()
val modelLoader = rememberModelLoader(engine)
val model = modelLoader.createModel("model.glb")
var frame by remember { mutableStateOf<Frame?>(null) }
val childNodes = rememberNodes()
ARScene(
    modifier = Modifier.fillMaxSize(),
    engine = engine,
    modelLoader = modelLoader,
    onSessionUpdated = { session, updatedFrame ->
        frame = updatedFrame
    },
    onGestureListener = rememberOnGestureListener(
        onSingleTapConfirmed = { motionEvent, node ->
            val hitResults = frame?.hitTest(motionEvent.x, motionEvent.y)
            val anchor = hitResults?.firstOrNull {
                it.isValid(depthPoint = false, point = false)
            }?.createAnchorOrNull()

            if (anchor != null) {
                val anchorNode = AnchorNode(engine = engine, anchor = anchor)
                anchorNode.addChildNode(
                    ModelNode(modelInstance = modelLoader.createInstance(model)!!)
                )
                childNodes += anchorNode
            }
        }
    )
)

Sample

3D @Composable Scene()

https://github.com/SceneView/sceneview-android/blob/8be5d205d4b168e5d6e8ba0521e4bf71f3d93bcd/sceneview/src/main/java/io/github/sceneview/Scene.kt#L50-L200

AR @Composable ARScene()

https://github.com/SceneView/sceneview-android/blob/8be5d205d4b168e5d6e8ba0521e4bf71f3d93bcd/arsceneview/src/main/java/io/github/sceneview/ar/ARScene.kt#L62-L244

Samples

https://github.com/SceneView/sceneview-android/tree/main/samples

Links

Tutorials

Youtube Videos

Filament

GitHub

https://github.com/google/filament

Dependencies

https://github.com/SceneView/sceneview-android/blob/3abb70cc4362100a2232a2fd1ade9f850fe83096/sceneview/build.gradle#L113-L117

Filament Dependency

https://github.com/SceneView/sceneview-android/blob/8be5d205d4b168e5d6e8ba0521e4bf71f3d93bcd/arsceneview/build.gradle#L92-L93

Support our work

Help us

  • Buy devices to test the SDK on
  • Equipment for decent video recording Tutorials and Presentations
  • Sceneview Hosting Fees

How To Contribute

Open Collective


⚠️ Geospatial API: Be sure to follow the official Google Geospatial Developer guide to enable Geospatial API in your application.

About

SceneView is a 3D and AR Android View with Google Filament and ARCore. This is a Sceneform replacement in Kotlin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 51.5%
  • Java 47.6%
  • Other 0.9%