Error loading player: Unable to load from

Hey everone! :smiley:
I have solved the problem in the following way:

Instead of serving the models directory using the webpack dev server, I have copy the models directory to the build directory using the copy-webpack-plugin. This way, the models will be available in the same directory structure in my build output.

First, I had to need to install the copy-webpack-plugin with:

npm install copy-webpack-plugin --save-dev

or

npm install --save-dev copy-webpack-plugin@latest

Then, I add it to mywebpack.common.js configuration:

const CopyPlugin = require('copy-webpack-plugin');

module.exports = {
  // ...
  plugins: [
    new CopyPlugin({
      patterns: [
        { from: 'src/Resources/models', to: 'Resources/models' },
      ],
    }),
  ],
  // ...
}

This configuration tells webpack to copy the contents of src/Resources/models to Resources/models in my build directory.

Once I’ve done this, I had restart my webpack server and try loading the model again.

Note: Make sure your path to the model is correct when you load it in your application. If your build output directory is set as dist, then the model should be available at /Resources/models/yacht.glb after the build.

2 Likes