Realistic lighting (sunlight) with Three.js?

后端 未结 2 939
天命终不由人
天命终不由人 2021-02-01 05:51

I\'m attempting to create a small 1st-person game using Three.js, but I\'m having trouble with the lighting. Basically I want to simulate the sun and have it rotate around casti

2条回答
  •  借酒劲吻你
    2021-02-01 06:29

    I used a combination of these two lights to create this video: http://www.youtube.com/watch?v=m68FDmU0wGw

                var hemiLight = new THREE.HemisphereLight( 0xffffff, 0xffffff, 0.6 );
                hemiLight.color.setHSV( 0.6, 0.75, 0.5 );
                hemiLight.groundColor.setHSV( 0.095, 0.5, 0.5 );
                hemiLight.position.set( 0, 500, 0 );
                scene.add( hemiLight );
    
                var dirLight = new THREE.DirectionalLight( 0xffffff, 1 );
                dirLight.position.set( -1, 0.75, 1 );
                dirLight.position.multiplyScalar( 50);
                dirLight.name = "dirlight";
                // dirLight.shadowCameraVisible = true;
    
                scene.add( dirLight );
    
                dirLight.castShadow = true;
                dirLight.shadowMapWidth = dirLight.shadowMapHeight = 1024*2;
    
                var d = 300;
    
                dirLight.shadowCameraLeft = -d;
                dirLight.shadowCameraRight = d;
                dirLight.shadowCameraTop = d;
                dirLight.shadowCameraBottom = -d;
    
                dirLight.shadowCameraFar = 3500;
                dirLight.shadowBias = -0.0001;
                dirLight.shadowDarkness = 0.35;
    

提交回复
热议问题