Unable to fully remove a mesh from a loaded GLTF

Hi,

I am loading a GLTF but iPhones are having a very bad time with transparencies on both Safari & Chrome, with massive FPS drops and can even crash the both browsers after a time… So I thought I would traverse the mesh and then remove it by uuid or name from the blender mesh name.

However I can get it to remove from view but the object still exists on the var that stores the GLTF and scene.children groups still has it in there also.

How do I delete it from view, reference, render, memory? How do I get rid of it so that three doesn’t even know it existed?

I can’t use visibility, it still crashes safari and chrome on iphones.

        this.meshes.gallery.traverse(mesh => {
            if (mesh.isMesh) {
                let lcMeshName = mesh.name.toLowerCase();
                // log(`lcMeshName: ${lcMeshName}`);

                if (mesh.name === "Glass_NO_IPHONE") {
                    console.warn("FOUND")// Finds it
                    mesh.visible = false; // Hides from view but crashes still on iphone
                    
                    // BELOW DOES NOTHING
                    mesh.geometry.dispose();
                    mesh.material.dispose();
                    this.scene.remove(mesh)
                    this.renderer.renderLists.dispose();
                    // log(mesh.parent)

                }
            }
            //
        })

        this.logMeshNames(this.meshes.gallery); // Still find mesh with name removed
        log(this.scene) // still find mesh in drill down in console

Any ideas?

Also any ideas how I can advise the designer to build better windows that are more optimised for three? I don’t have this problem in babylon.

You can only remove a mesh from its parent. Try it with:

mesh.removeFromParent();

Calling dispose() on the geometry and material is important. But I doubt you need the call in context of render lists.

Besides, you should check if the material holds textures. Calling dispose() on those is important as well.

BTW: You only have to call dispose() methods if you have rendered your object once.

You probably want to ask this question separately with more details.

I am labelling mesh’s in Blender adding _no_ios to their names for anything that the 3D designer has supplied me in the GLTF that has a transparency on it, in this case “room windows which reflect the env”, this is all fine on Android but latest os and software on any iPhone in real world and browserstack crash… Thus I am detecting ios, traversing and detecting if name includes “_no_ios” and removing it.

If the windows with env reflection come into display on ios (latest os and version of safari and chrome) the fps drops sometimes as low as 7fps from a solid 58+ on iphone 8 and rock solid 60 on newer.

Android has no problems with it at all… So no windows for iPhone users but desktop and android users will get windows with env reflection.

I would like to do it dynamically, but I think it might just be best to create multiple exports and load a different model in for iPhones.