Running Babylon.js On A Server

Starting with Babylon.js v3.1, we introduced the NullEngine which is a version of the main Babylon.js engine but with no need for a WebGL capable device.

The NullEngine will not produce any rendering and thus can be used in a Node.js / server side environment.

It can be used to:

  • Run tests
  • Run a server side version of your application / game
  • Use specific Babylon.js services (like glTF loaders for instance)


To use a headless version of Babylon.js, just run:

var engine = new BABYLON.NullEngine();
var scene = new BABYLON.Scene(engine);

If you want to use it in a Node.js environment, you may need to add some additional resources (like support for xhr):

var BABYLON = require("../../dist/preview release/babylon.max");
var LOADERS = require("../../dist/preview release/loaders/babylonjs.loaders");
global.XMLHttpRequest = require("xhr2").XMLHttpRequest;
var engine = new BABYLON.NullEngine();
var scene = new BABYLON.Scene(engine);
var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);
var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene);
BABYLON.SceneLoader.ImportMesh("", "", "skull.babylon", scene, function (newMeshes) { = newMeshes[0];
console.log("Meshes loaded from babylon file: " + newMeshes.length);
for (let index = 0; index < newMeshes.length; index++) {
BABYLON.SceneLoader.ImportMesh("", "", "DamagedHelmet.gltf", scene, function (meshes) {
console.log("Meshes loaded from gltf file: " + meshes.length);
for (let index = 0; index < meshes.length; index++) {
console.log("render started")
engine.runRenderLoop(function() {


You can specifiy some options in the NullEngine constructor:

var engine = new BABYLON.NullEngine({
renderWidth: 512,
renderHeight: 256,
textureSize: 512

With renderWidth and renderHeight you can define the size of the virtual canvas used to simulate the render surface. With textureSize, you can define the size of all textures (which will be all black) used by the NullEngine.


While the goal of the NullEngine is to completely replace the Engine class, some features cannot be used server side:

  • camera.attachControl cannot be used as it requires an HTML element
  • DynamicTexture cannot be used as it relies on HTML canvas

Furthermore as we already mentioned earlier, you need to provide an implementation of the XMLHttpRequest class.