问题
I'm a newbie, and I think I missed something.
Could someone check, please?
HTML page: http://xalien95.altervista.org/pkmnxy_engine/alisopoli.html
MODEL and TEXTURES: http://xalien95.altervista.org/pkmnxy_engine/alisopoli/
I can see the model (with weird colors), but not the textures (it's a mesh with multiple materials).
Thanks in advance!
EDIT: I tried with all the materials types:
- THREE.MeshBasicMaterial
- THREE.MeshDepthMaterial
- THREE.MeshLambertMaterial
- THREE.MeshNormalMaterial
- THREE.MeshPhongMaterial
But noone works, so I think I've missed something (or the materials path is different). Here's the script:
var camera, scene, renderer, mesh, loader;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 1000;
scene = new THREE.Scene();
loader = new THREE.JSONLoader();
loader.load( "./alisopoli/alisopoli.js", function( geometry, materials ) {
var faceMaterial = new THREE.MeshPhongMaterial( materials );
mesh = new THREE.Mesh( geometry, faceMaterial );
mesh.scale.set( 100, 100, 100 );
mesh.position.y = -150;
mesh.position.x = 0;
mesh.rotation.x = 60;
scene.add( mesh );
} );
var ambientLight = new THREE.AmbientLight(0x555555);
scene.add(ambientLight);
//var directionalLight = new THREE.DirectionalLight(0xffffff);
//directionalLight.position.set(1, 1, 1).normalize();
//scene.add(directionalLight);
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
}
function animate() {
requestAnimationFrame( animate );
//mesh.rotation.y += 0.005;
renderer.render( scene, camera );
}
Thanks in advance!
回答1:
The weird colors are because you are assigning every mesh a "MeshNormalMaterial" during your load. You should check the three.js json loader examples or somehow get the correct material instead of assignen MeshNormalMaterials to the sub-meshes
来源:https://stackoverflow.com/questions/17868304/loading-textures-with-jsonloader