Reputation: 1819
Question : I want my electron app to have a built-in 3d model, what would be the best way to go about it?
I am currently storing it in the dist/models/foot.babylon.When the app is opened I want to load a file in. I tried using fetch('/models/foot.babylon')
, but that didn't work.
My folder structure.
├──.babelrc
├──.eslintrc
├──.flowconfig
├──.gitignore
├──LICENSE
├──README.md
├──dist
│ ├──bundle.css
│ ├──bundle.js
│ ├──index.html
│ └──models
│ ├──foot.babylon
├──main.js
├──package-lock.json
├──package.json
├──src
│ ├──actions
│ │ ├──files.js
│ │ ├──index.js
│ │ └──types.js
│ ├──components
│ ├──containers
│ │ ├──Analyser
│ │ ├──App
│ │ ├──Header
│ │ └──LiveData
│ ├──engines
│ │ ├──RenderEngine.js
│ │ └──Scene.js
│ ├──helpers
│ ├──index.js
│ ├──menu.js
│ ├──reducers
│ ├──routes.js
│ └──store
│ └──index.js
├──template.ejs
├──tools
├──webpack.build.config.js
├──webpack.dev.config.js
└──yarn.lock
I could possibly import it as a string to one of my .js files, but the file size at least 10mb, so it would be slow for bundling.
Upvotes: 0
Views: 99
Reputation: 1464
Your best bet would be to use fs you could create a splash screen when assets load since fs is asynchronous.
fs.readFile(__dirname + "/models/foot.babylon", (err, data) => {
if (err) {
console.error(err);
} else {
console.log(data);
// Process file data
// Remove splash screen and show app
}
});
Upvotes: 1