VRMLoader.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
  14. this.gltfLoader = new THREE.GLTFLoader( this.manager );
  15. }
  16. VRMLoader.prototype = {
  17. constructor: VRMLoader,
  18. crossOrigin: 'Anonymous',
  19. load: function ( url, onLoad, onProgress, onError ) {
  20. this.gltfLoader.load( url, onLoad, onProgress, onError );
  21. },
  22. setCrossOrigin: function ( value ) {
  23. this.glTFLoader.setCrossOrigin( value );
  24. return this;
  25. },
  26. setPath: function ( value ) {
  27. this.glTFLoader.setPath( value );
  28. return this;
  29. },
  30. setDRACOLoader: function ( dracoLoader ) {
  31. this.glTFLoader.setDRACOLoader( dracoLoader );
  32. return this;
  33. }
  34. };
  35. return VRMLoader;
  36. } )();