Lookiing for an x3d viewer

Folks,

I’m fixing a bug in vtkX3DExporter. I can’t find an x3d viewer for MAC OS or Ubuntu. Can someone point me to a viewer that they have used? I’ve tried the x3d viewer plugin for chrome on both systems, but neither of display x3d files properly. They just show a plane and axes, but no model.

Bill

1 Like

Hi Bill,

I would suggest to pick one in the “official” list here: https://www.web3d.org/x3d/content/examples/X3dResources.html#Applications
I guess instantreality.org is a good candidate.

Best,
Joachim

@JPouderoux, thanks. I tried several on that page but not Instant Reality. Just what I need!

@lorensen, I have a working script to use VTK’s vtkX3DExporter that can send VTK render widows to X3D HTML which can be displayed in Jupyter notebooks or any web browser over in this (somewhat stale) pull request for PyVista: https://github.com/pyvista/pyvista/pull/300

Here is a script to make HTML of a vtkRenderWindow:

import vtk
 
X3D_JAVASCRIPT = '''
 <?xml version="1.0" encoding ="UTF-8"?>
 <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN"
 "http://www.web3d.org/specifications/x3d-3.3.dtd">
 <head>
 <script type='text/javascript' src='http://www.x3dom.org/x3dom/release/x3dom.js'> </script>
 <link rel='stylesheet' type='text/css' href='http://www.x3dom.org/x3dom/release/x3dom.css'></link>
 </head>
 <body>
 {}
 </body>
 '''

def export_x3d(ren_win, binary=True, speed=4.0):
     """Exports the scene to an X3D (XML-based format) for
     representation 3D scenes (similar to VRML). Check out
     http://www.web3d.org/x3d/ for more details.
     """
     exporter = vtk.vtkX3DExporter()
     exporter.SetInput(ren_win)
     exporter.FastestOff()
     if speed:
         exporter.SetSpeed(speed)
     exporter.SetWriteToOutputString(True)
     exporter.Update()
     exporter.Write()
     return X3D_JAVASCRIPT.format(exporter.GetOutputString())

Then you could display that output in Python using:

from IPython.core.display import display, HTML
display(HTML(the_output))

or you could save that HTML to a file and open it with any web browser

@banesullivan thanks, but the instantreality viewer is all I need,

1 Like