簡體   English   中英

ARKIT:在一個 SCNNode 到另一個 SCNNode 之間畫線時觀察滯后

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM