Viswanathan Posted January 12, 2017 Share Posted January 12, 2017 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 Quote Link to comment Share on other sites More sharing options...
Viswanathan Posted January 12, 2017 Author Share Posted January 12, 2017 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. Quote Link to comment Share on other sites More sharing options...
Viswanathan Posted January 13, 2017 Author Share Posted January 13, 2017 Another problem I have is that it's not importing line meshes. Aren't they supported? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 13, 2017 Share Posted January 13, 2017 Hello! So line meshes are not exported yet. For textures, can you provide the .babylon file and the associated textures? Quote Link to comment Share on other sites More sharing options...
Viswanathan Posted January 13, 2017 Author Share Posted January 13, 2017 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 14, 2017 Share Posted January 14, 2017 there is no problem with lineMeshes, we just need to do it:) (Happy to accept a PR, if you have time to do it) Regarding textures, dynamic textures cannot be serialized as they do not exist as files Quote Link to comment Share on other sites More sharing options...
Viswanathan Posted January 15, 2017 Author Share Posted January 15, 2017 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. Quote Link to comment Share on other sites More sharing options...
Viswanathan Posted January 15, 2017 Author Share Posted January 15, 2017 Hi. I've just realized a mistake I was making; I was assigning the same id to all materials. Correcting that solved part of my problem. Now I'm trying to find out how to correctly export materials with dynamic textures. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 17, 2017 Share Posted January 17, 2017 Dynamic textures are tough to export because you first need to save them as a file and this is almost impossible to do with web browsers Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 17, 2017 Share Posted January 17, 2017 Using PHP allows you to save a dynamic texture. Quote Link to comment Share on other sites More sharing options...
Viswanathan Posted January 17, 2017 Author Share Posted January 17, 2017 Thank you for your responses @Deltakosh and @Dad72. I'll try to do it with PHP and I'll try to understand the code of exportations in order to contribute with LinesMeshes exportations. Regards. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.