VRMLoader.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * @author Takahiro / https://github.com/takahirox
  3. */
  4. import {
  5. Loader
  6. } from "../../../build/three.module.js";
  7. import { GLTFLoader } from "../loaders/GLTFLoader.js";
  8. // VRM Specification: https://dwango.github.io/vrm/vrm_spec/
  9. //
  10. // VRM is based on glTF 2.0 and VRM extension is defined
  11. // in top-level json.extensions.VRM
  12. var VRMLoader = ( function () {
  13. function VRMLoader( manager ) {
  14. if ( GLTFLoader === undefined ) {
  15. throw new Error( 'THREE.VRMLoader: Import GLTFLoader.' );
  16. }
  17. Loader.call( this, manager );
  18. this.gltfLoader = new GLTFLoader( this.manager );
  19. }
  20. VRMLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
  21. constructor: VRMLoader,
  22. load: function ( url, onLoad, onProgress, onError ) {
  23. var scope = this;
  24. this.gltfLoader.load( url, function ( gltf ) {
  25. scope.parse( gltf, onLoad );
  26. }, onProgress, onError );
  27. },
  28. setDRACOLoader: function ( dracoLoader ) {
  29. this.gltfLoader.setDRACOLoader( dracoLoader );
  30. return this;
  31. },
  32. parse: function ( gltf, onLoad ) {
  33. // var gltfParser = gltf.parser;
  34. // var gltfExtensions = gltf.userData.gltfExtensions || {};
  35. // var vrmExtension = gltfExtensions.VRM || {};
  36. // handle VRM Extension here
  37. onLoad( gltf );
  38. }
  39. } );
  40. return VRMLoader;
  41. } )();
  42. export { VRMLoader };