Error with SceneLoader.ImportMeshAsync in Vue/Vite & BabylonJS(6.33.2): Seeking Help with glTF Loader Issue

Hi there!

Reproduce:

Reproduce (click here)
  1. npm create vue@latest
✔ **Project name:** … babylon-reproduce-bug
✔ **Add TypeScript?** … Yes
✔ **Add JSX Support?** … No
✔ **Add Vue Router for Single Page Application development?** … No
✔ **Add Pinia for state management?** … No
✔ **Add Vitest for Unit Testing?** … No
✔ **Add an End-to-End Testing Solution?** › Playwright
✔ **Add ESLint for code quality?** … Yes
✔ **Add Prettier for code formatting?** … Yes
  1. Install default setup: cd babylon-reproduce-bug; npm install; npm run format; npm run dev;
  2. Install Babylon npm i @babylonjs/core @babylonjs/loaders @babylonjs/havok
  3. Add to vite.config.ts:
  optimizeDeps: {
    // https://forum.babylonjs.com/t/unable-to-load-havok-plugin-error-while-loading-wasm-file-from-browser/40289/28?page=2
    exclude: ['@babylonjs/havok'],
  },

because without it will be:

  1. App.vue
<script setup lang="ts">
import "@babylonjs/loaders/glTF"
import HavokPhysics from '@babylonjs/havok'
import { ref } from 'vue'
import { Engine } from '@babylonjs/core'

const canvas = ref<HTMLCanvasElement>();

HavokPhysics().then((hk) => {
  if (!canvas.value) {
    return;
  }
  console.log(hk) // temp

  new Engine(canvas.value, true, {
    preserveDrawingBuffer: true,
    stencil: true,
  })
  // ....
});
</script>

<template>
  <canvas ref="canvas"/>
</template>

Result:

flowGraphExecutionBlock.ts:12 Uncaught TypeError: Class extends value undefined is not a constructor or null
    at flowGraphExecutionBlock.ts:12:7
(anonymous) @ flowGraphExecutionBlock.ts:12

My goal: Just call the function SceneLoader.ImportMeshAsync(…), but @babylonjs/loaders/glTF doesn’t work

It is funny, but I changed all code to babylonjs and babylonjs-loaders (NPM Support | Babylon.js Documentation) instead of @babylonjs/core and “@babylonjs/loaders” and now all is working

Try @babylonjs/loaders instead of @babylonjs/loaders/glTF

Try @babylonjs/loaders instead of @babylonjs/loaders/glTF

I tried, didn’t help

This Vue/Babylon/Havok example may help - GitHub - armomu/ergoudan: Havok physics character controller demo using Babylon.js 6

1 Like

Hmmm… I can’t find a fundamental difference at the moment. I’ll set up it locally tomorrow and compare, thanks

Oh! cc @carolhmj who has fixed this issue in an active PR.

hm, I didn’t find this PR. Could you provide the link?

Was merged yesterday, I am releasing 6.34.1 right now.
PR that fixed it - fix circular dependency by carolhmj · Pull Request #14612 · BabylonJS/Babylon.js (github.com)

2 Likes

I checked. Version 6.34.1 resolves my topic :fire: :+1:

2 Likes