Pure THREE.JS template
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r73/three.min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/3587259/Code/Threejs/OrbitControls.js">
</script>
JavaScript
var scene, renderer, camera, controls;
init();
animate();
function init()
{
basicScene();
var spotLight = new THREE.SpotLight( 0xffffff, 1 );
spotLight.position.set( 0.5, 2.5, 1 );
spotLight.angle = 0.5 * Math.PI/2;
spotLight.distance = spotLight.position.y + 5;
spotLight.exponent = 10;
spotLight.shadowDarkness = 0.1;
spotLight.castShadow = true;
var helper = new THREE.SpotLightHelper( spotLight );
// Add the helper and the shadow is gone!
//scene.add( helper );
spotLight.shadowCameraFov = 30;
spotLight.shadowCameraNear = 0.5;
spotLight.shadowCameraFar = spotLight.position.y + 1;
spotLight.shadowMapWidth = 2048;
spotLight.shadowMapHeight = 2048;
//spotLight.shadowBias = -0.05;
var helper = new THREE.CameraHelper( spotLight.shadow.camera );
helper.update();
//scene.add( helper );
scene.add( spotLight );
var plane = new THREE.Mesh(
new THREE.PlaneBufferGeometry( 40, 40, 1, 1 ),
new THREE.MeshPhongMaterial( { color: 0x999999, specular: 0x101010 } )
);
plane.rotation.x = -Math.PI/2;
scene.add( plane );
plane.receiveShadow = true;
var x = new THREE.Mesh( new THREE.BoxGeometry( 1, 1, 1 ) );
x.position.set( 0, 0.5, 2 );
scene.add( x );
}
function animate()
{
controls.update();
requestAnimationFrame ( animate );
renderer.render (scene, camera);
}
function basicScene() {
renderer = new THREE.WebGLRenderer( {antialias:true} );
var width = window.innerWidth;
var height = window.innerHeight;
renderer.setSize (width, height);
// background color
renderer.setClearColor( 0x55ff55, 1);
renderer.shadowMap.enabled = true;
document.body.appendChild (renderer.domElement);
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera (45, width/height, 1, 10000);
camera.position.y = 2;
camera.position.z = 1;
camera.lookAt (new THREE.Vector3(0,0,0));
controls = new THREE.OrbitControls (camera, renderer.domElement);
var aL = new THREE.AmbientLight (...