I’m learning about classes, objects, and arrays, and I decided to create a class called Box which will be instantiated in an array of the class called Game. I would like to change the position of each box of the array, but only the last object is being updated. Here you can check what I’ve done:
How can I change the position of each box?
Without trying the code, here is something to try in Box.js:
- make the
cube
inside the constructor, so that each instance of Box
has its own cube
- in this case, the reference to this cube should be
this.cube
, e.g.:
this.cube = new THREE.Mesh( this.geometry, this.material );
this.cube.position.x = 0;
...
and so on.
1 Like
Thank you alot!! It worked!!
1 Like