particleSystem = {
const geometry = new THREE.BufferGeometry();
const vertices = [];
const targetVertices = [];
const colors = [];
const sizes = [];
const t = [];
let color = new THREE.Color(0xffffff);
data2Parsed.forEach((el, idx) => {
vertices.push(0, 0, 0);
targetVertices.push(el.tX, el.tY, el.tZ);
color = color.setStyle(colorScale(el.type));
colors.push(color.r, color.g, color.b);
sizes.push( el.type==='Satellite'? 3 + Math.random(): 2+2*Math.random());
t.push(1.0);
});
geometry.addAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
geometry.addAttribute('targetPosition', new THREE.Float32BufferAttribute(targetVertices, 3));
geometry.addAttribute('color', new THREE.Float32BufferAttribute(colors, 3));
geometry.addAttribute('size', new THREE.Float32BufferAttribute(sizes, 1).setDynamic(true));
geometry.addAttribute('t', new THREE.Float32BufferAttribute(t, 1).setDynamic(true));
const material = new THREE.ShaderMaterial({
vertexShader: vertexShader,
fragmentShader: fragmentShader,
transparent: true,
blending: THREE.NormalBlending,
vertexColors: true
});
const particleSystem = new THREE.Points(geometry, material);
return particleSystem;
}