我正在尝试使用 SCNGeometrySource 的init(vertices: CMutablePointer<SCNVector3>, count: Int)
初始化程序,但我不知道如何制作CMutablePointer<SCNVector3>
.
在 Objective-C 中,我会使用 C 数组,但我不认为SCNVector3[]
Swift 中的 a 是这样布局的。
You can get a CMutablePointer<SCNVector3>
from SCNVector3[]
with &
:
var vertices: SCNVector3[] = [ ... ]
let geometrySource = SCNGeometrySource(vertices: &vertices, count: vertices.count)
It's important that vertices is mutable (declared with 'var' instead of 'let').
(found thanks to Adam's nudging in the comments above... whose answer I'll accept if he writes one :)