maplibre-gl-layers 1.0.0 → 1.1.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/index.cjs +8454 -6253
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1353 -7
- package/dist/index.mjs +8453 -6252
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -9
- package/dist/SpriteLayer.d.ts +0 -41
- package/dist/config.d.ts +0 -26
- package/dist/const.d.ts +0 -98
- package/dist/default.d.ts +0 -29
- package/dist/gl/atlas.d.ts +0 -64
- package/dist/gl/hitTest.d.ts +0 -54
- package/dist/gl/mouseEvents.d.ts +0 -36
- package/dist/gl/shader.d.ts +0 -114
- package/dist/gl/text.d.ts +0 -17
- package/dist/gl/tracking.d.ts +0 -36
- package/dist/host/calculationHost.d.ts +0 -87
- package/dist/host/mapLibreProjectionHost.d.ts +0 -18
- package/dist/host/projectionHost.d.ts +0 -62
- package/dist/host/runtime.d.ts +0 -38
- package/dist/host/wasmCalculationHost.d.ts +0 -78
- package/dist/host/wasmHost.d.ts +0 -133
- package/dist/host/wasmProjectionHost.d.ts +0 -19
- package/dist/internalTypes.d.ts +0 -582
- package/dist/interpolation/degreeInterpolation.d.ts +0 -49
- package/dist/interpolation/distanceInterpolation.d.ts +0 -32
- package/dist/interpolation/easing.d.ts +0 -26
- package/dist/interpolation/interpolationChannels.d.ts +0 -59
- package/dist/interpolation/locationInterpolation.d.ts +0 -30
- package/dist/interpolation/rotationInterpolation.d.ts +0 -40
- package/dist/types.d.ts +0 -944
- package/dist/utils/color.d.ts +0 -20
- package/dist/utils/image.d.ts +0 -32
- package/dist/utils/looseQuadTree.d.ts +0 -34
- package/dist/utils/math.d.ts +0 -451
- package/dist/utils/utils.d.ts +0 -37
- package/dist/wasm/config.json.d.ts +0 -16
package/dist/internalTypes.d.ts
DELETED
|
@@ -1,582 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* name: maplibre-gl-layers
|
|
3
|
-
* version: 1.0.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: 3a2127f77d7fd3ed6ae30186d4a06f52610673a6
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { SpriteMode, SpriteAnchor, SpriteInterpolationOptions, SpriteImageOriginLocation, SpriteLocation, SpriteTextGlyphHorizontalAlign, SpriteTextureMagFilter, SpriteTextureMinFilter, SpriteInterpolationMode, SpriteScreenPoint, SpritePoint, SpriteEasingParam, SpriteImageLineAttributeState, SpriteImageState, SpriteInterpolatedValues, SpriteImageInterpolatedOffset, SpriteCurrentState } from './types';
|
|
12
|
-
import { ResolvedSpriteScalingOptions, SurfaceCorner } from './utils/math';
|
|
13
|
-
export interface Releasable {
|
|
14
|
-
readonly release: () => void;
|
|
15
|
-
}
|
|
16
|
-
export type RgbaColor = readonly [number, number, number, number];
|
|
17
|
-
/**
|
|
18
|
-
* Represents a projected three dimensional position.
|
|
19
|
-
* `MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units:
|
|
20
|
-
* - the size of 1 unit is the width of the projected world instead of the "mercator meter"
|
|
21
|
-
* - the origin of the coordinate space is at the north-west corner instead of the middle
|
|
22
|
-
*/
|
|
23
|
-
export interface SpriteMercatorCoordinate {
|
|
24
|
-
readonly x: number;
|
|
25
|
-
readonly y: number;
|
|
26
|
-
readonly z: number;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* The handle value that using the instance.
|
|
30
|
-
*/
|
|
31
|
-
export type IdHandle = number;
|
|
32
|
-
/**
|
|
33
|
-
* Id handler interface.
|
|
34
|
-
* @param T Identified instance type
|
|
35
|
-
* @remarks It is used for (wasm) interoperability for identity.
|
|
36
|
-
*/
|
|
37
|
-
export interface IdHandler<T> {
|
|
38
|
-
/**
|
|
39
|
-
* Allocates a numeric handle for the specified identifier.
|
|
40
|
-
* @param {string} rawId - Raw identifier.
|
|
41
|
-
* @returns {IdHandle} Allocated handle.
|
|
42
|
-
*/
|
|
43
|
-
readonly allocate: (rawId: string) => IdHandle;
|
|
44
|
-
/**
|
|
45
|
-
* Stores an instance reference at the given handle index.
|
|
46
|
-
* @param {IdHandle} handle - Numeric handle.
|
|
47
|
-
* @param {T} instance - Registered instance.
|
|
48
|
-
*/
|
|
49
|
-
readonly store: (handle: IdHandle, instance: T) => void;
|
|
50
|
-
/**
|
|
51
|
-
* Get instance by handle.
|
|
52
|
-
* @param handle Numeric handle
|
|
53
|
-
* @returns Instance.
|
|
54
|
-
*/
|
|
55
|
-
readonly get: (handle: IdHandle) => T;
|
|
56
|
-
/**
|
|
57
|
-
* Releases the handle associated with the provided identifier.
|
|
58
|
-
* @param {string} rawId - Raw identifier.
|
|
59
|
-
*/
|
|
60
|
-
readonly release: (rawId: string) => void;
|
|
61
|
-
/**
|
|
62
|
-
* Clears all handle bookkeeping state.
|
|
63
|
-
*/
|
|
64
|
-
readonly reset: () => void;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Buffers exposing image metadata indexed by handle.
|
|
68
|
-
* @remarks It is used for (wasm) interoperability for image identity.
|
|
69
|
-
*/
|
|
70
|
-
export interface ImageHandleBuffers {
|
|
71
|
-
readonly widths: Float32Array;
|
|
72
|
-
readonly heights: Float32Array;
|
|
73
|
-
readonly textureReady: Uint8Array;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Registered image references aligned by handle index.
|
|
77
|
-
* @remarks It is used for (wasm) interoperability for image identity.
|
|
78
|
-
*/
|
|
79
|
-
export type ImageResourceTable = readonly (Readonly<RegisteredImage> | undefined)[];
|
|
80
|
-
/**
|
|
81
|
-
* Image handle buffer controller interface.
|
|
82
|
-
* @remarks It is used for (wasm) interoperability for image identity.
|
|
83
|
-
*/
|
|
84
|
-
export interface ImageHandleBufferController {
|
|
85
|
-
/**
|
|
86
|
-
* Flag metadata buffers for regeneration.
|
|
87
|
-
* @param images Image map.
|
|
88
|
-
*/
|
|
89
|
-
readonly markDirty: (images: ReadonlyMap<string, RegisteredImage>) => void;
|
|
90
|
-
/**
|
|
91
|
-
* Rebuilds the metadata buffers when flagged as dirty.
|
|
92
|
-
* @returns {ImageHandleBuffers} Metadata buffers aligned by handle index.
|
|
93
|
-
*/
|
|
94
|
-
readonly ensure: () => ImageHandleBuffers;
|
|
95
|
-
/**
|
|
96
|
-
* Returns registered images aligned by handle index. Ensures buffers are up to date.
|
|
97
|
-
*/
|
|
98
|
-
readonly getResourcesByHandle: () => ImageResourceTable;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Encoded pointer representing the target of an origin reference.
|
|
102
|
-
* @remarks It is used for (wasm) interoperability for image identity.
|
|
103
|
-
* The high bits encode the sub-layer while the low bits encode the order slot.
|
|
104
|
-
*/
|
|
105
|
-
export type SpriteOriginReferenceKey = number;
|
|
106
|
-
/** Sentinel used when the image does not reference another sprite image. */
|
|
107
|
-
export declare const SPRITE_ORIGIN_REFERENCE_KEY_NONE = -1;
|
|
108
|
-
/**
|
|
109
|
-
* Index into the render target bucket pointing at the resolved origin image.
|
|
110
|
-
* @remarks It is used for (wasm) interoperability for image identity.
|
|
111
|
-
* When no origin is assigned or the reference could not be resolved,
|
|
112
|
-
* the value will be {@link SPRITE_ORIGIN_REFERENCE_INDEX_NONE}.
|
|
113
|
-
*/
|
|
114
|
-
export type SpriteOriginReferenceIndex = number;
|
|
115
|
-
/** Sentinel indicating that the origin pointer has not been resolved yet. */
|
|
116
|
-
export declare const SPRITE_ORIGIN_REFERENCE_INDEX_NONE = -1;
|
|
117
|
-
/**
|
|
118
|
-
* Encode/Decode interface for a (subLayer, order) pair into a compact numeric key.
|
|
119
|
-
* @remarks It is used for (wasm) interoperability for image identity.
|
|
120
|
-
*/
|
|
121
|
-
export interface SpriteOriginReference {
|
|
122
|
-
/**
|
|
123
|
-
* Encodes a (subLayer, order) pair into a compact numeric key.
|
|
124
|
-
* @param subLayer Sub-layer identifier within the sprite.
|
|
125
|
-
* @param order Order slot inside the sub-layer.
|
|
126
|
-
* @returns Encoded origin reference key.
|
|
127
|
-
*/
|
|
128
|
-
readonly encodeKey: (subLayer: number, order: number) => SpriteOriginReferenceKey;
|
|
129
|
-
/**
|
|
130
|
-
* Decodes an origin reference key back into the sub-layer and order pair.
|
|
131
|
-
* @param key Encoded origin reference key.
|
|
132
|
-
* @returns `subLayer` and `order` components; when the key is invalid, both values are set to `-1`.
|
|
133
|
-
*/
|
|
134
|
-
readonly decodeKey: (key: SpriteOriginReferenceKey) => {
|
|
135
|
-
readonly subLayer: number;
|
|
136
|
-
readonly order: number;
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Tuple representing a single entry in a render target bucket.
|
|
141
|
-
* @remarks It is used for (wasm) interoperability for sprite origin.
|
|
142
|
-
* The first item is the sprite's frame-level state and the second item is
|
|
143
|
-
* the specific image being rendered,
|
|
144
|
-
* mirroring how the renderer stores draw calls on the CPU side.
|
|
145
|
-
* Keeping the pair immutable prevents accidental divergence between cached data
|
|
146
|
-
* and the GPU buffers derived from it.
|
|
147
|
-
*/
|
|
148
|
-
export type RenderTargetEntryLike<TTag> = readonly [
|
|
149
|
-
InternalSpriteCurrentState<TTag>,
|
|
150
|
-
InternalSpriteImageState
|
|
151
|
-
];
|
|
152
|
-
/**
|
|
153
|
-
* Parallel typed arrays that expose bucket metadata in a WASM-friendly layout.
|
|
154
|
-
* @remarks It is used for (wasm) interoperability for sprite origin.
|
|
155
|
-
* Both arrays always share the same length as the bucket, allowing shader-side
|
|
156
|
-
* code (or WASM helpers) to traverse origin reference metadata without touching
|
|
157
|
-
* the heavyweight tuple objects.
|
|
158
|
-
*/
|
|
159
|
-
export interface RenderTargetBucketBuffers {
|
|
160
|
-
/**
|
|
161
|
-
* Encoded origin metadata (sub-layer/order pairs) for each queued image,
|
|
162
|
-
* mirroring `image.originReferenceKey`. A value of
|
|
163
|
-
* `SPRITE_ORIGIN_REFERENCE_KEY_NONE` denotes that the entry is self-originating.
|
|
164
|
-
*/
|
|
165
|
-
readonly originReferenceKeys: Int32Array;
|
|
166
|
-
/**
|
|
167
|
-
* Bucket index pointing to the entry that should provide the origin image for
|
|
168
|
-
* the current sprite. Values equal to
|
|
169
|
-
* `SPRITE_ORIGIN_REFERENCE_INDEX_NONE` or outside the bucket range mark the
|
|
170
|
-
* origin as unresolved.
|
|
171
|
-
*/
|
|
172
|
-
readonly originTargetIndices: Int32Array;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Mutable interpolation states.
|
|
176
|
-
*/
|
|
177
|
-
export interface MutableSpriteInterpolation<TValue> {
|
|
178
|
-
state: SpriteInterpolationState<TValue> | null;
|
|
179
|
-
options: Readonly<SpriteInterpolationOptions> | null;
|
|
180
|
-
lastCommandValue: TValue;
|
|
181
|
-
baseValue: TValue | undefined;
|
|
182
|
-
targetValue: TValue | undefined;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Mutable counterpart to {@link SpriteInterpolatedValues}, used internally so SpriteLayer
|
|
186
|
-
* can reuse object references while still exposing readonly snapshots publicly.
|
|
187
|
-
*/
|
|
188
|
-
export interface MutableSpriteInterpolatedValues<TValue> extends SpriteInterpolatedValues<TValue> {
|
|
189
|
-
current: TValue;
|
|
190
|
-
from: TValue | undefined;
|
|
191
|
-
to: TValue | undefined;
|
|
192
|
-
invalidated: boolean | undefined;
|
|
193
|
-
interpolation: MutableSpriteInterpolation<TValue>;
|
|
194
|
-
}
|
|
195
|
-
export interface MutableSpriteImageInterpolatedOffset extends SpriteImageInterpolatedOffset {
|
|
196
|
-
offsetMeters: MutableSpriteInterpolatedValues<number>;
|
|
197
|
-
offsetDeg: MutableSpriteInterpolatedValues<number>;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Mimimum abstraction that exposes projection-related helpers.
|
|
201
|
-
*/
|
|
202
|
-
export interface ProjectionHost extends Releasable {
|
|
203
|
-
/**
|
|
204
|
-
* Get current zoom level.
|
|
205
|
-
* @returns Zoom level.
|
|
206
|
-
*/
|
|
207
|
-
readonly getZoom: () => number;
|
|
208
|
-
/**
|
|
209
|
-
* Get camera location.
|
|
210
|
-
* @returns Camera location when viewport is available.
|
|
211
|
-
*/
|
|
212
|
-
readonly getCameraLocation: () => SpriteLocation | undefined;
|
|
213
|
-
/**
|
|
214
|
-
* Extracts the current clip-space context if the mercator matrix is available.
|
|
215
|
-
* @returns {ClipContext | undefined} Clip context or `undefined` when the transform is not ready.
|
|
216
|
-
*/
|
|
217
|
-
readonly getClipContext: () => ClipContext | undefined;
|
|
218
|
-
/**
|
|
219
|
-
* Get mercator coordinate from the location
|
|
220
|
-
* @param location Location.
|
|
221
|
-
* @returns Mercator coordinate.
|
|
222
|
-
*/
|
|
223
|
-
readonly fromLngLat: (location: Readonly<SpriteLocation>) => SpriteMercatorCoordinate;
|
|
224
|
-
/**
|
|
225
|
-
* Project the location.
|
|
226
|
-
* @param location Location.
|
|
227
|
-
* @returns Projected point if valid location.
|
|
228
|
-
*/
|
|
229
|
-
readonly project: (location: Readonly<SpriteLocation>) => SpritePoint | undefined;
|
|
230
|
-
/**
|
|
231
|
-
* Unproject the location.
|
|
232
|
-
* @param point Projected point.
|
|
233
|
-
* @returns Location if valid point.
|
|
234
|
-
*/
|
|
235
|
-
readonly unproject: (point: Readonly<SpritePoint>) => SpriteLocation | undefined;
|
|
236
|
-
/**
|
|
237
|
-
* Calculate perspective ratio.
|
|
238
|
-
* @param location Location.
|
|
239
|
-
* @param cachedMercator Mercator coodinate when available earlier calculation.
|
|
240
|
-
* @returns The ratio.
|
|
241
|
-
*/
|
|
242
|
-
readonly calculatePerspectiveRatio: (location: Readonly<SpriteLocation>, cachedMercator?: SpriteMercatorCoordinate) => number;
|
|
243
|
-
}
|
|
244
|
-
export interface PrepareDrawSpriteImageParamsBase {
|
|
245
|
-
readonly imageResources: ImageResourceTable;
|
|
246
|
-
readonly imageHandleBuffers: Readonly<ImageHandleBuffers>;
|
|
247
|
-
readonly baseMetersPerPixel: number;
|
|
248
|
-
readonly drawingBufferWidth: number;
|
|
249
|
-
readonly drawingBufferHeight: number;
|
|
250
|
-
readonly pixelRatio: number;
|
|
251
|
-
readonly clipContext: Readonly<ClipContext> | undefined;
|
|
252
|
-
}
|
|
253
|
-
export interface PrepareDrawSpriteImageParamsBefore<TTag> extends PrepareDrawSpriteImageParamsBase {
|
|
254
|
-
readonly bucket: readonly Readonly<RenderTargetEntryLike<TTag>>[];
|
|
255
|
-
readonly bucketBuffers: Readonly<RenderTargetBucketBuffers>;
|
|
256
|
-
readonly resolvedScaling: ResolvedSpriteScalingOptions;
|
|
257
|
-
}
|
|
258
|
-
export interface PrepareDrawSpriteImageParamsAfter extends PrepareDrawSpriteImageParamsBase {
|
|
259
|
-
readonly identityScaleX: number;
|
|
260
|
-
readonly identityScaleY: number;
|
|
261
|
-
readonly identityOffsetX: number;
|
|
262
|
-
readonly identityOffsetY: number;
|
|
263
|
-
readonly screenToClipScaleX: number;
|
|
264
|
-
readonly screenToClipScaleY: number;
|
|
265
|
-
readonly screenToClipOffsetX: number;
|
|
266
|
-
readonly screenToClipOffsetY: number;
|
|
267
|
-
}
|
|
268
|
-
export interface PrepareDrawSpriteImageParams<TTag> extends PrepareDrawSpriteImageParamsBefore<TTag>, PrepareDrawSpriteImageParamsAfter {
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Prepared parameters for WebGL rendering.
|
|
272
|
-
*/
|
|
273
|
-
export interface PreparedDrawSpriteImageParams<T> {
|
|
274
|
-
readonly spriteEntry: InternalSpriteCurrentState<T>;
|
|
275
|
-
readonly imageEntry: InternalSpriteImageState;
|
|
276
|
-
readonly imageResource: RegisteredImage;
|
|
277
|
-
readonly vertexData: Float32Array;
|
|
278
|
-
opacity: number;
|
|
279
|
-
readonly cameraDistanceMeters: number;
|
|
280
|
-
readonly hitTestCorners: readonly [
|
|
281
|
-
Readonly<SpriteScreenPoint>,
|
|
282
|
-
Readonly<SpriteScreenPoint>,
|
|
283
|
-
Readonly<SpriteScreenPoint>,
|
|
284
|
-
Readonly<SpriteScreenPoint>
|
|
285
|
-
] | null;
|
|
286
|
-
readonly screenToClip: {
|
|
287
|
-
readonly scaleX: number;
|
|
288
|
-
readonly scaleY: number;
|
|
289
|
-
readonly offsetX: number;
|
|
290
|
-
readonly offsetY: number;
|
|
291
|
-
};
|
|
292
|
-
readonly useShaderSurface: boolean;
|
|
293
|
-
readonly surfaceShaderInputs: SurfaceShaderInputs | undefined;
|
|
294
|
-
readonly surfaceClipEnabled: boolean;
|
|
295
|
-
readonly useShaderBillboard: boolean;
|
|
296
|
-
readonly billboardUniforms: {
|
|
297
|
-
readonly center: SpritePoint;
|
|
298
|
-
readonly halfWidth: number;
|
|
299
|
-
readonly halfHeight: number;
|
|
300
|
-
readonly anchor: SpriteAnchor;
|
|
301
|
-
readonly sin: number;
|
|
302
|
-
readonly cos: number;
|
|
303
|
-
} | null;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Common frame parameters shared with interpolation processing.
|
|
307
|
-
*/
|
|
308
|
-
export interface RenderInterpolationFrameContext {
|
|
309
|
-
readonly baseMetersPerPixel: number;
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Parameters consumed when processing sprite interpolations.
|
|
313
|
-
*/
|
|
314
|
-
export interface RenderInterpolationParams<TTag> {
|
|
315
|
-
readonly sprites: readonly InternalSpriteCurrentState<TTag>[];
|
|
316
|
-
readonly timestamp: number;
|
|
317
|
-
readonly frameContext?: RenderInterpolationFrameContext;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Result produced by sprite interpolation processing.
|
|
321
|
-
*/
|
|
322
|
-
export interface RenderInterpolationResult {
|
|
323
|
-
readonly handled: boolean;
|
|
324
|
-
readonly hasActiveInterpolation: boolean;
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Parameters passed into RenderCalculationHost.processDrawSpriteImages.
|
|
328
|
-
*/
|
|
329
|
-
export interface ProcessDrawSpriteImagesParams<TTag> {
|
|
330
|
-
readonly interpolationParams?: RenderInterpolationParams<TTag>;
|
|
331
|
-
readonly prepareParams?: PrepareDrawSpriteImageParams<TTag>;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Result returned from RenderCalculationHost.processDrawSpriteImages.
|
|
335
|
-
*/
|
|
336
|
-
export interface ProcessDrawSpriteImagesResult<TTag> {
|
|
337
|
-
readonly preparedItems: PreparedDrawSpriteImageParams<TTag>[];
|
|
338
|
-
readonly interpolationResult: RenderInterpolationResult;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* The render calculation host.
|
|
342
|
-
* Abstraction that render calculations.
|
|
343
|
-
* @param TTag Tag type.
|
|
344
|
-
*/
|
|
345
|
-
export interface RenderCalculationHost<TTag> extends Releasable {
|
|
346
|
-
readonly processDrawSpriteImages: (params: ProcessDrawSpriteImagesParams<TTag>) => ProcessDrawSpriteImagesResult<TTag>;
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Corner model describing world displacements and resulting geographic coordinates for shader validation.
|
|
350
|
-
*/
|
|
351
|
-
export interface SurfaceShaderCornerState extends SpriteLocation, SurfaceCorner {
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Aggregated inputs required to reproduce surface geometry on the GPU.
|
|
355
|
-
*/
|
|
356
|
-
export interface SurfaceShaderInputs {
|
|
357
|
-
readonly mercatorCenter: {
|
|
358
|
-
readonly x: number;
|
|
359
|
-
readonly y: number;
|
|
360
|
-
readonly z: number;
|
|
361
|
-
};
|
|
362
|
-
readonly worldToMercatorScale: Readonly<SurfaceCorner>;
|
|
363
|
-
readonly halfSizeMeters: Readonly<SurfaceCorner>;
|
|
364
|
-
readonly anchor: Readonly<SpriteAnchor>;
|
|
365
|
-
readonly offsetMeters: Readonly<SurfaceCorner>;
|
|
366
|
-
readonly sinCos: {
|
|
367
|
-
readonly sin: number;
|
|
368
|
-
readonly cos: number;
|
|
369
|
-
};
|
|
370
|
-
readonly totalRotateDeg: number;
|
|
371
|
-
readonly depthBiasNdc: number;
|
|
372
|
-
readonly centerDisplacement: Readonly<SurfaceCorner>;
|
|
373
|
-
readonly baseLngLat: Readonly<SpriteLocation>;
|
|
374
|
-
readonly displacedCenter: Readonly<SpriteLocation>;
|
|
375
|
-
readonly scaleAdjustment: number;
|
|
376
|
-
readonly corners: readonly Readonly<SurfaceShaderCornerState>[];
|
|
377
|
-
clipCenter: {
|
|
378
|
-
readonly x: number;
|
|
379
|
-
readonly y: number;
|
|
380
|
-
readonly z: number;
|
|
381
|
-
readonly w: number;
|
|
382
|
-
};
|
|
383
|
-
clipBasisEast: {
|
|
384
|
-
readonly x: number;
|
|
385
|
-
readonly y: number;
|
|
386
|
-
readonly z: number;
|
|
387
|
-
readonly w: number;
|
|
388
|
-
};
|
|
389
|
-
clipBasisNorth: {
|
|
390
|
-
readonly x: number;
|
|
391
|
-
readonly y: number;
|
|
392
|
-
readonly z: number;
|
|
393
|
-
readonly w: number;
|
|
394
|
-
};
|
|
395
|
-
clipCorners: ReadonlyArray<{
|
|
396
|
-
readonly x: number;
|
|
397
|
-
readonly y: number;
|
|
398
|
-
readonly z: number;
|
|
399
|
-
readonly w: number;
|
|
400
|
-
}>;
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Easing function type.
|
|
404
|
-
*/
|
|
405
|
-
export type EasingFunction = (progress: number) => number;
|
|
406
|
-
/**
|
|
407
|
-
* Runtime state describing the active interpolation between two sprite locations.
|
|
408
|
-
* Consumers reuse the same state across ticks to avoid re-allocations while animation is running.
|
|
409
|
-
*/
|
|
410
|
-
export interface SpriteInterpolationState<TValue> {
|
|
411
|
-
/** Strategy used to resolve the target location (feedback or feedforward). */
|
|
412
|
-
readonly mode: SpriteInterpolationMode;
|
|
413
|
-
/** Total time allocated for the interpolation in milliseconds. */
|
|
414
|
-
readonly durationMs: number;
|
|
415
|
-
/** Easing attributes */
|
|
416
|
-
readonly easingParam: SpriteEasingParam;
|
|
417
|
-
/** Resolved easing function applied to raw progress values. */
|
|
418
|
-
readonly easingFunc: EasingFunction;
|
|
419
|
-
/** Origin sprite location cloned from the current render state. */
|
|
420
|
-
readonly from: TValue;
|
|
421
|
-
/** Destination sprite location being interpolated towards. */
|
|
422
|
-
readonly to: TValue;
|
|
423
|
-
/** */
|
|
424
|
-
readonly pathTarget?: TValue;
|
|
425
|
-
/** Epoch millisecond when the interpolation started, or -1 when uninitialized. */
|
|
426
|
-
startTimestamp: number;
|
|
427
|
-
}
|
|
428
|
-
export interface SpriteInterpolationEvaluationResult<TValue> {
|
|
429
|
-
readonly value: TValue;
|
|
430
|
-
readonly completed: boolean;
|
|
431
|
-
readonly effectiveStartTimestamp: number;
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Texture filtering parameters resolved from the public options structure.
|
|
435
|
-
*/
|
|
436
|
-
export interface ResolvedTextureFilteringOptions {
|
|
437
|
-
readonly minFilter: SpriteTextureMinFilter;
|
|
438
|
-
readonly magFilter: SpriteTextureMagFilter;
|
|
439
|
-
readonly generateMipmaps: boolean;
|
|
440
|
-
readonly maxAnisotropy: number;
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Image metadata ready for use as a WebGL texture.
|
|
444
|
-
*/
|
|
445
|
-
export interface RegisteredImage {
|
|
446
|
-
readonly id: string;
|
|
447
|
-
/**
|
|
448
|
-
* For use (wasm) interoperability id.
|
|
449
|
-
*/
|
|
450
|
-
readonly handle: number;
|
|
451
|
-
readonly width: number;
|
|
452
|
-
readonly height: number;
|
|
453
|
-
readonly bitmap: ImageBitmap;
|
|
454
|
-
texture: WebGLTexture | undefined;
|
|
455
|
-
atlasPageIndex: number;
|
|
456
|
-
atlasU0: number;
|
|
457
|
-
atlasV0: number;
|
|
458
|
-
atlasU1: number;
|
|
459
|
-
atlasV1: number;
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Padding resolved for glyph rendering with guaranteed non-negative values.
|
|
463
|
-
*/
|
|
464
|
-
export interface ResolvedTextGlyphPadding {
|
|
465
|
-
readonly top: number;
|
|
466
|
-
readonly right: number;
|
|
467
|
-
readonly bottom: number;
|
|
468
|
-
readonly left: number;
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Border sides resolved for glyph rendering.
|
|
472
|
-
*/
|
|
473
|
-
export interface ResolvedBorderSides {
|
|
474
|
-
readonly top: boolean;
|
|
475
|
-
readonly right: boolean;
|
|
476
|
-
readonly bottom: boolean;
|
|
477
|
-
readonly left: boolean;
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Fully resolved glyph rendering options with defaults applied.
|
|
481
|
-
*/
|
|
482
|
-
export interface ResolvedTextGlyphOptions {
|
|
483
|
-
readonly fontFamily: string;
|
|
484
|
-
readonly fontStyle: 'normal' | 'italic';
|
|
485
|
-
readonly fontWeight: string;
|
|
486
|
-
readonly fontSizePixel: number;
|
|
487
|
-
readonly color: string;
|
|
488
|
-
readonly letterSpacingPixel: number;
|
|
489
|
-
readonly backgroundColor?: string;
|
|
490
|
-
readonly paddingPixel: ResolvedTextGlyphPadding;
|
|
491
|
-
readonly borderColor?: string;
|
|
492
|
-
readonly borderWidthPixel: number;
|
|
493
|
-
readonly borderRadiusPixel: number;
|
|
494
|
-
readonly borderSides: ResolvedBorderSides;
|
|
495
|
-
readonly textAlign: SpriteTextGlyphHorizontalAlign;
|
|
496
|
-
readonly renderPixelRatio: number;
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Mutable point reused when computing hit-test corners.
|
|
500
|
-
*/
|
|
501
|
-
export interface MutableSpriteScreenPoint extends SpriteScreenPoint {
|
|
502
|
-
x: number;
|
|
503
|
-
y: number;
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Compact representation of an Array-like 4x4 matrix.
|
|
507
|
-
*/
|
|
508
|
-
export type MatrixInput = ArrayLike<number>;
|
|
509
|
-
/**
|
|
510
|
-
* Cached clip-space context containing the mercator matrix required to project coordinates.
|
|
511
|
-
*/
|
|
512
|
-
export interface ClipContext {
|
|
513
|
-
readonly mercatorMatrix: MatrixInput;
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* 2D canvas rendering context accepted by the glyph renderer.
|
|
517
|
-
*/
|
|
518
|
-
export type Canvas2DContext = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
519
|
-
/**
|
|
520
|
-
* Canvas sources supported when rendering text glyphs.
|
|
521
|
-
*/
|
|
522
|
-
export type Canvas2DSource = HTMLCanvasElement | OffscreenCanvas;
|
|
523
|
-
/** Line definition resolved for rendering. */
|
|
524
|
-
export interface ResolvedSpriteImageLineAttribute extends SpriteImageLineAttributeState {
|
|
525
|
-
readonly rgba: RgbaColor;
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* Base mutable attribute view for an image that composes a sprite.
|
|
529
|
-
*/
|
|
530
|
-
export interface InternalSpriteImageState extends SpriteImageState {
|
|
531
|
-
subLayer: number;
|
|
532
|
-
order: number;
|
|
533
|
-
imageId: string;
|
|
534
|
-
imageHandle: number;
|
|
535
|
-
mode: SpriteMode;
|
|
536
|
-
scale: number;
|
|
537
|
-
anchor: Readonly<SpriteAnchor>;
|
|
538
|
-
border: ResolvedSpriteImageLineAttribute | undefined;
|
|
539
|
-
borderPixelWidth: number;
|
|
540
|
-
leaderLine: ResolvedSpriteImageLineAttribute | undefined;
|
|
541
|
-
leaderLinePixelWidth: number;
|
|
542
|
-
rotateDeg: number;
|
|
543
|
-
opacity: number;
|
|
544
|
-
lodOpacity: number;
|
|
545
|
-
finalOpacity: MutableSpriteInterpolatedValues<number>;
|
|
546
|
-
offset: MutableSpriteImageInterpolatedOffset;
|
|
547
|
-
finalRotateDeg: MutableSpriteInterpolatedValues<number>;
|
|
548
|
-
autoRotation: boolean;
|
|
549
|
-
autoRotationMinDistanceMeters: number;
|
|
550
|
-
originLocation: Readonly<SpriteImageOriginLocation> | undefined;
|
|
551
|
-
originReferenceKey: SpriteOriginReferenceKey;
|
|
552
|
-
originRenderTargetIndex: SpriteOriginReferenceIndex;
|
|
553
|
-
interpolationDirty: boolean;
|
|
554
|
-
surfaceShaderInputs: Readonly<SurfaceShaderInputs> | undefined;
|
|
555
|
-
hitTestCorners: [
|
|
556
|
-
MutableSpriteScreenPoint,
|
|
557
|
-
MutableSpriteScreenPoint,
|
|
558
|
-
MutableSpriteScreenPoint,
|
|
559
|
-
MutableSpriteScreenPoint
|
|
560
|
-
] | undefined;
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Current sprite mutable state view tracked internally by the layer.
|
|
564
|
-
*/
|
|
565
|
-
export interface InternalSpriteCurrentState<TTag> extends SpriteCurrentState<TTag> {
|
|
566
|
-
spriteId: string;
|
|
567
|
-
handle: IdHandle;
|
|
568
|
-
isEnabled: boolean;
|
|
569
|
-
visibilityDistanceMeters: number | undefined;
|
|
570
|
-
opacityMultiplier: number;
|
|
571
|
-
location: MutableSpriteInterpolatedValues<SpriteLocation>;
|
|
572
|
-
images: Map<number, Map<number, InternalSpriteImageState>>;
|
|
573
|
-
tag: TTag | null;
|
|
574
|
-
lastAutoRotationLocation: Readonly<SpriteLocation>;
|
|
575
|
-
currentAutoRotateDeg: number;
|
|
576
|
-
autoRotationInvalidated: boolean;
|
|
577
|
-
interpolationDirty: boolean;
|
|
578
|
-
cachedMercator: Readonly<SpriteMercatorCoordinate>;
|
|
579
|
-
cachedMercatorLng: number;
|
|
580
|
-
cachedMercatorLat: number;
|
|
581
|
-
cachedMercatorZ: number | undefined;
|
|
582
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* name: maplibre-gl-layers
|
|
3
|
-
* version: 1.0.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: 3a2127f77d7fd3ed6ae30186d4a06f52610673a6
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { SpriteInterpolationOptions } from '../types';
|
|
12
|
-
import { SpriteInterpolationEvaluationResult, InternalSpriteImageState, SpriteInterpolationState } from '../internalTypes';
|
|
13
|
-
import { SpriteInterpolationChannelDescriptor } from './interpolationChannels';
|
|
14
|
-
/**
|
|
15
|
-
* Parameters required to construct a {@link DegreeInterpolationState}.
|
|
16
|
-
*/
|
|
17
|
-
export interface CreateDegreeInterpolationStateParams {
|
|
18
|
-
/** Current numeric value rendered on screen. */
|
|
19
|
-
currentValue: number;
|
|
20
|
-
/** Desired value after interpolation completes. */
|
|
21
|
-
targetValue: number;
|
|
22
|
-
/** Prior commanded value used for feed-forward prediction. */
|
|
23
|
-
previousCommandValue?: number;
|
|
24
|
-
/** Timing and easing configuration. */
|
|
25
|
-
options: SpriteInterpolationOptions;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Result returned by {@link createDegreeInterpolationState} containing state and a flag for activation.
|
|
29
|
-
*/
|
|
30
|
-
export interface CreateDegreeInterpolationStateResult {
|
|
31
|
-
/** Resolved state object. */
|
|
32
|
-
readonly state: SpriteInterpolationState<number>;
|
|
33
|
-
/** Indicates whether the caller should animate or snap. */
|
|
34
|
-
readonly requiresInterpolation: boolean;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Creates interpolation state describing how to move from the current value to the target value.
|
|
38
|
-
* @param {CreateDegreeInterpolationStateParams} params - Inputs describing the current, target, and options.
|
|
39
|
-
* @returns {CreateDegreeInterpolationStateResult} State data plus a flag indicating if animation is needed.
|
|
40
|
-
*/
|
|
41
|
-
export declare const createDegreeInterpolationState: (params: CreateDegreeInterpolationStateParams) => CreateDegreeInterpolationStateResult;
|
|
42
|
-
export declare const evaluateDegreeInterpolation: (state: SpriteInterpolationState<number>, timestamp: number) => SpriteInterpolationEvaluationResult<number>;
|
|
43
|
-
export interface DegreeInterpolationWorkItem extends SpriteInterpolationState<number> {
|
|
44
|
-
readonly descriptor: SpriteInterpolationChannelDescriptor;
|
|
45
|
-
readonly image: InternalSpriteImageState;
|
|
46
|
-
readonly channel: 'rotation' | 'offsetDeg';
|
|
47
|
-
}
|
|
48
|
-
export declare const collectDegreeInterpolationWorkItems: (image: InternalSpriteImageState, workItems: DegreeInterpolationWorkItem[]) => void;
|
|
49
|
-
export declare const applyDegreeInterpolationEvaluations: (workItems: readonly DegreeInterpolationWorkItem[], evaluations: readonly SpriteInterpolationEvaluationResult<number>[], timestamp: number) => boolean;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* name: maplibre-gl-layers
|
|
3
|
-
* version: 1.0.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: 3a2127f77d7fd3ed6ae30186d4a06f52610673a6
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { SpriteInterpolationOptions } from '../types';
|
|
12
|
-
import { InternalSpriteImageState, SpriteInterpolationEvaluationResult, SpriteInterpolationState } from '../internalTypes';
|
|
13
|
-
import { SpriteInterpolationChannelDescriptor } from './interpolationChannels';
|
|
14
|
-
export interface CreateDistanceInterpolationStateParams {
|
|
15
|
-
currentValue: number;
|
|
16
|
-
targetValue: number;
|
|
17
|
-
previousCommandValue?: number;
|
|
18
|
-
options: SpriteInterpolationOptions;
|
|
19
|
-
}
|
|
20
|
-
export interface CreateDistanceInterpolationStateResult {
|
|
21
|
-
readonly state: SpriteInterpolationState<number>;
|
|
22
|
-
readonly requiresInterpolation: boolean;
|
|
23
|
-
}
|
|
24
|
-
export declare const createDistanceInterpolationState: (params: CreateDistanceInterpolationStateParams) => CreateDistanceInterpolationStateResult;
|
|
25
|
-
export declare const evaluateDistanceInterpolation: (state: SpriteInterpolationState<number>, timestamp: number) => SpriteInterpolationEvaluationResult<number>;
|
|
26
|
-
export interface DistanceInterpolationWorkItem extends SpriteInterpolationState<number> {
|
|
27
|
-
readonly descriptor: SpriteInterpolationChannelDescriptor;
|
|
28
|
-
readonly image: InternalSpriteImageState;
|
|
29
|
-
readonly channel: 'offsetMeters' | 'opacity';
|
|
30
|
-
}
|
|
31
|
-
export declare const collectDistanceInterpolationWorkItems: (image: InternalSpriteImageState, workItems: DistanceInterpolationWorkItem[], includeOffsetMeters: boolean, includeOpacity: boolean) => void;
|
|
32
|
-
export declare const applyDistanceInterpolationEvaluations: (workItems: readonly DistanceInterpolationWorkItem[], evaluations: readonly SpriteInterpolationEvaluationResult<number>[], timestamp: number) => boolean;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* name: maplibre-gl-layers
|
|
3
|
-
* version: 1.0.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: 3a2127f77d7fd3ed6ae30186d4a06f52610673a6
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { EasingFunction } from '../internalTypes';
|
|
12
|
-
import { SpriteEasingParam } from '../types';
|
|
13
|
-
/**
|
|
14
|
-
* Linear interpolation that clamps the value to the [0, 1] range.
|
|
15
|
-
*/
|
|
16
|
-
export declare const linearEasing: EasingFunction;
|
|
17
|
-
export interface ResolvedEasing {
|
|
18
|
-
readonly param: SpriteEasingParam;
|
|
19
|
-
readonly func: EasingFunction;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Resolves an easing definition into its implementation, defaulting to linear when unspecified or unknown.
|
|
23
|
-
* @param easing - Easing parameter.
|
|
24
|
-
* @return Resolved easing parameters.
|
|
25
|
-
*/
|
|
26
|
-
export declare const resolveEasing: (easing?: SpriteEasingParam) => ResolvedEasing;
|