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

366
Views
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 answers
Answer question

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