首页 > 解决方案 > 如何修复 MapBox sceneKit(AR 场景)的“调用中的额外参数“缩放”?

问题描述

该错误表明它不需要“缩放”参数,但所有在线文档都建议使用其他方法。

当我删除“缩放”参数时,它再次出错并说它需要两个参数。我是否错过了需要添加的另一个论点?

此外,我尝试使用有人建议使用的“乘数”参数也不起作用。

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
        })
    }
}

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

任何帮助将不胜感激,因为我目前正在扯掉我的头发。非常感谢任何看到这篇文章并可以提供任何建议的人。

错误截图

标签: swiftxcodemapboxscenekitaugmented-reality

解决方案


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无关,但对于纯粹的快速实现,您应该使用print语句并避免使用NSLogs.


推荐阅读