Reputation: 554
I've made a scn file called arrowsign.scn which contains a arrow like the picture below:
I wrote a piece of code to load the arrow object:
SCNNode *node = [SCNNode node];
SCNNode *a[10];
for (int i = 0;i<10;i++){
a[i] = [scene.rootNode childNodeWithName:@"arrowsign" recursively:NO];//just one arrow in arrowsign.scn
a[i].scale = SCNVector3Make(0.15f, 0.15f, 0.15f);
a[i].position = SCNVector3Make(1+i, 0, 0);
[node addChildNode:a[i]];
}
[scene.rootNode addChildNode:node];
Ideally there will be a row of arrows displaying in the screen. However, there is just one arrow displaying. How can I achieve my goal?
Upvotes: 0
Views: 1173
Reputation: 349
I think you can simply clone node
let sphereNode2 = sphereNode.clone()
sphereNode2.position = SCNVector3(x: 0, y: 0, z: -20)
scene.rootNode.addChildNode(sphereNode2)
Upvotes: 2
Reputation: 299
Instead of creating new SCNNode instances, create SCNReferenceNode instances in order to load your .scn file into them.
Upvotes: 2