PointLight 点光源

—> Light —> Object3D

PointLight 是从一个点发出, 照射到所有方向的光源. 蜡烛的光就是生活中的点光源的一个例子. 太阳发出的光也是整个宇宙中的一个点光源. 从下面的演示中可以看出, MeshStandardMaterial 这种材质对于点光源相当的 敏感, 它不会像 MeshLambertMaterial 和 MeshPhongMaterial 那样整体发光. SpotLightDirectionalLight也能实现类似的效果.

function PointLight( color, intensity, distance, decay ) { } var light = new THREE.PointLight(0xffff00, 1, 50); light.position.set(0, 0, 5); scene.add(light); var cubeMaterial = new THREE.MeshLambertMaterial({color: 0xffffff}), sphereMaterial = new THREE.MeshStandardMaterial({color:0xffffff}), fishMaterial = new THREE.MeshPhongMaterial({color: 0xffffff, side:THREE.DoubleSide});

Attributes

type : String

Default value : 'PointLight'
Description : 类型.

isPointLight : Boolean

Default value : true (只读)
Description : 类型是否为PointLight.

decay : Float

Default value : 1
Description : 光线沿距离衰减的量. 在物理正确的模式下, decay = 2 会引导物理上逼真的光线衰减.

distance : Float

Default value : 0
Description : 光源照射到的距离.

shadow : LightShadow

Default value : new LightShadow( new PerspectiveCamera( 90, 1, 0.5, 500 ) )
Description : 阴影

图解API

点光源的光是向四面八方照射的. 点开查看

addPointLight(-10, 7, 6, 0xffff00); addPointLight(0,10,0, 0xffffff); var geometry = new THREE.SphereGeometry(3, 64, 64), material = new THREE.MeshPhongMaterial({color: 0x663399}); mesh = new THREE.Mesh( geometry, material ); mesh.castShadow = true; scene.add(mesh); var floorGeometry = new THREE.PlaneBufferGeometry( 50, 50), floorMaterial = new THREE.MeshPhongMaterial( { color: 0x666666 }), floor = new THREE.Mesh( floorGeometry, floorMaterial ); floor.rotation.x = -Math.PI/2; floor.position.y = -9; floor.position.z = -10; floor.receiveShadow = true; scene.add( floor ); function addPointLight(x,y,z,color){ var light = new THREE.PointLight(color); light.position.set(x,y,z); scene.add(light); light.decay = 1; light.distance = 40; light.castShadow = true; light.shadow.mapSize.width = 200; light.shadow.mapSize.height = 200; light.shadow.camera.left = -5; light.shadow.camera.right = 5; light.shadow.camera.top = 5; light.shadow.camera.bottom = -5; light.shadow.camera.near = 1; light.shadow.camera.far = 65; }