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

368
Vistas
Why can't I declare a position in my multidimensional array?

I'm trying to do a 3d version of an L-Syste. But I cannot declare elements in my multidimensional array. When I debug, I see that the element stays the same. I call for example arraygrowth [0][1] = 100; But the Element at that position stays 0

let arraygrowth =[];
arraygrowth.push(new THREE.Vector3(0,0,0)); 
arraygrowth.push(new THREE.Vector3(0,0,0));
arraygrowth.push(new THREE.Vector3(0,0,0));

arraygrowth [0][1] = 100;
arraygrowth [1][1] = 100;
arraygrowth [2][1] = 100;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Cleaning up your code, you're essentially doing this:

let arraygrowth =[];
arraygrowth.push(new THREE.Vector3(0,0,0)); 
arraygrowth.push(new THREE.Vector3(0,0,0));
arraygrowth.push(new THREE.Vector3(0,0,0));

arraygrowth [0][1] = 100;
arraygrowth [1][1] = 100;
arraygrowth [2][1] = 100;

This is the equivalent of new THREE.Vector3(0, 0, 0)[1] = 100; ... which doesn't make sense. That this is not how you change the x, y, z parameters of a Vector3. When you call arraygrowth[0], you get a Vector3, and now you have to use one of its properties or methods to assign the value you want. For example:

arraygrowth[0].y = 100; // Sets y value
arraygrowth[0].setY(100); // Also sets y value
arraygrowth[0].setComponent(1) = 100; // Also sets y value

https://threejs.org/docs/#api/en/math/Vector3.setComponent

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