Search code examples
xcodepivotscenekitbounding-boxsketchup

Why is the BoundingBox so big and do I have to change the pivot?


I have imported a .dae file from SketchUp:

https://i.sstatic.net/s3Rqa.png

1: How can I change the size of the bounding box?
2: Why isn't the pivot in the center of the SCNNode and how can I change this. (I would prefer a solution thats not programmatically.)


Solution

  • If you want to change those properties without code you need to change them in SketchUp. Position and scale your model there and these changes should apply in Xcode as well. To change the size of the model in Xcode you can set the models scale to a small value.

    Changing a nodes pivot is not supported in the SceneKit editor. You can either

    • add your model as a subnode of an empty 'parent' node and position your model relative to this parent. Later you change the position of the parent node to move the node around.

    • just change the pivot in code, it is really easy. Add the boundingBox.min and max vectors and divide them by 2. Then you set the pivot to a translation matrix (via SCNMatrix4MakeTranslation from the vector you have computed.