@deck.gl/extensions 9.0.0-beta.1 → 9.0.0-beta.3
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/brushing/brushing-extension.js +80 -0
- package/dist/{esm/brushing → brushing}/shader-module.js +24 -30
- package/dist/clip/clip-extension.js +117 -0
- package/{typed → dist}/collision-filter/collision-filter-effect.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-effect.js +193 -0
- package/dist/collision-filter/collision-filter-extension.js +49 -0
- package/{typed → dist}/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-pass.js +25 -0
- package/dist/{esm/collision-filter → collision-filter}/shader-module.js +17 -24
- package/dist/data-filter/aggregator.js +104 -0
- package/{typed → dist}/data-filter/data-filter-extension.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.js +162 -0
- package/dist/data-filter/shader-module.js +159 -0
- package/dist/dist.dev.js +1519 -9832
- package/dist/fill-style/fill-style-extension.js +118 -0
- package/dist/{esm/fill-style → fill-style}/shaders.glsl.js +37 -43
- package/dist/fp64/fp64-extension.js +35 -0
- package/dist/{esm/fp64 → fp64}/project64.glsl.js +19 -1
- package/dist/fp64/project64.js +50 -0
- package/dist/index.cjs +2724 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +11 -0
- package/{typed → dist}/mask/mask-effect.d.ts.map +1 -1
- package/dist/mask/mask-effect.js +194 -0
- package/dist/mask/mask-extension.js +57 -0
- package/{typed → dist}/mask/mask-pass.d.ts.map +1 -1
- package/dist/mask/mask-pass.js +44 -0
- package/dist/{esm/mask → mask}/shader-module.js +18 -21
- package/dist/path-style/path-style-extension.js +111 -0
- package/dist/{esm/path-style → path-style}/shaders.glsl.js +20 -13
- package/dist/terrain/height-map-builder.js +104 -0
- package/dist/terrain/shader-module.js +139 -0
- package/dist/terrain/terrain-cover.js +187 -0
- package/{typed → dist}/terrain/terrain-effect.d.ts.map +1 -1
- package/dist/terrain/terrain-effect.js +184 -0
- package/dist/terrain/terrain-extension.js +44 -0
- package/{typed → dist}/terrain/terrain-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-pass.js +61 -0
- package/{typed → dist}/terrain/terrain-picking-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-picking-pass.js +66 -0
- package/dist/terrain/utils.js +21 -0
- package/{typed → dist}/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +50 -0
- package/dist/utils/projection-utils.js +153 -0
- package/dist.min.js +72 -201
- package/package.json +19 -12
- package/src/collision-filter/collision-filter-effect.ts +12 -8
- package/src/collision-filter/collision-filter-pass.ts +1 -3
- package/src/data-filter/data-filter-extension.ts +3 -5
- package/src/mask/mask-effect.ts +0 -1
- package/src/mask/mask-pass.ts +1 -3
- package/src/terrain/terrain-effect.ts +8 -2
- package/src/terrain/terrain-pass.ts +2 -5
- package/src/terrain/terrain-picking-pass.ts +1 -3
- package/src/utils/debug.ts +1 -2
- package/dist/es5/brushing/brushing-extension.js +0 -108
- package/dist/es5/brushing/brushing-extension.js.map +0 -1
- package/dist/es5/brushing/shader-module.js +0 -50
- package/dist/es5/brushing/shader-module.js.map +0 -1
- package/dist/es5/clip/clip-extension.js +0 -98
- package/dist/es5/clip/clip-extension.js.map +0 -1
- package/dist/es5/collision-filter/collision-filter-effect.js +0 -294
- package/dist/es5/collision-filter/collision-filter-effect.js.map +0 -1
- package/dist/es5/collision-filter/collision-filter-extension.js +0 -109
- package/dist/es5/collision-filter/collision-filter-extension.js.map +0 -1
- package/dist/es5/collision-filter/collision-filter-pass.js +0 -79
- package/dist/es5/collision-filter/collision-filter-pass.js.map +0 -1
- package/dist/es5/collision-filter/shader-module.js +0 -39
- package/dist/es5/collision-filter/shader-module.js.map +0 -1
- package/dist/es5/data-filter/aggregator.js +0 -79
- package/dist/es5/data-filter/aggregator.js.map +0 -1
- package/dist/es5/data-filter/data-filter-extension.js +0 -236
- package/dist/es5/data-filter/data-filter-extension.js.map +0 -1
- package/dist/es5/data-filter/shader-module.js +0 -122
- package/dist/es5/data-filter/shader-module.js.map +0 -1
- package/dist/es5/fill-style/fill-style-extension.js +0 -190
- package/dist/es5/fill-style/fill-style-extension.js.map +0 -1
- package/dist/es5/fill-style/shaders.glsl.js +0 -59
- package/dist/es5/fill-style/shaders.glsl.js.map +0 -1
- package/dist/es5/fp64/fp64-extension.js +0 -55
- package/dist/es5/fp64/fp64-extension.js.map +0 -1
- package/dist/es5/fp64/project64.glsl.js +0 -9
- package/dist/es5/fp64/project64.glsl.js.map +0 -1
- package/dist/es5/fp64/project64.js +0 -52
- package/dist/es5/fp64/project64.js.map +0 -1
- package/dist/es5/index.js +0 -88
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/mask/mask-effect.js +0 -279
- package/dist/es5/mask/mask-effect.js.map +0 -1
- package/dist/es5/mask/mask-extension.js +0 -113
- package/dist/es5/mask/mask-extension.js.map +0 -1
- package/dist/es5/mask/mask-pass.js +0 -106
- package/dist/es5/mask/mask-pass.js.map +0 -1
- package/dist/es5/mask/shader-module.js +0 -38
- package/dist/es5/mask/shader-module.js.map +0 -1
- package/dist/es5/path-style/path-style-extension.js +0 -169
- package/dist/es5/path-style/path-style-extension.js.map +0 -1
- package/dist/es5/path-style/shaders.glsl.js +0 -25
- package/dist/es5/path-style/shaders.glsl.js.map +0 -1
- package/dist/es5/terrain/height-map-builder.js +0 -111
- package/dist/es5/terrain/height-map-builder.js.map +0 -1
- package/dist/es5/terrain/shader-module.js +0 -86
- package/dist/es5/terrain/shader-module.js.map +0 -1
- package/dist/es5/terrain/terrain-cover.js +0 -256
- package/dist/es5/terrain/terrain-cover.js.map +0 -1
- package/dist/es5/terrain/terrain-effect.js +0 -326
- package/dist/es5/terrain/terrain-effect.js.map +0 -1
- package/dist/es5/terrain/terrain-extension.js +0 -94
- package/dist/es5/terrain/terrain-extension.js.map +0 -1
- package/dist/es5/terrain/terrain-pass.js +0 -121
- package/dist/es5/terrain/terrain-pass.js.map +0 -1
- package/dist/es5/terrain/terrain-picking-pass.js +0 -124
- package/dist/es5/terrain/terrain-picking-pass.js.map +0 -1
- package/dist/es5/terrain/utils.js +0 -35
- package/dist/es5/terrain/utils.js.map +0 -1
- package/dist/es5/utils/debug.js +0 -71
- package/dist/es5/utils/debug.js.map +0 -1
- package/dist/es5/utils/projection-utils.js +0 -168
- package/dist/es5/utils/projection-utils.js.map +0 -1
- package/dist/esm/brushing/brushing-extension.js +0 -68
- package/dist/esm/brushing/brushing-extension.js.map +0 -1
- package/dist/esm/brushing/shader-module.js.map +0 -1
- package/dist/esm/clip/clip-extension.js +0 -86
- package/dist/esm/clip/clip-extension.js.map +0 -1
- package/dist/esm/collision-filter/collision-filter-effect.js +0 -246
- package/dist/esm/collision-filter/collision-filter-effect.js.map +0 -1
- package/dist/esm/collision-filter/collision-filter-extension.js +0 -75
- package/dist/esm/collision-filter/collision-filter-extension.js.map +0 -1
- package/dist/esm/collision-filter/collision-filter-pass.js +0 -32
- package/dist/esm/collision-filter/collision-filter-pass.js.map +0 -1
- package/dist/esm/collision-filter/shader-module.js.map +0 -1
- package/dist/esm/data-filter/aggregator.js +0 -102
- package/dist/esm/data-filter/aggregator.js.map +0 -1
- package/dist/esm/data-filter/data-filter-extension.js +0 -189
- package/dist/esm/data-filter/data-filter-extension.js.map +0 -1
- package/dist/esm/data-filter/shader-module.js +0 -164
- package/dist/esm/data-filter/shader-module.js.map +0 -1
- package/dist/esm/fill-style/fill-style-extension.js +0 -156
- package/dist/esm/fill-style/fill-style-extension.js.map +0 -1
- package/dist/esm/fill-style/shaders.glsl.js.map +0 -1
- package/dist/esm/fp64/fp64-extension.js +0 -20
- package/dist/esm/fp64/fp64-extension.js.map +0 -1
- package/dist/esm/fp64/project64.glsl.js.map +0 -1
- package/dist/esm/fp64/project64.js +0 -43
- package/dist/esm/fp64/project64.js.map +0 -1
- package/dist/esm/index.js +0 -11
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/mask/mask-effect.js +0 -228
- package/dist/esm/mask/mask-effect.js.map +0 -1
- package/dist/esm/mask/mask-extension.js +0 -83
- package/dist/esm/mask/mask-extension.js.map +0 -1
- package/dist/esm/mask/mask-pass.js +0 -58
- package/dist/esm/mask/mask-pass.js.map +0 -1
- package/dist/esm/mask/shader-module.js.map +0 -1
- package/dist/esm/path-style/path-style-extension.js +0 -130
- package/dist/esm/path-style/path-style-extension.js.map +0 -1
- package/dist/esm/path-style/shaders.glsl.js.map +0 -1
- package/dist/esm/terrain/height-map-builder.js +0 -86
- package/dist/esm/terrain/height-map-builder.js.map +0 -1
- package/dist/esm/terrain/shader-module.js +0 -127
- package/dist/esm/terrain/shader-module.js.map +0 -1
- package/dist/esm/terrain/terrain-cover.js +0 -212
- package/dist/esm/terrain/terrain-cover.js.map +0 -1
- package/dist/esm/terrain/terrain-effect.js +0 -219
- package/dist/esm/terrain/terrain-effect.js.map +0 -1
- package/dist/esm/terrain/terrain-extension.js +0 -59
- package/dist/esm/terrain/terrain-extension.js.map +0 -1
- package/dist/esm/terrain/terrain-pass.js +0 -71
- package/dist/esm/terrain/terrain-pass.js.map +0 -1
- package/dist/esm/terrain/terrain-picking-pass.js +0 -73
- package/dist/esm/terrain/terrain-picking-pass.js.map +0 -1
- package/dist/esm/terrain/utils.js +0 -19
- package/dist/esm/terrain/utils.js.map +0 -1
- package/dist/esm/utils/debug.js +0 -61
- package/dist/esm/utils/debug.js.map +0 -1
- package/dist/esm/utils/projection-utils.js +0 -134
- package/dist/esm/utils/projection-utils.js.map +0 -1
- /package/{typed → dist}/brushing/brushing-extension.d.ts +0 -0
- /package/{typed → dist}/brushing/brushing-extension.d.ts.map +0 -0
- /package/{typed → dist}/brushing/shader-module.d.ts +0 -0
- /package/{typed → dist}/brushing/shader-module.d.ts.map +0 -0
- /package/{typed → dist}/clip/clip-extension.d.ts +0 -0
- /package/{typed → dist}/clip/clip-extension.d.ts.map +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-effect.d.ts +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-extension.d.ts +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-extension.d.ts.map +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-pass.d.ts +0 -0
- /package/{typed → dist}/collision-filter/shader-module.d.ts +0 -0
- /package/{typed → dist}/collision-filter/shader-module.d.ts.map +0 -0
- /package/{typed → dist}/data-filter/aggregator.d.ts +0 -0
- /package/{typed → dist}/data-filter/aggregator.d.ts.map +0 -0
- /package/{typed → dist}/data-filter/data-filter-extension.d.ts +0 -0
- /package/{typed → dist}/data-filter/shader-module.d.ts +0 -0
- /package/{typed → dist}/data-filter/shader-module.d.ts.map +0 -0
- /package/{typed → dist}/fill-style/fill-style-extension.d.ts +0 -0
- /package/{typed → dist}/fill-style/fill-style-extension.d.ts.map +0 -0
- /package/{typed → dist}/fill-style/shaders.glsl.d.ts +0 -0
- /package/{typed → dist}/fill-style/shaders.glsl.d.ts.map +0 -0
- /package/{typed → dist}/fp64/fp64-extension.d.ts +0 -0
- /package/{typed → dist}/fp64/fp64-extension.d.ts.map +0 -0
- /package/{typed → dist}/fp64/project64.d.ts +0 -0
- /package/{typed → dist}/fp64/project64.d.ts.map +0 -0
- /package/{typed → dist}/fp64/project64.glsl.d.ts +0 -0
- /package/{typed → dist}/fp64/project64.glsl.d.ts.map +0 -0
- /package/{typed → dist}/index.d.ts +0 -0
- /package/{typed → dist}/index.d.ts.map +0 -0
- /package/{typed → dist}/mask/mask-effect.d.ts +0 -0
- /package/{typed → dist}/mask/mask-extension.d.ts +0 -0
- /package/{typed → dist}/mask/mask-extension.d.ts.map +0 -0
- /package/{typed → dist}/mask/mask-pass.d.ts +0 -0
- /package/{typed → dist}/mask/shader-module.d.ts +0 -0
- /package/{typed → dist}/mask/shader-module.d.ts.map +0 -0
- /package/{typed → dist}/path-style/path-style-extension.d.ts +0 -0
- /package/{typed → dist}/path-style/path-style-extension.d.ts.map +0 -0
- /package/{typed → dist}/path-style/shaders.glsl.d.ts +0 -0
- /package/{typed → dist}/path-style/shaders.glsl.d.ts.map +0 -0
- /package/{typed → dist}/terrain/height-map-builder.d.ts +0 -0
- /package/{typed → dist}/terrain/height-map-builder.d.ts.map +0 -0
- /package/{typed → dist}/terrain/shader-module.d.ts +0 -0
- /package/{typed → dist}/terrain/shader-module.d.ts.map +0 -0
- /package/{typed → dist}/terrain/terrain-cover.d.ts +0 -0
- /package/{typed → dist}/terrain/terrain-cover.d.ts.map +0 -0
- /package/{typed → dist}/terrain/terrain-effect.d.ts +0 -0
- /package/{typed → dist}/terrain/terrain-extension.d.ts +0 -0
- /package/{typed → dist}/terrain/terrain-extension.d.ts.map +0 -0
- /package/{typed → dist}/terrain/terrain-pass.d.ts +0 -0
- /package/{typed → dist}/terrain/terrain-picking-pass.d.ts +0 -0
- /package/{typed → dist}/terrain/utils.d.ts +0 -0
- /package/{typed → dist}/terrain/utils.d.ts.map +0 -0
- /package/{typed → dist}/utils/debug.d.ts +0 -0
- /package/{typed → dist}/utils/projection-utils.d.ts +0 -0
- /package/{typed → dist}/utils/projection-utils.d.ts.map +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { WebMercatorViewport, OrthographicViewport } from '@deck.gl/core';
|
|
2
|
+
/*
|
|
3
|
+
* Compute the union of bounds from multiple layers
|
|
4
|
+
* Returns bounds in CARTESIAN coordinates
|
|
5
|
+
*/
|
|
6
|
+
export function joinLayerBounds(
|
|
7
|
+
/** The layers to combine */
|
|
8
|
+
layers,
|
|
9
|
+
/** A Viewport instance that is used to determine the type of the view */
|
|
10
|
+
viewport) {
|
|
11
|
+
// Join the bounds of layer data
|
|
12
|
+
const bounds = [Infinity, Infinity, -Infinity, -Infinity];
|
|
13
|
+
for (const layer of layers) {
|
|
14
|
+
const layerBounds = layer.getBounds();
|
|
15
|
+
if (layerBounds) {
|
|
16
|
+
const bottomLeftCommon = layer.projectPosition(layerBounds[0], { viewport, autoOffset: false });
|
|
17
|
+
const topRightCommon = layer.projectPosition(layerBounds[1], { viewport, autoOffset: false });
|
|
18
|
+
bounds[0] = Math.min(bounds[0], bottomLeftCommon[0]);
|
|
19
|
+
bounds[1] = Math.min(bounds[1], bottomLeftCommon[1]);
|
|
20
|
+
bounds[2] = Math.max(bounds[2], topRightCommon[0]);
|
|
21
|
+
bounds[3] = Math.max(bounds[3], topRightCommon[1]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (Number.isFinite(bounds[0])) {
|
|
25
|
+
return bounds;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const MAX_VIEWPORT_SIZE = 2048;
|
|
30
|
+
/** Construct a viewport that just covers the target bounds. Used for rendering to common space indexed texture. */
|
|
31
|
+
export function makeViewport(opts) {
|
|
32
|
+
const { bounds, viewport, border = 0 } = opts;
|
|
33
|
+
const { isGeospatial } = viewport;
|
|
34
|
+
if (bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const centerWorld = viewport.unprojectPosition([
|
|
38
|
+
(bounds[0] + bounds[2]) / 2,
|
|
39
|
+
(bounds[1] + bounds[3]) / 2,
|
|
40
|
+
0
|
|
41
|
+
]);
|
|
42
|
+
let { width, height, zoom } = opts;
|
|
43
|
+
if (zoom === undefined) {
|
|
44
|
+
// Use width and height to determine zoom
|
|
45
|
+
width = width - border * 2;
|
|
46
|
+
height = height - border * 2;
|
|
47
|
+
const scale = Math.min(width / (bounds[2] - bounds[0]), height / (bounds[3] - bounds[1]));
|
|
48
|
+
zoom = Math.min(Math.log2(scale), 20);
|
|
49
|
+
}
|
|
50
|
+
else if (!width || !height) {
|
|
51
|
+
// Use zoom to determine width and height
|
|
52
|
+
const scale = 2 ** zoom;
|
|
53
|
+
width = Math.round(Math.abs(bounds[2] - bounds[0]) * scale);
|
|
54
|
+
height = Math.round(Math.abs(bounds[3] - bounds[1]) * scale);
|
|
55
|
+
const maxSize = MAX_VIEWPORT_SIZE - border * 2;
|
|
56
|
+
if (width > maxSize || height > maxSize) {
|
|
57
|
+
const r = maxSize / Math.max(width, height);
|
|
58
|
+
width = Math.round(width * r);
|
|
59
|
+
height = Math.round(height * r);
|
|
60
|
+
zoom += Math.log2(r);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// TODO - find a more generic way to construct this viewport
|
|
64
|
+
// Geospatial viewports may not be web-mercator
|
|
65
|
+
return isGeospatial
|
|
66
|
+
? new WebMercatorViewport({
|
|
67
|
+
id: viewport.id,
|
|
68
|
+
x: border,
|
|
69
|
+
y: border,
|
|
70
|
+
width,
|
|
71
|
+
height,
|
|
72
|
+
longitude: centerWorld[0],
|
|
73
|
+
latitude: centerWorld[1],
|
|
74
|
+
zoom,
|
|
75
|
+
orthographic: true
|
|
76
|
+
})
|
|
77
|
+
: new OrthographicViewport({
|
|
78
|
+
id: viewport.id,
|
|
79
|
+
x: border,
|
|
80
|
+
y: border,
|
|
81
|
+
width,
|
|
82
|
+
height,
|
|
83
|
+
target: centerWorld,
|
|
84
|
+
zoom,
|
|
85
|
+
flipY: false
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** Returns viewport bounds in CARTESIAN coordinates */
|
|
89
|
+
export function getViewportBounds(viewport, zRange) {
|
|
90
|
+
// Viewport bounds in world coordinates
|
|
91
|
+
let viewportBoundsWorld;
|
|
92
|
+
if (zRange && zRange.length === 2) {
|
|
93
|
+
const [minZ, maxZ] = zRange;
|
|
94
|
+
const bounds0 = viewport.getBounds({ z: minZ });
|
|
95
|
+
const bounds1 = viewport.getBounds({ z: maxZ });
|
|
96
|
+
viewportBoundsWorld = [
|
|
97
|
+
Math.min(bounds0[0], bounds1[0]),
|
|
98
|
+
Math.min(bounds0[1], bounds1[1]),
|
|
99
|
+
Math.max(bounds0[2], bounds1[2]),
|
|
100
|
+
Math.max(bounds0[3], bounds1[3])
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
viewportBoundsWorld = viewport.getBounds();
|
|
105
|
+
}
|
|
106
|
+
// Viewport bounds in cartesian coordinates
|
|
107
|
+
const viewportBottomLeftCommon = viewport.projectPosition(viewportBoundsWorld.slice(0, 2));
|
|
108
|
+
const viewportTopRightCommon = viewport.projectPosition(viewportBoundsWorld.slice(2, 4));
|
|
109
|
+
return [
|
|
110
|
+
viewportBottomLeftCommon[0],
|
|
111
|
+
viewportBottomLeftCommon[1],
|
|
112
|
+
viewportTopRightCommon[0],
|
|
113
|
+
viewportTopRightCommon[1]
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
/*
|
|
117
|
+
* Determine the common space bounds that best cover the given data for the given viewport
|
|
118
|
+
* Returns bounds in CARTESIAN coordinates
|
|
119
|
+
*/
|
|
120
|
+
export function getRenderBounds(layerBounds, viewport, zRange) {
|
|
121
|
+
if (!layerBounds) {
|
|
122
|
+
return [0, 0, 1, 1];
|
|
123
|
+
}
|
|
124
|
+
const viewportBounds = getViewportBounds(viewport, zRange);
|
|
125
|
+
// Expand viewport bounds by 2X. Heurestically chosen to avoid masking
|
|
126
|
+
// errors when mask is partially out of view
|
|
127
|
+
const paddedBounds = doubleBounds(viewportBounds);
|
|
128
|
+
// When bounds of the layers are smaller than the viewport bounds simply use
|
|
129
|
+
// mask bounds, so as to maximize resolution & avoid rerenders
|
|
130
|
+
if (layerBounds[2] - layerBounds[0] <= paddedBounds[2] - paddedBounds[0] &&
|
|
131
|
+
layerBounds[3] - layerBounds[1] <= paddedBounds[3] - paddedBounds[1]) {
|
|
132
|
+
return layerBounds;
|
|
133
|
+
}
|
|
134
|
+
// As viewport shrinks, to avoid pixelation along mask edges
|
|
135
|
+
// we need to reduce the bounds and only render the visible portion
|
|
136
|
+
// of the mask.
|
|
137
|
+
// We pad the viewport bounds to capture the section
|
|
138
|
+
// of the mask just outside the viewport to correctly maskByInstance.
|
|
139
|
+
// Intersect mask & padded viewport bounds
|
|
140
|
+
return [
|
|
141
|
+
Math.max(layerBounds[0], paddedBounds[0]),
|
|
142
|
+
Math.max(layerBounds[1], paddedBounds[1]),
|
|
143
|
+
Math.min(layerBounds[2], paddedBounds[2]),
|
|
144
|
+
Math.min(layerBounds[3], paddedBounds[3])
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
function doubleBounds(bounds) {
|
|
148
|
+
const dx = bounds[2] - bounds[0];
|
|
149
|
+
const dy = bounds[3] - bounds[1];
|
|
150
|
+
const centerX = (bounds[0] + bounds[2]) / 2;
|
|
151
|
+
const centerY = (bounds[1] + bounds[3]) / 2;
|
|
152
|
+
return [centerX - dx, centerY - dy, centerX + dx, centerY + dy];
|
|
153
|
+
}
|