ARCore - 如何将特定对象位置添加到ARAnchor?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ARCore - 如何将特定对象位置添加到ARAnchor?相关的知识,希望对你有一定的参考价值。

我想在没有敲击的情况下向锚添加特定的对象位置。

有解决方案吗?

答案

使用以下代码将特定对象的位置添加到ARAnchor:

float[] position = { 0, 0, -2.5 };
float[] rotation = { 0, 0, 0, 1 };

Session session = arFragment.getArSceneView().getSession();
Anchor myAnchor = session.createAnchor(new Pose(position, rotation));
anchorNode = new AnchorNode(myAnchor);
anchorNode.setRenderable(myModel);

anchorNode.setParent(arFragment.getArSceneView().getScene());

希望这可以帮助。

以上是关于ARCore - 如何将特定对象位置添加到ARAnchor?的主要内容,如果未能解决你的问题,请参考以下文章