Skip to content

Commit 94cec23

Browse files
fix(encode): encodes a valid image when an invalid tonemapping value was provided as input
1 parent b425943 commit 94cec23

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/encode/materials/SDRMaterial.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,24 +161,32 @@ export class SDRMaterial extends ShaderMaterial {
161161

162162
get toneMapping () { return this._toneMapping }
163163
set toneMapping (value: ToneMapping) {
164+
let valid = false
164165
switch (value) {
165166
case ACESFilmicToneMapping:
166167
this.defines.TONEMAPPING_FUNCTION = 'ACESFilmicToneMapping'
168+
valid = true
167169
break
168170
case ReinhardToneMapping:
169171
this.defines.TONEMAPPING_FUNCTION = 'ReinhardToneMapping'
172+
valid = true
170173
break
171174
case CineonToneMapping:
172175
this.defines.TONEMAPPING_FUNCTION = 'CineonToneMapping'
176+
valid = true
173177
break
174178
case LinearToneMapping:
175179
this.defines.TONEMAPPING_FUNCTION = 'LinearToneMapping'
180+
valid = true
176181
break
177182
default:
178-
console.error('Unsupported toneMapping')
179-
return
183+
console.error(`Unsupported toneMapping: ${value}. Using LinearToneMapping.`)
184+
this.defines.TONEMAPPING_FUNCTION = 'LinearToneMapping'
185+
this._toneMapping = LinearToneMapping
186+
}
187+
if (valid) {
188+
this._toneMapping = value
180189
}
181-
this._toneMapping = value
182190
this.needsUpdate = true
183191
}
184192

0 commit comments

Comments
 (0)