forked from Soft8Soft/verge3d-code-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc_uv_tests.html
95 lines (65 loc) · 2.4 KB
/
misc_uv_tests.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<title>Verge3D - uv mapping tests</title>
<meta charset=utf-8 />
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background: #ffffff;
color: #000000;
text-align: center;
font-family: sans-serif;
}
h3 {
margin-top: 60px;
margin-bottom: 30px;
font-weight: normal;
}
canvas {
width: 100%;
}
</style>
</head>
<body>
<!-- Import maps polyfill -->
<!-- Remove this when import maps will be widely supported -->
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"v3d": "../build/v3d.module.js",
"v3d/addons/": "./jsm/"
}
}
</script>
<script type="module">
import * as v3d from 'v3d';
import { UVsDebug } from 'v3d/addons/utils/UVsDebug.js';
/*
* This is to help debug UVs problems in geometry,
* as well as allow a new user to visualize what UVs are about.
*/
function test(name, geometry) {
const d = document.createElement('div');
d.innerHTML = '<h3>' + name + '</h3>';
d.appendChild(UVsDebug(geometry));
document.body.appendChild(d);
}
const points = [];
for (let i = 0; i < 10; i++) {
points.push(new v3d.Vector2(Math.sin(i * 0.2) * 15 + 50, (i - 5) * 2));
}
//
test('new v3d.PlaneGeometry(100, 100, 4, 4)', new v3d.PlaneGeometry(100, 100, 4, 4));
test('new v3d.SphereGeometry(75, 12, 6)', new v3d.SphereGeometry(75, 12, 6));
test('new v3d.IcosahedronGeometry(30, 1)', new v3d.IcosahedronGeometry(30, 1));
test('new v3d.OctahedronGeometry(30, 2)', new v3d.OctahedronGeometry(30, 2));
test('new v3d.CylinderGeometry(25, 75, 100, 10, 5)', new v3d.CylinderGeometry(25, 75, 100, 10, 5));
test('new v3d.BoxGeometry(100, 100, 100, 4, 4, 4)', new v3d.BoxGeometry(100, 100, 100, 4, 4, 4));
test('new v3d.LatheGeometry(points, 8)', new v3d.LatheGeometry(points, 8));
test('new v3d.TorusGeometry(50, 20, 8, 8)', new v3d.TorusGeometry(50, 20, 8, 8));
test('new v3d.TorusKnotGeometry(50, 10, 12, 6)', new v3d.TorusKnotGeometry(50, 10, 12, 6));
</script>
</body>
</html>