I have used swift IOS for creating map and loading map. In creating function, I tried to add an object on the map and recorded its SCNVector3 location in Placenote database. After relaunching the app and loading the same map, I place the object on the recorded SCNVector3 location but the object is placed in another position.
The above problem only happens when I restart the app. Does anyone have the same problem? Thanks.
@IBAction func createMap(_ sender: Any) {
LibPlacenote.instance.startSession()
self.ptViz?.enablePointcloud()
self.tapGestureRecognizer?.isEnabled = true
// handleTap function added the object name & its SCNVector3 location
}
@IBAction func saveMap(_ sender: Any) {
LibPlacenote.instance.saveMap(
savedCb: { (mapID: String?) -> Void in
LibPlacenote.instance.stopSession()
self.ptViz?.clearPointCloud()
self.tapGestureRecognizer?.isEnabled = false
let metadata = LibPlacenote.MapMetadataSettable()
metadata.name = "test"
// self.userdata included all the object location
metadata.userdata = self.userdata
if (!LibPlacenote.instance.setMetadata(mapId: mapID!, metadata: metadata, metadataSavedCb: {(success: Bool) -> Void in})) {
print ("Failed to set map metadata")
}
}
// Loaded Map
func onLocalized() {
for item in self.objectList {
let x = Float(item["userData"]!["x"]!)!
let y = Float(item["userData"]!["y"]!)!
let z = Float(item["userData"]!["z"]!)!
let location = item["userData"]!["location"]!
let position = SCNVector3(x: x, y: y, z: z)
self.addLocation(location: location, position: position)
}
}
Placenote database: enter image description here
question from:
https://stackoverflow.com/questions/65920198/placenote-swift-wrong-position-after-loading-the-same-map 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…