使用
var rectangle = new Cesium.RectangleGeometry({
rectangle: Cesium.Rectangle.fromDegrees(110.0, 29.0, 114.0, 32.0),});var circle = new Cesium.CircleGeometry({
center: Cesium.Cartesian3.fromDegrees(115.59777, 30.03883),radius: 100000.0,});var len = 1.0;var longitude = 114;var latitude = 30;var positions = Cesium.Cartesian3.fromDegreesArray([longitude - len,latitude,longitude + len,latitude,]);var maximumHeight = 300000;var minimumHeight = 0;var wall = Cesium.WallGeometry.fromConstantHeights({
positions: positions,minimumHeight: minimumHeight,maximumHeight: maximumHeight,});var geometryInstances = [];geometryInstances.push(new Cesium.GeometryInstance({
geometry: rectangle,}));geometryInstances.push(new Cesium.GeometryInstance({
geometry: circle,}));geometryInstances.push(new Cesium.GeometryInstance({
geometry: wall,}));var options = {
geometryInstances: geometryInstances,appearance: new Cesium.MaterialAppearance({
renderState: {
depthTest: {
enabled: true },depthMask: true,blending: Cesium.BlendingState.ALPHA_BLEND,cull: {
enabled: false,face: Cesium.CullFace.FRONT,},},translucent: false,}),asynchronous: true,};var fs = "czm_material czm_getMaterial(czm_materialInput materialInput) { \n" +" czm_material material = czm_getDefaultMaterial(materialInput); \n" +" vec2 st = materialInput.st; \n" +" vec4 color = texture2D(image, st); \n" +" material.diffuse = color.rgb; \n" +" material.alpha = 1.0 - min(color.r,min(color.g,color.b)); \n" +" return material; \n" +"} \n";options.url = 'http://img6.cache.netease.com/game/2016/3/3/20160303135738201d6.gif';options.fragmentShaderSource = fs;var primitive = new GifPrimitive(options);viewer.scene.primitives.add(primitive);
可以通过加入着色器控制透明度
使用了libgif的canvas,编译需要npm引入
"dependencies": {
"libgif": "^0.0.3"}
GifPrimitive