threejs光的介绍

AmbientLight(环境光):

这个光的最大作用就是物体背对着光就不会一片黑怎么都看不见

const light = new THREE.AmbientLight(oxffffff, 0.2) //oxffffff是环境光 0.2是光的强度

 DirectionalLight(平行光):

const light = new THREE.DirectionalLight(oxffffff) //oxffffff 光的颜色
light.position.set(2, 2, 2) // 设置光的位置
scene.add(light) // 添加场景

如图:

 SpotLight(台灯光):

const spotLight = new THREE.SpotLight(0xffffff)
spotLight.position.set(1, 1, 1) //光源的位置 注意:光源越近就越亮
spotLight.angle = 60 / 180 * Math.PI //台灯照射的角度   当前值为60
spotLight.distance = 2 //锥体照射到的范围  超过这个范围就照不到了

scene.add(spotLight)

const spotLightHelper = new THREE.SporLightHelper(spotLight) //台灯灯光照射辅助
scene.add(spotLightHelper)

如图:

PointLight(点光源):

光照向四面八方

const pointLight = new THREE.PointLight(0xffffff)
pointLight.position.y = 2 //设置光源的位置
pointLight.intensity = 1 //光亮强度
pointLight.distance = 2 //光照射范围  超过这个范围就不会被照射
scene.add(pointLight)

const pointLightHelper = new THREE.PointLightHelper(pointLight)
scene.add(pointLightHelper)

如图:

RectAreaLight(范围光):

注意:范围光只针对 MeshStanardMaterialMeshPhysicalMaterial这两种材料

const rectAreaLight = new THREE.RectAreaLight(0xffffff, 1, 1, 1) //参数:颜色、光强度、长、宽
rectAreaLight.position.set(0, 1, 0)
rectAreaLight.rotation.x = -0.5 * Math.PI
scene.add(rectAreaLight)

const helper = new THREE.RectAreaLightHelper(rectAreaLight)
scene.add(helper)

如图:

HemisphereLight:

const hLight = new THREE.HemisphereLight(0xff0000, 0x0000ff, 1) //参数:天空的颜色  地面的颜色、光的强度
scene.add(hLight)

总结光种类图:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值