Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Xiaoji Chen
committed
Apr 7, 2019
1 parent
a746f07
commit af7d27e
Showing
8 changed files
with
139 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
examples/website/brushing/arc-brushing-layer/arc-brushing-layer-fragment.glsl.js
This file was deleted.
Oops, something went wrong.
140 changes: 0 additions & 140 deletions
140
examples/website/brushing/arc-brushing-layer/arc-brushing-layer-vertex.glsl.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
examples/website/brushing/brushing-layers/brushing-shader-module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright (c) 2015-2017 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
const vs = ` | ||
const float R_EARTH = 6371000.; // earth radius in km | ||
uniform vec2 brushing_mousePos; | ||
uniform float brushing_radius; | ||
varying float brushing_hidden; | ||
// approximate distance between lng lat in meters | ||
float distanceBetweenLatLng(vec2 source, vec2 target) { | ||
vec2 delta = (source - target) * PI / 180.; | ||
float a = | ||
sin(delta.y / 2.) * sin(delta.y / 2.) + | ||
cos(source.y * PI / 180.) * cos(target.y * PI / 180.) * | ||
sin(delta.x / 2.) * sin(delta.x / 2.); | ||
float c = 2. * atan(sqrt(a), sqrt(1. - a)); | ||
return R_EARTH * c; | ||
} | ||
bool brushing_isPointInRange(vec2 position) { | ||
return distanceBetweenLatLng(position, brushing_mousePos) <= brushing_radius; | ||
} | ||
void brushing_setVisible(bool visible) { | ||
brushing_hidden = float(!visible); | ||
} | ||
`; | ||
|
||
const fs = ` | ||
varying float brushing_hidden; | ||
void brushing_filter() { | ||
if (brushing_hidden > 0.5) { | ||
discard; | ||
} | ||
} | ||
`; | ||
|
||
const INITIAL_MODULE_OPTIONS = {}; | ||
|
||
export default { | ||
name: 'brushing', | ||
dependencies: ['project'], | ||
vs, | ||
fs, | ||
getUniforms: (opts = INITIAL_MODULE_OPTIONS) => { | ||
if (opts.viewport) { | ||
return { | ||
brushing_radius: opts.brushRadius, | ||
brushing_mousePos: opts.mousePosition ? opts.viewport.unproject(opts.mousePosition) : [0, 0] | ||
}; | ||
} | ||
return {}; | ||
} | ||
}; |
Oops, something went wrong.