I adopted the documentation for displaying a 3D Puck however it’s not exhibiting.
Already tried with one other .gltf, .glb or perhaps a .usdz however nonetheless no luck. File is imported accurately too.
The puck does present if I modify the .puckType
to a .puck2D()
.
Deadly Error doesn’t get known as so MapBox is getting the mannequin efficiently, and the file doesn’t have any errors.
Additionally tried altering the modelScale however no luck. In addition to modelOpacity or orientation.
class MapViewController: UIViewController {
var mapView: MapView!
non-public var cancelables = Set<AnyCancelable>()
override func viewDidLoad() {
tremendous.viewDidLoad()
let choices = MapInitOptions()
mapView = MapView(body: view.bounds, mapInitOptions: choices)
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(mapView)
mapView.mapboxMap.onStyleLoaded.observeNext { _ in
self.configureMapView()
}.retailer(in: &cancelables)
setupGestureRecognizers()
}
non-public func configureMapView() {
// Fetch the asset
guard let uri = Bundle.fundamental.url(forResource: "truck", withExtension: "gltf") else {
fatalError("Didn't find glb mannequin in asset catalog")
}
// Instantiate the mannequin
let myModel = Mannequin(uri: uri, orientation: [0, 0, 180])
let configuration = Puck3DConfiguration(
mannequin: myModel,
modelScale: .fixed([10, 10, 10])
)
mapView.location.choices.puckType = .puck3D(configuration)
mapView.location.choices.puckBearing = .course
mapView.location.choices.puckBearingEnabled = true
mapView.location.onLocationChange.observeNext { [weak mapView] newLocation in
guard let location = newLocation.final, let mapView else { return }
mapView.digicam.ease(
to: CameraOptions(
heart: location.coordinate,
zoom: 15,
bearing: 0,
pitch: 55),
period: 1,
curve: .linear,
completion: nil
)
}.retailer(in: &cancelables)
}
}