intensity 0 – 1
set directional light
var light = new THREE.DirectionalLight( 0xFFFAAD, 0.7 ); light.position.set( 200, 500, 600 ); scene.add( light); lignt.position.set( 2, 5, 6); light.position.set( 0.02, 0.05, 0.06 );
scene.add( new THREE.AmbientLight( 0x222222)); var someMaterial = new THREE.MeshLamberMaterial( ); someMaterial.color.setRGB(0.8, 0.2, 0.1); someMaterial.ambient.copy( someMaterial.color );
function render(){ var delta = clock.getDelta(); cameraControls.update(delta); render.render(scene, camera); }
headlight = new THREE.PointLight( 0xFFFFFF, 1.0 ); scene.add( headlight );
color: full white intensity: 1.5 location: -400, 1200, 300 angle: 20 degrees exponent: 1 target position: 0, 200, 0
var light = new THREE.SpotLight( 0xFFFFFF, 1.0 ); light.position.set( -400, 1200, 300); light.angle = 20 * Math.PI / 180; light.exponent = 1; light.target.position.set(0, 200, 0); scene.add(light);
shadow in three.js
renderer.shadowMapEnabled = true; spotlight.castShadow = true; cube.castShadow = true; cube.receiveShadow = true; bbird.traverse( function (object){ object.castShadow = ture; object.receiveShadow = true; });
light.position.x = Math.cos( effectController.angle * Math.PI/180.0 ); light.position.z = Math.sin( effectController.angle * Math.PI/180.0 );
light.position.y = Math.sin(effectController.altitude * Math.PI/180.0); var length = Math.sqrt(1 - light.position.y*light.position.y); light.position.x = length * Math.cos( effectController.azimuth * Math.PI/180.0); light.position.z = length * Math.sin( effectController.azimuth * Math.PI/180.0);