From 77acf2da2240f5223b7bdcf315c50bbda6a05b71 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 May 2011 13:08:08 -0400 Subject: [PATCH 1/4] Replaced old file loading code with much better code. Thanks to cwdesautels for providing it. --- c3dl/c3dapi.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/c3dl/c3dapi.js b/c3dl/c3dapi.js index 3ba0702..5aa2a85 100644 --- a/c3dl/c3dapi.js +++ b/c3dl/c3dapi.js @@ -16,6 +16,7 @@ var parts = scripts[scripts.length - 1].src.split("/"); parts.pop(); var basePath = parts.join("/"); var head = document.getElementsByTagName("head")[0]; +basePath += "/"; /** @private @@ -26,11 +27,13 @@ var head = document.getElementsByTagName("head")[0]; */ c3dl_require = function (path) { - document.write('<' + 'script'); - document.write(' language="javascript"'); - document.write(' type="text/javascript"'); - document.write(' src="' + basePath + "/" + path + '">'); - document.write(''); + var s = window.document.createElement('script'); + s.type = 'text/javascript'; + s.onload = function(){ + window.document.head.removeChild(s); + }; + s.src = basePath + path; + window.document.head.appendChild(s); } //Some classes depend on others, so the order of the following lines should not be From 5eb55bc56049175b448f585554eedf029ca5aeeb Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Jun 2011 12:00:29 -0400 Subject: [PATCH 2/4] Replaced old file loading code with much better code. Thanks to cwdesautels. for providing it. --- c3dl/c3dapi.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/c3dl/c3dapi.js b/c3dl/c3dapi.js index 3ba0702..5aa2a85 100644 --- a/c3dl/c3dapi.js +++ b/c3dl/c3dapi.js @@ -16,6 +16,7 @@ var parts = scripts[scripts.length - 1].src.split("/"); parts.pop(); var basePath = parts.join("/"); var head = document.getElementsByTagName("head")[0]; +basePath += "/"; /** @private @@ -26,11 +27,13 @@ var head = document.getElementsByTagName("head")[0]; */ c3dl_require = function (path) { - document.write('<' + 'script'); - document.write(' language="javascript"'); - document.write(' type="text/javascript"'); - document.write(' src="' + basePath + "/" + path + '">'); - document.write(''); + var s = window.document.createElement('script'); + s.type = 'text/javascript'; + s.onload = function(){ + window.document.head.removeChild(s); + }; + s.src = basePath + path; + window.document.head.appendChild(s); } //Some classes depend on others, so the order of the following lines should not be From 4a40a246d726849e7cb38bd96a21aaa2899205e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Jun 2011 15:12:07 -0400 Subject: [PATCH 3/4] File was messing up git, wasn't actually used anywhere --- tools/jsmin.c | 275 -------------------------------------------------- 1 file changed, 275 deletions(-) delete mode 100644 tools/jsmin.c diff --git a/tools/jsmin.c b/tools/jsmin.c deleted file mode 100644 index 71d3b29..0000000 --- a/tools/jsmin.c +++ /dev/null @@ -1,275 +0,0 @@ -/* jsmin.c - 2008-08-03 - -Copyright (c) 2002 Douglas Crockford (www.crockford.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -The Software shall be used for Good, not Evil. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include -#include - -static int theA; -static int theB; -static int theLookahead = EOF; - - -/* isAlphanum -- return true if the character is a letter, digit, underscore, - dollar sign, or non-ASCII character. -*/ - -static int -isAlphanum(int c) -{ - return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || - (c >= 'A' && c <= 'Z') || c == '_' || c == '$' || c == '\\' || - c > 126); -} - - -/* get -- return the next character from stdin. Watch out for lookahead. If - the character is a control character, translate it to a space or - linefeed. -*/ - -static int -get() -{ - int c = theLookahead; - theLookahead = EOF; - if (c == EOF) { - c = getc(stdin); - } - if (c >= ' ' || c == '\n' || c == EOF) { - return c; - } - if (c == '\r') { - return '\n'; - } - return ' '; -} - - -/* peek -- get the next character without getting it. -*/ - -static int -peek() -{ - theLookahead = get(); - return theLookahead; -} - - -/* next -- get the next character, excluding comments. peek() is used to see - if a '/' is followed by a '/' or '*'. -*/ - -static int -next() -{ - int c = get(); - if (c == '/') { - switch (peek()) { - case '/': - for (;;) { - c = get(); - if (c <= '\n') { - return c; - } - } - case '*': - get(); - for (;;) { - switch (get()) { - case '*': - if (peek() == '/') { - get(); - return ' '; - } - break; - case EOF: - fprintf(stderr, "Error: JSMIN Unterminated comment.\n"); - exit(1); - } - } - default: - return c; - } - } - return c; -} - - -/* action -- do something! What you do is determined by the argument: - 1 Output A. Copy B to A. Get the next B. - 2 Copy B to A. Get the next B. (Delete A). - 3 Get the next B. (Delete B). - action treats a string as a single character. Wow! - action recognizes a regular expression if it is preceded by ( or , or =. -*/ - -static void -action(int d) -{ - switch (d) { - case 1: - putc(theA, stdout); - case 2: - theA = theB; - if (theA == '\'' || theA == '"') { - for (;;) { - putc(theA, stdout); - theA = get(); - if (theA == theB) { - break; - } - if (theA == '\\') { - putc(theA, stdout); - theA = get(); - } - if (theA == EOF) { - fprintf(stderr, "Error: JSMIN unterminated string literal."); - exit(1); - } - } - } - case 3: - theB = next(); - if (theB == '/' && (theA == '(' || theA == ',' || theA == '=' || - theA == ':' || theA == '[' || theA == '!' || - theA == '&' || theA == '|' || theA == '?' || - theA == '{' || theA == '}' || theA == ';' || - theA == '\n')) { - putc(theA, stdout); - putc(theB, stdout); - for (;;) { - theA = get(); - if (theA == '/') { - break; - } - if (theA =='\\') { - putc(theA, stdout); - theA = get(); - } - if (theA == EOF) { - fprintf(stderr, -"Error: JSMIN unterminated Regular Expression literal.\n"); - exit(1); - } - putc(theA, stdout); - } - theB = next(); - } - } -} - - -/* jsmin -- Copy the input to the output, deleting the characters which are - insignificant to JavaScript. Comments will be removed. Tabs will be - replaced with spaces. Carriage returns will be replaced with linefeeds. - Most spaces and linefeeds will be removed. -*/ - -static void -jsmin() -{ - theA = '\n'; - action(3); - while (theA != EOF) { - switch (theA) { - case ' ': - if (isAlphanum(theB)) { - action(1); - } else { - action(2); - } - break; - case '\n': - switch (theB) { - case '{': - case '[': - case '(': - case '+': - case '-': - action(1); - break; - case ' ': - action(3); - break; - default: - if (isAlphanum(theB)) { - action(1); - } else { - action(2); - } - } - break; - default: - switch (theB) { - case ' ': - if (isAlphanum(theA)) { - action(1); - break; - } - action(3); - break; - case '\n': - switch (theA) { - case '}': - case ']': - case ')': - case '+': - case '-': - case '"': - case '\'': - action(1); - break; - default: - if (isAlphanum(theA)) { - action(1); - } else { - action(3); - } - } - break; - default: - action(1); - break; - } - } - } -} - - -/* main -- Output any command line arguments as comments - and then minify the input. -*/ -extern int -main(int argc, char* argv[]) -{ - int i; - for (i = 1; i < argc; i += 1) { - fprintf(stdout, "// %s\n", argv[i]); - } - jsmin(); - return 0; -} From 857c9d0863ce76b823d5b1ac0d0b6b13e016cf84 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Jun 2011 16:44:29 -0400 Subject: [PATCH 4/4] Adding in makefile and JS compiler. This solution was hacked together by Dave Humphry, with other modifications made by David Perit --- .gitignore | 2 + Makefile | 137 ++ c3dl-dev/J3DXplorer/index.html | 2 +- c3dl-dev/asteroids3/asteroids.html | 2 +- c3dl-dev/psys_test2/index.html | 2 +- c3dl-dev/tests/aabb/aabbtest.html | 2 +- c3dl-dev/tests/backBearing/index.html | 2 +- c3dl-dev/tests/center/index.html | 2 +- c3dl-dev/tests/collada/index.html | 2 +- c3dl-dev/tests/collada/models/move_widget.dae | 1968 ++++++++--------- c3dl-dev/tests/collision/collision.html | 2 +- c3dl-dev/tests/effects/test1/index.html | 2 +- c3dl-dev/tests/frustum culling/index.html | 2 +- c3dl-dev/tests/lines/lines.html | 2 +- c3dl-dev/tests/points/index.html | 2 +- c3dl-dev/tests/scene pause/scenepause.html | 2 +- c3dl-dev/tests/shapes/shapes.html | 2 +- c3dl-dev/tests/sizeTest/size.html | 2 +- c3dl-dev/tests/speed test/speed.html | 2 +- c3dl-dev/tests/static objects/static.html | 2 +- c3dl-dev/tests/texture/index.html | 2 +- c3dl-dev/tests/update texture/index.html | 2 +- c3dl-dev/tests/velocity/avel.html | 2 +- c3dl-dev/tests/velocity/vel.html | 2 +- c3dl/c3dapi.js | 17 +- c3dl/c3dlnamespace.js | 2 +- c3dl/collada/collada.js | 1 + c3dl/constants.js | 4 +- c3dl/init.js | 19 +- c3dl/math/mjs.js | 6 +- c3dl/particle_system/particlesystem.js | 2 +- c3dl/scene.js | 2 +- c3dl/shapes/cube.js | 2 +- tools/closure/COPYING | 202 ++ tools/closure/compiler.jar | Bin 0 -> 4163155 bytes 35 files changed, 1377 insertions(+), 1029 deletions(-) create mode 100644 Makefile create mode 100644 tools/closure/COPYING create mode 100644 tools/closure/compiler.jar diff --git a/.gitignore b/.gitignore index e43b0f9..be87cf1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .DS_Store +.dist +*~ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c68b332 --- /dev/null +++ b/Makefile @@ -0,0 +1,137 @@ +# NOTES: +# +# Requires: java +# +# make - builds c3dl-DEV-VERSION.js and c3dl-DEV-VERSION.min.js in dist/ +# +# make VERSION=1.2 -builds c3dl-1.2.js and c3dl-1.2.min.js in dist/ +# +# make clean - delete dist/ + +VERSION ?= DEV-VERSION +NULL := +SRC_DIR := . +C3DL := c3dl +C3DL_DIR := $(SRC_DIR)/$(C3DL) +TOOLS_DIR := $(SRC_DIR)/tools +DIST_DIR := $(SRC_DIR)/dist + +C3DL_DIST := $(DIST_DIR)/$(C3DL)-$(VERSION).js +C3DL_MIN := $(DIST_DIR)/$(C3DL)-$(VERSION).min.js + +# Add any c3dl JS files below +JS_SOURCES := $(C3DL_DIR)/c3dlnamespace.js \ + $(C3DL_DIR)/constants.js \ + $(C3DL_DIR)/effects/effect_docs.js \ + $(C3DL_DIR)/debug.js \ + $(C3DL_DIR)/renderer/renderer.js \ + $(C3DL_DIR)/renderer/rendererwebgl.js \ + $(C3DL_DIR)/renderer/programobject.js \ + $(C3DL_DIR)/math/mjs.js \ + $(C3DL_DIR)/math/mathutils.js \ + $(C3DL_DIR)/math/vector.js \ + $(C3DL_DIR)/math/matrix.js \ + $(C3DL_DIR)/math/quaternion.js \ + $(C3DL_DIR)/matrixstack.js \ + $(C3DL_DIR)/camera/camera.js \ + $(C3DL_DIR)/camera/freecamera.js \ + $(C3DL_DIR)/camera/orbitcamera.js \ + $(C3DL_DIR)/enclosure/boundingsphere.js \ + $(C3DL_DIR)/enclosure/boundingvolume.js \ + $(C3DL_DIR)/enclosure/visualboundingsphere.js \ + $(C3DL_DIR)/enclosure/obb.js \ + $(C3DL_DIR)/enclosure/aabb.js \ + $(C3DL_DIR)/actors/actor.js \ + $(C3DL_DIR)/actors/primitive.js \ + $(C3DL_DIR)/actors/point.js \ + $(C3DL_DIR)/actors/line.js \ + $(C3DL_DIR)/shapes/shape.js \ + $(C3DL_DIR)/shapes/cube.js \ + $(C3DL_DIR)/shapes/plane.js \ + $(C3DL_DIR)/shapes/sphere.js \ + $(C3DL_DIR)/shapes/custom.js \ + $(C3DL_DIR)/shapes/customplane.js \ + $(C3DL_DIR)/frustum_culling/frustum.js \ + $(C3DL_DIR)/frustum_culling/plane.js \ + $(C3DL_DIR)/scene.js \ + $(C3DL_DIR)/texture/texture.js \ + $(C3DL_DIR)/texture/texturemanager.js \ + $(C3DL_DIR)/texture/textureutils.js \ + $(C3DL_DIR)/collada/colladamanager.js \ + $(C3DL_DIR)/collada/colladaloader.js \ + $(C3DL_DIR)/collada/colladaqueue.js \ + $(C3DL_DIR)/collada/geometry.js \ + $(C3DL_DIR)/collada/primitiveset.js \ + $(C3DL_DIR)/light/light.js \ + $(C3DL_DIR)/light/positionallight.js \ + $(C3DL_DIR)/light/directionallight.js \ + $(C3DL_DIR)/light/spotlight.js \ + $(C3DL_DIR)/material.js \ + $(C3DL_DIR)/collada/collada.js \ + $(C3DL_DIR)/scenegraph/scenenode.js \ + $(C3DL_DIR)/utilities/utilities.js \ + $(C3DL_DIR)/shaders/model/light/light_vs.js \ + $(C3DL_DIR)/shaders/model/material/material.js \ + $(C3DL_DIR)/shaders/model/standard/model_fs.js \ + $(C3DL_DIR)/shaders/model/standard/model_vs.js \ + $(C3DL_DIR)/shaders/model/standard/std_callback.js \ + $(C3DL_DIR)/shaders/particle_system/psys_vs.js \ + $(C3DL_DIR)/shaders/particle_system/psys_fs.js \ + $(C3DL_DIR)/shaders/point/point/point_vs.js \ + $(C3DL_DIR)/shaders/point/point/point_fs.js \ + $(C3DL_DIR)/shaders/point/sphere/point_sphere_vs.js \ + $(C3DL_DIR)/shaders/point/sphere/point_sphere_fs.js \ + $(C3DL_DIR)/shaders/line/line_vs.js \ + $(C3DL_DIR)/shaders/line/line_fs.js \ + $(C3DL_DIR)/shaders/bounding_sphere/bounding_sphere_vs.js \ + $(C3DL_DIR)/shaders/bounding_sphere/bounding_sphere_fs.js \ + $(C3DL_DIR)/shaders/model/greyscale/greyscale_vs.js \ + $(C3DL_DIR)/shaders/model/greyscale/greyscale_fs.js \ + $(C3DL_DIR)/shaders/model/greyscale/greyscale_callback.js \ + $(C3DL_DIR)/shaders/model/sepia/sepia_vs.js \ + $(C3DL_DIR)/shaders/model/sepia/sepia_fs.js \ + $(C3DL_DIR)/shaders/model/sepia/sepia_callback.js \ + $(C3DL_DIR)/shaders/model/cartoon/cartoon_vs.js \ + $(C3DL_DIR)/shaders/model/cartoon/cartoon_fs.js \ + $(C3DL_DIR)/shaders/model/cartoon/cartoon_callback.js \ + $(C3DL_DIR)/shaders/model/gooch/gooch_vs.js \ + $(C3DL_DIR)/shaders/model/gooch/gooch_fs.js \ + $(C3DL_DIR)/shaders/model/gooch/gooch_callback.js \ + $(C3DL_DIR)/shaders/model/solid_color/solid_color_vs.js \ + $(C3DL_DIR)/shaders/model/solid_color/solid_color_fs.js \ + $(C3DL_DIR)/shaders/model/solid_color/solid_color_callback.js \ + $(C3DL_DIR)/effects/effecttemplate.js \ + $(C3DL_DIR)/effects/effect.js \ + $(C3DL_DIR)/particle_system/particlesystem.js \ + $(C3DL_DIR)/particle_system/particle.js \ + $(C3DL_DIR)/init.js \ + $(C3DL_DIR)/interaction/collision.js \ + $(C3DL_DIR)/interaction/picking.js \ + $(C3DL_DIR)/interaction/pickingresult.js \ + $(NULL) + +CLOSURE := java -jar $(TOOLS_DIR)/closure/compiler.jar + +c3dl: $(DIST_DIR) $(C3DL_DIST) $(C3DL_MIN) + @@echo "Finishied. See $(DIST_DIR)" + +$(DIST_DIR): + @@mkdir -p $(DIST_DIR) + +$(C3DL_DIST): $(DIST_DIR) + @@echo "Building $(C3DL_DIST)" + @@cat $(JS_SOURCES) > $(C3DL_DIST) + +$(C3DL_MIN): $(DIST_DIR) + @@echo "Building $(C3DL_MIN)" + @@$(CLOSURE) $(shell for js in $(JS_SOURCES) ; do echo --js $$js ; done) \ + --compilation_level SIMPLE_OPTIMIZATIONS \ + --js_output_file $(C3DL_MIN) + +advanced: $(DIST_DIR) + @@echo "Building $(C3DL_MIN) with advanced optimizations" + @@$(CLOSURE) $(shell for js in $(JS_SOURCES) ; do echo --js $$js ; done) \ + --compilation_level ADVANCED_OPTIMIZATIONS \ + --js_output_file $(C3DL_MIN) +clean: + @@rm -fr $(DIST_DIR) diff --git a/c3dl-dev/J3DXplorer/index.html b/c3dl-dev/J3DXplorer/index.html index 2a9283b..17c045d 100755 --- a/c3dl-dev/J3DXplorer/index.html +++ b/c3dl-dev/J3DXplorer/index.html @@ -2,7 +2,7 @@ Cavas3D test environment - + diff --git a/c3dl-dev/asteroids3/asteroids.html b/c3dl-dev/asteroids3/asteroids.html index 274b4f2..2898194 100644 --- a/c3dl-dev/asteroids3/asteroids.html +++ b/c3dl-dev/asteroids3/asteroids.html @@ -3,7 +3,7 @@ - + diff --git a/c3dl-dev/psys_test2/index.html b/c3dl-dev/psys_test2/index.html index 8cc731a..c208896 100644 --- a/c3dl-dev/psys_test2/index.html +++ b/c3dl-dev/psys_test2/index.html @@ -2,7 +2,7 @@ C3DL test environment: particle system - + diff --git a/c3dl-dev/tests/aabb/aabbtest.html b/c3dl-dev/tests/aabb/aabbtest.html index 49441b8..0467717 100644 --- a/c3dl-dev/tests/aabb/aabbtest.html +++ b/c3dl-dev/tests/aabb/aabbtest.html @@ -1,7 +1,7 @@ AABB Test - + diff --git a/c3dl-dev/tests/backBearing/index.html b/c3dl-dev/tests/backBearing/index.html index 30173c1..018e26e 100644 --- a/c3dl-dev/tests/backBearing/index.html +++ b/c3dl-dev/tests/backBearing/index.html @@ -5,7 +5,7 @@ C3DL Picking Back-Bearing test - +