Recently, I've been experimenting with the GLTFLoader feature in THREE.js along with the new blender exporter found here. After successfully adding a model with similar color material and importing the scene into my THREE.js project, I noticed that while the mesh imported correctly, the lights from the Blender scene were not working as expected.
I had to manually add a THREE.js light to see anything, indicating that the imported lights were recognized as 3D objects without their functionality. Is there a way to automatically activate the imported lights or do I need to programmatically replace them with THREE.js lights at their respective positions? Furthermore, is there a method to configure sun lights and point lights from Blender so they face the correct direction when imported?
Below is some of the code I've been working on (with limited support for all types of lights):
function automaticallyAddLightsTo(inputScene) {
inputScene.children.forEach((x) => {
var light = new THREE.DirectionalLight(0xffffff, 0), //placeholder
isActuallyALight = false;
if(x.name.includes("Sun")) {
light = new THREE.DirectionalLight(0xffffff, 1);
isActuallyALight = true;
} else if(x.name.includes("Point")) {
light = new THREE.PointLight(0xffffff, 1, 100);
isActuallyALight = true;
} // Add other light types here
light.position.copy(x.position);
light.rotation.copy(x.rotation);
light.scale.copy(x.scale);
light.quaternion.copy(x.quaternion);
if(isActuallyALight)
s.add(light);
});
}
One question remains: how can I detect the intensity of these imported lights?