Nodragem

Mesh.MergeMeshes() throws: Uncaught Error: Positions are required

Recommended Posts

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 :)

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

@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()){

 

Share this post


Link to post
Share on other sites
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

maze.png.efbb5d1bec10d4479524714637229226.png

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.