Loading GLTF models in Nodejs

Hi everyone,

Wow, this took me a while to get working :dizzy_face: Sharing the following node setup. Hope is saves you some time :slight_smile:

Use case? Needed this setup for unit testing.

  "devDependencies": {
    "xhr2": "^0.2.1"
  "dependencies": {
    "@babylonjs/core": "^6.5.0",
    "@babylonjs/loaders": "^6.5.0"

//npm install @babylonjs/core
//npm install @babylonjs/loaders
//npm install @xhr2
import * as BABYLON from "@babylonjs/core";
import "@babylonjs/loaders";
import XMLHttpRequest from 'xhr2';

//test setup
global.XMLHttpRequest = XMLHttpRequest;

var gltf = `data:{ ... }`;
await BABYLON.SceneLoader.AppendAsync("", gltf, scene);
console.log( scene.getMeshByName("UnitTestCubeWDirs") )

Best wishes


Thanks, I bet it can help !!!

Thanks for sharing with the community!