GLTFLoader parse method not works with dracoloader

Hello,
When I try to load .glb files compressed with draco, I cannot load them on my scene with a the parse method of GLTFLoader.

For some reason I cannot use the load method to load my models.

My loader code :

const loader = new GLTFLoader();
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('/draco/gltf/');

loader.setDRACOLoader(dracoLoader);

loader.parse(buffer, undefined, (gltf) => {
	resolve(gltf);
});

Error : “SyntaxError: expected expression, got ‘<’”

This code works with not compressed .glb

I hope you could help me.

Thanks

Can you please verify if you can import the DRACO compressed glTF asset into the three.js editor via drag’n’drop? The code in the editor does not use load(), too.

I don’t see the texture of the model, but it works.

I also try on babylonjs and it works too (with the textures and materials this time).


After more research, I suspect that the problem doesn’t came from the parse method, but from create react app loading.

You might have to add some lights to the scene.

But yeah, when it works in the editor it’s probably a project setup issue.

I have found the solution !

I finally used the gstatic decoder’s path instead of a wrong relative path.

Thank for your help.

2 Likes