Author Topic: Online 3D file viewing?  (Read 11099 times)

Offline jarvist

  • obsessive maniac
  • ***
  • Posts: 424
  • Imperial College CC / Northern Pennine Club
    • Imperial College Caving Club
Online 3D file viewing?
« on: January 31, 2011, 05:25:43 pm »
Is there any modern solution for displaying a .3d file on the web?

One of our old members wrote a Java program to do it back in 2002:
http://www.union.ic.ac.uk/rcc/caving/caverot/applet.php

It still works, but feels a little dated, preparing the data is rather clunky + all the cool kids use flash these days. Is there anything similar / better out there?

Offline graham

  • Retired
  • forum hero
  • *****
  • Posts: 10943
  • UBSS, Speleo-Club de Perigueux, GSG, SUI
    • UBSS
Re: Online 3D file viewing?
« Reply #1 on: January 31, 2011, 05:57:10 pm »
Can you write one that'll work with .lox files, please?  :)
Caving is for Life not just for Christmas

Offline TheBitterEnd

  • forum hero
  • *****
  • Posts: 1461
  • KCC
    • KCC - Join an active club
Re: Online 3D file viewing?
« Reply #2 on: January 31, 2011, 08:40:47 pm »
I think this was discussed recently here: http://ukcaving.com/board/index.php?topic=11215.msg144842#msg144842

What does .lox format look like? I probably could write something  :-\ if a Java applet is what you want?
'Never argue with a fool, onlookers may not be able to tell the difference.' — Mark Twain

Offline TheBitterEnd

  • forum hero
  • *****
  • Posts: 1461
  • KCC
    • KCC - Join an active club
Re: Online 3D file viewing?
« Reply #3 on: February 21, 2011, 07:50:08 pm »
Alright, here ya' go - this is Little Neath River Cave (as read from http://www.ubss.org.uk/resources/surveys/survex/LNRC.lox). You will need  the Java runtime installed (http://www.java.com) and you will need to accept my self signed certificate.
 
http://chris-h.me.uk/loch/LochViewer.html

As you will see I have only done centre-line data, if there is any real interest I may well be persuaded to do the surfaces & images etc. I'll post the source when I get it tidied up a bit.

Putting something like this in your webpage gets you a view of your Loch file specified by the VALUE parameter

Code: [Select]
<APPLET CODE="plumbing.swing.d3.Applet3d" WIDTH="800" HEIGHT="800" archive="loch.jar"
codebase='http://chris-h.me.uk/loch/'>
    <PARAM NAME="lochUrl"    VALUE="http://www.ubss.org.uk/resources/surveys/survex/LNRC.lox">
</APPLET>
'Never argue with a fool, onlookers may not be able to tell the difference.' — Mark Twain

Offline graham

  • Retired
  • forum hero
  • *****
  • Posts: 10943
  • UBSS, Speleo-Club de Perigueux, GSG, SUI
    • UBSS
Re: Online 3D file viewing?
« Reply #4 on: February 21, 2011, 08:05:32 pm »
 :thumbsup: :thumbsup: :thumbsup:
Caving is for Life not just for Christmas

Offline Duncan Price

  • forum star
  • ****
  • Posts: 601
Re: Online 3D file viewing?
« Reply #5 on: February 21, 2011, 11:06:59 pm »
Excellent!  :clap2:

I'd like to use this to provide an easy way for visitors to my website to view surveys without having to have the SURVEX or Loch viewers installed locally.  Currently I upload a .jpeg plan of the state-of-play:



for those interested.  But it would be much better if it could be done better - particularly as I'm about to move to a nested storage of the raw data for the purposes of better organisation (you'd need to download a .zip archive and recompile).  I'd rather visitors have an easy way of exploring the survey without too much pain.

3d support with passage walls and surface overlay would be a bonus.

Duncan

Offline graham

  • Retired
  • forum hero
  • *****
  • Posts: 10943
  • UBSS, Speleo-Club de Perigueux, GSG, SUI
    • UBSS
Re: Online 3D file viewing?
« Reply #6 on: February 22, 2011, 09:52:12 am »
sirch2

This is brilliant!

Is it possible to give it the same functionality as the lox viewer, as in what can be turned on and off from the view as well as the ability to move it about?

And doubtless Duncan will say he wants a "Survex Aven" version as well though I can convert his survex 3d file to Therion very quickly.
Caving is for Life not just for Christmas

Offline TheBitterEnd

  • forum hero
  • *****
  • Posts: 1461
  • KCC
    • KCC - Join an active club
Re: Online 3D file viewing?
« Reply #7 on: February 22, 2011, 08:37:23 pm »
Bugger! Having got that off my chest I was rather hoping it would sit in a corner and die quietly. All of a sudden some of those digs down Notts2 are looking quite attractive ;D (Loch scraps and surfaces could be a bit of a fight!)

Seriously though, thanks for the encouraging feedback.

Before I get too locked into the Applet thing I want to try out some alternative methods of presentation, so to that end I thought I'd look at SVG and after a limited trial the results are pretty unusable for real time 3D (SVG is pretty good for vector graphics on the web but not for 3d calcs). Here is the same Little Neath as SVG (it could be mouse controlled like the applet but because it is so slow I left the sliders in).
http://chris-h.me.uk/loch/LNRC.svg
It works but it is really slow. Here is a cut down version with just the first 100 survey legs which is just about usable
http://chris-h.me.uk/loch/LNRC-part.svg

I think next I might have a go at a flash version. As I understand it flash does some sort of compile to byte-code a bit like Java so may run faster than the javascript in the SVG.

Graham - it will probably be possible to turn things on and off, what attributes do you want to base visibility on?

As for reading other file formats, assuming the format is known, it's then just a matter of doing the leg work.
'Never argue with a fool, onlookers may not be able to tell the difference.' — Mark Twain

Offline Duncan Price

  • forum star
  • ****
  • Posts: 601
Re: Online 3D file viewing?
« Reply #8 on: February 23, 2011, 01:00:19 am »
And doubtless Duncan will say he wants a "Survex Aven" version as well though I can convert his survex 3d file to Therion very quickly.

I'm sure you can - but I'm thinking along the lines of doing a better conversion.

Offline graham

  • Retired
  • forum hero
  • *****
  • Posts: 10943
  • UBSS, Speleo-Club de Perigueux, GSG, SUI
    • UBSS
Re: Online 3D file viewing?
« Reply #9 on: February 23, 2011, 04:47:27 pm »
And doubtless Duncan will say he wants a "Survex Aven" version as well though I can convert his survex 3d file to Therion very quickly.

I'm sure you can - but I'm thinking along the lines of doing a better conversion.

Good man.  :thumbsup:
Caving is for Life not just for Christmas

Offline TheBitterEnd

  • forum hero
  • *****
  • Posts: 1461
  • KCC
    • KCC - Join an active club
Re: Online 3D file viewing?
« Reply #10 on: February 23, 2011, 09:15:27 pm »
Thses things are just like buses, none for ages and then a load come along at once.

Try this one. It's a flash based example (ignore the big status box at the bottom, that will be going). I have tried it with a couple of versions of flash and with the latest version it seems fine, on an older version it is unusably slow. Let me know if it is usable for you.

http://chris-h.me.uk/loch/flashExample.html

There are pros and cons of flash versus the Java applet and I am open to input from you guys about which way to jump.

The Java Applet can read lox files directly, Java applets have been around since the mid nineties and Java is a very well established platform that runs on a wide range of systems. The draw back is that users have to install a large plug-in, which most people don't have.

The flash version will not be able to read the lox file directly - some kind of conversion will be needed. Flash has been around for nearly as long as Java but has been through 3 owners. It does have a massive installed base for the plug-in. Nearly everyone has it.
'Never argue with a fool, onlookers may not be able to tell the difference.' — Mark Twain

Offline Duncan Price

  • forum star
  • ****
  • Posts: 601
Re: Online 3D file viewing?
« Reply #11 on: February 24, 2011, 12:01:45 am »
I'm happy with the Java version - I need Java to run other stuff and it is not unreasonable to advise viewers of this.  There is no (?) Flash for 64 bit IE so I'm forced to run the 32 bit browser on Win7 Home Premium.

When I get my $h1t together I'll put up .lox versions on my survey data - at the moment I rely on readers to have the 1.1.15 version of Survex which is not supported by the Loch viewer.

Duncan

Offline Bob G

  • I could stop if I wanted - so not an
  • addict
  • **
  • Posts: 117
Re: Online 3D file viewing?
« Reply #12 on: February 24, 2011, 05:16:51 am »
Slightly oblique to the topic, but is there any support for generating stereoscopic images of the surveys?
This has become an interesting proposition with the increasing availability of large 3d TVs and 3d-capable PC monitors.
As I understand it, rendering 3d coordinate data to a stereo image is not as difficult as one might think, but I imagine real-time re-rendering after multi-axis rotation may well be beyond the average PC.

Offline graham

  • Retired
  • forum hero
  • *****
  • Posts: 10943
  • UBSS, Speleo-Club de Perigueux, GSG, SUI
    • UBSS
Re: Online 3D file viewing?
« Reply #13 on: February 24, 2011, 07:17:03 am »
Bob G

Both Therion ans Survex will generate stereoscopic images, but as I lost my 3d glasses ages ago, I don't use them often enough to say how well they work.
Caving is for Life not just for Christmas

Offline TheBitterEnd

  • forum hero
  • *****
  • Posts: 1461
  • KCC
    • KCC - Join an active club
Re: Online 3D file viewing?
« Reply #14 on: February 24, 2011, 07:50:02 am »
...
 but I imagine real-time re-rendering after multi-axis rotation may well be beyond the average PC.

I would have thought, for cave surveys, your average PC was up to it, after all it's only calculating a second set of points displaced from the first by some factor proportional to z-axis position. We are not trying to render light and shade or leaves blowing in the wind.

That said, what would 3D add to our understanding of the relationship of cave passages? I personally think 3D is an over-hyped gimmick that is really there to help protect copyright (and rip off the gullible) so I doubt that I'll be implementing it. But the source will be available so someone else might.

'Never argue with a fool, onlookers may not be able to tell the difference.' — Mark Twain

Offline footleg

  • Caving
  • forum star
  • ****
  • Posts: 649
  • avid photographer & survey drawerupperer
    • Footleg's Cave Photography
Re: Online 3D file viewing?
« Reply #15 on: February 24, 2011, 09:53:12 am »
For me the flash based viewer works the best. I had to disable lots of security and use Internet Explorer for the Java based one as it appears it also uses an ActiveX control. But the flash based one works great in Firefox (on 64 bit Windows 7).

As for 3D stereo views. The Loch viewer in Therion has a red-green anaglyph mode which works really well with the appropriate red-green glasses and really helps to see what it what on complex cave systems.

Offline wookey

  • player
  • **
  • Posts: 105
Re: Online 3D file viewing?
« Reply #16 on: February 24, 2011, 11:32:34 am »
Here is another interesting development that Julian Todd alerted me to recently:
VML is a standard for online graphics which is better designed than VRML, and thus may achieve wider usage.
Here is a library using it, which has some cool demos: http://raphaeljs.com/

And here are Julian's demos using tunnel which show how easy it is to have real online surveys in a standards-compliant manner without evil proprietary flash, or OS-specific stuff like silverlight:

To quote Julian:
Very first experiment here:                                                                                                 
    http://scraperwiki.com/views/cave-svg-viewer/full/                                                                     
                                                                                                                           
And this shows the tiny amount of code needed to do that:                                                                   
    http://scraperwiki.com/views/cave-svg-viewer/edit/

This looks like a very promising area for activity to me. If anyone fancies working on this stuff I'm sure that would be a very productive.

Offline TheBitterEnd

  • forum hero
  • *****
  • Posts: 1461
  • KCC
    • KCC - Join an active club
Re: Online 3D file viewing?
« Reply #17 on: February 24, 2011, 12:06:59 pm »
Bob G - apologies if I came on a little strong earlier, nothing wrong with your Stereo suggestion. It's just that paying an extra £3 per child to watch an out of focus film and finish up with a head ache in the name of "a better motion picture experience" gets right up my nose.
'Never argue with a fool, onlookers may not be able to tell the difference.' — Mark Twain

Offline TheBitterEnd

  • forum hero
  • *****
  • Posts: 1461
  • KCC
    • KCC - Join an active club
Re: Online 3D file viewing?
« Reply #18 on: February 24, 2011, 12:16:05 pm »
Footleg, the Java version works fine for me in Firefox 3.6.13 - like you said it is probably a security setting somewhere. And of course flash is an ActiveX control...

BTW. the majority seem to be liking the Java better than Flash. The thing with Flash is that I doubt that it will read Loch files directly, so it will either mean having to convert the .lox to something like XML either manually and store as yet another file on the server, or via a server-side component that does the conversion on the fly. That said I was quite chuffed with the Flash version, so I'm not necessarily ruling out maintaining both but obviously it is up to those hosting the surveys to choose what they implement.
'Never argue with a fool, onlookers may not be able to tell the difference.' — Mark Twain

Offline TheBitterEnd

  • forum hero
  • *****
  • Posts: 1461
  • KCC
    • KCC - Join an active club
Re: Online 3D file viewing?
« Reply #19 on: February 24, 2011, 12:29:08 pm »
Wookey - behind all that is SVG, see my SVG post earlier in the thread. The issue is that to achieve real time 3D requires some calculations and to do this in SVG means using JavaScript which is a wholly interpreted language, so it is much slower than Java and ActionScript which get compiled to Byte Code. So for tens to hundreds of points it's ok, but for thousands it's too slow.

I personally think SVG is a nifty little format but you need a bit of a reality check on your prejudices - SVG is a format created and owned by Adobe, and if you use IE then you are using an Adobe plugin to view it (Firefox does it natively but does not offer full support). Adobe are of course the owners of "evil proprietary flash" :shrug:
'Never argue with a fool, onlookers may not be able to tell the difference.' — Mark Twain

Offline Martin Laverty

  • menacing presence
  • **
  • Posts: 196
Re: Online 3D file viewing?
« Reply #20 on: February 24, 2011, 02:36:16 pm »
Erm, SVG certainly does not belong to Adobe, nor did they specify it: it is a W3C specification
(Wikipedia has a good entry - http://en.wikipedia.org/wiki/Scalable_Vector_Graphics).
In fact, although Adobe's plugin for IE is very good - indeed, perhaps the best implementation for most purposes - they actually withdrew support for it in January 2009, having ceased any development soon after they purchased Flash.

Offline jarvist

  • obsessive maniac
  • ***
  • Posts: 424
  • Imperial College CC / Northern Pennine Club
    • Imperial College Caving Club
Re: Online 3D file viewing?
« Reply #21 on: February 24, 2011, 03:39:53 pm »
to do this in SVG means using JavaScript which is a wholly interpreted language, so it is much slower than Java and ActionScript which get compiled to Byte Code.

There is a massive effort to improve JavaScript speed, methods include JIT compilation and register based virtual machines. The difference in performance is certainly narrowing, and with the vast complicated javascript web applications out there & commercial backing, would only be expected to decrease.

Eventually we should also get WebGL, and there's the O3D javascript library if you fancy playing with this, I wouldn't be surprised if it or something similar ends up in flash too.

Just a note on the stereo image question -- there's lots of ways to do it, but one pretty good way is simply a 15 degree +/- 'rocking' which lets your brain figure out the depth perception without the strain + complexity of cross-eyed stereo / anaglyph coloured glasses / shutter glasses. I always find myself doing this manually with Aven by tapping to reverse the direction of cave rotation.

Offline TheBitterEnd

  • forum hero
  • *****
  • Posts: 1461
  • KCC
    • KCC - Join an active club
Re: Online 3D file viewing?
« Reply #22 on: February 24, 2011, 06:55:19 pm »
Martin Laverty:  ;D ;D ;D someone always has to ruin a good flame war with facts  ;D ;D ;D

Dunno where that came from, it's not like I haven't been to the W3C SVG site exactly one bazillion times
'Never argue with a fool, onlookers may not be able to tell the difference.' — Mark Twain

Offline footleg

  • Caving
  • forum star
  • ****
  • Posts: 649
  • avid photographer & survey drawerupperer
    • Footleg's Cave Photography
Re: Online 3D file viewing?
« Reply #23 on: February 24, 2011, 09:33:01 pm »
Footleg, the Java version works fine for me in Firefox 3.6.13 - like you said it is probably a security setting somewhere. And of course flash is an ActiveX control...

I possibly confused things with my last post. Flash works fine in Firefox. There is a flash plug-in for Firefox, and an ActiveX control for IE. It was actually the Java where I had security problems. IE was very unhappy about the Java page and I had to disable security to view it. Firefox just did not display it, but I found out later that when installing a 64bit JDK I had messed up the Java plug-in in my Firefox browser. So that might be why I could not get the Java page to work in Firefox.

Offline footleg

  • Caving
  • forum star
  • ****
  • Posts: 649
  • avid photographer & survey drawerupperer
    • Footleg's Cave Photography
Re: Online 3D file viewing?
« Reply #24 on: February 24, 2011, 09:36:48 pm »
SVG means using JavaScript which is a wholly interpreted language, so it is much slower than Java and ActionScript which get compiled to Byte Code. So for tens to hundreds of points it's ok, but for thousands it's too slow.

I just tried that link to Julian's VML stuff, and it absolutly flies in my browser. No performance problems at all. Where as the earlier SVG based page that sirch2 posted was very slow. So there is something different there.