Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Take Your Web Pages to the Next Dimension with FastScript3D

Rocket-power your Web pages with the new Java technology from NASA's Jet Propulsion Laboratory.


WEBINAR: On-Demand

Unleash Your DevOps Strategy by Synchronizing Application and Database Changes REGISTER >

elieve it or not, the Jet Propulsion Laboratory (JPL) from NASA is actually developing Java capabilities. The JPL is a division of NASA responsible for the robotic exploration of the solar system. Household names such as the Mars Pathfinder and the Voyager explorers are products of JPL.

One of their Java capabilities is the FastScript3D library for Java3D, and it is a technology that really shows some promise.

FastScript3D is a Web-friendly extensible scripting interface to Java3D. It allows you to quickly harness the power of 3D Web graphics using JavaScript or VBScript to add interactive 3D applets to your pages. There are a number of free examples on the JPL Web site. But in essence FastScript is an applet to which you can pass simple script commands in order to make it generate 3D Web objects automatically.

This technology could be used to render and display three-dimensional models on your Web site, in much the same way that VRML (Virtual Reality Modeling Language) did. The nice thing about FastScript3D is that it doesn't have a proprietary file format, and that it can load the model description files from a variety of 3D modeling applications.

Getting Started
In this article you will step through the basics of the FastScript3D API, and build some Web pages that render different 3D models. You will begin by looking at how to install the API, and from there will build three-dimensional models using the built in primitives. Then you'll see how to load and render a 3D model from the popular Lightwave 3D modeling application. By the end of the tutorial you will have covered the basic operations offered by the API and will be prepared to look into some of the more complex aspects, such as extending the API and animating your 3D worlds.

You will need a J2SE SDK version 1.4 or later, and the Java 3D API version 1.3.1 or later. These may be downloaded from http://java.sun.com. Make sure that you are using the correct Java plug-in for your browser by opening Control Panel and selecting the 'Java Plug-in' Applet. On the 'Advanced' tab, select the correct runtime. This should read something like 'SDK 1.4.2_01 in C:\j2sdk1.4.2_01.'

Close down and restart your browser, and then browse to http://fastscript3d.jpl.nasa.gov/HelloUniverse.html. You should see a spinning multicolored cube. If you do, then you are ready to go with fastScript3D.

Setting Up Your Development System
Fastscript3D uses the LiveConnect classes from Sun to communicate between JavaScript and Java. LiveConnect is a technology that allows JavaScript to interface with Java applets. With it you can access Java variables, methods, events, and packages directly and gain full control over your applets.

Figure 1. Picture This: Here's the easy FastScript3D application in action.
On the PC platform the JAR file containing LiveConnect is called jaws.jar, and on the Sun platform it is called java40.jar. Find the appropriate jar for your platform and add it to your classpath.

The next thing you will need is the JAR file containing the supporting files for FastScript, fs.jar, which is available for download on the JPL site. This needs to be placed in the directory on your Web server where the HTML files containing the 3D applets will reside. Under this directory create the following subdirectories: FS_MODEL, FS_TEXTURE, FS_SIM, and FS_DEMO.

The JPL has provided a very basic example which has three cubes—a red one, a green one, and a blue one—floating in 3D space. The source code for which (easy.java) is included in the download for this article. To compile this you must have references to the java3d JARs (usually found in jre\lib\ext\j3dutils.jar) and the FastScript JAR that you downloaded earlier.

Once this is compiled into easy.class, place it in the directory on your Web server that you created earlier. Finally, take the HTML file from the download with this article (easy.htm) and put it in the same directory. Browse to the HTML, and you should see something like that shown in Figure 1.

Author's Note: If you follow the example on the JPL site directly you will get an error, as the JAR file for FastScript3D that you download is newer than the one referenced in their example. Use the ones in the download with this article and it should work easily.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date