Connect a "for loop" to a box mesh

Hello Hello!

Here is another PG I made and this is the one I want to use as the base for my project:

https://www.babylonjs-playground.com/#KSQ7M0

Issue is connecting a for loop to my box mesh row. I created a separate JS file to hold the loop:
swar.js
for(i=0;i<5;i++){
console.log(“box” + i);
};

Did I need to make a separate file or could Ive had added this to my index file? Where would it go so that when I save I dont end up with a blank screen when loaded?

Also as far as texture I wonder do I have “var mat” the right place? I want to have logo on front of boxes while displaying different image on back of box…no need for top or bottom image or sides.(I would like to shrink the width so the box will be thinner.

My apologies for asking too much :blush:

:heart: :heart:,
Mekaboo

You can use the for loop to clone the boxes as well and refer to them later by name.

It’s is not that you are asking too much it is that you are asking about the wrong things. The help it seems you really need is with coding in general whilst this site is about helping with Babylon.js.

I will ask a contributor, who likes to encourage beginners, if they might help you.

1 Like

HI @Mekaboo,

I don’t think you need to create separate file just for the for loop. You can probably just include it in the index file. I am not sure what you are trying to do with the for loop and your boxes. Can you explain what your end goal is? Do you want to make series of 5 boxes?

1 Like

I would greatly appreciate that :relaxed:

Hello :smiley:I wanted to make 5 rows of the boxes…thats all

Sirs @JohnK and @belfortk this is what I was looking for:

https://www.babylonjs-playground.com/#HB4C01#7

Rows of boxes/squares…it also displays the for loop I was asking about…will use this :slightly_smiling_face:

Happy you have found what you are looking for.

2 Likes