我在three.js中使用图像纹理,图像将在运行时更改。像这样的代码。
var geom1 = new THREE.PlaneGeometry(50, 50);
var map1 = new THREE.ImageUtils.loadTexture('0.png');
var material = new THREE.MeshBasicMaterial({map: map1, side: THREE.DoubleSide});
var mesh1 = new THREE.Mesh(geom1, material1);
scene.add(mesh1);
renderer.render(scene, camera);
//then '0.png' changed
//...
//then following codes run, I need remove mesh1 and create a new mesh
scene.remove(mesh1);
renderer.render(scene, camera);
var geom2 = new THREE.PlaneGeometry(50, 50);
var map2 = new THREE.ImageUtils.loadTexture('0.png');
var material2 = new THREE.MeshBasicMaterial({map: map2, side: THREE.DoubleSide});
var mesh2 = new THREE.Mesh(geom2, material2);
scene.add(mesh2)
renderer.render(scene, camera);
但mesh2中使用的图像纹理不变。我似乎需要使用needsUpdate
。我在创建map2.needsUpdate = true
后使用map2
,在创建map2时使用回调函数,但它不起作用。
我正在使用three.min.js r70
和Firefox 36.0.1
。