Hello, I am looking to load an environment map from a jpg file ( env.jpg ) onto an object that has been loaded using THREE.JSONLoader(). Unfortunately, I was unable to export this map using Maya, so it needs to be added in this way. Can anyone help me with how to do this? Below is my code.
Thank you
loader.load(
// resource URL
'assets/alexander_test.json',
// onLoad callback
function ( geometry, materials ) {
//new THREE.MeshNormalMaterial()
var material = materials[ 0 ];
console.log(material.normalMap);
var object = new THREE.Mesh( geometry, material );
object.castShadow = true;
object.receiveShadow = true;
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
child.receiveShadow = true;
child.castShadow = true;
}
});
scene.add( object );
},
// onProgress callback
function ( xhr ) {
console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
},
// onError callback
function( err ) {
console.log( 'An error happened' );
}
);
EDIT:
Here is the online example: Here is the environment map:
EDIT:
Check out this working fiddle: https://jsfiddle.net/xk12n88z/4/
Thanks