maplibre-gl-layers 0.5.0 → 0.10.0
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/README.md +1 -1
- package/dist/SpriteLayer.d.ts +5 -171
- package/dist/const.d.ts +29 -0
- package/dist/degreeInterpolation.d.ts +66 -0
- package/dist/distanceInterpolation.d.ts +33 -0
- package/dist/easing.d.ts +2 -2
- package/dist/index.cjs +851 -190
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +852 -191
- package/dist/index.mjs.map +1 -1
- package/dist/internalTypes.d.ts +189 -0
- package/dist/interpolation.d.ts +4 -22
- package/dist/interpolationChannels.d.ts +37 -0
- package/dist/location.d.ts +2 -2
- package/dist/math.d.ts +2 -2
- package/dist/rotationInterpolation.d.ts +11 -9
- package/dist/types.d.ts +110 -56
- package/dist/utils.d.ts +19 -3
- package/package.json +6 -6
- package/dist/numericInterpolation.d.ts +0 -80
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: maplibre-gl-layers
|
|
3
|
+
* version: 0.10.0
|
|
4
|
+
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
+
* git.commit.hash: 58b99588e56fc80c6874d78a17e91a50901abc17
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { SpriteMode, SpriteAnchor, SpriteImageOffset, SpriteInterpolationOptions, SpriteImageOriginLocation, SpriteLocation, SpriteTextGlyphHorizontalAlign, SpriteTextureMagFilter, SpriteTextureMinFilter, SpriteInterpolationMode, EasingFunction } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* Runtime state describing the active interpolation between two sprite locations.
|
|
14
|
+
* Consumers reuse the same state across ticks to avoid re-allocations while animation is running.
|
|
15
|
+
*
|
|
16
|
+
* @property mode - Strategy used to resolve the target location (feedback or feedforward).
|
|
17
|
+
* @property durationMs - Total time allocated for the interpolation in milliseconds.
|
|
18
|
+
* @property easing - Resolved easing function applied to raw progress values.
|
|
19
|
+
* @property startTimestamp - Epoch millisecond when the interpolation started, or -1 when uninitialized.
|
|
20
|
+
* @property from - Origin sprite location cloned from the current render state.
|
|
21
|
+
* @property to - Destination sprite location being interpolated towards.
|
|
22
|
+
*/
|
|
23
|
+
export interface SpriteInterpolationState {
|
|
24
|
+
readonly mode: SpriteInterpolationMode;
|
|
25
|
+
readonly durationMs: number;
|
|
26
|
+
readonly easing: EasingFunction;
|
|
27
|
+
startTimestamp: number;
|
|
28
|
+
readonly from: SpriteLocation;
|
|
29
|
+
readonly to: SpriteLocation;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Runtime state tracked for numeric interpolations.
|
|
33
|
+
* @property {number} durationMs - Total duration of the interpolation in milliseconds.
|
|
34
|
+
* @property {EasingFunction} easing - Easing function applied to progress samples.
|
|
35
|
+
* @property {number} from - Start value used for interpolation.
|
|
36
|
+
* @property {number} to - Adjusted target along the shortest rotation path.
|
|
37
|
+
* @property {number} finalValue - Caller-requested final value (used once interpolation completes).
|
|
38
|
+
* @property {number} startTimestamp - Timestamp when interpolation began, `-1` until evaluation starts.
|
|
39
|
+
*/
|
|
40
|
+
export interface DegreeInterpolationState {
|
|
41
|
+
readonly durationMs: number;
|
|
42
|
+
readonly easing: EasingFunction;
|
|
43
|
+
readonly from: number;
|
|
44
|
+
readonly to: number;
|
|
45
|
+
readonly finalValue: number;
|
|
46
|
+
startTimestamp: number;
|
|
47
|
+
}
|
|
48
|
+
export interface DistanceInterpolationState {
|
|
49
|
+
readonly durationMs: number;
|
|
50
|
+
readonly easing: EasingFunction;
|
|
51
|
+
readonly from: number;
|
|
52
|
+
readonly to: number;
|
|
53
|
+
readonly finalValue: number;
|
|
54
|
+
startTimestamp: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Alias for the interpolation state used internally by sprites.
|
|
58
|
+
*/
|
|
59
|
+
export type InternalSpriteInterpolationState = SpriteInterpolationState;
|
|
60
|
+
/**
|
|
61
|
+
* Texture filtering parameters resolved from the public options structure.
|
|
62
|
+
*/
|
|
63
|
+
export interface ResolvedTextureFilteringOptions {
|
|
64
|
+
readonly minFilter: SpriteTextureMinFilter;
|
|
65
|
+
readonly magFilter: SpriteTextureMagFilter;
|
|
66
|
+
readonly generateMipmaps: boolean;
|
|
67
|
+
readonly maxAnisotropy: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Image metadata ready for use as a WebGL texture.
|
|
71
|
+
*/
|
|
72
|
+
export interface RegisteredImage {
|
|
73
|
+
id: string;
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
bitmap: ImageBitmap;
|
|
77
|
+
texture: WebGLTexture | undefined;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Padding resolved for glyph rendering with guaranteed non-negative values.
|
|
81
|
+
*/
|
|
82
|
+
export interface ResolvedTextGlyphPadding {
|
|
83
|
+
readonly top: number;
|
|
84
|
+
readonly right: number;
|
|
85
|
+
readonly bottom: number;
|
|
86
|
+
readonly left: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Border sides resolved for glyph rendering.
|
|
90
|
+
*/
|
|
91
|
+
export interface ResolvedBorderSides {
|
|
92
|
+
readonly top: boolean;
|
|
93
|
+
readonly right: boolean;
|
|
94
|
+
readonly bottom: boolean;
|
|
95
|
+
readonly left: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Fully resolved glyph rendering options with defaults applied.
|
|
99
|
+
*/
|
|
100
|
+
export interface ResolvedTextGlyphOptions {
|
|
101
|
+
readonly fontFamily: string;
|
|
102
|
+
readonly fontStyle: 'normal' | 'italic';
|
|
103
|
+
readonly fontWeight: string;
|
|
104
|
+
readonly fontSizePixel: number;
|
|
105
|
+
readonly color: string;
|
|
106
|
+
readonly letterSpacingPixel: number;
|
|
107
|
+
readonly backgroundColor?: string;
|
|
108
|
+
readonly paddingPixel: ResolvedTextGlyphPadding;
|
|
109
|
+
readonly borderColor?: string;
|
|
110
|
+
readonly borderWidthPixel: number;
|
|
111
|
+
readonly borderRadiusPixel: number;
|
|
112
|
+
readonly borderSides: ResolvedBorderSides;
|
|
113
|
+
readonly textAlign: SpriteTextGlyphHorizontalAlign;
|
|
114
|
+
readonly renderPixelRatio: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Mutable point reused when computing hit-test corners.
|
|
118
|
+
*/
|
|
119
|
+
export interface MutableSpriteScreenPoint {
|
|
120
|
+
x: number;
|
|
121
|
+
y: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Compact representation of an Array-like 4x4 matrix.
|
|
125
|
+
*/
|
|
126
|
+
export type MatrixInput = ArrayLike<number>;
|
|
127
|
+
/**
|
|
128
|
+
* Cached clip-space context containing the mercator matrix required to project coordinates.
|
|
129
|
+
*/
|
|
130
|
+
export type ClipContext = {
|
|
131
|
+
readonly mercatorMatrix: MatrixInput;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* 2D canvas rendering context accepted by the glyph renderer.
|
|
135
|
+
*/
|
|
136
|
+
export type Canvas2DContext = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
137
|
+
/**
|
|
138
|
+
* Canvas sources supported when rendering text glyphs.
|
|
139
|
+
*/
|
|
140
|
+
export type Canvas2DSource = HTMLCanvasElement | OffscreenCanvas;
|
|
141
|
+
/**
|
|
142
|
+
* Base attributes for an image that composes a sprite.
|
|
143
|
+
*/
|
|
144
|
+
export interface InternalSpriteImageState {
|
|
145
|
+
subLayer: number;
|
|
146
|
+
order: number;
|
|
147
|
+
imageId: string;
|
|
148
|
+
mode: SpriteMode;
|
|
149
|
+
opacity: number;
|
|
150
|
+
scale: number;
|
|
151
|
+
anchor: SpriteAnchor;
|
|
152
|
+
offset: SpriteImageOffset;
|
|
153
|
+
rotateDeg: number;
|
|
154
|
+
displayedRotateDeg: number;
|
|
155
|
+
autoRotation: boolean;
|
|
156
|
+
autoRotationMinDistanceMeters: number;
|
|
157
|
+
resolvedBaseRotateDeg: number;
|
|
158
|
+
originLocation?: SpriteImageOriginLocation;
|
|
159
|
+
rotationInterpolationState: DegreeInterpolationState | null;
|
|
160
|
+
rotationInterpolationOptions: SpriteInterpolationOptions | null;
|
|
161
|
+
offsetDegInterpolationState: DegreeInterpolationState | null;
|
|
162
|
+
offsetMetersInterpolationState: DistanceInterpolationState | null;
|
|
163
|
+
lastCommandRotateDeg: number;
|
|
164
|
+
lastCommandOffsetDeg: number;
|
|
165
|
+
lastCommandOffsetMeters: number;
|
|
166
|
+
hitTestCorners?: [
|
|
167
|
+
MutableSpriteScreenPoint,
|
|
168
|
+
MutableSpriteScreenPoint,
|
|
169
|
+
MutableSpriteScreenPoint,
|
|
170
|
+
MutableSpriteScreenPoint
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Current sprite state tracked internally by the layer.
|
|
175
|
+
*/
|
|
176
|
+
export interface InternalSpriteCurrentState<TTag> {
|
|
177
|
+
spriteId: string;
|
|
178
|
+
isEnabled: boolean;
|
|
179
|
+
currentLocation: SpriteLocation;
|
|
180
|
+
fromLocation?: SpriteLocation;
|
|
181
|
+
toLocation?: SpriteLocation;
|
|
182
|
+
images: Map<number, Map<number, InternalSpriteImageState>>;
|
|
183
|
+
tag: TTag | null;
|
|
184
|
+
interpolationState: InternalSpriteInterpolationState | null;
|
|
185
|
+
pendingInterpolationOptions: SpriteInterpolationOptions | null;
|
|
186
|
+
lastCommandLocation: SpriteLocation;
|
|
187
|
+
lastAutoRotationLocation: SpriteLocation;
|
|
188
|
+
lastAutoRotationAngleDeg: number;
|
|
189
|
+
}
|
package/dist/interpolation.d.ts
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.10.0
|
|
4
4
|
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 58b99588e56fc80c6874d78a17e91a50901abc17
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
* Runtime state describing the active interpolation between two sprite locations.
|
|
14
|
-
* Consumers reuse the same state across ticks to avoid re-allocations while animation is running.
|
|
15
|
-
*
|
|
16
|
-
* @property mode - Strategy used to resolve the target location (feedback or feedforward).
|
|
17
|
-
* @property durationMs - Total time allocated for the interpolation in milliseconds.
|
|
18
|
-
* @property easing - Resolved easing function applied to raw progress values.
|
|
19
|
-
* @property startTimestamp - Epoch millisecond when the interpolation started, or -1 when uninitialised.
|
|
20
|
-
* @property from - Origin sprite location cloned from the current render state.
|
|
21
|
-
* @property to - Destination sprite location being interpolated towards.
|
|
22
|
-
*/
|
|
23
|
-
export interface SpriteInterpolationState {
|
|
24
|
-
readonly mode: SpriteInterpolationMode;
|
|
25
|
-
readonly durationMs: number;
|
|
26
|
-
readonly easing: EasingFunction;
|
|
27
|
-
startTimestamp: number;
|
|
28
|
-
readonly from: SpriteLocation;
|
|
29
|
-
readonly to: SpriteLocation;
|
|
30
|
-
}
|
|
11
|
+
import { SpriteInterpolationOptions, SpriteLocation } from './types';
|
|
12
|
+
import { SpriteInterpolationState } from './internalTypes';
|
|
31
13
|
/**
|
|
32
14
|
* Parameters required to create a fresh interpolation state for the next animation segment.
|
|
33
15
|
*
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: maplibre-gl-layers
|
|
3
|
+
* version: 0.10.0
|
|
4
|
+
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
+
* git.commit.hash: 58b99588e56fc80c6874d78a17e91a50901abc17
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { SpriteInterpolationOptions, SpriteImageOffset } from './types';
|
|
12
|
+
import { InternalSpriteImageState } from './internalTypes';
|
|
13
|
+
/**
|
|
14
|
+
* Ensures the rotation channel reflects the latest targets, optionally overriding interpolation.
|
|
15
|
+
*/
|
|
16
|
+
export declare const syncImageRotationChannel: (image: InternalSpriteImageState, optionsOverride?: SpriteInterpolationOptions | null) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Clears any running offset angle interpolation.
|
|
19
|
+
*/
|
|
20
|
+
export declare const clearOffsetDegInterpolation: (image: InternalSpriteImageState) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Clears any running offset distance interpolation in meters.
|
|
23
|
+
*/
|
|
24
|
+
export declare const clearOffsetMetersInterpolation: (image: InternalSpriteImageState) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Executes all interpolation steppers for an image and reports whether any remain active.
|
|
27
|
+
*/
|
|
28
|
+
export declare const stepSpriteImageInterpolations: (image: InternalSpriteImageState, timestamp: number) => boolean;
|
|
29
|
+
interface ApplyOffsetUpdateOptions {
|
|
30
|
+
readonly deg?: SpriteInterpolationOptions | null;
|
|
31
|
+
readonly meters?: SpriteInterpolationOptions | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Applies offset updates across both angular and radial channels.
|
|
35
|
+
*/
|
|
36
|
+
export declare const applyOffsetUpdate: (image: InternalSpriteImageState, nextOffset: SpriteImageOffset, options?: ApplyOffsetUpdateOptions) => void;
|
|
37
|
+
export {};
|
package/dist/location.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.10.0
|
|
4
4
|
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 58b99588e56fc80c6874d78a17e91a50901abc17
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { SpriteLocation } from './types';
|
package/dist/math.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.10.0
|
|
4
4
|
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 58b99588e56fc80c6874d78a17e91a50901abc17
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { SpriteAnchor, SpriteImageOffset, SpriteLocation, SpriteScalingOptions } from './types';
|
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.10.0
|
|
4
4
|
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 58b99588e56fc80c6874d78a17e91a50901abc17
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { SpriteInterpolationOptions } from './types';
|
|
12
|
+
import { DegreeInterpolationState } from './internalTypes';
|
|
13
13
|
/**
|
|
14
14
|
* Normalizes an absolute angle in degrees to the range [0, 360).
|
|
15
15
|
* @param {number} angle - Angle provided by the caller which may fall outside a single revolution.
|
|
16
16
|
* @returns {number} Angle wrapped to [0, 360) with negative zero converted to zero.
|
|
17
17
|
*/
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const normalizeAngleDeg: (angle: number) => number;
|
|
19
19
|
/**
|
|
20
20
|
* Parameters describing the rotation update request.
|
|
21
21
|
* @property {number} currentAngleDeg - Current angle already applied to the sprite in degrees.
|
|
22
22
|
* @property {number} targetAngleDeg - Desired angle in degrees that should be reached.
|
|
23
|
-
* @property {
|
|
23
|
+
* @property {number | undefined} previousCommandAngleDeg - Previous commanded angle for feed-forward prediction.
|
|
24
|
+
* @property {SpriteInterpolationOptions | null} [options] - Optional interpolation configuration.
|
|
24
25
|
*/
|
|
25
26
|
export interface ResolveRotationTargetParams {
|
|
26
27
|
currentAngleDeg: number;
|
|
27
28
|
targetAngleDeg: number;
|
|
28
|
-
|
|
29
|
+
previousCommandAngleDeg?: number;
|
|
30
|
+
options?: SpriteInterpolationOptions | null;
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
33
|
* Result produced by {@link resolveRotationTarget} when determining the next rotation step.
|
|
32
34
|
* @property {number} nextAngleDeg - Angle that should be applied immediately.
|
|
33
|
-
* @property {
|
|
35
|
+
* @property {DegreeInterpolationState | null} interpolationState - Optional state for animating toward the target.
|
|
34
36
|
*/
|
|
35
37
|
export interface ResolveRotationTargetResult {
|
|
36
38
|
readonly nextAngleDeg: number;
|
|
37
|
-
readonly interpolationState:
|
|
39
|
+
readonly interpolationState: DegreeInterpolationState | null;
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* Determines whether a rotation change requires interpolation and, if so, produces the state to drive it.
|
package/dist/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.10.0
|
|
4
4
|
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 58b99588e56fc80c6874d78a17e91a50901abc17
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { CustomLayerInterface } from 'maplibre-gl';
|
|
@@ -71,6 +71,28 @@ export interface SpriteImageOriginLocation {
|
|
|
71
71
|
*/
|
|
72
72
|
useResolvedAnchor?: boolean;
|
|
73
73
|
}
|
|
74
|
+
/** Defines movement interpolation modes. */
|
|
75
|
+
export type SpriteInterpolationMode = 'feedback' | 'feedforward';
|
|
76
|
+
/** Easing function signature used to map interpolation progress. */
|
|
77
|
+
export type EasingFunction = (progress: number) => number;
|
|
78
|
+
/** Options for interpolating values. */
|
|
79
|
+
export interface SpriteInterpolationOptions {
|
|
80
|
+
/** Interpolation mode; defaults to feedback. */
|
|
81
|
+
mode?: SpriteInterpolationMode;
|
|
82
|
+
/** Duration in milliseconds. */
|
|
83
|
+
durationMs: number;
|
|
84
|
+
/** Easing function mapping interpolation progress. Defaults to linear. */
|
|
85
|
+
easing?: EasingFunction;
|
|
86
|
+
}
|
|
87
|
+
/** Interpolation configuration for rotateDeg and offsetDeg. */
|
|
88
|
+
export interface SpriteImageInterpolationOptions {
|
|
89
|
+
/** Interpolation settings for rotateDeg; null disables interpolation. */
|
|
90
|
+
rotateDeg?: SpriteInterpolationOptions | null;
|
|
91
|
+
/** Interpolation settings for offset.offsetDeg; null disables interpolation. */
|
|
92
|
+
offsetDeg?: SpriteInterpolationOptions | null;
|
|
93
|
+
/** Interpolation settings for offset.offsetMeters; null disables interpolation. */
|
|
94
|
+
offsetMeters?: SpriteInterpolationOptions | null;
|
|
95
|
+
}
|
|
74
96
|
/**
|
|
75
97
|
* Initial attributes that define a sprite image.
|
|
76
98
|
*/
|
|
@@ -108,9 +130,9 @@ export interface SpriteImageDefinitionInit {
|
|
|
108
130
|
*/
|
|
109
131
|
autoRotationMinDistanceMeters?: number;
|
|
110
132
|
/**
|
|
111
|
-
* Optional interpolation settings
|
|
133
|
+
* Optional interpolation settings.
|
|
112
134
|
*/
|
|
113
|
-
|
|
135
|
+
interpolation?: SpriteImageInterpolationOptions;
|
|
114
136
|
}
|
|
115
137
|
/**
|
|
116
138
|
* Update payload for a sprite image. Properties left undefined are ignored.
|
|
@@ -134,8 +156,8 @@ export interface SpriteImageDefinitionUpdate {
|
|
|
134
156
|
autoRotation?: boolean;
|
|
135
157
|
/** Minimum distance in meters before auto-rotation updates. */
|
|
136
158
|
autoRotationMinDistanceMeters?: number;
|
|
137
|
-
/** Optional interpolation settings
|
|
138
|
-
|
|
159
|
+
/** Optional interpolation settings. */
|
|
160
|
+
interpolation?: SpriteImageInterpolationOptions;
|
|
139
161
|
}
|
|
140
162
|
/**
|
|
141
163
|
* Helper for bulk initializing sprite images.
|
|
@@ -255,40 +277,13 @@ export interface SpriteCurrentState<TTag> {
|
|
|
255
277
|
/** Optional tag value; null indicates no tag. */
|
|
256
278
|
readonly tag: TTag | null;
|
|
257
279
|
}
|
|
258
|
-
/** Defines movement interpolation modes. */
|
|
259
|
-
export type SpriteInterpolationMode = 'feedback' | 'feedforward';
|
|
260
|
-
/** Easing function signature used to map interpolation progress. */
|
|
261
|
-
export type EasingFunction = (progress: number) => number;
|
|
262
|
-
/** Options controlling position interpolation. */
|
|
263
|
-
export interface SpriteInterpolationOptions {
|
|
264
|
-
/** Interpolation mode; defaults to feedback. */
|
|
265
|
-
mode?: SpriteInterpolationMode;
|
|
266
|
-
/** Duration in milliseconds. */
|
|
267
|
-
durationMs: number;
|
|
268
|
-
/** Easing function mapping interpolation progress. Defaults to linear. */
|
|
269
|
-
easing?: EasingFunction;
|
|
270
|
-
}
|
|
271
|
-
/** Options for interpolating numeric values such as angles. */
|
|
272
|
-
export interface SpriteNumericInterpolationOptions {
|
|
273
|
-
/** Duration in milliseconds. */
|
|
274
|
-
durationMs: number;
|
|
275
|
-
/** Easing function mapping interpolation progress. Defaults to linear. */
|
|
276
|
-
easing?: EasingFunction;
|
|
277
|
-
}
|
|
278
|
-
/** Interpolation configuration for rotateDeg and offsetDeg. */
|
|
279
|
-
export interface SpriteImageRotationInterpolationOptions {
|
|
280
|
-
/** Interpolation settings for rotateDeg; null disables interpolation. */
|
|
281
|
-
rotateDeg?: SpriteNumericInterpolationOptions | null;
|
|
282
|
-
/** Interpolation settings for offset.offsetDeg; null disables interpolation. */
|
|
283
|
-
offsetDeg?: SpriteNumericInterpolationOptions | null;
|
|
284
|
-
}
|
|
285
280
|
/**
|
|
286
281
|
* Base structure for sprite updates.
|
|
287
282
|
*
|
|
288
283
|
* @template TTag Tag type stored on the sprite.
|
|
289
284
|
* @property {boolean | undefined} isEnabled - Optional toggle to enable or disable the sprite.
|
|
290
285
|
* @property {SpriteLocation | undefined} location - Optional target location for the sprite.
|
|
291
|
-
* @property {
|
|
286
|
+
* @property {SpriteLocationInterpolationOptions | null | undefined} interpolation - Optional location interpolation settings; `null` disables interpolation.
|
|
292
287
|
* @property {TTag | null | undefined} tag - Optional tag value to replace the current one; `null` clears the tag.
|
|
293
288
|
*/
|
|
294
289
|
export interface SpriteUpdateEntryBase<TTag> {
|
|
@@ -326,11 +321,6 @@ export interface SpriteUpdateEntry<TTag> extends SpriteUpdateEntryBase<TTag> {
|
|
|
326
321
|
/** Optional set of image updates. */
|
|
327
322
|
images?: SpriteImageDefinitionUpdateEntry[];
|
|
328
323
|
}
|
|
329
|
-
/** @deprecated Scheduled for removal in a future release. Use {@link SpriteLayerInterface.mutateSprites} instead. */
|
|
330
|
-
export interface SpriteUpdateBulkEntry<T> extends SpriteUpdateEntry<T> {
|
|
331
|
-
/** @deprecated Scheduled for removal in a future release. Use {@link SpriteLayerInterface.mutateSprites} instead. */
|
|
332
|
-
spriteId: string;
|
|
333
|
-
}
|
|
334
324
|
/**
|
|
335
325
|
* Callback-based helper for mutating sprite state.
|
|
336
326
|
*
|
|
@@ -374,7 +364,7 @@ export interface SpriteMutateCallbacks<TTag, TSourceItem extends SpriteMutateSou
|
|
|
374
364
|
* (or `null`) to skip creation.
|
|
375
365
|
*
|
|
376
366
|
* @param sourceItem Source item that produced the sprite ID.
|
|
377
|
-
* @returns Sprite
|
|
367
|
+
* @returns Sprite initializer to insert, or `undefined`/`null` to skip.
|
|
378
368
|
*/
|
|
379
369
|
add: (sourceItem: TSourceItem) => SpriteInit<TTag> | null | undefined;
|
|
380
370
|
/**
|
|
@@ -413,24 +403,49 @@ export interface SpriteScreenPoint {
|
|
|
413
403
|
export interface SpriteLayerClickEvent<T> {
|
|
414
404
|
/** Discriminated event type. */
|
|
415
405
|
readonly type: 'spriteclick';
|
|
416
|
-
/** Snapshot of the sprite that was hit. */
|
|
417
|
-
readonly sprite: SpriteCurrentState<T
|
|
418
|
-
/** Sprite image that received the interaction. */
|
|
419
|
-
readonly image: SpriteImageState;
|
|
406
|
+
/** Snapshot of the sprite that was hit, or `undefined` when it no longer exists. */
|
|
407
|
+
readonly sprite: SpriteCurrentState<T> | undefined;
|
|
408
|
+
/** Sprite image that received the interaction, or `undefined` when missing. */
|
|
409
|
+
readonly image: SpriteImageState | undefined;
|
|
420
410
|
/** Screen position of the interaction. */
|
|
421
411
|
readonly screenPoint: SpriteScreenPoint;
|
|
422
412
|
/** Original DOM event. */
|
|
423
413
|
readonly originalEvent: MouseEvent | PointerEvent | TouchEvent;
|
|
424
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* Event dispatched when a sprite is hovered by a pointing device.
|
|
417
|
+
*
|
|
418
|
+
* @template T Tag type stored on sprites.
|
|
419
|
+
* @property {'spritehover'} type - Discriminated event type.
|
|
420
|
+
* @property {SpriteCurrentState<T>} sprite - Snapshot of the sprite that was hit.
|
|
421
|
+
* @property {SpriteImageState} image - Sprite image that received the interaction.
|
|
422
|
+
* @property {SpriteScreenPoint} screenPoint - Screen position of the interaction.
|
|
423
|
+
* @property {MouseEvent | PointerEvent} originalEvent - Original hover-capable DOM event.
|
|
424
|
+
*/
|
|
425
|
+
export interface SpriteLayerHoverEvent<T> {
|
|
426
|
+
/** Discriminated event type. */
|
|
427
|
+
readonly type: 'spritehover';
|
|
428
|
+
/** Snapshot of the sprite that was hit, or `undefined` when it no longer exists. */
|
|
429
|
+
readonly sprite: SpriteCurrentState<T> | undefined;
|
|
430
|
+
/** Sprite image that received the interaction, or `undefined` when missing. */
|
|
431
|
+
readonly image: SpriteImageState | undefined;
|
|
432
|
+
/** Screen position of the interaction. */
|
|
433
|
+
readonly screenPoint: SpriteScreenPoint;
|
|
434
|
+
/** Original hover-capable DOM event. */
|
|
435
|
+
readonly originalEvent: MouseEvent | PointerEvent;
|
|
436
|
+
}
|
|
425
437
|
/**
|
|
426
438
|
* Map of events emitted by SpriteLayer.
|
|
427
439
|
*
|
|
428
440
|
* @template T Tag type stored on sprites.
|
|
429
441
|
* @property {SpriteLayerClickEvent<T>} spriteclick - Event fired when a sprite image is clicked.
|
|
442
|
+
* @property {SpriteLayerHoverEvent<T>} spritehover - Event fired when a sprite image is hovered.
|
|
430
443
|
*/
|
|
431
444
|
export interface SpriteLayerEventMap<T> {
|
|
432
445
|
/** Event fired when a sprite image is clicked. */
|
|
433
446
|
readonly spriteclick: SpriteLayerClickEvent<T>;
|
|
447
|
+
/** Event fired when a sprite image is hovered. */
|
|
448
|
+
readonly spritehover: SpriteLayerHoverEvent<T>;
|
|
434
449
|
}
|
|
435
450
|
/**
|
|
436
451
|
* Event listener callback.
|
|
@@ -472,26 +487,68 @@ export interface SpriteScalingOptions {
|
|
|
472
487
|
spriteMaxPixel?: number;
|
|
473
488
|
}
|
|
474
489
|
/**
|
|
475
|
-
*
|
|
476
|
-
|
|
490
|
+
* Allowed minification filters for sprite textures.
|
|
491
|
+
*/
|
|
492
|
+
export type SpriteTextureMinFilter = 'nearest' | 'linear' | 'nearest-mipmap-nearest' | 'nearest-mipmap-linear' | 'linear-mipmap-nearest' | 'linear-mipmap-linear';
|
|
493
|
+
/**
|
|
494
|
+
* Allowed magnification filters for sprite textures.
|
|
477
495
|
*/
|
|
478
|
-
export
|
|
496
|
+
export type SpriteTextureMagFilter = 'nearest' | 'linear';
|
|
479
497
|
/**
|
|
480
|
-
*
|
|
481
|
-
*
|
|
498
|
+
* Texture filtering configuration.
|
|
499
|
+
*
|
|
500
|
+
* @property {SpriteTextureMinFilter | undefined} minFilter - Minification filter to apply (defaults to `linear`).
|
|
501
|
+
* @property {SpriteTextureMagFilter | undefined} magFilter - Magnification filter to apply (defaults to `linear`).
|
|
502
|
+
* @property {boolean | undefined} generateMipmaps - Generates mipmaps during upload when true (defaults to `false`).
|
|
503
|
+
* @property {number | undefined} maxAnisotropy - Desired anisotropy factor (>= 1) when EXT_texture_filter_anisotropic is available.
|
|
482
504
|
*/
|
|
483
|
-
export
|
|
505
|
+
export interface SpriteTextureFilteringOptions {
|
|
506
|
+
minFilter?: SpriteTextureMinFilter;
|
|
507
|
+
magFilter?: SpriteTextureMagFilter;
|
|
508
|
+
generateMipmaps?: boolean;
|
|
509
|
+
maxAnisotropy?: number;
|
|
510
|
+
}
|
|
484
511
|
/**
|
|
485
512
|
* Options accepted when creating a SpriteLayer.
|
|
486
513
|
*
|
|
487
514
|
* @property {string | undefined} id - Optional layer identifier supplied to MapLibre.
|
|
488
515
|
* @property {SpriteScalingOptions | undefined} spriteScaling - Optional scaling controls. Default is UNLIMITED_SPRITE_SCALING_OPTIONS.
|
|
516
|
+
* @property {SpriteTextureFilteringOptions | undefined} textureFiltering - Optional texture filtering overrides.
|
|
489
517
|
*/
|
|
490
518
|
export interface SpriteLayerOptions {
|
|
491
519
|
/** Optional layer identifier supplied to MapLibre. */
|
|
492
520
|
id?: string;
|
|
493
521
|
/** Optional scaling controls. */
|
|
494
522
|
spriteScaling?: SpriteScalingOptions;
|
|
523
|
+
/** Optional texture filtering configuration. */
|
|
524
|
+
textureFiltering?: SpriteTextureFilteringOptions;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Options used when registering SVG images.
|
|
528
|
+
*/
|
|
529
|
+
export interface SpriteImageSvgOptions {
|
|
530
|
+
/** Treat the resource as SVG even when the MIME type is missing or incorrect. */
|
|
531
|
+
readonly assumeSvg?: boolean;
|
|
532
|
+
/** Enables parsing of the SVG markup to detect intrinsic sizing. Defaults to true for SVG images. */
|
|
533
|
+
readonly inspectSize?: boolean;
|
|
534
|
+
/**
|
|
535
|
+
* Uses the SVG viewBox dimensions as the raster size when width/height attributes are missing.
|
|
536
|
+
* When disabled (default), such SVGs fail to load instead of inferring a size.
|
|
537
|
+
*/
|
|
538
|
+
readonly useViewBoxDimensions?: boolean;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Options accepted by {@link SpriteLayerInterface.registerImage}.
|
|
542
|
+
*/
|
|
543
|
+
export interface SpriteImageRegisterOptions {
|
|
544
|
+
/** Target width in CSS pixels. When only one dimension is supplied, the aspect ratio is preserved if known. */
|
|
545
|
+
readonly width?: number;
|
|
546
|
+
/** Target height in CSS pixels. When only one dimension is supplied, the aspect ratio is preserved if known. */
|
|
547
|
+
readonly height?: number;
|
|
548
|
+
/** Resampling quality used during rasterization. */
|
|
549
|
+
readonly resizeQuality?: ResizeQuality;
|
|
550
|
+
/** SVG-specific configuration. */
|
|
551
|
+
readonly svg?: SpriteImageSvgOptions;
|
|
495
552
|
}
|
|
496
553
|
/** Horizontal alignment options for text glyphs. */
|
|
497
554
|
export type SpriteTextGlyphHorizontalAlign = 'left' | 'center' | 'right';
|
|
@@ -572,9 +629,10 @@ export interface SpriteLayerInterface<TTag = any> extends CustomLayerInterface {
|
|
|
572
629
|
*
|
|
573
630
|
* @param {string} imageId - Unique image identifier.
|
|
574
631
|
* @param {string | ImageBitmap} image - Image source (URL or ImageBitmap) to upload.
|
|
632
|
+
* @param {SpriteImageRegisterOptions | undefined} options - Optional SVG handling controls.
|
|
575
633
|
* @returns {Promise<boolean>} Resolves to `true` when the image was registered; `false` if the ID already existed.
|
|
576
634
|
*/
|
|
577
|
-
readonly registerImage: (imageId: string, image: string | ImageBitmap) => Promise<boolean>;
|
|
635
|
+
readonly registerImage: (imageId: string, image: string | ImageBitmap, options?: SpriteImageRegisterOptions) => Promise<boolean>;
|
|
578
636
|
/**
|
|
579
637
|
* Registers a text glyph texture for later use.
|
|
580
638
|
*
|
|
@@ -690,17 +748,13 @@ export interface SpriteLayerInterface<TTag = any> extends CustomLayerInterface {
|
|
|
690
748
|
* @returns {boolean} `true` when the sprite was found and updated.
|
|
691
749
|
*/
|
|
692
750
|
readonly updateSprite: (spriteId: string, update: SpriteUpdateEntry<TTag>) => boolean;
|
|
693
|
-
/**
|
|
694
|
-
* @deprecated Use {@link SpriteLayerInterface.mutateSprites} instead for clearer mutation flows.
|
|
695
|
-
*/
|
|
696
|
-
readonly updateBulk: (updateBulkList: SpriteUpdateBulkEntry<TTag>[]) => number;
|
|
697
751
|
/**
|
|
698
752
|
* Adds, updates, or removes sprites based on an arbitrary collection of source items.
|
|
699
753
|
*
|
|
700
754
|
* @param {readonly TSourceItem[]} sourceItems - Source items that describe desired sprite state.
|
|
701
755
|
* @param {SpriteMutateCallbacks<TTag, TSourceItem>} mutator - Callbacks responsible for creation and modification.
|
|
702
756
|
* @returns {number} Number of sprites that changed. Counts each `add` that returns a non-null
|
|
703
|
-
*
|
|
757
|
+
* initializer and each `modify` that either invoked the updater helper or returned `'remove'`.
|
|
704
758
|
*/
|
|
705
759
|
readonly mutateSprites: <TSourceItem extends SpriteMutateSourceItem>(sourceItems: readonly TSourceItem[], mutator: SpriteMutateCallbacks<TTag, TSourceItem>) => number;
|
|
706
760
|
/**
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.10.0
|
|
4
4
|
* description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/maplibre-gl-layers.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 58b99588e56fc80c6874d78a17e91a50901abc17
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { SpriteImageRegisterOptions } from './types';
|
|
12
|
+
export type SvgSizeResolutionErrorCode = 'size-missing' | 'viewbox-disabled' | 'invalid-dimensions';
|
|
13
|
+
export declare class SvgSizeResolutionError extends Error implements Error {
|
|
14
|
+
readonly code: SvgSizeResolutionErrorCode;
|
|
15
|
+
constructor(message: string, code: SvgSizeResolutionErrorCode);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Helper that read an ImageBitmap from a blob.
|
|
19
|
+
* @param blob Target blob.
|
|
20
|
+
* @param options Optional reading options.
|
|
21
|
+
* @returns Promise resolving to the ImageBitmap.
|
|
22
|
+
* @remarks This function helps reading SVG with better manner.
|
|
23
|
+
*/
|
|
24
|
+
export declare const readImageBitmap: (blob: Blob, options?: SpriteImageRegisterOptions) => Promise<ImageBitmap>;
|
|
11
25
|
/**
|
|
12
26
|
* Helper that loads an ImageBitmap from a URL.
|
|
13
27
|
* @param url Target image URL.
|
|
28
|
+
* @param options Optional loading options.
|
|
14
29
|
* @returns Promise resolving to the ImageBitmap.
|
|
30
|
+
* @remarks This function helps loading SVG with better manner.
|
|
15
31
|
*/
|
|
16
|
-
export declare const loadImageBitmap: (url: string) => Promise<ImageBitmap>;
|
|
32
|
+
export declare const loadImageBitmap: (url: string, options?: SpriteImageRegisterOptions) => Promise<ImageBitmap>;
|