3D solid file layers to three.js json - html

First of all: I'm a skilled developer and a total noob of 3D solid files/drawing.
I started playing with webgl and three.js. My task is to port a solid 3D file(i.e. STEP/IGES) to a web page(a sort of a cad viewer).
I started from this example:
http://www.johannes-raida.de/jnetcad/RadialEngine.htm
I want to obtain something like the above link with
a navigation tree and hide/show layers functionality.
The above link has sever json file, one for layer.
I want to obtain: a threejs-json file for each layer to get the hide/show functionality.
Now, I have a solid file (STEP format: .STP). That file contains layers. I want to obtain a json(three.js) file for each layer.
Questions are:
how to export to threejs-json using free software? I read that the best method could be: STEP > Wavefront OBJ [using freecad?] > treejs-json [using blender?]
Does the collada format is better than obj?
Shoud I have to manually export each single layer to json?
Is there an utility out there to generate all the layers(separated files)(json-threejs format) from a 3d file?

So, I did it by myself.
Three.js is a great library but it requires some 3d skills.
Here are my answers:
how to export to threejs-json using free software?
Well, my suggestion is to convert your solid file to DAE, use anything you want.
Then open DAE with Blender and use the exporter script of three.js:
https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender
Shoud I have to manually export each single layer to json?
No, the 3D file has all the informations about layers. So you can use a single file.
Is there an utility out there to generate all the layers?
I don't have found somethig good out there.
If you want to create single layers, you can split the json file created with blender.

Related

Update 3D Scene Programmatically to be Showed in Blend4Web WebPlayer (JSON)

I created a blender project, exported it as JSON+BIN files and showed it through the blend4web webplayer. Everything goes fine until my need to change the JSON file programmatically to add/remove a new 3D object (e.g. a cube or rectangle). I want to renderize the already showed 3D model adding or removing a 3D object. However, since the exportation of a project to blend4web generate a .bin file, if I change only the .json the model was not showed as expected. Considering this scenario, the unique way to change the model is modifing the .blend file and exports it again from Blender. But based on my need, I can't add a new 3D object in a Blender project programmatically considering the .json file. Additionally, the .json file which I am updating/using is considering data retrieved from a Database, such data indicates how and the position where the new 3D object will be displayed in the scene, which hinder me to use Blender to create a 3D Model modificated.
In this perspective, I need help to identify:
Which is the best way to change the scene and show it in blend4web programmatically and mainly considering a .json as an input for the model?
Is there any python script to user a blend4web .json file as an input to be compiled, without the Blender project and regenerate the .bin file, making it possible to show correctly my 3D model using the blend4web webplayer for JSON files?
Or, is there some (easy) way to modify a project from Blender considering data in JSON format, compile and generate the files to be shown programmatically by the blend4web webplayer (for JSON)?
Thanks in advance.

How can I export a .dwg file from the Forge Viewer that also includes MarkupsCore markups?

I'm working on a javascript application that uses the MarkupsCore extension to create markups on a floor plan in the Autodesk Forge Viewer. I want to export a .dwg file from the viewer, but I also want the file to contain those markups. I basically know how to export the .dwg file, but I don't know how to combine the svg markups with the file before exporting. Is this even possible? If so, how?
The markups as stored/saved as SVG files, which is a XML-based format to describe geometry. And I believe you know that :-) I did a quick search and found a few articles about SVG to DXF conversion, where DXF can be imported and converted into DWG via AutoCAD engine (or Design Automation API).
So a route would be: show DWG model, add markups, save as SVG, convert to DXF, convert again to DWG, merge into original DWG. I don't have such a sample nor can guarantee it will work and be accurate, sorry.

Easy tool for drawing graphs and export as xml, json?

Do you know a tool/application that allows me to draw a directed graph (with drag and drop would be ideally) and than easily export it into an XML or JSON file?
I tried using http://cmap.ihmc.us/ but it exports the picture into an XML not the graph's content, which it makes it horrible to parse.
The main goal is to draw a graph and then somehow construct it in memory (in C++/Java).
Gephi is a good free tool to create and export graphs:
https://gephi.org/
User made addons are available and allow you to export in multiple formats :
https://marketplace.gephi.org/plugin/json-exporter/

Blender export to three.js JSON only processing one geometry object

I'm pretty new to three.js so bear with me!
I'm a seasoned user of Blender and have looking for the best way to export to a three.js importer.
So far, the most successful has been the obj importer, although I would love to include animations. With this in mind, I have tried the Collada dae importer (a bit hit and miss) and am now on the JSON route.
I have successfully (I hope) added the JSON export addon into Blender (2.74) which does now export JSON files. These work OK when imported into three.js, but for some reason, it is only exporting one object when I have several in the scene. I have also checked the JSON file and there is only one set of vertices.
I have read on older posts that it has something to do with parenting, but I can't export the scene as it breaks when imported for some reason.
The reason I want multiple objects is because I want to animate various objects within a scene using keyframes. Sounds easy? Not so much.
Are there any specific limitations of bone-based (on armatures) animations. I have a feeling it may have something to do with the object parenting to the bones?
My error could be in the JSON importer in the three.js file...
The documentation on this is a bit limited so any advice would be welcome.

Three.js (r64) - Blender JSON export miss normals for smooth shading

Using Three.js r64 I'd like to import from Blender an animated object with its smoothing groups, the file is exported as JSON through Three.js Blender exporter.
The animation part is working fine.
In Blender, the model looks fine (there is a small smoothing group around the central part).
Picture: http://www.defresne.fr/demo/so/three/smooth_shading/gears.png
I can achive to get the same result when exporting in OBJ with 'Smooth Groups' and 'Include Normals' options checked. However I can't get it working correctly while exporting a JSON file (with normals). Next are pictures of the scene, with a live demo.
Picture: (append next link with) three_gears.png
Live demo: http://www.defresne.fr/demo/so/three/smooth_shading/
I did intense lookup all over the web and couldn't find correct informations. Best is another question on SO which is a bit old (r55) and never got any accepted answer.
I did try to compute the object's normals with
geometry.computeFaceNormals();
geometry.computeVertexNormals();
but, obviously, it computes the whole object normals and result in a completly smoothed object.
So, what should be a correct approach to make JSON smoothing groups work in three.js ? Wait for a built-in function ? build it myself ? Modify the exporter ?
As three.js seems to load correctly OBJ and Collada models with smoothing groups, maybe I could borrow some of the code in these loaders to get the logic ?
Thanks for your help
[EDIT]
I just found something great !
In Blender, produce 2 exports of the model: first a JSON file, second an OBJ file. Load the second one with three.js online editor then convert it to get the geometry JSON...
I can collect the vertices, normals and faces of this freshly exported geometry and copy it to the first exported file.
It works fine ! I got nice shading groups. Even skinning works fine.
But it's a tedious way of processing and I wish I could save myself some extra conversions.
So does that mean there is a problem while exporting geometry from Blender ? Any idea why ?
Any help would be greatly appreciated !
Ok, I finally found what happens.
The r64 Three.js Blender exporter doesn't export smoothing groups so if you need to preserve these, there is no other solution than export the geometry to an OBJ file, then convert it with the python script 'convert_obj_three.py' avaible within Three.js repository. Converted file will have correct normals. (don't forget to check normal option while exporting the OBJ file)