ThreeJS对象组中的面上未收到阴影

时间:2016-11-03 15:20:45

标签: javascript three.js

我遇到的问题是在Object3D组的脸上没有收到阴影。

阴影是从物体投射出来并被地面接收的,但是阴影在它们应该的时候不会被彼此接收。

我已经四处寻找,但我似乎无法找到类似的问题,这让我相信我设置错误。

有人能看一眼吗?我在下面的JSfiddle中放了一个工作示例。我认为这可能与我设置面孔的方式有关。

https://jsfiddle.net/shanemccster/848k1qxh/

var makeobject = function(width, height, depth){
    logger('makeobject fired');
    var geometry = new THREE.BoxGeometry( width, height, depth );
    var materials = [
        new THREE.MeshLambertMaterial({ color: 0xffffff }),
        new THREE.MeshLambertMaterial({ color: 0xffcc00 }),
        new THREE.MeshLambertMaterial({ color: 0xffffff }),
        new THREE.MeshLambertMaterial({ color: 0xffcc00 }),
        new THREE.MeshLambertMaterial({ color: 0xffffff }),
        new THREE.MeshLambertMaterial({ color: 0xffcc00 })
    ];
    var texture = new THREE.MeshFaceMaterial( materials );
    texture.minFilter = THREE.LinearFilter;
    var theObject = new THREE.Mesh(geometry,texture);
    theObject.recieveShadow = true;
    theObject.castShadow = true;
    return theObject;
}

1 个答案:

答案 0 :(得分:1)

您需要在网格上设置receiveShadow标志。查看Object3D的文档,https://jsfiddle.net/woa7kzz1/Mesh的父文件。

relay-subscriptions