maplibre-gl-layers 0.13.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.
Files changed (40) hide show
  1. package/README.md +3 -3
  2. package/dist/SpriteLayer.d.ts +3 -27
  3. package/dist/config.d.ts +10 -2
  4. package/dist/const.d.ts +3 -3
  5. package/dist/default.d.ts +2 -2
  6. package/dist/gl/atlas.d.ts +64 -0
  7. package/dist/gl/hitTest.d.ts +54 -0
  8. package/dist/{shader.d.ts → gl/shader.d.ts} +22 -4
  9. package/dist/gl/text.d.ts +17 -0
  10. package/dist/{calculationHost.d.ts → host/calculationHost.d.ts} +26 -4
  11. package/dist/{mapLibreProjectionHost.d.ts → host/mapLibreProjectionHost.d.ts} +3 -3
  12. package/dist/{projectionHost.d.ts → host/projectionHost.d.ts} +5 -4
  13. package/dist/host/runtime.d.ts +38 -0
  14. package/dist/{wasmCalculationHost.d.ts → host/wasmCalculationHost.d.ts} +14 -14
  15. package/dist/{wasmHost.d.ts → host/wasmHost.d.ts} +14 -8
  16. package/dist/{wasmProjectionHost.d.ts → host/wasmProjectionHost.d.ts} +3 -3
  17. package/dist/index.cjs +7117 -4673
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +4 -3
  20. package/dist/index.mjs +7117 -4673
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/internalTypes.d.ts +109 -15
  23. package/dist/{degreeInterpolation.d.ts → interpolation/degreeInterpolation.d.ts} +19 -4
  24. package/dist/interpolation/distanceInterpolation.d.ts +46 -0
  25. package/dist/{easing.d.ts → interpolation/easing.d.ts} +9 -4
  26. package/dist/{interpolation.d.ts → interpolation/interpolation.d.ts} +5 -27
  27. package/dist/{interpolationChannels.d.ts → interpolation/interpolationChannels.d.ts} +16 -7
  28. package/dist/{rotationInterpolation.d.ts → interpolation/rotationInterpolation.d.ts} +5 -10
  29. package/dist/types.d.ts +75 -26
  30. package/dist/{image.d.ts → utils/image.d.ts} +3 -3
  31. package/dist/{looseQuadTree.d.ts → utils/looseQuadTree.d.ts} +2 -2
  32. package/dist/{math.d.ts → utils/math.d.ts} +15 -4
  33. package/dist/{utils.d.ts → utils/utils.d.ts} +3 -3
  34. package/dist/wasm/config.json.d.ts +16 -0
  35. package/dist/wasm/offloads-nosimd.wasm +0 -0
  36. package/dist/wasm/offloads-simd-mt.js +2 -0
  37. package/dist/wasm/offloads-simd-mt.wasm +0 -0
  38. package/dist/wasm/offloads-simd.wasm +0 -0
  39. package/package.json +7 -9
  40. package/dist/distanceInterpolation.d.ts +0 -33
package/README.md CHANGED
@@ -27,7 +27,7 @@ Here is a minimal example that places a single sprite:
27
27
  import { Map } from 'maplibre-gl';
28
28
  import {
29
29
  createSpriteLayer,
30
- initializeSpriteLayerHost,
30
+ initializeRuntimeHost,
31
31
  } from 'maplibre-gl-layers';
32
32
 
33
33
  // Create the MapLibre instance
@@ -43,8 +43,8 @@ const spriteLayer = createSpriteLayer({ id: 'vehicles' });
43
43
 
44
44
  // When MapLibre is ready
45
45
  map.on('load', async () => {
46
- // Optional: enable WASM acceleration (falls back to JS when unavailable)
47
- await initializeSpriteLayerHost();
46
+ // Initialize and add SpriteLayer to MapLibre
47
+ await initializeRuntimeHost();
48
48
  map.addLayer(spriteLayer);
49
49
 
50
50
  // Register an image that can be referenced by sprites
@@ -1,21 +1,15 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
- import { SpriteLayerInterface, SpriteLayerOptions, SpriteAnchor, SpriteLocation, SpriteImageDefinitionInit, SpriteImageOffset, SpriteInterpolationOptions, SpriteLayerCalculationVariant } from './types';
11
+ import { SpriteLayerInterface, SpriteLayerOptions, SpriteLocation, SpriteImageDefinitionInit } from './types';
12
12
  import { InternalSpriteImageState, InternalSpriteCurrentState, SpriteOriginReference } from './internalTypes';
13
- export interface SpriteLayerHostOptions {
14
- readonly variant?: SpriteLayerCalculationVariant;
15
- readonly wasmBaseUrl?: string;
16
- }
17
- export declare const initializeSpriteLayerHost: (variantOrOptions?: SpriteLayerCalculationVariant | SpriteLayerHostOptions) => Promise<SpriteLayerCalculationVariant>;
18
- export declare const releaseSpriteLayerHost: () => void;
19
13
  /**
20
14
  * Applies auto-rotation to all images within a sprite when movement exceeds the configured threshold.
21
15
  * @template T Arbitrary sprite tag type.
@@ -24,24 +18,6 @@ export declare const releaseSpriteLayerHost: () => void;
24
18
  * @returns {boolean} `true` when auto-rotation was applied, `false` otherwise.
25
19
  */
26
20
  export declare const applyAutoRotation: <T>(sprite: InternalSpriteCurrentState<T>, nextLocation: SpriteLocation) => boolean;
27
- /**
28
- * Clones a sprite anchor, defaulting to the origin when none supplied.
29
- * @param {SpriteAnchor} [anchor] - Anchor to clone.
30
- * @returns {SpriteAnchor} Safe copy for mutation within the layer state.
31
- */
32
- export declare const cloneAnchor: (anchor?: SpriteAnchor) => SpriteAnchor;
33
- /**
34
- * Clones an image offset, applying defaults when missing.
35
- * @param {SpriteImageOffset} [offset] - Offset definition to copy.
36
- * @returns {SpriteImageOffset} Cloned offset structure.
37
- */
38
- export declare const cloneOffset: (offset?: SpriteImageOffset) => SpriteImageOffset;
39
- /**
40
- * Deep-clones interpolation options to prevent shared references between sprites.
41
- * @param {SpriteInterpolationOptions} options - Options provided by the user.
42
- * @returns {SpriteInterpolationOptions} Cloned options object.
43
- */
44
- export declare const cloneInterpolationOptions: (options: SpriteInterpolationOptions) => SpriteInterpolationOptions;
45
21
  /**
46
22
  * Creates internal sprite image state from initialization data and layer bookkeeping fields.
47
23
  * @param {SpriteImageDefinitionInit} imageInit - Caller-provided image definition.
package/dist/config.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
11
  /** Debug flag */
@@ -16,3 +16,11 @@ export declare const USE_SHADER_BILLBOARD_GEOMETRY = true;
16
16
  export declare const USE_SHADER_SURFACE_GEOMETRY = true;
17
17
  /** Whether to enable the NDC bias for surface rendering (disabled by default). */
18
18
  export declare const ENABLE_NDC_BIAS_SURFACE = true;
19
+ /** Maximum number of atlas operations handled per processing pass. */
20
+ export declare const ATLAS_QUEUE_CHUNK_SIZE = 64;
21
+ /** Time budget (milliseconds) spent per atlas queue processing pass. */
22
+ export declare const ATLAS_QUEUE_TIME_BUDGET_MS = 20;
23
+ /** Maximum number of text glyph jobs handled per processing pass. */
24
+ export declare const TEXT_GLYPH_QUEUE_CHUNK_SIZE = 16;
25
+ /** Time budget (milliseconds) spent on text glyph generation per pass. */
26
+ export declare const TEXT_GLYPH_QUEUE_TIME_BUDGET_MS = 20;
package/dist/const.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
- import { Rect } from './looseQuadTree';
11
+ import { Rect } from './utils/looseQuadTree';
12
12
  import { SpriteAnchor, SpriteImageOffset, SpriteTextGlyphHorizontalAlign } from './types';
13
13
  /** Default sprite anchor centered at the image origin. */
14
14
  export declare const DEFAULT_ANCHOR: Readonly<SpriteAnchor>;
package/dist/default.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
11
  import { SpriteScalingOptions, SpriteTextureFilteringOptions } from './types';
@@ -0,0 +1,64 @@
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 { Deferred } from 'async-primitives';
12
+ import { Canvas2DSource } from '../internalTypes';
13
+ export interface AtlasManagerOptions {
14
+ readonly pageWidth?: number;
15
+ readonly pageHeight?: number;
16
+ readonly padding?: number;
17
+ }
18
+ export interface AtlasPlacement {
19
+ readonly pageIndex: number;
20
+ readonly width: number;
21
+ readonly height: number;
22
+ readonly x: number;
23
+ readonly y: number;
24
+ readonly u0: number;
25
+ readonly v0: number;
26
+ readonly u1: number;
27
+ readonly v1: number;
28
+ }
29
+ export interface AtlasPageState {
30
+ readonly index: number;
31
+ readonly width: number;
32
+ readonly height: number;
33
+ readonly canvas: Canvas2DSource;
34
+ needsUpload: boolean;
35
+ }
36
+ export interface AtlasManager {
37
+ readonly upsertImage: (id: string, bitmap: ImageBitmap) => AtlasPlacement;
38
+ readonly removeImage: (id: string) => boolean;
39
+ readonly getImagePlacement: (id: string) => AtlasPlacement | null;
40
+ readonly getPages: () => readonly AtlasPageState[];
41
+ readonly markPageClean: (pageIndex: number) => void;
42
+ readonly clear: () => void;
43
+ }
44
+ export interface AtlasQueueUpsertEntry {
45
+ readonly imageId: string;
46
+ readonly bitmap: ImageBitmap;
47
+ readonly deferred: Deferred<boolean>;
48
+ }
49
+ export interface AtlasQueueOptions {
50
+ readonly maxOperationsPerPass: number;
51
+ readonly timeBudgetMs: number;
52
+ }
53
+ export interface AtlasQueueCallbacks {
54
+ readonly onChunkProcessed: () => void;
55
+ }
56
+ export interface AtlasOperationQueue {
57
+ readonly enqueueUpsert: (entry: AtlasQueueUpsertEntry) => void;
58
+ readonly flushPending: () => void;
59
+ readonly cancelForImage: (imageId: string, reason?: Error) => void;
60
+ readonly rejectAll: (reason: Error) => void;
61
+ readonly pendingCount: number;
62
+ }
63
+ export declare const createAtlasManager: (options?: AtlasManagerOptions) => AtlasManager;
64
+ export declare const createAtlasOperationQueue: (atlasManager: AtlasManager, options: AtlasQueueOptions, callbacks: AtlasQueueCallbacks) => AtlasOperationQueue;
@@ -0,0 +1,54 @@
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 { Map as MapLibreMap } from 'maplibre-gl';
12
+ import { InternalSpriteCurrentState, InternalSpriteImageState, ProjectionHost, RegisteredImage } from '../internalTypes';
13
+ import { SpriteScreenPoint } from '../types';
14
+ import { ResolvedSpriteScalingOptions } from '../utils/math';
15
+ export interface HitTestEntry<T> {
16
+ readonly sprite: InternalSpriteCurrentState<T>;
17
+ readonly image: InternalSpriteImageState;
18
+ readonly corners: readonly [
19
+ SpriteScreenPoint,
20
+ SpriteScreenPoint,
21
+ SpriteScreenPoint,
22
+ SpriteScreenPoint
23
+ ];
24
+ readonly minX: number;
25
+ readonly maxX: number;
26
+ readonly minY: number;
27
+ readonly maxY: number;
28
+ }
29
+ export interface HitTestResult<T> {
30
+ readonly hitEntry: HitTestEntry<T> | null;
31
+ readonly screenPoint: SpriteScreenPoint;
32
+ }
33
+ export interface HitTestControllerParams {
34
+ readonly images: Map<string, RegisteredImage>;
35
+ readonly getResolvedScaling: () => ResolvedSpriteScalingOptions;
36
+ }
37
+ export interface HitTestController<T> {
38
+ readonly beginFrame: () => void;
39
+ readonly clearAll: () => void;
40
+ readonly getHitTestEntries: () => readonly HitTestEntry<T>[];
41
+ readonly registerHitTestEntry: (sprite: Readonly<InternalSpriteCurrentState<T>>, image: Readonly<InternalSpriteImageState>, corners: readonly [
42
+ SpriteScreenPoint,
43
+ SpriteScreenPoint,
44
+ SpriteScreenPoint,
45
+ SpriteScreenPoint
46
+ ], drawIndex: number) => void;
47
+ readonly removeImageBounds: (image: InternalSpriteImageState) => void;
48
+ readonly refreshSpriteHitTestBounds: (projectionHost: ProjectionHost, sprite: Readonly<InternalSpriteCurrentState<T>>) => void;
49
+ readonly findTopmostHitEntry: (point: SpriteScreenPoint, map: MapLibreMap | null) => HitTestEntry<T> | null;
50
+ readonly resolveHitTestResult: (nativeEvent: MouseEvent | PointerEvent | TouchEvent, canvasElement: HTMLCanvasElement | null, map: MapLibreMap | null) => HitTestResult<T> | null;
51
+ readonly setHitTestEnabled: (enabled: boolean) => boolean;
52
+ readonly isHitTestEnabled: () => boolean;
53
+ }
54
+ export declare const createHitTestController: <T>({ images, getResolvedScaling, }: HitTestControllerParams) => HitTestController<T>;
@@ -1,14 +1,15 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
- import { SpriteAnchor, SpriteScreenPoint } from './types';
11
+ import { SpriteAnchor, SpriteScreenPoint } from '../types';
12
+ import { PreparedDrawSpriteImageParams, Releasable } from '../internalTypes';
12
13
  /** Number of components per vertex (clipPosition.xyzw + uv.xy). */
13
14
  export declare const VERTEX_COMPONENT_COUNT = 6;
14
15
  /** Component count for clip-space position attributes. */
@@ -24,7 +25,7 @@ export declare const UV_OFFSET: number;
24
25
  /** Vertex count required to draw one sprite as two triangles. */
25
26
  export declare const QUAD_VERTEX_COUNT = 6;
26
27
  /** Shared vertex shader that converts screen-space vertices when requested. */
27
- export declare const VERTEX_SHADER_SOURCE: "\nattribute vec4 a_position;\nattribute vec2 a_uv;\nuniform vec2 u_screenToClipScale;\nuniform vec2 u_screenToClipOffset;\nuniform float u_billboardMode;\nuniform float u_surfaceMode;\nuniform vec2 u_billboardCenter;\nuniform vec2 u_billboardHalfSize;\nuniform vec2 u_billboardAnchor;\nuniform vec2 u_billboardSinCos;\nuniform float u_surfaceClipEnabled;\nuniform vec4 u_surfaceClipCenter;\nuniform vec4 u_surfaceClipBasisEast;\nuniform vec4 u_surfaceClipBasisNorth;\nuniform float u_surfaceDepthBias;\nvarying vec2 v_uv;\nvec2 computeBillboardCorner(vec2 uv) {\n vec2 base = vec2(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0);\n vec2 anchorShift = vec2(u_billboardAnchor.x * u_billboardHalfSize.x, u_billboardAnchor.y * u_billboardHalfSize.y);\n vec2 shifted = vec2(base.x * u_billboardHalfSize.x, base.y * u_billboardHalfSize.y) - anchorShift;\n float sinR = u_billboardSinCos.x;\n float cosR = u_billboardSinCos.y;\n vec2 rotated = vec2(\n shifted.x * cosR - shifted.y * sinR,\n shifted.x * sinR + shifted.y * cosR\n );\n return vec2(\n u_billboardCenter.x + rotated.x,\n u_billboardCenter.y - rotated.y\n );\n}\nvec4 computeSurfaceCorner(vec2 corner) {\n if (u_surfaceClipEnabled < 0.5) {\n return vec4(0.0, 0.0, 0.0, 1.0);\n }\n vec4 clip = u_surfaceClipCenter\n + (corner.x * u_surfaceClipBasisEast)\n + (corner.y * u_surfaceClipBasisNorth);\n clip.z += u_surfaceDepthBias * clip.w;\n return clip;\n}\nvoid main() {\n v_uv = a_uv;\n vec4 position;\n if (u_billboardMode > 0.5) {\n vec2 screenPosition = computeBillboardCorner(a_uv);\n position = vec4(screenPosition, 0.0, 1.0);\n } else if (u_surfaceMode > 0.5) {\n vec2 baseCorner = vec2(a_position.x, a_position.y);\n position = computeSurfaceCorner(baseCorner);\n } else {\n position = a_position;\n }\n position.xy = position.xy * u_screenToClipScale + u_screenToClipOffset;\n gl_Position = position;\n}\n";
28
+ export declare const VERTEX_SHADER_SOURCE: "\nattribute vec4 a_position;\nattribute vec2 a_uv;\nuniform vec2 u_screenToClipScale;\nuniform vec2 u_screenToClipOffset;\nuniform float u_billboardMode;\nuniform float u_surfaceMode;\nuniform vec2 u_billboardCenter;\nuniform vec2 u_billboardHalfSize;\nuniform vec2 u_billboardAnchor;\nuniform vec2 u_billboardSinCos;\nuniform float u_surfaceClipEnabled;\nuniform mat4 u_surfaceClipMatrix;\nuniform float u_surfaceDepthBias;\nvarying vec2 v_uv;\nvec2 computeBillboardCorner(vec2 baseCorner) {\n vec2 anchorShift = vec2(u_billboardAnchor.x * u_billboardHalfSize.x, u_billboardAnchor.y * u_billboardHalfSize.y);\n vec2 shifted = vec2(baseCorner.x * u_billboardHalfSize.x, baseCorner.y * u_billboardHalfSize.y) - anchorShift;\n float sinR = u_billboardSinCos.x;\n float cosR = u_billboardSinCos.y;\n vec2 rotated = vec2(\n shifted.x * cosR - shifted.y * sinR,\n shifted.x * sinR + shifted.y * cosR\n );\n return vec2(\n u_billboardCenter.x + rotated.x,\n u_billboardCenter.y - rotated.y\n );\n}\nvec4 computeSurfaceCorner(vec2 corner) {\n if (u_surfaceClipEnabled < 0.5) {\n return vec4(0.0, 0.0, 0.0, 1.0);\n }\n vec4 clip = u_surfaceClipMatrix * vec4(1.0, corner.x, corner.y, 0.0);\n clip.z += u_surfaceDepthBias * clip.w;\n return clip;\n}\nvoid main() {\n v_uv = a_uv;\n vec4 position;\n if (u_billboardMode > 0.5) {\n vec2 screenPosition = computeBillboardCorner(a_position.xy);\n position = vec4(screenPosition, 0.0, 1.0);\n } else if (u_surfaceMode > 0.5) {\n vec2 baseCorner = vec2(a_position.x, a_position.y);\n position = computeSurfaceCorner(baseCorner);\n } else {\n position = a_position;\n }\n position.xy = position.xy * u_screenToClipScale + u_screenToClipOffset;\n gl_Position = position;\n}\n";
28
29
  /** Fragment shader that applies texture sampling and opacity. */
29
30
  export declare const FRAGMENT_SHADER_SOURCE: "\nprecision mediump float;\nuniform sampler2D u_texture;\nuniform float u_opacity;\nvarying vec2 v_uv;\nvoid main() {\n vec4 texel = texture2D(u_texture, v_uv);\n gl_FragColor = vec4(texel.rgb, texel.a) * u_opacity;\n}\n";
30
31
  /** Initial vertex data for a unit quad. */
@@ -81,3 +82,20 @@ export declare const compileShader: (glContext: WebGLRenderingContext, type: num
81
82
  * @throws When linking fails or a program cannot be created.
82
83
  */
83
84
  export declare const createShaderProgram: (glContext: WebGLRenderingContext, vertexSource: string, fragmentSource: string) => WebGLProgram;
85
+ export interface SpriteDrawProgram<TTag> extends Releasable {
86
+ beginFrame(): void;
87
+ uploadVertexBatch(items: PreparedDrawSpriteImageParams<TTag>[]): void;
88
+ draw(prepared: PreparedDrawSpriteImageParams<TTag>): boolean;
89
+ }
90
+ export declare const createSpriteDrawProgram: <TTag>(glContext: WebGLRenderingContext) => SpriteDrawProgram<TTag>;
91
+ export interface DebugOutlineRenderer extends Releasable {
92
+ begin(screenToClipScaleX: number, screenToClipScaleY: number, screenToClipOffsetX: number, screenToClipOffsetY: number): void;
93
+ drawOutline(corners: readonly [
94
+ SpriteScreenPoint,
95
+ SpriteScreenPoint,
96
+ SpriteScreenPoint,
97
+ SpriteScreenPoint
98
+ ]): void;
99
+ end(): void;
100
+ }
101
+ export declare const createDebugOutlineRenderer: (glContext: WebGLRenderingContext) => DebugOutlineRenderer;
@@ -0,0 +1,17 @@
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 { SpriteTextGlyphDimensions, SpriteTextGlyphOptions } from '../types';
12
+ export interface TextGlyphRenderResult {
13
+ readonly bitmap: ImageBitmap;
14
+ readonly width: number;
15
+ readonly height: number;
16
+ }
17
+ export declare const renderTextGlyphBitmap: (text: string, dimensions: SpriteTextGlyphDimensions, options?: SpriteTextGlyphOptions) => Promise<TextGlyphRenderResult>;
@@ -1,16 +1,16 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
11
  import { Map as MapLibreMap } from 'maplibre-gl';
12
- import { InternalSpriteCurrentState, InternalSpriteImageState, RegisteredImage, ProjectionHost, PreparedDrawSpriteImageParams, RenderCalculationHost, PrepareDrawSpriteImageParamsBefore, PrepareDrawSpriteImageParamsAfter } from './internalTypes';
13
- import { SpritePoint } from './types';
12
+ import { DistanceInterpolationEvaluationParams, DistanceInterpolationEvaluationResult, DegreeInterpolationEvaluationParams, DegreeInterpolationEvaluationResult, InternalSpriteCurrentState, InternalSpriteImageState, RegisteredImage, ProjectionHost, PreparedDrawSpriteImageParams, RenderCalculationHost, PrepareDrawSpriteImageParamsBefore, PrepareDrawSpriteImageParamsAfter, RenderInterpolationParams, RenderInterpolationResult, SpriteInterpolationEvaluationParams, SpriteInterpolationEvaluationResult } from '../internalTypes';
13
+ import { SpritePoint } from '../types';
14
14
  import { ProjectionHostParams } from './projectionHost';
15
15
  /**
16
16
  * Cache entry storing anchor-adjusted and raw centers for a sprite image.
@@ -31,6 +31,7 @@ type ImageCenterCache = Map<string, Map<string, ImageCenterCacheEntry>>;
31
31
  * culled or stored in another bucket).
32
32
  */
33
33
  type OriginImageResolver<T> = (sprite: Readonly<InternalSpriteCurrentState<T>>, image: Readonly<InternalSpriteImageState>) => InternalSpriteImageState | null;
34
+ export declare const DEFAULT_RENDER_INTERPOLATION_RESULT: RenderInterpolationResult;
34
35
  interface DepthSortedItem<T> {
35
36
  readonly sprite: InternalSpriteCurrentState<T>;
36
37
  readonly image: InternalSpriteImageState;
@@ -43,6 +44,22 @@ export declare const collectDepthSortedItemsInternal: <T>(projectionHost: Projec
43
44
  * Prepares quad data for a single sprite image before issuing the draw call.
44
45
  */
45
46
  export declare const prepareDrawSpriteImageInternal: <TTag>(projectionHost: ProjectionHost, item: DepthSortedItem<TTag>, zoom: number, zoomScaleFactor: number, originCenterCache: ImageCenterCache, { imageResources, baseMetersPerPixel, spriteMinPixel, spriteMaxPixel, drawingBufferWidth, drawingBufferHeight, pixelRatio, clipContext, identityScaleX, identityScaleY, identityOffsetX, identityOffsetY, screenToClipScaleX, screenToClipScaleY, screenToClipOffsetX, screenToClipOffsetY, }: PrepareDrawSpriteImageParamsAfter) => PreparedDrawSpriteImageParams<TTag> | null;
47
+ export declare const applyVisibilityDistanceLod: <TTag>(preparedItems: readonly PreparedDrawSpriteImageParams<TTag>[]) => void;
48
+ export declare const syncPreparedOpacities: <TTag>(preparedItems: readonly PreparedDrawSpriteImageParams<TTag>[]) => void;
49
+ export declare const filterVisiblePreparedItems: <TTag>(preparedItems: readonly PreparedDrawSpriteImageParams<TTag>[]) => PreparedDrawSpriteImageParams<TTag>[];
50
+ export interface ProcessInterpolationPresetRequests {
51
+ readonly distance: readonly DistanceInterpolationEvaluationParams[];
52
+ readonly degree: readonly DegreeInterpolationEvaluationParams[];
53
+ readonly sprite: readonly SpriteInterpolationEvaluationParams[];
54
+ }
55
+ export interface ProcessInterpolationsEvaluationHandlers {
56
+ readonly prepare?: (requests: ProcessInterpolationPresetRequests) => void;
57
+ readonly evaluateDistance: (requests: readonly DistanceInterpolationEvaluationParams[]) => readonly DistanceInterpolationEvaluationResult[];
58
+ readonly evaluateDegree: (requests: readonly DegreeInterpolationEvaluationParams[]) => readonly DegreeInterpolationEvaluationResult[];
59
+ readonly evaluateSprite: (requests: readonly SpriteInterpolationEvaluationParams[]) => readonly SpriteInterpolationEvaluationResult[];
60
+ }
61
+ export declare const processInterpolationsInternal: <TTag>(params: RenderInterpolationParams<TTag>, handlers?: ProcessInterpolationsEvaluationHandlers) => RenderInterpolationResult;
62
+ export declare const processOpacityInterpolationsAfterPreparation: <TTag>(params: RenderInterpolationParams<TTag>, preparedItems: readonly PreparedDrawSpriteImageParams<TTag>[], handlers?: ProcessInterpolationsEvaluationHandlers) => RenderInterpolationResult;
46
63
  /**
47
64
  * Create calculation host that binding MapLibre.
48
65
  * @param TTag Tag type.
@@ -60,4 +77,9 @@ export declare const createCalculationHost: <TTag>(params: ProjectionHostParams)
60
77
  export declare const __wasmProjectionCalculationTestInternals: {
61
78
  __createWasmProjectionCalculationTestHost: <TTag>(params: ProjectionHostParams) => RenderCalculationHost<TTag>;
62
79
  };
80
+ export declare const __calculationHostTestInternals: {
81
+ applyVisibilityDistanceLod: <TTag>(preparedItems: readonly PreparedDrawSpriteImageParams<TTag>[]) => void;
82
+ syncPreparedOpacities: <TTag>(preparedItems: readonly PreparedDrawSpriteImageParams<TTag>[]) => void;
83
+ processOpacityInterpolationsAfterPreparation: <TTag>(params: RenderInterpolationParams<TTag>, preparedItems: readonly PreparedDrawSpriteImageParams<TTag>[], handlers?: ProcessInterpolationsEvaluationHandlers) => RenderInterpolationResult;
84
+ };
63
85
  export {};
@@ -1,15 +1,15 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
11
  import { Map as MapLibreMap } from 'maplibre-gl';
12
- import { ProjectionHost } from './internalTypes';
12
+ import { ProjectionHost } from '../internalTypes';
13
13
  /**
14
14
  * Create a projection host that delegates to MapLibre.
15
15
  * @param map MapLibre map instance
@@ -1,17 +1,17 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
11
  import { mat4 as Mat4 } from 'gl-matrix';
12
12
  import { Map as MapLibreMap } from 'maplibre-gl';
13
- import { SpriteLocation } from './types';
14
- import { ClipContext, ProjectionHost } from './internalTypes';
13
+ import { SpriteLocation } from '../types';
14
+ import { ClipContext, ProjectionHost } from '../internalTypes';
15
15
  /**
16
16
  * Required projection parameters. These correspond to the MapLibre transform state.
17
17
  */
@@ -43,6 +43,7 @@ export interface PreparedProjectionState {
43
43
  readonly pixelPerMeter: number;
44
44
  readonly cameraToCenterDistance: number;
45
45
  readonly clipContext: ClipContext | null;
46
+ readonly cameraLocation: SpriteLocation | null;
46
47
  }
47
48
  export declare const prepareProjectionState: (params: ProjectionHostParams) => PreparedProjectionState;
48
49
  /**
@@ -0,0 +1,38 @@
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 { SpriteLayerCalculationVariant, SpriteLayerHostOptions } from '../types';
12
+ export declare const isSpriteLayerHostEnabled: () => boolean;
13
+ export declare const reportWasmRuntimeFailure: (reason?: unknown) => void;
14
+ /**
15
+ * Initialize maplibre-gl-layers runtime host.
16
+ * @param variantOrOptions Options.
17
+ * @returns Initialized calculation variant.
18
+ */
19
+ export declare const initializeRuntimeHost: (options?: SpriteLayerHostOptions) => Promise<SpriteLayerCalculationVariant>;
20
+ /**
21
+ * Release maplibre-gl-layers runtime host.
22
+ * @returns
23
+ */
24
+ export declare const releaseRuntimeHost: () => void;
25
+ /**
26
+ * SIMD and multi-threading module availability.
27
+ */
28
+ export interface MultiThreadedModuleAvailability {
29
+ /** Is available? */
30
+ readonly available: boolean;
31
+ /** Not available, reason text */
32
+ readonly reason?: string;
33
+ }
34
+ /**
35
+ * Detects SIMD and multi-threading module availability.
36
+ * @returns MultiThreadedModuleAvailability.
37
+ */
38
+ export declare const detectMultiThreadedModuleAvailability: () => MultiThreadedModuleAvailability;
@@ -1,26 +1,24 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
- import { ClipContext, ImageHandleBufferController, IdHandler, InternalSpriteCurrentState, InternalSpriteImageState, PreparedDrawSpriteImageParams, PrepareDrawSpriteImageParams, Releaseable, RegisteredImage, RenderCalculationHost, SpriteOriginReference } from './internalTypes';
12
- import { SurfaceCorner } from './math';
13
- import { SpriteLocation, SpriteScreenPoint } from './types';
11
+ import { DistanceInterpolationEvaluationResult, DegreeInterpolationEvaluationResult, ImageHandleBufferController, IdHandler, InternalSpriteCurrentState, InternalSpriteImageState, PreparedDrawSpriteImageParams, PrepareDrawSpriteImageParams, Releasable, RegisteredImage, RenderCalculationHost, RenderInterpolationParams, RenderInterpolationResult, SpriteOriginReference, SpriteInterpolationEvaluationResult } from '../internalTypes';
12
+ import { SurfaceCorner } from '../utils/math';
13
+ import { SpriteLocation } from '../types';
14
14
  import { BufferHolder, WasmHost } from './wasmHost';
15
+ import { ProcessInterpolationPresetRequests } from './calculationHost';
15
16
  import { PreparedProjectionState, ProjectionHostParams } from './projectionHost';
16
- export declare const createWasmProjectLngLatToClipSpace: () => {
17
- (clipContext: Readonly<ClipContext> | null, location: Readonly<SpriteLocation>): number[] | null;
18
- release(): void;
19
- };
20
- export declare const createWasmCalculateBillboardDepthKey: (preparedState: PreparedProjectionState) => {
21
- (_center: Readonly<SpriteScreenPoint>): number | null;
22
- release(): void;
23
- };
17
+ interface WasmProcessInterpolationResults {
18
+ readonly distance: DistanceInterpolationEvaluationResult[];
19
+ readonly degree: DegreeInterpolationEvaluationResult[];
20
+ readonly sprite: SpriteInterpolationEvaluationResult[];
21
+ }
24
22
  type CalculateSurfaceDepthKeyOptions = {
25
23
  readonly indices?: readonly number[];
26
24
  readonly bias?: {
@@ -32,7 +30,7 @@ export declare const createWasmCalculateSurfaceDepthKey: (preparedState: Prepare
32
30
  (baseLngLat: Readonly<SpriteLocation>, displacements: readonly SurfaceCorner[], options?: CalculateSurfaceDepthKeyOptions): number | null;
33
31
  release(): void;
34
32
  };
35
- interface PreparedInputBuffer extends Releaseable {
33
+ interface PreparedInputBuffer extends Releasable {
36
34
  readonly parameterHolder: BufferHolder<Float64Array>;
37
35
  readonly resultItemCount: number;
38
36
  }
@@ -64,5 +62,7 @@ export declare const __wasmCalculationTestInternals: {
64
62
  convertToWasmProjectionState: <TTag>(wasm: WasmHost, params: ProjectionHostParams, deps: WasmCalculationInteropDependencies<TTag>) => WritableWasmProjectionState<TTag>;
65
63
  converToPreparedDrawImageParams: <TTag>(state: WritableWasmProjectionState<TTag>, deps: WasmCalculationInteropDependencies<TTag>, resultBuffer: BufferHolder<Float64Array>) => PreparedDrawSpriteImageParams<TTag>[];
66
64
  prepareDrawSpriteImagesInternal: <TTag>(wasm: WasmHost, wasmState: WritableWasmProjectionState<TTag>, deps: WasmCalculationInteropDependencies<TTag>, params: PrepareDrawSpriteImageParams<TTag>) => PreparedDrawSpriteImageParams<TTag>[];
65
+ processInterpolationsViaWasm: (wasm: WasmHost, requests: ProcessInterpolationPresetRequests) => WasmProcessInterpolationResults;
66
+ processInterpolationsWithWasm: <TTag>(wasm: WasmHost, params: RenderInterpolationParams<TTag>) => RenderInterpolationResult;
67
67
  };
68
68
  export {};
@@ -1,14 +1,14 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
- import { SpriteLayerCalculationVariant } from './types';
11
+ import { SpriteLayerCalculationVariant } from '../types';
12
12
  /**
13
13
  * `fromLngLat` function parameter
14
14
  */
@@ -29,6 +29,7 @@ export type WasmProjectLngLatToClipSpace = (lng: number, lat: number, altitude:
29
29
  export type WasmCalculateBillboardDepthKey = (centerX: number, centerY: number, worldSize: number, inverseMatrixPtr: number, mercatorMatrixPtr: number, outPtr: number) => boolean;
30
30
  export type WasmCalculateSurfaceDepthKey = (baseLng: number, baseLat: number, baseAltitude: number, displacementPtr: number, displacementCount: number, indexPtr: number, indexCount: number, mercatorMatrixPtr: number, applyBias: number, biasNdc: number, minClipZEpsilon: number, outPtr: number) => boolean;
31
31
  export type WasmPrepareDrawSpriteImages = (paramsPtr: number, resultPtr: number) => boolean;
32
+ export type WasmProcessInterpolations = (paramsPtr: number, resultPtr: number) => boolean;
32
33
  /**
33
34
  * Wasm raw pointer type.
34
35
  */
@@ -65,6 +66,10 @@ export type TypedArrayConstructor<TArray extends TypedArrayBufferView<TArray>> =
65
66
  * @param TArray - A type for ArrayBufferView (ex: Float64Array)
66
67
  */
67
68
  export interface BufferHolder<TArray extends TypedArrayBufferView<TArray>> {
69
+ /**
70
+ * Element count (Float64Array: mod 8)
71
+ */
72
+ readonly length: number;
68
73
  /**
69
74
  * Prepare and get the raw pointer and the buffer reference.
70
75
  * @returns The raw pointer and the buffer reference.
@@ -92,12 +97,13 @@ export interface WasmHost {
92
97
  readonly allocateTypedBuffer: <TArray extends TypedArrayBufferView<TArray>>(ArrayType: TypedArrayConstructor<TArray>, elements: number | ArrayLike<TypedArrayElement<TArray>>) => BufferHolder<TArray>;
93
98
  readonly fromLngLat: WasmFromLngLat;
94
99
  readonly project: WasmProject;
95
- readonly calculatePerspectiveRatio: WasmCalculatePerspectiveRatio;
96
100
  readonly unproject: WasmUnproject;
101
+ readonly calculatePerspectiveRatio: WasmCalculatePerspectiveRatio;
97
102
  readonly projectLngLatToClipSpace: WasmProjectLngLatToClipSpace;
98
103
  readonly calculateBillboardDepthKey: WasmCalculateBillboardDepthKey;
99
104
  readonly calculateSurfaceDepthKey: WasmCalculateSurfaceDepthKey;
100
- readonly prepareDrawSpriteImages?: WasmPrepareDrawSpriteImages;
105
+ readonly prepareDrawSpriteImages: WasmPrepareDrawSpriteImages;
106
+ readonly processInterpolations: WasmProcessInterpolations;
101
107
  }
102
108
  export type WasmVariant = SpriteLayerCalculationVariant;
103
109
  /**
@@ -105,9 +111,9 @@ export type WasmVariant = SpriteLayerCalculationVariant;
105
111
  */
106
112
  export interface InitializeWasmHostOptions {
107
113
  /** Force initialization. Default is false. */
108
- readonly force?: boolean;
114
+ readonly force: boolean;
109
115
  /** Override the URL used to fetch wasm artifacts. */
110
- readonly wasmBaseUrl?: string;
116
+ readonly wasmBaseUrl: string | undefined;
111
117
  }
112
118
  /**
113
119
  * Initialize wasm offload module.
@@ -115,7 +121,7 @@ export interface InitializeWasmHostOptions {
115
121
  * @param options Options.
116
122
  * @returns Initialized WasmHost.
117
123
  */
118
- export declare const initializeWasmHost: (preferredVariant: WasmVariant, options?: InitializeWasmHostOptions) => Promise<WasmVariant>;
124
+ export declare const initializeWasmHost: (preferredVariant?: WasmVariant, options?: InitializeWasmHostOptions) => Promise<WasmVariant>;
119
125
  /**
120
126
  * Release wasm offload module.
121
127
  */
@@ -1,15 +1,15 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.13.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: 4934aa7f4fed93594ece419184b32b5b972bbb88
8
+ * git.commit.hash: d850b7e9c713f54f0630248dc4ea370721b6965b
9
9
  */
10
10
 
11
11
  import { ProjectionHostParams } from './projectionHost';
12
- import { ProjectionHost } from './internalTypes';
12
+ import { ProjectionHost } from '../internalTypes';
13
13
  /**
14
14
  * Create wasm-based calculation projection host.
15
15
  * @param params Projection parameters