Particles.js — modify on frame-change

我是研究僧i 提交于 2019-12-10 12:09:56

问题


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:

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.

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?


回答1:


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
});


来源:https://stackoverflow.com/questions/28738469/particles-js-modify-on-frame-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!