Nodragem Posted September 13, 2018 Share Posted September 13, 2018 Hello, I am trying to make a Labyrinth. Hence I cloned a box to make the walls and the floor. For some reason, when I try to merge the floor boxes, Mesh.MergeMeshes() works but when I try to merge the wall boxes, Mesh.MergeMeshes() returns an error: babylon.js:18 Uncaught Error: Positions are required at t._validate (babylon.js:18) at t.merge (babylon.js:18) at Function.r.MergeMeshes (babylon.js:17) at e.MergeMeshes (MazeLoader.ts:70) at new e (MazeLoader.ts:26) at new e (game.ts:20) at game.ts:73 you can see my code on Github here: https://github.com/Nodragem/Maze-Demo/tree/master/src Feel free to clone and run it. To reproduce the error, simply uncomment line 94 of MazeLoader.ts (note: the debugger is wrong when it reports the defective line 'at MazeLoader.ts: 70'; it is referring to the js file). Thank you for your help Quote Link to comment Share on other sites More sharing options...
Gijs Posted September 13, 2018 Share Posted September 13, 2018 Hi, maybe it's because the meshWall gets disposed after the first merger due to the second parameter being true Quote Link to comment Share on other sites More sharing options...
Nodragem Posted September 14, 2018 Author Share Posted September 14, 2018 Hi, If I swap the two lines like so: this.mazeWalls = BABYLON.Mesh.MergeMeshes(wallMeshes, true); this.mazeFloor = BABYLON.Mesh.MergeMeshes(floorMeshes, true); I still have the crash happening for the line with 'this.mazeWalls', hence your suggestion is refuted. The following may help. Before I use Mesh.MergeMeshes(), I am adding my meshes to an array and I run that little test on each mesh before to push it to the array: if (!element.getVerticesData(BABYLON.VertexBuffer.PositionKind)) console.log("problems with: " + element.name); The result is that all the wall meshes fail this test and print "problems with ... " in the console log. The floor meshes pass the test. Hence, it seems that somehow, my wall meshes do not have vertex position information?... Quote Link to comment Share on other sites More sharing options...
MarianG Posted September 14, 2018 Share Posted September 14, 2018 Hi, i didn't test your repo, but I saw a transformNode. Are you trying to merge this too? Be carefull and use only plenty abstract meshes, no parents, no children for merge. And double check what is the difference between your floors boxes and wall boxes.If i'll have some time I'll try this later. Hope this help a little bit. Gijs 1 Quote Link to comment Share on other sites More sharing options...
Gijs Posted September 14, 2018 Share Posted September 14, 2018 @Nodragem Ok I actually ran it this time, and I found the error: The HuntAndKillMazeAlgorithm may dispose the mazeCells, so the tryToPushToForMerge function also has to check for that: if(element !== undefined && !element.isDisposed()){ Quote Link to comment Share on other sites More sharing options...
Nodragem Posted September 14, 2018 Author Share Posted September 14, 2018 On my side, if I do that, the list is then empty and the Mesh.MergeMesh() doesn't work either... Quote Link to comment Share on other sites More sharing options...
Gijs Posted September 14, 2018 Share Posted September 14, 2018 18 minutes ago, Nodragem said: On my side, if I do that, the list is then empty and the Mesh.MergeMesh() doesn't work either... That's odd. On my side, the original list would be of length 220, while the isDisposed checked list is of length 121, and when I do this.mazeWalls.dispose(); I see just the floor, so I'm pretty sure the merging succeeded Quote Link to comment Share on other sites More sharing options...
Nodragem Posted September 15, 2018 Author Share Posted September 15, 2018 Ok, so I tried again and it seems to work! However, when I activate checkCollisions = true on mazeWalls, it seems that the collision are wrong... Does that happen on your side? Quote Link to comment Share on other sites More sharing options...
Nodragem Posted September 15, 2018 Author Share Posted September 15, 2018 Here is what I mean: https://nodragem.itch.io/maze-demo Quote Link to comment Share on other sites More sharing options...
Gijs Posted September 16, 2018 Share Posted September 16, 2018 On 9/15/2018 at 3:56 PM, Nodragem said: Ok, so I tried again and it seems to work! However, when I activate checkCollisions = true on mazeWalls, it seems that the collision are wrong... Does that happen on your side? The collisions seem off on my side as well, but with the camera ellipsoid set to (0.5, 0.75, 0.5) it seems fine. And I couldn't see the maze demo on itch, because it requires a password. Nodragem 1 Quote Link to comment Share on other sites More sharing options...
Nodragem Posted September 17, 2018 Author Share Posted September 17, 2018 oh yeah my bad ^^ I forgot about this password. You did not miss anything though, you were right about the collision ? I am so bad at seeing my own bugs ^^ Thank you very much! Gijs 1 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.