I would like to find the best way to add lights from a blender scene into a THREE.js project. I can not find an explanation of how to import the lighting from blender to THREE.js anywhere. You are expected to already have lighting in your THREE.js project. This is not very efficient when working with large scenes.
THREE.js output from blender import using gltf format
This is my import statement
initGLTFLoader(){
this.gltfLoader = new THREE.GLTFLoader();
}
loadCTF(){
// Load a glTF resource
this.gltfLoader.load(
// resource URL
'ctf.gltf',
// called when the resource is loaded
function ( gltf ) {
// this console.log indicates that the light are actually in the import,
// but dont get added to the scene
console.log(gltf);
this.scene.add( gltf.scene );
}.bind(this),
// called while loading is progressing
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
// called when loading has errors
function ( error ) {
console.log( 'An error happened', error );
}
);
}
physicallyCorrectLights
must be enabled on your renderer for the lights to behave according to the glTF spec. threejs.org/docs/#examples/en/loaders/GLTFLoader – Hypermetropia