My code below places a dice multiples times. This is exactly what I want the code to doo. However when I change diceCollada.scn to another scn file that is in the assets folder. I don’t know why if I import another scn file I can not change the arkit object. All I want to do is to be able to use this exact code with another scn file that’s it.
func addDice(atLocation location: ARHitTestResult) {
// Create a new scene
////IF I CHANGE diceCollada.scn to hat.scn THE OBJECT DOES NOT SHOW UP
let diceScene = SCNScene(named: "art.scnassets/diceCollada.scn")!
// Create Dice Node for Pos.
if let diceNode = diceScene.rootNode.childNode(withName: "Dice", recursively: true) {
// Assign found position to dice
diceNode.position = SCNVector3(
location.worldTransform.columns.3.x,
location.worldTransform.columns.3.y + diceNode.boundingSphere.radius,
location.worldTransform.columns.3.z
)
diceArray.append(diceNode)
// Set the scene to the view
sceneView.scene.rootNode.addChildNode(diceNode)
// Roll Dice
roll(dice: diceNode)
}}