Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
  2.         url: './data/meta',
  3.         cullWithChildrenBounds: true,
  4.     }));
  5.  
  6.  
  7.     tileset.style = new Cesium.Cesium3DTileStyle({
  8.         pointSize: 2,
  9.         color: 'color("red")',
  10.     })
  11.  
  12.     function getPoint(typedArray, index, { isQuantized = false, rtcCenter = null, quantized: { scale, offset } }) {
  13.         let positionX = typedArray[index * 3],
  14.             positionY = typedArray[(index * 3) + 1],
  15.             positionZ = typedArray[(index * 3) + 2];
  16.         if (rtcCenter != null) {
  17.             positionX += rtcCenter.x;
  18.             positionY += rtcCenter.y;
  19.             positionZ += rtcCenter.z;
  20.         } else if (isQuantized) {
  21.             positionX = positionX * scale.x / SHORT_CAPACITY + offset.x;
  22.             positionY = positionY * scale.y / SHORT_CAPACITY + offset.y;
  23.             positionZ = positionZ * scale.z / SHORT_CAPACITY + offset.z;
  24.         }
  25.         return new Cesium.Cartesian3(positionX, positionY, positionZ);
  26.     }
  27.  
  28.  
  29.     tileset.tileLoad.addEventListener(tile => {
  30.         // highjack the cesium tile loading process
  31.         tile._contentState = Cesium.Cesium3DTileContentState.PROCESSING;
  32.         const { _quantizedVolumeOffset: offset, _quantizedVolumeScale: scale, _parsedContent: { positions } } = tile._content;
  33.         const cartographicPositions = [], options = { isQuantized: true,  quantized: { scale, offset }};
  34.         for (let idx = 0; idx < positions.length / 3; idx++)
  35.             cartographicPositions.push(Cesium.Cartographic.fromCartesian(getPoint(positions, idx, options)))
  36.  
  37.            
  38.         Cesium.sampleTerrainMostDetailed(terrainProvider, cartographicPositions).then(updatedPoints => {
  39.             //completed height re-quanitzation
  40.             console.log(cartographicPositions);
  41.             tile._contentState = Cesium.Cesium3DTileContentState.READY;
  42.         });
  43.  
  44.  
  45.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement