【发布时间】:2021-05-24 06:50:18
【问题描述】:
所以我目前正在使用一个使用 AR Core Sceneform SDK 渲染模型的应用程序 - 我正在使用 Thomas Gorisse 维护的神奇库在同一场景中渲染模型。
public void loadModels(String url) {
spinner.setVisibility(View.VISIBLE);
WeakReference<MainActivity> weakActivity = new WeakReference<>(this);
ModelRenderable.builder()
.setSource(this, Uri.parse(url))
.setIsFilamentGltf(true)
.setAsyncLoadEnabled(true)
.build()
.thenAccept(model -> {
spinner.setVisibility(View.GONE);
Toast.makeText(this, "Model Ready", Toast.LENGTH_SHORT).show();
MainActivity activity = weakActivity.get();
if (activity != null) {
activity.model = model;
}
})
.exceptionally(throwable -> {
Toast.makeText(this, "Unable to load model", Toast.LENGTH_LONG).show();
return null;
});
}
我使用它来获取模型的 url 并将其加载到场景中,据我所知 AR Core 只能使用 Scene Viewer 将模型作为新意图加载。
Intent sceneViewerIntent = new Intent(Intent.ACTION_VIEW);
sceneViewerIntent.setData(Uri.parse("https://arvr.google.com/scene-viewer/1.0?file=https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Avocado/glTF/Avocado.gltf"));
sceneViewerIntent.setPackage("com.google.android.googlequicksearchbox");
startActivity(sceneViewerIntent);
我们被要求完全切换到 ARCore,所以有没有办法在 AR Core 中实现相同的过程,在相同的活动中加载模型,而无需每次都启动新的意图。
【问题讨论】: