-
Notifications
You must be signed in to change notification settings - Fork 0
/
animated-arc-layer.js
62 lines (56 loc) · 1.48 KB
/
animated-arc-layer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import {ArcLayer} from '@deck.gl/layers';
export default class AnimatedArcLayer extends ArcLayer {
getShaders() {
const shaders = super.getShaders();
shaders.inject = {
'vs:#decl': `\
uniform vec2 timeRange;
attribute float instanceTargetTimestamp;
attribute float instanceSourceTimestamp;
varying float vTimestamp;
`,
'vs:#main-end': `\
vTimestamp = mix(instanceTargetTimestamp, instanceSourceTimestamp, segmentRatio);
`,
'fs:#decl': `\
uniform vec2 timeRange;
varying float vTimestamp;
`,
// 'fs:#main-start': `\
// if (vTimestamp < timeRange.x || vTimestamp > timeRange.y) {
// discard;
// }
// `,
'fs:DECKGL_FILTER_COLOR': `\
color.a *= (vTimestamp - timeRange.y) / (timeRange.x - timeRange.y);
`
};
return shaders;
}
initializeState() {
super.initializeState();
this.getAttributeManager().addInstanced({
instanceSourceTimestamp: {
size: 1,
accessor: 'getSourceTimestamp'
},
instanceTargetTimestamp: {
size: 1,
accessor: 'getTargetTimestamp'
}
});
}
draw(params) {
params.uniforms = Object.assign({}, params.uniforms, {
timeRange: this.props.timeRange
});
super.draw(params);
}
}
AnimatedArcLayer.layerName = 'AnimatedArcLayer';
AnimatedArcLayer.defaultProps = {
getSourceTimestamp: {type: 'accessor', value: 0},
getTargetTimestamp: {type: 'accessor', value: 1},
timeRange: {type: 'array', compare: true, value: [0, 1]},
// getTilt: d => d.tilt
};