Search code examples
iosscenekitarkit3d-model

Model in dae format can't be moved or scaled, can it be locked?


I am trying to work with a dae model, but somehow can't modify the position or scale it at all. Other models work fine though. Can these dae models be locked somehow?

let objScene = SCNScene(named: "art.scnassets/test.dae")!
self.objNode = objScene.rootNode.childNode(withName: "test", recursively: true)

let action = SCNAction.scale(by: 0.25, duration: 1.0)
self.objNode.runAction(action)

self.objNode?.position = SCNVector3(0.0,0.0,-2.0)
self.arSceneView.scene.rootNode.addChildNode(self.objNode!) 

Solution

  • This can happen if your Collada file contains animations that target the "test" node.

    If you programmatically set the node's position or scale, and then an animation targeting the node's transform is evaluated it will override everything giving the impression that the node can't be modified.

    You can always nest a node targeted by an animation under a dummy parent node, that you can freely translate, rotate or scale.