@navaramap/three 0.0.8 → 0.1.1

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 (39) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +20 -8
  3. package/dist/assets/fontWorker-C5cHhkWQ.js +2 -0
  4. package/dist/assets/fontWorker-C5cHhkWQ.js.map +1 -0
  5. package/dist/assets/{index-DaejBdUz.js → index-VfUncKuS.js} +2 -2
  6. package/dist/assets/index-VfUncKuS.js.map +1 -0
  7. package/dist/assets/{navara_wasm_font_worker_bg-CSmoDs_Q.wasm → navara_wasm_font_worker_bg-CKqHBoCR.wasm} +0 -0
  8. package/dist/assets/{navara_wasm_worker_bg-C1dUd_Nk.wasm → navara_wasm_worker_bg-CT26EH41.wasm} +0 -0
  9. package/dist/index.d.ts +298 -54
  10. package/dist/index.js +1569 -1396
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.umd.cjs +90 -69
  13. package/dist/index.umd.cjs.map +1 -1
  14. package/package.json +12 -12
  15. package/src/core/BaseDesc.ts +25 -1
  16. package/src/core/MeshDesc.test.ts +6 -8
  17. package/src/core/MeshDesc.ts +4 -6
  18. package/src/evaluations/FeatureEvaluator.ts +17 -10
  19. package/src/event/feature.ts +15 -2
  20. package/src/event/features/billboard.test.ts +62 -0
  21. package/src/event/features/billboard.ts +4 -2
  22. package/src/index.ts +266 -98
  23. package/src/material/enhancer/model/modelBaseEnhancer/shader.ts +2 -2
  24. package/src/material/enhancer/polygon/polygonBaseEnhancer/shader.ts +2 -2
  25. package/src/material/macro/tileShader.ts +12 -2
  26. package/src/mesh/polyline.ts +32 -4
  27. package/src/mesh/sdfText/batchedSdfText.test.ts +65 -0
  28. package/src/mesh/sdfText/batchedSdfText.ts +121 -43
  29. package/src/mesh/sprite/instancedSprite.ts +173 -65
  30. package/src/pick/pickHelper.test.ts +389 -4
  31. package/src/pick/pickHelper.ts +212 -37
  32. package/src/plugins/AttributionPlugin/index.ts +1 -1
  33. package/src/renderOrder.ts +10 -0
  34. package/src/terrain/sampleTerrainMostDetailed.test.ts +6 -6
  35. package/src/terrain/sampleTerrainMostDetailed.ts +7 -5
  36. package/src/type/index.ts +22 -1
  37. package/dist/assets/fontWorker-CkLGtrXf.js +0 -2
  38. package/dist/assets/fontWorker-CkLGtrXf.js.map +0 -1
  39. package/dist/assets/index-DaejBdUz.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -798,12 +798,25 @@ export declare abstract class BaseDesc<Config extends BaseDescConfig = BaseDescC
798
798
  /** The underlying Three.js instance. */
799
799
  protected _instance: Instance | undefined;
800
800
  private _visible?;
801
+ private _destroyed;
801
802
  constructor(view: ThreeView, ctx: ViewContext, config?: Config);
802
803
  /**
803
804
  * Called when the this class is added to the scene. Override this to create the Three.js objects.
804
805
  * This is where you should initialize `this._instance` and add it to the appropriate scene.
805
- */
806
- abstract onCreate(): void;
806
+ *
807
+ * May return a promise: a descriptor whose implementation loads lazily
808
+ * (e.g. an `await import(...)` of a heavy renderer dependency) can be
809
+ * `async`, awaiting the module before delegating to `super.onCreate()`
810
+ * (after checking {@link destroyed}). `addMesh`/`addLight`/`addEffect`
811
+ * still return their handle synchronously; the instance appears once the
812
+ * promise settles, and a rejection is reported through the descriptor's
813
+ * `error` event (when it declares one). Handle calls issued while the
814
+ * promise is pending are safe: `update()`/`visible` store their fields
815
+ * without touching the missing instance (the deferred `super.onCreate()`
816
+ * applies them), and per-frame/resize hooks are wired only after creation
817
+ * completes.
818
+ */
819
+ abstract onCreate(): void | Promise<void>;
807
820
  /**
808
821
  * Called when the configuration is updated via `BaseHandle.update()`.
809
822
  * Override this to handle custom configuration updates.
@@ -816,6 +829,12 @@ export declare abstract class BaseDesc<Config extends BaseDescConfig = BaseDescC
816
829
  * Override this to clean up resources. Remember to call `super.onDestroy()`.
817
830
  */
818
831
  onDestroy(): void;
832
+ /**
833
+ * True once {@link onDestroy} has run. An async {@link onCreate} (and the
834
+ * hook wiring that waits on it) checks this after its awaited module
835
+ * resolves, so a descriptor deleted mid-load creates nothing.
836
+ */
837
+ get destroyed(): boolean;
819
838
  /**
820
839
  * Gets whether this is currently visible.
821
840
  */
@@ -995,8 +1014,15 @@ export declare class BatchedSdfTextMesh extends InstancedMesh<Object3D> implemen
995
1014
  private _transform;
996
1015
  /** Labels in slot order — `_labels[slot]` is also the declutter handle map. */
997
1016
  private _labels;
998
- /** Sparse batchIndex → label; labels are created on first per-feature touch. */
999
- private _labelByIndex;
1017
+ /** Sparse anchor slot → label; labels are created on first per-feature touch. */
1018
+ private _labelByInstance;
1019
+ /**
1020
+ * Feature (batch) index → this feature's anchor slots. A feature owns
1021
+ * multiple anchors for MultiPoint geometry and for labels derived from
1022
+ * line/polygon vertices via `geometryTypes`, so per-feature styling must fan
1023
+ * out to all of them. `null` means anchors and features are 1:1.
1024
+ */
1025
+ private _batchIndexToInstances;
1000
1026
  /** In-flight per-feature text preparations; see {@link whenLabelsSettled}. */
1001
1027
  private _pendingTextPrepares;
1002
1028
  private _glyphs;
@@ -1104,9 +1130,20 @@ export declare class BatchedSdfTextMesh extends InstancedMesh<Object3D> implemen
1104
1130
  onAfterPicking(): void;
1105
1131
  getRenderable(): Object3D;
1106
1132
  private extractPositions;
1133
+ /**
1134
+ * Group anchor slots by their feature's batch index from the geometry's
1135
+ * per-anchor `batch_index` buffer. The u32 view is consumed synchronously —
1136
+ * other wasm calls may detach views, so it must not be stored. An identity
1137
+ * mapping (every feature owns exactly one anchor, the common MVT case) skips
1138
+ * the map entirely.
1139
+ */
1140
+ private _rebuildBatchIndexMap;
1141
+ /** All anchor slots owned by the feature at `batchIndex`. */
1142
+ private _instancesOfBatchIndex;
1107
1143
  _update(m: TextMesh, needRender?: () => void): Promise<void>;
1108
1144
  private _applyUpdate;
1109
1145
  setTextByBatchIndex(batchIndex: number, text: string): void;
1146
+ private _setTextByInstance;
1110
1147
  /** Kick off async font preparation for `text`, then lay it out — unless a
1111
1148
  * newer text supersedes it while the fonts load. */
1112
1149
  private _prepareAndApply;
@@ -1137,6 +1174,20 @@ declare class BatchPropResult {
1137
1174
  private constructor();
1138
1175
  free(): void;
1139
1176
  [Symbol.dispose](): void;
1177
+ /**
1178
+ * The picked feature's canonical global batch id (its first instance's
1179
+ * id). A picked instance of a multi-instance feature (e.g. MultiPoint)
1180
+ * carries its own id, while styling APIs report the canonical one, so
1181
+ * consumers correlate picks through this field.
1182
+ */
1183
+ get batchId(): number | undefined;
1184
+ /**
1185
+ * The picked feature's canonical global batch id (its first instance's
1186
+ * id). A picked instance of a multi-instance feature (e.g. MultiPoint)
1187
+ * carries its own id, while styling APIs report the canonical one, so
1188
+ * consumers correlate picks through this field.
1189
+ */
1190
+ set batchId(value: number | null | undefined);
1140
1191
  get layerId(): string | undefined;
1141
1192
  set layerId(value: string | null | undefined);
1142
1193
  properties: any;
@@ -1226,6 +1277,18 @@ declare class BillboardMaterial {
1226
1277
  * Emissive glow intensity (default: 0.3 when Bloom enabled)
1227
1278
  */
1228
1279
  set emissiveIntensity(value: number | null | undefined);
1280
+ /**
1281
+ * Source geometry types this appearance consumes: `"point"`, `"line"`,
1282
+ * `"polygon"`. Defaults to `["point"]`; adding `"line"`/`"polygon"` also
1283
+ * emits a billboard per line-string / polygon-ring vertex.
1284
+ */
1285
+ get geometryTypes(): string[] | undefined;
1286
+ /**
1287
+ * Source geometry types this appearance consumes: `"point"`, `"line"`,
1288
+ * `"polygon"`. Defaults to `["point"]`; adding `"line"`/`"polygon"` also
1289
+ * emits a billboard per line-string / polygon-ring vertex.
1290
+ */
1291
+ set geometryTypes(value: string[] | null | undefined);
1229
1292
  get height(): number | undefined;
1230
1293
  set height(value: number | null | undefined);
1231
1294
  /**
@@ -1643,6 +1706,14 @@ declare class CameraStatus {
1643
1706
 
1644
1707
  export { CascadedShadowMaps }
1645
1708
 
1709
+ /**
1710
+ * Travel tolerance in CSS pixels between pointerdown and pointerup to count as a click.
1711
+ * Follows Cesium's `_clickPixelTolerance` (MapLibre uses 3px).
1712
+ * ref: https://github.com/CesiumGS/cesium/blob/9fda7ab97a762e40c74b1d0e1814c98a2de43337/packages/engine/Source/Core/ScreenSpaceEventHandler.js#L1012
1713
+ * ref: https://github.com/maplibre/maplibre-gl-js/blob/3a0a4f795fef5b2a29034d71833475589c344eaf/src/ui/map.ts#L542
1714
+ */
1715
+ export declare const CLICK_PIXEL_TOLERANCE = 5;
1716
+
1646
1717
  export declare const CLOUD_LOCAL_WEATHER_URL: string;
1647
1718
 
1648
1719
  export declare const CLOUD_SHAPE_DETAIL_URL: string;
@@ -1994,6 +2065,14 @@ declare type ConvertColorFields<T> = {
1994
2065
  [K in keyof T]: K extends `${string}Color` | "color" ? T[K] extends number | undefined ? Color | undefined : T[K] extends number ? Color : T[K] : T[K] extends object | undefined ? ConvertColorFields<T[K]> | Extract<T[K], undefined> : T[K];
1995
2066
  };
1996
2067
 
2068
+ /**
2069
+ * Helper type to narrow the generated `geometryTypes?: string[]` material
2070
+ * fields to the {@link SourceGeometryType} literal union.
2071
+ */
2072
+ declare type ConvertGeometryTypeFields<T> = {
2073
+ [K in keyof T]: K extends "geometryTypes" ? SourceGeometryType[] | Extract<T[K], undefined> : T[K] extends object | undefined ? ConvertGeometryTypeFields<T[K]> | Extract<T[K], undefined> : T[K];
2074
+ };
2075
+
1997
2076
  /**
1998
2077
  * Converts screen coordinates to world coordinates by raycasting against the WGS84 ellipsoid.
1999
2078
  * @param window - Window configuration with width, height, and pixelRatio
@@ -3353,11 +3432,13 @@ declare class ElevationHeatmapMaterial {
3353
3432
  * Wrapper class for geodesic calculations on an ellipsoid surface.
3354
3433
  * Precomputes common variables for optimization when instantiated.
3355
3434
  *
3435
+ * All latitudes/longitudes and headings are in **degrees**.
3436
+ *
3356
3437
  * @example
3357
3438
  * ```typescript
3358
3439
  * const geodesic = new EllipsoidGeodesic(
3359
- * { lat: 0.5, lng: 2.0, height: 0 },
3360
- * { lat: 0.6, lng: 2.1, height: 0 }
3440
+ * { lat: 35.6812, lng: 139.7671, height: 0 },
3441
+ * { lat: 34.7025, lng: 135.4959, height: 0 }
3361
3442
  * );
3362
3443
  *
3363
3444
  * console.log(geodesic.distance);
@@ -3371,8 +3452,8 @@ export declare class EllipsoidGeodesic {
3371
3452
  private _raw;
3372
3453
  /**
3373
3454
  * Create a new geodesic between two points on the ellipsoid.
3374
- * @param start - Start point in geodetic coordinates (lat/lng in radians)
3375
- * @param end - End point in geodetic coordinates (lat/lng in radians)
3455
+ * @param start - Start point in geodetic coordinates (lat/lng in degrees)
3456
+ * @param end - End point in geodetic coordinates (lat/lng in degrees)
3376
3457
  */
3377
3458
  constructor(start: LatLngHeight, end: LatLngHeight);
3378
3459
  /** Distance in meters between start and end points */
@@ -3384,24 +3465,24 @@ export declare class EllipsoidGeodesic {
3384
3465
  * unreliable solution.
3385
3466
  */
3386
3467
  get converged(): boolean;
3387
- /** Heading at the start point in radians */
3468
+ /** Heading at the start point in degrees */
3388
3469
  get startHeading(): number;
3389
- /** Heading at the end point in radians */
3470
+ /** Heading at the end point in degrees */
3390
3471
  get endHeading(): number;
3391
- /** Start point in geodetic coordinates */
3472
+ /** Start point in geodetic coordinates (lat/lng in degrees) */
3392
3473
  get start(): LatLngHeight;
3393
- /** End point in geodetic coordinates */
3474
+ /** End point in geodetic coordinates (lat/lng in degrees) */
3394
3475
  get end(): LatLngHeight;
3395
3476
  /**
3396
3477
  * Interpolate points along the geodesic path.
3397
3478
  * @param granularity - Distance between interpolated points in meters (optional)
3398
- * @returns Array of interpolated points in geodetic coordinates
3479
+ * @returns Array of interpolated points in geodetic coordinates (lat/lng in degrees)
3399
3480
  */
3400
3481
  interpolatePoints(granularity?: number): LatLngHeight[];
3401
3482
  /**
3402
3483
  * Interpolate a point at a specific distance along the geodesic path.
3403
3484
  * @param distance - Distance from start point in meters
3404
- * @returns Interpolated point in geodetic coordinates
3485
+ * @returns Interpolated point in geodetic coordinates (lat/lng in degrees)
3405
3486
  */
3406
3487
  interpolateDistance(distance: number): LatLngHeight;
3407
3488
  /**
@@ -3854,6 +3935,11 @@ declare type FeatureHandler = {
3854
3935
  * Information about a feature batch, passed to evaluation callbacks.
3855
3936
  */
3856
3937
  export declare type FeatureInfo = {
3938
+ /**
3939
+ * The feature's canonical global batch id (its first instance's id when a
3940
+ * feature spans several instances, e.g. MultiPoint). Pick events report the
3941
+ * same canonical id, so picks and evaluations correlate through this field.
3942
+ */
3857
3943
  batchId: number;
3858
3944
  properties: Record<string, unknown> | undefined;
3859
3945
  layerId: LayerId | undefined;
@@ -4115,14 +4201,14 @@ export declare type GeodeticPlacement = {
4115
4201
 
4116
4202
  /**
4117
4203
  * Computes the surface normal vector at a geodetic position on the WGS84 ellipsoid.
4118
- * @param lle - Geodetic coordinates (lng in radians, lat in radians, height in meters)
4204
+ * @param lle - Geodetic coordinates (lng in degrees, lat in degrees, height in meters)
4119
4205
  * @returns Unit normal vector pointing outward from the ellipsoid surface
4120
4206
  */
4121
4207
  export declare function geodeticSurfaceNormal(lle: LatLngHeight): Vector3;
4122
4208
 
4123
4209
  /**
4124
4210
  * Converts geodetic coordinates (longitude, latitude, height) to a Cartesian Vector3 in ECEF coordinates.
4125
- * @param lle - Geodetic coordinates (lng in radians, lat in radians, height in meters)
4211
+ * @param lle - Geodetic coordinates (lng in degrees, lat in degrees, height in meters)
4126
4212
  * @returns Cartesian Vector3 in Earth-Centered Earth-Fixed (ECEF) coordinates
4127
4213
  */
4128
4214
  export declare function geodeticToVector3(lle: LatLngHeight): Vector3;
@@ -4448,7 +4534,6 @@ declare type HandleEvent = {
4448
4534
  * engines differ in which axis they treat as an asset's front, so a model
4449
4535
  * ported from one may need a multiple of 90° added to its heading.
4450
4536
  *
4451
- * NOTE: unlike {@link geodeticToVector3} and the other helpers in this module,
4452
4537
  * `lng`/`lat` and all angles here are in **degrees**, matching
4453
4538
  * `setCamera` and the `geodetic` mesh Descriptor field.
4454
4539
  *
@@ -4902,7 +4987,15 @@ export declare type InstancedSpriteMaterialProps = {
4902
4987
 
4903
4988
  export declare class InstancedSpriteMesh extends Mesh_2<BufferGeometry, Material | Material[], CustomObject3DEventMap> implements PickableMesh, DeclutterParticipant {
4904
4989
  private _geometryType;
4905
- private _batchIdToInstance;
4990
+ /**
4991
+ * Feature (batch) index → this feature's instance ids. A feature owns
4992
+ * multiple instances for MultiPoint geometry and for points derived from
4993
+ * line/polygon vertices via `geometryTypes`, so per-feature styling must
4994
+ * fan out to all of them. `null` means instances and features are 1:1.
4995
+ */
4996
+ private _batchIndexToInstances;
4997
+ /** Instance count of the current geometry; bounds the identity fallback. */
4998
+ private _instanceCount;
4906
4999
  private _initialColor;
4907
5000
  private _initialHeight;
4908
5001
  private _initialSize;
@@ -4995,6 +5088,15 @@ export declare class InstancedSpriteMesh extends Mesh_2<BufferGeometry, Material
4995
5088
  * hasn't been overridden per-feature via setFeatureImageByBatchId.
4996
5089
  */
4997
5090
  private _setDefaultImage;
5091
+ /**
5092
+ * An instance's atlas rect changed. The rect drives the quad's aspect and
5093
+ * whether the instance draws at all, so the declutter bounds computed before
5094
+ * the image landed are stale — and because packs resolve long after the
5095
+ * frame that requested them, the view has usually gone idle by now. Without
5096
+ * the render request the page keeps showing the pre-image state until the
5097
+ * next camera move.
5098
+ */
5099
+ private _onAtlasRectsChanged;
4998
5100
  onBeforePicking(): void;
4999
5101
  onAfterPicking(): void;
5000
5102
  getRenderable(): Object3D;
@@ -5002,10 +5104,21 @@ export declare class InstancedSpriteMesh extends Mesh_2<BufferGeometry, Material
5002
5104
  * Get the enhancer, throwing if not initialized.
5003
5105
  */
5004
5106
  private getEnhancer;
5005
- setFeatureColorByBatchId(batchId: number, color: Color_3): void;
5006
- setFeatureShowByBatchId(batchId: number, rawVisible: boolean): void;
5007
- setFeatureOpacityByBatchId(batchId: number, opacity: number): void;
5008
- setFeatureHeightByBatchId(batchId: number, height: number): void;
5107
+ /**
5108
+ * Group instances by their feature's batch index from the geometry's
5109
+ * per-instance `batch_index` buffer. The u32 view is consumed synchronously,
5110
+ * so other wasm calls may detach views, so it must not be stored. The handle
5111
+ * stays owned by the ECS geometry, whose destroy path frees it
5112
+ * (`remove_from_buf`). An identity mapping (every feature owns exactly one
5113
+ * instance, the common case) skips the map entirely.
5114
+ */
5115
+ private _rebuildBatchIndexMap;
5116
+ /** All instances owned by the feature at `batchIndex`; empty when unknown. */
5117
+ private instancesOfBatchIndex;
5118
+ setFeatureColorByBatchIndex(batchIndex: number, color: Color_3): void;
5119
+ setFeatureShowByBatchIndex(batchIndex: number, rawVisible: boolean): void;
5120
+ setFeatureOpacityByBatchIndex(batchIndex: number, opacity: number): void;
5121
+ setFeatureHeightByBatchIndex(batchIndex: number, height: number): void;
5009
5122
  /**
5010
5123
  * Set one instance's declutter fade target; the attribute animates toward
5011
5124
  * it in {@link stepDeclutterFade}. Deliberately separate from the `show`
@@ -5018,8 +5131,8 @@ export declare class InstancedSpriteMesh extends Mesh_2<BufferGeometry, Material
5018
5131
  * layer-level `declutterPriority` for this instance. Driven by the feature
5019
5132
  * evaluator.
5020
5133
  */
5021
- setFeatureDeclutterPriorityByBatchId(batchId: number, priority: number): void;
5022
- setFeatureSizeByBatchId(batchId: number, size: number): void;
5134
+ setFeatureDeclutterPriorityByBatchIndex(batchIndex: number, priority: number): void;
5135
+ setFeatureSizeByBatchIndex(batchIndex: number, size: number): void;
5023
5136
  /**
5024
5137
  * Give one feature its own image, packed into this mesh's texture atlas.
5025
5138
  * Loads are deduplicated by URL, so styling many features with few distinct
@@ -5028,7 +5141,7 @@ export declare class InstancedSpriteMesh extends Mesh_2<BufferGeometry, Material
5028
5141
  * reverts the feature to the material's default image. No-op for
5029
5142
  * non-billboard (point) meshes.
5030
5143
  */
5031
- setFeatureImageByBatchId(batchId: number, url: string | null | undefined): Promise<void>;
5144
+ setFeatureImageByBatchIndex(batchIndex: number, url: string | null | undefined): Promise<void>;
5032
5145
  dispose(): void;
5033
5146
  }
5034
5147
 
@@ -5071,8 +5184,12 @@ export declare type LabelLayout = {
5071
5184
  maxYEm: number;
5072
5185
  };
5073
5186
 
5187
+ /** Geodetic position: `lat`/`lng` in **degrees**. */
5074
5188
  export declare type LatLng = Omit<LatLngHeight, "height">;
5075
5189
 
5190
+ /**
5191
+ * Geodetic position: `lat`/`lng` in **degrees**, `height` in meters.
5192
+ */
5076
5193
  export declare type LatLngHeight = Required<NormalizeWASMClass<LLE>>;
5077
5194
 
5078
5195
  /**
@@ -5403,12 +5520,13 @@ export declare type LUT = readonly (ColorTuple | Color_2)[];
5403
5520
  export declare const MAPBOX_ELEVATION_DECODER: () => ElevationDecoder;
5404
5521
 
5405
5522
  /**
5406
- * Mouse event extended with map coordinates at the event location.
5523
+ * Pointer event extended with map coordinates at the event location.
5524
+ * Fired for every input type; `pointerType` tells them apart.
5407
5525
  */
5408
- export declare type MapMouseEvent = {
5409
- /** World coordinates (ECEF) at the mouse position on the globe surface. */
5526
+ export declare type MapPointerEvent = {
5527
+ /** World coordinates (ECEF) at the pointer position on the globe surface. */
5410
5528
  map: XYZ;
5411
- } & MouseEvent;
5529
+ } & PointerEvent;
5412
5530
 
5413
5531
  /**
5414
5532
  * Core abstraction: Material enhancer with shader type constraints
@@ -6610,7 +6728,11 @@ export declare type Options = {
6610
6728
  atmosphere?: AtmosphereOptions;
6611
6729
  /** Background color of the scene. Defaults to dark color (0x0a0a0f). */
6612
6730
  backgroundColor?: Color_2;
6613
- /** Feature picking configuration. */
6731
+ /**
6732
+ * Feature picking configuration (default: true). Enables the `featureClick`
6733
+ * event (click or touch tap) and the `featureHover` / `featureEnter` /
6734
+ * `featureLeave` events (pointer hover).
6735
+ */
6614
6736
  picking?: boolean;
6615
6737
  /** When true, renders every frame. When false, renders only on changes or when forceUpdate() is called. */
6616
6738
  animation?: boolean;
@@ -6795,6 +6917,13 @@ export declare class Pass<P extends Pass_2, E extends Effect_2 | unknown, O exte
6795
6917
 
6796
6918
  export declare type PassKey = keyof Pick<Scenes, "opaque" | "transparent" | "mrt" | "skyEnvMap" | "draped">;
6797
6919
 
6920
+ /**
6921
+ * Pick search radius in CSS pixels around the pointer. The pick reads a
6922
+ * (2r+1)² window and takes the non-zero batch id closest to its center, so
6923
+ * small features (points, thin lines) don't demand pixel-perfect aim.
6924
+ */
6925
+ export declare const PICK_RADIUS = 3;
6926
+
6798
6927
  /**
6799
6928
  * Turnkey {@link PickableMesh} implementation for `InstancedMesh`.
6800
6929
  *
@@ -7033,6 +7162,18 @@ declare class PointMaterial {
7033
7162
  * Emissive glow intensity (default: 0.3 when Bloom enabled)
7034
7163
  */
7035
7164
  set emissiveIntensity(value: number | null | undefined);
7165
+ /**
7166
+ * Source geometry types this appearance consumes: `"point"`, `"line"`,
7167
+ * `"polygon"`. Defaults to `["point"]`; adding `"line"`/`"polygon"` also
7168
+ * emits a point per line-string / polygon-ring vertex.
7169
+ */
7170
+ get geometryTypes(): string[] | undefined;
7171
+ /**
7172
+ * Source geometry types this appearance consumes: `"point"`, `"line"`,
7173
+ * `"polygon"`. Defaults to `["point"]`; adding `"line"`/`"polygon"` also
7174
+ * emits a point per line-string / polygon-ring vertex.
7175
+ */
7176
+ set geometryTypes(value: string[] | null | undefined);
7036
7177
  get height(): number | undefined;
7037
7178
  set height(value: number | null | undefined);
7038
7179
  /**
@@ -7751,6 +7892,22 @@ declare class PolylineMaterial {
7751
7892
  * Emissive glow intensity (default: 0.3 when Bloom enabled)
7752
7893
  */
7753
7894
  set emissiveIntensity(value: number | null | undefined);
7895
+ /**
7896
+ * Source geometry types this appearance consumes: `"line"`, `"polygon"`.
7897
+ * Defaults to `["line"]`; adding `"polygon"` also renders polygon boundary
7898
+ * rings (outer ring and holes) as closed polylines at the ring's base
7899
+ * height. Extruded-polygon edges stay the polygon material's `outline`
7900
+ * feature.
7901
+ */
7902
+ get geometryTypes(): string[] | undefined;
7903
+ /**
7904
+ * Source geometry types this appearance consumes: `"line"`, `"polygon"`.
7905
+ * Defaults to `["line"]`; adding `"polygon"` also renders polygon boundary
7906
+ * rings (outer ring and holes) as closed polylines at the ring's base
7907
+ * height. Extruded-polygon edges stay the polygon material's `outline`
7908
+ * feature.
7909
+ */
7910
+ set geometryTypes(value: string[] | null | undefined);
7754
7911
  get height(): number | undefined;
7755
7912
  set height(value: number | null | undefined);
7756
7913
  /**
@@ -7858,6 +8015,8 @@ export declare class PolylineMesh extends BatchedFeatureMesh<BufferGeometry<Attr
7858
8015
  get emissiveColor(): number;
7859
8016
  get emissiveIntensity(): number;
7860
8017
  get effectIdsMask(): number;
8018
+ /** Visible stroke width to restore after a pick-pass width bump. */
8019
+ private _pickSavedWidth?;
7861
8020
  onBeforePicking(pickingCoord?: Vector2): void;
7862
8021
  onAfterPicking(): void;
7863
8022
  _getDefaultBatchAttributeValues(): DefaultBatchAttributeValues;
@@ -8466,9 +8625,9 @@ export declare type RTEUserData = {
8466
8625
  };
8467
8626
 
8468
8627
  export declare type SampledTerrainPosition = {
8469
- /** Latitude in radians, echoed from the input. */
8628
+ /** Latitude in degrees, echoed from the input. */
8470
8629
  lat: number;
8471
- /** Longitude in radians, echoed from the input. */
8630
+ /** Longitude in degrees, echoed from the input. */
8472
8631
  lng: number;
8473
8632
  /**
8474
8633
  * Terrain height in meters, or `undefined` when no tile covering the
@@ -9061,6 +9220,15 @@ declare class SourceDescription_2 {
9061
9220
  set type(value: string | null | undefined);
9062
9221
  }
9063
9222
 
9223
+ /**
9224
+ * Source geometry categories a vector appearance can consume via its
9225
+ * `geometryTypes` option. Each appearance defaults to its native geometry only
9226
+ * (`"point"` for point/billboard/text, `"line"` for polyline); adding entries
9227
+ * derives extra representations, e.g. `polyline: { geometryTypes: ["line",
9228
+ * "polygon"] }` also renders polygon boundary rings as polylines.
9229
+ */
9230
+ export declare type SourceGeometryType = "point" | "line" | "polygon";
9231
+
9064
9232
  export declare type SourceLayerBase<Layer extends {
9065
9233
  source?: string | undefined;
9066
9234
  }> = Omit<Layer, "source"> & {
@@ -9105,6 +9273,13 @@ declare type SupportedMaterial_6 = ShaderMaterial;
9105
9273
  */
9106
9274
  declare type SupportedMaterial_7 = ShaderMaterial;
9107
9275
 
9276
+ /**
9277
+ * Travel tolerance for touch taps. Finger contact jitters far more than a
9278
+ * mouse, so follows MapLibre's tap `MAX_DIST` instead.
9279
+ * ref: https://github.com/maplibre/maplibre-gl-js/blob/3a0a4f795fef5b2a29034d71833475589c344eaf/src/ui/handler/tap_recognizer.ts
9280
+ */
9281
+ export declare const TAP_PIXEL_TOLERANCE = 30;
9282
+
9108
9283
  /**
9109
9284
  * Temporary DEM state while waiting for edge updates.
9110
9285
  * Stores only the WASM buffer handle and received edge strips — NOT the full padded DEM.
@@ -9300,6 +9475,18 @@ declare class TextMaterial {
9300
9475
  * is specified.
9301
9476
  */
9302
9477
  set font(value: string | null | undefined);
9478
+ /**
9479
+ * Source geometry types this appearance consumes: `"point"`, `"line"`,
9480
+ * `"polygon"`. Defaults to `["point"]`; adding `"line"`/`"polygon"` also
9481
+ * emits a label per line-string / polygon-ring vertex.
9482
+ */
9483
+ get geometryTypes(): string[] | undefined;
9484
+ /**
9485
+ * Source geometry types this appearance consumes: `"point"`, `"line"`,
9486
+ * `"polygon"`. Defaults to `["point"]`; adding `"line"`/`"polygon"` also
9487
+ * emits a label per line-string / polygon-ring vertex.
9488
+ */
9489
+ set geometryTypes(value: string[] | null | undefined);
9303
9490
  get height(): number | undefined;
9304
9491
  set height(value: number | null | undefined);
9305
9492
  /**
@@ -9548,6 +9735,8 @@ declare class ThreeView<D extends Descriptions = EmptyDescriptions> extends Even
9548
9735
  /** Pending `flyTo` promises keyed by flight id, settled by
9549
9736
  * `camera_flight_ended` events from the engine. */
9550
9737
  private _pendingFlights;
9738
+ /** Currently hovered feature, used to diff-synthesize hover events. */
9739
+ private _hoveredFeature;
9551
9740
  private _meshes;
9552
9741
  private _abortControllers;
9553
9742
  private _workerPoolPromises;
@@ -9625,9 +9814,9 @@ declare class ThreeView<D extends Descriptions = EmptyDescriptions> extends Even
9625
9814
  set lit(value: boolean);
9626
9815
  constructor(options?: Options);
9627
9816
  /**
9628
- * Convert a mouse event to a MapMouseEvent by adding map coordinates
9817
+ * Extend a pointer event with map coordinates at its location
9629
9818
  */
9630
- private convertMouseEventToMapEvent;
9819
+ private convertToMapEvent;
9631
9820
  private initializeRenderPass;
9632
9821
  private get renderPass();
9633
9822
  /** The camera controller that manages view position, orientation, and projection. */
@@ -9777,6 +9966,18 @@ declare class ThreeView<D extends Descriptions = EmptyDescriptions> extends Even
9777
9966
  * @returns A Source handle for referencing, updating, and deleting the source
9778
9967
  */
9779
9968
  addSource(s: SourceDescription): Source;
9969
+ /**
9970
+ * Tracks a possibly-async `onCreate()` (see `BaseDesc.onCreate`): the
9971
+ * `add*` methods still return their handle synchronously, the descriptor's
9972
+ * instance appears when the promise settles, and a rejection is logged and
9973
+ * reported through the descriptor's `error` event (when it declares one).
9974
+ *
9975
+ * `wire` binds the descriptor's lifecycle hooks (per-frame `update`,
9976
+ * `onResize`, `needsUpdate`). It runs immediately for a synchronous
9977
+ * creation, and only after the promise resolves for an async one — the
9978
+ * hooks must not fire while the descriptor has no instance yet.
9979
+ */
9980
+ private _trackAsyncCreate;
9780
9981
  /**
9781
9982
  * Adds a 3D mesh to the scene.
9782
9983
  * The mesh kind is determined by the nested key (e.g., `{ box: { width: 200 } }`).
@@ -10006,7 +10207,7 @@ declare class ThreeView<D extends Descriptions = EmptyDescriptions> extends Even
10006
10207
  cameraFreeLook(enabled: boolean, target?: LatLngHeight): void;
10007
10208
  /**
10008
10209
  * Samples the terrain height at a given geodetic position synchronously.
10009
- * @param pos - Geodetic position (lat in radians, lng in radians)
10210
+ * @param pos - Geodetic position (lat in degrees, lng in degrees)
10010
10211
  * @returns Terrain height in meters, or undefined if terrain data not loaded
10011
10212
  */
10012
10213
  sampleTerrainHeight(pos: LatLng): number | undefined;
@@ -10024,14 +10225,14 @@ declare class ThreeView<D extends Descriptions = EmptyDescriptions> extends Even
10024
10225
  * sampled.
10025
10226
  *
10026
10227
  * @param source - A registered terrain source (handle or id)
10027
- * @param positions - Geodetic positions (lat/lng in radians)
10228
+ * @param positions - Geodetic positions (lat/lng in degrees)
10028
10229
  * @param options - Optional abort signal and fixed-level sampling
10029
10230
  * @returns One result per input position, in the same order
10030
10231
  */
10031
10232
  sampleTerrainMostDetailed(source: SourceRef, positions: LatLng[], options?: SampleTerrainOptions): Promise<SampledTerrainPosition[]>;
10032
10233
  /**
10033
10234
  * Observes terrain height changes at a position. Callback is invoked each time terrain data updates.
10034
- * @param pos - Geodetic position to observe (lat in radians, lng in radians)
10235
+ * @param pos - Geodetic position to observe (lat in degrees, lng in degrees)
10035
10236
  * @param cb - Callback function receiving the terrain height in meters
10036
10237
  * @returns Cleanup function to stop observing
10037
10238
  */
@@ -10050,11 +10251,22 @@ declare class ThreeView<D extends Descriptions = EmptyDescriptions> extends Even
10050
10251
  private _startMainLoop;
10051
10252
  private _getCanvasSize;
10052
10253
  private _handleResize;
10254
+ /**
10255
+ * Resolves a picked batch ID into feature information via the engine's
10256
+ * property store.
10257
+ */
10258
+ private resolvePickedFeature;
10053
10259
  /**
10054
10260
  * Handles pick events and emits the picked feature information.
10055
10261
  * @param pickArr - Array of picked batch IDs
10056
10262
  */
10057
10263
  private onPick;
10264
+ /**
10265
+ * Handles hover pick results and synthesizes `featureHover` / `featureEnter` /
10266
+ * `featureLeave` events by diffing against the previously hovered feature.
10267
+ * @param pickArr - Array of picked batch IDs
10268
+ */
10269
+ private onHoverPick;
10058
10270
  /**
10059
10271
  * Gets whether continuous animation mode is enabled.
10060
10272
  */
@@ -10063,6 +10275,11 @@ declare class ThreeView<D extends Descriptions = EmptyDescriptions> extends Even
10063
10275
  * Sets whether to render every frame continuously (true) or only on changes (false).
10064
10276
  */
10065
10277
  set animation(v: boolean);
10278
+ /**
10279
+ * Gets the canvas element the view renders into. Useful for styling,
10280
+ * e.g. switching the cursor from a `featureHover` event listener.
10281
+ */
10282
+ get canvas(): HTMLCanvasElement;
10066
10283
  /**
10067
10284
  * Gets the current screen size in pixels.
10068
10285
  */
@@ -10560,6 +10777,9 @@ declare class TileXYZ {
10560
10777
  z: number;
10561
10778
  }
10562
10779
 
10780
+ /** Pick search radius for touch: fingertips land less precisely than a cursor. */
10781
+ export declare const TOUCH_PICK_RADIUS = 10;
10782
+
10563
10783
  declare type TransactionCallbackParams<AddKey extends JsEventsKey, RemoveKey extends JsEventsKey, ChangeKey extends JsEventsKey> = {
10564
10784
  type: "add";
10565
10785
  event: GetJsEventValue<AddKey>;
@@ -10903,7 +11123,7 @@ export declare class UnknownTypeError extends Error {
10903
11123
  /**
10904
11124
  * Converts a Cartesian Vector3 in ECEF coordinates to geodetic coordinates.
10905
11125
  * @param xyz - Cartesian Vector3 in Earth-Centered Earth-Fixed (ECEF) coordinates
10906
- * @returns Geodetic coordinates (lng in radians, lat in radians, height in meters)
11126
+ * @returns Geodetic coordinates (lng in degrees, lat in degrees, height in meters)
10907
11127
  */
10908
11128
  export declare function vector3ToGeodetic(xyz: Vector3): LatLngHeight;
10909
11129
 
@@ -10913,9 +11133,9 @@ export declare class UnknownTypeError extends Error {
10913
11133
  */
10914
11134
  export declare type VectorLayer = SourceLayerBase<VectorLayerBase>;
10915
11135
 
10916
- declare type VectorLayerBase = WithColorSupport<Layer_2<VectorLayerDescription & {
11136
+ declare type VectorLayerBase = WithColorSupport<ConvertGeometryTypeFields<Layer_2<VectorLayerDescription & {
10917
11137
  type: "vector";
10918
- }>>;
11138
+ }>>>;
10919
11139
 
10920
11140
  /**
10921
11141
  * A `vector` layer references a `geojson` or `vector-tile` source and renders
@@ -11181,8 +11401,24 @@ export declare class UnknownTypeError extends Error {
11181
11401
  export declare type ViewEvents = {
11182
11402
  /** Emitted when the view is resized. Receives width and height in pixels. */
11183
11403
  resize: (w: number, h: number) => void;
11184
- /** Emitted when a feature is picked. Receives picked feature info or null. */
11185
- pick: (info: Nullable<PickedFeature>) => void;
11404
+ /**
11405
+ * Emitted when a feature is clicked or tapped (click-gesture GPU pick).
11406
+ * Receives the clicked feature, or null when empty space was clicked. For
11407
+ * raw click coordinates use the `click` event instead.
11408
+ */
11409
+ featureClick: (info: Nullable<PickedFeature>) => void;
11410
+ /**
11411
+ * Emitted when the hovered feature changes (hover picking). Receives
11412
+ * the newly hovered feature, or null when the pointer leaves all pickable
11413
+ * features. Hover picking runs a GPU pick per frame while the pointer
11414
+ * moves, and is active only while at least one `featureHover` /
11415
+ * `featureEnter` / `featureLeave` listener is registered.
11416
+ */
11417
+ featureHover: (info: Nullable<PickedFeature>) => void;
11418
+ /** Emitted when the pointer starts hovering a pickable feature. See `featureHover` for activation. */
11419
+ featureEnter: (info: PickedFeature) => void;
11420
+ /** Emitted when the pointer stops hovering the previously hovered feature. See `featureHover` for activation. */
11421
+ featureLeave: (info: PickedFeature) => void;
11186
11422
  /** Emitted when a layer event occurs. Receives event type, layer ID, and event arguments. */
11187
11423
  layer: <K extends keyof LayerEvent>(k: K, layerId: string, ...args: Parameters<LayerEvent[K]>) => void;
11188
11424
  /** Emitted before an update process happens. Receives `DOMHighResTimeStamp` as a timestamp. */
@@ -11195,18 +11431,26 @@ export declare class UnknownTypeError extends Error {
11195
11431
  postRender: (t: number) => void;
11196
11432
  /** @private Emitted when terrain height sampling completes. */
11197
11433
  _sample_terrain_height_received: (ev: TerrainHeightUpdatedEvent) => void;
11198
- /** Emitted on mouse down with map coordinates. */
11199
- mousedown: (event: MapMouseEvent) => void;
11200
- /** Emitted when mouse enters the canvas with map coordinates. */
11201
- mouseenter: (event: MapMouseEvent) => void;
11202
- /** Emitted when mouse leaves the canvas with map coordinates. */
11203
- mouseleave: (event: MapMouseEvent) => void;
11204
- /** Emitted on mouse move with map coordinates. */
11205
- mousemove: (event: MapMouseEvent) => void;
11206
- /** Emitted on mouse up with map coordinates. */
11207
- mouseup: (event: MapMouseEvent) => void;
11208
- /** Emitted on click with map coordinates. */
11209
- click: (event: MapMouseEvent) => void;
11434
+ /** Emitted on pointerdown with map coordinates, for every input type. */
11435
+ pointerdown: (event: MapPointerEvent) => void;
11436
+ /** Emitted when a pointer enters the canvas with map coordinates, for every input type. */
11437
+ pointerenter: (event: MapPointerEvent) => void;
11438
+ /** Emitted when a pointer leaves the canvas with map coordinates, for every input type. */
11439
+ pointerleave: (event: MapPointerEvent) => void;
11440
+ /** Emitted on pointermove with map coordinates, for every input type. */
11441
+ pointermove: (event: MapPointerEvent) => void;
11442
+ /** Emitted on pointerup with map coordinates, for every input type. */
11443
+ pointerup: (event: MapPointerEvent) => void;
11444
+ /** Emitted when the browser cancels an active pointer (e.g. a system gesture takes over). */
11445
+ pointercancel: (event: PointerEvent) => void;
11446
+ /**
11447
+ * Emitted on a click or touch tap with map coordinates: a primary-pointer
11448
+ * press and release within the travel tolerance
11449
+ * ({@link CLICK_PIXEL_TOLERANCE}, or {@link TAP_PIXEL_TOLERANCE} for
11450
+ * touch). Camera drags and pinches never fire it. `pointerType` tells the
11451
+ * input kinds apart.
11452
+ */
11453
+ click: (event: MapPointerEvent) => void;
11210
11454
  /** Emitted when the engine becomes idle (no Rust-side events for `idleThreshold` ms). */
11211
11455
  idle: () => void;
11212
11456
  };