【问题标题】:Position object relative to camera in SceneView在 SceneView 中相对于相机定位对象
【发布时间】:2018-05-10 21:39:20
【问题描述】:

我尝试修改 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
}

【问题讨论】:

    标签: android arcore sceneform


    【解决方案1】:

    这行得通,我认为本地位置在可见的范围之外。如果相机是 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)
    

    【讨论】:

      【解决方案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);
                                          }
                               }
      }
      

      【讨论】:

        猜你喜欢
        • 2015-03-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-08
        • 2023-04-09
        • 1970-01-01
        • 2013-02-26
        相关资源
        最近更新 更多