GithubHelp home page GithubHelp logo

isabella232 / three-gltf-plugins Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrdoob/three-gltf-plugins

0.0 0.0 0.0 26.3 MB

Unofficial Three.js glTF loader/exporter plugins

License: MIT License

JavaScript 99.97% HTML 0.03%

three-gltf-plugins's Introduction

three-gltf-plugins

npm version

Three.js glTF loader and exporter have plugin system to provide extensibility mechanism to users. glTF extensions can be handled with the plugin system.

Some plugins for major and stable extensions are built-in in the loader and exporter. But other extensions are not supported as built-in by them (yet) because for example the specification is not great fit to Three.js API or structure, or the specification is not finalized.

If you want to use such extensions you need to write plugins by yourself but it requires the knowledge of glTF specification, extensions specification, Three.js core API, or Three.js glTF loader/exporter API. It can be difficult for some users.

This project provides you Three.js glTF loader/extension plugins even for such extensions. You no longer need to write the plugin on your own.

Goals

  • Provide reusablity and easiness to use even for the the extensions the spec of which isn't great fit to Three.js API or structure
  • Allow early trial of glTF extensions the spec of which is not finalized yet
  • Send feedback to Three.js glTF loader/exporter plugin system APIs

Online demo

Supported glTF extensions

Compatible Three.js revision

>= r126dev

How to use

GLTFLoader plugins

// Import Three.js
import * as THREE from 'path_to_three.module.js';
import {GLTFLoader} from 'path_to_GLTFLoader.js';

// Import three-gltf-plugins loader plugins
import GLTFFooExtension from 'path_to_three-gltf-plugins/loaders/Foo_extension/Foo_extension.js';

// Register the plugin to the loader and then load glTF
const loader = new GLTFLoader();
loader.register(parser => new GLTFFooExtension(parser));
loader.load(path_to_gltf_asset, gltf => {
  ...
});

GLTFExporter plugins

// Import Three.js
import * as THREE from 'path_to_three.module.js';
import {GLTFExporter} from 'path_to_GLTFExporter.js';

// Import three-gltf-plugins exporter plugins
import GLTFExporterFooExtension from 'path_to_three-gltf-plugins/exporters/Foo_extension/Foo_extension_exporter.js';

// Register the plugin to the exporter and then export Three.js objects
const exporter = new GLTFExporter();
exporter.register(writer => new GLTFExporterFooExtension(writer));
exporter.parse(scene, result => {
  ...
});

Refer to each plugin's README for more detail.

Locally run examples

$ npm install
$ npm start
# Access http://localhost:8080/examples/index.html

Unit Test

Unit Test on Web browser

$ npm install
$ npm run test-install
$ npm run test-build
$ npm start
# Access http://localhost:8080/test/index.html

Unit Test on Node.js

$ npm run test-install
$ npm run test

Note that the unit tests which rely on Web don't run. I recommend to run the unit tests on Web browser.

Customize the plugins in your side

As written above, some extensions are not great fit to Three.js API or structure. So the plugins for them may have some limitations. If they don't cover your use case, please fork the repository and customize in your side.

three-gltf-plugins's People

Contributors

takahirox avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.