Skip to content

Commit

Permalink
fix: Clouds rename attribute to prevent conflict (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
vis-prime committed Aug 28, 2024
1 parent 60337e0 commit 3999cbf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/Cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ const CloudMaterialMaker = (material: typeof Material) => {
const opaque_fragment = parseInt(REVISION.replace(/\D+/g, '')) >= 154 ? 'opaque_fragment' : 'output_fragment'
this.onBeforeCompile = (shader) => {
shader.vertexShader =
`attribute float opacity;
`attribute float cloudOpacity;
varying float vOpacity;
` +
shader.vertexShader.replace(
'#include <fog_vertex>',
`#include <fog_vertex>
vOpacity = opacity;
vOpacity = cloudOpacity;
`
)
shader.fragmentShader =
Expand Down Expand Up @@ -140,7 +140,7 @@ export class Clouds extends Group {

const opAttr = new InstancedBufferAttribute(opacities, 1)
opAttr.setUsage(DynamicDrawUsage)
planeGeometry.setAttribute('opacity', opAttr)
planeGeometry.setAttribute('cloudOpacity', opAttr)

const CloudMaterial = CloudMaterialMaker(material)

Expand Down Expand Up @@ -195,7 +195,7 @@ export class Clouds extends Group {
if (instance.instanceColor) {
setUpdateRange(instance.instanceColor, { offset: 0, count: count * 3 })
}
setUpdateRange(instance.geometry.attributes.opacity as BufferAttribute, { offset: 0, count: count })
setUpdateRange(instance.geometry.attributes.cloudOpacity as BufferAttribute, { offset: 0, count: count })
}

let t = 0
Expand Down Expand Up @@ -233,7 +233,7 @@ export class Clouds extends Group {
}

// Update instance
instance.geometry.attributes.opacity.needsUpdate = true
instance.geometry.attributes.cloudOpacity.needsUpdate = true
instance.instanceMatrix.needsUpdate = true
if (instance.instanceColor) instance.instanceColor.needsUpdate = true
}
Expand Down

0 comments on commit 3999cbf

Please sign in to comment.