SceneKit节点不会改变场景根节点的位置 [英] SceneKit nodes aren't changing position with scene's root node

查看:307
本文介绍了SceneKit节点不会改变场景根节点的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有ARKit的SceneKit,现在有一个简单的应用程序,我点击屏幕,它在我的场景中添加了一个ARAnchor和一个SCNNode。

I'm using SceneKit with ARKit, and right now have a simple app where I tap on the screen and it adds an ARAnchor and a SCNNode to my scene.

在某些时候,我想要移动整个场景,所以我尝试更改 sceneView.scene.rootNode.position.x + = 10 来测试它。如果我在任何特定节点上调用它,该节点确实会正确移动。但是在 rootNode 上调用它,没有任何反应,我希望每个子节点(场景中的每个节点)都随之移动。

At some point, I'm going to want to move the entire scene, so I tried changing sceneView.scene.rootNode.position.x += 10 to test this out. If I call this on any particular node, that node does move appropriately. But calling this on rootNode, nothing happens, where I'd expect every child node (which is every node in the scene) to move along with it.

为什么我的其他节点没有正确移动,我能做些什么来解决这个问题?或者我在考虑这个错误?

Why are my other nodes not moving appropriately, and is there something I can do to fix this? Or am I thinking about this wrong?

推荐答案

根据 SCNScene.rootNode


你应该不修改根节点的转换属性。

根节点定义世界坐标系的起源 - 所有其他测量都与它相关。因此,改变其位置,方向,规模或其变换的任何其他方面都没有意义(并且通常是有问题的)。

The root node defines the origin of the world coordinate system — all other measurements are relative to it. Hence, it's not meaningful (and is often problematic) to change its position, orientation, scale, or any other aspect of its transform.

如果要移动SceneKit场景中的所有内容,请创建一个新节点以包含所有其他节点,并更改该节点的变换。 (对于由 ARSCNView 添加的节点,您无法执行此操作,因为ARKit会生成根节点的直接子节点,但这些节点的重点在于将它们放置在世界空间中。 )

If you want to move all the content in your SceneKit scene, create a new node to contain all of the others, and change that node's transform. (You can't do this for nodes added by ARSCNView, because ARKit makes those direct children of the root node, but the whole point of those is positioning them in world space.)

这篇关于SceneKit节点不会改变场景根节点的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆