Webpack GLTF loader 2
A webpack loader for .gltf
files, should automatically bundles all referenced files.
Based on the work by Magnus Bergman but rewritten almost from scratch.
https://www.npmjs.com/package/gltf-loader this is his original loader that didn't work for me when I tried so I decided to rewrite it.
(it also doesn't have a valid github repository to contribute to, as of today, 10/05/2018)
WARNING: this is pretty much untested and alpha version, contrubutions appreciated
Webpack configuration
rules: [
{
test: /\.(png|jpe?g|gif)(\?.*)?$/,
exclude: /gltf/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'img/[name].[hash:7].[ext]'
}
},
{
test: /\.(gltf)$/,
loader: 'gltf-loader-2'
},
{
test: /gltf.*\.(bin|png|jpe?g|gif)$/,
loader: 'file-loader',
options: {
name: 'gltf/[name].[hash:7].[ext]'
}
}
]
Usage Example in Three.js
import gltfFile from 'assets/gltf/some.gltf';
var loader = new GLTFLoader()
loader.parse(shieldGLTF, '', (gltf) => {
let scene = gltf.scene
})