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

161
Views
Cómo extender una línea recta existente en Three.js

Tengo una línea existente iniciada

 // material const material = new THREE.LineBasicMaterial({ color: 0xffffff }); // array of vertices vertices.push(new THREE.Vector3(0, 0, 0)); vertices.push(new THREE.Vector3(0, 0, 5)); // const geometry = new THREE.BufferGeometry().setFromPoints(vertices); const line = new THREE.Line(geometry, material);

Y lo que quiero hacer es extender esta línea siguiendo su iniciación. He leído esta página sobre cómo actualizar cosas y no creo que se ajuste a esta situación porque en lugar de agregar vértices a mi forma, quiero moverlos. Por otra parte, es muy probable que haya entendido mal. Intenté eliminar la línea y luego volver a dibujarla por más tiempo, pero no puedo hacer que funcione sin que mi navegador se bloquee.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

BufferGeometry expone sus vértices a través de sus positionsBufferAttribute . Para cambiar las posiciones, debe hacer algo como lo siguiente:

 // // Assuming we want to move your line segment (0, 0, 0)-(0, 0, 5) by // one unit in the direction of positive x, to (1, 0, 0)-(1, 0, 5). // // Get a reference to the "position" buffer attribute const pos = geometry.getAttribute("position"); // Set the new positions pos.setXYZ(0, vertices[0].x + 1, vertices[0].y, vertices[0].z); pos.setXYZ(1, vertices[1].x + 1, vertices[1].y, vertices[1].z); // Update the vertex buffer in graphics memory pos.needsUpdate = true; // Update the bounds to support, eg, frustum culling geometry.computeBoundingBox(); geometry.computeBoundingSphere();

Existen otros métodos, como modificar la matriz de respaldo del atributo directamente y copiar en una nueva matriz, pero el proceso general será el mismo.

about 4 years ago · Juan Pablo Isaza 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!