A cave and LiDAR visualiser: a CesiumJS globe with Potree point clouds in the browser, a small Node server behind it, and a Python pipeline that bakes any area into a self-contained offline viewer — or an Android app you can carry underground.
2024 National Speleological Society convention talk: https://docs.google.com/presentation/d/1ijDiJJ1g6IRt8oCFVmPTKpNqkT0I9oWBMN1QG8OYKQc/edit?usp=sharing
Demo video: https://feroz.us/FLEX-demo.mp4
Node 18 or newer:
npm install
For terrain export you also need Python 3 with PDAL, GDAL, NumPy, SciPy and Pillow. A conda environment is the least painful route:
conda create -n entwine -c conda-forge python pdal python-pdal gdal numpy scipy pillow
node server.js
then open http://localhost:8081/index.html. ⓘ Help → Open the FLEX guide (or http://localhost:8081/help.html) walks through setting up, projects, saving, CalTopo, LiDAR, your own map layers and the phone app, with diagrams.
On Windows, FLEX.bat starts the server and a browser together. Copy
Tokens.js.example to Tokens.js and fill in your own API keys; both are
gitignored.
- Globe and terrain — CesiumJS with several imagery and elevation sources
- Point clouds — Potree, from local or remote EPT datasets. The server can start and stop a local EPT host from the UI
- Cave surveys — imports PLT, Breakout and Walls (its shapefile export) surveys, draws them as lines, stations and passage walls from the LRUDs, and supports georectification: pin stations to world coordinates and warp the survey with IDW rubber-sheeting. Caves take the same vertical datum shift as the point clouds, can be saved and loaded as sets, and can be coloured by survey, elevation, depth below ground (3D terrain, or the loaded LiDAR's ground returns) or passage difficulty
- CalTopo integration through an authenticated proxy
The export dialog bakes the current area into a standalone viewer: a terrain mesh from LiDAR (or, for big areas, the map's own 3D terrain, with no point cloud needed), satellite and optional hillshade imagery, and the cave surveys.
python export_terrain.py --ept <ept.json> --bbox <minLon> <minLat> <maxLon> <maxLat> \
--caves caves.json --out export.zip
The zip holds a single viewer.html with everything inlined — it opens in any
browser with no server and no network — plus the same assets as sidecar files
(terrain.glb, tex_sat.jpg, tex_hs.jpg, caves.json, libs/) for the
Android build, and serve.bat / serve.sh for serving it locally.
The viewer has orbit and fly/crane camera modes, tappable stations with survey details, terrain opacity and brightness, a satellite/hillshade toggle, KML and KMZ import, and GPS with a compass-oriented caver marker.
Useful flags: --resolution (DEM cell size, default 0.5 m), --max-triangles
(default 2 M), --tex-size (default 8192), --satellite-source (bing or
esri), --hillshade-url (any XYZ tile template; empty by default).
One app, in android/, that imports export zips and opens them offline —
terrain, imagery and cave surveys, with GPS and compass underground, plus
notes, leads and field survey that come back to FLEX in sync files. Build it
in PowerShell (it needs the Android SDK):
cd android
.\gradlew.bat installReleaseOn the phone: Import map (or Open with / Share a zip from Files or Drive).
It exists for one specific reason. Chrome refuses geolocation to file://,
content:// and bare LAN-IP origins — they are not "potentially trustworthy"
origins, so the request is denied and no permission prompt ever appears. The app
serves the files over https://appassets.androidplatform.net/ through
WebViewAssetLoader and grants the permission itself, so GPS and the compass
work with no network at all. It declares no INTERNET permission.
android/README.md has the details.
Still rough in places. PotreeCopied/ is a vendored copy of
Potree by Markus Schütz. The globe is
CesiumJS; the offline viewer uses
three.js. Every third-party library, its version,
licence and source is listed in THIRD_PARTY.md.
See CLAUDE.md for architecture notes and the non-obvious pitfalls.