Hi Al,
I am trying to simply import mesh into my scene. In the console, it is visible that my mesh has been loaded 100% but it is not visible on the screen. I am attaching the code I am using. Plz, help me with the solution.
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75,
window.innerWidth / window.innerHeight,0.1,1000);
camera.position.set(0, 0, 5);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var loader = new THREE.GLTFLoader();
loader.load(
"./Switch.glb",
function (gltf) {
scene.add(gltf.scene)
},
function (xhr) {
console.log((xhr.loaded / xhr.total * 100) + '% loaded');
},
function (error) {
console.log('An error happened');
}
);
const animate = function () {
requestAnimationFrame(animate);
renderer.render(scene, camera);
};
animate();