如何修复 MapBox sceneKit(AR 场景)的“调用中的额外参数 'zoom'”?

How to fix 'Extra argument 'zoom' in call' for MapBox sceneKit (AR scene)?

错误表明它不需要 'zoom' 参数,但所有在线文档都另有建议。

当我删除 'zoom' 参数时,它再次出错并说它需要两个参数。我是否遗漏了另一个我需要添加的参数?

此外,我尝试使用 'multiplier' 参数,有人建议使用该参数也不起作用。

func createTerrain() {
    terrainNode = TerrainNode(minLat: minLat, maxLat: maxLat,
                              minLon: minLon, maxLon: maxLon)
    
    if let terrainNode = terrainNode {
        terrainNode.scale = terrainNodeScale // Scale down map
        terrainNode.position = SCNVector3Make(0, -0.15, 0) // Place map slightly below clouds
        terrainNode.geometry?.materials = defaultMaterials() // Add default materials
        scene.rootNode.addChildNode(terrainNode)
        
        terrainNode.fetchTerrainHeights(minWallHeight: 100.0, enableDynamicShadows: true, progress: { progress, total in
        }, completion: {
            NSLog("Terrain load complete")
        })
        
        terrainNode.fetchTerrainTexture("mapbox/satellite-v9", zoom: 14, progress: { progress, total in
        }, completion: { image in
            NSLog("Texture load complete")
            terrainNode.geometry?.materials[4].diffuse.contents = image
        })
    }
}

这是在地形纹理和卫星图像到地形节点的代码部分。我假设我需要知道 'zoom' 级别,但它希望将其删除。

任何帮助将不胜感激,因为我目前正在扯头发。非常感谢遇到此问题的任何人 post 并可以提供任何建议。

fetchTextureTerrain 方法似乎已从您的方法更改:

terrainNode.fetchTerrainTexture("mapbox/satellite-v9", zoom: 14, progress: { progress, total in
        }, completion: { image in
            NSLog("Texture load complete")
            terrainNode.geometry?.materials[4].diffuse.contents = image
        })

类似于:

terrainNode.fetchTerrainTexture("mapbox/satellite-v9", progress: { progress, total in
      // Some code here.

      }, completion: { image, fetchError in
            if let fetchError = fetchError {
                NSLog("Texture load failed: \(fetchError.localizedDescription)")
            }
            if image != nil {
                NSLog("Texture load complete")
                terrainNode.geometry?.materials[4].diffuse.contents = image
            }
      })

注意完成块中的额外 fetchError 项(以及您之前注意到的 zoom 项的删除)。无关但对于纯粹的 swift 实现,您应该使用 print 语句并避免 NSLogs.