VRMLoader.js 1.7 KB

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