2014-09-23 237 views
0

我不得不加載一個大的obj文件,因爲不支持WebGL加載的計算機變得太慢,所以我必須在完整對象前後上傳一個燈光對象。 爲此,我需要在處理完整對象時旋轉視圖時停止呈現過程。有沒有解決這個問題的功能?謝謝!Three.js停止渲染過程

我的代碼:

var renderWire = function() { 
     renderer.render(wireScene, camera); 
     render(); 
    }; 
    var render = function() { 
     renderer.render(scene, camera); 
    }; 

    $(document).ready(function() { 
     $(document).keypress(function(event) { 
      switch(event.keyCode) { 
       case 100: //destra 
        //rotation 
        break; 
       case 97: //sinistra 
        //rotation 
        break; 
       default: 
        //not set 
        break 
      } 

      //here i have to stop render if running and start a new render 

      renderWire(); 
     }); 
    }); 
+0

實際上加載文件與WebGL無關。 – gaitat 2014-09-23 13:11:01

回答

0

我會試圖以時間來加載一個對象。這樣你就可以控制加載過程的流程。這聽起來像你需要加載3個對象

var firstTexture = THREE.ImageUtils.loadTexture("images/firstTexture.png", undefined, firstObject); 
function firstObject (texture) { 
      var material = new THREE.SpriteMaterial({ map: texture }); 
      firstObject = new THREE.Sprite(material); 
      scene.add(firstObject); 
      var secoundTexture = THREE.ImageUtils.loadTexture("images/secoundTexture.png", undefined, secoundObject); 
     }; 

     function secoundObject (texture) { 
      var material = new THREE.SpriteMaterial({ map: texture }); 
      secoundObject = new THREE.Sprite(material); 
      scene.add(secoundObject); 
      var thirdTexture = THREE.ImageUtils.loadTexture("images/thirdTexture.png", undefined, thirdObject); 
     }; 

     function thirdObject (texture) { 
      var material = new THREE.SpriteMaterial({ map: texture }); 
      thirdObject = new THREE.Sprite(material); 
      scene.add(thirdObject); 
      codeAfterloading(); 
     }; 

     function codeAfterloading() { 

     }; 

我希望這可以幫助你。