raytracing_sandbox_workers.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>three.js - raytracing renderer with web workers</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <style>
  8. body {
  9. font-family: Monospace;
  10. color: #ffffff;
  11. margin: 0px;
  12. padding: 0px;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <script src="../build/three.min.js"></script>
  18. <script src="js/renderers/RaytracingWorkerRenderer.js"></script>
  19. <script>
  20. var hash = location.hash ? location.hash.substring(1) : '4';
  21. var WORKERS = +hash || navigator.hardwareConcurrency || 4;
  22. var container;
  23. var camera, controls, scene, renderer;
  24. var torus, cube;
  25. init();
  26. render();
  27. function init() {
  28. container = document.createElement( 'div' );
  29. document.body.appendChild( container );
  30. var info = document.createElement( 'div' );
  31. info.style.position = 'absolute';
  32. info.style.top = '10px';
  33. info.style.width = '100%';
  34. info.style.zIndex = '100';
  35. info.style.textAlign = 'center';
  36. info.innerHTML = '<a href="http://threejs.org" target="_blank">three.js<a/> - raytracing renderer (using ' + WORKERS + ' web workers)';
  37. container.appendChild( info );
  38. //
  39. renderer = new THREE.RaytracingWorkerRenderer({
  40. workers: WORKERS
  41. });
  42. renderer.setClearColor( 0xf0f0f0 );
  43. renderer.setSize( window.innerWidth, window.innerHeight );
  44. renderer.domElement.style.position = "absolute";
  45. renderer.domElement.style.top = "0px";
  46. renderer.domElement.style.left = "0px";
  47. container.appendChild( renderer.domElement );
  48. }
  49. function render() {
  50. renderer.render( scene, camera );
  51. }
  52. </script>
  53. </body>
  54. </html>