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
| const viewer = new Cesium.Viewer("cesiumContainer");
try { const tileset = await Cesium.Cesium3DTileset.fromIonAssetId(75343, { customShader: new Cesium.CustomShader({
lightingModel: Cesium.LightingModel.UNLIT, fragmentShaderText: ` void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) { material.diffuse = vec3(0.0, 0.0, 1.0); material.diffuse.g = -fsInput.attributes.positionEC.z / 1.0e4; } `, }), }); viewer.scene.primitives.add(tileset); } catch (error) { console.log(`瓦片加载出现错误: ${error}`); }
const initialPosition = Cesium.Cartesian3.fromDegrees( -74.01881302800248, 40.69114333714821, 753, ); const initialOrientation = new Cesium.HeadingPitchRoll.fromDegrees( 21.27879878293835, -21.34390550872461, 0.0716951918898415, ); viewer.scene.camera.setView({ destination: initialPosition, orientation: initialOrientation, endTransform: Cesium.Matrix4.IDENTITY, });
|