misc_uv_tests.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. <!-- Import maps polyfill -->
  26. <!-- Remove this when import maps will be widely supported -->
  27. <script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
  28. <script type="importmap">
  29. {
  30. "imports": {
  31. "three": "../build/three.module.js",
  32. "three/addons/": "./jsm/"
  33. }
  34. }
  35. </script>
  36. <script type="module">
  37. import * as THREE from 'three';
  38. import { UVsDebug } from 'three/addons/utils/UVsDebug.js';
  39. /*
  40. * This is to help debug UVs problems in geometry,
  41. * as well as allow a new user to visualize what UVs are about.
  42. */
  43. function test( name, geometry ) {
  44. const d = document.createElement( 'div' );
  45. d.innerHTML = '<h3>' + name + '</h3>';
  46. d.appendChild( UVsDebug( geometry ) );
  47. document.body.appendChild( d );
  48. }
  49. const points = [];
  50. for ( let i = 0; i < 10; i ++ ) {
  51. points.push( new THREE.Vector2( Math.sin( i * 0.2 ) * 15 + 50, ( i - 5 ) * 2 ) );
  52. }
  53. //
  54. test( 'new THREE.PlaneGeometry( 100, 100, 4, 4 )', new THREE.PlaneGeometry( 100, 100, 4, 4 ) );
  55. test( 'new THREE.SphereGeometry( 75, 12, 6 )', new THREE.SphereGeometry( 75, 12, 6 ) );
  56. test( 'new THREE.IcosahedronGeometry( 30, 1 )', new THREE.IcosahedronGeometry( 30, 1 ) );
  57. test( 'new THREE.OctahedronGeometry( 30, 2 )', new THREE.OctahedronGeometry( 30, 2 ) );
  58. test( 'new THREE.CylinderGeometry( 25, 75, 100, 10, 5 )', new THREE.CylinderGeometry( 25, 75, 100, 10, 5 ) );
  59. test( 'new THREE.BoxGeometry( 100, 100, 100, 4, 4, 4 )', new THREE.BoxGeometry( 100, 100, 100, 4, 4, 4 ) );
  60. test( 'new THREE.LatheGeometry( points, 8 )', new THREE.LatheGeometry( points, 8 ) );
  61. test( 'new THREE.TorusGeometry( 50, 20, 8, 8 )', new THREE.TorusGeometry( 50, 20, 8, 8 ) );
  62. test( 'new THREE.TorusKnotGeometry( 50, 10, 12, 6 )', new THREE.TorusKnotGeometry( 50, 10, 12, 6 ) );
  63. </script>
  64. </body>
  65. </html>