# Problem with using THREE.js as function object (class imitation)

**URL:** <https://discourse.threejs.org/t/problem-with-using-three-js-as-function-object-class-imitation/6113>\
**Category:** Questions\
**Tags:** loaders\
**Created:** [February 13, 2019, 8:56pm UTC](https://discourse.threejs.org/t/problem-with-using-three-js-as-function-object-class-imitation/6113 "2019-02-13T20:56:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arrowman](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@arrowman](https://discourse.threejs.org/u/arrowman)\
**Post date:** [February 13, 2019, 8:56pm UTC](https://discourse.threejs.org/t/problem-with-using-three-js-as-function-object-class-imitation/6113/1 "2019-02-13T20:56:24Z")

</div>

Hello,  
I am sorry for topis and primitive nomenclature. I don’t know what names these things have.  
I don’t understand what in _function(image, texture)_ I don’t have acces to one of texture variable defined above (this.texture, var texture)?

```
this.texture = new THREE.Texture();
var texture = new THREE.Texture();

var loader = new THREE.ImageLoader(manager);
loader.load(
  path,
  function(image, texture) {
	texture.image = image;
	texture.needsUpdate = true;
  }

```

In general I would like to create “class” like this:

```
var MyObjloader = function () {
   this.init();
};

MyObjloader.prototype.init = function() { (...) };
MyObjloader.prototype.render = function() { (...) };
MyObjloader.prototype.loadObj = function() { (...) };
(...)

```

Is this possible that way?

Should I use variable which I want to have range range only inside one of instance of MyObjLoader by that way:  
`MyObjLoader.variableName;`  
Inside methods etc.?

Thanks,  
A.

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [February 14, 2019, 10:14am UTC](https://discourse.threejs.org/t/problem-with-using-three-js-as-function-object-class-imitation/6113/2 "2019-02-14T10:14:09Z")

</div>

The `onLoad()` callback of `THREE.ImageLoader` does only have a **single** parameter (the loaded image). The correct usage looks like this which is essentially the code from `TextureLoader`:

```auto
var texture = new Texture();

var loader = new ImageLoader( this.manager );
loader.setCrossOrigin( this.crossOrigin );
loader.setPath( this.path );

loader.load( url, function ( image ) {

    texture.image = image;

    // more code...

} );

```
