@navaramap/three 0.1.0 → 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.
package/README.md CHANGED
@@ -11,8 +11,8 @@ Navara's answer to the trade-off is a tiered API. Capabilities are organized int
11
11
 
12
12
  Under the hood, Navara is a headless GIS core, independent of the rendering engine. The complex but reusable GIS logic (data parsing, geometry construction, and more) lives in Rust / WebAssembly, and drawing is delegated to libraries specialized in CG rendering. This package is the Three.js-based binding and the main entry point for building Navara applications. Its public API is `ThreeView` plus a declarative Source/Layer/Descriptor model.
13
13
 
14
- - 📖 **Documentation**: https://navara-docs.reearth.workers.dev/
15
- - 🌏 **Live examples**: https://navara-preview.reearth.workers.dev/
14
+ - 📖 **Documentation**: https://navara.world/docs/
15
+ - 🌏 **Live examples**: https://navara.world/examples/
16
16
 
17
17
  ## Install
18
18
 
@@ -64,7 +64,7 @@ view.attribution?.add([
64
64
  ]);
65
65
  ```
66
66
 
67
- See [What is Navara?](https://navara-docs.reearth.workers.dev/guides/introduction/what-is-navara/) for an overview and [Getting Started](https://navara-docs.reearth.workers.dev/guides/introduction/getting-started/) to build your first 3D map.
67
+ See [What is Navara?](https://navara.world/docs/guides/introduction/what-is-navara/) for an overview and [Getting Started](https://navara.world/docs/guides/introduction/getting-started/) to build your first 3D map.
68
68
 
69
69
  ## Related packages
70
70
 
@@ -75,7 +75,7 @@ See [What is Navara?](https://navara-docs.reearth.workers.dev/guides/introductio
75
75
 
76
76
  ## Documentation
77
77
 
78
- Full documentation, including every source/layer/material option and runnable examples, is at https://navara-docs.reearth.workers.dev/.
78
+ Full documentation, including every source/layer/material option and runnable examples, is at https://navara.world/docs/.
79
79
 
80
80
  ## License
81
81
 
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
  */
@@ -1687,6 +1706,14 @@ declare class CameraStatus {
1687
1706
 
1688
1707
  export { CascadedShadowMaps }
1689
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
+
1690
1717
  export declare const CLOUD_LOCAL_WEATHER_URL: string;
1691
1718
 
1692
1719
  export declare const CLOUD_SHAPE_DETAIL_URL: string;
@@ -5493,12 +5520,13 @@ export declare type LUT = readonly (ColorTuple | Color_2)[];
5493
5520
  export declare const MAPBOX_ELEVATION_DECODER: () => ElevationDecoder;
5494
5521
 
5495
5522
  /**
5496
- * 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.
5497
5525
  */
5498
- export declare type MapMouseEvent = {
5499
- /** 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. */
5500
5528
  map: XYZ;
5501
- } & MouseEvent;
5529
+ } & PointerEvent;
5502
5530
 
5503
5531
  /**
5504
5532
  * Core abstraction: Material enhancer with shader type constraints
@@ -6702,8 +6730,8 @@ export declare type Options = {
6702
6730
  backgroundColor?: Color_2;
6703
6731
  /**
6704
6732
  * Feature picking configuration (default: true). Enables the `featureClick`
6705
- * event (click) and the `featureHover` / `featureEnter` / `featureLeave`
6706
- * events (mousemove).
6733
+ * event (click or touch tap) and the `featureHover` / `featureEnter` /
6734
+ * `featureLeave` events (pointer hover).
6707
6735
  */
6708
6736
  picking?: boolean;
6709
6737
  /** When true, renders every frame. When false, renders only on changes or when forceUpdate() is called. */
@@ -6889,6 +6917,13 @@ export declare class Pass<P extends Pass_2, E extends Effect_2 | unknown, O exte
6889
6917
 
6890
6918
  export declare type PassKey = keyof Pick<Scenes, "opaque" | "transparent" | "mrt" | "skyEnvMap" | "draped">;
6891
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
+
6892
6927
  /**
6893
6928
  * Turnkey {@link PickableMesh} implementation for `InstancedMesh`.
6894
6929
  *
@@ -9238,6 +9273,13 @@ declare type SupportedMaterial_6 = ShaderMaterial;
9238
9273
  */
9239
9274
  declare type SupportedMaterial_7 = ShaderMaterial;
9240
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
+
9241
9283
  /**
9242
9284
  * Temporary DEM state while waiting for edge updates.
9243
9285
  * Stores only the WASM buffer handle and received edge strips — NOT the full padded DEM.
@@ -9772,9 +9814,9 @@ declare class ThreeView<D extends Descriptions = EmptyDescriptions> extends Even
9772
9814
  set lit(value: boolean);
9773
9815
  constructor(options?: Options);
9774
9816
  /**
9775
- * Convert a mouse event to a MapMouseEvent by adding map coordinates
9817
+ * Extend a pointer event with map coordinates at its location
9776
9818
  */
9777
- private convertMouseEventToMapEvent;
9819
+ private convertToMapEvent;
9778
9820
  private initializeRenderPass;
9779
9821
  private get renderPass();
9780
9822
  /** The camera controller that manages view position, orientation, and projection. */
@@ -9924,6 +9966,18 @@ declare class ThreeView<D extends Descriptions = EmptyDescriptions> extends Even
9924
9966
  * @returns A Source handle for referencing, updating, and deleting the source
9925
9967
  */
9926
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;
9927
9981
  /**
9928
9982
  * Adds a 3D mesh to the scene.
9929
9983
  * The mesh kind is determined by the nested key (e.g., `{ box: { width: 200 } }`).
@@ -10723,6 +10777,9 @@ declare class TileXYZ {
10723
10777
  z: number;
10724
10778
  }
10725
10779
 
10780
+ /** Pick search radius for touch: fingertips land less precisely than a cursor. */
10781
+ export declare const TOUCH_PICK_RADIUS = 10;
10782
+
10726
10783
  declare type TransactionCallbackParams<AddKey extends JsEventsKey, RemoveKey extends JsEventsKey, ChangeKey extends JsEventsKey> = {
10727
10784
  type: "add";
10728
10785
  event: GetJsEventValue<AddKey>;
@@ -11345,13 +11402,13 @@ export declare class UnknownTypeError extends Error {
11345
11402
  /** Emitted when the view is resized. Receives width and height in pixels. */
11346
11403
  resize: (w: number, h: number) => void;
11347
11404
  /**
11348
- * Emitted when a feature is clicked (click-gesture GPU pick). Receives the
11349
- * clicked feature, or null when empty space was clicked. For raw click
11350
- * coordinates use the `click` event instead.
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.
11351
11408
  */
11352
11409
  featureClick: (info: Nullable<PickedFeature>) => void;
11353
11410
  /**
11354
- * Emitted when the hovered feature changes (mousemove picking). Receives
11411
+ * Emitted when the hovered feature changes (hover picking). Receives
11355
11412
  * the newly hovered feature, or null when the pointer leaves all pickable
11356
11413
  * features. Hover picking runs a GPU pick per frame while the pointer
11357
11414
  * moves, and is active only while at least one `featureHover` /
@@ -11374,18 +11431,26 @@ export declare class UnknownTypeError extends Error {
11374
11431
  postRender: (t: number) => void;
11375
11432
  /** @private Emitted when terrain height sampling completes. */
11376
11433
  _sample_terrain_height_received: (ev: TerrainHeightUpdatedEvent) => void;
11377
- /** Emitted on mouse down with map coordinates. */
11378
- mousedown: (event: MapMouseEvent) => void;
11379
- /** Emitted when mouse enters the canvas with map coordinates. */
11380
- mouseenter: (event: MapMouseEvent) => void;
11381
- /** Emitted when mouse leaves the canvas with map coordinates. */
11382
- mouseleave: (event: MapMouseEvent) => void;
11383
- /** Emitted on mouse move with map coordinates. */
11384
- mousemove: (event: MapMouseEvent) => void;
11385
- /** Emitted on mouse up with map coordinates. */
11386
- mouseup: (event: MapMouseEvent) => void;
11387
- /** Emitted on click with map coordinates. */
11388
- 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;
11389
11454
  /** Emitted when the engine becomes idle (no Rust-side events for `idleThreshold` ms). */
11390
11455
  idle: () => void;
11391
11456
  };