如果您在这里使用r71
完成操作,阴影将起作用:
var shadowlight = new THREE.DirectionalLight( 0xffffff, 1.8 );
shadowlight.position.set( 0, 100, 0 );
shadowlight.castShadow = true;
shadowlight.shadowDarkness = 0.1;
this.scene.add(shadowlight);
this.renderer.setClearColor( 0xf1c140, 1 );
this.renderer.shadowMapEnabled = true;
this.renderer.shadowMapType = THREE.PCFSoftShadowMap;
https://codepen.io/nicolasdnl/pen/VYRXWr
但是,如果我将版本更改为104
,并进行建议的必要更改,则:
.shadowMapEnabled is now .shadowMap.enabled.
.shadowMapType is now .shadowMap.type.
THREE.Light: .shadowDarkness has been removed.
阴影不再起作用:https://codepen.io/bertug48/pen/YMowKx
如何在v104上启用像r71这样的阴影?
答案 0 :(得分:1)
MeshBasicMaterial
超过三年无法接收阴影。您必须使用带照明的材料作为地面,或添加带有THREE.ShadowMaterial实例的附加地面网格。
演示:https://jsfiddle.net/38weog40/
var planeGeometry = new THREE.PlaneGeometry( 200, 200 );
planeGeometry.rotateX( - Math.PI / 2 );
var planeMaterial = new THREE.ShadowMaterial();
planeMaterial.opacity = 0.2;
var plane = new THREE.Mesh( planeGeometry, planeMaterial );
plane.position.y = -200;
plane.receiveShadow = true;
scene.add( plane );
顺便说一句:MeshBasicMaterial
不再接收阴影的原因如下:https://github.com/mrdoob/three.js/issues/8116#issuecomment-183540170
three.js R104