Is it possible to create objects based on matrix array?

For example if I am trying to create walls at every 1 and nothing at 0, is it possible to make a nested loop that would do this? Or would it be overly complicated because of the grid system in threejs?
let wallArr = [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
];

This can be done in a similar way as in this examples.

BoxLabyrinthCreation3D

BufferLabyrinthCreation3D

LineGridDesign

See

See also

Addon to create special / extended geometries - #4 by hofk

GitHub - hofk/THREEg.js: three.js addon to create special or extended geometries. The addon generates indexed or non indexed BufferGeometries.

So that is just a library I can add in that will do it for me? I was wondering if there was a simple way of doing it without using another library

THREEg is a kind of library.

But the first three examples do not use a library!

You can look at the code and take things over according to your needs. :slightly_smiling_face:

But you can also look into THREEg and take over things.

Look for this post Circular control used for walkable areas control

The walls and some other things are created only from arrays. Is still in work.


This is what an example of a showroom created from data currently looks like.


Not sure what you are referring to but three.js does not have a “grid system”. Meaning you have to implement by yourself how your grid definition (represented as an array) is parsed into a grid expressed in world units.