Permalink
Browse files

Update demo to use require.js

  • Loading branch information...
1 parent 4ff1ff9 commit 059dc315b47f185621baccb02aa587ec296b4b08 Fabien Lavignotte committed Mar 4, 2013
Showing with 121 additions and 158 deletions.
  1. +0 −135 demo/client/GlobWeb.min.js
  2. +3 −0 demo/client/build.bat
  3. +17 −0 demo/client/build.js
  4. +1 −8 demo/client/index.html
  5. +35 −15 demo/client/main.js
  6. +65 −0 demo/client/main.min.js
View
Oops, something went wrong.
View
@@ -0,0 +1,3 @@
+call "C:\Program Files\nodejs\nodejsvars.bat"
+node ../../build/r.js -o build.js
+pause
View
@@ -0,0 +1,17 @@
+({
+ paths: {
+ gw: '../../src'
+ },
+ name: "main",
+ exclude: ['js/jquery-1.7.2.min','js/jquery-ui-1.8.20.custom.min'],
+ out: "main.min.js",
+ optimize: "uglify2",
+ uglify2: {
+ output: {
+ beautify: false
+ },
+ warnings: true,
+ mangle: true
+ },
+
+})
View
@@ -7,15 +7,8 @@
<link rel="stylesheet" type="text/css" href="css/redmond/jquery-ui-1.8.20.custom.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
-<!--script type="text/javascript" src="GlobWeb.min.js"></script-->
-<script type="text/javascript" src="../../src/GlobWeb.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
-<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
-<script type="text/javascript" src="js/jquery-ui-1.8.20.custom.min.js"></script>
-
-
-<script type="text/javascript" src="config.js"></script>
-<script type="text/javascript" src="main.js"></script>
+<script type="text/javascript" data-main="main" src="require.min.js"></script>
</head>
View
@@ -1,3 +1,18 @@
+requirejs.config({
+ shim: {
+ 'js/jquery-ui-1.8.20.custom.min': ['js/jquery-1.7.2.min'],
+ },
+ paths: {
+ gw: '../../src'
+ }
+});
+
+require(['gw/Globe','gw/WMSLayer','gw/WCSElevationLayer', 'gw/VectorLayer', 'gw/AtmosphereLayer',
+ 'gw/PathAnimation','gw/Navigation','gw/Stats','gw/FeatureStyle',
+ 'gw/PointRenderer', 'gw/LineStringRenderable',
+ 'js/jquery-1.7.2.min','js/jquery-ui-1.8.20.custom.min','config'],
+ function(Globe,WMSLayer,WCSElevationLayer,VectorLayer,AtmosphereLayer,PathAnimation,Navigation,Stats,FeatureStyle) {
+
var globe = null;
var nav = null;
var pathAnimation = null;
@@ -52,7 +67,7 @@ onElevationClicked = function(e)
// Called when a POI is clicked
onPoiClicked = function(e)
{
- nav.zoomTo( [e.currentTarget.lon, e.currentTarget.lat], 20000, 1500 );
+ nav.zoomTo( [ parseFloat(e.currentTarget.dataset.long), parseFloat(e.currentTarget.dataset.lat) ], 20000, 1500 );
}
onWindowResize = function(e)
@@ -66,7 +81,12 @@ onWindowResize = function(e)
// Initialize the POI into GlobWeb
initializePoi = function(pois)
{
- var poiLayer = new GlobWeb.VectorLayer();
+ var poiLayer = new VectorLayer({
+ style: new FeatureStyle({
+ iconUrl: 'hotspot.png',
+ fillColor: [1, 1, 1, 1]
+ })
+ });
for (var i=0; i < pois.length; i++)
{
pois[i].lat = parseFloat( pois[i].getAttribute("data-lat") );
@@ -80,7 +100,6 @@ initializePoi = function(pois)
coordinates: [pois[i].lon,pois[i].lat,pois[i].height]
}
};
- //var poi = new GlobWeb.Poi(pois[i].name,pois[i].lat,pois[i].lon,pois[i].height);
poiLayer.addFeature( poi );
}
globe.addLayer(poiLayer);
@@ -90,19 +109,17 @@ initializePoi = function(pois)
initializeElevation = function(value)
{
elevations["None"] = null;
- elevations["GTOPO"] = new GlobWeb.WMSElevationLayer({ baseUrl: config.serverUrl + "/wmspub", layers: "GTOPO"});
- //new GlobWeb.BasicElevationLayer( { baseUrl: config.serverUrl + "/GlobeWeb/map.php"} );
-
+ elevations["GTOPO"] = new WCSElevationLayer({ baseUrl: config.serverUrl + "/wcspub", coverage: "GTOPO", version: "1.0.0"});
activeElevation = elevations[value];
globe.setBaseElevation( activeElevation );
}
// Initialize the imagery
initializeImagery = function(value)
{
- imageries["PO"] = new GlobWeb.WMSLayer( { baseUrl: config.serverUrl + "/wmspo", layers: "PO150m,POFrance15m,POI15m" } );
- //imageries["Landsat"] = new GlobWeb.WMSLayer( { baseUrl: config.serverUrl + "/wmspo", layers: "PO150m,POFrance15m,POI15m" } );
- imageries["OSM"] = new GlobWeb.WMSLayer( { baseUrl: config.serverUrl + "/geocache/wms", layers: "imposm-fr", format: "image/png" } );
+ imageries["PO"] = new WMSLayer( { baseUrl: config.serverUrl + "/wmspo", layers: "PO150m,POFrance15m,POI15m" } );
+ //imageries["Landsat"] = new WMSLayer( { baseUrl: config.serverUrl + "/wmspo", layers: "PO150m,POFrance15m,POI15m" } );
+ imageries["OSM"] = new WMSLayer( { baseUrl: config.serverUrl + "/geocache/wms", layers: "imposm-fr", format: "image/png" } );
activeImagery = imageries[value];
globe.setBaseImagery( activeImagery );
@@ -199,12 +216,12 @@ initializePath = function()
coords.push( [ lon.childNodes[0].nodeValue / 1000000.0, lat.childNodes[0].nodeValue / 1000000.0 ] );
}
- var pathLayer = new GlobWeb.VectorLayer();
+ var pathLayer = new VectorLayer();
var feature = { type: "Feature", geometry: { type: "LineString", coordinates: coords } };
pathLayer.addFeature( feature );
globe.addLayer(pathLayer);
- pathAnimation = new GlobWeb.PathAnimation(coords,1000,undefined);
+ pathAnimation = new PathAnimation(coords,1000,undefined);
globe.addAnimation(pathAnimation);
}
@@ -258,8 +275,7 @@ $(function()
// Initialize webgl
try
{
- globe = new GlobWeb.Globe({ canvas: 'GlobWebCanvas',
- atmosphere: false,
+ globe = new Globe({ canvas: 'GlobWebCanvas',
shadersPath: config.shadersPath
});
}
@@ -269,7 +285,9 @@ $(function()
document.getElementById('webGLNotAvailable').style.display = "block";
}
- nav = new GlobWeb.Navigation(globe);
+ nav = new Navigation(globe);
+
+ globe.addLayer( new AtmosphereLayer() );
initializeImagery('PO');
initializeElevation('GTOPO');
@@ -278,7 +296,9 @@ $(function()
initializePath();
// Init Stats
- var stats = new GlobWeb.Stats(globe,{element: "fps",verbose: false});
+ var stats = new Stats(globe,{element: "fps",verbose: false});
+
+});
});
View
Oops, something went wrong.

0 comments on commit 059dc31

Please sign in to comment.