//clear context references
Laya.Render._context.destroy(false);
Laya.RenderContext3D._instance.scene = null;
Laya.RenderContext3D._instance.camera = null;
//clearshaders
let shaderIncetance = Laya.RenderContext3D._instance.shader;
shaderIncetance.destroy();
Laya.RenderContext3D._instance.shader = null;
for (let shaderKey in Laya.Shader3D._preCompileShader)
{
Laya.Shader3D._preCompileShader[shaderKey]._subShaders.forEach(subShader =>
{
subShader._passes.forEach(pass =>
{
pass._cacheSharders.forEach(cache =>
{
cache && cache.forEach(allInstance =>
{
allInstance && allInstance.forEach(ins =>
{
ins && ins.destroy();
})
allInstance = [];
})
cache = [];
})
pass._cacheSharders = [];
})
})
};
添加以上代码后,可以强行清除引用并且清空内存,但是这种做法感觉不太科学,求大佬提供更多思路