Jump to content

How to build a CAD system


altreality
 Share

Recommended Posts

Hi,

 

I am trying to build a CAD system in Babylon.js that allows the detailed construction of large and complex objects. Objects like the space shuttle or the International Space Station. Since these objects have a lot of intricate parts that require accurate positioning I was thinking of an interface like blender.

 

The user can have a 3D view which can be used to switch to 2D as needed. There is the standard panel of objects to the right that can be placed along with their properties.

 

I was wondering about data structures that help manage such hierarchical collections of parts. Has anyone done large scale management of parts that could easily go into thousands. 

 

Also I was wondering how to manage their display. Would I need to use something like an Octree and cull objects according to the view frustum? Or can Babylon.js manage it.

 

Of course I am planning on starting out small by designing small buildings first along with all the plumbing, wiring etc. Then move on to larger systems.

 

Also is the performance of Babylon.js better if running as a standalone node webkit app?

 

Thanks.

Link to comment
Share on other sites

Hi AltReality... good to see you again!  Did you continue work on your vintage trains project?  I'd love to hear about it.

 

I have some comments on the CAD subject, but please keep in mind my newbie-ness.  Expect bad opinions and extreme wrongness in my response.  :)

 

 

I am trying to build a CAD system in Babylon.js that allows the detailed construction of large and complex objects.

 

I'd like to reword that line, and you can tell me if it has the same meaning afterwards.

 

You want to build a CAD-like modeler in Javascript, using webGL as the display layer, and using BJS as the interface tool... to the webGL display layer.

 

How's that sound?  The point being... webGL is your point of limitation and not BJS.  It is my guess that BJS exposes about 85% of the official webGL API, and you can certainly "go into the cellar" and talk directly to the webGL interface, from JS... whenever you wish.  That's exactly what the BabylonJS "engine" does.  It takes care of "basement/cellar duty" for us.  :)

 

Whip into https://github.com/BabylonJS/Babylon.js/blob/master/src/babylon.engine.js and search that page for "gl".  Lots of hits, huh?  The engine is the sweetest part of BabylonJS (imho).  These guys who wrote the engine... they are performance-enhancing junkies, so you will have to work REAL HARD to make a faster interface to webGL.  (opinion, but probably truth, too).  If you are motivated enough to take-on a CAD system in JS, then you may wish to write your own engine to talk directly from JS to webGL. 

 

 

Since these objects have a lot of intricate parts that require accurate positioning I was thinking of an interface like blender.

 

Why not use Blender?  How many years, how many team members... did it take to dev Blender?  Got resources?  Got team?  Got 10 years?  Got things in your CAD editor that Blender cannot do?  My advice here is to hack Blender and make a personal/special version of it for your project.  Blender even allows you to re-brand it as YOUR modeller... with certain minor stipulations.  Also, WebGL and JS  (and thus BJS) is as accurate as Blender.  It all depends on your camera views/zooms and your grid-snap accuracies and quantizings.  Zoom in close-enough, and make your snap grids precise-enough, and you will be working in microns... at molecular and sub-atomic granularity... if you really want to go there.  I'm quite sure that all of the BJS cameras have macro lenses for viewing the hairs on mosquito legs.   :)  Think about it.  Tiny, high-detail things... are just big fat things... scaled small.  WebGL is a scaling professional.  It will take good care of you, monstrous or microscopic.

 

 

I was wondering about data structures that help manage such hierarchical collections of parts

 

This is a JS issue and not a BJS issue, but, what the heck.  :)  I am THE WORST topic-derailer on the entire forum, so I have no right to whine about this.   hehe. 

 

BabylonJS only deals-with the "scene graph", as far as I know.  And, the scene graph is really a WebGL thing... and BJS interfaces with it... like honey-butter on a steaming country biscuit.  (the ones from the oven, not the ones found in the woodlands)  heh.

 

FindByTags (full matching), findByName, findByID... textures, mesh, lights, cams... Babylon has an EXCELLENT interface to the scene graph... via its Scene object.  But, just like any other part of BJS, use it or over-ride it.  You can certainly write your own Scene object and use that instead, along with the BJS engine object, but you must follow the rules of the API's between the two.

 

 

Would I need to use something like an Octree and cull objects according to the view frustum? Or can Babylon.js manage it.

yes, yes, yes, yes, yes, and... yes.  :)  You CAN use octrees with BJS, and you might "need" to use them.  Or not.  All options for octrees (and LOD)... are available and addressed in BJS, I believe.

 

 

Also is the performance of Babylon.js better if running as a standalone node webkit app?

 

NW.js (the new name for node-webkit) uses a core sub-section of the Chromium browser... which is the open-source version of Google's Chrome browser (commercial).  Re-worded, Google Chrome uses Chromium as its core.  So, with NW, you can expect BJS performance to match Google Chrome (loosely stated).

 

Ok, sorry for all the wrong things I've surely said here, but I hope I was able to say something useful, somewhere in my mess.  :)  Hopefully, others will follow with wiser opinions and will help clean-up the wrong things I've said.  :)

 

Feel free to PM to me about your trains project... if you don't want to mess-up this thread topic.  Or heck, just go find your old train forum topic, and give us an update on it, if you want.  (thx!)   Be well, party on!

Link to comment
Share on other sites

Hey Wingnut :) Good to see you too. Thanks for the detailed reply. 

 

As for the train project, it continues here: http://synth2014.github.io/Age-of-Steam/babylon/rk4.html

It looks funny right now. Took me quite a while for me to work out the movement using vectors in 3D. Today I am trying to attach the wheels to the chassis of the box shaped locomotive by parenting them. Will post about it soon if I have any issues with it. 

 

 

You want to build a CAD-like modeler in Javascript, using webGL as the display layer, and using BJS as the interface tool... to the webGL display layer.

 

 

Yep thats pretty much what I want to do. The reason I wanted to do it in BabylonJS is because i wanted it to be easy to share. Its very easy for people to just go to a website and start building like in minecraft.

 

I will probably have performance issues much later on with really large scenes but I guess careful LOD and Octree usage could take us far. I guess the ease of using BabylonJS is just too much, to jump into WebGL directly just yet. I'll give it a shot with BabylonJS that being the easiest option and see how far we get.

 

By the way CastorEngine seems to have a nice UI. Is there any english version of the UI that I can try out. I could probably reuse some of its code.

 

Its great to know that WebGL and JS  (and thus BJS) is very accurate. Seems with proper management of zoom levels and snapping points I can give a pretty nifty build tool to users.

 

Babylon has an EXCELLENT interface to the scene graph.

 

 

That's wonderful to know. I think there is also a test scene somewhere with thousands of objects. That should be more than enough for my needs.

Link to comment
Share on other sites

  • 1 year later...
On 9/24/2015 at 6:33 PM, altreality said:

Hey Wingnut :) Good to see you too. Thanks for the detailed reply. 

 

As for the train project, it continues here: http://synth2014.github.io/Age-of-Steam/babylon/rk4.html

It looks funny right now. Took me quite a while for me to work out the movement using vectors in 3D. Today I am trying to attach the wheels to the chassis of the box shaped locomotive by parenting them. Will post about it soon if I have any issues with it. 

 

 

 

Yep thats pretty much what I want to do. The reason I wanted to do it in BabylonJS is because i wanted it to be easy to share. Its very easy for people to just go to a website and start building like in minecraft.

 

I will probably have performance issues much later on with really large scenes but I guess careful LOD and Octree usage could take us far. I guess the ease of using BabylonJS is just too much, to jump into WebGL directly just yet. I'll give it a shot with BabylonJS that being the easiest option and see how far we get.

 

By the way CastorEngine seems to have a nice UI. Is there any english version of the UI that I can try out. I could probably reuse some of its code.

 

Its great to know that WebGL and JS  (and thus BJS) is very accurate. Seems with proper management of zoom levels and snapping points I can give a pretty nifty build tool to users.

 

 

That's wonderful to know. I think there is also a test scene somewhere with thousands of objects. That should be more than enough for my needs.

Hey @altreality , how is this project coming along? Are you still working on it? Because I am working on the exact same thing. However, I went with three.js instead of Babylon initially, simply because I'm dealing with JT files. I'm using JNetCAD to convert the JT files (http://www.johannes-raida.de/jnetcad.htm ) Initially, we were looking to work with Babylon and could convert JTs to obj but were unable to generate the associated .mtl files. So anyway, we have built a JT viewer as a widget for our webapp. We have restricted the user manipulation to rotate, scale, translate and selection of parts and show the associated data for that part in other widgets. The viewer works fine for smaller assemblies and light JSONs. But when trying to load anything like say a car with 1000s of parts (each with a JT to JSON converted file), the performance degrades a lot. We are using a modified z buffer along with bounding box, to get the outer most parts and few of the inner ones, but sadly its not good enough. We are looking for a dynamic solution something like Babylon's sceneOptimizer or LoD along with incremental loading. So my questions are,

1) What CAD formats are you dealing with?

2) Can you generate a mtl file

3) Are you using sceneOptimizer, LoD and/or incremental loading?

 

Link to comment
Share on other sites

Jack my script from: http://pryme8.github.io/TOWER/

Im not sure if I have the geometry kernel on that version yet, if you don't see anything about vertex manipulation and things let me know.  And Ill have to send you a different file.  but that one you will have to sign a non disclosure for.

I just looked at the version I have online yeah to get the stuff you want you will have to sign a non disclosure with me.   The example I just posted is widget management and no modeling yet.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...