Dad72 Posted January 19, 2017 Share Posted January 19, 2017 Hello, When I serialize a mesh (ground for example), the value 'updatable' is not serialized. It does not exist in the string JSON. And I can not find a property to set updatable to true. BABYLON.Mesh.CreateGround("ground", 100, 100, 10, scene, true, 0); In green I find the properties in red impossible to find it and I need to have ground.updatable = true to change the terrain when it is recharging from the serialization. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 22, 2017 Author Share Posted January 22, 2017 I've found a solution that may be what needed to be done, but I think a simpler function would help. ground.setVerticesData(BABYLON.VertexBuffer.PositionKind, ground.getVerticesData(BABYLON.VertexBuffer.PositionKind), true); ground.setVerticesData(BABYLON.VertexBuffer.NormalKind, ground.getVerticesData(BABYLON.VertexBuffer.NormalKind), true); I have to do this every objects, this will be very repetitive. Would not it be simpler to serialize the "updatable" property of each meshes. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 23, 2017 Share Posted January 23, 2017 I agree this could be smarter. Fancy doing a PR? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 23, 2017 Author Share Posted January 23, 2017 I'm not sure my PR would be correct. The code below is enough to make a mesh updatable ? What allows the property to be updatable ? I'm not sure about doing a correct PR. In fact I have the impression that this code ( setVerticesData ) is not enough, because if I serialize, modifications of the terrain are not taken into account. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 23, 2017 Share Posted January 23, 2017 This code is great to make the mesh updatable but not related to the serialization. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 23, 2017 Author Share Posted January 23, 2017 How to redefine 'actualizable', I would like to be able to reload a terrain serialized to edit it again and save it again with seralize. Is there an alternative solution could help to do that. Or why not just serialize the property 'updatable' which would be simpler to do I think. Please. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 23, 2017 Author Share Posted January 23, 2017 I revise the code : mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind), true); mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind), true); mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind), true, false); BABYLON.VertexData.ComputeNormals(mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind), mesh.getIndices(), mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind)); mesh.updateVerticesData(BABYLON.VertexBuffer.NormalKind, mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind), true, false); mesh.updateCache(); But I still have a cache problem and recording. I find myself with a file of 3Ko instead of 1600ko for example. Serialize is not updated, why? What must I do for that? Why can not redefine updatable to true when loading an object with ImportMesh. This works fine when creating a CreateGround object for example, but not when reloading after serialization. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 24, 2017 Share Posted January 24, 2017 Actually i had a look and it is not that simple. This is where geometries are saved: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.geometry.ts#L613 So I had to add a new parameter there: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.geometry.ts#L618 It should work now. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 24, 2017 Author Share Posted January 24, 2017 Thanks Dk, but the uvs do not serialize if I compare two files. The ground does not reload. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 24, 2017 Share Posted January 24, 2017 No sure to follow you. I'll show you the code I changed. Please provide a repro case if you think there is a bug Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 24, 2017 Author Share Posted January 24, 2017 Arf, j'ai du mal avec l'anglais, je vais ecrire en Français pour être plus facilement claire. Je me suis tromper, pour les uvs, c’est tout le vertexData qui n'est pas sérialiser ou vider. En faite je crois que depuis le début je n'indique pas la bonne erreur, ou le vrais probleme. A force des faire des testes, j'ai fini pas mieux comprendre ce qui vas pas. J'explique: Je créer un terrain avec CreateGround et je met le terrain en Updatable a true pour l'éditer avec un outils d’élévation qui créer des montagnes et autres. Ensuite j'enregistre ce terrain une premier fois, ca fonctionne jusque là. (j'enregistre avec SerializeMesh dans un fichier .babylon en passant par du PHP avec file_put_contents() et json_decode() et json_encode()). Ensuite je peut donc recharger ce terrain enregistrer avec ImportMesh et l’éditer grâce au bout de code au début de ce post. jusque la ca fonctionne. si j'enregistre une première fois, tout est ok, le terrain est bien sérialiser entièrement. Mais, si j'enregistre une seconde fois, modifications du terrain ou non, la sérialisation ne ce fait pas correctement. A chaque fois dans le second enregistrement, le SerializeMesh me vide le vertextData (je ne sais pas du tout pourquoi a la seconde sérialisation ?) : Voila le resultat de la seconde sérialisation : "geometries": { "boxes": [], "spheres": [], "cylinders": [], "toruses": [], "grounds": [], "planes": [], "torusKnots": [], "vertexData": [] }, au lieux de : "geometries": { "boxes": [], "spheres": [], "cylinders": [], "toruses": [], "grounds": [], "planes": [], "torusKnots": [], "vertexData": [{ "id": "44d46d08-c2e0-438d-b1f1-5b5fba4f40e9", "positions": [-64, 0, 64, -62.79245283018868, 0, 64, -61.58490566037736, 0, 64, -60.37735849056604, ... ], "normals": [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, ...], "uvs": [0, 1, 0.009433962264150943, 1, 0.018867924528301886, 1, 0.02830188679245283, 1, 0.03773584905660377, ...], "indices": [108, 1, 0, 107, 108, 0, 109, 2, 1, 108, 109, 1, 110, 3, 2, 109, 110, 2, 111, 4, 3, 110, 111, 3, 112, 5, ... ] }] }, Je vais te faire un PG demain pour essayer de reproduire ca de la manière la plus simple. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 25, 2017 Author Share Posted January 25, 2017 Ok, DK, I made a playground that reproduces the problem at the simplest. If you look in the console, in the second serialization, the vertexData [] is empty, but not in the first. http://www.babylonjs-playground.com/#1SQFJP#2 In fact ImportMesh does not access a geometries. Hence the problem that vertexData is emptying. I would like to be able to serialize again vertexData when I load a ground with ImportMesh. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 26, 2017 Author Share Posted January 26, 2017 Resolution of bypass : I have found a workaround. I'll get every vertexData in mesh._geometry and add ._vertexBuffers.position._buffer._data, ._vertexBuffers.normal._buffer._data ... in mesh.metadata and I serialize mesh to get serialization.geometries and add serialization.geometries.vertexData = mesh.metadata.vertexData; http://www.babylonjs-playground.com/#1SQFJP#4 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 27, 2017 Author Share Posted January 27, 2017 Must I specify the resolved subject view that I find a workaround or there is a bug about it ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 27, 2017 Share Posted January 27, 2017 Ok gotcha. you can mark it as solved 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.