【问题标题】:PointLight won't illuminate anythingPointLight 不会照亮任何东西
【发布时间】:2015-04-09 06:28:52
【问题描述】:

编辑: 现在我有两个准系统示例,使用第一个 MeshBasicMaterial 和第二个 MeshLambertMaterial:

PointLight_sucks__MeshBasicMaterial.html

PointLight_sucks__MeshLambertMaterial.html

两者都使用 PointLight,但 LambertMaterial 几何体并没有完全被照亮(但屏幕上似乎有闪烁的小点?)。


我有一个用MeshBasicMaterial 制作的几何图形。不知何故,它照亮了自己:

我还有一个PointLight

light = new THREE.PointLight( 0xaaaaaa );
light.position.set = new THREE.Vector3(-400, 0, 0);
makeScene.scene.add( light );

但它对场景没有影响。我希望场景只被 PointLight 照亮。

我为我的几何体尝试了各种其他材料,例如 MeshPhongMaterial、MeshNormalMaterial、MeshLambertMaterial 和 MeshFaceMaterial。

这就是我应用MeshBasicMaterial的方式:

material = new THREE.MeshBasicMaterial( { map: texture } );
mesh = new THREE.Mesh(aGeometry, material);

我怀疑我的PointLight 可能有问题。如何验证PointLight 是否正确应用于场景?

【问题讨论】:

  • 看看我编辑的答案。

标签: javascript three.js


【解决方案1】:

THREE.MeshBasicMaterial() 不受光线影响。将其更改为THREE.MeshLambertMaterial()THREE.MeshPhongMaterial()

编辑:

另外THREE.PointLight() 不影响THREE.MeshBasicMaterial()http://threejs.org/docs/#Reference/Lights/PointLight 一样。

根据PointLight() 以及与MeshLambertMaterial() 的交互,您的代码中有错误: 线条

light1.position.set = new THREE.Vector3(0, -120, 150);
light2.position.set = new THREE.Vector3(0,  120, 150);

应该是

light1.position.set (0, -120, 150);
light2.position.set (0,  120, 150);

【讨论】:

  • 你能创建一个jsfiddle吗?你的灯在负 x 轴上。网格的那一侧更亮吗?
  • 谢谢 :D 我可以在 11 小时后给你赏金
【解决方案2】:

MeshBasicMaterial 不受光线影响,请使用 gaitat 建议的其他材质类型。

我经常遇到光线太小而无法注意到的情况,或者它离我想要照亮的网格太远。也许这也是你的情况。

【讨论】:

    猜你喜欢
    • 2021-03-07
    • 2011-02-14
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多