Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelLayer disappears abruptly on panning when pitch is applied #2152

Open
qandeelabbassi opened this issue Mar 21, 2024 · 8 comments
Open
Labels
bug 🪲 Something is broken!

Comments

@qandeelabbassi
Copy link

qandeelabbassi commented Mar 21, 2024

Environment

  • Xcode version: 15.3
  • iOS version: 17.4
  • Devices affected:
  • Maps SDK Version: 11.1.0

Observed behavior and steps to reproduce

ModelLayer disappears abruptly on panning when pitch is applied. Sometimes, initially, it doesn't even appear until I move the camera around

Code for adding model

 let plane = Bundle.main.url(
      forResource: MapViewModel.MapViewLabels.modelName,
      withExtension: MapViewModel.MapViewLabels.modelExt)!.absoluteString
  var source = GeoJSONSource(id: MapViewLabels.sourseID)
  try? mapProxy?.map!.addStyleModel(modelId: MapViewLabels.modelID, modelUri: plane)
  var planeFeature = Feature(geometry: Point(CLLocationCoordinate2D(latitude: position?.latitude ?? self.latitude, longitude: position?.longitude ?? self.longitude)))
  planeFeature.properties = [MapViewLabels.modelKey: .string(MapViewLabels.modelID)]
  source.data = .featureCollection(FeatureCollection(features: [planeFeature]))
  try? mapProxy?.map!.addSource(source)
  var layer = ModelLayer(id: MapViewLabels.layerId, source: MapViewLabels.sourseID)
  layer.modelId = .expression(Exp(.get) { MapViewLabels.modelKey })
  layer.modelType = .constant(.common3d)
  layer.modelScale = .constant(MapViewModel.MapViewLabels.modelScale)
  let altitude = position?.altitude?.feetToMeter() ?? Double(self.altitude)
  layer.modelTranslation = .constant([0, 0, altitude])
  let headingAngle = Double(position?.heading ?? heading) - 180
  layer.modelRotation = .constant([0, 0, headingAngle])
  layer.maxZoom = 22
  layer.minZoom = 0  
  try? mapProxy?.map!.addLayer(layer)

Code for setting camera:

let freeCam = self.mapProxy?.map?.freeCameraOptions
freeCam?.location = CLLocationCoordinate2D(latitude: lat, longitude: lng)
freeCam?.altitude = camAltitude
freeCam?.lookAtPoint(forLocation: CLLocationCoordinate2D(latitude: modelLat, longitude: modelLng), altitude: modelAltitude)
mapProxy?.map?.freeCameraOptions = freeCam!

Video

recording.mov

Expected behavior

The model shouldn't disappear

@qandeelabbassi qandeelabbassi added the bug 🪲 Something is broken! label Mar 21, 2024
@astojilj
Copy link
Contributor

@qandeelabbassi Thanks. This issue is related to tile cover: internally, geojson is split into tiles, and when the underlying tile gets out of the viewport, each of the 3D model objects anchored to the positions on that tile is not rendered.

We will work on resolving this. Meanwhile, as a workaround, would it help to lower layer.maxZoom = 22, to e.g. layer.maxZoom = 5? Larger tiles (occupying larger geometry) would be less likely to get out of the viewport. The workaround would be problematic for a high zoom situations due to precision loss.

@qandeelabbassi
Copy link
Author

@astojilj, thanks for the quick response.

  1. I forgot to mention that the 2 models in the above video are two different instances, they are not connected in any way, should the tile cover still be an issue?
  2. When the underlying tile gets out of the viewport, each of the 3D model objects anchored to the positions on that tile is not rendered.

But the models never get out of the viewport in the above video. My understanding of the viewport might be incorrect, so I would like to know what viewport you are referring to here.

  1. Meanwhile, as a workaround, would it help to lower layer.maxZoom = 22, to e.g. layer.maxZoom = 5?

According to my understanding, decreasing the maxZoom would cause the model to disappear quickly or when we get closer to the model. Wouldn't this worsen the issue?

@astojilj
Copy link
Contributor

@qandeelabbassi
My mistake here:

Meanwhile, as a workaround, would it help to lower layer.maxZoom = 22, to e.g. layer.maxZoom = 5?

According to my understanding, decreasing the maxZoom would cause the model to disappear quickly or when we get closer to the model. Wouldn't this worsen the issue?

I meant GeoJSONSource source's maxzoom.

But the models never get out of the viewport in the above video. My understanding of the viewport might be incorrect, so I would like to know what viewport you are referring to here.

Models don't, but the tile on the ground gets out of viewport. This we need to resolve but I hope that the workaround (lower maxzoom for source) would help on this meanwhile.

@qandeelcc
Copy link

@astojilj, setting maxzoon on geojson source doesn't solve the issue. If i use 3D puck would it solve the problem?

@astojilj
Copy link
Contributor

3D puck should solve the issue, and could be used as a workaround until we fix this, since the underlying data is not tiled.

@qandeelabbassi
Copy link
Author

qandeelabbassi commented May 2, 2024

@astojilj using maxzoom=4 (or even 0) fixed the issue for now. Thanks a lot for the help!

@astojilj
Copy link
Contributor

astojilj commented May 2, 2024

@qandeelabbassi thanks, good to know that the workaround helped. We are working on a proper solution for this

@qandeelcc
Copy link

qandeelcc commented Jun 5, 2024

@astojilj Although maxZoom solves the described issue, it causes the model to shift away from the center of the map. Any idea how I can fix this?
I am willing to contribute if you can point me in the right direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something is broken!
Projects
None yet
Development

No branches or pull requests

3 participants