From 1ce3ceab3bbb73e26a6acd194ac4d6d87673e78e Mon Sep 17 00:00:00 2001 From: Marcus Sen Date: Mon, 4 Aug 2014 16:44:20 +0100 Subject: [PATCH 1/4] Layer separation based on order of models. Explode layers based on model position in order rather than DTM values. Not necessarily robust but much better, works for Glasgow layers. --- js/EarthServerClient_DailyBuild.js | 28 ++++++++++------------------ js/SceneManager.js | 20 +++++--------------- js/ServerRequest.js | 7 ++++--- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/js/EarthServerClient_DailyBuild.js b/js/EarthServerClient_DailyBuild.js index 2333efb..bcb2b81 100644 --- a/js/EarthServerClient_DailyBuild.js +++ b/js/EarthServerClient_DailyBuild.js @@ -2464,7 +2464,7 @@ EarthServerGenericClient.SceneManager = function() offSetMult = ( 2* Math.abs( models[modelIndex].xOffset -0.5 )); cubeMult = cubeSizeX / 10; - if( offSetMult !== 0.0 && separationVector[which] !== 1 ) + if( offSetMult !== 0.0 ) { if( newTrans >= 0) newTrans += cubeMult * separationVector[which] * this.getSeparationMultiplierForModel(modelIndex,which); @@ -2486,7 +2486,7 @@ EarthServerGenericClient.SceneManager = function() offSetMult = ( 2* Math.abs( models[modelIndex].yOffset -0.5 )); cubeMult = cubeSizeY / 10; - if( offSetMult !== 0.0 && separationVector[which] !== 1 ) + if( offSetMult !== 0.0 ) { if( newTrans >= 0) newTrans += cubeMult * separationVector[which] * this.getSeparationMultiplierForModel(modelIndex,which); @@ -2506,7 +2506,7 @@ EarthServerGenericClient.SceneManager = function() offSetMult = ( 2* Math.abs( models[modelIndex].zOffset -0.5 )); cubeMult = cubeSizeZ / 10; - if( offSetMult !== 0.0 && separationVector[which] !== 1 ) + if( offSetMult !== 0.0 ) { if( newTrans >= 0) newTrans += cubeMult * separationVector[which] * this.getSeparationMultiplierForModel(modelIndex,which); @@ -2642,18 +2642,8 @@ EarthServerGenericClient.SceneManager = function() */ this.getSeparationMultiplierForModel = function(modelIndex,axis) { - var minModelValue = this.getMinDataValueAtAxis(modelIndex,axis); - var axisValues = this.getMinimumDataValueForAxis(axis); - - var value = 1; - - if( axisValues.min === axisValues.max ) - { return value; } - else - { - value += ( minModelValue - axisValues.min ) / ( axisValues.max - axisValues.min ); - return value; - } + var value = modelIndex / (this.getModelCount() - 1); + return value - 0.5; }; @@ -5807,7 +5797,8 @@ EarthServerGenericClient.getWCPSDemCoverage = function(callback,responseData,WCP tmp = parseFloat(valuesList[k]); hm[i][k] = tmp; - + if (tmp !== demNoData) + { if (responseData.maxHMvalue < tmp) { responseData.maxHMvalue = parseFloat(tmp); @@ -5816,7 +5807,7 @@ EarthServerGenericClient.getWCPSDemCoverage = function(callback,responseData,WCP { responseData.minHMvalue = parseFloat(tmp); } - + } } } if(responseData.minHMvalue!=0 && responseData.maxHMvalue!=0) @@ -6297,7 +6288,8 @@ EarthServerGenericClient.requestWCSPointCloud = function(callback,WCSurl,WCSvers EarthServerGenericClient.getPointCloudWCS(callback,data,WCSurl,WCSversion,WCScoverID,minx,maxx,miny,maxy,minh,maxh); -};//Namespace +}; +//Namespace var EarthServerGenericClient = EarthServerGenericClient || {}; /** diff --git a/js/SceneManager.js b/js/SceneManager.js index 3ce3bfd..62e9ed6 100644 --- a/js/SceneManager.js +++ b/js/SceneManager.js @@ -2464,7 +2464,7 @@ EarthServerGenericClient.SceneManager = function() offSetMult = ( 2* Math.abs( models[modelIndex].xOffset -0.5 )); cubeMult = cubeSizeX / 10; - if( offSetMult !== 0.0 && separationVector[which] !== 1 ) + if( offSetMult !== 0.0 ) { if( newTrans >= 0) newTrans += cubeMult * separationVector[which] * this.getSeparationMultiplierForModel(modelIndex,which); @@ -2486,7 +2486,7 @@ EarthServerGenericClient.SceneManager = function() offSetMult = ( 2* Math.abs( models[modelIndex].yOffset -0.5 )); cubeMult = cubeSizeY / 10; - if( offSetMult !== 0.0 && separationVector[which] !== 1 ) + if( offSetMult !== 0.0 ) { if( newTrans >= 0) newTrans += cubeMult * separationVector[which] * this.getSeparationMultiplierForModel(modelIndex,which); @@ -2506,7 +2506,7 @@ EarthServerGenericClient.SceneManager = function() offSetMult = ( 2* Math.abs( models[modelIndex].zOffset -0.5 )); cubeMult = cubeSizeZ / 10; - if( offSetMult !== 0.0 && separationVector[which] !== 1 ) + if( offSetMult !== 0.0 ) { if( newTrans >= 0) newTrans += cubeMult * separationVector[which] * this.getSeparationMultiplierForModel(modelIndex,which); @@ -2642,18 +2642,8 @@ EarthServerGenericClient.SceneManager = function() */ this.getSeparationMultiplierForModel = function(modelIndex,axis) { - var minModelValue = this.getMinDataValueAtAxis(modelIndex,axis); - var axisValues = this.getMinimumDataValueForAxis(axis); - - var value = 1; - - if( axisValues.min === axisValues.max ) - { return value; } - else - { - value += ( minModelValue - axisValues.min ) / ( axisValues.max - axisValues.min ); - return value; - } + var value = modelIndex / (this.getModelCount() - 1); + return value - 0.5; }; diff --git a/js/ServerRequest.js b/js/ServerRequest.js index 377dc49..4e0d001 100644 --- a/js/ServerRequest.js +++ b/js/ServerRequest.js @@ -290,7 +290,8 @@ EarthServerGenericClient.getWCPSDemCoverage = function(callback,responseData,WCP tmp = parseFloat(valuesList[k]); hm[i][k] = tmp; - + if (tmp !== demNoData) + { if (responseData.maxHMvalue < tmp) { responseData.maxHMvalue = parseFloat(tmp); @@ -299,7 +300,7 @@ EarthServerGenericClient.getWCPSDemCoverage = function(callback,responseData,WCP { responseData.minHMvalue = parseFloat(tmp); } - + } } } if(responseData.minHMvalue!=0 && responseData.maxHMvalue!=0) @@ -780,4 +781,4 @@ EarthServerGenericClient.requestWCSPointCloud = function(callback,WCSurl,WCSvers EarthServerGenericClient.getPointCloudWCS(callback,data,WCSurl,WCSversion,WCScoverID,minx,maxx,miny,maxy,minh,maxh); -}; \ No newline at end of file +}; From a4f5b081a5ae1e121ec7ed086124090b0b8b7e8c Mon Sep 17 00:00:00 2001 From: Marcus Sen Date: Tue, 5 Aug 2014 09:04:22 +0100 Subject: [PATCH 2/4] Fix interaction of vert exaggeration and offsetting Make updateOffset method remember original vertical exaggeration so that can calculate minimum values for offsets and translations correctly. This was done in updateElevation method already. --- js/EarthServerClient_DailyBuild.js | 6 +++++- js/SceneManager.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/EarthServerClient_DailyBuild.js b/js/EarthServerClient_DailyBuild.js index bcb2b81..bcfc2bf 100644 --- a/js/EarthServerClient_DailyBuild.js +++ b/js/EarthServerClient_DailyBuild.js @@ -2478,7 +2478,11 @@ EarthServerGenericClient.SceneManager = function() break; case 1: offset = cubeSizeY/2.0; - minValue *= scale.y; + if( baseElevation[modelIndex] === undefined) + { + baseElevation[modelIndex] = scale.y; + } + minValue *= baseElevation[modelIndex]; newTrans = (value - offset- minValue); if( models[modelIndex].isChildOf === null ) diff --git a/js/SceneManager.js b/js/SceneManager.js index 62e9ed6..f73ebed 100644 --- a/js/SceneManager.js +++ b/js/SceneManager.js @@ -2478,7 +2478,11 @@ EarthServerGenericClient.SceneManager = function() break; case 1: offset = cubeSizeY/2.0; - minValue *= scale.y; + if( baseElevation[modelIndex] === undefined) + { + baseElevation[modelIndex] = scale.y; + } + minValue *= baseElevation[modelIndex]; newTrans = (value - offset- minValue); if( models[modelIndex].isChildOf === null ) From 69bc24a742f8cc2b4ccff74b0fad2dd8bcf2cc40 Mon Sep 17 00:00:00 2001 From: Marcus Sen Date: Thu, 14 Aug 2014 11:05:32 +0100 Subject: [PATCH 3/4] Fix separation code to use appropriate axis offset --- js/SceneManager.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/SceneManager.js b/js/SceneManager.js index f73ebed..cb5a8fc 100644 --- a/js/SceneManager.js +++ b/js/SceneManager.js @@ -2571,17 +2571,24 @@ EarthServerGenericClient.SceneManager = function() { value /= 10; var axisSign = ""; + var currentSliderValue; switch( parseInt(axis) ) { case 0: separationVector[0] = parseFloat(value); axisSign = "X"; + // Set slider value to default value + currentSliderValue = EarthServerGenericClient.MainScene.getModelOffsetX(i) * EarthServerGenericClient.MainScene.getCubeSizeX(); break; case 1: separationVector[1] = parseFloat(value); axisSign = "Y"; + // Set slider value to default valu + currentSliderValue = EarthServerGenericClient.MainScene.getModelOffsetY(i) * EarthServerGenericClient.MainScene.getCubeSizeY(); break; case 2: separationVector[2] = parseFloat(value); axisSign = "Z"; + // Set slider value to default value + currentSliderValue = EarthServerGenericClient.MainScene.getModelOffsetZ(i) * EarthServerGenericClient.MainScene.getCubeSizeZ(); break; default: console.log("EarthServerGenericClient::SceneManager::updateSeparation: Axis with value " +value+ " not known."); return; } @@ -2590,8 +2597,6 @@ EarthServerGenericClient.SceneManager = function() { if( models[i].isChildOf === null ) { - // Set slider value to default value - var currentSliderValue = EarthServerGenericClient.MainScene.getModelOffsetZ(i) * EarthServerGenericClient.MainScene.getCubeSizeZ(); var slider = document.getElementById("Model"+i+axisSign); if(slider) From a7b31f6584cdf1e3cc165cb4f8b553f9f4d2f96b Mon Sep 17 00:00:00 2001 From: Marcus Sen Date: Thu, 14 Aug 2014 11:14:11 +0100 Subject: [PATCH 4/4] Copy latest changes to DailyBuild file --- js/EarthServerClient_DailyBuild.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/EarthServerClient_DailyBuild.js b/js/EarthServerClient_DailyBuild.js index a05d665..7582420 100644 --- a/js/EarthServerClient_DailyBuild.js +++ b/js/EarthServerClient_DailyBuild.js @@ -2571,17 +2571,24 @@ EarthServerGenericClient.SceneManager = function() { value /= 10; var axisSign = ""; + var currentSliderValue; switch( parseInt(axis) ) { case 0: separationVector[0] = parseFloat(value); axisSign = "X"; + // Set slider value to default value + currentSliderValue = EarthServerGenericClient.MainScene.getModelOffsetX(i) * EarthServerGenericClient.MainScene.getCubeSizeX(); break; case 1: separationVector[1] = parseFloat(value); axisSign = "Y"; + // Set slider value to default valu + currentSliderValue = EarthServerGenericClient.MainScene.getModelOffsetY(i) * EarthServerGenericClient.MainScene.getCubeSizeY(); break; case 2: separationVector[2] = parseFloat(value); axisSign = "Z"; + // Set slider value to default value + currentSliderValue = EarthServerGenericClient.MainScene.getModelOffsetZ(i) * EarthServerGenericClient.MainScene.getCubeSizeZ(); break; default: console.log("EarthServerGenericClient::SceneManager::updateSeparation: Axis with value " +value+ " not known."); return; } @@ -2590,8 +2597,6 @@ EarthServerGenericClient.SceneManager = function() { if( models[i].isChildOf === null ) { - // Set slider value to default value - var currentSliderValue = EarthServerGenericClient.MainScene.getModelOffsetZ(i) * EarthServerGenericClient.MainScene.getCubeSizeZ(); var slider = document.getElementById("Model"+i+axisSign); if(slider)