|
@@ -5,28 +5,29 @@
|
|
|
<meta charset="utf-8">
|
|
|
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
|
|
<style>
|
|
|
+ html, body {
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
body {
|
|
|
- background:#000000;
|
|
|
- padding:0;
|
|
|
- margin:0;
|
|
|
- font-weight: bold;
|
|
|
- overflow:hidden;
|
|
|
+ background: #ffffff;
|
|
|
+ padding: 0;
|
|
|
+ margin: 0;
|
|
|
+ font-family: Monospace;
|
|
|
+ font-size: 13px;
|
|
|
+ overflow: hidden;
|
|
|
}
|
|
|
|
|
|
#info {
|
|
|
- position: absolute;
|
|
|
top: 0px;
|
|
|
width: 100%;
|
|
|
- color: #ffffff;
|
|
|
- padding: 5px;
|
|
|
- font-family:Monospace;
|
|
|
- font-size:13px;
|
|
|
- text-align:center;
|
|
|
+ color: #000000;
|
|
|
+ margin: 6px 0px;
|
|
|
+ text-align: center;
|
|
|
}
|
|
|
|
|
|
#message {
|
|
|
color: #ff0000;
|
|
|
- font-size:14px;
|
|
|
display: none;
|
|
|
}
|
|
|
|
|
@@ -34,47 +35,71 @@
|
|
|
color: #ff0000;
|
|
|
}
|
|
|
|
|
|
- a { color: #ffffff; }
|
|
|
+ #container {
|
|
|
+ width: 100%;
|
|
|
+ height: calc(100% - 80px);
|
|
|
+ }
|
|
|
+
|
|
|
+ #ui {
|
|
|
+ margin-top: 8px;
|
|
|
+ height: 80px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ #button {
|
|
|
+ border: 0;
|
|
|
+ padding: 4px 6px;
|
|
|
+ background: #dddddd;
|
|
|
+ outline: none;
|
|
|
+ }
|
|
|
</style>
|
|
|
- <script src="js/WebGL.js"></script>
|
|
|
</head>
|
|
|
<body>
|
|
|
<div id="info">
|
|
|
- <a href="https://threejs.org" target="_blank" rel="noopener noreferrer">three.js</a> offscreen canvas<br/><br/>
|
|
|
- three.js runs in a worker and produces asynchronously frames for the canvas element in the main thread. <br/>
|
|
|
- This is an <a href="https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas" target="_blank" rel="noopener noreferrer"> experimental feature</a>!
|
|
|
+ <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>
|
|
|
</div>
|
|
|
|
|
|
- <canvas id="canvas" style="width: 100%; height: 100%"></canvas>
|
|
|
- </body>
|
|
|
- <script>
|
|
|
+ <div id="container">
|
|
|
+ <canvas id="canvas1" style="width: 50%; height: 100%"></canvas><canvas id="canvas2" style="width: 50%; height: 100%"></canvas>
|
|
|
+ </div>
|
|
|
+ <div id="ui">
|
|
|
+ <button id="button">START JANK</button><br/>
|
|
|
+ <span id="result"></span>
|
|
|
+ </div>
|
|
|
|
|
|
- if ( WEBGL.isWebGLAvailable() === false ) {
|
|
|
+ <script src="../build/three.js"></script>
|
|
|
+ <script src="js/offscreen/scene.js"></script>
|
|
|
+ <script src="js/offscreen/jank.js"></script>
|
|
|
+ <script>
|
|
|
|
|
|
- document.body.appendChild( WEBGL.getWebGLErrorMessage() );
|
|
|
+ // onscreen
|
|
|
|
|
|
- }
|
|
|
+ var width = canvas1.clientWidth;
|
|
|
+ var height = canvas1.clientHeight;
|
|
|
+ var pixelRatio = window.devicePixelRatio;
|
|
|
|
|
|
- var canvas = document.getElementById( 'canvas' );
|
|
|
+ init( canvas1, width, height, pixelRatio, './' );
|
|
|
|
|
|
- if ( canvas.transferControlToOffscreen !== undefined ) {
|
|
|
+ // offscreen
|
|
|
|
|
|
- var offscreen = canvas.transferControlToOffscreen();
|
|
|
- var worker = new Worker( 'js/workers/OffscreenCanvas.js' );
|
|
|
+ if ( 'transferControlToOffscreen' in canvas2 ) {
|
|
|
|
|
|
- worker.postMessage( {
|
|
|
- drawingSurface: offscreen,
|
|
|
- width: window.innerWidth,
|
|
|
- height: window.innerHeight,
|
|
|
- pixelRatio: window.devicePixelRatio
|
|
|
- }, [ offscreen ] ); // transfer
|
|
|
+ var offscreen = canvas2.transferControlToOffscreen();
|
|
|
+ var worker = new Worker( 'js/offscreen/offscreen.js' );
|
|
|
+ worker.postMessage( {
|
|
|
+ drawingSurface: offscreen,
|
|
|
+ width: canvas2.clientWidth,
|
|
|
+ height: canvas2.clientHeight,
|
|
|
+ pixelRatio: window.devicePixelRatio,
|
|
|
+ path: '../../'
|
|
|
+ }, [ offscreen ] );
|
|
|
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
|
|
|
- document.getElementById( 'message' ).style.display = 'block';
|
|
|
+ document.getElementById( 'message' ).style.display = 'block';
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- </script>
|
|
|
+ </script>
|
|
|
+ </body>
|
|
|
</html>
|