why cesium can not display the terrain?
There was a problem loading the terrain in cesium. The cesium globe displays normally after removing the terrain. In cesium1.96, chrome displays the following error: Cesium.js:85 An error occurred in "Py": Failed to obtain terrain tile X: 0 Y: 0 Level: 0. Error message: "RangeError: Invalid typed array length: 8894653434" Cesium.js:85 An error occurred in "Py": Failed to obtain terrain tile X: 1 Y: 0 Level: 0. Error message: "RangeError: Invalid typed array length: 2017542741"
cesium code like this: var terrainProvider1=new Cesium.CesiumTerrainProvider({ url:"http://localhost:9000/" }); const viewer = new Cesium.Viewer("cesiumContainer", { baseLayerPicker: false, imageryProvider: imageryProvider, terrainProvider:terrainProvider1 }); viewer.scene.globe.enableLighting=true;
However, in the latest cesium, chrome does not output any errors and just does not display the globe. How can I solve this problem? @homme @thomas001 @chris-cooper @tmizu23 @kyosho-
@Brilliant-orange I faced the same problem. Unzipping generated tiles solved the issue for me.
@Brilliant-orange I faced the same problem. Unzipping generated tiles solved the issue for me. @bingo-soft Would you mind tell us how did you do that? I have this problem and i don't know how to unzip terrain files. thanks.
写.terrain时,不能用gzwrite,那样写不出正确的.terrain,而是用fwrite方式. 修正如下:在terraintile.cpp中改写
void Terrain::writeFile(const char fileName) const { FILE terrainFile = fopen(fileName, "wb");
if (terrainFile == NULL) {
throw CTBException("Failed to open file");
}
// Write the height data,float应该是4 * TILE_CELL_SIZE
//if (gzwrite(terrainFile, mHeights.data(), TILE_CELL_SIZE * 2) == 0)
if (fwrite( mHeights.data(), sizeof(i_terrain_height),TILE_CELL_SIZE, terrainFile) == 0)
{
fclose(terrainFile);
throw CTBException("Failed to write height data");
}
// Write the child flags
if (fputc(mChildren,terrainFile ) == -1) {
fclose(terrainFile);
throw CTBException("Failed to write child flags");
}
// Write the water mask
if (fwrite(mMask,sizeof(char), mMaskLength,terrainFile ) == 0) {
fclose(terrainFile);
throw CTBException("Failed to write water mask");
}
fclose(terrainFile);
} /* void Terrain::writeFile(const char *fileName) const { gzFile terrainFile = gzopen(fileName, "wb");
if (terrainFile == NULL) {
throw CTBException("Failed to open file");
}
// Write the height data,float应该是4 * TILE_CELL_SIZE
//if (gzwrite(terrainFile, mHeights.data(), TILE_CELL_SIZE * 2) == 0)
if (gzwrite(terrainFile, mHeights.data(), TILE_CELL_SIZE * sizeof(i_terrain_height)) == 0)
{
gzclose(terrainFile);
throw CTBException("Failed to write height data");
}
// Write the child flags
if (gzputc(terrainFile, mChildren) == -1) {
gzclose(terrainFile);
throw CTBException("Failed to write child flags");
}
// Write the water mask
if (gzwrite(terrainFile, mMask, mMaskLength) == 0) {
gzclose(terrainFile);
throw CTBException("Failed to write water mask");
}
// Try and close the file
switch (gzclose(terrainFile)) {
case Z_OK:
break;
case Z_STREAM_ERROR:
case Z_ERRNO:
case Z_MEM_ERROR:
case Z_BUF_ERROR:
default:
throw CTBException("Failed to close file");
}
}
@Brilliant-orange I faced the same problem. Unzipping generated tiles solved the issue for me. hello?how to unzip the .terrain file?
@Brilliant-orange I faced the same problem. Unzipping generated tiles solved the issue for me. hello?how to unzip the .terrain file?
I know its been over a year since this issue was opened, but figured I'd leave this here in case anyone else is experiencing this issue.
Rather than unzipping the gzipped terrain tile, what solved it for me was that I had to configure my server to set the following headers for .terrain files, as
res.setHeader("Content-Type", "application/vnd.quantized-mesh");
res.setHeader("Content-Encoding", "gzip");
These links helped me figure this out.
https://github.com/tum-gis/cesium-terrain-builder-docker/issues/8#issuecomment-662863407 https://stackoverflow.com/questions/31164976/unable-to-serve-terrain-files-in-cesium-sandcastle
thank you verymuch,this problem confuse me so lang