Unify envmap textures and deprecate sphericalEnvMap #5454
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Follow-up of #5453, also preparation work for #5449. In A-Frame environment maps were handled separately in both the
standard
andphong
shader. Besides the code-duplication this also meant that there was no texture re-use between them or other textures.This PR moves the envMap logic into
utils/material
andsystems/material
in a similar vein to other textures. The eventual texture loads now also go through the texture cache. The possible values forenvMap
has been broadened to support both cubemaps and equirectangular maps. The latter allows a fallback for the currently incorrect behaviour ofsphericalEnvMap
. There is one small breaking change, theenvMap
value now behaves closer toasset
property types, meaning it now only supports ID based selectors and would otherwise assume a URL in case it's unwrapped (e.g. breakingenvMap="#someElement > a-cubemap.active"
).Changes proposed:
envMap
to a common implementation inutils/material
andsystems/material
making use of existing texture loading and caching.envMap
to support both cubemap (six images/<a-cubemap>
) as well as Equirectangular images.sphericalEnvMap
as Three.js dropped support for them long ago and A-Frame incorrectly uses them as Equirectangular images. Fallback is in place, logging a warning, but otherwise ensuring those expecting the equirectangular behaviour won't notice a regression.utils/src-loader
andshaders/phong