我正在使用threejs将3d对象渲染到Web中。我正在使用法线贴图加载皱纹效果。在所有浅色上都清晰可见皱纹,而在黑色和棕色上则看不到皱纹。这与阴影颜色或强度有关吗?
任何帮助将不胜感激。
var mtlLoader = new THREE.MTLLoader();
//mtlLoader.setBaseUrl(jsStoreDirectory+'Configurator-Angular/build/assets/materials/');
mtlLoader.setPath(jsStoreDirectory+'Configurator-Angular/build/assets/materials/');
mtlLoader.load(mtlFile, function (materials) {
materials.preload();
console.log(materials);
var objLoader = new THREE.OBJLoader();
objLoader.setMaterials(materials);
objLoader.setPath(jsStoreDirectory+'Configurator-Angular/build/assets/materials/');
objLoader.load(objFile, function (object) {
//var imgSrc = "http://localhost:8080/CustomSublimation/store/3D/assets/228180.png";
objResponse = object;
imgSrc = image;
//console.log(imgSrc);
textureLoader = new THREE.TextureLoader();
textureLoader.crossOrigin = '';
texture = textureLoader.load( imgSrc );
var normalMapTexture = textureLoader.load(jsStoreDirectory+'Configurator-Angular/build/assets/materials/'+styleNumber+'-NormalMap.png');
var textureReverse = textureLoader.load( imageReverse );
var i=0;
object.traverse( function( node ) {
if( node.material ) {
var materialn = new THREE.MeshPhongMaterial({
map: texture,
normalMap: normalMapTexture
});
if(imageReverse != undefined && imageReverse != 'undefined' && imageReverse != ""){
var materialReverse = new THREE.MeshPhongMaterial({
map: textureReverse
});
}else{
var materialReverse = new THREE.MeshPhongMaterial({
color: 0xCDCDCD
});
}
if ( node instanceof THREE.Mesh ) {
if(node.material[0]){
var j;
for(j=0; j < node.material.length; j++){
var materialnew = new THREE.MeshPhongMaterial({
map: texture,
normalMap: normalMapTexture
});
if(node.material[j].name != 'reverse'){
materialnew.name= node.material[j].name;
node.material[j]=materialnew;
}else{
materialReverse.name= node.material[j].name;
node.material[j]=materialReverse;
}
}
}else{
if(node.material.name == 'reverse'){
materialReverse.name= node.material.name;
node.material = materialReverse;
}else{
materialn.name = node.material.name;
node.material = materialn;
}
}
mesh[i] = node;
i=i+1;
node.castShadow = true;
}
}
});
scene.add(object);
});
});