Skip to content

Commit

Permalink
Fixed LinearGradient/RadialGradient effect for DynamicShader (#419)
Browse files Browse the repository at this point in the history
Resolved an issue where the linearGradient didn't return the proper
effect key that it need to differentiate between two different
linearGradient effects. Since the radialGradient had the same issue I
fixed it for that effect too.

Resolves issue #411
  • Loading branch information
wouterlucas authored Oct 22, 2024
2 parents f704121 + c2b9222 commit e99d314
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
type DefaultEffectProps,
ShaderEffect,
type ShaderEffectUniforms,
type ShaderEffectValueMap,
} from './ShaderEffect.js';

/**
Expand Down Expand Up @@ -54,6 +55,12 @@ export class LinearGradientEffect extends ShaderEffect {
override readonly name = 'linearGradient';

static override getEffectKey(props: LinearGradientEffectProps): string {
if ((props.colors as unknown as ShaderEffectValueMap).value as number[]) {
return `linearGradient${
((props.colors as unknown as ShaderEffectValueMap).value as number[])
.length
}`;
}
return `linearGradient${props.colors!.length}`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
type DefaultEffectProps,
ShaderEffect,
type ShaderEffectUniforms,
type ShaderEffectValueMap,
} from './ShaderEffect.js';

/**
Expand Down Expand Up @@ -62,7 +63,13 @@ export class RadialGradientEffect extends ShaderEffect {
override readonly name = 'radialGradient';

static override getEffectKey(props: RadialGradientEffectProps): string {
return `radialGradient${props.colors!.length}`;
if ((props.colors as unknown as ShaderEffectValueMap).value as number[]) {
return `linearGradient${
((props.colors as unknown as ShaderEffectValueMap).value as number[])
.length
}`;
}
return `linearGradient${props.colors!.length}`;
}

static override resolveDefaults(
Expand Down

0 comments on commit e99d314

Please sign in to comment.