<repo_name>lonelydatum/mappingMigration<file_sep>/lib/interaction.js
import Init3d from './init';

var camera = Init3d.camera;

var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;

var targetRotation = 0;
var targetRotationOnMouseDown = 0;

var mouseX = 0;
var mouseXOnMouseDown = 0;

function onTargetRotationChanged(value){

	_signals.onTargetRotation.dispatch(value);
}

function onWindowResize() {

	windowHalfX = window.innerWidth / 2;
	windowHalfY = window.innerHeight / 2;

	camera.aspect = window.innerWidth / window.innerHeight;
	camera.updateProjectionMatrix();

	renderer.setSize( window.innerWidth, window.innerHeight );
};

function onDocumentMouseDown( event ) {

	event.preventDefault();

	document.addEventListener( 'mousemove', onDocumentMouseMove, false );
	document.addEventListener( 'mouseup', onDocumentMouseUp, false );
	document.addEventListener( 'mouseout', onDocumentMouseOut, false );

	mouseXOnMouseDown = event.clientX - windowHalfX;
	targetRotationOnMouseDown = targetRotation;
};

function onDocumentMouseMove( event ) {

	mouseX = event.clientX - windowHalfX;

	targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.02;
	onTargetRotationChanged(targetRotation)
};

function onDocumentMouseUp( event ) {

	document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
	document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
	document.removeEventListener( 'mouseout', onDocumentMouseOut, false );
};

function onDocumentMouseOut( event ) {

	document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
	document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
	document.removeEventListener( 'mouseout', onDocumentMouseOut, false );
};

function onDocumentTouchStart( event ) {

	if ( event.touches.length == 1 ) {

		event.preventDefault();

		mouseXOnMouseDown = event.touches[ 0 ].pageX - windowHalfX;
		targetRotationOnMouseDown = targetRotation;
	}
};

function onDocumentTouchMove( event ) {

	if ( event.touches.length == 1 ) {

		event.preventDefault();

		mouseX = event.touches[ 0 ].pageX - windowHalfX;
		targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.05;
		onTargetRotationChanged(targetRotation);
	}
};



document.addEventListener( 'mousedown', onDocumentMouseDown, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false );
window.addEventListener( 'resize', onWindowResize, false );
var _signals;
export default function(signals){
	_signals = signals;
};

<file_sep>/lib/util/minMaxFamily.js
class MinMaxFamily{
	constructor(){
		this.
	}
}

export default MinMaxFamily;

<file_sep>/README.md
# mappingMigration

Mapping Migration
<file_sep>/config.js
System.config({
  "paths": {
    "*": "*.js",
    "app/*": "lib/*.js",
    "github:*": "jspm_packages/github/*.js",
    "npm:*": "jspm_packages/npm/*.js"
  }
});

System.config({
  "meta": {
    "jspm_packages/github/mrdoob/three.js@master/build/three": {
      "format": "global"
    },
    "jspm_packages/github/greensock/GreenSock-JS@1.15.1/src/minified/TweenLite.min": {
      "format": "global"
    },
    "jspm_packages/github/greensock/GreenSock-JS@1.15.1/src/minified/easing/EasePack.min": {
      "format": "global"
    }
  }
});

System.config({
  "map": {
    "TweenLite": "jspm_packages/github/greensock/GreenSock-JS@1.15.1/src/minified/TweenLite.min",
    "Easing": "jspm_packages/github/greensock/GreenSock-JS@1.15.1/src/minified/easing/EasePack.min",
    "signals": "github:millermedeiros/js-signals@1.0.0",
    "jsonp": "npm:jsonp@0.1.0",
    "stats.js": "github:mrdoob/stats.js@master",
    "three": "jspm_packages/github/mrdoob/three.js@master/build/three",
    "github:jspm/nodelibs-fs@0.1.0": {
      "assert": "npm:assert@1.3.0",
      "fs": "github:jspm/nodelibs-fs@0.1.0"
    },
    "github:jspm/nodelibs-process@0.1.0": {
      "process": "npm:process@0.10.0"
    },
    "github:jspm/nodelibs-tty@0.1.0": {
      "tty-browserify": "npm:tty-browserify@0.0.0"
    },
    "github:jspm/nodelibs-util@0.1.0": {
      "util": "npm:util@0.10.3"
    },
    "npm:assert@1.3.0": {
      "util": "npm:util@0.10.3"
    },
    "npm:debug@2.1.1": {
      "fs": "github:jspm/nodelibs-fs@0.1.0",
      "ms": "npm:ms@0.6.2",
      "net": "github:jspm/nodelibs-net@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.0",
      "tty": "github:jspm/nodelibs-tty@0.1.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:inherits@2.0.1": {
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:jsonp@0.1.0": {
      "debug": "npm:debug@2.1.1"
    },
    "npm:util@0.10.3": {
      "inherits": "npm:inherits@2.0.1",
      "process": "github:jspm/nodelibs-process@0.1.0"
    }
  }
});

<file_sep>/lib/util/minMax.js
class MinMax{

	constructor(){
		this.minX = 999999;
		this.maxX = 0;
		this.minY = 999999;
		this.maxY = 0;
		this.family = [];
	}
	testXY(x,y){
		this.minX = (x<this.minX) ? x : this.minX;
		this.minY = (y<this.minY) ? y : this.minY;
		this.maxX = (x>this.maxX) ? x : this.maxX;
		this.maxY = (y>this.maxY) ? y : this.maxY;
		this.setCenter();
	}
	testFamily(minMax){
		this.family.push(minMax);
		this.family.forEach(item=>{
			this.testXY(item.minX, item.minY);
			this.testXY(item.maxX, item.maxY);
		});


	}
	setCenter(){
		this.width = this.maxX - this.minX;
		this.height = this.maxY - this.minY;
		this.center = {
			x: this.minX + (this.width*.5),
			y: this.minY + (this.height*.5)
		}
	}

}

export default MinMax;

<file_sep>/lib/main.js
import MapController from './map/map_Controller';
import MapView from './map/map_View';
import Interaction from './interaction';
import Init3d from './init';
import Signals from 'signals';
import Asia from './data/asia';







var signals = {
	onTargetRotation: new Signals()
}

signals.onTargetRotation.add(function(d){
	targetRotation = d;
})

Interaction(signals);




var targetRotation = 0;
var targetRotationOnMouseDown = 0;

var renderer = Init3d.renderer;
var scene = Init3d.scene;
var camera = Init3d.camera;


var group = new THREE.Group();
scene.add( group );
group.rotation.x = Math.PI/180 * -60;



var mapController = new MapController();
var mapView = new MapView(group, mapController);


var helper = new THREE.GridHelper( 80, 10 );
helper.rotation.x = Math.PI / 2;
group.add( helper );


var container = document.getElementById("map");
document.body.appendChild( container );
container.appendChild( renderer.domElement );

var obj = {}

var btn = document.getElementById("tester");
btn.addEventListener("click", function(){
	mapController.amountToggle();
}.bind(obj));




function animate() {
	requestAnimationFrame( animate );
	render();
};

function render() {
	group.rotation.z += ( targetRotation - group.rotation.z ) * 0.006;
	renderer.render( scene, camera );
};
animate();


export var main = {};<file_sep>/jspm_packages/github/millermedeiros/js-signals@1.0.0.js
define(["github:millermedeiros/js-signals@1.0.0/dist/signals"], function(main) {
  return main;
});<file_sep>/lib/map/map_Controller.js
import SvgPoints from '../svgPoints';
import MapItem from './mapItem_Controller';
import Signals from 'signals';
import MinMax from '../util/minMax';

var _signals = {
	onAmountChanged: new Signals()

}

class MapController{
	constructor(){
		this.amount = {
			isFuture: null,
			isPast: null,
			active: 0,
			options: ["future", "past"]
		}
		this.list = [];
		this.center = SvgPoints.center;
		this.parseData();
	}

	amountToggle(){
		this.amount.active++;
		if(this.amount.active%2 == 0){
			this.amount.isFuture = true;
			this.amount.isPast = false;
		}else{
			this.amount.isFuture = false;
			this.amount.isPast = true;
		}
		_signals.onAmountChanged.dispatch(this.amount)
	}



	parseData(){
		this.minMax = new MinMax();


		SvgPoints.paths.forEach( (dataItem) => {
			var mapItem = new MapItem(dataItem, _signals);
			this.minMax.testFamily(mapItem.minMax);


			this.list.push(mapItem);
		});




	}
}

export default MapController;

