Mesh.simplify is not working

Please can someone help Mesh.simplify does not seem to be working, in fact the whole mesh disappears when i try to have 2 LODs :slight_smile:

// Meshes

            const phongMeshes = [];

            const pbrMeshes = [];

            this.fpsCounter.iNumVerts = 0;

            this.fpsCounter.iNumIndices = 0;

            this.fpsCounter.iNumFaces = 0;

            var lodSettings: Array<ISimplificationSettings> = []; //in JS: var settings = new Array();

            lodSettings.push(new SimplificationSettings(1.0, 0, true));

            lodSettings.push(new SimplificationSettings(1.0, 10, true));

            //lodSettings.push(new SimplificationSettings(0.9, 2));

            //lodSettings.push(new SimplificationSettings(0.8, 3));

           // lodSettings.push(new SimplificationSettings(0.7, 4));

           // lodSettings.push(new SimplificationSettings(0.6, 5));

            for (const mesh of container.meshes) {

                if (mesh.material instanceof PBRMaterial) {

                    pbrMeshes.push(mesh);

                } else if (mesh.material instanceof StandardMaterial) {

                    phongMeshes.push(mesh);

                }

                const thisMesh = mesh as Mesh;

                thisMesh.simplify(lodSettings, true);

                // Mesh Optimizations

                mesh.doNotSyncBoundingInfo = true;

                //mesh.material.needDepthPrePass = true;

                //mesh.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;

                //mesh.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;

               

                this.fpsCounter.iNumVerts += thisMesh.getVerticesData.length;

                this.fpsCounter.iNumIndices += thisMesh.getIndices.length;

                this.fpsCounter.iNumFaces += Math.floor( thisMesh.getIndices.length / 3 );

            }

could you reproduce that on the playground?

Im really new to Babylon.JS how would i go about doing that?

Hi @kellyma2010 and welcome to the community

About the playground

By reproducing the error we mean some simple code in the playground that reproduces the error. You can use a built in mesh as your starting point to apply your code to

import an available mesh

or import a mesh of your own

2 Likes

Hello just checking in, was your question answered? @kellyma2010

No not really, but we are considering it in our evaluation (babylon but our meshes are extremely large),
There is not currently any optimizations that i use that seem to have any effect on the scenegraph.

Regards
Mark

Hi,
I am sorry to hear you are having issues with your mesh import. If you cannot import it into the playground, may be you could share a link to your mesh with us (or a similar dummy example mesh).
Without the mesh or a PG, it will be hard to provide with an appropriate answer.
There are many ways (other than LOD) to handle large meshes. Though, we would need to understand what you mean when you say ‘extremely large’.
I can assure you that LOD works in BJS and meshes are imported and transformed with the best level of performance you can get from WebGL2.

1 Like

Its more of a problem in the Typescript the following sample for trying to Mesh.Simplify or do LOD on Mesh has no effect or even completely removes the mesh from the scene :-

I believe you but understand that without the mesh it’s really hard to even just make an assessment of what’s going on…
Edit: @RaananW may be you can detect anything in that script that would explain this (or be worth investigating)?

Can I ask why you are simplifying for quality 1.0 (i.e. 100%) twice? for distance 0 and 10?

Anyhow, it is very hard to know without the actual mesh. Some meshes are not very simplification-friendly TBH.

1 Like