aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/utilities.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/utilities.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/utilities.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/utilities.js b/js/helper-classes/RDGE/src/core/script/utilities.js
index ff67868c..3cf43e92 100755
--- a/js/helper-classes/RDGE/src/core/script/utilities.js
+++ b/js/helper-classes/RDGE/src/core/script/utilities.js
@@ -32,13 +32,13 @@ POSSIBILITY OF SUCH DAMAGE.
32var RDGE = RDGE || {}; 32var RDGE = RDGE || {};
33 33
34 34
35/* 35/*
36// Methods not currently used in Ninja 36// Methods not currently used in Ninja
37RDGE.getRandColor = function () { 37RDGE.getRandColor = function () {
38 var r = Math.random(); 38 var r = Math.random();
39 var g = Math.random(); 39 var g = Math.random();
40 var b =Math.random(); 40 var b =Math.random();
41 41
42 return [r, g, b, 1.0]; 42 return [r, g, b, 1.0];
43}; 43};
44 44
@@ -46,7 +46,7 @@ RDGE.unProject = function (winx, winy, winz, modelMatrix, projMatrix, viewport)
46 var inVal = [0,0,0,0]; 46 var inVal = [0,0,0,0];
47 47
48 var finalMatrix = RDGE.mat4.mul(modelMatrix, projMatrix); 48 var finalMatrix = RDGE.mat4.mul(modelMatrix, projMatrix);
49 49
50 finalMatrix = RDGE.mat4.inverse(finalMatrix); 50 finalMatrix = RDGE.mat4.inverse(finalMatrix);
51 if(!finalMatrix) 51 if(!finalMatrix)
52 return null; 52 return null;
@@ -56,24 +56,24 @@ RDGE.unProject = function (winx, winy, winz, modelMatrix, projMatrix, viewport)
56 inVal[2]=winz; 56 inVal[2]=winz;
57 inVal[3]=1.0; 57 inVal[3]=1.0;
58 58
59 // Map x and y from window coordinates 59 // Map x and y from window coordinates
60 inVal[0] = (inVal[0] - viewport[0]) / viewport[2]; 60 inVal[0] = (inVal[0] - viewport[0]) / viewport[2];
61 inVal[1] = (inVal[1] - viewport[1]) / viewport[3]; 61 inVal[1] = (inVal[1] - viewport[1]) / viewport[3];
62 62
63 // Map to range -1 to 1 63 // Map to range -1 to 1
64 inVal[0] = inVal[0] * 2 - 1; 64 inVal[0] = inVal[0] * 2 - 1;
65 inVal[1] = inVal[1] * 2 - 1; 65 inVal[1] = inVal[1] * 2 - 1;
66 inVal[2] = inVal[2] * 2 - 1; 66 inVal[2] = inVal[2] * 2 - 1;
67 67
68 var v4Out = RDGE.mat4.transformPoint(finalMatrix, inVal); 68 var v4Out = RDGE.mat4.transformPoint(finalMatrix, inVal);
69 69
70 if (v4Out[3] <= 0.0001) 70 if (v4Out[3] <= 0.0001)
71 return null; 71 return null;
72 72
73 v4Out[0] /= v4Out[3]; 73 v4Out[0] /= v4Out[3];
74 v4Out[1] /= v4Out[3]; 74 v4Out[1] /= v4Out[3];
75 v4Out[2] /= v4Out[3]; 75 v4Out[2] /= v4Out[3];
76 76
77 return [ v4Out[0], v4Out[1], v4Out[2] ]; 77 return [ v4Out[0], v4Out[1], v4Out[2] ];
78}; 78};
79 79
@@ -87,7 +87,7 @@ RDGE.AABB2LineSegment = function (box, startPoint, endPoint) {
87 87
88 var adx = Math.abs(d[0]); 88 var adx = Math.abs(d[0]);
89 if( Math.abs(m[0]) > e[0] + adx ) return false; 89 if( Math.abs(m[0]) > e[0] + adx ) return false;
90 90
91 var ady = Math.abs(d[1]); 91 var ady = Math.abs(d[1]);
92 if( Math.abs(m[1]) > e[1] + ady ) return false; 92 if( Math.abs(m[1]) > e[1] + ady ) return false;
93 93
@@ -109,7 +109,7 @@ RDGE.hitTest = function (mesh, near, far) {
109 // holds distance to the nearest BV 109 // holds distance to the nearest BV
110 var dist = null; 110 var dist = null;
111 var BV = null; 111 var BV = null;
112 112
113 for (var index = 0; index < mesh.BVL.length; index++) { 113 for (var index = 0; index < mesh.BVL.length; index++) {
114 if (AABB2LineSegment(mesh.BVL[index], near, far)) { 114 if (AABB2LineSegment(mesh.BVL[index], near, far)) {
115 var center = RDGE.vec3.scale(RDGE.vec3.add(mesh.BVL[index].min, mesh.BVL[index].max), 0.5); 115 var center = RDGE.vec3.scale(RDGE.vec3.add(mesh.BVL[index].min, mesh.BVL[index].max), 0.5);
@@ -147,7 +147,7 @@ RDGE.loadShader = function (ctx, shaderType, shaderStr) {
147 var shader = ctx.createShader(shaderType); 147 var shader = ctx.createShader(shaderType);
148 if (shader == null) { 148 if (shader == null) {
149 149
150 ctx.console.log("*** Error: unable to create shader '"+shaderType+"'"); 150 ctx.console.log("*** Error: unable to create shader '"+shaderType+"'");
151 151
152 return null; 152 return null;
153 } 153 }
@@ -236,7 +236,7 @@ RDGE.createShader = function (ctx, strVertShaderName, strFragShaderName, attribs
236 236
237 return null; 237 return null;
238 } 238 }
239 239
240 program.shaderID = "Shader" + RDGE.g_shaderCounter++; 240 program.shaderID = "Shader" + RDGE.g_shaderCounter++;
241 program.vname = strVertShaderName; 241 program.vname = strVertShaderName;
242 program.RDGEUniform = new RDGE.RDGEUniformInit(); 242 program.RDGEUniform = new RDGE.RDGEUniformInit();