VRMLSite Magazine

VRML 2.0 URLs
VRML by the Pound
People Linking to Us
Subscribe for Free
Tell a Friend
We'll Link to You

IntranetSite

Aereal, Inc.
Instant VRML World

Spotlight BackContentsNext
view me!


JavaScripting VRML
by Pioneer Joel

It's hot, it's new, it's the edge of the Web (The Wedge, if you will). It's JavaScript, and it'll do wonders for your .wrls! This less powerful, often painful, quite delightful, bastard son of Java drives The Wedge through a client's beating heart and cleaves your site from the tangled blur of the Inter-mess.

Though a JavaScript composite of any Web-based material gives thousands of times the strength of either independant substance, three JavaScript-galvanizations of VRML are noteworthy; compression, customization, and transition. JavaScript shines as a tool of VRML compression

JavaScript shines as a tool of VRML compression

Infinite Reality, Finite Bandwidth
Perhaps the greatest complaint about VRML is file size. While it isn't true that .wrls must be several megabytes in diameter, more often than not they are. And while g-zipping and shrewd scripting alleviate most of the super-K tension, JavaScript shines as a tool of VRML compression, creating vast scenes with highly resolved objects which used to demand large file sizes.

How can I get limitless .wrls with bounded JavaScript? By dynamically generating VRML on the client side! Long ago, CGIs created VRML out of thin air, per client request. This, however, meant that the resulting .wrl was transfered via the Net. With JavaScript, the client's computer does all the work. Without writing a JavaScript tutorial, I'll give you an example:

<script code=JavaScript>
<!--

function build_wrl(range){

	var coord = "";
	var VRML = "";

	for(i=0;i<range;i++){
	
		coord += -10+20*random()+", ";
		coord += -10+20*random()+", ";
		coord += -10+20*random()+",\n";

	}

	VRML += "#VRML V2.0 utf8\n\n";
	VRML += "#pioneer.joel@asu.edu\n\n";
	VRML += "Shape{\ngeometry PointSet{\n";
	VRML += " coord Coordinate{\n  point[\n";
	VRML += coord;
	VRML += "   ]\n  }\n }\n}\n";

	parent.output.document.open("x-world/x-vrml");
	parent.output.document.writeln(VRML);
	parent.output.document.close();
}

-->
</script>

Looking through this simple JavaScript code, you probably ask yourself, "what does it all mean?" Simply, some function build_wrl is called from an HTML form and given the INSERT range. After some variables are intitiated, a for loop begins. For every integer between 0 and range, three random numbers are added to the variable coord. This coord variable is then used as the value for the point field of a VRML Coordinate node. The final VRML is output to another frame called output.

Sierpinski Triangle
Seashell generator

As you can see, by creating an INSERT named range in an HTML form, clients can choose any number of points. Entering 1000 in the form would cause 1000 random points to be dynamically generated on the client's Java machine. The file size of a .wrl with 1000 points would be much larger than this simple JavaScript. One quick download of this script allows any client to generate infinitely many scenes, all of which never cross the Web! I have used this trick to generate fractals of infinite intrigue. A seashell generator and a Serpienski Triangle generator I have made both exploit JavaScript compression and the inherent characteristics of fractals.

Incidentally, the line:
parent.output.document.open("x-world/x-vrml"); sets the Content-type of the output frame. Using JavaScript to create VRML in another window is THE ONLY EXAMPLE ON THE NET TODAY of generating non-HTML Content-type in frames!

Big-endian, Little-endian
Since clients are deciding how much VRML to generate, each visitor may set the .wrl size to whatever his computer manages best. This gives the JavaScripting VRML author the chance to attract visitors with high and low end machines. This also relieves authors of the burden of creating several .wrls to accomodate everyone. You can create scenes that vary on every hit

You can create scenes that vary on every hit

Using random and controlled JavaScript techniques, you may create scenes that vary on every hit! Netter-betters will enjoy the ability to optimize preformance, and return more often to a site that is never the same twice.

Bridging the Gulf War
Sadly, VRML is largely considered to merely be a show-piece of the Web. The third power of the Net has yet to be harnessed and VRML remains an elitist chrome job isolated from the Net@large. While VRML does allow for network interaction with inlines and anchors, .wrls still have not integrated with the flat web. Because of the nature of the information currently dominating the Internet, three dimensional interfaces do little to enhance understanding. Essentially, the Web is text based. VRML's polygonized text is a poor, poor solution to the problem of incorporating the broader Net into the truly virtual world.

Ideally, VRML (and all immersive environments) should be text-free zones. A JavaScript-powered, forms-based HTML interface permits authors to better mesh their .wrl's with their existing Web presence. A pleasant combination of words and .wrls will help forge the new metaphors needed for survival in a cold, hard .wrl.

By giving your site limitless originality, accomodating computing capacities, and dove-tailing immersion with your existing site, JavaScript will push your .wrls to The Wedge! With a little creativity, .wrls can be exciting, dynamic, managable, useful environments from which we may all exploit the full potential of the Internet.

Pioneer Joel is a student of architecture at Arizona State University and works for (among other people) the Arizona State Public Informaion Network. He has been wearing the Internet for quite a while and is currently consumed by the architectural potential of the Web.
BackContentsNext
© 1996 Aereal, Inc. Please send suggestions to suggest@vrmlsite.com.