From JReality Wiki
Jump to: navigation, search

Loading and displaying a geometry

Display a geometry in JRViewer

Source file: Icosahedron

Run as Java webstart

Calling JRViewer.display(SceneGraphNode n) opens the jReality viewer and displays the Geometry or a SceneGraphComponent passed in as argument.

Some simple geometries are implemented in class de.jreality.geometry.Primitives, find an example below.



Display a geometry in JRViewerVR

Source file: IcosahedronVR

Run as Java webstart

If you like to look at a geometry in a virtual reality environment then add the following plugins to the JRViewer:

JRViewer v = new JRViewer();
v.registerPlugin(new ContentAppearance());
v.registerPlugin(new ContentTools());

We call this collection of plugins ViewerVR or JRViewerVR, see also the ViewerVR_User_Manual.

icosahedron in ViewerVR

Load a geometry into JRViewer

Source file: Intro02

Run as Java webstart

Calling JRViewer.display(SceneGraphNode node) opens a jReality JRViewer and displays the node node. The node should be an instance of Geometry or SceneGraphComponent if you want to see anything!

The following method reads in the file which we used in the User Tutorial. Notice that it's expected that you have a copy of this file in the directory where you are running these examples (see the getResource() method call). If you're using the jReality src-tutorial folder itself, then the file is already present there. Otherwise, you'll need to copy it to wherever you're running these examples.

 private static SceneGraphComponent readDodec() {
		URL url = Intro02.class.getResource("");
		SceneGraphComponent sgc = null;
		try {
			sgc =;
		} catch (IOException e) {

If you prefer to access the file as a URL, replace the method call shown with

    sgc =

Pass the component returned from this method to the JRViewer.display() method. Customize the resulting JRViewer to display the navigator panel. And finally, encompass the scene with the 'e' key.

The resulting code should pop up a window looking like this (taken from the User Tutorial):

After loading a dodecahedron

Previous: Intro01 Developer Tutorial: Contents Next: Intro03