android - 如何在 Android 版 Google Filament 中设置背景颜色?

标签 android kotlin surfaceview google-filament

我正在关注这个灯丝教程:https://medium.com/@philiprideout/getting-started-with-filament-on-android-d10b16f0ec67

如何将背景颜色设置为白色?

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        surfaceView = SurfaceView(this).apply {
            setContentView(this)
        }
        choreographer = Choreographer.getInstance()
        modelViewer = ModelViewer(surfaceView)
        surfaceView.setOnTouchListener(modelViewer)

        loadGlb("DamagedHelmet")

        modelViewer.scene.skybox = Skybox.Builder().build(modelViewer.engine)
        loadEnvironment("venetian_crossroads_2k")

    }

我尝试在 SurfaceView 上设置背景颜色,但没有成功。

目前,它看起来像这样(似乎默认是黑色):

最佳答案

我明白了。我需要设置天空盒颜色。

例如,这将颜色设置为红色。

modelViewer.view.blendMode = com.google.android.filament.View.BlendMode.OPAQUE
modelViewer.scene.skybox = Skybox.Builder().color(0.81f, 0f, 0f, 0f).build(modelViewer.engine)

关于android - 如何在 Android 版 Google Filament 中设置背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71243382/

相关文章:

Android - 签名 APK - Gradle 执行失败

android - 禁用 ViewPager 滚动动画

gradle - Gradle Kotlin DSL:配置任务: Unresolved reference

Android:相机 View - 当我不使用已弃用的方法时应用程序崩溃

android - 在 Android 上使用 Camera API 尽可能快地拍照

应用恢复时的 android.support.v4.app.Fragment.setUserVisibleHint 空指针

Android 应用程序在 setText 上崩溃

android - 如果数组为空,如何找到最大的数字和 null

java - Guice:在 Binder 内独立使用相同的实例

android - 为什么在使用 GONE 设置可见性并继续使用 VISIBLE 时多次调用 surfaceCreated 和 surfaceDestroyed?