Using imported meshes in SPS

Hi everybody!

I’m having quite a problem with SPS right now and don’t know what to do with it, so - I want to generate a terrain made of my imported meshes (which then I’ll use as obstacles to player and as navmesh for enemies) but the problem is that it doesn’t want to work. Whenever I try to add those meshes to my SPS I get either “Cannot read properties of undefined (reading ‘length’)” or “Cannot read properties of undefined (reading ‘getVerticesData’)”. With primitive shapes it does work without a problem but my goal is to use meshes that I made, not just a grey boxes, so my question is - can imported meshes be used as SPS shapes? And if yes - what is the right way to do it?

Here is my repro (clicking on a sphere should generate a new obstacle terrain made of imported meshes):
https://playground.babylonjs.com/#T06UQ3#1

The newMeshes array only had 1 element, so newMeshes[1] was an undefined object: SPS imported mesh problem | Babylon.js Playground (babylonjs.com)

1 Like

Oh, right, well that’s what I get for not checking it, I thought that it will be root and then mesh as second element so I didn’t even bothered to check that. Even though it works now (in playground) that isn’t a case in my project because there I do operate on existing object, but now I see that it is possible to use imported meshes here so it’s probably a bad code order on my side, thanks for help!

1 Like

1 Like