zoukankan      html  css  js  c++  java
  • Cesium添加水面

    var viewer = new Cesium.Viewer('cesiumContainer');
    var
    waterPrimitive = new Cesium.Primitive({ //show:false,// 默认隐藏 allowPicking:false, geometryInstances : new Cesium.GeometryInstance({ geometry : new Cesium.PolygonGeometry({ polygonHierarchy : new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights(waterFace)),//waterFace是一个组成多边形顶点数组[lon,lat,alt] //extrudedHeight: 0,//注释掉此属性可以只显示水面 perPositionHeight : true//注释掉此属性水面就贴地了 }) }), // 可以设置内置的水面shader appearance : new Cesium.EllipsoidSurfaceAppearance({ material : new Cesium.Material({ fabric : { type : 'Water', uniforms : { //baseWaterColor:new Cesium.Color(0.0, 0.0, 1.0, 0.5), //blendColor: new Cesium.Color(0.0, 0.0, 1.0, 0.5), //specularMap: 'gray.jpg', normalMap: 'waterNormals.jpg', frequency: 1000.0, animationSpeed: 0.01, amplitude: 10.0 } } }), fragmentShaderSource:'varying vec3 v_positionMC; varying vec3 v_positionEC; varying vec2 v_st; void main() { czm_materialInput materialInput; vec3 normalEC = normalize(czm_normal3D * czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0))); #ifdef FACE_FORWARD normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC); #endif materialInput.s = v_st.s; materialInput.st = v_st; materialInput.str = vec3(v_st, 0.0); materialInput.normalEC = normalEC; materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, materialInput.normalEC); vec3 positionToEyeEC = -v_positionEC; materialInput.positionToEyeEC = positionToEyeEC; czm_material material = czm_getMaterial(materialInput); #ifdef FLAT gl_FragColor = vec4(material.diffuse + material.emission, material.alpha); #else gl_FragColor = czm_phong(normalize(positionToEyeEC), material); gl_FragColor.a=0.5; #endif } '//重写shader,修改水面的透明度 }) });
    water
    =viewer.scene.primitives.add(waterPrimitive);
  • 相关阅读:
    人民币贬值之后该买什么
    elasticsearch系列(一): elasticsearch安装(docker方式)
    sql处理字符串: replace替换, substring_index拆分和处理json
    ab并发测试
    java反射--PropertyDescriptor类、Introspector类、BeanUtils库
    sql特殊用法: 查询添加, 查询更新, 添加或更新
    es查看和删除索引
    windows同步文件夹-增量同步最新修改
    mvn打包-指定模块
    grep过滤文本,awk,sort去重显示
  • 原文地址:https://www.cnblogs.com/coolbear/p/9039653.html
Copyright © 2011-2022 走看看