ladybug-tools / spider

:spider_web: 3D interactive analysis in your browser mostly written around the Three.js JavaScript library
http://www.ladybug.tools/spider
44 stars 15 forks source link

write rad to json parser #119

Closed mostaphaRoudsari closed 6 years ago

mostaphaRoudsari commented 6 years ago

@theo-armour,

I tested the viewer with a number of files and it fails to parse the files correctly in most of the cases. I think if I can write the parser and give you a ready to visualize json object you can concentrate on the visualizer which in many cases will be similar to the gbXML viewer.

I will put it together in python first and then we can convert it to JS. Haven't written code in JS for quite some time! Here is the schema that I'm thinking about.

{
  "geometry":[
      {"type": "polygon", "name": str, "vertices": [{"x": float, "y": float, "z": float}, ...]}, ... // we can add other geometry types later
   ],
   "modifier": [
        {"name": str, "type": str (glass/plastic/...), "values": str // full definition for visualization}, ...
    ]
}
theo-armour commented 6 years ago

@mostaphaRoudsari

I think the reason the current viewer is incomplete is because I have only four test files to work with.

See: https://github.com/ladybug-tools/spider/tree/master/radiance-sample-files

Also, I do not yet know how to identify failures.

For example: is there anything wrong with the geometry here:

image

In any case, links to more sample files would be of great benefit!

sariths commented 6 years ago

@mostaphaRoudsari All the sample files from my tutorial are on github. And I should have a few more, include the one of that TajMahal model (if want to go crazy ;) !

Let me know if those would be helpful and I can clean them and share it here.

theo-armour commented 6 years ago

@sariths

I had a quick run through your repos and found this one with .RAD files:

https://github.com/sariths/radTutorialFiles

Thank you for making this tutorial available.

Please do make more files available for testing.

theo-armour commented 6 years ago

@sariths @mostaphaRoudsari

image

Progress is being made. With Sariths' files I see that rad files may be embedded in other files. I added a bit of recursion and we are reading embedded files.

There are still issues with locating the files locally using the file dialog box, For now I am just copying the html file into the same folder as the master rad file.

More tomorrow. This update is just to indicate that progress is being made. And more sample files will be much appreciated.

mostaphaRoudsari commented 6 years ago

@theo-armour, both cases are loaded correctly. If it is possible to upload multiple files at the same time user can upload them together instead of you searching the directories. @sariths, your sample files are going to be very helpful. I cannot share the ones that I used for testing since I don't own them! :| All the other models that I have are too simple.

theo-armour commented 6 years ago

See also #118 update with kink to Rad viewer r6

I have found a good amount of RAD files here:

http://radsite.lbl.gov/radiance/pub/objects/

I'm think of extracting all the files and putting them in a repo at Ladybug Tools. This would give easy online access to all the files from anywhere. Anybody have any thoughts on this?

sariths commented 6 years ago

@theo-armour , @mostaphaRoudsari

Santa brings presents ... https://github.com/rndmStff/radModels

I had been meaning to put some of these on a repo for a while. The instructions on the main page apply for all models.

The data structure for most (if not all) radiance materials and geometry follow the format described on page 4 of file-formats. Some of my models contain textures and lights, both of which you can ignore. The list of surfaces can be found here: http://radsite.lbl.gov/radiance/refer/ray.html#Surfaces . It would useful to color the surfaces according to their modifier materials . For commonly used modifiers, the colors are rgb triplets specified at the beginning of the numerical array.

Finally, assuming that 3.js also follows some sort of global coordinate system like Radiance, it might be really useful to read-from and write-to view definitions like the ones provided in the view sub-directory for each project (example).

Please let me know if you would like any further details.

2018-05-14 12_08_21-c__users_sarith_appdata_local_temp_tmpvobxyprad_scene oct 2018-05-14 11_54_50-c__users_sarith_appdata_local_temp_tmplpr08frad_scene oct 2018-05-14 11_46_26-c__users_sarith_appdata_local_temp_tmpnizaecrad_scene oct 2018-05-14 12_58_58-c__users_sarith_appdata_local_temp_tmpkm8zxprad_scene oct 2018-05-14 12_53_29-c__users_sarith_appdata_local_temp_tmpkm8zxprad_scene oct 2018-05-14 12_39_06-c__users_sarith_appdata_local_temp_tmpn4bqrvrad_scene oct 2018-05-14 12_34_54-c__users_sarith_appdata_local_temp_tmpn4bqrvrad_scene oct 2018-05-14 12_33_53-c__users_sarith_appdata_local_temp_tmpn4bqrvrad_scene oct 2018-05-14 12_22_16-c__users_sarith_appdata_local_temp_tmpkz6zdzrad_scene oct 2018-05-14 12_18_37-c__users_sarith_appdata_local_temp_tmpfn_balrad_scene oct 2018-05-14 12_10_11-c__users_sarith_appdata_local_temp_tmpvobxyprad_scene oct

theo-armour commented 6 years ago

@sariths @mostaphaRoudsari

Wow! Awesome gift. Thank you very much for sharing these great efforts.

Now let's see how much I can downgrade them. ;-)

rad viewer 7

See also #118

jugs1 jugs

house01 house01

house-with-pool house with pool

island-house island house

manhattan2 manhattan

Taj Mahal: running out of memory and or not handling xforms well yet

All of these files - being exports of CAD programs - have very high face counts, so performance id not great, but it's a start. And I very much appreciate all these sample files.

And, I look forward to being able to handle examples exported by Honeybee.

sariths commented 6 years ago

@theo-armour This is awesome (I am really awed)!

There are have been a few Radiance object viewers in the past, but none of them are web-based or particularly stable. Even the ones which are desktop-based are not really cross-platform. The ones that I am aware of are Glrad, Rshow and Objview . I have never been able to get Glrad to work and haven't tried tinkering with Rshow. Objview is actually a perl (earlier csh) script that is a pain to run on Windows. I wrote a Python version of objview and it is what I use for my own work. However, the issue with all these viewers is that they focus on rendering Radiance scenes as-is and that is extremely time-consuming. A lot of times one is only interested in knowing if the import from CAD to Radiance was successful or not. Or, in some cases, assigning views for rendering scenes (or annual climate-based simulations). So, a stable version of rad viewer would be really useful for the community as a whole.

PS: Things move at a (0.00001 x snails-pace) in the Radiance world. So, it will be a while before the community wakes up to the possibilities of such a tool.)

PS2: I agree that the face-count is high and not optimized. I dont know much (any) CAD and most of these files are from when I was trying to learn Radiance.

theo-armour commented 6 years ago

@sariths @mostaphaRoudsari

Have a look at #118. We have colors

image

So, a stable version of rad viewer would be really useful for the community as a whole.

The code needs another release or to two be cleaned up, but after that - or any time actually - I can take feature requests.

I agree that the face-count is high and not optimized.

Going from a Sketchup export format and then to Radiance is definitely going to generate a ton of faces. But I don't think that will be the usual workflow. The files supplied by Mostapha and Michal are reasonable in size and load fast. So I don't expect many problems with this sort of workflow.

Let's make Radiance fun again. ;-)