Browse Source

Convert vertex colors to Linear from sRGB (#23340)

Garrett Johnson 3 years ago
parent
commit
98f64b0030
1 changed files with 7 additions and 3 deletions
  1. 7 3
      examples/jsm/loaders/OBJLoader.js

+ 7 - 3
examples/jsm/loaders/OBJLoader.js

@@ -11,7 +11,8 @@ import {
 	MeshPhongMaterial,
 	Points,
 	PointsMaterial,
-	Vector3
+	Vector3,
+	Color
 } from 'three';
 
 // o object_name | g group_name
@@ -30,6 +31,8 @@ const _vC = new Vector3();
 const _ab = new Vector3();
 const _cb = new Vector3();
 
+const _color = new Color();
+
 function ParserState() {
 
 	const state = {
@@ -536,12 +539,13 @@ class OBJLoader extends Loader {
 						);
 						if ( data.length >= 7 ) {
 
-							state.colors.push(
+							_color.setRGB(
 								parseFloat( data[ 4 ] ),
 								parseFloat( data[ 5 ] ),
 								parseFloat( data[ 6 ] )
+							).convertSRGBToLinear();
 
-							);
+							state.colors.push( _color.r, _color.g, _color.b );
 
 						} else {