Android localRotation不围绕立方体中心旋转

Android localRotation不围绕立方体中心旋转,android,sceneform,Android,Sceneform,Android上的Sceneform 1.15 我想让立方体围绕自己的中心旋转 val anchorNode = AnchorNode().apply { setParent(scene) worldPosition = Vector3(2f, 3f, 0f) } scene.addChild(anchorNode) dieNode = Node().app

Android上的Sceneform 1.15

我想让立方体围绕自己的中心旋转

val anchorNode = AnchorNode().apply {
                setParent(scene)
                worldPosition = Vector3(2f, 3f, 0f)
            }

            scene.addChild(anchorNode)

            dieNode = Node().apply {
                setParent(anchorNode)
                localRotation = Quaternion.eulerAngles(Vector3(10f,20f,60f))
                name = "die"
                renderable = it
            }
我制作了一个动画师,应该只围绕立方体自身的中心旋转立方体

private fun roll() {
    val anim = createAnimator()
    val node = scene.findByName("die")!!
    anim.target = node
    anim.setDuration(9000)
    anim.start()
}

private fun createAnimator() : ObjectAnimator {
    val o1 = Quaternion.eulerAngles(Vector3(-90f,180f,90f))
    val animator = ObjectAnimator()
    animator.setObjectValues(o1)
    animator.setPropertyName("localRotation")
    animator.setEvaluator(QuaternionEvaluator())
    animator.setInterpolator(LinearInterpolator())
    animator.setAutoCancel(true)
    return animator
}
但是,当立方体旋转时,它也会被移动,这不是期望的行为

屏幕截图,其中一个对称放置的模具只能旋转:

立方体对象的位置未居中。如果它偏离父对象的中心,它将围绕(0,0,0)旋转,如果它偏离此轴-对象将在圆中移动,而不是旋转。

立方体对象的位置不居中。如果它相对于父对象偏离中心,它将围绕(0,0,0)旋转,如果它偏离此轴-对象将在一个圆中移动,而不是旋转。

你所说的“旋转动画时立方体中心移动”是什么意思?指定您的问题将有助于找到合适的答案。我更新了答案以澄清问题。您所说的“旋转动画时移动立方体中心”是什么意思?指定您的问题将有助于找到合适的答案。我更新了答案以使其更清楚。