From 2bdb0cb0fa267027655c38d86c71206fe2ae90e4 Mon Sep 17 00:00:00 2001 From: Caven Chen Date: Tue, 17 May 2022 21:31:07 +0800 Subject: [PATCH] imporve the wind layer #96 --- modules/wind/WindCanvas.js | 5 +++++ modules/wind/WindLayer.js | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/wind/WindCanvas.js b/modules/wind/WindCanvas.js index 862da522..33996fb4 100644 --- a/modules/wind/WindCanvas.js +++ b/modules/wind/WindCanvas.js @@ -126,6 +126,11 @@ class WindCanvas { _drawPixelParticle(particle, min, max) { let pointPrev = [particle.x, particle.y] let pointNext = [particle.xt, particle.yt] + let dx = particle.xt - particle.x + let dy = particle.yt - particle.y + if (dx * dx + dy * dy > 20 * 20) { + return + } if ( pointNext && pointPrev && diff --git a/modules/wind/WindLayer.js b/modules/wind/WindLayer.js index 76f4143e..dd90f3b1 100644 --- a/modules/wind/WindLayer.js +++ b/modules/wind/WindLayer.js @@ -117,9 +117,17 @@ class WindLayer extends Layer { let camera = this._viewer.camera let ellipsoid = Cesium.Ellipsoid.WGS84 this._delegate.intersectsCoordinate = coordinate => { - let occluder = new Cesium.EllipsoidalOccluder(ellipsoid, camera.position) - let point = Cesium.Cartesian3.fromDegrees(coordinate[0], coordinate[1]) - return occluder.isPointVisible(point) + if (scene.mode === Cesium.SceneMode.SCENE3D) { + let occluder = new Cesium.EllipsoidalOccluder( + ellipsoid, + camera.position + ) + let point = Cesium.Cartesian3.fromDegrees(coordinate[0], coordinate[1]) + return occluder.isPointVisible(point) + } else if (scene.mode === Cesium.SceneMode.SCENE2D) { + return !(coordinate[0] === -180 || coordinate[0] === 180) + } + return true } this._delegate.project = coordinate => {