Hi, I want to display a point cloud in webgl. I thought I could use the particle system, but I need to load the particles positions in and then have the particle system paused.
Here’s my attemp so far but I can’t see any of the particles.
Can I manually create particles like this ? Is thee a proper way to create particles from a file?
You could also create some interesting effects if you could start your particle system in a preloaded format.
public class ParticlePoints : MonoBehaviour
{
ParticleSystem m_System;
ParticleSystem.Particle[] m_Particles;
Vector3[] points;
// Start is called before the first frame update
void Start()
{
if (m_System == null)
{
m_System = GetComponent<ParticleSystem>();
}
PointCloudData data = new PointCloudData();
data.Vertices = new[] { new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f),
new Vector3(10f, 2f, 1f), new Vector3(1f, 1f, 2f),
new Vector3(1f, 2f, 1f), new Vector3(1f, 1f, 2f),
new Vector3(20f, 2f, 1f), new Vector3(2f, 1f, 2f)};
points = data.Vertices;
CreatePoints();
}
public void CreatePoints(/*Vector3[] points*/)
{
//m_Particles = new ParticleSystem.Particle[m_System.main.maxParticles];
m_Particles = new ParticleSystem.Particle[points.Length];
for (int i = 0; i < points.Length; i++)
{
m_Particles[i].position = points[i];
}
m_System.SetParticles(m_Particles, points.Length);
//m_System.Play();
m_System.Pause();
}
}