@@ -142,11 +142,12 @@ export const flockMaterial = {
142142 } ,
143143 glow ( meshName , { color } = { } ) {
144144 if ( flock . materialsDebug ) console . log ( `Making ${ meshName } glow` ) ;
145- // Ensure the glow layer is initialised and only affects explicitly
146- // included meshes.
147145 if ( ! flock . glowLayer ) {
148146 flock . glowLayer = new flock . BABYLON . GlowLayer ( "glowLayer" , flock . scene ) ;
149147 flock . glowLayer . intensity = 0.5 ;
148+ if ( flock . sky ) {
149+ flock . glowLayer . addExcludedMesh ( flock . sky ) ;
150+ }
150151 }
151152
152153 return new Promise ( ( resolve ) => {
@@ -166,10 +167,6 @@ export const flockMaterial = {
166167 m . metadata = m . metadata || { } ;
167168 m . metadata . glow = true ;
168169
169- if ( flock . glowLayer ) {
170- flock . glowLayer . addIncludedOnlyMesh ( m ) ;
171- }
172-
173170 if ( m . material ) {
174171 const currentMat = m . material ;
175172 const color = glowColor
@@ -280,13 +277,10 @@ export const flockMaterial = {
280277 targetMesh . metadata . glow = false ;
281278
282279 if ( flock . glowLayer ) {
283- flock . glowLayer . removeIncludedOnlyMesh ( targetMesh ) ;
284-
285- const hasIncludedMeshes =
286- flock . glowLayer . includedOnlyMeshes &&
287- flock . glowLayer . includedOnlyMeshes . length > 0 ;
288-
289- if ( ! hasIncludedMeshes ) {
280+ const anyGlowing = flock . scene . meshes . some (
281+ ( m ) => m !== targetMesh && m . metadata ?. glow ,
282+ ) ;
283+ if ( ! anyGlowing ) {
290284 flock . glowLayer . dispose ( ) ;
291285 flock . glowLayer = null ;
292286 }
0 commit comments