GLTF2Export.GLBAsync function returning incorrect glb files in Vue.js

Hello everyone

I’m encountering an issue with the GLTF2Export.GLBAsync function in Babylon.js. When using this function to my scene or mesh to GLB, it seems to be returning incorrect glb files.
I can’t open this glb file in https://sandbox.babylonjs.com/ and also in my project.

Here’s the code I’m using:

import {Scene, Engine, FreeCamera, Vector3, HemisphericLight, MeshBuilder, CubeTexture, PBRMaterial, Texture, SceneLoader, Color3} from "@babylonjs/core"

import "@babylonjs/loaders"
import { GLTF2Export } from "babylonjs-serializers";

export class CustomModels{
    scene: Scene;
    engine: Engine;

    constructor(private canvas:HTMLCanvasElement){
        this.engine = new Engine(this.canvas, true);
        this.scene = new Scene(this.engine);

        const camera = new FreeCamera("camera", new Vector3(0,1,-5), this.scene);
        camera.attachControl();
        camera.speed = 0.25;

        const hemiLight = new HemisphericLight("hemiLight", new Vector3(0,1,0), this.scene);

        hemiLight.intensity = 1;

        const material = new PBRMaterial("pbr", this.scene);
        material.albedoColor = new Color3(1, 1, 1);
        material.metallic = 0;
        material.roughness = 0;
    
        const cube = MeshBuilder.CreateBox("cube", {}, this.scene);
        cube.position.y = 1;
        cube.material = material;

        // SceneLoader.ImportMeshAsync("","./models/", "test.glb");
        
        this.engine.runRenderLoop(()=>{
            this.scene.render();
        })

        GLTF2Export.GLBAsync(this.scene, "test").then((glb) => {
            glb.downloadFiles();
        });
    }
}

And versions are like this
@babylonjs/core”: “^6.4.0”,
@babylonjs/loaders”: “^6.4.0”,
“babylonjs-serializers”: “^6.4.0”,
“vue”: “^3.2.13”

I have try the same code in playground, and it works correctly

export by playground glb file is like this

and export by my vue.js project file is like this

I would appreciate any insights or suggestions on how to resolve this issue. Thank you!

I change
“babylonjs-serializers”: “^6.4.0”
to
@babylonjs/serializers”: “^6.4.0”,
and fix it

2 Likes