如何使用新的THREE.TextureLoader加载多个纹理

Ale*_*ein 5 javascript three.js

如何使用Three.js中的新THREE.TextureLoader加载多个纹理?

目前我正在加载我的纹理:

  var texture1 = THREE.ImageUtils.loadTexture('texture1.jpg');
  var texture2 = THREE.ImageUtils.loadTexture('texture2.jpg');
  var texture3 = THREE.ImageUtils.loadTexture('texture3.jpg');
  var texture4 = THREE.ImageUtils.loadTexture('texture4.jpg');
  var texture5 = THREE.ImageUtils.loadTexture('texture5.jpg');
  ...
Run Code Online (Sandbox Code Playgroud)

Google Chrome的开发者工具会发出以下警告:

THREE.ImageUtils.loadTexture已被弃用.请改用THREE.TextureLoader().

我尝试使用新的THREE.TextureLoader:

var loader = new THREE.TextureLoader();

loader.load('texture1.jpg',function ( texture1 ) {});
loader.load('texture2.jpg',function ( texture2 ) {});
loader.load('texture3.jpg',function ( texture3 ) {});
loader.load('texture4.jpg',function ( texture4 ) {});
loader.load('texture5.jpg',function ( texture5 ) {});
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

TextureLoader

Fal*_*ele 13

加载器返回纹理,实际上非常简单:

var loader = new THREE.TextureLoader();
var texture1 = loader.load('texture1.jpg');
var texture2 = loader.load('texture2.jpg');
Run Code Online (Sandbox Code Playgroud)

您可以看到r74dev示例已使用新语法更新:https://github.com/mrdoob/three.js/blob/dev/examples/webgl_decals.html#L49-L51

  • 你*可以*使用那个回调,但你没有*有*.看到这个工作示例,我正在加载两个纹理并在场景中使用它们:http://jsfiddle.net/f17Lz5ux/5398/ (2认同)