@ino-cesium/material 0.0.7 → 0.0.8
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 +40 -10
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,16 @@ interface IEllipsoidElectricMaterialOptions {
|
|
|
69
69
|
*/
|
|
70
70
|
speed?: number;
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* 扫描球体
|
|
74
|
+
*/
|
|
75
|
+
interface IEllipsoidScanMaterialOptions {
|
|
76
|
+
color?: string;
|
|
77
|
+
/**
|
|
78
|
+
* 速度
|
|
79
|
+
*/
|
|
80
|
+
speed?: number;
|
|
81
|
+
}
|
|
72
82
|
/**
|
|
73
83
|
* 雷达扫描材质
|
|
74
84
|
* @param selectColor 选中颜色
|
|
@@ -108,12 +118,13 @@ type types_ICircleRaderWaveMaterialOptions = ICircleRaderWaveMaterialOptions;
|
|
|
108
118
|
type types_ICircleWaveMaterialOptions = ICircleWaveMaterialOptions;
|
|
109
119
|
type types_ICorridorMaterialOptions = ICorridorMaterialOptions;
|
|
110
120
|
type types_IEllipsoidElectricMaterialOptions = IEllipsoidElectricMaterialOptions;
|
|
121
|
+
type types_IEllipsoidScanMaterialOptions = IEllipsoidScanMaterialOptions;
|
|
111
122
|
type types_ILightWallMaterialOptions = ILightWallMaterialOptions;
|
|
112
123
|
type types_IPolylineFlowMaterialOptions = IPolylineFlowMaterialOptions;
|
|
113
124
|
type types_IPolylineTrailMaterialOptions = IPolylineTrailMaterialOptions;
|
|
114
125
|
type types_IRadarScanMaterialOptions = IRadarScanMaterialOptions;
|
|
115
126
|
declare namespace types {
|
|
116
|
-
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_ILightWallMaterialOptions as ILightWallMaterialOptions, types_IPolylineFlowMaterialOptions as IPolylineFlowMaterialOptions, types_IPolylineTrailMaterialOptions as IPolylineTrailMaterialOptions, types_IRadarScanMaterialOptions as IRadarScanMaterialOptions };
|
|
127
|
+
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 };
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
/**
|
|
@@ -126,7 +137,7 @@ declare class PolylineTrailMaterialProperty extends BaseMaterialProperty {
|
|
|
126
137
|
private image;
|
|
127
138
|
constructor(options: IPolylineTrailMaterialOptions);
|
|
128
139
|
get isConstant(): boolean;
|
|
129
|
-
get definitionChanged(): any
|
|
140
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
130
141
|
getType(): string;
|
|
131
142
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
132
143
|
equals(other: PolylineTrailMaterialProperty): any;
|
|
@@ -149,7 +160,7 @@ declare class PolylineFlowMaterialProperty extends BaseMaterialProperty {
|
|
|
149
160
|
private name;
|
|
150
161
|
constructor(options: IPolylineFlowMaterialOptions);
|
|
151
162
|
get isConstant(): boolean;
|
|
152
|
-
get definitionChanged(): any
|
|
163
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
153
164
|
getType(): string;
|
|
154
165
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
155
166
|
equals(other: PolylineFlowMaterialProperty): boolean;
|
|
@@ -169,7 +180,7 @@ declare class CircleWaveMaterialProperty extends BaseMaterialProperty {
|
|
|
169
180
|
private name;
|
|
170
181
|
constructor(options?: ICircleWaveMaterialOptions);
|
|
171
182
|
get isConstant(): boolean;
|
|
172
|
-
get definitionChanged(): any
|
|
183
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
173
184
|
getType(): string;
|
|
174
185
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
175
186
|
equals(other: CircleWaveMaterialProperty): any;
|
|
@@ -188,7 +199,7 @@ declare class CircleRaderWaveMaterialProperty extends BaseMaterialProperty {
|
|
|
188
199
|
private name;
|
|
189
200
|
constructor(options: ICircleRaderWaveMaterialOptions);
|
|
190
201
|
get isConstant(): boolean;
|
|
191
|
-
get definitionChanged(): any
|
|
202
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
192
203
|
getType(): string;
|
|
193
204
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
194
205
|
equals(other: CircleRaderWaveMaterialProperty): boolean;
|
|
@@ -207,7 +218,7 @@ declare class CircleRaderFanMaterialProperty extends BaseMaterialProperty {
|
|
|
207
218
|
private name;
|
|
208
219
|
constructor(options: ICircleRaderFanMaterialOptions);
|
|
209
220
|
get isConstant(): boolean;
|
|
210
|
-
get definitionChanged(): any
|
|
221
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
211
222
|
getType(): string;
|
|
212
223
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
213
224
|
equals(other: CircleRaderFanMaterialProperty): boolean;
|
|
@@ -226,7 +237,7 @@ declare class CircleApertureMaterialProperty extends BaseMaterialProperty {
|
|
|
226
237
|
private name;
|
|
227
238
|
constructor(options?: ICircleApertureMaterialOptions);
|
|
228
239
|
get isConstant(): boolean;
|
|
229
|
-
get definitionChanged(): any
|
|
240
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
230
241
|
getType(): string;
|
|
231
242
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
232
243
|
equals(other: CircleApertureMaterialProperty): any;
|
|
@@ -250,7 +261,7 @@ declare class LightWallMaterialProperty extends BaseMaterialProperty {
|
|
|
250
261
|
private name;
|
|
251
262
|
constructor(options: ILightWallMaterialOptions);
|
|
252
263
|
get isConstant(): boolean;
|
|
253
|
-
get definitionChanged(): any
|
|
264
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
254
265
|
getType(): string;
|
|
255
266
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
256
267
|
equals(other: LightWallMaterialProperty): any;
|
|
@@ -269,7 +280,7 @@ declare class EllipsoidElectricMaterialProperty extends BaseMaterialProperty {
|
|
|
269
280
|
private name;
|
|
270
281
|
constructor(options: IEllipsoidElectricMaterialOptions);
|
|
271
282
|
get isConstant(): boolean;
|
|
272
|
-
get definitionChanged(): any
|
|
283
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
273
284
|
getType(): string;
|
|
274
285
|
getValue(time: Cesium.JulianDate, result: any): any;
|
|
275
286
|
equals(other: EllipsoidElectricMaterialProperty): boolean;
|
|
@@ -279,4 +290,23 @@ declare const createEllipsoidElectricMaterial: (options: IEllipsoidElectricMater
|
|
|
279
290
|
material: Cesium.Material;
|
|
280
291
|
};
|
|
281
292
|
|
|
282
|
-
|
|
293
|
+
/**
|
|
294
|
+
* 雷达扇形扫描
|
|
295
|
+
*/
|
|
296
|
+
declare class EllipsoidScanMaterialProperty extends BaseMaterialProperty {
|
|
297
|
+
private speed;
|
|
298
|
+
private color;
|
|
299
|
+
private name;
|
|
300
|
+
constructor(options: IEllipsoidScanMaterialOptions);
|
|
301
|
+
get isConstant(): boolean;
|
|
302
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
303
|
+
getType(): string;
|
|
304
|
+
getValue(time: Cesium.JulianDate, result: any): any;
|
|
305
|
+
equals(other: EllipsoidScanMaterialProperty): boolean;
|
|
306
|
+
init(): void;
|
|
307
|
+
}
|
|
308
|
+
declare const createEllipsoidScanMaterial: (options: IEllipsoidScanMaterialOptions) => {
|
|
309
|
+
material: Cesium.Material;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export { CircleApertureMaterialProperty, CircleRaderFanMaterialProperty, CircleRaderWaveMaterialProperty, CircleWaveMaterialProperty, EllipsoidElectricMaterialProperty, EllipsoidScanMaterialProperty, LightWallMaterialProperty, types as Material, PolylineFlowMaterialProperty, PolylineTrailMaterialProperty, createCircleApertureMaterial, createCircleRaderFanMaterial, createCircleWaveMaterial, createEllipsoidElectricMaterial, createEllipsoidScanMaterial, createLightWallMaterial, createPoylineFlowMaterial, createRaderWaveMaterial, createScanRadarMaterial, createTrailMaterial };
|
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:"LightWallMater",CircleAperture:"CircleAperture",RadarScanCircle:"RadarScanCircle",EllipsoidElectric:"EllipsoidElectric",Corridor:"Corridor"};(()=>{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:x},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:x},translucent:!0})}},x="\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",z={name:"circle-fan",color:"rgba(255,255,255,1)",speed:8};class I extends a{speed;color;name="";constructor(t){super();const r={...z,...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={...z,...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 P 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 P&&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 D=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",W={color:"rgba(255,255,255,1)",count:3,duration:1500};class q extends a{duration;count;vertical;direction;color;_time;image;name="";constructor(t){super();const r={...W,...t};Object.prototype.hasOwnProperty.call(r,"vertical")||(r.vertical=1),console.log(r.color),this.name=o.LightWall,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 q&&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(o.LightWall,{fabric:{type:o.LightWall,uniforms:{color:this.color,duration:this.duration,vertical:this.vertical,image:this.image,count:this.count,time:-20},source:t},translucent:()=>!0})}}const R=t=>{const r={...W,...t};return{material:new e.Material({fabric:{type:o.LightWall,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(st.s), fract(float(${e.count})*st.t${r} time)));\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:L},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:L},translucent:!0})}},L="\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";export{P as CircleApertureMaterialProperty,I as CircleRaderFanMaterialProperty,y as CircleRaderWaveMaterialProperty,g as CircleWaveMaterialProperty,F as EllipsoidElectricMaterialProperty,q as LightWallMaterialProperty,i as Material,d as PolylineFlowMaterialProperty,l as PolylineTrailMaterialProperty,D as createCircleApertureMaterial,M as createCircleRaderFanMaterial,C as createCircleWaveMaterial,O as createEllipsoidElectricMaterial,R as createLightWallMaterial,p as createPoylineFlowMaterial,_ as createRaderWaveMaterial,N as createScanRadarMaterial,c as createTrailMaterial};
|
|
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:"LightWallMater",CircleAperture:"CircleAperture",RadarScanCircle:"RadarScanCircle",EllipsoidElectric:"EllipsoidElectric",EllipsoidScan:"EllipsoidScan",Corridor:"Corridor"};(()=>{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:b},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:b},translucent:!0})}},b="\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",v={color:"rgba(255,255,255,1)",speed:8};class y extends a{speed;color;name="";constructor(t){super();const r={...v,...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={...v,...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",W={color:"rgba(255,255,255,1)",count:3,duration:1500};class q extends a{duration;count;vertical;direction;color;_time;image;name="";constructor(t){super();const r={...W,...t};Object.prototype.hasOwnProperty.call(r,"vertical")||(r.vertical=1),console.log(r.color),this.name=o.LightWall,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 q&&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(o.LightWall,{fabric:{type:o.LightWall,uniforms:{color:this.color,duration:this.duration,vertical:this.vertical,image:this.image,count:this.count,time:-20},source:t},translucent:()=>!0})}}const E=t=>{const r={...W,...t};return{material:new e.Material({fabric:{type:o.LightWall,uniforms:{color:e.Color.fromCssColorString(r.color),duration:r.duration,vertical:r.vertical,image:r.image,count:r.count,time:-20},source:R({count:r.count,vertical:r.vertical,direction:r.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(st.s), fract(float(${e.count})*st.t${r} time)));\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:L},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:L},translucent:!0})}},L="\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:H},translucent:()=>!0})}}const k=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:H},translucent:!0})}},H="\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";export{D as CircleApertureMaterialProperty,I as CircleRaderFanMaterialProperty,y as CircleRaderWaveMaterialProperty,g as CircleWaveMaterialProperty,F as EllipsoidElectricMaterialProperty,j as EllipsoidScanMaterialProperty,q as LightWallMaterialProperty,i as Material,d as PolylineFlowMaterialProperty,l as PolylineTrailMaterialProperty,P as createCircleApertureMaterial,M as createCircleRaderFanMaterial,C as createCircleWaveMaterial,O as createEllipsoidElectricMaterial,k as createEllipsoidScanMaterial,E as createLightWallMaterial,p as createPoylineFlowMaterial,_ as createRaderWaveMaterial,N as createScanRadarMaterial,c as createTrailMaterial};
|
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.8",
|
|
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.8"
|
|
35
35
|
},
|
|
36
36
|
"types": "./dist/index.d.ts",
|
|
37
37
|
"scripts": {
|