The same code works in Playground but not in Vite

After testing, it was found that Htmlmesh does not work in Vite5

CreateAndStartAnimation does not work in Vite6

I use vite/5.4.14 darwin-arm64 node-v22.0.0 and HtmlMesh works. There is no reason for vite to influence the behavior of babylon.js.

Maybe you could share more information on your issues.

FWIW: I’m successfully using Vite 6 for a BJS project. Not using HtmlMesh though.

The only BJS specific config I have for Vite is this:

  assetsInclude: ['**/*.glb', 'src/assets/**/*.env'],
  optimizeDeps: {
    exclude: ['@babylonjs/havok'],
  }

After testing, it was found that if you use an svg image as the material background, it will cause the subsequent CreateAndStartAnimation htmlmesh not work

import jtImg from ‘./assets/jt.svg?url’

Sorry, I’m not sure I get this correctly. Do you use animations on HtmlMesh? Those are not working?

@dalidaliW Can you share the

The same code works in Playground but not in Vite

playground?

image
Probably because Vite6 will convert SVG to such an address
Unable to find the SVG address on the network, let’s temporarily switch to PNG

You can use SVGs with vite like this:

Code:

import mySVG from './assets/example.svg';

JSX:

<img src={mySVG} alt="My SVG" />
1 Like