W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
這在SpotLights內(nèi)部用于計(jì)算陰影。
//Create a WebGLRenderer and turn on shadows in the renderer
const renderer = new THREE.WebGLRenderer();
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap
//Create a SpotLight and turn on shadows for the light
const light = new THREE.SpotLight( 0xffffff );
light.castShadow = true; // default false
scene.add( light );
//Set up shadow properties for the light
light.shadow.mapSize.width = 512; // default
light.shadow.mapSize.height = 512; // default
light.shadow.camera.near = 0.5; // default
light.shadow.camera.far = 500 // default
light.shadow.focus = 1; // default
//Create a sphere that cast shadows (but does not receive them)
const sphereGeometry = new THREE.SphereGeometry( 5, 32, 32 );
const sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } );
const sphere = new THREE.Mesh( sphereGeometry, sphereMaterial );
sphere.castShadow = true; //default is false
sphere.receiveShadow = false; //default
scene.add( sphere );
//Create a plane that receives shadows (but does not cast them)
const planeGeometry = new THREE.PlaneGeometry( 20, 20, 32, 32 );
const planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } )
const plane = new THREE.Mesh( planeGeometry, planeMaterial );
plane.receiveShadow = true;
scene.add( plane );
//Create a helper for the shadow camera (optional)
const helper = new THREE.CameraHelper( light.shadow.camera );
scene.add( helper );
構(gòu)造函數(shù)創(chuàng)建一個(gè) PerspectiveCamera : PerspectiveCamera 來(lái)管理陰影的世界視圖
有關(guān)常用屬性,請(qǐng)參閱基礎(chǔ)LightShadow類。
在光的世界里。這用于生成場(chǎng)景的深度圖;從光的角度來(lái)看,其他物體背后的物體將處于陰影中。默認(rèn)值為PerspectiveCamera,近剪裁平面為0.5。 fov將通過(guò)更新方法跟蹤擁有SpotLight的角度屬性。同樣,aspect屬性將跟蹤mapSize的方面。如果設(shè)置了燈光的距離屬性,則遠(yuǎn)剪裁平面將跟蹤該值,否則默認(rèn)為500。
用于聚焦陰影相機(jī)。相機(jī)的視野設(shè)置為聚光燈視野的百分比。范圍是 [0, 1]。默認(rèn)值為 1.0。
只讀標(biāo)志,用于檢查給定對(duì)象是否屬于 SpotLightShadow 類型。
有關(guān)常用方法,請(qǐng)參閱基礎(chǔ)LightShadow類。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: