mapbox / mapbox/mapbox-maps-ios

ModelLayer disappears abruptly on panning when pitch is applied

Open
#2,152 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :beetle:
Dominant language
Swift
Stars
601
Forks
196
PR merge metrics
No merged PRs in 30d

Description

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

https://github.com/mapbox/mapbox-maps-ios/assets/14296772/93b8176b-8cfc-4997-9f64-518aeea589fc

Expected behavior

The model shouldn't disappear

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported ModelLayer setup with freeCameraOptions on Xcode 15.3 and iOS 17.4, then inspect the ModelLayer and camera-pitch rendering entry points. Done means the model appears initially and remains visible during panning with pitch applied.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
computer-graphics, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.