Permalink
Browse files

Package collada models in a zip-file for increased download speed and…

… bandwidth usage.
  • Loading branch information...
1 parent 7d81502 commit eda4f67a28607f3296f1166a35b1907a4c46f91a @andreasrosdal andreasrosdal committed Dec 2, 2016
View
@@ -76,4 +76,5 @@ resin*
freeciv-web.project
configuration.sh.dist
freeciv-web/src/main/webapp/META-INF/context.xml
+models.zip
@@ -1,7 +1,7 @@
#!/bin/bash
# builds javascript files Freeciv-web and copies the resulting file to tomcat.
-mvn compile && cp target/freeciv-web/javascript/webclient.min.* /var/lib/tomcat8/webapps/ROOT/javascript/
+mvn compile && cp target/freeciv-web/javascript/webclient.min.* /var/lib/tomcat8/webapps/ROOT/javascript/ && cp target/freeciv-web/javascript/webgl/libs/webgl-client.min* /var/lib/tomcat8/webapps/ROOT/javascript/webgl/libs/
# update timestamp to clear browser cache.
sed -i.bak -e "s/ts=\"/ts=\"1/" -e "s/\?ts=/\?ts=1/" /var/lib/tomcat8/webapps/ROOT/webclient/index.jsp
@@ -26,4 +26,11 @@ mkdir -p $DATADIR/savegames
mkdir -p $DATADIR/scorelogs
mkdir -p $DATADIR/ranklogs
+echo "compressing 3d-models into zip file"
+(
+ cd src/main/webapp/3d-models
+ zip -9 models.zip *.dae
+)
+
+echo "maven package"
mvn package && cp target/freeciv-web.war "${TOMCATDIR}/webapps/ROOT.war"
View
@@ -119,6 +119,7 @@
</dependency>
</dependencies>
<executions>
+ <!-- Create minified common webclient.min.js and css -->
<execution>
<id>default-minify</id>
<configuration>
@@ -156,11 +157,40 @@
</jsSourceExcludes>
<jsEngine>CLOSURE</jsEngine>
<closureCreateSourceMap>true</closureCreateSourceMap>
+ <closureLanguage>ECMASCRIPT5</closureLanguage>
</configuration>
<goals>
<goal>minify</goal>
</goals>
</execution>
+ <!-- Create minified WebGL specific webgl-client.min.js -->
+ <execution>
+ <id>webgl-minify</id>
+ <configuration>
+ <jsSourceDir>javascript/webgl/libs/</jsSourceDir>
+ <jsFinalFile>webgl-client.js</jsFinalFile>
+ <closureLanguage>ECMASCRIPT5</closureLanguage>
+ <jsSourceIncludes>
+ <jsSourceInclude>*.js</jsSourceInclude>
+ </jsSourceIncludes>
+ <jsSourceExcludes>
+ <jsSourceExclude>three.min.js</jsSourceExclude>
+ <jsSourceExclude>zip.js</jsSourceExclude>
+ <jsSourceExclude>zip-ext.js</jsSourceExclude>
+ <jsSourceExclude>deflate.js</jsSourceExclude>
+ <jsSourceExclude>inflate.js</jsSourceExclude>
+ <jsSourceExclude>z-worker.js</jsSourceExclude>
+ <jsSourceExclude>CanvasRenderer.js</jsSourceExclude>
+ <jsSourceExclude>Projector.js</jsSourceExclude>
+ </jsSourceExcludes>
+ <jsEngine>CLOSURE</jsEngine>
+ <closureCreateSourceMap>true</closureCreateSourceMap>
+ </configuration>
+ <goals>
+ <goal>minify</goal>
+ </goals>
+ </execution>
+
</executions>
</plugin>
@@ -8,3 +8,8 @@ The blender models can be found in the Freeciv-web source repository in the /ble
The models must not contain lamps or light sources. I have not been able to export Blender models with armatures to the Collada
format and import them into Three.js.
+All the collada .dae files in this directory are compressed to a zip-file called models.zip by the build.sh script.
+Tue file models.zip is downloaded by the browser and uncompressed, so that bandwidth usage is limited as much as possible.
+So to update models, you have to run the build.sh script.
+
+
Oops, something went wrong.

0 comments on commit eda4f67

Please sign in to comment.