Over the past year, a lot of people have started using npm for front-end dependency management, so we thought it was time Cesium officially provided it as an option for our community. Starting with 1.16, which was released December 1, we’ve made Cesium available as an npm module. Getting the latest release of Cesium is now as easy as running npm install cesium. Even better, we will be publishing a new release of the npm module on the first business day of every month, which is the same thing we’ve done for the last 44 months’ worth of Cesium releases—a streak we don’t plan on breaking anytime soon.

Cesium on npm

The Cesium npm module includes everything you need for app development.

  • Source - A collection of modules that can be used with any AMD-aware loaders, such as requirejs, webpack, and browserify. This is our preferred development method and ideal for those who have embraced module-based web development.

  • Build/Cesium - Combined and minified Cesium.js and associated files, suitable for deploying an application.

  • Build/CesiumUnminified - Combined and unminified Cesium.js and associated files, along with extra error checking and validation, suitable for development.

Note: We accidentally deployed a copy of the documentation this time around, but in keeping with npm guidelines, that will not be included in Cesium 1.17.

But wait, there’s more! While having Cesium available via npm for the front-end was the feature everyone was asking for, there are actually a lot of use cases for using Cesium on the server as well. That’s why we’ve also decided to launch initial support for using Cesium from directly within Node! This includes most of Core and even parts of DataSources. While this support is preliminary, the Cesium team at AGI has been using it quite a bit for other Cesium-based projects. For example, we use Cesium to generate 3D Tiles tilesets for our New York City demo. Here’s a stripped down example of what some of that code looks like:

var Cesium = require('cesium');
var parseColor = require('parseColor');

var Color = Cesium.color;
var definedNotNull = Cesium.definedNotNull;
var PolygonGeometry = Cesium.PolygonGeometry;
var VertexFormat = Cesium.VertexFormat;

function processBuilding(tags, colors, geometries) {
    //...
    //...
    var bodyColor = parseColor(tags['building:colour'], tags['building:material']);
    var openTop = !Color.equals(bodyColor, roofColor);

    var geometry = PolygonGeometry.createGeometry(new PolygonGeometry({
        vertexFormat: VertexFormat.POSITION_AND_NORMAL,
        polygonHierarchy: polygonHierarchy,
        extrudedHeight: height !== 0 ? height : undefined,
        open: openTop
    }));

    if (definedNotNull(geometry)) {
        colors.push(bodyColor);
        geometries.push(geometry);
    }
    //...
    //...
}

module.exports = addBuildingBodyGeometry;

That’s all there is to it. If you use Cesium from within a Node application for your own projects, we would love to hear about it on the forum. While we can’t run our extensive unit test suite under Node yet, our long-term development plans for Cesium 2.0 include better modularization and fully validated server-side support.