0

如果我分配一个MDLAsset并且SCNNode喜欢这样

let device: MTLDevice = (sceneView?.device)!
let allocator = MTKMeshBufferAllocator(device: device)
let url = Bundle.main.url(forResource: name, withExtension: "obj")
let asset = MDLAsset(url: url! as URL, vertexDescriptor: nil, bufferAllocator: allocator)

guard let object = asset.object(at: 0) as? MDLMesh else {
      print("Failed to get mesh from obj asset")
      return nil
}

let node = SCNNode.init(mdlObject: object)
let geometrySources = node.geometry.sources

我的geometrySource对象是由 Metal 缓冲区支持的,还是该过程已经消失并复制了 NSData 中的数据?

4

1 回答 1

0

经过实验,确实是这样,除非您SCNGeometrySource使用金属缓冲区显式初始化 a ,否则它将由非可变NSData缓冲区支持。即使在初始设置中将obj文件加载到MDLAsset使用中也是如此。MTLMeshBufferAllocator

于 2020-11-19T03:00:24.420 回答