Importing and Implementing Havok in Vite\ React + Ts Project Fails

Babylon expects to find HavokPhysics.wasm in the same folder as HavokPhysics.js.

Vite will correctly copy it when building, but not while in dev mode.

You can see what Vite is building and serving in dev mode under ../node_modules/.vite/deps/.

You can configure Vite to serve Havok from its original location.

You might need to adjust the allowed path based on your configuration.

Add this to your vite.config.ts:

 server: {
        fs: {
          // Allow serving files outside of the root
          allow: [
            "../.."
          ]
        }
      },
optimizeDeps: { exclude: ["@babylonjs/havok"] },
5 Likes