swift - 如何修复 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
})
}
}
这是将地形纹理和卫星图像发送到地形节点的代码部分。我假设我需要知道“缩放”级别,但它希望将其删除。
任何帮助将不胜感激,因为我目前正在扯掉我的头发。非常感谢任何看到这篇文章并可以提供任何建议的人。
解决方案
该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
语句并避免使用NSLog
s.
推荐阅读
- apache-kafka - 通过 kafka-configs.sh 获取代理配置
- java - 结合 Spring Data JPA 和 Feign 的映射
- hibernate - 休眠:OneToMany 在同一个表中
- javascript - 数组不是作为新索引推送,而是作为新数组推送
- jenkins - 如何自动更新詹金斯构建文件
- cognos - IBM Cognos Analytics 与 jQuery/DataTables 绘制或 setData 函数问题
- sql-server - 如何在当前表中显示相关数据?
- wordpress - 图像小部件 -> 动态 -> 简码 -> 无输出
- vuejs2 - Firebase 存储 getDownloadURL 创建无限循环
- typescript - 打字稿的奇怪情况