Questions about onPointerObservable

We finally have the explanation!!

The slow version is slow because with more than 1 million faces the memory cache is not as efficient as the other version.
Why? Because the slow version has faces dispatched in a random order where the fast version has faces gathered if they share common vertices.

To get rid of that we have introduce a new feature on mesh:

const terrain = scene.getMeshByName("Terrain");
await terrain.optimizeIndicesAsync();

That function will reorganize the indices to maximize cache hit.

PR: Add a new optimizeIndices features to improve cache hit on large models by deltakosh · Pull Request #16009 · BabylonJS/Babylon.js

1 Like