@ino-cesium/material 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +22 -39
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as Cesium from 'cesium';
|
|
2
|
-
import { Material } from 'cesium';
|
|
3
2
|
import { BaseMaterialProperty } from '@ino-cesium/common';
|
|
4
3
|
|
|
5
4
|
interface IPolylineTrailMaterialOptions {
|
|
@@ -35,7 +34,14 @@ interface ICircleRaderFanMaterialOptions {
|
|
|
35
34
|
color?: string;
|
|
36
35
|
speed?: number;
|
|
37
36
|
}
|
|
38
|
-
interface
|
|
37
|
+
interface ICircleApertureMaterialOptions {
|
|
38
|
+
color?: string;
|
|
39
|
+
/**
|
|
40
|
+
* 速度
|
|
41
|
+
*/
|
|
42
|
+
speed?: number;
|
|
43
|
+
}
|
|
44
|
+
interface ILightWallMaterialOptions {
|
|
39
45
|
image: string;
|
|
40
46
|
color?: string;
|
|
41
47
|
count?: number;
|
|
@@ -52,13 +58,6 @@ interface ILightWallMaterialOptions$1 {
|
|
|
52
58
|
*/
|
|
53
59
|
direction?: number;
|
|
54
60
|
}
|
|
55
|
-
interface ICircleApertureMaterialOptions {
|
|
56
|
-
color?: string;
|
|
57
|
-
/**
|
|
58
|
-
* 速度
|
|
59
|
-
*/
|
|
60
|
-
speed?: number;
|
|
61
|
-
}
|
|
62
61
|
/**
|
|
63
62
|
* 电弧球体
|
|
64
63
|
*/
|
|
@@ -127,12 +126,13 @@ type types_ICircleWaveMaterialOptions = ICircleWaveMaterialOptions;
|
|
|
127
126
|
type types_ICorridorMaterialOptions = ICorridorMaterialOptions;
|
|
128
127
|
type types_IEllipsoidElectricMaterialOptions = IEllipsoidElectricMaterialOptions;
|
|
129
128
|
type types_IEllipsoidScanMaterialOptions = IEllipsoidScanMaterialOptions;
|
|
129
|
+
type types_ILightWallMaterialOptions = ILightWallMaterialOptions;
|
|
130
130
|
type types_IPolylineFlowMaterialOptions = IPolylineFlowMaterialOptions;
|
|
131
131
|
type types_IPolylineTrailMaterialOptions = IPolylineTrailMaterialOptions;
|
|
132
132
|
type types_IRadarScanMaterialOptions = IRadarScanMaterialOptions;
|
|
133
133
|
type types_IZapsMaterialOptions = IZapsMaterialOptions;
|
|
134
134
|
declare namespace types {
|
|
135
|
-
export type { types_ICircleApertureMaterialOptions as ICircleApertureMaterialOptions, types_ICircleRaderFanMaterialOptions as ICircleRaderFanMaterialOptions, types_ICircleRaderWaveMaterialOptions as ICircleRaderWaveMaterialOptions, types_ICircleWaveMaterialOptions as ICircleWaveMaterialOptions, types_ICorridorMaterialOptions as ICorridorMaterialOptions, types_IEllipsoidElectricMaterialOptions as IEllipsoidElectricMaterialOptions, types_IEllipsoidScanMaterialOptions as IEllipsoidScanMaterialOptions,
|
|
135
|
+
export type { types_ICircleApertureMaterialOptions as ICircleApertureMaterialOptions, types_ICircleRaderFanMaterialOptions as ICircleRaderFanMaterialOptions, types_ICircleRaderWaveMaterialOptions as ICircleRaderWaveMaterialOptions, types_ICircleWaveMaterialOptions as ICircleWaveMaterialOptions, types_ICorridorMaterialOptions as ICorridorMaterialOptions, types_IEllipsoidElectricMaterialOptions as IEllipsoidElectricMaterialOptions, types_IEllipsoidScanMaterialOptions as IEllipsoidScanMaterialOptions, types_ILightWallMaterialOptions as ILightWallMaterialOptions, types_IPolylineFlowMaterialOptions as IPolylineFlowMaterialOptions, types_IPolylineTrailMaterialOptions as IPolylineTrailMaterialOptions, types_IRadarScanMaterialOptions as IRadarScanMaterialOptions, types_IZapsMaterialOptions as IZapsMaterialOptions };
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
|
@@ -145,7 +145,7 @@ declare class PolylineTrailMaterialProperty extends BaseMaterialProperty {
|
|
|
145
145
|
private image;
|
|
146
146
|
constructor(options: IPolylineTrailMaterialOptions);
|
|
147
147
|
get isConstant(): boolean;
|
|
148
|
-
get definitionChanged(): any
|
|
148
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
149
149
|
getType(): string;
|
|
150
150
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
151
151
|
equals(other: PolylineTrailMaterialProperty): any;
|
|
@@ -168,7 +168,7 @@ declare class PolylineFlowMaterialProperty extends BaseMaterialProperty {
|
|
|
168
168
|
private name;
|
|
169
169
|
constructor(options: IPolylineFlowMaterialOptions);
|
|
170
170
|
get isConstant(): boolean;
|
|
171
|
-
get definitionChanged(): any
|
|
171
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
172
172
|
getType(): string;
|
|
173
173
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
174
174
|
equals(other: PolylineFlowMaterialProperty): boolean;
|
|
@@ -188,7 +188,7 @@ declare class CircleWaveMaterialProperty extends BaseMaterialProperty {
|
|
|
188
188
|
private name;
|
|
189
189
|
constructor(options?: ICircleWaveMaterialOptions);
|
|
190
190
|
get isConstant(): boolean;
|
|
191
|
-
get definitionChanged(): any
|
|
191
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
192
192
|
getType(): string;
|
|
193
193
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
194
194
|
equals(other: CircleWaveMaterialProperty): any;
|
|
@@ -207,7 +207,7 @@ declare class CircleRaderWaveMaterialProperty extends BaseMaterialProperty {
|
|
|
207
207
|
private name;
|
|
208
208
|
constructor(options: ICircleRaderWaveMaterialOptions);
|
|
209
209
|
get isConstant(): boolean;
|
|
210
|
-
get definitionChanged(): any
|
|
210
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
211
211
|
getType(): string;
|
|
212
212
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
213
213
|
equals(other: CircleRaderWaveMaterialProperty): boolean;
|
|
@@ -226,7 +226,7 @@ declare class CircleRaderFanMaterialProperty extends BaseMaterialProperty {
|
|
|
226
226
|
private name;
|
|
227
227
|
constructor(options: ICircleRaderFanMaterialOptions);
|
|
228
228
|
get isConstant(): boolean;
|
|
229
|
-
get definitionChanged(): any
|
|
229
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
230
230
|
getType(): string;
|
|
231
231
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
232
232
|
equals(other: CircleRaderFanMaterialProperty): boolean;
|
|
@@ -245,7 +245,7 @@ declare class CircleApertureMaterialProperty extends BaseMaterialProperty {
|
|
|
245
245
|
private name;
|
|
246
246
|
constructor(options?: ICircleApertureMaterialOptions);
|
|
247
247
|
get isConstant(): boolean;
|
|
248
|
-
get definitionChanged(): any
|
|
248
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
249
249
|
getType(): string;
|
|
250
250
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
251
251
|
equals(other: CircleApertureMaterialProperty): any;
|
|
@@ -253,7 +253,7 @@ declare class CircleApertureMaterialProperty extends BaseMaterialProperty {
|
|
|
253
253
|
}
|
|
254
254
|
declare const createCircleApertureMaterial: (options?: ICircleApertureMaterialOptions) => Cesium.Material;
|
|
255
255
|
|
|
256
|
-
declare const createScanRadarMaterial: (options?: IRadarScanMaterialOptions) => Material;
|
|
256
|
+
declare const createScanRadarMaterial: (options?: IRadarScanMaterialOptions) => Cesium.Material;
|
|
257
257
|
|
|
258
258
|
/**
|
|
259
259
|
* 光墙材质
|
|
@@ -269,7 +269,7 @@ declare class LightWallMaterialProperty extends BaseMaterialProperty {
|
|
|
269
269
|
private name;
|
|
270
270
|
constructor(options: ILightWallMaterialOptions);
|
|
271
271
|
get isConstant(): boolean;
|
|
272
|
-
get definitionChanged(): any
|
|
272
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
273
273
|
getType(): string;
|
|
274
274
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
275
275
|
equals(other: LightWallMaterialProperty): any;
|
|
@@ -278,23 +278,6 @@ declare class LightWallMaterialProperty extends BaseMaterialProperty {
|
|
|
278
278
|
declare const createLightWallMaterial: (options: ILightWallMaterialOptions) => {
|
|
279
279
|
material: Cesium.Material;
|
|
280
280
|
};
|
|
281
|
-
interface ILightWallMaterialOptions {
|
|
282
|
-
image: string;
|
|
283
|
-
color?: string;
|
|
284
|
-
count?: number;
|
|
285
|
-
/**
|
|
286
|
-
* 时间 单位为秒
|
|
287
|
-
*/
|
|
288
|
-
duration?: number;
|
|
289
|
-
/**
|
|
290
|
-
* 0为水平 1为垂直 默认为1
|
|
291
|
-
*/
|
|
292
|
-
vertical?: number;
|
|
293
|
-
/**
|
|
294
|
-
* 1由下到上 0由上到下 默认为0
|
|
295
|
-
*/
|
|
296
|
-
direction?: number;
|
|
297
|
-
}
|
|
298
281
|
|
|
299
282
|
/**
|
|
300
283
|
* 雷达扇形扫描
|
|
@@ -305,7 +288,7 @@ declare class EllipsoidElectricMaterialProperty extends BaseMaterialProperty {
|
|
|
305
288
|
private name;
|
|
306
289
|
constructor(options: IEllipsoidElectricMaterialOptions);
|
|
307
290
|
get isConstant(): boolean;
|
|
308
|
-
get definitionChanged(): any
|
|
291
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
309
292
|
getType(): string;
|
|
310
293
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
311
294
|
equals(other: EllipsoidElectricMaterialProperty): boolean;
|
|
@@ -324,7 +307,7 @@ declare class EllipsoidScanMaterialProperty extends BaseMaterialProperty {
|
|
|
324
307
|
private name;
|
|
325
308
|
constructor(options: IEllipsoidScanMaterialOptions);
|
|
326
309
|
get isConstant(): boolean;
|
|
327
|
-
get definitionChanged(): any
|
|
310
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
328
311
|
getType(): string;
|
|
329
312
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
330
313
|
equals(other: EllipsoidScanMaterialProperty): boolean;
|
|
@@ -344,7 +327,7 @@ declare class ZapsMaterialProperty extends BaseMaterialProperty {
|
|
|
344
327
|
private name;
|
|
345
328
|
constructor(options: IZapsMaterialOptions);
|
|
346
329
|
get isConstant(): boolean;
|
|
347
|
-
get definitionChanged(): any
|
|
330
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
348
331
|
getType(): string;
|
|
349
332
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
350
333
|
equals(other: ZapsMaterialProperty): any;
|
|
@@ -355,4 +338,4 @@ declare const createZapsMaterial: (options: IZapsMaterialOptions) => {
|
|
|
355
338
|
};
|
|
356
339
|
|
|
357
340
|
export { CircleApertureMaterialProperty, CircleRaderFanMaterialProperty, CircleRaderWaveMaterialProperty, CircleWaveMaterialProperty, EllipsoidElectricMaterialProperty, EllipsoidScanMaterialProperty, LightWallMaterialProperty, types as Material, PolylineFlowMaterialProperty, PolylineTrailMaterialProperty, ZapsMaterialProperty, createCircleApertureMaterial, createCircleRaderFanMaterial, createCircleWaveMaterial, createEllipsoidElectricMaterial, createEllipsoidScanMaterial, createLightWallMaterial, createPoylineFlowMaterial, createRaderWaveMaterial, createScanRadarMaterial, createTrailMaterial, createZapsMaterial };
|
|
358
|
-
export type { ILightWallMaterialOptions };
|
|
341
|
+
export type { ICircleApertureMaterialOptions, ICircleRaderFanMaterialOptions, ICircleRaderWaveMaterialOptions, ICircleWaveMaterialOptions, ICorridorMaterialOptions, IEllipsoidElectricMaterialOptions, IEllipsoidScanMaterialOptions, ILightWallMaterialOptions, IPolylineFlowMaterialOptions, IPolylineTrailMaterialOptions, IRadarScanMaterialOptions, IZapsMaterialOptions };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"cesium";import{Material as t,Color as r}from"cesium";import{BaseMaterialProperty as a,numberId as n}from"@ino-cesium/common";var i=Object.freeze({__proto__:null});const o={PolylineFlow:"PolylineFlow",PolylineTrail:"PolylineTrail",CircleWave:"CircleWave",CircleRaderWave:"CircleRaderWave",CircleRaderFan:"CircleRaderFan",LightWall:"LightWall",CircleAperture:"CircleAperture",RadarScanCircle:"RadarScanCircle",EllipsoidElectric:"EllipsoidElectric",EllipsoidScan:"EllipsoidScan",Corridor:"Corridor",Zaps:"Zaps"};(()=>{for(const t in o)e.Material[t]=o[t]})();const s={color:"rgba(255,255,255,1)",speed:6*Math.random()};class l extends a{speed;color;name="";image="";constructor(t){super(),this.createPropertyDescriptors();const r={...s,...t};this.image=r.image,this.name=`${o.PolylineTrail}-${n()}`,this.color=e.Color.fromCssColorString(r.color),this.speed=r.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,r){return e.defined(r)||(r={}),r.color=e.Property.getValueOrClonedDefault(this.color,t,e.Color.WHITE,r.color),r.speed=this.speed,r.image=this.image,r}equals(t){return this===t||t instanceof l&&this.speed===t.speed&&e.Property.equals(this.color,t.color)&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{image:this.image,color:e.Color.fromCssColorString("#ff0000"),speed:this.speed},source:m},translucent:()=>!0})}createPropertyDescriptors(){Object.defineProperties(this,{color:e.createPropertyDescriptor("color")})}}const c=t=>{const r={...s,...t};return new e.Material({fabric:{type:`${o.PolylineTrail}-${n()}`,uniforms:{color:e.Color.fromCssColorString(r.color),image:r.image,speed:r.speed},source:m},translucent:!0})},m="\n uniform sampler2D image;\n uniform vec4 color;\n uniform float speed;\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float time = fract(czm_frameNumber * speed / 1000.0);\n vec4 colorImage = texture(image,st);\n vec3 fragColor = color.rgb;\n if(st.t > 0.45 && st.t < 0.55 ) {\n fragColor = vec3(1.0);\n }\n if(color.a == 0.0){\n material.alpha = colorImage.a * 1.5 * fract(st.s - time);\n material.diffuse = colorImage.rgb;\n }else{\n material.alpha = colorImage.a * color.a * 1.5 * smoothstep(.0,1., fract(st.s - time));\n material.diffuse = max(fragColor.rgb * material.alpha , fragColor.rgb);\n }\n return material;\n }\n\n",u={color:"rgba(255,255,255,1)",speed:6,repeatCount:4,blendColor:!0};class d extends a{repeatCount;image;speed;color;blend;name="";constructor(t){super(),this.createPropertyDescriptors();const r={...u,...t};this.name=`${o.PolylineFlow}-${n()}`,this.color=e.Color.fromCssColorString(r.color),this.speed=r.speed,this.image=r.image,this.repeatCount=r.repeatCount,this.blend=r.blendColor?1:0,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,r){return e.defined(r)||(r={}),r.color=e.Property.getValueOrClonedDefault(this.color,t,e.Color.WHITE,r.color),r.image=this.image,r.blend=this.blend,r.speed=this.speed,r.repeatCount=this.repeatCount,r}equals(e){return this===e||e instanceof d&&this.speed===e.speed&&this.repeatCount===e.repeatCount&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:e.Color.fromCssColorString("#ffffff"),image:"",speed:this.speed,count:this.repeatCount,blend:this.blend},source:f},translucent:()=>!0})}createPropertyDescriptors(){Object.defineProperties(this,{color:e.createPropertyDescriptor("color")})}}const p=t=>{const r={...u,...t};return new e.Material({fabric:{type:o.PolylineFlow+n(),uniforms:{color:e.Color.fromCssColorString(r.color),image:r.image,speed:r.speed,count:r.repeatCount,blend:r.blendColor?1:0},source:f},translucent:!0})},f="\n uniform vec4 color;\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n float time = fract(czm_frameNumber * speed / 1000.0);\n vec2 st = materialInput.st;\n vec4 colorImage = texture(image, vec2(fract( count * st.s - time),fract(st.t)));\n material.alpha = colorImage.a * color.a;\n if(blend > 0.5) {\n material.diffuse = (colorImage.rgb + color.rgb) * 2.0;\n } else {\n material.diffuse = color.rgb * 2.0 ;\n }\n return material;\n }\n",h={color:"rgba(255,255,0,0.3)",speed:8,count:5,gradient:.3};class g extends a{count;speed;gradient;color;name="";constructor(t){super(),t||(t={});const r={...h,...t};this.name=`${o.CircleWave}-${n()}`,this.color=e.Color.fromCssColorString(r.color),this.speed=r.speed,this.count=r.count,this.gradient=r.gradient,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.color=this.color,r.speed=this.speed,r.repeatCount=this.count||h.count,r}equals(t){return this===t||t instanceof g&&e.Property.equals(this.color,t.color)&&this.speed===t.speed&&this.count===t.count&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:new e.Color(1,0,0,.5),speed:this.speed,count:this.count,gradient:this.gradient},source:v},translucent:()=>!0})}}const C=t=>{const r={...h,...t};return{material:new e.Material({fabric:{type:`${o.CircleWave}-${n()}`,uniforms:{color:e.Color.fromCssColorString(r.color),speed:r.speed,count:r.count,gradient:r.gradient},source:v},translucent:!0})}},v="\n uniform vec4 color;\n uniform float speed;\n uniform float count;\n uniform float gradient;\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(czm_frameNumber * speed / 1000.0);\n if(count == 1.0){\n if(dis > per * 0.5){\n discard;\n }else {\n material.alpha = color.a * dis / per / 2.0;\n }\n } else {\n vec3 str = materialInput.str;\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.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,(1.0 + 10.0 * (1.0 - gradient)));\n }\n }\n }\n }\n }\n return material;\n }\n",b={color:"rgba(255,255,255,1)",speed:8};class y extends a{speed;color;name="";constructor(t){super();const r={...b,...t};this.name=`${o.CircleRaderWave}-${n()}`,this.color=e.Color.fromCssColorString(r.color),this.speed=r.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.speed=this.speed,r}equals(e){return this===e||e instanceof y&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:z},translucent:()=>!0})}}const _=t=>{const r={...b,...t};return{material:new e.Material({fabric:{type:`${o.CircleRaderWave}-${n()}`,uniforms:{color:e.Color.fromCssColorString(r.color),speed:r.speed},source:z},translucent:!0})}},z="\n uniform vec4 color;\n uniform float speed;\n #define PI 3.14159265359\n float rand(vec2 co){\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n }\n\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n vec2 pos = st - vec2(0.5);\n float time = czm_frameNumber * speed / 1000.0 ;\n float r = length(pos);\n float t = atan(pos.y, pos.x) - time * 2.5;\n float a = (atan(sin(t), cos(t)) + PI)/(2.0*PI);\n float ta = 0.5;\n float v = smoothstep(ta-0.05,ta+0.05,a) * smoothstep(ta+0.05,ta-0.05,a);\n vec3 flagColor = color.rgb * v;\n float blink = pow(sin(time*1.5)*0.5+0.5, 0.8);\n flagColor = color.rgb * pow(a, 4.0*(.2+blink))*(sin(r*500.0)*.5+.5) ;\n flagColor = flagColor * pow(r, 0.4);\n material.alpha = length(flagColor) * 1.3;\n material.diffuse = flagColor * 3.0;\n return material;\n }\n",x={name:"circle-fan",color:"rgba(255,255,255,1)",speed:8};class I extends a{speed;color;name="";constructor(t){super();const r={...x,...t};this.name=`${o.CircleRaderFan}-${n()}`,this.color=e.Color.fromCssColorString(r.color),this.speed=r.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.speed=this.speed,r}equals(e){return this===e||e instanceof I&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:$},translucent:()=>!0})}}const M=t=>{const r={...x,...t};return{material:new e.Material({fabric:{type:`${o.CircleRaderFan}-${n()}`,uniforms:{color:e.Color.fromCssColorString(r.color),speed:r.speed},source:$},translucent:!0})}},$="\n uniform vec4 color;\n uniform float speed;\n #define PI 3.14159265359\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n // 绘制边线\n float dis = distance(materialInput.st, vec2(0.5));\n float alpha = step((0.5- 0.01), dis);\n\n material.alpha = alpha;\n material.diffuse = color.rgb;\n\n // 绘制扇区\n vec2 xy = materialInput.st;\n float rx = xy.x - 0.5;\n float ry = xy.y - 0.5;\n float at = atan(ry, rx);\n float per = czm_frameNumber * speed / PI * 3.0 / 200.0;\n // 半径\n float radius = sqrt(rx * rx + ry * ry);\n // 扇区叠加旋转角度\n float current_radians = at + per;\n xy = vec2(cos(current_radians) * radius, sin(current_radians) * radius);\n xy = vec2(xy.x + 0.5, xy.y + 0.5);\n // 扇区渐变色渲染\n if (xy.y - xy.x < 0.0 && xy.x > 0.5 && xy.y > 0.5){\n material.alpha = (alpha + color.a) * dis;\n material.diffuse = color.rgb;\n }\n return material;\n }\n",w={color:"rgba(255,255,0,0.3)",speed:8};class D extends a{speed;color;name="";constructor(t){super(),t||(t={});const r={...w,...t};this.name=`${o.CircleAperture}-${n()}`,this.color=e.Color.fromCssColorString(r.color),this.speed=r.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.color=this.color,r.speed=this.speed,r}equals(t){return this===t||t instanceof D&&e.Property.equals(this.color,t.color)&&this.speed===t.speed&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:new e.Color(1,0,0,.5),speed:this.speed},source:S},translucent:()=>!0})}}const P=t=>{const r={...w,...t};return new e.Material({fabric:{type:`${o.CircleAperture}-${n()}`,uniforms:{color:e.Color.fromCssColorString(r.color),speed:r.speed},source:S},translucent:!0})},S="\n uniform vec4 color;\n uniform float speed;\n\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float d = distance(st, vec2(0.5, 0.5));\n float alpha = step(.15, d) * step(d, .17) + step(.49, d) * step(d, 0.5) + d * d * step(d, 0.5);\n float movingCircleD = fract(czm_frameNumber * speed / 1000.0);\n alpha += step(movingCircleD, d) * step(d, movingCircleD + .015);\n material.diffuse = color.rgb;\n material.alpha = alpha;\n return material;\n }\n",N=e=>{e||(e={});return new t({fabric:{type:`${o.RadarScanCircle}-${n()}`,uniforms:{radians:3*Math.PI/8,bgColor:r.fromCssColorString(e.bgColor||"rgba(0,255,0,0.2)"),sectorColor:r.fromCssColorString(e.sectorColor||"rgba(152,18,8,.1)"),width:e.width||.003,offset:e.offset||0,count:e.count||3},source:T},translucent:!0})},T="\n uniform vec4 bgColor;\n uniform vec4 sectorColor;\n uniform float count;\n uniform float radians;\n uniform float width;\n uniform float offset;\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float dis = distance(st, vec2(0.5));\n\n float alpha;\n vec3 diffuse;\n // 绘制圆圈\n float sp = 1.0 / count / 2.0;\n float m = mod(dis, sp);\n alpha = step(sp * (1.0 - width * 10.0), m);\n // alpha = clamp(alpha, 0.2, 1.0);\n if (alpha < bgColor.a){\n alpha = bgColor.a;\n diffuse = bgColor.rgb;\n } else {\n diffuse = bgColor.rgb;\n }\n material.alpha = alpha;\n material.diffuse = diffuse;\n // 绘制十字线\n if ((st.s > 0.5 - width / 2.0 && st.s < 0.5 + width / 2.0) || (st.t > 0.5 - width / 2.0 && st.t < 0.5 + width / 2.0)) {\n material.alpha = 0.8;\n material.diffuse = bgColor.rgb;\n return material;\n }\n // 绘制光晕\n float ma = mod(dis + offset, 0.5);\n if (ma < 0.25){\n alpha = ma * 3.0 + alpha;\n } else{\n alpha = 3.0 * (0.5 - ma) + alpha;\n }\n material.alpha = alpha;\n material.diffuse = bgColor.rgb;\n // 绘制扇区\n vec2 xy = materialInput.st;\n float rx = xy.x - 0.5;\n float ry = xy.y - 0.5;\n float at = atan(ry, rx);\n // 半径\n float radius = sqrt(rx * rx + ry * ry);\n // 扇区叠加旋转角度\n float current_radians = at + radians;\n xy = vec2(cos(current_radians) * radius, sin(current_radians) * radius);\n xy = vec2(xy.x + 0.5, xy.y + 0.5);\n // 扇区渐变色渲染\n if (xy.y - xy.x < 0.0 && xy.x > 0.5 && xy.y > 0.5){\n material.alpha = alpha + sectorColor.a;\n material.diffuse = sectorColor.rgb;\n }\n return material;\n }\n",q={color:"rgba(255,255,255,1)",count:3,duration:1500};class R extends a{duration;count;vertical;direction;color;_time;image;name="";constructor(t){super();const r={...q,...t};Object.prototype.hasOwnProperty.call(r,"vertical")||(r.vertical=1),this.name=`LightWall-${n()}`,this._time=(new Date).getTime(),this.color=e.Color.fromCssColorString(r.color),this.duration=r.duration,this.count=r.count,this.vertical=r.vertical,this.image=r.image,this.direction=r.direction,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,r){return e.defined(r)||(r={}),r.color=this.color,r.image=this.image,r.vertical=this.vertical,r.direction=this.direction,r.count=this.count,r.duration=this.duration,this.duration&&(r.time=((new Date).getTime()-this._time)%this.duration/this.duration),r}equals(t){return this===t||t instanceof R&&e.Property.equals(this.color,t.color)&&this.name===t.name&&this.image===t.image&&this.vertical===t.vertical&&this.direction===t.direction&&this.count===t.count&&this.duration===t.duration}init(){const t=E({count:this.count,vertical:this.vertical,direction:this.direction});e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,duration:this.duration,vertical:this.vertical,image:this.image,count:this.count,time:-20},source:t},translucent:()=>!0})}}const W=t=>{const r={...q,...t};return{material:new e.Material({fabric:{type:`LightWall${n()}`,uniforms:{color:e.Color.fromCssColorString(r.color),duration:r.duration,vertical:r.vertical,image:r.image,count:r.count,time:-20},source:E({count:r.count,vertical:r.vertical,direction:r.direction})}})}},E=e=>{const t=e.vertical?"vertical":"standard",r=e.direction?"+":"-";let a="czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;";return a+="vertical"===t?`vec4 colorImage = texture(image, vec2(fract(float(${e.count})*st.t ${r} time)),fract(st.s));\n `:`vec4 colorImage = texture(image, vec2(fract(float(${e.count})*st.s ${r} time), fract(st.t)));\n `,a+="vec4 fragColor;\n fragColor.rgb = (colorImage.rgb+color.rgb) / 1.0;\n fragColor = czm_gammaCorrect(fragColor);\n material.diffuse = colorImage.rgb;\n material.alpha = colorImage.a * color.a;\n material.emission = fragColor.rgb;\n return material;\n }",a},V={name:"circle-fan",color:"rgba(255,255,255,1)",speed:8};class F extends a{speed;color;name="";constructor(t){super();const r={...V,...t};this.name=`${o.EllipsoidElectric}-${n()}`,this.color=e.Color.fromCssColorString(r.color),this.speed=r.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.speed=this.speed,r}equals(e){return this===e||e instanceof F&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:Z},translucent:()=>!0})}}const O=t=>{const r={...V,...t};return{material:new e.Material({fabric:{type:`${o.EllipsoidElectric}-${n()}`,uniforms:{color:e.Color.fromCssColorString(r.color),speed:r.speed},source:Z},translucent:!0})}},Z="\n uniform vec4 color;\n uniform float speed;\n #define pi 3.1415926535\n #define PI2RAD 0.01745329252\n #define TWO_PI (2. * PI)\n\n float rands(float p){\n return fract(sin(p) * 10000.0);\n }\n\n float noise(vec2 p){\n float time = fract( czm_frameNumber * speed / 1000.0);\n float t = time / 20000.0;\n\n if(t > 1.0) t -= floor(t);\n return rands(p.x * 14. + p.y * sin(t) * 0.5);\n }\n\n vec2 sw(vec2 p){\n return vec2(floor(p.x), floor(p.y));\n }\n\n vec2 se(vec2 p){\n return vec2(ceil(p.x), floor(p.y));\n }\n\n vec2 nw(vec2 p){\n return vec2(floor(p.x), ceil(p.y));\n }\n\n vec2 ne(vec2 p){\n return vec2(ceil(p.x), ceil(p.y));\n }\n\n float smoothNoise(vec2 p){\n vec2 inter = smoothstep(0.0, 1.0, fract(p));\n float s = mix(noise(sw(p)), noise(se(p)), inter.x);\n float n = mix(noise(nw(p)), noise(ne(p)), inter.x);\n return mix(s, n, inter.y);\n }\n\n float fbm(vec2 p){\n float z = 2.0;\n float rz = 0.0;\n vec2 bp = p;\n for(float i = 1.0; i < 6.0; i++){\n rz += abs((smoothNoise(p) - 0.5)* 2.0) / z;\n z *= 2.0;\n p *= 2.0;\n }\n return rz;\n }\n\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n vec2 st2 = materialInput.st;\n float time = fract( czm_frameNumber * speed / 1000.0);\n if (st.t < 0.5) {\n discard;\n }\n st *= 4.;\n float rz = fbm(st);\n st /= exp(mod( time * 2.0, pi));\n rz *= pow(15., 0.9);\n vec4 temp = vec4(0);\n temp = mix( color / rz, vec4(color.rgb, 0.1), 0.2);\n if (st2.s < 0.05) {\n temp = mix(vec4(color.rgb, 0.1), temp, st2.s / 0.05);\n }\n if (st2.s > 0.95){\n temp = mix(temp, vec4(color.rgb, 0.1), (st2.s - 0.95) / 0.05);\n }\n material.diffuse = temp.rgb;\n material.alpha = temp.a * 2.0;\n return material;\n }\n",A={name:"circle-fan",color:"rgba(255,255,255,1)",speed:8};class j extends a{speed;color;name="";constructor(t){super();const r={...A,...t};this.name=`${o.EllipsoidScan}-${n()}`,this.color=e.Color.fromCssColorString(r.color),this.speed=r.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.speed=this.speed,r}equals(e){return this===e||e instanceof j&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:k},translucent:()=>!0})}}const L=t=>{const r={...A,...t};return{material:new e.Material({fabric:{type:`${o.EllipsoidScan}-${n()}`,uniforms:{color:e.Color.fromCssColorString(r.color),speed:r.speed},source:k},translucent:!0})}},k="\n uniform vec4 color;\n uniform float speed;\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float time = fract(czm_frameNumber * speed / 1000.0);\n float alpha = abs(smoothstep(0.5,1.,fract( -st.t - time)));\n alpha += .1;\n material.alpha = alpha;\n material.diffuse = color.rgb;\n return material;\n }\n",H={color:"rgba(255,255,255,1)",speed:1};class B extends a{color;speed;name="";constructor(t){super();const r={...H,...t};this.name=o.Zaps,this.color=e.Color.fromCssColorString(r.color),this.speed=r.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,r){return e.defined(r)||(r={}),r.color=this.color,r}equals(t){return this===t||t instanceof B&&e.Property.equals(this.color,t.color)&&this.speed===t.speed&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(o.Zaps,{fabric:{type:o.Zaps,uniforms:{uColor:this.color,speed:this.speed,uResolution:new e.Cartesian2(1024,1024)},source:J},translucent:()=>!0})}}const G=t=>{const r={...H,...t};return{material:new e.Material({fabric:{type:o.Zaps,uniforms:{uColor:e.Color.fromCssColorString(r.color),uSpeed:r.speed,uResolution:new e.Cartesian2(1024,1024)},source:J}})}},J="\n uniform float uSpeed;\n uniform vec4 uColor;\n uniform vec2 uResolution;\n\n void mainImage(out vec4 o, vec2 u, float time)\n {\n vec2 v = uResolution.xy;\n u = .2*(u+u-v)/v.y;\n\n vec4 z = o = vec4(1,2,3,0);\n for (float a = .5, t = time, i;\n ++i < 19.;\n o += (1. + cos(z+t))\n / length((1.+i*dot(v,v))\n * sin(1.5*u/(.5-dot(u,u)) - 9.*u.yx + t))\n )\n v = cos(++t - 7.*u*pow(a += .03, i)) - 5.*u,\n // use stanh here if shader has black artifacts\n // vvvv\n u += tanh(40. * dot(u *= mat2(cos(i + .02*t - vec4(0,11,33,0)))\n ,u)\n * cos(1e2*u.yx + t)) / 2e2\n + .2 * a * u\n + cos(4./exp(dot(o,o)/1e2) + t) / 3e2;\n\n o = 25.6 / (min(o, 13.) + 164. / o)\n - dot(u, u) / 250.;\n }\n\n czm_material czm_getMaterial(czm_materialInput materialInput) {\n float time = fract(czm_frameNumber * speed / 1000.0);\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec4 color = vec4(0.0,0.0,0.0,1.0);\n mainImage(color,materialInput.st * uResolution,time);\n\n material.diffuse = color.rgb * uColor.rgb;\n material.alpha = 0.33 + (sin(time * 0.3) + 1.0) / 3.0;\n return material;\n }\n ";export{D as CircleApertureMaterialProperty,I as CircleRaderFanMaterialProperty,y as CircleRaderWaveMaterialProperty,g as CircleWaveMaterialProperty,F as EllipsoidElectricMaterialProperty,j as EllipsoidScanMaterialProperty,R as LightWallMaterialProperty,i as Material,d as PolylineFlowMaterialProperty,l as PolylineTrailMaterialProperty,B as ZapsMaterialProperty,P as createCircleApertureMaterial,M as createCircleRaderFanMaterial,C as createCircleWaveMaterial,O as createEllipsoidElectricMaterial,L as createEllipsoidScanMaterial,W as createLightWallMaterial,p as createPoylineFlowMaterial,_ as createRaderWaveMaterial,N as createScanRadarMaterial,c as createTrailMaterial,G as createZapsMaterial};
|
|
1
|
+
import*as e from"cesium";import{BaseMaterialProperty as t,numberId as r}from"@ino-cesium/common";var a=Object.freeze({__proto__:null});const n={PolylineFlow:"PolylineFlow",PolylineTrail:"PolylineTrail",CircleWave:"CircleWave",CircleRaderWave:"CircleRaderWave",CircleRaderFan:"CircleRaderFan",LightWall:"LightWall",CircleAperture:"CircleAperture",RadarScanCircle:"RadarScanCircle",EllipsoidElectric:"EllipsoidElectric",EllipsoidScan:"EllipsoidScan",Corridor:"Corridor",Zaps:"Zaps"};(()=>{for(const t in n)e.Material[t]=n[t]})();const i={color:"rgba(255,255,255,1)",speed:6*Math.random()};class o extends t{speed;color;name="";image="";constructor(t){super(),this.createPropertyDescriptors();const a={...i,...t};this.image=a.image,this.name=`${n.PolylineTrail}-${r()}`,this.color=e.Color.fromCssColorString(a.color),this.speed=a.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,r){return e.defined(r)||(r={}),r.color=e.Property.getValueOrClonedDefault(this.color,t,e.Color.WHITE,r.color),r.speed=this.speed,r.image=this.image,r}equals(t){return this===t||t instanceof o&&this.speed===t.speed&&e.Property.equals(this.color,t.color)&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{image:this.image,color:e.Color.fromCssColorString("#ff0000"),speed:this.speed},source:l},translucent:()=>!0})}createPropertyDescriptors(){Object.defineProperties(this,{color:e.createPropertyDescriptor("color")})}}const s=t=>{const a={...i,...t};return new e.Material({fabric:{type:`${n.PolylineTrail}-${r()}`,uniforms:{color:e.Color.fromCssColorString(a.color),image:a.image,speed:a.speed},source:l},translucent:!0})},l="\n uniform sampler2D image;\n uniform vec4 color;\n uniform float speed;\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float time = fract(czm_frameNumber * speed / 1000.0);\n vec4 colorImage = texture(image,st);\n vec3 fragColor = color.rgb;\n if(st.t > 0.45 && st.t < 0.55 ) {\n fragColor = vec3(1.0);\n }\n if(color.a == 0.0){\n material.alpha = colorImage.a * 1.5 * fract(st.s - time);\n material.diffuse = colorImage.rgb;\n }else{\n material.alpha = colorImage.a * color.a * 1.5 * smoothstep(.0,1., fract(st.s - time));\n material.diffuse = max(fragColor.rgb * material.alpha , fragColor.rgb);\n }\n return material;\n }\n\n",c={color:"rgba(255,255,255,1)",speed:6,repeatCount:4,blendColor:!0};class m extends t{repeatCount;image;speed;color;blend;name="";constructor(t){super(),this.createPropertyDescriptors();const a={...c,...t};this.name=`${n.PolylineFlow}-${r()}`,this.color=e.Color.fromCssColorString(a.color),this.speed=a.speed,this.image=a.image,this.repeatCount=a.repeatCount,this.blend=a.blendColor?1:0,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,r){return e.defined(r)||(r={}),r.color=e.Property.getValueOrClonedDefault(this.color,t,e.Color.WHITE,r.color),r.image=this.image,r.blend=this.blend,r.speed=this.speed,r.repeatCount=this.repeatCount,r}equals(e){return this===e||e instanceof m&&this.speed===e.speed&&this.repeatCount===e.repeatCount&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:e.Color.fromCssColorString("#ffffff"),image:"",speed:this.speed,count:this.repeatCount,blend:this.blend},source:d},translucent:()=>!0})}createPropertyDescriptors(){Object.defineProperties(this,{color:e.createPropertyDescriptor("color")})}}const u=t=>{const a={...c,...t};return new e.Material({fabric:{type:n.PolylineFlow+r(),uniforms:{color:e.Color.fromCssColorString(a.color),image:a.image,speed:a.speed,count:a.repeatCount,blend:a.blendColor?1:0},source:d},translucent:!0})},d="\n uniform vec4 color;\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n float time = fract(czm_frameNumber * speed / 1000.0);\n vec2 st = materialInput.st;\n vec4 colorImage = texture(image, vec2(fract( count * st.s - time),fract(st.t)));\n material.alpha = colorImage.a * color.a;\n if(blend > 0.5) {\n material.diffuse = (colorImage.rgb + color.rgb) * 2.0;\n } else {\n material.diffuse = color.rgb * 2.0 ;\n }\n return material;\n }\n",p={color:"rgba(255,255,0,0.3)",speed:8,count:5,gradient:.3};class f extends t{count;speed;gradient;color;name="";constructor(t){super(),t||(t={});const a={...p,...t};this.name=`${n.CircleWave}-${r()}`,this.color=e.Color.fromCssColorString(a.color),this.speed=a.speed,this.count=a.count,this.gradient=a.gradient,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.color=this.color,r.speed=this.speed,r.repeatCount=this.count||p.count,r}equals(t){return this===t||t instanceof f&&e.Property.equals(this.color,t.color)&&this.speed===t.speed&&this.count===t.count&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:new e.Color(1,0,0,.5),speed:this.speed,count:this.count,gradient:this.gradient},source:g},translucent:()=>!0})}}const h=t=>{const a={...p,...t};return{material:new e.Material({fabric:{type:`${n.CircleWave}-${r()}`,uniforms:{color:e.Color.fromCssColorString(a.color),speed:a.speed,count:a.count,gradient:a.gradient},source:g},translucent:!0})}},g="\n uniform vec4 color;\n uniform float speed;\n uniform float count;\n uniform float gradient;\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(czm_frameNumber * speed / 1000.0);\n if(count == 1.0){\n if(dis > per * 0.5){\n discard;\n }else {\n material.alpha = color.a * dis / per / 2.0;\n }\n } else {\n vec3 str = materialInput.str;\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.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,(1.0 + 10.0 * (1.0 - gradient)));\n }\n }\n }\n }\n }\n return material;\n }\n",C={color:"rgba(255,255,255,1)",speed:8};class v extends t{speed;color;name="";constructor(t){super();const a={...C,...t};this.name=`${n.CircleRaderWave}-${r()}`,this.color=e.Color.fromCssColorString(a.color),this.speed=a.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.speed=this.speed,r}equals(e){return this===e||e instanceof v&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:y},translucent:()=>!0})}}const b=t=>{const a={...C,...t};return{material:new e.Material({fabric:{type:`${n.CircleRaderWave}-${r()}`,uniforms:{color:e.Color.fromCssColorString(a.color),speed:a.speed},source:y},translucent:!0})}},y="\n uniform vec4 color;\n uniform float speed;\n #define PI 3.14159265359\n float rand(vec2 co){\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n }\n\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n vec2 pos = st - vec2(0.5);\n float time = czm_frameNumber * speed / 1000.0 ;\n float r = length(pos);\n float t = atan(pos.y, pos.x) - time * 2.5;\n float a = (atan(sin(t), cos(t)) + PI)/(2.0*PI);\n float ta = 0.5;\n float v = smoothstep(ta-0.05,ta+0.05,a) * smoothstep(ta+0.05,ta-0.05,a);\n vec3 flagColor = color.rgb * v;\n float blink = pow(sin(time*1.5)*0.5+0.5, 0.8);\n flagColor = color.rgb * pow(a, 4.0*(.2+blink))*(sin(r*500.0)*.5+.5) ;\n flagColor = flagColor * pow(r, 0.4);\n material.alpha = length(flagColor) * 1.3;\n material.diffuse = flagColor * 3.0;\n return material;\n }\n",_={name:"circle-fan",color:"rgba(255,255,255,1)",speed:8};class z extends t{speed;color;name="";constructor(t){super();const a={..._,...t};this.name=`${n.CircleRaderFan}-${r()}`,this.color=e.Color.fromCssColorString(a.color),this.speed=a.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.speed=this.speed,r}equals(e){return this===e||e instanceof z&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:I},translucent:()=>!0})}}const x=t=>{const a={..._,...t};return{material:new e.Material({fabric:{type:`${n.CircleRaderFan}-${r()}`,uniforms:{color:e.Color.fromCssColorString(a.color),speed:a.speed},source:I},translucent:!0})}},I="\n uniform vec4 color;\n uniform float speed;\n #define PI 3.14159265359\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n // 绘制边线\n float dis = distance(materialInput.st, vec2(0.5));\n float alpha = step((0.5- 0.01), dis);\n\n material.alpha = alpha;\n material.diffuse = color.rgb;\n\n // 绘制扇区\n vec2 xy = materialInput.st;\n float rx = xy.x - 0.5;\n float ry = xy.y - 0.5;\n float at = atan(ry, rx);\n float per = czm_frameNumber * speed / PI * 3.0 / 200.0;\n // 半径\n float radius = sqrt(rx * rx + ry * ry);\n // 扇区叠加旋转角度\n float current_radians = at + per;\n xy = vec2(cos(current_radians) * radius, sin(current_radians) * radius);\n xy = vec2(xy.x + 0.5, xy.y + 0.5);\n // 扇区渐变色渲染\n if (xy.y - xy.x < 0.0 && xy.x > 0.5 && xy.y > 0.5){\n material.alpha = (alpha + color.a) * dis;\n material.diffuse = color.rgb;\n }\n return material;\n }\n",M={color:"rgba(255,255,0,0.3)",speed:8};class $ extends t{speed;color;name="";constructor(t){super(),t||(t={});const a={...M,...t};this.name=`${n.CircleAperture}-${r()}`,this.color=e.Color.fromCssColorString(a.color),this.speed=a.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.color=this.color,r.speed=this.speed,r}equals(t){return this===t||t instanceof $&&e.Property.equals(this.color,t.color)&&this.speed===t.speed&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:new e.Color(1,0,0,.5),speed:this.speed},source:D},translucent:()=>!0})}}const w=t=>{const a={...M,...t};return new e.Material({fabric:{type:`${n.CircleAperture}-${r()}`,uniforms:{color:e.Color.fromCssColorString(a.color),speed:a.speed},source:D},translucent:!0})},D="\n uniform vec4 color;\n uniform float speed;\n\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float d = distance(st, vec2(0.5, 0.5));\n float alpha = step(.15, d) * step(d, .17) + step(.49, d) * step(d, 0.5) + d * d * step(d, 0.5);\n float movingCircleD = fract(czm_frameNumber * speed / 1000.0);\n alpha += step(movingCircleD, d) * step(d, movingCircleD + .015);\n material.diffuse = color.rgb;\n material.alpha = alpha;\n return material;\n }\n",P=t=>{t||(t={});return new e.Material({fabric:{type:`${n.RadarScanCircle}-${r()}`,uniforms:{radians:3*Math.PI/8,bgColor:e.Color.fromCssColorString(t.bgColor||"rgba(0,255,0,0.2)"),sectorColor:e.Color.fromCssColorString(t.sectorColor||"rgba(152,18,8,.1)"),width:t.width||.003,offset:t.offset||0,count:t.count||3},source:S},translucent:!0})},S="\n uniform vec4 bgColor;\n uniform vec4 sectorColor;\n uniform float count;\n uniform float radians;\n uniform float width;\n uniform float offset;\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float dis = distance(st, vec2(0.5));\n\n float alpha;\n vec3 diffuse;\n // 绘制圆圈\n float sp = 1.0 / count / 2.0;\n float m = mod(dis, sp);\n alpha = step(sp * (1.0 - width * 10.0), m);\n // alpha = clamp(alpha, 0.2, 1.0);\n if (alpha < bgColor.a){\n alpha = bgColor.a;\n diffuse = bgColor.rgb;\n } else {\n diffuse = bgColor.rgb;\n }\n material.alpha = alpha;\n material.diffuse = diffuse;\n // 绘制十字线\n if ((st.s > 0.5 - width / 2.0 && st.s < 0.5 + width / 2.0) || (st.t > 0.5 - width / 2.0 && st.t < 0.5 + width / 2.0)) {\n material.alpha = 0.8;\n material.diffuse = bgColor.rgb;\n return material;\n }\n // 绘制光晕\n float ma = mod(dis + offset, 0.5);\n if (ma < 0.25){\n alpha = ma * 3.0 + alpha;\n } else{\n alpha = 3.0 * (0.5 - ma) + alpha;\n }\n material.alpha = alpha;\n material.diffuse = bgColor.rgb;\n // 绘制扇区\n vec2 xy = materialInput.st;\n float rx = xy.x - 0.5;\n float ry = xy.y - 0.5;\n float at = atan(ry, rx);\n // 半径\n float radius = sqrt(rx * rx + ry * ry);\n // 扇区叠加旋转角度\n float current_radians = at + radians;\n xy = vec2(cos(current_radians) * radius, sin(current_radians) * radius);\n xy = vec2(xy.x + 0.5, xy.y + 0.5);\n // 扇区渐变色渲染\n if (xy.y - xy.x < 0.0 && xy.x > 0.5 && xy.y > 0.5){\n material.alpha = alpha + sectorColor.a;\n material.diffuse = sectorColor.rgb;\n }\n return material;\n }\n",N={color:"rgba(255,255,255,1)",count:3,duration:1500};class T extends t{duration;count;vertical;direction;color;_time;image;name="";constructor(t){super();const a={...N,...t};Object.prototype.hasOwnProperty.call(a,"vertical")||(a.vertical=1),this.name=`LightWall-${r()}`,this._time=(new Date).getTime(),this.color=e.Color.fromCssColorString(a.color),this.duration=a.duration,this.count=a.count,this.vertical=a.vertical,this.image=a.image,this.direction=a.direction,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,r){return e.defined(r)||(r={}),r.color=this.color,r.image=this.image,r.vertical=this.vertical,r.direction=this.direction,r.count=this.count,r.duration=this.duration,this.duration&&(r.time=((new Date).getTime()-this._time)%this.duration/this.duration),r}equals(t){return this===t||t instanceof T&&e.Property.equals(this.color,t.color)&&this.name===t.name&&this.image===t.image&&this.vertical===t.vertical&&this.direction===t.direction&&this.count===t.count&&this.duration===t.duration}init(){const t=R({count:this.count,vertical:this.vertical,direction:this.direction});e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,duration:this.duration,vertical:this.vertical,image:this.image,count:this.count,time:-20},source:t},translucent:()=>!0})}}const q=t=>{const a={...N,...t};return{material:new e.Material({fabric:{type:`LightWall${r()}`,uniforms:{color:e.Color.fromCssColorString(a.color),duration:a.duration,vertical:a.vertical,image:a.image,count:a.count,time:-20},source:R({count:a.count,vertical:a.vertical,direction:a.direction})}})}},R=e=>{const t=e.vertical?"vertical":"standard",r=e.direction?"+":"-";let a="czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;";return a+="vertical"===t?`vec4 colorImage = texture(image, vec2(fract(float(${e.count})*st.t ${r} time)),fract(st.s));\n `:`vec4 colorImage = texture(image, vec2(fract(float(${e.count})*st.s ${r} time), fract(st.t)));\n `,a+="vec4 fragColor;\n fragColor.rgb = (colorImage.rgb+color.rgb) / 1.0;\n fragColor = czm_gammaCorrect(fragColor);\n material.diffuse = colorImage.rgb;\n material.alpha = colorImage.a * color.a;\n material.emission = fragColor.rgb;\n return material;\n }",a},W={name:"circle-fan",color:"rgba(255,255,255,1)",speed:8};class E extends t{speed;color;name="";constructor(t){super();const a={...W,...t};this.name=`${n.EllipsoidElectric}-${r()}`,this.color=e.Color.fromCssColorString(a.color),this.speed=a.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.speed=this.speed,r}equals(e){return this===e||e instanceof E&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:F},translucent:()=>!0})}}const V=t=>{const a={...W,...t};return{material:new e.Material({fabric:{type:`${n.EllipsoidElectric}-${r()}`,uniforms:{color:e.Color.fromCssColorString(a.color),speed:a.speed},source:F},translucent:!0})}},F="\n uniform vec4 color;\n uniform float speed;\n #define pi 3.1415926535\n #define PI2RAD 0.01745329252\n #define TWO_PI (2. * PI)\n\n float rands(float p){\n return fract(sin(p) * 10000.0);\n }\n\n float noise(vec2 p){\n float time = fract( czm_frameNumber * speed / 1000.0);\n float t = time / 20000.0;\n\n if(t > 1.0) t -= floor(t);\n return rands(p.x * 14. + p.y * sin(t) * 0.5);\n }\n\n vec2 sw(vec2 p){\n return vec2(floor(p.x), floor(p.y));\n }\n\n vec2 se(vec2 p){\n return vec2(ceil(p.x), floor(p.y));\n }\n\n vec2 nw(vec2 p){\n return vec2(floor(p.x), ceil(p.y));\n }\n\n vec2 ne(vec2 p){\n return vec2(ceil(p.x), ceil(p.y));\n }\n\n float smoothNoise(vec2 p){\n vec2 inter = smoothstep(0.0, 1.0, fract(p));\n float s = mix(noise(sw(p)), noise(se(p)), inter.x);\n float n = mix(noise(nw(p)), noise(ne(p)), inter.x);\n return mix(s, n, inter.y);\n }\n\n float fbm(vec2 p){\n float z = 2.0;\n float rz = 0.0;\n vec2 bp = p;\n for(float i = 1.0; i < 6.0; i++){\n rz += abs((smoothNoise(p) - 0.5)* 2.0) / z;\n z *= 2.0;\n p *= 2.0;\n }\n return rz;\n }\n\n czm_material czm_getMaterial(czm_materialInput materialInput)\n {\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n vec2 st2 = materialInput.st;\n float time = fract( czm_frameNumber * speed / 1000.0);\n if (st.t < 0.5) {\n discard;\n }\n st *= 4.;\n float rz = fbm(st);\n st /= exp(mod( time * 2.0, pi));\n rz *= pow(15., 0.9);\n vec4 temp = vec4(0);\n temp = mix( color / rz, vec4(color.rgb, 0.1), 0.2);\n if (st2.s < 0.05) {\n temp = mix(vec4(color.rgb, 0.1), temp, st2.s / 0.05);\n }\n if (st2.s > 0.95){\n temp = mix(temp, vec4(color.rgb, 0.1), (st2.s - 0.95) / 0.05);\n }\n material.diffuse = temp.rgb;\n material.alpha = temp.a * 2.0;\n return material;\n }\n",O={name:"circle-fan",color:"rgba(255,255,255,1)",speed:8};class Z extends t{speed;color;name="";constructor(t){super();const a={...O,...t};this.name=`${n.EllipsoidScan}-${r()}`,this.color=e.Color.fromCssColorString(a.color),this.speed=a.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return`${this.name}`}getValue(t,r){return e.defined(r)||(r={}),r.speed=this.speed,r}equals(e){return this===e||e instanceof Z&&this.speed===e.speed&&this.name===e.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(this.name,{fabric:{type:this.name,uniforms:{color:this.color,speed:6},source:j},translucent:()=>!0})}}const A=t=>{const a={...O,...t};return{material:new e.Material({fabric:{type:`${n.EllipsoidScan}-${r()}`,uniforms:{color:e.Color.fromCssColorString(a.color),speed:a.speed},source:j},translucent:!0})}},j="\n uniform vec4 color;\n uniform float speed;\n czm_material czm_getMaterial(czm_materialInput materialInput){\n czm_material material = czm_getDefaultMaterial(materialInput);\n vec2 st = materialInput.st;\n float time = fract(czm_frameNumber * speed / 1000.0);\n float alpha = abs(smoothstep(0.5,1.,fract( -st.t - time)));\n alpha += .1;\n material.alpha = alpha;\n material.diffuse = color.rgb;\n return material;\n }\n",L={color:"rgba(255,255,255,1)",speed:1};class k extends t{color;speed;name="";constructor(t){super();const r={...L,...t};this.name=n.Zaps,this.color=e.Color.fromCssColorString(r.color),this.speed=r.speed,this.init()}get isConstant(){return!1}get definitionChanged(){return this._definitionChanged}getType(){return this.name}getValue(t,r){return e.defined(r)||(r={}),r.color=this.color,r}equals(t){return this===t||t instanceof k&&e.Property.equals(this.color,t.color)&&this.speed===t.speed&&this.name===t.name}init(){e.Material[this.name]=this.name,e.Material._materialCache.addMaterial(n.Zaps,{fabric:{type:n.Zaps,uniforms:{uColor:this.color,speed:this.speed,uResolution:new e.Cartesian2(1024,1024)},source:B},translucent:()=>!0})}}const H=t=>{const r={...L,...t};return{material:new e.Material({fabric:{type:n.Zaps,uniforms:{uColor:e.Color.fromCssColorString(r.color),uSpeed:r.speed,uResolution:new e.Cartesian2(1024,1024)},source:B}})}},B="\n uniform float uSpeed;\n uniform vec4 uColor;\n uniform vec2 uResolution;\n\n void mainImage(out vec4 o, vec2 u, float time)\n {\n vec2 v = uResolution.xy;\n u = .2*(u+u-v)/v.y;\n\n vec4 z = o = vec4(1,2,3,0);\n for (float a = .5, t = time, i;\n ++i < 19.;\n o += (1. + cos(z+t))\n / length((1.+i*dot(v,v))\n * sin(1.5*u/(.5-dot(u,u)) - 9.*u.yx + t))\n )\n v = cos(++t - 7.*u*pow(a += .03, i)) - 5.*u,\n // use stanh here if shader has black artifacts\n // vvvv\n u += tanh(40. * dot(u *= mat2(cos(i + .02*t - vec4(0,11,33,0)))\n ,u)\n * cos(1e2*u.yx + t)) / 2e2\n + .2 * a * u\n + cos(4./exp(dot(o,o)/1e2) + t) / 3e2;\n\n o = 25.6 / (min(o, 13.) + 164. / o)\n - dot(u, u) / 250.;\n }\n\n czm_material czm_getMaterial(czm_materialInput materialInput) {\n float time = fract(czm_frameNumber * speed / 1000.0);\n czm_material material = czm_getDefaultMaterial(materialInput);\n\n vec4 color = vec4(0.0,0.0,0.0,1.0);\n mainImage(color,materialInput.st * uResolution,time);\n\n material.diffuse = color.rgb * uColor.rgb;\n material.alpha = 0.33 + (sin(time * 0.3) + 1.0) / 3.0;\n return material;\n }\n ";export{$ as CircleApertureMaterialProperty,z as CircleRaderFanMaterialProperty,v as CircleRaderWaveMaterialProperty,f as CircleWaveMaterialProperty,E as EllipsoidElectricMaterialProperty,Z as EllipsoidScanMaterialProperty,T as LightWallMaterialProperty,a as Material,m as PolylineFlowMaterialProperty,o as PolylineTrailMaterialProperty,k as ZapsMaterialProperty,w as createCircleApertureMaterial,x as createCircleRaderFanMaterial,h as createCircleWaveMaterial,V as createEllipsoidElectricMaterial,A as createEllipsoidScanMaterial,q as createLightWallMaterial,u as createPoylineFlowMaterial,b as createRaderWaveMaterial,P as createScanRadarMaterial,s as createTrailMaterial,H as createZapsMaterial};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ino-cesium/material",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.14",
|
|
5
5
|
"author": "koino",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cesium",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"cesium": "*"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ino-cesium/common": "0.0.
|
|
34
|
+
"@ino-cesium/common": "0.0.14"
|
|
35
35
|
},
|
|
36
36
|
"types": "./dist/index.d.ts",
|
|
37
37
|
"scripts": {
|