camera setup:
Camera = new THREE.PerspectiveCamera(45, Width / Height, 0.1, 10000);
Camera.position.set( 150, 400, 400);
Scene.add(Camera);
Lighting configuration
Light = new THREE.SpotLight(0xffccff,.5, 0, Math.PI/2, 1);
Light.position.set(0, 2000, 0);
Light.castShadow = true;
Light.shadowBias = -0.0002;
Light.shadowCameraNear = 850;
Light.shadowCameraFar = 8000;
Light.shadowCameraFov = 600;
Light.shadowDarkness = .7;
Light.shadowMapWidth = 2048;
Light.shadowMapHeight = 2048;
Scene.add(Light);
Renderer settings
Renderer = new THREE.WebGLRenderer({
antialias: true,
sortObjects: false,
preserveDrawingBuffer: true,
shadowMapEnabled: true
});
document.body.appendChild(Renderer.domElement);
Renderer.shadowMap.type = THREE.PCFSoftShadowMap;
Renderer.shadowMap.cullFace = THREE.CullFaceBack;
Renderer.gammaInput = true;
Renderer.gammaOutput = true;
Renderer.setSize(window.innerWidth, window.innerHeight);
This function is used to add a 3D model
function getModel(path, texture) {
var Material = new THREE.MeshPhongMaterial({shading: THREE.SmoothShading,
specular: 0xff9900,
shininess: 0,
side: THREE.DoubleSide,
shading: THREE.SmoothShading
});
Loader = new THREE.JSONLoader();
Loader.load(path,function(geometry){
geometry.mergeVertices();
geometry.computeFaceNormals();
geometry.computeVertexNormals();
TextureLoader.load(texture,function(texture){
Mesh = new THREE.Mesh(geometry, Material);
Mesh.material.map = texture;
Mesh.material.map.wrapS = THREE.RepeatWrapping;
Mesh.material.map.wrapT = THREE.RepeatWrapping;
Mesh.material.map.repeat.set(38, 38);
//Mesh.position.y -= 1;
Mesh.position.y = 160;
Mesh.position.x = 0;
Mesh.position.z = 0;
Mesh.scale.set(40, 40, 40);
Mesh.castShadow = true;
Mesh.receiveShadow = true;
Scene.add(Mesh);
});
});
}
The plane that receives shadows is defined as:
var planeGeometry = new THREE.PlaneBufferGeometry(100,100);
var planematerial = new THREE.MeshLambertMaterial(
{
shininess: 80,
color: 0xffaaff,
specular: 0xffffff
});
var plane = new THREE.Mesh(planeGeometry, planematerial);
plane.rotation.x = - Math.PI / 2;
plane.position.set(0,100,0);
plane.scale.set( 10, 10, 10 );
plane.receiveShadow = true;
plane.castShadow = true;
Scene.add(plane);
I made adjustments to the lights' positions and modified the values of shadowCameraNear, Light.shadowCameraFar, and Light.shadowCameraFov, but I could not see any changes reflected in the scene.