Drawing 3D mesh with giving 2D array

Hi, having this array for example lines = [[0,0], [0, 2]] in 2D and I want to convert to 3D while Y is fixed 5, is that possible to achive that?and it will be a rectangle in 3D , is that possible to achive that? how ?

1 Like

Usually in web 3d we deal with flat arrays… (and usually TypedArrays).
Nested 2d arrays take more electricity and memory management to throw around, and none of the 3d api’s really understand nested arrays, so IMO in general it’s good to adopt a mindset of using flat arrays and doing the math to index it in 2d.

so instead of array[ x ][ y ] doing array [ x + (y*rowSize) ].
This way, you can send your data into shaders or DataTextures or vertex arrays etc. easily/quickly.

Not sure if I understand your requirements correctly.

Is that what you mean?

From the Collection of examples from discourse.threejs.org




1 Like