@mappedin/mappedin-js 6.30.0 → 6.31.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.
@@ -4,7 +4,7 @@ import { MVFv2_STANDARD_MVFv3 as MVFv2_STANDARD_MVFv3$1, ParsedMVF as ParsedMVF$
4
4
  import * as _mappedin_renderer_three0 from "@mappedin/renderer-three";
5
5
  import { AddLabelOptionsInternal, AddText3DOptions, AddText3DOptions as AddText3DOptions$1, AddText3DPointOptions, AddText3DPointOptions as AddText3DPointOptions$1, CameraSystemState, ColorString, DebugState, DebugState as DebugState$1, EntityId, EnvMapOptions, EnvMapOptions as EnvMapOptions$1, GLTFExportOptions as GLTFExportOptions$1, GroupContainerState, ISystemPlugin, ISystemPlugin as ISystemPlugin$1, ImagePlacementOptions, InitializeModelState, InitializeModelState as InitializeModelState$1, InitializeText3DState, InsetPadding, InsetPadding as InsetPadding$1, InsetPaddingOption, InsetPaddingOption as InsetPaddingOption$1, InterpolateOn, Interpolation, LabelRenderedState, LineStyle, LineStyle as LineStyle$1, MapViewState, MarkerState, OutlinesOptions, PaintStyle, PaintStyle as PaintStyle$1, PathState, PathWidth, PathWidth as PathWidth$1, PixelWidth, Position as Position$1, RendererCore, RendererCoreOptions, RendererCoreOptions as RendererCoreOptions$1, Shading, ShadowsOptions, Text3DState, WatermarkUpdateOptions } from "@mappedin/renderer-three";
6
6
  import * as three0 from "three";
7
- import { AmbientLight, BatchedMesh, BatchedMeshGeometryRange, Box3, BufferAttribute, BufferGeometry, Camera as Camera$1, Color, DirectionalLight, Group, Intersection, LineSegments, Matrix4, Mesh, MeshLambertMaterial, MeshLambertMaterialParameters, Object3D, Object3DEventMap, PerspectiveCamera, Plane, PlaneGeometry, Raycaster, Scene, ShaderMaterial, Texture, TubeGeometry, Vector2, Vector3, WebGLRenderer } from "three";
7
+ import { AmbientLight, BatchedMesh, BatchedMeshGeometryRange, Box3, BufferAttribute, BufferGeometry, Camera as Camera$1, Color, DataTexture, DirectionalLight, Group, Intersection, LineSegments, Matrix4, Mesh, MeshLambertMaterial, MeshLambertMaterialParameters, Object3D, Object3DEventMap, PerspectiveCamera, Plane, PlaneGeometry, Raycaster, Scene, ShaderMaterial, Texture, TubeGeometry, Vector2, Vector3, WebGLRenderer } from "three";
8
8
  import * as _tweenjs_tween_js0 from "@tweenjs/tween.js";
9
9
  import { Group as Group$1, Tween } from "@tweenjs/tween.js";
10
10
  import { CustomLayerInterface, IControl, Map as Map$1, MapEventType } from "@mappedin/outdoor-context";
@@ -660,11 +660,8 @@ declare class QuadTree<T$1 = unknown> {
660
660
  //#endregion
661
661
  //#region ../2d-labels-markers/lib/esm/systems/collision/types.d.ts
662
662
  type WatermarkPosition$1 = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center' | 'top' | 'bottom' | 'left' | 'right';
663
- type TSerializedColliderResponse = [number, 1 | 0, Rectangle?];
664
663
  type PackedBBox = [x: number, y: number, w: number, h: number, index: number];
665
664
  type PackedBBoxes = PackedBBox[];
666
- type PackedCollider = [bboxes: PackedBBoxes, enabled: 0 | 1, alwaysVisible: 0 | 1, x: number, y: number, shouldCollideWithScreenEdges?: 0 | 1, onlyExposeStrategyIndex?: number];
667
- type PackedMessage = [colliders: PackedCollider[], devicePixelRatio: number, totalHeight: number, totalWidth: number, watermarkWidth: number, watermarkHeight: number, watermarkPosition: WatermarkPosition$1];
668
665
  type PackedJsonMessage = {
669
666
  x: number;
670
667
  y: number;
@@ -3159,6 +3156,47 @@ declare class LabelComponent {
3159
3156
  style: TStyle;
3160
3157
  projection: Vec2;
3161
3158
  labelCacheId?: string;
3159
+ /**
3160
+ * Inputs {@link labelCacheId} was last built from; lets the draw system reuse the id string
3161
+ * instead of rebuilding it every frame.
3162
+ * @internal
3163
+ */
3164
+ labelCacheKeyInputs: {
3165
+ pinColor?: string;
3166
+ pinColorInactive?: string;
3167
+ pinOutlineColor?: string;
3168
+ pinOutlineColorInactive?: string;
3169
+ pinSize?: number;
3170
+ iconVisible?: boolean;
3171
+ iconBorderRadiusFactor?: number;
3172
+ };
3173
+ /**
3174
+ * Last zoom-interpolated icon scale and its inputs, so an unchanged zoom does not re-interpolate.
3175
+ * @internal
3176
+ */
3177
+ iconScaleCache: {
3178
+ zoom: number;
3179
+ input: unknown;
3180
+ output: unknown;
3181
+ easing: unknown;
3182
+ value: number;
3183
+ };
3184
+ /**
3185
+ * Inputs of the composited pin + icon sprite last resolved by the draw system, and that sprite
3186
+ * (`TwoDDrawSystem.getPinIconSprite`).
3187
+ * @internal
3188
+ */
3189
+ pinIconKeyInputs: {
3190
+ pin?: unknown;
3191
+ img?: unknown;
3192
+ iconFit?: string;
3193
+ iconOverflow?: string;
3194
+ iconPadding?: number;
3195
+ iconBorderRadiusFactor?: number;
3196
+ totalPinSize?: number;
3197
+ generation?: number;
3198
+ sprite: OffscreenCanvas | HTMLCanvasElement | null;
3199
+ };
3162
3200
  _cache: {};
3163
3201
  appearance: LabelAppearanceWithDefaults;
3164
3202
  options: AddLabelOptionsInternal$1;
@@ -3204,6 +3242,12 @@ declare class LabelComponent {
3204
3242
  pinSize: number;
3205
3243
  iconVisible: boolean;
3206
3244
  static testId: number;
3245
+ /** Renderer pixel ratio that {@link pinSize} is measured in. Kept current by {@link setPixelRatio}. */
3246
+ private pixelRatio;
3247
+ /**
3248
+ * Converts CSS px to device px at the label's current pixel ratio.
3249
+ * @param v - CSS px (default 1, which returns the ratio itself)
3250
+ */
3207
3251
  dp: (v?: number) => number;
3208
3252
  /**
3209
3253
  * @param text - Label text
@@ -3211,6 +3255,13 @@ declare class LabelComponent {
3211
3255
  * @param pixelRatio - Device pixel ratio from the host renderer
3212
3256
  */
3213
3257
  constructor(text: string, options: AddLabelOptionsInternal$1, pixelRatio: number);
3258
+ /**
3259
+ * Updates the pixel ratio the label measures its pin in, and marks the pin, text and collision box for
3260
+ * recalculation. The renderer's ratio can change after the label is created without
3261
+ * `devicePixelRatio` changing (MapLibre clamps the drawing buffer by window width).
3262
+ * @param pixelRatio - The renderer's new pixel ratio
3263
+ */
3264
+ setPixelRatio(pixelRatio: number): void;
3214
3265
  calculatePinSize(): void;
3215
3266
  /**
3216
3267
  * Get the bounding box when the label has no text.
@@ -3230,7 +3281,18 @@ declare class LabelComponent {
3230
3281
  animate: boolean;
3231
3282
  recomputeCurrentStrategy(scale?: number): void;
3232
3283
  onStrategySelected: (strategyIndex: number) => void;
3284
+ /**
3285
+ * Largest bbox extent (CSS px) from the anchor over every strategy, as of the last
3286
+ * {@link toPackedMessage} repack; `-1` until packed. Lets the collision system skip
3287
+ * components that are far outside the viewport .
3288
+ * @internal
3289
+ */
3290
+ collisionExtent: number;
3233
3291
  private packedMessage;
3292
+ private _validMemoIndex;
3293
+ private _validMemoText;
3294
+ private _validMemoStrategies;
3295
+ private _validMemoValue;
3234
3296
  toPackedMessage(isPanning?: boolean): PackedJsonMessage;
3235
3297
  destroy(): void;
3236
3298
  }
@@ -3405,6 +3467,13 @@ declare class MarkerComponent {
3405
3467
  invalidateStrategies(): void;
3406
3468
  private getBoundingBoxForPlacement;
3407
3469
  get strategies(): MarkerStrategy[];
3470
+ /**
3471
+ * Largest bbox extent (CSS px) from the anchor over every strategy, as of the last
3472
+ * {@link toPackedMessage} repack; `-1` until packed. Lets the collision system skip
3473
+ * components that are far outside the viewport .
3474
+ * @internal
3475
+ */
3476
+ collisionExtent: number;
3408
3477
  private packedMessage;
3409
3478
  toPackedMessage(isPanning?: boolean): PackedJsonMessage;
3410
3479
  private _cachedLowPriorityPinIndex;
@@ -3477,14 +3546,17 @@ interface TwoDPipelineState {
3477
3546
  pixelRatio: number;
3478
3547
  }
3479
3548
  /**
3480
- * Function type for projecting world coordinates to screen pixels.
3481
- * The host renderer provides this to the pipeline during construction.
3482
- * @param worldX - X coordinate in world space
3483
- * @param worldY - Y coordinate in world space
3484
- * @param worldZ - Z coordinate in world space
3485
- * @returns Screen-space position or null if off-screen
3549
+ * Projects world positions to screen pixels. The host renderer provides this to the pipeline,
3550
+ * which calls it once per frame for every entity.
3551
+ *
3552
+ * @param positions - World coordinates, `[x0, y0, z0, x1, y1, z1, …]`
3553
+ * @param out - Optional reusable destination; the host may return a larger replacement
3554
+ * @param count - Number of points
3555
+ * @returns `PROJECT_BATCH_STRIDE` slots per point: `[screenX, screenY, flags]` (see
3556
+ * {@link ProjectBatchFlags}). An exact `(0, 0)` means "no projection": the entity keeps its
3557
+ * previous position.
3486
3558
  */
3487
- type ProjectFn = (worldX: number, worldY: number, worldZ: number) => Vec2 | null;
3559
+ type ProjectBatchFn = (positions: Float64Array, out: Float64Array | undefined, count: number) => Float64Array;
3488
3560
  /**
3489
3561
  * Aggregate counts and byte size for a single 2D draw cache.
3490
3562
  * @internal - For diagnostic tooling only.
@@ -3506,6 +3578,8 @@ interface TwoDDrawSystemCacheStats {
3506
3578
  pinCache: TwoDCacheStats;
3507
3579
  wrapperCache: TwoDCacheStats;
3508
3580
  imageCache: TwoDCacheStats;
3581
+ /** Pre-composited active pin + clipped icon sprites (one canvas per entry). */
3582
+ pinIconCache: TwoDCacheStats;
3509
3583
  /** Bytes of the full-screen label canvas (held as the draw system's collider canvas). */
3510
3584
  labelCanvasBytes: number;
3511
3585
  /** Sum of all per-cache bytes plus the label canvas bytes. */
@@ -3632,25 +3706,68 @@ declare class PubSub<EVENT_PAYLOAD, EVENT extends keyof EVENT_PAYLOAD = keyof EV
3632
3706
  destroy(): void;
3633
3707
  }
3634
3708
  //#endregion
3709
+ //#region ../2d-labels-markers/lib/esm/systems/collision/packing.d.ts
3710
+ /** Message posted back from the collision worker. */
3711
+ type FlatCollisionResponse = {
3712
+ id: number;
3713
+ /** The request buffer, returned for reuse. */
3714
+ input: Float64Array;
3715
+ /** Result buffer (see layout above). */
3716
+ output: Float64Array;
3717
+ colliderCount: number;
3718
+ };
3719
+ //#endregion
3635
3720
  //#region ../2d-labels-markers/lib/esm/systems/collision/system.d.ts
3636
3721
  type TCollisionSystemEvent = {
3637
3722
  'visibility-changed': undefined;
3638
3723
  };
3724
+ type Component = MarkerComponent | LabelComponent;
3639
3725
  /**
3640
3726
  * Collision system for 2D labels and markers.
3641
3727
  * Manages collision detection using a quad-tree and web worker (or sync fallback).
3728
+ *
3729
+ * Each run is written into one `Float64Array` (see `packing.ts`) that is **transferred** to the
3730
+ * worker (zero-copy) and comes back for reuse, and results come back as a second `Float64Array`;
3731
+ * no nested arrays or `Rectangle` objects are structured-cloned across threads.
3642
3732
  */
3643
3733
  declare class CollisionSystem extends PubSub<TCollisionSystemEvent, keyof TCollisionSystemEvent> {
3644
- #private;
3645
3734
  private worker;
3646
3735
  collidersDirty: boolean;
3647
- packedMessage: PackedMessage;
3736
+ /** Reused request writer; its buffer is transferred to the worker and handed back with the result. */
3737
+ private _writer;
3738
+ /** Spare result buffer offered to the worker so it can write results without allocating. */
3739
+ private _spareOutput;
3740
+ /** True while the request buffer is owned by the worker (transferred). */
3741
+ private _bufferInFlight;
3742
+ private _requestId;
3743
+ /** Components the in-flight request was packed from, in packing order. */
3744
+ private _inFlight;
3745
+ /** Two reusable arrays for {@link _inFlight}, so the order is kept even if `componentArray` re-sorts. */
3746
+ private _snapshotA;
3747
+ private _snapshotB;
3748
+ /** Copy of the in-flight request . */
3749
+ private _sentInput;
3750
+ private _sentLength;
3751
+ /** Copy of the last request whose results were applied, its results and component order. */
3752
+ private _appliedInput;
3753
+ private _appliedLength;
3754
+ private _appliedResults;
3755
+ private _appliedCount;
3756
+ private _appliedComponents;
3757
+ /** Reused list of the components packed into the current request . */
3758
+ private _sendList;
3648
3759
  visibleCollidersQTree: QuadTree<{
3649
3760
  entityId: string | number;
3650
3761
  }>;
3651
3762
  interactiveCollidersQTree: QuadTree<{
3652
3763
  entityId: string | number;
3653
3764
  }>;
3765
+ private _state;
3766
+ private _canvasWidth;
3767
+ private _canvasHeight;
3768
+ private _debug;
3769
+ private _debugCanvas;
3770
+ private _debugCtx;
3654
3771
  /**
3655
3772
  * @param state - Pipeline state
3656
3773
  * @param canvasWidth - Width of the collision canvas
@@ -3661,7 +3778,7 @@ declare class CollisionSystem extends PubSub<TCollisionSystemEvent, keyof TColli
3661
3778
  */
3662
3779
  constructor(state: TwoDPipelineState, canvasWidth: number, canvasHeight: number, workerUrl?: string, useWorker?: boolean, container?: HTMLElement);
3663
3780
  working: boolean;
3664
- componentArray: (MarkerComponent | LabelComponent)[];
3781
+ componentArray: Component[];
3665
3782
  /**
3666
3783
  * Resizes the collision area dimensions.
3667
3784
  * @param width - New width
@@ -3669,22 +3786,40 @@ declare class CollisionSystem extends PubSub<TCollisionSystemEvent, keyof TColli
3669
3786
  */
3670
3787
  resizeCanvas(width: number, height: number): void;
3671
3788
  /**
3672
- * Runs the collision update, packing components and posting to worker.
3789
+ * Packs all active entities into a flat request and posts it to the worker. While a request is in
3790
+ * flight the call only refreshes the sorted component list; the next call after the result
3791
+ * arrives picks up the latest state.
3792
+ *
3793
+ * @param watermarkWidth - Watermark width to avoid
3794
+ * @param watermarkHeight - Watermark height to avoid
3795
+ * @param watermarkPosition - Watermark anchor
3796
+ * @param lockStrategies - Keep current strategies (camera moving)
3797
+ * @param staticColliders - Extra screen rectangles to avoid (e.g. images)
3673
3798
  */
3674
3799
  update: (watermarkWidth: number, watermarkHeight: number, watermarkPosition?: WatermarkPosition$1, lockStrategies?: boolean, staticColliders?: Rectangle[]) => void;
3675
- resize(watermarkWidth: number, watermarkHeight: number, watermarkPosition: WatermarkPosition$1): void;
3676
3800
  /**
3677
- * Resolves collision results from the worker and updates component visibility state.
3801
+ * Applies collision results from the worker to components and publishes `visibility-changed`.
3802
+ */
3803
+ resolve: (e: {
3804
+ data: FlatCollisionResponse;
3805
+ }) => void;
3806
+ /**
3807
+ * When `input` is identical to the last applied request (same components, same order), the
3808
+ * collision result would be identical too: re-apply the cached result locally.
3809
+ * Publishes `visibility-changed` only when applying left a component with pending work.
3810
+ * @returns `true` when the request was satisfied from cache.
3811
+ */
3812
+ private _tryReuseLastResult;
3813
+ /**
3814
+ * Applies a flat result buffer to components and rebuilds the collider quad trees.
3815
+ * @returns Whether any component changed or has a pending visibility update afterwards.
3678
3816
  */
3679
- resolve: (e: MessageEvent<{
3680
- msgId: string;
3681
- colliders: TSerializedColliderResponse[];
3682
- staticColliders: Rectangle[];
3683
- }>) => void;
3817
+ private _applyResults;
3684
3818
  /** Enables the debug overlay that draws visible collision boxes. */
3685
3819
  showCollisionBoxes(): void;
3686
3820
  /** Disables the debug overlay and clears the canvas. */
3687
3821
  hideCollisionBoxes(): void;
3822
+ private _drawDebug;
3688
3823
  destroy: () => void;
3689
3824
  }
3690
3825
  //#endregion
@@ -3712,6 +3847,12 @@ interface LabelTextCache {
3712
3847
  /** Block height device px. */
3713
3848
  height: number;
3714
3849
  }
3850
+ /**
3851
+ * Max pre-composited pin + icon sprites kept by {@link TwoDDrawSystem.pinIconCache}. A sprite is the pin
3852
+ * canvas size (roughly 100-140 px square at DPR 2, ~40-80 KB), so this bounds the cache to a few MB while
3853
+ * still covering every distinct icon on screen at once.
3854
+ */
3855
+
3715
3856
  /**
3716
3857
  * 2D canvas draw system for labels.
3717
3858
  * Renders label pins, icons, and text to a canvas overlay.
@@ -3763,10 +3904,34 @@ declare class TwoDDrawSystem extends PubSub<{
3763
3904
  /** Lazily-mounted DOM overlay that renders per-frame stats. */
3764
3905
  private statsElement?;
3765
3906
  /**
3766
- * Runs the draw pass for all label entities.
3907
+ * Pre-composited active pin + clipped icon sprites, keyed by pin cache id + icon inputs.
3908
+ * Least-recently-used, capped at {@link PIN_ICON_CACHE_MAX_ENTRIES} (Map iteration order = recency);
3909
+ * cleared on a full redraw (`dirty`). Only used for icons with `iconOverflow` other than `'visible'`,
3910
+ * where one sprite exists per distinct icon + pin style, so a large directory of logos would otherwise
3911
+ * keep one canvas per logo for the whole session.
3912
+ */
3913
+ pinIconCache: Map<string, HTMLCanvasElement | OffscreenCanvas>;
3914
+ /**
3915
+ * Bumped when {@link pinIconCache} is cleared or evicts a sprite, so per-label sprite references
3916
+ * (`LabelComponent.pinIconKeyInputs.sprite`) are re-resolved.
3917
+ */
3918
+ private pinIconGeneration;
3919
+ /** Labels collected for drawing this frame (only the first `drawCount` entries of a frame are valid). */
3920
+ private _drawList;
3921
+ /** Cache ids parallel to {@link _drawList}. */
3922
+ private _drawListIds;
3923
+ /**
3924
+ * Runs the draw pass for all label entities, in two passes: pass 1 runs every per-label prep step
3925
+ * (caches, strategies) and collects the labels to draw, skipping invisible and offscreen ones; pass 2
3926
+ * clears the canvas and draws them.
3767
3927
  * @param zoomLevel - Current zoom level (for icon scale interpolation)
3768
3928
  */
3769
3929
  update: (zoomLevel: number) => void;
3930
+ /**
3931
+ * Per-label prep shared by both update paths: icon visibility, pin size, caches, strategy.
3932
+ * @returns The pin cache id when the label should be drawn this frame, otherwise `null`.
3933
+ */
3934
+ private _prepareLabel;
3770
3935
  processText: (text: string, size: number, maxWidth: number, maxLines: number, lineHeight: number, balance?: boolean) => {
3771
3936
  lineStrings: string[];
3772
3937
  lineWidths: number[];
@@ -3868,6 +4033,16 @@ declare class TwoDDrawSystem extends PubSub<{
3868
4033
  * All coordinates are in canvas pixels (already multiplied by pixelRatio).
3869
4034
  */
3870
4035
  private drawWrapperBackground;
4036
+ /**
4037
+ * Returns a cached sprite with the active pin and the clipped icon composited, laid out like the
4038
+ * active pin canvas (same size and center) so it is blitted with the pin's destination rect.
4039
+ * Everything in the icon draw scales linearly with `iconScale`, so the sprite is rendered at
4040
+ * the pin canvas' max icon scale and the blit applies the current scale.
4041
+ *
4042
+ * @returns The sprite, or `null` when the label must use the separate pin + icon path (no icon
4043
+ * loaded yet, `iconOverflow: 'visible'`, or a fixed `imageDimensionsCache` size).
4044
+ */
4045
+ getPinIconSprite(label: LabelComponent, labelCacheId: string): OffscreenCanvas | HTMLCanvasElement | null;
3871
4046
  /**
3872
4047
  * Draws a single label to the canvas.
3873
4048
  */
@@ -3921,13 +4096,42 @@ interface TwoDPipelineOptions {
3921
4096
  * Owns the canvas and DOM overlay elements and all sub-systems.
3922
4097
  *
3923
4098
  * Usage:
3924
- * 1. `new TwoDPipeline(container, state, project, options)`
4099
+ * 1. `new TwoDPipeline(container, state, projectBatch, options)`
3925
4100
  * 2. Call `update(zoomLevel, isUserInteracting)` each frame
3926
4101
  * 3. Call `cancelPendingFrames()` before sync renders
3927
4102
  * 4. Call `destroy()` on cleanup
3928
4103
  */
3929
4104
  declare class TwoDPipeline {
3930
- #private;
4105
+ private _state;
4106
+ private _viewportSize;
4107
+ private _projectBatch;
4108
+ /** Reused `[x, y, z, …]` input for {@link _projectBatch}. */
4109
+ private _batchPositions;
4110
+ /** Reused output for {@link _projectBatch}; replaced by the host if it needs more room. */
4111
+ private _batchOut;
4112
+ private _engineContainer;
4113
+ private _labelCanvas;
4114
+ private _markerContainer;
4115
+ private _collisionSystem;
4116
+ private _drawSystem;
4117
+ private _visibilitySystem;
4118
+ private _domDrawSystem;
4119
+ private _domVisibilitySystem;
4120
+ private _domResizeSystem;
4121
+ private _framesSinceLastCollision;
4122
+ /** Frame time of the last collision run started by {@link update}. */
4123
+ private _lastCollisionTime;
4124
+ private _resizeCollisionFrame;
4125
+ private _twoDFrameId;
4126
+ private _animationFrameId;
4127
+ private _updateEntitiesFrameId;
4128
+ private _headless;
4129
+ /** Frame time of the last {@link update} call (`-Infinity` before the first one). */
4130
+ private _lastUpdateTime;
4131
+ /** Whether the pending rAF redraw was already deferred once for a continuously-rendering host. */
4132
+ private _rafDrawDeferred;
4133
+ /** Last observed interval between {@link update} calls (ms). */
4134
+ private _updateInterval;
3931
4135
  /**
3932
4136
  * When true, the next collision update will perform a full strategy recompute.
3933
4137
  * Set to false by the host renderer on camera-start events so that collision
@@ -3936,13 +4140,24 @@ declare class TwoDPipeline {
3936
4140
  * Resets to false automatically at the end of each {@link update} call.
3937
4141
  */
3938
4142
  collidersNeedRecomputing: boolean;
4143
+ private _watermark;
4144
+ private _lastZoomLevel;
4145
+ private _lastImageScreenBBoxes;
4146
+ /** Pixel ratio the label caches were baked at; see {@link _handlePixelRatioChange}. */
4147
+ private _lastPixelRatio;
3939
4148
  get collisionSystem(): CollisionSystem;
3940
4149
  get drawSystem(): TwoDDrawSystem;
3941
4150
  /** Exposed for testing; DOM draw is internal to the pipeline */
3942
4151
  get domDrawSystem(): DOMDrawSystem;
3943
4152
  /** @internal Canvas used for rendering 2D labels. */
3944
4153
  get labelCanvas(): HTMLCanvasElement;
3945
- constructor(container: HTMLElement, state: TwoDPipelineState, project: ProjectFn, options?: TwoDPipelineOptions);
4154
+ /**
4155
+ * @param container - Element the label canvas and marker layer are appended to
4156
+ * @param state - Shared pipeline state
4157
+ * @param projectBatch - Host projection: world `[x, y, z, …]` → screen `[x, y, flags, …]`
4158
+ * @param options - Worker, image, watermark, viewport and headless options
4159
+ */
4160
+ constructor(container: HTMLElement, state: TwoDPipelineState, projectBatch: ProjectBatchFn, options?: TwoDPipelineOptions);
3946
4161
  /**
3947
4162
  * Registers an entity in the lookup map without activating it.
3948
4163
  * Use {@link activateEntity} to also add it to the active set.
@@ -3990,6 +4205,28 @@ declare class TwoDPipeline {
3990
4205
  * Called by the host renderer on init and container resize.
3991
4206
  */
3992
4207
  resize(): void;
4208
+ /**
4209
+ * Rebakes everything sized in device px after the host renderer's pixel ratio changes. The label text,
4210
+ * pin and wrapper canvases are drawn at the ratio in effect when they were cached and blitted 1:1, so a
4211
+ * stale bake shows up as text too large or too small next to its pin. The ratio can change without
4212
+ * `devicePixelRatio` changing: MapLibre clamps the drawing buffer to 4096 px, so moving a window between
4213
+ * a laptop screen and a wide external monitor changes it on a 2x display. Cold path: runs only on change.
4214
+ * @param pixelRatio - The new pixel ratio
4215
+ */
4216
+ private _handlePixelRatioChange;
4217
+ /**
4218
+ * Projects all entities from world coordinates to screen pixels with one host
4219
+ * {@link ProjectBatchFn} call. An exact `(0, 0)` result keeps the entity's previous
4220
+ * projection (the long-standing "no projection" convention). Reports the number of
4221
+ * projected entities to the draw system for diagnostics.
4222
+ *
4223
+ * Note: intentionally does NOT mutate `component.offscreen`. The
4224
+ * authoritative off-screen determination is the collision worker's
4225
+ * viewport/collider test (see collision/system.ts). Previously this
4226
+ * loop reset `offscreen = false` every frame, clobbering the worker's
4227
+ * result and effectively disabling viewport culling in the draw loop.
4228
+ */
4229
+ private _projectEntities;
3993
4230
  /**
3994
4231
  * Main update entry point. Called by the host renderer each frame.
3995
4232
  *
@@ -3999,6 +4236,13 @@ declare class TwoDPipeline {
3999
4236
  * @param imageScreenBBoxes - Bounding boxes of images on screen for collision avoidance
4000
4237
  */
4001
4238
  update(zoomLevel: number, isUserInteracting: boolean, isCameraMoving?: boolean, imageScreenBBoxes?: Rectangle[]): void;
4239
+ /**
4240
+ * Schedules a collision update on the next animation frame.
4241
+ * Used when the render loop is idle but collision needs re-evaluation
4242
+ * (e.g. after a marker's DOM content resizes).
4243
+ * Uses a dedicated frame ID so it never cancels a full update from {@link update}.
4244
+ */
4245
+ private _scheduleCollisionUpdate;
4002
4246
  /**
4003
4247
  * Updates the watermark configuration at runtime.
4004
4248
  * @param watermark - New watermark dimensions and position
@@ -4008,6 +4252,15 @@ declare class TwoDPipeline {
4008
4252
  height: number;
4009
4253
  position: WatermarkPosition$1;
4010
4254
  }): void;
4255
+ /** Called when collision results arrive: queue visibility + draw */
4256
+ private _onVisibilityChanged;
4257
+ /** Immediate draw pass for labels + markers */
4258
+ private _draw2DEntities;
4259
+ private _rafDraw;
4260
+ /** Called by visibility system when draw is needed */
4261
+ private _onDraw2D;
4262
+ /** Called by visibility system to advance animations */
4263
+ private _onAnimate2D;
4011
4264
  /**
4012
4265
  * Marks the 2D state as dirty, triggering re-population of the entity set
4013
4266
  * and collision recalculation.
@@ -4620,6 +4873,16 @@ declare abstract class BaseMapData {
4620
4873
  #private;
4621
4874
  /**
4622
4875
  * The identity of the map data.
4876
+ *
4877
+ * This `id` is **transient**: it may be regenerated whenever the map is modified, so it can change
4878
+ * between builds of the same map. It is safe to use during runtime, but it should not be stored as a
4879
+ * reference that persists between executions — for example, saved to a database or hardcoded in
4880
+ * application code.
4881
+ *
4882
+ * Use `externalId` instead, where available, for a value that remains constant. `externalId` is a text
4883
+ * field that can be entered and set in the map editor, so it stays the same even if the object is
4884
+ * deleted and re-created. Note that `externalId` is optional and is only populated if it has been set
4885
+ * in the map editor.
4623
4886
  */
4624
4887
  readonly id: string;
4625
4888
  constructor(id: string, _data: MapDataInternal);
@@ -4685,6 +4948,9 @@ declare class Floor extends BaseMapData implements IFocusable, IGeoJSONData {
4685
4948
  /**
4686
4949
  * Gets the external ID of the floor.
4687
4950
  *
4951
+ * Unlike {@link id}, this value is stable across map edits: it is a text field that can be entered and
4952
+ * set in the map editor, so it stays the same even if the floor is deleted and re-created.
4953
+ *
4688
4954
  * @returns {string} The external ID of the floor.
4689
4955
  */
4690
4956
  get externalId(): string;
@@ -4788,6 +5054,16 @@ declare class Floor extends BaseMapData implements IFocusable, IGeoJSONData {
4788
5054
  declare abstract class BaseMetaData {
4789
5055
  /**
4790
5056
  * The identity of the map metadata.
5057
+ *
5058
+ * This `id` is **transient**: it may be regenerated whenever the map is modified, so it can change
5059
+ * between builds of the same map. It is safe to use during runtime, but it should not be stored as a
5060
+ * reference that persists between executions — for example, saved to a database or hardcoded in
5061
+ * application code.
5062
+ *
5063
+ * Where available, use `externalId` instead for a value that remains constant. `externalId` is a text
5064
+ * field that can be entered and set in the map editor, so it stays the same even if the object is
5065
+ * deleted and re-created. Note that `externalId` is optional and is only populated if it has been set
5066
+ * in the map editor. Not all types expose an `externalId`.
4791
5067
  */
4792
5068
  readonly id: string;
4793
5069
  constructor(id: string);
@@ -4863,6 +5139,9 @@ declare class Node extends BaseMetaData implements IGeoJSONData, IFocusable, IAn
4863
5139
  /**
4864
5140
  * Gets the external ID of the node.
4865
5141
  *
5142
+ * Unlike {@link id}, this value is stable across map edits: it is a text field that can be entered and
5143
+ * set in the map editor, so it stays the same even if the node is deleted and re-created.
5144
+ *
4866
5145
  * @returns {string} The external ID of the node.
4867
5146
  */
4868
5147
  get externalId(): string;
@@ -5257,6 +5536,10 @@ declare abstract class DetailedMapData<MVFData extends Feature$1<Geometry$1, {
5257
5536
  /**
5258
5537
  * Gets the external identifier of the map feature.
5259
5538
  *
5539
+ * Unlike {@link id}, which is transient and may be regenerated whenever the map is modified, this
5540
+ * value is stable: it is a text field that can be entered and set in the map editor, so it stays the
5541
+ * same even if the map feature is deleted and re-created.
5542
+ *
5260
5543
  * @returns {string} The external ID of the map feature, or an empty string if no external ID exists.
5261
5544
  */
5262
5545
  get externalId(): string;
@@ -6143,6 +6426,9 @@ declare class FloorStack extends BaseMapData implements IGeoJSONData, IFocusable
6143
6426
  get shortName(): string;
6144
6427
  /**
6145
6428
  * Gets the externalId of FloorStack
6429
+ *
6430
+ * Unlike {@link id}, this value is stable across map edits: it is a text field that can be entered and
6431
+ * set in the map editor, so it stays the same even if the floor stack is deleted and re-created.
6146
6432
  */
6147
6433
  get externalId(): string;
6148
6434
  /**
@@ -12176,7 +12462,7 @@ declare class Camera {
12176
12462
  /**
12177
12463
  * The camera's current pan mode.
12178
12464
  */
12179
- get panMode(): "elevation" | "default";
12465
+ get panMode(): "default" | "elevation";
12180
12466
  /**
12181
12467
  * Set the camera's pan mode. 'elevation' moves the camera up and down, while 'default' allows the camera to pan in all directions.
12182
12468
  * @experimental
@@ -13266,6 +13552,10 @@ declare class Text3D {
13266
13552
  }: {
13267
13553
  currentMapGetter: CurrentMapGetter;
13268
13554
  });
13555
+ /**
13556
+ * @internal
13557
+ */
13558
+ getById(id: string): Text3DView | undefined;
13269
13559
  /**
13270
13560
  * Creates polygon labels for all spaces.
13271
13561
  *
@@ -13790,8 +14080,8 @@ declare const markerStateSchema: ZodObject<{
13790
14080
  }, $strip>;
13791
14081
  /** @internal */
13792
14082
  declare const markerStateSchemaPartial: ZodObject<{
13793
- type: ZodOptional<ZodDefault<ZodLiteral<"marker">>>;
13794
14083
  enabled: ZodOptional<ZodDefault<ZodBoolean>>;
14084
+ type: ZodOptional<ZodDefault<ZodLiteral<"marker">>>;
13795
14085
  interactive: ZodOptional<ZodDefault<ZodUnion<readonly [ZodBoolean, ZodLiteral<"pointer-events-auto">]>>>;
13796
14086
  rank: ZodOptional<ZodCustom<"initial" | TCollisionRankingTier, "initial" | TCollisionRankingTier>>;
13797
14087
  occlude: ZodOptional<ZodDefault<ZodBoolean>>;
@@ -14055,6 +14345,7 @@ declare const shapeStateSchemaPartial: ZodObject<{
14055
14345
  offset: ZodOptional<ZodNumber>;
14056
14346
  segments: ZodOptional<ZodNumber>;
14057
14347
  }, $strip>>>;
14348
+ visibleThroughGeometry: ZodOptional<ZodDefault<ZodBoolean>>;
14058
14349
  position: ZodOptional<ZodCustom<Coordinate, Coordinate>>;
14059
14350
  }, $strip>;
14060
14351
  /** @internal */
@@ -14074,6 +14365,7 @@ declare const shapeStateSchemaStrict: ZodObject<{
14074
14365
  offset: ZodOptional<ZodNumber>;
14075
14366
  segments: ZodOptional<ZodNumber>;
14076
14367
  }, $strip>>;
14368
+ visibleThroughGeometry: ZodDefault<ZodBoolean>;
14077
14369
  position: ZodCustom<Coordinate, Coordinate>;
14078
14370
  }, $strict>;
14079
14371
  /**
@@ -14176,7 +14468,14 @@ type TModelUpdateState = output<typeof modelStateUpdateSchema>;
14176
14468
  declare const text3DUpdateStateSchema: ZodObject<{
14177
14469
  visible: ZodOptional<ZodOptional<ZodBoolean>>;
14178
14470
  color: ZodOptional<ZodOptional<ZodString>>;
14471
+ rotation: ZodOptional<ZodOptional<ZodNumber>>;
14179
14472
  flipToFaceCamera: ZodOptional<ZodOptional<ZodBoolean>>;
14473
+ content: ZodOptional<ZodOptional<ZodString>>;
14474
+ align: ZodOptional<ZodOptional<ZodOptional<ZodEnum<{
14475
+ center: "center";
14476
+ left: "left";
14477
+ right: "right";
14478
+ }>>>>;
14180
14479
  font: ZodOptional<ZodOptional<ZodOptional<ZodString>>>;
14181
14480
  fontSize: ZodOptional<ZodOptional<ZodNumber>>;
14182
14481
  outlineColor: ZodOptional<ZodOptional<ZodString>>;
@@ -14217,6 +14516,11 @@ declare const text3DStateSchemaStrict: ZodObject<{
14217
14516
  id: ZodUnion<readonly [ZodString, ZodNumber]>;
14218
14517
  content: ZodString;
14219
14518
  rotation: ZodNumber;
14519
+ align: ZodOptional<ZodEnum<{
14520
+ center: "center";
14521
+ left: "left";
14522
+ right: "right";
14523
+ }>>;
14220
14524
  type: ZodDefault<ZodLiteral<"text3d">>;
14221
14525
  position: ZodCustom<Coordinate, Coordinate>;
14222
14526
  }, $strict>;
@@ -14646,6 +14950,10 @@ type TClickPayload = {
14646
14950
  * Interactive {@link Image3DView | 3D Image}s under the pointer.
14647
14951
  */
14648
14952
  images?: Image3DView[];
14953
+ /**
14954
+ * Interactive {@link Text3DView | 3D Text}s under the pointer.
14955
+ */
14956
+ text3ds?: Text3DView[];
14649
14957
  /**
14650
14958
  * Interactive {@link Label}s under the pointer.
14651
14959
  */
@@ -15895,7 +16203,9 @@ type TAddText3DOptions = AddText3DOptions$1;
15895
16203
  /**
15896
16204
  * Options for adding 3D text at an anchorable target (e.g., Coordinate).
15897
16205
  */
15898
- type TAddText3DAnchorableOptions = AddText3DPointOptions$1;
16206
+ type TAddText3DAnchorableOptions = AddText3DPointOptions$1 & {
16207
+ align?: 'left' | 'center' | 'right';
16208
+ };
15899
16209
  /**
15900
16210
  * Options for controlling the behavior of an {@link Image3DView}.
15901
16211
  */
@@ -18117,6 +18427,7 @@ type Style$1 = {
18117
18427
  washOutAmount?: number;
18118
18428
  washOutUseDepth?: boolean;
18119
18429
  maxImageSize?: number;
18430
+ visibleThroughGeometry?: boolean;
18120
18431
  };
18121
18432
  declare class StyleComponent implements Style$1 {
18122
18433
  #private;
@@ -18172,6 +18483,12 @@ declare class StyleComponent implements Style$1 {
18172
18483
  washOutAmount: number;
18173
18484
  washOutUseDepth: boolean;
18174
18485
  maxImageSize?: number;
18486
+ /**
18487
+ * Whether this geometry renders on top of other geometry (depth test/write off).
18488
+ * Applied per geometry by the `RenderOrderSystem`, which also assigns the
18489
+ * render order that keeps it above the rest of the scene.
18490
+ */
18491
+ visibleThroughGeometry: boolean;
18175
18492
  constructor(style?: Partial<Style$1>);
18176
18493
  }
18177
18494
  //#endregion
@@ -18600,6 +18917,14 @@ type FeatureCollectionState = {
18600
18917
  desaturateUseDepth?: boolean;
18601
18918
  washOutAmount?: number;
18602
18919
  washOutUseDepth?: boolean;
18920
+ /**
18921
+ * When true, renders every feature in the collection on top of other geometry
18922
+ * by disabling depth testing. Cascades to all children, which are detached
18923
+ * from the shared batched mesh so the depth state does not leak to siblings.
18924
+ *
18925
+ * @default false
18926
+ */
18927
+ visibleThroughGeometry?: boolean;
18603
18928
  /**
18604
18929
  * The position of the feature collection as a GeoJSON Position `[lon, lat]`,
18605
18930
  * computed from the centroid of its child features. Vertical offset is a
@@ -18875,6 +19200,18 @@ declare class EntityBatchedMesh extends BatchedMesh {
18875
19200
  };
18876
19201
  detached?: boolean;
18877
19202
  };
19203
+ /**
19204
+ * Assigned by three's BatchedMesh constructor / setColorAt but not present in @types/three.
19205
+ * `declare` emits nothing, so it cannot overwrite the value three set in super().
19206
+ */
19207
+ protected _colorsTexture: DataTexture | null;
19208
+ /**
19209
+ * Perf: three 0.178 WebGLRenderer.setProgram checks `object.colorTexture` for batched
19210
+ * meshes, but BatchedMesh only defines `_colorsTexture` — so `undefined !== null` is always true and
19211
+ * every batched mesh without per-instance colors forces needsProgramChange -> getProgram on every
19212
+ * draw. Expose the getter so the check compares the real texture.
19213
+ */
19214
+ get colorTexture(): DataTexture | null;
18878
19215
  }
18879
19216
  declare class EntityMergedMesh extends Mesh {
18880
19217
  type: "entityMergedMesh";
@@ -19022,6 +19359,16 @@ type GeometryState = {
19022
19359
  * The width of the border
19023
19360
  */
19024
19361
  borderWidth?: number;
19362
+ /**
19363
+ * When true, the geometry renders on top of other geometry: depth testing and
19364
+ * depth writing are disabled and it is given an always-on-top render order.
19365
+ *
19366
+ * Setting this detaches the geometry from its shared batched mesh, because the
19367
+ * depth state belongs to the material.
19368
+ *
19369
+ * @default false
19370
+ */
19371
+ visibleThroughGeometry?: boolean;
19025
19372
  };
19026
19373
  declare class MeshComponent {
19027
19374
  #private;
@@ -19571,6 +19918,12 @@ declare class PathComponent {
19571
19918
  readonly type = "path";
19572
19919
  mesh: PatMeshContainer;
19573
19920
  material?: PathMaterial;
19921
+ /**
19922
+ * The main path mesh (`name === 'path'`), set by `buildPath`. It is the only child that can be placed on
19923
+ * `RENDER_LAYERS.ALWAYS_ON_TOP_PATHS` (when `visibleThroughGeometry`), so the per-frame on-top count
19924
+ * reads it directly instead of scanning children.
19925
+ */
19926
+ pathObject?: PathMesh;
19574
19927
  geometry?: BufferGeometry;
19575
19928
  outline?: LineSegments;
19576
19929
  feature: FeatureCollection<Point, PathProperties>;
@@ -19779,6 +20132,10 @@ type Text3DState$1 = {
19779
20132
  * Content of the text3d
19780
20133
  */
19781
20134
  content: string;
20135
+ /**
20136
+ * Horizontal alignment of multi-line text: 'left' | 'center' | 'right'.
20137
+ */
20138
+ align?: 'left' | 'center' | 'right';
19782
20139
  /**
19783
20140
  * Rotation of the text in degrees clockwise from North.
19784
20141
  */
@@ -19792,10 +20149,10 @@ type Text3DState$1 = {
19792
20149
  */
19793
20150
  type InitializeText3DState$1 = Partial<Omit<Text3DState$1, 'id' | 'type'>>;
19794
20151
  /**
19795
- * At this moment updating text margin, rotation, and content are not supported.
20152
+ * At this moment updating text margin, maxWidth, and maxHeight (text-area-only fields) are not supported.
19796
20153
  * @interface
19797
20154
  */
19798
- type UpdatableText3DState = Omit<InitializeText3DState$1, 'margin' | 'position' | 'content' | 'rotation'>;
20155
+ type UpdatableText3DState = Omit<InitializeText3DState$1, 'margin' | 'maxWidth' | 'maxHeight'>;
19799
20156
  type Text3DProperties = {
19800
20157
  id: string;
19801
20158
  content: string;
@@ -19806,6 +20163,7 @@ type Text3DProperties = {
19806
20163
  */
19807
20164
  type AddText3DOptions$2 = {
19808
20165
  appearance?: Partial<InitializeText3DState$1>;
20166
+ interactive?: boolean;
19809
20167
  };
19810
20168
  declare class Text3DComponent {
19811
20169
  mesh: Geometry3DObject3D;
@@ -20393,8 +20751,11 @@ declare class Renderer {
20393
20751
  * @param renderTarget {null or WebGLRenderTarget}
20394
20752
  * @param scene {Scene}
20395
20753
  * @param sceneCamera {Camera}
20754
+ * @param renderAlwaysOnTop Whether to run the second, always-on-top pass
20755
+ * (`RENDER_LAYERS.ALWAYS_ON_TOP_PATHS`). Callers pass `false` when nothing in the scene
20756
+ * is on that layer: three still walks the whole scene graph for an empty layer pass.
20396
20757
  */
20397
- renderFullScene(scene: Scene, sceneCamera: Camera$1): void;
20758
+ renderFullScene(scene: Scene, sceneCamera: Camera$1, renderAlwaysOnTop?: boolean): void;
20398
20759
  clear(): void;
20399
20760
  /**
20400
20761
  * Set the size of the renderer, composer, and all its internal buffers.
@@ -21040,6 +21401,16 @@ declare class CameraSystem extends PubSub<CameraEvents> {
21040
21401
  */
21041
21402
  setPosition: (x: number, y: number) => void;
21042
21403
  private updateCameraPosition;
21404
+ /**
21405
+ * Clamps a centre to the pan bounds, exactly as {@link setCenter} would, without moving the camera.
21406
+ * Lets another camera driver (MapLibre in interleaved mode) stay inside the same bounds.
21407
+ *
21408
+ * @param longitude Proposed centre longitude, degrees.
21409
+ * @param latitude Proposed centre latitude, degrees.
21410
+ * @returns The clamped `[longitude, latitude]`, or `undefined` if the centre is already inside.
21411
+ * @hidden
21412
+ */
21413
+ clampCenterToPanBounds(longitude: number, latitude: number): [number, number] | undefined;
21043
21414
  /**
21044
21415
  * Tilts the camera up or down by some number of radians. Bounded by minTilt and maxTilt.
21045
21416
  *
@@ -21335,6 +21706,12 @@ declare class Camera$2 extends PubSub<{
21335
21706
  * @param center The center in [longitude, latitude] degrees.
21336
21707
  */
21337
21708
  setCenter(center: Position$2): void;
21709
+ /**
21710
+ * @internal
21711
+ * Run several camera setters as one update: at most one `camera-change` is published (synchronously,
21712
+ * before this returns) and one render is requested.
21713
+ */
21714
+ batch(fn: () => void): void;
21338
21715
  /**
21339
21716
  * Current camera zoom in mercator zoom level units.
21340
21717
  */
@@ -21901,6 +22278,17 @@ declare class GeometryInFocusSystem extends PubSub<{
21901
22278
  private screenBoundsMap;
21902
22279
  private screenDiagonal;
21903
22280
  private lastPublishedEntities?;
22281
+ /** View-projection matrix used by the last compute(). */
22282
+ private lastComputedVP;
22283
+ private hasComputed;
22284
+ /** Set when the focusable set changed since the last compute(). */
22285
+ private focusablesChangedSinceCompute;
22286
+ private lastComputeTime;
22287
+ private trailingTimer?;
22288
+ private clipPool;
22289
+ private clipScratch;
22290
+ private screenPool;
22291
+ private screenScratch;
21904
22292
  constructor(state: RendererState, camera: Camera$1);
21905
22293
  resize(): void;
21906
22294
  /**
@@ -22243,45 +22631,91 @@ declare class Debug$1 {
22243
22631
  }
22244
22632
  //#endregion
22245
22633
  //#region ../renderer-three/src/systems/2d-occlusion/system.d.ts
22634
+ /**
22635
+ * Hides 2D entities (labels, markers) that sit behind 3D occluder geometry by writing `UI.isOccluded`.
22636
+ *
22637
+ * Each pass renders the occluders into a half-resolution id texture (the picking pass), then hands the pending
22638
+ * entities' projected pixels to a {@link SampleReadback}, which samples that texture on the GPU and reads only those
22639
+ * pixels back without stalling. Results are applied on a later frame. See `ARCHITECTURE.md` in this directory.
22640
+ */
22246
22641
  declare class Occlusion2DSystem {
22247
22642
  private state;
22248
22643
  private renderer;
22249
22644
  private renderService;
22250
- private pickingTexture?;
22251
- private pickingMaterial;
22252
- private pixelBuffer?;
22253
- private width;
22254
- private height;
22255
- private scale;
22256
- private color;
22257
22645
  private convertTo3DMapPosition;
22258
22646
  private destroyed;
22259
22647
  private enabled;
22260
22648
  backgroundId: number;
22649
+ /** Last occluder id handed out by {@link reserveOccluderId}. */
22650
+ private color;
22651
+ private pickingTexture?;
22652
+ private pickingMaterial;
22653
+ /** Reused clear colour for the picking pass, set to {@link backgroundId}. */
22654
+ private readonly clearColor;
22655
+ /** GPU sample-pack + PBO readback of the pending entities' picking-texture pixels. */
22656
+ private readback;
22261
22657
  /**
22262
- * Applies the id to the geometry which is encoded as a color
22658
+ * Snapshot of the entities driving the in-flight read: sample `i` belongs to entity `i`. Applying results walks
22659
+ * this list (not `geometry2DsInScene`), so entities added or removed mid-read can't misalign samples.
22263
22660
  */
22264
- private applyId;
22265
- private createOccluderMesh;
22661
+ private pendingEntities;
22662
+ activeOccluders: Set<unknown>;
22663
+ private framesSinceLastUpdate;
22266
22664
  constructor(state: RendererState, convertTo3DMapPosition: (position: Position) => Vector3, renderer?: Renderer);
22267
22665
  reserveOccluderId(): number;
22268
22666
  enable(): void;
22269
22667
  disable(): void;
22270
22668
  resize: () => void;
22271
- private shouldShowByXY;
22272
- activeOccluders: Set<unknown>;
22273
- private framesSinceLastUpdate;
22274
22669
  /**
22275
- * Throttled per-frame entry point called by the render loop. Delegates to
22276
- * {@link updateImmediately} once every {@link OCCLUSION_SKIP_FRAMES} calls.
22277
- * Callers that need a guaranteed synchronous pass should use
22278
- * {@link updateImmediately} directly. When running under the visual
22279
- * regression harness (`?e2e=true`) the throttle is bypassed so every
22280
- * render produces a deterministic occlusion state.
22670
+ * Per-frame entry point called by the render loop. Applies the in-flight read once the GPU has finished it, then
22671
+ * (every {@link OCCLUSION_SKIP_FRAMES} calls, or every call under the visual test harness) starts the next one.
22672
+ * Polling from the render loop keeps the CPU work frame-aligned, unlike `readRenderTargetPixelsAsync`, which polls
22673
+ * its fence with `setTimeout` and resumes in a microtask detached from the frame.
22281
22674
  */
22282
22675
  update: () => void;
22676
+ /**
22677
+ * Kick off an occlusion pass immediately, bypassing the frame throttle. Still asynchronous: the results are
22678
+ * applied on a later {@link update} once the GPU finishes. A no-op while a read is in flight.
22679
+ */
22283
22680
  updateImmediately: () => void;
22681
+ /**
22682
+ * Called after the WebGL context was lost and restored. The readback's PBO and fence are raw GL objects of the
22683
+ * dead context, so drop them (and the in-flight snapshot); the next pass reallocates. three.js rebuilds the picking
22684
+ * texture and materials itself.
22685
+ */
22686
+ contextRestored(): void;
22284
22687
  destroy(): void;
22688
+ /** Rebuilds dirty occluders, snapshots the pending entities, renders the picking pass and dispatches the read. */
22689
+ private beginPass;
22690
+ /**
22691
+ * Records which occluders are in the scene ({@link activeOccluders}) and (re)builds the mesh of any occluder whose
22692
+ * feature changed.
22693
+ */
22694
+ private refreshOccluders;
22695
+ private buildOccluderMesh;
22696
+ private createOccluderMesh;
22697
+ /**
22698
+ * Applies the id to the geometry which is encoded as a color
22699
+ */
22700
+ private applyId;
22701
+ /**
22702
+ * Snapshots the eligible 2D entities (occlusion enabled, occluder in the scene) into {@link pendingEntities}, and
22703
+ * un-occludes entities whose occlusion component is disabled since they won't get a sample.
22704
+ *
22705
+ * @returns Number of entities queued for sampling.
22706
+ */
22707
+ private collectPendingEntities;
22708
+ /** Writes each pending entity's projected picking-texture pixel into the readback's positions buffer. */
22709
+ private writePositions;
22710
+ /** Renders the occluder layer into the picking texture, so each texel holds the nearest occluder's id. */
22711
+ private renderPickingPass;
22712
+ /** Applies the in-flight read once it completes; a stale or failed read is consumed without being applied. */
22713
+ private pollReadback;
22714
+ /**
22715
+ * Sets `isOccluded` on each snapshotted entity from its sample. Re-checks `enabled`: a component disabled while
22716
+ * the read was in flight means the consumer asked for the entity to show, so the stale sample is ignored.
22717
+ */
22718
+ private applyResults;
22285
22719
  }
22286
22720
  //#endregion
22287
22721
  //#region ../renderer-three/src/systems/geometry-disposal/system.d.ts
@@ -22356,6 +22790,15 @@ declare class RenderOrderSystem {
22356
22790
  */
22357
22791
  getOrder(object: object): number | undefined;
22358
22792
  update(): void;
22793
+ /**
22794
+ * Applies always-on-top depth settings and render order for a single geometry
22795
+ * (a shape feature) whose style opted into `visibleThroughGeometry`.
22796
+ *
22797
+ * Runs off `StyleComponent.dirty` (the draw system clears it later in the frame,
22798
+ * after this system). A mesh that is not loaded yet is picked up on the next frame
22799
+ * because the style stays dirty until the draw system consumes it.
22800
+ */
22801
+ private updateVisibleThroughGeometry;
22359
22802
  /**
22360
22803
  * Applies render order to a model component's mesh
22361
22804
  * @param modelComponent - The model component to apply render order to
@@ -22581,7 +23024,13 @@ declare class ShadowsSystem {
22581
23024
  * tall casters. 1 when the default range already fits. Not applied to the adaptive `'auto'` bias.
22582
23025
  */
22583
23026
  private depthScale;
23027
+ /** Depth range of the cached caster bounds written by `updateBoundsDepthRange`: reused, never re-created. */
23028
+ private rangeNear;
23029
+ private rangeFar;
22584
23030
  private readonly scratchBox;
23031
+ /** Reused by `groundShadowFitHalfSize` for the light camera's two view-plane axes. */
23032
+ private readonly scratchRight;
23033
+ private readonly scratchUp;
22585
23034
  private shadowPlane;
22586
23035
  private shadowPlaneMaterial;
22587
23036
  private shadowPlaneEnabled;
@@ -22700,11 +23149,23 @@ declare class ShadowsSystem {
22700
23149
  private matrix;
22701
23150
  private updateLightMatrix;
22702
23151
  /**
22703
- * Depth range `[nearest, farthest]` (distance along the light's view direction, from the light) spanned by
22704
- * the cached caster bounds. Projects the box's 8 corners onto the sun direction: constant work, no scene walk.
22705
- * Called whenever the light moves, so it must stay cheap.
23152
+ * Writes the depth range the cached caster bounds and the ground shadows they cast span along the light's
23153
+ * view direction into `rangeNear` / `rangeFar`.
23154
+ *
23155
+ * Both ends are per corner, and per corner they are the union of the corner *and* its landing point, not the
23156
+ * casters widened by one constant. The light's view direction is the sun direction, so a corner's landing point
23157
+ * sits `(corner.z − plane z) / sin(sun elevation)` further along the view direction than the corner
23158
+ * (`dir · (p + t·dir) = dir · p + t`), and that distance differs per corner — as does its sign, since a corner
23159
+ * below the plane lands nearer the light. Uniting per corner is what keeps the range tight and complete;
23160
+ * widening the whole box by a single maximum leaves the deepest corner's landing point outside the far plane
23161
+ * whenever that corner is not also the one furthest from the light.
23162
+ *
23163
+ * A ray is clamped to half the shadow plane's size both ways: the plane is the only surface a shadow lands on,
23164
+ * and a sun at or below the horizon would otherwise ask for an unbounded far plane. Eight corner projections,
23165
+ * no scene walk, no allocation — the result lands in the two fields rather than a tuple so the per-frame path
23166
+ * creates nothing.
22706
23167
  */
22707
- private getCasterDepthRange;
23168
+ private updateBoundsDepthRange;
22708
23169
  /**
22709
23170
  * Marks the cached shadow-caster bounds stale (and the shadow map with it). Call when casters are added,
22710
23171
  * removed, moved or resized: the scene's 3D entities change, a model loads, an altitude or height
@@ -22728,6 +23189,41 @@ declare class ShadowsSystem {
22728
23189
  */
22729
23190
  private updateAutoShadowResolution;
22730
23191
  private updateAutoLightSize;
23192
+ /**
23193
+ * Frustum half-size that contains every shadow the scene can draw. The casters are enough: the light sits on
23194
+ * `shadowCenter − sunDirection × sunDistance` and looks at the centre, so its view direction *is* the sun
23195
+ * direction, and a shadow's landing point is the caster's own point moved along the sun. Moving along the view
23196
+ * direction leaves both view-plane coordinates unchanged (`sunDirection · right = sunDirection · up = 0`),
23197
+ * so a landing point projects to the same place as the caster it fell from — at any height, on any receiver.
23198
+ * Containing the casters therefore contains every receiver the shadow map can shade; reserving more would
23199
+ * spend texels on ground no shadow reaches.
23200
+ *
23201
+ * This is what makes the fit independent of where the camera target is. The light is centred on the
23202
+ * camera's snapped cell (`updateSnap`), so its axis is routinely tens of metres off the venue; a fit
23203
+ * measured about the casters' *own* centre (ADR 0013's `1.15 × bounding-sphere radius`) therefore contains
23204
+ * the venue only while the camera happens to be near it, and every shadow on screen goes out at once past the
23205
+ * offset the 1.15 margin absorbs (SDK-516). Measuring from the centre the light actually sits on removes that
23206
+ * coupling.
23207
+ *
23208
+ * The light camera's view-plane axes are the two directions the orthographic box measures in. Read from its
23209
+ * world matrix so the fit uses the same basis `updateLightMatrix` renders with. `lookAt` builds that basis
23210
+ * from the view direction and the camera's `up`, which is three.js's default (0, 1, 0) — the position is
23211
+ * always `shadowCenter − sunDirection × sunDistance` and the target `shadowCenter`, so the view direction is
23212
+ * the sun direction at every pose and the basis depends on neither the shadow centre nor the ortho size. A
23213
+ * matrix left over from the previous frame therefore carries the same basis — see the ordering note in
23214
+ * `update`.
23215
+ *
23216
+ * @returns The half-size in metres, before the zoom-derived cap and the `LIGHT_SIZE_BASE` floor.
23217
+ */
23218
+ private groundShadowFitHalfSize;
23219
+ /**
23220
+ * Largest distance from `centre` to the cached caster bounds along `axis`, in metres — the support of the
23221
+ * box, which the axis-aligned extreme corner gives without enumerating all eight. No scene walk, no
23222
+ * allocation.
23223
+ * @param axis - A unit view-plane axis of the light camera.
23224
+ * @param centre - The point the light sits on (`shadowCenter`).
23225
+ */
23226
+ private casterSupport;
22731
23227
  /**
22732
23228
  * Updates shadow visibility and opacity based on zoom level threshold.
22733
23229
  * Shadows smoothly fade in/out over a zoom range for a smoother transition.
@@ -23049,10 +23545,10 @@ declare class TwoDEntitySystem {
23049
23545
  * @param container - DOM element to host the 2D overlay
23050
23546
  * @param state - Renderer state
23051
23547
  * @param pipelineState - 2D pipeline state
23052
- * @param projectFn - Function to project world coords to screen coords
23548
+ * @param projectBatch - Batched world → screen projection (`RendererCore.projectBatch`)
23053
23549
  * @param options - Pipeline options (worker URL, collision settings, etc.)
23054
23550
  */
23055
- constructor(container: HTMLElement, state: RendererState, pipelineState: TwoDPipelineState, projectFn: (out: Vector2, v3: Vector3) => void, options?: TwoDPipelineOptions);
23551
+ constructor(container: HTMLElement, state: RendererState, pipelineState: TwoDPipelineState, projectBatch: ProjectBatchFn, options?: TwoDPipelineOptions);
23056
23552
  /** Returns the internal pipeline for direct access (test use only). */
23057
23553
  get pipeline(): TwoDPipeline;
23058
23554
  /** @internal Canvas used for rendering 2D labels. */
@@ -23240,6 +23736,24 @@ declare class Core extends PubSub<MapEvent> {
23240
23736
  * @internal
23241
23737
  */
23242
23738
  constructor(container: HTMLElement, options?: RendererCoreOptions$2);
23739
+ /**
23740
+ * Projects many world positions to screen pixels in one pass; the batched form of {@link project}.
23741
+ *
23742
+ * Each result equals `project()` on that point (same camera matrices, same behind-camera rule,
23743
+ * same 0.1 px truncation) whenever the cached canvas size matches the live layout box, i.e. once
23744
+ * {@link CanvasSizeTracker} has refreshed after a size change. Unlike `project()` it makes no
23745
+ * per-point function call, allocates nothing per point, and reads the canvas size once per call
23746
+ * from the tracker instead of `clientWidth`/`clientHeight` per point.
23747
+ *
23748
+ * @param positions - World coordinates, `[x0, y0, z0, x1, y1, z1, …]` (as `project()` takes them)
23749
+ * @param out - Optional destination, reused across calls; replaced with a larger array if too small
23750
+ * @param count - Number of points; defaults to `positions.length / 3`
23751
+ * @returns `out` (or its replacement), `PROJECT_BATCH_STRIDE` slots per point:
23752
+ * `[screenX, screenY, flags]`, where `flags` holds `ProjectBatchFlags` (e.g. `BehindCamera`).
23753
+ * Further flag bits are reserved for per-point metadata such as occlusion.
23754
+ * @internal
23755
+ */
23756
+ projectBatch: (positions: ArrayLike<number>, out?: Float64Array, count?: number) => Float64Array;
23243
23757
  /**
23244
23758
  * Projects a position into screen space. If a Vector3 is provided, the z-coordinate will include the depth from the camera.
23245
23759
  * @param projectVector - The vector to project the position into
@@ -23451,6 +23965,12 @@ declare class Core extends PubSub<MapEvent> {
23451
23965
  * @internal
23452
23966
  */
23453
23967
  convert3DMapPositionToCoordinate: (v: Vector3) => Position$2;
23968
+ /**
23969
+ * @internal
23970
+ * Cheap visibility read for an entity — avoids building a full {@link getState} object.
23971
+ * Returns `undefined` when the entity does not exist.
23972
+ */
23973
+ getVisible(geometryOrGeometryId: Record<string | number, any> | string | number): boolean | undefined;
23454
23974
  /**
23455
23975
  * Sets the background color of the renderer. Only applies to "standalone mode"
23456
23976
  */
@@ -23579,6 +24099,12 @@ declare class Core extends PubSub<MapEvent> {
23579
24099
  * Destroys instance and frees resources
23580
24100
  */
23581
24101
  destroy: () => void;
24102
+ /**
24103
+ * @internal
24104
+ * Runs `fn` with camera `change` handling deferred, then handles at most one change (one
24105
+ * `camera-change` publish, one render request) synchronously before returning. Re-entrant.
24106
+ */
24107
+ batchCameraChanges(fn: () => void): void;
23582
24108
  }
23583
24109
  //#endregion
23584
24110
  //#region ../renderer-three/src/entities/group-container.d.ts
@@ -23679,7 +24205,22 @@ declare class Occlusion2DComponent implements Occlusion2D {
23679
24205
  }
23680
24206
  //#endregion
23681
24207
  //#region ../renderer-three/src/entities/geometry2d.d.ts
23682
- declare class Geometry2DObject3D extends Object3D {}
24208
+ /**
24209
+ * Scene-graph anchor for a 2D label/marker. It has no geometry; it exists so the anchor inherits its
24210
+ * parent container's transform and scene membership.
24211
+ *
24212
+ * Anchors are excluded from three.js' per-frame scene traversal:
24213
+ * - `visible` is `false` so `WebGLRenderer.projectObject` returns immediately for each anchor.
24214
+ * Scene membership is decided by {@link populateGeometry2DIdsInScene}, which checks the parent
24215
+ * containers' visibility, not this flag.
24216
+ * - `updateMatrixWorld` is a no-op; the world position is computed on demand by
24217
+ * {@link Geometry2D.position} via `getWorldPosition` (which uses `updateWorldMatrix`, not this).
24218
+ *
24219
+ * With thousands of labels this traversal was ~20% of frame time while producing nothing.
24220
+ */
24221
+ declare class Geometry2DObject3D extends Object3D {
24222
+ constructor();
24223
+ }
23683
24224
  type ComponentTypeMap = {
23684
24225
  interaction: InteractionComponent;
23685
24226
  marker: MarkerComponent;
@@ -23960,9 +24501,18 @@ type ShadowsOptions$1 = {
23960
24501
  * Mercator zoom level at which shadows become visible.
23961
24502
  * Shadows are hidden when zoomed out beyond this level for performance.
23962
24503
  * Higher values mean you need to zoom in more to see shadows.
23963
- * @default 18
24504
+ * @default 15
23964
24505
  */
23965
24506
  visibleAtZoomLevel?: number;
24507
+ /**
24508
+ * Where the shadow light frustum's half-size comes from.
24509
+ * - `'venue'` caps the zoom-derived size at the shadow casters' bounding sphere, so a small venue
24510
+ * keeps a dense shadow map when zoomed out instead of paying for a texel sized for a much larger
24511
+ * area. The cap only ever shrinks the frustum, so zoomed-in framing is unaffected.
24512
+ * - `'zoom'` derives it from zoom alone, which pins it at its maximum for every zoom at or below 15.
24513
+ * @default 'venue'
24514
+ */
24515
+ frustumMode?: 'zoom' | 'venue';
23966
24516
  };
23967
24517
  //#endregion
23968
24518
  //#region ../renderer-three/src/types/index.d.ts
@@ -24076,6 +24626,17 @@ type PaintStyle$2 = {
24076
24626
  * @experimental
24077
24627
  */
24078
24628
  __EXPERIMENTAL_maskEnabled?: boolean;
24629
+ /**
24630
+ * When true, renders the geometry on top of other geometry by disabling depth
24631
+ * testing. Useful for shapes that should always be visible regardless of
24632
+ * occlusion.
24633
+ *
24634
+ * Depth state belongs to the material, so a feature opting in is detached from
24635
+ * its shared batched mesh and given its own material.
24636
+ *
24637
+ * @default false
24638
+ */
24639
+ visibleThroughGeometry?: boolean;
24079
24640
  };
24080
24641
  /**
24081
24642
  * Configures the vertical shading gradient applied to extruded geometry to give
@@ -24183,6 +24744,11 @@ type ClickPayload = {
24183
24744
  * Only images added with `interactive: true` are included.
24184
24745
  */
24185
24746
  images: [string | number] | [];
24747
+ /**
24748
+ * An array of 3D text IDs the user interaction passed through. Empty if no text was interacted with.
24749
+ * Only text added with `interactive: true` is included.
24750
+ */
24751
+ text3ds: [string | number] | [];
24186
24752
  /**
24187
24753
  * An array of label IDs which the user interaction passed through. Will be empty if no labels were interacted with.
24188
24754
  */
@@ -24436,6 +25002,12 @@ type RendererState = {
24436
25002
  * system from the renderer service.
24437
25003
  */
24438
25004
  renderStats: RenderFrameStats;
25005
+ /**
25006
+ * Number of visible paths in the scene that draw on `RENDER_LAYERS.ALWAYS_ON_TOP_PATHS`
25007
+ * (`visibleThroughGeometry`). Recounted every frame by the path system over
25008
+ * `geometry3DsInScene`; the always-on-top render pass is skipped while it is 0.
25009
+ */
25010
+ alwaysOnTopPaths: number;
24439
25011
  };
24440
25012
  /**
24441
25013
  * All of the entities in the scene
@@ -24583,6 +25155,7 @@ declare class MapLibreOverlay<T$1> extends PubSub<T$1> implements IControl {
24583
25155
  private handleStyleChange;
24584
25156
  private handleMoveStart;
24585
25157
  private handleMove;
25158
+ private applyMapCameraToSystem;
24586
25159
  private handleMoveEnd;
24587
25160
  private handleError;
24588
25161
  /**