My object isn't reflects the light in Three.js

若如初见. 提交于 2019-12-12 15:06:39

问题


I have some CubeGeometry based mesh in a three.js scene, and all of them reflects the PointLight what I'm using globally. But one of them, which made by "hand" with just THREE.Geometry (add vertices and faces by code) is not reflected. Even it has no color, I only can set color for this, if I set a THREE.Color to "emissive" key on the MeshPhongMaterial.

The geometry made by a JS function dinamically. I'm using this litghs:

    pointLight = new THREE.PointLight(0xFFFEF0, 1, 100000)
    pointLight.position = camera.position;
    scene.add(
        pointLight
    );  

And I'm creating the mentioned mesh with this code:

        var floor = new THREE.Mesh(
            ShelfArchitect.Utils.getFloorGeometry(walls), 
            new THREE.MeshPhongMaterial(materialParams)
        );

I should add something on materialParams? Or what is the problem?


回答1:


It sounds like the geometry made by "hand" is missing, or has incorrect, vertex normals.

You can do this:

geometry.computeFaceNormals();
geometry.computeVertexNormals();


来源:https://stackoverflow.com/questions/13943907/my-object-isnt-reflects-the-light-in-three-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!