Skip to content

Commit 98f64b0

Browse files
authored
Convert vertex colors to Linear from sRGB (#23340)
1 parent a0ca79c commit 98f64b0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

examples/jsm/loaders/OBJLoader.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
MeshPhongMaterial,
1212
Points,
1313
PointsMaterial,
14-
Vector3
14+
Vector3,
15+
Color
1516
} from 'three';
1617

1718
// o object_name | g group_name
@@ -30,6 +31,8 @@ const _vC = new Vector3();
3031
const _ab = new Vector3();
3132
const _cb = new Vector3();
3233

34+
const _color = new Color();
35+
3336
function ParserState() {
3437

3538
const state = {
@@ -536,12 +539,13 @@ class OBJLoader extends Loader {
536539
);
537540
if ( data.length >= 7 ) {
538541

539-
state.colors.push(
542+
_color.setRGB(
540543
parseFloat( data[ 4 ] ),
541544
parseFloat( data[ 5 ] ),
542545
parseFloat( data[ 6 ] )
546+
).convertSRGBToLinear();
543547

544-
);
548+
state.colors.push( _color.r, _color.g, _color.b );
545549

546550
} else {
547551

0 commit comments

Comments
 (0)