Hello there, I have a weird behavior and I can't figure what is really going on here.
I have a babylon scene which works fine in my browser, electron, ...
For my workflow I was planning to use the null engine to be able to do some preprocessing through CLI (mesh merging, lightmap baking, navigation mesh, ...).
It seems to work, the engine is loading fine, xhr2 seems to work ok, my mesh are loaded but my textures are not.
I use this code to load my different assets (exactly the same code than the browser version):
// Loading Mesh
const modelTask = assetsManager.addMeshTask(modelId, null, "assets/models/", modelId + ".babylon");
modelTask.onSuccess = (task) => console.log("loaded mesh", modelId, task.rootUrl, !!task.loadedMeshes, task.taskState);
modelTask.onError = (task, message, exception) => console.error(message, exception);
// Load Textures
const textureTask = assetsManager.addTextureTask(textureId, "assets/textures/" + textureId, false, true);
textureTask.onSuccess = (task) => console.log("loaded texture", textureId, task.url, task.texture, task.taskState);
textureTask.onError = (task, message, exception) => console.error(message, exception);
So something quite standard which work fine in the browser
But in node cli:
Loading JSON:
console.log("loaded map", name, task.url, !!task.text, task.taskState);
>> loaded map map1 http://localhost:8000/data/maps/map1.json true 2
Loading Mesh:
console.log("loaded mesh", modelId, task.rootUrl, !!task.loadedMeshes, task.taskState);
>> loaded mesh wall http://localhost:8000/assets/models/ true 2
Loading Texture:
console.log("loaded texture", textureId, task.url, task.texture, task.taskState);
>> loaded texture Bricks.png http://localhost:8000/assets/textures/Bricks.png undefined 2
So it turns out that both json and meshes are loaded properly.
But my texture loading task created with `assetsManager.addTextureTask`
- onSuccess is called 👍
- task.taskState is 2 👍
- task.texture is undefined 🤔
How can onSuccess be called if the texture is not loaded ?
Is it a known limitation of the null engine (Cannot load textures, only meshes) ?
I was able to reproduce that here https://playground.babylonjs.com/#9I07DU#1
Just comment/uncomment the 3rd line (declaration of nullEngine) to switch engine