Jump to content

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


Nodragem
 Share

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

 

Link to comment
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?...

Link to comment
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.

Link to comment
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

Link to comment
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.

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...