adding localRotation moves ArCore Node?

322 views Asked by At

This has me totally puzzled. I put this node in the scene, but as soon as I add "localRotation", the node moves. It looks fine if I don't move it (positioned centered where I expect). Do I have to initialize the Quaternion so that it's perpendicular to the floor plane/pose?

   scene?.apply {
       boundingBoxNode?.let { scene.removeChild(it) }
       boundingBoxNode = null

       viewModel.boundingBox?.let { box ->
                        MaterialFactory.makeTransparentWithColor(this@MyActivity, boundingBoxColor)
                         .thenAccept { material ->
                              boundingBoxNode = Node().apply {
                                renderable = ShapeFactory.makeCube(box.size, box.center, material).apply {
                                    collisionShape = null
                                    isShadowCaster = false
                                }
                                localRotation = box.rotation
                                scene.addChild(this)
                        }
       }
  }
1

There are 1 answers

0
kenyee On BEST ANSWER

FYI, don't set the center on ShapeFactory.makeCube(box.size, box.center). Do this instead (ShapeFactory.makeCube(box.size, Vector3.zero()) so that it's centered on the origin. You can then do: worldPosition = box.center to move it. I was rotating a box that wasn't centered :facepalm: