Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bengsfort/rollup-plugin-gltf
Rollup plugin for importing glTF 3D models as ES6 modules.
https://github.com/bengsfort/rollup-plugin-gltf
Last synced: 27 days ago
JSON representation
Rollup plugin for importing glTF 3D models as ES6 modules.
- Host: GitHub
- URL: https://github.com/bengsfort/rollup-plugin-gltf
- Owner: bengsfort
- License: mit
- Created: 2018-03-29T10:10:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-26T05:03:44.000Z (over 4 years ago)
- Last Synced: 2024-02-15T10:34:01.657Z (10 months ago)
- Language: HTML
- Size: 912 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome - gltf - Import glTF 3d models as a URI or inlined JSON. (Plugins / Other File Imports)
README
# rollup-plugin-gltf
![build status](https://api.travis-ci.org/bengsfort/rollup-plugin-gltf.svg?branch=master) [![npm version](https://badge.fury.io/js/rollup-plugin-gltf.svg)](https://www.npmjs.com/package/rollup-plugin-gltf) ![coverage](coverage/coverage.svg)
Rollup plugin for embedding or copying glTF models into your bundles.
## Installation
```shell
npm install --save-dev rollup-plugin-gltf
```## Usage
```js
// 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.```js
// 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);
});
```### Options
- `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.## License
MIT