Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var worldTerrain = Cesium.createWorldTerrain({
  2.     requestWaterMask: true,
  3.     requestVertexNormals: true
  4. });
  5.  
  6. var viewer = new Cesium.Viewer('cesiumContainer', {
  7.     terrainProvider: worldTerrain,
  8.     timeline: false,
  9.     animation: false,
  10.     baseLayerPicker: true,
  11.     fullscreenButton: false,
  12.     geocoder: false,
  13.     homeButton: false,
  14.     sceneModePicker: false,
  15.     scene3DOnly: true,
  16.     shadows: false
  17. });
  18.  
  19. viewer.scene.frameState.creditDisplay.destroy();
  20. viewer.baseLayerPicker.viewModel.selectedImagery = viewer.baseLayerPicker.viewModel.imageryProviderViewModels[9];
  21.  
  22. function addTileset(url_, heightOffset = 0.0)
  23. {
  24.     var tileset_ = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
  25.         url: url_,
  26.         maximumScreenSpaceError: 1,
  27.         //shadows: Cesium.ShadowMode.DISABLED,
  28.         skipLevelOfDetail: false
  29.     }));
  30.  
  31.     tileset_.readyPromise.then(function (tileset)
  32.     {
  33.         // Position tileset
  34.         var boundingSphere = tileset.boundingSphere;
  35.         var cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
  36.         var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
  37.         var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, heightOffset);
  38.         var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
  39.         tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
  40.     });
  41.  
  42.     return tileset_;
  43. }
  44.  
  45. viewer.entities.removeAll();
  46.  
  47. var tileset = addTileset('/3dTilesets/kremlin/tileset.json', 2.0);
  48.  
  49. viewer.zoomTo(tileset)
  50.     .otherwise(function (error) {
  51.         console.log(error);
  52.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement