localRotation is not rotating around the cube center

*爱你&永不变心* 提交于 2020-07-23 06:44:12

问题


Sceneform 1.15 on Android

Cube renderable that is set to node is not rotating around the node centar.

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
            }

Even animation doesn't rotate around cube (node) center. The cube center is moved while animating rotation.

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
}

来源:https://stackoverflow.com/questions/62968188/localrotation-is-not-rotating-around-the-cube-center

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!