I use GLTF2Export GLBAsync encountered an issue while exporting the scene


“babylonjs-serializers”: “^7.42.0”,

import { GLTF2Export } from ‘babylonjs-serializers’;

export const exportGLB = async (scene: Scene, fileName: string) => {
console.log(exportGLB===>, scene);
GLTF2Export.GLBAsync(scene, fileName).then((glb) => {
console.log(glb===>, glb);
glb.downloadFiles();
});
}
I used the above code to export the scene, and all resources have been loaded and materials have been assigned by default.
However, when the model is loaded in Three.jseditor, only attributes, materials, and other information are lost
I don’t know what’s going on here

The issue likely stems from incomplete resource loading or incompatible material definitions between Babylon.js and Three.js. Verify resource loading before export, simplify the scene to isolate the problem, debug material definitions, and ensure you’re using the latest dependencies. If possible, provide a minimal reproducible example for more accurate diagnosis.

I believe we need a kind of repro to debug the problem, otherwise we also will not know what’s going on there…

1 Like

Hello, I have uploaded the sample code to GitHub

Here is the part of your code

import { appendSceneAsync, loadAssetContainerAsync, loadSceneAsync, Scene, SceneLoader } from "@babylonjs/core";
import '@babylonjs/loaders';
import { GLTF2Export } from 'babylonjs-serializers';

You mix 2 types of import, with @ and without @
Change the last import to

import { GLTF2Export } from '@babylonjs/serializers/glTF'

(and change other imports without @, if you have them. You may refer to NPM package instructions, for example @babylonjs/serializers - npm)

2 Likes

Thank you.

1 Like

Thank you .
It has been resolved

1 Like