浏览代码

Adjust OBJExporter to convert Linear colors to sRGB (#23374)

Garrett Johnson 3 年之前
父节点
当前提交
f75cbd1e11
共有 2 个文件被更改,包括 3 次插入2 次删除
  1. 1 1
      examples/jsm/exporters/OBJExporter.js
  2. 2 1
      examples/misc_exporter_obj.html

+ 1 - 1
examples/jsm/exporters/OBJExporter.js

@@ -251,7 +251,7 @@ class OBJExporter {
 
 
 					if ( colors !== undefined ) {
 					if ( colors !== undefined ) {
 
 
-						color.fromBufferAttribute( colors, i );
+						color.fromBufferAttribute( colors, i ).convertLinearToSRGB();
 
 
 						output += ' ' + color.r + ' ' + color.g + ' ' + color.b;
 						output += ' ' + color.r + ' ' + color.g + ' ' + color.b;
 
 

+ 2 - 1
examples/misc_exporter_obj.html

@@ -130,7 +130,7 @@
 				} else if ( type === 6 ) {
 				} else if ( type === 6 ) {
 
 
 					const points = [ 0, 0, 0, 100, 0, 0, 100, 100, 0, 0, 100, 0 ];
 					const points = [ 0, 0, 0, 100, 0, 0, 100, 100, 0, 0, 100, 0 ];
-					const colors = [ 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0 ];
+					const colors = [ 0.5, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0.5, 0 ];
 
 
 					const geometry = new THREE.BufferGeometry();
 					const geometry = new THREE.BufferGeometry();
 					geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( points, 3 ) );
 					geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( points, 3 ) );
@@ -149,6 +149,7 @@
 			function init() {
 			function init() {
 
 
 				renderer = new THREE.WebGLRenderer();
 				renderer = new THREE.WebGLRenderer();
+				renderer.outputEncoding = THREE.sRGBEncoding;
 				renderer.setPixelRatio( window.devicePixelRatio );
 				renderer.setPixelRatio( window.devicePixelRatio );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				document.body.appendChild( renderer.domElement );
 				document.body.appendChild( renderer.domElement );