diff --git a/README.txt b/_old/README.txt similarity index 100% rename from README.txt rename to _old/README.txt diff --git a/glUtils.js b/_old/glUtils.js similarity index 99% rename from glUtils.js rename to _old/glUtils.js index 30338f6..2ed4a43 100644 --- a/glUtils.js +++ b/_old/glUtils.js @@ -1,4 +1,4 @@ -// augment Sylvester some +// augment Sylvester some /* Matrix.Translation = function (v) { @@ -63,34 +63,34 @@ Matrix.prototype.ensure4x4 = function() this.elements.push([0, 0, 0, 1]); } - return this; -}; - -Matrix.prototype.inverse3x3 = function() { + return this; +}; + +Matrix.prototype.inverse3x3 = function() { if (this.elements.length != 3 || this.elements[0].length != 3) return null; - - var r = Matrix.Zero(3,3); - var A = this.elements; - var determinant = +A[0][0]*(A[1][1]*A[2][2]-A[2][1]*A[1][2]) - -A[0][1]*(A[1][0]*A[2][2]-A[1][2]*A[2][0]) - +A[0][2]*(A[1][0]*A[2][1]-A[1][1]*A[2][0]); - - if (Math.abs(determinant) < 1e-20) - return null; - var invdet = 1/determinant; - - r.elements[0][0] = (A[1][1] * A[2][2] - A[2][1] * A[1][2]) * invdet; - r.elements[1][0] = -(A[0][1] * A[2][2] - A[0][2] * A[2][1]) * invdet; - r.elements[2][0] = (A[0][1] * A[1][2] - A[0][2] * A[1][1]) * invdet; - r.elements[0][1] = -(A[1][0] * A[2][2] - A[1][2] * A[2][0]) * invdet; - r.elements[1][1] = (A[0][0] * A[2][2] - A[0][2] * A[2][0]) * invdet; - r.elements[2][1] = -(A[0][0] * A[1][2] - A[1][0] * A[0][2]) * invdet; - r.elements[0][2] = (A[1][0] * A[2][1] - A[2][0] * A[1][1]) * invdet; - r.elements[1][2] = -(A[0][0] * A[2][1] - A[2][0] * A[0][1]) * invdet; - r.elements[2][2] = (A[0][0] * A[1][1] - A[1][0] * A[0][1]) * invdet; - - return r.transpose(); + + var r = Matrix.Zero(3,3); + var A = this.elements; + var determinant = +A[0][0]*(A[1][1]*A[2][2]-A[2][1]*A[1][2]) + -A[0][1]*(A[1][0]*A[2][2]-A[1][2]*A[2][0]) + +A[0][2]*(A[1][0]*A[2][1]-A[1][1]*A[2][0]); + + if (Math.abs(determinant) < 1e-20) + return null; + var invdet = 1/determinant; + + r.elements[0][0] = (A[1][1] * A[2][2] - A[2][1] * A[1][2]) * invdet; + r.elements[1][0] = -(A[0][1] * A[2][2] - A[0][2] * A[2][1]) * invdet; + r.elements[2][0] = (A[0][1] * A[1][2] - A[0][2] * A[1][1]) * invdet; + r.elements[0][1] = -(A[1][0] * A[2][2] - A[1][2] * A[2][0]) * invdet; + r.elements[1][1] = (A[0][0] * A[2][2] - A[0][2] * A[2][0]) * invdet; + r.elements[2][1] = -(A[0][0] * A[1][2] - A[1][0] * A[0][2]) * invdet; + r.elements[0][2] = (A[1][0] * A[2][1] - A[2][0] * A[1][1]) * invdet; + r.elements[1][2] = -(A[0][0] * A[2][1] - A[2][0] * A[0][1]) * invdet; + r.elements[2][2] = (A[0][0] * A[1][1] - A[1][0] * A[0][1]) * invdet; + + return r.transpose(); } Matrix.prototype.make3x3 = function() @@ -106,13 +106,13 @@ Matrix.prototype.make3x3 = function() Vector.prototype.flatten = function () { - return this.elements; -}; -/* - -Vector.prototype.lsquare3 = function() -{ - return this.elements[0]*this.elements[0]+this.elements[1]*this.elements[1]+this.elements[2]*this.elements[2]; + return this.elements; +}; +/* + +Vector.prototype.lsquare3 = function() +{ + return this.elements[0]*this.elements[0]+this.elements[1]*this.elements[1]+this.elements[2]*this.elements[2]; } function mht(m) { var s = ""; @@ -156,27 +156,27 @@ function makeLookAt(ex, ey, ez, [0, 1, 0, -ey], [0, 0, 1, -ez], [0, 0, 0, 1]]); - return m.x(t); -} - -function makeLookAtv(eye, center, up) { - var mag; - - var z = eye.subtract(center).toUnitVector(); - var x = up.cross(z).toUnitVector(); - var y = z.cross(x).toUnitVector(); - - var m = $M([[x.e(1), x.e(2), x.e(3), 0], - [y.e(1), y.e(2), y.e(3), 0], - [z.e(1), z.e(2), z.e(3), 0], - [0, 0, 0, 1]]); - - var t = $M([[1, 0, 0, -eye.e(1)], - [0, 1, 0, -eye.e(2)], - [0, 0, 1, -eye.e(3)], - [0, 0, 0, 1]]); - return m.x(t); - //return m; + return m.x(t); +} + +function makeLookAtv(eye, center, up) { + var mag; + + var z = eye.subtract(center).toUnitVector(); + var x = up.cross(z).toUnitVector(); + var y = z.cross(x).toUnitVector(); + + var m = $M([[x.e(1), x.e(2), x.e(3), 0], + [y.e(1), y.e(2), y.e(3), 0], + [z.e(1), z.e(2), z.e(3), 0], + [0, 0, 0, 1]]); + + var t = $M([[1, 0, 0, -eye.e(1)], + [0, 1, 0, -eye.e(2)], + [0, 0, 1, -eye.e(3)], + [0, 0, 0, 1]]); + return m.x(t); + //return m; } // @@ -226,6 +226,6 @@ function makeOrtho(left, right, bottom, top, znear, zfar) [0, 0, -2 / (zfar - znear), tz], [0, 0, 0, 1]]); } - */ - - + */ + + diff --git a/jquery-1.4.2.min.js b/_old/jquery-1.4.2.min.js similarity index 100% rename from jquery-1.4.2.min.js rename to _old/jquery-1.4.2.min.js diff --git a/old_snips.txt b/_old/old_snips.txt similarity index 96% rename from old_snips.txt rename to _old/old_snips.txt index 1e1a38f..d14843a 100644 --- a/old_snips.txt +++ b/_old/old_snips.txt @@ -1,151 +1,151 @@ - /* var request = new XMLHttpRequest(); - request.open("GET", filename); - request.overrideMimeType("application/json"); - request.onreadystatechange = function() { - if (this.readyState == 4) { - var parsed = JSON.parse(this.responseText); - createBuffers(parsed, model); - if (meshdata) - createVectors(parsed, model); - onload(); - } - } - request.send();*/ - ---------------------- - - - // local coord alternates between 1 and 0 in adjacent vertices. - // it is used for the grid texture shader - var localCoord = []; - var onesList = [0], zerosList = []; - while (onesList.length > 0 || zerosList.length > 0) { - while (onesList.length > 0) { - var c = onesList.pop(); - if (c in localCoord) - continue; - localCoord[c] = 1; - var nc = nei[c]; - zerosList = zerosList.concat(Object.keys(nc).slice(0,4)); - } - while (zerosList.length > 0) { - var c = zerosList.pop(); - if (c in localCoord) - continue; - localCoord[c] = 0; - var nc = nei[c]; - onesList = onesList.concat(Object.keys(nc).slice(0,4)); - } - } - model.localCoord = localCoord; - - ------------------------------ - - -function _testDraw(model) -{ - if (!model.vtxBut) - return - - setMatrixUniforms(); - gl.bindBuffer(gl.ARRAY_BUFFER, model.vtxBut); - gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, model.vtxBut.itemSize, gl.FLOAT, false, 0, 0); - gl.vertexAttribPointer(shaderProgram.vertexNormalAttribute, model.vtxBut.itemSize, gl.FLOAT, false, 0, 0); - - // gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, model.idx); - gl.drawElements(gl.TRIANGLE_STRIP, model.idx.numItems, gl.UNSIGNED_SHORT, 0); - - checkGLErrors(); -} - -function _testinitBuffers(model) { - var vertices = [ - 1.0, 0.8, 0.0, - -1.0, 1.0, 0.0, - 1.0, -1.0, 0.0, - -1.0, -1.0, 0.0 - ]; - model.vtxBut = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, model.vtxBut); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - model.vtxBut.itemSize = 3; - model.vtxBut.numItems = 4; - - var indices = [0,1,2,3]; - model.idx = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, model.idx); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW); - model.idx.itemSize = 1; - model.idx.numItems = indices.length; - - checkGLErrors(); - -} - - - - --------------------------- - -function _testDraw(model) -{ - if (!model.squareVertexPositionBuffer) - return - - setMatrixUniforms(); - gl.bindBuffer(gl.ARRAY_BUFFER, model.squareVertexPositionBuffer); - gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, model.squareVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); - gl.vertexAttribPointer(shaderProgram.vertexNormalAttribute, model.squareVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); - - gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); -} - -function _testinitBuffers(model) { - model.squareVertexPositionBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, model.squareVertexPositionBuffer); - var vertices = [ - 1.0, 0.8, 0.0, - -1.0, 1.0, 0.0, - 1.0, -1.0, 0.0, - -1.0, -1.0, 0.0 - ]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); - model.squareVertexPositionBuffer.itemSize = 3; - model.squareVertexPositionBuffer.numItems = 4; -} - ----------------------------- - -function crash() { - buf = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buf); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 16, gl.DYNAMIC_DRAW); - gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, -20, new Uint16Array([1,2,3,4])); -} - ------------------------------ geom mesh with lines - - if (input.lines) { - /* for (var i = 0; i < input.lines.length; i += 2) { - var a = input.lines[i], b = input.lines[i + 1]; - ds = indexDist(model, a, b); - nei[a][b] = ds; nei[b][a] = ds; - distSum += ds; ++distCount; - }*/ - throw Error("not supported"); - } - - ---------------------------- sound lags - -function testAudio() { - var snd = new SoundMixer($("#turnSound1")[0], 5); - var i = 0; - setInterval(function() { - snd.play(1); - clearDebug(); - writeDebug(i++); - }, 200); -} + /* var request = new XMLHttpRequest(); + request.open("GET", filename); + request.overrideMimeType("application/json"); + request.onreadystatechange = function() { + if (this.readyState == 4) { + var parsed = JSON.parse(this.responseText); + createBuffers(parsed, model); + if (meshdata) + createVectors(parsed, model); + onload(); + } + } + request.send();*/ + +--------------------- + + + // local coord alternates between 1 and 0 in adjacent vertices. + // it is used for the grid texture shader + var localCoord = []; + var onesList = [0], zerosList = []; + while (onesList.length > 0 || zerosList.length > 0) { + while (onesList.length > 0) { + var c = onesList.pop(); + if (c in localCoord) + continue; + localCoord[c] = 1; + var nc = nei[c]; + zerosList = zerosList.concat(Object.keys(nc).slice(0,4)); + } + while (zerosList.length > 0) { + var c = zerosList.pop(); + if (c in localCoord) + continue; + localCoord[c] = 0; + var nc = nei[c]; + onesList = onesList.concat(Object.keys(nc).slice(0,4)); + } + } + model.localCoord = localCoord; + + +----------------------------- + + +function _testDraw(model) +{ + if (!model.vtxBut) + return + + setMatrixUniforms(); + gl.bindBuffer(gl.ARRAY_BUFFER, model.vtxBut); + gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, model.vtxBut.itemSize, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(shaderProgram.vertexNormalAttribute, model.vtxBut.itemSize, gl.FLOAT, false, 0, 0); + + // gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, model.idx); + gl.drawElements(gl.TRIANGLE_STRIP, model.idx.numItems, gl.UNSIGNED_SHORT, 0); + + checkGLErrors(); +} + +function _testinitBuffers(model) { + var vertices = [ + 1.0, 0.8, 0.0, + -1.0, 1.0, 0.0, + 1.0, -1.0, 0.0, + -1.0, -1.0, 0.0 + ]; + model.vtxBut = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, model.vtxBut); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + model.vtxBut.itemSize = 3; + model.vtxBut.numItems = 4; + + var indices = [0,1,2,3]; + model.idx = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, model.idx); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW); + model.idx.itemSize = 1; + model.idx.numItems = indices.length; + + checkGLErrors(); + +} + + + + +-------------------------- + +function _testDraw(model) +{ + if (!model.squareVertexPositionBuffer) + return + + setMatrixUniforms(); + gl.bindBuffer(gl.ARRAY_BUFFER, model.squareVertexPositionBuffer); + gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, model.squareVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(shaderProgram.vertexNormalAttribute, model.squareVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); +} + +function _testinitBuffers(model) { + model.squareVertexPositionBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, model.squareVertexPositionBuffer); + var vertices = [ + 1.0, 0.8, 0.0, + -1.0, 1.0, 0.0, + 1.0, -1.0, 0.0, + -1.0, -1.0, 0.0 + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + model.squareVertexPositionBuffer.itemSize = 3; + model.squareVertexPositionBuffer.numItems = 4; +} + +---------------------------- + +function crash() { + buf = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buf); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 16, gl.DYNAMIC_DRAW); + gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, -20, new Uint16Array([1,2,3,4])); +} + +----------------------------- geom mesh with lines + + if (input.lines) { + /* for (var i = 0; i < input.lines.length; i += 2) { + var a = input.lines[i], b = input.lines[i + 1]; + ds = indexDist(model, a, b); + nei[a][b] = ds; nei[b][a] = ds; + distSum += ds; ++distCount; + }*/ + throw Error("not supported"); + } + + +--------------------------- sound lags + +function testAudio() { + var snd = new SoundMixer($("#turnSound1")[0], 5); + var i = 0; + setInterval(function() { + snd.play(1); + clearDebug(); + writeDebug(i++); + }, 200); +} diff --git a/sylvester.js b/_old/sylvester.js similarity index 100% rename from sylvester.js rename to _old/sylvester.js diff --git a/testdbl.html b/_old/testdbl.html similarity index 96% rename from testdbl.html rename to _old/testdbl.html index 41f5557..61abc93 100644 --- a/testdbl.html +++ b/_old/testdbl.html @@ -1,41 +1,41 @@ - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/worker.js b/_old/worker.js similarity index 96% rename from worker.js rename to _old/worker.js index a7d6149..fe7272c 100644 --- a/worker.js +++ b/_old/worker.js @@ -1,24 +1,24 @@ - - -importScripts("glMatrix-0.9.4.min.js", "pUtils.js", "Player.js", "geomProcess.js"); - -if (!self.writeDebug) {// did not include debug.js - self.writeDebug = function() {} - self.enableDebug = function() {} - self.clearDebug = function() {} -} - -onmessage = function(e) { - if (!e || !e.data) - return; - - if (e.data.func) { // func is a string name of the function to call - var output = self[e.data.func](e.data.input, function(pc) { - postMessage( { progress: pc, index: e.data.index } ); - }); - output.index = e.data.index; - postMessage(output); - - } - + + +importScripts("glMatrix-0.9.4.min.js", "pUtils.js", "Player.js", "geomProcess.js"); + +if (!self.writeDebug) {// did not include debug.js + self.writeDebug = function() {} + self.enableDebug = function() {} + self.clearDebug = function() {} +} + +onmessage = function(e) { + if (!e || !e.data) + return; + + if (e.data.func) { // func is a string name of the function to call + var output = self[e.data.func](e.data.input, function(pc) { + postMessage( { progress: pc, index: e.data.index } ); + }); + output.index = e.data.index; + postMessage(output); + + } + } \ No newline at end of file diff --git a/myPage.komodoproject b/myPage.komodoproject new file mode 100644 index 0000000..7599271 --- /dev/null +++ b/myPage.komodoproject @@ -0,0 +1,8 @@ + + + + + 1 + en-US + + diff --git a/.htaccess b/src/.htaccess similarity index 100% rename from .htaccess rename to src/.htaccess diff --git a/about.php b/src/about.php similarity index 100% rename from about.php rename to src/about.php diff --git a/aiControl.js b/src/aiControl.js similarity index 100% rename from aiControl.js rename to src/aiControl.js diff --git a/browserDetect.js b/src/browserDetect.js similarity index 100% rename from browserDetect.js rename to src/browserDetect.js diff --git a/build_number.js b/src/build_number.js similarity index 98% rename from build_number.js rename to src/build_number.js index 5e158e2..0b0040d 100644 --- a/build_number.js +++ b/src/build_number.js @@ -1,2 +1,2 @@ - // this file is created by the build script + // this file is created by the build script var BUILD_NUMBER=152 \ No newline at end of file diff --git a/colorwheel/colorwheel.js b/src/colorwheel/colorwheel.js similarity index 100% rename from colorwheel/colorwheel.js rename to src/colorwheel/colorwheel.js diff --git a/colorwheel/raphael-1.3.1-min.js b/src/colorwheel/raphael-1.3.1-min.js similarity index 100% rename from colorwheel/raphael-1.3.1-min.js rename to src/colorwheel/raphael-1.3.1-min.js diff --git a/colorwheel/raphael-1.5.2-min.js b/src/colorwheel/raphael-1.5.2-min.js similarity index 100% rename from colorwheel/raphael-1.5.2-min.js rename to src/colorwheel/raphael-1.5.2-min.js diff --git a/contact.php b/src/contact.php similarity index 100% rename from contact.php rename to src/contact.php diff --git a/debug.js b/src/debug.js similarity index 100% rename from debug.js rename to src/debug.js diff --git a/favicon.ico b/src/favicon.ico similarity index 100% rename from favicon.ico rename to src/favicon.ico diff --git a/gameControl.js b/src/gameControl.js similarity index 100% rename from gameControl.js rename to src/gameControl.js diff --git a/geomProcess.js b/src/geomProcess.js similarity index 100% rename from geomProcess.js rename to src/geomProcess.js diff --git a/glMatrix-0.9.4.min.js b/src/glMatrix-0.9.4.min.js similarity index 100% rename from glMatrix-0.9.4.min.js rename to src/glMatrix-0.9.4.min.js diff --git a/jquery-1.4.4.min.js b/src/jquery-1.4.4.min.js similarity index 100% rename from jquery-1.4.4.min.js rename to src/jquery-1.4.4.min.js diff --git a/jquery.cookie.js b/src/jquery.cookie.js similarity index 100% rename from jquery.cookie.js rename to src/jquery.cookie.js diff --git a/loadManager.js b/src/loadManager.js similarity index 96% rename from loadManager.js rename to src/loadManager.js index a886460..c5db06c 100644 --- a/loadManager.js +++ b/src/loadManager.js @@ -1,247 +1,247 @@ - - - -// possible resources: world, bike, explode -var resources = { - _ready: false // this is the only property that is not a resource. means that the essential resources are loaded -}; - -var workProgress = { - items: {}, // items that are currently in processing (models) - ondone: null, // called after all items are done - onprogress: null // bool(float) called for progress report. receives [0-1] progress. - // should return true if next action should be async. -}; - -function updateProgress(name, status) { - if (status === null) { - delete workProgress.items[name]; - - if (workProgress.ondone && Object.keys(workProgress.items).length === 0) { - workProgress.onprogress = null; - workProgress.ondone(); - workProgress.ondone = null; - } - return; - } - workProgress.items[name] = status; -} - -function waitAsyncProgress(ondone) { - if (Object.keys(workProgress.items).length === 0) { - ondone(); - return; - } - c2d.loadingScreen(0); - workProgress.ondone = ondone; - - var curPercent = -1; - workProgress.onprogress = function(cp) { - //if (cp >= curPercent + 0.05) { - c2d.loadingScreen(cp); - // curPercent = cp; - //} - return false; // from here on, work will be sync (blocked) because we are in the loading screen. - }; -} - -// do the actual processing of the mesh after it is loaded. -// if async is true, this only start the process -function processWorldModel(loadedName, async) { - updateProgress(loadedName, "processing"); - var rec = resources[loadedName]; - var model = {}; - - var _start = new Date().getTime(); - writeDebug("start " + loadedName); - - createMeshData(rec.input, model); - createGridMeshBuffers(model, async, - function() { // done - rec.model = model; - writeDebug("done " + loadedName + " " + (new Date().getTime() - _start)); - updateProgress(loadedName, null); // may call workProgress.ondone which may lead to startLife - }, - function(pc) { // progress - if (workProgress.onprogress) - return workProgress.onprogress(pc) - return true; // working on the background, do async - } - ); -} - -/* -function processWorldModel2(loadedName, async) { - updateProgress(loadedName, "processing"); - var rec = resources[loadedName]; - var model = {}; - - var _start = new Date().getTime(); - writeDebug("start " + loadedName); - - doWork( {func: "makeWorldSync", input:rec.input}, function(data) { - if (!(data.vertexBuffer instanceof Float32Array)) { // chrome bug doesn't preserve typed arrays - data.vertexBuffer = new Float32Array(data.vertexBuffer); - data.vNormalBuffer = new Float32Array(data.vNormalBuffer); - data.triangles = new Uint16Array(data.triangles); - } - - data.vertexBuffer = GLBuffer.Data(gl.ARRAY_BUFFER, data.vertexBuffer, gl.STATIC_DRAW, 3); - data.vNormalBuffer = GLBuffer.Data(gl.ARRAY_BUFFER, data.vNormalBuffer, gl.STATIC_DRAW, 3); - data.triangles = GLBuffer.Data(gl.ELEMENT_ARRAY_BUFFER, data.triangles, gl.STATIC_DRAW, 1); - - rec.model = data; - writeDebug("done " + loadedName + " " + (new Date().getTime() - _start)); - - updateProgress(loadedName, null); // may call workProgress.ondone which may lead to startLife - }, - workProgress.onprogress - ); - - -}*/ - -//processWorldModel = processWorldModel2; // process with worker thread. Chrome crashes due to copies of data - - -function deleteModel(name) { - if (!resources[name] || !resources[name].model) - return; - writeDebug("deleting " + name); - delete resources[name].model; -} - - -function loadedWorld(loadedName, item, args) { - - var model = { input: item, name: loadedName }; // onload- the hook that starts the level when it is loaded. see startLife() - resources[loadedName] = model; // clean up item - - if (args.gridProc) { - processWorldModel(loadedName, args.async); // loading it now async - } - else { - updateProgress(loadedName, null); // not loading it now - } - -} - - -// -function loadLevelWorld(lvl, gridProc, async) { - if (!levels[lvl]) - return; - - var name = levels[lvl].worldModel; - - if (resources[name] === undefined || resources[name].input === undefined) { // not loaded and not processed - loadModel(worldModels[name].file, "none", name, loadedWorld, { gridProc:gridProc, async:async }); - return; - } - if (resources[name].model === undefined && gridProc) { // loaded but not processed - processWorldModel(name, async); - } -} - -function ensureLevelLoaded(lvlNum, howMany, ondone) { - var level = levels[lvlNum]; - if (level === undefined) - throw new Error("level not found"); - if (resources[level.worldModel] !== undefined && resources[level.worldModel].model !== undefined) { - if (ondone) - ondone(); - return; - } - - var async = true; - - // delete everything. we don't want to take too much memory. keep the input though - for(var i = 0; i < lvlNum; ++i) - deleteModel(levels[i].worldModel); - for(var i = lvlNum + howMany; i < levels.length; ++i) - deleteModel(levels[i].worldModel); - - // queue the loading, when the data arrive, do sync processing that is faster - for(var i = 0; i < howMany; ++i) { - loadLevelWorld(lvlNum + i, true, async); - } - - if (ondone) - waitAsyncProgress(ondone); -} - - -function loadedResource(loadedName, item) { - resources[loadedName] = item; - updateProgress(loadedName, null); - // all resources needed to start game are ready. - if (resources.life && resources.bike) - { - resources._ready = true; - - checkGLErrors("rcsinit"); - } -} - -// world meshes enter the loaded items registry as raw data -// other models enter the registry with their buffers -function loadModel(filename, method, name, onload, args) { - updateProgress(name, "loading"); - - var ret = $.getJSON(filename, {}, function(data) { - - if (method === "indexed") { - var model = {}; - createMeshBuffersIndexed(data, model); - onload(name, model, args); - } - else if (method === "inlined") { - var model = {}; - createMeshBuffersInlined(data, model); - onload(name, model, args); - } - else if (method === "none") { - onload(name, data, args); - } - else - throw "unknown load method"; - }); -} - - -/* -var procworker = null; - - -function doWork(runObj, ondone, onprogress) -{ - runObj.index = procworker.index; - procworker.waiting[procworker.index] = { ondone:ondone, onprogress:onprogress }; - ++procworker.index; - procworker.postMessage(runObj); -} - -function startWorker() -{ - procworker = new Worker("worker.js"); - procworker.onmessage = function(e) { - var data = e.data; - if (data.progress) { // it's a progress message - var waiter = procworker.waiting[data.index]; - if (waiter.onprogress) - waiter.onprogress(data.progress); - return; - } - writeDebug('Worker output'); - var waiter = procworker.waiting[data.index]; - delete procworker.waiting[data.index]; - if (waiter.ondone) - waiter.ondone(data); - }; - procworker.waiting = []; - procworker.index = 1; - - // procworker.postMessage(); // start the worker -} -*/ - + + + +// possible resources: world, bike, explode +var resources = { + _ready: false // this is the only property that is not a resource. means that the essential resources are loaded +}; + +var workProgress = { + items: {}, // items that are currently in processing (models) + ondone: null, // called after all items are done + onprogress: null // bool(float) called for progress report. receives [0-1] progress. + // should return true if next action should be async. +}; + +function updateProgress(name, status) { + if (status === null) { + delete workProgress.items[name]; + + if (workProgress.ondone && Object.keys(workProgress.items).length === 0) { + workProgress.onprogress = null; + workProgress.ondone(); + workProgress.ondone = null; + } + return; + } + workProgress.items[name] = status; +} + +function waitAsyncProgress(ondone) { + if (Object.keys(workProgress.items).length === 0) { + ondone(); + return; + } + c2d.loadingScreen(0); + workProgress.ondone = ondone; + + var curPercent = -1; + workProgress.onprogress = function(cp) { + //if (cp >= curPercent + 0.05) { + c2d.loadingScreen(cp); + // curPercent = cp; + //} + return false; // from here on, work will be sync (blocked) because we are in the loading screen. + }; +} + +// do the actual processing of the mesh after it is loaded. +// if async is true, this only start the process +function processWorldModel(loadedName, async) { + updateProgress(loadedName, "processing"); + var rec = resources[loadedName]; + var model = {}; + + var _start = new Date().getTime(); + writeDebug("start " + loadedName); + + createMeshData(rec.input, model); + createGridMeshBuffers(model, async, + function() { // done + rec.model = model; + writeDebug("done " + loadedName + " " + (new Date().getTime() - _start)); + updateProgress(loadedName, null); // may call workProgress.ondone which may lead to startLife + }, + function(pc) { // progress + if (workProgress.onprogress) + return workProgress.onprogress(pc) + return true; // working on the background, do async + } + ); +} + +/* +function processWorldModel2(loadedName, async) { + updateProgress(loadedName, "processing"); + var rec = resources[loadedName]; + var model = {}; + + var _start = new Date().getTime(); + writeDebug("start " + loadedName); + + doWork( {func: "makeWorldSync", input:rec.input}, function(data) { + if (!(data.vertexBuffer instanceof Float32Array)) { // chrome bug doesn't preserve typed arrays + data.vertexBuffer = new Float32Array(data.vertexBuffer); + data.vNormalBuffer = new Float32Array(data.vNormalBuffer); + data.triangles = new Uint16Array(data.triangles); + } + + data.vertexBuffer = GLBuffer.Data(gl.ARRAY_BUFFER, data.vertexBuffer, gl.STATIC_DRAW, 3); + data.vNormalBuffer = GLBuffer.Data(gl.ARRAY_BUFFER, data.vNormalBuffer, gl.STATIC_DRAW, 3); + data.triangles = GLBuffer.Data(gl.ELEMENT_ARRAY_BUFFER, data.triangles, gl.STATIC_DRAW, 1); + + rec.model = data; + writeDebug("done " + loadedName + " " + (new Date().getTime() - _start)); + + updateProgress(loadedName, null); // may call workProgress.ondone which may lead to startLife + }, + workProgress.onprogress + ); + + +}*/ + +//processWorldModel = processWorldModel2; // process with worker thread. Chrome crashes due to copies of data + + +function deleteModel(name) { + if (!resources[name] || !resources[name].model) + return; + writeDebug("deleting " + name); + delete resources[name].model; +} + + +function loadedWorld(loadedName, item, args) { + + var model = { input: item, name: loadedName }; // onload- the hook that starts the level when it is loaded. see startLife() + resources[loadedName] = model; // clean up item + + if (args.gridProc) { + processWorldModel(loadedName, args.async); // loading it now async + } + else { + updateProgress(loadedName, null); // not loading it now + } + +} + + +// +function loadLevelWorld(lvl, gridProc, async) { + if (!levels[lvl]) + return; + + var name = levels[lvl].worldModel; + + if (resources[name] === undefined || resources[name].input === undefined) { // not loaded and not processed + loadModel(worldModels[name].file, "none", name, loadedWorld, { gridProc:gridProc, async:async }); + return; + } + if (resources[name].model === undefined && gridProc) { // loaded but not processed + processWorldModel(name, async); + } +} + +function ensureLevelLoaded(lvlNum, howMany, ondone) { + var level = levels[lvlNum]; + if (level === undefined) + throw new Error("level not found"); + if (resources[level.worldModel] !== undefined && resources[level.worldModel].model !== undefined) { + if (ondone) + ondone(); + return; + } + + var async = true; + + // delete everything. we don't want to take too much memory. keep the input though + for(var i = 0; i < lvlNum; ++i) + deleteModel(levels[i].worldModel); + for(var i = lvlNum + howMany; i < levels.length; ++i) + deleteModel(levels[i].worldModel); + + // queue the loading, when the data arrive, do sync processing that is faster + for(var i = 0; i < howMany; ++i) { + loadLevelWorld(lvlNum + i, true, async); + } + + if (ondone) + waitAsyncProgress(ondone); +} + + +function loadedResource(loadedName, item) { + resources[loadedName] = item; + updateProgress(loadedName, null); + // all resources needed to start game are ready. + if (resources.life && resources.bike) + { + resources._ready = true; + + checkGLErrors("rcsinit"); + } +} + +// world meshes enter the loaded items registry as raw data +// other models enter the registry with their buffers +function loadModel(filename, method, name, onload, args) { + updateProgress(name, "loading"); + + var ret = $.getJSON(filename, {}, function(data) { + + if (method === "indexed") { + var model = {}; + createMeshBuffersIndexed(data, model); + onload(name, model, args); + } + else if (method === "inlined") { + var model = {}; + createMeshBuffersInlined(data, model); + onload(name, model, args); + } + else if (method === "none") { + onload(name, data, args); + } + else + throw "unknown load method"; + }); +} + + +/* +var procworker = null; + + +function doWork(runObj, ondone, onprogress) +{ + runObj.index = procworker.index; + procworker.waiting[procworker.index] = { ondone:ondone, onprogress:onprogress }; + ++procworker.index; + procworker.postMessage(runObj); +} + +function startWorker() +{ + procworker = new Worker("worker.js"); + procworker.onmessage = function(e) { + var data = e.data; + if (data.progress) { // it's a progress message + var waiter = procworker.waiting[data.index]; + if (waiter.onprogress) + waiter.onprogress(data.progress); + return; + } + writeDebug('Worker output'); + var waiter = procworker.waiting[data.index]; + delete procworker.waiting[data.index]; + if (waiter.ondone) + waiter.ondone(data); + }; + procworker.waiting = []; + procworker.index = 1; + + // procworker.postMessage(); // start the worker +} +*/ + diff --git a/main.js b/src/main.js similarity index 100% rename from main.js rename to src/main.js diff --git a/pUtils.js b/src/pUtils.js similarity index 100% rename from pUtils.js rename to src/pUtils.js diff --git a/src/pack_footer.js b/src/pack_footer.js new file mode 100644 index 0000000..ef9519d --- /dev/null +++ b/src/pack_footer.js @@ -0,0 +1,2 @@ +return { webGLStart: webGLStart}; +}()); \ No newline at end of file diff --git a/src/pack_header.js b/src/pack_header.js new file mode 100644 index 0000000..c3e1c04 --- /dev/null +++ b/src/pack_header.js @@ -0,0 +1 @@ +var cb = (function () { \ No newline at end of file diff --git a/page.css b/src/page.css similarity index 100% rename from page.css rename to src/page.css diff --git a/page.html b/src/page.html similarity index 100% rename from page.html rename to src/page.html diff --git a/player.js b/src/player.js similarity index 100% rename from player.js rename to src/player.js diff --git a/release.html b/src/release.html similarity index 98% rename from release.html rename to src/release.html index 0021672..acad0bf 100644 --- a/release.html +++ b/src/release.html @@ -1,62 +1,62 @@ - - -Cycleblob - A WebGL lightcycle game - - - - - - - - - - - - - -
- - - -
-
- Feedback   About -     - -
- - - - - - - - - - - - - - - - - - - + + +Cycleblob - A WebGL lightcycle game + + + + + + + + + + + + + +
+ + + +
+
+ Feedback   About +     + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/screens2d.js b/src/screens2d.js similarity index 100% rename from screens2d.js rename to src/screens2d.js diff --git a/sfx.js b/src/sfx.js similarity index 100% rename from sfx.js rename to src/sfx.js diff --git a/shaders.html b/src/shaders.html similarity index 100% rename from shaders.html rename to src/shaders.html diff --git a/shaders.js b/src/shaders.js similarity index 100% rename from shaders.js rename to src/shaders.js diff --git a/sprintf-0.6.js b/src/sprintf-0.6.js similarity index 100% rename from sprintf-0.6.js rename to src/sprintf-0.6.js diff --git a/transform.js b/src/transform.js similarity index 100% rename from transform.js rename to src/transform.js diff --git a/ui/jquery.ui.core.min.js b/src/ui/jquery.ui.core.min.js similarity index 100% rename from ui/jquery.ui.core.min.js rename to src/ui/jquery.ui.core.min.js diff --git a/ui/jquery.ui.mouse.min.js b/src/ui/jquery.ui.mouse.min.js similarity index 100% rename from ui/jquery.ui.mouse.min.js rename to src/ui/jquery.ui.mouse.min.js diff --git a/ui/jquery.ui.slider.min.js b/src/ui/jquery.ui.slider.min.js similarity index 100% rename from ui/jquery.ui.slider.min.js rename to src/ui/jquery.ui.slider.min.js diff --git a/ui/jquery.ui.widget.min.js b/src/ui/jquery.ui.widget.min.js similarity index 100% rename from ui/jquery.ui.widget.min.js rename to src/ui/jquery.ui.widget.min.js diff --git a/ui/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png b/src/ui/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png similarity index 100% rename from ui/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png rename to src/ui/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png diff --git a/ui/themes/base/images/ui-bg_flat_75_ffffff_40x100.png b/src/ui/themes/base/images/ui-bg_flat_75_ffffff_40x100.png similarity index 100% rename from ui/themes/base/images/ui-bg_flat_75_ffffff_40x100.png rename to src/ui/themes/base/images/ui-bg_flat_75_ffffff_40x100.png diff --git a/ui/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png b/src/ui/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png similarity index 100% rename from ui/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png rename to src/ui/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png diff --git a/ui/themes/base/images/ui-bg_glass_65_ffffff_1x400.png b/src/ui/themes/base/images/ui-bg_glass_65_ffffff_1x400.png similarity index 100% rename from ui/themes/base/images/ui-bg_glass_65_ffffff_1x400.png rename to src/ui/themes/base/images/ui-bg_glass_65_ffffff_1x400.png diff --git a/ui/themes/base/images/ui-bg_glass_75_dadada_1x400.png b/src/ui/themes/base/images/ui-bg_glass_75_dadada_1x400.png similarity index 100% rename from ui/themes/base/images/ui-bg_glass_75_dadada_1x400.png rename to src/ui/themes/base/images/ui-bg_glass_75_dadada_1x400.png diff --git a/ui/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png b/src/ui/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png similarity index 100% rename from ui/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png rename to src/ui/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png diff --git a/ui/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png b/src/ui/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png similarity index 100% rename from ui/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png rename to src/ui/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png diff --git a/ui/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/src/ui/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png similarity index 100% rename from ui/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png rename to src/ui/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png diff --git a/ui/themes/base/images/ui-icons_222222_256x240.png b/src/ui/themes/base/images/ui-icons_222222_256x240.png similarity index 100% rename from ui/themes/base/images/ui-icons_222222_256x240.png rename to src/ui/themes/base/images/ui-icons_222222_256x240.png diff --git a/ui/themes/base/images/ui-icons_2e83ff_256x240.png b/src/ui/themes/base/images/ui-icons_2e83ff_256x240.png similarity index 100% rename from ui/themes/base/images/ui-icons_2e83ff_256x240.png rename to src/ui/themes/base/images/ui-icons_2e83ff_256x240.png diff --git a/ui/themes/base/images/ui-icons_454545_256x240.png b/src/ui/themes/base/images/ui-icons_454545_256x240.png similarity index 100% rename from ui/themes/base/images/ui-icons_454545_256x240.png rename to src/ui/themes/base/images/ui-icons_454545_256x240.png diff --git a/ui/themes/base/images/ui-icons_888888_256x240.png b/src/ui/themes/base/images/ui-icons_888888_256x240.png similarity index 100% rename from ui/themes/base/images/ui-icons_888888_256x240.png rename to src/ui/themes/base/images/ui-icons_888888_256x240.png diff --git a/ui/themes/base/images/ui-icons_cd0a0a_256x240.png b/src/ui/themes/base/images/ui-icons_cd0a0a_256x240.png similarity index 100% rename from ui/themes/base/images/ui-icons_cd0a0a_256x240.png rename to src/ui/themes/base/images/ui-icons_cd0a0a_256x240.png diff --git a/ui/themes/base/jquery.ui.accordion.css b/src/ui/themes/base/jquery.ui.accordion.css similarity index 100% rename from ui/themes/base/jquery.ui.accordion.css rename to src/ui/themes/base/jquery.ui.accordion.css diff --git a/ui/themes/base/jquery.ui.all.css b/src/ui/themes/base/jquery.ui.all.css similarity index 100% rename from ui/themes/base/jquery.ui.all.css rename to src/ui/themes/base/jquery.ui.all.css diff --git a/ui/themes/base/jquery.ui.autocomplete.css b/src/ui/themes/base/jquery.ui.autocomplete.css similarity index 100% rename from ui/themes/base/jquery.ui.autocomplete.css rename to src/ui/themes/base/jquery.ui.autocomplete.css diff --git a/ui/themes/base/jquery.ui.base.css b/src/ui/themes/base/jquery.ui.base.css similarity index 100% rename from ui/themes/base/jquery.ui.base.css rename to src/ui/themes/base/jquery.ui.base.css diff --git a/ui/themes/base/jquery.ui.button.css b/src/ui/themes/base/jquery.ui.button.css similarity index 100% rename from ui/themes/base/jquery.ui.button.css rename to src/ui/themes/base/jquery.ui.button.css diff --git a/ui/themes/base/jquery.ui.core.css b/src/ui/themes/base/jquery.ui.core.css similarity index 100% rename from ui/themes/base/jquery.ui.core.css rename to src/ui/themes/base/jquery.ui.core.css diff --git a/ui/themes/base/jquery.ui.datepicker.css b/src/ui/themes/base/jquery.ui.datepicker.css similarity index 100% rename from ui/themes/base/jquery.ui.datepicker.css rename to src/ui/themes/base/jquery.ui.datepicker.css diff --git a/ui/themes/base/jquery.ui.dialog.css b/src/ui/themes/base/jquery.ui.dialog.css similarity index 100% rename from ui/themes/base/jquery.ui.dialog.css rename to src/ui/themes/base/jquery.ui.dialog.css diff --git a/ui/themes/base/jquery.ui.progressbar.css b/src/ui/themes/base/jquery.ui.progressbar.css similarity index 100% rename from ui/themes/base/jquery.ui.progressbar.css rename to src/ui/themes/base/jquery.ui.progressbar.css diff --git a/ui/themes/base/jquery.ui.resizable.css b/src/ui/themes/base/jquery.ui.resizable.css similarity index 100% rename from ui/themes/base/jquery.ui.resizable.css rename to src/ui/themes/base/jquery.ui.resizable.css diff --git a/ui/themes/base/jquery.ui.selectable.css b/src/ui/themes/base/jquery.ui.selectable.css similarity index 100% rename from ui/themes/base/jquery.ui.selectable.css rename to src/ui/themes/base/jquery.ui.selectable.css diff --git a/ui/themes/base/jquery.ui.slider.css b/src/ui/themes/base/jquery.ui.slider.css similarity index 100% rename from ui/themes/base/jquery.ui.slider.css rename to src/ui/themes/base/jquery.ui.slider.css diff --git a/ui/themes/base/jquery.ui.tabs.css b/src/ui/themes/base/jquery.ui.tabs.css similarity index 100% rename from ui/themes/base/jquery.ui.tabs.css rename to src/ui/themes/base/jquery.ui.tabs.css diff --git a/ui/themes/base/jquery.ui.theme.css b/src/ui/themes/base/jquery.ui.theme.css similarity index 100% rename from ui/themes/base/jquery.ui.theme.css rename to src/ui/themes/base/jquery.ui.theme.css diff --git a/userInput.js b/src/userInput.js similarity index 100% rename from userInput.js rename to src/userInput.js diff --git a/viewPoint.js b/src/viewPoint.js similarity index 100% rename from viewPoint.js rename to src/viewPoint.js diff --git a/webgl-utils.js b/src/webgl-utils.js similarity index 100% rename from webgl-utils.js rename to src/webgl-utils.js