Error on click (scene.pick) when scene is loaded from file

Hello everyone,

I am a total beginner with Babylon and 3D in general and I recently inherited of a project. I have data in .babylon file that were generated and worked in Babylonjs v2.2 (with some modification in the babylon.js file of the time).

I have a example of a file loaded in the playground :

When I click inside the cube in the example I have the following error in the console :
babylon.js:16 Uncaught TypeError: Cannot read property ‘subtractToRef’ of undefined
at e.intersectsTriangle (babylon.js:16)
at t._intersectTriangles (babylon.js:16)
at t.intersects (babylon.js:16)
at t.intersects (babylon.js:16)
at t.s.a._internalPick (babylon.js:16)
at t.s.a.pick (babylon.js:16)
at e._initActionManager (babylon.js:16)
at e._initClickEvent (babylon.js:16)
at _onPointerUp (babylon.js:16)

I think that the data format exported might not be correct, but I can’t tell what’s the problem because I have no Babylon notion nor 3D notions. It might be something totaly different.
I notice that the pointerUp uses t.s.a.pick (babylon.js:16) and if I do a manual scene.pick I have the same error.

I hope that I am clear enough.
Could someone tell me why I can’t pick on the scene loaded from my .babylon file ?

Thanks !

Could you try to reexport your scene ? it looks like that some of the vertex data might be corrupted inside ?

Actually one of the submesh starts at index 22 which does not cover a full triangle so it should be 21

I reexported the scene and I get the same result.
Could you tell me wich submesh are you talking about ?
And may be try to explain what the indexes referes to ? or should be ?


Yeah, 19 mesh in that file. 10 cameras, too. Interesting.

I like looking at the babylon file… in an online JSON file viewer… kind of cool. [ link ]

Blender-made? Maybe it could use an “export selected mesh ONLY” option… to export less scene items. shrug. I’m no export expert, though. :slight_smile:

mesh name is LE(1,1,0,0,1,0)(33,36) and it s unique submesh has an index start of 22 knowing the indices buffer contains only 23 slots

The exporter was custom made by a someone a long time ago from a proprietary format (which I do not know).
I cannot really update the exporter without breaking something ^^
Thanks for the json file viewer.

How do you know the indices’ buffer lenght ? Where is it describe in the file ?

I know from debugging

this is inside the indices array in the JSON related to the submesh or mesh in question.

Actually you can even see in the screenshot upper that the number of verts is 2 therefore not a complete triangle and I am sure-ish that you rely on triangle mode.

I’m sorry I might ask “dumb” questions.
But what are verts ?
And what is triangle mode ?
And also, how can I debug babylon ?

verts stand for vertices, which is one single point and gpu usually draws triangles so needs three of them therefore the huge suspition on a mesh containing only 2 of them.

I usually debug by running the code locally following the instructions from the getting started guide in the documentation.

Ok thank you for the explanation, I’ll try to check the exporter to know what it does.
However I realised than the mesh we are talking about is a “line mesh” it only has 2 points. Not 3. Do I have to add a “fake” point to have 3 ?

For the debug, I don’t understand what you mean by locally ? I have the babylon.js script on my local project (because I try to make the same modification the person who did this in v2.2 however I could not). I’m totally a beginner in web dev and javascript/typescript. So I’ll try to make it work.

you can use babylon.max.js so at least you ll see the none minified code

I have an angular 8 solution, so I import the babylon module (babylon.d.ts). I don’t know yet how to use babylon.max.js in the debugger. Next week I get support from a web developper, I’ll ask him how to do that. He should be able to help me. Let’s hope ^^

But the important thing is that the exported file is probably wrong. Do you have an idea to export correctly line meshes ?

When you say line meshes, do you mean this particular mesh is a line ??? cause it would make sense to be only 2 points then and not 3.

Yes that is what I mean. I see that in the exporter it creates a mesh when it’s a line. So only two points are exported.

could you the replace “pickable”: true, by “pickable”: false, for all the meshes which have “isLine”: true, in the JSON ???

sorry for the late reply.

So I tried to set “pickable”: false on meshes with “isLine”: true. I don’t have the error in the console, however as expected I can’t use scene.pick on those lines wich I need to do. I need to be able to select faces and edges.

Do you know how to select lines ?

You can not select lines only you would need to create them as ribbon Or plane for instances. A lune would have no faces.