2013-07-19 56 views
2

我有矩形幾何形狀(寬×高尺寸)和質地(2×寬×高),我需要顯示只有一半的是:如何隨時更改紋理UVMapping?

... 
    var pageGeometry = new THREE.PlaneGeometry(pageWidth, pageHeight, 1, 1); 
     var texture = someTexture; 
     pageGeometry.faceVertexUvs[0] = []; 
     pageGeometry.faceVertexUvs[0].push([ 
      new THREE.Vector2(0.5, 1), 
      new THREE.Vector2(0.5, 0), 
      new THREE.Vector2(1, 0), 
      new THREE.Vector2(1, 1)]); 

     var page = new THREE.Mesh(
      pageGeometry, 
      new THREE.MeshLambertMaterial({ 
       color: options.background, 
       map: texture 
      }) 
     ); 

它的工作原理,但亞特有的旋轉(90度)我需要更改紋理偏移量:

page.geometry.faceVertexUvs[0] = []; 
    page.geometry.faceVertexUvs[0].push([ 
     new THREE.Vector2(0, 1), 
     new THREE.Vector2(0, 0), 
     new THREE.Vector2(0.5, 0), 
     new THREE.Vector2(0.5, 1)]); 
    page.material = new THREE.MeshLambertMaterial({ 
     color: options.background, 
     map: textureNext 
    }); 

但它不起作用,偏移量保持不變。

回答

4

你有沒有嘗試過這樣的: https://github.com/mrdoob/three.js/wiki/Updates

即: geometry.uvsNeedUpdate = true;

希望這有助於但無論也許不是在源代碼中的作品,你會肯定需要更換UV後設置此更新標誌 - 我認爲,下屬。

+0

謝謝你,它的工作原理! –