@deck.gl/extensions 8.8.0-alpha.4 → 8.8.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +480 -1335
- package/dist/es5/brushing/brushing.js +19 -15
- package/dist/es5/brushing/brushing.js.map +1 -1
- package/dist/es5/brushing/shader-module.js +1 -1
- package/dist/es5/brushing/shader-module.js.map +1 -1
- package/dist/es5/clip/clip.js +4 -2
- package/dist/es5/clip/clip.js.map +1 -1
- package/dist/es5/data-filter/aggregator.js +1 -1
- package/dist/es5/data-filter/aggregator.js.map +1 -1
- package/dist/es5/data-filter/data-filter.js +9 -9
- package/dist/es5/data-filter/data-filter.js.map +1 -1
- package/dist/es5/data-filter/shader-module.js +22 -13
- package/dist/es5/data-filter/shader-module.js.map +1 -1
- package/dist/es5/fill-style/fill-style.js +13 -11
- package/dist/es5/fill-style/fill-style.js.map +1 -1
- package/dist/es5/fill-style/shaders.glsl.js +8 -6
- package/dist/es5/fill-style/shaders.glsl.js.map +1 -1
- package/dist/es5/fp64/fp64.js +4 -2
- package/dist/es5/fp64/fp64.js.map +1 -1
- package/dist/es5/fp64/project64.glsl.js +1 -1
- package/dist/es5/fp64/project64.js +2 -5
- package/dist/es5/fp64/project64.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/mask/mask.js +7 -4
- package/dist/es5/mask/mask.js.map +1 -1
- package/dist/es5/mask/shader-module.js +6 -7
- package/dist/es5/mask/shader-module.js.map +1 -1
- package/dist/es5/path-style/path-style.js +5 -5
- package/dist/es5/path-style/path-style.js.map +1 -1
- package/dist/es5/path-style/shaders.glsl.js +1 -1
- package/dist/es5/path-style/shaders.glsl.js.map +1 -1
- package/dist/esm/brushing/brushing.js +20 -15
- package/dist/esm/brushing/brushing.js.map +1 -1
- package/dist/esm/brushing/shader-module.js +1 -1
- package/dist/esm/brushing/shader-module.js.map +1 -1
- package/dist/esm/clip/clip.js +5 -2
- package/dist/esm/clip/clip.js.map +1 -1
- package/dist/esm/data-filter/aggregator.js +1 -1
- package/dist/esm/data-filter/aggregator.js.map +1 -1
- package/dist/esm/data-filter/data-filter.js +6 -3
- package/dist/esm/data-filter/data-filter.js.map +1 -1
- package/dist/esm/data-filter/shader-module.js +21 -21
- package/dist/esm/data-filter/shader-module.js.map +1 -1
- package/dist/esm/fill-style/fill-style.js +18 -13
- package/dist/esm/fill-style/fill-style.js.map +1 -1
- package/dist/esm/fill-style/shaders.glsl.js +6 -2
- package/dist/esm/fill-style/shaders.glsl.js.map +1 -1
- package/dist/esm/fp64/fp64.js +4 -2
- package/dist/esm/fp64/fp64.js.map +1 -1
- package/dist/esm/fp64/project64.glsl.js +1 -1
- package/dist/esm/fp64/project64.glsl.js.map +1 -1
- package/dist/esm/fp64/project64.js +2 -3
- package/dist/esm/fp64/project64.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mask/mask.js +7 -4
- package/dist/esm/mask/mask.js.map +1 -1
- package/dist/esm/mask/shader-module.js +6 -6
- package/dist/esm/mask/shader-module.js.map +1 -1
- package/dist/esm/path-style/path-style.js +6 -5
- package/dist/esm/path-style/path-style.js.map +1 -1
- package/dist/esm/path-style/shaders.glsl.js +1 -1
- package/dist/esm/path-style/shaders.glsl.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +6 -3
- package/src/brushing/{brushing.js → brushing.ts} +45 -17
- package/src/brushing/{shader-module.js → shader-module.ts} +13 -3
- package/src/clip/{clip.js → clip.ts} +26 -9
- package/src/data-filter/{aggregator.js → aggregator.ts} +12 -8
- package/src/data-filter/{data-filter.js → data-filter.ts} +90 -13
- package/src/data-filter/{shader-module.js → shader-module.ts} +36 -27
- package/src/fill-style/{fill-style.js → fill-style.ts} +83 -19
- package/src/fill-style/{shaders.glsl.js → shaders.glsl.ts} +24 -4
- package/src/fp64/{fp64.js → fp64.ts} +6 -3
- package/src/fp64/{project64.glsl.js → project64.glsl.ts} +0 -0
- package/src/fp64/{project64.js → project64.ts} +16 -5
- package/src/index.ts +8 -0
- package/src/mask/{mask.js → mask.ts} +25 -8
- package/src/mask/shader-module.ts +86 -0
- package/src/path-style/{path-style.js → path-style.ts} +65 -14
- package/src/path-style/{shaders.glsl.js → shaders.glsl.ts} +0 -0
- package/typed/brushing/brushing.d.ts +40 -0
- package/typed/brushing/brushing.d.ts.map +1 -0
- package/typed/brushing/brushing.js +83 -0
- package/typed/brushing/shader-module.d.ts +12 -0
- package/typed/brushing/shader-module.d.ts.map +1 -0
- package/typed/brushing/shader-module.js +116 -0
- package/typed/clip/clip.d.ts +29 -0
- package/typed/clip/clip.d.ts.map +1 -0
- package/typed/clip/clip.js +114 -0
- package/typed/data-filter/aggregator.d.ts +11 -0
- package/typed/data-filter/aggregator.d.ts.map +1 -0
- package/typed/data-filter/aggregator.js +98 -0
- package/typed/data-filter/data-filter.d.ts +90 -0
- package/typed/data-filter/data-filter.d.ts.map +1 -0
- package/typed/data-filter/data-filter.js +159 -0
- package/typed/data-filter/shader-module.d.ts +9 -0
- package/typed/data-filter/shader-module.d.ts.map +1 -0
- package/typed/data-filter/shader-module.js +152 -0
- package/typed/fill-style/fill-style.d.ts +77 -0
- package/typed/fill-style/fill-style.d.ts.map +1 -0
- package/typed/fill-style/fill-style.js +152 -0
- package/typed/fill-style/shaders.glsl.d.ts +12 -0
- package/typed/fill-style/shaders.glsl.d.ts.map +1 -0
- package/typed/fill-style/shaders.glsl.js +95 -0
- package/typed/fp64/fp64.d.ts +8 -0
- package/typed/fp64/fp64.d.ts.map +1 -0
- package/typed/fp64/fp64.js +34 -0
- package/typed/fp64/project64.d.ts +7 -0
- package/typed/fp64/project64.d.ts.map +1 -0
- package/typed/fp64/project64.glsl.d.ts +3 -0
- package/typed/fp64/project64.glsl.d.ts.map +1 -0
- package/typed/fp64/project64.glsl.js +100 -0
- package/typed/fp64/project64.js +50 -0
- package/typed/index.d.ts +15 -0
- package/typed/index.d.ts.map +1 -0
- package/typed/index.js +9 -0
- package/typed/mask/mask.d.ts +24 -0
- package/typed/mask/mask.d.ts.map +1 -0
- package/typed/mask/mask.js +48 -0
- package/typed/mask/shader-module.d.ts +8 -0
- package/typed/mask/shader-module.d.ts.map +1 -0
- package/{src → typed}/mask/shader-module.js +16 -21
- package/typed/package.json +6 -0
- package/typed/path-style/path-style.d.ts +66 -0
- package/typed/path-style/path-style.d.ts.map +1 -0
- package/typed/path-style/path-style.js +107 -0
- package/typed/path-style/shaders.glsl.d.ts +17 -0
- package/typed/path-style/shaders.glsl.d.ts.map +1 -0
- package/typed/path-style/shaders.glsl.js +93 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {project} from '@deck.gl/core';
|
|
2
|
-
|
|
1
|
+
import { project } from '@deck.gl/core';
|
|
3
2
|
const vs = `
|
|
4
3
|
uniform vec4 mask_bounds;
|
|
5
4
|
uniform bool mask_maskByInstance;
|
|
@@ -7,7 +6,6 @@ vec2 mask_getCoords(vec4 position) {
|
|
|
7
6
|
return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);
|
|
8
7
|
}
|
|
9
8
|
`;
|
|
10
|
-
|
|
11
9
|
const fs = `
|
|
12
10
|
uniform sampler2D mask_texture;
|
|
13
11
|
uniform int mask_channel;
|
|
@@ -30,12 +28,11 @@ bool mask_isInBounds(vec2 texCoords) {
|
|
|
30
28
|
return maskValue < 0.5;
|
|
31
29
|
}
|
|
32
30
|
`;
|
|
33
|
-
|
|
34
31
|
const inject = {
|
|
35
|
-
|
|
32
|
+
'vs:#decl': `
|
|
36
33
|
varying vec2 mask_texCoords;
|
|
37
34
|
`,
|
|
38
|
-
|
|
35
|
+
'vs:#main-end': `
|
|
39
36
|
vec4 mask_common_position;
|
|
40
37
|
if (mask_maskByInstance) {
|
|
41
38
|
mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
@@ -44,10 +41,10 @@ varying vec2 mask_texCoords;
|
|
|
44
41
|
}
|
|
45
42
|
mask_texCoords = mask_getCoords(mask_common_position);
|
|
46
43
|
`,
|
|
47
|
-
|
|
44
|
+
'fs:#decl': `
|
|
48
45
|
varying vec2 mask_texCoords;
|
|
49
46
|
`,
|
|
50
|
-
|
|
47
|
+
'fs:#main-start': `
|
|
51
48
|
if (mask_enabled) {
|
|
52
49
|
bool mask = mask_isInBounds(mask_texCoords);
|
|
53
50
|
|
|
@@ -59,20 +56,18 @@ varying vec2 mask_texCoords;
|
|
|
59
56
|
}
|
|
60
57
|
`
|
|
61
58
|
};
|
|
62
|
-
|
|
63
59
|
const getMaskUniforms = (opts = {}) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
const uniforms = {};
|
|
61
|
+
if (opts.maskMap) {
|
|
62
|
+
uniforms.mask_texture = opts.maskMap;
|
|
63
|
+
}
|
|
64
|
+
return uniforms;
|
|
69
65
|
};
|
|
70
|
-
|
|
71
66
|
export default {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
name: 'mask',
|
|
68
|
+
dependencies: [project],
|
|
69
|
+
vs,
|
|
70
|
+
fs,
|
|
71
|
+
inject,
|
|
72
|
+
getUniforms: getMaskUniforms
|
|
78
73
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { LayerExtension } from '@deck.gl/core/typed';
|
|
2
|
+
import type { Layer, LayerContext, Accessor, UpdateParameters } from '@deck.gl/core/typed';
|
|
3
|
+
export declare type PathStyleExtensionProps<DataT = any> = {
|
|
4
|
+
/**
|
|
5
|
+
* Accessor for the dash array to draw each path with: `[dashSize, gapSize]` relative to the width of the path.
|
|
6
|
+
* Requires the `dash` option to be on.
|
|
7
|
+
*/
|
|
8
|
+
getDashArray?: Accessor<DataT, [number, number]>;
|
|
9
|
+
/**
|
|
10
|
+
* Accessor for the offset to draw each path with, relative to the width of the path.
|
|
11
|
+
* Negative offset is to the left hand side, and positive offset is to the right hand side.
|
|
12
|
+
* @default 0
|
|
13
|
+
*/
|
|
14
|
+
getOffset?: Accessor<DataT, number>;
|
|
15
|
+
/**
|
|
16
|
+
* If `true`, adjust gaps for the dashes to align at both ends.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
dashJustified?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* If `true`, gaps between solid strokes are pickable. If `false`, only the solid strokes are pickable.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
dashGapPickable?: boolean;
|
|
25
|
+
};
|
|
26
|
+
declare type PathStyleExtensionOptions = {
|
|
27
|
+
/**
|
|
28
|
+
* Add capability to render dashed lines.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
dash: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Add capability to offset lines.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
offset: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Improve dash rendering quality in certain circumstances. Note that this option introduces additional performance overhead.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
highPrecisionDash: boolean;
|
|
42
|
+
};
|
|
43
|
+
/** Adds selected features to the `PathLayer` and composite layers that render the `PathLayer`. */
|
|
44
|
+
export default class PathStyleExtension extends LayerExtension<PathStyleExtensionOptions> {
|
|
45
|
+
static defaultProps: {
|
|
46
|
+
getDashArray: {
|
|
47
|
+
type: string;
|
|
48
|
+
value: number[];
|
|
49
|
+
};
|
|
50
|
+
getOffset: {
|
|
51
|
+
type: string;
|
|
52
|
+
value: number;
|
|
53
|
+
};
|
|
54
|
+
dashJustified: boolean;
|
|
55
|
+
dashGapPickable: boolean;
|
|
56
|
+
};
|
|
57
|
+
static extensionName: string;
|
|
58
|
+
constructor({ dash, offset, highPrecisionDash }?: Partial<PathStyleExtensionOptions>);
|
|
59
|
+
isEnabled(layer: Layer<PathStyleExtensionProps>): boolean;
|
|
60
|
+
getShaders(this: Layer<PathStyleExtensionProps>, extension: this): any;
|
|
61
|
+
initializeState(this: Layer<PathStyleExtensionProps>, context: LayerContext, extension: this): void;
|
|
62
|
+
updateState(this: Layer<PathStyleExtensionProps>, params: UpdateParameters<Layer<PathStyleExtensionProps>>, extension: this): void;
|
|
63
|
+
getDashOffsets(this: Layer<PathStyleExtensionProps>, path: number[] | number[][]): number[];
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=path-style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-style.d.ts","sourceRoot":"","sources":["../../src/path-style/path-style.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,cAAc,EAAgC,MAAM,eAAe,CAAC;AAI5E,OAAO,KAAK,EAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AASnF,oBAAY,uBAAuB,CAAC,KAAK,GAAG,GAAG,IAAI;IACjD;;;OAGG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD;;;;OAIG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACpC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,aAAK,yBAAyB,GAAG;IAC/B;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,kGAAkG;AAClG,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,cAAc,CAAC,yBAAyB,CAAC;IACvF,MAAM,CAAC,YAAY;;;;;;;;;;;MAAgB;IACnC,MAAM,CAAC,aAAa,SAAwB;gBAEhC,EACV,IAAY,EACZ,MAAc,EACd,iBAAyB,EAC1B,GAAE,OAAO,CAAC,yBAAyB,CAAM;IAI1C,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,uBAAuB,CAAC,GAAG,OAAO;IAIzD,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,uBAAuB,CAAC,EAAE,SAAS,EAAE,IAAI,GAAG,GAAG;IAiBtE,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,uBAAuB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI;IA4B5F,WAAW,CACT,IAAI,EAAE,KAAK,CAAC,uBAAuB,CAAC,EACpC,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,EACxD,SAAS,EAAE,IAAI;IAgBjB,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,uBAAuB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE;CAoB5F"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
import { LayerExtension, _mergeShaders as mergeShaders } from '@deck.gl/core';
|
|
21
|
+
import { dashShaders, offsetShaders } from './shaders.glsl';
|
|
22
|
+
import { dist } from 'gl-matrix/vec3';
|
|
23
|
+
const defaultProps = {
|
|
24
|
+
getDashArray: { type: 'accessor', value: [0, 0] },
|
|
25
|
+
getOffset: { type: 'accessor', value: 0 },
|
|
26
|
+
dashJustified: false,
|
|
27
|
+
dashGapPickable: false
|
|
28
|
+
};
|
|
29
|
+
export default class PathStyleExtension extends LayerExtension {
|
|
30
|
+
constructor({ dash = false, offset = false, highPrecisionDash = false } = {}) {
|
|
31
|
+
super({ dash: dash || highPrecisionDash, offset, highPrecisionDash });
|
|
32
|
+
}
|
|
33
|
+
isEnabled(layer) {
|
|
34
|
+
return layer.state.pathTesselator;
|
|
35
|
+
}
|
|
36
|
+
getShaders(extension) {
|
|
37
|
+
if (!extension.isEnabled(this)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
// Merge shader injection
|
|
41
|
+
let result = {};
|
|
42
|
+
if (extension.opts.dash) {
|
|
43
|
+
result = mergeShaders(result, dashShaders);
|
|
44
|
+
}
|
|
45
|
+
if (extension.opts.offset) {
|
|
46
|
+
result = mergeShaders(result, offsetShaders);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
initializeState(context, extension) {
|
|
51
|
+
const attributeManager = this.getAttributeManager();
|
|
52
|
+
if (!attributeManager || !extension.isEnabled(this)) {
|
|
53
|
+
// This extension only works with the PathLayer
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
extension.enabled = true;
|
|
57
|
+
if (extension.opts.dash) {
|
|
58
|
+
attributeManager.addInstanced({
|
|
59
|
+
instanceDashArrays: { size: 2, accessor: 'getDashArray' }
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (extension.opts.highPrecisionDash) {
|
|
63
|
+
attributeManager.addInstanced({
|
|
64
|
+
instanceDashOffsets: {
|
|
65
|
+
size: 1,
|
|
66
|
+
accessor: 'getPath',
|
|
67
|
+
transform: extension.getDashOffsets.bind(this)
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (extension.opts.offset) {
|
|
72
|
+
attributeManager.addInstanced({
|
|
73
|
+
instanceOffsets: { size: 1, accessor: 'getOffset' }
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
updateState(params, extension) {
|
|
78
|
+
if (!extension.isEnabled(this)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const uniforms = {};
|
|
82
|
+
if (extension.opts.dash) {
|
|
83
|
+
uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
|
|
84
|
+
uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
|
|
85
|
+
}
|
|
86
|
+
this.state.model.setUniforms(uniforms);
|
|
87
|
+
}
|
|
88
|
+
getDashOffsets(path) {
|
|
89
|
+
const result = [0];
|
|
90
|
+
const positionSize = this.props.positionFormat === 'XY' ? 2 : 3;
|
|
91
|
+
const isNested = Array.isArray(path[0]);
|
|
92
|
+
const geometrySize = isNested ? path.length : path.length / positionSize;
|
|
93
|
+
let p;
|
|
94
|
+
let prevP;
|
|
95
|
+
for (let i = 0; i < geometrySize - 1; i++) {
|
|
96
|
+
p = isNested ? path[i] : path.slice(i * positionSize, i * positionSize + positionSize);
|
|
97
|
+
p = this.projectPosition(p);
|
|
98
|
+
if (i > 0) {
|
|
99
|
+
result[i] = result[i - 1] + dist(prevP, p);
|
|
100
|
+
}
|
|
101
|
+
prevP = p;
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
PathStyleExtension.extensionName = 'PathStyleExtension';
|
|
107
|
+
PathStyleExtension.defaultProps = defaultProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const dashShaders: {
|
|
2
|
+
inject: {
|
|
3
|
+
'vs:#decl': string;
|
|
4
|
+
'vs:#main-end': string;
|
|
5
|
+
'fs:#decl': string;
|
|
6
|
+
'fs:#main-start': string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const offsetShaders: {
|
|
10
|
+
inject: {
|
|
11
|
+
'vs:#decl': string;
|
|
12
|
+
'vs:DECKGL_FILTER_SIZE': string;
|
|
13
|
+
'vCornerOffset = offsetVec;': string;
|
|
14
|
+
'fs:#main-start': string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=shaders.glsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shaders.glsl.d.ts","sourceRoot":"","sources":["../../src/path-style/shaders.glsl.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;;CAwEvB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;CAsBzB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export const dashShaders = {
|
|
2
|
+
inject: {
|
|
3
|
+
'vs:#decl': `
|
|
4
|
+
attribute vec2 instanceDashArrays;
|
|
5
|
+
attribute float instanceDashOffsets;
|
|
6
|
+
varying vec2 vDashArray;
|
|
7
|
+
varying float vDashOffset;
|
|
8
|
+
`,
|
|
9
|
+
'vs:#main-end': `
|
|
10
|
+
vDashArray = instanceDashArrays;
|
|
11
|
+
vDashOffset = instanceDashOffsets / width.x;
|
|
12
|
+
`,
|
|
13
|
+
'fs:#decl': `
|
|
14
|
+
uniform float dashAlignMode;
|
|
15
|
+
uniform float capType;
|
|
16
|
+
uniform bool dashGapPickable;
|
|
17
|
+
varying vec2 vDashArray;
|
|
18
|
+
varying float vDashOffset;
|
|
19
|
+
|
|
20
|
+
float round(float x) {
|
|
21
|
+
return floor(x + 0.5);
|
|
22
|
+
}
|
|
23
|
+
`,
|
|
24
|
+
// if given position is in the gap part of the dashed line
|
|
25
|
+
// dashArray.x: solid stroke length, relative to width
|
|
26
|
+
// dashArray.y: gap length, relative to width
|
|
27
|
+
// alignMode:
|
|
28
|
+
// 0 - no adjustment
|
|
29
|
+
// o---- ---- ---- ---- o---- -o---- ---- o
|
|
30
|
+
// 1 - stretch to fit, draw half dash at each end for nicer joints
|
|
31
|
+
// o-- ---- ---- ---- --o-- --o-- ---- --o
|
|
32
|
+
'fs:#main-start': `
|
|
33
|
+
float solidLength = vDashArray.x;
|
|
34
|
+
float gapLength = vDashArray.y;
|
|
35
|
+
float unitLength = solidLength + gapLength;
|
|
36
|
+
|
|
37
|
+
float offset;
|
|
38
|
+
|
|
39
|
+
if (unitLength > 0.0) {
|
|
40
|
+
if (dashAlignMode == 0.0) {
|
|
41
|
+
offset = vDashOffset;
|
|
42
|
+
} else {
|
|
43
|
+
unitLength = vPathLength / round(vPathLength / unitLength);
|
|
44
|
+
offset = solidLength / 2.0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
float unitOffset = mod(clamp(vPathPosition.y, 0.0, vPathLength) + offset, unitLength);
|
|
48
|
+
|
|
49
|
+
if (gapLength > 0.0 && unitOffset > solidLength) {
|
|
50
|
+
if (capType <= 0.5) {
|
|
51
|
+
if (!(dashGapPickable && picking_uActive)) {
|
|
52
|
+
discard;
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
// caps are rounded, test the distance to solid ends
|
|
56
|
+
float distToEnd = length(vec2(
|
|
57
|
+
min(unitOffset - solidLength, unitLength - unitOffset),
|
|
58
|
+
vPathPosition.x
|
|
59
|
+
));
|
|
60
|
+
if (distToEnd > 1.0) {
|
|
61
|
+
if (!(dashGapPickable && picking_uActive)) {
|
|
62
|
+
discard;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
export const offsetShaders = {
|
|
72
|
+
inject: {
|
|
73
|
+
'vs:#decl': `
|
|
74
|
+
attribute float instanceOffsets;
|
|
75
|
+
`,
|
|
76
|
+
'vs:DECKGL_FILTER_SIZE': `
|
|
77
|
+
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
78
|
+
size *= offsetWidth;
|
|
79
|
+
`,
|
|
80
|
+
'vCornerOffset = offsetVec;': `
|
|
81
|
+
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
82
|
+
vec2 offsetCenter = -instanceOffsets * (isCap ? perp : miterVec * miterSize) * 2.0;
|
|
83
|
+
vCornerOffset = vCornerOffset * offsetWidth - offsetCenter;
|
|
84
|
+
`,
|
|
85
|
+
'fs:#main-start': `
|
|
86
|
+
float isInside;
|
|
87
|
+
isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
|
|
88
|
+
if (isInside == 0.0) {
|
|
89
|
+
discard;
|
|
90
|
+
}
|
|
91
|
+
`
|
|
92
|
+
}
|
|
93
|
+
};
|