2
0

WebGL-compatibility-check.html 905 B

123456789101112131415161718192021222324252627282930313233
  1. <!DOCTYPE html>
  2. <html lang="en">
  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>[name]</h1>
  11. <p>
  12. Even though this is becoming less and less of a problem, some devices or browsers may still not support WebGL 2.
  13. The following method allows you to check if it is supported and display a message to the user if it is not.
  14. Import the WebGL support detection module, and run the following before attempting to render anything.
  15. </p>
  16. <code>
  17. import WebGL from 'three/addons/capabilities/WebGL.js';
  18. if ( WebGL.isWebGL2Available() ) {
  19. // Initiate function or other initializations here
  20. animate();
  21. } else {
  22. const warning = WebGL.getWebGL2ErrorMessage();
  23. document.getElementById( 'container' ).appendChild( warning );
  24. }
  25. </code>
  26. </body>
  27. </html>