Преглед на файлове

Editor: Use RGBFormat when loading a jpg.

Mr.doob преди 7 години
родител
ревизия
65747a39f5
променени са 3 файла, в които са добавени 6 реда и са изтрити 0 реда
  1. 1 0
      editor/js/libs/ui.three.js
  2. 2 0
      src/loaders/ObjectLoader.js
  3. 3 0
      src/textures/Texture.js

+ 1 - 0
editor/js/libs/ui.three.js

@@ -79,6 +79,7 @@ UI.Texture = function ( mapping ) {
 
 						var texture = new THREE.Texture( this, mapping );
 						texture.sourceFile = file.name;
+						texture.format = file.type === 'image/jpeg' ? THREE.RGBFormat : THREE.RGBAFormat;
 						texture.needsUpdate = true;
 
 						scope.setValue( texture );

+ 2 - 0
src/loaders/ObjectLoader.js

@@ -563,6 +563,8 @@ Object.assign( ObjectLoader.prototype, {
 
 				}
 
+				if ( data.format !== undefined ) texture.format = data.format;
+
 				if ( data.minFilter !== undefined ) texture.minFilter = parseConstant( data.minFilter, TEXTURE_FILTER );
 				if ( data.magFilter !== undefined ) texture.magFilter = parseConstant( data.magFilter, TEXTURE_FILTER );
 				if ( data.anisotropy !== undefined ) texture.anisotropy = data.anisotropy;

+ 3 - 0
src/textures/Texture.js

@@ -165,6 +165,7 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
 		}
 
 		var output = {
+
 			metadata: {
 				version: 4.5,
 				type: 'Texture',
@@ -183,11 +184,13 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
 
 			wrap: [ this.wrapS, this.wrapT ],
 
+			format: this.format,
 			minFilter: this.minFilter,
 			magFilter: this.magFilter,
 			anisotropy: this.anisotropy,
 
 			flipY: this.flipY
+
 		};
 
 		if ( this.image !== undefined ) {