|
@@ -53,7 +53,7 @@
|
|
<body>
|
|
<body>
|
|
<div id="info">
|
|
<div id="info">
|
|
<a href="https://threejs.org" target="_blank" rel="noopener noreferrer">three.js</a> - offscreen canvas (<a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas" target="_blank" rel="noopener noreferrer">about</a>)<br/>
|
|
<a href="https://threejs.org" target="_blank" rel="noopener noreferrer">three.js</a> - offscreen canvas (<a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas" target="_blank" rel="noopener noreferrer">about</a>)<br/>
|
|
- <p id="message">Your browser does not support OffscreenCanvas. Check the browser support <a href="https://caniuse.com/#feat=offscreencanvas" target="_blank" rel="noopener noreferrer">here</a></p>
|
|
|
|
|
|
+ <p id="message">Your browser does not support OffscreenCanvas with a WebGL Context. Check the browser support <a href="https://caniuse.com/#feat=offscreencanvas" target="_blank" rel="noopener noreferrer">here</a></p>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div id="container">
|
|
<div id="container">
|
|
@@ -77,7 +77,7 @@
|
|
|
|
|
|
import initJank from 'three/addons/offscreen/jank.js';
|
|
import initJank from 'three/addons/offscreen/jank.js';
|
|
import init from 'three/addons/offscreen/scene.js';
|
|
import init from 'three/addons/offscreen/scene.js';
|
|
-
|
|
|
|
|
|
+
|
|
// onscreen
|
|
// onscreen
|
|
|
|
|
|
const canvas1 = document.getElementById( 'canvas1' );
|
|
const canvas1 = document.getElementById( 'canvas1' );
|
|
@@ -92,7 +92,20 @@
|
|
|
|
|
|
// offscreen
|
|
// offscreen
|
|
|
|
|
|
- if ( 'transferControlToOffscreen' in canvas2 ) {
|
|
|
|
|
|
+ const isSafari = /^((?!chrome|android).)*safari/i.test( navigator.userAgent );
|
|
|
|
+ let supportOffScreenWebGL = 'transferControlToOffscreen' in canvas2;
|
|
|
|
+
|
|
|
|
+ // If it's Safari, then check the version because Safari < 17 doesn't support OffscreenCanvas with a WebGL context.
|
|
|
|
+ if ( isSafari ) {
|
|
|
|
+
|
|
|
|
+ var versionMatch = navigator.userAgent.match( /version\/(\d+)/i );
|
|
|
|
+ var safariVersion = versionMatch ? parseInt( versionMatch[ 1 ] ) : 0;
|
|
|
|
+
|
|
|
|
+ supportOffScreenWebGL = safariVersion >= 17;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( supportOffScreenWebGL ) {
|
|
|
|
|
|
const offscreen = canvas2.transferControlToOffscreen();
|
|
const offscreen = canvas2.transferControlToOffscreen();
|
|
const worker = new Worker( 'jsm/offscreen/offscreen.js', { type: 'module' } );
|
|
const worker = new Worker( 'jsm/offscreen/offscreen.js', { type: 'module' } );
|