VRMLoader.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. scope.parse( gltf, onLoad );
  23. }, onProgress, onError );
  24. },
  25. setDRACOLoader: function ( dracoLoader ) {
  26. this.glTFLoader.setDRACOLoader( dracoLoader );
  27. return this;
  28. },
  29. parse: function ( gltf, onLoad ) {
  30. // var gltfParser = gltf.parser;
  31. // var gltfExtensions = gltf.userData.gltfExtensions || {};
  32. // var vrmExtension = gltfExtensions.VRM || {};
  33. // handle VRM Extension here
  34. onLoad( gltf );
  35. }
  36. } );
  37. return VRMLoader;
  38. } )();