threejs-responsive-editor.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. }
  20. #c {
  21. width: 100%;
  22. height: 100%;
  23. }
  24. .gutter {
  25. background-color: #eee;
  26. background-repeat: no-repeat;
  27. background-position: 50%;
  28. }
  29. .gutter.gutter-horizontal {
  30. cursor: ew-resize;
  31. background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==')
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <div id="editor">
  37. <div id="view"><canvas id="c"></canvas></div>
  38. <div id="controls">
  39. <div>
  40. <p>various controls
  41. would appear here</p>
  42. <div>Drag this bar</div>
  43. <div>⇐</div>
  44. </div>
  45. </div>
  46. </div>
  47. </body>
  48. <script src="resources/threejs/r93/three.min.js"></script>
  49. <script src="resources/threejs-lessons-helper.js"></script> <!-- you can and should delete this script. it is only used on the site to help with errors -->
  50. <script src="threejs-responsive.js"></script>
  51. <script src="../3rdparty/split.min.js"></script>
  52. <script>
  53. 'use strict';
  54. // This code is only related to handling the split.
  55. // Our three.js code has not changed
  56. Split(['#view', '#controls'], {
  57. sizes: [75, 25],
  58. minSize: 100,
  59. elementStyle: (dimension, size, gutterSize) => {
  60. return {
  61. 'flex-basis': `calc(${size}% - ${gutterSize}px)`,
  62. };
  63. },
  64. gutterStyle: (dimension, gutterSize) => {
  65. return {
  66. 'flex-basis': `${gutterSize}px`,
  67. };
  68. },
  69. });
  70. </script>
  71. </html>