2016-03-14 37 views
0

我正在尋找使用P5.js製作雲粒子系統。我打算有很多帶有PNG雲紋理填充的橢圓。然後用這些橢圓編程一個系統。p5.js將紋理加載到二維橢圓上

不幸的是,我得到一個錯誤,當我嘗試應用紋理p5.js

遺漏的類型錯誤:this._renderer._getShader不是一個函數

var cloudImg; 

//P5 Setup 
function setup(){ 
    createCanvas(1500, 750); 
    background('rgba(0, 0, 0, 0.3)'); 
    cloudImg = loadImage("cloud100.png"), 
    numParts = 80, 
    diam = 100; 
} 


//Render 
function draw(){ 
    background(0); 
    translate(mouseX, mouseY); 
    beginShape(); 
    texture(cloudImg); 
    var theta = TWO_PI/numParts; 
    for (i=0; i<numParts; i++) { 
    var angle = theta * i, 
     x = cos(angle), 
     y = sin(angle); 
    vertex(x * diam, y * diam, (x+1)/2, (y+1)/2); 
    } 
    endShape(); 
} 
+0

什麼行會拋出錯誤?你有沒有嘗試過使用[preload()](http://p5js.org/reference/#/p5/preload)函數? –

+0

這是p5.min.js中的一行...我必須看一下預載 –

回答

0

我覺得texture()需要webgl爲渲染。

嘗試createCanvas(1500, 750, WEBGL);

點擊here看到texture()的官方文件。