Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda