@maptoolkit/maplibre-scene3d-control 0.5.0 → 0.5.2
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 +16 -1
- package/dist/Scene3dControl.d.ts +11 -1
- package/dist/{maplibre-3d-layers-0.6.0.standalone.mjs → maplibre-3d-layers-0.6.1.standalone.mjs} +410 -349
- package/dist/maplibre-scene3d-control.js.map +1 -1
- package/dist/maplibre-scene3d-control.standalone.js +1 -1
- package/dist/maplibre-scene3d-control.standalone.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ All values are plain MapLibre or maplibre-3d-layers options. Maptoolkit styles g
|
|
|
102
102
|
version: 1,
|
|
103
103
|
source: "https://…/buildings.json", // TileJSON of the buildings, without api_key
|
|
104
104
|
lod1: { filter, paint, layout }, // fill-extrusion on the source layer buildings2d
|
|
105
|
-
fill3d: { paint },
|
|
105
|
+
fill3d: { paint, extrusion }, // Fill3DLayer on the source layer buildings3d
|
|
106
106
|
landmarks: { position, filter, paint }, // the landmarks in buildings3d, a Fill3DLayer of their own
|
|
107
107
|
models: { tree_1: "https://static.maptoolkit.net/3d/models/…/Tree.gltf" },
|
|
108
108
|
gltf: [{ id, models: ["tree_1"], source: "mtk", "source-layer": "natural", filter, minzoom, layout, paint, lighting }],
|
|
@@ -123,6 +123,21 @@ landmarks: {
|
|
|
123
123
|
|
|
124
124
|
`fill3d` then leaves those features out: its filter becomes `["all", <its own filter, if any>, ["!", <the landmarks' filter>]]` (expression filters). A scene without `landmarks` keeps them in `fill3d`, drawn as plain buildings. `landmarks` works without `fill3d` and `lod1` too; the style's own 3D buildings (`hideLayers`) then stay. `paint` goes to the `Fill3DLayer` as it is, on `fill3d` as well, including the `fill-3d-ambient-occlusion-*` keys of maplibre-3d-layers ≥ 0.6 (older versions ignore them, and place a landmark like a building instead of rigidly at its anchor).
|
|
125
125
|
|
|
126
|
+
`fill3d.extrusion` lets the `Fill3DLayer` extrude the 2D footprints as well (maplibre-3d-layers ≥ 0.6.0, experimental), so that they get the shading and the fake ambient occlusion of the 3D buildings. The control passes it on as it is; hand the same footprints over by the zoom of the tile, so that none is drawn twice:
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
lod1: { filter: ["all", ["!=", ["get", "extrude"], false], ["<", ["zoom"], 15]], paint }, // native in tiles below z15
|
|
130
|
+
fill3d: {
|
|
131
|
+
extrusion: {
|
|
132
|
+
"source-layer": "buildings2d",
|
|
133
|
+
filter: ["all", ["!=", ["get", "extrude"], false], [">=", ["zoom"], 15]], // three.js from z15
|
|
134
|
+
},
|
|
135
|
+
paint,
|
|
136
|
+
},
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Both filters see the zoom of the tile, not of the map. Don't stop `lod1` with `maxzoom` instead: that is the map zoom, and a pitched view at zoom 15+ still loads z13/z14 tiles in the distance, which then get no buildings from either layer. The extruded faces carry `type: "roof" | "wall"`, so a `fill-3d-color` keyed on `type` colours them like the 3D buildings.
|
|
140
|
+
|
|
126
141
|
MapLibre ignores a diffed `setStyle` that changes nothing but the metadata. A scene that changes on its own, with the rest of the style unchanged, therefore never reaches the control that way: pass it with `setScene()` or use `setStyle` with `diff: false`.
|
|
127
142
|
|
|
128
143
|
## Requirements
|
package/dist/Scene3dControl.d.ts
CHANGED
|
@@ -44,11 +44,21 @@ export interface Scene3dManifest {
|
|
|
44
44
|
paint?: Record<string, Expression>;
|
|
45
45
|
layout?: Record<string, Expression>;
|
|
46
46
|
};
|
|
47
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* `Fill3DLayer` on the source layer `buildings3d`. With `extrusion` it also extrudes the 2D footprints of a source
|
|
49
|
+
* layer of the same tiles (maplibre-3d-layers ≥ 0.6.0, experimental), so that they get its shading and fake ambient
|
|
50
|
+
* occlusion; leave the same footprints out of `lod1` where it does, by a filter on the tile zoom (not `maxzoom`).
|
|
51
|
+
*/
|
|
48
52
|
fill3d?: {
|
|
49
53
|
position?: Scene3dPosition;
|
|
50
54
|
filter?: FilterSpecification;
|
|
51
55
|
paint?: Record<string, Expression>;
|
|
56
|
+
extrusion?: {
|
|
57
|
+
"source-layer": string;
|
|
58
|
+
filter?: FilterSpecification;
|
|
59
|
+
height?: Expression;
|
|
60
|
+
base?: Expression;
|
|
61
|
+
};
|
|
52
62
|
};
|
|
53
63
|
/**
|
|
54
64
|
* The landmarks in the source layer `buildings3d`, as a `Fill3DLayer` of their own: with their own paint and their
|