Permalink
Browse files

moved the posToScreen functions to utilities.js

  • Loading branch information...
1 parent 7d600f4 commit b4351955c1a500b4960d90acc0c113765545f610 @ivankuzev committed Mar 3, 2012
Showing with 17 additions and 17 deletions.
  1. +13 −1 js/app/Utilities.js
  2. +2 −14 js/app/controlers.webgl.js
  3. +2 −2 js/app/stage.starsystem.js
View
@@ -22,4 +22,16 @@ Function.prototype.inheritsFrom = function( parentClassOrObject ){
this.prototype.parentClass = parentClassOrObject;
}
return this;
-}
+}
+//prepares a matrix for the postoscreen function
+function posToScreenPrepare(camera){
+ var matrix = new THREE.Matrix4();
+ return matrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
+};
+//pos to screen returns a {x,y} value from -1 to 1,
+//0 being the center of the viewport
+function posToScreen(position,matrix) {
+ var pos = position.clone();
+ matrix.multiplyVector3( pos );
+ return pos;
+};
View
@@ -11,8 +11,7 @@
this.FPS = 60,
this.MAX_FRAME_SKIP = 10,
this.SKIP_TICKS = 1000 / this.FPS;
- this.projScreenMat = new THREE.Matrix4();
-
+
this.renderer;
this.projector;
@@ -96,18 +95,7 @@
return intersection;
};
- Webgl.prototype.toScreenPrepare = function(camera){
- this.projScreenMat.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
- };
-
- Webgl.prototype.toScreenXY = function(position) {
- var pos = position.clone();
- this.projScreenMat.multiplyVector3( pos );
- return pos;
-
- };
-
- //pass the event handling to proper stage
+ //pass the event handling to proper stage
Webgl.prototype.onEvent = function(){
var self = this;
return function(event, delta) {
@@ -40,10 +40,10 @@
'mousemove': 'onMouseMove'
};
- var $viewport = this._controller.getViewport();
+ this._$viewport = this._controller.getViewport();
// Initialize camera
- this.camera = new THREE.PerspectiveCamera( 45, $viewport.width() / $viewport.height(), 1, 999999 );
+ this.camera = new THREE.PerspectiveCamera( 45, this._$viewport.width() / this._$viewport.height(), 1, 999999 );
this.cameraLookTarget = new THREE.Vector3(0,0,0);
this.cameraRotations = new THREE.Vector3(45,0,0);

0 comments on commit b435195

Please sign in to comment.