# VolumeSpotLight组件

使用VolumeSpotLight组件可以为实体添加灯锥效果,由 @tx3d/extension 包提供。

import { VolumeSpotLight } from '@tx3d/extension';

// 创建实体
const entity = engine.createEntity();

// 添加VolumeSpotLight组件
const volumeSpotLight = entity.addComponent( VolumeSpotLight, {

    position: [100.0, 140.0, 0.0],  // 位置
    target: [0.0, 0.0, 0.0],        // 目标点
    radiusTop: 1.0,                 // 顶部半径
    distance: 220.0,                // 衰减距离
    angle: Math.PI / 12.0,          // 光锥散射角度(单位:弧度)
    color: '#ff00ff',               // 颜色
    opacity: 0.8,                   // 透明度
    // openDepthClipping: false,    // 是否开始深度裁剪

} );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

提示

VolumeSpotLight组件初始化参数,详见VolumeSpotLightParameters

# 属性

🌏 opacity 光锥透明度

// 获取光锥透明度
const opacity = VolumeSpotLight.opacity;

// 设置光锥透明度
VolumeSpotLight.opacity = 1.0;
1
2
3
4
5

🌏 color 光锥颜色

// 获取光锥颜色
const color = VolumeSpotLight.color;

// 设置光锥颜色
VolumeSpotLight.color = '#ffffff';
1
2
3
4
5

🌏 openDepthClipping 是否开始深度裁剪

// 是否开始深度裁剪
const openDepthClipping = VolumeSpotLight.openDepthClipping;

// 是否开始深度裁剪
VolumeSpotLight.openDepthClipping = false;
1
2
3
4
5

🌏 target 目标(Local)

// 获取目标
const target = VolumeSpotLight.target;

// 设置目标
VolumeSpotLight.target = [ 10.0, 0.0, 0.0 ];
1
2
3
4
5
Last Updated: 7/24/2023, 3:50:31 PM