Hello everyone I am new around here, so please be patient if I asked stupid questions.
I work with Mathematica and in specific coding 3D human anatomical structures, which while Mathematica has 3D support for these I am not happy with the browser and mobile phone rendering capabilities and as a result dabbling into ThreeJS and Clara:
This is a bifurcated vein system, export JSON from Mathematica manually loaded into Clara
Trabecula carnea of right ventricle
Here is a list of probably very simple questions
Export JSON from Mathematica but need a ftp command of some kind to run from within the Mathematica code , do not like to make a Java or PHP external code perhaps later on for super large uploads. I can call ftp from inside Mathematica. So I could create the JSON file for the anatomical structure and then like to call ftp to upload to Clara.io
I could easily create deformations of the 3D structures and store frames in JSON, would like then to do the same upload as #1.
I like to know some high level description of the JSON file which stores the frames for #2 .
How to specify color and opacity for the JSON frames, for example multiple anatomical structures, each with different color and opacity
Thanx everyone, hope to have a lot of fun here
Kilkenny Ireland, Toronto
I haven’t used Mathematica for quite a while, but it probably has a few different ways of exporting in 3D - OBJ or Collada (DAE) formats may be better than JSON.
I know that Clara.io has an API, maybe you can connect Mathematica up to that. You might be better asking on their forums though.
Are your models animated in Mathematica? If so, again, there might be better export paths than JSON (note that OBJ doesn’t support animation though).
Same goes here, although JSON does tend to be the easiest format to read. How are you exporting JSON from Mathematica?
If you use a different export format, I would assume that things like colour and opacity should be exported too.
EDIT: The Mathematica doc pages are really slow for me now, but there’s a list of supported 3d formats here - of these I think only the OBJ and Collada loaders are well maintained in three.js. The VRML loader may be worth checking out too.
Thank you for quick response.
I do not know what is Clara’s API, if I have the FTP address that allows me to upload models then I will be all set. All I found was some Java code or manual upload button.
All my materials are computed in Mathematica, I can export JSON and .PLY and .OBJ. No idea what format is “paths”.
Details of the Clara.io API for importing are here: https://clara.io/learn/sdk/api/import
There’s no FTP address, it’s all done over HTTP, but you can upload files over HTTP too using the POST method.
Sorry, by “export paths”, I meant “ways of exporting”, i.e. different formats.
Can you share one of you JSON files?
Ah, it’s completely raw JSON data.
There’s a three.js JSON format, I thought you might have been using that.
It’s not very well documented, but you can find some examples here. You could probably write an exporter for Mathematica that would suit your purposes pretty easily.
However, I would recommend trying to export in .OBJ or .PLY format first.
You can see examples of how to load these here:
Note that neither of these formats supports animation though, you would need to export in DAE format for that, which should be possible from Mathematica.
Here’s a DAE example with animation:
And here’s the mathematica page on DAE format:
I just checked DAE format is supported in Mathematica.
I will focus coming days to get an animation loaded into Clara using Mathematica generated 3D frames.
I have 64 cpu core server, each with a standalone license of Mathematica, so I could build large animated sequences, in particular the ones that require computational geometry algorithms e.g. vein generation which creates smoothly joined tube-like structures.
Here is the workflow for how I have to create scenes and animations in Clara, note that we do not want to do anything manually all has to be from the server code:
Mathematica running on 64 linux cpu cores, each core computes a frame for the animation
All frames are sequences and placed in DAE file in Mathematica.
Create New Scene in Clara??? is this necessary need to do that from Mathematica
Copy DAE file into the Scene??? am I understanding this correctly need to do that from Mathematica
Where and how server places the actual Java code in Clara?
How the server gets the URL for the animation from Clara?
No luck opening DAE files generated from Mathematica
This is not good, since Mathematica file conversions are superb and never had issues. Calar is also the standard for reading DAE files, so I am stuck.
All Clara issues is INTERNAL ERROR + Empty Scene
I’m getting a “Cannot read property ‘childNodes’ of undefined” error when loading with three.js.
@Mugen87 are these valid Collada files?
There are no childNodes attribute specified in Mathematica.
These files were created in Mathematica using Export call with DAE format.
I also tried nothing in that file(.dae)
I can write to Wolfram Techsupport and file a ticket.
Meanwhile I uploaded OBJ files into Calara and all worked, for animations I was told to use DAE format.
Is there another format for animations while calling techsupport?
dae files seem to be corrupt. I’m unable to import them in Blender. The preview of Finder on Mac also shows no result.
@dara you can also test files with the three.js editor - just drag and drop them onto the scene. Also, Windows and Mac now ship with 3D viewers so you can test with those too, or use Blender on Linux.
At this point, you will probably need to go through the various 3D export formats available in Mathematica, see if you can get the models to work the way you want in any viewer.
However, I still think that Collada is likely your best bet here, if you can get Mathematica to export correctly. If you are contacting support, ask them is the Mathematica collada exporter support animation too.
Once you get past that step, you can figure out how to set up an online viewer.
@looeeeb Thanx I already worked most of what is needed. Could easily upload .OBJ files and it is already working for Boundary shells and filled solids, opaque and translucent.
The problem is which format to use for sequence of 3D models to make an animation, which you had proposed to use DAE. DAE is the issue not the rest.
I think I will stick to Three.js and Clara.
Again DAE is the only left item.
Thank you everyone
I cannot do any of the listed operations manually on the front end editors. All has to be accomplished thru some code in some server.
The 3D structures we work with e.g. Anatomical are nearly impossible to handle manually since there is a huge number of them, and huge amount of annotation and dissections, beyond any amounts of man hours.
I made a simple triangle and exported it to DAE from Mathematica, this is the xml within the file
Created with the Wolfram Language : www.wolfram.com
0.05 0.05 0.05 1
0.6 0.6 0.6 1
0.6 0.6 0.6 1
0 0 3 2 0 0 0 -1 1
0 1 2
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1