2017-03-21 183 views
-1

我正在使用Threejs我正在面對紋理問題,所以我想問一個問題,就是如何在不啓動動畫的情況下加載紋理,它顯示空白圖像而不啓動動畫。誰能告訴我如何做到這一點..關於Threejs紋理動畫

/////code/////////////////// 
var geometry = new THREE.PlaneGeometry(15, 5.3, 2); 
var te = new THREE.ImageUtils.loadTexture("b4.jpg") ; 
var material = new THREE.MeshBasicMaterial({color: "",map:te}); 
plane = new THREE.Mesh(geometry, material); 
plane.position.set(-12.89,-7.2,19); 
plane.visible=false; 
scene.add(plane); 
//////code//////////////////// 
+0

請一些代碼添加到您的問題說明你是如何設定目前動畫紋理。 –

回答

0

你有嘗試有一個回調函數觸發紋理成功加載後?怎麼樣它在文檔中進行:https://threejs.org/docs/?q=textUr#Reference/Loaders/TextureLoader

因此,像:

var geometry = new THREE.PlaneGeometry(15, 5.3, 2); 

var loader = new THREE.TextureLoader(); 
// load a resource 
loader.load(
    // resource URL 
    'b4.jpg', 
    // Function when resource is loaded 
    function (texture) { 
     // do something with the texture 
     var material = new THREE.MeshBasicMaterial({color: "",map:te}); 
     plane = new THREE.Mesh(geometry, material); 

     plane.position.set(-12.89,-7.2,19); 

     plane.visible=false; 

     scene.add(plane); 
    }, 
    // Function called when download errors 
    function (xhr) { 
     console.log('An error happened'); 
    } 
);