Three.js loadTexture onload callback

时间:2015-08-07 16:54:50

标签: javascript asynchronous three.js

如何等待图像加载到three.js?我正在做以下事情:

function myClass {

  var IMAGE, TEXTURE;

  IMAGE = ...; // properly initialised image object

  function asyncFunc() {

    TEXTURE.minFilter = THREE.LinearFilter;
    ... // rest of code

  }

  myClass.prototype.loadSomething = function(args) {

    var base64Image = IMAGE.src;

    TEXTURE = THREE.ImageUtils.loadTexture(
      base64Image,
      {},
      asyncFunc(args)
    );

  };

}

在我的main.js中,我呼吁以下内容:

var x = new myClass();
x.loadSomething(args);

但是,我收到TEXTURE未定义的错误。我希望在加载纹理后调用asyncFunc(),但它不是。

关于如何处理异步纹理加载的任何想法?

0 个答案:

没有答案