Exception onClick: Uncaught TypeError: Cannot read property 'subtractToRef' of undefined

Hello,
I’m new to babylonjs and I lerning it, but I face problem I can’t solve by my self.
When I create custom mesh I get error “Uncaught TypeError: Cannot read property ‘subtractToRef’ of undefined” when clicking on the screen. Problem disapear when I run convertToFlatShadedMesh function. Why is it so?

Here is the reproduced problem in sandbox.
https://playground.babylonjs.com/#1H7L5C#95

I looking for your help :slight_smile:

Uncaught TypeError: Cannot read property 'subtractToRef' of undefined
at e.intersectsTriangle (babylon.js:16)
at e._intersectTriangles (babylon.js:16)
at e.intersects (babylon.js:16)
at t.intersects (babylon.js:16)
at t.s.a._internalPickForMesh (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 e._onPointerUp (babylon.js:16)

Well after making this example in sandbox I was able to fix it by my self… :slight_smile:
The problem was in incorrect calculation indices.
Here is link to corrected example: https://playground.babylonjs.com/#1H7L5C#98