kovacsv / JSModeler

A JavaScript framework to create and visualize 3D models.
MIT License
655 stars 123 forks source link

GenerateSquareGrid usage #19

Closed shiruken1 closed 7 years ago

shiruken1 commented 8 years ago

Hello @kovacsv and thank you once again for providing this library.

I have the following code:

grid = new JSM.GenerateSquareGrid(50, 1, false);
var body = JSM.ConvertBodyToRenderBody(grid);
viewer.AddBody(body);

However instead of getting a grid, I get a square plane. Am I missing something? Thanks!

kovacsv commented 7 years ago

Hi!

The GenerateSquareGrid function (as its name says) always generates a square with size and segmentation parameters. You passed 1 as segmentation, so it generated one single square.

I think you are looking for the GenerateGrid function like in this example: http://jsfiddle.net/65gpb5o8/2/

Viktor

shiruken1 commented 7 years ago

Ooooh. Thanks for the fiddle. See, I was creating it with a single material (hence it looked like a big square plane). I was expecting it to produce a grid like the background of ThreeJS's editor

Is there a method I could use to create such a ground plane? Any suggestions? Thanks again for your time and help!

kovacsv commented 7 years ago

GenerateWireBody does the trick for you, although it is not the fastest way to generate grids. I would manually add lines to the body.

http://jsfiddle.net/65gpb5o8/4/

shiruken1 commented 7 years ago

That is so strange... that method isn't on my pull of bodyutils.js at all, and I did a merge just this morning. Weird...

In any case, thanks again!