diff options
Diffstat (limited to 'public/assets')
| -rw-r--r-- | public/assets/javascripts/rectangles/engine/scenery/_scenery.js | 2 | ||||
| -rw-r--r-- | public/assets/javascripts/rectangles/models/vec3.js | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js index 867bb6f..9e9e2bf 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js +++ b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js @@ -20,7 +20,7 @@ var Scenery = new function(){ var loader = new Loader(function(){ base.load(loader.images) }) - loader.preloadImages(urls) + // loader.preloadImages(urls) } base.load = function(images){ diff --git a/public/assets/javascripts/rectangles/models/vec3.js b/public/assets/javascripts/rectangles/models/vec3.js index 4e9f3cb..4e00b0c 100644 --- a/public/assets/javascripts/rectangles/models/vec3.js +++ b/public/assets/javascripts/rectangles/models/vec3.js @@ -3,3 +3,29 @@ function vec3(a,b,c){ this.b = b this.c = c } +vec3.prototype.add = function(v){ + this.a += v.a + this.b += v.b + this.c += v.c + return this +} +vec3.prototype.sub = function(v){ + this.a -= v.a + this.b -= v.b + this.c -= v.c + return this +} + +// input: mat4 projection matrix +vec3.prototype.apply_projection = function (m) { + var x = this.a, y = this.b, z = this.c; + + var e = m.elements; + var d = 1 / ( e[3] * x + e[7] * y + e[11] * z + e[15] ); // perspective divide + + this.x = ( e[0] * x + e[4] * y + e[8] * z + e[12] ) * d; + this.y = ( e[1] * x + e[5] * y + e[9] * z + e[13] ) * d; + this.z = ( e[2] * x + e[6] * y + e[10] * z + e[14] ) * d; + + return this; +} |
