光的三原色: 红red、绿green、蓝blue。
色彩模式: HSL、HSV。
色相Hue、饱和度Saturation、亮度Lightness、明度 Value。
白色反射所有光(白色的物体利于测试灯光)
把颜色添加到整个场景和对象的当前颜色上
maya环境光测试
一个蓝色的环境光渲染灰色box
THREE代码重构
环境光的特点:
构造函数声明
THREE.AmbientLight( hex );
function initLight() {
var light=new THREE.AmbientLight(0x0000ff);//蓝色环境环境光
var light_help=new THREE.SphereGeometry(16,16,16);
light.add(new THREE.Mesh(light_help,new THREE.MeshBasicMaterial({color:0xffffff})));//蓝色球体
scene.add(light);
}
function initObject() {
var r=10;
// var geometry = new THREE.SphereBufferGeometry( r,16,16);
var geometry = new THREE.CubeGeometry(300,300,300,);
//白色反射所有光线
var material = new THREE.MeshLambertMaterial( { color:0xFFFFFF} );//白色
var mesh = new THREE.Mesh( geometry,material);
mesh.position = new THREE.Vector3(0,0,0);
scene.add(mesh);
}
点发散光,例如蜡烛、白炽灯
maya点光测试
maya创建点光源预览
three代码重构
点光源PolintLight的构造函数
PointLight(color,intensity,distance);
function initLight() {
var light_point = new THREE.PointLight(0x0000FF,1,1000);//点光源,绿色,rgb
light_point.position.set(20,80,200);
var sphere = new THREE.SphereBufferGeometry( 10, 16, 16 );//添加一个球体
light_point.add(new THREE.Mesh(sphere,new THREE.MeshBasicMaterial({color:0x0000ff})));//绿色球体
scene.add(light_point);
}
光源的光线从一个锥体射出,在被照射的物体上产生聚光效果。舞台灯光
有一个顶角α
maya聚光灯测试
three代码重构
聚光灯的构造函数
THREE.SpotLight(hex,intensity,distance,angle,exponent);
前三个通俗易懂
var spotLight = new THREE.SpotLight( 0xffffff, 1 );
spotLight.position.set( 15, 40, 35 );
spotLight.angle = Math.PI / 4;
spotLight.penumbra = 0.05;
spotLight.decay = 2;
spotLight.distance = 200;
spotLight.castShadow = true;
spotLight.shadow.mapSize.width = 1024;
spotLight.shadow.mapSize.height = 1024;
spotLight.shadow.camera.near = 10;
spotLight.shadow.camera.far = 200;
scene.add( spotLight );
lightHelper = new THREE.SpotLightHelper( spotLight );
scene.add( lightHelper );
shadowCameraHelper = new THREE.CameraHelper( spotLight.shadow.camera );
scene.add( shadowCameraHelper );
平行光束,太阳光进入地球变成生活中的平行光。
maya平行光测试
平行光构造函数
THREEE.DirectionalLight=function(hex,instensizty);
three代码重构
var light_direction=new THREE.DirectionalLight(0x0000FF,1);//方向光蓝色
light_direction.position.set(10,20,6);
var ld_help=new THREE.DirectionalLightHelper(light_direction,20,0x0000FF);
scene.add(light_direction);//方向光
scene.add(ld_help);