// 聚光灯光源
spotLight (color, x, y, z, dis) {
const spotLight = new THREE.SpotLight(color)
spotLight.position.set(x, y, z); // 光源位置
spotLight.castShadow = true; //开启灯光投射阴影
spotLight.intensity = 3 // 强度
spotLight.angle = 0.3; // 角度
spotLight.penumbra = 1; // 半影
spotLight.decay = 1; // 衰退
spotLight.distance = dis; // 距离
this.scene.add(spotLight)
// 辅助线
let spotLightHelper = new THREE.SpotLightHelper(spotLight, 0x976fb6);
this.scene.add(spotLightHelper)
// 光源寄托
this.createLightView(color, x, y, z)
},
// 光源寄托
createLightView(color, x, y, z){
let geometry = new THREE.SphereGeometry(30, 30, 30);
let material = new THREE.MeshPhongMaterial({ color });
let cube = new THREE.Mesh(geometry, material);
cube.position.set(x, y, z)
this.scene.add(cube)
},
网友评论