gpt4 book ai didi

ios - 无法使用 ARKit (ARKit + CoreLocation) 对场景节点进行动画处理

转载 作者:行者123 更新时间:2023-11-30 11:45:44 27 4
gpt4 key购买 nike

我正在尝试向场景中的每个节点添加动画。我的一个问题是,在层次结构中 - 我应该将动画添加到哪个节点。我认为它是由您实际看到的内容所代表的节点,这将是网格对象...但我有一个持有两个灯和网格对象的节点...对该一个进行动画处理也可以吗?

这是我的代码 - 我使用委托(delegate)方法等待场景填充,然后尝试遍历场景的节点并添加动画:

func sceneLocationViewDidSetupSceneNode(sceneLocationView: SceneLocationView, sceneNode: SCNNode) {
let animation = CABasicAnimation(keyPath: "opacity")
animation.fromValue = 100.0
animation.toValue = 0.0
animation.duration = 2.0
animation.autoreverses = true
animation.repeatCount = .infinity

print("\(sceneNode) name name name name name" )
for node in sceneNode.childNodes {
for nodeInner in node.childNodes {
for nodeInnermost in nodeInner.childNodes {
if (nodeInnermost.name?.localizedStandardContains("ship"))! {
print(nodeInnermost.childNodes.first ?? "FIRST DOESNT EXIST")
nodeInnermost.childNodes.first?.addAnimation(animation, forKey: "opac")
}
}
}
}
}

它根本不起作用,不透明度没有变化。

最佳答案

请尝试这个:

    let plane = SCNPlane(width: 0.2, height: 0.2)
plane.firstMaterial?.diffuse.contents = vc2
let planeNode = SCNNode(geometry: plane)
planeNode.opacity = 0
node.addChildNode(planeNode)

DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
SCNTransaction.animationDuration = 4

planeNode.opacity = 1
planeNode.position.z = -0.2
}
return node

关于ios - 无法使用 ARKit (ARKit + CoreLocation) 对场景节点进行动画处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48846017/

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