From 27ef03d341b7a5c4afe1734ec42e51bb1e317990 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Wed, 3 Mar 2021 12:27:40 +0100 Subject: [PATCH] Examples: Better show WebGL2 error messages. --- ...webgl2_buffergeometry_attributes_integer.html | 8 ++++++++ examples/webgl2_multisampled_renderbuffers.html | 16 +++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/examples/webgl2_buffergeometry_attributes_integer.html b/examples/webgl2_buffergeometry_attributes_integer.html index 2acab06bef7a4e..1044a4d33b8021 100644 --- a/examples/webgl2_buffergeometry_attributes_integer.html +++ b/examples/webgl2_buffergeometry_attributes_integer.html @@ -48,6 +48,14 @@ import * as THREE from '../build/three.module.js'; + import { WEBGL } from './jsm/WebGL.js'; + + if ( WEBGL.isWebGL2Available() === false ) { + + document.body.appendChild( WEBGL.getWebGL2ErrorMessage() ); + + } + let camera, scene, renderer, mesh; init(); diff --git a/examples/webgl2_multisampled_renderbuffers.html b/examples/webgl2_multisampled_renderbuffers.html index e82b33d6ea4c2a..08f57e7e0ee409 100644 --- a/examples/webgl2_multisampled_renderbuffers.html +++ b/examples/webgl2_multisampled_renderbuffers.html @@ -43,21 +43,21 @@ import { CopyShader } from './jsm/shaders/CopyShader.js'; import { WEBGL } from './jsm/WebGL.js'; - if ( WEBGL.isWebGL2Available() === false ) { - - document.body.appendChild( WEBGL.getWebGL2ErrorMessage() ); - - } - let camera, renderer, clock, group, container; let composer1, composer2; init(); - animate(); function init() { + if ( WEBGL.isWebGL2Available() === false ) { + + document.body.appendChild( WEBGL.getWebGL2ErrorMessage() ); + return; + + } + container = document.getElementById( 'container' ); camera = new THREE.PerspectiveCamera( 45, container.offsetWidth / container.offsetHeight, 1, 2000 ); @@ -140,6 +140,8 @@ window.addEventListener( 'resize', onWindowResize ); + animate(); + } function onWindowResize() {