When i write below code and host .terrain files on Tomcat, i can correctly see elevations of an area:
var terrainProvider = new Cesium.CesiumTerrainProvider({
url: 'http://localhost:8080/terrain/terrain_52_06'
});
this.scene.terrainProvider = terrainProvider;
But, when i write below code and host .terrain files on nodejs server, i can see elevations of the area, but in addition to that i can see elevated spikes all over map on the globe also:
var terrainProvider = new Cesium.CesiumTerrainProvider({
url: 'http://localhost:3005/terrain/terrain_52_06'
});
this.scene.terrainProvider = terrainProvider;
Basically, my app runs on node server at: http://localhost:3005. So, in the Tomcat case, i enable CORS and then it works, whereas in Node server i dont need CORS.
You mush specify headers "Content-Type" and "Content-Encoding" for .terrain files. For example, if you are using express, it will be something like this:
app.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'X-Requested-With');
if (path.extname(req.url) === '.terrain') {
res.header('Content-Type', 'application/octet-stream');
res.header('Content-Encoding', 'gzip');
}
next();
}
I hope it will help.