# See: http://wiki.flightgear.org/MapStructure # Class things: var name = 'TERRAIN'; var parents = [DotSym]; var __self__ = caller(0)[0]; DotSym.makeinstance( name, __self__ ); var element_type = "group"; var tile_list = ["tile_00.png","tile_04.png","tile_06.png"]; var updateTerrain = func(size){ if(me.fetching) return; var pos = geo.aircraft_position(); var lat = pos.lat(); var lon = pos.lon(); me.fetching = 1; for (var a=0; a < me.tileradius; a+=1) { var len = size(me.terrlayer["L" ~ a]); for (var r=0; r < len; r+=1) { var imgx = math.mod(r*a,3); me.terrlayer["L" ~ a].setFile(me.imgpath ~ me.tile_list[imgx]).show(); me.terrlayer["R" ~ a].setFile(me.imgpath ~ me.tile_list[2-imgx]).show(); } } me.last_request = getprop("sim/time/elapsed-sec"); me.fetching = 0; }; var init = func { print('TERRAIN init'); me.tile = 20; me.fetching = 0; me.timeStamp = nil; me.fetchRad = me.model.fetchRad; # Radius of radar layer to fetch me.range = me.model.rangeNm; # Range of Navigation Display me.viewport_radius = me.getOption('viewport_radius', 670); me.imgpath = get_local_path('res/'); var tile = me.tile; var gx = int(me.viewport_radius / tile); me.tileradius = gx; me.terrlayer = {}; #me.element.createChild("image").set("z-index", -100).hide(); var centx = me.viewport_radius; for (var c=0; c me.update_interval) { me.updateTerrain(r_scaled); } };