I just started testing the GLTFLoader from THREE.js with the new blender exporter here, and I'm able to add a model with (at least the same color) material, and when I add the imported scene to the THREE.js scene, the mesh is imported fine and when I log it to the console I also see the camera and light from the default blender scene imported as well.
However, I had to manually add a THREE.js light to be able to see anything, so it seems that the light that is imported is only recognized as a 3D object. Is there some way to automatically get the imported lights to work, or do you have to programatically add THREE.js lights at the position of the imported "light" object? If so is there a way to match sun lights from blender, and point lights, and get them to face the right direction? Or is there some built-in way to do this?
BTW this is the code I have to far (still didn't add ALL lights support):
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 = newTHREE.PointLight( 0xffffff, 1, 100);
isActuallyALight = true;
} //etc for other lights
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);
});
}
but how do I detect intensity?
maybe this helps with the blender lights:
renderer.physicallyCorrectLights = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With