diff --git a/android/samples/sample-gltf-viewer/src/main/assets/models/helmet.glb b/android/samples/sample-gltf-viewer/src/main/assets/models/helmet.glb new file mode 100644 index 0000000000..2cee76d76a Binary files /dev/null and b/android/samples/sample-gltf-viewer/src/main/assets/models/helmet.glb differ diff --git a/android/samples/sample-gltf-viewer/src/main/java/com/google/android/filament/gltf/MainActivity.kt b/android/samples/sample-gltf-viewer/src/main/java/com/google/android/filament/gltf/MainActivity.kt index 8322cbbb88..56855eb274 100644 --- a/android/samples/sample-gltf-viewer/src/main/java/com/google/android/filament/gltf/MainActivity.kt +++ b/android/samples/sample-gltf-viewer/src/main/java/com/google/android/filament/gltf/MainActivity.kt @@ -18,6 +18,7 @@ package com.google.android.filament.gltf import android.annotation.SuppressLint import android.app.Activity +import android.content.Intent import android.os.Bundle import android.util.Log import android.view.* @@ -50,6 +51,7 @@ class MainActivity : Activity() { // Load the library for the utility layer, which in turn loads gltfio and the Filament core. init { Utils.init() } private const val TAG = "gltf-viewer" + private const val STATIC_MODEL_TAG = "use-static-model" } private lateinit var surfaceView: SurfaceView @@ -69,6 +71,7 @@ class MainActivity : Activity() { private var loadStartTime = 0L private var loadStartFence: Fence? = null private val viewerContent = AutomationEngine.ViewerContent() + private var useStaticModel = false @SuppressLint("ClickableViewAccessibility") override fun onCreate(savedInstanceState: Bundle?) { @@ -83,6 +86,12 @@ class MainActivity : Activity() { doubleTapDetector = GestureDetector(applicationContext, doubleTapListener) singleTapDetector = GestureDetector(applicationContext, singleTapListener) + val intent: Intent = intent + val bundle: Bundle? = intent.extras + bundle?.let { + useStaticModel = it.getBoolean(STATIC_MODEL_TAG, false) + } + modelViewer = ModelViewer(surfaceView) viewerContent.view = modelViewer.view viewerContent.sunlight = modelViewer.light @@ -141,7 +150,16 @@ class MainActivity : Activity() { } private fun createDefaultRenderables() { - val buffer = assets.open("models/scene.gltf").use { input -> + // Sometimes it's useful to set to the default model to something static. You can enable + // the static model by launching the app from adb, as in + // `adb shell am start -n com.google.android.filament.gltf/.MainActivity --ez "use-static-model" true` + val modelPath = if (useStaticModel) { + "models/helmet.glb" + } else { + "models/scene.gltf" + } + + val buffer = assets.open(modelPath).use { input -> val bytes = ByteArray(input.available()) input.read(bytes) ByteBuffer.wrap(bytes)