Hi everyone, I have an object in .glb format like this (usign windows visualizer 3D):
But when I try to import in threeJS appears like so:
Even when I try to put some light like direction, area, ambient the result does not change.
What I have to do?
This is my code that I use to import glb file and set to scene:
const loader = new GLTFLoader();
loader.load(
modelURL,
(gltf) => {
gltf.scene.traverse(
(child) => {
if ((child as THREE.Mesh).isMesh) {
const m = child as THREE.Mesh;
m.receiveShadow = true;
m.castShadow = true;
(m.material as MeshStandardMaterial).flatShading = false;
this.sceneMeshes.push(m);
}
if ((child as THREE.Light).isLight) {
const l = child as THREE.Light;
l.castShadow = true;
l.shadow.bias = -0.003;
l.shadow.mapSize.width = 2048;
l.shadow.mapSize.height = 2048;
}
});
const model = gltf.scene.children[0];
model.position.set(0, 0, 0);
this.scene.add(gltf.scene);
gltf.scene.scale.set(3, 3, 3);
const box = new Box3().setFromObject(gltf.scene);
const c = box.getCenter(new Vector3());
gltf.scene.position.set(-c.x, -c.y, c.z); // center the scene
}
);
Thanks for replay.