I looked through a number of other SO questions, followed all the tips, but I still donβt know why I canβt get shadows for rendering on this very main scene.
http://jsfiddle.net/4Txgp/
[Updated] Code:
var SCREEN_WIDTH = window.innerWidth - 25; var SCREEN_HEIGHT = window.innerHeight - 25; var camera, scene; var canvasRenderer, webglRenderer; var container, mesh, geometry, plane; var windowHalfX = window.innerWidth / 2; var windowHalfY = window.innerHeight / 2; init(); animate(); function init() { container = document.createElement('div'); document.body.appendChild(container); camera = new THREE.PerspectiveCamera(30, window.innerWidth / window.innerHeight, 1, 10000); camera.position.x = 1200; camera.position.y = 1000; camera.lookAt({ x: 0, y: 0, z: 0 }); scene = new THREE.Scene(); var groundMaterial = new THREE.MeshLambertMaterial({ color: 0x6C6C6C }); plane = new THREE.Mesh(new THREE.PlaneGeometry(10000, 10000, 100, 100), groundMaterial); plane.rotation.x = -Math.PI / 2; plane.receiveShadow = true; scene.add(plane);
I have a scene with a plane object (cube), a projector (copied directly from http://threejs.org/docs/58/#Reference/Lights/SpotLight for testing purposes), and the camera. This is great, except that the cube does not cast a shadow on the βgroundβ (plane), and the shading looks as if everything was done in the main material. I use combos by Phongs and Lamberts.
My directional light is set to castShadow = true ;, and my plane is set using receiveShadow = true along with the shadow map settings. The rendering itself has shadowMapEnabled = true.
I tried various solutions, I remember that with previous versions of ThreeJS, depending on what you wanted to do, there would be calls to external libraries, but I also saw other examples on JSFiddle just calling ThreeJS on their own, as well as examples from the official site that work great.
Any hints / info / constructive notes on how to skip something simple and small?