地板上的阴影在three.js v104中不起作用,但在r71中工作

问题描述 投票:1回答:1

如果你看看这里用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之类的阴影?

three.js shadow
1个回答
1
投票

MeshBasicMaterial现在无法接收阴影超过三年。您必须使用点燃的材料作为您的地面或添加额外的地面网格与THREE.ShadowMaterial的实例。

但是:ぁzxswい

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

© www.soinside.com 2019 - 2024. All rights reserved.