AlvinfromDiaspar
AlvinfromDiaspar

Reputation: 6814

THREE.js - How to have different colored particles?

I basically have a bunch of particles that were created by THREE.Points with a THREE.ParticleBasicMaterial.

Currently they all have the same color (based on the material).

Question: How can I get different colors particles?

Upvotes: 2

Views: 1293

Answers (1)

gaitat
gaitat

Reputation: 12632

If you are using THREE.Geometry() inside your THREE.Points() and If you only have a few number of colors you want to use you can create separate materials and separate your points based on which color you want to assign them. Example at: https://github.com/mrdoob/three.js/blob/master/examples/webgl_points_random.html

If you are using THREE.BufferGeometry() inside your THREE.Points() you can assign a different color to each of your points using only one THREE.ShaderMaterial(). Example at: https://github.com/mrdoob/three.js/blob/master/examples/webgl_interactive_points.html

Upvotes: 3

Related Questions