SCNNode를 여러 번 복사하고 각 노드와 다른 위치에 서로 다른 재료를 사용하고 싶습니다. 그러나 동일한 규모를 유지. 따라서 복사 한 노드의 크기를 변경하면 복사 된 모든 노드가 변경됩니다.SCNNode를 복사하고 저울을 유지할 수 있습니까?
아래 코드에서 changeScale()을 실행하면 복사 된 노드 눈금이 변경되지 않습니다.
복사 된 모든 노드의 크기 또는 지오메트리의 크기를 함께 변경할 수있는 방법이 있습니까? 열거 또는 개별적으로
let mainNode = SCNNode()
let mainGeo = SCNPlane(width: CGFloat(4), height: CGFloat(4))
mainNode.geometry = mainGeo
for var i = 1; i <= 10; i += 1 {
let thisNode = mainNode.copy() as! SCNNode
thisNode.position = SCNVector3Make(Float(rx), Float(ry), Float(rz))
thisNode.geometry = thisNode.geometry!.copy() as? SCNGeometry
thisNode.geometry?.firstMaterial = thisNode.geometry?.firstMaterial!.copy() as? SCNMaterial
if i == 0 {
thisNode.geometry?.firstMaterial?.diffuse.contents = UIColor.blueColor()
} else {
thisNode.geometry?.firstMaterial?.diffuse.contents = UIColor.redColor()
}
scene.rootNode.addChildNode(thisNode)
}
func changeScale() {
mainNode.scale = SCNVector3Make(7, 7, 7)
}