- //加载云特效
-
function LoadClouds() {
-
const worldRectangle1 = viewer.scene.primitives.add(new Cesium.Primitive({
-
geometryInstances: new Cesium.GeometryInstance({
-
geometry: new Cesium.RectangleGeometry({
- rectangle: Cesium.Rectangle.fromDegrees(-180.0, -90.0, 180.0, 90.0),
- vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
- })
- }),
-
appearance: new Cesium.EllipsoidSurfaceAppearance({
-
material: new Cesium.Material({
-
fabric: {
- type: ‘Image’,
-
uniforms: {
- image: ‘../../img/clouds.png’,
- radians: 0,
- },
- //shader
- source: `
- #define M_PI 3.1415926535897932384626433832795
- uniform sampler2D image;
- uniform float radians;
- czm_material czm_getMaterial(czm_materialInput materialInput)
-
{
- czm_material material = czm_getDefaultMaterial(materialInput);
- vec2 st = vec2(materialInput.st.x – 0.5, materialInput.st.y – 0.5);
- float alpha = 1.3 – st.x – 0.5;
- float current_radians = atan(st.y, st.x);
- float radius = sqrt(st.x * st.x + st.y * st.y);
-
if (radius < 0.50) {
- current_radians = current_radians – radians;
- st = vec2(cos(current_radians) * radius, sin(current_radians) * radius);
- st = vec2(st.x + 0.5, st.y + 0.5);
- vec4 colorImage = texture2D(image, st);
- material.diffuse = colorImage.rgb;
- material.alpha = colorImage.a * alpha;
-
} else {
- material.alpha = 0.0;
- }
- return material;
- }
- `
- }
- }),
- aboveGround: true
- }),
- show: true
- }))
- var radians = 0
-
viewer.scene.postRender.addEventListener(() => {
- radians += Math.PI / 50000;
- worldRectangle1.appearance.material.uniforms.radians = radians;
- });
- }
- LoadClouds();
版权声明:本文为QQhelphelp原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。