【发布时间】:2019-08-23 11:37:00
【问题描述】:
我需要将 SCNVector3 乘以 0.1 才能获得新位置。当我尝试这样做时,我遇到了错误。这在早期的 Xcode 版本中是有效的。我正在使用 Xcode 10.1 和 Swift 4 版本的编译器。我已经看到了同类问题的其他答案,但这里的数据类型不同。
Binary operator '*' cannot be applied to operands of type 'SCNVector3' and 'Double'
我使用的代码如下,
guard let pointOfView = sceneView.pointOfView else { return }
let mat = pointOfView.transform
let dir = SCNVector3(-1 * mat.m31, -1 * mat.m32, -1 * mat.m33)
让 currentPosition = pointOfView.position + (dir * 0.1) ------> 此处出错
let projectedPlaneCenter = self.sceneView.projectPoint(currentPosition)
zVal = Double(projectedPlaneCenter.z)
【问题讨论】: