map-core-func 0.1.15 → 0.1.17

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("maptalks"),t=require("three"),r=require("maptalks.three");function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=i(e),n=i(t);function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(a=i.key,n=void 0,"symbol"==typeof(n=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?n:String(n)),i)}var a,n}function l(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function d(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function p(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=h(e);if(t){var a=h(this).constructor;r=Reflect.construct(i,arguments,a)}else r=i.apply(this,arguments);return d(this,r)}}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function f(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw n}}}}function v(){var e="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"iep".concat(e,"layer")}var g={altitude:0,imageWidth:512,imageHeight:512,texture:null},y=function(e){c(i,r.BaseObject);var t=p(i);function i(e,r,s,l){var c;o(this,i);var h=r=a.Util.extend({},g,r),u=h.altitude;h.imageHeight,h.imageWidth,e instanceof a.Extent||(e=new a.Extent(e));var d=e,p=d.xmin,m=d.ymin,f=d.xmax,v=d.ymax,y=1/0,x=1/0,b=-1/0,_=-1/0;[[p,m],[p,v],[f,v],[f,m]].forEach((function(e){var t=l.coordinateToVector3(e),r=t.x,i=t.y;y=Math.min(r,y),x=Math.min(i,x),b=Math.max(r,b),_=Math.max(i,_)}));var w=Math.abs(b-y),M=Math.abs(_-x),L=new n.PlaneBufferGeometry(w,M);(c=t.call(this))._initOptions(r),c._createMesh(L,s);var j=l.distanceToVector3(u,u).x,O=l.coordinateToVector3(e.getCenter(),j);return c.getObject3d().position.copy(O),c.parent=null,c.type="Image",c}return l(i)}(),x=function(){function e(t,r,i,s,l){var c=this;o(this,e),this.threelayer=l,this.map=l.map,this.textureLoader=new n.TextureLoader;var h=t.split(","),u=r.split(","),d=parseFloat(h[0]),p=parseFloat(h[1]),m=parseFloat(u[0]),f=parseFloat(u[1]),v=s.maxZoom||11,g=s.renderOrder||0,x=s.opacity||1,b=s.minZoom||3,_=new a.Extent(d,p,m,f);this.xmin_g=d,this.ymin_g=p,this.xmax_g=m,this.ymax_g=f,this.textureLoader.load(i,(function(e){var t=new n.MeshBasicMaterial({map:e,transparent:!0,opacity:x}),r=new y(_,{imageWidth:512,imageHeight:512,maxZoom:v,minZoom:b,interactive:void 0!==s.interactive&&s.interactive},t,c.threelayer);r.object3d.renderOrder=g,c.imgMesh=r,c.imgMesh.parent=c,c.m=t,c.texture=e,c.threelayer.addMesh(c.imgMesh),s.opacityItems&&s.opacityItems.length>0&&!isNaN(s.opacityItems[0])&&!isNaN(s.opacityItems[1])&&s.opacityItems[0]>3&&s.opacityItems[0]<=18&&s.opacityItems[1]>=0&&s.opacityItems[1]<=1&&(c.opacityItems=s.opacityItems,c._bindMapEvents(),c._viewChange())}))}return l(e,[{key:"_bindMapEvents",value:function(){this.map.on("viewchange",this._viewChange,this)}},{key:"_viewChange",value:function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1}},{key:"_closeEvent",value:function(){this.map.off("viewchange",this._viewChange,this)}},{key:"updateImage",value:function(e,t){var r=this;if(t&&t.leftbottom&&t.righttop){var i=parseFloat(t.leftbottom[0]),o=parseFloat(t.leftbottom[1]),s=parseFloat(t.righttop[0]),l=parseFloat(t.righttop[1]);if(i!==this.xmin_g||o!==this.ymin_g||s!==this.xmax_g||l!==this.ymax_g){var c=new a.Extent(i,o,s,l),h=1/0,u=1/0,d=-1/0,p=-1/0;[[i,o],[i,l],[s,l],[s,o]].forEach((function(e){var t=r.threelayer.coordinateToVector3(e),i=t.x,a=t.y;h=Math.min(i,h),u=Math.min(a,u),d=Math.max(i,d),p=Math.max(a,p)}));for(var m=Math.abs(d-h),f=Math.abs(p-u),v=new n.PlaneBufferGeometry(m,f),g=v.attributes.position.array,y=this.imgMesh.object3d.geometry.attributes.position.array,x=0;x<y.length;x++)y[x]=g[x];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var b=this.threelayer.coordinateToVector3(c.getCenter(),0);this.imgMesh.getObject3d().position.copy(b),v.dispose(),this.xmin_g=i,this.ymin_g=o,this.xmax_g=s,this.ymax_g=l}}this.textureLoader.load(e,(function(e){r.texture&&r.texture.dispose(),delete r.texture,e.magFilter=n.NearestFilter,e.minFilter=n.NearestFilter,r.imgMesh.object3d.material.map=e,r.imgMesh.object3d.material.map.needsUpdate=!0,r.texture=e,!1===r.imgMesh.isAdd&&(r.threelayer.addMesh(r.imgMesh),r.opacityItems&&r._bindMapEvents())}))}},{key:"clearImage",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())}},{key:"dispose",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader}}]),e}(),b={altitude:0,imageWidth:512,imageHeight:512,texture:null},_=function(e){c(i,r.BaseObject);var t=p(i);function i(e,r,s,l,c){var h;o(this,i);var u=(s=a.Util.extend({},b,s)).altitude,d=c.distanceToVector3(r,r).x,p=new n.CircleGeometry(d,32);(h=t.call(this))._initOptions(s),h._createMesh(p,l);var m=c.distanceToVector3(u,u).x,f=c.coordinateToVector3(e,m);return h.getObject3d().position.copy(f),h.parent=null,h.type="radarObject",h}return l(i)}(),w=function(){function e(t,r,i,a,s){o(this,e),this.threelayer=a,this.map=a.map,this.layerClass=s,this.imgUrl=i.imgUrl,this.loader=new n.TextureLoader,this.texture=this.loader.load(this.imgUrl),this._uniforms={map:{value:this.texture},time:{value:0}};var l=new n.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n const float PI = 3.14159265359;\n const float TWO_PI = 6.28318530718;\n const int N = 3;\n const float r0 = 0.01;\n const float r_blue = 0.025;\n const float r_red = 0.015;\n const float edge = 0.95;\n const float offset = 0.05;\n\n uniform float time;\n varying vec2 vUv;\n uniform sampler2D map;\n float plot(const vec2 st, const float pct, const float width)\n {\n return smoothstep(pct - width, pct, st.y) -\n smoothstep(pct, pct + width, st.y);\n }\n float drawPolygon(const vec2 polygonCenter, const int N, const float radius, vec2 pos)\n {\n pos = pos - polygonCenter;\n float d = 0.0;\n float a = atan(pos.x, pos.y);\n float r = TWO_PI / float(N);\n d = cos(floor(0.5 + a / r)*r - a)*length(pos);\n return (1.0 - smoothstep(radius, radius + radius/10.0, d));\n }\n float gradations(const float a, const float gradNum, const float outRad, const float tickLen, const float tickWidth, const float r, const float move)\n {\n float f = step(0.0, cos((a + move)*gradNum) - tickWidth)*tickLen + (outRad - tickLen);\n return 1.0 - step(f, r) * 1.0 - step(r, outRad - tickLen);\n }\n void main() {\n // Normalized pixel coordinates (from 0 to 1)\n vec2 uv = vUv;\n vec2 pos = uv.xy - vec2(0.5, 0.5) ; // center what being drawn\n vec4 grndSpd = vec4(0.0, time/5.0, 0.0, 0.0);\n vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.85, 0.0, 1.0);\n //vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.58, 1.0, 1.0);\n //vec3 color = vec3(0.0, 0.0, 0.0);\n vec3 color = vec3(0.0, 147. / 255., 1.0);\n float r = length(pos) * 2.0;\n float a = atan(pos.y, pos.x); // angle of pixel\n float an = PI - mod(time/ 1.0, TWO_PI); // angle of radar sweep\n float blipSpd = 3.0; // Blip / Trace speed\n vec2 translate1 = vec2(cos(time/ blipSpd), sin(time/ blipSpd));\n vec2 translate2 = vec2(sin(time/ blipSpd), cos(time/ blipSpd));\n vec2 left1 = translate1 * 0.35;\n vec2 right1 = -translate1 * 0.30;\n vec2 left2 = translate2 * 0.15;\n vec2 right2 = -translate2 * 0.25;\n // Radar Sweep\n float sn = step(PI/2.0, an) * step(-PI/2.0, (a + an)) * step(r, edge) * (1.0 - 0.55 * (a + (TWO_PI) - an));\n float sw = step(an, a) * step(r, edge);\n float s_blade = sw * (1.0 - (a - an) * 20.0);\n float s = sw * (1.0 - 0.55 * (a - an));\n s = max(sn,s);\n float se = step(r, edge - 0.05);\n // Center point\n float s1 = smoothstep(edge - 0.00, edge + 0.01, r)* smoothstep(edge + 0.02, edge + 0.01, r);\n // Circular concentric rings\n float s0 = 1.0 - smoothstep(r0 / 2.0, r0, length(pos));\n float smb = (1.0 - smoothstep(0.2, 0.2 + 0.01, length(pos))) * (1.0 - smoothstep(0.2 +0.01, 0.2, length(pos)));\n float smr = (1.0 - smoothstep(0.3, 0.3 + 0.01, length(pos))) * (1.0 - smoothstep(0.3 +0.01, 0.3, length(pos)));\n // Circular concentric gradations\n float gradNum = 120.0;\n float tickWidth = 0.9;\n const float tickLen = 0.04;\n float outRad = edge;\n float move = 0.0;\n float sm = 0.75*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n gradNum = 36.0;\n tickWidth = 0.95;\n outRad = 0.6;\n move = sin(time/10.0);\n smr += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n outRad = 0.4;\n move = cos(time/10.0);\n smb += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n // Radial spoke gradations\n float sr = plot(pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.x, 0.002) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.y, 0.003) * step(r, edge - 0.06);\n sr += plot(-pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr *= 0.75;\n // Blue circular radar blip traces\n vec2 st_trace1 = left2;\n float s_trace1 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1)));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+offset, +offset))));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+2.0 *offset, +2.0 *offset))));\n\n vec2 st_trace2 = right1;\n float s_trace2 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace2)));\n // Red Trianglular radar flight blip trace\n vec2 st_trace3 = left1;\n float st1 = s * (drawPolygon(st_trace3, N, r_red , pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(-offset, -offset), N, r_red, pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(+offset, -offset), N, r_red, pos));\n\n vec2 st_trace4 = right2;\n float st2 = s * (drawPolygon(st_trace4, N, r_red, pos)); \n // Lets add all the bits together and send them to screen\n float s_grn = max(s * mapcol.y, s_blade);\n s_grn = max(s_grn, (s0 + sr + sm));\n s_grn += s1 / 1.5 + smb + smr;\n\n float s_red = st1*2.0 + st2*2.0 + smr;\n \n float s_blue = max(s_trace1 + s_trace2, s_blade) + smb;\n\n if (s_trace1 > 0.0 || s_trace2 > 0.0) { s_blue = max(s, s_blue); s_grn = max(s_grn, s_blue); }\n\n color += vec3(s_red , s_grn, s_blue); \n vec4 texColor = mapcol * s;\n // Output to screen \n gl_FragColor = vec4(color, 0.5);//Set the screen pixel to that color\n }",side:n.DoubleSide,transparent:!0});this.radar=new _(t,r,{},l,a),this.threelayer.addMesh(this.radar),this.layerClass.updatables.push(this)}return l(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.radar),this.radar.object3d.geometry&&this.radar.object3d.geometry.dispose(),this.radar.object3d.material&&this.radar.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),M={radius:100,altitude:0},L=function(e){c(i,r.BaseObject);var t=p(i);function i(e,r,s,l){var c;o(this,i),r=a.Util.extend({},M,r,{layer:l,coordinate:e}),(c=t.call(this))._initOptions(r);var h=r,u=h.altitude,d=h.radius,p=l.distanceToVector3(d,d).x,m=r.thetaStart||0,f=r.thetaLength||90,v=new n.CircleGeometry(p,128,m*Math.PI/180,f*Math.PI/180);c._createMesh(v,s);var g=l.distanceToVector3(u,u).x,y=l.coordinateToVector3(e,g);return c.getObject3d().position.copy(y),c}return l(i)}(),j=function(){function e(t,r,i,a,s){o(this,e),this.threelayer=a,this.map=a.map,this.layerClass=s;var l=i.thetaLength||90,c=i.rotation||0,h=l/2;this.imgUrl=i.imgUrl,this.loader=new n.TextureLoader,this.texture=this.loader.load(this.imgUrl);var u=c-h;u=u<0?u+360:u,this._uniforms={map:{value:this.texture},time:{value:0}};var d=new n.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n varying vec2 vUv;\n void main() {\n vec2 uv = vUv;\n //uv = uv.xy - vec2(0.5, 0.5);\n //gl_FragColor = texture2D(map, uv);\n gl_FragColor = vec4(1.0, 1.0, 1.0, 0.5);\n }",side:n.DoubleSide,transparent:!0,depthTest:!1});this.sector=new L(t,{thetaStart:u,thetaLength:i.thetaLength,radius:r},d,a),this.threelayer.addMesh(this.sector)}return l(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"dispose",value:function(){}}]),e}(),O={altitude:0,height:0},T=function(e){c(i,r.BaseObject);var t=p(i);function i(e,r,s,l){var c;o(this,i),s=a.Util.extend({},O,s,{layer:l}),c=t.call(this);var h=s,u=h.width,d=h.height,p=h.altitude;c._initOptions(s);var m=new n.PlaneGeometry(u,d);m.computeBoundingBox();var f=new n.Mesh(m,r);c._createGroup(),c.getObject3d().add(f);var v=l.distanceToVector3(p,p).x,g=l.coordinateToVector3(e,v);return f.position.set(0,m.boundingBox.max.y,0),c.getObject3d().position.copy(g),c}return l(i)}();function k(e,t,r,i,a,o){this.tilesHorizontal=t,this.tilesVertical=r,this.numberOfTiles=i,e.wrapS=e.wrapT=n.RepeatWrapping,e.repeat.set(1/this.tilesHorizontal,1/this.tilesVertical),this.tileDisplayDuration=a,this.currentDisplayTime=0,this.currentTile=0,this.flag=o,this.update=function(t){for(this.currentDisplayTime+=t;this.currentDisplayTime>this.tileDisplayDuration;){this.currentDisplayTime-=this.tileDisplayDuration,this.currentTile++,this.currentTile==this.numberOfTiles&&(this.currentTile=0);var r=this.currentTile%this.tilesHorizontal;e.offset.x=r/this.tilesHorizontal;var i=Math.floor(this.currentTile/this.tilesHorizontal);this.flag?e.offset.y=this.tilesVertical-i/this.tilesVertical:e.offset.y=1-i/this.tilesVertical-1/this.tilesVertical}}}var P=function(){function e(t,r,i,a,s){var l=this;o(this,e),this.threelayer=a,this.map=a.map,this.layerClass=s;var c=i.thetaLength||45;this.millsec=i.millsec||1e3,this.duration=i.duration||75,this.tilesHoriz=i.tilesHoriz||12,this.tilesVert=i.tilesVert||5,this.numTiles=i.numTiles||49;var h=i.rotation||0,u=c/2,d=a.distanceToVector3(r,r).x,p=Math.sin(u*Math.PI/180)*d*2,m=void 0===i.flag;this.imgUrl=i.imgUrl,this.textureLoader=new n.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){l.texture=e,l.annie=new k(e,l.tilesHoriz,l.tilesVert,l.numTiles,l.duration,m);var r=new n.MeshBasicMaterial({transparent:!0,map:e,side:n.DoubleSide,depthTest:!1});l.imgObj=new T(t,r,{width:p,height:d},a),l.imgObj.object3d.renderOrder=1,l.imgObj.object3d.rotation.z=h*Math.PI/180,l.threelayer.addMesh(l.imgObj),l.layerClass.updatables.push(l)}))}return l(e,[{key:"tick",value:function(e){var t;null===(t=this.annie)||void 0===t||t.update(this.millsec*e)}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.imgObj),this.imgObj.object3d.geometry&&this.imgObj.object3d.geometry.dispose(),this.imgObj.object3d.material&&this.imgObj.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),I={radius:100,altitude:0},S=function(e){c(i,r.BaseObject);var t=p(i);function i(e,r,s,l){var c;o(this,i),r=a.Util.extend({},I,r,{layer:l}),c=t.call(this);var h=r,u=h.width;h.height;var d=h.altitude;c._initOptions(r);var p=new n.CircleGeometry(u,32);c._createMesh(p,s);var m=l.distanceToVector3(d,d).x,f=l.coordinateToVector3(e,m);return c.getObject3d().position.copy(f),c}return l(i)}(),C=function(){function e(t,r,i,a){var s=this;o(this,e),this.threelayer=i,this.map=i.map,this.layerClass=a,this.time=0,i.coordinateToVector3(t,0),this.imgUrl=r.imgUrl,this.textureLoader=new n.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){s.texture=e,s._uniforms={impactPosition:{value:new n.Vector3(0,0,0)},impactMaxRadius:{value:2},impactRatio:{value:.25},map:{value:s.texture}};var r=new n.ShaderMaterial({uniforms:s._uniforms,vertexShader:"\n varying vec3 vPosition;\n varying vec2 vUv;\n void main(){\n vUv = uv;\n vPosition = position;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n uniform vec3 impactPosition;\n uniform float impactMaxRadius;\n uniform float impactRatio;\n varying vec3 vPosition;\n varying vec2 vUv;\n void main() {\n float dist = distance(vPosition, impactPosition);\n float curRadius = impactMaxRadius * impactRatio;\n float sstep = smoothstep(0., curRadius, dist) - smoothstep(curRadius - ( 0.25 * impactRatio ), curRadius, dist);\n sstep = 1. - sstep * (1. - impactRatio);\n vec3 col = mix(vec3(1., 0.5, 0.0625), vec3(1., 0.25, 0.125), impactRatio);\n gl_FragColor = texture2D(map, vUv);\n gl_FragColor = vec4( mix( col, gl_FragColor.rgb, sstep), 1.0 );\n }",side:n.DoubleSide,transparent:!0,depthTest:!1}),a=new S(t,{width:2,height:2},r,i);s.threelayer.addMesh(a),s.layerClass.updatables.push(s)}))}return l(e,[{key:"tick",value:function(e){this.time+=.2*e,this.time%=1,this._uniforms.impactRatio.value=this.time}},{key:"dispose",value:function(){}}]),e}(),R=function(){function e(t,i){var a=this;o(this,e),this.map=i,this.animationId=null,this.updatables=[];var s=v();this.threeLayer=new r.ThreeLayer(s,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new n.Clock;var l=function e(){var t,r;(a.threeLayer._needsUpdate=!a.threeLayer._needsUpdate,a.threeLayer._needsUpdate)&&(null===(t=a.threeLayer)||void 0===t||null===(r=t.getRenderer())||void 0===r||r.clearCanvas(),a.threeLayer.renderScene());var i,n=a.clock.getDelta(),o=f(a.updatables);try{for(o.s();!(i=o.n()).done;){i.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}a.animationId=requestAnimationFrame(e)};this.threeLayer.prepareToDraw=function(e,t,r){var i=new n.DirectionalLight(16777215);i.position.set(0,-10,10).normalize(),t.add(i),l()},this.threeLayer.addTo(i),this.layerId=s,this.layerName=t,this.dirty=!1,this.initFlag=!1}return l(e,[{key:"getLayerId",value:function(){return this.layerId}},{key:"changeLayerId",value:function(){if(this.threeLayer){var e=v();this.threeLayer.setId(e),this.layerId=e}}},{key:"setVisible",value:function(e,t){this.threeLayer&&(!0===e?(this.threeLayer.show(),t&&t()):(this.threeLayer.hide(),t&&t()))}},{key:"prepareToDraw",value:function(){var e=this,t=function t(){var r,i;(e.threeLayer._needsUpdate=!e.threeLayer._needsUpdate,e.threeLayer._needsUpdate)&&(null===(r=e.threeLayer)||void 0===r||null===(i=r.getRenderer())||void 0===i||i.clearCanvas(),e.threeLayer.renderScene());var a,n=e.clock.getDelta(),o=f(e.updatables);try{for(o.s();!(a=o.n()).done;){a.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}e.animationId=requestAnimationFrame(t)};return new Promise((function(r){e.threeLayer.prepareToDraw=function(e,i,a){var o=new n.DirectionalLight(16777215);o.position.set(0,-10,10).normalize(),i.add(o),i.add(new n.AmbientLight(16777215)),t(),r()}}))}},{key:"drawRadar",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new w(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new w(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSector",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new j(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new j(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSectorImg",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new P(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new P(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawImage",value:function(e,t,r,i){var a=this;return new Promise((function(n){if(a.threeLayer.getScene()){var o=new x(e,t,r,i,a.threeLayer);n(o)}else a.initFlag=!0,a.prepareToDraw().then((function(){var o=new x(e,t,r,i,a.threeLayer);n(o)}))}))}},{key:"drawShock",value:function(e,t){var r=this;return new Promise((function(i){if(r.threeLayer.getScene()){var a=new C(e,t||{},r.threeLayer,r);i(a)}else r.initFlag=!0,r.prepareToDraw().then((function(){var a=new C(e,t||{},r.threeLayer,r);i(a)}))}))}},{key:"dispose",value:function(){this.animationId&&cancelAnimationFrame(this.animationId);var e=this.threeLayer.getMeshes();this.threeLayer.clear(),e.forEach((function(e){}));var t=this.threeLayer.getCamera(),r=this.threeLayer.getScene(),i=this.threeLayer.getPick(),a=i.pickingTexture;i.pickingScene;var n=this.threeLayer.getRenderer();r.remove(t),t=null,r=null,a.dispose(),a=null,n.context.dispose(),n.context.forceContextLoss(),n.context=null,n.remove(),n=null,this.map.removeLayer(this.threeLayer)}}]),e}();exports.imgClass=x,exports.layerClass=R,exports.planeSectorClass=P,exports.radarClass=w,exports.sectorClass=j,exports.shockClass=C;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("maptalks"),t=require("three"),r=require("maptalks.three");function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=i(e),n=i(t);function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(a=i.key,n=void 0,"symbol"==typeof(n=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?n:String(n)),i)}var a,n}function l(e,t,r){return t&&s(e.prototype,t),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function d(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function p(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=h(e);if(t){var a=h(this).constructor;r=Reflect.construct(i,arguments,a)}else r=i.apply(this,arguments);return d(this,r)}}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function f(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw n}}}}function v(){var e="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"iep".concat(e,"layer")}var g={altitude:0,imageWidth:512,imageHeight:512,texture:null},y=function(e){c(i,r.BaseObject);var t=p(i);function i(e,r,s,l){var c;o(this,i);var h=r=a.Util.extend({},g,r),u=h.altitude;h.imageHeight,h.imageWidth,e instanceof a.Extent||(e=new a.Extent(e));var d=e,p=d.xmin,m=d.ymin,f=d.xmax,v=d.ymax,y=1/0,x=1/0,b=-1/0,_=-1/0;[[p,m],[p,v],[f,v],[f,m]].forEach((function(e){var t=l.coordinateToVector3(e),r=t.x,i=t.y;y=Math.min(r,y),x=Math.min(i,x),b=Math.max(r,b),_=Math.max(i,_)}));var w=Math.abs(b-y),M=Math.abs(_-x),L=new n.PlaneBufferGeometry(w,M);(c=t.call(this))._initOptions(r),c._createMesh(L,s);var j=l.distanceToVector3(u,u).x,O=l.coordinateToVector3(e.getCenter(),j);return c.getObject3d().position.copy(O),c.parent=null,c.type="Image",c}return l(i)}(),x=function(){function e(t,r,i,s,l){var c=this;o(this,e),this.threelayer=l,this.map=l.map,this.textureLoader=new n.TextureLoader;var h=t.split(","),u=r.split(","),d=parseFloat(h[0]),p=parseFloat(h[1]),m=parseFloat(u[0]),f=parseFloat(u[1]),v=s.maxZoom||11,g=s.renderOrder||0,x=s.opacity||1,b=s.minZoom||3,_=new a.Extent(d,p,m,f);this.xmin_g=d,this.ymin_g=p,this.xmax_g=m,this.ymax_g=f,this.textureLoader.load(i,(function(e){var t=new n.MeshBasicMaterial({map:e,transparent:!0,opacity:x}),r=new y(_,{imageWidth:512,imageHeight:512,maxZoom:v,minZoom:b,interactive:void 0!==s.interactive&&s.interactive},t,c.threelayer);r.object3d.renderOrder=g,c.imgMesh=r,c.imgMesh.parent=c,c.m=t,c.texture=e,c.threelayer.addMesh(c.imgMesh),s.opacityItems&&s.opacityItems.length>0&&!isNaN(s.opacityItems[0])&&!isNaN(s.opacityItems[1])&&s.opacityItems[0]>3&&s.opacityItems[0]<=18&&s.opacityItems[1]>=0&&s.opacityItems[1]<=1&&(c.opacityItems=s.opacityItems,c._bindMapEvents(),c._viewChange())}))}return l(e,[{key:"_bindMapEvents",value:function(){this.map.on("viewchange",this._viewChange,this)}},{key:"_viewChange",value:function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1}},{key:"_closeEvent",value:function(){this.map.off("viewchange",this._viewChange,this)}},{key:"updateImage",value:function(e,t){var r=this;if(t&&t.leftbottom&&t.righttop){var i=parseFloat(t.leftbottom[0]),o=parseFloat(t.leftbottom[1]),s=parseFloat(t.righttop[0]),l=parseFloat(t.righttop[1]);if(i!==this.xmin_g||o!==this.ymin_g||s!==this.xmax_g||l!==this.ymax_g){var c=new a.Extent(i,o,s,l),h=1/0,u=1/0,d=-1/0,p=-1/0;[[i,o],[i,l],[s,l],[s,o]].forEach((function(e){var t=r.threelayer.coordinateToVector3(e),i=t.x,a=t.y;h=Math.min(i,h),u=Math.min(a,u),d=Math.max(i,d),p=Math.max(a,p)}));for(var m=Math.abs(d-h),f=Math.abs(p-u),v=new n.PlaneBufferGeometry(m,f),g=v.attributes.position.array,y=this.imgMesh.object3d.geometry.attributes.position.array,x=0;x<y.length;x++)y[x]=g[x];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var b=this.threelayer.coordinateToVector3(c.getCenter(),0);this.imgMesh.getObject3d().position.copy(b),v.dispose(),this.xmin_g=i,this.ymin_g=o,this.xmax_g=s,this.ymax_g=l}}this.textureLoader.load(e,(function(e){r.texture&&r.texture.dispose(),delete r.texture,e.magFilter=n.NearestFilter,e.minFilter=n.NearestFilter,r.imgMesh.object3d.material.map=e,r.imgMesh.object3d.material.map.needsUpdate=!0,r.texture=e,!1===r.imgMesh.isAdd&&r.threelayer&&(r.threelayer.addMesh(r.imgMesh),r.opacityItems&&r._bindMapEvents())}))}},{key:"clearImage",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())}},{key:"dispose",value:function(){this.imgMesh&&(!0===this.imgMesh.isAdd&&this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader}}]),e}(),b={altitude:0,imageWidth:512,imageHeight:512,texture:null},_=function(e){c(i,r.BaseObject);var t=p(i);function i(e,r,s,l,c){var h;o(this,i);var u=(s=a.Util.extend({},b,s)).altitude,d=c.distanceToVector3(r,r).x,p=new n.CircleGeometry(d,32);(h=t.call(this))._initOptions(s),h._createMesh(p,l);var m=c.distanceToVector3(u,u).x,f=c.coordinateToVector3(e,m);return h.getObject3d().position.copy(f),h.parent=null,h.type="radarObject",h}return l(i)}(),w=function(){function e(t,r,i,a,s){o(this,e),this.threelayer=a,this.map=a.map,this.layerClass=s,this.imgUrl=i.imgUrl,this.loader=new n.TextureLoader,this.texture=this.loader.load(this.imgUrl),this._uniforms={map:{value:this.texture},time:{value:0}};var l=new n.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n const float PI = 3.14159265359;\n const float TWO_PI = 6.28318530718;\n const int N = 3;\n const float r0 = 0.01;\n const float r_blue = 0.025;\n const float r_red = 0.015;\n const float edge = 0.95;\n const float offset = 0.05;\n\n uniform float time;\n varying vec2 vUv;\n uniform sampler2D map;\n float plot(const vec2 st, const float pct, const float width)\n {\n return smoothstep(pct - width, pct, st.y) -\n smoothstep(pct, pct + width, st.y);\n }\n float drawPolygon(const vec2 polygonCenter, const int N, const float radius, vec2 pos)\n {\n pos = pos - polygonCenter;\n float d = 0.0;\n float a = atan(pos.x, pos.y);\n float r = TWO_PI / float(N);\n d = cos(floor(0.5 + a / r)*r - a)*length(pos);\n return (1.0 - smoothstep(radius, radius + radius/10.0, d));\n }\n float gradations(const float a, const float gradNum, const float outRad, const float tickLen, const float tickWidth, const float r, const float move)\n {\n float f = step(0.0, cos((a + move)*gradNum) - tickWidth)*tickLen + (outRad - tickLen);\n return 1.0 - step(f, r) * 1.0 - step(r, outRad - tickLen);\n }\n void main() {\n // Normalized pixel coordinates (from 0 to 1)\n vec2 uv = vUv;\n vec2 pos = uv.xy - vec2(0.5, 0.5) ; // center what being drawn\n vec4 grndSpd = vec4(0.0, time/5.0, 0.0, 0.0);\n vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.85, 0.0, 1.0);\n //vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.58, 1.0, 1.0);\n //vec3 color = vec3(0.0, 0.0, 0.0);\n vec3 color = vec3(0.0, 147. / 255., 1.0);\n float r = length(pos) * 2.0;\n float a = atan(pos.y, pos.x); // angle of pixel\n float an = PI - mod(time/ 1.0, TWO_PI); // angle of radar sweep\n float blipSpd = 3.0; // Blip / Trace speed\n vec2 translate1 = vec2(cos(time/ blipSpd), sin(time/ blipSpd));\n vec2 translate2 = vec2(sin(time/ blipSpd), cos(time/ blipSpd));\n vec2 left1 = translate1 * 0.35;\n vec2 right1 = -translate1 * 0.30;\n vec2 left2 = translate2 * 0.15;\n vec2 right2 = -translate2 * 0.25;\n // Radar Sweep\n float sn = step(PI/2.0, an) * step(-PI/2.0, (a + an)) * step(r, edge) * (1.0 - 0.55 * (a + (TWO_PI) - an));\n float sw = step(an, a) * step(r, edge);\n float s_blade = sw * (1.0 - (a - an) * 20.0);\n float s = sw * (1.0 - 0.55 * (a - an));\n s = max(sn,s);\n float se = step(r, edge - 0.05);\n // Center point\n float s1 = smoothstep(edge - 0.00, edge + 0.01, r)* smoothstep(edge + 0.02, edge + 0.01, r);\n // Circular concentric rings\n float s0 = 1.0 - smoothstep(r0 / 2.0, r0, length(pos));\n float smb = (1.0 - smoothstep(0.2, 0.2 + 0.01, length(pos))) * (1.0 - smoothstep(0.2 +0.01, 0.2, length(pos)));\n float smr = (1.0 - smoothstep(0.3, 0.3 + 0.01, length(pos))) * (1.0 - smoothstep(0.3 +0.01, 0.3, length(pos)));\n // Circular concentric gradations\n float gradNum = 120.0;\n float tickWidth = 0.9;\n const float tickLen = 0.04;\n float outRad = edge;\n float move = 0.0;\n float sm = 0.75*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n gradNum = 36.0;\n tickWidth = 0.95;\n outRad = 0.6;\n move = sin(time/10.0);\n smr += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n outRad = 0.4;\n move = cos(time/10.0);\n smb += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n // Radial spoke gradations\n float sr = plot(pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.x, 0.002) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.y, 0.003) * step(r, edge - 0.06);\n sr += plot(-pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr *= 0.75;\n // Blue circular radar blip traces\n vec2 st_trace1 = left2;\n float s_trace1 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1)));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+offset, +offset))));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+2.0 *offset, +2.0 *offset))));\n\n vec2 st_trace2 = right1;\n float s_trace2 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace2)));\n // Red Trianglular radar flight blip trace\n vec2 st_trace3 = left1;\n float st1 = s * (drawPolygon(st_trace3, N, r_red , pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(-offset, -offset), N, r_red, pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(+offset, -offset), N, r_red, pos));\n\n vec2 st_trace4 = right2;\n float st2 = s * (drawPolygon(st_trace4, N, r_red, pos)); \n // Lets add all the bits together and send them to screen\n float s_grn = max(s * mapcol.y, s_blade);\n s_grn = max(s_grn, (s0 + sr + sm));\n s_grn += s1 / 1.5 + smb + smr;\n\n float s_red = st1*2.0 + st2*2.0 + smr;\n \n float s_blue = max(s_trace1 + s_trace2, s_blade) + smb;\n\n if (s_trace1 > 0.0 || s_trace2 > 0.0) { s_blue = max(s, s_blue); s_grn = max(s_grn, s_blue); }\n\n color += vec3(s_red , s_grn, s_blue); \n vec4 texColor = mapcol * s;\n // Output to screen \n gl_FragColor = vec4(color, 0.5);//Set the screen pixel to that color\n }",side:n.DoubleSide,transparent:!0});this.radar=new _(t,r,{},l,a),this.threelayer.addMesh(this.radar),this.layerClass.updatables.push(this)}return l(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.radar),this.radar.object3d.geometry&&this.radar.object3d.geometry.dispose(),this.radar.object3d.material&&this.radar.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),M={radius:100,altitude:0},L=function(e){c(i,r.BaseObject);var t=p(i);function i(e,r,s,l){var c;o(this,i),r=a.Util.extend({},M,r,{layer:l,coordinate:e}),(c=t.call(this))._initOptions(r);var h=r,u=h.altitude,d=h.radius,p=l.distanceToVector3(d,d).x,m=r.thetaStart||0,f=r.thetaLength||90,v=new n.CircleGeometry(p,128,m*Math.PI/180,f*Math.PI/180);c._createMesh(v,s);var g=l.distanceToVector3(u,u).x,y=l.coordinateToVector3(e,g);return c.getObject3d().position.copy(y),c}return l(i)}(),j=function(){function e(t,r,i,a,s){o(this,e),this.threelayer=a,this.map=a.map,this.layerClass=s;var l=i.thetaLength||90,c=i.rotation||0,h=l/2;this.imgUrl=i.imgUrl,this.loader=new n.TextureLoader,this.texture=this.loader.load(this.imgUrl);var u=c-h;u=u<0?u+360:u,this._uniforms={map:{value:this.texture},time:{value:0}};var d=new n.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n varying vec2 vUv;\n void main() {\n vec2 uv = vUv;\n //uv = uv.xy - vec2(0.5, 0.5);\n //gl_FragColor = texture2D(map, uv);\n gl_FragColor = vec4(1.0, 1.0, 1.0, 0.5);\n }",side:n.DoubleSide,transparent:!0,depthTest:!1});this.sector=new L(t,{thetaStart:u,thetaLength:i.thetaLength,radius:r},d,a),this.threelayer.addMesh(this.sector)}return l(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"dispose",value:function(){}}]),e}(),O={altitude:0,height:0},T=function(e){c(i,r.BaseObject);var t=p(i);function i(e,r,s,l){var c;o(this,i),s=a.Util.extend({},O,s,{layer:l}),c=t.call(this);var h=s,u=h.width,d=h.height,p=h.altitude;c._initOptions(s);var m=new n.PlaneGeometry(u,d);m.computeBoundingBox();var f=new n.Mesh(m,r);c._createGroup(),c.getObject3d().add(f);var v=l.distanceToVector3(p,p).x,g=l.coordinateToVector3(e,v);return f.position.set(0,m.boundingBox.max.y,0),c.getObject3d().position.copy(g),c}return l(i)}();function k(e,t,r,i,a,o){this.tilesHorizontal=t,this.tilesVertical=r,this.numberOfTiles=i,e.wrapS=e.wrapT=n.RepeatWrapping,e.repeat.set(1/this.tilesHorizontal,1/this.tilesVertical),this.tileDisplayDuration=a,this.currentDisplayTime=0,this.currentTile=0,this.flag=o,this.update=function(t){for(this.currentDisplayTime+=t;this.currentDisplayTime>this.tileDisplayDuration;){this.currentDisplayTime-=this.tileDisplayDuration,this.currentTile++,this.currentTile==this.numberOfTiles&&(this.currentTile=0);var r=this.currentTile%this.tilesHorizontal;e.offset.x=r/this.tilesHorizontal;var i=Math.floor(this.currentTile/this.tilesHorizontal);this.flag?e.offset.y=this.tilesVertical-i/this.tilesVertical:e.offset.y=1-i/this.tilesVertical-1/this.tilesVertical}}}var P=function(){function e(t,r,i,a,s){var l=this;o(this,e),this.threelayer=a,this.map=a.map,this.layerClass=s;var c=i.thetaLength||45;this.millsec=i.millsec||1e3,this.duration=i.duration||75,this.tilesHoriz=i.tilesHoriz||12,this.tilesVert=i.tilesVert||5,this.numTiles=i.numTiles||49;var h=i.rotation||0,u=c/2,d=a.distanceToVector3(r,r).x,p=Math.sin(u*Math.PI/180)*d*2,m=void 0===i.flag;this.imgUrl=i.imgUrl,this.textureLoader=new n.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){l.texture=e,l.annie=new k(e,l.tilesHoriz,l.tilesVert,l.numTiles,l.duration,m);var r=new n.MeshBasicMaterial({transparent:!0,map:e,side:n.DoubleSide,depthTest:!1});l.imgObj=new T(t,r,{width:p,height:d},a),l.imgObj.object3d.renderOrder=1,l.imgObj.object3d.rotation.z=h*Math.PI/180,l.threelayer.addMesh(l.imgObj),l.layerClass.updatables.push(l)}))}return l(e,[{key:"tick",value:function(e){var t;null===(t=this.annie)||void 0===t||t.update(this.millsec*e)}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.imgObj),this.imgObj.object3d.geometry&&this.imgObj.object3d.geometry.dispose(),this.imgObj.object3d.material&&this.imgObj.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),I={radius:100,altitude:0},S=function(e){c(i,r.BaseObject);var t=p(i);function i(e,r,s,l){var c;o(this,i),r=a.Util.extend({},I,r,{layer:l}),c=t.call(this);var h=r,u=h.width;h.height;var d=h.altitude;c._initOptions(r);var p=new n.CircleGeometry(u,32);c._createMesh(p,s);var m=l.distanceToVector3(d,d).x,f=l.coordinateToVector3(e,m);return c.getObject3d().position.copy(f),c}return l(i)}(),C=function(){function e(t,r,i,a){var s=this;o(this,e),this.threelayer=i,this.map=i.map,this.layerClass=a,this.time=0,i.coordinateToVector3(t,0),this.imgUrl=r.imgUrl,this.textureLoader=new n.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){s.texture=e,s._uniforms={impactPosition:{value:new n.Vector3(0,0,0)},impactMaxRadius:{value:2},impactRatio:{value:.25},map:{value:s.texture}};var r=new n.ShaderMaterial({uniforms:s._uniforms,vertexShader:"\n varying vec3 vPosition;\n varying vec2 vUv;\n void main(){\n vUv = uv;\n vPosition = position;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n uniform vec3 impactPosition;\n uniform float impactMaxRadius;\n uniform float impactRatio;\n varying vec3 vPosition;\n varying vec2 vUv;\n void main() {\n float dist = distance(vPosition, impactPosition);\n float curRadius = impactMaxRadius * impactRatio;\n float sstep = smoothstep(0., curRadius, dist) - smoothstep(curRadius - ( 0.25 * impactRatio ), curRadius, dist);\n sstep = 1. - sstep * (1. - impactRatio);\n vec3 col = mix(vec3(1., 0.5, 0.0625), vec3(1., 0.25, 0.125), impactRatio);\n gl_FragColor = texture2D(map, vUv);\n gl_FragColor = vec4( mix( col, gl_FragColor.rgb, sstep), 1.0 );\n }",side:n.DoubleSide,transparent:!0,depthTest:!1}),a=new S(t,{width:2,height:2},r,i);s.threelayer.addMesh(a),s.layerClass.updatables.push(s)}))}return l(e,[{key:"tick",value:function(e){this.time+=.2*e,this.time%=1,this._uniforms.impactRatio.value=this.time}},{key:"dispose",value:function(){}}]),e}(),R=function(){function e(t,i){var a=this;o(this,e),this.map=i,this.animationId=null,this.updatables=[];var s=v();this.threeLayer=new r.ThreeLayer(s,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new n.Clock;var l=function e(){var t,r;(a.threeLayer._needsUpdate=!a.threeLayer._needsUpdate,a.threeLayer._needsUpdate)&&(null===(t=a.threeLayer)||void 0===t||null===(r=t.getRenderer())||void 0===r||r.clearCanvas(),a.threeLayer.renderScene());var i,n=a.clock.getDelta(),o=f(a.updatables);try{for(o.s();!(i=o.n()).done;){i.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}a.animationId=requestAnimationFrame(e)};this.threeLayer.prepareToDraw=function(e,t,r){var i=new n.DirectionalLight(16777215);i.position.set(0,-10,10).normalize(),t.add(i),l()},this.threeLayer.addTo(i),this.layerId=s,this.layerName=t,this.dirty=!1,this.initFlag=!1}return l(e,[{key:"getLayerId",value:function(){return this.layerId}},{key:"changeLayerId",value:function(){if(this.threeLayer){var e=v();this.threeLayer.setId(e),this.layerId=e}}},{key:"setVisible",value:function(e,t){this.threeLayer&&(!0===e?(this.threeLayer.show(),t&&t()):(this.threeLayer.hide(),t&&t()))}},{key:"prepareToDraw",value:function(){var e=this,t=function t(){var r,i;(e.threeLayer._needsUpdate=!e.threeLayer._needsUpdate,e.threeLayer._needsUpdate)&&(null===(r=e.threeLayer)||void 0===r||null===(i=r.getRenderer())||void 0===i||i.clearCanvas(),e.threeLayer.renderScene());var a,n=e.clock.getDelta(),o=f(e.updatables);try{for(o.s();!(a=o.n()).done;){a.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}e.animationId=requestAnimationFrame(t)};return new Promise((function(r){e.threeLayer.prepareToDraw=function(e,i,a){var o=new n.DirectionalLight(16777215);o.position.set(0,-10,10).normalize(),i.add(o),i.add(new n.AmbientLight(16777215)),t(),r()}}))}},{key:"drawRadar",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new w(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new w(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSector",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new j(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new j(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSectorImg",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new P(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new P(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawImage",value:function(e,t,r,i){var a=this;return new Promise((function(n){if(a.threeLayer.getScene()){var o=new x(e,t,r,i,a.threeLayer);n(o)}else a.initFlag=!0,a.prepareToDraw().then((function(){var o=new x(e,t,r,i,a.threeLayer);n(o)}))}))}},{key:"drawShock",value:function(e,t){var r=this;return new Promise((function(i){if(r.threeLayer.getScene()){var a=new C(e,t||{},r.threeLayer,r);i(a)}else r.initFlag=!0,r.prepareToDraw().then((function(){var a=new C(e,t||{},r.threeLayer,r);i(a)}))}))}},{key:"dispose",value:function(){this.animationId&&cancelAnimationFrame(this.animationId);var e=this.threeLayer.getMeshes();this.threeLayer.clear(),e.forEach((function(e){}));var t=this.threeLayer.getCamera(),r=this.threeLayer.getScene(),i=this.threeLayer.getPick(),a=i.pickingTexture;i.pickingScene;var n=this.threeLayer.getRenderer();r.remove(t),t=null,r=null,a.dispose(),a=null,n.context.dispose(),n.context.forceContextLoss(),n.context=null,n.remove(),n=null,this.map.removeLayer(this.threeLayer)}}]),e}();exports.imgClass=x,exports.layerClass=R,exports.planeSectorClass=P,exports.radarClass=w,exports.sectorClass=j,exports.shockClass=C,exports.sleep=function(e){return new Promise((function(t){return setTimeout(t,e)}))};
@@ -1 +1 @@
1
- import*as e from"maptalks";import*as t from"three";import{BaseObject as r,ThreeLayer as i}from"maptalks.three";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(a=i.key,n=void 0,"symbol"==typeof(n=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?n:String(n)),i)}var a,n}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function h(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=l(e);if(t){var a=l(this).constructor;r=Reflect.construct(i,arguments,a)}else r=i.apply(this,arguments);return h(this,r)}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function m(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw n}}}}function p(){var e="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"iep".concat(e,"layer")}var f={altitude:0,imageWidth:512,imageHeight:512,texture:null},v=function(i){s(l,r);var n=u(l);function l(r,i,o,s){var c;a(this,l);var h=i=e.Util.extend({},f,i),u=h.altitude;h.imageHeight,h.imageWidth,r instanceof e.Extent||(r=new e.Extent(r));var d=r,m=d.xmin,p=d.ymin,v=d.xmax,g=d.ymax,y=1/0,x=1/0,b=-1/0,_=-1/0;[[m,p],[m,g],[v,g],[v,p]].forEach((function(e){var t=s.coordinateToVector3(e),r=t.x,i=t.y;y=Math.min(r,y),x=Math.min(i,x),b=Math.max(r,b),_=Math.max(i,_)}));var w=Math.abs(b-y),M=Math.abs(_-x),L=new t.PlaneBufferGeometry(w,M);(c=n.call(this))._initOptions(i),c._createMesh(L,o);var T=s.distanceToVector3(u,u).x,k=s.coordinateToVector3(r.getCenter(),T);return c.getObject3d().position.copy(k),c.parent=null,c.type="Image",c}return o(l)}(),g=function(){function r(i,n,o,s,l){var c=this;a(this,r),this.threelayer=l,this.map=l.map,this.textureLoader=new t.TextureLoader;var h=i.split(","),u=n.split(","),d=parseFloat(h[0]),m=parseFloat(h[1]),p=parseFloat(u[0]),f=parseFloat(u[1]),g=s.maxZoom||11,y=s.renderOrder||0,x=s.opacity||1,b=s.minZoom||3,_=new e.Extent(d,m,p,f);this.xmin_g=d,this.ymin_g=m,this.xmax_g=p,this.ymax_g=f,this.textureLoader.load(o,(function(e){var r=new t.MeshBasicMaterial({map:e,transparent:!0,opacity:x}),i=new v(_,{imageWidth:512,imageHeight:512,maxZoom:g,minZoom:b,interactive:void 0!==s.interactive&&s.interactive},r,c.threelayer);i.object3d.renderOrder=y,c.imgMesh=i,c.imgMesh.parent=c,c.m=r,c.texture=e,c.threelayer.addMesh(c.imgMesh),s.opacityItems&&s.opacityItems.length>0&&!isNaN(s.opacityItems[0])&&!isNaN(s.opacityItems[1])&&s.opacityItems[0]>3&&s.opacityItems[0]<=18&&s.opacityItems[1]>=0&&s.opacityItems[1]<=1&&(c.opacityItems=s.opacityItems,c._bindMapEvents(),c._viewChange())}))}return o(r,[{key:"_bindMapEvents",value:function(){this.map.on("viewchange",this._viewChange,this)}},{key:"_viewChange",value:function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1}},{key:"_closeEvent",value:function(){this.map.off("viewchange",this._viewChange,this)}},{key:"updateImage",value:function(r,i){var a=this;if(i&&i.leftbottom&&i.righttop){var n=parseFloat(i.leftbottom[0]),o=parseFloat(i.leftbottom[1]),s=parseFloat(i.righttop[0]),l=parseFloat(i.righttop[1]);if(n!==this.xmin_g||o!==this.ymin_g||s!==this.xmax_g||l!==this.ymax_g){var c=new e.Extent(n,o,s,l),h=1/0,u=1/0,d=-1/0,m=-1/0;[[n,o],[n,l],[s,l],[s,o]].forEach((function(e){var t=a.threelayer.coordinateToVector3(e),r=t.x,i=t.y;h=Math.min(r,h),u=Math.min(i,u),d=Math.max(r,d),m=Math.max(i,m)}));for(var p=Math.abs(d-h),f=Math.abs(m-u),v=new t.PlaneBufferGeometry(p,f),g=v.attributes.position.array,y=this.imgMesh.object3d.geometry.attributes.position.array,x=0;x<y.length;x++)y[x]=g[x];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var b=this.threelayer.coordinateToVector3(c.getCenter(),0);this.imgMesh.getObject3d().position.copy(b),v.dispose(),this.xmin_g=n,this.ymin_g=o,this.xmax_g=s,this.ymax_g=l}}this.textureLoader.load(r,(function(e){a.texture&&a.texture.dispose(),delete a.texture,e.magFilter=t.NearestFilter,e.minFilter=t.NearestFilter,a.imgMesh.object3d.material.map=e,a.imgMesh.object3d.material.map.needsUpdate=!0,a.texture=e,!1===a.imgMesh.isAdd&&(a.threelayer.addMesh(a.imgMesh),a.opacityItems&&a._bindMapEvents())}))}},{key:"clearImage",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())}},{key:"dispose",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader}}]),r}(),y={altitude:0,imageWidth:512,imageHeight:512,texture:null},x=function(i){s(l,r);var n=u(l);function l(r,i,o,s,c){var h;a(this,l);var u=(o=e.Util.extend({},y,o)).altitude,d=c.distanceToVector3(i,i).x,m=new t.CircleGeometry(d,32);(h=n.call(this))._initOptions(o),h._createMesh(m,s);var p=c.distanceToVector3(u,u).x,f=c.coordinateToVector3(r,p);return h.getObject3d().position.copy(f),h.parent=null,h.type="radarObject",h}return o(l)}(),b=function(){function e(r,i,n,o,s){a(this,e),this.threelayer=o,this.map=o.map,this.layerClass=s,this.imgUrl=n.imgUrl,this.loader=new t.TextureLoader,this.texture=this.loader.load(this.imgUrl),this._uniforms={map:{value:this.texture},time:{value:0}};var l=new t.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n const float PI = 3.14159265359;\n const float TWO_PI = 6.28318530718;\n const int N = 3;\n const float r0 = 0.01;\n const float r_blue = 0.025;\n const float r_red = 0.015;\n const float edge = 0.95;\n const float offset = 0.05;\n\n uniform float time;\n varying vec2 vUv;\n uniform sampler2D map;\n float plot(const vec2 st, const float pct, const float width)\n {\n return smoothstep(pct - width, pct, st.y) -\n smoothstep(pct, pct + width, st.y);\n }\n float drawPolygon(const vec2 polygonCenter, const int N, const float radius, vec2 pos)\n {\n pos = pos - polygonCenter;\n float d = 0.0;\n float a = atan(pos.x, pos.y);\n float r = TWO_PI / float(N);\n d = cos(floor(0.5 + a / r)*r - a)*length(pos);\n return (1.0 - smoothstep(radius, radius + radius/10.0, d));\n }\n float gradations(const float a, const float gradNum, const float outRad, const float tickLen, const float tickWidth, const float r, const float move)\n {\n float f = step(0.0, cos((a + move)*gradNum) - tickWidth)*tickLen + (outRad - tickLen);\n return 1.0 - step(f, r) * 1.0 - step(r, outRad - tickLen);\n }\n void main() {\n // Normalized pixel coordinates (from 0 to 1)\n vec2 uv = vUv;\n vec2 pos = uv.xy - vec2(0.5, 0.5) ; // center what being drawn\n vec4 grndSpd = vec4(0.0, time/5.0, 0.0, 0.0);\n vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.85, 0.0, 1.0);\n //vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.58, 1.0, 1.0);\n //vec3 color = vec3(0.0, 0.0, 0.0);\n vec3 color = vec3(0.0, 147. / 255., 1.0);\n float r = length(pos) * 2.0;\n float a = atan(pos.y, pos.x); // angle of pixel\n float an = PI - mod(time/ 1.0, TWO_PI); // angle of radar sweep\n float blipSpd = 3.0; // Blip / Trace speed\n vec2 translate1 = vec2(cos(time/ blipSpd), sin(time/ blipSpd));\n vec2 translate2 = vec2(sin(time/ blipSpd), cos(time/ blipSpd));\n vec2 left1 = translate1 * 0.35;\n vec2 right1 = -translate1 * 0.30;\n vec2 left2 = translate2 * 0.15;\n vec2 right2 = -translate2 * 0.25;\n // Radar Sweep\n float sn = step(PI/2.0, an) * step(-PI/2.0, (a + an)) * step(r, edge) * (1.0 - 0.55 * (a + (TWO_PI) - an));\n float sw = step(an, a) * step(r, edge);\n float s_blade = sw * (1.0 - (a - an) * 20.0);\n float s = sw * (1.0 - 0.55 * (a - an));\n s = max(sn,s);\n float se = step(r, edge - 0.05);\n // Center point\n float s1 = smoothstep(edge - 0.00, edge + 0.01, r)* smoothstep(edge + 0.02, edge + 0.01, r);\n // Circular concentric rings\n float s0 = 1.0 - smoothstep(r0 / 2.0, r0, length(pos));\n float smb = (1.0 - smoothstep(0.2, 0.2 + 0.01, length(pos))) * (1.0 - smoothstep(0.2 +0.01, 0.2, length(pos)));\n float smr = (1.0 - smoothstep(0.3, 0.3 + 0.01, length(pos))) * (1.0 - smoothstep(0.3 +0.01, 0.3, length(pos)));\n // Circular concentric gradations\n float gradNum = 120.0;\n float tickWidth = 0.9;\n const float tickLen = 0.04;\n float outRad = edge;\n float move = 0.0;\n float sm = 0.75*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n gradNum = 36.0;\n tickWidth = 0.95;\n outRad = 0.6;\n move = sin(time/10.0);\n smr += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n outRad = 0.4;\n move = cos(time/10.0);\n smb += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n // Radial spoke gradations\n float sr = plot(pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.x, 0.002) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.y, 0.003) * step(r, edge - 0.06);\n sr += plot(-pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr *= 0.75;\n // Blue circular radar blip traces\n vec2 st_trace1 = left2;\n float s_trace1 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1)));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+offset, +offset))));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+2.0 *offset, +2.0 *offset))));\n\n vec2 st_trace2 = right1;\n float s_trace2 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace2)));\n // Red Trianglular radar flight blip trace\n vec2 st_trace3 = left1;\n float st1 = s * (drawPolygon(st_trace3, N, r_red , pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(-offset, -offset), N, r_red, pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(+offset, -offset), N, r_red, pos));\n\n vec2 st_trace4 = right2;\n float st2 = s * (drawPolygon(st_trace4, N, r_red, pos)); \n // Lets add all the bits together and send them to screen\n float s_grn = max(s * mapcol.y, s_blade);\n s_grn = max(s_grn, (s0 + sr + sm));\n s_grn += s1 / 1.5 + smb + smr;\n\n float s_red = st1*2.0 + st2*2.0 + smr;\n \n float s_blue = max(s_trace1 + s_trace2, s_blade) + smb;\n\n if (s_trace1 > 0.0 || s_trace2 > 0.0) { s_blue = max(s, s_blue); s_grn = max(s_grn, s_blue); }\n\n color += vec3(s_red , s_grn, s_blue); \n vec4 texColor = mapcol * s;\n // Output to screen \n gl_FragColor = vec4(color, 0.5);//Set the screen pixel to that color\n }",side:t.DoubleSide,transparent:!0});this.radar=new x(r,i,{},l,o),this.threelayer.addMesh(this.radar),this.layerClass.updatables.push(this)}return o(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.radar),this.radar.object3d.geometry&&this.radar.object3d.geometry.dispose(),this.radar.object3d.material&&this.radar.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),_={radius:100,altitude:0},w=function(i){s(l,r);var n=u(l);function l(r,i,o,s){var c;a(this,l),i=e.Util.extend({},_,i,{layer:s,coordinate:r}),(c=n.call(this))._initOptions(i);var h=i,u=h.altitude,d=h.radius,m=s.distanceToVector3(d,d).x,p=i.thetaStart||0,f=i.thetaLength||90,v=new t.CircleGeometry(m,128,p*Math.PI/180,f*Math.PI/180);c._createMesh(v,o);var g=s.distanceToVector3(u,u).x,y=s.coordinateToVector3(r,g);return c.getObject3d().position.copy(y),c}return o(l)}(),M=function(){function e(r,i,n,o,s){a(this,e),this.threelayer=o,this.map=o.map,this.layerClass=s;var l=n.thetaLength||90,c=n.rotation||0,h=l/2;this.imgUrl=n.imgUrl,this.loader=new t.TextureLoader,this.texture=this.loader.load(this.imgUrl);var u=c-h;u=u<0?u+360:u,this._uniforms={map:{value:this.texture},time:{value:0}};var d=new t.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n varying vec2 vUv;\n void main() {\n vec2 uv = vUv;\n //uv = uv.xy - vec2(0.5, 0.5);\n //gl_FragColor = texture2D(map, uv);\n gl_FragColor = vec4(1.0, 1.0, 1.0, 0.5);\n }",side:t.DoubleSide,transparent:!0,depthTest:!1});this.sector=new w(r,{thetaStart:u,thetaLength:n.thetaLength,radius:i},d,o),this.threelayer.addMesh(this.sector)}return o(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"dispose",value:function(){}}]),e}(),L={altitude:0,height:0},T=function(i){s(l,r);var n=u(l);function l(r,i,o,s){var c;a(this,l),o=e.Util.extend({},L,o,{layer:s}),c=n.call(this);var h=o,u=h.width,d=h.height,m=h.altitude;c._initOptions(o);var p=new t.PlaneGeometry(u,d);p.computeBoundingBox();var f=new t.Mesh(p,i);c._createGroup(),c.getObject3d().add(f);var v=s.distanceToVector3(m,m).x,g=s.coordinateToVector3(r,v);return f.position.set(0,p.boundingBox.max.y,0),c.getObject3d().position.copy(g),c}return o(l)}();function k(e,r,i,a,n,o){this.tilesHorizontal=r,this.tilesVertical=i,this.numberOfTiles=a,e.wrapS=e.wrapT=t.RepeatWrapping,e.repeat.set(1/this.tilesHorizontal,1/this.tilesVertical),this.tileDisplayDuration=n,this.currentDisplayTime=0,this.currentTile=0,this.flag=o,this.update=function(t){for(this.currentDisplayTime+=t;this.currentDisplayTime>this.tileDisplayDuration;){this.currentDisplayTime-=this.tileDisplayDuration,this.currentTile++,this.currentTile==this.numberOfTiles&&(this.currentTile=0);var r=this.currentTile%this.tilesHorizontal;e.offset.x=r/this.tilesHorizontal;var i=Math.floor(this.currentTile/this.tilesHorizontal);this.flag?e.offset.y=this.tilesVertical-i/this.tilesVertical:e.offset.y=1-i/this.tilesVertical-1/this.tilesVertical}}}var j=function(){function e(r,i,n,o,s){var l=this;a(this,e),this.threelayer=o,this.map=o.map,this.layerClass=s;var c=n.thetaLength||45;this.millsec=n.millsec||1e3,this.duration=n.duration||75,this.tilesHoriz=n.tilesHoriz||12,this.tilesVert=n.tilesVert||5,this.numTiles=n.numTiles||49;var h=n.rotation||0,u=c/2,d=o.distanceToVector3(i,i).x,m=Math.sin(u*Math.PI/180)*d*2,p=void 0===n.flag;this.imgUrl=n.imgUrl,this.textureLoader=new t.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){l.texture=e,l.annie=new k(e,l.tilesHoriz,l.tilesVert,l.numTiles,l.duration,p);var i=new t.MeshBasicMaterial({transparent:!0,map:e,side:t.DoubleSide,depthTest:!1});l.imgObj=new T(r,i,{width:m,height:d},o),l.imgObj.object3d.renderOrder=1,l.imgObj.object3d.rotation.z=h*Math.PI/180,l.threelayer.addMesh(l.imgObj),l.layerClass.updatables.push(l)}))}return o(e,[{key:"tick",value:function(e){var t;null===(t=this.annie)||void 0===t||t.update(this.millsec*e)}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.imgObj),this.imgObj.object3d.geometry&&this.imgObj.object3d.geometry.dispose(),this.imgObj.object3d.material&&this.imgObj.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),O={radius:100,altitude:0},P=function(i){s(l,r);var n=u(l);function l(r,i,o,s){var c;a(this,l),i=e.Util.extend({},O,i,{layer:s}),c=n.call(this);var h=i,u=h.width;h.height;var d=h.altitude;c._initOptions(i);var m=new t.CircleGeometry(u,32);c._createMesh(m,o);var p=s.distanceToVector3(d,d).x,f=s.coordinateToVector3(r,p);return c.getObject3d().position.copy(f),c}return o(l)}(),I=function(){function e(r,i,n,o){var s=this;a(this,e),this.threelayer=n,this.map=n.map,this.layerClass=o,this.time=0,n.coordinateToVector3(r,0),this.imgUrl=i.imgUrl,this.textureLoader=new t.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){s.texture=e,s._uniforms={impactPosition:{value:new t.Vector3(0,0,0)},impactMaxRadius:{value:2},impactRatio:{value:.25},map:{value:s.texture}};var i=new t.ShaderMaterial({uniforms:s._uniforms,vertexShader:"\n varying vec3 vPosition;\n varying vec2 vUv;\n void main(){\n vUv = uv;\n vPosition = position;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n uniform vec3 impactPosition;\n uniform float impactMaxRadius;\n uniform float impactRatio;\n varying vec3 vPosition;\n varying vec2 vUv;\n void main() {\n float dist = distance(vPosition, impactPosition);\n float curRadius = impactMaxRadius * impactRatio;\n float sstep = smoothstep(0., curRadius, dist) - smoothstep(curRadius - ( 0.25 * impactRatio ), curRadius, dist);\n sstep = 1. - sstep * (1. - impactRatio);\n vec3 col = mix(vec3(1., 0.5, 0.0625), vec3(1., 0.25, 0.125), impactRatio);\n gl_FragColor = texture2D(map, vUv);\n gl_FragColor = vec4( mix( col, gl_FragColor.rgb, sstep), 1.0 );\n }",side:t.DoubleSide,transparent:!0,depthTest:!1}),a=new P(r,{width:2,height:2},i,n);s.threelayer.addMesh(a),s.layerClass.updatables.push(s)}))}return o(e,[{key:"tick",value:function(e){this.time+=.2*e,this.time%=1,this._uniforms.impactRatio.value=this.time}},{key:"dispose",value:function(){}}]),e}(),S=function(){function e(r,n){var o=this;a(this,e),this.map=n,this.animationId=null,this.updatables=[];var s=p();this.threeLayer=new i(s,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new t.Clock;var l=function e(){var t,r;(o.threeLayer._needsUpdate=!o.threeLayer._needsUpdate,o.threeLayer._needsUpdate)&&(null===(t=o.threeLayer)||void 0===t||null===(r=t.getRenderer())||void 0===r||r.clearCanvas(),o.threeLayer.renderScene());var i,a=o.clock.getDelta(),n=m(o.updatables);try{for(n.s();!(i=n.n()).done;){i.value.tick(a)}}catch(e){n.e(e)}finally{n.f()}o.animationId=requestAnimationFrame(e)};this.threeLayer.prepareToDraw=function(e,r,i){var a=new t.DirectionalLight(16777215);a.position.set(0,-10,10).normalize(),r.add(a),l()},this.threeLayer.addTo(n),this.layerId=s,this.layerName=r,this.dirty=!1,this.initFlag=!1}return o(e,[{key:"getLayerId",value:function(){return this.layerId}},{key:"changeLayerId",value:function(){if(this.threeLayer){var e=p();this.threeLayer.setId(e),this.layerId=e}}},{key:"setVisible",value:function(e,t){this.threeLayer&&(!0===e?(this.threeLayer.show(),t&&t()):(this.threeLayer.hide(),t&&t()))}},{key:"prepareToDraw",value:function(){var e=this,r=function t(){var r,i;(e.threeLayer._needsUpdate=!e.threeLayer._needsUpdate,e.threeLayer._needsUpdate)&&(null===(r=e.threeLayer)||void 0===r||null===(i=r.getRenderer())||void 0===i||i.clearCanvas(),e.threeLayer.renderScene());var a,n=e.clock.getDelta(),o=m(e.updatables);try{for(o.s();!(a=o.n()).done;){a.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}e.animationId=requestAnimationFrame(t)};return new Promise((function(i){e.threeLayer.prepareToDraw=function(e,a,n){var o=new t.DirectionalLight(16777215);o.position.set(0,-10,10).normalize(),a.add(o),a.add(new t.AmbientLight(16777215)),r(),i()}}))}},{key:"drawRadar",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new b(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new b(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSector",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new M(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new M(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSectorImg",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new j(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new j(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawImage",value:function(e,t,r,i){var a=this;return new Promise((function(n){if(a.threeLayer.getScene()){var o=new g(e,t,r,i,a.threeLayer);n(o)}else a.initFlag=!0,a.prepareToDraw().then((function(){var o=new g(e,t,r,i,a.threeLayer);n(o)}))}))}},{key:"drawShock",value:function(e,t){var r=this;return new Promise((function(i){if(r.threeLayer.getScene()){var a=new I(e,t||{},r.threeLayer,r);i(a)}else r.initFlag=!0,r.prepareToDraw().then((function(){var a=new I(e,t||{},r.threeLayer,r);i(a)}))}))}},{key:"dispose",value:function(){this.animationId&&cancelAnimationFrame(this.animationId);var e=this.threeLayer.getMeshes();this.threeLayer.clear(),e.forEach((function(e){}));var t=this.threeLayer.getCamera(),r=this.threeLayer.getScene(),i=this.threeLayer.getPick(),a=i.pickingTexture;i.pickingScene;var n=this.threeLayer.getRenderer();r.remove(t),t=null,r=null,a.dispose(),a=null,n.context.dispose(),n.context.forceContextLoss(),n.context=null,n.remove(),n=null,this.map.removeLayer(this.threeLayer)}}]),e}();export{g as imgClass,S as layerClass,j as planeSectorClass,b as radarClass,M as sectorClass,I as shockClass};
1
+ import*as e from"maptalks";import*as t from"three";import{BaseObject as r,ThreeLayer as i}from"maptalks.three";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(a=i.key,n=void 0,"symbol"==typeof(n=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?n:String(n)),i)}var a,n}function o(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function h(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=l(e);if(t){var a=l(this).constructor;r=Reflect.construct(i,arguments,a)}else r=i.apply(this,arguments);return h(this,r)}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function m(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw n}}}}function p(){var e="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"iep".concat(e,"layer")}function f(e){return new Promise((function(t){return setTimeout(t,e)}))}var v={altitude:0,imageWidth:512,imageHeight:512,texture:null},g=function(i){s(l,r);var n=u(l);function l(r,i,o,s){var c;a(this,l);var h=i=e.Util.extend({},v,i),u=h.altitude;h.imageHeight,h.imageWidth,r instanceof e.Extent||(r=new e.Extent(r));var d=r,m=d.xmin,p=d.ymin,f=d.xmax,g=d.ymax,y=1/0,x=1/0,b=-1/0,_=-1/0;[[m,p],[m,g],[f,g],[f,p]].forEach((function(e){var t=s.coordinateToVector3(e),r=t.x,i=t.y;y=Math.min(r,y),x=Math.min(i,x),b=Math.max(r,b),_=Math.max(i,_)}));var w=Math.abs(b-y),M=Math.abs(_-x),L=new t.PlaneBufferGeometry(w,M);(c=n.call(this))._initOptions(i),c._createMesh(L,o);var T=s.distanceToVector3(u,u).x,k=s.coordinateToVector3(r.getCenter(),T);return c.getObject3d().position.copy(k),c.parent=null,c.type="Image",c}return o(l)}(),y=function(){function r(i,n,o,s,l){var c=this;a(this,r),this.threelayer=l,this.map=l.map,this.textureLoader=new t.TextureLoader;var h=i.split(","),u=n.split(","),d=parseFloat(h[0]),m=parseFloat(h[1]),p=parseFloat(u[0]),f=parseFloat(u[1]),v=s.maxZoom||11,y=s.renderOrder||0,x=s.opacity||1,b=s.minZoom||3,_=new e.Extent(d,m,p,f);this.xmin_g=d,this.ymin_g=m,this.xmax_g=p,this.ymax_g=f,this.textureLoader.load(o,(function(e){var r=new t.MeshBasicMaterial({map:e,transparent:!0,opacity:x}),i=new g(_,{imageWidth:512,imageHeight:512,maxZoom:v,minZoom:b,interactive:void 0!==s.interactive&&s.interactive},r,c.threelayer);i.object3d.renderOrder=y,c.imgMesh=i,c.imgMesh.parent=c,c.m=r,c.texture=e,c.threelayer.addMesh(c.imgMesh),s.opacityItems&&s.opacityItems.length>0&&!isNaN(s.opacityItems[0])&&!isNaN(s.opacityItems[1])&&s.opacityItems[0]>3&&s.opacityItems[0]<=18&&s.opacityItems[1]>=0&&s.opacityItems[1]<=1&&(c.opacityItems=s.opacityItems,c._bindMapEvents(),c._viewChange())}))}return o(r,[{key:"_bindMapEvents",value:function(){this.map.on("viewchange",this._viewChange,this)}},{key:"_viewChange",value:function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1}},{key:"_closeEvent",value:function(){this.map.off("viewchange",this._viewChange,this)}},{key:"updateImage",value:function(r,i){var a=this;if(i&&i.leftbottom&&i.righttop){var n=parseFloat(i.leftbottom[0]),o=parseFloat(i.leftbottom[1]),s=parseFloat(i.righttop[0]),l=parseFloat(i.righttop[1]);if(n!==this.xmin_g||o!==this.ymin_g||s!==this.xmax_g||l!==this.ymax_g){var c=new e.Extent(n,o,s,l),h=1/0,u=1/0,d=-1/0,m=-1/0;[[n,o],[n,l],[s,l],[s,o]].forEach((function(e){var t=a.threelayer.coordinateToVector3(e),r=t.x,i=t.y;h=Math.min(r,h),u=Math.min(i,u),d=Math.max(r,d),m=Math.max(i,m)}));for(var p=Math.abs(d-h),f=Math.abs(m-u),v=new t.PlaneBufferGeometry(p,f),g=v.attributes.position.array,y=this.imgMesh.object3d.geometry.attributes.position.array,x=0;x<y.length;x++)y[x]=g[x];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var b=this.threelayer.coordinateToVector3(c.getCenter(),0);this.imgMesh.getObject3d().position.copy(b),v.dispose(),this.xmin_g=n,this.ymin_g=o,this.xmax_g=s,this.ymax_g=l}}this.textureLoader.load(r,(function(e){a.texture&&a.texture.dispose(),delete a.texture,e.magFilter=t.NearestFilter,e.minFilter=t.NearestFilter,a.imgMesh.object3d.material.map=e,a.imgMesh.object3d.material.map.needsUpdate=!0,a.texture=e,!1===a.imgMesh.isAdd&&a.threelayer&&(a.threelayer.addMesh(a.imgMesh),a.opacityItems&&a._bindMapEvents())}))}},{key:"clearImage",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())}},{key:"dispose",value:function(){this.imgMesh&&(!0===this.imgMesh.isAdd&&this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader}}]),r}(),x={altitude:0,imageWidth:512,imageHeight:512,texture:null},b=function(i){s(l,r);var n=u(l);function l(r,i,o,s,c){var h;a(this,l);var u=(o=e.Util.extend({},x,o)).altitude,d=c.distanceToVector3(i,i).x,m=new t.CircleGeometry(d,32);(h=n.call(this))._initOptions(o),h._createMesh(m,s);var p=c.distanceToVector3(u,u).x,f=c.coordinateToVector3(r,p);return h.getObject3d().position.copy(f),h.parent=null,h.type="radarObject",h}return o(l)}(),_=function(){function e(r,i,n,o,s){a(this,e),this.threelayer=o,this.map=o.map,this.layerClass=s,this.imgUrl=n.imgUrl,this.loader=new t.TextureLoader,this.texture=this.loader.load(this.imgUrl),this._uniforms={map:{value:this.texture},time:{value:0}};var l=new t.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n const float PI = 3.14159265359;\n const float TWO_PI = 6.28318530718;\n const int N = 3;\n const float r0 = 0.01;\n const float r_blue = 0.025;\n const float r_red = 0.015;\n const float edge = 0.95;\n const float offset = 0.05;\n\n uniform float time;\n varying vec2 vUv;\n uniform sampler2D map;\n float plot(const vec2 st, const float pct, const float width)\n {\n return smoothstep(pct - width, pct, st.y) -\n smoothstep(pct, pct + width, st.y);\n }\n float drawPolygon(const vec2 polygonCenter, const int N, const float radius, vec2 pos)\n {\n pos = pos - polygonCenter;\n float d = 0.0;\n float a = atan(pos.x, pos.y);\n float r = TWO_PI / float(N);\n d = cos(floor(0.5 + a / r)*r - a)*length(pos);\n return (1.0 - smoothstep(radius, radius + radius/10.0, d));\n }\n float gradations(const float a, const float gradNum, const float outRad, const float tickLen, const float tickWidth, const float r, const float move)\n {\n float f = step(0.0, cos((a + move)*gradNum) - tickWidth)*tickLen + (outRad - tickLen);\n return 1.0 - step(f, r) * 1.0 - step(r, outRad - tickLen);\n }\n void main() {\n // Normalized pixel coordinates (from 0 to 1)\n vec2 uv = vUv;\n vec2 pos = uv.xy - vec2(0.5, 0.5) ; // center what being drawn\n vec4 grndSpd = vec4(0.0, time/5.0, 0.0, 0.0);\n vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.85, 0.0, 1.0);\n //vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.58, 1.0, 1.0);\n //vec3 color = vec3(0.0, 0.0, 0.0);\n vec3 color = vec3(0.0, 147. / 255., 1.0);\n float r = length(pos) * 2.0;\n float a = atan(pos.y, pos.x); // angle of pixel\n float an = PI - mod(time/ 1.0, TWO_PI); // angle of radar sweep\n float blipSpd = 3.0; // Blip / Trace speed\n vec2 translate1 = vec2(cos(time/ blipSpd), sin(time/ blipSpd));\n vec2 translate2 = vec2(sin(time/ blipSpd), cos(time/ blipSpd));\n vec2 left1 = translate1 * 0.35;\n vec2 right1 = -translate1 * 0.30;\n vec2 left2 = translate2 * 0.15;\n vec2 right2 = -translate2 * 0.25;\n // Radar Sweep\n float sn = step(PI/2.0, an) * step(-PI/2.0, (a + an)) * step(r, edge) * (1.0 - 0.55 * (a + (TWO_PI) - an));\n float sw = step(an, a) * step(r, edge);\n float s_blade = sw * (1.0 - (a - an) * 20.0);\n float s = sw * (1.0 - 0.55 * (a - an));\n s = max(sn,s);\n float se = step(r, edge - 0.05);\n // Center point\n float s1 = smoothstep(edge - 0.00, edge + 0.01, r)* smoothstep(edge + 0.02, edge + 0.01, r);\n // Circular concentric rings\n float s0 = 1.0 - smoothstep(r0 / 2.0, r0, length(pos));\n float smb = (1.0 - smoothstep(0.2, 0.2 + 0.01, length(pos))) * (1.0 - smoothstep(0.2 +0.01, 0.2, length(pos)));\n float smr = (1.0 - smoothstep(0.3, 0.3 + 0.01, length(pos))) * (1.0 - smoothstep(0.3 +0.01, 0.3, length(pos)));\n // Circular concentric gradations\n float gradNum = 120.0;\n float tickWidth = 0.9;\n const float tickLen = 0.04;\n float outRad = edge;\n float move = 0.0;\n float sm = 0.75*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n gradNum = 36.0;\n tickWidth = 0.95;\n outRad = 0.6;\n move = sin(time/10.0);\n smr += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n outRad = 0.4;\n move = cos(time/10.0);\n smb += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n // Radial spoke gradations\n float sr = plot(pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.x, 0.002) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.y, 0.003) * step(r, edge - 0.06);\n sr += plot(-pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr *= 0.75;\n // Blue circular radar blip traces\n vec2 st_trace1 = left2;\n float s_trace1 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1)));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+offset, +offset))));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+2.0 *offset, +2.0 *offset))));\n\n vec2 st_trace2 = right1;\n float s_trace2 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace2)));\n // Red Trianglular radar flight blip trace\n vec2 st_trace3 = left1;\n float st1 = s * (drawPolygon(st_trace3, N, r_red , pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(-offset, -offset), N, r_red, pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(+offset, -offset), N, r_red, pos));\n\n vec2 st_trace4 = right2;\n float st2 = s * (drawPolygon(st_trace4, N, r_red, pos)); \n // Lets add all the bits together and send them to screen\n float s_grn = max(s * mapcol.y, s_blade);\n s_grn = max(s_grn, (s0 + sr + sm));\n s_grn += s1 / 1.5 + smb + smr;\n\n float s_red = st1*2.0 + st2*2.0 + smr;\n \n float s_blue = max(s_trace1 + s_trace2, s_blade) + smb;\n\n if (s_trace1 > 0.0 || s_trace2 > 0.0) { s_blue = max(s, s_blue); s_grn = max(s_grn, s_blue); }\n\n color += vec3(s_red , s_grn, s_blue); \n vec4 texColor = mapcol * s;\n // Output to screen \n gl_FragColor = vec4(color, 0.5);//Set the screen pixel to that color\n }",side:t.DoubleSide,transparent:!0});this.radar=new b(r,i,{},l,o),this.threelayer.addMesh(this.radar),this.layerClass.updatables.push(this)}return o(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.radar),this.radar.object3d.geometry&&this.radar.object3d.geometry.dispose(),this.radar.object3d.material&&this.radar.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),w={radius:100,altitude:0},M=function(i){s(l,r);var n=u(l);function l(r,i,o,s){var c;a(this,l),i=e.Util.extend({},w,i,{layer:s,coordinate:r}),(c=n.call(this))._initOptions(i);var h=i,u=h.altitude,d=h.radius,m=s.distanceToVector3(d,d).x,p=i.thetaStart||0,f=i.thetaLength||90,v=new t.CircleGeometry(m,128,p*Math.PI/180,f*Math.PI/180);c._createMesh(v,o);var g=s.distanceToVector3(u,u).x,y=s.coordinateToVector3(r,g);return c.getObject3d().position.copy(y),c}return o(l)}(),L=function(){function e(r,i,n,o,s){a(this,e),this.threelayer=o,this.map=o.map,this.layerClass=s;var l=n.thetaLength||90,c=n.rotation||0,h=l/2;this.imgUrl=n.imgUrl,this.loader=new t.TextureLoader,this.texture=this.loader.load(this.imgUrl);var u=c-h;u=u<0?u+360:u,this._uniforms={map:{value:this.texture},time:{value:0}};var d=new t.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n varying vec2 vUv;\n void main() {\n vec2 uv = vUv;\n //uv = uv.xy - vec2(0.5, 0.5);\n //gl_FragColor = texture2D(map, uv);\n gl_FragColor = vec4(1.0, 1.0, 1.0, 0.5);\n }",side:t.DoubleSide,transparent:!0,depthTest:!1});this.sector=new M(r,{thetaStart:u,thetaLength:n.thetaLength,radius:i},d,o),this.threelayer.addMesh(this.sector)}return o(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"dispose",value:function(){}}]),e}(),T={altitude:0,height:0},k=function(i){s(l,r);var n=u(l);function l(r,i,o,s){var c;a(this,l),o=e.Util.extend({},T,o,{layer:s}),c=n.call(this);var h=o,u=h.width,d=h.height,m=h.altitude;c._initOptions(o);var p=new t.PlaneGeometry(u,d);p.computeBoundingBox();var f=new t.Mesh(p,i);c._createGroup(),c.getObject3d().add(f);var v=s.distanceToVector3(m,m).x,g=s.coordinateToVector3(r,v);return f.position.set(0,p.boundingBox.max.y,0),c.getObject3d().position.copy(g),c}return o(l)}();function j(e,r,i,a,n,o){this.tilesHorizontal=r,this.tilesVertical=i,this.numberOfTiles=a,e.wrapS=e.wrapT=t.RepeatWrapping,e.repeat.set(1/this.tilesHorizontal,1/this.tilesVertical),this.tileDisplayDuration=n,this.currentDisplayTime=0,this.currentTile=0,this.flag=o,this.update=function(t){for(this.currentDisplayTime+=t;this.currentDisplayTime>this.tileDisplayDuration;){this.currentDisplayTime-=this.tileDisplayDuration,this.currentTile++,this.currentTile==this.numberOfTiles&&(this.currentTile=0);var r=this.currentTile%this.tilesHorizontal;e.offset.x=r/this.tilesHorizontal;var i=Math.floor(this.currentTile/this.tilesHorizontal);this.flag?e.offset.y=this.tilesVertical-i/this.tilesVertical:e.offset.y=1-i/this.tilesVertical-1/this.tilesVertical}}}var O=function(){function e(r,i,n,o,s){var l=this;a(this,e),this.threelayer=o,this.map=o.map,this.layerClass=s;var c=n.thetaLength||45;this.millsec=n.millsec||1e3,this.duration=n.duration||75,this.tilesHoriz=n.tilesHoriz||12,this.tilesVert=n.tilesVert||5,this.numTiles=n.numTiles||49;var h=n.rotation||0,u=c/2,d=o.distanceToVector3(i,i).x,m=Math.sin(u*Math.PI/180)*d*2,p=void 0===n.flag;this.imgUrl=n.imgUrl,this.textureLoader=new t.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){l.texture=e,l.annie=new j(e,l.tilesHoriz,l.tilesVert,l.numTiles,l.duration,p);var i=new t.MeshBasicMaterial({transparent:!0,map:e,side:t.DoubleSide,depthTest:!1});l.imgObj=new k(r,i,{width:m,height:d},o),l.imgObj.object3d.renderOrder=1,l.imgObj.object3d.rotation.z=h*Math.PI/180,l.threelayer.addMesh(l.imgObj),l.layerClass.updatables.push(l)}))}return o(e,[{key:"tick",value:function(e){var t;null===(t=this.annie)||void 0===t||t.update(this.millsec*e)}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.imgObj),this.imgObj.object3d.geometry&&this.imgObj.object3d.geometry.dispose(),this.imgObj.object3d.material&&this.imgObj.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),P={radius:100,altitude:0},I=function(i){s(l,r);var n=u(l);function l(r,i,o,s){var c;a(this,l),i=e.Util.extend({},P,i,{layer:s}),c=n.call(this);var h=i,u=h.width;h.height;var d=h.altitude;c._initOptions(i);var m=new t.CircleGeometry(u,32);c._createMesh(m,o);var p=s.distanceToVector3(d,d).x,f=s.coordinateToVector3(r,p);return c.getObject3d().position.copy(f),c}return o(l)}(),S=function(){function e(r,i,n,o){var s=this;a(this,e),this.threelayer=n,this.map=n.map,this.layerClass=o,this.time=0,n.coordinateToVector3(r,0),this.imgUrl=i.imgUrl,this.textureLoader=new t.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){s.texture=e,s._uniforms={impactPosition:{value:new t.Vector3(0,0,0)},impactMaxRadius:{value:2},impactRatio:{value:.25},map:{value:s.texture}};var i=new t.ShaderMaterial({uniforms:s._uniforms,vertexShader:"\n varying vec3 vPosition;\n varying vec2 vUv;\n void main(){\n vUv = uv;\n vPosition = position;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n uniform vec3 impactPosition;\n uniform float impactMaxRadius;\n uniform float impactRatio;\n varying vec3 vPosition;\n varying vec2 vUv;\n void main() {\n float dist = distance(vPosition, impactPosition);\n float curRadius = impactMaxRadius * impactRatio;\n float sstep = smoothstep(0., curRadius, dist) - smoothstep(curRadius - ( 0.25 * impactRatio ), curRadius, dist);\n sstep = 1. - sstep * (1. - impactRatio);\n vec3 col = mix(vec3(1., 0.5, 0.0625), vec3(1., 0.25, 0.125), impactRatio);\n gl_FragColor = texture2D(map, vUv);\n gl_FragColor = vec4( mix( col, gl_FragColor.rgb, sstep), 1.0 );\n }",side:t.DoubleSide,transparent:!0,depthTest:!1}),a=new I(r,{width:2,height:2},i,n);s.threelayer.addMesh(a),s.layerClass.updatables.push(s)}))}return o(e,[{key:"tick",value:function(e){this.time+=.2*e,this.time%=1,this._uniforms.impactRatio.value=this.time}},{key:"dispose",value:function(){}}]),e}(),C=function(){function e(r,n){var o=this;a(this,e),this.map=n,this.animationId=null,this.updatables=[];var s=p();this.threeLayer=new i(s,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new t.Clock;var l=function e(){var t,r;(o.threeLayer._needsUpdate=!o.threeLayer._needsUpdate,o.threeLayer._needsUpdate)&&(null===(t=o.threeLayer)||void 0===t||null===(r=t.getRenderer())||void 0===r||r.clearCanvas(),o.threeLayer.renderScene());var i,a=o.clock.getDelta(),n=m(o.updatables);try{for(n.s();!(i=n.n()).done;){i.value.tick(a)}}catch(e){n.e(e)}finally{n.f()}o.animationId=requestAnimationFrame(e)};this.threeLayer.prepareToDraw=function(e,r,i){var a=new t.DirectionalLight(16777215);a.position.set(0,-10,10).normalize(),r.add(a),l()},this.threeLayer.addTo(n),this.layerId=s,this.layerName=r,this.dirty=!1,this.initFlag=!1}return o(e,[{key:"getLayerId",value:function(){return this.layerId}},{key:"changeLayerId",value:function(){if(this.threeLayer){var e=p();this.threeLayer.setId(e),this.layerId=e}}},{key:"setVisible",value:function(e,t){this.threeLayer&&(!0===e?(this.threeLayer.show(),t&&t()):(this.threeLayer.hide(),t&&t()))}},{key:"prepareToDraw",value:function(){var e=this,r=function t(){var r,i;(e.threeLayer._needsUpdate=!e.threeLayer._needsUpdate,e.threeLayer._needsUpdate)&&(null===(r=e.threeLayer)||void 0===r||null===(i=r.getRenderer())||void 0===i||i.clearCanvas(),e.threeLayer.renderScene());var a,n=e.clock.getDelta(),o=m(e.updatables);try{for(o.s();!(a=o.n()).done;){a.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}e.animationId=requestAnimationFrame(t)};return new Promise((function(i){e.threeLayer.prepareToDraw=function(e,a,n){var o=new t.DirectionalLight(16777215);o.position.set(0,-10,10).normalize(),a.add(o),a.add(new t.AmbientLight(16777215)),r(),i()}}))}},{key:"drawRadar",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new _(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new _(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSector",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new L(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new L(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSectorImg",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new O(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new O(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawImage",value:function(e,t,r,i){var a=this;return new Promise((function(n){if(a.threeLayer.getScene()){var o=new y(e,t,r,i,a.threeLayer);n(o)}else a.initFlag=!0,a.prepareToDraw().then((function(){var o=new y(e,t,r,i,a.threeLayer);n(o)}))}))}},{key:"drawShock",value:function(e,t){var r=this;return new Promise((function(i){if(r.threeLayer.getScene()){var a=new S(e,t||{},r.threeLayer,r);i(a)}else r.initFlag=!0,r.prepareToDraw().then((function(){var a=new S(e,t||{},r.threeLayer,r);i(a)}))}))}},{key:"dispose",value:function(){this.animationId&&cancelAnimationFrame(this.animationId);var e=this.threeLayer.getMeshes();this.threeLayer.clear(),e.forEach((function(e){}));var t=this.threeLayer.getCamera(),r=this.threeLayer.getScene(),i=this.threeLayer.getPick(),a=i.pickingTexture;i.pickingScene;var n=this.threeLayer.getRenderer();r.remove(t),t=null,r=null,a.dispose(),a=null,n.context.dispose(),n.context.forceContextLoss(),n.context=null,n.remove(),n=null,this.map.removeLayer(this.threeLayer)}}]),e}();export{y as imgClass,C as layerClass,O as planeSectorClass,_ as radarClass,L as sectorClass,S as shockClass,f as sleep};
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("maptalks"),require("three"),require("maptalks.three")):"function"==typeof define&&define.amd?define(["exports","maptalks","three","maptalks.three"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).mapcore=e.mapcore||{},e.maptalks,e.THREE,e.maptalks)}(this,(function(e,t,r,i){function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=a(t),o=a(r);function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(a=i.key,n=void 0,"symbol"==typeof(n=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?n:String(n)),i)}var a,n}function c(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function m(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function p(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=u(e);if(t){var a=u(this).constructor;r=Reflect.construct(i,arguments,a)}else r=i.apply(this,arguments);return m(this,r)}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function v(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw n}}}}function y(){var e="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"iep".concat(e,"layer")}var g={altitude:0,imageWidth:512,imageHeight:512,texture:null},x=function(e){h(r,e);var t=p(r);function r(e,i,a,l){var c;s(this,r);var h=i=n.Util.extend({},g,i),u=h.altitude;h.imageHeight,h.imageWidth,e instanceof n.Extent||(e=new n.Extent(e));var d=e,m=d.xmin,p=d.ymin,f=d.xmax,v=d.ymax,y=1/0,x=1/0,b=-1/0,_=-1/0;[[m,p],[m,v],[f,v],[f,p]].forEach((function(e){var t=l.coordinateToVector3(e),r=t.x,i=t.y;y=Math.min(r,y),x=Math.min(i,x),b=Math.max(r,b),_=Math.max(i,_)}));var w=Math.abs(b-y),M=Math.abs(_-x),L=new o.PlaneBufferGeometry(w,M);(c=t.call(this))._initOptions(i),c._createMesh(L,a);var j=l.distanceToVector3(u,u).x,T=l.coordinateToVector3(e.getCenter(),j);return c.getObject3d().position.copy(T),c.parent=null,c.type="Image",c}return c(r)}(i.BaseObject),b=function(){function e(t,r,i,a,l){var c=this;s(this,e),this.threelayer=l,this.map=l.map,this.textureLoader=new o.TextureLoader;var h=t.split(","),u=r.split(","),d=parseFloat(h[0]),m=parseFloat(h[1]),p=parseFloat(u[0]),f=parseFloat(u[1]),v=a.maxZoom||11,y=a.renderOrder||0,g=a.opacity||1,b=a.minZoom||3,_=new n.Extent(d,m,p,f);this.xmin_g=d,this.ymin_g=m,this.xmax_g=p,this.ymax_g=f,this.textureLoader.load(i,(function(e){var t=new o.MeshBasicMaterial({map:e,transparent:!0,opacity:g}),r=new x(_,{imageWidth:512,imageHeight:512,maxZoom:v,minZoom:b,interactive:void 0!==a.interactive&&a.interactive},t,c.threelayer);r.object3d.renderOrder=y,c.imgMesh=r,c.imgMesh.parent=c,c.m=t,c.texture=e,c.threelayer.addMesh(c.imgMesh),a.opacityItems&&a.opacityItems.length>0&&!isNaN(a.opacityItems[0])&&!isNaN(a.opacityItems[1])&&a.opacityItems[0]>3&&a.opacityItems[0]<=18&&a.opacityItems[1]>=0&&a.opacityItems[1]<=1&&(c.opacityItems=a.opacityItems,c._bindMapEvents(),c._viewChange())}))}return c(e,[{key:"_bindMapEvents",value:function(){this.map.on("viewchange",this._viewChange,this)}},{key:"_viewChange",value:function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1}},{key:"_closeEvent",value:function(){this.map.off("viewchange",this._viewChange,this)}},{key:"updateImage",value:function(e,t){var r=this;if(t&&t.leftbottom&&t.righttop){var i=parseFloat(t.leftbottom[0]),a=parseFloat(t.leftbottom[1]),s=parseFloat(t.righttop[0]),l=parseFloat(t.righttop[1]);if(i!==this.xmin_g||a!==this.ymin_g||s!==this.xmax_g||l!==this.ymax_g){var c=new n.Extent(i,a,s,l),h=1/0,u=1/0,d=-1/0,m=-1/0;[[i,a],[i,l],[s,l],[s,a]].forEach((function(e){var t=r.threelayer.coordinateToVector3(e),i=t.x,a=t.y;h=Math.min(i,h),u=Math.min(a,u),d=Math.max(i,d),m=Math.max(a,m)}));for(var p=Math.abs(d-h),f=Math.abs(m-u),v=new o.PlaneBufferGeometry(p,f),y=v.attributes.position.array,g=this.imgMesh.object3d.geometry.attributes.position.array,x=0;x<g.length;x++)g[x]=y[x];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var b=this.threelayer.coordinateToVector3(c.getCenter(),0);this.imgMesh.getObject3d().position.copy(b),v.dispose(),this.xmin_g=i,this.ymin_g=a,this.xmax_g=s,this.ymax_g=l}}this.textureLoader.load(e,(function(e){r.texture&&r.texture.dispose(),delete r.texture,e.magFilter=o.NearestFilter,e.minFilter=o.NearestFilter,r.imgMesh.object3d.material.map=e,r.imgMesh.object3d.material.map.needsUpdate=!0,r.texture=e,!1===r.imgMesh.isAdd&&(r.threelayer.addMesh(r.imgMesh),r.opacityItems&&r._bindMapEvents())}))}},{key:"clearImage",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())}},{key:"dispose",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader}}]),e}(),_={altitude:0,imageWidth:512,imageHeight:512,texture:null},w=function(e){h(r,e);var t=p(r);function r(e,i,a,l,c){var h;s(this,r);var u=(a=n.Util.extend({},_,a)).altitude,d=c.distanceToVector3(i,i).x,m=new o.CircleGeometry(d,32);(h=t.call(this))._initOptions(a),h._createMesh(m,l);var p=c.distanceToVector3(u,u).x,f=c.coordinateToVector3(e,p);return h.getObject3d().position.copy(f),h.parent=null,h.type="radarObject",h}return c(r)}(i.BaseObject),M=function(){function e(t,r,i,a,n){s(this,e),this.threelayer=a,this.map=a.map,this.layerClass=n,this.imgUrl=i.imgUrl,this.loader=new o.TextureLoader,this.texture=this.loader.load(this.imgUrl),this._uniforms={map:{value:this.texture},time:{value:0}};var l=new o.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n const float PI = 3.14159265359;\n const float TWO_PI = 6.28318530718;\n const int N = 3;\n const float r0 = 0.01;\n const float r_blue = 0.025;\n const float r_red = 0.015;\n const float edge = 0.95;\n const float offset = 0.05;\n\n uniform float time;\n varying vec2 vUv;\n uniform sampler2D map;\n float plot(const vec2 st, const float pct, const float width)\n {\n return smoothstep(pct - width, pct, st.y) -\n smoothstep(pct, pct + width, st.y);\n }\n float drawPolygon(const vec2 polygonCenter, const int N, const float radius, vec2 pos)\n {\n pos = pos - polygonCenter;\n float d = 0.0;\n float a = atan(pos.x, pos.y);\n float r = TWO_PI / float(N);\n d = cos(floor(0.5 + a / r)*r - a)*length(pos);\n return (1.0 - smoothstep(radius, radius + radius/10.0, d));\n }\n float gradations(const float a, const float gradNum, const float outRad, const float tickLen, const float tickWidth, const float r, const float move)\n {\n float f = step(0.0, cos((a + move)*gradNum) - tickWidth)*tickLen + (outRad - tickLen);\n return 1.0 - step(f, r) * 1.0 - step(r, outRad - tickLen);\n }\n void main() {\n // Normalized pixel coordinates (from 0 to 1)\n vec2 uv = vUv;\n vec2 pos = uv.xy - vec2(0.5, 0.5) ; // center what being drawn\n vec4 grndSpd = vec4(0.0, time/5.0, 0.0, 0.0);\n vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.85, 0.0, 1.0);\n //vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.58, 1.0, 1.0);\n //vec3 color = vec3(0.0, 0.0, 0.0);\n vec3 color = vec3(0.0, 147. / 255., 1.0);\n float r = length(pos) * 2.0;\n float a = atan(pos.y, pos.x); // angle of pixel\n float an = PI - mod(time/ 1.0, TWO_PI); // angle of radar sweep\n float blipSpd = 3.0; // Blip / Trace speed\n vec2 translate1 = vec2(cos(time/ blipSpd), sin(time/ blipSpd));\n vec2 translate2 = vec2(sin(time/ blipSpd), cos(time/ blipSpd));\n vec2 left1 = translate1 * 0.35;\n vec2 right1 = -translate1 * 0.30;\n vec2 left2 = translate2 * 0.15;\n vec2 right2 = -translate2 * 0.25;\n // Radar Sweep\n float sn = step(PI/2.0, an) * step(-PI/2.0, (a + an)) * step(r, edge) * (1.0 - 0.55 * (a + (TWO_PI) - an));\n float sw = step(an, a) * step(r, edge);\n float s_blade = sw * (1.0 - (a - an) * 20.0);\n float s = sw * (1.0 - 0.55 * (a - an));\n s = max(sn,s);\n float se = step(r, edge - 0.05);\n // Center point\n float s1 = smoothstep(edge - 0.00, edge + 0.01, r)* smoothstep(edge + 0.02, edge + 0.01, r);\n // Circular concentric rings\n float s0 = 1.0 - smoothstep(r0 / 2.0, r0, length(pos));\n float smb = (1.0 - smoothstep(0.2, 0.2 + 0.01, length(pos))) * (1.0 - smoothstep(0.2 +0.01, 0.2, length(pos)));\n float smr = (1.0 - smoothstep(0.3, 0.3 + 0.01, length(pos))) * (1.0 - smoothstep(0.3 +0.01, 0.3, length(pos)));\n // Circular concentric gradations\n float gradNum = 120.0;\n float tickWidth = 0.9;\n const float tickLen = 0.04;\n float outRad = edge;\n float move = 0.0;\n float sm = 0.75*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n gradNum = 36.0;\n tickWidth = 0.95;\n outRad = 0.6;\n move = sin(time/10.0);\n smr += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n outRad = 0.4;\n move = cos(time/10.0);\n smb += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n // Radial spoke gradations\n float sr = plot(pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.x, 0.002) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.y, 0.003) * step(r, edge - 0.06);\n sr += plot(-pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr *= 0.75;\n // Blue circular radar blip traces\n vec2 st_trace1 = left2;\n float s_trace1 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1)));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+offset, +offset))));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+2.0 *offset, +2.0 *offset))));\n\n vec2 st_trace2 = right1;\n float s_trace2 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace2)));\n // Red Trianglular radar flight blip trace\n vec2 st_trace3 = left1;\n float st1 = s * (drawPolygon(st_trace3, N, r_red , pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(-offset, -offset), N, r_red, pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(+offset, -offset), N, r_red, pos));\n\n vec2 st_trace4 = right2;\n float st2 = s * (drawPolygon(st_trace4, N, r_red, pos)); \n // Lets add all the bits together and send them to screen\n float s_grn = max(s * mapcol.y, s_blade);\n s_grn = max(s_grn, (s0 + sr + sm));\n s_grn += s1 / 1.5 + smb + smr;\n\n float s_red = st1*2.0 + st2*2.0 + smr;\n \n float s_blue = max(s_trace1 + s_trace2, s_blade) + smb;\n\n if (s_trace1 > 0.0 || s_trace2 > 0.0) { s_blue = max(s, s_blue); s_grn = max(s_grn, s_blue); }\n\n color += vec3(s_red , s_grn, s_blue); \n vec4 texColor = mapcol * s;\n // Output to screen \n gl_FragColor = vec4(color, 0.5);//Set the screen pixel to that color\n }",side:o.DoubleSide,transparent:!0});this.radar=new w(t,r,{},l,a),this.threelayer.addMesh(this.radar),this.layerClass.updatables.push(this)}return c(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.radar),this.radar.object3d.geometry&&this.radar.object3d.geometry.dispose(),this.radar.object3d.material&&this.radar.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),L={radius:100,altitude:0},j=function(e){h(r,e);var t=p(r);function r(e,i,a,l){var c;s(this,r),i=n.Util.extend({},L,i,{layer:l,coordinate:e}),(c=t.call(this))._initOptions(i);var h=i,u=h.altitude,d=h.radius,m=l.distanceToVector3(d,d).x,p=i.thetaStart||0,f=i.thetaLength||90,v=new o.CircleGeometry(m,128,p*Math.PI/180,f*Math.PI/180);c._createMesh(v,a);var y=l.distanceToVector3(u,u).x,g=l.coordinateToVector3(e,y);return c.getObject3d().position.copy(g),c}return c(r)}(i.BaseObject),T=function(){function e(t,r,i,a,n){s(this,e),this.threelayer=a,this.map=a.map,this.layerClass=n;var l=i.thetaLength||90,c=i.rotation||0,h=l/2;this.imgUrl=i.imgUrl,this.loader=new o.TextureLoader,this.texture=this.loader.load(this.imgUrl);var u=c-h;u=u<0?u+360:u,this._uniforms={map:{value:this.texture},time:{value:0}};var d=new o.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n varying vec2 vUv;\n void main() {\n vec2 uv = vUv;\n //uv = uv.xy - vec2(0.5, 0.5);\n //gl_FragColor = texture2D(map, uv);\n gl_FragColor = vec4(1.0, 1.0, 1.0, 0.5);\n }",side:o.DoubleSide,transparent:!0,depthTest:!1});this.sector=new j(t,{thetaStart:u,thetaLength:i.thetaLength,radius:r},d,a),this.threelayer.addMesh(this.sector)}return c(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"dispose",value:function(){}}]),e}(),k={altitude:0,height:0},O=function(e){h(r,e);var t=p(r);function r(e,i,a,l){var c;s(this,r),a=n.Util.extend({},k,a,{layer:l}),c=t.call(this);var h=a,u=h.width,d=h.height,m=h.altitude;c._initOptions(a);var p=new o.PlaneGeometry(u,d);p.computeBoundingBox();var f=new o.Mesh(p,i);c._createGroup(),c.getObject3d().add(f);var v=l.distanceToVector3(m,m).x,y=l.coordinateToVector3(e,v);return f.position.set(0,p.boundingBox.max.y,0),c.getObject3d().position.copy(y),c}return c(r)}(i.BaseObject);function P(e,t,r,i,a,n){this.tilesHorizontal=t,this.tilesVertical=r,this.numberOfTiles=i,e.wrapS=e.wrapT=o.RepeatWrapping,e.repeat.set(1/this.tilesHorizontal,1/this.tilesVertical),this.tileDisplayDuration=a,this.currentDisplayTime=0,this.currentTile=0,this.flag=n,this.update=function(t){for(this.currentDisplayTime+=t;this.currentDisplayTime>this.tileDisplayDuration;){this.currentDisplayTime-=this.tileDisplayDuration,this.currentTile++,this.currentTile==this.numberOfTiles&&(this.currentTile=0);var r=this.currentTile%this.tilesHorizontal;e.offset.x=r/this.tilesHorizontal;var i=Math.floor(this.currentTile/this.tilesHorizontal);this.flag?e.offset.y=this.tilesVertical-i/this.tilesVertical:e.offset.y=1-i/this.tilesVertical-1/this.tilesVertical}}}var I=function(){function e(t,r,i,a,n){var l=this;s(this,e),this.threelayer=a,this.map=a.map,this.layerClass=n;var c=i.thetaLength||45;this.millsec=i.millsec||1e3,this.duration=i.duration||75,this.tilesHoriz=i.tilesHoriz||12,this.tilesVert=i.tilesVert||5,this.numTiles=i.numTiles||49;var h=i.rotation||0,u=c/2,d=a.distanceToVector3(r,r).x,m=Math.sin(u*Math.PI/180)*d*2,p=void 0===i.flag;this.imgUrl=i.imgUrl,this.textureLoader=new o.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){l.texture=e,l.annie=new P(e,l.tilesHoriz,l.tilesVert,l.numTiles,l.duration,p);var r=new o.MeshBasicMaterial({transparent:!0,map:e,side:o.DoubleSide,depthTest:!1});l.imgObj=new O(t,r,{width:m,height:d},a),l.imgObj.object3d.renderOrder=1,l.imgObj.object3d.rotation.z=h*Math.PI/180,l.threelayer.addMesh(l.imgObj),l.layerClass.updatables.push(l)}))}return c(e,[{key:"tick",value:function(e){var t;null===(t=this.annie)||void 0===t||t.update(this.millsec*e)}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.imgObj),this.imgObj.object3d.geometry&&this.imgObj.object3d.geometry.dispose(),this.imgObj.object3d.material&&this.imgObj.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),S={radius:100,altitude:0},C=function(e){h(r,e);var t=p(r);function r(e,i,a,l){var c;s(this,r),i=n.Util.extend({},S,i,{layer:l}),c=t.call(this);var h=i,u=h.width;h.height;var d=h.altitude;c._initOptions(i);var m=new o.CircleGeometry(u,32);c._createMesh(m,a);var p=l.distanceToVector3(d,d).x,f=l.coordinateToVector3(e,p);return c.getObject3d().position.copy(f),c}return c(r)}(i.BaseObject),R=function(){function e(t,r,i,a){var n=this;s(this,e),this.threelayer=i,this.map=i.map,this.layerClass=a,this.time=0,i.coordinateToVector3(t,0),this.imgUrl=r.imgUrl,this.textureLoader=new o.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){n.texture=e,n._uniforms={impactPosition:{value:new o.Vector3(0,0,0)},impactMaxRadius:{value:2},impactRatio:{value:.25},map:{value:n.texture}};var r=new o.ShaderMaterial({uniforms:n._uniforms,vertexShader:"\n varying vec3 vPosition;\n varying vec2 vUv;\n void main(){\n vUv = uv;\n vPosition = position;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n uniform vec3 impactPosition;\n uniform float impactMaxRadius;\n uniform float impactRatio;\n varying vec3 vPosition;\n varying vec2 vUv;\n void main() {\n float dist = distance(vPosition, impactPosition);\n float curRadius = impactMaxRadius * impactRatio;\n float sstep = smoothstep(0., curRadius, dist) - smoothstep(curRadius - ( 0.25 * impactRatio ), curRadius, dist);\n sstep = 1. - sstep * (1. - impactRatio);\n vec3 col = mix(vec3(1., 0.5, 0.0625), vec3(1., 0.25, 0.125), impactRatio);\n gl_FragColor = texture2D(map, vUv);\n gl_FragColor = vec4( mix( col, gl_FragColor.rgb, sstep), 1.0 );\n }",side:o.DoubleSide,transparent:!0,depthTest:!1}),a=new C(t,{width:2,height:2},r,i);n.threelayer.addMesh(a),n.layerClass.updatables.push(n)}))}return c(e,[{key:"tick",value:function(e){this.time+=.2*e,this.time%=1,this._uniforms.impactRatio.value=this.time}},{key:"dispose",value:function(){}}]),e}(),U=function(){function e(t,r){var a=this;s(this,e),this.map=r,this.animationId=null,this.updatables=[];var n=y();this.threeLayer=new i.ThreeLayer(n,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new o.Clock;var l=function e(){var t,r;(a.threeLayer._needsUpdate=!a.threeLayer._needsUpdate,a.threeLayer._needsUpdate)&&(null===(t=a.threeLayer)||void 0===t||null===(r=t.getRenderer())||void 0===r||r.clearCanvas(),a.threeLayer.renderScene());var i,n=a.clock.getDelta(),o=v(a.updatables);try{for(o.s();!(i=o.n()).done;){i.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}a.animationId=requestAnimationFrame(e)};this.threeLayer.prepareToDraw=function(e,t,r){var i=new o.DirectionalLight(16777215);i.position.set(0,-10,10).normalize(),t.add(i),l()},this.threeLayer.addTo(r),this.layerId=n,this.layerName=t,this.dirty=!1,this.initFlag=!1}return c(e,[{key:"getLayerId",value:function(){return this.layerId}},{key:"changeLayerId",value:function(){if(this.threeLayer){var e=y();this.threeLayer.setId(e),this.layerId=e}}},{key:"setVisible",value:function(e,t){this.threeLayer&&(!0===e?(this.threeLayer.show(),t&&t()):(this.threeLayer.hide(),t&&t()))}},{key:"prepareToDraw",value:function(){var e=this,t=function t(){var r,i;(e.threeLayer._needsUpdate=!e.threeLayer._needsUpdate,e.threeLayer._needsUpdate)&&(null===(r=e.threeLayer)||void 0===r||null===(i=r.getRenderer())||void 0===i||i.clearCanvas(),e.threeLayer.renderScene());var a,n=e.clock.getDelta(),o=v(e.updatables);try{for(o.s();!(a=o.n()).done;){a.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}e.animationId=requestAnimationFrame(t)};return new Promise((function(r){e.threeLayer.prepareToDraw=function(e,i,a){var n=new o.DirectionalLight(16777215);n.position.set(0,-10,10).normalize(),i.add(n),i.add(new o.AmbientLight(16777215)),t(),r()}}))}},{key:"drawRadar",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new M(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new M(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSector",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new T(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new T(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSectorImg",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new I(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new I(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawImage",value:function(e,t,r,i){var a=this;return new Promise((function(n){if(a.threeLayer.getScene()){var o=new b(e,t,r,i,a.threeLayer);n(o)}else a.initFlag=!0,a.prepareToDraw().then((function(){var o=new b(e,t,r,i,a.threeLayer);n(o)}))}))}},{key:"drawShock",value:function(e,t){var r=this;return new Promise((function(i){if(r.threeLayer.getScene()){var a=new R(e,t||{},r.threeLayer,r);i(a)}else r.initFlag=!0,r.prepareToDraw().then((function(){var a=new R(e,t||{},r.threeLayer,r);i(a)}))}))}},{key:"dispose",value:function(){this.animationId&&cancelAnimationFrame(this.animationId);var e=this.threeLayer.getMeshes();this.threeLayer.clear(),e.forEach((function(e){}));var t=this.threeLayer.getCamera(),r=this.threeLayer.getScene(),i=this.threeLayer.getPick(),a=i.pickingTexture;i.pickingScene;var n=this.threeLayer.getRenderer();r.remove(t),t=null,r=null,a.dispose(),a=null,n.context.dispose(),n.context.forceContextLoss(),n.context=null,n.remove(),n=null,this.map.removeLayer(this.threeLayer)}}]),e}();e.imgClass=b,e.layerClass=U,e.planeSectorClass=I,e.radarClass=M,e.sectorClass=T,e.shockClass=R}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("maptalks"),require("three"),require("maptalks.three")):"function"==typeof define&&define.amd?define(["exports","maptalks","three","maptalks.three"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).mapcore=e.mapcore||{},e.maptalks,e.THREE,e.maptalks)}(this,(function(e,t,r,i){function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=a(t),o=a(r);function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(a=i.key,n=void 0,"symbol"==typeof(n=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?n:String(n)),i)}var a,n}function c(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function m(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function p(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=u(e);if(t){var a=u(this).constructor;r=Reflect.construct(i,arguments,a)}else r=i.apply(this,arguments);return m(this,r)}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function v(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw n}}}}function y(){var e="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"iep".concat(e,"layer")}var g={altitude:0,imageWidth:512,imageHeight:512,texture:null},x=function(e){h(r,e);var t=p(r);function r(e,i,a,l){var c;s(this,r);var h=i=n.Util.extend({},g,i),u=h.altitude;h.imageHeight,h.imageWidth,e instanceof n.Extent||(e=new n.Extent(e));var d=e,m=d.xmin,p=d.ymin,f=d.xmax,v=d.ymax,y=1/0,x=1/0,b=-1/0,_=-1/0;[[m,p],[m,v],[f,v],[f,p]].forEach((function(e){var t=l.coordinateToVector3(e),r=t.x,i=t.y;y=Math.min(r,y),x=Math.min(i,x),b=Math.max(r,b),_=Math.max(i,_)}));var w=Math.abs(b-y),M=Math.abs(_-x),L=new o.PlaneBufferGeometry(w,M);(c=t.call(this))._initOptions(i),c._createMesh(L,a);var j=l.distanceToVector3(u,u).x,T=l.coordinateToVector3(e.getCenter(),j);return c.getObject3d().position.copy(T),c.parent=null,c.type="Image",c}return c(r)}(i.BaseObject),b=function(){function e(t,r,i,a,l){var c=this;s(this,e),this.threelayer=l,this.map=l.map,this.textureLoader=new o.TextureLoader;var h=t.split(","),u=r.split(","),d=parseFloat(h[0]),m=parseFloat(h[1]),p=parseFloat(u[0]),f=parseFloat(u[1]),v=a.maxZoom||11,y=a.renderOrder||0,g=a.opacity||1,b=a.minZoom||3,_=new n.Extent(d,m,p,f);this.xmin_g=d,this.ymin_g=m,this.xmax_g=p,this.ymax_g=f,this.textureLoader.load(i,(function(e){var t=new o.MeshBasicMaterial({map:e,transparent:!0,opacity:g}),r=new x(_,{imageWidth:512,imageHeight:512,maxZoom:v,minZoom:b,interactive:void 0!==a.interactive&&a.interactive},t,c.threelayer);r.object3d.renderOrder=y,c.imgMesh=r,c.imgMesh.parent=c,c.m=t,c.texture=e,c.threelayer.addMesh(c.imgMesh),a.opacityItems&&a.opacityItems.length>0&&!isNaN(a.opacityItems[0])&&!isNaN(a.opacityItems[1])&&a.opacityItems[0]>3&&a.opacityItems[0]<=18&&a.opacityItems[1]>=0&&a.opacityItems[1]<=1&&(c.opacityItems=a.opacityItems,c._bindMapEvents(),c._viewChange())}))}return c(e,[{key:"_bindMapEvents",value:function(){this.map.on("viewchange",this._viewChange,this)}},{key:"_viewChange",value:function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1}},{key:"_closeEvent",value:function(){this.map.off("viewchange",this._viewChange,this)}},{key:"updateImage",value:function(e,t){var r=this;if(t&&t.leftbottom&&t.righttop){var i=parseFloat(t.leftbottom[0]),a=parseFloat(t.leftbottom[1]),s=parseFloat(t.righttop[0]),l=parseFloat(t.righttop[1]);if(i!==this.xmin_g||a!==this.ymin_g||s!==this.xmax_g||l!==this.ymax_g){var c=new n.Extent(i,a,s,l),h=1/0,u=1/0,d=-1/0,m=-1/0;[[i,a],[i,l],[s,l],[s,a]].forEach((function(e){var t=r.threelayer.coordinateToVector3(e),i=t.x,a=t.y;h=Math.min(i,h),u=Math.min(a,u),d=Math.max(i,d),m=Math.max(a,m)}));for(var p=Math.abs(d-h),f=Math.abs(m-u),v=new o.PlaneBufferGeometry(p,f),y=v.attributes.position.array,g=this.imgMesh.object3d.geometry.attributes.position.array,x=0;x<g.length;x++)g[x]=y[x];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var b=this.threelayer.coordinateToVector3(c.getCenter(),0);this.imgMesh.getObject3d().position.copy(b),v.dispose(),this.xmin_g=i,this.ymin_g=a,this.xmax_g=s,this.ymax_g=l}}this.textureLoader.load(e,(function(e){r.texture&&r.texture.dispose(),delete r.texture,e.magFilter=o.NearestFilter,e.minFilter=o.NearestFilter,r.imgMesh.object3d.material.map=e,r.imgMesh.object3d.material.map.needsUpdate=!0,r.texture=e,!1===r.imgMesh.isAdd&&r.threelayer&&(r.threelayer.addMesh(r.imgMesh),r.opacityItems&&r._bindMapEvents())}))}},{key:"clearImage",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())}},{key:"dispose",value:function(){this.imgMesh&&(!0===this.imgMesh.isAdd&&this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader}}]),e}(),_={altitude:0,imageWidth:512,imageHeight:512,texture:null},w=function(e){h(r,e);var t=p(r);function r(e,i,a,l,c){var h;s(this,r);var u=(a=n.Util.extend({},_,a)).altitude,d=c.distanceToVector3(i,i).x,m=new o.CircleGeometry(d,32);(h=t.call(this))._initOptions(a),h._createMesh(m,l);var p=c.distanceToVector3(u,u).x,f=c.coordinateToVector3(e,p);return h.getObject3d().position.copy(f),h.parent=null,h.type="radarObject",h}return c(r)}(i.BaseObject),M=function(){function e(t,r,i,a,n){s(this,e),this.threelayer=a,this.map=a.map,this.layerClass=n,this.imgUrl=i.imgUrl,this.loader=new o.TextureLoader,this.texture=this.loader.load(this.imgUrl),this._uniforms={map:{value:this.texture},time:{value:0}};var l=new o.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n const float PI = 3.14159265359;\n const float TWO_PI = 6.28318530718;\n const int N = 3;\n const float r0 = 0.01;\n const float r_blue = 0.025;\n const float r_red = 0.015;\n const float edge = 0.95;\n const float offset = 0.05;\n\n uniform float time;\n varying vec2 vUv;\n uniform sampler2D map;\n float plot(const vec2 st, const float pct, const float width)\n {\n return smoothstep(pct - width, pct, st.y) -\n smoothstep(pct, pct + width, st.y);\n }\n float drawPolygon(const vec2 polygonCenter, const int N, const float radius, vec2 pos)\n {\n pos = pos - polygonCenter;\n float d = 0.0;\n float a = atan(pos.x, pos.y);\n float r = TWO_PI / float(N);\n d = cos(floor(0.5 + a / r)*r - a)*length(pos);\n return (1.0 - smoothstep(radius, radius + radius/10.0, d));\n }\n float gradations(const float a, const float gradNum, const float outRad, const float tickLen, const float tickWidth, const float r, const float move)\n {\n float f = step(0.0, cos((a + move)*gradNum) - tickWidth)*tickLen + (outRad - tickLen);\n return 1.0 - step(f, r) * 1.0 - step(r, outRad - tickLen);\n }\n void main() {\n // Normalized pixel coordinates (from 0 to 1)\n vec2 uv = vUv;\n vec2 pos = uv.xy - vec2(0.5, 0.5) ; // center what being drawn\n vec4 grndSpd = vec4(0.0, time/5.0, 0.0, 0.0);\n vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.85, 0.0, 1.0);\n //vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.58, 1.0, 1.0);\n //vec3 color = vec3(0.0, 0.0, 0.0);\n vec3 color = vec3(0.0, 147. / 255., 1.0);\n float r = length(pos) * 2.0;\n float a = atan(pos.y, pos.x); // angle of pixel\n float an = PI - mod(time/ 1.0, TWO_PI); // angle of radar sweep\n float blipSpd = 3.0; // Blip / Trace speed\n vec2 translate1 = vec2(cos(time/ blipSpd), sin(time/ blipSpd));\n vec2 translate2 = vec2(sin(time/ blipSpd), cos(time/ blipSpd));\n vec2 left1 = translate1 * 0.35;\n vec2 right1 = -translate1 * 0.30;\n vec2 left2 = translate2 * 0.15;\n vec2 right2 = -translate2 * 0.25;\n // Radar Sweep\n float sn = step(PI/2.0, an) * step(-PI/2.0, (a + an)) * step(r, edge) * (1.0 - 0.55 * (a + (TWO_PI) - an));\n float sw = step(an, a) * step(r, edge);\n float s_blade = sw * (1.0 - (a - an) * 20.0);\n float s = sw * (1.0 - 0.55 * (a - an));\n s = max(sn,s);\n float se = step(r, edge - 0.05);\n // Center point\n float s1 = smoothstep(edge - 0.00, edge + 0.01, r)* smoothstep(edge + 0.02, edge + 0.01, r);\n // Circular concentric rings\n float s0 = 1.0 - smoothstep(r0 / 2.0, r0, length(pos));\n float smb = (1.0 - smoothstep(0.2, 0.2 + 0.01, length(pos))) * (1.0 - smoothstep(0.2 +0.01, 0.2, length(pos)));\n float smr = (1.0 - smoothstep(0.3, 0.3 + 0.01, length(pos))) * (1.0 - smoothstep(0.3 +0.01, 0.3, length(pos)));\n // Circular concentric gradations\n float gradNum = 120.0;\n float tickWidth = 0.9;\n const float tickLen = 0.04;\n float outRad = edge;\n float move = 0.0;\n float sm = 0.75*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n gradNum = 36.0;\n tickWidth = 0.95;\n outRad = 0.6;\n move = sin(time/10.0);\n smr += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n outRad = 0.4;\n move = cos(time/10.0);\n smb += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n // Radial spoke gradations\n float sr = plot(pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.x, 0.002) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.y, 0.003) * step(r, edge - 0.06);\n sr += plot(-pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr *= 0.75;\n // Blue circular radar blip traces\n vec2 st_trace1 = left2;\n float s_trace1 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1)));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+offset, +offset))));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+2.0 *offset, +2.0 *offset))));\n\n vec2 st_trace2 = right1;\n float s_trace2 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace2)));\n // Red Trianglular radar flight blip trace\n vec2 st_trace3 = left1;\n float st1 = s * (drawPolygon(st_trace3, N, r_red , pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(-offset, -offset), N, r_red, pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(+offset, -offset), N, r_red, pos));\n\n vec2 st_trace4 = right2;\n float st2 = s * (drawPolygon(st_trace4, N, r_red, pos)); \n // Lets add all the bits together and send them to screen\n float s_grn = max(s * mapcol.y, s_blade);\n s_grn = max(s_grn, (s0 + sr + sm));\n s_grn += s1 / 1.5 + smb + smr;\n\n float s_red = st1*2.0 + st2*2.0 + smr;\n \n float s_blue = max(s_trace1 + s_trace2, s_blade) + smb;\n\n if (s_trace1 > 0.0 || s_trace2 > 0.0) { s_blue = max(s, s_blue); s_grn = max(s_grn, s_blue); }\n\n color += vec3(s_red , s_grn, s_blue); \n vec4 texColor = mapcol * s;\n // Output to screen \n gl_FragColor = vec4(color, 0.5);//Set the screen pixel to that color\n }",side:o.DoubleSide,transparent:!0});this.radar=new w(t,r,{},l,a),this.threelayer.addMesh(this.radar),this.layerClass.updatables.push(this)}return c(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.radar),this.radar.object3d.geometry&&this.radar.object3d.geometry.dispose(),this.radar.object3d.material&&this.radar.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),L={radius:100,altitude:0},j=function(e){h(r,e);var t=p(r);function r(e,i,a,l){var c;s(this,r),i=n.Util.extend({},L,i,{layer:l,coordinate:e}),(c=t.call(this))._initOptions(i);var h=i,u=h.altitude,d=h.radius,m=l.distanceToVector3(d,d).x,p=i.thetaStart||0,f=i.thetaLength||90,v=new o.CircleGeometry(m,128,p*Math.PI/180,f*Math.PI/180);c._createMesh(v,a);var y=l.distanceToVector3(u,u).x,g=l.coordinateToVector3(e,y);return c.getObject3d().position.copy(g),c}return c(r)}(i.BaseObject),T=function(){function e(t,r,i,a,n){s(this,e),this.threelayer=a,this.map=a.map,this.layerClass=n;var l=i.thetaLength||90,c=i.rotation||0,h=l/2;this.imgUrl=i.imgUrl,this.loader=new o.TextureLoader,this.texture=this.loader.load(this.imgUrl);var u=c-h;u=u<0?u+360:u,this._uniforms={map:{value:this.texture},time:{value:0}};var d=new o.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n varying vec2 vUv;\n void main() {\n vec2 uv = vUv;\n //uv = uv.xy - vec2(0.5, 0.5);\n //gl_FragColor = texture2D(map, uv);\n gl_FragColor = vec4(1.0, 1.0, 1.0, 0.5);\n }",side:o.DoubleSide,transparent:!0,depthTest:!1});this.sector=new j(t,{thetaStart:u,thetaLength:i.thetaLength,radius:r},d,a),this.threelayer.addMesh(this.sector)}return c(e,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"dispose",value:function(){}}]),e}(),k={altitude:0,height:0},O=function(e){h(r,e);var t=p(r);function r(e,i,a,l){var c;s(this,r),a=n.Util.extend({},k,a,{layer:l}),c=t.call(this);var h=a,u=h.width,d=h.height,m=h.altitude;c._initOptions(a);var p=new o.PlaneGeometry(u,d);p.computeBoundingBox();var f=new o.Mesh(p,i);c._createGroup(),c.getObject3d().add(f);var v=l.distanceToVector3(m,m).x,y=l.coordinateToVector3(e,v);return f.position.set(0,p.boundingBox.max.y,0),c.getObject3d().position.copy(y),c}return c(r)}(i.BaseObject);function P(e,t,r,i,a,n){this.tilesHorizontal=t,this.tilesVertical=r,this.numberOfTiles=i,e.wrapS=e.wrapT=o.RepeatWrapping,e.repeat.set(1/this.tilesHorizontal,1/this.tilesVertical),this.tileDisplayDuration=a,this.currentDisplayTime=0,this.currentTile=0,this.flag=n,this.update=function(t){for(this.currentDisplayTime+=t;this.currentDisplayTime>this.tileDisplayDuration;){this.currentDisplayTime-=this.tileDisplayDuration,this.currentTile++,this.currentTile==this.numberOfTiles&&(this.currentTile=0);var r=this.currentTile%this.tilesHorizontal;e.offset.x=r/this.tilesHorizontal;var i=Math.floor(this.currentTile/this.tilesHorizontal);this.flag?e.offset.y=this.tilesVertical-i/this.tilesVertical:e.offset.y=1-i/this.tilesVertical-1/this.tilesVertical}}}var I=function(){function e(t,r,i,a,n){var l=this;s(this,e),this.threelayer=a,this.map=a.map,this.layerClass=n;var c=i.thetaLength||45;this.millsec=i.millsec||1e3,this.duration=i.duration||75,this.tilesHoriz=i.tilesHoriz||12,this.tilesVert=i.tilesVert||5,this.numTiles=i.numTiles||49;var h=i.rotation||0,u=c/2,d=a.distanceToVector3(r,r).x,m=Math.sin(u*Math.PI/180)*d*2,p=void 0===i.flag;this.imgUrl=i.imgUrl,this.textureLoader=new o.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){l.texture=e,l.annie=new P(e,l.tilesHoriz,l.tilesVert,l.numTiles,l.duration,p);var r=new o.MeshBasicMaterial({transparent:!0,map:e,side:o.DoubleSide,depthTest:!1});l.imgObj=new O(t,r,{width:m,height:d},a),l.imgObj.object3d.renderOrder=1,l.imgObj.object3d.rotation.z=h*Math.PI/180,l.threelayer.addMesh(l.imgObj),l.layerClass.updatables.push(l)}))}return c(e,[{key:"tick",value:function(e){var t;null===(t=this.annie)||void 0===t||t.update(this.millsec*e)}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.imgObj),this.imgObj.object3d.geometry&&this.imgObj.object3d.geometry.dispose(),this.imgObj.object3d.material&&this.imgObj.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),e}(),S={radius:100,altitude:0},C=function(e){h(r,e);var t=p(r);function r(e,i,a,l){var c;s(this,r),i=n.Util.extend({},S,i,{layer:l}),c=t.call(this);var h=i,u=h.width;h.height;var d=h.altitude;c._initOptions(i);var m=new o.CircleGeometry(u,32);c._createMesh(m,a);var p=l.distanceToVector3(d,d).x,f=l.coordinateToVector3(e,p);return c.getObject3d().position.copy(f),c}return c(r)}(i.BaseObject),R=function(){function e(t,r,i,a){var n=this;s(this,e),this.threelayer=i,this.map=i.map,this.layerClass=a,this.time=0,i.coordinateToVector3(t,0),this.imgUrl=r.imgUrl,this.textureLoader=new o.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){n.texture=e,n._uniforms={impactPosition:{value:new o.Vector3(0,0,0)},impactMaxRadius:{value:2},impactRatio:{value:.25},map:{value:n.texture}};var r=new o.ShaderMaterial({uniforms:n._uniforms,vertexShader:"\n varying vec3 vPosition;\n varying vec2 vUv;\n void main(){\n vUv = uv;\n vPosition = position;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n uniform vec3 impactPosition;\n uniform float impactMaxRadius;\n uniform float impactRatio;\n varying vec3 vPosition;\n varying vec2 vUv;\n void main() {\n float dist = distance(vPosition, impactPosition);\n float curRadius = impactMaxRadius * impactRatio;\n float sstep = smoothstep(0., curRadius, dist) - smoothstep(curRadius - ( 0.25 * impactRatio ), curRadius, dist);\n sstep = 1. - sstep * (1. - impactRatio);\n vec3 col = mix(vec3(1., 0.5, 0.0625), vec3(1., 0.25, 0.125), impactRatio);\n gl_FragColor = texture2D(map, vUv);\n gl_FragColor = vec4( mix( col, gl_FragColor.rgb, sstep), 1.0 );\n }",side:o.DoubleSide,transparent:!0,depthTest:!1}),a=new C(t,{width:2,height:2},r,i);n.threelayer.addMesh(a),n.layerClass.updatables.push(n)}))}return c(e,[{key:"tick",value:function(e){this.time+=.2*e,this.time%=1,this._uniforms.impactRatio.value=this.time}},{key:"dispose",value:function(){}}]),e}(),U=function(){function e(t,r){var a=this;s(this,e),this.map=r,this.animationId=null,this.updatables=[];var n=y();this.threeLayer=new i.ThreeLayer(n,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new o.Clock;var l=function e(){var t,r;(a.threeLayer._needsUpdate=!a.threeLayer._needsUpdate,a.threeLayer._needsUpdate)&&(null===(t=a.threeLayer)||void 0===t||null===(r=t.getRenderer())||void 0===r||r.clearCanvas(),a.threeLayer.renderScene());var i,n=a.clock.getDelta(),o=v(a.updatables);try{for(o.s();!(i=o.n()).done;){i.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}a.animationId=requestAnimationFrame(e)};this.threeLayer.prepareToDraw=function(e,t,r){var i=new o.DirectionalLight(16777215);i.position.set(0,-10,10).normalize(),t.add(i),l()},this.threeLayer.addTo(r),this.layerId=n,this.layerName=t,this.dirty=!1,this.initFlag=!1}return c(e,[{key:"getLayerId",value:function(){return this.layerId}},{key:"changeLayerId",value:function(){if(this.threeLayer){var e=y();this.threeLayer.setId(e),this.layerId=e}}},{key:"setVisible",value:function(e,t){this.threeLayer&&(!0===e?(this.threeLayer.show(),t&&t()):(this.threeLayer.hide(),t&&t()))}},{key:"prepareToDraw",value:function(){var e=this,t=function t(){var r,i;(e.threeLayer._needsUpdate=!e.threeLayer._needsUpdate,e.threeLayer._needsUpdate)&&(null===(r=e.threeLayer)||void 0===r||null===(i=r.getRenderer())||void 0===i||i.clearCanvas(),e.threeLayer.renderScene());var a,n=e.clock.getDelta(),o=v(e.updatables);try{for(o.s();!(a=o.n()).done;){a.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}e.animationId=requestAnimationFrame(t)};return new Promise((function(r){e.threeLayer.prepareToDraw=function(e,i,a){var n=new o.DirectionalLight(16777215);n.position.set(0,-10,10).normalize(),i.add(n),i.add(new o.AmbientLight(16777215)),t(),r()}}))}},{key:"drawRadar",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new M(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new M(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSector",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new T(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new T(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSectorImg",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new I(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new I(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawImage",value:function(e,t,r,i){var a=this;return new Promise((function(n){if(a.threeLayer.getScene()){var o=new b(e,t,r,i,a.threeLayer);n(o)}else a.initFlag=!0,a.prepareToDraw().then((function(){var o=new b(e,t,r,i,a.threeLayer);n(o)}))}))}},{key:"drawShock",value:function(e,t){var r=this;return new Promise((function(i){if(r.threeLayer.getScene()){var a=new R(e,t||{},r.threeLayer,r);i(a)}else r.initFlag=!0,r.prepareToDraw().then((function(){var a=new R(e,t||{},r.threeLayer,r);i(a)}))}))}},{key:"dispose",value:function(){this.animationId&&cancelAnimationFrame(this.animationId);var e=this.threeLayer.getMeshes();this.threeLayer.clear(),e.forEach((function(e){}));var t=this.threeLayer.getCamera(),r=this.threeLayer.getScene(),i=this.threeLayer.getPick(),a=i.pickingTexture;i.pickingScene;var n=this.threeLayer.getRenderer();r.remove(t),t=null,r=null,a.dispose(),a=null,n.context.dispose(),n.context.forceContextLoss(),n.context=null,n.remove(),n=null,this.map.removeLayer(this.threeLayer)}}]),e}();e.imgClass=b,e.layerClass=U,e.planeSectorClass=I,e.radarClass=M,e.sectorClass=T,e.shockClass=R,e.sleep=function(e){return new Promise((function(t){return setTimeout(t,e)}))}}));
@@ -1 +1 @@
1
- function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,(i=a.key,n=void 0,"symbol"==typeof(n=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(i,"string"))?n:String(n)),a)}var i,n}function r(e,r,a){return r&&t(e.prototype,r),a&&t(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&n(e,t)}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function n(e,t){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n(e,t)}function o(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,a=i(e);if(t){var n=i(this).constructor;r=Reflect.construct(a,arguments,n)}else r=a.apply(this,arguments);return o(this,r)}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r<t;r++)a[r]=e[r];return a}function c(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var a=0,i=function(){};return{s:i,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw n}}}}function h(){var e="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"iep".concat(e,"layer")}var u={altitude:0,imageWidth:512,imageHeight:512,texture:null},d=function(t){a(n,maptalks.BaseObject);var i=s(n);function n(t,r,a,o){var s;e(this,n);var l=r=maptalks.Util.extend({},u,r),c=l.altitude;l.imageHeight,l.imageWidth,t instanceof maptalks.Extent||(t=new maptalks.Extent(t));var h=t,d=h.xmin,m=h.ymin,p=h.xmax,f=h.ymax,v=1/0,g=1/0,y=-1/0,x=-1/0;[[d,m],[d,f],[p,f],[p,m]].forEach((function(e){var t=o.coordinateToVector3(e),r=t.x,a=t.y;v=Math.min(r,v),g=Math.min(a,g),y=Math.max(r,y),x=Math.max(a,x)}));var b=Math.abs(y-v),_=Math.abs(x-g),w=new THREE.PlaneBufferGeometry(b,_);(s=i.call(this))._initOptions(r),s._createMesh(w,a);var T=o.distanceToVector3(c,c).x,M=o.coordinateToVector3(t.getCenter(),T);return s.getObject3d().position.copy(M),s.parent=null,s.type="Image",s}return r(n)}(),m=function(){function t(r,a,i,n,o){var s=this;e(this,t),this.threelayer=o,this.map=o.map,this.textureLoader=new THREE.TextureLoader;var l=r.split(","),c=a.split(","),h=parseFloat(l[0]),u=parseFloat(l[1]),m=parseFloat(c[0]),p=parseFloat(c[1]),f=n.maxZoom||11,v=n.renderOrder||0,g=n.opacity||1,y=n.minZoom||3,x=new maptalks.Extent(h,u,m,p);this.xmin_g=h,this.ymin_g=u,this.xmax_g=m,this.ymax_g=p,this.textureLoader.load(i,(function(e){var t=new THREE.MeshBasicMaterial({map:e,transparent:!0,opacity:g}),r=new d(x,{imageWidth:512,imageHeight:512,maxZoom:f,minZoom:y,interactive:void 0!==n.interactive&&n.interactive},t,s.threelayer);r.object3d.renderOrder=v,s.imgMesh=r,s.imgMesh.parent=s,s.m=t,s.texture=e,s.threelayer.addMesh(s.imgMesh),n.opacityItems&&n.opacityItems.length>0&&!isNaN(n.opacityItems[0])&&!isNaN(n.opacityItems[1])&&n.opacityItems[0]>3&&n.opacityItems[0]<=18&&n.opacityItems[1]>=0&&n.opacityItems[1]<=1&&(s.opacityItems=n.opacityItems,s._bindMapEvents(),s._viewChange())}))}return r(t,[{key:"_bindMapEvents",value:function(){this.map.on("viewchange",this._viewChange,this)}},{key:"_viewChange",value:function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1}},{key:"_closeEvent",value:function(){this.map.off("viewchange",this._viewChange,this)}},{key:"updateImage",value:function(e,t){var r=this;if(t&&t.leftbottom&&t.righttop){var a=parseFloat(t.leftbottom[0]),i=parseFloat(t.leftbottom[1]),n=parseFloat(t.righttop[0]),o=parseFloat(t.righttop[1]);if(a!==this.xmin_g||i!==this.ymin_g||n!==this.xmax_g||o!==this.ymax_g){var s=new maptalks.Extent(a,i,n,o),l=1/0,c=1/0,h=-1/0,u=-1/0;[[a,i],[a,o],[n,o],[n,i]].forEach((function(e){var t=r.threelayer.coordinateToVector3(e),a=t.x,i=t.y;l=Math.min(a,l),c=Math.min(i,c),h=Math.max(a,h),u=Math.max(i,u)}));for(var d=Math.abs(h-l),m=Math.abs(u-c),p=new THREE.PlaneBufferGeometry(d,m),f=p.attributes.position.array,v=this.imgMesh.object3d.geometry.attributes.position.array,g=0;g<v.length;g++)v[g]=f[g];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var y=this.threelayer.coordinateToVector3(s.getCenter(),0);this.imgMesh.getObject3d().position.copy(y),p.dispose(),this.xmin_g=a,this.ymin_g=i,this.xmax_g=n,this.ymax_g=o}}this.textureLoader.load(e,(function(e){r.texture&&r.texture.dispose(),delete r.texture,e.magFilter=THREE.NearestFilter,e.minFilter=THREE.NearestFilter,r.imgMesh.object3d.material.map=e,r.imgMesh.object3d.material.map.needsUpdate=!0,r.texture=e,!1===r.imgMesh.isAdd&&(r.threelayer.addMesh(r.imgMesh),r.opacityItems&&r._bindMapEvents())}))}},{key:"clearImage",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())}},{key:"dispose",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader}}]),t}(),p={altitude:0,imageWidth:512,imageHeight:512,texture:null},f=function(t){a(n,maptalks.BaseObject);var i=s(n);function n(t,r,a,o,s){var l;e(this,n);var c=(a=maptalks.Util.extend({},p,a)).altitude,h=s.distanceToVector3(r,r).x,u=new THREE.CircleGeometry(h,32);(l=i.call(this))._initOptions(a),l._createMesh(u,o);var d=s.distanceToVector3(c,c).x,m=s.coordinateToVector3(t,d);return l.getObject3d().position.copy(m),l.parent=null,l.type="radarObject",l}return r(n)}(),v=function(){function t(r,a,i,n,o){e(this,t),this.threelayer=n,this.map=n.map,this.layerClass=o,this.imgUrl=i.imgUrl,this.loader=new THREE.TextureLoader,this.texture=this.loader.load(this.imgUrl),this._uniforms={map:{value:this.texture},time:{value:0}};var s=new THREE.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n const float PI = 3.14159265359;\n const float TWO_PI = 6.28318530718;\n const int N = 3;\n const float r0 = 0.01;\n const float r_blue = 0.025;\n const float r_red = 0.015;\n const float edge = 0.95;\n const float offset = 0.05;\n\n uniform float time;\n varying vec2 vUv;\n uniform sampler2D map;\n float plot(const vec2 st, const float pct, const float width)\n {\n return smoothstep(pct - width, pct, st.y) -\n smoothstep(pct, pct + width, st.y);\n }\n float drawPolygon(const vec2 polygonCenter, const int N, const float radius, vec2 pos)\n {\n pos = pos - polygonCenter;\n float d = 0.0;\n float a = atan(pos.x, pos.y);\n float r = TWO_PI / float(N);\n d = cos(floor(0.5 + a / r)*r - a)*length(pos);\n return (1.0 - smoothstep(radius, radius + radius/10.0, d));\n }\n float gradations(const float a, const float gradNum, const float outRad, const float tickLen, const float tickWidth, const float r, const float move)\n {\n float f = step(0.0, cos((a + move)*gradNum) - tickWidth)*tickLen + (outRad - tickLen);\n return 1.0 - step(f, r) * 1.0 - step(r, outRad - tickLen);\n }\n void main() {\n // Normalized pixel coordinates (from 0 to 1)\n vec2 uv = vUv;\n vec2 pos = uv.xy - vec2(0.5, 0.5) ; // center what being drawn\n vec4 grndSpd = vec4(0.0, time/5.0, 0.0, 0.0);\n vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.85, 0.0, 1.0);\n //vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.58, 1.0, 1.0);\n //vec3 color = vec3(0.0, 0.0, 0.0);\n vec3 color = vec3(0.0, 147. / 255., 1.0);\n float r = length(pos) * 2.0;\n float a = atan(pos.y, pos.x); // angle of pixel\n float an = PI - mod(time/ 1.0, TWO_PI); // angle of radar sweep\n float blipSpd = 3.0; // Blip / Trace speed\n vec2 translate1 = vec2(cos(time/ blipSpd), sin(time/ blipSpd));\n vec2 translate2 = vec2(sin(time/ blipSpd), cos(time/ blipSpd));\n vec2 left1 = translate1 * 0.35;\n vec2 right1 = -translate1 * 0.30;\n vec2 left2 = translate2 * 0.15;\n vec2 right2 = -translate2 * 0.25;\n // Radar Sweep\n float sn = step(PI/2.0, an) * step(-PI/2.0, (a + an)) * step(r, edge) * (1.0 - 0.55 * (a + (TWO_PI) - an));\n float sw = step(an, a) * step(r, edge);\n float s_blade = sw * (1.0 - (a - an) * 20.0);\n float s = sw * (1.0 - 0.55 * (a - an));\n s = max(sn,s);\n float se = step(r, edge - 0.05);\n // Center point\n float s1 = smoothstep(edge - 0.00, edge + 0.01, r)* smoothstep(edge + 0.02, edge + 0.01, r);\n // Circular concentric rings\n float s0 = 1.0 - smoothstep(r0 / 2.0, r0, length(pos));\n float smb = (1.0 - smoothstep(0.2, 0.2 + 0.01, length(pos))) * (1.0 - smoothstep(0.2 +0.01, 0.2, length(pos)));\n float smr = (1.0 - smoothstep(0.3, 0.3 + 0.01, length(pos))) * (1.0 - smoothstep(0.3 +0.01, 0.3, length(pos)));\n // Circular concentric gradations\n float gradNum = 120.0;\n float tickWidth = 0.9;\n const float tickLen = 0.04;\n float outRad = edge;\n float move = 0.0;\n float sm = 0.75*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n gradNum = 36.0;\n tickWidth = 0.95;\n outRad = 0.6;\n move = sin(time/10.0);\n smr += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n outRad = 0.4;\n move = cos(time/10.0);\n smb += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n // Radial spoke gradations\n float sr = plot(pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.x, 0.002) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.y, 0.003) * step(r, edge - 0.06);\n sr += plot(-pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr *= 0.75;\n // Blue circular radar blip traces\n vec2 st_trace1 = left2;\n float s_trace1 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1)));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+offset, +offset))));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+2.0 *offset, +2.0 *offset))));\n\n vec2 st_trace2 = right1;\n float s_trace2 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace2)));\n // Red Trianglular radar flight blip trace\n vec2 st_trace3 = left1;\n float st1 = s * (drawPolygon(st_trace3, N, r_red , pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(-offset, -offset), N, r_red, pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(+offset, -offset), N, r_red, pos));\n\n vec2 st_trace4 = right2;\n float st2 = s * (drawPolygon(st_trace4, N, r_red, pos)); \n // Lets add all the bits together and send them to screen\n float s_grn = max(s * mapcol.y, s_blade);\n s_grn = max(s_grn, (s0 + sr + sm));\n s_grn += s1 / 1.5 + smb + smr;\n\n float s_red = st1*2.0 + st2*2.0 + smr;\n \n float s_blue = max(s_trace1 + s_trace2, s_blade) + smb;\n\n if (s_trace1 > 0.0 || s_trace2 > 0.0) { s_blue = max(s, s_blue); s_grn = max(s_grn, s_blue); }\n\n color += vec3(s_red , s_grn, s_blue); \n vec4 texColor = mapcol * s;\n // Output to screen \n gl_FragColor = vec4(color, 0.5);//Set the screen pixel to that color\n }",side:THREE.DoubleSide,transparent:!0});this.radar=new f(r,a,{},s,n),this.threelayer.addMesh(this.radar),this.layerClass.updatables.push(this)}return r(t,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.radar),this.radar.object3d.geometry&&this.radar.object3d.geometry.dispose(),this.radar.object3d.material&&this.radar.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),t}(),g={radius:100,altitude:0},y=function(t){a(n,maptalks.BaseObject);var i=s(n);function n(t,r,a,o){var s;e(this,n),r=maptalks.Util.extend({},g,r,{layer:o,coordinate:t}),(s=i.call(this))._initOptions(r);var l=r,c=l.altitude,h=l.radius,u=o.distanceToVector3(h,h).x,d=r.thetaStart||0,m=r.thetaLength||90,p=new THREE.CircleGeometry(u,128,d*Math.PI/180,m*Math.PI/180);s._createMesh(p,a);var f=o.distanceToVector3(c,c).x,v=o.coordinateToVector3(t,f);return s.getObject3d().position.copy(v),s}return r(n)}(),x=function(){function t(r,a,i,n,o){e(this,t),this.threelayer=n,this.map=n.map,this.layerClass=o;var s=i.thetaLength||90,l=i.rotation||0,c=s/2;this.imgUrl=i.imgUrl,this.loader=new THREE.TextureLoader,this.texture=this.loader.load(this.imgUrl);var h=l-c;h=h<0?h+360:h,this._uniforms={map:{value:this.texture},time:{value:0}};var u=new THREE.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n varying vec2 vUv;\n void main() {\n vec2 uv = vUv;\n //uv = uv.xy - vec2(0.5, 0.5);\n //gl_FragColor = texture2D(map, uv);\n gl_FragColor = vec4(1.0, 1.0, 1.0, 0.5);\n }",side:THREE.DoubleSide,transparent:!0,depthTest:!1});this.sector=new y(r,{thetaStart:h,thetaLength:i.thetaLength,radius:a},u,n),this.threelayer.addMesh(this.sector)}return r(t,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"dispose",value:function(){}}]),t}(),b={altitude:0,height:0},_=function(t){a(n,maptalks.BaseObject);var i=s(n);function n(t,r,a,o){var s;e(this,n),a=maptalks.Util.extend({},b,a,{layer:o}),s=i.call(this);var l=a,c=l.width,h=l.height,u=l.altitude;s._initOptions(a);var d=new THREE.PlaneGeometry(c,h);d.computeBoundingBox();var m=new THREE.Mesh(d,r);s._createGroup(),s.getObject3d().add(m);var p=o.distanceToVector3(u,u).x,f=o.coordinateToVector3(t,p);return m.position.set(0,d.boundingBox.max.y,0),s.getObject3d().position.copy(f),s}return r(n)}();function w(e,t,r,a,i,n){this.tilesHorizontal=t,this.tilesVertical=r,this.numberOfTiles=a,e.wrapS=e.wrapT=THREE.RepeatWrapping,e.repeat.set(1/this.tilesHorizontal,1/this.tilesVertical),this.tileDisplayDuration=i,this.currentDisplayTime=0,this.currentTile=0,this.flag=n,this.update=function(t){for(this.currentDisplayTime+=t;this.currentDisplayTime>this.tileDisplayDuration;){this.currentDisplayTime-=this.tileDisplayDuration,this.currentTile++,this.currentTile==this.numberOfTiles&&(this.currentTile=0);var r=this.currentTile%this.tilesHorizontal;e.offset.x=r/this.tilesHorizontal;var a=Math.floor(this.currentTile/this.tilesHorizontal);this.flag?e.offset.y=this.tilesVertical-a/this.tilesVertical:e.offset.y=1-a/this.tilesVertical-1/this.tilesVertical}}}var T=function(){function t(r,a,i,n,o){var s=this;e(this,t),this.threelayer=n,this.map=n.map,this.layerClass=o;var l=i.thetaLength||45;this.millsec=i.millsec||1e3,this.duration=i.duration||75,this.tilesHoriz=i.tilesHoriz||12,this.tilesVert=i.tilesVert||5,this.numTiles=i.numTiles||49;var c=i.rotation||0,h=l/2,u=n.distanceToVector3(a,a).x,d=Math.sin(h*Math.PI/180)*u*2,m=void 0===i.flag;this.imgUrl=i.imgUrl,this.textureLoader=new THREE.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){s.texture=e,s.annie=new w(e,s.tilesHoriz,s.tilesVert,s.numTiles,s.duration,m);var t=new THREE.MeshBasicMaterial({transparent:!0,map:e,side:THREE.DoubleSide,depthTest:!1});s.imgObj=new _(r,t,{width:d,height:u},n),s.imgObj.object3d.renderOrder=1,s.imgObj.object3d.rotation.z=c*Math.PI/180,s.threelayer.addMesh(s.imgObj),s.layerClass.updatables.push(s)}))}return r(t,[{key:"tick",value:function(e){var t;null===(t=this.annie)||void 0===t||t.update(this.millsec*e)}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.imgObj),this.imgObj.object3d.geometry&&this.imgObj.object3d.geometry.dispose(),this.imgObj.object3d.material&&this.imgObj.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),t}(),M={radius:100,altitude:0},E=function(t){a(n,maptalks.BaseObject);var i=s(n);function n(t,r,a,o){var s;e(this,n),r=maptalks.Util.extend({},M,r,{layer:o}),s=i.call(this);var l=r,c=l.width;l.height;var h=l.altitude;s._initOptions(r);var u=new THREE.CircleGeometry(c,32);s._createMesh(u,a);var d=o.distanceToVector3(h,h).x,m=o.coordinateToVector3(t,d);return s.getObject3d().position.copy(m),s}return r(n)}(),L=function(){function t(r,a,i,n){var o=this;e(this,t),this.threelayer=i,this.map=i.map,this.layerClass=n,this.time=0,i.coordinateToVector3(r,0),this.imgUrl=a.imgUrl,this.textureLoader=new THREE.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){o.texture=e,o._uniforms={impactPosition:{value:new THREE.Vector3(0,0,0)},impactMaxRadius:{value:2},impactRatio:{value:.25},map:{value:o.texture}};var t=new THREE.ShaderMaterial({uniforms:o._uniforms,vertexShader:"\n varying vec3 vPosition;\n varying vec2 vUv;\n void main(){\n vUv = uv;\n vPosition = position;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n uniform vec3 impactPosition;\n uniform float impactMaxRadius;\n uniform float impactRatio;\n varying vec3 vPosition;\n varying vec2 vUv;\n void main() {\n float dist = distance(vPosition, impactPosition);\n float curRadius = impactMaxRadius * impactRatio;\n float sstep = smoothstep(0., curRadius, dist) - smoothstep(curRadius - ( 0.25 * impactRatio ), curRadius, dist);\n sstep = 1. - sstep * (1. - impactRatio);\n vec3 col = mix(vec3(1., 0.5, 0.0625), vec3(1., 0.25, 0.125), impactRatio);\n gl_FragColor = texture2D(map, vUv);\n gl_FragColor = vec4( mix( col, gl_FragColor.rgb, sstep), 1.0 );\n }",side:THREE.DoubleSide,transparent:!0,depthTest:!1}),a=new E(r,{width:2,height:2},t,i);o.threelayer.addMesh(a),o.layerClass.updatables.push(o)}))}return r(t,[{key:"tick",value:function(e){this.time+=.2*e,this.time%=1,this._uniforms.impactRatio.value=this.time}},{key:"dispose",value:function(){}}]),t}(),k=function(){function t(r,a){var i=this;e(this,t),this.map=a,this.animationId=null,this.updatables=[];var n=h();this.threeLayer=new maptalks.ThreeLayer(n,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new THREE.Clock;var o=function e(){var t,r;(i.threeLayer._needsUpdate=!i.threeLayer._needsUpdate,i.threeLayer._needsUpdate)&&(null===(t=i.threeLayer)||void 0===t||null===(r=t.getRenderer())||void 0===r||r.clearCanvas(),i.threeLayer.renderScene());var a,n=i.clock.getDelta(),o=c(i.updatables);try{for(o.s();!(a=o.n()).done;){a.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}i.animationId=requestAnimationFrame(e)};this.threeLayer.prepareToDraw=function(e,t,r){var a=new THREE.DirectionalLight(16777215);a.position.set(0,-10,10).normalize(),t.add(a),o()},this.threeLayer.addTo(a),this.layerId=n,this.layerName=r,this.dirty=!1,this.initFlag=!1}return r(t,[{key:"getLayerId",value:function(){return this.layerId}},{key:"changeLayerId",value:function(){if(this.threeLayer){var e=h();this.threeLayer.setId(e),this.layerId=e}}},{key:"setVisible",value:function(e,t){this.threeLayer&&(!0===e?(this.threeLayer.show(),t&&t()):(this.threeLayer.hide(),t&&t()))}},{key:"prepareToDraw",value:function(){var e=this,t=function t(){var r,a;(e.threeLayer._needsUpdate=!e.threeLayer._needsUpdate,e.threeLayer._needsUpdate)&&(null===(r=e.threeLayer)||void 0===r||null===(a=r.getRenderer())||void 0===a||a.clearCanvas(),e.threeLayer.renderScene());var i,n=e.clock.getDelta(),o=c(e.updatables);try{for(o.s();!(i=o.n()).done;){i.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}e.animationId=requestAnimationFrame(t)};return new Promise((function(r){e.threeLayer.prepareToDraw=function(e,a,i){var n=new THREE.DirectionalLight(16777215);n.position.set(0,-10,10).normalize(),a.add(n),a.add(new THREE.AmbientLight(16777215)),t(),r()}}))}},{key:"drawRadar",value:function(e,t,r){var a=this;return new Promise((function(i){if(a.threeLayer.getScene()){var n=new v(e,t,r||{},a.threeLayer,a);i(n)}else a.initFlag=!0,a.prepareToDraw().then((function(){var n=new v(e,t,r||{},a.threeLayer,a);i(n)}))}))}},{key:"drawSector",value:function(e,t,r){var a=this;return new Promise((function(i){if(a.threeLayer.getScene()){var n=new x(e,t,r||{},a.threeLayer,a);i(n)}else a.initFlag=!0,a.prepareToDraw().then((function(){var n=new x(e,t,r||{},a.threeLayer,a);i(n)}))}))}},{key:"drawSectorImg",value:function(e,t,r){var a=this;return new Promise((function(i){if(a.threeLayer.getScene()){var n=new T(e,t,r||{},a.threeLayer,a);i(n)}else a.initFlag=!0,a.prepareToDraw().then((function(){var n=new T(e,t,r||{},a.threeLayer,a);i(n)}))}))}},{key:"drawImage",value:function(e,t,r,a){var i=this;return new Promise((function(n){if(i.threeLayer.getScene()){var o=new m(e,t,r,a,i.threeLayer);n(o)}else i.initFlag=!0,i.prepareToDraw().then((function(){var o=new m(e,t,r,a,i.threeLayer);n(o)}))}))}},{key:"drawShock",value:function(e,t){var r=this;return new Promise((function(a){if(r.threeLayer.getScene()){var i=new L(e,t||{},r.threeLayer,r);a(i)}else r.initFlag=!0,r.prepareToDraw().then((function(){var i=new L(e,t||{},r.threeLayer,r);a(i)}))}))}},{key:"dispose",value:function(){this.animationId&&cancelAnimationFrame(this.animationId);var e=this.threeLayer.getMeshes();this.threeLayer.clear(),e.forEach((function(e){}));var t=this.threeLayer.getCamera(),r=this.threeLayer.getScene(),a=this.threeLayer.getPick(),i=a.pickingTexture;a.pickingScene;var n=this.threeLayer.getRenderer();r.remove(t),t=null,r=null,i.dispose(),i=null,n.context.dispose(),n.context.forceContextLoss(),n.context=null,n.remove(),n=null,this.map.removeLayer(this.threeLayer)}}]),t}();export{m as imgClass,k as layerClass,T as planeSectorClass,v as radarClass,x as sectorClass,L as shockClass};
1
+ function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(a=i.key,n=void 0,"symbol"==typeof(n=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?n:String(n)),i)}var a,n}function r(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&n(e,t)}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}function n(e,t){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n(e,t)}function o(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=a(e);if(t){var n=a(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return o(this,r)}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function c(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,n=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw n}}}}function h(){var e="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"iep".concat(e,"layer")}function u(e){return new Promise((function(t){return setTimeout(t,e)}))}var d={altitude:0,imageWidth:512,imageHeight:512,texture:null},m=function(t){i(n,maptalks.BaseObject);var a=s(n);function n(t,r,i,o){var s;e(this,n);var l=r=maptalks.Util.extend({},d,r),c=l.altitude;l.imageHeight,l.imageWidth,t instanceof maptalks.Extent||(t=new maptalks.Extent(t));var h=t,u=h.xmin,m=h.ymin,p=h.xmax,f=h.ymax,v=1/0,g=1/0,y=-1/0,x=-1/0;[[u,m],[u,f],[p,f],[p,m]].forEach((function(e){var t=o.coordinateToVector3(e),r=t.x,i=t.y;v=Math.min(r,v),g=Math.min(i,g),y=Math.max(r,y),x=Math.max(i,x)}));var b=Math.abs(y-v),_=Math.abs(x-g),w=new THREE.PlaneBufferGeometry(b,_);(s=a.call(this))._initOptions(r),s._createMesh(w,i);var T=o.distanceToVector3(c,c).x,M=o.coordinateToVector3(t.getCenter(),T);return s.getObject3d().position.copy(M),s.parent=null,s.type="Image",s}return r(n)}(),p=function(){function t(r,i,a,n,o){var s=this;e(this,t),this.threelayer=o,this.map=o.map,this.textureLoader=new THREE.TextureLoader;var l=r.split(","),c=i.split(","),h=parseFloat(l[0]),u=parseFloat(l[1]),d=parseFloat(c[0]),p=parseFloat(c[1]),f=n.maxZoom||11,v=n.renderOrder||0,g=n.opacity||1,y=n.minZoom||3,x=new maptalks.Extent(h,u,d,p);this.xmin_g=h,this.ymin_g=u,this.xmax_g=d,this.ymax_g=p,this.textureLoader.load(a,(function(e){var t=new THREE.MeshBasicMaterial({map:e,transparent:!0,opacity:g}),r=new m(x,{imageWidth:512,imageHeight:512,maxZoom:f,minZoom:y,interactive:void 0!==n.interactive&&n.interactive},t,s.threelayer);r.object3d.renderOrder=v,s.imgMesh=r,s.imgMesh.parent=s,s.m=t,s.texture=e,s.threelayer.addMesh(s.imgMesh),n.opacityItems&&n.opacityItems.length>0&&!isNaN(n.opacityItems[0])&&!isNaN(n.opacityItems[1])&&n.opacityItems[0]>3&&n.opacityItems[0]<=18&&n.opacityItems[1]>=0&&n.opacityItems[1]<=1&&(s.opacityItems=n.opacityItems,s._bindMapEvents(),s._viewChange())}))}return r(t,[{key:"_bindMapEvents",value:function(){this.map.on("viewchange",this._viewChange,this)}},{key:"_viewChange",value:function(){this.opacityItems[0]<=this.map.getZoom()?this.imgMesh.object3d.material.opacity=this.opacityItems[1]:this.imgMesh.object3d.material.opacity=1}},{key:"_closeEvent",value:function(){this.map.off("viewchange",this._viewChange,this)}},{key:"updateImage",value:function(e,t){var r=this;if(t&&t.leftbottom&&t.righttop){var i=parseFloat(t.leftbottom[0]),a=parseFloat(t.leftbottom[1]),n=parseFloat(t.righttop[0]),o=parseFloat(t.righttop[1]);if(i!==this.xmin_g||a!==this.ymin_g||n!==this.xmax_g||o!==this.ymax_g){var s=new maptalks.Extent(i,a,n,o),l=1/0,c=1/0,h=-1/0,u=-1/0;[[i,a],[i,o],[n,o],[n,a]].forEach((function(e){var t=r.threelayer.coordinateToVector3(e),i=t.x,a=t.y;l=Math.min(i,l),c=Math.min(a,c),h=Math.max(i,h),u=Math.max(a,u)}));for(var d=Math.abs(h-l),m=Math.abs(u-c),p=new THREE.PlaneBufferGeometry(d,m),f=p.attributes.position.array,v=this.imgMesh.object3d.geometry.attributes.position.array,g=0;g<v.length;g++)v[g]=f[g];this.imgMesh.object3d.geometry.attributes.position.needsUpdate=!0;var y=this.threelayer.coordinateToVector3(s.getCenter(),0);this.imgMesh.getObject3d().position.copy(y),p.dispose(),this.xmin_g=i,this.ymin_g=a,this.xmax_g=n,this.ymax_g=o}}this.textureLoader.load(e,(function(e){r.texture&&r.texture.dispose(),delete r.texture,e.magFilter=THREE.NearestFilter,e.minFilter=THREE.NearestFilter,r.imgMesh.object3d.material.map=e,r.imgMesh.object3d.material.map.needsUpdate=!0,r.texture=e,!1===r.imgMesh.isAdd&&r.threelayer&&(r.threelayer.addMesh(r.imgMesh),r.opacityItems&&r._bindMapEvents())}))}},{key:"clearImage",value:function(){this.imgMesh&&(this.threelayer.removeMesh(this.imgMesh),this.opacityItems&&this._closeEvent())}},{key:"dispose",value:function(){this.imgMesh&&(!0===this.imgMesh.isAdd&&this.threelayer.removeMesh(this.imgMesh),this.imgMesh.object3d.geometry&&this.imgMesh.object3d.geometry.dispose(),this.imgMesh.object3d.material&&(this.imgMesh.object3d.material.dispose(),delete this.m)),this.texture&&(this.texture&&this.texture.dispose(),delete this.texture),this.opacityItems&&(this._closeEvent(),delete this.opacityItems),this.threelayer=null,this.textureLoader&&delete this.textureLoader}}]),t}(),f={altitude:0,imageWidth:512,imageHeight:512,texture:null},v=function(t){i(n,maptalks.BaseObject);var a=s(n);function n(t,r,i,o,s){var l;e(this,n);var c=(i=maptalks.Util.extend({},f,i)).altitude,h=s.distanceToVector3(r,r).x,u=new THREE.CircleGeometry(h,32);(l=a.call(this))._initOptions(i),l._createMesh(u,o);var d=s.distanceToVector3(c,c).x,m=s.coordinateToVector3(t,d);return l.getObject3d().position.copy(m),l.parent=null,l.type="radarObject",l}return r(n)}(),g=function(){function t(r,i,a,n,o){e(this,t),this.threelayer=n,this.map=n.map,this.layerClass=o,this.imgUrl=a.imgUrl,this.loader=new THREE.TextureLoader,this.texture=this.loader.load(this.imgUrl),this._uniforms={map:{value:this.texture},time:{value:0}};var s=new THREE.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n const float PI = 3.14159265359;\n const float TWO_PI = 6.28318530718;\n const int N = 3;\n const float r0 = 0.01;\n const float r_blue = 0.025;\n const float r_red = 0.015;\n const float edge = 0.95;\n const float offset = 0.05;\n\n uniform float time;\n varying vec2 vUv;\n uniform sampler2D map;\n float plot(const vec2 st, const float pct, const float width)\n {\n return smoothstep(pct - width, pct, st.y) -\n smoothstep(pct, pct + width, st.y);\n }\n float drawPolygon(const vec2 polygonCenter, const int N, const float radius, vec2 pos)\n {\n pos = pos - polygonCenter;\n float d = 0.0;\n float a = atan(pos.x, pos.y);\n float r = TWO_PI / float(N);\n d = cos(floor(0.5 + a / r)*r - a)*length(pos);\n return (1.0 - smoothstep(radius, radius + radius/10.0, d));\n }\n float gradations(const float a, const float gradNum, const float outRad, const float tickLen, const float tickWidth, const float r, const float move)\n {\n float f = step(0.0, cos((a + move)*gradNum) - tickWidth)*tickLen + (outRad - tickLen);\n return 1.0 - step(f, r) * 1.0 - step(r, outRad - tickLen);\n }\n void main() {\n // Normalized pixel coordinates (from 0 to 1)\n vec2 uv = vUv;\n vec2 pos = uv.xy - vec2(0.5, 0.5) ; // center what being drawn\n vec4 grndSpd = vec4(0.0, time/5.0, 0.0, 0.0);\n vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.85, 0.0, 1.0);\n //vec4 mapcol = texture2D(map,uv) * vec4 (0.0, 0.58, 1.0, 1.0);\n //vec3 color = vec3(0.0, 0.0, 0.0);\n vec3 color = vec3(0.0, 147. / 255., 1.0);\n float r = length(pos) * 2.0;\n float a = atan(pos.y, pos.x); // angle of pixel\n float an = PI - mod(time/ 1.0, TWO_PI); // angle of radar sweep\n float blipSpd = 3.0; // Blip / Trace speed\n vec2 translate1 = vec2(cos(time/ blipSpd), sin(time/ blipSpd));\n vec2 translate2 = vec2(sin(time/ blipSpd), cos(time/ blipSpd));\n vec2 left1 = translate1 * 0.35;\n vec2 right1 = -translate1 * 0.30;\n vec2 left2 = translate2 * 0.15;\n vec2 right2 = -translate2 * 0.25;\n // Radar Sweep\n float sn = step(PI/2.0, an) * step(-PI/2.0, (a + an)) * step(r, edge) * (1.0 - 0.55 * (a + (TWO_PI) - an));\n float sw = step(an, a) * step(r, edge);\n float s_blade = sw * (1.0 - (a - an) * 20.0);\n float s = sw * (1.0 - 0.55 * (a - an));\n s = max(sn,s);\n float se = step(r, edge - 0.05);\n // Center point\n float s1 = smoothstep(edge - 0.00, edge + 0.01, r)* smoothstep(edge + 0.02, edge + 0.01, r);\n // Circular concentric rings\n float s0 = 1.0 - smoothstep(r0 / 2.0, r0, length(pos));\n float smb = (1.0 - smoothstep(0.2, 0.2 + 0.01, length(pos))) * (1.0 - smoothstep(0.2 +0.01, 0.2, length(pos)));\n float smr = (1.0 - smoothstep(0.3, 0.3 + 0.01, length(pos))) * (1.0 - smoothstep(0.3 +0.01, 0.3, length(pos)));\n // Circular concentric gradations\n float gradNum = 120.0;\n float tickWidth = 0.9;\n const float tickLen = 0.04;\n float outRad = edge;\n float move = 0.0;\n float sm = 0.75*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n gradNum = 36.0;\n tickWidth = 0.95;\n outRad = 0.6;\n move = sin(time/10.0);\n smr += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n outRad = 0.4;\n move = cos(time/10.0);\n smb += 0.5*gradations(a, gradNum, outRad, tickLen, tickWidth, r, move);\n // Radial spoke gradations\n float sr = plot(pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.x, 0.002) * step(r, edge - 0.06);\n sr += plot(vec2(0.0, 0.0), pos.y, 0.003) * step(r, edge - 0.06);\n sr += plot(-pos, pos.x, 0.003) * step(r, edge - 0.06);\n sr *= 0.75;\n // Blue circular radar blip traces\n vec2 st_trace1 = left2;\n float s_trace1 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1)));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+offset, +offset))));\n s_trace1 += s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace1 + vec2(+2.0 *offset, +2.0 *offset))));\n\n vec2 st_trace2 = right1;\n float s_trace2 = s * (1.0 - smoothstep(r_blue / 10.0, r_blue, length(pos - st_trace2)));\n // Red Trianglular radar flight blip trace\n vec2 st_trace3 = left1;\n float st1 = s * (drawPolygon(st_trace3, N, r_red , pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(-offset, -offset), N, r_red, pos));\n st1 += s * (drawPolygon(st_trace3 + vec2(+offset, -offset), N, r_red, pos));\n\n vec2 st_trace4 = right2;\n float st2 = s * (drawPolygon(st_trace4, N, r_red, pos)); \n // Lets add all the bits together and send them to screen\n float s_grn = max(s * mapcol.y, s_blade);\n s_grn = max(s_grn, (s0 + sr + sm));\n s_grn += s1 / 1.5 + smb + smr;\n\n float s_red = st1*2.0 + st2*2.0 + smr;\n \n float s_blue = max(s_trace1 + s_trace2, s_blade) + smb;\n\n if (s_trace1 > 0.0 || s_trace2 > 0.0) { s_blue = max(s, s_blue); s_grn = max(s_grn, s_blue); }\n\n color += vec3(s_red , s_grn, s_blue); \n vec4 texColor = mapcol * s;\n // Output to screen \n gl_FragColor = vec4(color, 0.5);//Set the screen pixel to that color\n }",side:THREE.DoubleSide,transparent:!0});this.radar=new v(r,i,{},s,n),this.threelayer.addMesh(this.radar),this.layerClass.updatables.push(this)}return r(t,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.radar),this.radar.object3d.geometry&&this.radar.object3d.geometry.dispose(),this.radar.object3d.material&&this.radar.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),t}(),y={radius:100,altitude:0},x=function(t){i(n,maptalks.BaseObject);var a=s(n);function n(t,r,i,o){var s;e(this,n),r=maptalks.Util.extend({},y,r,{layer:o,coordinate:t}),(s=a.call(this))._initOptions(r);var l=r,c=l.altitude,h=l.radius,u=o.distanceToVector3(h,h).x,d=r.thetaStart||0,m=r.thetaLength||90,p=new THREE.CircleGeometry(u,128,d*Math.PI/180,m*Math.PI/180);s._createMesh(p,i);var f=o.distanceToVector3(c,c).x,v=o.coordinateToVector3(t,f);return s.getObject3d().position.copy(v),s}return r(n)}(),b=function(){function t(r,i,a,n,o){e(this,t),this.threelayer=n,this.map=n.map,this.layerClass=o;var s=a.thetaLength||90,l=a.rotation||0,c=s/2;this.imgUrl=a.imgUrl,this.loader=new THREE.TextureLoader,this.texture=this.loader.load(this.imgUrl);var h=l-c;h=h<0?h+360:h,this._uniforms={map:{value:this.texture},time:{value:0}};var u=new THREE.ShaderMaterial({uniforms:this._uniforms,vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n varying vec2 vUv;\n void main() {\n vec2 uv = vUv;\n //uv = uv.xy - vec2(0.5, 0.5);\n //gl_FragColor = texture2D(map, uv);\n gl_FragColor = vec4(1.0, 1.0, 1.0, 0.5);\n }",side:THREE.DoubleSide,transparent:!0,depthTest:!1});this.sector=new x(r,{thetaStart:h,thetaLength:a.thetaLength,radius:i},u,n),this.threelayer.addMesh(this.sector)}return r(t,[{key:"tick",value:function(e){this._uniforms.time.value+=2.4*e}},{key:"dispose",value:function(){}}]),t}(),_={altitude:0,height:0},w=function(t){i(n,maptalks.BaseObject);var a=s(n);function n(t,r,i,o){var s;e(this,n),i=maptalks.Util.extend({},_,i,{layer:o}),s=a.call(this);var l=i,c=l.width,h=l.height,u=l.altitude;s._initOptions(i);var d=new THREE.PlaneGeometry(c,h);d.computeBoundingBox();var m=new THREE.Mesh(d,r);s._createGroup(),s.getObject3d().add(m);var p=o.distanceToVector3(u,u).x,f=o.coordinateToVector3(t,p);return m.position.set(0,d.boundingBox.max.y,0),s.getObject3d().position.copy(f),s}return r(n)}();function T(e,t,r,i,a,n){this.tilesHorizontal=t,this.tilesVertical=r,this.numberOfTiles=i,e.wrapS=e.wrapT=THREE.RepeatWrapping,e.repeat.set(1/this.tilesHorizontal,1/this.tilesVertical),this.tileDisplayDuration=a,this.currentDisplayTime=0,this.currentTile=0,this.flag=n,this.update=function(t){for(this.currentDisplayTime+=t;this.currentDisplayTime>this.tileDisplayDuration;){this.currentDisplayTime-=this.tileDisplayDuration,this.currentTile++,this.currentTile==this.numberOfTiles&&(this.currentTile=0);var r=this.currentTile%this.tilesHorizontal;e.offset.x=r/this.tilesHorizontal;var i=Math.floor(this.currentTile/this.tilesHorizontal);this.flag?e.offset.y=this.tilesVertical-i/this.tilesVertical:e.offset.y=1-i/this.tilesVertical-1/this.tilesVertical}}}var M=function(){function t(r,i,a,n,o){var s=this;e(this,t),this.threelayer=n,this.map=n.map,this.layerClass=o;var l=a.thetaLength||45;this.millsec=a.millsec||1e3,this.duration=a.duration||75,this.tilesHoriz=a.tilesHoriz||12,this.tilesVert=a.tilesVert||5,this.numTiles=a.numTiles||49;var c=a.rotation||0,h=l/2,u=n.distanceToVector3(i,i).x,d=Math.sin(h*Math.PI/180)*u*2,m=void 0===a.flag;this.imgUrl=a.imgUrl,this.textureLoader=new THREE.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){s.texture=e,s.annie=new T(e,s.tilesHoriz,s.tilesVert,s.numTiles,s.duration,m);var t=new THREE.MeshBasicMaterial({transparent:!0,map:e,side:THREE.DoubleSide,depthTest:!1});s.imgObj=new w(r,t,{width:d,height:u},n),s.imgObj.object3d.renderOrder=1,s.imgObj.object3d.rotation.z=c*Math.PI/180,s.threelayer.addMesh(s.imgObj),s.layerClass.updatables.push(s)}))}return r(t,[{key:"tick",value:function(e){var t;null===(t=this.annie)||void 0===t||t.update(this.millsec*e)}},{key:"removeAnimation",value:function(){var e=this.layerClass.updatables.indexOf(this);e>-1&&this.layerClass.updatables.splice(e,1)}},{key:"dispose",value:function(){var e;this.removeAnimation(),this.threelayer.removeMesh(this.imgObj),this.imgObj.object3d.geometry&&this.imgObj.object3d.geometry.dispose(),this.imgObj.object3d.material&&this.imgObj.object3d.material.dispose(),this.loader&&delete this.loader,null===(e=this.texture)||void 0===e||e.dispose()}}]),t}(),E={radius:100,altitude:0},L=function(t){i(n,maptalks.BaseObject);var a=s(n);function n(t,r,i,o){var s;e(this,n),r=maptalks.Util.extend({},E,r,{layer:o}),s=a.call(this);var l=r,c=l.width;l.height;var h=l.altitude;s._initOptions(r);var u=new THREE.CircleGeometry(c,32);s._createMesh(u,i);var d=o.distanceToVector3(h,h).x,m=o.coordinateToVector3(t,d);return s.getObject3d().position.copy(m),s}return r(n)}(),k=function(){function t(r,i,a,n){var o=this;e(this,t),this.threelayer=a,this.map=a.map,this.layerClass=n,this.time=0,a.coordinateToVector3(r,0),this.imgUrl=i.imgUrl,this.textureLoader=new THREE.TextureLoader,this.imgUrl&&this.textureLoader.load(this.imgUrl,(function(e){o.texture=e,o._uniforms={impactPosition:{value:new THREE.Vector3(0,0,0)},impactMaxRadius:{value:2},impactRatio:{value:.25},map:{value:o.texture}};var t=new THREE.ShaderMaterial({uniforms:o._uniforms,vertexShader:"\n varying vec3 vPosition;\n varying vec2 vUv;\n void main(){\n vUv = uv;\n vPosition = position;\n gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D map;\n uniform vec3 impactPosition;\n uniform float impactMaxRadius;\n uniform float impactRatio;\n varying vec3 vPosition;\n varying vec2 vUv;\n void main() {\n float dist = distance(vPosition, impactPosition);\n float curRadius = impactMaxRadius * impactRatio;\n float sstep = smoothstep(0., curRadius, dist) - smoothstep(curRadius - ( 0.25 * impactRatio ), curRadius, dist);\n sstep = 1. - sstep * (1. - impactRatio);\n vec3 col = mix(vec3(1., 0.5, 0.0625), vec3(1., 0.25, 0.125), impactRatio);\n gl_FragColor = texture2D(map, vUv);\n gl_FragColor = vec4( mix( col, gl_FragColor.rgb, sstep), 1.0 );\n }",side:THREE.DoubleSide,transparent:!0,depthTest:!1}),i=new L(r,{width:2,height:2},t,a);o.threelayer.addMesh(i),o.layerClass.updatables.push(o)}))}return r(t,[{key:"tick",value:function(e){this.time+=.2*e,this.time%=1,this._uniforms.impactRatio.value=this.time}},{key:"dispose",value:function(){}}]),t}(),R=function(){function t(r,i){var a=this;e(this,t),this.map=i,this.animationId=null,this.updatables=[];var n=h();this.threeLayer=new maptalks.ThreeLayer(n,{forceRenderOnMoving:!0,forceRenderOnRotating:!0,identifyCountOnEvent:1}),this.clock=new THREE.Clock;var o=function e(){var t,r;(a.threeLayer._needsUpdate=!a.threeLayer._needsUpdate,a.threeLayer._needsUpdate)&&(null===(t=a.threeLayer)||void 0===t||null===(r=t.getRenderer())||void 0===r||r.clearCanvas(),a.threeLayer.renderScene());var i,n=a.clock.getDelta(),o=c(a.updatables);try{for(o.s();!(i=o.n()).done;){i.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}a.animationId=requestAnimationFrame(e)};this.threeLayer.prepareToDraw=function(e,t,r){var i=new THREE.DirectionalLight(16777215);i.position.set(0,-10,10).normalize(),t.add(i),o()},this.threeLayer.addTo(i),this.layerId=n,this.layerName=r,this.dirty=!1,this.initFlag=!1}return r(t,[{key:"getLayerId",value:function(){return this.layerId}},{key:"changeLayerId",value:function(){if(this.threeLayer){var e=h();this.threeLayer.setId(e),this.layerId=e}}},{key:"setVisible",value:function(e,t){this.threeLayer&&(!0===e?(this.threeLayer.show(),t&&t()):(this.threeLayer.hide(),t&&t()))}},{key:"prepareToDraw",value:function(){var e=this,t=function t(){var r,i;(e.threeLayer._needsUpdate=!e.threeLayer._needsUpdate,e.threeLayer._needsUpdate)&&(null===(r=e.threeLayer)||void 0===r||null===(i=r.getRenderer())||void 0===i||i.clearCanvas(),e.threeLayer.renderScene());var a,n=e.clock.getDelta(),o=c(e.updatables);try{for(o.s();!(a=o.n()).done;){a.value.tick(n)}}catch(e){o.e(e)}finally{o.f()}e.animationId=requestAnimationFrame(t)};return new Promise((function(r){e.threeLayer.prepareToDraw=function(e,i,a){var n=new THREE.DirectionalLight(16777215);n.position.set(0,-10,10).normalize(),i.add(n),i.add(new THREE.AmbientLight(16777215)),t(),r()}}))}},{key:"drawRadar",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new g(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new g(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSector",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new b(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new b(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawSectorImg",value:function(e,t,r){var i=this;return new Promise((function(a){if(i.threeLayer.getScene()){var n=new M(e,t,r||{},i.threeLayer,i);a(n)}else i.initFlag=!0,i.prepareToDraw().then((function(){var n=new M(e,t,r||{},i.threeLayer,i);a(n)}))}))}},{key:"drawImage",value:function(e,t,r,i){var a=this;return new Promise((function(n){if(a.threeLayer.getScene()){var o=new p(e,t,r,i,a.threeLayer);n(o)}else a.initFlag=!0,a.prepareToDraw().then((function(){var o=new p(e,t,r,i,a.threeLayer);n(o)}))}))}},{key:"drawShock",value:function(e,t){var r=this;return new Promise((function(i){if(r.threeLayer.getScene()){var a=new k(e,t||{},r.threeLayer,r);i(a)}else r.initFlag=!0,r.prepareToDraw().then((function(){var a=new k(e,t||{},r.threeLayer,r);i(a)}))}))}},{key:"dispose",value:function(){this.animationId&&cancelAnimationFrame(this.animationId);var e=this.threeLayer.getMeshes();this.threeLayer.clear(),e.forEach((function(e){}));var t=this.threeLayer.getCamera(),r=this.threeLayer.getScene(),i=this.threeLayer.getPick(),a=i.pickingTexture;i.pickingScene;var n=this.threeLayer.getRenderer();r.remove(t),t=null,r=null,a.dispose(),a=null,n.context.dispose(),n.context.forceContextLoss(),n.context=null,n.remove(),n=null,this.map.removeLayer(this.threeLayer)}}]),t}();export{p as imgClass,R as layerClass,M as planeSectorClass,g as radarClass,b as sectorClass,k as shockClass,u as sleep};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "map-core-func",
3
3
  "umdName": "map-core-func",
4
- "version": "0.1.15",
4
+ "version": "0.1.17",
5
5
  "description": "map-core-func",
6
6
  "files": [
7
7
  "dist"