title: javascript make a new class
body: <p>I have some code for load an object in to javascript/three js.
  This code I want to have in a differnt class so I have a smaller code.</p>
  
  <p>The following code I want to have in a class</p>
  
  <pre><code>var manager = new THREE.LoadingManager();
  manager.onProgress = function ( item, loaded, total ) {};
  
  var texture = new THREE.Texture();
  var onProgress = function ( xhr ) {
      if ( xhr.lengthComputable ) {
          var percentComplete = xhr.loaded / xhr.total * 100;
          console.log( Math.round(percentComplete, 2) + '% downloaded' );
      }
  };
  var onError = function ( xhr ) {};
  
  var loaderA = new THREE.ImageLoader( manager );
  loaderA.load('sig.png', function ( image ) {
      texture.image = image;
      texture.needsUpdate = true;
  });
  
  var loaderB = new THREE.OBJLoader( manager );
  loaderB.load( 'hoesjes/hoes.obj', function ( object ) {
      object.traverse( function ( child ) {
          if ( child instanceof THREE.Mesh ) {
              child.material.map = texture;
          }
      } );
  
      this.objectLoader.position.x = xpos;
      this.objectLoader.position.y = ypos;
      this.objectLoader.position.z = zpos;  
  
      object.position.y = - 20;
      scene.add( object );
  }, onProgress, onError );
  
  } 
  </code></pre>
  
  <p>Is it right if I make an class with constructor like below?</p>
  
  <pre><code>class objectLoader
  
  constructor(xpos, ypos, zpos) {
      var manager = new THREE.LoadingManager();
      manager.onProgress = function ( item, loaded, total ) {};
      var texture = new THREE.Texture();
  
      var onProgress = function ( xhr ) {
          if ( xhr.lengthComputable ) {
              var percentComplete = xhr.loaded / xhr.total * 100;
              console.log( Math.round(percentComplete, 2) + '% downloaded' );
          }
      };
      var onError = function ( xhr ) {};
  
      var loaderA = new THREE.ImageLoader( manager );
      loaderA.load('sig.png', function ( image ) {
          texture.image = image;
          texture.needsUpdate = true;
      } );
  
      var loaderB = new THREE.OBJLoader( manager );
      loaderB.load( 'hoesjes/hoes.obj', function ( object ) {
          object.traverse( function ( child ) {
              if ( child instanceof THREE.Mesh ) {
                  child.material.map = texture;
              }
          } );
          this.objectLoader.position.x = xpos;
          this.objectLoader.position.y = ypos;
          this.objectLoader.position.z = zpos;  
  
          object.position.y = - 20;
          scene.add( object );
      }, onProgress, onError );
  }
  </code></pre>
  
  <p>} </p>
  
  <p>If this is right how do I call it on my mainpage? Thanks in advance</p>