我的目标并不反映Three.js中的光 [英] My object isn't reflects the light in Three.js

查看:108
本文介绍了我的目标并不反映Three.js中的光的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在three.js场景中有一些基于CubeGeometry的网格,所有这些都反映了我在全局使用的PointLight。但其中一个,只用THREE.Geometry(通过代码添加顶点和面)的手制作,没有反映出来。即使它没有颜色,我只能为此设置颜色,如果我在MeshPhongMaterial上将THREE.Color设置为emissive键。

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.

由几何形成JS功能动态。我正在使用这个litghs:

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)
        );

我应该在materialParams上添加一些东西?或者问题是什么?

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

推荐答案

听起来像手所做的几何体缺失,或顶点法线不正确。

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

你可以这样做:

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

这篇关于我的目标并不反映Three.js中的光的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆