function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,i){return t&&_defineProperties(e.prototype,t),i&&_defineProperties(e,i),e}var ErectdynamicLine=function(){"use strict";function t(e){_classCallCheck(this,t),this["\x5f\x69\x64"]=e["\x69\x64"],Cesium["\x64\x65\x66\x69\x6e\x65\x64"](this["\x5f\x69\x64"])||(this["\x5f\x69\x64"]=Cesium["\x63\x72\x65\x61\x74\x65\x47\x75\x69\x64"]()),this["\x77\x69\x64\x74\x68"]=e["\x77\x69\x64\x74\x68"],Cesium["\x64\x65\x66\x69\x6e\x65\x64"](this["\x77\x69\x64\x74\x68"])||(this["\x77\x69\x64\x74\x68"]=16),this["\x5f\x63\x6f\x6c\x6f\x72"]=e["\x63\x6f\x6c\x6f\x72"],Cesium["\x64\x65\x66\x69\x6e\x65\x64"](this["\x5f\x63\x6f\x6c\x6f\x72"])||(this["\x5f\x63\x6f\x6c\x6f\x72"]=new Cesium["\x43\x6f\x6c\x6f\x72"](.3,.8,1,1)),this["\x5f\x65\x76\x65\x6e\x74"]=new Cesium["\x45\x76\x65\x6e\x74"],this["\x5f\x65\x76\x65\x6e\x74\x48\x65\x6c\x70\x65\x72"]=new Cesium["\x45\x76\x65\x6e\x74\x48\x65\x6c\x70\x65\x72"],this["\x5f\x73\x63\x72\x61\x74\x63\x68\x54\x57\x50"]=void 0,this["\x5f\x64\x79\x6e\x61\x6d\x69\x63\x4c\x69\x6e\x65\x50\x72\x69\x6d\x69\x74\x69\x76\x65\x73"]=[],this["\x5f\x64\x79\x6e\x61\x6d\x69\x63\x4c\x69\x6e\x65\x52\x6f\x75\x74\x65\x73"]=[],this["\x5f\x64\x69\x73\x70\x6f\x73\x65\x4c\x69\x73\x74\x65\x6e\x65\x72"]=void 0,this["\x72\x6f\x75\x74\x65\x73"]=e["\x72\x6f\x75\x74\x65\x73"],this["\x63\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e"]=new Cesium["\x50\x72\x69\x6d\x69\x74\x69\x76\x65\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e"],this["\x50\x72\x69\x6d\x69\x74\x69\x76\x65\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e"]=[],this["\x62\x75\x69\x6c\x64"]()}return _createClass(t,[{key:"build",value:function(){var B$qs1=this["\x72\x6f\x75\x74\x65\x73"];this["\x5f\x64\x79\x6e\x61\x6d\x69\x63\x4c\x69\x6e\x65\x52\x6f\x75\x74\x65\x73"]["\x70\x75\x73\x68"](B$qs1);var rlWeZu_K2=this["\x63\x72\x65\x61\x74\x65\x44\x79\x6e\x61\x6d\x69\x63\x4c\x69\x6e\x65\x73\x50\x72\x69\x6d\x69\x74\x69\x76\x65"](B$qs1);this["\x63\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e"]["\x61\x64\x64"](rlWeZu_K2),this["\x63\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e"]["\x5f\x67\x75\x69\x64"]=this["\x5f\x69\x64"],this["\x50\x72\x69\x6d\x69\x74\x69\x76\x65\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e"]["\x70\x75\x73\x68"](this["\x63\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e"]),viewer["\x73\x63\x65\x6e\x65"]["\x70\x72\x69\x6d\x69\x74\x69\x76\x65\x73"]["\x61\x64\x64"](this["\x63\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e"]),this["\x5f\x64\x79\x6e\x61\x6d\x69\x63\x4c\x69\x6e\x65\x50\x72\x69\x6d\x69\x74\x69\x76\x65\x73"]["\x70\x75\x73\x68"](rlWeZu_K2),B$qs1["\x66\x6f\x72\x45\x61\x63\x68"](function(ABhuo3){ABhuo3["\x73\x74\x61\x72\x74\x54\x69\x6d\x65"],ABhuo3["\x64\x75\x72\x61\x74\x69\x6f\x6e"];ABhuo3["\x66\x6f\x72\x77\x61\x72\x64"]=Cesium["\x64\x65\x66\x61\x75\x6c\x74\x56\x61\x6c\x75\x65"](ABhuo3["\x66\x6f\x72\x77\x61\x72\x64"],!0),1==ABhuo3["\x66\x6f\x72\x77\x61\x72\x64"]?(ABhuo3["\x74\x69\x6d\x65"]=ABhuo3["\x73\x74\x61\x72\x74\x54\x69\x6d\x65"],ABhuo3["\x64\x65\x6c\x74\x61"]=.01):(ABhuo3["\x74\x69\x6d\x65"]=ABhuo3["\x73\x74\x61\x72\x74\x54\x69\x6d\x65"]+ABhuo3["\x64\x75\x72\x61\x74\x69\x6f\x6e"],ABhuo3["\x64\x65\x6c\x74\x61"]=-.01),ABhuo3["\x72\x6f\x75\x6e\x64"]=Cesium["\x64\x65\x66\x61\x75\x6c\x74\x56\x61\x6c\x75\x65"](ABhuo3["\x72\x6f\x75\x6e\x64"],!1)}),this["\x61\x64\x64\x4c\x73\x6e\x72\x4f\x66\x4d\x6f\x74\x69\x6f\x6e"](),viewer["\x73\x63\x65\x6e\x65"]["\x72\x65\x71\x75\x65\x73\x74\x52\x65\x6e\x64\x65\x72"]()}},{key:"createDynamicLinesPrimitive",value:function(e,t,n){var a=[],r=this;return e.forEach(function(e){var t=e.positions,i=r.createDynamicLinesGeometryInstance(t,n);a.push(i)}),new Cesium.Primitive({geometryInstances:a,appearance:this.createDynamicLinesApperance(t)})}},{key:"createDynamicLinesGeometryInstance",value:function(e){return new Cesium.GeometryInstance({geometry:new Cesium.PolylineGeometry({positions:e,width:this.width,vertexFormat:Cesium.PolylineMaterialAppearance.VERTEX_FORMAT}),attributes:{twp:new Cesium.GeometryInstanceAttribute({componentDatatype:Cesium.ComponentDatatype.FLOAT,componentsPerAttribute:4,normalize:!1,value:[0,.5,1,1]})}})}},{key:"createDynamicLinesApperance",value:function(){var e=new Cesium.PolylineMaterialAppearance({material:new Cesium.Material({fabric:{type:"Color",uniforms:{color:this._color}},translucent:!0}),renderState:new Cesium.RenderState({polygonOffset:{enabled:!0,factor:-1,units:-1},depthTest:{enabled:!1,func:Cesium.WebGLConstants.LEQUAL}})}),t=Cesium.ShaderSource.replaceMain(e._vertexShaderSource,"czm_twp_main");e._vertexShaderSource=t+"\nvarying vec4 v_twp; \nvoid main() \n{ \n czm_twp_main(); \n v_twp = czm_batchTable_twp(batchId); \n}";var i=Cesium.ShaderSource.replaceMain(e._fragmentShaderSource,"czm_twp2_main");return e._fragmentShaderSource=i+"\nvarying vec4 v_twp; \nvoid main() \n{ \n czm_twp2_main(); \n float t = v_twp.x; float w = v_twp.y; float p = v_twp.z; float d = v_twp.w; float alpha = 0.1; if(d > 0.0){ if(v_st.s > (t - 0.06) && v_st.s < t){ alpha = smoothstep(1.0, alpha, abs(v_st.s - t) / 0.06) * (1.0 - alpha) + alpha; } } else { if(v_st.s > t && v_st.s < (t + 0.06)){ alpha = smoothstep(1.0, alpha, abs(v_st.s - t) / 0.06) * (1.0 - alpha) + alpha; } } gl_FragColor.a = alpha;}",e}},{key:"addLsnrOfMotion",value:function(){var i=this;null==this._disposeListener&&(this._disposeListener=viewer.scene.preUpdate.addEventListener(function(){for(var e=0;e<i._dynamicLinePrimitives.length;e++){var t=i._dynamicLinePrimitives[e];Cesium.defined(t)&&i.setDynamicLinesStatus(t,i._dynamicLineRoutes[e])}}))}},{key:"setDynamicLinesStatus",value:function(e,t){var i=this.getScratchTWP();if(void 0!==e._batchTable)for(var n=e._batchTableAttributeIndices.twp,a=e._batchTable._numberOfInstances,r=0;r<a;++r){var s=r,o=t[s],c=o.startTime,l=o.duration,u=o.time;c+l<(u+=o.delta)?o.round?(u=c+l,o.delta*=-1):u=c:u<c&&(o.round?(u=c,o.delta*=-1):u=c+l);var m=(o.time=u)-c,h=Math.min(m/l,1);Cesium.Cartesian4.fromElements(h,.3,1,o.delta,i),e._batchTable.setBatchedAttribute(s,n,i)}}},{key:"getScratchTWP",value:function(){return void 0===this._scratchTWP&&(this._scratchTWP=new Cesium.Cartesian4(0,0,0,0)),this._scratchTWP}},{key:"getprimitivebyid",value:function(e){for(var t=null,i=viewer.scene.primitives,n=i.length,a=0;a<n;a++){var r=i.get(a);r._guid===e&&(t=r)}return t}},{key:"removeprimitive",value:function(e){var t=this.getprimitivebyid(e);null!=t&&viewer.scene.primitives.remove(t)}},{key:"removeprimitiveList",value:function(){for(var e=0;e<this.PrimitiveCollection.length;e++){var t=this.PrimitiveCollection[e];viewer.scene.primitives.remove(t),this.PrimitiveCollection.splice(e,1),e--}}}]),t}();
评论5