Jump to content

Problem with addMeshTask() and $_each


Dad72
 Share

Recommended Posts

Hello,

I have a small problem that I do not understand with addMeshTask().

If I do this, it does not work. (I have no error in the console and I get out the value of 'key')

// Not Work
$.getJSON(global.game.nameProjet, function(json) {
	$.each(json, function (key, val) {
		addTask(key);
	});
});	

function addTask(key) {
	global.game.meshTask = global.game.assetsManager.addMeshTask(key, "", "../../scene/"+key+"/", key+".babylon");
	global.game.meshTask.onSuccess = function(task) {
		task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0);
	}
}

 

But if I do this, it works:

// Work
function addTask(key) {
	global.game.meshTask = global.game.assetsManager.addMeshTask(key, "", "../../scene/"+key+"/", key+".babylon");
	global.game.meshTask.onSuccess = function(task) {
		task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0);
	}
}
addTask("scene_name");

 

I would like to load multiple scene with addMeshTask() from a list of json file, but it does not work. Why ?

Thank you for your help.

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