BoxGeometry.html 2.9 KB

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