WebGL-compatibility-check.html 1016 B

1234567891011121314151617181920212223242526272829303132333435
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8">
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>WebGL兼容性检查([name])</h1>
  11. <p>
  12. 虽然这个问题现在已经变得越来不明显,但不可否定的是,某些设备以及浏览器直到现在仍然不支持WebGL 2。
  13. <br>以下的方法可以帮助你检测当前用户所使用的环境是否支持WebGL 2,如果不支持,将会向用户提示一条信息。
  14. </p>
  15. <p>
  16. 导入 WebGL 兼容检测模块,并在尝试渲染任何内容之前运行以下程序。
  17. </p>
  18. <code>
  19. import WebGL from 'three/addons/capabilities/WebGL.js';
  20. if ( WebGL.isWebGL2Available() ) {
  21. // Initiate function or other initializations here
  22. animate();
  23. } else {
  24. const warning = WebGL.getWebGL2ErrorMessage();
  25. document.getElementById( 'container' ).appendChild( warning );
  26. }
  27. </code>
  28. </body>
  29. </html>