![](/img/trans.png)
[英]ARKit – Is it possible to add a SCNNode while ARSession is paused?
[英]ARKIT: Observe lagging while drawing line between one SCNNode to another SCNNode
我画了线并创建了带有尺寸的框。 在 iPhone 8 及更高版本上遇到滞后问题,但在 iPhone7 上运行流畅。
对于更新行:
fileprivate func updateLine(_ line: SCNNode, from position: SCNVector3, distance: Float, axis: SCNVector3.Axis) {
guard let box = line.geometry as? SCNBox else {
fatalError("Tried to update something that is not a line")
}
let absDistance = CGFloat(abs(distance))
let offset = distance * 0.5
switch axis {
case .x:
box.width = absDistance
line.position = position + SCNVector3(x: offset, y: 0, z: 0)
case .y:
box.height = absDistance
line.position = position + SCNVector3(x: 0, y: offset, z: 0)
case .z:
box.length = absDistance
line.position = position + SCNVector3(x: 0, y: 0, z: offset)
}
}
iPhone 7:
中央处理器:48%
内存:199MB
每秒帧数:60
帧渲染时间:1.9 毫秒
iPhone 8 Plus: CPU:48%
内存:236 MB
图形处理器:4.5
每秒帧数:60
帧渲染时间:16.6 毫秒
项目中没有内存泄漏。
我在 iphone 8 plus 及更高版本上遇到了滞后问题,但在 iPhone7 上画线工作顺利,所以我实现了
// Show statistics such as fps and timing information
sceneView.showsStatistics = true
为了比较 iPhone7 和 iPhone8-plus 之间的差异,我注意到 iPhone 8Plus 及更高版本的帧渲染时间为 18 毫秒,而 iPhone 7 的帧渲染时间仅为 1 毫秒,因此我将 FPS 从默认值 60FPS 降低
sceneView.preferredFramesPerSecond = 40
现在滞后问题解决了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.