responsive-editor.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. html, body {
  10. height: 100%;
  11. margin: 0;
  12. font-size: 16pt;
  13. }
  14. #editor {
  15. display: flex;
  16. width: 100%;
  17. height: 100%;
  18. }
  19. #controls {
  20. background: #AAA;
  21. padding: 5px;
  22. }
  23. #c {
  24. width: 100%;
  25. height: 100%;
  26. display: block;
  27. }
  28. .gutter {
  29. background-color: #eee;
  30. background-repeat: no-repeat;
  31. background-position: 50%;
  32. }
  33. .gutter.gutter-horizontal {
  34. cursor: ew-resize;
  35. background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==')
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div id="editor">
  41. <div id="view"><canvas id="c"></canvas></div>
  42. <div id="controls">
  43. <div>
  44. <p>various controls
  45. would appear here</p>
  46. <div>Drag this bar</div>
  47. <div>⇐</div>
  48. </div>
  49. </div>
  50. </div>
  51. </body>
  52. <script type="importmap">
  53. {
  54. "imports": {
  55. "three": "../../build/three.module.js"
  56. }
  57. }
  58. </script>
  59. <script type="module" src="threejs-responsive.js"></script>
  60. <script src="../3rdparty/split.min.js"></script>
  61. <script type="module">
  62. /* global Split */
  63. // This code is only related to handling the split.
  64. // Our three.js code has not changed
  65. Split( [ '#view', '#controls' ], { // eslint-disable-line new-cap
  66. sizes: [ 75, 25 ],
  67. minSize: 100,
  68. elementStyle: ( dimension, size, gutterSize ) => {
  69. return {
  70. 'flex-basis': `calc(${size}% - ${gutterSize}px)`,
  71. };
  72. },
  73. gutterStyle: ( dimension, gutterSize ) => {
  74. return {
  75. 'flex-basis': `${gutterSize}px`,
  76. };
  77. },
  78. } );
  79. </script>
  80. </html>