简体   繁体   English

THREE.JS GLTFLoader,使用工作灯加载搅拌机场景

[英]THREE.JS GLTFLoader, load blender scene WITH working lights

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.我刚刚开始使用新的搅拌机导出器在此处测试 THREE.js 中的 GLTFLoader,并且我能够添加具有(至少相同颜色)材质的模型,并且当我将导入的场景添加到 THREE.js 场景时,网格导入得很好,当我将它登录到控制台时,我还看到了来自默认搅拌机场景的相机和灯光。

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.但是,我必须手动添加一个 THREE.js 灯才能看到任何东西,因此似乎导入的灯只能识别为 3D 对象。 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?有什么方法可以让导入的灯光自动工作,还是必须以编程方式在导入的“灯光”对象的位置添加 THREE.js 灯光? 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?但我如何检测强度?

也许这有助于搅拌机灯:

renderer.physicallyCorrectLights = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM