Browser deployment
Deploy the browser engine with your application’s static assets. The getting-started guide covers initialization and drawing your first scene.
Serve spatialengine.wasm and the geodata folder from the same package release with your
application. The engine starts with no coordinate reference systems. Your app loads the registry
files, any definitions it registers, and any grids it needs through geodata when it chooses,
usually on its loading screen.
Asset URLs
Set module_or_path in init to supply the Wasm URL or bytes explicitly. This option does not
change where geodata reads its files, which defaults to geodata/manifest.json beside the SDK
module. Set geodataUrl to the manifest’s URL when the folder is served elsewhere, or set
geodataBaseUrl to a folder you host, as Coordinate data
describes.
Each geodata load also accepts { url } or { bytes } to read one file from somewhere else.
Build tools
A bundler cannot emit a folder, so copy geodata during your build:
import { copyGeodata } from "@fslabs/spatialengine/assets.mjs";
const geodataUrl = await copyGeodata("dist/assets");The helper copies the folder whole and returns the relative URL of its manifest. Pass its public
URL as geodataUrl during initialization. The helper accepts { source: pathOrFileURL } to copy
another folder.
Caching
Every file in geodata except manifest.json carries its SHA-256 hash in its name, so those
files can use immutable caching. Serve manifest.json with Cache-Control: no-cache and an ETag
or Last-Modified header so browsers revalidate after deployment. Alternatively, publish each
release in a new directory and cache that directory’s assets as immutable.
Extensions
Sandboxed extensions require a window and cross-origin isolation through COOP and COEP headers. Headless Node.js engines do not host extensions.
Direct ESM imports load the npm package’s adjacent extensions/ assets. For bundled apps, copy
that directory to a publicly served path and set extensionAssetBase to its URL during
initialization. Setting extensionAssetBase changes only the extension asset URL.
Raw Wasm bindings
When importing raw Wasm bindings, await their initializer and then call start(config). The raw
initializer does not schedule engine startup. Geospatial data reaches the engine only through
statements, so send geo.data.installRegistryFile, geo.crs.register and geo.data.installGrid
after start.