ios - 场景工具包节点不旋转
<p><p>我正在尝试按场景工具包节点旋转,但它没有旋转。</p>
<p>我希望它绕 y 轴旋转。它是一个球体。</p>
<pre><code>let node = SCNNode()
node.geometry = SCNSphere(radius: 1)
node.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "diffuse.png")
node.geometry?.firstMaterial?.specular.contents = UIImage(named: "specular.png")
node.geometry?.firstMaterial?.emission.contents = UIImage(named: "emission.png")
scene.rootNode.addChildNode(node)
let action = SCNAction.rotate(by:360 * CGFloat((Double.pi)/180.0), around: SCNVector3(x: 0, y: 1, z: 0), duration: 8)
let repeatAction = SCNAction.repeatForever(action)
node.runAction(repeatAction)
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你确定它没有旋转吗?我不确定你的漫反射、镜面反射和发射图像是什么,但可能是因为它是一个球体,它看起来并不像在旋转,因为它从各个方面看起来都一样。 </p>
<p>在 viewDidAppear 中对多维数据集运行相同的操作对我有用,因此您可能无法真正注意到球体的旋转。我使用了这段代码:</p>
<pre><code> let node = SCNNode()
node.geometry = SCNBox (width: 0.5, height: 0.5, length: 0.5, chamferRadius: 0.1)
node.position = SCNVector3Make(0, 0, -1)
sceneView.scene.rootNode.addChildNode(node)
let action = SCNAction.rotate(by:360 * CGFloat((Double.pi)/180.0), around: SCNVector3(x: 0, y: 1, z: 0), duration: 8)
let repeatAction = SCNAction.repeatForever(action)
node.runAction(repeatAction)
</code></pre>
<p>立方体可以按照您旋转 SCNNode 的方式正常旋转。 </p>
<p>希望对你有帮助</p></p>
<p style="font-size: 20px;">关于ios - 场景工具包节点不旋转,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/45830598/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/45830598/
</a>
</p>
页:
[1]