Browse Source

convert vertex colors to linear in PLYLoader (#23342)

Garrett Johnson 3 years ago
parent
commit
145f71253f
1 changed files with 10 additions and 2 deletions
  1. 10 2
      examples/jsm/loaders/PLYLoader.js

+ 10 - 2
examples/jsm/loaders/PLYLoader.js

@@ -3,7 +3,8 @@ import {
 	FileLoader,
 	Float32BufferAttribute,
 	Loader,
-	LoaderUtils
+	LoaderUtils,
+	Color
 } from 'three';
 
 /**
@@ -32,6 +33,7 @@ import {
  *
  */
 
+const _color = new Color();
 
 class PLYLoader extends Loader {
 
@@ -407,7 +409,13 @@ class PLYLoader extends Loader {
 
 				if ( attrR !== null && attrG !== null && attrB !== null ) {
 
-					buffer.colors.push( element[ attrR ] / 255.0, element[ attrG ] / 255.0, element[ attrB ] / 255.0 );
+					_color.setRGB(
+						element[ attrR ] / 255.0,
+						element[ attrG ] / 255.0,
+						element[ attrB ] / 255.0
+					).convertSRGBToLinear();
+
+					buffer.colors.push( _color.r, _color.g, _color.b );
 
 				}