Scenekit:模型在动画时改变大小
Scenekit: Model change size when animation
我使用 Scenekit 为模型(由 Blender 创建)制作动画,但模型在动画时会改变大小(在 Blender 中,它工作正常)。
https://youtu.be/WCE_sXEyfXU
let sceneView = SCNView(frame: self.view.frame)
sceneView.allowsCameraControl = true
self.view.addSubview(sceneView)
let manScene = SCNScene(named: "art.scnassets/man.dae", inDirectory: nil, options: nil)
sceneView.scene = manScene
let camera = SCNCamera()
let cameraNode = SCNNode()
cameraNode.camera = camera
cameraNode.position = SCNVector3(-3.0, 3.0, 3.0)
let light = SCNLight()
light.type = SCNLight.LightType.ambient
let lightNode = SCNNode()
lightNode.light = light
lightNode.position = SCNVector3(10, 10, 10)
manScene!.rootNode.addChildNode(cameraNode)
let oneLegAnimation = SCNAnimationPlayer.loadAnimation(fromSceneNamed: "art.scnassets/oneLeg.dae")
oneLegAnimation.animation.isCumulative = false
oneLegAnimation.stop()
manScene!.rootNode.addAnimationPlayer(oneLegAnimation, forKey: "man")
manScene!.rootNode.animationPlayer(forKey: "man")?.play()
谢谢!
我认为 Blender 和 Xcode 之间存在差异。最后,我通过添加 IK 骨骼和大量关键帧(每 0.5 秒)修复它。
我使用 Scenekit 为模型(由 Blender 创建)制作动画,但模型在动画时会改变大小(在 Blender 中,它工作正常)。 https://youtu.be/WCE_sXEyfXU
let sceneView = SCNView(frame: self.view.frame)
sceneView.allowsCameraControl = true
self.view.addSubview(sceneView)
let manScene = SCNScene(named: "art.scnassets/man.dae", inDirectory: nil, options: nil)
sceneView.scene = manScene
let camera = SCNCamera()
let cameraNode = SCNNode()
cameraNode.camera = camera
cameraNode.position = SCNVector3(-3.0, 3.0, 3.0)
let light = SCNLight()
light.type = SCNLight.LightType.ambient
let lightNode = SCNNode()
lightNode.light = light
lightNode.position = SCNVector3(10, 10, 10)
manScene!.rootNode.addChildNode(cameraNode)
let oneLegAnimation = SCNAnimationPlayer.loadAnimation(fromSceneNamed: "art.scnassets/oneLeg.dae")
oneLegAnimation.animation.isCumulative = false
oneLegAnimation.stop()
manScene!.rootNode.addAnimationPlayer(oneLegAnimation, forKey: "man")
manScene!.rootNode.animationPlayer(forKey: "man")?.play()
谢谢!
我认为 Blender 和 Xcode 之间存在差异。最后,我通过添加 IK 骨骼和大量关键帧(每 0.5 秒)修复它。