@ino-cesium/material 0.0.8 → 0.0.9
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 +50 -4
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ interface ICircleRaderFanMaterialOptions {
|
|
|
35
35
|
color?: string;
|
|
36
36
|
speed?: number;
|
|
37
37
|
}
|
|
38
|
-
interface ILightWallMaterialOptions {
|
|
38
|
+
interface ILightWallMaterialOptions$1 {
|
|
39
39
|
image: string;
|
|
40
40
|
color?: string;
|
|
41
41
|
count?: number;
|
|
@@ -111,6 +111,14 @@ interface IRadarScanMaterialOptions {
|
|
|
111
111
|
}
|
|
112
112
|
interface ICorridorMaterialOptions {
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* 闪电材质,
|
|
116
|
+
* https://www.shadertoy.com/view/XXyGzh
|
|
117
|
+
*/
|
|
118
|
+
interface IZapsMaterialOptions {
|
|
119
|
+
color?: string;
|
|
120
|
+
speed: number;
|
|
121
|
+
}
|
|
114
122
|
|
|
115
123
|
type types_ICircleApertureMaterialOptions = ICircleApertureMaterialOptions;
|
|
116
124
|
type types_ICircleRaderFanMaterialOptions = ICircleRaderFanMaterialOptions;
|
|
@@ -119,12 +127,12 @@ type types_ICircleWaveMaterialOptions = ICircleWaveMaterialOptions;
|
|
|
119
127
|
type types_ICorridorMaterialOptions = ICorridorMaterialOptions;
|
|
120
128
|
type types_IEllipsoidElectricMaterialOptions = IEllipsoidElectricMaterialOptions;
|
|
121
129
|
type types_IEllipsoidScanMaterialOptions = IEllipsoidScanMaterialOptions;
|
|
122
|
-
type types_ILightWallMaterialOptions = ILightWallMaterialOptions;
|
|
123
130
|
type types_IPolylineFlowMaterialOptions = IPolylineFlowMaterialOptions;
|
|
124
131
|
type types_IPolylineTrailMaterialOptions = IPolylineTrailMaterialOptions;
|
|
125
132
|
type types_IRadarScanMaterialOptions = IRadarScanMaterialOptions;
|
|
133
|
+
type types_IZapsMaterialOptions = IZapsMaterialOptions;
|
|
126
134
|
declare namespace types {
|
|
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,
|
|
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, ILightWallMaterialOptions$1 as ILightWallMaterialOptions, types_IPolylineFlowMaterialOptions as IPolylineFlowMaterialOptions, types_IPolylineTrailMaterialOptions as IPolylineTrailMaterialOptions, types_IRadarScanMaterialOptions as IRadarScanMaterialOptions, types_IZapsMaterialOptions as IZapsMaterialOptions };
|
|
128
136
|
}
|
|
129
137
|
|
|
130
138
|
/**
|
|
@@ -270,6 +278,23 @@ declare class LightWallMaterialProperty extends BaseMaterialProperty {
|
|
|
270
278
|
declare const createLightWallMaterial: (options: ILightWallMaterialOptions) => {
|
|
271
279
|
material: Cesium.Material;
|
|
272
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
|
+
}
|
|
273
298
|
|
|
274
299
|
/**
|
|
275
300
|
* 雷达扇形扫描
|
|
@@ -309,4 +334,25 @@ declare const createEllipsoidScanMaterial: (options: IEllipsoidScanMaterialOptio
|
|
|
309
334
|
material: Cesium.Material;
|
|
310
335
|
};
|
|
311
336
|
|
|
312
|
-
|
|
337
|
+
/**
|
|
338
|
+
* 闪电迁移shadertoy
|
|
339
|
+
* https://www.shadertoy.com/view/XXyGzh
|
|
340
|
+
*/
|
|
341
|
+
declare class ZapsMaterialProperty extends BaseMaterialProperty {
|
|
342
|
+
private color;
|
|
343
|
+
private speed;
|
|
344
|
+
private name;
|
|
345
|
+
constructor(options: IZapsMaterialOptions);
|
|
346
|
+
get isConstant(): boolean;
|
|
347
|
+
get definitionChanged(): Cesium.Event<(...args: any[]) => void>;
|
|
348
|
+
getType(): string;
|
|
349
|
+
getValue(time: Cesium.JulianDate, result: any): any;
|
|
350
|
+
equals(other: ZapsMaterialProperty): any;
|
|
351
|
+
init(): void;
|
|
352
|
+
}
|
|
353
|
+
declare const createZapsMaterial: (options: IZapsMaterialOptions) => {
|
|
354
|
+
material: Cesium.Material;
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
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 };
|
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",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};
|
|
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};
|
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.9",
|
|
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.9"
|
|
35
35
|
},
|
|
36
36
|
"types": "./dist/index.d.ts",
|
|
37
37
|
"scripts": {
|