How to use KHR extensions to load files?

Hi,

In my react project I’d like to import a gltf file which uses “KHR_draco_mesh_compression” and “KHR_texture_transform” extensions.

By default babylon cannot import the file while also did not complain (just doesn’t show the imported file). I wonder what is the correct way to import the file that uses extensions?

Right now I’m using AssetsManager.addMeshTask to import gltf.

Best,
Chen

Hey!

you should have nothing to do to support it
Does your file work when used with the Sandbox?

Hi @Deltakosh, thanks for your reply.

Yes the file works with the Sandbox, but doesn’t work in my setup (React Project bootstrapped by CRA).

in packages.json:

"@babylonjs/core": "^4.2.0",
"@babylonjs/gui": "^4.2.0",
"@babylonjs/inspector": "^4.2.0",
"@babylonjs/loaders": "^4.2.0",
"@babylonjs/materials": "^4.2.0",
"@babylonjs/procedural-textures": "^4.2.0",

in index.ts:

import '@babylonjs/core/Debug/debugLayer';
import '@babylonjs/inspector';
import '@babylonjs/loaders';

The import function:


// the assets manager does not work
var meshTask = assetsManager.addMeshTask('parseGLTF', '', '', 'data:' + data);
meshTask.run(scene, onSuccess, onError);

// the sceneloader does not work either
SceneLoader.ImportMesh(null, '', 'data:' + data, scene, onSuccess, null, onError);

the error message:

Uncaught (in promise) Error: /textures/0: Error while trying to load image: data:data:{"asset":{"generator":... - Fallback texture was used
    at :3000/static/js/0.chunk.js:437794
    at onInternalError (:3000/static/js/0.chunk.js:124203)
    at Image.errorHandler (:3000/static/js/0.chunk.js:243607)

After upgrading to version 4.2, I can see the following error message:

model.zip (127.0 KB) Here is the gltf model that I’m trying to import.

Pinging @bghgary

Any news on this? Any help would be appreciated. My project is currently stuck here…

Adding @bghgary but it looks like the problem is about the “data:” way of loading. could you try to repro in the playground to simplify the debug ???

Hi @sebavan , thanks for your response:

I reproduced it in the playground here. I got the exact same error.

Perfect, this will help @bghgary a lot !!!

Sorry for the slow response. I’m a bit swamped right now. There definitely seems like there is a bug here. The code is not using the buffer we are passing to the engine to load the texture and it’s because the url (which should be a name for buffer) has a string that looks like base64 encoded data. @ccc159 Can you file an issue on GitHub?

@bghgary Thanks for your reply.

I’ve create a issue here accordingly.

1 Like

I have a fix: Fixes for direct load of glTF by bghgary · Pull Request #9436 · BabylonJS/Babylon.js · GitHub

1 Like

@bghgary Thanks for your effort! I wonder when this fix will be released?

1 Like

PR is merged and the nightly build has the fixes. It should be propagated in the next few hours. For the npm package, we do this weekly early in the week typically.

1 Like

My change was reverted, so it will be a bit longer before it’s ready.

And it’s back in now. Sorry for the delay. Your PG should be working now.

2 Likes