1、光源的類型code
2、基礎光源get
一、AmbientLightit
沒有特定來源,不會產生陰影,不能單獨使用,與其餘光源一塊兒使用,目的是弱化陰影或添加顏色。io
var ambientLight = new THREE.AmbientLight('#0c0c0c'); scene.add(ambientLight);
不須要指定光源位置ast
二、PointLight基礎
new THREE.PointLight(color顏色, intensity強度, distance距離, position位置, visible光源開閉)渲染
var pointColor = '#ccffcc'; var pointLight = new THREE.PointLight(pointColor, 2, 100); pointLight.position.x = -20; pointLight.position.y = 10; pointLight.position.z = 0; pointLight.visible = true; scene.add(pointLight);
*點光源不會產生投影,由於點光源向全部方向發射光,計算負擔太重。di
三、SpotLightpoi
var spotLight = new THREE.SpotLight('#FFFFFF'); spotLight.position.set(-40, 60, -10); spotLight.castShadow = true; spotLight.target = plane; scene.add(spotLight);
若想指向其餘地方,空間其餘點位,能夠建立一個空的THREE.Object3D()實例vi
var target = new THREE.Object3D(); target.position = new THREE.Vector3(5, 0, 0); spotlight.target = target;
其餘屬性有待研究
四、DirectinalLight
var directionalLight = new THREE.DirectionalLight('#FFFFFF'); directionalLight.position.set(-20, 50, -20); directionalLight.castShadow = true; directionalLight.shadowCameraNear = 2; directionalLight.shadowCameraFar = 200; directionalLight.shadowCameraTop = 50; directionalLight.shadowCameraBottom = -50; directionalLight.shadowCameraLeft = -50; directionalLight.shadowCameraRight = 50; scene.add(directionalLight);
3、特殊光源
待更