Changeset 9b1c16f for src/webapp/webclient/js
- Timestamp:
- Aug 24, 2017, 5:50:45 PM (9 years ago)
- Branches:
- 0.5, debian/bullseye, debian/jessie, master
- Children:
- 172e90d, 68030fa, dffb538
- Parents:
- 17bc29b
- git-author:
- Joachim Langenbach <joachim.langenbach@…> (08/24/17 17:44:38)
- git-committer:
- Joachim Langenbach <joachim.langenbach@…> (08/24/17 17:50:45)
- File:
-
- 1 edited
-
src/webapp/webclient/js/GnuBoat.js (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/webapp/webclient/js/GnuBoat.js
r17bc29b r9b1c16f 193 193 }); 194 194 195 $("# 3dchart").empty();196 var width = $("# 3dchart").width();197 var height = $("# 3dchart").height();195 $("#rendering").empty(); 196 var width = $("#rendering").width(); 197 var height = $("#rendering").height(); 198 198 199 199 var fieldOfView = 75; 200 200 201 201 GnuBoat.private.renderScene = new THREE.Scene(); 202 // var aspect = width/height; 203 // var distance = 1000; 204 // GnuBoat.private.renderCamera = new THREE.OrthographicCamera(-distance * aspect, distance * aspect, distance, -distance, 0.1, 1000000); 205 // GnuBoat.private.renderCamera.up = new THREE.Vector3(0, 0, 1); 206 // GnuBoat.private.renderCamera.position.set(-1, -1, distance); 207 // GnuBoat.private.renderCamera.lookAt(GnuBoat.private.renderScene.position); 202 GnuBoat.private.renderScene.background = new THREE.Color(0xEEEEEE); 208 203 209 204 GnuBoat.private.renderCamera = new THREE.PerspectiveCamera(75, width/height, 0.1, 1000000); … … 214 209 GnuBoat.private.renderRenderer = new THREE.WebGLRenderer(); 215 210 GnuBoat.private.renderRenderer.setSize(width, height); 216 GnuBoat.private.renderRenderer.setClearColor(0xEEEEEE); 217 document.getElementById("3dchart").appendChild(GnuBoat.private.renderRenderer.domElement); 218 219 GnuBoat.private.animate(); 211 GnuBoat.private.renderRenderer.setPixelRatio( window.devicePixelRatio ); 212 document.getElementById("rendering").appendChild(GnuBoat.private.renderRenderer.domElement); 213 214 GnuBoat.private.renderControls = new THREE.OrbitControls( GnuBoat.private.renderCamera, GnuBoat.private.renderRenderer.domElement ); 215 GnuBoat.private.renderControls.zoomSpeed = 2; 216 217 218 219 var deep = new THREE.Color(0x347C7C); 220 var shallow = new THREE.Color(0xBCD9D9); 221 var size = 5; 222 GnuBoat.private.renderDepthSteps = 50; 223 224 var deltaR = (Math.max(deep.r, shallow.r) - Math.min(deep.r, shallow.r))/GnuBoat.private.renderDepthSteps; 225 var deltaG = (Math.max(deep.g, shallow.g) - Math.min(deep.g, shallow.g))/GnuBoat.private.renderDepthSteps; 226 var deltaB = (Math.max(deep.b, shallow.b) - Math.min(deep.b, shallow.b))/GnuBoat.private.renderDepthSteps; 227 for(var i = 0; i < GnuBoat.private.renderDepthSteps; i++){ 228 var stepColor = new THREE.Color(Math.max(deep.r, shallow.r) - i * deltaR, 229 Math.max(deep.g, shallow.g) - i * deltaG, 230 Math.max(deep.b, shallow.b) - i * deltaB); 231 GnuBoat.private.renderDepthMaterials.push(stepColor); 232 } 233 GnuBoat.private.renderDepthMaterials.push(shallow); 220 234 } 221 235 … … 237 251 GnuBoat.private.timerDisplay = setInterval(GnuBoat.displayDataGet, 10000); 238 252 GnuBoat.logfilesLoad(); 253 254 GnuBoat.private.animate(); 239 255 } 240 256 … … 272 288 renderCamera: null, 273 289 renderRenderer: null, 274 renderGeometry: null,275 renderMaterial: null,276 renderCube: null,277 290 renderMapBounds: null, 278 291 renderGrid: null, 292 renderControls: null, 293 renderCloud: null, 294 renderDepthMaterials: [], 295 renderDepthSteps: null, 279 296 280 297 openLink: function(target) … … 378 395 } 379 396 } 380 GnuBoat.private.drawDensityEstimation(densityPoints, maximas["waterdepth"] );397 GnuBoat.private.drawDensityEstimation(densityPoints, maximas["waterdepth"], minimas["waterdepth"]); 381 398 } 382 399 } … … 478 495 var m4 = GnuBoat.private.mercator(GnuBoat.private.mapBounds.getNorth(), GnuBoat.private.mapBounds.getWest()); 479 496 var geometryMapBounds = new THREE.Geometry(); 480 var materialMapBounds = new THREE.LineBasicMaterial({color: 0x 000000, linewidth: 1});497 var materialMapBounds = new THREE.LineBasicMaterial({color: 0x66BD66, linewidth: 1}); 481 498 // z is greator 0, to draw the map boundings over the grid 482 499 var vertex = new THREE.Vector3(0, 0, 2); … … 490 507 GnuBoat.private.renderMapBounds = new THREE.LineLoop(geometryMapBounds, materialMapBounds); 491 508 GnuBoat.private.renderScene.add(GnuBoat.private.renderMapBounds); 492 493 // var geometry = new THREE.Geometry();494 // geometry.vertices.push(new THREE.Vector3(0, 0, 4));495 // geometry.vertices.push(new THREE.Vector3(1000, 0, 4));496 // var line = new THREE.Line(geometry, new THREE.LineBasicMaterial({color: 0xFF0000}));497 // GnuBoat.private.renderScene.add(line);498 //499 // geometry = new THREE.Geometry();500 // geometry.vertices.push(new THREE.Vector3(0, 0, 4));501 // geometry.vertices.push(new THREE.Vector3(0, 1000, 4));502 // line = new THREE.Line(geometry, new THREE.LineBasicMaterial({color: 0x0000FF}));503 // GnuBoat.private.renderScene.add(line);504 //505 // geometry = new THREE.Geometry();506 // geometry.vertices.push(new THREE.Vector3(0, 0, 4));507 // geometry.vertices.push(new THREE.Vector3(0, 0, 1000));508 // line = new THREE.Line(geometry, new THREE.LineBasicMaterial({color: 0x00FF00}));509 // GnuBoat.private.renderScene.add(line);510 509 511 510 // add 500m grid … … 514 513 geometryMapBounds.computeBoundingBox(); 515 514 var maxLength = Math.max(geometryMapBounds.boundingBox.getSize().x, geometryMapBounds.boundingBox.getSize().y); 516 GnuBoat.private.renderGrid = new THREE.GridHelper(maxLength, Math.round(maxLength / 500.0), 0x DDDDDD, 0xDDDDDD);515 GnuBoat.private.renderGrid = new THREE.GridHelper(maxLength, Math.round(maxLength / 500.0), 0xCCCCCC, 0xCCCCCC); 517 516 GnuBoat.private.renderGrid.geometry.rotateX( Math.PI / 2 ); 518 517 GnuBoat.private.renderGrid.translateX(maxLength / 2.0); … … 520 519 GnuBoat.private.renderScene.add(GnuBoat.private.renderGrid); 521 520 522 var distance = 0.3 * maxLength;521 var distance = 150; 523 522 var fieldOfView = 2 * Math.atan(maxLength / (2.0 * distance) ) * 180.0 / Math.PI; 524 GnuBoat.private.renderCamera.position.set( 0.1 * maxLength, 0.2 * maxLength, 0.3 * maxLength);523 GnuBoat.private.renderCamera.position.set(-10, -5, 100); 525 524 GnuBoat.private.renderCamera.fov = fieldOfView; 525 GnuBoat.private.renderCamera.lookAt(GnuBoat.private.renderScene.position); 526 GnuBoat.private.renderCamera.zoom = 5; 526 527 GnuBoat.private.renderCamera.updateProjectionMatrix(); 527 528 }, 528 529 529 drawDensityEstimation: function(densityPoints, maxim a)530 { 531 var material = new THREE.PointsMaterial({ color: 0x00CCCC, size: 1});530 drawDensityEstimation: function(densityPoints, maximum, minimum) 531 { 532 var material = new THREE.PointsMaterial({vertexColors: THREE.VertexColors, size: 5}); 532 533 var geometry = new THREE.Geometry(); 533 534 var mercatorSouthWest = {x: 0, y: 0}; 534 if(GnuBoat.private.mapBounds != null) {535 if(GnuBoat.private.mapBounds != null) 535 536 mercatorSouthWest = GnuBoat.private.mercator(GnuBoat.private.mapBounds.getSouth(), GnuBoat.private.mapBounds.getWest()); 536 }537 537 538 538 for(var i = 0; i < densityPoints.length; i++){ 539 539 var mercator = GnuBoat.private.mercator(densityPoints[i].latitude, densityPoints[i].longitude); 540 var vertex = new THREE.Vector3(mercator.x - mercatorSouthWest.x, mercator.y - mercatorSouthWest.y, (densityPoints[i].depth * -1) + maxima); 540 var vertex = new THREE.Vector3(mercator.x - mercatorSouthWest.x, mercator.y - mercatorSouthWest.y, (densityPoints[i].depth * -1) + maximum); 541 var color = new THREE.Color(0x000000); 542 if(GnuBoat.private.renderDepthSteps != null){ 543 var step = Math.floor((densityPoints[i].depth - minimum)/((maximum-minimum)/GnuBoat.private.renderDepthSteps)); 544 if(step >= 0 && step < GnuBoat.private.renderDepthMaterials.length) 545 color = GnuBoat.private.renderDepthMaterials[step]; 546 } 541 547 geometry.vertices.push(vertex); 548 geometry.colors.push(color); 542 549 } 543 550 // point cloud … … 551 558 { 552 559 requestAnimationFrame(GnuBoat.private.animate); 553 554 // if(GnuBoat.private.mapBounds != null){ 555 // GnuBoat.private.camera.position.set(GnuBoat.private.mapBounds.getCenter().lng, GnuBoat.private.mapBounds.getSouth(), 0); 556 // GnuBoat.private.camera.up = new THREE.Vector3(0, 0, 1); 557 // GnuBoat.private.camera.lookAt(new THREE.Vector3(GnuBoat.private.mapBounds.getCenter().lng, GnuBoat.private.mapBounds.getCenter().lat, 0)); 558 // GnuBoat.private.camera.zoom = 1; 559 // } 560 561 // var width = $("#3dchart").width(); 562 // var height = $("#3dchart").height(); 563 // GnuBoat.private.renderer.setSize(width, height); 560 if(GnuBoat.private.renderCloud != null){ 561 var scaleZ = $("#renderScaleZ").val(); 562 if(GnuBoat.private.renderCloud.scale.z != scaleZ) 563 GnuBoat.private.renderCloud.scale.set(1, 1, scaleZ); 564 } 565 566 GnuBoat.private.renderControls.update(); 564 567 GnuBoat.private.renderRenderer.render(GnuBoat.private.renderScene, GnuBoat.private.renderCamera); 565 568 },
Note:
See TracChangeset
for help on using the changeset viewer.
