Particles.js - 修改帧更改 [英] Particles.js — modify on frame-change

查看:100
本文介绍了Particles.js - 修改帧更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全缺乏javascript直觉的道歉,但我想知道是否可以更改的属性动态 particles.js 对象:

Apologies for my complete lack of javascript intuition, but I was wondering if it is possible to change properties of a particles.js object dynamically:

我正在使用 jQuery 检测用户何时移动屏幕上的滑块(成功)。但是,我想知道如何将这些滑块值更改应用到我在后台的 particles.js 画布。

I'm using jQuery to detect when a user moves a slider on the screen (successfully). However, I was wondering how to apply these slider-value changes to the particles.js canvas I have in the background.

即移动滑块,粒子变大。

I.e. Move the slider across, and the particles get larger.

但是,我不知道如何更新 particles.js - 是否有人熟悉回调或动画循环功能,我可以将我的属性更改删除?

However, I'm not sure how to update the particles.js — is anyone familiar with a callback or animation loop function that I can drop my property changes into?

推荐答案

有关于此主题的公开问题
但您可以通过访问每个粒子的radius属性手动更改它:

There is an open issue on this subject. But you can change it manually by accessing the radius property of each particle:

pJS.particles.array.forEach(function(p) { 
    p.radius = p.radius * sliderValue; // change by a factor
    p.radius = sliderValue; // change to a single size
});

这篇关于Particles.js - 修改帧更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆