Jump to content

Null Engine and AssetManager


Kefniark
 Share

Recommended Posts

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

Link to comment
Share on other sites

Everything related to DOM or webgl is not supported by the nullEngine. 

In your case the images cannot be loaded because they rely on the Image tag to decode the files :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...