VRMLoader.js 1.2 KB

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