@@ -31,7 +31,6 @@ import fillExtrusion from './draw_fill_extrusion';
3131import { HD , prepareHD } from '../../modules/hd_main' ;
3232import hillshade from './draw_hillshade' ;
3333import raster , { prepare as prepareRaster } from './draw_raster' ;
34- import rasterParticle , { prepare as prepareRasterParticle } from './draw_raster_particle' ;
3534import background from './draw_background' ;
3635import { default as drawDebug , drawDebugPadding , drawDebugQueryGeometry } from './draw_debug' ;
3736import custom from './draw_custom' ;
@@ -53,8 +52,6 @@ import {WireframeDebugCache} from './wireframe_cache';
5352import { FOG_OPACITY_THRESHOLD } from '../style/fog_helpers' ;
5453import Framebuffer from '../gl/framebuffer' ;
5554import { OcclusionParams } from './occlusion_params' ;
56- import { Rain } from '../precipitation/draw_rain' ;
57- import { Snow } from '../precipitation/draw_snow' ;
5855import { PerformanceUtils } from '../util/performance' ;
5956
6057import type ImageManager from './image_manager' ;
@@ -144,7 +141,7 @@ const draw: Record<string, DrawStyleLayer> = {
144141 'fill-extrusion' : fillExtrusion ,
145142 hillshade,
146143 raster,
147- 'raster-particle' : rasterParticle ,
144+ 'raster-particle' : null ,
148145 background,
149146 sky,
150147 custom,
@@ -155,7 +152,7 @@ const prepare = {
155152 line : prepareLine ,
156153 model : modelPrepare ,
157154 raster : prepareRaster ,
158- 'raster-particle' : prepareRasterParticle
155+ 'raster-particle' : null
159156} ;
160157
161158const depthPrepass = {
@@ -167,7 +164,9 @@ const groundShadowMask = {
167164
168165async function setupHD ( ) {
169166 await prepareHD ( ) ;
170- draw . building = HD . drawBuilding ;
167+ draw . building = HD . building . draw ;
168+ draw [ 'raster-particle' ] = HD . particles . draw ;
169+ prepare [ 'raster-particle' ] = HD . particles . prepare ;
171170}
172171
173172/**
@@ -230,8 +229,8 @@ class Painter {
230229 loadTimeStamps : Array < number > ;
231230 _backgroundTiles : Record < number , Tile > ;
232231 _atmosphere : Atmosphere | null | undefined ;
233- _rain ?: Rain ;
234- _snow ?: Snow ;
232+ _rain ?: InstanceType < typeof HD . precipitation . Rain > ;
233+ _snow ?: InstanceType < typeof HD . precipitation . Snow > ;
235234 replacementSource : ReplacementSource ;
236235 conflationActive : boolean ;
237236 firstLightBeamLayer : number ;
@@ -1093,16 +1092,21 @@ class Painter {
10931092 const snow = this . _debugParams . forceEnablePrecipitation || ! ! ( this . style && this . style . snow ) ;
10941093 const rain = this . _debugParams . forceEnablePrecipitation || ! ! ( this . style && this . style . rain ) ;
10951094
1096- if ( snow && ! this . _snow ) {
1097- this . _snow = new Snow ( this ) ;
1095+ // Load HD for precipitation functionality
1096+ if ( ( snow || rain ) && ( ! HD . precipitation || ! HD . precipitation . Rain || ! HD . precipitation . Snow ) ) {
1097+ void prepareHD ( ) ;
1098+ }
1099+
1100+ if ( snow && ! this . _snow && HD . precipitation && HD . precipitation . Snow ) {
1101+ this . _snow = new HD . precipitation . Snow ( this ) ;
10981102 }
10991103 if ( ! snow && this . _snow ) {
11001104 this . _snow . destroy ( ) ;
11011105 delete this . _snow ;
11021106 }
11031107
1104- if ( rain && ! this . _rain ) {
1105- this . _rain = new Rain ( this ) ;
1108+ if ( rain && ! this . _rain && HD . precipitation && HD . precipitation . Rain ) {
1109+ this . _rain = new HD . precipitation . Rain ( this ) ;
11061110 }
11071111 if ( ! rain && this . _rain ) {
11081112 this . _rain . destroy ( ) ;
@@ -1731,7 +1735,7 @@ class Painter {
17311735 const globalDefines = this . currentGlobalDefines ( name , overrideFog , overrideRtt ) ;
17321736 const allDefines = globalDefines . concat ( defines ) ;
17331737
1734- const shaderSource = shaders [ name as keyof typeof shaders ] || HD . shaders [ name as keyof typeof HD . shaders ] ;
1738+ const shaderSource = shaders [ name as keyof typeof shaders ] || ( HD . shaders && HD . shaders [ name as keyof typeof HD . shaders ] ) || ( HD . precipitationShaders && HD . precipitationShaders [ name as keyof typeof HD . precipitationShaders ] ) ;
17351739 const key = Program . cacheKey ( shaderSource , name , allDefines , config ) ;
17361740
17371741 if ( ! this . cache [ key ] ) {
0 commit comments