Index: src/webapp/webclient/js/GnuBoat.js
===================================================================
--- src/webapp/webclient/js/GnuBoat.js	(revision 17bc29b07d38f017c531cc43197dfe284541b3ea)
+++ src/webapp/webclient/js/GnuBoat.js	(revision 9b1c16f7d685d419f59115763707444f5b083872)
@@ -193,17 +193,12 @@
 	});
 	
-	$("#3dchart").empty();
-	var width = $("#3dchart").width();
-	var height = $("#3dchart").height();
+	$("#rendering").empty();
+	var width = $("#rendering").width();
+	var height = $("#rendering").height();
 
 	var fieldOfView = 75;
 	
 	GnuBoat.private.renderScene = new THREE.Scene();
-// 	var aspect = width/height;
-// 	var distance = 1000;
-// 	GnuBoat.private.renderCamera = new THREE.OrthographicCamera(-distance * aspect, distance * aspect, distance, -distance, 0.1, 1000000);
-// 	GnuBoat.private.renderCamera.up = new THREE.Vector3(0, 0, 1);
-// 	GnuBoat.private.renderCamera.position.set(-1, -1, distance);
-// 	GnuBoat.private.renderCamera.lookAt(GnuBoat.private.renderScene.position);
+	GnuBoat.private.renderScene.background = new THREE.Color(0xEEEEEE);
 	
 	GnuBoat.private.renderCamera = new THREE.PerspectiveCamera(75, width/height, 0.1, 1000000);
@@ -214,8 +209,27 @@
 	GnuBoat.private.renderRenderer = new THREE.WebGLRenderer();
 	GnuBoat.private.renderRenderer.setSize(width, height);
-	GnuBoat.private.renderRenderer.setClearColor(0xEEEEEE);
-	document.getElementById("3dchart").appendChild(GnuBoat.private.renderRenderer.domElement);
-
-	GnuBoat.private.animate();
+	GnuBoat.private.renderRenderer.setPixelRatio( window.devicePixelRatio );
+	document.getElementById("rendering").appendChild(GnuBoat.private.renderRenderer.domElement);
+	
+	GnuBoat.private.renderControls = new THREE.OrbitControls( GnuBoat.private.renderCamera, GnuBoat.private.renderRenderer.domElement );
+	GnuBoat.private.renderControls.zoomSpeed = 2;
+	
+	
+	
+	var deep = new THREE.Color(0x347C7C);
+	var shallow = new THREE.Color(0xBCD9D9);
+	var size = 5;
+	GnuBoat.private.renderDepthSteps = 50;
+
+	var deltaR = (Math.max(deep.r, shallow.r) - Math.min(deep.r, shallow.r))/GnuBoat.private.renderDepthSteps;
+	var deltaG = (Math.max(deep.g, shallow.g) - Math.min(deep.g, shallow.g))/GnuBoat.private.renderDepthSteps;
+	var deltaB = (Math.max(deep.b, shallow.b) - Math.min(deep.b, shallow.b))/GnuBoat.private.renderDepthSteps;
+	for(var i = 0; i < GnuBoat.private.renderDepthSteps; i++){
+		var stepColor = new THREE.Color(Math.max(deep.r, shallow.r) - i * deltaR,
+										Math.max(deep.g, shallow.g) - i * deltaG,
+										Math.max(deep.b, shallow.b) - i * deltaB);
+		GnuBoat.private.renderDepthMaterials.push(stepColor);
+	}
+	GnuBoat.private.renderDepthMaterials.push(shallow);
 }
 
@@ -237,4 +251,6 @@
 		GnuBoat.private.timerDisplay = setInterval(GnuBoat.displayDataGet, 10000);
 	GnuBoat.logfilesLoad();	
+	
+	GnuBoat.private.animate();
 }
 
@@ -272,9 +288,10 @@
 	renderCamera: null,
 	renderRenderer: null,
-	renderGeometry: null,
-	renderMaterial: null,
-	renderCube: null,
 	renderMapBounds: null,
 	renderGrid: null,
+	renderControls: null,
+	renderCloud: null,
+	renderDepthMaterials: [],
+	renderDepthSteps: null,
 	
 	openLink: function(target)
@@ -378,5 +395,5 @@
 					}
 				}
-				GnuBoat.private.drawDensityEstimation(densityPoints, maximas["waterdepth"]);
+				GnuBoat.private.drawDensityEstimation(densityPoints, maximas["waterdepth"], minimas["waterdepth"]);
 			}
 		}
@@ -478,5 +495,5 @@
 		var m4 = GnuBoat.private.mercator(GnuBoat.private.mapBounds.getNorth(), GnuBoat.private.mapBounds.getWest());
 		var geometryMapBounds = new THREE.Geometry();
-		var materialMapBounds = new THREE.LineBasicMaterial({color: 0x000000, linewidth: 1});
+		var materialMapBounds = new THREE.LineBasicMaterial({color: 0x66BD66, linewidth: 1});
 		// z is greator 0, to draw the map boundings over the grid
 		var vertex = new THREE.Vector3(0, 0, 2);
@@ -490,22 +507,4 @@
 		GnuBoat.private.renderMapBounds = new THREE.LineLoop(geometryMapBounds, materialMapBounds);
 		GnuBoat.private.renderScene.add(GnuBoat.private.renderMapBounds);
-		
-// 		var geometry = new THREE.Geometry();
-// 		geometry.vertices.push(new THREE.Vector3(0, 0, 4));
-// 		geometry.vertices.push(new THREE.Vector3(1000, 0, 4));
-// 		var line = new THREE.Line(geometry, new THREE.LineBasicMaterial({color: 0xFF0000}));
-// 		GnuBoat.private.renderScene.add(line);
-// 		
-// 		geometry = new THREE.Geometry();
-// 		geometry.vertices.push(new THREE.Vector3(0, 0, 4));
-// 		geometry.vertices.push(new THREE.Vector3(0, 1000, 4));
-// 		line = new THREE.Line(geometry, new THREE.LineBasicMaterial({color: 0x0000FF}));
-// 		GnuBoat.private.renderScene.add(line);
-// 		
-// 		geometry = new THREE.Geometry();
-// 		geometry.vertices.push(new THREE.Vector3(0, 0, 4));
-// 		geometry.vertices.push(new THREE.Vector3(0, 0, 1000));
-// 		line = new THREE.Line(geometry, new THREE.LineBasicMaterial({color: 0x00FF00}));
-// 		GnuBoat.private.renderScene.add(line);
 
 		// add 500m grid
@@ -514,5 +513,5 @@
 		geometryMapBounds.computeBoundingBox();	
 		var maxLength = Math.max(geometryMapBounds.boundingBox.getSize().x, geometryMapBounds.boundingBox.getSize().y);
-		GnuBoat.private.renderGrid = new THREE.GridHelper(maxLength, Math.round(maxLength / 500.0), 0xDDDDDD, 0xDDDDDD);
+		GnuBoat.private.renderGrid = new THREE.GridHelper(maxLength, Math.round(maxLength / 500.0), 0xCCCCCC, 0xCCCCCC);
 		GnuBoat.private.renderGrid.geometry.rotateX( Math.PI / 2 );
 		GnuBoat.private.renderGrid.translateX(maxLength / 2.0);
@@ -520,24 +519,32 @@
 		GnuBoat.private.renderScene.add(GnuBoat.private.renderGrid);
 		
-		var distance = 0.3 * maxLength;
+		var distance = 150;
 		var fieldOfView = 2 * Math.atan(maxLength / (2.0 * distance) ) * 180.0 / Math.PI;
-		GnuBoat.private.renderCamera.position.set(0.1 * maxLength, 0.2 * maxLength, 0.3 * maxLength);
+		GnuBoat.private.renderCamera.position.set(-10, -5, 100);
 		GnuBoat.private.renderCamera.fov = fieldOfView;
+		GnuBoat.private.renderCamera.lookAt(GnuBoat.private.renderScene.position);
+		GnuBoat.private.renderCamera.zoom = 5;
 		GnuBoat.private.renderCamera.updateProjectionMatrix();
 	},
 	
-	drawDensityEstimation: function(densityPoints, maxima)
-	{
-		var material = new THREE.PointsMaterial({color: 0x00CCCC, size: 1});
+	drawDensityEstimation: function(densityPoints, maximum, minimum)
+	{
+		var material = new THREE.PointsMaterial({vertexColors: THREE.VertexColors, size: 5});
 		var geometry = new THREE.Geometry();
 		var mercatorSouthWest = {x: 0, y: 0};
-		if(GnuBoat.private.mapBounds != null){
+		if(GnuBoat.private.mapBounds != null)
 			mercatorSouthWest = GnuBoat.private.mercator(GnuBoat.private.mapBounds.getSouth(), GnuBoat.private.mapBounds.getWest());
-		}
 		
 		for(var i = 0; i < densityPoints.length; i++){
 			var mercator = GnuBoat.private.mercator(densityPoints[i].latitude, densityPoints[i].longitude);
-			var vertex = new THREE.Vector3(mercator.x - mercatorSouthWest.x, mercator.y - mercatorSouthWest.y, (densityPoints[i].depth * -1) + maxima);
+			var vertex = new THREE.Vector3(mercator.x - mercatorSouthWest.x, mercator.y - mercatorSouthWest.y, (densityPoints[i].depth * -1) + maximum);
+			var color = new THREE.Color(0x000000);
+			if(GnuBoat.private.renderDepthSteps != null){
+				var step = Math.floor((densityPoints[i].depth - minimum)/((maximum-minimum)/GnuBoat.private.renderDepthSteps));
+				if(step >= 0 && step < GnuBoat.private.renderDepthMaterials.length)
+					color = GnuBoat.private.renderDepthMaterials[step];
+			}
 			geometry.vertices.push(vertex);
+			geometry.colors.push(color);
 		}
 		// point cloud
@@ -551,15 +558,11 @@
 	{
 		requestAnimationFrame(GnuBoat.private.animate);
-
-// 		if(GnuBoat.private.mapBounds != null){
-// 			GnuBoat.private.camera.position.set(GnuBoat.private.mapBounds.getCenter().lng, GnuBoat.private.mapBounds.getSouth(), 0);
-// 			GnuBoat.private.camera.up = new THREE.Vector3(0, 0, 1);
-// 			GnuBoat.private.camera.lookAt(new THREE.Vector3(GnuBoat.private.mapBounds.getCenter().lng, GnuBoat.private.mapBounds.getCenter().lat, 0));
-// 			GnuBoat.private.camera.zoom = 1;
-// 		}
-		
-// 		var width = $("#3dchart").width();
-// 		var height = $("#3dchart").height();
-// 		GnuBoat.private.renderer.setSize(width, height);
+		if(GnuBoat.private.renderCloud != null){
+			var scaleZ = $("#renderScaleZ").val();
+			if(GnuBoat.private.renderCloud.scale.z != scaleZ)
+				GnuBoat.private.renderCloud.scale.set(1, 1, scaleZ);
+		}
+		
+		GnuBoat.private.renderControls.update();
 		GnuBoat.private.renderRenderer.render(GnuBoat.private.renderScene, GnuBoat.private.renderCamera);
 	},
