mapbox / mapbox-gl-js

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
https://docs.mapbox.com/mapbox-gl-js/
Other
11.11k stars 2.21k forks source link

3D models not showing with GeoJSON source #13191

Closed joecusdin closed 3 months ago

joecusdin commented 4 months ago

mapbox-gl-js version: 3.4.0

browser: Chrome Version 122.0.6261.69

Steps to Trigger Behavior

  1. Add a GeoJSON source
  2. Add a 3D model layer using the GeoJSON source

Link to Demonstration

https://codepen.io/Joe-djc/pen/ZENeJQV#

Expected Behavior

3D models show at positions of GeoJSON points

Actual Behavior

No 3D models are shown, and no errors are thrown. In the demonstration, I have added a circle layer using the same source to show where I expect the models to appear. I am using the "turbinetower-lod1" model (part of the standard style).

Expecting to see 'Turbine Towers' on the black circles

Screenshot 2024-06-01 at 11 25 11
linze99 commented 3 months ago

This is not a bug, add model before you add the model layer. 截屏2024-06-03 14 00 03

joecusdin commented 3 months ago

Ok thanks @linze99. I used a model which was part of the style sheet assuming I could use it (e.g. a tree which is part of the standard style...those turbine towers are in the style). I'll add them after the style has loaded in future.

jtorresfabra commented 3 months ago

Hey @joecusdin,

The problem here is that geojson layers have a different scope than basemap defined layers. Right now you cannot use already loaded models from basemap style in your own layers.

However, no need to set addModel, you can directly reference the modelUrl in the model-id section. like "model-id" : "mapbox://models/mapbox/turbinerotor-lod1.glb". And the models should load correcltly

image

joecusdin commented 3 months ago

Ok thanks for the clarification @jtorresfabra