在 Three.js 中的 MeshPhongMaterial 或 MeshLambertMaterial 上投射阴影 [英] Casting shadow on MeshPhongMaterial or MeshLambertMaterial in Three.js

查看:56
本文介绍了在 Three.js 中的 MeshPhongMaterial 或 MeshLambertMaterial 上投射阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得我在这里遗漏了一些简单的东西.

我使用了

I feel like I'm missing something simple here.

I used JSFiddle by @WestLangley, which demonstrates how to cast a shadow from an object onto a plane.

Everything works as expected when the plane is filled with just color:

var groundMaterial = new THREE.MeshLambertMaterial({
  color: 0xFF0000
});

Then I change it to use texture instead:

var groundMaterial = new THREE.MeshLambertMaterial({
  // color: 0xFF0000,
  map: texture
});

..all of a sudden, shadow is gone:

This happens with both MeshPhongMaterial and MeshLambertMaterial.

Note that neither camera position nor shadow configuration is changed. Everything stays the same, yet shadow is gone.

Should texture be "told" to receive light or is this something else?

Tested on r61, r66, r67.

解决方案

This is a pretty old question, but just to provide some closure, I'd like to point out that the version that was having this issue has since been fixed. The fiddle used Three.js r66, but the most recent (r107 as of this writing) no longer has this problem:

这篇关于在 Three.js 中的 MeshPhongMaterial 或 MeshLambertMaterial 上投射阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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