Jump to content

Recommended Posts

Hello.

I was trying to serialize my scene, but it threw an error in line 29 of babylon.2.4.js file.

This is the error:


 

babylon.2.4.js:29 Uncaught TypeError: Cannot read property 'length' of undefined
    at r (babylon.2.4.js:29)
    at Function.o.Serialize (babylon.2.4.js:29)

I think is missing a validation at a for loop

for(var a=0;a<t.subMeshes.length;a++){
//...
}

beacause in my case t.subMeshes is undefine and that seems to be causing the error.

My workarround was to add a validation in order to skip that for loop if t.subMeshes is undefined, but my next problem was at the moment of loading my scene.

Uncaught Error: No camera defined
    at i.render (babylon.2.4.m.js:11)

I attached my scene in json format.

Do you have any idea to solve it?

Thanks in advance.

 

 

 

sceneP.zip

Link to post
Share on other sites

I've already been able to load my scene. I saved it to a .babylon file and loaded it from a new page. Now, my problem is that the scene doesn't look like it should.

The problem seems to be related to textures, because the log shows me the following errors:

GET http://localhost:90/test-load-scene/sceneP.babylon.manifest?1484262452161 404 (Not Found)
t.checkManifestFile @ babylon.2.4.js:2
t @ babylon.2.4.js:2
t.Append @ babylon.2.4.js:15
t.Load @ babylon.2.4.js:15
(anonymous) @ (index):29
_AREAS%20COMERCIALES:1 GET http://localhost:90/test-load-scene/_AREAS%20COMERCIALES 404 (Not Found)
_MERCA%20VARIOS:1 GET http://localhost:90/test-load-scene/_MERCA%20VARIOS 404 (Not Found)
_KIOSKOS%20ALIANZAS%20MKT:1 GET http://localhost:90/test-load-scene/_KIOSKOS%20ALIANZAS%20MKT 404 (Not Found)
_PLANO%20BASE%20GENERAL:1 GET http://localhost:90/test-load-scene/_PLANO%20BASE%20GENERAL 404 (Not Found)
_NIVELES%20Y%20GRAL%20MANTTO:1 GET http://localhost:90/test-load-scene/_NIVELES%20Y%20GRAL%20MANTTO 404 (Not Found)
_KIOSKOS%20COMERCIALES:1 GET http://localhost:90/test-load-scene/_KIOSKOS%20COMERCIALES 404 (Not Found)
babylon.2.4.js:3 BJS - [17:07:40]: Error while trying to load texture: _AREAS COMERCIALES
t._ErrorEnabled @ babylon.2.4.js:3
s.onerror @ babylon.2.4.js:3
babylon.2.4.js:3 BJS - [17:07:40]: Error while trying to load texture: _MERCA VARIOS
t._ErrorEnabled @ babylon.2.4.js:3
s.onerror @ babylon.2.4.js:3
babylon.2.4.js:3 BJS - [17:07:40]: Error while trying to load texture: _KIOSKOS ALIANZAS MKT
t._ErrorEnabled @ babylon.2.4.js:3
s.onerror @ babylon.2.4.js:3
babylon.2.4.js:3 BJS - [17:07:40]: Error while trying to load texture: _PLANO BASE GENERAL
t._ErrorEnabled @ babylon.2.4.js:3
s.onerror @ babylon.2.4.js:3
babylon.2.4.js:3 BJS - [17:07:40]: Error while trying to load texture: _NIVELES Y GRAL MANTTO
t._ErrorEnabled @ babylon.2.4.js:3
s.onerror @ babylon.2.4.js:3
babylon.2.4.js:3 BJS - [17:07:40]: Error while trying to load texture: _KIOSKOS COMERCIALES

I attach the the images of how it looks before and after serialize and load the scenes.

 

beforeSerialize.png

afterSerialize.png

Link to post
Share on other sites

Hello!

I attached my .babylon in a zipped file in the first post of this topic.

Textures that I used were generated by javascript like this:

 


			    var material = new BABYLON.StandardMaterial("mat", sc);
 		        var texture = new BABYLON.Texture("img/ANSI31.png", scene);
			    material.diffuseColor = new BABYLON.Color3(7, 7, 7);
			    material.diffuseTexture = texture;

I also generated dynamic textures containing text like this:



		function makeTextPlane(sc, positionx, positiony, text, textHeight, layer, handleData, color) {

		  var w = 20;
		  var h = 5;

		  var fontHeight = 64;

		  if(textHeight) {
		  	fontHeight = textHeight*150;
		  }


		  var plane = BABYLON.MeshBuilder.CreatePlane(layer, {width:20, height:5}, scene, false);
		  plane.position = new BABYLON.Vector3(positionx + w/2, positiony - h/2, -0.01);
		  plane.scaling.y = 1;//scaling.y

		  var dynamicTexture = new BABYLON.DynamicTexture(layer, {width:2048, height:512}, sc, true);
		  plane.material.diffuseTexture = dynamicTexture;
		  plane.material.specularColor = new BABYLON.Color3(0, 0, 0);
		  plane.material.emissiveColor = new BABYLON.Color3(1, 1, 1);//emissiveColor
		  plane.material.backFaceCulling = false;
		  dynamicTexture.hasAlpha = true;

		  var bgc = "transparent";
		  // if(text.includes("HOLA")) {
		  // 	bgc = "#FFFF00";
		  // }

		  var splittedText = text.split("\n");
		  for(var i= 0; i<splittedText.length; i++) {
		  	dynamicTexture.drawText(splittedText[i], 0, fontHeight*(i+1) + 2, "bold " + fontHeight + "px Arial", color , bgc, true);//#FFFF00
		  	//break;

		  }



		  return plane;
		}

In the site where I'm loading the scene I included all images used in textures.

It seems like textures are not being correctly exported.

I attach the images I used.

 

So, Is there nothing to do for now about LineMeshes?

Any idea of what could be the problem with the textures?

Thank you.

 

 

 

 

ANSI31.png

arena_sand-009.jpg

hatch_diag.png

LINE.png

Link to post
Share on other sites

Ok, I'd like to contribute with the export of LineMeshes. I will check it.

About the textures, I thought that every mesh created would be fully exported (including its textures) when serialializing it.

I'm probably misunderstanding the use of SceneSerializer and SceneLoader classes. I'm new to Babylonjs, so I'm trying to learn the correct way to use these utilities.

So, how can I create that textures as files in order to be exported? 

Regards.

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.

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...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...