2014-06-08 85 views
0

我正在處理響應網站,因此需要給帆布100%的垂直和水平寬度 - 但它以某種方式不起作用。 我發現,有可能在平面着色器(fss.js)大小爲100%?

var geometry = new FSS.Plane(600, 400, 6, 4); 

在腳本窗口改變一些值,H和W不過遺憾的是它並不需要百分比。

  1. 演示:http://jsfiddle.net/99DS3/1/
  2. 演示:http://codepen.io/wouwi/pen/Apvaq(別人用它的SVG版本嘗試,它以某種方式得到了100%)

編輯:我已經嘗試設置w和h的畫布CSS到100%(即使使用!important) - 沒有工作。

+0

它更新到新源 – Cruto

+0

採取窗口H + W於準備好了嗎?類似的東西? – Cruto

+0

我剛剛發佈了一個答案,我刪除了我的意見,以保持這個清潔。 –

回答

2

如果您只是擦除畫布並重新創建飛機,該怎麼辦?

相關JS:

function resize() { 
    var width = container.offsetWidth, // No need to query these twice, when in an onresize they can be expensive 
     height = container.offsetHeight; 

    renderer.setSize(width, height); 

    scene.remove(mesh); // Remove the mesh and clear the canvas 
    renderer.clear(); 

    geometry = new FSS.Plane(width, height, 6, 4); // Recreate the plane and then mesh 
    mesh = new FSS.Mesh(geometry, material); 

    scene.add(mesh); // Readd the mesh 
} 

演示:http://jsfiddle.net/SO_AMK/99DS3/3/

+0

完美!謝謝!我是一個JS初學者,但我很高興有人像你們一樣拿出這樣的解決方案:) – Cruto

+0

我以前從來沒有聽說過FSS,我只是看了一下在codepen演示中做了什麼以及試圖去適應它。 –