Skip to content

Commit

Permalink
Properly handle exr files on drag-and-drop
Browse files Browse the repository at this point in the history
  • Loading branch information
WestLangley committed Sep 3, 2020
1 parent bdd0946 commit e23695f
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions examples/webgl_materials_matcap.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@
var manager = new THREE.LoadingManager( render );

// matcap
var loader = new EXRLoader( manager );
var loader = new EXRLoader( manager )
.setDataType( THREE.UnsignedByteType ); // default: FloatType

var matcap = loader.load( 'textures/matcaps/040full.exr' );

// normalmap
var loader = new THREE.TextureLoader( manager );

var normalmap = loader.load( 'models/gltf/LeePerrySmith/Infinite-Level_02_Tangent_SmoothUV.jpg' );

// model
Expand Down Expand Up @@ -179,6 +182,8 @@

var loader = new EXRLoader();

loader.setDataType( THREE.UnsignedByteType ); // default: FloatType

var texData = loader.parse( contents );

var texture = new THREE.DataTexture();
Expand All @@ -190,9 +195,28 @@
texture.format = texData.format;
texture.type = texData.type;

texture.generateMipmaps = false;
texture.magFilter = THREE.LinearFilter;
texture.minFilter = THREE.LinearFilter;
switch ( texture.type ) {

case THREE.UnsignedByteType:

texture.encoding = THREE.RGBEEncoding;
texture.minFilter = THREE.NearestFilter;
texture.magFilter = THREE.NearestFilter;
texture.generateMipmaps = false;
texture.flipY = false;
break;

case THREE.FloatType:
case THREE.HalfFloatType:

texture.encoding = THREE.LinearEncoding;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.generateMipmaps = false;
texture.flipY = false;
break;

}

updateMatcap( texture );

Expand Down

0 comments on commit e23695f

Please sign in to comment.