I am not sure if this topic is somewhat related to the problem I was having in this discussion, but just in case.
What I did was
-
git clone clone https://github.com/akira-cn/node-canvas-webgl.git
-
modify test/babylonjs.js like below
const fs = require('fs');
const BABYLON = require('babylonjs');
const { createCanvas } = require('../lib');
const XMLHttpRequest = require("xhr2");
global.XMLHttpRequest = XMLHttpRequest;
global.HTMLElement = function () {};
global.window = {
setTimeout,
addEventListener() {},
};
global.navigator = {};
global.document = {
createElement() {
return createCanvas(300, 150);
},
addEventListener() {},
};
const canvas = createCanvas(512, 512);
const engine = new BABYLON.Engine(canvas, true, {preserveDrawingBuffer: true, stencil: true});
const scene = new BABYLON.Scene(engine);
const createScene = async function () {
scene.clearColor = new BABYLON.Color4(0.5, 0.4, 0.4, 1);
const camera = new BABYLON.FreeCamera('cam1', new BABYLON.Vector3(-6.8, 9.8, -9.3), scene)
camera.setTarget(new BABYLON.Vector3(-1.8, 0, 0))
const rootURL = 'https://playground.babylonjs.com/scenes/'
const fileName = 'candle.babylon'
const { meshes } = await BABYLON.SceneLoader.ImportMeshAsync('', rootURL, fileName, scene, null, '.babylon')
const light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0, 1, 0), scene);
scene.render();
};
createScene();
setTimeout(() => {
fs.writeFileSync('./snapshot/snap-babylon.png', canvas.toBuffer());
}, 3000)
I don’t know what changed, but since I upgraded babylon version to 5.22.1, the whole model fails to load not just the textures