Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

76
Views
How can I get the particular point in a THREE.Points object to change his position?

I work on a personal project to try out equations to try to simulate the behavior of a galaxy. I have so far managed to place the Points as I wanted, but now I want to take each point individually to change its position. The goal for now is just to successfully try to apply a Random Vector to each of the points. I tried:

var direction = new THREE.Vector3(0.00003, 0.000005, 0);
points.position.add(direction);

but this applies to all Points. Then I tried something like that:

for (let i = 0; i < points.geometry.attributes.position.count; i++) {
    points.geometry.attributes.position[i] = Math.random() * 500
}
points.geometry.attributes.position.needsUpdate = true;

But nothing append :( I thing I missed something but I dind't know what

Here the full code on codepen: Codepen

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

When you access:

points.geometry.attributes.position[i]

you're not getting the array of the vertex positions. You're getting the BufferAttribute. What you probably want is the array inside the BufferAttribute:

points.geometry.attributes.position.array[i]

However, this is still not the recommended approach. Three.js recommends you use the .getAttribute() method:

// Get the attribute
const posAttribute = points.geometry.getAttribute("position");

// Get the array inside the attribute
const posArray = posAttribute.array;

// Increment by 3 at a time to access XYZ separately
for(let i3 = 0; i3 < posArray.length; i3 += 3) {
    posArray[i3 + 0] = xPosition;
    posArray[i3 + 1] = yPosition;
    posArray[i3 + 2] = zPosition;
}

// Tell the attribute it needs updatin
posAttribute.needsUpdate = true;
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!