1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| const viewer = new Cesium.Viewer("cesiumContainer", { geocoder: false, sceneModePicker: false, homeButton: false, navigationHelpButton: false, baseLayerPicker: false, navigationInstructionsInitiallyVisible: false, fullscreenButton: false, selectionIndicator: false, skyBox: false, timeline: false, animation: false, shouldAnimate: true, terrain: Cesium.Terrain.fromWorldTerrain(), }); const scene = viewer.scene; scene.globe.depthTestAgainstTerrain = false;
viewer.cesiumWidget.creditContainer.style.display = "none";
let tileset; try {
tileset = await Cesium.Cesium3DTileset.fromIonAssetId(2342602); viewer.scene.primitives.add(tileset); viewer.zoomTo(tileset); } catch (error) { console.log(`瓦片集加载出错: ${error}`); }
const shaders = { NO_TEXTURE: undefined,
UNCERTAINTY_CE90: new Cesium.CustomShader({ fragmentShaderText: ` void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) { int horizontalUncertainty = fsInput.metadata.r3dm_uncertainty_ce90sum; material.diffuse = vec3(float(horizontalUncertainty) / 255.0); } `, }), UNCERTAINTY_LE90: new Cesium.CustomShader({ fragmentShaderText: ` void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) { int verticalUncertainty = fsInput.metadata.r3dm_uncertainty_le90sum; material.diffuse = vec3(float(verticalUncertainty) / 255.0); } `, }), UNCERTAINTY: new Cesium.CustomShader({ fragmentShaderText: ` void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) { int uncertainty = fsInput.metadata.r3dm_uncertainty_ce90sum + fsInput.metadata.r3dm_uncertainty_le90sum; material.diffuse = vec3(float(uncertainty) / 255.0); } `, }), };
Sandcastle.addDefaultToolbarMenu([ { text: "水平不确定性", onselect: function () { tileset.customShader = shaders.UNCERTAINTY_CE90; }, }, { text: "垂直不确定性", onselect: function () { tileset.customShader = shaders.UNCERTAINTY_LE90; }, }, { text: "综合不确定性", onselect: function () { tileset.customShader = shaders.UNCERTAINTY; }, }, { text: "无不确定性", onselect: function () { tileset.customShader = shaders.NO_TEXTURE; }, }, ]); tileset.customShader = shaders.UNCERTAINTY_CE90;
|