feat: add Snow and Rain particle effect components#4179
Open
feat: add Snow and Rain particle effect components#4179
Conversation
Implements <Snow /> and <Rain /> components backed by Mapbox Maps SDK v11.9+ experimental precipitation APIs (@_spi(Experimental)). - Add snow/rain to the code generator (generateCodeWithEjs.mjs, globals.mjs) - Generate SnowLayerStyleProps / RainLayerStyleProps TypeScript types - Add RNMBXSnow / RNMBXRain iOS singleton layer implementations - Add RNMBXSnow / RNMBXRain Fabric component views (iOS) - Add RNMBXSnow / RNMBXRain Android implementations + managers - Register components in RNMBXPackage and package.json codegenConfig - Export Snow and Rain from src/Mapbox.native.ts - Add SnowAndRain example (V11) and integrate into TerrainSkyAtmosphere - Bump Mapbox SDK iOS + Android to 11.20.1 - Work around MapContentReconciler reset of rain by async re-applying after initial style load completes
…ression errors The default color and vignetteColor for Rain use measure-light(brightness) expressions which fail with 'Brightness is unavailable in the current evaluation context' in terrain/atmosphere map styles. Set explicit static colors to bypass the failing expressions.
…ationReference Fix Android build by using precipitations.generated package path for Snow/Rain. Remove rasterElevationReference (not in SDK 11.20.1 despite spec claiming 11.19.0). Add measure-light availability warning to Rain.
04c976b to
e1c29ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements
<Snow />and<Rain />components that expose the experimental Mapbox Maps SDK v11.9+ precipitation particle effects to React Native. Follows the existing<Atmosphere />pattern throughout.snowandrainas singleton style layers, generatesSnowLayerStyleProps/RainLayerStylePropsTypeScript types and native style settersRNMBXSnow/RNMBXRainSwift singleton layer implementations + Fabric component viewsRNMBXSnow/RNMBXRainKotlin implementations + ViewManagers, registered inRNMBXPackageSnow.tsx/Rain.tsxcomponents exported fromMapbox.native.tsSnowAndRainexample (V11) + Snow/Rain toggle buttons integrated intoTerrainSkyAtmosphere11.18.2 → 11.20.1color/opacity/vignetteColorScreenshots
iOS Rain workaround
The Mapbox SDK's
MapContentReconcilerresets programmatically-appliedRainafterisStyleRootLoadedfires (which can happen after tile/sprite loading completes, well after the initialstyleLoadedevent). Since the style JSON has norainkey, the reconciler resets it to nil.RNMBXRain.addToMapschedules an async re-apply to survive this reset. Snow does not exhibit the same behaviour.To investigate the exact trigger: add a symbolic breakpoint in Xcode on
MapboxMaps.StyleManager.setStyleRainForPropertieswith "Automatically continue after evaluating" + a backtrace action — the callstack will pinpoint what fires it.Test plan
yarn generateproducesSnowLayerStyleProps/RainLayerStylePropsinsrc/utils/MapboxStyles.tspod install)./gradlew assembleDebug)