Cannot read property 'subtractToRef' of undefined

Update: I found a similar issue (Error when clicking on point-cloud mesh without indices), but there was no mention of what the fix was. Maybe it’s related to that?

Also I realized that this issue usually occurs when clicking on the model when trying to rotate the camera. Even though my playground doesn’t reproduce the error, it should give you an idea of what my code is doing.

https://www.babylonjs-playground.com/#KM2N07#20

Lastly I should mention that I’m using views since I’m using multiple canvases so maybe that has something to do with it

Nevermind I figured it out. It was an oversight. The crash was caused by this line in my code:

scene.clearCachedVertexData();
scene.cleanCachedTextureBuffer();

I add those 2 lines to reduce the memory footprint as per the documentation (Reduce memory footprint - Babylon.js Documentation), but I didn’t realize it would cause this error.

1 Like