저는 scenekit
응용 프로그램을 빌드 중이지만 일부 세부적인 문제가 있습니다. 나는 scene
을 만들었고 사용자 정의 지오메트리를 추가했습니다. 노드 수가 약 100에 도달 할 때까지 제대로 작동합니다. 장면에 많은 수의 노드를 추가하는 것이 이상적이며 더 깨끗한 방법이 있습니까?많은 사용자 정의 노드를 장면에 추가하면로드하는 데 오랜 시간이 걸립니다.
for i in 0..<modelArr!.count {
let model = modelArr![i]
let pos: [SCNVector3] = Parser.loadPosition(model)
let norm:[SCNVector3] = Parser.loadNormals(model)
let ind:[CInt] = Parser.loadIndices(model)
let src = SCNGeometrySource(vertices: pos, count: pos.count)
let norSrc = SCNGeometrySource(normals: norm, count: norm.count)
//let indexData = NSData(bytes: ind, length: sizeof(CInt) * ind.count)
let indexData = NSData(bytes: Array<CInt>(0..<CInt(ind.count)),
length: ind.count * sizeof(Float))
let element = SCNGeometryElement(data: indexData,
primitiveType: .Triangles,
primitiveCount: pos.count/3,
bytesPerIndex: sizeof(Float))
let geo = SCNGeometry(sources: [src, norSrc], elements: [element])
let material = SCNMaterial()
material.diffuse.contents = UIColor.redColor()
material.specular.contents = UIColor.whiteColor()
let cubeNode = SCNNode(geometry: geo)
cubeNode.geometry?.firstMaterial = material
emptyNode.addChildNode(cubeNode)
}
scn.rootNode.addChildNode(emptyNode)
}
나는 많은 수의 색인, 법선 및 위치를 가지고 있습니다. 당신이 할 수있는