1

我尝试修改 SceneForm 示例,以便在触摸场景后立即相对于相机定位对象,但没有对象出现。我错过了什么?检查文档和 YouTube 视频无济于事。任何想法,将不胜感激!

下面的代码(在 Kotlin 中):

arFragment!!.arSceneView.setOnTouchListener { view : View, event: MotionEvent ->
  println("Touch!")
  val andy = Node()
  andy.setParent(arFragment?.arSceneView?.scene?.camera)
  andy.localPosition = Vector3(1.0f, 1.0f, 1.0f)
  andy.renderable = andyRenderable
  true
}
4

2 回答 2

2

这行得通,我认为本地位置在可见的范围之外。如果相机为 0,0,0,则向前一米为 0,0,-1。这对我有用。将安迪放在镜头前:

      Node andy = new Node();
      andy.setParent(arFragment.getArSceneView().getScene().getCamera());
      andy.setLocalPosition(new Vector3(0f,0,-1f));
      andy.setRenderable(andyRenderable)
于 2018-05-10T22:48:11.067 回答
-2
how to add rotating animation to the modelRenderable(andy) in sceneview - android 

{
`if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            CompletableFuture<ViewRenderable> finalCouponLayout = couponLayout;
            CompletableFuture<ModelRenderable> finalAndy = andy;
            CompletableFuture.allOf(couponLayout, finalAndy)
                    .handle(
                            (notUsed, throwable) -> {

                                if (throwable != null) {
                                    return null;
                                }

                                try {
                                    // Non scalable info outside location
                                    ViewRenderable vr = finalCouponLayout.get();
                                    //
                                    ModelRenderable andyRenderable = finalAndy.get();
                                    //
                                    Node base = new Node();

                                    if (flag.equals("coin")) {

                                        base.setRenderable(andyRenderable);

                                    } else if (flag.equals("feeds")) {
                                        base.setRenderable(vr);
                                    }
                         }
}
于 2018-08-03T10:09:42.203 回答