使用AFrame和three。制作了一个简单的AFrame场景,一个相机,一个渲染器,一个聚光灯,一个平面和一个立方体。
我想让这个立方体在平面上投下阴影。
我已经使用引用cube.object3D和spotlight.object3D在立方体中设置了聚光灯下的.castShadow。
我已经使用reference plane.object3D设置了平面中的receiveShadow。
还设置了renderer.shadowMapEnabled。
但是看不到投射到平面上的任何阴影。
有什么提示吗?
非常感谢。
发布于 2017-02-28 10:49:22
自那以后,阴影已添加到A帧:https://github.com/aframevr/aframe/pull/2350
https://aframe.io/docs/master/components/light.html#configuring-shadows
<a-scene shadow>
<a-entity light="type: directional; castShadows: true"></a-entity>
<a-box shadow="cast: true; receive: true"></a-box>
</a-scene>发布于 2017-02-10 14:27:46
非常感谢你的回答。
我正在通过实践学习A-Frame,Three.js,Javascript和html。
你用A-Frame做的事情真是太棒了。
执行以下操作后,它不是完美的,但目前它可以工作:
在函数初始化中: registerComponent ()
在网格中投射阴影:
el.getObject3D('mesh').castShadow = data.shadow;//data.shadow = true
在要接收阴影的网格中:
el.getObject3D('mesh').receiveShadow = data.shadow;//data.shadow = true
聚光灯下:
this.spotlight = new THREE.SpotLight(data.colorm);
el.setObject3D('spotlight', this.spotlight);
el.getObject3D('spotlight').castShadow = data.shadow;
el.getObject3D('spotlight').shadow.camera.near = data.shadowcameranear;
el.getObject3D('spotlight').shadow.camera.far = data.shadowcamerafar;
el.sceneEl.systems.light.registerLight(el);然后使用场景已加载事件:
function setShadows()
{
aframeRenderer.shadowMap.enabled = true;
aframeRenderer.shadowMap.type = THREE.PCFSoftShadowMap;
aframeRenderer.setClearColor(0x000000, 1.0);
aframeRenderer.setSize(window.innerWidth, window.innerHeight);
aframeRenderer.shadowMap.enabled = true;
threeSpotLight.shadowCameraNear = 0.01;
threeSpotLight.castShadow = true;
threeCube.castShadow = true;
threeCube.receiveShadow = false;
threePlane.castShadow = false;
threePlane.receiveShadow = true;
threeSpotLight.visible = true;
}https://stackoverflow.com/questions/42062194
复制相似问题