Hi,I have hard times with asynchronous mesh loading.
I need to apply textures to meshes right after meshes are ready. I'm importing in this way:
var loader = new BABYLON.AssetsManager(scene);
someLoader = loader.addMeshTask("roulette", "", "", "rouletteTable.obj");
anotherLoader =loader.addMeshTask("chip", "", "", "blackChip.obj");
someLoader.onSuccess = function (t) {
t.loadedMeshes.forEach(function (m) {
tableMeshArr.push(m);
});
tableMeshArr[0].material = materialWheel;
tableMeshArr[1].material = materialRoulette;
tableMeshArr[2].material = materialBlack;
};
anotherLoader.onSuccess = function (t) {
t.loadedMeshes.forEach(function (m) {
chip=m;
chip.material=materialChips;
});
};
loader.onFinish = applyObjTextures;
loader.load();
var applyObjTextures = function () {
tableMeshArr[0].material = materialWheel;
tableMeshArr[1].material = materialRoulette;
tableMeshArr[2].material = materialBlack;
chip.material = materialChips;
};
But it applies only to tableMeshArr[0] mesh.
onFinish Callback works right after finishing importing first mesh, but I need a callback when all meshes are loaded.