@tileflow/dom 0.1.0-alpha.3 → 0.1.0-alpha.4

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/REFERENCE.md CHANGED
@@ -30,6 +30,7 @@ Every option except `source` is optional and can change after mount through `upd
30
30
  | `views` | `{marker?, popup?, tooltip?}` renderers that fill a plain element. |
31
31
  | `renderTargets` | `{marker?, popup?, tooltip?, onChange}` for a framework that draws views itself; replaces `views`. |
32
32
  | `onLoad`, `onError`, `onThemeChange` | The loaded MapLibre map; `{code, error}` failures (`console.error` without a handler); theme transitions. |
33
+ | `onSceneLoad` | The map's 3D scene, once its style declares buildings, trees or street lights and the scene has mounted. |
33
34
  | `onInteractionEvent`, `onInteractionStateChange` | Pointer and popup events; requested popup state. |
34
35
  | `onInteractionDiagnostic` | Each distinct interaction diagnostic, once. |
35
36
  | `onStatusChange` | Every change to the status `getStatus` returns. |
@@ -70,9 +71,16 @@ with no renderer keeps the default view.
70
71
  | `setInteractionState(state)` | Opens or closes a popup; on a controlled map the same as passing `interactionState`. |
71
72
  | `getStatus()` | `{readiness, theme, diagnostics, imageUrl}`: `loading`, `idle` or `error`, the theme shown, interaction diagnostics and, in image mode, the image. |
72
73
  | `getMap()`, `getThemeController()` | The MapLibre map and theme controller, `null` until the map exists and after it is taken down. |
74
+ | `getScene()` | The mounted 3D scene (`TileflowMap3D`): `null` until the style declares one and it mounts, and after the map is taken down. |
73
75
  | `getInteractionState()`, `getRenderTargets()` | The open popup; the view elements the map handed out. |
74
76
  | `destroy()` | Takes the map down, removes the capture attributes and stops every listener. Later calls do nothing. |
75
77
 
78
+ The 3D scene loads only for a style that declares one, after the map. `viewMode` shows or hides it
79
+ at once; `getScene()` or the scene passed to `onSceneLoad` gives its own controls, such as a rise
80
+ or descent with a transition (`show` and `hide`), what it still waits for (`pending()`), and its
81
+ buildings, trees and street lights. The style's `camera` policy sets its pitch cap and adaptive
82
+ perspective.
83
+
76
84
  Use `getMap()` or the map passed to `onLoad` for application-owned MapLibre sources, layers,
77
85
  controls and events. Tileflow owns the style; theme changes may replace it, so reinstall your
78
86
  own layers on `style.load`, or use `dataSources` and `dataOverlays`. Calling the MapLibre map's
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as maplibre_gl from 'maplibre-gl';
2
2
  import { Map, MapOptions } from 'maplibre-gl';
3
3
  import { TileflowMapLibreOverlay, TileflowGeoJsonSource } from '@tileflow/core';
4
- import { TileflowThemeController, TileflowBounds, TileflowFitBoundsOptions, TileflowColorOverrides, TileflowEmphasis, TileflowBrowserThemeBlendSelection, TileflowThemeTransitionOptions, TileflowViewMode, TileflowNavigationControlInput, TileflowMapError, TileflowThemeTransition } from '@tileflow/core/browser';
4
+ import { TileflowMap3D, TileflowThemeController, TileflowBounds, TileflowFitBoundsOptions, TileflowColorOverrides, TileflowEmphasis, TileflowBrowserThemeBlendSelection, TileflowThemeTransitionOptions, TileflowViewMode, TileflowNavigationControlInput, TileflowMapError, TileflowThemeTransition } from '@tileflow/core/browser';
5
5
  import { TileflowThemeSelection, TileflowRuntimeSource, TileflowTimeOfDay, TileflowAnalytics } from '@tileflow/core/runtime';
6
6
  import { TileflowAnnotation, TileflowAnnotationViewContext, TileflowInteractionViewContext, TileflowInteractionState, TileflowInteractionDiagnostic, TileflowInteractionBinding, TileflowInteractionEvent } from '@tileflow/interactions';
7
7
  import { TileflowMapLibreDomRenderTarget, TileflowMapLibreSemanticDomRenderTarget, TileflowAnnotationClusterOptions } from '@tileflow/interactions/maplibre';
@@ -119,6 +119,11 @@ type TileflowMapControllerOptions<TAnnotation extends TileflowAnnotation = Tilef
119
119
  renderTargets?: TileflowMapRenderTargetsOptions<TAnnotation>;
120
120
  onError?: (event: TileflowMapError) => void;
121
121
  onLoad?: (map: Map) => void;
122
+ /**
123
+ * Receives the map's 3D scene once its style declares buildings, trees or street lights and the
124
+ * renderers have mounted it. A style without 3D never mounts one.
125
+ */
126
+ onSceneLoad?: (scene: TileflowMap3D) => void;
122
127
  onThemeChange?: (transition: TileflowThemeTransition) => void;
123
128
  onInteractionDiagnostic?: (diagnostic: TileflowInteractionDiagnostic) => void;
124
129
  onInteractionEvent?: (event: TileflowInteractionEvent<TAnnotation>) => void;
@@ -150,6 +155,11 @@ type TileflowMapController<TAnnotation extends TileflowAnnotation = TileflowAnno
150
155
  /** The MapLibre map, or `null` before it is created and after it is taken down. */
151
156
  getMap(): Map | null;
152
157
  getRenderTargets(): TileflowMapRenderTargetList<TAnnotation>;
158
+ /**
159
+ * The map's mounted 3D scene, for its buildings, trees and street lights: `null` until the
160
+ * style declares one and its renderers have loaded, and after the map is taken down.
161
+ */
162
+ getScene(): TileflowMap3D | null;
153
163
  getStatus(): TileflowMapStatus;
154
164
  /** Changes theme, colours and emphasis; `null` until the map exists or when it has no themes. */
155
165
  getThemeController(): TileflowThemeController | null;
package/dist/index.js CHANGED
@@ -1484,6 +1484,9 @@ function createTileflowMap(container, initialOptions, createOptions = {}) {
1484
1484
  onError: (error) => {
1485
1485
  if (scene === mapScene) reportError("scene", error);
1486
1486
  },
1487
+ onLoad: (mountedScene) => {
1488
+ if (scene === mapScene) options.onSceneLoad?.(mountedScene);
1489
+ },
1487
1490
  // Direct tile readers use HTTP, not MapLibre's custom World protocol.
1488
1491
  transformRequest: createTileflowTransformRequest({
1489
1492
  getAnalytics: () => current.resolvedAnalytics,
@@ -1821,6 +1824,7 @@ function createTileflowMap(container, initialOptions, createOptions = {}) {
1821
1824
  getInteractionState: () => interactionCoordinator?.getInteractionState() ?? coordinatedInteractionState,
1822
1825
  getMap: () => map,
1823
1826
  getRenderTargets: () => lastRenderTargets,
1827
+ getScene: () => map ? scene?.scene ?? null : null,
1824
1828
  getStatus: () => lastStatus ?? computeStatus(),
1825
1829
  getThemeController: () => map ? themeController ?? null : null,
1826
1830
  ready,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tileflow/dom",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.4",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Mount a Tileflow map in any DOM element, without a framework.",
6
6
  "type": "module",
@@ -40,7 +40,7 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@tileflow/core": ">=0.1.0-alpha.53 <0.1.0-beta.0",
43
+ "@tileflow/core": ">=0.1.0-alpha.54 <0.1.0-beta.0",
44
44
  "@tileflow/interactions": ">=0.1.0-alpha.11 <0.1.0-beta.0"
45
45
  },
46
46
  "peerDependencies": {