Skip to content

Commit

Permalink
new textures, degradation of horizon, add/remove free layer, initial …
Browse files Browse the repository at this point in the history
…hit geodata support
  • Loading branch information
davidmtech committed Mar 22, 2017
1 parent 5106536 commit 6deb33f
Show file tree
Hide file tree
Showing 29 changed files with 7,375 additions and 6,237 deletions.
Empty file added build/.placeholder
Empty file.
3 changes: 2 additions & 1 deletion make.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CLOSURECOMPILER=../build/tools/closure-compiler/compiler.jar
CLOSURECOMPILER=./build/tools/closure-compiler/compiler.jar


# create lincense header
Expand Down Expand Up @@ -74,6 +74,7 @@ cat src/core/utils/matrix.js \
src/core/map/submesh.js \
src/core/map/surface.js \
src/core/map/surface-sequence.js \
src/core/map/subtexture.js \
src/core/map/texture.js \
src/core/map/virtual-surface.js \
src/core/map/surface-tile.js \
Expand Down
10 changes: 10 additions & 0 deletions src/browser/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ Melown.BrowserInterface.prototype.getBoundLayerInfo = function(layerId_) {
return (layer_ != null) ? layer_.getInfo() : null;
};

Melown.BrowserInterface.prototype.addFreeLayer = function(id_, options_) {
if(!this.map_) return;
return this.map_.addFreeLayer(id_, options_);
};

Melown.BrowserInterface.prototype.removeFreeLayer = function(id_) {
if(!this.map_) return;
return this.map_.removeFreeLayer(id_);
};

Melown.BrowserInterface.prototype.getFreeLayers = function() {
if(!this.map_) return;
return this.map_.getFreeLayers();
Expand Down
4 changes: 3 additions & 1 deletion src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Melown.Core.prototype.initConfig = function() {
mapHeightLodBlend_ : true,
mapHeightNodeBlend_ : true,
mapBasicTileSequence_ : false,
mapPreciseBBoxTest_ : true,
mapPreciseBBoxTest_ : false,
mapPreciseDistanceTest_ : false,
mapHeightfiledWhenUnloaded_ : true,
mapForceMetatileV3_ : false,
Expand All @@ -37,6 +37,8 @@ Melown.Core.prototype.initConfig = function() {
mapGeodataLoadMode_ : "fit", //"fitonly"
mapXhrImageLoad_ : false,
mapStoreLoadStats_ : true,
mapDegradeHorizon_ : false,
mapDegradeHorizonParams_ : [1, 1500, 97500, 3500], //[1, 3000, 15000, 7000],
mapFog_ : true,
rendererAntialiasing_ : true,
rendererAllowScreenshots_ : false,
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ string getCoreVersion()
*/

Melown.getCoreVersion = function(full_) {
return (full_ ? "Core: " : "") + "1.89";
return (full_ ? "Core: " : "") + "1.94";
};


Expand Down
19 changes: 16 additions & 3 deletions src/core/inspector/input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

//mouse events
/*
Melown.Inspector.prototype.onClick = function(event_) {
if (this.measureMode_) {
var pos_ = this.core_.hitTest(this.mouseX_, this.mouseY_, "all");
}
};*/

//keyboard events
Melown.Inspector.prototype.onKeyDown = function(event_) {
Expand Down Expand Up @@ -109,10 +116,16 @@ Melown.Inspector.prototype.onKeyUp = function(event_, press_) {

switch(keyCode_) {

case 68:
case 100:
break; //key D pressed
case 67:
case 99:
map_.config_.mapDegradeHorizon_ = !map_.config_.mapDegradeHorizon_;

//this.measureMode_ = !this.measureMode_;
//this.measurePoints_ = [];
//var pos_ = this.core_.hitTest(this.mouseX_, this.mouseY_, "all");
//console.log("hit pos: " + pos_[0] + " " + pos_[1] + " " + pos_[2] + " " + pos_[3] + " d " + pos_[4]); //key T pressed

break; //key C pressed

case 49: /*this.core_.setControlMode("manual"); done_();*/ break; //key 1 pressed
case 50: /*this.core_.setControlMode("drone"); done_();*/ break; //key 2 pressed
Expand Down
11 changes: 11 additions & 0 deletions src/core/inspector/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Melown.Inspector = function(core_) {
this.initReplayPanel();
this.initStylesheetsPanel();

//mouse events
//document.addEventListener("click", this.onKeyClick.bind(this), false);

//keyboard events
document.addEventListener("keyup", this.onKeyUp.bind(this), false);
document.addEventListener("keypress", this.onKeyPress.bind(this), false);
Expand All @@ -23,6 +26,8 @@ Melown.Inspector = function(core_) {
this.drawRadar_ = false;
this.radarLod_ = null;
this.debugValue_ = 0;
this.measureMode_ = false;
this.measurePoints_ = [];
};

Melown.Inspector.prototype.addStyle = function(string_) {
Expand All @@ -48,6 +53,12 @@ Melown.Inspector.prototype.onMapUpdate = function(string_) {
map_.redraw();
}

/*if (this.measureMode_) {
var renderer_ = this.core_.getRenderer();
var p_ = map_.convertCoordsFromPhysToNav(this.measurePoints_[0]);
map_.convertCoordsFromPhysToCanvas(this.measurePoints_[0]);
}*/

if (this.drawReplayGlobe_) {
var renderer_ = this.core_.getRenderer();
var p_ = map_.convertCoordsFromPhysToCameraSpace([0,0,0]);
Expand Down
10 changes: 10 additions & 0 deletions src/core/map/bound-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ Melown.MapBoundLayer.prototype.parseJson = function(json_) {

};

Melown.MapBoundLayer.prototype.kill = function() {
};

Melown.MapBoundLayer.prototype.setOptions = function(options_) {
};

Melown.MapBoundLayer.prototype.getOptions = function() {
return this.getInfo();
};

Melown.MapBoundLayer.prototype.getInfo = function() {
return {
"type" : this.type_,
Expand Down
9 changes: 7 additions & 2 deletions src/core/map/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Melown.Map.prototype.updateCamera = function() {
this.cameraDistance2_ = this.position_.getViewDistance();
this.cameraDistance_ = Math.max(this.cameraTerrainHeight_, this.cameraDistance2_);
this.cameraDistance_ = Melown.clamp(this.cameraDistance_, 0.1, this.camera_.getFar());

this.cameraDistanceFactor_ = Math.tan(Melown.radians(this.position_.getFov()*0.5));

this.cameraPerceivedDistance_ = Math.max(this.cameraTerrainHeight_, this.cameraDistance2_ * this.cameraDistanceFactor_);

//this.renderer_.cameraDistance_ = camInfo_.distance_; //needed for fog
this.renderer_.cameraDistance_ = this.cameraDistance_; //needed for fog
Expand All @@ -50,8 +54,9 @@ Melown.Map.prototype.updateCamera = function() {
this.camera_.setViewHeight(this.position_.getViewExtent());
//this.camera_.setOrtho(true);

//convert public coords to physical
var worldPos_ = this.convertCoords([this.position_.getCoords()[0], this.position_.getCoords()[1], height_], "navigation", "physical");
//convert nav coords to physical
var coords_ = this.position_.getCoords();
var worldPos_ = this.convertCoords([coords_[0], coords_[1], height_], "navigation", "physical");
this.cameraCenter_ = [worldPos_[0], worldPos_[1], worldPos_[2]];
worldPos_[0] += camInfo_.orbitCoords_[0];
worldPos_[1] += camInfo_.orbitCoords_[1];
Expand Down
17 changes: 12 additions & 5 deletions src/core/map/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Melown.Map.prototype.draw = function(skipFreeLayers_, projected_, camInfo_) {
this.drawTileCounter_ = 0;
var cameraPos_ = this.cameraPosition_;

if (this.freeLayersHaveGeodata_ && this.drawChannel_ == 0) {
this.renderer_.drawGpuJobs();
}

if (this.drawEarth_) {
if (this.replay_.storeNodes_ || this.replay_.storeFreeNodes_) {
this.replay_.nodeBuffer_ = [];
Expand Down Expand Up @@ -96,7 +100,6 @@ Melown.Map.prototype.draw = function(skipFreeLayers_, projected_, camInfo_) {
(this.replay_.drawLoaded_ && this.replay_.loaded_)) {

if (this.freeLayersHaveGeodata_) {
this.renderer_.drawGpuJobs();
this.renderer_.clearJobBuffer();
}
}
Expand Down Expand Up @@ -301,7 +304,6 @@ Melown.Map.prototype.draw = function(skipFreeLayers_, projected_, camInfo_) {
}*/

if (this.freeLayersHaveGeodata_) {
this.renderer_.drawGpuJobs();
this.renderer_.clearJobBuffer();
}
}
Expand Down Expand Up @@ -981,7 +983,7 @@ Melown.Map.prototype.drawGeodataTile = function(tile_, node_, cameraPos_, pixelS
};

Melown.Map.prototype.drawMonoliticGeodata = function(surface_) {
if (!surface_) {
if (!surface_ || this.drawChannel_ != 0) {
return;
}

Expand All @@ -990,7 +992,12 @@ Melown.Map.prototype.drawMonoliticGeodata = function(surface_) {
}

if (surface_.monoGeodata_ == null) {
var path_ = surface_.getMonoGeodataUrl(surface_.id_);
if (typeof surface_.geodataUrl_ === "object") {
var path_ = surface_.geodataUrl_;
} else {
var path_ = surface_.getMonoGeodataUrl(surface_.id_);
}

surface_.monoGeodata_ = new Melown.MapGeodata(this, path_, {tile_:null, surface_:surface_});
}

Expand Down Expand Up @@ -1124,7 +1131,7 @@ Melown.Map.prototype.updateTileSurfaceBounds = function(tile_, submesh_, surface

var texture_ = tile_.boundTextures_[layer_.id_];

if (!texture_) {
if (!texture_) { //TODO: make sure that we load only textures which we need
var path_ = layer_.getUrl(tile_.id_);
texture_ = tile_.resources_.getTexture(path_, null, extraBound_, {tile_: tile_, layer_: layer_}, tile_, false);
texture_.isReady(true); //check for mask but do not load
Expand Down
2 changes: 1 addition & 1 deletion src/core/map/geodata-processor/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Melown.MapGeodataProcessor = function(surface_, listener_) {
} else {

//debug worker
this.processWorker_ = new Worker("../melown-core-api/melown-core/map/geodata-processor/worker-debug.js");
this.processWorker_ = new Worker("../src/core/map/geodata-processor/worker-debug.js");

this.processWorker_.onerror = function(event){
throw new Error(event.message + " (" + event.filename + ":" + event.lineno + ")");
Expand Down
14 changes: 13 additions & 1 deletion src/core/map/geodata.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Melown.MapGeodata = function(map_, url_, extraInfo_) {
this.loadState_ = 0;
this.loadErrorTime_ = null;
this.loadErrorCounter_ = 0;

this.map_.markDirty();
};

Melown.MapGeodata.prototype.kill = function() {
Expand Down Expand Up @@ -59,7 +61,17 @@ Melown.MapGeodata.prototype.isReady = function(doNotLoad_, priority_, doNotCheck
} else {
//not loaded
//add to loading queue or top position in queue
this.scheduleLoad(priority_);


if (typeof this.mapLoaderUrl_ === "object") { //use geodata directly
this.geodata_ = JSON.stringify(this.mapLoaderUrl_);
this.loadState_ = 2;
this.cacheItem_ = this.map_.resourcesCache_.insert(this.killGeodata.bind(this, true), this.geodata_.length);
this.map_.resourcesCache_.updateItem(this.cacheItem_);
return true;
} else {
this.scheduleLoad(priority_);
}
}
} else if (this.loadState_ == 3) { //loadError
if (this.loadErrorCounter_ <= this.map_.config_.mapLoadErrorMaxRetryCount_ &&
Expand Down
52 changes: 52 additions & 0 deletions src/core/map/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,40 @@ Melown.MapInterface.prototype.getReferenceFrame = function() {
return this.map_.referenceFrame_.getInfo();
};

Melown.MapInterface.prototype.addFreeLayer = function(id_, options_) {
var layer_ = new Melown.MapSurface(this.map_, options_, "free");
this.map_.addFreeLayer(id_, layer_);
};

Melown.MapInterface.prototype.removeFreeLayer = function(id_) {
this.map_.removeFreeLayer(id_);
};

/* Melown.MapInterface.prototype.setFreeLayerOptions = function(id_, options_) {
this.map_.setFreeLayerOptions(id_, options_);
};
Melown.MapInterface.prototype.getFreeLayerOptions = function(id_) {
return this.map_.getFreeLayerOptions(id_);
}; */

Melown.MapInterface.prototype.addBoundLayer = function(id_, options_) {
var layer_ = new Melown.MapBoundLayer(this.map_, options_, id_);
this.map_.addBoundLayer(id_, layer_);
};

Melown.MapInterface.prototype.removeBoundLayer = function(id_) {
this.map_.removeBoundLayer(id_);
};

/* Melown.MapInterface.prototype.setBoundLayerOptions = function(id_, options_) {
this.map_.setBoundLayerOptions(id_, options_);
};
Melown.MapInterface.prototype.getBoundLayerOptions = function(id_) {
return this.map_.setBoundLayerOptions(id_);
};*/

Melown.MapInterface.prototype.convertPositionViewMode = function(position_, mode_) {
var pos_ = (new Melown.MapPosition(this.map_, position_)).convertViewMode(mode_);
return (pos_ != null) ? pos_.pos_ : pos_;
Expand Down Expand Up @@ -341,6 +375,14 @@ Melown.MapInterface.prototype.getStats = function() {
};
};

Melown.MapInterface.prototype.click = function(screenX_, screenY_, state_) {
map_.click(screenX_, screenY_, state_);
};

Melown.MapInterface.prototype.hover = function(screenX_, screenY_, persistent_, state_) {
map_.hover(screenX_, screenY_, persistent_, state_);
};

Melown.MapPositionInterface = Melown.MapPosition;

Melown.MapInterface.prototype["setPosition"] = Melown.MapInterface.prototype.setPosition;
Expand All @@ -361,6 +403,14 @@ Melown.MapInterface.prototype["getSurfaceInfo"] = Melown.MapInterface.prototype.
Melown.MapInterface.prototype["getSrses"] = Melown.MapInterface.prototype.getSrses;
Melown.MapInterface.prototype["getSrsInfo"] = Melown.MapInterface.prototype.getSrsInfo;
Melown.MapInterface.prototype["getReferenceFrame"] = Melown.MapInterface.prototype.getReferenceFrame;
Melown.MapInterface.prototype["addFreeLayer"] = Melown.MapInterface.prototype.addFreeLayer;
Melown.MapInterface.prototype["removeFreeLayer"] = Melown.MapInterface.prototype.removeFreeLayer;
//Melown.MapInterface.prototype["setFreeLayerOptions"] = Melown.MapInterface.prototype.setFreeLayerOptions;
//Melown.MapInterface.prototype["getFreeLayerOptions"] = Melown.MapInterface.prototype.getFreeLayerOptions;
Melown.MapInterface.prototype["addBoundLayer"] = Melown.MapInterface.prototype.addBoundLayer;
Melown.MapInterface.prototype["removeBoundLayer"] = Melown.MapInterface.prototype.removeBoundLayer;
//Melown.MapInterface.prototype["setBoundLayerOptions"] = Melown.MapInterface.prototype.setBoundLayerOptions;
//Melown.MapInterface.prototype["getBoundLayerOptions"] = Melown.MapInterface.prototype.getBoundLayerOptions;
Melown.MapInterface.prototype["convertPositionViewMode"] = Melown.MapInterface.prototype.convertPositionViewMode;
Melown.MapInterface.prototype["convertPositionHeightMode"] = Melown.MapInterface.prototype.convertPositionHeightMode;
Melown.MapInterface.prototype["convertCoords"] = Melown.MapInterface.prototype.convertCoords;
Expand Down Expand Up @@ -406,4 +456,6 @@ Melown.MapInterface.prototype["getGpuCache"] = Melown.MapInterface.prototype.get
Melown.MapInterface.prototype["getHitCoords"] = Melown.MapInterface.prototype.getHitCoords;
Melown.MapInterface.prototype["getScreenRay"] = Melown.MapInterface.prototype.getScreenRay;
Melown.MapInterface.prototype["getStats"] = Melown.MapInterface.prototype.getStats;
Melown.MapInterface.prototype["click"] = Melown.MapInterface.prototype.click;
Melown.MapInterface.prototype["hover"] = Melown.MapInterface.prototype.hover;

Loading

0 comments on commit 6deb33f

Please sign in to comment.