noisejs学习

这是一个2D和3D Perlin噪声和简单噪声的Javascript插件。
库相当快(10M查询/秒)。但它仍然比使用着色器慢得多。例如,如果您尝试更新整个屏幕的像素值,它将是缓慢的。

怎么使用

noise.seed(Math.random());

for (var x = 0; x < canvas.width; x++) {
  for (var y = 0; y < canvas.height; y++) {

    // noise.simplex2 and noise.perlin2 for 2d noise
    var value = noise.simplex2(x / 100, y / 100);
    // ... or noise.simplex3 and noise.perlin3:
    var value = noise.simplex3(x / 100, y / 100, time);

    image[x][y].r = Math.abs(value) * 256; 
  }
}

该库提供了一个名为“噪声”的对象,具有以下属性:

  • simplex2(x, y): 2D Simplex noise function
  • simplex3(x, y, z): 3D Simplex noise function
  • perlin2(x, y): 2D Perlin noise function
  • perlin3(x, y, z): 3D Perlin noise function
  • seed(val): Seed the noise functions. Only 65536 different seeds are
    supported. Use a float between 0 and 1 or an integer from 1 to 65536.

Github地址:https://github.com/josephg/noisejs

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值