美文网首页
vue-three 聚光灯及光源辅助线

vue-three 聚光灯及光源辅助线

作者: name_howe | 来源:发表于2023-04-16 14:17 被阅读0次
        // 聚光灯光源
        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)
        },
    

    相关文章

      网友评论

          本文标题:vue-three 聚光灯及光源辅助线

          本文链接:https://www.haomeiwen.com/subject/mhnqyltx.html