-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuvtest.html
124 lines (67 loc) · 2.28 KB
/
uvtest.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html>
<!-- ~KTB -->
<head>
<title>Test</title>
</head>
<body>
</body>
<script type="text/javascript" src="js/lib/three70.js"></script>
<script type="text/javascript" src="js/lib/CopyShader.js"></script>
<script type="text/javascript" src="js/src/Utils.js"></script>
<script type="text/javascript" src="js/src/ShaderPass.js"></script>
<script type="text/javascript" src="js/src/UVMapper.js"></script>
<script type="text/javascript" src="js/src/UVMapAnimator.js"></script>
<script type="text/javascript" src="js/src/shaders/UVMapShader.js"></script>
<script type="text/javascript">
var renderer = new THREE.WebGLRenderer({
alpha: false,
depth: true,
stencil: false,
});
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.autoClear = false;
renderer.setClearColor(0x111133, 1);
document.body.appendChild( renderer.domElement );
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(45, window.innerWidth/window.innerHeight, 1, 10);
camera.position.z = 5;
var material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
// scene.add(new THREE.Mesh(
// new THREE.SphereGeometry(1),
// material
// ));
// renderer.clear();
// renderer.render(scene, camera);
var url = Utils.getParameterByName("model") || "models/wolf.json";
var uvAnim = new UVMapAnimator(renderer, 512);
var copyPass = new ShaderPass(THREE.CopyShader);
copyPass.material.uniforms.tDiffuse.value = uvAnim.target;
var _mesh;
var _loader = new THREE.JSONLoader( true );
_loader.load(url, function(geometry) {
_mesh = new THREE.MorphAnimMesh(geometry, new THREE.MeshBasicMaterial({ color: 0x00ff00, wireframe: true, morphTargets:true }));
_mesh.scale.set(0.05,0.05,0.05);
_mesh.position.y -= 1;
uvAnim.setMesh(_mesh);
// scene.add(_mesh);
});
var prevTime = Date.now();
function update() {
var time = Date.now();
if (uvAnim) {
uvAnim.update((time-prevTime)/1000.0);
copyPass.render(renderer);
}
// else if (_mesh) {
// _mesh.updateAnimation(time-prevTime);
// _mesh.rotation.y += 0.01;
// renderer.clear();
// renderer.render(scene, camera);
// }
prevTime = time;
requestAnimationFrame(update);
}
update();
</script>
</html>