Hello, I am a beginner in ThreeJS and I'm currently working on adding an Environment Map on top of the materials loaded using JSON loader. This is my approach:
var gun = null;
var loader = new THREE.JSONLoader();
loader.load("obj/nissan/nissan-gt-r-nismo.json", function(geometry, materials){
var mat = new THREE.MeshPhongMaterial({
color: 0xffffff,
envMap: cubeMap,
shininess: 2.0
});
materials.push(mat);
var matface = new THREE.MeshFaceMaterial(materials);
gun = new THREE.Mesh(geometry, matface);
gun.scale.set(0.5,0.5, 0.5);
scene.add(gun);
} );
However, I noticed that the environment map gets overwritten by the materials loaded with JSONLoader. (Environment mapping works when I remove the loaded materials)
By the way, should I use JSONLoader or ObjectLoader for this task?
UPDATE: I RESOLVED THIS ISSUE BY UPDATING EACH MATERIAL TO INCLUDE THE ENVIRONMENT MAP.
for(var i = 0; i < materials.length; i++){
materials[i].envMap = cubeMap;
if(materials[i].name =="body-paint"){
materials[i].reflectivity = 0.2;
}
}
Is this the recommended method to achieve the desired outcome?