WegGL 和 瀏覽器兼容性檢測
有一些設備和瀏覽器可能不支持webgl。下面的代碼可以做基本的檢測!
如果你下載了three.js的完整包,在examples/js里面有個(gè)Detector.js就是干這個(gè)事情的!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="build/three.js"></script>
<script src="examples/js/Detector.js" type="text/javascript" ></script>
<style type="text/css">
div#container{
border:1px solid red
}
</style>
</head>
<body>
<div id="container">測試結果:
</div>
<script type="text/javascript">
if(Detector.webgl){
/*init();*/
/*animate();*/
alert('支持webgl');
}else{
alert('該版本不支持webgl');
var warning=Detector.getWebGLErrorMessage();
document.getElementById('container').appendChild(warning);
}
</script>
</body>
</html>
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請
點(diǎn)擊舉報。