问题
I am trying to vary the opacity of particles as a function of their distance from a plane.
This issue describes my problem, and the answer a year ago was essentially \"you can\'t\". Opacity is apparently a parameter of a material, not an element, and hence individual particle opacity is not possible.
Has anything changed, is there any way I could achieve this? If individual particle colouring is possible, I imagine this isn\'t out of reach.
Cheers
回答1:
ParticleSystem
has been renamed to PointCloud
and then to Points
.
Yes, you can create a Point Cloud and vary the alpha value of each particle's color dynamically.
In three.js, you can do this by setting the Point Cloud's material to be a ShaderMaterial
having an attribute equal to the desired alpha value for each particle.
If ShaderMaterials
, vertex shaders and fragment shaders are new to you, here is a really simple Fiddle that implements a Point Cloud with dynamic alphas: http://jsfiddle.net/8mrH7/266/.
EDIT: Updated fiddle
three.js r.84
来源:https://stackoverflow.com/questions/12337660/three-js-adjusting-opacity-of-individual-particles