Answer the question
In order to leave comments, you need to log in
How to light up an object in three.js? Where is the mistake?
It is not possible to illuminate the object that is in the upper block
https://pateder.ru/RODECOR/
function main() {
// const canvas = document.querySelector('#three');
// const renderer = new THREE.WebGLRenderer({canvas});
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, document.querySelector('.main__decor').clientWidth / document.querySelector('.main__decor').clientHeight, 0.1, 1000)
const renderer = new THREE.WebGLRenderer({antialias: true, alpha: true});
renderer.setSize( document.querySelector('.main__decor').clientWidth, document.querySelector('.main__decor').clientHeight)
renderer.domElement.setAttribute('id', 'three')
document.querySelector('#three').append(renderer.domElement);
renderer.setClearColor( 0xff0000, 0 );
renderer.render(scene, camera)
let objLoader = new THREE.OBJLoader();
objLoader.load('./obj.obj', obj => {
console.log(obj)
scene.add(obj);
obj.rotation.x += 1;
camera.rotation.x += -0.1
})
var spotLight = new THREE.SpotLight( 0xffffff );
scene.add(spotLight);
let light = new THREE.AmbientLight(0xffffff)
scene.add(light);
camera.position.z = 5;
var render = function () {
requestAnimationFrame( render );
renderer.render(scene, camera);
};
render();
}
main();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question