Friday, July 25, 2014

vA3C Viewer R3 Update: Now with Save and Open

Three.js Examples - FGx Aircraft - vA3C Grasshopper
The glorious thing about a computer is that it enables you to process data, save that data, and then - later and elsewhere - open that data for re-processing. This saving and opening thing - being such a sacred holy grail of computing - is normally programmed by the very high-priests in the various cults of data-crunchers. Moving that array of pixels on your screen down to very tiny magnetic blips onto the platter that's spinning very fast and from there to a server-farm in, say, Brea, California and from there to an array of pixels on your friend's screen in Poznan, Poland is not self-evident. It's a job best left to people with PhDs, distinguished resumes and first class brain cells.

The vA3C Viewer app that's being worked on is for viewing data files. So saving is not really a thing that viewers need to do. Unfortunately, the ability to move things about and change materials started creeping into the viewer. So now there are different states: Do you want to see that pretty pony in blue? Or in pink?

AlgeSurf PE - Jurgen Meier Equations
Thus a way of registering those states for reuse would be nice. The previous release of the viewer has the ability to create permalinks - text added onto the end of a URL. In turn these were hand--massaged into text files that restores selected states.

The plan was and still is to automate that process for R3. The idea is to provide a 'save' button that would collect all the links to all the models in the display along with their position, rotation and scale and save these into a script file that you can load that recreates what you had on your display when you saved.

vA3C Revit - Three.js Examples

This is a simple and light weight method and very doable. It is not the same thing as going through every item of geometry, finding every face, vertex and the associated materials and shuffling these all into a tidy bundle on your hard disk. This latter activity is for the pros. The former is OK for script kiddies such as your vA3C Viewer team.

Well, upon the morning that had been appropriated to the permalink coding task, it was decided that reviewing Mr.doob's Three.js Editor would be a good thing.

The Editor does *not* have a save feature. It does, however, have a command that reads the data in memory and sends that data as text to a new window where you can review the data.

vA3C Grasshopper - Three.js Examples

And, then, it turns out the HTML5 has the new ability to enable you to save text that's in a window to a file on your hard disk.

Somehow these two thoughts became co-mingled. Code was copied, pasted and cobbled together. A 'Save' button was added to the vA3C Viewer.

FGx Aircraft - Three.js Examples - AlgeSurf PE Jurgen Meier Equations  
And then, the Save button was clicked.

The mental lollipops nearly fell on the floor.

It worked.

vA3C Viewer R3 is now enabled to take all the data that is in the display and write it out to a brand new JSON file. And these files, in turn can be used to create further JSON files.

Of course, it's not perfect. Files with shaders and other exotics don't work. Somethings come in and can be edited and others can't.  But many fun things do work.

The images on this page show assemblies of files from the FGx Aircraft libray, the Jaanga AlgeSurf parametric equations library, the Three.js Examples library and the vA3C JSON files prepared for the AEC Hackathon. It's an assembly of arbitrary colorful fantasies.

So, yes, the computer has the wonderful ability to process data and to save it and reuse it. Unfortunately this does not stop the peeps with loose wing nuts from producing hyper-whimsical images.

Viewer Live Demo
Read Me
Source Code