跳至主要內容

DirectionalLightHelper

yisky小于 1 分钟组件文档组件助手方向光助手DirectionalLightHelper

DirectionalLightHelper——方向光助手,用于模拟方向光(DirectionalLight)的辅助渲染组件,其中包含表示光位置的平面和表示光方向的线段,如下图所示:

重要

  • 在添加 DirectionalLightHelper 组件前请务必确保实体已经添加 DirectionalLight 组件;
  • DirectionalLightHelper 组件由 @fantasy3d/addons 包提供。

创建

import { Vector3 } from 'three';
import { DirectionalLight } from '@fantasy3d/core';
import { DirectionalLightHelper } from '@fantasy3d/addons';

const { rootEntity } = scene;

// 在场根实体上添加方向光组件
const light = rootEntity.addComponent( DirectionalLight, {

    color: '#ffffff',                           // 方向光颜色
    intensity: 1.0 * Math.PI,                   // 方向光强度
    position: new Vector3( 20.0, 20.0, 20.0 ),  // 方向光位置
    target: new Vector3( 0.0, 0.0, 0.0 )        // 方向光目标点

} );

// 添加方向光助手
light.addComponent( DirectionaLightHelper );
上次编辑于: