BoxGeometry.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:BufferGeometry] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. [name] is a geometry class for a rectangular cuboid with a given 'width', 'height', and 'depth'.
  14. On creation, the cuboid is centred on the origin, with each edge parallel to one of the axes.
  15. </p>
  16. <iframe id="scene" src="scenes/geometry-browser.html#BoxGeometry"></iframe>
  17. <script>
  18. // iOS iframe auto-resize workaround
  19. if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
  20. const scene = document.getElementById( 'scene' );
  21. scene.style.width = getComputedStyle( scene ).width;
  22. scene.style.height = getComputedStyle( scene ).height;
  23. scene.setAttribute( 'scrolling', 'no' );
  24. }
  25. </script>
  26. <h2>Code Example</h2>
  27. <code>const geometry = new THREE.BoxGeometry( 1, 1, 1 );
  28. const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
  29. const cube = new THREE.Mesh( geometry, material );
  30. scene.add( cube );
  31. </code>
  32. <h2>Constructor</h2>
  33. <h3>[name]([param:Float width], [param:Float height], [param:Float depth], [param:Integer widthSegments], [param:Integer heightSegments], [param:Integer depthSegments])</h3>
  34. <p>
  35. width — Width; that is, the length of the edges parallel to the X axis. Optional; defaults to 1.<br />
  36. height — Height; that is, the length of the edges parallel to the Y axis. Optional; defaults to 1.<br />
  37. depth — Depth; that is, the length of the edges parallel to the Z axis. Optional; defaults to 1.<br />
  38. widthSegments — Number of segmented rectangular faces along the width of the sides. Optional; defaults to 1.<br />
  39. heightSegments — Number of segmented rectangular faces along the height of the sides. Optional; defaults to 1.<br />
  40. depthSegments — Number of segmented rectangular faces along the depth of the sides. Optional; defaults to 1.<br />
  41. </p>
  42. <h2>Properties</h2>
  43. <p>See the base [page:BufferGeometry] class for common properties.</p>
  44. <h3>[property:Object parameters]</h3>
  45. <p>
  46. An object with a property for each of the constructor parameters. Any modification after instantiation does not change the geometry.
  47. </p>
  48. <p>
  49. Using the above example:
  50. <code>
  51. geometry.parameters; // {width: 1, height: 1, depth: 1, widthSegments: undefined, heightSegments: undefined, depthSegments: undefined}
  52. cube.geometry.parameters; // as above
  53. cube.geometry.parameters.width; // === 1
  54. cube.geometry.parameters.widthSegments; // === undefined.
  55. </code>
  56. </p>
  57. <h2>Methods</h2>
  58. <p>See the base [page:BufferGeometry] class for common methods.</p>
  59. <h2>Source</h2>
  60. <p>
  61. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  62. </p>
  63. </body>
  64. </html>