jahow 146 Report post Posted March 3, 2015 Hi, I'm currently doing heavy optimization work, and having a great time (kidding). Bringing the draw call count down etc. As such, merging meshes for static geometry is an absolute necessity. There is an 'old' tutorial about that here, but I figured I'd try the modern way which is using Mesh.MergeMeshes. It didn't give me immediately expected behaviour: 1/ I realized I was trying to merge cloned meshes, and BJS made the browser freeze since it basically tried to merge an array with itself. I fixed the problem by using makeGeometryUnique on the meshes before merging, but that is kind of counter-intuitive (also there's a small bug on Geometry.clone() so it won't work that way in the playground either, but I've fixed this one locally). 2/ I've also found I needed to force a new computation of the meshes' world matrices before doing the merging. Again, this is kind of counter-intuitive and may lead to a lot of head banging on wall (it did with me). These issues are illustrated in this playground: http://www.babylonjs-playground.com/#2FQOTS Is this behaviour intentional/acceptable? If the answer is no, I'll gladly work on a PR to fix it. Otherwise, I guess this could all be explained in the documentation (which needs updating anyway). Quote Share this post Link to post Share on other sites
Deltakosh 4315 Report post Posted March 4, 2015 I suggest you checking what I'm doing there:https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Tools/babylon.sceneOptimizer.ts#L115 More doc on SceneOptimizer:http://doc.babylonjs.com/page.php?p=22581 Quote Share this post Link to post Share on other sites
jahow 146 Report post Posted March 4, 2015 Thanks, I had not looked into that but it's interesting. I also realized I needed to do a forced matrix computation because I was merging the meshes before any render happened. Still, wouldn't that be easier to automatically recompute the meshes' world matrices before merging them? Also, the MergeMeshOptimization still fails if we're using cloned meshes... Quote Share this post Link to post Share on other sites
Deltakosh 4315 Report post Posted March 4, 2015 Yes and I saw your PR (i'll validate it quickly) Quote Share this post Link to post Share on other sites