[v3] Casting light from 3D models / layer interactions
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Before Mapbox v3 beta, I had implemented the building layer and additional models using the third party Threebox library; this enabled me to cast light from models and have it interact with surrounding buildings.
For example, in the image below you can see the white dot casting blue light onto the surrounding buildings.
I have since switched to v3 and have been able to import models with the recommended approaches (looks awesome - thanks!!!), but have been unable to implement any sort of lighting. I have attempted to add light sources to my .glb
glb = {
...
"extensions": {
"KHR_lights_punctual": {
"lights": [
{
"color": [
1,
1,
1
],
"intensity": 1,
"type": "point",
"range": 100
}
]
}
},
"extensionsUsed": [
"KHR_lights_punctual"
]
...
}
but this has no evident effect on the output model layer in Mapbox. I have also tried to add additional lights utilizing the new lights API, to no avail.
I'm wondering if there is any recommended way to implement point light sources that interact with other layers (building / trees) or another raycasting sort of feature that achieves the same effect? Additionally, as can be seen in the image above, I am not able to get shadows between the model layer and tree layer to behave in the expected way when dealing with a opacity gradient in my source model (the tree shadow is cut off); I have changed the model-cast-shadows and model-recieve-shadows layer attributes, but this has no effect. I have also not been able to place the model layer above the tree layer as when I set the before? parameter in addLayer to 'trees' or 'trees\u001fbasemap', I recieve an error that this layer cannot be found, even when I can successfully query for it with betaMap.style.getLayer('trees\u001fbasemap').
Thanks for your help.
@mourner @astojilj
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the v3 model-layer lighting, shadow, and addLayer ordering behavior described here, comparing the GLB KHR_lights_punctual setup with the new lights API. A useful result would document whether point lights can affect surrounding building and tree layers, whether opacity-gradient shadows are supported, and why the requested before-layer identifier is rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- computer-graphics, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100