I have tried a few different lights now (Directional, Spot, Point), but none of them produce a nice shadow on MeshFaceMaterial objects. Instead, the entire MeshFaceMaterial object will become black.
我现在尝试了几种不同的灯(Directional,Spot,Point),但它们都没有在MeshFaceMaterial对象上产生漂亮的阴影。相反,整个MeshFaceMaterial对象将变为黑色。
My Test Website (please view with a grain of salt, constantly being changed).
我的测试网站(请查看,不断变化)。
How can I use lights to create shadows on MeshFaceMaterials? Does MeshFaceMaterial support shadows? The documentation says "Affects objects using MeshLambertMaterial or MeshPhongMaterial."
如何使用灯光在MeshFaceMaterials上创建阴影? MeshFaceMaterial是否支持阴影?文档说“使用MeshLambertMaterial或MeshPhongMaterial影响对象”。
Here is sample code of how I am loading .json model.
这是我如何加载.json模型的示例代码。
loader.load('sample-concrete.js', function ( geometry, materials ) {
mesh1 = new THREE.Mesh(
geometry, new THREE.MeshFaceMaterial( materials )
);
mesh1.rotation.x = -Math.PI / 2;
scene.add( mesh1 );
});
and here is a sample of the material from my .json file.
这是我的.json文件中的材料示例。
"materials": [
{
"DbgIndex" : 0,
"DbgName" : "Steel",
"colorDiffuse" : [0.3059, 0.0471, 0.0471],
"colorAmbient" : [0.3059, 0.0471, 0.0471],
"colorSpecular" : [1.0000, 1.0000, 1.0000],
"transparency" : 1.0,
"specularCoef" : 25.0,
"vertexColors" : false
}
Thank you.
1 个解决方案
#1
A MeshFaceMaterial
is just a collection of materials. So if your materials
variable contains MeshLambertMaterial
or MeshPhongMaterial
you should be fine. Shadows will be generated from a DirectionalLight
or a SpotLight
.
MeshFaceMaterial只是一组材料。因此,如果您的材料变量包含MeshLambertMaterial或MeshPhongMaterial,那么您应该没问题。将从DirectionalLight或SpotLight生成阴影。
Just make sure your renderer has:
只需确保您的渲染器具有:
renderer.shadowMapEnabled = true;
your light has:
你的光有:
light.castShadow = true;
each one of your meshes:
每个网格:
mesh.castShadow = true;
and you have at least one object (a plane for example) where you do:
并且您至少有一个对象(例如一个平面):
plane.receiveShadow = true;
#1
A MeshFaceMaterial
is just a collection of materials. So if your materials
variable contains MeshLambertMaterial
or MeshPhongMaterial
you should be fine. Shadows will be generated from a DirectionalLight
or a SpotLight
.
MeshFaceMaterial只是一组材料。因此,如果您的材料变量包含MeshLambertMaterial或MeshPhongMaterial,那么您应该没问题。将从DirectionalLight或SpotLight生成阴影。
Just make sure your renderer has:
只需确保您的渲染器具有:
renderer.shadowMapEnabled = true;
your light has:
你的光有:
light.castShadow = true;
each one of your meshes:
每个网格:
mesh.castShadow = true;
and you have at least one object (a plane for example) where you do:
并且您至少有一个对象(例如一个平面):
plane.receiveShadow = true;