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

71
Views
¿Cómo puedo hacer que el punto particular en un objeto THREE.Points cambie su posición?

Trabajo en un proyecto personal para probar ecuaciones para tratar de simular el comportamiento de una galaxia. Hasta ahora he logrado colocar los Puntos como quería, pero ahora quiero tomar cada punto individualmente para cambiar su posición. El objetivo por ahora es tratar de aplicar con éxito un vector aleatorio a cada uno de los puntos. Lo intenté:

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

pero esto se aplica a todos los Puntos. Entonces probé algo así:

 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;

Pero nada adjunto :( Creo que me perdí algo pero no sabía qué

Aquí el código completo en codepen: Codepen

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Cuando accedes:

points.geometry.attributes.position[i]

no obtienes la matriz de las posiciones de los vértices. Obtienes el BufferAttribute . Lo que probablemente quieras es la matriz dentro de BufferAttribute:

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

Sin embargo, este todavía no es el enfoque recomendado. Three.js recomienda usar el método .getAttribute() :

 // 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!