TubeGeometry.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <!DOCTYPE html>
  2. <html lang="fr">
  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">Crée un tube qui s'extrude le long d'une courbe 3D.</p>
  13. <iframe id="scene" src="scenes/geometry-browser.html#TubeGeometry"></iframe>
  14. <script>
  15. // iOS iframe auto-resize workaround
  16. if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
  17. const scene = document.getElementById( 'scene' );
  18. scene.style.width = getComputedStyle( scene ).width;
  19. scene.style.height = getComputedStyle( scene ).height;
  20. scene.setAttribute( 'scrolling', 'no' );
  21. }
  22. </script>
  23. <h2>Exemple de code :</h2>
  24. <code>
  25. class CustomSinCurve extends THREE.Curve {
  26. constructor( scale = 1 ) {
  27. super();
  28. this.scale = scale;
  29. }
  30. getPoint( t, optionalTarget = new THREE.Vector3() ) {
  31. const tx = t * 3 - 1.5;
  32. const ty = Math.sin( 2 * Math.PI * t );
  33. const tz = 0;
  34. return optionalTarget.set( tx, ty, tz ).multiplyScalar( this.scale );
  35. }
  36. }
  37. const path = new CustomSinCurve( 10 );
  38. const geometry = new THREE.TubeGeometry( path, 20, 2, 8, false );
  39. const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
  40. const mesh = new THREE.Mesh( geometry, material );
  41. scene.add( mesh );
  42. </code>
  43. <h2>Constructeur</h2>
  44. <h3>[name]([param:Curve path], [param:Integer tubularSegments], [param:Float radius], [param:Integer radialSegments], [param:Boolean closed])</h3>
  45. <p>
  46. path — [page:Curve] - Un chemin 3D qui hérite de la classe de base [page:Curve]. La valeur par défaut est une courbe de Bézier quadratique.<br />
  47. tubularSegments — [page:Integer] - Le nombre de segments qui composent le tube. La valeur par défaut est '64'.<br />
  48. radius — [page:Float] - Le rayon du tube. La valeur par défaut est '1'.<br />
  49. radialSegments — [page:Integer] - Le nombre de segments qui composent la section. La valeur par défaut est '8'.<br />
  50. closed — [page:Boolean] Spécifie si le tube est ouvert ou fermé. La valeur par défaut est `false`.<br />
  51. </p>
  52. <h2>Propriétés</h2>
  53. <p>Voir la classe de base [page:BufferGeometry] pour les propriétés communes.</p>
  54. <h3>[property:Object parameters]</h3>
  55. <p>
  56. Un objet avec une propriété pour chacun des paramètres du constructeur. Toute modification après instanciation ne change pas la géométrie.
  57. </p>
  58. <h3>[property:Array tangents]</h3>
  59. <p>
  60. Un tableau de tangentes [page:Vector3].
  61. </p>
  62. <h3>[property:Array normals]</h3>
  63. <p>
  64. Un tableau de normales [page:Vector3].
  65. </p>
  66. <h3>[property:Array binormals]</h3>
  67. <p>
  68. Un tableau de binormaux [page:Vector3].
  69. </p>
  70. <h2>Méthodes</h2>
  71. <p>Voir la classe de base [page:BufferGeometry] pour les méthodes communes.</p>
  72. <h2>Source</h2>
  73. <p>
  74. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  75. </p>
  76. </body>
  77. </html>