Array of

Greetings all, is it possible to make an array of THREE.Group()?

Let tGroup = [];
for(let i =0; i < 40; i++){
tGroup[i] = new THREE.Group();
Let cluster[i] = new Cluster(); //call to a class

Is this possible?

Hmmm, yes :thinking: ? I mean - technically you shared an answer right after the question - except maybe for a tiny syntax error at let cluster[i] = ... :sweat_smile:

tGroup[i] = new THREE.Group();

let cluster = new Cluster(); // <- no need to add an index in this line

You can make array of anything in javascript - numbers, functions, Three.js objects etc.

thank you for your response. I was hoping it was that simple. But, In either case, this is the error I’ve been getting, “THREE.Object3D.add: object not an instance of THREE.Object3D”.
I tried commenting out the most of the class it calls(enough to keep it in existence) to make sure the error didn’t derive from it, but no change.
So this is the part where I explain what I’m coding. I had to recode my website which I’d written in Flash Action Script years ago. It works like this. It first loads a .csv file which is a list of images and there location. This allow me to update/change images without changing the code. Once the file is loaded and parsed, the images are loaded in a texture. the aspect ratio of each image is checked to setup the PlaneGeometry size. the planes are assembled to form a 3D carousel, which is initilized as a THREE.Group(). this allows me to position the carousel group where I want. The images now textures are thumbnails. this I’ve done and with success with one carousel. Now I’m trying the same thing, but with many carousels/groups. I’m using Group, because I couldn’t seem to position the object created in the class without it. So the carousel/group is the center point which the thumbnails rotate around.
Oh yeah, I am new to THREE JS. It is excellent.

Ok, Here is where I messed up. I should have been adding each thumbnail created to the carousel group, not the carousel object created in the class. my bad.
again, thanks for your input. I’m sure I’ll have more question before this project is through

So, I could not get THREE.Group to work an array. At least not an array as we know them.
This is what I had to do to get a THREE.Group to work as a sudo array:
Let t = ‘tGroup’;
For(let I = 0; I < 40; i+"){
Window[ t + I] = new THREE.Group();
Window[t + i].add(cluster[i]);

And so on…