Skip to content

Commit 3999cbf

Browse files
authored
fix: Clouds rename attribute to prevent conflict (#72)
1 parent 60337e0 commit 3999cbf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/core/Cloud.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ const CloudMaterialMaker = (material: typeof Material) => {
9999
const opaque_fragment = parseInt(REVISION.replace(/\D+/g, '')) >= 154 ? 'opaque_fragment' : 'output_fragment'
100100
this.onBeforeCompile = (shader) => {
101101
shader.vertexShader =
102-
`attribute float opacity;
102+
`attribute float cloudOpacity;
103103
varying float vOpacity;
104104
` +
105105
shader.vertexShader.replace(
106106
'#include <fog_vertex>',
107107
`#include <fog_vertex>
108-
vOpacity = opacity;
108+
vOpacity = cloudOpacity;
109109
`
110110
)
111111
shader.fragmentShader =
@@ -140,7 +140,7 @@ export class Clouds extends Group {
140140

141141
const opAttr = new InstancedBufferAttribute(opacities, 1)
142142
opAttr.setUsage(DynamicDrawUsage)
143-
planeGeometry.setAttribute('opacity', opAttr)
143+
planeGeometry.setAttribute('cloudOpacity', opAttr)
144144

145145
const CloudMaterial = CloudMaterialMaker(material)
146146

@@ -195,7 +195,7 @@ export class Clouds extends Group {
195195
if (instance.instanceColor) {
196196
setUpdateRange(instance.instanceColor, { offset: 0, count: count * 3 })
197197
}
198-
setUpdateRange(instance.geometry.attributes.opacity as BufferAttribute, { offset: 0, count: count })
198+
setUpdateRange(instance.geometry.attributes.cloudOpacity as BufferAttribute, { offset: 0, count: count })
199199
}
200200

201201
let t = 0
@@ -233,7 +233,7 @@ export class Clouds extends Group {
233233
}
234234

235235
// Update instance
236-
instance.geometry.attributes.opacity.needsUpdate = true
236+
instance.geometry.attributes.cloudOpacity.needsUpdate = true
237237
instance.instanceMatrix.needsUpdate = true
238238
if (instance.instanceColor) instance.instanceColor.needsUpdate = true
239239
}

0 commit comments

Comments
 (0)