使用 ARCore 检测点击事件是否命中已添加的 3d 对象 [英] Detecting if an tap event with ARCore hits an already added 3d object

查看:23
本文介绍了使用 ARCore 检测点击事件是否命中已添加的 3d 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 ARCore 示例(https://github.com/google-ar/arcore-android-sdk) 并且我正在尝试删除已添加的对象 3d (andy).如何检测使用 ARCore 的点击事件是否击中了已添加的 3d 对象?

I am following the ARCore sample (https://github.com/google-ar/arcore-android-sdk) and I am trying to remove object 3d (andy) already added. How can I detect if an tap event with ARCore hits an already added 3d object?

推荐答案

在这种情况下使用 listener 是很常见的方法:

Using a listener is quite common approach in such situation:

private Node getModel() {
    Node node = new Node();
    node.setRenderable(modelRenderable);
    Context cont = this;
    node.setOnTapListener((v, event) -> {
        Toast.makeText(
            cont, "Model was touched", Toast.LENGTH_LONG)   // Toast Notification 
            .show();
    });
    return node;
}

这篇关于使用 ARCore 检测点击事件是否命中已添加的 3d 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆