【问题标题】:How to render multiple AR models in the same activity using AR Core?如何使用 AR Core 在同一个活动中渲染多个 AR 模型?
【发布时间】: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 中实现相同的过程,在相同的活动中加载模型,而无需每次都启动新的意图。

【问题讨论】:

    标签: android arcore


    【解决方案1】:

    这是带有许多教程的 Sceneform 库。在问这些琐碎的问题之前先看看那些。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-15
      • 1970-01-01
      • 2022-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多