-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathv2x
executable file
·59 lines (54 loc) · 1.82 KB
/
v2x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# a bash scrip to convert g4_??.wrl to g4_??.x3d
# check if the script is run as a CGI script
if [ ! -z "$SCRIPT_NAME" ]; then # if yes, construct a webpage
echo "Content-type: text/html"
# https://en.wikipedia.org/wiki/Common_Gateway_Interface
echo # leave a blank line
echo '<html style="padding: 10px;">'
echo '<head><title>VRML Web Viewer</title></head>'
echo '<body style="max-width: 800px; margin: auto;">'
echo '<pre style="border:1px solid; padding: 5px; overflow: auto;">'
fi
echo Print working environment ...
env; echo; java -version 2>&1; echo
echo Search g4_??.wrl files ...
files=`find . | grep wrl`
# quit if there is none
if [ -z "$files" ]; then
echo "There is no g4_??.wrl file found"
echo "Please run \`gears VRML.mac\` to generate some"
exit
else
for each in $files; do echo $each; done; echo
fi
echo "Convert g4_??.wrl to g4_??.x3d ..."
for each in $files; do
file=${each#./} # remove ./ from the beginning of string
fx3d=${file/wrl/x3d} # .wrl -> .x3d
page=${file/wrl/html} # .wrl -> .html
# convert g4_??.wrl to g4_??.x3d
java -jar VrmlMerge-0.5beta.jar -convert $file $fx3d
# tune transparency in g4_??.x3d
sed -i.bak 's/"0.7"/"0.1"/g' $fx3d; rm $fx3d.bak
# embed g4_??.x3d in g4_??.html
base=`basename $fx3d`
sed "s|gears.x3d|$base|" gearsX3D.html > $page
done
if [ -z "$SCRIPT_NAME" ]; then # run in shell
p3=`command -v python3` # print path to python3
if [ ! -z "$p3" ]; then # python3 exists
echo
$p3 -u -m http.server -b 0.0.0.0 --cgi # launch http server
fi
else # run as a CGI script
echo '</pre>'
echo '<h3>Choose one from the following scanning result to view:</h3>'
echo '<ul>'
for each in $files; do
echo "<li><a style=\"color:blue;\" href=\".${each/wrl/html}\">${each#./}</a></li>"
done
echo '</ul>'
echo '</body>'
echo '</html>'
fi