Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
- url: './data/meta',
- cullWithChildrenBounds: true,
- }));
- tileset.style = new Cesium.Cesium3DTileStyle({
- pointSize: 2,
- color: 'color("red")',
- })
- function getPoint(typedArray, index, { isQuantized = false, rtcCenter = null, quantized: { scale, offset } }) {
- let positionX = typedArray[index * 3],
- positionY = typedArray[(index * 3) + 1],
- positionZ = typedArray[(index * 3) + 2];
- if (rtcCenter != null) {
- positionX += rtcCenter.x;
- positionY += rtcCenter.y;
- positionZ += rtcCenter.z;
- } else if (isQuantized) {
- positionX = positionX * scale.x / SHORT_CAPACITY + offset.x;
- positionY = positionY * scale.y / SHORT_CAPACITY + offset.y;
- positionZ = positionZ * scale.z / SHORT_CAPACITY + offset.z;
- }
- return new Cesium.Cartesian3(positionX, positionY, positionZ);
- }
- tileset.tileLoad.addEventListener(tile => {
- // highjack the cesium tile loading process
- tile._contentState = Cesium.Cesium3DTileContentState.PROCESSING;
- const { _quantizedVolumeOffset: offset, _quantizedVolumeScale: scale, _parsedContent: { positions } } = tile._content;
- const cartographicPositions = [], options = { isQuantized: true, quantized: { scale, offset }};
- for (let idx = 0; idx < positions.length / 3; idx++)
- cartographicPositions.push(Cesium.Cartographic.fromCartesian(getPoint(positions, idx, options)))
- Cesium.sampleTerrainMostDetailed(terrainProvider, cartographicPositions).then(updatedPoints => {
- //completed height re-quanitzation
- console.log(cartographicPositions);
- tile._contentState = Cesium.Cesium3DTileContentState.READY;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement