Unable to download Scene on Mobile app

Hello Team

I have written an animation and rendered it on a mobile app using React Native Expo and Three.js.

Now I want to export that animation in GLTF format and save it on mobile (not a web application) or any format that I can open later on mobile as 3d image, However I am getting an error.

My Code:

        const exporter = new GLTFExporter();
        exporter.parse( scene, function ( gltf ) {
            //console.log( "GLTF Exporter",gltf );
            const output = JSON.stringify(gltf,null,2);
            console.log("Output", output);
            saveString(output,'scene.gltf');
        // downloadJSON( gltf );
        } , {});

Getting an error on exporter.parse line:

undefined is not an object (evaluating ‘image.width’)

I am not too sure where to set the width of an image.

I tried to set through options but nothing worked.

It will be really helpful if you can redirect me here in the right direction.
Really thanks for your help.

Code I followed to export as GLTF:

it looks like scene is not defined in the scope, can you provide more of your code to debug or a live example?

Thanks for your reply.
Important point to note here is , I am using this on my mobile app and 3d functionality is displayed perfectly on app using this code.
However I want to download/export that 3d scene on my mobile for which I need help.

<GLView
onContextCreate={gl => {
const scene = new THREE.Scene();
scene.name=‘photo’;
const camera = new THREE.PerspectiveCamera(
75, gl.drawingBufferWidth / gl.drawingBufferHeight, 0.1, 1000
);
const renderer = new Renderer({ gl });
renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight);
const geometry = new THREE.SphereBufferGeometry(1, 36, 36);
var image = “img.jpeg”; //Pulling image from some other source
var expoAsset = new Expo.Asset({ uri: image });
expoAsset.downloaded = true;
expoAsset.localUri = expoAsset.uri;
var texture = new TextureLoader().load(expoAsset);
const material = new THREE.MeshBasicMaterial({
map: texture

        });

        const sphere = new THREE.Mesh(geometry, material);
        scene.add(sphere);
        const render = () => {
            requestAnimationFrame(render);
            sphere.rotation.x += 0.0001;
            sphere.rotation.y -= 0.002;
            renderer.render(scene, camera);
            gl.endFrameEXP();
        };
        render();
        const exporter = new GLTFExporter();
        exporter.parse( texture, function ( gltf ) {
        const output = JSON.stringify(gltf,null,2);
         saveString(output,'scene.gltf');

        // downloadJSON( gltf );

        } , {});
        function save( blob, filename ) {
            link.href = URL.createObjectURL( blob );
            link.download = filename;
            link.click();
        }
        function saveString( text, filename ) {
            save( new Blob( [ text ], { type: 'text/plain' } ), filename );
        }
    }}
/>

Anyone got any solution?