#!/bin/sh

#dispatch-vrml-c -- VRML 1.0/2.0 browser startup script tailored
#to be used with the XSwallow plugin for X netscape, takes 
#dispatch-vrml-c filename urlname [width] [height]
#Caolan.McNamara@ul.ie http://skynet.csn.ul.ie/~caolan/docs/Xswallow.html
#based completely on dispatch-vrml, see below
#edit these line to suit your setup

JDK=/usr/local
LREALITY=/usr/local/java/lib
LD_LIBRARY_PATH=/usr/local/java/lib/lib/i586/
export LD_LIBRARY_PATH


# dispatch-vrml -- a VRML 1.0/2.0 browser startup script
# to be called by Netscape from ~/.mailcap like
#
#   x-world/x-vrml;  dispatch-vrml %s %u
#
# The VRML version is identified by looking at the header line.
#
# Created 18-Sep-96 by Johan Hagman (Johan.Hagman@mailbox.swipnet.se) for
# the Solaris Helpers page (http://home1.swipnet.se/%7Ew-10694/helpers.html)
#
#  9-Oct-96  stdout and stderr properly redirected to /dev/null
# 23-Feb-97  added entry for VRwave 0.7 (commented out)
#  8-Jun-97  added the (commented out) file copy to /tmp/dispatch_vrml.wrl



if [ -f $1 -a $# -gt 1 ]; then

    # Remove the comment from the line below to get a .wrl copy in /tmp
    #cp $1 /tmp/dispatch_vrml.wrl

    if [ "`head -1 $1`" = "#VRML V1.0 ascii" ]; then

	#----- Start a VRML 1.0 browser -----

 	# VRweb 1.5
	exec vrweb -geometry 120x120+9000+9000 -URL "$2" $1 >/dev/null
#	exec vrweb  -geometry 120x120+9000+9000 -URL "$2" -remote $1  >/dev/null &

	# TGS Webspace
	#webspace -remote $1 -URL $2

    else
	#----- Start a VRML 2.0 browser -----

 	# VRwave 0.7
	# To enable, remove the comments from the following *two* lines
	#vrwave "$1" 2>/dev/null >/dev/null
	#exit 0

	# The following works with Liquid Reality 1.0 beta
	# and the appletviewer included with JDK 1.0.2
	#
	# Two variables must be set in the users's environment:
	# JDK = JDK installation directory
	# LREALITY = Liquid Reality installation directory
	#
	# First build a HTML file for AppletViewer, which will
	# call the Liquid Reality applet to render VRML 2.0
    if [ "$3" = "" ]; then
	width="420"
	else
	width=$3
	fi

    if [ "$4" = "" ]; then
	height="400"
	else
	height=$4
	fi
	
	AVFILE=/tmp/avfile$$.html
	(
cat << END_AVFILE
<html>
<head>
 <title>Liquid Reality Browser</title>
</head>
<body>
<applet code="dnx.lrbrowser.LRBrowser.class" width="$width" height="$height">
<param name=vrml value="$1">
</applet>
</body>
</html>
END_AVFILE
	) > $AVFILE

	# Set CLASSPATH to included the LR classes
	CLASSPATH=$LREALITY/classes
	export CLASSPATH

	# Start the browser
	$JDK/java/bin/appletviewer $AVFILE 2>/dev/null >/dev/null
	# Clean up
	rm -f $AVFILE
    fi
else
    echo "dispatch-vrml: need two URL arguments"
fi
exit 0
