@tileflow/svelte 0.1.0-alpha.30 → 0.1.0-alpha.32

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
@@ -102,18 +102,27 @@ themes instead of `theme`: position 0 is the first theme and 1.5 is halfway from
102
102
  third. Moving the position updates the map at once. See
103
103
  [theme transitions and blends](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/theme-transitions-and-blends.md).
104
104
 
105
- Interactive maps automatically render the map's vegetation. `vegetation` overrides visibility
106
- (omitting it uses the map default); false hides models and flat artwork alike. `viewMode` is `2d`
107
- by default and may be `3d`: only maps with `vegetation.mode: 'auto'` switch representation.
108
- Streets uses model trees in either view. Changing either prop updates the existing map immediately.
109
- These props do not change camera pitch, buildings or lighting and do not apply in image mode. See
110
- [vegetation controls](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/trees-3d.md#visibility-and-representation).
105
+ Interactive maps show the 3D scene their style declares by default: buildings with Tileflow
106
+ landmarks and the map's Team building models, 3D trees, and street lights where the map enables
107
+ them. The 3D renderers load only when the style declares a scene, so 2D maps do not download them.
108
+ `viewMode` is `3d` by default; `viewMode="2d"` opts out, mounting no 3D buildings or street lights, and
109
+ draws vegetation as the map's policy sets for the 2D view (Streets keeps its model trees in either
110
+ view). `vegetation` overrides vegetation visibility (omitting it uses the map default); `vegetation={false}`
111
+ hides models and flat artwork alike. Changing either prop updates the existing map immediately.
112
+ They do not change camera pitch and do not apply in image mode. See
113
+ [the map's 3D scene](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/buildings-3d.md#the-maps-3d-scene)
114
+ and [vegetation controls](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/trees-3d.md#visibility-and-representation).
111
115
 
112
116
  `mapOptions` accepts native MapLibre options except `container` and `style`. Direct props win over
113
117
  those options, then the manifest view, then shared defaults. `TileflowMap` always selects a Tileflow
114
- map through its manifest; it has no renderer discriminator or direct-style mode. The obsolete
115
- source fields `kind` and `style` are rejected. For a completely unmanaged map, use `maplibre-gl`
116
- directly rather than a Tileflow component.
118
+ map through its manifest; it has no renderer discriminator or direct-style mode. Tileflow's styles
119
+ are validated when they are compiled, so `validateStyle` defaults to `false`; pass `true` to
120
+ validate them again in the browser.
121
+ The map canvas is multisampled by default (`canvasContextAttributes.antialias` is `true`) so the
122
+ thin edges of 3D models stay continuous; other context attributes you pass are kept, and
123
+ `canvasContextAttributes: {antialias: false}` trades that smoothing for lower GPU cost.
124
+ The obsolete source fields `kind` and `style` are rejected. For a completely unmanaged map, use
125
+ `maplibre-gl` directly rather than a Tileflow component.
117
126
 
118
127
  ## Add annotations and native popup UI
119
128
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tileflow/svelte",
3
- "version": "0.1.0-alpha.30",
3
+ "version": "0.1.0-alpha.32",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Svelte component for rendering Tileflow maps with MapLibre.",
6
6
  "type": "module",
@@ -44,8 +44,8 @@
44
44
  "access": "public"
45
45
  },
46
46
  "dependencies": {
47
- "@tileflow/core": ">=0.1.0-alpha.37 <0.1.0-beta.0",
48
- "@tileflow/interactions": ">=0.1.0-alpha.5 <0.1.0-beta.0"
47
+ "@tileflow/core": ">=0.1.0-alpha.39 <0.1.0-beta.0",
48
+ "@tileflow/interactions": ">=0.1.0-alpha.6 <0.1.0-beta.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "maplibre-gl": ">=6.4.1 <7",
@@ -54,7 +54,7 @@
54
54
  "devDependencies": {
55
55
  "maplibre-gl": "6.13.0",
56
56
  "svelte": "^5.57.2",
57
- "svelte-check": "^4.3.4"
57
+ "svelte-check": "^4.7.7"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "svelte-check --tsconfig ./tsconfig.json",
@@ -31,12 +31,13 @@
31
31
  import {
32
32
  attachTileflowAtmosphere,
33
33
  attachTileflowFairUseNotice,
34
+ attachTileflowMap3D,
34
35
  attachTileflowMapLifecycle,
36
+ attachTileflowNauticalLights,
35
37
  attachTileflowNotices,
36
38
  createTileflowSessionStarter,
37
39
  createTileflowThemeController,
38
- createTileflowVegetation,
39
- type TileflowVegetationController,
40
+ type TileflowMap3DAttachment,
40
41
  createTileflowTransformRequest,
41
42
  getTileflowSystemColorScheme,
42
43
  loadTileflowStyleFonts,
@@ -44,6 +45,8 @@
44
45
  registerTileflowPmtilesProtocol,
45
46
  registerTileflowWorldRequestBridge,
46
47
  subscribeTileflowSystemColorScheme,
48
+ tileflowMaxPitch,
49
+ tileflowCanvasContextAttributes,
47
50
  type TileflowFairUseNoticeController,
48
51
  type TileflowMapLifecycleAttachment,
49
52
  type TileflowThemeController,
@@ -105,7 +108,7 @@
105
108
  export let timeOfDay: TileflowMapProps['timeOfDay'] = undefined;
106
109
  export let themeBlend: TileflowMapProps['themeBlend'] = undefined;
107
110
  export let vegetation: TileflowMapProps['vegetation'] = undefined;
108
- export let viewMode: NonNullable<TileflowMapProps['viewMode']> = '2d';
111
+ export let viewMode: NonNullable<TileflowMapProps['viewMode']> = '3d';
109
112
  export let themeTransition: TileflowMapProps['themeTransition'] = undefined;
110
113
  export let tooltip: TileflowMapProps['tooltip'] = undefined;
111
114
  export let zoom: TileflowMapProps['zoom'] = undefined;
@@ -148,9 +151,9 @@
148
151
  let interactionRuntimesDisposing = false;
149
152
  let mapResizeObserver: ResizeObserver | null = null;
150
153
  let mapWorldRequestBridge: TileflowWorldRequestBridge | null = null;
151
- let vegetationController: TileflowVegetationController | null = null;
152
- $: vegetationController?.setVisible(vegetation);
153
- $: vegetationController?.setViewMode(viewMode);
154
+ let sceneAttachment: TileflowMap3DAttachment | null = null;
155
+ $: sceneAttachment?.setVegetation(vegetation);
156
+ $: sceneAttachment?.setViewMode(viewMode);
154
157
  let themeController: TileflowThemeController | null = null;
155
158
  let systemColorScheme: 'dark' | 'light' = 'light';
156
159
  let unsubscribeSystemColorScheme: (() => void) | null = null;
@@ -460,8 +463,8 @@
460
463
  const unsubscribeSemanticTargets = semanticRuntimeTargetsUnsubscribe;
461
464
  const currentMap = mapInstance;
462
465
  const currentThemeController = themeController;
463
- const currentVegetationController = vegetationController;
464
- vegetationController = null;
466
+ const currentSceneAttachment = sceneAttachment;
467
+ sceneAttachment = null;
465
468
  const worldRequestBridge = mapWorldRequestBridge;
466
469
  interactionRuntimesDisposing = true;
467
470
  mapFairUseNotice = null;
@@ -504,7 +507,7 @@
504
507
  () => semanticInteractionsForMap?.dispose(),
505
508
  () => annotationInteractionsForMap?.dispose(),
506
509
  () => lifecycleAttachment?.dispose(),
507
- () => currentVegetationController?.dispose(),
510
+ () => currentSceneAttachment?.dispose(),
508
511
  () => currentThemeController?.dispose(),
509
512
  () => worldRequestBridge?.dispose(),
510
513
  () => fairUseNotice?.dispose(),
@@ -586,7 +589,11 @@
586
589
  });
587
590
  const maplibreMap = new maplibregl.Map({
588
591
  ...mapOptions,
592
+ canvasContextAttributes: tileflowCanvasContextAttributes(mapOptions?.canvasContextAttributes),
589
593
  attributionControl: mapOptions?.attributionControl ?? {compact: true},
594
+ // Tileflow's compiled styles are validated when they are built.
595
+ validateStyle: mapOptions?.validateStyle ?? false,
596
+ maxPitch: mapOptions?.maxPitch ?? tileflowMaxPitch,
590
597
  bearing: resolvedBearing,
591
598
  center: resolvedCenter as LngLatLike,
592
599
  container: targetContainer,
@@ -606,6 +613,7 @@
606
613
  mapInstance = maplibreMap;
607
614
  attachTileflowAtmosphere(maplibreMap);
608
615
  attachTileflowNotices(maplibreMap);
616
+ attachTileflowNauticalLights(maplibreMap);
609
617
  themeController =
610
618
  runtime.theme === undefined
611
619
  ? null
@@ -624,11 +632,14 @@
624
632
  },
625
633
  });
626
634
 
627
- vegetationController = createTileflowVegetation({
635
+ // The map's 3D scene loads only once its style declares one, so 2D maps do not pay for it.
636
+ sceneAttachment = attachTileflowMap3D({
628
637
  map: maplibreMap,
629
638
  ...(themeController ? {controller: themeController} : {}),
630
- visible: vegetation,
639
+ vegetation,
631
640
  viewMode,
641
+ load: () => import('@tileflow/core/3d'),
642
+ onError: (error) => console.error('Failed to load the Tileflow 3D scene', error),
632
643
  transformRequest: createTileflowTransformRequest({
633
644
  getAnalytics: () => resolvedAnalytics,
634
645
  sessionController: session,