[英]Three.js - Creating shadows with MeshFaceMaterial
我現在嘗試了幾種不同的燈光(方向,點,點),但是它們都沒有在MeshFaceMaterial對象上產生漂亮的陰影。 相反,整個MeshFaceMaterial對象將變為黑色。
我的測試網站 (請仔細查看,並不斷更改)。
如何使用燈光在MeshFaceMaterials上創建陰影? MeshFaceMaterial是否支持陰影? 該文檔說:“使用MeshLambertMaterial或MeshPhongMaterial影響對象。”
這是我如何加載.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 );
});
這是我的.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
}
謝謝。
MeshFaceMaterial
只是材料的集合。 因此,如果您的materials
變量包含MeshLambertMaterial
或MeshPhongMaterial
,則應該沒問題。 陰影將由DirectionalLight
或SpotLight
生成。
只要確保您的渲染器具有:
renderer.shadowMapEnabled = true;
你的燈有:
light.castShadow = true;
您的每個網格:
mesh.castShadow = true;
並且您在其中至少有一個對象(例如飛機):
plane.receiveShadow = true;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.