Hi! I have the following problem:
I create a SCNNode, which works perfectly fine, and add it to a SCNView as a childNode, that also works.
However, when interacting with the scene, the node is placed somewhere on the screen/scene and not at the center, which causes weird behaviour when the user rotates the scene, since that rotation happens relative to the center of the view, but the node is - for example (not always) - on the left side, meaning the interaction is very hard to handle.
The main use would be for the user to view the node (which represents a custom object) from different perspectives by rotating/zooming/etc.
Here is my code:
I spent a lot of time debugging and trying to find what causes the problem, but I did not find the cause. I think the geometry should be fine, there are no outliers.
Also, I tested with different objects (which I basically create from an array of points with x, y, z coordinates and rgb values) and sometimes it works as intended (even though there is no difference between the objects aside from the different coordinates of the points, obviously). At least it feels like that, the node still might not be exactly in the middle, but might just be off by a very small margin.
Is there anything obvious that I am missing here?
Any tips would be very much appreciated!
I create a SCNNode, which works perfectly fine, and add it to a SCNView as a childNode, that also works.
However, when interacting with the scene, the node is placed somewhere on the screen/scene and not at the center, which causes weird behaviour when the user rotates the scene, since that rotation happens relative to the center of the view, but the node is - for example (not always) - on the left side, meaning the interaction is very hard to handle.
The main use would be for the user to view the node (which represents a custom object) from different perspectives by rotating/zooming/etc.
Here is my code:
Code Block let scene = SCNScene() prepareData() let geometry = createFromData() let objectNode = SCNNode() objectNode.geometry = geometry scene.rootNode.addChildNode(objectNode) self.sceneView = self.view as! SCNView self.sceneView.scene = scene self.sceneView.backgroundColor = UIColor.black self.sceneView.allowsCameraControl = true
I spent a lot of time debugging and trying to find what causes the problem, but I did not find the cause. I think the geometry should be fine, there are no outliers.
Also, I tested with different objects (which I basically create from an array of points with x, y, z coordinates and rgb values) and sometimes it works as intended (even though there is no difference between the objects aside from the different coordinates of the points, obviously). At least it feels like that, the node still might not be exactly in the middle, but might just be off by a very small margin.
Is there anything obvious that I am missing here?
Any tips would be very much appreciated!