Cesium 若干绘制示例
一、效果
1、水流效果
2、曲线插值
3、流动箭头线
4、飞鸟
二、代码 鸟
/* * @Author: 苹果园dog * @Date: 2021-04-07 10:14:19 * @LastEditTime: 2021-04-12 18:39:52 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \web\cesiumS\cesium\cesium\mytest\Innosky2021\web\src\pages\飞鸟\Flybird.js */ import png1 from './1.png'; import png2 from './2.png'; import png3 from './3.png'; export default class Flybird { constructor(options) { this._image = options.image || 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAAiCAYAAAADILqZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAksSURBVGhD7Vh5bBTnFX8zs7Pe0xAbY7v4xBeHMUdTXIq42grqKJS2okSCUqKKpgkqpEkbCIFCWylpRKExVWLqlkYEEZKi1lSVisRVsBuZOBCMneAD2xhs1tj4wMeuvTs7M19/3+xgDAICxrD9oz/r7cx88x3v9977vnnPFE60tLQkn383/8VLp4tnmE2PHIJ5DQvqPtz5fpy1drl3oI16PZ0npdRle9KWvvC+IAiq2WXEEVbCjVuWVaZ8RZtCmbFEDSeovaKaeoNJzVriDwuduc//MWFSQqfZdcQQNsKMMaF+1bSW9AVqHMuaiudIEp0Wou5S6qk4S53tTq+atLrANuflnckTk1vMYQ+NsBFubGwcrW/6esv476Tbadwo0lqriCIziRzjSHI5iAbOkrf8OLVfkQOBpBfy5dyNv0+fFn/NHD5siOb1scPa2RkpW4J2stmJaToJej+Rt4pYVynpbdXE9Ankmv0qpS75ZkSC9ocNdCD1Ys3u17Y2Nel2c4phIWyEmSzbmR8k7TYi1U9MQDhb3NDISqQggrvLiF2rIF1PJ9fc1yhtyRxnvPeNXw3sGnOx+kDBc+Y0D4xBwo3l5aPbq6vdbW1trjNn/uko/esOO7/3eDwO7De5sLBQPnHihIVhGxiCPWgOHRZ8Pt+oniYvSFoxWRAtQ6YT4UTJCS/3EvWUg/h50sVsilz0KmXmZcbFNKwprPnl5E/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/sp7qSvkvXx+1cM/E3FyZPWLL8QKjz8BA2wh0dHdfVoNhHOCBJw0HIsyRHDFnGjCUxWEMdJUVUX+xv7Irb/rOMrZfTMle8uMsc+lAI2x7maFiz4ML43N4MGo/PixAkra2W2us7qU+d+BnLeO7tzO+v+zM+Z/xbNmIIK+HGXRtKUnItc/xXjlN7RSUNOL56WMpcXZi+ePlBs8uII7yEz5R913uycL1t7Nj/CGmL96bPnv25+er/GBkQ/RdUeHuNa+U1ywAAAABJRU5ErkJggg=='; this._positions = options.positions || []; this._color = options.color || Cesium.Color.YELLOW; this._width = options.width || 10; this._duration = options.duration || 3000; this._entities = []; this._create(); } /** * 创建 */ _create() { let preData={ preTime:Cesium.JulianDate.now(), preIndex:0, preImage:png1 } var rotation = Cesium.Math.toRadians(0); let curPolygonPositions2 = Cesium.Rectangle.fromCartesianArray(this._positions); var birdEntity = viewer.entities.add({ rectangle: { coordinates:curPolygonPositions2, material:new Cesium.ImageMaterialProperty({ image:new Cesium.CallbackProperty((time,result) => { let timestep = Cesium.JulianDate.secondsDifference(time, preData.preTime); if (timestep < 0.2) { return preData.preImage; } if(preData.preIndex===0){ preData={ preImage:png2, preTime:time, preIndex:1 } }else if(preData.preIndex===1){ preData={ preImage:png3, preTime:time, preIndex:2 } }else if(preData.preIndex===2){ preData={ preImage:png1, preTime:time, preIndex:0 } } return preData.preImage; }, false) }), rotation: new Cesium.CallbackProperty(() => rotation, false), stRotation: new Cesium.CallbackProperty(() => rotation, false), classificationType: Cesium.ClassificationType.TERRAIN, }, }); this._entities.push(birdEntity); } /** * 获取所有加到球上的entity * @returns */ getEntities() { return this._entities; } /** * 移除所有实体 */ clear() { for (let index = 0; index < this._entities.length; index++) { const element = this._entities[index]; viewer.entities.remove(element); } } /** * 定位 */ flyTo() { viewer.flyTo(this._entities); } }