diff --git a/src/Obj/Base/PolylineObject/index.js b/src/Obj/Base/PolylineObject/index.js index 81d4987..473a576 100644 --- a/src/Obj/Base/PolylineObject/index.js +++ b/src/Obj/Base/PolylineObject/index.js @@ -335,9 +335,13 @@ class PolylineObject extends Base { this._elms.lineWidth.forEach(item => { item.value = this.options.width }) - this.entity && - this.entity.polyline && - (this.entity.polyline.width = this.options.width) + if (this.entity && this.entity.polyline) { + this.entity.polyline.width = this.entity.polyline.width + v - this.entity.polyline.oriWidth + this.entity.polyline.oriWidth = this.options.width + } + // this.entity && + // this.entity.polyline && + // (this.entity.polyline.width = this.options.width) && (this.entity.polyline.oriWidth = this.options.width) } get lineType() { @@ -1316,6 +1320,7 @@ class PolylineObject extends Base { zIndex: that.sdk._entityZIndex } }) + that.entity.polyline.oriWidth = that.options.width that.sdk._entityZIndex++ PolylineObject.createLabel(that) // that.entity.polyline.positionsLngLat = positions diff --git a/src/Obj/Materail/LineTextureMaterialProperty.js b/src/Obj/Materail/LineTextureMaterialProperty.js index 5bed3ec..70afe5a 100644 --- a/src/Obj/Materail/LineTextureMaterialProperty.js +++ b/src/Obj/Materail/LineTextureMaterialProperty.js @@ -12,7 +12,7 @@ function LineTexture() { this.image = options.image || ""; this.color = new Cesium.Color.fromCssColorString(options.color || "rgba(255,255,255,1)"); this.speed = options.speed != undefined ? options.speed : 1.0; - this.repeat = options.repeat || 1.0; + this.repeat = options.repeat || new Cesium.Cartesian2(1.0, 1.0); } get isConstant() { @@ -52,7 +52,7 @@ function LineTexture() { result.repeat = Cesium.Property.getValueOrDefault( this._repeat, time, - 1.0, + new Cesium.Cartesian2(1.0, 1.0), result.repeat ); result.frameNumber = Cesium.getTimestamp(); @@ -85,14 +85,14 @@ function LineTexture() { uniform vec4 color; uniform sampler2D image; uniform float speed; - uniform float repeat; + // uniform float repeat; czm_material czm_getMaterial(czm_materialInput materialInput) { czm_material material = czm_getDefaultMaterial(materialInput); vec2 st = materialInput.st; - st.s *= repeat; // 关键:通过repeat控制纹理密度 + st.s *= repeat.x; // 关键:通过repeat控制纹理密度 // vec4 colorImage = texture2D(image, vec2(fract(st.s + speed*czm_frameNumber* 0.01), st.t)); - vec4 colorImage = speed==0.0?texture2D(image, vec2(fract(st.s), st.t)):texture2D(image, vec2(fract(st.s + frameNumber / 1000.0 / speed * repeat ), st.t)); + vec4 colorImage = speed==0.0?texture2D(image, vec2(fract(st.s), st.t)):texture2D(image, vec2(fract(st.s + frameNumber / 1000.0 / speed * repeat.x / repeat.y ), st.t)); material.alpha = colorImage.a * color.a; material.diffuse = color.rgb; return material; @@ -106,7 +106,7 @@ function LineTexture() { uniforms: { color: new Cesium.Color(1.0, 1.0, 1.0, 1.0), image: '', - repeat: 1.0, + repeat: new Cesium.Cartesian2(1.0, 1.0), speed: 1.0, frameNumber: Cesium.getTimestamp(), uTime: 1 diff --git a/src/Tools/index.js b/src/Tools/index.js index 746d2d0..f788a26 100644 --- a/src/Tools/index.js +++ b/src/Tools/index.js @@ -585,8 +585,6 @@ class Tools { getMaterial(color = '#2ab0c2', type = 0, entity = null, newParam = {}) { let material = '' - - switch (Number(type)) { case 1: //虚线 @@ -645,8 +643,18 @@ class Tools { space: newParam.space, speed: newParam.speed } - let arr = [7, 8, 9, 10, 11] + let arr = { + '7': 10, + '8': 3, + '9': 4, + '10': 4, + '11': 4, + '12': 2 + } param.speed = newParam.rotate ? param.speed : 0 - param.speed + console.log(entity.polyline.oriWidth, arr[type + ''], type, 'oriWidth') + entity.polyline.width = entity.polyline.oriWidth + arr[type + ''] + this.getFlowTexture(this, param, entity) break @@ -683,6 +691,8 @@ class Tools { // let repeat = getRepeat() // }, false) + entity.polyline.material.oriRepeat = undefined + entity.polyline.material.oriSpeed = undefined entity.polyline.material = new Cesium.LineTextureMaterialProperty( { color: options.color, @@ -696,8 +706,8 @@ class Tools { var positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime); if (!Cesium.defined(positions)) { - // return new Cesium.Cartesian2(1.0, 1.0); - return 1.0; + return new Cesium.Cartesian2(1.0, 1.0); + // return 1.0; } var distance = 0; @@ -721,14 +731,21 @@ class Tools { var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight) // repeatX *= groundResolution / cameraHeight / ((myImg.width / myImg.height * 5) + 1); repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1); + let speed + if (entity.polyline.material.oriRepeat) { + speed = repeatX / entity.polyline.material.oriRepeat + } else { + entity.polyline.material.oriRepeat = repeatX + } // if (repeatX < 3) { // repeatX = 3 // } - // return new Cesium.Cartesian2(repeatX, 1.0); - return repeatX; + return new Cesium.Cartesian2(repeatX, speed || 1.0); + // return repeatX; }) } ) + entity.polyline.material.oriSpeed = options.speed } } diff --git a/static/img/arrow/1.png b/static/img/arrow/1.png index 650bc1f..62d84a0 100644 Binary files a/static/img/arrow/1.png and b/static/img/arrow/1.png differ diff --git a/static/img/arrow/11.png b/static/img/arrow/11.png new file mode 100644 index 0000000..650bc1f Binary files /dev/null and b/static/img/arrow/11.png differ diff --git a/static/img/arrow/13.png b/static/img/arrow/13.png deleted file mode 100644 index 6992950..0000000 Binary files a/static/img/arrow/13.png and /dev/null differ diff --git a/static/img/arrow/2.png b/static/img/arrow/2.png index ae98b82..b20bf3f 100644 Binary files a/static/img/arrow/2.png and b/static/img/arrow/2.png differ diff --git a/static/img/arrow/3.png b/static/img/arrow/3.png index bd22ff5..7da948e 100644 Binary files a/static/img/arrow/3.png and b/static/img/arrow/3.png differ diff --git a/static/img/arrow/4 - 副本.png b/static/img/arrow/4 - 副本.png deleted file mode 100644 index b3cbe70..0000000 Binary files a/static/img/arrow/4 - 副本.png and /dev/null differ diff --git a/static/img/arrow/4.png b/static/img/arrow/4.png index 263a223..935d8ab 100644 Binary files a/static/img/arrow/4.png and b/static/img/arrow/4.png differ diff --git a/static/img/arrow/5.png b/static/img/arrow/5.png index 26f3964..bd1fa7f 100644 Binary files a/static/img/arrow/5.png and b/static/img/arrow/5.png differ diff --git a/static/img/arrow/6.png b/static/img/arrow/6.png index eca7083..7eb7923 100644 Binary files a/static/img/arrow/6.png and b/static/img/arrow/6.png differ