ARCore:如何在没有平面跟踪的情况下从会话对象创建锚点?

Har*_*han 4 android arcore sceneform

我一直在尝试这样做,但是当我尝试以下操作时,我收到了 NotTrackingException

    Pose pose = Pose.makeTranslation(-0.41058916f, -0.6668466f, 0.04225248f);

    Anchor anchor = arFragment.getArSceneView().getSession().createAnchor(pose);
Run Code Online (Sandbox Code Playgroud)

或者

    Pose pose = Pose.makeTranslation(-0.41058916f, -0.6668466f, 0.04225248f);

    Anchor anchor =new Session(this).createAnchor(pose);
Run Code Online (Sandbox Code Playgroud)

Mic*_*ick 6

您可以通过多种方式在 Arcore 场景中设置锚点。一种听起来可能满足您的需求的方法是设置相对于相机焦点的锚点位置 - 请参阅这个答案,该答案经过测试并且有效:

从会话对象创建锚点的关键代码是:

          //Add an Anchor and a renderable in front of the camera       
          Session session = arFragment.getArSceneView().getSession();
          float[] pos = { 0,0,-1 };
          float[] rotation = {0,0,0,1};
          Anchor anchor =  session.createAnchor(new Pose(pos, rotation));
          anchorNode = new AnchorNode(anchor);
          anchorNode.setRenderable(andyRenderable);
          anchorNode.setParent(arFragment.getArSceneView().getScene());
Run Code Online (Sandbox Code Playgroud)

如果您查看该问题的其他一些答案,您还可以看到一些替代的非计划跟踪方法。