Jump to content

Using variables with AssetsManager


juanmajr93
 Share

Recommended Posts

Hi, this is my code:

 

	for(var t = 0; t < edificios_texto.length; t++){
		var loader = new BABYLON.AssetsManager(scene);
		//console.log(edificios_texto[n]);
		var edificio = loader.addMeshTask(t, "", "http://localhost:8080/modelos2/"+edificios_texto[t]+"/",edificios_texto[t]+".obj");
		edificio.onSuccess = function (task) {
			//console.log(task.loadedMeshes.length);
			console.log(edificio.name);
			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;
				}
				vertex_data.applyToMesh(b);
				
				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;
						break;
					}
				
				}
			});
			
		}
	/*	
		edificio.onFinish = function() {
			engine.runRenderLoop(function () {
            scene.render();
			});
		};
*/
		loader.load();
	}	

 

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

JuanMa J.R

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