Draw vectorBase: a MapLibre style's vector tiles painted as imagery

src/render/vectorBase/ is a Cesium-free painter: loadVectorStyle loads
a style and its TileJSON sources and compiles its layers (skipping, with a
reason, what it does not draw), and paintVectorTile paints a Web Mercator
tile on a canvas: background, fill, line and circle layers with filters in
both syntaxes, legacy functions and a listed subset of expressions, and
symbol text labels placed clear of each other inside the tile. Sources are
decoded with pbf and @mapbox/vector-tile, already dependencies. The Cesium
port loads the style before changing the base, draws it as Web Mercator
imagery under the base's other imagery, credits its sources, and claims
vectorBase; the stub loads the style. globe.base.vector serves a style and
tile from data URLs and reads the drawn fill.
This commit is contained in:
Sameh Khamis committed 2026-11-11 18:24:49 -08:00
1 parent d9ad7da9d5
commit 5fae3cf485
17 files changed
+2032 -15

No files matched your search

+6
View File
@@ -18,6 +18,7 @@ import { CAPABILITIES, CONTRACT_VERSION } from '../contract/index.js';
import { createStubCamera } from './camera.js';
import { motionPosition } from '../motion/iconMotion.js';
import { computeViewRectangle } from './viewRectangle.js';
import { loadVectorStyle } from '../vectorBase/index.js';
import {
add,
dot,
@@ -1420,6 +1421,11 @@ export function createStubRenderer(options = {}) {
const globe = {
async setBase(base) {
log('globe', 'setBase', [base]);
if (base.vector && !capabilities.has('vectorBase'))
throw new TypeError('This renderer draws no vector base');
// The style is loaded, as a renderer drawing it loads it, so one that
// fails changes nothing; the stub paints none of it.
if (base.vector) await loadVectorStyle(base.vector.styleUrl);
for (const layer of imageryLayers.slice()) layer.remove();
if (base.photoreal !== undefined)
await globe.setPhotoreal(base.photoreal);