Hi everyone,
I have a .glb model that I want to load into my ThreeJS project and I successfully did so.
However, it isn’t rendered correctly (see pictures)
This is how it supposed to look like (I exported the same model to https://gltf-viewer.donmccurdy.com/):
And this is how it turned out:
Using this code
const scene = new THREE.Scene();
renderer = new THREE.WebGLRenderer({antialias:true});
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
scene.background = new THREE.Color(0xdddddd);
const camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 1, 5000);
camera.rotation.y = 45/180*Math.PI;
camera.position.x = 8;
camera.position.y = 10;
camera.position.z = 10;
const controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.addEventListener('change', renderer);
const hlight = new THREE.AmbientLight (0xffffff,0.86);
scene.add(hlight);
directionalLight = new THREE.DirectionalLight(0xffffff,100);
directionalLight.position.set(0,1,0);
directionalLight.castShadow = true;
scene.add(directionalLight);
const loader = new THREE.GLTFLoader();
loader.load('./correct/scene.glb',
( gltf ) => {
scene.add(gltf.scene)
},
( xhr ) => {
//progress
},
( error ) => {
console.log( error );
}
);
const animate = () =>{
render();
requestAnimationFrame(animate)
}
const render = () =>{
requestAnimationFrame(render);
renderer.render(scene,camera)
}
render();
The glb file:
glbtest.zip (2.3 MB)
As you can see, the light is not rendered correctly. Any idea what causes this and what the possible fixes are?
Thanks a lot!!