JSAPI Three API Reference
    正在准备搜索索引...

    类 DynamicWeather

    动态天气系统,提供多种天气效果模拟,包括晴天、多云、雪、雨和雾等,并支持天气效果之间的平滑过渡。 会调整光照强度、云密度、雾密度以及各种视觉效果来模拟不同的天气状态。 需要基于 DynamicSky 使用。

    支持的天气类型包括:

    • clear: 晴天
    • partlyCloudy: 局部多云
    • cloudy: 多云
    • overcast: 阴天
    • foggy: 雾天
    • rainy: 雨天
    • snowy: 雪天
    // 创建动态天气系统
    const weather = engine.add(new mapvthree.DynamicWeather(sky));

    // 设置为下雪天气
    weather.weather = 'snowy';

    // 设置天气过渡时间(毫秒)
    weather.transitionDuration = 2000;

    层级

    • unknown
      • DynamicWeather
    索引

    构造函数

    • 创建一个动态天气实例

      参数

      • sky: DynamicSky

        关联的动态天空实例

      返回 DynamicWeather

    属性

    transitionDuration: number = 1000

    天气变化过渡的持续时间(毫秒)

    // 设置天气过渡时间为2秒
    weather.transitionDuration = 2000;

    方法

    • 添加天气变化监听器

      参数

      • listener: Function

        监听器函数

      返回 void

      // 添加天气变化监听
      weather.addWeatherChangedListener((weatherType) => {
      console.log('天气变为:', weatherType);
      });
    • 移除天气变化监听器

      参数

      • listener: Function

        监听器函数

      返回 void

    访问器

    • get weather(): string

      获取当前天气类型

      返回 string

      // 获取当前天气
      const currentWeather = weather.weather;
    • set weather(weather: string): void

      设置天气类型

      参数

      • weather: string

      返回 void

      // 设置为晴天
      weather.weather = 'clear';

      // 设置为雨天
      weather.weather = 'rainy';