npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@csi-foxbyte/mesh-dem-to-terrain

v0.0.4

Published

A Node.js library that converts DEM meshes (DXF, GeoJSON, etc.) into Cesium Terrain Tiles (quantized-mesh or heightmap) with flexible zoom-level control and multi-threading support.

Readme

mesh-dem-to-terrain 🚀🥾

A Node.js library for converting DEM meshes (DXF, GeoJSON, etc.) into Cesium Terrain Tiles (quantized-mesh or heightmap), with flexible zoom-level control.

Table of Contents

🎉 Features

  • 🔄 Preprocess Mesh Archive: Unpacks and prepares DXF/GeoJSON mesh archives into a working directory, reprojects coordinates using Proj4 strings. 🗺️
  • 🗻 Terrain Tile Generation: Generates Cesium-compatible terrain tiles (quantized-mesh or heightmap) across specified zoom levels. 📈
  • 📐 Projection Support: Accept any Proj4-formatted CRS string for flexible coordinate transformations. ✨
  • 📊 Progress Callbacks: Receive real-time progress updates (percentage or log messages). 📢
  • 🧵 Multi-threading: Customize worker threads for CPU-bound tasks. ⚙️

📥 Installation

npm install mesh-dem-to-terrain

💻 Usage

import { preprocess, generate } from "mesh-dem-to-terrain/index.js";

(async () => {
  // Step 1: Unpack and reproject your mesh archive 🛠️
  await preprocess(
    "D:\\dxf.zip",                      // Path to DXF/GeoJSON archive
    "D:\\dxf_test",                    // Working directory for intermediate files
    console.log,                       // Progress callback (log messages)
    "+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs"  // Proj4 CRS string
  );

  // Step 2: Generate Cesium Terrain Tiles 🌄
  await generate(
    "D:\\dxf_test",                    // Working directory from preprocess
    (progress) => console.log((progress * 100).toFixed(2), "%"),  // Progress callback (percentage)
    { endZoom: 16, startZoom: 0, threadCount: 2 }  // Options: zoom range & threads
  );
})();

⚙️ API

preprocess(inputArchive, workDir, progressCallback, proj4String)

  • inputArchive (string) – Path to a ZIP archive containing DXF, GeoJSON, or other mesh files. 📂
  • workDir (string) – Directory to extract and preprocess mesh data. 📁
  • progressCallback (function) – Called with log messages or progress updates. 📢
  • proj4String (string) – Proj4-formatted CRS string for coordinate transformation. 🌍

Returns: A promise that resolves when preprocessing is complete. ✅

generate(workDir, progressCallback, options)

  • workDir (string) – Directory prepared by preprocess(). 📂

  • progressCallback (function) – Called with a number in [0,1] indicating progress. 📈

  • options (object):

    • startZoom (number) – Minimum zoom level to generate (default: 0). ↗️
    • endZoom (number) – Maximum zoom level to generate (required). ↘️
    • threadCount (number) – Number of worker threads (default: number of CPU cores). 🧵

Returns: A promise that resolves when terrain tile generation is complete. ✅

🛠️ Options Overview

| Option | Default | Description | | ------------- | ------------------ | ------------------------------------------ | | startZoom | 0 | Minimum zoom level for generated tiles. ↗️ | | endZoom | required | Maximum zoom level for generated tiles. ↘️ | | threadCount | os.cpus().length | Number of parallel worker threads. 🧵 |

📜 CLI Wrapper Example

Wrap the library in a convenient CLI script:

#!/usr/bin/env node
import path from "path";
import { preprocess, generate } from "mesh-dem-to-terrain/index.js";

const [,, archive, outDir, proj, startZ, endZ, threads] = process.argv;

(async () => {
  // Preprocess mesh archive 🛠️
  await preprocess(
    path.resolve(archive),
    path.resolve(outDir),
    console.log,
    proj
  );

  // Generate terrain tiles 🌄
  await generate(
    path.resolve(outDir),
    (p) => console.log(`${(p*100).toFixed(2)} %`),
    {
      startZoom: Number(startZ) || 0,
      endZoom:   Number(endZ) || 16,
      threadCount: Number(threads) || 4
    }
  );
})();

🤝 Contributing

Contributions are welcome! Please open issues or pull requests on the GitHub repository. 🙌