Attention ! Gitlab fournissant maintenant nativement des certificats Let’s Encrypt aux domaines personnalisés des Gitlab Pages, nous avons coupé notre service qui le faisait automatiquement pour vous.

Il est impératif, pour que votre domaine personnalisé continue à avoir un certificat Let’s Encrypt à jour, d’activer la fonctionnalité native dans les paramètres de votre projet. Cette activation remplacera votre certificat actuel par un nouveau certificat Let’s Encrypt géré par Gitlab.

Voir les détails sur https://docs.framasoft.org/fr/gitlab/gitlab-pages-le.html

Commit d949c1a7 authored by Clément Igonet's avatar Clément Igonet

viewer-earth-api-integration

parent 37d07204
This is the first Open Earth View viewer with 3D building representation.
{
"name": "open-earth-view-viewer-earth3",
"authors": [
"Clément Igonet <clement@igonet.fr>"
],
"description": "Open Earth View project - Earth viewer 3",
"main": "index.html",
"moduleType": [
"none"
],
"keywords": [
"threejs",
"3D",
"osm"
],
"license": "MIT",
"homepage": "http://wiki.openstreetmap.org/wiki/Open_Earth_View",
"ignore": [
"**/.*",
"node_modules",
"bower_components"
],
"dependencies": {
"three.js": "",
"turf": ""
}
}
<html>
<head>
<meta charset=utf-8>
<!--
Open Earth View - viewer-threejs
The MIT License (MIT)
Copyright (c) 2016 Clément Igonet
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<title>Open Earth View - viewer-earth</title>
<html lang="en">
<head>
<link rel="stylesheet" href="css/openearthview.css" type="text/css">
<style>
body {
margin: 0;
}
#osmworld {
height: 90%;
margin-left: 5%;
margin-right: 5%;
}
</style>
<!-- <script src="bower_components/three.js/three.min.js"></script> -->
<script src="node_modules/three/build/three.js"></script>
<script src="js/turf/v2.0.2/turf.min.js"></script>
<script src="js/openearthview.js" type="text/javascript"></script>
<script src="js/toolbox.js" type="text/javascript"></script>
<!-- <script src="js/loaders/TerrainLoader.js" type="text/javascript"></script> -->
<script src="js/loaders/TileLoader.js" type="text/javascript"></script>
<script src="js/loaders/TerrainLoader.js" type="text/javascript"></script>
<script src="js/loaders/GeojsonLoader.js"></script>
<script src="js/loaders/mapzenGeojsonLoader.js"></script>
<!-- <script src="js/toolbox.js" type="text/javascript"></script> -->
<script src="js/controls/EarthControls.js"></script>
<script src="js/layers/Layer.js"></script>
<script src="js/layers/OsmLayer.js"></script>
<script src="js/layers/BuildingLayer.js"></script>
<script src="js/terrains/Terrain.js"></script>
<script src="js/terrains/FlatTerrain.js"></script>
<title>OpenEartView example</title>
</head>
<body>
<!-- <h2>Open Earth View demo</h2> -->
<div id="osmworld"></div>
<script type="text/javascript">
var world = new OpenEarthView.World("osmworld");
// world.updateSceneLazy();
// world.addLayer(new OpenEarthView.Layer.OSM(
// "OpenStreetMap", [
// "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
// "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
// "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
// ]));
// world.addLayer(new OpenEarthView.Layer.Building(
// "OpenEarthView", [
// 'http://localhost:8081/3dtile?format=geojson&xtile=${x}&ytile=${y}&zoom=${z}&factor=${f}'
// ]));
// http://localhost:8083/proxycache-geojson?tile=${z},${x},${y}
world.addLayer(new OpenEarthView.Layer.OSM(
"OpenCycleMap", [
"http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"
]));
// world.addLayer(new OpenEarthView.Layer.OSM(
// "GoogleMap", [
// "http://mt0.google.com/vt/lyrs=y&x=${x}&y=${y}&z=${z}",
// "http://mt1.google.com/vt/lyrs=y&x=${x}&y=${y}&z=${z}",
// "http://mt2.google.com/vt/lyrs=y&x=${x}&y=${y}&z=${z}",
// "http://mt3.google.com/vt/lyrs=y&x=${x}&y=${y}&z=${z}"
// ], {
// mapTextureRequest: 10
// }));
// world.addLayer(new OpenEarthView.Layer.Elevation(
// "OpenEarthView", [
// 'http://localhost:8084/oevElevation?tile=${z},${x},${y},${lod}'
// ]));
// world.addTerrain(new OpenEarthView.Terrain.FlatTerrain("FlatTerrain"));
// UNESCO
// world.setCenter(2.3057599523656336, 48.849568465379264);
// LOUVRE
world.setCenter(2.3364709900972684, 48.86045538042749);
// MANHATTAN
// world.setCenter(286.02073690310226, 40.747508647167834);
</script>
</body>
</html>
This diff is collapsed.
// world.addLayer(new OpenEarthView.Layer.OSM(
// "OpenStreetMap", [
// "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
// "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
// "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
// ]));
OpenEarthView.Layer.Building = function(name, urls, options) {
this.name = (name !== undefined) ? name : 'OpenEarthView';
if (options !== undefined) {
this.minZoom = (options.minZoom !== undefined)?options.minZoom:18;
console.log('minZoom: ' + this.minZoom);
}
if (OpenEarthViewLayers.hasOwnProperty(name)) {
console.err('Cannot register this already existing layer !');
return;
}
OpenEarthViewLayers[name] = (urls !== undefined) ? urls : [
'http://localhost:8081/3dtile?format=geojson&xtile=${x}&ytile=${y}&zoom=${z}'
];
};
OpenEarthView.Layer.Building.prototype = {
constructor: OpenEarthView.Layer.Building,
type: 'building',
getName: function() {
return this.name
},
getUrl: function(zoom, xtile, ytile) {
var scope = this;
var urls = OpenEarthViewLayers[scope.name];
var urlRandom = urls[
Math.floor(Math.random() * urls.length)];
// console.log('urlRandom:', urlRandom);
// var url = urlRandom.replace(
// /(.*)\$\{z\}(.*)\$\{x\}(.*)\$\{y\}(.*)/,
// function replacer(match, p1, p2, p3, p4, offset, string) {
// // console.log("Match!");
// return p1 + zoom + p2 + xtile + p3 + ytile + p4;
// });
// var url = urlRandom.replace('${f}', factor);
var url = urlRandom.replace('${z}', zoom);
var url = url.replace('${x}', xtile);
return url.replace('${y}', ytile);
// return url;
}
}
var OpenEarthViewLayers = {};
OpenEarthView.Layer = {};
// world.addLayer(new OpenEarthView.Layer.OSM(
// "OpenStreetMap", [
// "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
// "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
// "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
// ]));
OpenEarthView.Layer.OSM = function(name, urls) {
this.name = (name !== undefined) ? name : 'OpenStreetMap';
if (OpenEarthViewLayers.hasOwnProperty(name)) {
console.err('Cannot register this already existing layer !');
return;
}
OpenEarthViewLayers[name] = (urls !== undefined) ? urls : [
"http://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
"http://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
"http://c.tile.openstreetmap.org/${z}/${x}/${y}.png"
];
};
OpenEarthView.Layer.OSM.prototype = {
constructor: OpenEarthView.Layer.OSM,
type: 'tile',
opacity: 1,
getName: function() {
return this.name
},
getUrl: function(zoom, xtile, ytile) {
var scope = this;
var urls = OpenEarthViewLayers[scope.name];
var urlRandom = urls[
Math.floor(Math.random() * urls.length)];
// console.log('urlRandom:', urlRandom);
// var url = urlRandom.replace(
// /(.*)\$\{z\}(.*)\$\{x\}(.*)\$\{y\}(.*)/,
// function replacer(match, p1, p2, p3, p4, offset, string) {
// // console.log("Match!");
// return p1 + zoom + p2 + xtile + p3 + ytile + p4;
// });
var url = urlRandom.replace('${z}', zoom);
var url = url.replace('${x}', xtile);
return url.replace('${y}', ytile);
}
}
This diff is collapsed.
/**
Open Earth View - viewer-threejs
The MIT License (MIT)
Copyright (c) 2016 Clément Igonet
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* @author Clement Igonet
*/
THREE.TerrainLoader = function(manager) {
this.manager = (manager !== undefined) ? manager : THREE.DefaultLoadingManager;
};
// var R = 6378.137;
//
var terrains = {};
var terrainRequests = {};
var terrainAliveRequests = {};
var terrainAliveRequestsCount = 0;
var terrainRequestsCount = 0;
var MAX_ELEVATION_REQUEST = 10;
THREE.TerrainLoader.prototype = {
constructor: THREE.TerrainLoader,
crossOrigin: undefined,
load: function(url, onLoad, onProgress, onError) {
var scope = this;
var loader = new THREE.XHRLoader(scope.manager);
if (terrains.hasOwnProperty(url)) {
terrain = terrains[url];
try {
var myTerrain = JSON.parse(terrain);
onLoad(scope.parse(myTerrain));
} catch (e) {
console.error('Cannot parse terrain data (' + url + ')');
onLoad(scope.parse({}));
}
} else {
terrainRequestsCount = terrainRequestsCount +
(terrainRequests.hasOwnProperty(url) ? 0 : 1);
terrainRequests[url] = {
onLoad: onLoad,
onProgress: onProgress,
onError: onError
}
scope.loadNextTerrain();
}
},
loadNextTerrain: function() {
var scope = this;
var loader = new THREE.XHRLoader(scope.manager);
while (terrainAliveRequestsCount < MAX_ELEVATION_REQUEST && terrainRequestsCount > 0) {
var urls = Object.keys(terrainRequests);
var url = urls[urls.length - 1];
terrainAliveRequestsCount = terrainAliveRequestsCount +
(terrainAliveRequests.hasOwnProperty(url) ? 0 : 1);
console.log('terrainAliveRequestsCount:', terrainAliveRequestsCount);
terrainAliveRequests[url] = terrainRequests[url];
var onLoad = terrainAliveRequests[url].onLoad;
var onProgress = terrainAliveRequests[url].onProgress;
var onError = terrainAliveRequests[url].onError;
var lod = terrainAliveRequests[url].lod;
var defaultColor = terrainAliveRequests[url].defaultColor;
delete terrainRequests[url];
terrainRequestsCount--;
(function(url, onLoad, onProgress, onError) {
loader.load(
url,
function(terrain) {
if (terrainAliveRequests.hasOwnProperty(url)) {
delete terrainAliveRequests[url];
terrainAliveRequestsCount--;
console.log('terrainAliveRequestsCount:', terrainAliveRequestsCount);
try {
var myTerrain = JSON.parse(terrain);
terrains[url] = terrain;
onLoad(scope.parse(myTerrain));
} catch (e) {
console.error('Cannot parse terrain data (' + url + ')');
onLoad(scope.parse({}));
}
}
scope.loadNextTerrain();
}, onProgress,
function(geojson) {
if (terrainAliveRequests.hasOwnProperty(url)) {
delete terrainAliveRequests[url];
terrainAliveRequestsCount--;
console.log('terrainAliveRequestsCount:', terrainAliveRequestsCount);
}
scope.loadNextTerrain();
});
})(url, onLoad, onProgress, onError, lod, defaultColor);
}
},
setCrossOrigin: function(value) {
this.crossOrigin = value;
},
parse: function(json) {
// var zoom;
// var xtile;
// var ytile;
// var factor;
var tile = new THREE.Mesh();
// var tileGeometry = new THREE.Geometry();
// tileGeometry.vertices = [];
// for (int xIdx = 0; xIdx < Math.pow(2, factor), xIdx++) {
// for (int yIdx = 0; yIdx < Math.pow(2, factor), yIdx++) {
// var x = ((crd[0] - lonOri) / Math.abs(lonOri - crd[0])) * measure(latOri, lonOri, latOri, crd[0]);
// var y = ((crd[1] - latOri) / Math.abs(latOri - crd[1])) * measure(latOri, lonOri, crd[1], lonOri);
// }
// }
// for (var crdIdx = 0; crdIdx < coord.length; crdIdx++) {
// var crd = coord[crdIdx];
// var x = ((crd[0] - lonOri) / Math.abs(lonOri - crd[0])) * measure(latOri, lonOri, latOri, crd[0]);
// var y = ((crd[1] - latOri) / Math.abs(latOri - crd[1])) * measure(latOri, lonOri, crd[1], lonOri);
// tileGeometry.vertices.push(new THREE.Vector3(x, y, 0));
// }
//
// tile.geometry = tileGeometry;
// tile.material = tileMaterial;
return tile;
},
parseMaterials: function(json) {
var materials = {};
return materials;
},
parseGeometry: function(json) {
var geometry = new THREE.BufferGeometry();
return geometry;
},
parseObjects: function(json, materials) {
var scene = new THREE.Scene();
return scene;
},
};
/**
Open Earth View - viewer-threejs
The MIT License (MIT)
Copyright (c) 2016 Clément Igonet
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* @author Clement Igonet
*/
var MAX_TEXTURE_REQUEST = 10;
OpenEarthView.TileLoader = function() {
this.textureLoader = new THREE.TextureLoader();
this.textureLoader.crossOrigin = '';
// this.textureLoader
};
OpenEarthView.TileLoader.prototype = {
constructor: OpenEarthView.TileLoader,
textures: {},
textureRequests: {},
textureRequestsCount: 0,
textureAliveRequests: {},
textureAliveRequestsCount: 0,
loadNextTile: function() {
var scope = this;
// textureLoader.crossOrigin: '';
// console.log('textureAliveRequestsCount:', textureAliveRequestsCount, '/textureRequestsCount:', textureRequestsCount);
var textures = scope.textures;
var textureRequests = scope.textureRequests;
var textureAliveRequests = scope.textureAliveRequests;
// console.log('scope.textureAliveRequestsCount: ', scope.textureAliveRequestsCount);
// console.log('scope.textureRequestsCount: ', scope.textureRequestsCount);
while (scope.textureAliveRequestsCount < MAX_TEXTURE_REQUEST && scope.textureRequestsCount > 0) {
var ids = Object.keys(textureRequests);
var id = ids[ids.length - 1];
scope.textureAliveRequestsCount = scope.textureAliveRequestsCount + (textureAliveRequests.hasOwnProperty(id) ? 0 : 1);
textureAliveRequests[id] = textureRequests[id];
var url = textureAliveRequests[id].url;
delete textureRequests[id];
scope.textureRequestsCount--;
// console.log('(2) scope.textureAliveRequestsCount: ', scope.textureAliveRequestsCount);
// console.log('(2) scope.textureRequestsCount: ', scope.textureRequestsCount);
(function(url, id) {
// console.log("Asking for loading: ", url);
// zoom =
textureAliveRequests[id].request = scope.textureLoader.load(url,
function(texture) {
textures[id] = texture;
if (textureAliveRequests.hasOwnProperty(id)) {
textureAliveRequests[id].onLoaded(texture);
delete textureAliveRequests[id];
scope.textureAliveRequestsCount--;
// console.log('(0) scope.textureAliveRequestsCount: ', scope.textureAliveRequestsCount);
// console.log('(0) scope.textureRequestsCount: ', scope.textureRequestsCount);
}
scope.loadNextTile();
},
function() {},
function() {
if (textureAliveRequests.hasOwnProperty(id)) {
// textureAliveRequests[id].onLoaded(texture);
delete textureAliveRequests[id];
scope.textureAliveRequestsCount--;
// console.log('scope.textureAliveRequestsCount: ', scope.textureAliveRequestsCount);
// console.log('scope.textureRequestsCount: ', scope.textureRequestsCount);
}
scope.loadNextTile();
}
);
})(url, id);
}
},
// var TILE_PROVIDER01 = '.tile.openstreetmap.org';
// var TILE_PROVIDER01_RANDOM = ['a', 'b', 'c'];
// var TILE_PROVIDER01_FILE_EXT = 'png';
tilePreload: function(zoom, xtile, ytile, onLoaded) {
var scope = this;
var textures = scope.textures;
var textureRequests = scope.textureRequests;
var textureAliveRequests = scope.textureAliveRequests;
var id = zoom + '/' + xtile + '/' + ytile;
for (var diff = 0; diff < zoom; diff++) {
var power = Math.pow(2, diff);
var idZoomOther = (+zoom - diff) + '/' + Math.floor(xtile / power) + '/' + Math.floor(ytile / power);
// console.log('Looking for texture: ', idZoomOther);
if (textures.hasOwnProperty(idZoomOther)) {
// onLoaded(textures[idZoomOther]);
// origin : bottom left
var tex = textures[idZoomOther].clone();
tex.repeat.x = 1 / power;
tex.repeat.y = 1 / power;
var xOffset = xtile - Math.floor(xtile / power) * power
// console.log('xOffset: ', xOffset);
var yOffset = (power - 1) - (ytile - Math.floor(ytile / power) * power);
// console.log('yOffset: ', yOffset);
tex.offset.x = xOffset * tex.repeat.x;
tex.offset.y = yOffset * tex.repeat.y;
tex.needsUpdate = true;
onLoaded(tex);
return;
}
}
// for (var diff = Math.min(zoom - 19, -8); diff < Math.min(zoom - 1, -1); diff++) {
// var power = Math.pow(2, diff);
// var idZoomOther = (+zoom - diff) + '/' + Math.floor(xtile / power) + '/' + Math.floor(ytile / power);
// // console.log('Looking for texture: ', idZoomOther);
// if (textures.hasOwnProperty(idZoomOther)) {
// // onLoaded(textures[idZoomOther]);
// // origin : bottom left
// var tex = textures[idZoomOther].clone();
// tex.repeat.x = 1 / power;
// tex.repeat.y = 1 / power;
// var xOffset = xtile - Math.floor(xtile / power) * power
// console.log('xOffset: ', xOffset);
// var yOffset = (power - 1) - (ytile - Math.floor(ytile / power) * power);
// console.log('yOffset: ', yOffset);
// tex.offset.x = xOffset * tex.repeat.x;
// tex.offset.y = yOffset * tex.repeat.y;
// tex.needsUpdate = true;
// onLoaded(tex);
// return;
// }
// }
},
tileFactory: function(url, zoom, xtile, ytile, onLoaded) {
var scope = this;
var textures = scope.textures;
var textureRequests = scope.textureRequests;
var textureAliveRequests = scope.textureAliveRequests;
// var id = 'tile' + zoom + '_' + xtile + '_' + ytile + '_' + layerName;
// var myUrl = new URL(url);
var id = zoom + '/' + xtile + '/' + ytile;
if (textures.hasOwnProperty(id)) {
// onLoaded(textures[id]);
} else {
scope.textureRequestsCount = scope.textureRequestsCount + (textureRequests.hasOwnProperty(id) ? 0 : 1);
// console.log('scope.textureAliveRequestsCount: ', scope.textureAliveRequestsCount);
// console.log('scope.textureRequestsCount: ', scope.textureRequestsCount);
textureRequests[id] = {
zoom: zoom,
xtile: xtile,
ytile: ytile,
url: url,
onLoaded: onLoaded
}
scope.loadNextTile();
}
},
cancelOtherRequests: function(currentIds) {
var scope = this;
var textures = scope.textures;
var textureRequests = scope.textureRequests;
var textureAliveRequests = scope.textureAliveRequests;
// console.log('currentIds: ', JSON.stringify(currentIds));
for (var id in textureRequests) {
if (!currentIds.hasOwnProperty(id)) {
delete textureRequests[id];
scope.textureRequestsCount--;
// console.log('id: ', id);
// console.log('(1) scope.textureAliveRequestsCount: ', scope.textureAliveRequestsCount);
// console.log('(1) scope.textureRequestsCount: ', scope.textureRequestsCount);
}
}
for (var id in textureAliveRequests) {
if (!currentIds.hasOwnProperty(id)) {
// if (textureAliveRequests[id].request.hasOwnProperty('abort')) {
// textureAliveRequests[id].request.abort();
// }
// delete textureAliveRequests[id];
// textureAliveRequestsCount--;
}
}
scope.loadNextTile();
},
}
This diff is collapsed.
This diff is collapsed.
OpenEarthView.Terrain.ElevationTerrain = function(name, urls, options) {
this.name = (name !== undefined) ? name : 'OpenEarthView';
if (OpenEarthViewTerrains.hasOwnProperty(name)) {
console.err('Cannot register this already existing layer !');
return;
}
OpenEarthViewTerrains[name] = (urls !== undefined) ? urls : [
'http://localhost:8084/terrain?tile=${z},${x},${y},${lod}'
];
};
OpenEarthView.Terrain.ElevationTerrain.prototype = {
constructor: OpenEarthView.Terrain.ElevationTerrain,
type: 'terrain',
getName: function() {
return this.name
},
getUrl: function(zoom, xtile, ytile, lod) {
var scope = this;
var urls = OpenEarthViewTerrains[scope.name];
var urlRandom = urls[Math.floor(Math.random() * urls.length)];
var url = urlRandom.replace('${z}', zoom);
url = url.replace('${x}', xtile);
url = url.replace('${y}', ytile);
return url.replace('${lod}', lod);
}
}
// this.terrains["defaultTerrain"] = new OpenEarthView.Terrain.FlatTerrain("FlatTerrain");
// // this.addTerrain("defaultTerrain", new OpenEarthView.Terrain.FlatTerrain("FlatTerrain"));
// // world.addTerrain(new OpenEarthView.Terrain.FlatTerrain("FlatTerrain"));
OpenEarthView.Terrain.FlatTerrain = function(name, urls, options) {
this.name = (name !== undefined) ? name : 'OpenEarthView';
if (OpenEarthViewTerrains.hasOwnProperty(name)) {
console.err('Cannot register this already existing layer !');
return;
}
OpenEarthViewTerrains[name] = [];
};
OpenEarthView.Terrain.FlatTerrain.prototype = {
constructor: OpenEarthView.Terrain.FlatTerrain,
type: 'terrain',
getName: function() {
return this.name
},
getUrl: function(zoom, xtile, ytile) {
return undefined;
}
}
var OpenEarthViewTerrains = {};
OpenEarthView.Terrain = {};
// TOOLBOX //
/**
Open Earth View - viewer-threejs
The MIT License (MIT)
Copyright (c) 2016 Clément Igonet
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),