SpotLightHelper
小于 1 分钟组件文档组件助手聚光灯助手SpotLightHelper
SpotLightHelper——聚光灯助手,用于模拟聚光灯(SpotLight)的辅助渲染组件,如下图所示:

重要
- 在添加 SpotLightHelper 组件请务必确保实体已经添加 SpotLight 组件;
- SpotLightHelper 组件由 @fantasy3d/addons 包提供。
创建
import { Vector3 } from 'three';
import { SpotLight } from '@fantasy3d/core';
import { SpotLightHelper } from '@fantasy3d/addons';
const { rootEntity } = scene;
// 在场景根实体上添加聚光灯组件
const light = rootEntity.addComponent( SpotLight, {
color: '#ffffff', // 聚光灯颜色
intensity: 600.0 * Math.PI, // 聚光灯强度
distance: 100.0, // 聚光灯照射距离
position: new Vector3( 0.0, 20.0, 0.0 ), // 聚光灯位置
target: new Vector3( 0.0, 0.0, 0.0 ) // 聚光灯目标点
} );
// 添加聚光灯助手
light.addComponent( SpotLightHelper );