Problem with Simplifying models using SimplifyModifier

I am trying to reduce the number of vertices/meshes in my model by using the SimplifierModifier module. I copied the three js example and ran it with my own gltf model. But I keep getting an error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'clone')

which originates from the .clone() line in the example:

new GLTFLoader().load( 'test.glb', function ( gltf ) {

const mesh = gltf.scene.children[ 0 ];
mesh.position.x = - 3;
mesh.rotation.y = Math.PI / 2;
scene.add( mesh );

const modifier = new SimplifyModifier();
const simplified = mesh.clone();
simplified.material = simplified.material.clone();
simplified.material.flatShading = true;
const count = Math.floor( simplified.geometry.attributes.position.count * 0.875 ); // number of vertices to remove
simplified.geometry = modifier.modify( simplified.geometry, count );

simplified.position.x = 3;
simplified.rotation.y = - Math.PI / 2;
scene.add( simplified );


I thought that I might be using an old version so here is my three js versioning:

<script async src=""></script>
    <script type="importmap">
        "imports": {
            "three": ""

<script type="module">

      import * as THREE from 'three';

      import { OrbitControls } from '';
      import { GLTFLoader } from '';
      import { SimplifyModifier } from '';

But the error is still the same which seems to be stating that there is no function called clone().

Much of your code appears to be missing in the example above.

I think the most likely cause is that whatever object you’re working with is not a THREE.Mesh instance. The result of a GLTFLoader loading callback, e.g. gltf.scene is a THREE.Group. To simplify meshes in that group (there may be many) you’ll need to use traverse() and simplify each of them.