Jump to content

AssetManager not loading meshes correctly


Dwengo
 Share

Recommended Posts

TL;DR The `loadMesh` onSuccess gets called, But i got no mesh! haaaaalp!

Hi all, I've been having a problem with my asset-manager when loading meshes.

I've taken a look at the playground 'import mesh' and the code is almost the same, however on the 'addMeshTask' success callback I do not get access to the loaded mesh via 'task.getLoadedMeshes[0]' (as seen in the playground).

I'm really confused as to what could be causing it to trigger a success event, but not have any 'loaded' meshes. 

My code is open source:

https://github.com/dweng0/wildflower

to get it up and running you'll need to do an `npm install` and npm install -g`

when thats all done, in the command line, you'll need to run `webpack` 

then set up the mock server with `npm run serve`

Then in your browser go to localhost:3000 (have the console open). I've added a debug in the offending function, but it starts in the AssetsManager.ts -> `loadCharacter` function

 

loadCharacter(url: string, character: CharacterManifest, manifest: ICharacterData) {
let bodyTextureUrl = url + character.url + "/textures" + manifest.textureUrl;
let meshUrl = url + character.url + manifest.meshUrl;
debugger;
// load body texture
this.loadTexture(character.name + "_texture", bodyTextureUrl, () => {
console.log(character.name + " texture loaded");
}, () => {});
 
// todo load mesh
this.loadMesh(character.name + "_mesh", manifest.meshes[0], meshUrl, (task: BABYLON.MeshAssetTask) => {
console.log(task.loadedMeshes[0]); <====  No mesh WTF!!!!!!!!!!!
task.loadedMeshes[0].material = this._scene.getMaterialByName(character.name + "_texture"); /
}, () => {
debugger;
console.log('did it fail?');
});
}
 
loadMesh(taskName: string, meshNames: any, rootUrl: string, success: (meshAsset: BABYLON.MeshAssetTask) => any, fail: () => any) {
console.log('loading mesh', taskName);
let meshLoader = this._assets.addMeshTask(taskName, taskName, rootUrl, meshNames);
meshLoader.onSuccess = success.bind(this);
meshLoader.onError = fail.bind(this);
return meshLoader;
}

 

 

Link to comment
Share on other sites

  • 4 weeks later...

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...