I have created a rotating cube in ThreeJS that is made up of multiple particles. These particles belong to an array called 'particles' and are part of a group named 'group' which rotates around the origin on all axes (x, y, z). My goal is to dynamically connect two particles with a line. The current code I am using for this task is shown below:
var geometry2 = new THREE.Geometry();
linemat = new THREE.LineBasicMaterial({
color: 0xffffff
});
geometry2.vertices.push(particles[4].position);
geometry2.vertices.push(particles[1000].position);
geometry2.update;
line = new THREE.Line(geometry2, linemat);
scene.add(line);
This code snippet exists within my render loop. However, instead of linking the two particles with a line that updates as the cube rotates, it only draws a static line connecting where the particles used to be located. The line does not move along with the particles or update accordingly.
If anyone has any advice or solutions on how to achieve this dynamic particle connection, I would greatly appreciate it! Thank you