gpt4 book ai didi

swift - 如何在 RealityKit 中为变换设置动画

转载 作者:行者123 更新时间:2023-12-04 14:32:55 24 4
gpt4 key购买 nike

在我的 previous question我已经找到了如何仅在对象上的一个轴上进行旋转变换,现在我希望将其设置为动画。

有没有办法在 RealityKit 中做到这一点?

最佳答案

带动画的旋转:

copy the box's current transform


var rotationTransform = boxAnchor.steelBox?.transform

set the box to rotate 90 degrees over z-axis


rotationTransform?.rotation = simd_quatf(angle: .pi/2, axis: [0,0,1])

move the box to the new transform over 10s


boxAnchor.steelBox?.move(to: rotationTransform!, relativeTo: boxAnchor.steelBox?.parent, duration: 10, timingFunction: .easeInOut)

动画翻译:
var translationTransform = boxAnchor.steelBox?.transform

translationTransform?.translation = SIMD3<Float>(x: 5, y: 0, z: 0)

boxAnchor.steelBox?.move(to: translationTransform!, relativeTo: boxAnchor.steelBox?.parent, duration: 10, timingFunction: .easeInOut)

用动画缩放:
var scaleTransform = boxAnchor.steelBox?.transform

scaleTransform?.scale = SIMD3<Float>(x: 1, y: 1, z: 1)

boxAnchor.steelBox?.move(to: scaleTransform!, relativeTo: boxAnchor.steelBox?.parent, duration: 10, timingFunction: .easeInOut)

关于swift - 如何在 RealityKit 中为变换设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59335075/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com