threejs-responsive-editor.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!-- Licensed under a BSD license. See license.html for license -->
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
  7. <title>Three.js - Responsive Editor</title>
  8. <style>
  9. body {
  10. margin: 0;
  11. font-size: 16pt;
  12. }
  13. #editor {
  14. display: flex;
  15. width: 100vw;
  16. height: 100vh;
  17. }
  18. #controls {
  19. background: #AAA;
  20. padding: 5px;
  21. }
  22. #c {
  23. width: 100%;
  24. height: 100%;
  25. display: block;
  26. }
  27. .gutter {
  28. background-color: #eee;
  29. background-repeat: no-repeat;
  30. background-position: 50%;
  31. }
  32. .gutter.gutter-horizontal {
  33. cursor: ew-resize;
  34. background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==')
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <div id="editor">
  40. <div id="view"><canvas id="c"></canvas></div>
  41. <div id="controls">
  42. <div>
  43. <p>various controls
  44. would appear here</p>
  45. <div>Drag this bar</div>
  46. <div>⇐</div>
  47. </div>
  48. </div>
  49. </div>
  50. </body>
  51. <script type="module" src="threejs-responsive.js"></script>
  52. <script src="../3rdparty/split.min.js"></script>
  53. <script type="module">
  54. /* global Split */
  55. // This code is only related to handling the split.
  56. // Our three.js code has not changed
  57. Split(['#view', '#controls'], { // eslint-disable-line new-cap
  58. sizes: [75, 25],
  59. minSize: 100,
  60. elementStyle: (dimension, size, gutterSize) => {
  61. return {
  62. 'flex-basis': `calc(${size}% - ${gutterSize}px)`,
  63. };
  64. },
  65. gutterStyle: (dimension, gutterSize) => {
  66. return {
  67. 'flex-basis': `${gutterSize}px`,
  68. };
  69. },
  70. });
  71. </script>
  72. </html>