i am render a glb format file in html but it’s not showing correctly it’s showing with out color this is my code`
<script>
// Initialize Three.js variables
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(5, window.innerWidth / window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer();
// Disable gamma correction
renderer.outputEncoding = THREE.LinearEncoding;
// Set renderer size
renderer.setSize(window.innerWidth, window.innerHeight);
// Add renderer to the container in the HTML
document.getElementById('container').appendChild(renderer.domElement);
// Add light to the scene (optional)
var light = new THREE.AmbientLight(0xffffff, 0.5);
scene.add(light);
// Load the GLTF file
var loader = new THREE.GLTFLoader();
loader.load('bike.glb', function(gltf) {
console.log('GLTF loaded successfully:', gltf);
scene.add(gltf.scene);
}, undefined, function(error) {
console.error('Error loading GLTF:', error);
});
// Set camera position
camera.position.z = 5;
// Create OrbitControls
var controls = new THREE.OrbitControls(camera, renderer.domElement);
// Function to animate the scene
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
controls.update(); // Update controls
}
// Start the animation
animate();
</script>`
this is the image of result
and the orginal one is look like
what is the error please help me.