Kam*_*zak 2 3d android augmented-reality sceneform
我正在开发一个将在一个片段中包含 3D 模型查看器的项目。为了做到这一点,我决定使用sceneform。在我的选项卡片段中尝试显示 SceneView 后,我遇到了问题。
一切都是根据示例和场景形式文档完成的,但sceneView无论我指定的颜色如何,都会显示黑屏。
这是场景加载器
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
vw = inflater.inflate(R.layout.fragment_open_gl, container, false);
sceneView = vw.findViewById(R.id.scene_view);
return vw;
}
Run Code Online (Sandbox Code Playgroud)
和片段:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".OpenGL">
<com.google.ar.sceneform.SceneView
android:id="@+id/scene_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Crimson"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
我通过添加暂停和恢复场景视图以及片段解决了这个问题:
@Override
public void onPause() {
super.onPause();
sceneView.pause();
}
@Override
public void onResume() {
super.onResume();
try {
sceneView.resume();
} catch (CameraNotAvailableException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
314 次 |
| 最近记录: |