maplibre-gl-layers 0.6.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 +685 -180
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +686 -181
- 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 +89 -68
- package/dist/utils.d.ts +19 -3
- package/package.json +6 -6
- package/dist/numericInterpolation.d.ts +0 -80
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ MapLibre's layer extension library enabling the display, movement, and modificat
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
[](https://www.repostatus.org/#wip)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
|
|
10
10
|
----
|
package/dist/SpriteLayer.d.ts
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
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 { Map as MapLibreMap } from 'maplibre-gl';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { NumericInterpolationState } from './numericInterpolation';
|
|
15
|
-
/**
|
|
16
|
-
* Compact representation of an Array-like 4x4 matrix.
|
|
17
|
-
* Accepts typed arrays sourced from MapLibre internals.
|
|
18
|
-
*/
|
|
19
|
-
type MatrixInput = ArrayLike<number>;
|
|
20
|
-
/**
|
|
21
|
-
* Cached clip-space context containing the mercator matrix required to project coordinates.
|
|
22
|
-
* @property {MatrixInput} mercatorMatrix - Matrix mapping Mercator coordinates to clip space.
|
|
23
|
-
*/
|
|
24
|
-
type ClipContext = {
|
|
25
|
-
readonly mercatorMatrix: MatrixInput;
|
|
26
|
-
};
|
|
12
|
+
import { SpriteLayerInterface, SpriteLayerOptions, SpriteAnchor, SpriteLocation, SpriteImageDefinitionInit, SpriteImageOffset, SpriteInterpolationOptions } from './types';
|
|
13
|
+
import { MatrixInput, ClipContext, InternalSpriteImageState, InternalSpriteCurrentState } from './internalTypes';
|
|
27
14
|
/**
|
|
28
15
|
* Computes the perspective ratio from MapLibre's internal transform.
|
|
29
16
|
* Used to calculate distance-based scaling that responds to pitch, zoom, and altitude.
|
|
@@ -77,158 +64,6 @@ export declare const compileShader: (glContext: WebGLRenderingContext, type: num
|
|
|
77
64
|
* @throws When linking fails or a program cannot be created.
|
|
78
65
|
*/
|
|
79
66
|
export declare const createShaderProgram: (glContext: WebGLRenderingContext, vertexSource: string, fragmentSource: string) => WebGLProgram;
|
|
80
|
-
type MutableSpriteScreenPoint = {
|
|
81
|
-
x: number;
|
|
82
|
-
y: number;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Base attributes for an image that composes a sprite.
|
|
86
|
-
*/
|
|
87
|
-
interface InternalSpriteImageState {
|
|
88
|
-
/**
|
|
89
|
-
* Sub-layer identifier.
|
|
90
|
-
*/
|
|
91
|
-
subLayer: number;
|
|
92
|
-
/**
|
|
93
|
-
* Ordering value within the sub-layer.
|
|
94
|
-
*/
|
|
95
|
-
order: number;
|
|
96
|
-
/**
|
|
97
|
-
* Image ID referenced for rendering.
|
|
98
|
-
*/
|
|
99
|
-
imageId: string;
|
|
100
|
-
/**
|
|
101
|
-
* Rendering mode. Defaults to surface.
|
|
102
|
-
*/
|
|
103
|
-
mode: SpriteMode;
|
|
104
|
-
/**
|
|
105
|
-
* Opacity applied to the image alpha. Defaults to 1.0.
|
|
106
|
-
*/
|
|
107
|
-
opacity: number;
|
|
108
|
-
/**
|
|
109
|
-
* Multiplier for real-world meters corresponding to one image pixel. 1.0 = 1 meter. Defaults to 1.0.
|
|
110
|
-
*/
|
|
111
|
-
scale: number;
|
|
112
|
-
/**
|
|
113
|
-
* Anchor position within the sprite. Defaults to [0.0, 0.0].
|
|
114
|
-
*/
|
|
115
|
-
anchor: SpriteAnchor;
|
|
116
|
-
/**
|
|
117
|
-
* Offset from the sprite coordinate. Defaults to no offset.
|
|
118
|
-
*/
|
|
119
|
-
offset: SpriteImageOffset;
|
|
120
|
-
/**
|
|
121
|
-
* Requested rotation angle in degrees. Defaults to 0.
|
|
122
|
-
* Billboard mode: Clockwise rotation relative to the viewport.
|
|
123
|
-
* Surface mode: Clockwise azimuth from geographic north.
|
|
124
|
-
*/
|
|
125
|
-
rotateDeg: number;
|
|
126
|
-
/**
|
|
127
|
-
* Rotation currently applied during rendering.
|
|
128
|
-
*/
|
|
129
|
-
displayedRotateDeg: number;
|
|
130
|
-
/**
|
|
131
|
-
* Whether auto-rotation is enabled. Defaults to true in surface mode and false in billboard mode.
|
|
132
|
-
* The sprite orientation is derived from its movement vector when enabled.
|
|
133
|
-
*/
|
|
134
|
-
autoRotation: boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Minimum distance in meters required before auto-rotation updates. Defaults to 20 m.
|
|
137
|
-
* Values <= 0 trigger immediate updates.
|
|
138
|
-
*/
|
|
139
|
-
autoRotationMinDistanceMeters: number;
|
|
140
|
-
/**
|
|
141
|
-
* Base rotation determined by auto-rotation. Initially 0.
|
|
142
|
-
*/
|
|
143
|
-
resolvedBaseRotateDeg: number;
|
|
144
|
-
/**
|
|
145
|
-
* Reference sub-layer used as the origin for offsets. Defaults to sprite coordinates.
|
|
146
|
-
*/
|
|
147
|
-
originLocation?: SpriteImageOriginLocation;
|
|
148
|
-
/**
|
|
149
|
-
* Interpolation state for display rotation.
|
|
150
|
-
*/
|
|
151
|
-
rotationInterpolationState: NumericInterpolationState | null;
|
|
152
|
-
/**
|
|
153
|
-
* Default interpolation options for display rotation.
|
|
154
|
-
*/
|
|
155
|
-
rotationInterpolationOptions: SpriteNumericInterpolationOptions | null;
|
|
156
|
-
/**
|
|
157
|
-
* Interpolation state used for offset.offsetDeg.
|
|
158
|
-
*/
|
|
159
|
-
offsetInterpolationState: NumericInterpolationState | null;
|
|
160
|
-
/**
|
|
161
|
-
* Reusable buffer storing screen-space quad corners for hit testing.
|
|
162
|
-
*/
|
|
163
|
-
hitTestCorners?: [
|
|
164
|
-
MutableSpriteScreenPoint,
|
|
165
|
-
MutableSpriteScreenPoint,
|
|
166
|
-
MutableSpriteScreenPoint,
|
|
167
|
-
MutableSpriteScreenPoint
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Sprite position interpolation state.
|
|
172
|
-
*/
|
|
173
|
-
type InternalSpriteInterpolationState = SpriteInterpolationState;
|
|
174
|
-
/**
|
|
175
|
-
* Current sprite state.
|
|
176
|
-
* @param TTag Tag type.
|
|
177
|
-
*/
|
|
178
|
-
interface InternalSpriteCurrentState<TTag> {
|
|
179
|
-
/**
|
|
180
|
-
* Sprite identifier.
|
|
181
|
-
*/
|
|
182
|
-
spriteId: string;
|
|
183
|
-
/**
|
|
184
|
-
* Whether the sprite is enabled.
|
|
185
|
-
*/
|
|
186
|
-
isEnabled: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* Current location (interpolated position when moving).
|
|
189
|
-
*/
|
|
190
|
-
currentLocation: SpriteLocation;
|
|
191
|
-
/**
|
|
192
|
-
* Source location used for movement interpolation.
|
|
193
|
-
* Feedback mode: previous command location.
|
|
194
|
-
* Feed-forward mode: current command location.
|
|
195
|
-
*/
|
|
196
|
-
fromLocation?: SpriteLocation;
|
|
197
|
-
/**
|
|
198
|
-
* Destination location used for movement interpolation.
|
|
199
|
-
* Feedback mode: current command location.
|
|
200
|
-
* Feed-forward mode: predicted location.
|
|
201
|
-
*/
|
|
202
|
-
toLocation?: SpriteLocation;
|
|
203
|
-
/**
|
|
204
|
-
* Map of image states currently associated with the sprite.
|
|
205
|
-
*/
|
|
206
|
-
images: Map<number, Map<number, InternalSpriteImageState>>;
|
|
207
|
-
/**
|
|
208
|
-
* Optional tag (null when not set).
|
|
209
|
-
*/
|
|
210
|
-
tag: TTag | null;
|
|
211
|
-
/**
|
|
212
|
-
* Active interpolation state, or null when idle.
|
|
213
|
-
*/
|
|
214
|
-
interpolationState: InternalSpriteInterpolationState | null;
|
|
215
|
-
/**
|
|
216
|
-
* Most recently requested interpolation options, or null if none pending.
|
|
217
|
-
*/
|
|
218
|
-
pendingInterpolationOptions: SpriteInterpolationOptions | null;
|
|
219
|
-
/**
|
|
220
|
-
* Most recently commanded location, regardless of interpolation.
|
|
221
|
-
*/
|
|
222
|
-
lastCommandLocation: SpriteLocation;
|
|
223
|
-
/**
|
|
224
|
-
* Latest location used as the basis for auto-rotation calculation.
|
|
225
|
-
*/
|
|
226
|
-
lastAutoRotationLocation: SpriteLocation;
|
|
227
|
-
/**
|
|
228
|
-
* Last resolved base angle from auto-rotation in degrees, reused as the next initial value.
|
|
229
|
-
*/
|
|
230
|
-
lastAutoRotationAngleDeg: number;
|
|
231
|
-
}
|
|
232
67
|
/**
|
|
233
68
|
* Clones a sprite anchor, defaulting to the origin when none supplied.
|
|
234
69
|
* @param {SpriteAnchor} [anchor] - Anchor to clone.
|
|
@@ -242,7 +77,7 @@ export declare const cloneAnchor: (anchor?: SpriteAnchor) => SpriteAnchor;
|
|
|
242
77
|
*/
|
|
243
78
|
export declare const cloneOffset: (offset?: SpriteImageOffset) => SpriteImageOffset;
|
|
244
79
|
/**
|
|
245
|
-
* Deep-clones
|
|
80
|
+
* Deep-clones interpolation options to prevent shared references between sprites.
|
|
246
81
|
* @param {SpriteInterpolationOptions} options - Options provided by the user.
|
|
247
82
|
* @returns {SpriteInterpolationOptions} Cloned options object.
|
|
248
83
|
*/
|
|
@@ -266,4 +101,3 @@ export declare const createImageStateFromInit: (imageInit: SpriteImageDefinition
|
|
|
266
101
|
* @returns {SpriteLayerInterface<T>} Interface for sprite add/update/remove operations and MapLibre hooks.
|
|
267
102
|
*/
|
|
268
103
|
export declare const createSpriteLayer: <T = any>(options?: SpriteLayerOptions) => SpriteLayerInterface<T>;
|
|
269
|
-
export {};
|
package/dist/const.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 { SpriteScalingOptions, SpriteTextureFilteringOptions } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* Unlimited (default) values that fill in missing {@link SpriteScalingOptions} fields supplied by callers.
|
|
14
|
+
* metersPerPixel is 1.
|
|
15
|
+
*/
|
|
16
|
+
export declare const UNLIMITED_SPRITE_SCALING_OPTIONS: SpriteScalingOptions;
|
|
17
|
+
/**
|
|
18
|
+
* Standard values that fill in missing {@link SpriteScalingOptions} fields supplied by callers.
|
|
19
|
+
* metersPerPixel is 1.
|
|
20
|
+
*/
|
|
21
|
+
export declare const STANDARD_SPRITE_SCALING_OPTIONS: SpriteScalingOptions;
|
|
22
|
+
/**
|
|
23
|
+
* Defaulted text filtering options.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DEFAULT_TEXTURE_FILTERING_OPTIONS: SpriteTextureFilteringOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Better text filtering options than default options.
|
|
28
|
+
*/
|
|
29
|
+
export declare const BETTER_TEXTURE_FILTERING_OPTIONS: SpriteTextureFilteringOptions;
|
|
@@ -0,0 +1,66 @@
|
|
|
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 } from './types';
|
|
12
|
+
import { DegreeInterpolationState } from './internalTypes';
|
|
13
|
+
/**
|
|
14
|
+
* Parameters required to construct a {@link DegreeInterpolationState}.
|
|
15
|
+
* @property {number} currentValue - Current numeric value rendered on screen.
|
|
16
|
+
* @property {number} targetValue - Desired value after interpolation completes.
|
|
17
|
+
* @property {number | undefined} previousCommandValue - Prior commanded value used for feed-forward prediction.
|
|
18
|
+
* @property {SpriteInterpolationOptions} options - Timing and easing configuration.
|
|
19
|
+
*/
|
|
20
|
+
export interface CreateDegreeInterpolationStateParams {
|
|
21
|
+
currentValue: number;
|
|
22
|
+
targetValue: number;
|
|
23
|
+
previousCommandValue?: number;
|
|
24
|
+
options: SpriteInterpolationOptions;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result returned by {@link createDegreeInterpolationState} containing state and a flag for activation.
|
|
28
|
+
* @property {DegreeInterpolationState} state - Resolved state object.
|
|
29
|
+
* @property {boolean} requiresInterpolation - Indicates whether the caller should animate or snap.
|
|
30
|
+
*/
|
|
31
|
+
export interface CreateDegreeInterpolationStateResult {
|
|
32
|
+
readonly state: DegreeInterpolationState;
|
|
33
|
+
readonly requiresInterpolation: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates interpolation state describing how to move from the current value to the target value.
|
|
37
|
+
* @param {CreateDegreeInterpolationStateParams} params - Inputs describing the current, target, and options.
|
|
38
|
+
* @returns {CreateDegreeInterpolationStateResult} State data plus a flag indicating if animation is needed.
|
|
39
|
+
*/
|
|
40
|
+
export declare const createDegreeInterpolationState: (params: CreateDegreeInterpolationStateParams) => CreateDegreeInterpolationStateResult;
|
|
41
|
+
/**
|
|
42
|
+
* Parameters describing interpolation evaluation state.
|
|
43
|
+
* @property {DegreeInterpolationState} state - State generated via {@link createDegreeInterpolationState}.
|
|
44
|
+
* @property {number} timestamp - Timestamp in milliseconds used to sample the interpolation curve.
|
|
45
|
+
*/
|
|
46
|
+
export interface EvaluateDegreeInterpolationParams {
|
|
47
|
+
state: DegreeInterpolationState;
|
|
48
|
+
timestamp: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Result of evaluating a numeric interpolation at a specific timestamp.
|
|
52
|
+
* @property {number} value - Current interpolated value (or final value after completion).
|
|
53
|
+
* @property {boolean} completed - Indicates whether interpolation reached the end.
|
|
54
|
+
* @property {number} effectiveStartTimestamp - Start timestamp applied during evaluation.
|
|
55
|
+
*/
|
|
56
|
+
export interface EvaluateDegreeInterpolationResult {
|
|
57
|
+
readonly value: number;
|
|
58
|
+
readonly completed: boolean;
|
|
59
|
+
readonly effectiveStartTimestamp: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Evaluates a numeric interpolation against the provided timestamp.
|
|
63
|
+
* @param {EvaluateDegreeInterpolationParams} params - Inputs containing interpolation state and sample timestamp.
|
|
64
|
+
* @returns {EvaluateDegreeInterpolationResult} Current value, completion flag, and effective start time.
|
|
65
|
+
*/
|
|
66
|
+
export declare const evaluateDegreeInterpolation: (params: EvaluateDegreeInterpolationParams) => EvaluateDegreeInterpolationResult;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 } from './types';
|
|
12
|
+
import { DistanceInterpolationState } from './internalTypes';
|
|
13
|
+
export interface CreateDistanceInterpolationStateParams {
|
|
14
|
+
currentValue: number;
|
|
15
|
+
targetValue: number;
|
|
16
|
+
previousCommandValue?: number;
|
|
17
|
+
options: SpriteInterpolationOptions;
|
|
18
|
+
}
|
|
19
|
+
export interface CreateDistanceInterpolationStateResult {
|
|
20
|
+
readonly state: DistanceInterpolationState;
|
|
21
|
+
readonly requiresInterpolation: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const createDistanceInterpolationState: (params: CreateDistanceInterpolationStateParams) => CreateDistanceInterpolationStateResult;
|
|
24
|
+
export interface EvaluateDistanceInterpolationParams {
|
|
25
|
+
state: DistanceInterpolationState;
|
|
26
|
+
timestamp: number;
|
|
27
|
+
}
|
|
28
|
+
export interface EvaluateDistanceInterpolationResult {
|
|
29
|
+
readonly value: number;
|
|
30
|
+
readonly completed: boolean;
|
|
31
|
+
readonly effectiveStartTimestamp: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const evaluateDistanceInterpolation: (params: EvaluateDistanceInterpolationParams) => EvaluateDistanceInterpolationResult;
|
package/dist/easing.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 { EasingFunction } from './types';
|