一覧へ戻る
bengsfort/rollup-plugin-gltf(新しいタブで開きます)
主要言語: HTML
Rollup plugin for importing glTF 3D models as ES6 modules.
- star 数
- 12
- watcher 数
- 0
- fork 数
- 0
- issue 数
- 0
- 最終更新
- 2020/06/26
主要言語: HTML
Rollup plugin for importing glTF 3D models as ES6 modules.
Rollup plugin for embedding or copying glTF models into your bundles.
npm install --save-dev rollup-plugin-gltf
// rollup.config.js import gltf from 'rollup-plugin-gltf'; export default { entry: 'src/index.js', dest: 'dist/js/bundle.js', plugins: [ gltf({ include: '**/*.gltf', exclude: 'artwork/*.gltf', inlineAssetLimit: 250 * 1024, // 250kb inline: false, }), ], };
The importer will read through the gltf file and copy over / embed any assets within the file, then expose the file to JS as either a json object or uri.
// three.js usecase example import chestModel from './assets/chest.gltf'; const loader = new GLTFLoader(); // If `options.inline` is true loader.parse(chestModel, function(gltf) { scene.add(gltf.scene); }); // If `options.inline` is false loader.load(chestModel, function(gltf) { scene.add(gltf.scene); });
include: (optional) The glob for file patterns that should be included. Defaults to all .gltf files.exclude: (optional) The glob for file patterns that should be excluded.inlineAssetLimit: (optional) The size (in bytes) at which to copy asset files over rather than embed them into the gltf file. Defaults to 76800.inline: Boolean determining whether to expose the resolved gltf file as json rather than a uri to the asset.MIT