@@ -112,13 +112,13 @@ export const Clouds = /* @__PURE__ */ React.forwardRef<Group, CloudsProps>(
112
112
const opaque_fragment = parseInt ( REVISION . replace ( / \D + / g, '' ) ) >= 154 ? 'opaque_fragment' : 'output_fragment'
113
113
this . onBeforeCompile = ( shader ) => {
114
114
shader . vertexShader =
115
- `attribute float opacity ;
115
+ `attribute float cloudOpacity ;
116
116
varying float vOpacity;
117
117
` +
118
118
shader . vertexShader . replace (
119
119
'#include <fog_vertex>' ,
120
120
`#include <fog_vertex>
121
- vOpacity = opacity ;
121
+ vOpacity = cloudOpacity ;
122
122
`
123
123
)
124
124
shader . fragmentShader =
@@ -175,7 +175,7 @@ export const Clouds = /* @__PURE__ */ React.forwardRef<Group, CloudsProps>(
175
175
}
176
176
177
177
// Update instance
178
- instance . current . geometry . attributes . opacity . needsUpdate = true
178
+ instance . current . geometry . attributes . cloudOpacity . needsUpdate = true
179
179
instance . current . instanceMatrix . needsUpdate = true
180
180
if ( instance . current . instanceColor ) instance . current . instanceColor . needsUpdate = true
181
181
} )
@@ -187,11 +187,11 @@ export const Clouds = /* @__PURE__ */ React.forwardRef<Group, CloudsProps>(
187
187
if ( instance . current . instanceColor ) {
188
188
setUpdateRange ( instance . current . instanceColor , { offset : 0 , count : count * 3 } )
189
189
}
190
- setUpdateRange ( instance . current . geometry . attributes . opacity as BufferAttribute , { offset : 0 , count : count } )
190
+ setUpdateRange ( instance . current . geometry . attributes . cloudOpacity as BufferAttribute , { offset : 0 , count : count } )
191
191
} )
192
192
193
193
let imageBounds = [ cloudTexture ! . image . width ?? 1 , cloudTexture ! . image . height ?? 1 ]
194
- let max = Math . max ( imageBounds [ 0 ] , imageBounds [ 1 ] )
194
+ const max = Math . max ( imageBounds [ 0 ] , imageBounds [ 1 ] )
195
195
imageBounds = [ imageBounds [ 0 ] / max , imageBounds [ 1 ] / max ]
196
196
197
197
return (
@@ -206,7 +206,11 @@ export const Clouds = /* @__PURE__ */ React.forwardRef<Group, CloudsProps>(
206
206
>
207
207
< instancedBufferAttribute usage = { DynamicDrawUsage } attach = "instanceColor" args = { [ colors , 3 ] } />
208
208
< planeGeometry args = { [ ...imageBounds ] as any } >
209
- < instancedBufferAttribute usage = { DynamicDrawUsage } attach = "attributes-opacity" args = { [ opacities , 1 ] } />
209
+ < instancedBufferAttribute
210
+ usage = { DynamicDrawUsage }
211
+ attach = "attributes-cloudOpacity"
212
+ args = { [ opacities , 1 ] }
213
+ />
210
214
</ planeGeometry >
211
215
< cloudMaterial key = { material . name } map = { cloudTexture } transparent depthWrite = { false } />
212
216
</ instancedMesh >
@@ -278,7 +282,7 @@ export const CloudInstance = /* @__PURE__ */ React.forwardRef<Group, CloudProps>
278
282
279
283
const distributed = distribute ?.( cloud , index )
280
284
281
- if ( distributed || segments > 1 )
285
+ if ( distributed || segments > 1 ) {
282
286
cloud . position . copy ( cloud . bounds ) . multiply (
283
287
distributed ?. point ??
284
288
( {
@@ -287,6 +291,7 @@ export const CloudInstance = /* @__PURE__ */ React.forwardRef<Group, CloudProps>
287
291
z : random ( ) * 2 - 1 ,
288
292
} as Vector3 )
289
293
)
294
+ }
290
295
const xDiff = Math . abs ( cloud . position . x )
291
296
const yDiff = Math . abs ( cloud . position . y )
292
297
const zDiff = Math . abs ( cloud . position . z )
@@ -321,10 +326,9 @@ export const CloudInstance = /* @__PURE__ */ React.forwardRef<Group, CloudProps>
321
326
export const Cloud = /* @__PURE__ */ React . forwardRef < Group , CloudProps > ( ( props , fref ) => {
322
327
const parent = React . useContext ( context )
323
328
if ( parent ) return < CloudInstance ref = { fref } { ...props } />
324
- else
325
- return (
326
- < Clouds >
327
- < CloudInstance ref = { fref } { ...props } />
328
- </ Clouds >
329
- )
329
+ return (
330
+ < Clouds >
331
+ < CloudInstance ref = { fref } { ...props } />
332
+ </ Clouds >
333
+ )
330
334
} )
0 commit comments