Laya.timer.frameLoop(1, this, ()=>
{
angle +=1;
if(angle > 360)
{
angle = 0;
}
sp.graphics.clear();
sp.graphics.drawPie(128,128,128,0,angle,"0xff0000");
var tex = sp.drawToTexture(256,256,0,0);
//var html:Laya.HTMLCanvas = sp.drawToCanvas(256,256,0,0);
//img.loadImageSource(html.source,true);
//html.clear();
//html.destroy();
mat.albedoTexture.destroy(); // 先删除旧的
mat.albedoTexture = tex.bitmap; // 再设置新的
// 可以用 drawtotexture这种方式
// 这种比drawToCanvas效率要高,但是其实依然不适合这种不断调用的方式。我们以后会考虑这种需求。
// 这样实现的问题是y是颠倒的(本来这个函数是给2d用的,返回的Texture对象已经颠倒uv了,但是这里只用其中的Texture2D对象),针对这个项目可以通过自己修改uv坐标,或者加翻转矩阵的方法来抵消这种颠倒
});