123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- var Cesium = require("cesium/Cesium");
- export default
- function addCircleWave(viewer,msgarr,color) {
- viewer.entities.add({
- id:msgarr.userid+'',
- name: msgarr.username,
- position: Cesium.Cartesian3.fromDegrees(msgarr.lng ,msgarr.lat, 0 ),
- ellipse: {
- height: 0,
- semiMinorAxis: 15,
- semiMajorAxis: 15,
- material: new Cesium.CircleWaveMaterialProperty({
- duration: 2e3,
- gradient: 0,
- color: color,
- count: 3
- })
- },
- point: {
- pixelSize: 10,
- color: Cesium.Color.YELLOW,
- },
- label: {
- text: msgarr.username,
- font: "14pt monospace",
- style: Cesium.LabelStyle.FILL_AND_OUTLINE,
- outlineWidth: 2,
- verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
- pixelOffset: new Cesium.Cartesian2(0, -9),
- },
- });
- }
- export class CircleWaveMaterialProperty {
- constructor(options) {
- options = Cesium.defaultValue(options, Cesium.defaultValue.EMPTY_OBJECT);
- this._definitionChanged = new Cesium.Event();
- this._color = undefined;
- this._colorSubscription = undefined;
- this.color = options.color;
- this.duration = Cesium.defaultValue(options.duration, 1e3);
- this.count = Cesium.defaultValue(options.count, 2);
- if (this.count <= 0) this.count = 1;
- this.gradient = Cesium.defaultValue(options.gradient, 0.1);
- if (this.gradient < 0) this.gradient = 0;
- else if (this.gradient > 1) this.gradient = 1;
- this._time = performance.now();
- }
- }
- Object.defineProperties(CircleWaveMaterialProperty.prototype, {
- isConstant: {
- get: function() {
- return false;
- }
- },
- definitionChanged: {
- get: function() {
- return this._definitionChanged;
- }
- },
- color: Cesium.createPropertyDescriptor('color')
- });
- CircleWaveMaterialProperty.prototype.getType = function(time) {
- return Cesium.Material.CircleWaveMaterialType;
- }
- CircleWaveMaterialProperty.prototype.getValue = function(time, result) {
- if (!Cesium.defined(result)) {
- result = {};
- }
- result.color = Cesium.Property.getValueOrClonedDefault(this._color, time, Cesium.Color.WHITE, result.color);
- result.time = (performance.now() - this._time) / this.duration;
- result.count = this.count;
- result.gradient = 1 + 10 * (1 - this.gradient);
- return result;
- }
- CircleWaveMaterialProperty.prototype.equals = function(other) {
- return this === other ||
- (other instanceof CircleWaveMaterialProperty &&
- Cesium.Property.equals(this._color, other._color))
- }
- Cesium.Material.CircleWaveMaterialType = 'CircleWaveMaterial';
- Cesium.Material.PolylineTrailSource =
- // `czm_material czm_getMaterial(czm_materialInput materialInput)\n
- // {\n
- // czm_material material = czm_getDefaultMaterial(materialInput);\n
- // material.diffuse = 1.5 * color.rgb;\n
- // vec2 st = materialInput.st;\n
- // vec3 str = materialInput.str;\n
- // float dis = distance(st, vec2(0.5, 0.5));\n
- // float per = fract(time);\n
- // if (abs(str.z) > 0.001) {\n
- // discard;\n
- // }\n
- // if (dis > 0.5) { \n
- // discard; \n
- // } else { \n
- // float perDis = 0.5 / count;\n
- // float disNum; \n
- // float bl = .0; \n
- // for (int i = 0; i <= 999; i++) { \n
- // if (float(i) <= count) { \n
- // disNum = perDis *float(i) - dis + per / count; \n
- // if (disNum > 0.0) { \n
- // if (disNum < perDis) { \n
- // bl = 1.0 - disNum / perDis;\n
- // }\n
- // else if(disNum - perDis < perDis) { \n
- // bl = 1.0 - abs(1.0 - disNum / perDis); \n
- // } \n
- // material.alpha = pow(bl, gradient); \n
- // } \n
- // } \n
- // } \n
- // } \n
- // return material; \n
- // } \n`;
- "czm_material czm_getMaterial(czm_materialInput materialInput)\n" +
- "{\n" +
- "czm_material material = czm_getDefaultMaterial(materialInput);\n" +
- "material.diffuse = 1.5 * color.rgb;\n" +
- "vec2 st = materialInput.st;\n" +
- "float dis = distance(st, vec2(0.5, 0.5));\n" +
- "float per = fract(time);\n" +
- "if(dis > per * 0.5){\n" +
- "material.alpha = 0.0;\n"+
- "discard;\n" +
- "}else {\n" +
- "material.alpha = color.a * dis / per / 1.0;\n" +
- "}\n" +
- "return material;\n" +
- "}";
- Cesium.Material._materialCache.addMaterial(Cesium.Material.CircleWaveMaterialType, {
- fabric: {
- type: Cesium.Material.CircleWaveMaterialType,
- uniforms: {
- color: new Cesium.Color(1.0, 0.0, 0.0, 1.0),
- time: 1,
- count: 1,
- gradient: 0.1
- },
- source: Cesium.Material.PolylineTrailSource
- },
- translucent: function(material) {
- return !0;
- }
- });
- Cesium.CircleWaveMaterialProperty = CircleWaveMaterialProperty;
|