Is it possible to view an x3d file from a sage worksheet (assuming my browser has the necessary plugin or java support for example)? I saw numerous mentions of x3d support in the source code in plot/plot3d. For example if one generates a 'foo.png', the image is immediately and very conveniently rendered. This doesn't work if I save an x3d file.
The reason I ask is really simple. mayavi2 can produce x3d files via mlab.savefig('foo.x3d') for example (thanks to VTK) and freewrl is able to view these pretty well. I was wondering if there were a mechanism to support this seamlessly on a notebook. This would allow for very nice integrated 3D display. Alternatively, does jmol support display via x3d files? Ondrej has integrated mayavi2 with the notebook but it only produces static images and I'd like to find an easy way to also provide 3D interactivity. Here are a few simple examples from Ondrej's site that I made from some mlab examples:
> I saw > numerous mentions of x3d support in the source code in plot/plot3d. For > example if one generates a 'foo.png', the image is immediately and very > conveniently rendered. This doesn't work if I save an x3d file.
> The reason I ask is really simple. mayavi2 can produce x3d files via > mlab.savefig('foo.x3d') for example (thanks to VTK) and freewrl is able > to view these pretty well. I was wondering if there were a mechanism to > support this seamlessly on a notebook. This would allow for very nice > integrated 3D display. Alternatively, does jmol support display via x3d > files? Ondrej has integrated mayavi2 with the notebook but it only > produces static images and I'd like to find an easy way to also provide > 3D interactivity. Here are a few simple examples from Ondrej's site > that I made from some mlab examples:
> Is it possible to view an x3d file from a sage worksheet (assuming my > browser has the necessary plugin or java support for example)? I saw > numerous mentions of x3d support in the source code in plot/plot3d. For > example if one generates a 'foo.png', the image is immediately and very > conveniently rendered. This doesn't work if I save an x3d file.
If you want to add such support, the place to look is sage/server/notebook/cell.py, in the function files_html. This function takes a list of all the files that were produced by evaluating the cell, and produces HTML with display or download links for those files. For example, the case of *.svg files is handled like this:
> If you want to add such support, the place to look is > sage/server/notebook/cell.py, in the function files_html. This > function takes a list of all the files that were produced by > evaluating the cell, and produces HTML with display or download links > for those files. For example, the case of *.svg files is handled like > this:
except that on this one you can actually interact over the web. This is really cool although the x3d files can get pretty big. We'd probably want to throw in some compression in as well but I'm not sure that would work with all plugins (or would the browser take care of that?). Anyway, in the above I simply edited the worksheet and added something like:
>> Another option would be to produce output suitable for use with jmol. >> Would this require a pmesh exporter?
>> I'd appreciate any ideas on this. Thanks.
> Robert Bradshaw will likely have something useful to say tomorrow (=Monday) too.
Cool, will wait for his response. But it looks like simple x3d support should work with a trivial patch to cell.py as Carl pointed out. I'm swamped myself but if its a trivial patch I can have a go.
> On 03/08/09 22:31, Carl Witty wrote: >> If you want to add such support, the place to look is >> sage/server/notebook/cell.py, in the function files_html. This >> function takes a list of all the files that were produced by >> evaluating the cell, and produces HTML with display or download links >> for those files. For example, the case of *.svg files is handled like >> this:
> except that on this one you can actually interact over the web. This is > really cool although the x3d files can get pretty big. We'd probably > want to throw in some compression in as well but I'm not sure that would > work with all plugins (or would the browser take care of that?). Anyway, > in the above I simply edited the worksheet and added something like:
and clearly I could now create some nice 3d results of our code and it would work. Nice job!
jmol doesn't work for me in Debian/Ubuntu if I am using the opensource java. If I used the proprietary version, then it works, but I really prefer to use opensource tools. With freewrl, all I did was to add:
> and clearly I could now create some nice 3d results of our code and it > would work. Nice job!
Thanks.
> to may sources.list and "apt-get install freewrl" and it just works in firefox.
Yes, I have more complex visualizations on my local machine that work really well (for example the Lorenz attractor example renders surprisingly nicely). It works well with texture maps too so things like the image plane widget render pretty well. No 2D actors though but thats not a big deal.
While looking at cell.py I find that sage supports visualizing ".obj" files via sage_3d. So I tried that (yes mayavi2 exports wavefront obj as well) and despite having java enabled and doing this locally I ended up crashing my firefox even for the simplest .obj file (the little triangle). It seems that freewrl OTOH is light, fast and works well. VTK also has a POV exporter which mayavi2 exposes. There is also eps/pdf output (files are huge though) via gl2ps. Regardless, there are clearly a large number of viable options now given the variety of usable outputs mayavi2 and sage support.
Anyway, attached below is a little patch for cell.py that may help. The approach is clunky and the hardcoded width and height is poor. Perhaps more sophisticated rendering can be done with some nice javascript I found here:
In particular, the vb_VRMLDetect.js could be reused but I've already blown a little too much time on this and other work including a pile of grading beckons.
> On 03/08/09 19:19, William Stein wrote: >>> 3D interactivity. Here are a few simple examples from Ondrej's site >>> that I made from some mlab examples:
>>> Another option would be to produce output suitable for use with >>> jmol. >>> Would this require a pmesh exporter?
>>> I'd appreciate any ideas on this. Thanks.
>> Robert Bradshaw will likely have something useful to say tomorrow >> (=Monday) too.
> Cool, will wait for his response.
Way back when I started working on the 3d stuff, this is what I imagined people would do. Unfortunately, x3d viewers aren't common (meaning not commonly installed, they are easy to get) and using an applet to install and/or view them was unwieldily (both in terms of the download size, and there were weird rendering issues). Jmol was the first solution that worked well, out of the box, just about anywhere.
I'm not sure how well the x3d functions have been maintained, but it looks like you got them working which is a good sign. (No need to do jmol -> x3d, much easier to export it directly--in fact the internals of the 3d plotting in Sage is conceptually much closer to x3d than to jmol.)
> But it looks like simple x3d support > should work with a trivial patch to cell.py as Carl pointed out. I'm > swamped myself but if its a trivial patch I can have a go.
> On Mar 8, 2009, at 11:14 AM, Prabhu Ramachandran wrote:
>> On 03/08/09 19:19, William Stein wrote: >>>> 3D interactivity. Here are a few simple examples from Ondrej's site >>>> that I made from some mlab examples:
>>>> Another option would be to produce output suitable for use with >>>> jmol. >>>> Would this require a pmesh exporter?
>>>> I'd appreciate any ideas on this. Thanks.
>>> Robert Bradshaw will likely have something useful to say tomorrow >>> (=Monday) too.
>> Cool, will wait for his response.
> Way back when I started working on the 3d stuff, this is what I > imagined people would do. Unfortunately, x3d viewers aren't common > (meaning not commonly installed, they are easy to get) and using an > applet to install and/or view them was unwieldily (both in terms of > the download size, and there were weird rendering issues). Jmol was > the first solution that worked well, out of the box, just about > anywhere.
I think I am the minority here, but in fact jmol doesn't work out of the box for me at all, unless I install some proprietary java on my debian/ubuntu. If I install the opensource java, it just doesn't work -- I discussed this on the jmol list and even reported a bug against the java package in Debian, but I just don't have time to push this forward and get it fixed.
x3d on the other hand does work out of the box, after I installed one package.
> On Mon, Mar 9, 2009 at 10:41 AM, Robert Bradshaw > <rober...@math.washington.edu> wrote:
>> On Mar 8, 2009, at 11:14 AM, Prabhu Ramachandran wrote:
>>> On 03/08/09 19:19, William Stein wrote: >>>>> 3D interactivity. Here are a few simple examples from Ondrej's >>>>> site >>>>> that I made from some mlab examples:
>>>>> Another option would be to produce output suitable for use with >>>>> jmol. >>>>> Would this require a pmesh exporter?
>>>>> I'd appreciate any ideas on this. Thanks.
>>>> Robert Bradshaw will likely have something useful to say tomorrow >>>> (=Monday) too.
>>> Cool, will wait for his response.
>> Way back when I started working on the 3d stuff, this is what I >> imagined people would do. Unfortunately, x3d viewers aren't common >> (meaning not commonly installed, they are easy to get) and using an >> applet to install and/or view them was unwieldily (both in terms of >> the download size, and there were weird rendering issues). Jmol was >> the first solution that worked well, out of the box, just about >> anywhere.
> I think I am the minority here, but in fact jmol doesn't work out of > the box for me at all, unless I install some proprietary java on my > debian/ubuntu.
It isn't just "some" proprietary Java, it's the original and official Java from Sun. But yes, it's not completely free and open yet...
> If I install the opensource java, it just doesn't work > -- I discussed this on the jmol list and even reported a bug against > the java package in Debian, but I just don't have time to push this > forward and get it fixed.
Yes, this is clearly a bug in Debian's java--hopefully they fix it someday. (I don't have the time to work on it either.) Fixing either jmol and/or the open source Java to actually work together would be a great GSoC project.
> x3d on the other hand does work out of the box, after I installed > one package.
OK, I could lower the bar to "works out of the box over 50% of the time on at least 50% of the systems" and still jmol is the only thing we tried that actually passes this criteria. If the average user goes to sagenb.org, the 3d plots are likely to work.
That being said, I'd really like for x3d to be fully supported, and it would be nice to have a notebook option to choose between tachyon/ jmol/x3d as being the default way to show 3d data.
> On Mar 9, 2009, at 10:52 AM, Ondrej Certik wrote:
>> On Mon, Mar 9, 2009 at 10:41 AM, Robert Bradshaw >> <rober...@math.washington.edu> wrote:
>>> On Mar 8, 2009, at 11:14 AM, Prabhu Ramachandran wrote:
>>>> On 03/08/09 19:19, William Stein wrote: >>>>>> 3D interactivity. Here are a few simple examples from Ondrej's >>>>>> site >>>>>> that I made from some mlab examples:
>>>>>> Another option would be to produce output suitable for use with >>>>>> jmol. >>>>>> Would this require a pmesh exporter?
>>>>>> I'd appreciate any ideas on this. Thanks.
>>>>> Robert Bradshaw will likely have something useful to say tomorrow >>>>> (=Monday) too.
>>>> Cool, will wait for his response.
>>> Way back when I started working on the 3d stuff, this is what I >>> imagined people would do. Unfortunately, x3d viewers aren't common >>> (meaning not commonly installed, they are easy to get) and using an >>> applet to install and/or view them was unwieldily (both in terms of >>> the download size, and there were weird rendering issues). Jmol was >>> the first solution that worked well, out of the box, just about >>> anywhere.
>> I think I am the minority here, but in fact jmol doesn't work out of >> the box for me at all, unless I install some proprietary java on my >> debian/ubuntu.
> It isn't just "some" proprietary Java, it's the original and official > Java from Sun. But yes, it's not completely free and open yet...
Yes, that's what I mean, I don't want to install original and official non free programs on my machine. :) I mean I don't mind using some nonfree programs as a user, but I don't want to depend on them as a developer.
>> If I install the opensource java, it just doesn't work >> -- I discussed this on the jmol list and even reported a bug against >> the java package in Debian, but I just don't have time to push this >> forward and get it fixed.
> Yes, this is clearly a bug in Debian's java--hopefully they fix it > someday. (I don't have the time to work on it either.) Fixing either > jmol and/or the open source Java to actually work together would be a > great GSoC project.
Yep, for the record if anyone wants to give it a shot, here is my email from the jmol list:
So basically the Debian maintainer says the applet is wrong and jmol developers say the java in Debian is wrong, so both parties wash their hands and as the result jmol doesn't work in Debian. So to get this fixed, one needs to first determine where exactly the problem is and then push it.
>> x3d on the other hand does work out of the box, after I installed >> one package.
> OK, I could lower the bar to "works out of the box over 50% of the > time on at least 50% of the systems" and still jmol is the only thing > we tried that actually passes this criteria. If the average user goes > to sagenb.org, the 3d plots are likely to work.
Yep, jmol is a good choice for Sage.
> That being said, I'd really like for x3d to be fully supported, and > it would be nice to have a notebook option to choose between tachyon/ > jmol/x3d as being the default way to show 3d data.
> Way back when I started working on the 3d stuff, this is what I > imagined people would do. Unfortunately, x3d viewers aren't common > (meaning not commonly installed, they are easy to get) and using an > applet to install and/or view them was unwieldily (both in terms of > the download size, and there were weird rendering issues). Jmol was > the first solution that worked well, out of the box, just about > anywhere.
Jmol is very nice. Just FYI, the freewrl deb file is about 0.5 MB. On the mac the installer is about 8 MB and seems to work great, although the plugin works under Safari and I didn't bother to figure out what to do to get it to work under FF.
> I'm not sure how well the x3d functions have been maintained, but it > looks like you got them working which is a good sign. (No need to do
Sorry to disappoint you but I haven't used any of the existing x3d code in sage. mayavi2 generates x3d natively via VTK.
> jmol -> x3d, much easier to export it directly--in fact the internals > of the 3d plotting in Sage is conceptually much closer to x3d than to > jmol.)
>> But it looks like simple x3d support >> should work with a trivial patch to cell.py as Carl pointed out. I'm >> swamped myself but if its a trivial patch I can have a go.
> I bet it will be an easy patch.
It was and I sent it to the list but doing more fancy things like detecting x3d support and prompting the user appropriately if it is not installed or presenting a png image in such a case hasn't been done.
> Is it possible to view an x3d file from a sage worksheet (assuming my > browser has the necessary plugin or java support for example)? I saw > numerous mentions of x3d support in the source code in plot/plot3d. For > example if one generates a 'foo.png', the image is immediately and very > conveniently rendered. This doesn't work if I save an x3d file.
> The reason I ask is really simple. mayavi2 can produce x3d files via > mlab.savefig('foo.x3d') for example (thanks to VTK) and freewrl is able > to view these pretty well. I was wondering if there were a mechanism to > support this seamlessly on a notebook. This would allow for very nice > integrated 3D display. Alternatively, does jmol support display via x3d > files? Ondrej has integrated mayavi2 with the notebook but it only > produces static images and I'd like to find an easy way to also provide > 3D interactivity. Here are a few simple examples from Ondrej's site > that I made from some mlab examples:
I just installed FreeWRL and looked at this. Awesome! It looks like this might be the best way to get good opengl graphics (and mayavi!) in the sage notebook while we still wait on the possibility of an html canvas3d tag.
I noticed that, at least with Freewrl, there didn't seem to be an easy way of rotating the object in the above demo. Instead, all the methods focused on navigating the camera. Does anyone know a way to rotate the whole scene around some point, similar to grabbing and dragging an object in jmol or mayavi? This could be accomplished by moving the camera around a sphere, always pointing at the same spot in space.
> On Mar 9, 2009, at 10:52 AM, Ondrej Certik wrote:
> > On Mon, Mar 9, 2009 at 10:41 AM, Robert Bradshaw > > <rober...@math.washington.edu> wrote:
> >> On Mar 8, 2009, at 11:14 AM, Prabhu Ramachandran wrote:
> >>> On 03/08/09 19:19, William Stein wrote: > >>>>> 3D interactivity. Here are a few simple examples from Ondrej's > >>>>> site > >>>>> that I made from some mlab examples:
> >>>>> Another option would be to produce output suitable for use with > >>>>> jmol. > >>>>> Would this require a pmesh exporter?
> >>>>> I'd appreciate any ideas on this. Thanks.
> >>>> Robert Bradshaw will likely have something useful to say tomorrow > >>>> (=Monday) too.
> >>> Cool, will wait for his response.
> >> Way back when I started working on the 3d stuff, this is what I > >> imagined people would do. Unfortunately, x3d viewers aren't common > >> (meaning not commonly installed, they are easy to get) and using an > >> applet to install and/or view them was unwieldily (both in terms of > >> the download size, and there were weird rendering issues). Jmol was > >> the first solution that worked well, out of the box, just about > >> anywhere.
> > I think I am the minority here, but in fact jmol doesn't work out of > > the box for me at all, unless I install some proprietary java on my > > debian/ubuntu.
> It isn't just "some" proprietary Java, it's the original and official > Java from Sun. But yes, it's not completely free and open yet...
Actually in my Ubuntu even the official proprietary Java doesn't work with Jmol... The applet loads fine, including menus, but the model doesn't appear, just the black background.
> > If I install the opensource java, it just doesn't work > > -- I discussed this on the jmol list and even reported a bug against > > the java package in Debian, but I just don't have time to push this > > forward and get it fixed.
> Yes, this is clearly a bug in Debian's java--hopefully they fix it > someday. (I don't have the time to work on it either.) Fixing either > jmol and/or the open source Java to actually work together would be a > great GSoC project.
> > x3d on the other hand does work out of the box, after I installed > > one package.
> OK, I could lower the bar to "works out of the box over 50% of the > time on at least 50% of the systems" and still jmol is the only thing > we tried that actually passes this criteria. If the average user goes > to sagenb.org, the 3d plots are likely to work.
Even in sagenb.org it doesn't work for me :(
> That being said, I'd really like for x3d to be fully supported, and > it would be nice to have a notebook option to choose between tachyon/ > jmol/x3d as being the default way to show 3d data.
On Tue, Mar 10, 2009 at 5:39 PM, Ronan Paixão <ronanpai...@yahoo.com.br> wrote:
> Em Seg, 2009-03-09 às 11:11 -0700, Robert Bradshaw escreveu: >> On Mar 9, 2009, at 10:52 AM, Ondrej Certik wrote:
>> > On Mon, Mar 9, 2009 at 10:41 AM, Robert Bradshaw >> > <rober...@math.washington.edu> wrote:
>> >> On Mar 8, 2009, at 11:14 AM, Prabhu Ramachandran wrote:
>> >>> On 03/08/09 19:19, William Stein wrote: >> >>>>> 3D interactivity. Here are a few simple examples from Ondrej's >> >>>>> site >> >>>>> that I made from some mlab examples:
>> >>>>> Another option would be to produce output suitable for use with >> >>>>> jmol. >> >>>>> Would this require a pmesh exporter?
>> >>>>> I'd appreciate any ideas on this. Thanks.
>> >>>> Robert Bradshaw will likely have something useful to say tomorrow >> >>>> (=Monday) too.
>> >>> Cool, will wait for his response.
>> >> Way back when I started working on the 3d stuff, this is what I >> >> imagined people would do. Unfortunately, x3d viewers aren't common >> >> (meaning not commonly installed, they are easy to get) and using an >> >> applet to install and/or view them was unwieldily (both in terms of >> >> the download size, and there were weird rendering issues). Jmol was >> >> the first solution that worked well, out of the box, just about >> >> anywhere.
>> > I think I am the minority here, but in fact jmol doesn't work out of >> > the box for me at all, unless I install some proprietary java on my >> > debian/ubuntu.
>> It isn't just "some" proprietary Java, it's the original and official >> Java from Sun. But yes, it's not completely free and open yet...
> Actually in my Ubuntu even the official proprietary Java doesn't work > with Jmol... The applet loads fine, including menus, but the model > doesn't appear, just the black background.
Exactly, that's my experience too. Could you please try the x3d if it works for you?
> I just installed FreeWRL and looked at this. Awesome! It looks like > this might be the best way to get good opengl graphics (and mayavi!) in > the sage notebook while we still wait on the possibility of an html > canvas3d tag.
Thanks for the kind words. It would be nice if someone would incorporate the little patch to cell.py to support this directly. It would be cool if the build process for this were easier so others could also have a mayavi enabled sage. I am not sure what the status of that was, I believe Jaap and Ondrej were working that out.
> I noticed that, at least with Freewrl, there didn't seem to be an easy > way of rotating the object in the above demo. Instead, all the methods > focused on navigating the camera. Does anyone know a way to rotate the > whole scene around some point, similar to grabbing and dragging an > object in jmol or mayavi? This could be accomplished by moving the > camera around a sphere, always pointing at the same spot in space.
Left-click and drag rotates the camera and right click drag zooms. I couldn't find something for panning the camera. The trouble with the rotation is that the center of the rotation always seems to be at (0,0,0) which causes the funny interactionr. I wrote to John Stewart regarding fixing this a day or so ago and haven't heard back.