Sign in to follow this  

Using variables with AssetsManager

Recommended Posts

Hi, this is my code:


	for(var t = 0; t < edificios_texto.length; t++){
		var loader = new BABYLON.AssetsManager(scene);
		var edificio = loader.addMeshTask(t, "", "http://localhost:8080/modelos2/"+edificios_texto[t]+"/",edificios_texto[t]+".obj");
		edificio.onSuccess = function (task) {
			task.loadedMeshes.forEach(function(b) {
				b.scaling =  new BABYLON.Vector3(5,5, 5);
				b.rotation.y = Math.PI;
				// cambiar las X
				var vertex_data = BABYLON.VertexData.ExtractFromMesh(b);
				for (var i = 0; i < vertex_data.normals.length; i+=3) {
					vertex_data.positions[i] *= -1;
				for (var i = 0; i < edificios.length; i++) {
				//	console.log(edificios[i].texto);
					//	console.log(t);
					if(edificios[i].texto == edificios_texto[t]){
						var utmPlaceZ = edificios[i].x;
						var utmPlaceX = edificios[i].z;
						var utmPlaceXFromCentre = utmPlaceX - mapCentreX;
						var utmPlaceZFromCentre = utmPlaceZ - mapCentreZ;
						var x = utmPlaceXFromCentre/scaleX;
						var z = utmPlaceZFromCentre/scaleZ;	
						b.position.x = x;
						b.position.z = z;
		edificio.onFinish = function() {
			engine.runRenderLoop(function () {


I have to use the var edificios_texto[t] inside this function, How can I do it?

JuanMa J.R

Share this post

Link to post
Share on other sites

Sorry, @RaananW I cant get the value inside callback, I think that I have to send vector (edificios_texto) as parameter of function to access after...:huh:

The before code started with the init of vector:

        var edificios_texto = ['C6','A4'];


Share this post

Link to post
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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.