cesium_dev_kit 1.1.22 → 1.1.24
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/CHANGELOG.md +90 -0
- package/README.md +299 -291
- package/README.zh-CN.md +279 -0
- package/SECURITY.md +21 -0
- package/dist/Analysis-BLpVrGfg.d.mts +143 -0
- package/dist/Analysis-DmO1gtgS.d.ts +143 -0
- package/dist/Base-DH8H9suE.d.mts +635 -0
- package/dist/Base-DH8H9suE.d.ts +635 -0
- package/dist/Base-_BOXyMdS.d.ts +43 -0
- package/dist/Base-skqjcPfo.d.mts +43 -0
- package/dist/Control-B7AMFmHe.d.ts +98 -0
- package/dist/Control-BrpRU7RP.d.mts +98 -0
- package/dist/CustomCesiumPlugin-BqgAvlhi.d.ts +29 -0
- package/dist/CustomCesiumPlugin-CKYQ-7i9.d.mts +29 -0
- package/dist/Draw-1NhPP8z3.d.mts +490 -0
- package/dist/Draw-DRh7yNzc.d.ts +490 -0
- package/dist/Graphics-CuFNsQ3b.d.ts +1565 -0
- package/dist/Graphics-QE3Gb43w.d.mts +1565 -0
- package/dist/Material-CeZ4l-tY.d.mts +165 -0
- package/dist/Material-Cqbyf2Pn.d.ts +165 -0
- package/dist/Math3d-0nO-vFbT.d.mts +179 -0
- package/dist/Math3d-t635PYzU.d.ts +179 -0
- package/dist/PassEffect-DEFyytQZ.d.ts +41 -0
- package/dist/PassEffect-DEgElnVk.d.mts +41 -0
- package/dist/Plugin-BPCX0zTu.d.mts +197 -0
- package/dist/Plugin-DnYT0bue.d.ts +197 -0
- package/dist/Primitive-BNXp-9_6.d.mts +199 -0
- package/dist/Primitive-UEAuUimH.d.ts +199 -0
- package/dist/ThreeJs-BAlEWxa1.d.mts +44 -0
- package/dist/ThreeJs-DpAcw_qf.d.ts +44 -0
- package/dist/analysis.cjs +145 -0
- package/dist/analysis.cjs.map +1 -0
- package/dist/analysis.d.mts +6 -0
- package/dist/analysis.d.ts +6 -0
- package/dist/analysis.mjs +145 -0
- package/dist/analysis.mjs.map +1 -0
- package/dist/control.cjs +140 -0
- package/dist/control.cjs.map +1 -0
- package/dist/control.d.mts +4 -0
- package/dist/control.d.ts +4 -0
- package/dist/control.mjs +140 -0
- package/dist/control.mjs.map +1 -0
- package/dist/custom-cesium-plugin.cjs +507 -0
- package/dist/custom-cesium-plugin.cjs.map +1 -0
- package/dist/custom-cesium-plugin.d.mts +4 -0
- package/dist/custom-cesium-plugin.d.ts +4 -0
- package/dist/custom-cesium-plugin.mjs +507 -0
- package/dist/custom-cesium-plugin.mjs.map +1 -0
- package/dist/default-static.cjs +3 -0
- package/dist/default-static.cjs.map +1 -0
- package/dist/default-static.d.mts +37 -0
- package/dist/default-static.d.ts +37 -0
- package/dist/default-static.mjs +3 -0
- package/dist/default-static.mjs.map +1 -0
- package/dist/draw.cjs +140 -0
- package/dist/draw.cjs.map +1 -0
- package/dist/draw.d.mts +6 -0
- package/dist/draw.d.ts +6 -0
- package/dist/draw.mjs +140 -0
- package/dist/draw.mjs.map +1 -0
- package/dist/graphics.cjs +140 -0
- package/dist/graphics.cjs.map +1 -0
- package/dist/graphics.d.mts +19 -0
- package/dist/graphics.d.ts +19 -0
- package/dist/graphics.mjs +140 -0
- package/dist/graphics.mjs.map +1 -0
- package/dist/index.cjs +1112 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +674 -0
- package/dist/index.d.ts +674 -0
- package/dist/index.mjs +1112 -0
- package/dist/index.mjs.map +1 -0
- package/dist/material.cjs +391 -0
- package/dist/material.cjs.map +1 -0
- package/dist/material.d.mts +4 -0
- package/dist/material.d.ts +4 -0
- package/dist/material.mjs +391 -0
- package/dist/material.mjs.map +1 -0
- package/dist/pass-effect.cjs +416 -0
- package/dist/pass-effect.cjs.map +1 -0
- package/dist/pass-effect.d.mts +4 -0
- package/dist/pass-effect.d.ts +4 -0
- package/dist/pass-effect.mjs +416 -0
- package/dist/pass-effect.mjs.map +1 -0
- package/dist/plugin.cjs +141 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.mts +4 -0
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.mjs +141 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/primitive.cjs +370 -0
- package/dist/primitive.cjs.map +1 -0
- package/dist/primitive.d.mts +4 -0
- package/dist/primitive.d.ts +4 -0
- package/dist/primitive.mjs +370 -0
- package/dist/primitive.mjs.map +1 -0
- package/dist/three.cjs +140 -0
- package/dist/three.cjs.map +1 -0
- package/dist/three.d.mts +4 -0
- package/dist/three.d.ts +4 -0
- package/dist/three.mjs +140 -0
- package/dist/three.mjs.map +1 -0
- package/package.json +290 -46
- package/dist/index.js +0 -1
- package/dist/index.min.js +0 -1
- package/dist/index.umd.js +0 -1
- package/index.js +0 -37
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
'use strict';var H=class extends Error{constructor(u,g,m={}){super(`[cesium_dev_kit:${u}] ${g}`),this.name="CesiumDevKitError",this.code=u,this.details=m.details,this.cause=m.cause,Object.setPrototypeOf(this,new.target.prototype);}};function X(e,u){let g=u!=null&&u.scope?`[cesium_dev_kit:${u.scope}]`:"[cesium_dev_kit]";console.warn(g,e,u!=null?u:"");}var W=class{constructor(u){this.viewer=null;this.Cesium=u,this.init_data();}init_data(){this.viewer=null;}init({containerId:u,viewerConfig:g,extraConfig:m,MapImageryList:t,imageryProvider:r,viewer:a}){let i=u,o={contextOptions:{webgl:{alpha:false}},animation:false,timeline:false,fullscreenButton:false,geocoder:false,homeButton:false,selectionIndicator:false,shadow:true,sceneMode:this.Cesium.SceneMode.SCENE3D,infoBox:false,sceneModePicker:false,navigationHelpButton:false,projectionPicker:false,baseLayerPicker:false,shouldAnimate:true,navigation:false,showRenderLoopErrors:true},l=this.findCesiumProvider(r),s=m==null?void 0:m.AccessToken;s&&(this.Cesium.Ion.defaultAccessToken=s),o=Object.assign(o,g);let c=a||new this.Cesium.Viewer(i,{...o,...l});if(m&&!m.logo){let n=c.cesiumWidget.creditContainer;n.style.display="none";}if(m&&m.depthTest&&(c.scene.globe.depthTestAgainstTerrain=true),t&&t.length>0)for(let n=0;n<t.length;n++)this.addImageryProvider(c,t[n].type,t[n].option||t[n].classConfig);if(!a){let n=typeof document=="undefined"?null:i&&i.nodeType===1?i:document.getElementById(i);this.bindContainerResize(c,n);}return this.viewer=c,c}bindContainerResize(u,g){if(typeof ResizeObserver=="undefined"||!g)return;let m=()=>{try{(typeof u.isDestroyed!="function"||!u.isDestroyed())&&u.resize();}catch(a){X(a,{scope:"Controller.bindContainerResize"});}},t=new ResizeObserver(m);t.observe(g),typeof requestAnimationFrame=="function"&&requestAnimationFrame(m);let r=u.destroy.bind(u);u.destroy=function(){try{t.disconnect();}catch(a){X(a,{scope:"Controller.bindContainerResize.disconnect"});}return r()};}addImageryProvider(u,g,m){u.imageryLayers.addImageryProvider(this.createCesiumProvider({type:g,option:m}));}findCesiumProvider(u){let g={};if(!u)return g;for(let m in u){let t=u[m];if(t&&t.type){g[m]=this.createCesiumProvider(t);continue}g[m]=u[m];}return g}createCesiumProvider(u){switch(u.type){case "WebMapTileServiceImageryProvider":return new this.Cesium[u.type](u.option);case "UrlTemplateImageryProvider":return new this.Cesium[u.type](u.option);case "TileMapServiceImageryProvider":return new this.Cesium[u.type](u.option)}}};function ne(e,u){if(!u)return "";if(/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(u)||u.startsWith("data:")||u.startsWith("/"))return u;let g=(e||"").replace(/\/+$/,"");return g?g+"/"+u.replace(/^\/+/,""):u}function Y(e=""){return {baseService:e,skyBox:{one:{positiveX:"static/data/images/SkyBox/00h+00.jpg",negativeX:"static/data/images/SkyBox/12h+00.jpg",positiveY:"static/data/images/SkyBox/06h+00.jpg",negativeY:"static/data/images/SkyBox/18h+00.jpg",positiveZ:"static/data/images/SkyBox/06h+90.jpg",negativeZ:"static/data/images/SkyBox/06h-90.jpg"},two:{positiveX:"static/data/images/SkyBox/Version2_dark_px.jpg",negativeX:"static/data/images/SkyBox/Version2_dark_mx.jpg",positiveY:"static/data/images/SkyBox/Version2_dark_py.jpg",negativeY:"static/data/images/SkyBox/Version2_dark_my.jpg",positiveZ:"static/data/images/SkyBox/Version2_dark_pz.jpg",negativeZ:"static/data/images/SkyBox/Version2_dark_mz.jpg"},three:{positiveX:"static/data/images/SkyBox/tycho2t3_80_pxs.jpg",negativeX:"static/data/images/SkyBox/tycho2t3_80_mxs.jpg",positiveY:"static/data/images/SkyBox/tycho2t3_80_pys.jpg",negativeY:"static/data/images/SkyBox/tycho2t3_80_mys.jpg",positiveZ:"static/data/images/SkyBox/tycho2t3_80_pzs.jpg",negativeZ:"static/data/images/SkyBox/tycho2t3_80_mzs.jpg"},nearOne:{positiveX:"static/data/images/SkyBox/rightav9.jpg",negativeX:"static/data/images/SkyBox/leftav9.jpg",positiveY:"static/data/images/SkyBox/frontav9.jpg",negativeY:"static/data/images/SkyBox/backav9.jpg",positiveZ:"static/data/images/SkyBox/topav9.jpg",negativeZ:"static/data/images/SkyBox/bottomav9.jpg"},nearTwo:{positiveX:"static/data/images/SkyBox/SunSetRight.png",negativeX:"static/data/images/SkyBox/SunSetLeft.png",positiveY:"static/data/images/SkyBox/SunSetFront.png",negativeY:"static/data/images/SkyBox/SunSetBack.png",positiveZ:"static/data/images/SkyBox/SunSetUp.png",negativeZ:"static/data/images/SkyBox/SunSetDown.png"},nearThree:{positiveX:"static/data/images/SkyBox/Right.jpg",negativeX:"static/data/images/SkyBox/Left.jpg",positiveY:"static/data/images/SkyBox/Front.jpg",negativeY:"static/data/images/SkyBox/Back.jpg",positiveZ:"static/data/images/SkyBox/Up.jpg",negativeZ:"static/data/images/SkyBox/Down.jpg"}},drawPointGraphics:"static/data/images/file/location4.png",graphic:{craeteRotateCylinderGraphics:"static/data/images/file/cc2.png",craeteDynamicCricleGraphics:"static/data/images/Textures/circle_bg.png",craeteDynamicShadeWallGraphics:"static/data/images/Textures/fence.png",createCustomDefBillboardGraphics:"static/data/images/file/div1.png"},material:{PolylineCityLinkMaterialProperty:"static/data/images/Textures/meteor_01.png",WarnLinkMaterialProperty:"static/data/images/Textures/jsx2.png"},plugin:{Css3Renderer_one:"static/data/images/Textures/circle2.png",Css3Renderer_two:"static/data/images/Textures/circle1.png"},primitive:{TetrahedronPrimitive:"static/data/images/Textures/fence.png",WaterPrimitive:"static/data/images/Textures/river.png"},passEffect:{satellite:"static/data/images/file/satellite.svg"},amalysis:{createClipPlanAnalysis_wallImg:"static/data/images/file/excavate_side_min.jpg",createClipPlanAnalysis_bottomImg:"static/data/images/file/excavate_bottom_min.jpg",createSubmergedAnalysis:"static/data/images/file/water.png"}}}var fe=Object.assign((e,u)=>e!=null?e:u,{EMPTY_OBJECT:Object.freeze({})}),Z=fe;function $(e){function u(...g){let m=e();return new m(...g)}return u.prototype=e().prototype,Object.defineProperty(u,"__cesiumDevKitCreateModule",{value:e,enumerable:false,configurable:false,writable:false}),u}function q(e){let u=e==null?void 0:e.__cesiumDevKitCreateModule;return typeof u=="function"?u():e}function oe(e){if(e)try{if(typeof e.isDestroyed=="function"&&e.isDestroyed())return;typeof e.destroy=="function"&&e.destroy();}catch(u){console.warn("[cesium_dev_kit] failed to dispose viewer:",u);}}var V=new WeakMap;function K(e,u){if(!e||typeof u!="function")return;let g=V.get(e);g?g.push(u):V.set(e,[u]);}function Q(e,u){if(!e||!u||e===u)return;let g=V.get(e);if(!g||g.length===0)return;V.delete(e);let m=V.get(u);m?m.push(...g):V.set(u,g);}function ee(e){if(!e||typeof e!="object"&&typeof e!="function")return;let u=V.get(e);if(u){V.delete(e);for(let g=u.length-1;g>=0;g--)try{u[g]();}catch(m){console.warn("[cesium_dev_kit] cleanup failed:",m);}}}function te(e){e&&typeof e.destroy!="function"&&Object.defineProperty(e,"destroy",{value:function(){ee(this);},enumerable:false,configurable:true,writable:true});}function _e(){let e={},u;class g{constructor(t,r,a){if(t){this._viewer=t,e=r,u=a||Y(),this._drawLayer=new e.CustomDataSource("drawLayer"),t&&t.dataSources.add(this._drawLayer);let i=this._drawLayer;te(this),K(this,()=>{this._viewer&&i&&(this._viewer.dataSources.remove(i,true),this._drawLayer===i&&(this._drawLayer=void 0));}),this.type="base",this.id="base",this.myname="BASE",this._installBaiduImageryProvider(),this._installGoogleImageryProvider(),this._installAmapImageryProvider(),this._installTencentImageryProvider(),this._installTdtImageryProvider(),this._installGroundSkyBox();}}createGraphics(){return new e.Entity}_objHasOwnProperty(t,r,a){return t.hasOwnProperty(r)?t[r]:a}getDfSt(t){if(!u)return;let r=u,a=t.reduce((i,o)=>i?i[o]:r[o],void 0);if(a!=null)return typeof a!="string"?a:ne(r.baseService,a)}setOneSkyBox(){return new e.SkyBox({sources:{positiveX:this.getDfSt(["skyBox","one","positiveX"])||"static/data/images/SkyBox/00h+00.jpg",negativeX:this.getDfSt(["skyBox","one","negativeX"])||"static/data/images/SkyBox/12h+00.jpg",positiveY:this.getDfSt(["skyBox","one","positiveY"])||"static/data/images/SkyBox/06h+00.jpg",negativeY:this.getDfSt(["skyBox","one","negativeY"])||"static/data/images/SkyBox/18h+00.jpg",positiveZ:this.getDfSt(["skyBox","one","positiveZ"])||"static/data/images/SkyBox/06h+90.jpg",negativeZ:this.getDfSt(["skyBox","one","negativeZ"])||"static/data/images/SkyBox/06h-90.jpg"}})}setTwoSkyBox(){return new e.SkyBox({sources:{positiveX:this.getDfSt(["skyBox","two","negativeZ"])||"static/data/images/SkyBox/Version2_dark_px.jpg",negativeX:this.getDfSt(["skyBox","two","negativeX"])||"static/data/images/SkyBox/Version2_dark_mx.jpg",positiveY:this.getDfSt(["skyBox","two","positiveY"])||"static/data/images/SkyBox/Version2_dark_py.jpg",negativeY:this.getDfSt(["skyBox","two","negativeY"])||"static/data/images/SkyBox/Version2_dark_my.jpg",positiveZ:this.getDfSt(["skyBox","two","positiveZ"])||"static/data/images/SkyBox/Version2_dark_pz.jpg",negativeZ:this.getDfSt(["skyBox","two","negativeZ"])||"static/data/images/SkyBox/Version2_dark_mz.jpg"}})}setThreeSkyBox(){return new e.SkyBox({sources:{positiveX:this.getDfSt(["skyBox","three","negativeZ"])||"static/data/images/SkyBox/tycho2t3_80_pxs.jpg",negativeX:this.getDfSt(["skyBox","three","negativeX"])||"static/data/images/SkyBox/tycho2t3_80_mxs.jpg",positiveY:this.getDfSt(["skyBox","three","positiveY"])||"static/data/images/SkyBox/tycho2t3_80_pys.jpg",negativeY:this.getDfSt(["skyBox","three","negativeY"])||"static/data/images/SkyBox/tycho2t3_80_mys.jpg",positiveZ:this.getDfSt(["skyBox","three","positiveZ"])||"static/data/images/SkyBox/tycho2t3_80_pzs.jpg",negativeZ:this.getDfSt(["skyBox","three","negativeZ"])||"static/data/images/SkyBox/tycho2t3_80_mzs.jpg"}})}setOneGroundSkyBox(){return new e.Scene.GroundSkyBox({sources:{positiveX:this.getDfSt(["skyBox","nearOne","positiveX"])||"static/data/images/SkyBox/rightav9.jpg",negativeX:this.getDfSt(["skyBox","nearOne","negativeX"])||"static/data/images/SkyBox/leftav9.jpg",positiveY:this.getDfSt(["skyBox","nearOne","positiveY"])||"static/data/images/SkyBox/frontav9.jpg",negativeY:this.getDfSt(["skyBox","nearOne","negativeY"])||"static/data/images/SkyBox/backav9.jpg",positiveZ:this.getDfSt(["skyBox","nearOne","positiveZ"])||"static/data/images/SkyBox/topav9.jpg",negativeZ:this.getDfSt(["skyBox","nearOne","negativeZ"])||"static/data/images/SkyBox/bottomav9.jpg"}})}setTwoGroundSkyBox(){return new e.Scene.GroundSkyBox({sources:{positiveX:this.getDfSt(["skyBox","nearTwo","positiveX"])||"static/data/images/SkyBox/SunSetRight.png",negativeX:this.getDfSt(["skyBox","nearTwo","negativeX"])||"static/data/images/SkyBox/SunSetLeft.png",positiveY:this.getDfSt(["skyBox","nearTwo","positiveY"])||"static/data/images/SkyBox/SunSetFront.png",negativeY:this.getDfSt(["skyBox","nearTwo","negativeY"])||"static/data/images/SkyBox/SunSetBack.png",positiveZ:this.getDfSt(["skyBox","nearTwo","positiveZ"])||"static/data/images/SkyBox/SunSetUp.png",negativeZ:this.getDfSt(["skyBox","nearTwo","negativeZ"])||"static/data/images/SkyBox/SunSetDown.png"}})}setThreeGroundSkyBox(){return new e.Scene.GroundSkyBox({sources:{positiveX:this.getDfSt(["skyBox","nearThree","positiveX"])||"static/data/images/SkyBox/Right.jpg",negativeX:this.getDfSt(["skyBox","nearThree","negativeX"])||"static/data/images/SkyBox/Left.jpg",positiveY:this.getDfSt(["skyBox","nearThree","positiveY"])||"static/data/images/SkyBox/Front.jpg",negativeY:this.getDfSt(["skyBox","nearThree","negativeY"])||"static/data/images/SkyBox/Back.jpg",positiveZ:this.getDfSt(["skyBox","nearThree","positiveZ"])||"static/data/images/SkyBox/Up.jpg",negativeZ:this.getDfSt(["skyBox","nearThree","negativeZ"])||"static/data/images/SkyBox/Down.jpg"}})}setDarkEffect(t){t=t||{};var r=`uniform sampler2D colorTexture;
|
|
2
|
+
in vec2 v_textureCoordinates;
|
|
3
|
+
uniform float scale;
|
|
4
|
+
uniform vec3 offset;
|
|
5
|
+
void main() {
|
|
6
|
+
vec4 color = texture(colorTexture, v_textureCoordinates);
|
|
7
|
+
out_FragColor = vec4(color.r*0.2,color.g * 0.4,color.b*0.6, 1.0);
|
|
8
|
+
}
|
|
9
|
+
`;return this._viewer.scene.postProcessStages.add(new e.PostProcessStage({name:"darkEffect",fragmentShader:r,uniforms:{scale:1,offset(){return t.offset||new e.Cartesian3(.1,.2,.3)}}}))}setBlurBloom(t){if(this._viewer&&t){var r=`uniform float height;
|
|
10
|
+
uniform float width;
|
|
11
|
+
uniform sampler2D colorTexture1;
|
|
12
|
+
|
|
13
|
+
in vec2 v_textureCoordinates;
|
|
14
|
+
|
|
15
|
+
const int SAMPLES = 9;
|
|
16
|
+
void main()
|
|
17
|
+
{
|
|
18
|
+
vec2 st = v_textureCoordinates;
|
|
19
|
+
float wr = float(1.0 / width);
|
|
20
|
+
float hr = float(1.0 / height);
|
|
21
|
+
vec4 result = vec4(0.0);
|
|
22
|
+
int count = 0;
|
|
23
|
+
for(int i = -SAMPLES; i <= SAMPLES; ++i){
|
|
24
|
+
for(int j = -SAMPLES; j <= SAMPLES; ++j){
|
|
25
|
+
vec2 offset = vec2(float(i) * wr, float(j) * hr);
|
|
26
|
+
result += texture(colorTexture1, st + offset);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
result = result / float(count);
|
|
30
|
+
out_FragColor = result;
|
|
31
|
+
}
|
|
32
|
+
`;return this._viewer.scene.postProcessStages.add(new e.PostProcessStage({name:"blur_x_direction",fragmentShader:r,uniforms:{width:t.width,height:t.height,colorTexture1:"Bright"}}))}}setRainEffect(){if(this._viewer){var t=`uniform sampler2D colorTexture;
|
|
33
|
+
in vec2 v_textureCoordinates;
|
|
34
|
+
|
|
35
|
+
float hash(float x){
|
|
36
|
+
return fract(sin(x*23.3)*13.13);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void main(){
|
|
40
|
+
float time = czm_frameNumber / 60.0;
|
|
41
|
+
vec2 resolution = czm_viewport.zw;
|
|
42
|
+
vec2 uv=(gl_FragCoord.xy*2.-resolution.xy)/min(resolution.x,resolution.y);
|
|
43
|
+
vec3 c=vec3(.6,.7,.8);
|
|
44
|
+
float a=-.4;
|
|
45
|
+
float si=sin(a),co=cos(a);
|
|
46
|
+
uv*=mat2(co,-si,si,co);
|
|
47
|
+
uv*=length(uv+vec2(0,4.9))*.3+1.;
|
|
48
|
+
float v=1.-sin(hash(floor(uv.x*100.))*2.);
|
|
49
|
+
float b=clamp(abs(sin(20.*time*v+uv.y*(5./(2.+v))))-.95,0.,1.)*20.;
|
|
50
|
+
c*=v*b;
|
|
51
|
+
out_FragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(c, 1), 0.2);
|
|
52
|
+
}
|
|
53
|
+
`;return this._viewer.scene.postProcessStages.add(new e.PostProcessStage({name:"rainEffect",fragmentShader:t}))}}setSnowEffect(){if(this._viewer){var t=`uniform sampler2D colorTexture;
|
|
54
|
+
in vec2 v_textureCoordinates;
|
|
55
|
+
float snow(vec2 uv,float scale){
|
|
56
|
+
float time = czm_frameNumber / 60.0;
|
|
57
|
+
float w=smoothstep(1.,0.,-uv.y*(scale/10.));
|
|
58
|
+
if(w<.1)return 0.;
|
|
59
|
+
uv+=time/scale;
|
|
60
|
+
uv.y+=time*2./scale;
|
|
61
|
+
uv.x+=sin(uv.y+time*.5)/scale;
|
|
62
|
+
uv*=scale;
|
|
63
|
+
vec2 s=floor(uv),f=fract(uv),p;
|
|
64
|
+
float k=3.,d;
|
|
65
|
+
p=.5+.35*sin(11.*fract(sin((s+p+scale)*mat2(7,3,6,5))*5.))-f;
|
|
66
|
+
d=length(p);
|
|
67
|
+
k=min(d,k);
|
|
68
|
+
k=smoothstep(0.,k,sin(f.x+f.y)*0.01);
|
|
69
|
+
return k*w;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void main(){
|
|
73
|
+
vec2 resolution = czm_viewport.zw;
|
|
74
|
+
vec2 uv=(gl_FragCoord.xy*2.-resolution.xy)/min(resolution.x,resolution.y);
|
|
75
|
+
vec3 finalColor=vec3(0);
|
|
76
|
+
float c = 0.0;
|
|
77
|
+
c+=snow(uv,30.)*.0;
|
|
78
|
+
c+=snow(uv,20.)*.0;
|
|
79
|
+
c+=snow(uv,15.)*.0;
|
|
80
|
+
c+=snow(uv,10.);
|
|
81
|
+
c+=snow(uv,8.);
|
|
82
|
+
c+=snow(uv,6.);
|
|
83
|
+
c+=snow(uv,5.);
|
|
84
|
+
finalColor=(vec3(c));
|
|
85
|
+
out_FragColor = mix(texture(colorTexture, v_textureCoordinates), vec4(finalColor,1), 0.3);
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
`;return this._viewer.scene.postProcessStages.add(new e.PostProcessStage({name:"snowEffect",fragmentShader:t}))}}setFogEffect(){if(this._viewer){var t=`float getDistance(sampler2D depthTexture, vec2 texCoords)
|
|
89
|
+
{
|
|
90
|
+
float depth = czm_unpackDepth(texture(depthTexture, texCoords));
|
|
91
|
+
if (depth == 0.0) {
|
|
92
|
+
return czm_infinity;
|
|
93
|
+
}
|
|
94
|
+
vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);
|
|
95
|
+
return -eyeCoordinate.z / eyeCoordinate.w;
|
|
96
|
+
}
|
|
97
|
+
float interpolateByDistance(vec4 nearFarScalar, float distance)
|
|
98
|
+
{
|
|
99
|
+
float startDistance = nearFarScalar.x;
|
|
100
|
+
float startValue = nearFarScalar.y;
|
|
101
|
+
float endDistance = nearFarScalar.z;
|
|
102
|
+
float endValue = nearFarScalar.w;
|
|
103
|
+
float t = clamp((distance - startDistance) / (endDistance - startDistance), 0.0, 1.0);
|
|
104
|
+
return mix(startValue, endValue, t);
|
|
105
|
+
}
|
|
106
|
+
vec4 alphaBlend(vec4 sourceColor, vec4 destinationColor)
|
|
107
|
+
{
|
|
108
|
+
return sourceColor * vec4(sourceColor.aaa, 1.0) + destinationColor * (1.0 - sourceColor.a);
|
|
109
|
+
}
|
|
110
|
+
uniform sampler2D colorTexture;
|
|
111
|
+
uniform sampler2D depthTexture;
|
|
112
|
+
uniform vec4 fogByDistance;
|
|
113
|
+
uniform vec4 fogColor;
|
|
114
|
+
in vec2 v_textureCoordinates;
|
|
115
|
+
void main(void)
|
|
116
|
+
{
|
|
117
|
+
float distance = getDistance(depthTexture, v_textureCoordinates);
|
|
118
|
+
vec4 sceneColor = texture(colorTexture, v_textureCoordinates);
|
|
119
|
+
float blendAmount = interpolateByDistance(fogByDistance, distance);
|
|
120
|
+
vec4 finalFogColor = vec4(fogColor.rgb, fogColor.a * blendAmount);
|
|
121
|
+
out_FragColor = alphaBlend(finalFogColor, sceneColor);
|
|
122
|
+
}
|
|
123
|
+
`;return this._viewer.scene.postProcessStages.add(new e.PostProcessStage({fragmentShader:t,uniforms:{fogByDistance:new e.Cartesian4(10,0,200,.3),fogColor:e.Color.AZURE}}))}}setDefSceneConfig(){this._viewer&&(this._viewer.scene.sun.show=false,this._viewer.scene.moon.show=false,this._viewer.scene.fxaa=true,this._viewer.scene.globe.depthTestAgainstTerrain=true,this._viewer.scene.undergroundMode=false,this._viewer.scene.terrainProvider.isCreateSkirt=false,this._viewer.scene.skyAtmosphere.show=false,this._viewer.scene.globe.showGroundAtmosphere=false,this._viewer.scene.globe.enableLighting=true,this._viewer.scene.fog.enabled=false,this._viewer.cesiumWidget.creditContainer.style.display="none");}setBloomLightScene(){this._viewer&&(this._viewer.scene.postProcessStages.bloom.enabled=true,this._viewer.scene.postProcessStages.bloom.uniforms.contrast=119,this._viewer.scene.postProcessStages.bloom.uniforms.brightness=-0.4,this._viewer.scene.postProcessStages.bloom.uniforms.glowOnly=false,this._viewer.scene.postProcessStages.bloom.uniforms.delta=.9,this._viewer.scene.postProcessStages.bloom.uniforms.sigma=3.78,this._viewer.scene.postProcessStages.bloom.uniforms.stepSize=5,this._viewer.scene.postProcessStages.bloom.uniforms.isSelected=false);}removePostProcessStage(t){t&&(Array.isArray(t)?t.forEach(r=>{this._viewer.scene.postProcessStages.contains(r)&&this._viewer.scene.postProcessStages.remove(r);}):this._viewer.scene.postProcessStages.contains(t)&&this._viewer.scene.postProcessStages.remove(t));}setView(t){if(this._viewer&&t&&t.position){if(t.distance){var r=new e.Cartesian3(0,t.distance,window.opt.distance);t.position=e.Cartesian3.add(t.position,r,new e.Cartesian3);}this._viewer.scene.camera.setView({destination:t.position,orientation:t.orientation||{heading:e.Math.toRadians(90),pitch:e.Math.toRadians(90),roll:e.Math.toRadians(0)}});}}flyTo(t){if(this._viewer&&t&&t.position){if(t.distance){var r=new e.Cartesian3(0,t.distance,0);t.position=e.Cartesian3.add(t.position,r,new e.Cartesian3);}this._viewer.scene.camera.flyTo({destination:t.position,orientation:t.orientation||{heading:e.Math.toRadians(90),pitch:e.Math.toRadians(90),roll:e.Math.toRadians(0)},easingFunction:t.easingFunction||e.EasingFunction.LINEAR_NONE,duration:t.duration||3,complete:t.callback});}}transformCartesianToWGS84(t){var r,a,i;if(this._viewer&&t){if(t.x===void 0&&(t.lng!==void 0||t.lon!==void 0))return {lng:Number((r=t.lng)!=null?r:t.lon),lat:Number(t.lat),alt:Number((i=(a=t.alt)!=null?a:t.height)!=null?i:0)};let o=e.Cartographic.fromCartesian(t);return {lng:e.Math.toDegrees(o.longitude),lat:e.Math.toDegrees(o.latitude),alt:o.height}}}transformWGS84ArrayToCartesianArray(t,r){if(this._viewer&&t){var a=this;return t?t.map(function(i){return a.transformWGS84ToCartesian(i,r)}):[]}}transformWGS84ToCartesian(t,r){if(this._viewer)return t?e.Cartesian3.fromDegrees(t.lng||t.lon,t.lat,t.alt=r||t.alt,e.Ellipsoid.WGS84):e.Cartesian3.ZERO}transformCartesianArrayToWGS84Array(t){if(this._viewer){var r=this;return t?t.map(function(a){return r.transformCartesianToWGS84(a)}).filter(function(a){return !!a}):[]}}transformWGS84ToCartographic(t){return t?e.Cartographic.fromDegrees(t.lng||t.lon,t.lat,t.alt):e.Cartographic.ZERO}lnglatArrayToCartesians(t){if(!t||t.length<1)return [];let r=[];for(let a=0;a<t.length;a++){let i=e.Cartesian3.fromDegrees(Number(t[a][0]),Number(t[a][1]),Number(t[a][2]||0));r.push(i);}return r}setCameraEotateHeading(t){if(t){let r=this._viewer,a=e.Cartesian3.fromDegrees(t.lng,t.lat,t.height),i=e.Math.toRadians(-30),o=360/30,l=5e3,s=e.JulianDate.fromDate(new Date);r.clock.startTime=s.clone(),r.clock.currentTime=s.clone(),r.clock.clockRange=e.ClockRange.CLAMPED,r.clock.clockStep=e.ClockStep.SYSTEM_CLOCK;let c=r.camera.heading,n=function(){let y=e.JulianDate.secondsDifference(r.clock.currentTime,r.clock.startTime),d=e.Math.toRadians(y*o)+c;r.scene.camera.setView({destination:a,orientation:{heading:d,pitch:i}}),r.scene.camera.moveBackward(l),e.JulianDate.compare(r.clock.currentTime,r.clock.stopTime)>=0&&r.clock.onTick.removeEventListener(n);};r.clock.onTick.addEventListener(n),K(this,()=>{r.clock.onTick.removeEventListener(n);});}}getCatesian3FromPX(t){if(this._viewer&&t){var r=this._viewer.scene.pick(t),a=null,i=false,o=false;if(r instanceof e.Cesium3DTileFeature&&(i=true),i&&(a=this._viewer.scene.pickPosition(t),a)){let s=e.Cartographic.fromCartesian(a);s.height<0&&(s.height=0);let c=e.Math.toDegrees(s.longitude),n=e.Math.toDegrees(s.latitude),h=s.height;a=this.transformWGS84ToCartesian({lng:c,lat:n,alt:h});}if(!r){var l=this._viewer.scene.camera.getPickRay(t);if(!l)return null;a=this._viewer.scene.globe.pick(l,this._viewer.scene),o=true;}if(r&&!i&&(a=this._viewer.scene.pickPosition(t),a)){let s=e.Cartographic.fromCartesian(a);s.height<0&&(s.height=0);let c=e.Math.toDegrees(s.longitude),n=e.Math.toDegrees(s.latitude),h=s.height;a=this.transformWGS84ToCartesian({lng:c,lat:n,alt:h});}if(!i&&!o&&!r&&(a=this._viewer.scene.camera.pickEllipsoid(t,this._viewer.scene.globe.ellipsoid)),a){let s=this.transformCartesianToWGS84(a);return s.alt<0&&(a=this.transformWGS84ToCartesian(s,.1)),a}return false}}getCameraPosition(){if(this._viewer){var t=this._viewer.scene.camera.pickEllipsoid(new e.Cartesian2(this._viewer.canvas.clientWidth/2,this._viewer.canvas.clientHeight/2));if(t){var r=e.Ellipsoid.WGS84.cartesianToCartographic(t),a=r.longitude*180/Math.PI,i=r.latitude*180/Math.PI,o=this._viewer.camera._direction,l=e.Math.toDegrees(o.x),s=e.Math.toDegrees(o.y),c=e.Math.toDegrees(o.z),n=this._viewer.camera.positionCartographic.height,h=e.Math.toDegrees(this._viewer.camera.heading),y=e.Math.toDegrees(this._viewer.camera.pitch),d=e.Math.toDegrees(this._viewer.camera.roll),x=this._viewer.camera.computeViewRectangle(),p=x.west/Math.PI*180,f=x.north/Math.PI*180,E=x.east/Math.PI*180,S=x.south/Math.PI*180,_=(p+E)/2,M=(f+S)/2;return {lon:a,lat:i,height:n,heading:h,pitch:y,roll:d,position:this._viewer.camera.position,cameraHeading:this._viewer.camera.heading,cameraPitch:this._viewer.camera.pitch,cameraRoll:this._viewer.camera.roll,center:{x:_,y:M},direction:new e.Cartesian3(l,s,c)}}}}pickUpPosition(t){return this.getCatesian3FromPX(t.position)}getHandlerClickPosition(t){if(this._viewer){let r=this._viewer.scene,a=this._viewer,i=r.camera.pickEllipsoid(t.position,r.globe.elliposid),o={cameraPosistion:a.camera.position,heading:a.camera.heading,pitch:a.camera.pitch,roll:a.camera.roll},l=e.Cartographic.fromCartesian(i);l.height<0&&(l.height=0);let s={alt:l.height,lat:e.Math.toDegrees(l.latitude),lon:e.Math.toDegrees(l.longitude)},c=r.pickPosition(t.position),n=e.Cartographic.fromCartesian(c),h={height:n.height,latitude:e.Math.toDegrees(n.latitude),longitude:e.Math.toDegrees(n.longitude)};return {wgs84Coor:s,graphicCoor:h,cameraPosition:o}}}updateCameraState(t){this._viewer.scene._screenSpaceCameraController.enableRotate=t,this._viewer.scene._screenSpaceCameraController.enableTranslate=t,this._viewer.scene._screenSpaceCameraController.enableZoom=t,this._viewer.scene._screenSpaceCameraController.enableTilt=t,this._viewer.scene._screenSpaceCameraController.enableLook=t;}bindHandleEvent({leftClick:t,mouseMove:r,doubleClick:a,leftDown:i,mouseWheel:o,leftUp:l}){if(this._viewer){var s=new e.ScreenSpaceEventHandler(this._viewer.canvas);K(this,()=>{s&&!s.isDestroyed()&&s.destroy();}),t&&s.setInputAction(function(c){t(c,s);},e.ScreenSpaceEventType.LEFT_CLICK),r&&s.setInputAction(function(c){r(c,s);},e.ScreenSpaceEventType.MOUSE_MOVE),a&&s.setInputAction(function(c){a(c,s);},e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),i&&s.setInputAction(function(c){i(c,s);},e.ScreenSpaceEventType.LEFT_DOWN),o&&s.setInputAction(function(c){o(c,s);},e.ScreenSpaceEventType.WHEEL),l&&s.setInputAction(function(c){l(c,s);},e.ScreenSpaceEventType.LEFT_UP);}}bindHandelEvent(t){return this.bindHandleEvent(t)}getHandlePosition(t){if(this._viewer){var r=new e.ScreenSpaceEventHandler(this._viewer.scene.canvas),a=this;K(this,()=>{r&&!r.isDestroyed()&&r.destroy();}),r.setInputAction(function(i){var o=a._viewer.scene.camera.pickEllipsoid(i.endPosition,a._viewer.scene.globe.ellipsoid);typeof t=="function"&&t(a.transformCartesianToWGS84(o),r);},e.ScreenSpaceEventType.MOUSE_MOVE);}}getHandelPosition(t){return this.getHandlePosition(t)}saveSceneImages(){if(this._viewer){let l=function(s){for(var c=s.split(","),n=c[0].match(/:(.*?);/)[1],h=atob(c[1]),y=h.length,d=new Uint8Array(y);y--;)d[y]=h.charCodeAt(y);return new Blob([d],{type:n})};var t=this._viewer.scene.canvas,r=t.toDataURL("image/png").replace("image/png","image/octet-stream"),a=document.createElement("a"),i=l(r),o=URL.createObjectURL(i);a.download="scene.png",a.href=o,a.click();}}_installAmapImageryProvider(){let t="https://webst{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",r="https://webrd{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}";function a(i){return i.url=i.style==="img"?t:r,i.subdomains||(i.subdomains=["01","02","03","04"]),new e.UrlTemplateImageryProvider(i)}e.Scene.AmapImageryProvider=a;}_installTdtImageryProvider(){let t="https://{s}.tianditu.gov.cn/{layer}_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER={layer}&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk={key}";function r(a){return new e.WebMapTileServiceImageryProvider({url:t.replace(/\{layer\}/g,a.style||"vec").replace(/\{key\}/g,a.key||""),layer:a.style+"_w",style:"default",format:"tiles",tileMatrixSetID:"GoogleMapsCompatible",subdomains:["t0","t1","t2","t3","t4","t5","t6","t7"],minimumLevel:0,maximumLevel:18})}e.Scene.TdtImageryProvider=r;}_installTencentImageryProvider(){let t="https://p2.map.gtimg.com/sateTiles/{z}/{sx}/{sy}/{x}_{reverseY}.jpg?version=229",r="https://rt3.map.gtimg.com/tile?z={z}&x={x}&y={reverseY}&type=vector&styleid=1";function a(i){return i.layer==="img"?(i.url||(i.url=t),i.subdomains||(i.subdomains=["0","1","2"]),i.customTags={sx(o,l,s,c){return l>>4},sy(o,l,s,c){return (1<<c)-s>>4}}):i.url||(i.url=r),new e.UrlTemplateImageryProvider(i)}e.Scene.TencentImageryProvider=a;}_installGoogleImageryProvider(){let t="https://mt{s}.google.cn/vt/lyrs=m@207000000&hl=zh-CN&gl=CN&src=app&x={x}&y={y}&z={z}&s=Galile",r="https://mt{s}.google.cn/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}&s=Gali",a="https://mt{s}.google.cn/vt/lyrs=t@131,r@227000000&hl=zh-CN&gl=cn&x={x}&y={y}&z={z}&s=Galile";function i(o){return o.url=o.style==="img"?r:o.style==="ter"?a:t,o.subdomains||(o.subdomains=["1","2","3","4","5"]),new e.UrlTemplateImageryProvider(o)}e.Scene.GoogleImageryProvider=i;}_installGooGleImageryProvider(){return this._installGoogleImageryProvider()}_installBaiduImageryProvider(){var t="https://api{s}.map.bdimg.com/customimage/tile?&x={x}&y={y}&z={z}&scale=1&customid={style}";function r(i){t=i.url||t,this._url=t,this._tileWidth=256,this._tileHeight=256,this._maximumLevel=18,this._minimumLevel=1,this._tilingScheme=new e.WebMercatorTilingScheme({rectangleSouthwestInMeters:new e.Cartesian2(-33554054,-33746824),rectangleNortheastInMeters:new e.Cartesian2(33554054,33746824)}),this._rectangle=this._tilingScheme.rectangle,this._credit=void 0,this._style=i.style||"normal",this._ready=true;}Object.defineProperties(r.prototype,{url:{get(){return this._url}},token:{get(){return this._token}},tileWidth:{get(){if(!this.ready)throw new e.DeveloperError("tileWidth must not be called before the imagery provider is ready.");return this._tileWidth}},tileHeight:{get(){if(!this.ready)throw new e.DeveloperError("tileHeight must not be called before the imagery provider is ready.");return this._tileHeight}},maximumLevel:{get(){if(!this.ready)throw new e.DeveloperError("tileHeight must not be called before the imagery provider is ready.");return this._tileHeight}},minimumLevel:{get(){if(!this.ready)throw new e.DeveloperError("minimumLevel must not be called before the imagery provider is ready.");return 0}},tilingScheme:{get(){if(!this.ready)throw new e.DeveloperError("tilingScheme must not be called before the imagery provider is ready.");return this._tilingScheme}},rectangle:{get(){if(!this.ready)throw new e.DeveloperError("rectangle must not be called before the imagery provider is ready.");return this._rectangle}},ready:{get(){return !!this._url}},credit:{get(){return this._credit}},readyPromise:{get(){return this._readyPromise.promise}},usingPrecachedTiles:{get(){return this._useTiles}},hasAlphaChannel:{get(){return true}},layers:{get(){return this._layers}}});function a(i,o,l,s,c){var n=i._url+"&x={x}&y={y}&z={z}&customid={style}",h=i._tilingScheme.getNumberOfXTilesAtLevel(s),y=i._tilingScheme.getNumberOfYTilesAtLevel(s);return n=n.replace("{x}",String(o-h/2)).replace("{y}",String(y/2-l-1)).replace("{z}",String(s)).replace("{style}",c),n}r.prototype.getTileCredits=function(i,o,l){},r.prototype.requestImage=function(i,o,l){if(!this.ready)throw new e.DeveloperError("requestImage must not be called before the imagery provider is ready.");var s=a(this,i,o,l,this._style);return e.ImageryProvider.loadImage(this,s)},e.Scene.BaiduImageryProvider=r;}_installGroundSkyBox(){var t=e.BoxGeometry,r=e.Cartesian3,a=e.defaultValue||Z,i=e.defined,o=e.destroyObject,l=e.DeveloperError,s=e.GeometryPipeline,c=e.Matrix3,n=e.Matrix4,h=e.Transforms,y=e.VertexFormat,d=e.BufferUsage,x=e.CubeMap,p=e.DrawCommand,f=e.loadCubeMap,E=e.RenderState,S=e.VertexArray,_=e.BlendingState,M=e.SceneMode,C=e.ShaderProgram,P=e.ShaderSource,A=`uniform samplerCube u_cubeMap;
|
|
124
|
+
in vec3 v_texCoord;
|
|
125
|
+
void main()
|
|
126
|
+
{
|
|
127
|
+
vec4 color = texture(u_cubeMap, normalize(v_texCoord));
|
|
128
|
+
out_FragColor = vec4(czm_gammaCorrect(color).rgb, czm_morphTime);
|
|
129
|
+
}
|
|
130
|
+
`,b=`in vec3 position;
|
|
131
|
+
out vec3 v_texCoord;
|
|
132
|
+
uniform mat3 u_rotateMatrix;
|
|
133
|
+
void main()
|
|
134
|
+
{
|
|
135
|
+
vec3 p = czm_viewRotation * u_rotateMatrix * (czm_temeToPseudoFixed * (czm_entireFrustum.y * position));
|
|
136
|
+
gl_Position = czm_projection * vec4(p, 1.0);
|
|
137
|
+
v_texCoord = position.xyz;
|
|
138
|
+
}
|
|
139
|
+
`,D=typeof n.getRotation=="function"?n.getRotation.bind(n):n.getMatrix3.bind(n);function I(T){this.sources=T.sources,this._sources=void 0,this.show=a(T.show,true),this._command=new p({modelMatrix:n.clone(n.IDENTITY),owner:this}),this._cubeMap=void 0,this._attributeLocations=void 0,this._useHdr=void 0;}var k=new c;I.prototype.update=function(T,O){var F=this;if(this.show&&!(T.mode!==M.SCENE3D&&T.mode!==M.MORPHING)&&T.passes.render){var G=T.context;if(this._sources!==this.sources){this._sources=this.sources;var B=this.sources;if(!i(B.positiveX)||!i(B.negativeX)||!i(B.positiveY)||!i(B.negativeY)||!i(B.positiveZ)||!i(B.negativeZ))throw new l("this.sources is required and must have positiveX, negativeX, positiveY, negativeY, positiveZ, and negativeZ properties.");if(typeof B.positiveX!=typeof B.negativeX||typeof B.positiveX!=typeof B.positiveY||typeof B.positiveX!=typeof B.negativeY||typeof B.positiveX!=typeof B.positiveZ||typeof B.positiveX!=typeof B.negativeZ)throw new l("this.sources properties must all be the same type.");typeof B.positiveX=="string"?f(G,this._sources).then(function(w){F._cubeMap=F._cubeMap&&F._cubeMap.destroy(),F._cubeMap=w;}):(this._cubeMap=this._cubeMap&&this._cubeMap.destroy(),this._cubeMap=new x({context:G,source:B}));}var L=this._command;if(L.modelMatrix=h.eastNorthUpToFixedFrame(T.camera._positionWC),!i(L.vertexArray)){L.uniformMap={u_cubeMap(){return F._cubeMap},u_rotateMatrix(){return D(L.modelMatrix,k)}};var U=t.createGeometry(t.fromDimensions({dimensions:new r(2,2,2),vertexFormat:y.POSITION_ONLY})),j=this._attributeLocations=s.createAttributeLocations(U);L.vertexArray=S.fromGeometry({context:G,geometry:U,attributeLocations:j,bufferUsage:d._DRAW}),L.renderState=E.fromCache({blending:_.ALPHA_BLEND});}if(!i(L.shaderProgram)||this._useHdr!==O){var v=new P({defines:[O?"HDR":""],sources:[A]});L.shaderProgram=C.fromCache({context:G,vertexShaderSource:b,fragmentShaderSource:v,attributeLocations:this._attributeLocations}),this._useHdr=O;}if(i(this._cubeMap))return L}},I.prototype.isDestroyed=function(){return false},I.prototype.destroy=function(){var T=this._command;return T.vertexArray=T.vertexArray&&T.vertexArray.destroy(),T.shaderProgram=T.shaderProgram&&T.shaderProgram.destroy(),this._cubeMap=this._cubeMap&&this._cubeMap.destroy(),o(this)},e.Scene.GroundSkyBox=I;}removeHandlerByName(t=[]){t.forEach(r=>{this._viewer.screenSpaceEventHandler.removeInputAction(e.ScreenSpaceEventType[r]);});}}return g}var ie=$(_e);function xe(e,u,g,m){function t(r,a){let i={},o=q(a),l=[];if(Array.isArray(r))r.forEach(c=>{let n=q(c),h=new n(e,u,g,m);s(n,o),l.push(h);}),i=new o(e,u,g,m),l.forEach(c=>Object.assign(i,c)),l.forEach(c=>Q(c,i));else {let c=q(r),n=new c(e,u,g,m);s(c,o),i=new o(e,u,g,m),Object.assign(i,n),Q(n,i);}function s(c,n){let h=Object.getOwnPropertyNames(c.prototype);for(let y=0,d=h.length;y<d;y++)h[y]!=="constructor"&&(n.prototype[h[y]]=c.prototype[h[y]]);}return i}return t}function we({cesiumGlobal:e,threeGlobal:u,containerId:g,threeContainerId:m,viewerConfig:t={},extraConfig:r={},MapImageryList:a=[],defaultStatic:i,baseExtendsCom:o=[],extendsCom:l,extendsComName:s,viewer:c}){if(!e)throw new H("MISSING_CESIUM","\u7F3A\u5C11 Cesium \u5168\u5C40\u5BF9\u8C61\uFF0C\u8BF7\u4F20\u5165 cesiumGlobal\uFF08\u6216\u522B\u540D Cesium\uFF09\u3002");if(!g&&!c)throw new H("MISSING_VIEWER","\u7F3A\u5C11 containerId \u6216 viewer\uFF1A\u8BF7\u4F20\u5165\u6302\u8F7D\u5BB9\u5668 id\uFF0C\u6216\u76F4\u63A5\u4F20\u5165\u5DF2\u521B\u5EFA\u7684 viewer\u3002");let h=new W(e).init({containerId:g,viewerConfig:t,extraConfig:r,MapImageryList:a,viewer:c}),y=!c,p=xe(h,e,i,u?{threeGlobal:u,containerId:g,threeContainerId:m}:"")(o,l),f=false;return {viewer:h,[s]:p,dispose:()=>{if(!f){f=true;try{typeof p.destroy=="function"?p.destroy():ee(p);}catch(E){X(E,{scope:"singleImport.dispose"});}y&&oe(h);}}}}function se(e,u,g){function m(t){return we({...t,baseExtendsCom:e,extendsCom:u,extendsComName:g})}return m}var Se=`in vec3 position3DHigh;
|
|
140
|
+
in vec3 position3DLow;
|
|
141
|
+
in float batchId;
|
|
142
|
+
in vec3 position;
|
|
143
|
+
in vec2 st;
|
|
144
|
+
out vec2 v_st;
|
|
145
|
+
uniform vec3 v1;
|
|
146
|
+
uniform vec3 v2;
|
|
147
|
+
|
|
148
|
+
// \u7F57\u5FB7\u91CC\u683C\u65CB\u8F6C\u516C\u5F0F
|
|
149
|
+
mat4 RodriguesRotation(vec3 v1, vec3 v2, float theta) {
|
|
150
|
+
|
|
151
|
+
vec3 _p = v2 - v1;
|
|
152
|
+
vec3 p = normalize(_p);
|
|
153
|
+
|
|
154
|
+
float x = p.x;
|
|
155
|
+
float y = p.y;
|
|
156
|
+
float z = p.z;
|
|
157
|
+
|
|
158
|
+
float xy = x * y;
|
|
159
|
+
float xx = x * x;
|
|
160
|
+
float xz = x * z;
|
|
161
|
+
float yy = y * y;
|
|
162
|
+
float yz = y * z;
|
|
163
|
+
float zz = z * z;
|
|
164
|
+
|
|
165
|
+
float sintheta = sin(radians(theta));
|
|
166
|
+
float costheta = cos(radians(theta));
|
|
167
|
+
|
|
168
|
+
float _m00 = costheta + xx * (1.0 - costheta);
|
|
169
|
+
float _m01 = z * sintheta + xy * (1.0 - costheta);
|
|
170
|
+
float _m02 = -y * sintheta + xz * (1.0 - costheta);
|
|
171
|
+
float _m03 = 0.0;
|
|
172
|
+
float _m10 = -z * sintheta + xy * (1.0 - costheta);
|
|
173
|
+
float _m11 = costheta + yy * (1.0 - costheta);
|
|
174
|
+
float _m12 = x * sintheta + yz * (1.0 - costheta);
|
|
175
|
+
float _m13 = 0.0;
|
|
176
|
+
float _m20 = y * sintheta + xz * (1.0 - costheta);
|
|
177
|
+
float _m21 = -x * sintheta + yz * (1.0 - costheta);
|
|
178
|
+
float _m22 = costheta + zz * (1.0 - costheta);
|
|
179
|
+
float _m23 = 0.0;
|
|
180
|
+
|
|
181
|
+
return mat4(_m00, _m01, _m02, _m03, _m10, _m11, _m12, _m13, _m20, _m21, _m22,
|
|
182
|
+
_m23, 0, 0, 0, 1.0);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
void main() {
|
|
186
|
+
float ty = abs(cos(czm_frameNumber / 60.0)) * 0.3;
|
|
187
|
+
mat4 translateY = mat4(1, 0, 0, 0, 0, 1, 0, ty, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
188
|
+
mat4 roatateAxis = RodriguesRotation(v1, v2, czm_frameNumber);
|
|
189
|
+
//vec4 roatePosition = roatateAxis * vec4(position, 1.0);
|
|
190
|
+
vec4 roatePosition = vec4(position, 1.0);
|
|
191
|
+
v_st = st;
|
|
192
|
+
gl_Position = czm_projection * czm_modelView * roatePosition * translateY;
|
|
193
|
+
}`,ce=Se;var Ce=`in vec2 v_st;
|
|
194
|
+
uniform sampler2D wenli;
|
|
195
|
+
uniform vec2 iResolution;
|
|
196
|
+
void main() {
|
|
197
|
+
vec2 uv = gl_FragCoord.xy / iResolution.xy;
|
|
198
|
+
float r = 0.01;
|
|
199
|
+
// \u4F7F\u7528length \u5B9E\u73B0\u5706\u5F27\u5149\u5E26
|
|
200
|
+
uv.x *= iResolution.x / iResolution.y;
|
|
201
|
+
float d = length(uv);
|
|
202
|
+
r = abs(sin(r * czm_frameNumber) * iResolution.x / iResolution.y);
|
|
203
|
+
vec4 wenli = texture(wenli, v_st);
|
|
204
|
+
vec4 centerColor = vec4(0.0, 255.0, 0.0, 1.0);
|
|
205
|
+
float ratio =
|
|
206
|
+
smoothstep(r, r + 0.02, d) - smoothstep(r + 0.0029, r + 0.06, d);
|
|
207
|
+
vec4 mixColor = vec4(mix(vec4(ratio), centerColor, ratio));
|
|
208
|
+
out_FragColor = vec4(mix(wenli, mixColor, ratio));
|
|
209
|
+
}
|
|
210
|
+
`,le=Ce;var be=function(){var e={defaultRadius:40,defaultRenderer:"canvas2d",defaultGradient:{.25:"rgb(0,0,255)",.55:"rgb(0,255,0)",.85:"yellow",1:"rgb(255,0,0)"},defaultMaxOpacity:1,defaultMinOpacity:0,defaultBlur:.85,defaultXField:"x",defaultYField:"y",defaultValueField:"value",plugins:{}},u=(function(){var o=function(c){this._coordinator={},this._data=[],this._radi=[],this._min=0,this._max=1,this._xField=c.xField||c.defaultXField,this._yField=c.yField||c.defaultYField,this._valueField=c.valueField||c.defaultValueField,c.radius&&(this._cfgRadius=c.radius);},l=e.defaultRadius;return o.prototype={_organiseData:function(s,c){var n=s[this._xField],h=s[this._yField],y=this._radi,d=this._data,x=this._max,p=this._min,f=s[this._valueField]||1,E=s.radius||this._cfgRadius||l;return d[n]||(d[n]=[],y[n]=[]),d[n][h]?d[n][h]+=f:(d[n][h]=f,y[n][h]=E),d[n][h]>x?(c?this.setDataMax(d[n][h]):this._max=d[n][h],false):{x:n,y:h,value:f,radius:E,min:p,max:x}},_unOrganizeData:function(){var s=[],c=this._data,n=this._radi;for(var h in c)for(var y in c[h])s.push({x:h,y,radius:n[h][y],value:c[h][y]});return {min:this._min,max:this._max,data:s}},_onExtremaChange:function(){this._coordinator.emit("extremachange",{min:this._min,max:this._max});},addData:function(){if(arguments[0].length>0)for(var s=arguments[0],c=s.length;c--;)this.addData.call(this,s[c]);else {var n=this._organiseData(arguments[0],true);n&&this._coordinator.emit("renderpartial",{min:this._min,max:this._max,data:[n]});}return this},setData:function(s){var c=s.data,n=c.length;this._data=[],this._radi=[];for(var h=0;h<n;h++)this._organiseData(c[h],false);return this._max=s.max,this._min=s.min||0,this._onExtremaChange(),this._coordinator.emit("renderall",this._getInternalData()),this},removeData:function(){},setDataMax:function(s){return this._max=s,this._onExtremaChange(),this._coordinator.emit("renderall",this._getInternalData()),this},setDataMin:function(s){return this._min=s,this._onExtremaChange(),this._coordinator.emit("renderall",this._getInternalData()),this},setCoordinator:function(s){this._coordinator=s;},_getInternalData:function(){return {max:this._max,min:this._min,data:this._data,radi:this._radi}},getData:function(){return this._unOrganizeData()}},o})(),g=(function(){var o=function(n){var h=n.gradient||n.defaultGradient,y=document.createElement("canvas"),d=y.getContext("2d");y.width=256,y.height=1;var x=d.createLinearGradient(0,0,256,1);for(var p in h)x.addColorStop(p,h[p]);return d.fillStyle=x,d.fillRect(0,0,256,1),d.getImageData(0,0,256,1).data},l=function(n,h){var y=document.createElement("canvas"),d=y.getContext("2d"),x=n,p=n;if(y.width=y.height=n*2,h==1)d.beginPath(),d.arc(x,p,n,0,2*Math.PI,false),d.fillStyle="rgba(0,0,0,1)",d.fill();else {var f=d.createRadialGradient(x,p,n*h,x,p,n);f.addColorStop(0,"rgba(0,0,0,1)"),f.addColorStop(1,"rgba(0,0,0,0)"),d.fillStyle=f,d.fillRect(0,0,2*n,2*n);}return y},s=function(p){for(var h=[],y=p.min,d=p.max,x=p.radi,p=p.data,f=Object.keys(p),E=f.length;E--;)for(var S=f[E],_=Object.keys(p[S]),M=_.length;M--;){var C=_[M],P=p[S][C],A=x[S][C];h.push({x:S,y:C,value:P,radius:A});}return {min:y,max:d,data:h}};function c(n){var h=n.container,y=this.shadowCanvas=document.createElement("canvas"),d=this.canvas=n.canvas||document.createElement("canvas");this._renderBoundaries=[1e4,1e4,0,0];var p=getComputedStyle(n.container)||{};d.className="heatmap-canvas",this._width=d.width=y.width=n.width||+p.width.replace(/px/,""),this._height=d.height=y.height=n.height||+p.height.replace(/px/,""),this.shadowCtx=y.getContext("2d"),this.ctx=d.getContext("2d"),d.style.cssText=y.style.cssText="position:absolute;left:0;top:0;",h.style.position="relative",h.appendChild(d),this._palette=o(n),this._templates={},this._setStyles(n);}return c.prototype={renderPartial:function(n){n.data.length>0&&(this._drawAlpha(n),this._colorize());},renderAll:function(n){this._clear(),n.data.length>0&&(this._drawAlpha(s(n)),this._colorize());},_updateGradient:function(n){this._palette=o(n);},updateConfig:function(n){n.gradient&&this._updateGradient(n),this._setStyles(n);},setDimensions:function(n,h){this._width=n,this._height=h,this.canvas.width=this.shadowCanvas.width=n,this.canvas.height=this.shadowCanvas.height=h;},_clear:function(){this.shadowCtx.clearRect(0,0,this._width,this._height),this.ctx.clearRect(0,0,this._width,this._height);},_setStyles:function(n){this._blur=n.blur==0?0:n.blur||n.defaultBlur,n.backgroundColor&&(this.canvas.style.backgroundColor=n.backgroundColor),this._width=this.canvas.width=this.shadowCanvas.width=n.width||this._width,this._height=this.canvas.height=this.shadowCanvas.height=n.height||this._height,this._opacity=(n.opacity||0)*255,this._maxOpacity=(n.maxOpacity||n.defaultMaxOpacity)*255,this._minOpacity=(n.minOpacity||n.defaultMinOpacity)*255,this._useGradientOpacity=!!n.useGradientOpacity;},_drawAlpha:function(d){for(var h=this._min=d.min,y=this._max=d.max,d=d.data||[],x=d.length,p=1-this._blur;x--;){var f=d[x],E=f.x,S=f.y,_=f.radius,M=Math.min(f.value,y),C=E-_,P=S-_,A=this.shadowCtx,b;this._templates[_]?b=this._templates[_]:this._templates[_]=b=l(_,p);var D=(M-h)/(y-h);A.globalAlpha=D<.01?.01:D,A.drawImage(b,C,P),C<this._renderBoundaries[0]&&(this._renderBoundaries[0]=C),P<this._renderBoundaries[1]&&(this._renderBoundaries[1]=P),C+2*_>this._renderBoundaries[2]&&(this._renderBoundaries[2]=C+2*_),P+2*_>this._renderBoundaries[3]&&(this._renderBoundaries[3]=P+2*_);}},_colorize:function(){var n=this._renderBoundaries[0],h=this._renderBoundaries[1],y=this._renderBoundaries[2]-n,d=this._renderBoundaries[3]-h,x=this._width,p=this._height,f=this._opacity,E=this._maxOpacity,S=this._minOpacity,_=this._useGradientOpacity;n<0&&(n=0),h<0&&(h=0),n+y>x&&(y=x-n),h+d>p&&(d=p-h);for(var M=this.shadowCtx.getImageData(n,h,y,d),C=M.data,P=C.length,A=this._palette,b=3;b<P;b+=4){var D=C[b],I=D*4;if(I){var k;f>0?k=f:D<E?D<S?k=S:k=D:k=E,C[b-3]=A[I],C[b-2]=A[I+1],C[b-1]=A[I+2],C[b]=_?A[I+3]:k;}}this.ctx.putImageData(M,n,h),this._renderBoundaries=[1e3,1e3,0,0];},getValueAt:function(n){var h,y=this.shadowCtx,d=y.getImageData(n.x,n.y,1,1),x=d.data[3],p=this._max,f=this._min;return h=Math.abs(p-f)*(x/255)>>0,h},getDataURL:function(){return this.canvas.toDataURL()}},c})(),m=(function(){var o=false;return e.defaultRenderer==="canvas2d"&&(o=g),o})(),t={merge:function(){for(var i={},o=arguments.length,l=0;l<o;l++){var s=arguments[l];for(var c in s)i[c]=s[c];}return i}},r=(function(){var o=(function(){function n(){this.cStore={};}return n.prototype={on:function(h,y,d){var x=this.cStore;x[h]||(x[h]=[]),x[h].push(function(p){return y.call(d,p)});},emit:function(h,y){var d=this.cStore;if(d[h])for(var x=d[h].length,p=0;p<x;p++){var f=d[h][p];f(y);}}},n})(),l=function(c){var n=c._renderer,h=c._coordinator,y=c._store;h.on("renderpartial",n.renderPartial,n),h.on("renderall",n.renderAll,n),h.on("extremachange",function(d){c._config.onExtremaChange&&c._config.onExtremaChange({min:d.min,max:d.max,gradient:c._config.gradient||c._config.defaultGradient});}),y.setCoordinator(h);};function s(){var c=this._config=t.merge(e,arguments[0]||{});if(this._coordinator=new o,c.plugin){var n=c.plugin;if(e.plugins[n]){var h=e.plugins[n];this._renderer=new h.renderer(c),this._store=new h.store(c);}else throw new Error("Plugin '"+n+"' not found. Maybe it was not registered.")}else this._renderer=new m(c),this._store=new u(c);l(this);}return s.prototype={addData:function(){return this._store.addData.apply(this._store,arguments),this},removeData:function(){return this._store.removeData&&this._store.removeData.apply(this._store,arguments),this},setData:function(){return this._store.setData.apply(this._store,arguments),this},setDataMax:function(){return this._store.setDataMax.apply(this._store,arguments),this},setDataMin:function(){return this._store.setDataMin.apply(this._store,arguments),this},configure:function(c){return this._config=t.merge(this._config,c),this._renderer.updateConfig(this._config),this._coordinator.emit("renderall",this._store._getInternalData()),this},repaint:function(){return this._coordinator.emit("renderall",this._store._getInternalData()),this},getData:function(){return this._store.getData()},getDataURL:function(){return this._renderer.getDataURL()},getValueAt:function(c){return this._store.getValueAt?this._store.getValueAt(c):this._renderer.getValueAt?this._renderer.getValueAt(c):null}},s})(),a={create:function(i){return new r(i)},register:function(i,o){e.plugins[i]=o;}};return a},he=be();function Pe(){let e=null,g=function(m,t,r){m&&(this._viewer=m,e=t,te(this),this._installPrimitives());};return g.prototype={_installPrimitives:function(){this._installProbingPrimitive(),this._installTexturePrimitive(),this._installWaterPrimitive(),this._installPointsPrimitive(),this._installShadowPrimitive(),this._installArrowPolylinePrimitive(),this._installXyzAxisPrimitive(),this._installTetrahedronPrimitive();},_installTetrahedronPrimitive:function(){try{var m=e.Cartesian3,t=e.ComponentDatatype,r=e.PrimitiveType,a=e.BoundingSphere,i=e.GeometryAttribute,o=e.GeometryPipeline,l=e.Geometry,s=e.defined,c=e.RenderState,n=e.ShaderSource,h=e.ShaderProgram,y=e.DrawCommand,d=e.Pass,x=e.Appearance,p=e.BufferUsage,f=e.Color,E=e.VertexArray,S=e.buildModuleUrl,_=e.Matrix4,M=e.Matrix3,C=e.Texture,P=e.Resource,A=e.Transforms,b=e.defaultValue||Z,D=this._viewer,I=this.getDfSt(["primitive","TetrahedronPrimitive"])||"static/data/images/Textures/fence.png";let k=function(v){this.show=!0,this._command=void 0,this._enuMatrix=void 0,this._scaleMatrix=void 0,this._localPosition=v.position,this._createCommand=T,this._angle=0,this._distance=b(v.distance,1),this._setInterval=void 0,this._viewer=D,this._speed=b(v.speed,1),this._color=b(v.color,new f(1,1,0,.8)),this._scale=b(v.scale,new m(10,10,15)),this._texture=void 0,this._imageUrl=I,this._modelMatrix=U(this),this._height=j(this),L(this);};k.prototype.update=function(v){this.show&&(s(this._command)||(this._command=this._createCommand(v.context,this)),s(this._command)&&v.commandList.push(this._command));},k.prototype.isDestroyed=function(){return !1},k.prototype.destroy=function(){return s(this._command)&&(this._command.shaderProgram=this._command.shaderProgram&&this._command.shaderProgram.destroy()),destroyObject(this)},k.prototype.startAnimate=function(){let v=this;this._setInterval=setInterval(w,5);function w(){v._angle=v._angle+.01,Math.sin(v._angle)>0?v._height=.01:v._height=-.01;let R=new e.Cartesian3(0,0,v._height);_.multiplyByTranslation(v._modelMatrix,R,v._modelMatrix);let z=_.fromRotationTranslation(M.fromRotationZ(e.Math.toRadians(v._speed)));_.multiply(v._modelMatrix,z,v._modelMatrix);}},k.prototype.closeAnimate=function(){clearInterval(this._setInterval);};let T=function(v,w){var R=!1,z=!0,N=G(),J=B(),me=x.getDefaultRenderState(R,z,void 0),ue=c.fromCache(me),de=new n({sources:[N]}),ye=new n({sources:[J]}),pe={color:function(){return w._color},myImage:function(){return s(w._texture)?w._texture:w._viewer.scene.context.defaultTexture}};let ve={position:0,textureCoordinates:1};var ge=h.fromCache({context:v,vertexShaderSource:de,fragmentShaderSource:ye,attributeLocations:ve});return new y({vertexArray:O(v),primitiveType:r.TRIANGLES,renderState:ue,shaderProgram:ge,uniformMap:pe,owner:this,pass:d.TRANSLUCENT,modelMatrix:w._modelMatrix})},O=function(v){let w={position:0,textureCoordinates:1};var R=F(),z=new l({attributes:{position:new i({componentDatatype:t.FLOAT,componentsPerAttribute:3,values:R.positions}),textureCoordinates:new i({componentDatatype:t.FLOAT,componentsPerAttribute:2,values:R.sts})},indices:R.indices,primitiveType:r.TRIANGLES,boundingSphere:a.fromVertices(R.positions)}),N=o.computeNormal(z),J=E.fromGeometry({context:v,geometry:N,attributeLocations:w,bufferUsage:p.STATIC_DRAW});return J},F=function(){var v=new Float64Array(15);v[0]=0,v[1]=1,v[2]=0,v[3]=-1,v[4]=0,v[5]=0,v[6]=0,v[7]=-1,v[8]=0,v[9]=1,v[10]=0,v[11]=0,v[12]=0,v[13]=0,v[14]=-1;var w=new Uint16Array(18);w[0]=4,w[1]=2,w[2]=3,w[3]=4,w[4]=3,w[5]=0,w[6]=4,w[7]=0,w[8]=1,w[9]=4,w[10]=1,w[11]=2,w[12]=1,w[13]=2,w[14]=3,w[15]=1,w[16]=3,w[17]=0;var R=new Float32Array([0,0,1,0,1,1,0,1,.5,.5]);return {indices:w,positions:v,sts:R}},G=function(){var v=`#version 300 es
|
|
211
|
+
in vec3 position;
|
|
212
|
+
in vec3 normal;
|
|
213
|
+
in vec2 st;
|
|
214
|
+
in float batchId;
|
|
215
|
+
out vec3 v_positionEC;
|
|
216
|
+
out vec3 v_normalEC;
|
|
217
|
+
out vec2 v_st;
|
|
218
|
+
out vec4 v_pickColor;
|
|
219
|
+
void main()
|
|
220
|
+
{
|
|
221
|
+
v_positionEC = (czm_modelView * vec4(position, 1.0)).xyz;
|
|
222
|
+
v_normalEC = czm_normal * normal;
|
|
223
|
+
v_st = st;
|
|
224
|
+
// v_pickColor = czm_batchTable_pickColor(batchId);
|
|
225
|
+
gl_Position = czm_modelViewProjection * vec4(position, 1.0);
|
|
226
|
+
}
|
|
227
|
+
`;return v},B=function(){var v=`#version 300 es
|
|
228
|
+
precision mediump float;
|
|
229
|
+
in vec3 v_positionEC;
|
|
230
|
+
in vec3 v_normalEC;
|
|
231
|
+
in vec2 v_st;
|
|
232
|
+
uniform vec4 color;
|
|
233
|
+
in vec4 v_pickColor;
|
|
234
|
+
uniform sampler2D myImage;
|
|
235
|
+
void main()
|
|
236
|
+
{
|
|
237
|
+
vec3 positionToEyeEC = -v_positionEC;
|
|
238
|
+
vec3 normalEC = normalize(v_normalEC);
|
|
239
|
+
#ifdef FACE_FORWARD
|
|
240
|
+
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
|
|
241
|
+
#endif
|
|
242
|
+
czm_materialInput materialInput;
|
|
243
|
+
materialInput.normalEC = normalEC;
|
|
244
|
+
materialInput.positionToEyeEC = positionToEyeEC;
|
|
245
|
+
materialInput.st = v_st;
|
|
246
|
+
vec2 st = materialInput.st;
|
|
247
|
+
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
248
|
+
float dt_a11 = fract(czm_frameNumber / 100.0) * 3.14159265 * 2.0;
|
|
249
|
+
float dt_a12 = sin(dt_a11);
|
|
250
|
+
float vst=smoothstep(0.7, 1.0, dt_a12)+0.4;
|
|
251
|
+
vec4 colorImage = texture(myImage, vec2(fract(st.s- czm_frameNumber*0.003), st.t));
|
|
252
|
+
material.alpha =mix(0.1,1.0,clamp((1.0-st.t) * color.a,0.0,1.0)) +(1.0-sign(st.t-czm_frameNumber*0.001))*0.2*(1.0-colorImage.r)+0.4;
|
|
253
|
+
material.diffuse =(1.0-colorImage.a)*vec3(1.0,2.0,1.0)+colorImage.rgb*vec3(1.0,2.0,1.0);
|
|
254
|
+
#ifdef FLAT
|
|
255
|
+
out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
|
|
256
|
+
#else
|
|
257
|
+
out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
|
|
258
|
+
#endif
|
|
259
|
+
}
|
|
260
|
+
`;return v},L=function(v){P.createIfNeeded(v._imageUrl).fetchImage().then(function(w){var R,z=v._viewer.scene.context;s(w.internalFormat)?R=new C({context:z,pixelFormat:w.internalFormat,width:w.naturalWidth,height:w.naturalHeight,source:{arrayBufferView:w.bufferView}}):R=new C({context:z,source:w}),v._texture=R;});},U=function(v){let w=A.eastNorthUpToFixedFrame(v._localPosition),R=_.fromScale(v._scale),z=_.multiply(w,R,new _);return v._scaleMatrix=R,v._enuMatrix=w,z},j=function(v){let w=m.fromElements(0,0,v._distance,new e.Cartesian3),R=e.Matrix4.multiplyByPoint(v._enuMatrix,w,new m),z=_.multiplyByPoint(v._viewer.scene.camera._viewMatrix,R,new m),N=_.multiplyByPoint(v._viewer.scene.camera.frustum.projectionMatrix,z,new m);return m.normalize(N,new m).z};e.Scene.TetrahedronPrimitive=k;}catch(k){console.log(k);}},_installXyzAxisPrimitive:function(){function m(t){this._viewer=t.viewer,this._model=t.model,this._matrix=t.matrix,this._radius=void 0,this._layer=new e.CustomDataSource("xyz-axis"),this._viewer.dataSources.add(this._layer),this._handler=new e.ScreenSpaceEventHandler(this._viewer.scene.canvas),this._xyzState=false,this._xyzPid=void 0,this._builds();}m.prototype={_builds(){this._createAxisXYZ(),this._bindHandler();},remove(){this._layer._primitives.removeAll(),this._handler.destroy();},_createAxisXYZ:function(){this._model.readyPromise.then(t=>{let r=e.Matrix4.getTranslation(t.modelMatrix,new e.Cartesian3),a=t.boundingSphere,i=a.radius,o=new e.ArrowPolylinePrimitive({id:"axisZ",color:e.Color.RED,position:r,width:3,headWidth:5,length:i*2+50,headLength:10}),l=new e.ArrowPolylinePrimitive({id:"axisX",color:e.Color.GREEN,position:r,width:3,headWidth:5,length:i*2+50,headLength:10}),s=new e.ArrowPolylinePrimitive({id:"axisY",color:e.Color.BLUE,position:r,width:3,headWidth:5,length:i*2+50,headLength:10}),c=e.Matrix3.fromRotationY(e.Math.toRadians(90));this._rotationX=e.Matrix4.fromRotationTranslation(c),e.Matrix4.multiply(l.geometryInstances[0].modelMatrix,this._rotationX,l.geometryInstances[0].modelMatrix),e.Matrix4.multiply(l.geometryInstances[1].modelMatrix,this._rotationX,l.geometryInstances[1].modelMatrix);let n=e.Matrix3.fromRotationX(e.Math.toRadians(90));this._rotationY=e.Matrix4.fromRotationTranslation(n),e.Matrix4.multiply(s.geometryInstances[0].modelMatrix,this._rotationY,s.geometryInstances[0].modelMatrix),e.Matrix4.multiply(s.geometryInstances[1].modelMatrix,this._rotationY,s.geometryInstances[1].modelMatrix),this._layer._primitives.add(o),this._layer._primitives.add(l),this._layer._primitives.add(s),this._radius=a.radius,this._createAxisSphere();});},_createAxisSphere:function(){let t=[];for(let o=0;o<=360;o+=3){let l=Math.sin(e.Math.toRadians(o)),s=Math.cos(e.Math.toRadians(o)),c=this._radius*s,n=this._radius*l;t.push(new e.Cartesian3(c,n,0));}let r=this._createAxisSpheres("axisSphereZ",t,this._matrix,e.Color.RED);this._layer._primitives.add(r);let a=this._createAxisSpheres("axisSphereY",t,this._matrix,e.Color.GREEN);this._layer._primitives.add(a),e.Matrix4.multiply(a.geometryInstances.modelMatrix,this._rotationY,a.geometryInstances.modelMatrix);let i=this._createAxisSpheres("axisSphereX",t,this._matrix,e.Color.BLUE);this._layer._primitives.add(i),e.Matrix4.multiply(i.geometryInstances.modelMatrix,this._rotationX,i.geometryInstances.modelMatrix);},_createAxisSpheres:function(t,r,a,i){let o=new e.PolylineGeometry({positions:r,width:10}),l=new e.GeometryInstance({geometry:o,id:t,attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(i)}});return new e.Primitive({geometryInstances:l,appearance:new e.PolylineColorAppearance({translucent:false}),modelMatrix:a})},_updateAxis(t){if(this._layer){let a=this._layer._primitives._primitives;for(let i=1,o=a.length;i<o;i++){let l=a[i],s=e.Matrix4.fromTranslation(new e.Cartesian3(t.x,t.y,t.z));e.Matrix4.multiply(l.modelMatrix,s,l.modelMatrix);}}let r=e.Matrix4.fromTranslation(new e.Cartesian3(t.x,t.y,t.z));e.Matrix4.multiply(this._model.modelMatrix,r,this._model.modelMatrix);},_updateAxisSphere(t){if(this._layer){let a=this._layer._primitives._primitives;for(let i=1,o=a.length;i<o;i++){let l=a[i],s=e.Matrix4.fromRotationTranslation(t);e.Matrix4.multiply(l.modelMatrix,s,l.modelMatrix);}}let r=e.Matrix4.fromRotationTranslation(t);e.Matrix4.multiply(this._model.modelMatrix,r,this._model.modelMatrix);},_bindHandler(){this._handler.setInputAction(t=>{if(this._xyzState&&this._xyzPid)switch(this._xyzPid){case "axisX-line":this._updateAxis({x:-1,y:0,z:0});break;case "axisY-line":this._updateAxis({x:0,y:-1,z:0});break;case "axisZ-line":this._updateAxis({x:0,y:0,z:-1});break;case "axisX-arrow":this._updateAxis({x:1,y:0,z:0});break;case "axisY-arrow":this._updateAxis({x:0,y:1,z:0});break;case "axisZ-arrow":this._updateAxis({x:0,y:0,z:1});break;case "axisSphereX":this._updateAxisSphere(e.Matrix3.fromRotationX(e.Math.toRadians(1)));break;case "axisSphereY":this._updateAxisSphere(e.Matrix3.fromRotationY(e.Math.toRadians(1)));break;case "axisSphereZ":this._updateAxisSphere(e.Matrix3.fromRotationZ(e.Math.toRadians(1)));break}},e.ScreenSpaceEventType.MOUSE_MOVE),this._handler.setInputAction(t=>{let r=viewer.scene.pick(t.position);r&&r.id&&(this._xyzPid=r.id,this._xyzState=true);},e.ScreenSpaceEventType.LEFT_DOWN),this._handler.setInputAction(()=>{this._xyzState=false,this._xyzPid=void 0;},e.ScreenSpaceEventType.LEFT_UP);}},e.Scene.XyzAxisPrimitive=m;},_installArrowPolylinePrimitive:function(){function m(r={}){this._color=r.color||e.Color.RED,this._width=r.width||3,this._headWidth=r.headWidth||2*this._width,this._length=r.length||300,this._headLength=r.headLength||10,this._inverse=r.inverse||false,this.position=r.position;let a=r.id,i=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:this._length,topRadius:this._width,bottomRadius:this._width})),o=e.CylinderGeometry.createGeometry(new e.CylinderGeometry({length:this._headLength,topRadius:0,bottomRadius:this._headWidth})),l=(this._length+this._headLength)/2;return this._inverse&&(l=-l),t(o,[0,0,l]),new e.Primitive({modelMatrix:e.Transforms.eastNorthUpToFixedFrame(this.position),geometryInstances:[new e.GeometryInstance({id:a+"-line",geometry:i}),new e.GeometryInstance({id:a+"-arrow",geometry:o})],appearance:new e.MaterialAppearance({material:e.Material.fromType("Color",{color:this._color})})})}let t=function(r,a){let i=new e.Cartesian3;a.length?(i.x=a[0],i.y=a[1],i.z=a[2]):e.Cartesian3.clone(a,i);for(let o=0;o<r.attributes.position.values.length;o+=3)r.attributes.position.values[o]+=i.x,r.attributes.position.values[o+1]+=i.y,r.attributes.position.values[o+2]+=i.z;};e.Scene.ArrowPolylinePrimitive=m;},_installShadowPrimitive:function(){let m=e.defaultValue||Z,t=`in vec3 position;
|
|
261
|
+
uniform mat4 u_modelViewMatrix;
|
|
262
|
+
void main()
|
|
263
|
+
{
|
|
264
|
+
gl_Position = czm_projection* u_modelViewMatrix* vec4(position.xyz,1.0);
|
|
265
|
+
}
|
|
266
|
+
`,r=`uniform vec4 u_bgColor;
|
|
267
|
+
void main()
|
|
268
|
+
{
|
|
269
|
+
out_FragColor = u_bgColor;
|
|
270
|
+
}
|
|
271
|
+
`;function a(i){i=m(i,m.EMPTY_OBJECT);var o=i.scene;if(!e.defined(o))throw new e.DeveloperError("scene is required.");this._scene=o;var l=o._context;if(!e.defined(l))throw new e.DeveloperError("context is required.");if(!e.defined(i.viewerPosition))throw new e.DeveloperError("this view position is required.");this._viewerPosition=i.viewerPosition,this._positions=void 0,this._indices=void 0,this._drawLineCommand=void 0,this._depthCamera=new e.Camera(o),this._depthCamera.position=this._viewerPosition,this._direction=0,this._pitch=0,this._horizontalFov=m(i.horizontalFov,60),this._verticalFov=m(i.verticalFov,45),this._cameraUpdated=false,this._targetPoint=this._viewerPosition.clone();var s=new e.Cartesian3(0,0,100),c=e.Transforms.eastNorthUpToFixedFrame(this._viewerPosition);e.Matrix4.multiplyByPoint(c,s,this._targetPoint),this._distance=100,this._cameraUpdated=false,this._modelMatrix=new e.Matrix4,this._shadowMap=new e.ShadowMap({context:l,enabled:true,lightCamera:this._depthCamera,cascadesEnabled:false}),this.show=true,this._invisiblyColor=e.Color.RED,this._visiblyColor=e.Color.GREEN,this._shadowMap.useCustomColor=true,this.shadowMap._customColor={invisibly:e.Color.RED,visibly:e.Color.GREEN},this._initialize=function(){this._positions=new Float32Array(633),this._indices=new Uint16Array(408);var n=this._indices,h=0;n[h++]=0,n[h++]=1,n[h++]=0,n[h++]=21,n[h++]=0,n[h++]=85,n[h++]=0,n[h++]=105;for(var y=0,d=0;d<5;++d){y++;for(var x=0;x<20;++x)n[h++]=y++,n[h++]=y;}y++;for(var p=0;p<20;++p)for(var f=0;f<5;++f)n[h++]=y,n[h++]=5+y++;this._initialized=true;},this._debugLightFrustum=void 0,this._debugShow=true;}Object.defineProperties(a.prototype,{shadowMap:{get:function(){return this._shadowMap}},debugLightFrustum:{get:function(){return this._debugLightFrustum}},debugShow:{get:function(){return this._debugShow},set:function(i){this.shadowMap.debugShow=i,this._debugShow=i;}},invisiblyColor:{get:function(){return this._invisiblyColor},set:function(i){this._invisiblyColor=i;var o=this.shadowMap;o._customColor.invisibly=i;}},visiblyColor:{get:function(){return this._visiblyColor},set:function(i){this._visiblyColor=i;var o=this.shadowMap;o._customColor.visibly=i;}},viewerPosition:{get:function(){return this._viewerPosition},set:function(i){this._viewerPosition=i,this._cameraUpdated=false;}},direction:{get:function(){return this._direction},set:function(i){this._direction=i,this._cameraUpdated=false;}},pitch:{get:function(){return this._pitch},set:function(i){this._pitch=i,this._cameraUpdated=false;}},horizontalFov:{get:function(){return this._horizontalFov},set:function(i){this._horizontalFov=i,this._cameraUpdated=false,this._hintLineUpdated=false;}},verticalFov:{get:function(){return this._verticalFov},set:function(i){this._verticalFov=i,this._cameraUpdated=false,this._hintLineUpdated=false;}},distance:{get:function(){return this._distance},set:function(i){this._distance=i,this._cameraUpdated=false;}}}),a.prototype.setDebugFrustumEffect=function(i,o){if(this.debugShow){var l=this.debugLightFrustum._planesPrimitives,s=this.debugLightFrustum._outlinePrimitives;l.forEach(function(c){c.show=i;}),s.forEach(function(c){c.show=o;});}},a.prototype.update=function(i){if(this.show){this._cameraUpdated||(this._updateCamera(),this.debugShow&&(e.defined(this.debugLightFrustum)||(this._debugLightFrustum=new e.DebugCameraPrimitive({camera:this._depthCamera,color:e.Color.YELLOW,updateOnChange:true}),this.setDebugFrustumEffect(false,true))));var o=i.frustumSplits[1];i.frustumSplits[1]=this._distance,this._debugLightFrustum.update(i),i.frustumSplits[1]=o,i.shadowMaps.push(this.shadowMap);}},a.prototype._updateCamera=function(){this._depthCamera.frustum.near=.001*this._distance,this._depthCamera.frustum.far=this._distance,this._depthCamera.frustum.fov=e.Math.toRadians(Math.max(this._horizontalFov,this._verticalFov)),this._depthCamera.frustum.aspectRatio=this._horizontalFov/this._verticalFov,this._depthCamera.setView({destination:this._viewerPosition,orientation:{heading:e.Math.toRadians(this._direction),pitch:e.Math.toRadians(this._pitch)}}),this._modelMatrix=this._depthCamera.inverseViewMatrix,this._cameraUpdated=true;},a.prototype.setPoseByTargetPoint=function(i){this.distance=e.Cartesian3.distance(this._viewerPosition,i);var o=new e.Cartesian3,l=e.Transforms.eastNorthUpToFixedFrame(this._viewerPosition);e.Matrix4.inverse(l,l),e.Matrix4.multiplyByPoint(l,i,o),e.Cartesian3.normalize(o,o),this.direction=e.Math.toDegrees(Math.atan2(o.x,o.y)),this.pitch=e.Math.toDegrees(Math.asin(o.z));},a.prototype._updateHintLine=function(i){var o,l,s,c,n=this._positions,h=e.Math.toRadians(this._horizontalFov),y=e.Math.toRadians(this._verticalFov),d=Math.tan(.5*h),x=Math.tan(.5*y);l=this._distance*d,c=this._distance*x,o=-l,s=-c;var p=new e.Cartesian3(o,s,-this._distance),f=new e.Cartesian3(l,c,0);e.Matrix4.multiplyByPoint(this._modelMatrix,p,p),e.Matrix4.multiplyByPoint(this._modelMatrix,f,f);var E=e.BoundingSphere.fromCornerPoints(p,f);if(i.cullingVolume.computeVisibility(E)===Intersect.OUTSIDE)return void(this._valid=false);this._valid=true;var S=0;n[S++]=0,n[S++]=0,n[S++]=0;for(var _,M,C=Math.PI-.5*h,P=h/4,A=0;A<5;++A){_=C+A*P;for(var b=c/(this._distance/Math.cos(_)),D=Math.atan(b),I=-D,k=D/10,T=0;T<21;++T)M=I+T*k,n[S++]=this._distance*Math.cos(M)*Math.sin(_),n[S++]=this._distance*Math.sin(M),n[S++]=this._distance*Math.cos(M)*Math.cos(_);}P=h/20;for(var O=0;O<21;++O){_=C+O*P;for(var b=c/(this._distance/Math.cos(_)),D=Math.atan(b),I=-D,k=D/2,F=0;F<5;++F)M=I+F*k,n[S++]=this._distance*Math.cos(M)*Math.sin(_),n[S++]=this._distance*Math.sin(M),n[S++]=this._distance*Math.cos(M)*Math.cos(_);}var G=i.context,B=e.Buffer.createIndexBuffer({context:G,typedArray:new Uint32Array(this._indices),usage:e.BufferUsage.STATIC_DRAW,indexDatatype:IndexDatatype.UNSIGNED_INT}),L=e.Buffer.createVertexBuffer({context:G,typedArray:e.ComponentDatatype.createTypedArray(e.ComponentDatatype.FLOAT,this._positions),usage:e.BufferUsage.STATIC_DRAW}),U=[];U.push({index:0,vertexBuffer:L,componentDatatype:e.ComponentDatatype.FLOAT,componentsPerAttribute:3,normalize:false});var j=new e.VertexArray({context:G,attributes:U,indexBuffer:B});if(e.defined(this._drawLineCommand))this._drawLineCommand.vertexArray.destroy(),this._drawLineCommand.vertexArray=j,this._drawLineCommand.modelMatrix=this._modelMatrix,this._drawLineCommand.boundingVolume=E;else {var v=e.ShaderProgram.fromCache({context:G,vertexShaderSource:t,fragmentShaderSource:r}),w=e.RenderState.fromCache({depthTest:{enabled:true}}),R=this,z={u_bgColor:function(){return R._lineColor},u_modelViewMatrix:function(){return G.uniformState.modelView}};this._drawLineCommand=new e.DrawCommand({boundingVolume:E,modelMatrix:R._modelMatrix,primitiveType:e.PrimitiveType.LINES,vertexArray:j,shaderProgram:v,castShadows:false,receiveShadows:false,uniformMap:z,renderState:w,pass:e.Pass.OPAQUE});}this._hintLineUpdated=true;},e.Scene.ShadowPrimitive=a;},_installPointsPrimitive:function(){function m(t){t&&t.viewer&&t.Cartesians&&(this._vertexShader=this.getVSPolylie(),this._fragmentShader=this.getFSPolyline(),this._geometry=null,this._appearance=null,this._viewer=t.viewer,this.build(t));}m.prototype={build:function(t){if(t.Cartesians&&t.Cartesians.length>=2){var r=[],a=[],i=[];if(t.Colors&&t.Colors.length===t.Cartesians.length*4){for(var o=0;o<t.Cartesians.length;o++)r.push(t.Cartesians[o].x),r.push(t.Cartesians[o].y),r.push(t.Cartesians[o].z);a=t.Colors;}else for(var l=0;l<t.Cartesians.length;l++)r.push(t.Cartesians[l].x),r.push(t.Cartesians[l].y),r.push(t.Cartesians[l].z),a.push(0),a.push(0),a.push(1),a.push(1);for(var s=0;s<t.Cartesians.length;s++)i.push(s);this.positionArr=new Float64Array(r),this.colorArr=new Float32Array(a),this.indiceArr=new Uint16Array(i);}else {var c=e.Cartesian3.fromDegrees(0,0,-10),n=e.Cartesian3.fromDegrees(0,.001,-10);this.positionArr=new Float64Array([c.x,c.y,c.z,n.x,n.y,n.z]),this.colorArr=new Float32Array([0,0,1,1,0,0,1,1]),this.indiceArr=new Uint16Array([0,1]);}this._geometry=this.createGeometry(this.positionArr,this.colorArr,this.indiceArr),this._appearance=this.createAppearence(this._fragmentShader,this._vertexShader),this.primitive=this._viewer.scene.primitives.add(new e.Primitive({geometryInstances:new e.GeometryInstance({geometry:this._geometry}),appearance:this._appearance,asynchronous:false}));},getVSPolylie:function(){return "in vec3 position3DHigh; in vec3 position3DLow; in vec4 color; out vec4 v_color; in float batchId; void main() { vec4 p = czm_computePosition(); v_color =color; p = czm_modelViewProjectionRelativeToEye * p; gl_Position = p; gl_PointSize=4.0; } "},getFSPolyline:function(){return "in vec4 v_color; void main() { float d = distance(gl_PointCoord, vec2(0.5,0.5)); if(d < 0.5){ out_FragColor = v_color; }else{ discard; } } "},createAppearence:function(t,r){return new e.Appearance({renderState:{blending:e.BlendingState.PRE_MULTIPLIED_ALPHA_BLEND,depthTest:{enabled:true},depthMask:true},fragmentShaderSource:t,vertexShaderSource:r})},createGeometry:function(t,r,a){return new e.Geometry({attributes:{position:new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:t}),color:new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.FLOAT,componentsPerAttribute:4,values:r})},indices:a,primitiveType:e.PrimitiveType.POINTS,boundingSphere:e.BoundingSphere.fromVertices(t)})},remove:function(){this.primitive!=null&&(this._viewer.scene.primitives.remove(this.primitive),this.primitive=null);},updateCartesianPosition:function(t){if(this.primitive!=null){if(this._viewer.scene.primitives.remove(this.primitive),t&&t.length<2)return;if(t.length===this.positionArr.length/3){var r=t[0],a=t[1];this.positionArr=new Float64Array([r.x,r.y,r.z,a.x,a.y,a.z]),this._geometry=this.createGeometry(this.positionArr,this.colorArr,this.indiceArr);}else {for(var i=[],o=[],l=[],s=0;s<t.length;s++)i.push(t[s].x),i.push(t[s].y),i.push(t[s].z),o.push(0),o.push(0),o.push(1),o.push(1);for(var c=0;c<t.length;c++)l.push(c);this.positionArr=new Float64Array(i),this.colorArr=new Float32Array(o),this.indiceArr=new Uint16Array(l),geometry=this.createGeometry(this.positionArr,this.colorArr,this.indiceArr),appearance=this.createAppearence(this._fragmentShader,this._vertexShader);}this.primitive=this._viewer.scene.primitives.add(new e.Primitive({geometryInstances:new e.GeometryInstance({geometry:this._geometry}),appearance:this._appearance,asynchronous:false}));}else return},updateCartesianPositionColor:function(t,r){if(r.length===t.length*4)if(this.primitive!=null){if(viewer.scene.primitives.remove(this.primitive),t&&t.length<2)return;if(t.length===this.positionArr.length/3){var a=t[0],i=t[1];this.positionArr=new Float64Array([a.x,a.y,a.z,i.x,i.y,i.z]),this.colorArr=new Float32Array(r),geometry=CreateGeometry(this.positionArr,this.colorArr,this.indiceArr);}else {for(var o=[],l=[],s=0;s<t.length;s++)o.push(t[s].x),o.push(t[s].y),o.push(t[s].z);for(var s=0;s<t.length;s++)l.push(s);this.positionArr=new Float64Array(o),this.colorArr=new Float32Array(r),this.indiceArr=new Uint16Array(l),this._geometry=this.createGeometry(this.positionArr,this.colorArr,this.indiceArr),this._appearance=this.createAppearence(this._fragmentShader,this._vertexShader);}this.primitive=viewer.scene.primitives.add(new e.Primitive({geometryInstances:new e.GeometryInstance({geometry:this._geometry}),appearance:this._appearance,asynchronous:false}));}else return}},e.Scene.PointsPrimitive=m;},_installWaterPrimitive:function(){let m=this,t=function(r){this._positions=r.positions,this._url=r.img||this.getDfSt(["primitive","WaterPrimitive"])||"static/data/images/Textures/waterNormals.jpg",this._frequency=r.frequency||1e3,this._animationSpeed=r.animationSpeed||.01,this._amplitude=r.amplitude||10,this._extrudedHeight=r.extrudedHeight||0,this._viewer=m._viewer,this._fs=this.getFS();};t.prototype.build=function(){this._geometry=this._createGeometry(),this._appearance=this._createAppearence(),this.primitive=this._viewer.scene.primitives.add(new e.Primitive({allowPicking:false,geometryInstances:new e.GeometryInstance({geometry:this._geometry}),appearance:this._appearance,asynchronous:false}));},t.prototype._createAppearence=function(){return new e.EllipsoidSurfaceAppearance({material:new e.Material({fabric:{type:"Water",uniforms:{normalMap:this._url,frequency:this._frequency,animationSpeed:this._animationSpeed,amplitude:this._amplitude}}}),fragmentShaderSource:this._fs})},t.prototype._createGeometry=function(){return new e.PolygonGeometry({polygonHierarchy:new e.PolygonHierarchy(e.Cartesian3.fromDegreesArray(this._positions)),extrudedHeight:this._extrudedHeight,perPositionHeight:true})},t.prototype.getFS=function(){var r=`
|
|
272
|
+
precision highp float;
|
|
273
|
+
struct Light {
|
|
274
|
+
vec3 position;
|
|
275
|
+
vec3 ambient;
|
|
276
|
+
vec3 diffuse;
|
|
277
|
+
vec3 specular;
|
|
278
|
+
};
|
|
279
|
+
in vec3 position;
|
|
280
|
+
in vec2 textureCoord;
|
|
281
|
+
|
|
282
|
+
uniform vec3 viewPos;
|
|
283
|
+
uniform Light light;
|
|
284
|
+
|
|
285
|
+
uniform sampler2D normalSampler;
|
|
286
|
+
uniform samplerCube skybox;
|
|
287
|
+
uniform float detalX;
|
|
288
|
+
|
|
289
|
+
void main() {
|
|
290
|
+
|
|
291
|
+
float z = gl_FragCoord.z / gl_FragCoord.w;
|
|
292
|
+
const float LOG2 = 1.442695;
|
|
293
|
+
float density = 0.005;
|
|
294
|
+
float normalFactor = exp( -density * density * z * z * LOG2 );
|
|
295
|
+
normalFactor = clamp(normalFactor, 0.0, 1.0);
|
|
296
|
+
|
|
297
|
+
vec4 normalTex1 = texture(normalSampler, vec2(textureCoord.s + detalX/1024.0, textureCoord.t - detalX/1024.0));
|
|
298
|
+
vec3 normalTex2 = texture(normalSampler, vec2(textureCoord.t, textureCoord.s)).rgb;
|
|
299
|
+
vec3 normal1 = normalize(vec3(normalTex1.r * 2.0 - 1.0, normalTex1.b,normalTex1.g*2.0-1.0));
|
|
300
|
+
vec3 normal2 = normalize(vec3(normalTex2.r * 2.0 - 1.0, normalTex2.b,normalTex2.g*2.0-1.0));
|
|
301
|
+
|
|
302
|
+
vec3 normal = mix(normal1,normal2,0.2);
|
|
303
|
+
|
|
304
|
+
normal = mix(vec3(0.0,1.0,0.0),normal,0.2);
|
|
305
|
+
|
|
306
|
+
normal = mix(vec3(0.0,1.0,0.0),normal,normalFactor);
|
|
307
|
+
|
|
308
|
+
vec3 viewDir = normalize(viewPos - position);
|
|
309
|
+
|
|
310
|
+
vec3 I = normalize(position - viewPos);
|
|
311
|
+
vec3 R = reflect(I, normal);
|
|
312
|
+
vec3 reflection = texture(skybox, R).rgb;
|
|
313
|
+
|
|
314
|
+
float ratio = 1.00 / 1.33;
|
|
315
|
+
vec3 Rr = refract(I, normal , ratio);
|
|
316
|
+
vec3 refraction = texture(skybox, Rr).rgb;
|
|
317
|
+
|
|
318
|
+
float reflectivity = 0.02;
|
|
319
|
+
float theta = max( dot( viewDir, normal ), 0.0 );
|
|
320
|
+
float reflectance = reflectivity + ( 1.0 - reflectivity ) * pow( ( 1.0 - theta ), 2.0 );
|
|
321
|
+
|
|
322
|
+
vec3 reflectanceColor = mix( refraction, reflection, reflectance );
|
|
323
|
+
|
|
324
|
+
out_FragColor = vec4(reflectanceColor,1.0);
|
|
325
|
+
|
|
326
|
+
}
|
|
327
|
+
`;return r},t.prototype.getVS=function(){var r=" in vec3 normal;in vec2 st;in float batchId; out vec3 v_normalEC;uniform mat4 u_modelViewMatrix;uniform mat4 u_invWorldViewMatrix;uniform int u_clampToGroud;uniform vec3 u_camPos;uniform vec3 u_scale;out vec3 vToEye;out vec2 vUv;out vec4 vCoord;void main(void){v_normalEC = czm_normal * normal;if (u_clampToGroud == 1){} else {vCoord = gl_Position;}vUv = st;}";return r},t.prototype.getFS2=function(){return `in vec3 v_positionMC;
|
|
328
|
+
in vec3 v_positionEC;
|
|
329
|
+
in vec2 v_st;
|
|
330
|
+
|
|
331
|
+
void main()
|
|
332
|
+
{
|
|
333
|
+
czm_materialInput materialInput;
|
|
334
|
+
vec3 normalEC = normalize(czm_normal3D * czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0)));
|
|
335
|
+
#ifdef FACE_FORWARD
|
|
336
|
+
normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
|
|
337
|
+
#endif
|
|
338
|
+
materialInput.s = v_st.s;
|
|
339
|
+
materialInput.st = v_st;
|
|
340
|
+
materialInput.str = vec3(v_st, 0.0);
|
|
341
|
+
materialInput.normalEC = normalEC;
|
|
342
|
+
materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, materialInput.normalEC);
|
|
343
|
+
vec3 positionToEyeEC = -v_positionEC;
|
|
344
|
+
materialInput.positionToEyeEC = positionToEyeEC;
|
|
345
|
+
czm_material material = czm_getMaterial(materialInput);
|
|
346
|
+
#ifdef FLAT
|
|
347
|
+
out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
|
|
348
|
+
#else
|
|
349
|
+
out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
|
|
350
|
+
out_FragColor.a = 0.5;
|
|
351
|
+
#endif
|
|
352
|
+
}
|
|
353
|
+
`},g.prototype.updateDegreesPosition=function(r,a){if(this.primitive!=null){if(this._viewer.scene.primitives.remove(this.primitive),r&&r.length<3)return;var i=this._createGeometry(r,a||0);this.primitive=this._viewer.scene.primitives.add(new e.Primitive({allowPicking:false,geometryInstances:new e.GeometryInstance({geometry:i}),appearance:this._appearance,asynchronous:false}));}else return},e.Scene.WaterPrimitive=t;},_installTexturePrimitive:function(){function m(t){this._vertexShader=this.getVS(),this._fragmentShader=this.getFS(),this._materialShader=this.getMS(),this._url=t.url,this._cartesians=t.cartesians,this._id=t.id||"";}m.prototype.build=function(){for(var t=[],r=[0,0,1,0,1,1,0,1],a=[0,1,2,0,2,3],i=0;i<this._cartesians.length;i++)t.push(this._cartesians[i].x),t.push(this._cartesians[i].y),t.push(this._cartesians[i].z);this._positionArr=new Float32Array(t),this._sts=new Uint8Array(r),this._indiceArr=new Uint16Array(a),this._geometry=this._createGeometry(),this._appearance=this._createAppearence(),this.primitive=this._viewer.scene.primitives.add(new e.Primitive({geometryInstances:new e.GeometryInstance({geometry:this._geometry,id:this._id}),appearance:this._appearance,asynchronous:false}));},m.prototype._createGeometry=function(){var t=new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:this._sts});return new e.Geometry({attributes:{position:new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:this._positions}),st:t},indices:this._indices,primitiveType:e.PrimitiveType.TRIANGLES,boundingSphere:e.BoundingSphere.fromVertices(positions)})},m.prototype._createAppearence=function(){return new e.Appearance({material:new e.Material({fabric:{uniforms:{image:this._url},source:this._materialShader}}),aboveGround:true,faceForward:true,flat:true,translucent:false,renderState:{blending:e.BlendingState.PRE_MULTIPLIED_ALPHA_BLEND,depthTest:{enabled:true},depthMask:true},fragmentShaderSource:this._fragmentShader,vertexShaderSource:this._vertexShader})},m.prototype.getVS=function(){return "in vec3 position3DHigh; in vec3 position3DLow; in vec2 st; in float batchId; out vec2 v_st; void main() { vec4 p = czm_computePosition(); v_st=st; p = czm_modelViewProjectionRelativeToEye * p; gl_Position = p; } "},m.prototype.getFS=function(){return "in vec2 v_st; void main() { czm_materialInput materialInput; czm_material material=czm_getMaterial(materialInput,v_st); vec4 color=vec4(material.diffuse + material.emission,material.alpha); if(color.x==1.0&&color.y==1.0&&color.z==1.0&&color.w==1.0) color=vec4(vec3(0.0,0.0,0.0),0.0); out_FragColor =color; } "},m.prototype.getMS=function(){return "czm_material czm_getMaterial(czm_materialInput materialInput,vec2 v_st) { vec4 color = texture(image, v_st); czm_material material = czm_getDefaultMaterial(materialInput); material.diffuse= color.rgb; material.alpha=color.a; return material; } "},e.Scene.TexturePrimitive=m;},_installProbingPrimitive:function(){var m={color:new e.Color(1,0,1,.8),repeat:30,offset:0,thickness:.3,center:e.Cartesian3.fromDegrees(116.39,39.9),length:4e5,bottom:1e3,top:0},t=this._viewer;function r(a){this._viewer=t,this._length=a.length||m.length,this._center=a.center||m.center,this._color=a.color||m.color,this._repeat=a.repeat||m.repeat,this._offset=a.offset||m.offset,this._thickness=a.thickness||m.thickness,this._bottom=a.bottom||m.bottom,this._top=a.top||m.top,this._radar=void 0,this.build();}r.prototype.build=function(){var a=new e.CylinderGeometry({length:this._length,topRadius:this._top,bottomRadius:this._bottom,vertexFormat:e.MaterialAppearance.MaterialSupport.TEXTURED.vertexFormat}),i=new e.GeometryInstance({geometry:a,modelMatrix:this.getModelMatrix()}),o=new e.MaterialAppearance({material:this.getMaterial(),faceForward:false,closed:true}),l=this;this._radar=this._viewer.scene.primitives.add(new e.Primitive({geometryInstances:[i],appearance:o}));let s=function(){var c=l._radar.appearance.material.uniforms.offset;c-=.001,c>1&&(c=0),l._radar.appearance.material.uniforms.offset=c;};this._preUpdate=s,this._viewer.scene.preUpdate.addEventListener(s);},r.prototype.getModelMatrix=function(){return e.Matrix4.multiplyByTranslation(e.Transforms.eastNorthUpToFixedFrame(this._center),new e.Cartesian3(0,0,this._length*.5),new e.Matrix4)},r.prototype.updateModelMatrix=function(){},r.prototype.getMaterial=function(){var a=`uniform vec4 color;
|
|
354
|
+
uniform float repeat;
|
|
355
|
+
uniform float offset;
|
|
356
|
+
uniform float thickness;
|
|
357
|
+
|
|
358
|
+
czm_material czm_getMaterial(czm_materialInput materialInput){
|
|
359
|
+
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
360
|
+
float sp = 1.0/repeat;
|
|
361
|
+
vec2 st = materialInput.st;
|
|
362
|
+
float dis = distance(st, vec2(0.5));
|
|
363
|
+
float m = mod(dis + offset, sp);
|
|
364
|
+
float a = step(sp*(1.0-thickness), m);
|
|
365
|
+
|
|
366
|
+
material.diffuse = color.rgb;
|
|
367
|
+
material.alpha = a * color.a;
|
|
368
|
+
return material;
|
|
369
|
+
}`;return new e.Material({fabric:{type:"radarPrimitive",uniforms:{color:this._color,repeat:this._repeat,offset:this._offset,thickness:this._thickness},source:a},translucent:false})},r.prototype.remove=function(){this._preUpdate&&(this._viewer.scene.preUpdate.removeEventListener(this._preUpdate),this._preUpdate=null),this._radar&&(this._viewer.scene.primitives.remove(this._radar),this._radar=void 0);},r.prototype.destroy=function(){this.remove(),this._destroyed=true;},r.prototype.isDestroyed=function(){return this._destroyed===true},e.Scene.ProbingPrimitive=r;},_initCustomPrimitive:function(m){let t=e;function r({img:a,center:i,height1:o=0,height2:l=3e5,scale:s=.003}){this.drawCommand=null,this._texture=null,this._image=null,this.img=a,this.center=i,this.height1=o,this.height2=l,this.scale=s;}return r.prototype.update=function(a){this._destroyed!==true&&(this.drawCommand===null&&this.createDrawCommand(a.context),this._texture===null&&this.createTexture(a.context),a.commandList.push(this.drawCommand));},r.prototype.isDestroyed=function(){return this._destroyed===true},r.prototype.destroy=function(){this._texture&&!this._texture.isDestroyed()&&this._texture.destroy(),this._texture=null,this.drawCommand&&this.drawCommand.vertexArray&&!this.drawCommand.vertexArray.isDestroyed()&&this.drawCommand.vertexArray.destroy(),this.drawCommand=null,this._destroyed=true;},r.prototype.createTexture=function(a){this._image===null&&(this._image=new Image,this._image.src=this.img||"static/data/images/Textures/beautiful.jpg",this._image.onload=()=>{this._texture=new t.Texture({context:a,source:this._image});});},r.prototype.createDrawCommand=function(a){let i=this.createPyramidGeometry(),o=t.VertexArray.fromGeometry({context:a,geometry:i,attributeLocations:t.GeometryPipeline.createAttributeLocations(i)}),l=t.ShaderProgram.fromCache({context:a,vertexShaderSource:ce,fragmentShaderSource:le,attributeLocations:t.GeometryPipeline.createAttributeLocations(i)}),s=new t.Cartesian2(a.canvas.width,a.canvas.height),c={v1:()=>this.v1,v2:()=>this.v2,wenli:()=>this._texture!==null?this._texture:a.defaultTexture,iResolution:()=>s},n=t.RenderState.fromCache();this.drawCommand=new t.DrawCommand({vertexArray:o,shaderProgram:l,uniformMap:c,renderState:n,pass:t.Pass.OPAQUE});},r.prototype.createPyramidGeometry=function(){let a=this.height1,i=this.height2,o=this.scale,l=this.center||[104.057605,30.607196],s=f(l,[-o,o]),c=f(l,[o,o]),n=f(l,[-o,-o]),h=f(l,[o,o]),y=[],d=[0,1,3,0,1,2,0,2,4,0,3,4,1,2,3,2,3,4],x=[.5,.5,0,1,1,1,0,0,1,0];y.push(...p(l,a),...p(s),...p(c),...p(n),...p(h)),this.v1=new t.Cartesian3(...p(l,a)),this.v2=new t.Cartesian3(...p(l,i));function p(S,_=i){let M=t.Cartesian3.fromDegrees(...S,_);return [M.x,M.y,M.z]}function f(S,_){return [_[0]+S[0],_[1]+S[1]]}return new t.Geometry({attributes:{position:new t.GeometryAttribute({componentDatatype:t.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:new Float32Array(y)}),st:new t.GeometryAttribute({componentDatatype:t.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:new Float32Array(x)})},indices:d,boundingSphere:t.BoundingSphere.fromVertices(y)})},new r(m)},customPrimivive(m){return this._initCustomPrimitive(m)},_heatmap:function(){let m=null,t=1080,r=1920,a=[103.8258,30.58595,104.252263,30.87];return {getHeatmap({heatData:i,boundsArr:o,screenHeight:l,screenWidth:s}){a=o||a,l=l||t,s=s||r;let c=[];for(let h of i){let y=h.lng,d=h.lat,x=Math.round((y-a[0])/(a[2]-a[0])*r),p=t-Math.round((d-a[1])/(a[3]-a[1])*t);c.push({x,y:p,value:h.num});}return this.createHeatmap(c),this.createPrimitive()},createHeatmap(i){var o=document.createElement("div");o.setAttribute("style","width: "+r+"px; height: "+t+"px; margin: 0px; display: none;"),document.body.appendChild(o),m=he.create({container:o,radius:24,maxOpacity:1,minOpacity:.1,blur:.85,gradient:{".2":"blue",".4":"green",".6":"yellow",".8":"orange",".9":"red"}}),m.setData({min:0,max:100,data:i});},createPrimitive(){let i=new e.ImageMaterialProperty({image:m._renderer.canvas}),o=this.generateGeometryInstance(),l=new e.MaterialAppearance({material:e.Material.fromType(e.Material.ImageType,i.getValue(new e.JulianDate))}),s={geometryInstances:o,appearance:l,allowPicking:false,asynchronous:false,show:false};return new e.Primitive(s)},generateGeometryInstance(){let i=a[2]-a[0],o=a[3]-a[1],l=a[0],s=a[1],c=.001,n=.001,h=0,y=5,d=Math.floor(i/c),x=Math.floor(o/n),p=[];for(let P=0;P<x+1;P++){let A=[];for(let b=0;b<d+1;b++){let D=l+(b==d?i:b*c),I=s+(P==x?o:P*n),k={x:Math.round((D-l)/i*r),y:t-Math.round((I-s)/o*t)},T=m.getValueAt(k),O=m._renderer.ctx.getImageData(k.x,k.y,1,1).data;A.push([D,I,h+T*y,O.map(F=>F/255),[(D-l)/i,(I-s)/o]]);}p.push(A);}let f=[],E=[],S=[],_=[],C=0;for(let P=0;P<x;P++)for(let A=0;A<d;A++){let b=p[P][A],D=p[P][A+1],I=p[P+1][A+1],k=p[P+1][A];this.addVertices(b,f,S,_),this.addVertices(D,f,S,_),this.addVertices(I,f,S,_),this.addVertices(b,f,S,_),this.addVertices(I,f,S,_),this.addVertices(k,f,S,_),E.push(C+0,C+1,C+2,C+3,C+4,C+5),C+=6;}return new e.GeometryInstance({geometry:e.GeometryPipeline.computeNormal(this.generateGeometry(f,S,E,_))})},addVertices(i,o,l,s){let c=e.Cartesian3.fromDegrees(i[0],i[1],i[2]);o.push(c.x,c.y,c.z),l.push(i[3][0],i[3][1],i[3][2],i[3][3]),s.push(i[4][0],i[4][1]);},generateGeometry(i,o,l,s){var c=new e.GeometryAttributes({position:new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:new Float64Array(i)}),color:new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.FLOAT,componentsPerAttribute:4,values:new Float32Array(o)}),st:new e.GeometryAttribute({componentDatatype:e.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:new Float32Array(s)})});let n=e.BoundingSphere.fromVertices(i,new e.Cartesian3(0,0,0),3);return new e.Geometry({attributes:c,indices:l,primitiveType:e.PrimitiveType.TRIANGLES,boundingSphere:n})}}},createHeatmap3d(m){return this._heatmap().getHeatmap(m)}},g}var re=$(Pe);var tt=se([ie],re,"primitive");exports.Primitive=tt;//# sourceMappingURL=primitive.cjs.map
|
|
370
|
+
//# sourceMappingURL=primitive.cjs.map
|