misc_uv_tests.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>three.js - uv mapping tests</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. background: #ffffff;
  10. color: #000000;
  11. text-align: center;
  12. font-family: sans-serif;
  13. }
  14. h3 {
  15. margin-top: 60px;
  16. margin-bottom: 30px;
  17. font-weight: normal;
  18. }
  19. canvas {
  20. width: 100%;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <script type="importmap">
  26. {
  27. "imports": {
  28. "three": "../build/three.module.js",
  29. "three/addons/": "./jsm/"
  30. }
  31. }
  32. </script>
  33. <script type="module">
  34. import * as THREE from 'three';
  35. import { UVsDebug } from 'three/addons/utils/UVsDebug.js';
  36. /*
  37. * This is to help debug UVs problems in geometry,
  38. * as well as allow a new user to visualize what UVs are about.
  39. */
  40. function test( name, geometry ) {
  41. const d = document.createElement( 'div' );
  42. d.innerHTML = '<h3>' + name + '</h3>';
  43. d.appendChild( UVsDebug( geometry ) );
  44. document.body.appendChild( d );
  45. }
  46. const points = [];
  47. for ( let i = 0; i < 10; i ++ ) {
  48. points.push( new THREE.Vector2( Math.sin( i * 0.2 ) * 15 + 50, ( i - 5 ) * 2 ) );
  49. }
  50. //
  51. test( 'new THREE.PlaneGeometry( 100, 100, 4, 4 )', new THREE.PlaneGeometry( 100, 100, 4, 4 ) );
  52. test( 'new THREE.SphereGeometry( 75, 12, 6 )', new THREE.SphereGeometry( 75, 12, 6 ) );
  53. test( 'new THREE.IcosahedronGeometry( 30, 1 )', new THREE.IcosahedronGeometry( 30, 1 ) );
  54. test( 'new THREE.OctahedronGeometry( 30, 2 )', new THREE.OctahedronGeometry( 30, 2 ) );
  55. test( 'new THREE.CylinderGeometry( 25, 75, 100, 10, 5 )', new THREE.CylinderGeometry( 25, 75, 100, 10, 5 ) );
  56. test( 'new THREE.BoxGeometry( 100, 100, 100, 4, 4, 4 )', new THREE.BoxGeometry( 100, 100, 100, 4, 4, 4 ) );
  57. test( 'new THREE.LatheGeometry( points, 8 )', new THREE.LatheGeometry( points, 8 ) );
  58. test( 'new THREE.TorusGeometry( 50, 20, 8, 8 )', new THREE.TorusGeometry( 50, 20, 8, 8 ) );
  59. test( 'new THREE.TorusKnotGeometry( 50, 10, 12, 6 )', new THREE.TorusKnotGeometry( 50, 10, 12, 6 ) );
  60. </script>
  61. </body>
  62. </html>