You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.0 KiB

4 years ago
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>three.js webgl - teapot buffer geometry</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <style>
  8. body {
  9. color: #fff;
  10. font-family: Monospace;
  11. font-size: 13px;
  12. text-align: center;
  13. font-weight: bold;
  14. background-color: #000;
  15. margin: 0px;
  16. overflow: hidden;
  17. }
  18. #info {
  19. position: absolute;
  20. padding: 10px;
  21. width: 100%;
  22. text-align: center;
  23. color: #fff;
  24. }
  25. a { color: blue; }
  26. </style>
  27. </head>
  28. <body>
  29. <script src="js/three.min.js"></script>
  30. <script>
  31. //Preparamos el render
  32. Render=new THREE.WebGLRenderer();
  33. //Tamaño del render(resultado)
  34. Render.setSize(300,300);
  35. //Se agrega el render al documento html
  36. document.body.appendChild(Render.domElement);
  37. //El escenario
  38. Escenario=new THREE.Scene();
  39. //La cámara
  40. Camara=new THREE.PerspectiveCamera();
  41. //Acercamos la cámara en z es profundidad para ver el punto
  42. Camara.position.z=50;
  43. //agregando la cámara al escenario
  44. Escenario.add(Camara);
  45. // Geometría
  46. Geometria=new THREE.Geometry();
  47. // vector a dibujar
  48. vertices = [[2,7,0], [7,2,0],[12, 7, 0], [12, 17, 0], [7, 12, 0], [2, 17, 0], [2,7,0]];
  49. long_vertices = vertices.length;
  50. for(i=0;i<long_vertices;i++){
  51. x = vertices[i][0];
  52. y = vertices[i][1];
  53. z = vertices[i][2];
  54. //Agregamos vértices al vector
  55. Vector = new THREE.Vector3(x,y,z);
  56. //Agregamos el vector a la geometria
  57. Geometria.vertices.push(Vector);
  58. }
  59. // agregamos un material para que el punto tenga color
  60. Material=new THREE.ParticleBasicMaterial({color:0XFF0000});
  61. // creamos una partícula con la geometría y el material
  62. Figura=new THREE.Line(Geometria,Material);
  63. // agregamos la partícula al escenario
  64. Escenario.add(Figura);
  65. // agregamos todo el escenario y la cámara al render
  66. Render.render(Escenario,Camara);
  67. </script>
  68. </body>
  69. </html>