【发布时间】:2015-08-06 17:29:16
【问题描述】:
我一直在尝试在 Three.js 中使用搅拌机导出的模型,现在我可以导入模型,看看光线如何影响对象本身。我可以看到我使用的 directionalLight 突出了它所面对的东西,但我根本无法投射阴影。
这就是我正在做的事情:
renderer.shadowMapEnabled = true;
renderer.shadowMapType = THREE.PCFSoftShadowMap;
(...)
var directionalLight = new THREE.DirectionalLight(0xffffff);
directionalLight.position.set(30,10,-10);
directionalLight.castShadow = true;
directionalLight.shadowDarkness = 0.5;
directionalLight.shadowCameraVisible = true;
directionalLight.shadowBias = 0.1;
directionalLight.shadowMapWidth = 1024;
directionalLight.shadowMapHeight = 1024;
directionalLight.shadowCameraRight = 10;
directionalLight.shadowCameraLeft = -10;
directionalLight.shadowCameraTop = 10;
directionalLight.shadowCameraBottom = -10;
directionalLight.shadowCameraFar = 10;
directionalLight.shadowCameraNear = 10;
scene.add(directionalLight);
var loader = new THREE.ObjectLoader();
loader.load( "island.json", function ( geometry ) {
islandMesh = geometry;
for(k in islandMesh.children-1){
islandMesh.children[k].castShadow = true;
islandMesh.children[k].receiveShadow = true;
}
islandMesh.castShadow = true;
islandMesh.receiveShadow = true;
scene.add( islandMesh );
render();
} );
但即使我相信整个设置允许我完成投射阴影,我也无法投射任何阴影。 截图如下:
尽管光线来自岛屿的右侧,但山脉并没有像我预期的那样投下阴影。
我真的很感激你花时间看这个!
提前非常感谢,伙计们!
【问题讨论】:
标签: javascript json three.js