VRMLoader.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. console.warn( "THREE.VRMLoader: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation." );
  2. // VRM Specification: https://dwango.github.io/vrm/vrm_spec/
  3. //
  4. // VRM is based on glTF 2.0 and VRM extension is defined
  5. // in top-level json.extensions.VRM
  6. THREE.VRMLoader = ( function () {
  7. function VRMLoader( manager ) {
  8. if ( THREE.GLTFLoader === undefined ) {
  9. throw new Error( 'THREE.VRMLoader: Import THREE.GLTFLoader.' );
  10. }
  11. THREE.Loader.call( this, manager );
  12. this.gltfLoader = new THREE.GLTFLoader( this.manager );
  13. }
  14. VRMLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
  15. constructor: VRMLoader,
  16. load: function ( url, onLoad, onProgress, onError ) {
  17. var scope = this;
  18. this.gltfLoader.load( url, function ( gltf ) {
  19. try {
  20. scope.parse( gltf, onLoad );
  21. } catch ( e ) {
  22. if ( onError ) {
  23. onError( e );
  24. } else {
  25. console.error( e );
  26. }
  27. scope.manager.itemError( url );
  28. }
  29. }, onProgress, onError );
  30. },
  31. setDRACOLoader: function ( dracoLoader ) {
  32. this.gltfLoader.setDRACOLoader( dracoLoader );
  33. return this;
  34. },
  35. parse: function ( gltf, onLoad ) {
  36. // var gltfParser = gltf.parser;
  37. // var gltfExtensions = gltf.userData.gltfExtensions || {};
  38. // var vrmExtension = gltfExtensions.VRM || {};
  39. // handle VRM Extension here
  40. onLoad( gltf );
  41. }
  42. } );
  43. return VRMLoader;
  44. } )();