Bläddra i källkod

reset to Texture default setting

deepkolos 4 år sedan
förälder
incheckning
3194437dce
2 ändrade filer med 75 tillägg och 5 borttagningar
  1. 35 2
      examples/js/loaders/TGALoader.js
  2. 40 3
      examples/jsm/loaders/TGALoader.js

+ 35 - 2
examples/js/loaders/TGALoader.js

@@ -1,13 +1,46 @@
 THREE.TGALoader = function ( manager ) {
 
-	THREE.DataTextureLoader.call( this, manager );
+	THREE.Loader.call( this, manager );
 
 };
 
-THREE.TGALoader.prototype = Object.assign( Object.create( THREE.DataTextureLoader.prototype ), {
+THREE.TGALoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
 
 	constructor: THREE.TGALoader,
 
+	load: function ( url, onLoad, onProgress, onError ) {
+
+		var scope = this;
+
+		var texture = new THREE.DataTexture();
+		texture.flipY = true;
+		texture.generateMipmaps = true;
+		texture.unpackAlignment = 4;
+		texture.magFilter = THREE.LinearFilter;
+		texture.minFilter = THREE.LinearMipmapLinearFilter;
+
+		var loader = new THREE.FileLoader( this.manager );
+		loader.setResponseType( 'arraybuffer' );
+		loader.setPath( this.path );
+		loader.setWithCredentials( this.withCredentials );
+
+		loader.load( url, function ( buffer ) {
+
+			texture.image = scope.parse( buffer );
+			texture.needsUpdate = true;
+
+			if ( onLoad !== undefined ) {
+
+				onLoad( texture );
+
+			}
+
+		}, onProgress, onError );
+
+		return texture;
+
+	},
+
 	parse: function ( buffer ) {
 
 		// reference from vthibault, https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js

+ 40 - 3
examples/jsm/loaders/TGALoader.js

@@ -1,17 +1,54 @@
 import {
-	DataTextureLoader
+	DataTexture,
+	FileLoader,
+	LinearFilter,
+	LinearMipmapLinearFilter,
+	Loader
 } from '../../../build/three.module.js';
 
 var TGALoader = function ( manager ) {
 
-	DataTextureLoader.call( this, manager );
+	Loader.call( this, manager );
 
 };
 
-TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype ), {
+TGALoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	constructor: TGALoader,
 
+	load: function ( url, onLoad, onProgress, onError ) {
+
+		var scope = this;
+
+		var texture = new DataTexture();
+		texture.flipY = true;
+		texture.generateMipmaps = true;
+		texture.unpackAlignment = 4;
+		texture.minFilter = LinearMipmapLinearFilter;
+		texture.magFilter = LinearFilter;
+
+		var loader = new FileLoader( this.manager );
+		loader.setResponseType( 'arraybuffer' );
+		loader.setPath( this.path );
+		loader.setWithCredentials( this.withCredentials );
+
+		loader.load( url, function ( buffer ) {
+
+			texture.image = scope.parse( buffer );
+			texture.needsUpdate = true;
+
+			if ( onLoad !== undefined ) {
+
+				onLoad( texture );
+
+			}
+
+		}, onProgress, onError );
+
+		return texture;
+
+	},
+
 	parse: function ( buffer ) {
 
 		// reference from vthibault, https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js