代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<title>Verge3D webgl - worker - offscreen canvas</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link type="text/css" rel="stylesheet" href="main.css">
<style>
body {
background-color: #fff;
color: #444;
}
a {
color: #08f;
}
canvas {
display: inline-block;
}
#message {
color: #ff0000;
display: none;
}
#message > a {
color: #ff0000;
}
#container {
position: absolute;
top: 50px;
bottom: 70px;
width: 100%;
}
#ui {
position: absolute;
bottom: 20px;
width: 100%;
text-align: center;
}
#button {
border: 0;
padding: 4px 6px;
background: #dddddd;
outline: none;
}
</style>
</head>
<body>
<div id="info">
<a href="https://www.soft8soft.com/verge3d" target="_blank" rel="noopener noreferrer">Verge3D</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>
<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>
<script type="module">
import initJank from './jsm/offscreen/jank.js';
import init from './jsm/offscreen/scene.js';
// onscreen
const canvas1 = document.getElementById('canvas1');
const canvas2 = document.getElementById('canvas2');
const width = canvas1.clientWidth;
const height = canvas1.clientHeight;
const pixelRatio = window.devicePixelRatio;
init(canvas1, width, height, pixelRatio, './');
initJank();
// offscreen
if ('transferControlToOffscreen' in canvas2) {
const offscreen = canvas2.transferControlToOffscreen();
const worker = new Worker('jsm/offscreen/offscreen.js', { type: 'module' });
worker.postMessage({
drawingSurface: offscreen,
width: canvas2.clientWidth,
height: canvas2.clientHeight,
pixelRatio: window.devicePixelRatio,
path: '../../'
}, [offscreen]);
} else {
document.getElementById('message').style.display = 'block';
}
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。