How to use GLTFLoader in node js environment ?

I am facing the issues while using GLTFLoader in node js environment. I want to parse the GLB file data, So I used loader.load() and loader.parse() as mention in the documents GLTFLoader.

** I am aware** that GLTFLoader.js needed some dependency like XMLHttpRequest and my glb files has textures so HTMLImageElement also needed.

So any other way to do it ?

Thanks in Advance @mrdoob

It might help to clarify what you plan to do with three.js and GLTFLoader in Node.js. Are you trying to render headlessly? Modify the file somehow? Something else?

GLTFLoader is (as you mention) not supported in Node.js without those workarounds. Depending on your goals there may be solutions that do not involve GLTFLoader.

1 Like

Thanks for the quick reply.
So basically I want that parse data and further I have to work on that, but on backend side on Node js. can you please tell me what need to do so I can use this functions/methods - load() and parse() with node js environment.

Sorry but this does not help, “I have to work on that” does not tell me what you are doing. Do you need to render a screenshot of the model? Modify the model and save it to disk? Or something else?

1 Like
    let  loader = new THREE.GLTFLoader();
    loader.parse(arrayBuffer, url,
        (onLoade)=> {
            let object = new THREE.Group();
            let mesh = onLoade.scene.children[0];
            if(mesh.type.toLowerCase() == "mesh"){
            else if(mesh.children[0].type.toLowerCase() == "mesh"){
                mesh = mesh.children[0];

So, basically I want mesh of that GLB file.

If you need a THREE.Mesh instance to be created, then you must use GLTFLoader. If you just need some raw data out of the mesh then there are other ways to do it.