4

我想更新与每帧更新的锚点关联的数据。如何从 ArSceneView 获取每一帧的帧?

4

1 回答 1

5

ArSceneView 在绘制场景之前更新 ARCore Frame 对象。getArFrame()您可以通过从注册的方法调用来访问框架setOnUpdateListener()

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    this.sceneView = (ArSceneView) findViewById(R.id.scene_view);
    sceneView.getScene().setOnUpdateListener((this::onSceneUpdate));
}

private void onSceneUpdate(FrameTime updatedTime) {
    Frame frame = sceneView.getArFrame();
    Collection<Anchor> updatedAnchors = frame.getUpdatedAnchors();
    for (Anchor anchor : updatedAnchors) {
        // Handle updated anchors...
    }
}
于 2018-05-08T20:44:28.603 回答