@tileflow/react 0.1.0-alpha.32 → 0.1.0-alpha.34

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 (3) hide show
  1. package/README.md +15 -6
  2. package/dist/index.js +26 -14
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -111,16 +111,25 @@ themes instead of `theme`: position 0 is the first theme and 1.5 is halfway from
111
111
  third. Moving the position updates the map at once. See
112
112
  [theme transitions and blends](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/theme-transitions-and-blends.md).
113
113
 
114
- Interactive maps automatically render the map's vegetation. `vegetation` overrides visibility
115
- (omitting it uses the map default); false hides models and flat artwork alike. `viewMode` is `2d`
116
- by default and may be `3d`: only maps with `vegetation.mode: 'auto'` switch representation.
117
- Streets uses model trees in either view. Changing either prop updates the existing map immediately.
118
- These props do not change camera pitch, buildings or lighting and do not apply in image mode. See
119
- [vegetation controls](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/trees-3d.md#visibility-and-representation).
114
+ Interactive maps show the 3D scene their style declares by default: buildings with Tileflow
115
+ landmarks and the map's Team building models, 3D trees, and street lights where the map enables
116
+ them. The 3D renderers load only when the style declares a scene, so 2D maps do not download them.
117
+ `viewMode` is `3d` by default; `viewMode="2d"` opts out, mounting no 3D buildings or street lights, and
118
+ draws vegetation as the map's policy sets for the 2D view (Streets keeps its model trees in either
119
+ view). `vegetation` overrides vegetation visibility (omitting it uses the map default); `vegetation={false}`
120
+ hides models and flat artwork alike. Changing either prop updates the existing map immediately.
121
+ They do not change camera pitch and do not apply in image mode. See
122
+ [the map's 3D scene](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/buildings-3d.md#the-maps-3d-scene)
123
+ and [vegetation controls](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/trees-3d.md#visibility-and-representation).
120
124
 
121
125
  `mapOptions` accepts native MapLibre options except `container` and `style`. Direct camera props
122
126
  take priority over `mapOptions`, then the manifest view, then shared defaults. `Map` always selects
123
127
  a Tileflow map through its manifest; it has no renderer discriminator or direct-style mode.
128
+ Tileflow's styles are validated when they are compiled, so `validateStyle` defaults to `false`; pass
129
+ `true` to validate them again in the browser.
130
+ The map canvas is multisampled by default (`canvasContextAttributes.antialias` is `true`) so the
131
+ thin edges of 3D models stay continuous; other context attributes you pass are kept, and
132
+ `canvasContextAttributes: {antialias: false}` trades that smoothing for lower GPU cost.
124
133
  The obsolete source fields `kind` and `style` are rejected. For a completely unmanaged map, use
125
134
  `maplibre-gl` directly rather than a Tileflow component.
126
135
 
package/dist/index.js CHANGED
@@ -41,18 +41,21 @@ import { createPortal } from "react-dom";
41
41
  import {
42
42
  attachTileflowAtmosphere,
43
43
  attachTileflowFairUseNotice,
44
+ attachTileflowMap3D,
44
45
  attachTileflowMapLifecycle,
46
+ attachTileflowNauticalLights,
45
47
  attachTileflowNotices,
46
48
  createTileflowSessionStarter,
47
49
  createTileflowThemeController,
48
- createTileflowVegetation,
49
50
  createTileflowTransformRequest,
50
51
  getTileflowSystemColorScheme,
51
52
  loadTileflowStyleFonts,
52
53
  registerTileflowContourProtocol,
53
54
  registerTileflowPmtilesProtocol,
54
55
  registerTileflowWorldRequestBridge,
55
- subscribeTileflowSystemColorScheme
56
+ subscribeTileflowSystemColorScheme,
57
+ tileflowCanvasContextAttributes,
58
+ tileflowMaxPitch
56
59
  } from "@tileflow/core/browser";
57
60
  import { normalizeTileflowCaptureId } from "@tileflow/core/capture";
58
61
  import {
@@ -298,7 +301,7 @@ function Map2(props) {
298
301
  themeBlend,
299
302
  themeTransition,
300
303
  vegetation,
301
- viewMode = "2d",
304
+ viewMode = "3d",
302
305
  interactionState,
303
306
  interactions = defaultInteractions,
304
307
  onInteractionDiagnostic,
@@ -339,12 +342,12 @@ function Map2(props) {
339
342
  const containerRef = useRef(null);
340
343
  const imageRef = useRef(null);
341
344
  const mapRef = useRef(null);
342
- const vegetationRef = useRef(void 0);
343
- const vegetationInputsRef = useRef({ vegetation, viewMode });
344
- vegetationInputsRef.current = { vegetation, viewMode };
345
+ const sceneRef = useRef(void 0);
346
+ const sceneInputsRef = useRef({ vegetation, viewMode });
347
+ sceneInputsRef.current = { vegetation, viewMode };
345
348
  useEffect2(() => {
346
- vegetationRef.current?.setVisible(vegetation);
347
- vegetationRef.current?.setViewMode(viewMode);
349
+ sceneRef.current?.setVegetation(vegetation);
350
+ sceneRef.current?.setViewMode(viewMode);
348
351
  }, [vegetation, viewMode]);
349
352
  const themeControllerRef = useRef(void 0);
350
353
  const runtimeStyleRef = useRef(null);
@@ -805,6 +808,9 @@ function Map2(props) {
805
808
  });
806
809
  const map = new maplibregl.Map({
807
810
  ...stableMapOptions,
811
+ canvasContextAttributes: tileflowCanvasContextAttributes(
812
+ stableMapOptions?.canvasContextAttributes
813
+ ),
808
814
  container,
809
815
  style: initialRuntimeStyle.style,
810
816
  bearing: bearingRef.current,
@@ -815,6 +821,9 @@ function Map2(props) {
815
821
  attributionControl: stableMapOptions?.attributionControl ?? {
816
822
  compact: true
817
823
  },
824
+ // Tileflow's compiled styles are validated when they are built.
825
+ validateStyle: stableMapOptions?.validateStyle ?? false,
826
+ maxPitch: stableMapOptions?.maxPitch ?? tileflowMaxPitch,
818
827
  transformRequest
819
828
  });
820
829
  mapRef.current = map;
@@ -822,6 +831,7 @@ function Map2(props) {
822
831
  registerCleanup(() => map.remove());
823
832
  registerCleanup(attachTileflowAtmosphere(map));
824
833
  registerCleanup(attachTileflowNotices(map));
834
+ registerCleanup(attachTileflowNauticalLights(map));
825
835
  const themeController = initialRuntimeStyle.theme === void 0 ? void 0 : createTileflowThemeController({
826
836
  initial: initialRuntimeStyle,
827
837
  map,
@@ -845,11 +855,13 @@ function Map2(props) {
845
855
  }
846
856
  });
847
857
  }
848
- const vegetationController = createTileflowVegetation({
858
+ const scene = attachTileflowMap3D({
849
859
  map,
850
860
  ...themeController ? { controller: themeController } : {},
851
- visible: vegetationInputsRef.current.vegetation,
852
- viewMode: vegetationInputsRef.current.viewMode,
861
+ vegetation: sceneInputsRef.current.vegetation,
862
+ viewMode: sceneInputsRef.current.viewMode,
863
+ load: () => import("@tileflow/core/3d"),
864
+ onError: (error) => console.error("Failed to load the Tileflow 3D scene", error),
853
865
  // Direct tile readers use HTTP, not MapLibre's custom World protocol.
854
866
  transformRequest: createTileflowTransformRequest({
855
867
  getAnalytics: () => resolvedAnalyticsRef.current,
@@ -861,10 +873,10 @@ function Map2(props) {
861
873
  )
862
874
  })
863
875
  });
864
- vegetationRef.current = vegetationController;
876
+ sceneRef.current = scene;
865
877
  registerCleanup(() => {
866
- vegetationController.dispose();
867
- if (vegetationRef.current === vegetationController) vegetationRef.current = void 0;
878
+ scene.dispose();
879
+ if (sceneRef.current === scene) sceneRef.current = void 0;
868
880
  });
869
881
  const browserWindow = container.ownerDocument.defaultView;
870
882
  if (!browserWindow) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tileflow/react",
3
- "version": "0.1.0-alpha.32",
3
+ "version": "0.1.0-alpha.34",
4
4
  "license": "Apache-2.0",
5
5
  "description": "React components for rendering Tileflow maps with MapLibre.",
6
6
  "type": "module",
@@ -43,8 +43,8 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@tileflow/core": ">=0.1.0-alpha.37 <0.1.0-beta.0",
47
- "@tileflow/interactions": ">=0.1.0-alpha.5 <0.1.0-beta.0",
46
+ "@tileflow/core": ">=0.1.0-alpha.39 <0.1.0-beta.0",
47
+ "@tileflow/interactions": ">=0.1.0-alpha.6 <0.1.0-beta.0",
48
48
  "@tileflow/static": ">=0.1.0-alpha.28 <0.1.0-beta.0"
49
49
  },
50
50
  "peerDependencies": {