javascript - JS syntax issue or using three.js THREE.ImageLoader in a cycle -


think more javascript syntax issue three.js still.. have object "o = {}", textures stored this

o = {     ...     textures: {         one: {               low: { t: new three.texture(), url: 'http://i.imgur.com/tj0ujpt.jpg' },             normal: { t: new three.texture(), url: 'http://i.imgur.com/wbb1nzn.jpg' }         },         two: {               low: { t: new three.texture(), url: 'http://i.imgur.com/9jaozna.jpg' },             normal: { t: new three.texture(), url: 'http://i.imgur.com/p9wo18t.jpg' }             hd: ...             etc..         }          etc..     }     ... } 

what need function can load texture using three.imageloader. also, when textures loaded want run o.texturesonload(); function.

thats have http://jsfiddle.net/nexny/5/ last texture of o.textures working.. think i'm passing variables loader.load( ... ) in wrong way;

hope can me, thanks.

i found solution wrapping loader.load(...) in self executing function.

(function(obj, texture) {     if (current == total) {         // last texture         loader.load( texture.url, function (image){             texture.t.image = image;             texture.t.needsupdate = true;              obj.texturesonload();         });     } else {         loader.load( texture.url, function (image){             texture.t.image = image;             texture.t.needsupdate = true;         });     } })(this, this.textures[texture][quality]); 

http://jsfiddle.net/nexny/6/


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -