maplibre-gl-layers 0.14.0 → 0.15.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/dist/SpriteLayer.d.ts +3 -21
- package/dist/config.d.ts +2 -2
- package/dist/const.d.ts +3 -3
- package/dist/default.d.ts +2 -2
- package/dist/{atlas.d.ts → gl/atlas.d.ts} +3 -3
- package/dist/gl/hitTest.d.ts +54 -0
- package/dist/{shader.d.ts → gl/shader.d.ts} +6 -6
- package/dist/gl/text.d.ts +17 -0
- package/dist/{calculationHost.d.ts → host/calculationHost.d.ts} +26 -4
- package/dist/{mapLibreProjectionHost.d.ts → host/mapLibreProjectionHost.d.ts} +3 -3
- package/dist/{projectionHost.d.ts → host/projectionHost.d.ts} +5 -4
- package/dist/{runtime.d.ts → host/runtime.d.ts} +4 -3
- package/dist/{wasmCalculationHost.d.ts → host/wasmCalculationHost.d.ts} +14 -14
- package/dist/{wasmHost.d.ts → host/wasmHost.d.ts} +7 -5
- package/dist/{wasmProjectionHost.d.ts → host/wasmProjectionHost.d.ts} +3 -3
- package/dist/index.cjs +4378 -2891
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +4378 -2891
- package/dist/index.mjs.map +1 -1
- package/dist/internalTypes.d.ts +104 -15
- package/dist/{degreeInterpolation.d.ts → interpolation/degreeInterpolation.d.ts} +19 -4
- package/dist/interpolation/distanceInterpolation.d.ts +46 -0
- package/dist/{easing.d.ts → interpolation/easing.d.ts} +9 -4
- package/dist/{interpolation.d.ts → interpolation/interpolation.d.ts} +5 -27
- package/dist/{interpolationChannels.d.ts → interpolation/interpolationChannels.d.ts} +16 -7
- package/dist/{rotationInterpolation.d.ts → interpolation/rotationInterpolation.d.ts} +5 -10
- package/dist/types.d.ts +56 -22
- package/dist/{image.d.ts → utils/image.d.ts} +3 -3
- package/dist/{looseQuadTree.d.ts → utils/looseQuadTree.d.ts} +2 -2
- package/dist/{math.d.ts → utils/math.d.ts} +15 -4
- package/dist/{utils.d.ts → utils/utils.d.ts} +3 -3
- package/dist/wasm/config.json.d.ts +2 -2
- package/dist/wasm/offloads-nosimd.wasm +0 -0
- package/dist/wasm/offloads-simd-mt.js +1 -1
- package/dist/wasm/offloads-simd-mt.wasm +0 -0
- package/dist/wasm/offloads-simd.wasm +0 -0
- package/package.json +6 -8
- package/dist/distanceInterpolation.d.ts +0 -33
package/dist/internalTypes.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.15.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: d850b7e9c713f54f0630248dc4ea370721b6965b
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { SpriteMode, SpriteAnchor,
|
|
12
|
-
import { ResolvedSpriteScalingOptions, SurfaceCorner } from './math';
|
|
11
|
+
import { SpriteMode, SpriteAnchor, SpriteInterpolationOptions, SpriteImageOriginLocation, SpriteLocation, SpriteTextGlyphHorizontalAlign, SpriteTextureMagFilter, SpriteTextureMinFilter, SpriteInterpolationMode, EasingFunction, SpriteScreenPoint, SpritePoint, SpriteEasingPresetName } from './types';
|
|
12
|
+
import { ResolvedSpriteScalingOptions, SurfaceCorner } from './utils/math';
|
|
13
13
|
/**
|
|
14
14
|
* The handle value that using the instance.
|
|
15
15
|
*/
|
|
@@ -167,13 +167,26 @@ export interface SpriteMercatorCoordinate {
|
|
|
167
167
|
readonly y: number;
|
|
168
168
|
readonly z: number;
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Mutable counterpart to {@link InterpolatedValues}, used internally so SpriteLayer
|
|
172
|
+
* can reuse object references while still exposing readonly snapshots publicly.
|
|
173
|
+
*/
|
|
174
|
+
export interface MutableInterpolatedValues<T> {
|
|
175
|
+
current: T;
|
|
176
|
+
from: T | undefined;
|
|
177
|
+
to: T | undefined;
|
|
178
|
+
}
|
|
179
|
+
export interface MutableSpriteImageInterpolatedOffset {
|
|
180
|
+
offsetMeters: MutableInterpolatedValues<number>;
|
|
181
|
+
offsetDeg: MutableInterpolatedValues<number>;
|
|
182
|
+
}
|
|
183
|
+
export interface Releasable {
|
|
171
184
|
readonly release: () => void;
|
|
172
185
|
}
|
|
173
186
|
/**
|
|
174
187
|
* Abstraction that exposes projection-related helpers.
|
|
175
188
|
*/
|
|
176
|
-
export interface ProjectionHost extends
|
|
189
|
+
export interface ProjectionHost extends Releasable {
|
|
177
190
|
/**
|
|
178
191
|
* Get current zoom level.
|
|
179
192
|
* @returns Zoom level.
|
|
@@ -209,6 +222,7 @@ export interface ProjectionHost extends Releaseable {
|
|
|
209
222
|
* @returns The ratio.
|
|
210
223
|
*/
|
|
211
224
|
readonly calculatePerspectiveRatio: (location: Readonly<SpriteLocation>, cachedMercator?: SpriteMercatorCoordinate) => number;
|
|
225
|
+
readonly getCameraLocation: () => SpriteLocation | null;
|
|
212
226
|
}
|
|
213
227
|
export interface PrepareDrawSpriteImageParamsBase {
|
|
214
228
|
readonly imageResources: ImageResourceTable;
|
|
@@ -247,7 +261,8 @@ export interface PreparedDrawSpriteImageParams<T> {
|
|
|
247
261
|
readonly imageEntry: InternalSpriteImageState;
|
|
248
262
|
readonly imageResource: RegisteredImage;
|
|
249
263
|
readonly vertexData: Float32Array;
|
|
250
|
-
|
|
264
|
+
opacity: number;
|
|
265
|
+
readonly cameraDistanceMeters: number;
|
|
251
266
|
readonly hitTestCorners: readonly [
|
|
252
267
|
Readonly<SpriteScreenPoint>,
|
|
253
268
|
Readonly<SpriteScreenPoint>,
|
|
@@ -273,13 +288,50 @@ export interface PreparedDrawSpriteImageParams<T> {
|
|
|
273
288
|
readonly cos: number;
|
|
274
289
|
} | null;
|
|
275
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Common frame parameters shared with interpolation processing.
|
|
293
|
+
*/
|
|
294
|
+
export interface RenderInterpolationFrameContext {
|
|
295
|
+
readonly baseMetersPerPixel: number;
|
|
296
|
+
readonly spriteMinPixel: number;
|
|
297
|
+
readonly spriteMaxPixel: number;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Parameters consumed when processing sprite interpolations.
|
|
301
|
+
*/
|
|
302
|
+
export interface RenderInterpolationParams<TTag> {
|
|
303
|
+
readonly sprites: readonly InternalSpriteCurrentState<TTag>[];
|
|
304
|
+
readonly timestamp: number;
|
|
305
|
+
readonly frameContext?: RenderInterpolationFrameContext;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Result produced by sprite interpolation processing.
|
|
309
|
+
*/
|
|
310
|
+
export interface RenderInterpolationResult {
|
|
311
|
+
readonly handled: boolean;
|
|
312
|
+
readonly hasActiveInterpolation: boolean;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Parameters passed into RenderCalculationHost.processDrawSpriteImages.
|
|
316
|
+
*/
|
|
317
|
+
export interface ProcessDrawSpriteImagesParams<TTag> {
|
|
318
|
+
readonly interpolationParams?: RenderInterpolationParams<TTag>;
|
|
319
|
+
readonly prepareParams?: PrepareDrawSpriteImageParams<TTag>;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Result returned from RenderCalculationHost.processDrawSpriteImages.
|
|
323
|
+
*/
|
|
324
|
+
export interface ProcessDrawSpriteImagesResult<TTag> {
|
|
325
|
+
readonly preparedItems: PreparedDrawSpriteImageParams<TTag>[];
|
|
326
|
+
readonly interpolationResult: RenderInterpolationResult;
|
|
327
|
+
}
|
|
276
328
|
/**
|
|
277
329
|
* The render calculation host.
|
|
278
330
|
* Abstraction that render calculations.
|
|
279
331
|
* @param TTag Tag type.
|
|
280
332
|
*/
|
|
281
|
-
export interface RenderCalculationHost<TTag> extends
|
|
282
|
-
readonly
|
|
333
|
+
export interface RenderCalculationHost<TTag> extends Releasable {
|
|
334
|
+
readonly processDrawSpriteImages: (params: ProcessDrawSpriteImagesParams<TTag>) => ProcessDrawSpriteImagesResult<TTag>;
|
|
283
335
|
}
|
|
284
336
|
/**
|
|
285
337
|
* Corner model describing world displacements and resulting geographic coordinates for shader validation.
|
|
@@ -350,6 +402,7 @@ export interface SpriteInterpolationState {
|
|
|
350
402
|
readonly mode: SpriteInterpolationMode;
|
|
351
403
|
readonly durationMs: number;
|
|
352
404
|
readonly easing: EasingFunction;
|
|
405
|
+
readonly easingPreset: SpriteEasingPresetName | null;
|
|
353
406
|
startTimestamp: number;
|
|
354
407
|
readonly from: SpriteLocation;
|
|
355
408
|
readonly to: SpriteLocation;
|
|
@@ -366,6 +419,7 @@ export interface SpriteInterpolationState {
|
|
|
366
419
|
export interface DegreeInterpolationState {
|
|
367
420
|
readonly durationMs: number;
|
|
368
421
|
readonly easing: EasingFunction;
|
|
422
|
+
readonly easingPreset: SpriteEasingPresetName | null;
|
|
369
423
|
readonly from: number;
|
|
370
424
|
readonly to: number;
|
|
371
425
|
readonly finalValue: number;
|
|
@@ -374,11 +428,39 @@ export interface DegreeInterpolationState {
|
|
|
374
428
|
export interface DistanceInterpolationState {
|
|
375
429
|
readonly durationMs: number;
|
|
376
430
|
readonly easing: EasingFunction;
|
|
431
|
+
readonly easingPreset: SpriteEasingPresetName | null;
|
|
377
432
|
readonly from: number;
|
|
378
433
|
readonly to: number;
|
|
379
434
|
readonly finalValue: number;
|
|
380
435
|
startTimestamp: number;
|
|
381
436
|
}
|
|
437
|
+
export interface DistanceInterpolationEvaluationParams {
|
|
438
|
+
readonly state: DistanceInterpolationState;
|
|
439
|
+
readonly timestamp: number;
|
|
440
|
+
}
|
|
441
|
+
export interface DistanceInterpolationEvaluationResult {
|
|
442
|
+
readonly value: number;
|
|
443
|
+
readonly completed: boolean;
|
|
444
|
+
readonly effectiveStartTimestamp: number;
|
|
445
|
+
}
|
|
446
|
+
export interface DegreeInterpolationEvaluationParams {
|
|
447
|
+
readonly state: DegreeInterpolationState;
|
|
448
|
+
readonly timestamp: number;
|
|
449
|
+
}
|
|
450
|
+
export interface DegreeInterpolationEvaluationResult {
|
|
451
|
+
readonly value: number;
|
|
452
|
+
readonly completed: boolean;
|
|
453
|
+
readonly effectiveStartTimestamp: number;
|
|
454
|
+
}
|
|
455
|
+
export interface SpriteInterpolationEvaluationParams {
|
|
456
|
+
readonly state: SpriteInterpolationState;
|
|
457
|
+
readonly timestamp: number;
|
|
458
|
+
}
|
|
459
|
+
export interface SpriteInterpolationEvaluationResult {
|
|
460
|
+
readonly location: SpriteLocation;
|
|
461
|
+
readonly completed: boolean;
|
|
462
|
+
readonly effectiveStartTimestamp: number;
|
|
463
|
+
}
|
|
382
464
|
/**
|
|
383
465
|
* Alias for the interpolation state used internally by sprites.
|
|
384
466
|
*/
|
|
@@ -482,11 +564,12 @@ export interface InternalSpriteImageState {
|
|
|
482
564
|
imageId: string;
|
|
483
565
|
imageHandle: number;
|
|
484
566
|
mode: SpriteMode;
|
|
485
|
-
opacity: number
|
|
567
|
+
opacity: MutableInterpolatedValues<number>;
|
|
486
568
|
scale: number;
|
|
487
569
|
anchor: Readonly<SpriteAnchor>;
|
|
488
|
-
offset:
|
|
489
|
-
rotateDeg: number
|
|
570
|
+
offset: MutableSpriteImageInterpolatedOffset;
|
|
571
|
+
rotateDeg: MutableInterpolatedValues<number>;
|
|
572
|
+
rotationCommandDeg: number;
|
|
490
573
|
displayedRotateDeg: number;
|
|
491
574
|
autoRotation: boolean;
|
|
492
575
|
autoRotationMinDistanceMeters: number;
|
|
@@ -498,9 +581,15 @@ export interface InternalSpriteImageState {
|
|
|
498
581
|
rotationInterpolationOptions: Readonly<SpriteInterpolationOptions> | null;
|
|
499
582
|
offsetDegInterpolationState: Readonly<DegreeInterpolationState> | null;
|
|
500
583
|
offsetMetersInterpolationState: Readonly<DistanceInterpolationState> | null;
|
|
584
|
+
opacityInterpolationState: Readonly<DistanceInterpolationState> | null;
|
|
585
|
+
opacityInterpolationOptions: Readonly<SpriteInterpolationOptions> | null;
|
|
586
|
+
opacityTargetValue: number;
|
|
587
|
+
lodLastCommandOpacity: number;
|
|
501
588
|
lastCommandRotateDeg: number;
|
|
502
589
|
lastCommandOffsetDeg: number;
|
|
503
590
|
lastCommandOffsetMeters: number;
|
|
591
|
+
lastCommandOpacity: number;
|
|
592
|
+
interpolationDirty: boolean;
|
|
504
593
|
surfaceShaderInputs?: Readonly<SurfaceShaderInputs>;
|
|
505
594
|
hitTestCorners?: [
|
|
506
595
|
MutableSpriteScreenPoint,
|
|
@@ -516,9 +605,8 @@ export interface InternalSpriteCurrentState<TTag> {
|
|
|
516
605
|
spriteId: string;
|
|
517
606
|
handle: IdHandle;
|
|
518
607
|
isEnabled: boolean;
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
toLocation?: Readonly<SpriteLocation>;
|
|
608
|
+
visibilityDistanceMeters?: number;
|
|
609
|
+
location: MutableInterpolatedValues<Readonly<SpriteLocation>>;
|
|
522
610
|
images: Map<number, Map<number, InternalSpriteImageState>>;
|
|
523
611
|
tag: TTag | null;
|
|
524
612
|
interpolationState: InternalSpriteInterpolationState | null;
|
|
@@ -526,6 +614,7 @@ export interface InternalSpriteCurrentState<TTag> {
|
|
|
526
614
|
lastCommandLocation: Readonly<SpriteLocation>;
|
|
527
615
|
lastAutoRotationLocation: Readonly<SpriteLocation>;
|
|
528
616
|
lastAutoRotationAngleDeg: number;
|
|
617
|
+
interpolationDirty: boolean;
|
|
529
618
|
cachedMercator: Readonly<SpriteMercatorCoordinate>;
|
|
530
619
|
cachedMercatorLng: number;
|
|
531
620
|
cachedMercatorLat: number;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.15.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: d850b7e9c713f54f0630248dc4ea370721b6965b
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { SpriteInterpolationOptions } from '
|
|
12
|
-
import { DegreeInterpolationState } from '
|
|
11
|
+
import { SpriteInterpolationOptions } from '../types';
|
|
12
|
+
import { DegreeInterpolationState, DegreeInterpolationEvaluationResult, InternalSpriteImageState } from '../internalTypes';
|
|
13
13
|
/**
|
|
14
14
|
* Parameters required to construct a {@link DegreeInterpolationState}.
|
|
15
15
|
* @property {number} currentValue - Current numeric value rendered on screen.
|
|
@@ -64,3 +64,18 @@ export interface EvaluateDegreeInterpolationResult {
|
|
|
64
64
|
* @returns {EvaluateDegreeInterpolationResult} Current value, completion flag, and effective start time.
|
|
65
65
|
*/
|
|
66
66
|
export declare const evaluateDegreeInterpolation: (params: EvaluateDegreeInterpolationParams) => EvaluateDegreeInterpolationResult;
|
|
67
|
+
type DegreeInterpolationStateKey = 'rotationInterpolationState' | 'offsetDegInterpolationState';
|
|
68
|
+
interface DegreeInterpolationChannelDescriptor {
|
|
69
|
+
readonly stateKey: DegreeInterpolationStateKey;
|
|
70
|
+
readonly normalize?: (value: number) => number;
|
|
71
|
+
readonly applyValue: (image: InternalSpriteImageState, value: number) => void;
|
|
72
|
+
readonly applyFinalValue?: (image: InternalSpriteImageState, value: number) => void;
|
|
73
|
+
}
|
|
74
|
+
export interface DegreeInterpolationWorkItem {
|
|
75
|
+
readonly descriptor: DegreeInterpolationChannelDescriptor;
|
|
76
|
+
readonly image: InternalSpriteImageState;
|
|
77
|
+
readonly state: DegreeInterpolationState;
|
|
78
|
+
}
|
|
79
|
+
export declare const collectDegreeInterpolationWorkItems: (image: InternalSpriteImageState, workItems: DegreeInterpolationWorkItem[]) => void;
|
|
80
|
+
export declare const applyDegreeInterpolationEvaluations: (workItems: readonly DegreeInterpolationWorkItem[], evaluations: readonly DegreeInterpolationEvaluationResult[], timestamp: number) => boolean;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: maplibre-gl-layers
|
|
3
|
+
* version: 0.15.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: d850b7e9c713f54f0630248dc4ea370721b6965b
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { SpriteInterpolationOptions } from '../types';
|
|
12
|
+
import { DistanceInterpolationEvaluationParams, DistanceInterpolationEvaluationResult, DistanceInterpolationState, InternalSpriteImageState } 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 declare const evaluateDistanceInterpolation: (params: DistanceInterpolationEvaluationParams) => DistanceInterpolationEvaluationResult;
|
|
25
|
+
type DistanceInterpolationStateKey = 'offsetMetersInterpolationState' | 'opacityInterpolationState';
|
|
26
|
+
interface DistanceInterpolationChannelDescriptor {
|
|
27
|
+
readonly stateKey: DistanceInterpolationStateKey;
|
|
28
|
+
readonly normalize?: (value: number) => number;
|
|
29
|
+
readonly applyValue: (image: InternalSpriteImageState, value: number) => void;
|
|
30
|
+
readonly applyFinalValue?: (image: InternalSpriteImageState, value: number) => void;
|
|
31
|
+
}
|
|
32
|
+
declare const DISTANCE_INTERPOLATION_CHANNELS: Record<'offsetMeters' | 'opacity', DistanceInterpolationChannelDescriptor>;
|
|
33
|
+
export type DistanceInterpolationChannelDescriptorMap = typeof DISTANCE_INTERPOLATION_CHANNELS;
|
|
34
|
+
export type DistanceInterpolationChannelName = keyof DistanceInterpolationChannelDescriptorMap;
|
|
35
|
+
export interface DistanceInterpolationWorkItem {
|
|
36
|
+
readonly descriptor: DistanceInterpolationChannelDescriptorMap[DistanceInterpolationChannelName];
|
|
37
|
+
readonly image: InternalSpriteImageState;
|
|
38
|
+
readonly state: DistanceInterpolationState;
|
|
39
|
+
}
|
|
40
|
+
export interface CollectDistanceInterpolationWorkItemOptions {
|
|
41
|
+
readonly includeOffsetMeters?: boolean;
|
|
42
|
+
readonly includeOpacity?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare const collectDistanceInterpolationWorkItems: (image: InternalSpriteImageState, workItems: DistanceInterpolationWorkItem[], options?: CollectDistanceInterpolationWorkItemOptions) => void;
|
|
45
|
+
export declare const applyDistanceInterpolationEvaluations: (workItems: readonly DistanceInterpolationWorkItem[], evaluations: readonly DistanceInterpolationEvaluationResult[], timestamp: number) => boolean;
|
|
46
|
+
export {};
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.15.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: d850b7e9c713f54f0630248dc4ea370721b6965b
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { EasingFunction } from '
|
|
11
|
+
import { EasingFunction, SpriteEasingPresetName, SpriteInterpolationEasing } from '../types';
|
|
12
12
|
/**
|
|
13
13
|
* Linear interpolation that clamps the value to the [0, 1] range.
|
|
14
14
|
*/
|
|
15
15
|
export declare const linearEasing: EasingFunction;
|
|
16
|
+
export interface ResolvedEasing {
|
|
17
|
+
readonly easing: EasingFunction;
|
|
18
|
+
readonly preset: SpriteEasingPresetName | null;
|
|
19
|
+
}
|
|
16
20
|
/**
|
|
17
21
|
* Returns the provided easing function or falls back to linear interpolation.
|
|
22
|
+
* When a preset name is supplied the resolved preset identifier is preserved for downstream consumers.
|
|
18
23
|
*/
|
|
19
|
-
export declare const resolveEasing: (easing?:
|
|
24
|
+
export declare const resolveEasing: (easing?: SpriteInterpolationEasing) => ResolvedEasing;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.15.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: d850b7e9c713f54f0630248dc4ea370721b6965b
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { SpriteInterpolationOptions, SpriteLocation } from '
|
|
12
|
-
import { SpriteInterpolationState } from '
|
|
11
|
+
import { SpriteInterpolationOptions, SpriteLocation } from '../types';
|
|
12
|
+
import { SpriteInterpolationState, SpriteInterpolationEvaluationParams, SpriteInterpolationEvaluationResult } from '../internalTypes';
|
|
13
13
|
/**
|
|
14
14
|
* Parameters required to create a fresh interpolation state for the next animation segment.
|
|
15
15
|
*
|
|
@@ -41,32 +41,10 @@ export interface CreateInterpolationStateResult {
|
|
|
41
41
|
* @returns The prepared state alongside a boolean indicating whether animation should run.
|
|
42
42
|
*/
|
|
43
43
|
export declare const createInterpolationState: (params: CreateInterpolationStateParams) => CreateInterpolationStateResult;
|
|
44
|
-
/**
|
|
45
|
-
* Parameters required to evaluate an interpolation tick at a given moment.
|
|
46
|
-
*
|
|
47
|
-
* @property state - Active interpolation state previously created.
|
|
48
|
-
* @property timestamp - Epoch millisecond at which interpolation should be evaluated.
|
|
49
|
-
*/
|
|
50
|
-
export interface EvaluateInterpolationParams {
|
|
51
|
-
state: SpriteInterpolationState;
|
|
52
|
-
timestamp: number;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Result of evaluating interpolation progress at a specific timestamp.
|
|
56
|
-
*
|
|
57
|
-
* @property location - Interpolated sprite location corresponding to the evaluated time.
|
|
58
|
-
* @property completed - Indicates whether the interpolation has reached or exceeded its duration.
|
|
59
|
-
* @property effectiveStartTimestamp - Timestamp detected or assigned as the interpolation starting point.
|
|
60
|
-
*/
|
|
61
|
-
export interface EvaluateInterpolationResult {
|
|
62
|
-
readonly location: SpriteLocation;
|
|
63
|
-
readonly completed: boolean;
|
|
64
|
-
readonly effectiveStartTimestamp: number;
|
|
65
|
-
}
|
|
66
44
|
/**
|
|
67
45
|
* Evaluates an interpolation state at a specific point in time and returns the intermediate location.
|
|
68
46
|
*
|
|
69
47
|
* @param params - The interpolation state and the reference timestamp for evaluation.
|
|
70
48
|
* @returns The lerped location, whether the interpolation has finished, and the effective start time.
|
|
71
49
|
*/
|
|
72
|
-
export declare const evaluateInterpolation: (params:
|
|
50
|
+
export declare const evaluateInterpolation: (params: SpriteInterpolationEvaluationParams) => SpriteInterpolationEvaluationResult;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.15.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: d850b7e9c713f54f0630248dc4ea370721b6965b
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { SpriteInterpolationOptions, SpriteImageOffset } from '
|
|
12
|
-
import { InternalSpriteImageState } from '
|
|
11
|
+
import { SpriteInterpolationOptions, SpriteImageOffset } from '../types';
|
|
12
|
+
import { InternalSpriteImageState } from '../internalTypes';
|
|
13
13
|
/**
|
|
14
14
|
* Ensures the rotation channel reflects the latest targets, optionally overriding interpolation.
|
|
15
15
|
*/
|
|
@@ -22,11 +22,21 @@ export declare const clearOffsetDegInterpolation: (image: InternalSpriteImageSta
|
|
|
22
22
|
* Clears any running offset distance interpolation in meters.
|
|
23
23
|
*/
|
|
24
24
|
export declare const clearOffsetMetersInterpolation: (image: InternalSpriteImageState) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Clears any running opacity interpolation.
|
|
27
|
+
*/
|
|
28
|
+
export declare const clearOpacityInterpolation: (image: InternalSpriteImageState) => void;
|
|
29
|
+
export declare const applyOpacityUpdate: (image: InternalSpriteImageState, nextOpacity: number, interpolationOptions?: SpriteInterpolationOptions | null) => void;
|
|
30
|
+
export type ImageInterpolationStepperId = 'rotation' | 'offsetDeg' | 'offsetMeters' | 'opacity';
|
|
25
31
|
/**
|
|
26
32
|
* Executes all interpolation steppers for an image and reports whether any remain active.
|
|
27
33
|
*/
|
|
28
|
-
export
|
|
29
|
-
|
|
34
|
+
export interface StepSpriteImageInterpolationOptions {
|
|
35
|
+
readonly skipChannels?: Partial<Record<ImageInterpolationStepperId, boolean>>;
|
|
36
|
+
}
|
|
37
|
+
export declare const stepSpriteImageInterpolations: (image: InternalSpriteImageState, timestamp: number, options?: StepSpriteImageInterpolationOptions) => boolean;
|
|
38
|
+
export declare const hasActiveImageInterpolations: (image: InternalSpriteImageState) => boolean;
|
|
39
|
+
export interface ApplyOffsetUpdateOptions {
|
|
30
40
|
readonly deg?: SpriteInterpolationOptions | null;
|
|
31
41
|
readonly meters?: SpriteInterpolationOptions | null;
|
|
32
42
|
}
|
|
@@ -34,4 +44,3 @@ interface ApplyOffsetUpdateOptions {
|
|
|
34
44
|
* Applies offset updates across both angular and radial channels.
|
|
35
45
|
*/
|
|
36
46
|
export declare const applyOffsetUpdate: (image: InternalSpriteImageState, nextOffset: SpriteImageOffset, options?: ApplyOffsetUpdateOptions) => void;
|
|
37
|
-
export {};
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.15.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: d850b7e9c713f54f0630248dc4ea370721b6965b
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { SpriteInterpolationOptions } from '
|
|
12
|
-
import { DegreeInterpolationState } from '
|
|
13
|
-
|
|
14
|
-
* Normalizes an absolute angle in degrees to the range [0, 360).
|
|
15
|
-
* @param {number} angle - Angle provided by the caller which may fall outside a single revolution.
|
|
16
|
-
* @returns {number} Angle wrapped to [0, 360) with negative zero converted to zero.
|
|
17
|
-
*/
|
|
18
|
-
export declare const normalizeAngleDeg: (angle: number) => number;
|
|
11
|
+
import { SpriteInterpolationOptions } from '../types';
|
|
12
|
+
import { DegreeInterpolationState } from '../internalTypes';
|
|
13
|
+
export { normalizeAngleDeg } from '../utils/math';
|
|
19
14
|
/**
|
|
20
15
|
* Parameters describing the rotation update request.
|
|
21
16
|
* @property {number} currentAngleDeg - Current angle already applied to the sprite in degrees.
|
package/dist/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.15.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: d850b7e9c713f54f0630248dc4ea370721b6965b
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { CustomLayerInterface } from 'maplibre-gl';
|
|
@@ -75,14 +75,16 @@ export interface SpriteImageOriginLocation {
|
|
|
75
75
|
export type SpriteInterpolationMode = 'feedback' | 'feedforward';
|
|
76
76
|
/** Easing function signature used to map interpolation progress. */
|
|
77
77
|
export type EasingFunction = (progress: number) => number;
|
|
78
|
+
export type SpriteEasingPresetName = 'linear';
|
|
79
|
+
export type SpriteInterpolationEasing = EasingFunction | SpriteEasingPresetName;
|
|
78
80
|
/** Options for interpolating values. */
|
|
79
81
|
export interface SpriteInterpolationOptions {
|
|
80
82
|
/** Interpolation mode; defaults to feedback. */
|
|
81
83
|
mode?: SpriteInterpolationMode;
|
|
82
84
|
/** Duration in milliseconds. */
|
|
83
85
|
durationMs: number;
|
|
84
|
-
/** Easing
|
|
85
|
-
easing?:
|
|
86
|
+
/** Easing mapping applied to progress values. Accepts preset names or custom functions. Defaults to linear. */
|
|
87
|
+
easing?: SpriteInterpolationEasing;
|
|
86
88
|
}
|
|
87
89
|
/** Interpolation configuration for rotateDeg and offsetDeg. */
|
|
88
90
|
export interface SpriteImageInterpolationOptions {
|
|
@@ -92,6 +94,8 @@ export interface SpriteImageInterpolationOptions {
|
|
|
92
94
|
offsetDeg?: SpriteInterpolationOptions | null;
|
|
93
95
|
/** Interpolation settings for offset.offsetMeters; null disables interpolation. */
|
|
94
96
|
offsetMeters?: SpriteInterpolationOptions | null;
|
|
97
|
+
/** Interpolation settings for opacity; null disables interpolation. */
|
|
98
|
+
opacity?: SpriteInterpolationOptions | null;
|
|
95
99
|
}
|
|
96
100
|
/**
|
|
97
101
|
* Initial attributes that define a sprite image.
|
|
@@ -180,6 +184,11 @@ export interface SpriteInit<TTag> {
|
|
|
180
184
|
isEnabled?: boolean;
|
|
181
185
|
/** Initial location. */
|
|
182
186
|
location: SpriteLocation;
|
|
187
|
+
/**
|
|
188
|
+
* Pseudo LOD threshold for the sprite. When the camera distance exceeds this value,
|
|
189
|
+
* all images attached to the sprite become invisible.
|
|
190
|
+
*/
|
|
191
|
+
visibilityDistanceMeters?: number;
|
|
183
192
|
/** Array of zero or more images. */
|
|
184
193
|
images: SpriteImageDefinitionInitEntry[];
|
|
185
194
|
/** Optional tag value; null or omission means no tag. */
|
|
@@ -200,6 +209,27 @@ export interface SpriteInitEntry<TTag> extends SpriteInit<TTag> {
|
|
|
200
209
|
* @template TTag Tag type.
|
|
201
210
|
*/
|
|
202
211
|
export type SpriteInitCollection<TTag> = Record<string, SpriteInit<TTag>> | readonly SpriteInitEntry<TTag>[];
|
|
212
|
+
/**
|
|
213
|
+
* Interpolated values.
|
|
214
|
+
* @param T - Value type.
|
|
215
|
+
*/
|
|
216
|
+
export interface InterpolatedValues<T> {
|
|
217
|
+
/** Current time value. */
|
|
218
|
+
readonly current: T;
|
|
219
|
+
/** Requested value. */
|
|
220
|
+
readonly from: T | undefined;
|
|
221
|
+
/** Will be reached value. */
|
|
222
|
+
readonly to: T | undefined;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Offset with interpolation metadata for both distance and heading.
|
|
226
|
+
*/
|
|
227
|
+
export interface SpriteImageInterpolatedOffset {
|
|
228
|
+
/** Distance from the anchor in meters. */
|
|
229
|
+
readonly offsetMeters: InterpolatedValues<number>;
|
|
230
|
+
/** Heading describing the offset direction in degrees. */
|
|
231
|
+
readonly offsetDeg: InterpolatedValues<number>;
|
|
232
|
+
}
|
|
203
233
|
/**
|
|
204
234
|
* Sprite image state evaluated at runtime.
|
|
205
235
|
*
|
|
@@ -207,11 +237,11 @@ export type SpriteInitCollection<TTag> = Record<string, SpriteInit<TTag>> | read
|
|
|
207
237
|
* @property {number} order - Ordering slot within the sub-layer.
|
|
208
238
|
* @property {string} imageId - Identifier of the registered image or glyph.
|
|
209
239
|
* @property {SpriteMode} mode - Rendering mode applied to the image.
|
|
210
|
-
* @property {number} opacity - Opacity multiplier applied when rendering.
|
|
240
|
+
* @property {InterpolatedValues<number>} opacity - Opacity multiplier applied when rendering, with interpolation metadata.
|
|
211
241
|
* @property {number} scale - Scale factor converting pixels to meters.
|
|
212
242
|
* @property {Readonly<SpriteAnchor>} anchor - Anchor coordinates resolved for the image.
|
|
213
|
-
* @property {Readonly<
|
|
214
|
-
* @property {number} rotateDeg - Additional rotation in degrees.
|
|
243
|
+
* @property {Readonly<SpriteImageInterpolatedOffset>} offset - Offset applied relative to the anchor point, with interpolation metadata.
|
|
244
|
+
* @property {InterpolatedValues<number>} rotateDeg - Additional rotation in degrees plus interpolation metadata.
|
|
215
245
|
* @property {boolean} autoRotation - Indicates whether auto-rotation is active.
|
|
216
246
|
* @property {number} autoRotationMinDistanceMeters - Minimum travel distance before auto-rotation updates.
|
|
217
247
|
* @property {number} resolvedBaseRotateDeg - Internal base rotation resolved for the current frame.
|
|
@@ -227,16 +257,19 @@ export interface SpriteImageState {
|
|
|
227
257
|
readonly imageId: string;
|
|
228
258
|
/** Rendering mode applied to the image. */
|
|
229
259
|
readonly mode: SpriteMode;
|
|
230
|
-
/** Opacity multiplier applied when rendering. */
|
|
231
|
-
readonly opacity: number;
|
|
232
260
|
/** Scale factor converting pixels to meters. */
|
|
233
261
|
readonly scale: number;
|
|
234
262
|
/** Anchor coordinates resolved for the image. */
|
|
235
263
|
readonly anchor: Readonly<SpriteAnchor>;
|
|
264
|
+
/** Opacity multiplier applied when rendering. */
|
|
265
|
+
readonly opacity: InterpolatedValues<number>;
|
|
236
266
|
/** Offset applied relative to the anchor point. */
|
|
237
|
-
readonly offset: Readonly<
|
|
238
|
-
/**
|
|
239
|
-
|
|
267
|
+
readonly offset: Readonly<SpriteImageInterpolatedOffset>;
|
|
268
|
+
/**
|
|
269
|
+
* Additional rotation in degrees with interpolation metadata.
|
|
270
|
+
* `from`/`to` are `undefined` when no rotation animation is running.
|
|
271
|
+
*/
|
|
272
|
+
readonly rotateDeg: InterpolatedValues<number>;
|
|
240
273
|
/** Indicates whether auto-rotation is active. */
|
|
241
274
|
readonly autoRotation: boolean;
|
|
242
275
|
/** Minimum travel distance before auto-rotation updates. */
|
|
@@ -258,20 +291,16 @@ export interface SpriteCurrentState<TTag> {
|
|
|
258
291
|
readonly spriteId: string;
|
|
259
292
|
/** Indicates whether the sprite is enabled. */
|
|
260
293
|
readonly isEnabled: boolean;
|
|
261
|
-
/** Current (possibly interpolated) location. */
|
|
262
|
-
readonly currentLocation: Readonly<SpriteLocation>;
|
|
263
294
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* Feed-forward mode: current commanded location.
|
|
295
|
+
* Pseudo LOD threshold for the sprite. When the camera distance exceeds this value,
|
|
296
|
+
* the sprite's images become invisible.
|
|
267
297
|
*/
|
|
268
|
-
readonly
|
|
298
|
+
readonly visibilityDistanceMeters: number | undefined;
|
|
269
299
|
/**
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* Feed-forward mode: predicted location.
|
|
300
|
+
* Location information including current, source, and destination coordinates.
|
|
301
|
+
* `from`/`to` are `undefined` when interpolation is inactive.
|
|
273
302
|
*/
|
|
274
|
-
readonly
|
|
303
|
+
readonly location: InterpolatedValues<Readonly<SpriteLocation>>;
|
|
275
304
|
/** Current image states, grouped by sub-layer and order. */
|
|
276
305
|
readonly images: ReadonlyMap<number, ReadonlyMap<number, SpriteImageState>>;
|
|
277
306
|
/** Optional tag value; null indicates no tag. */
|
|
@@ -295,6 +324,11 @@ export interface SpriteUpdateEntryBase<TTag> {
|
|
|
295
324
|
interpolation?: SpriteInterpolationOptions | null;
|
|
296
325
|
/** Optional tag value to replace the current one; `null` clears the tag. */
|
|
297
326
|
tag?: TTag | null;
|
|
327
|
+
/**
|
|
328
|
+
* Pseudo LOD threshold for the sprite. Specify a positive finite value to enable the check,
|
|
329
|
+
* `null` to clear the current threshold, or leave `undefined` to keep the existing value.
|
|
330
|
+
*/
|
|
331
|
+
visibilityDistanceMeters?: number | null;
|
|
298
332
|
}
|
|
299
333
|
/**
|
|
300
334
|
* Update entry describing a sprite image modification.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: maplibre-gl-layers
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.15.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: d850b7e9c713f54f0630248dc4ea370721b6965b
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { SpriteImageRegisterOptions } from '
|
|
11
|
+
import { SpriteImageRegisterOptions } from '../types';
|
|
12
12
|
export type SvgSizeResolutionErrorCode = 'size-missing' | 'viewbox-disabled' | 'invalid-dimensions';
|
|
13
13
|
export declare class SvgSizeResolutionError extends Error implements Error {
|
|
14
14
|
readonly code: SvgSizeResolutionErrorCode;
|