# WindGL
A WebGL-powered visualization of wind power using custom Mapbox Layers.
Capable of rendering up to 1 million wind particles at 60fps.
## Project Status
The author, @gampleman no longer works at @astrosat. As such, this project will no longer recieve maintenance from him.
Furthermore, this project is not production ready, as there are a [number of bugs](https://github.com/astrosat/windgl/issues).
If you wish to make use of this project, consider:
1. Getting in touch with @astrosat to discuss comercial support.
2. Getting in touch with @gampleman to discuss a consulting arrangement.
3. Forking this repository and fixing all issues. You are welcome to submit patches here, but please do not expect a speedy review.
As such, the project is currently a nice technical demo, but you should expect putting in significant resources if you wish to make a production implementation.
## Usage
```sh
npm install --save @astrosat/windgl
```
```javascript
import {Map} from 'mapboxgl';
import {sampleFill, particles, source, arrows} from '@astrosat/windgl';
// 1. Create a source
const windSource = source('http://url/to/backend');
const map = new Map(...);
map.addLayer(sampleFill({
id: 'windbackground', // required
source: windSource, // required
'sample-fill-opacity': 0.8 // optional
}));
map.addLayer(particles({
id: 'particles',
source: windSource, // best to share the same source between all layers
'particle-speed': ['interpolate', ['zoom'], 0, 0.5, 10, 0.8]
// you can use mapbox style expressions
}));
map.addLayer(arrows({
id: 'arrows',
source: windSource
}), "waterway-label"); // inserting the layer in the middle of the layer stack is supported
```
## Layers
This package offers several ways to visualize wind speed.
### Sample Fill
![Sample Fill](./docs/random/sampleFill.png)
This layer will use a color map to show the wind speed at each pixel (interpolated from the data set). You can customize it with the following properties:
#### `sample-fill-color`
A `color` value. You can interpolate based on zoom or using data-driven styling (`["get", "speed"]` will get the speed at the current pixel). The default value is a nice color scale:
```json
[
"interpolate",
["linear"],
["get", "speed"],
0.0,
"#3288bd",
10,
"#66c2a5",
20,
"#abdda4",
30,
"#e6f598",
40,
"#fee08b",
50,
"#fdae61",
60,
"#f46d43",
100.0,
"#d53e4f"
]
```
#### `sample-opacity`
A `number` between `0` and `1`. Indicates the global opacity of the layer. You can use zoom for styling.
### Particles
![Particles](./docs/random/particles.png)
A particle layer showing wind speed by animating particles based on the wind speed. You can customize it with the following properties:
#### `particle-color`
A `color` value. You can interpolate based on zoom or using data-driven styling (`["get", "speed"]` will get the speed at the current particle). The default value is `white`.
#### `particle-speed`
A positive `number`. Indicates how quickly the particles move (i.e. is a multiplier for the speed vector from the dataset). Can be interpolated based on zoom levels. Default is `0.75`.
You can adjust the properties by calling `setProperty(property, value)`.
### Arrows
![Arrows](./docs/random/arrows.png)
A vector field layer. You can customize it with the following properties:
#### `arrow-min-size`
A positive `number`. In general, this layer will attempt to draw an arrow at every grid point of the underlying data. However, sometimes that would result in really tiny arrows. So if the size of the arrow would be less than this limit, we will switch to interpolation and show a larger arrow aggregating multiple values. Default is 40px.
#### `arrow-color`
A `color` value. You can interpolate based on zoom or using data-driven styling (`["get", "speed"]` will get the speed at the current grid point). The default value is `white`.
#### `arrow-halo-color`
A `color` value. You can interpolate based on zoom. The color of an outline drawn around the arrow. Defaults to transparent.
## Data
This visualization is designed to visualize wind speed data based on a regular grid - such that is typically available from forecast models. This data is encoded in a texture in [plate carrée](https://en.wikipedia.org/wiki/Equirectangular_projection) projection where the R channel corresponds to x (or u), and the G channel corresponds to y (or v). However, these encodings are relative to the total observed range which must be encoded in an accompanying JSON file:
```json
{
"source": "http://nomads.ncep.noaa.gov",
"date": "2016-11-20T00:00Z",
"width": 360,
"height": 180,
"uMin": -21.32,
"uMax": 26.8,
"vMin": -21.57,
"vMax": 21.42,
"tiles": ["https://example.com/demo/wind/{z}/{x}/{y}.png"]
}
```
The format is designed for tiling, but this hasn't been implemented in the visualization yet.
You can use the provided tool to get the data. Simply go to the `data` directory, create a python virtualenv with dependencies using Pipenv and the provided pipfile. Then run `gfswind2png.py --help` for instructions.
## Acknowledgments
This code started as a fork of [mapbox/webgl-wind](https://github.com/mapbox/webgl-wind).
没有合适的资源?快使用搜索试试~ 我知道了~
作为Mapbox自定义图层的WebGL风粒子模拟___下载.zip
共59个文件
png:26个
js:15个
glsl:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 138 浏览量
2023-04-08
18:01:42
上传
评论
收藏 4.87MB ZIP 举报
温馨提示
作为Mapbox自定义图层的WebGL风粒子模拟___下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
作为Mapbox自定义图层的WebGL风粒子模拟___下载.zip (59个子文件)
windgl-master
babel.config.js 149B
.travis.yml 38B
demo.js 4KB
src
arrow.js 4KB
tileID.js 2KB
source.js 3KB
layer.js 7KB
shaders
sampleFill.glsl 2KB
transform.glsl 170B
mercatorToWGS84.glsl 692B
wgs84ToMercator.glsl 621B
particles.glsl 5KB
bilinearWind.glsl 651B
arrow.glsl 3KB
util.js 3KB
particles.js 13KB
index.js 196B
sampleFill.js 2KB
data
Pipfile 158B
Pipfile.lock 12KB
gfswind2png.py 6KB
LICENSE 763B
docs
wind
2019031012
0
0
0.png 86KB
tile.json 227B
1
0
0.png 68KB
1.png 65KB
1
0.png 73KB
1.png 67KB
2
0
3.png 40KB
0.png 46KB
1.png 51KB
2.png 46KB
1
3.png 45KB
0.png 49KB
1.png 53KB
2.png 54KB
2
3.png 41KB
0.png 46KB
1.png 67KB
2.png 55KB
3
3.png 43KB
0.png 46KB
1.png 58KB
2.png 57KB
random
sampleFill.png 1.27MB
particles.png 937KB
arrows.png 1.18MB
index.html 814B
index.js 1.11MB
package.json 2KB
rollup.config.js 4KB
package-lock.json 418KB
test
shaders.test.js 3KB
runShader.js 996B
particleTiling.test.js 5KB
__image_snapshots__
shaders-test-js-arrows-draws-a-longer-red-arrow-1-snap.png 337B
shaders-test-js-arrows-draws-a-nice-arrow-1-snap.png 315B
.gitignore 40B
README.md 5KB
共 59 条
- 1
资源评论
- wsnbb_20232023-10-16资源内容详细,总结地很全面,与描述的内容一致,对我启发很大,学习了。
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功