AssetManager addMeshTask with custom data

Hi All, not sure the best way to approach this.
I have a bunch of models id like to load… the perfect job for AssetManager
trouble is that for each of these models, id like to “configure” the model based on some custom json configuration data that is specific to that model. So Ideally id like to pass the configuration info into the Mesh Task so that after it succeeds, I can perform operations on the mesh based on the custom json data. Remember that its important for the data to travel along with the task as its different for each mode. Whats the best way to accomplish this… there doesn’t seem to be anyplace I can attach some custom data to the task.

Hello! Yeah, there isn’t a way to pass custom information on the mesh task, but maybe you could do something like this: have each json configuration be the model’s name, and on the onSuccess callback you can check the mesh’s name and load the corresponding named file.

1 Like

It’s JavaScript, so you can add whatever you like on to the object returned by addMeshTask and it should keep it around until you need it.

true but Id like to attach data to what I send into AddMeshTask not attach it afterwords.
I will try Carol’s solution, using the name to key into the configuration json.

Actually im able to just pass the entire json object in the task name parameter. there doesnt seem to be any strict type checking going on there so it just takes the json object. It might still be better to just make the name a dictionary key or something into the list of json objects but thats an architectural consideration not a babylon thing. The AssetManager and AssetContainer is really nice… makes things easy. Gotta love Babylon.

3 Likes