[ARCore中的3D对象单击事件

问题描述 投票:1回答:3

[如何获取在Android Studio中使用Arcore SDK渲染的3D对象的点击事件?我的要求是单击该3D对象并显示弹出对话框。

arcore
3个回答
1
投票

这与ARCore无关。您正在使用的游戏引擎/框架实际上对此负责。

例如,如果您正在使用Unity,则可以使用Raycasting。

RaycastHit hit;
Ray ray = yourARCamera.ScreenPointToRay(Input.GetTouch(0).position);
if (Physics.Raycast(ray, out hit))
{
     // Check if what is hit is the desired object
     if(hit.tag == "The_Tag_Of_The_Object_You_Are_Looking_For")
     {
           // User clicked the object.. Do something here..
     }
}

在这里阅读更多:

https://unity3d.com/learn/tutorials/topics/physics/raycastinghttps://docs.unity3d.com/ScriptReference/Physics.Raycast.html


0
投票

ARCore不支持此功能。您需要自己做。最受欢迎的方法是射线拾取方法。有很多示例如何使用它


0
投票

在使用Arcore-Sceneform SDK的情况下,创建锚点后,只需像这样简单地在AnchorNode上设置侦听器

anchorNode.setOnTapListener((hitResult,motionEvent)->{
   //Your pop up
});
© www.soinside.com 2019 - 2024. All rights reserved.