-
Notifications
You must be signed in to change notification settings - Fork 0
/
represent_b.html
216 lines (174 loc) · 4.84 KB
/
represent_b.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE html>
<html lang="en">
<head>
<title>Represent by Leandro Estrella [AD]</title>
<meta charset="utf-8">
<link rel="author" href="https://leandroestrella.com">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/font-awesome.min.css">
<style>
body {
font-family: "Montserrat", sans-serif;
font-size: 12px;
background-color: #fff;
color: #000;
margin: 0px;
background-image: url("img/bookB.png");
background-color: transparent;
background-repeat: no-repeat;
background-position: left top;
background-size: 1155px 700px;
overflow: auto;
}
#before {
color: #000;
position: absolute;
top: 630px;
left: 65px;
width: 300px;
text-align: left;
z-index: 100;
display: block;
}
#next {
color: #000;
position: absolute;
top: 630px;
left: 1075px;
width: 300px;
text-align: left;
z-index: 100;
display: block;
}
p {
text-align: right;
}
a {
color: #000;
text-decoration: underline;
cursor: pointer;
text-decoration: none;
}
#canvas {
width: 1155px;
height: 700px;
margin-top: 0px;
padding: 0px;
position: absolute;
/* fixed or static */
top: 0px;
left: 0px;
}
</style>
</head>
<body>
<div id="canvas">
<script src="js/three.min.js"></script>
<script src="js/OBJLoader.js"></script>
<script src="js/AsciiEffect.js"></script>
<script>
var canvas_width = 1155;
var canvas_height = 700;
var start = Date.now();
var container = document.getElementById('canvas');
document.body.appendChild(container);
var camera, cameraTarget, scene, renderer;
var mouseX = 0, mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
init();
animate();
function init() {
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(1, 0, 1);
cameraTarget = new THREE.Vector3(0, 0, 0);
// scene
scene = new THREE.Scene();
// light
var light = new THREE.PointLight(0xffffff);
light.position.set(500, 500, 500);
scene.add(light);
var light = new THREE.PointLight(0xffffff, 0.25);
light.position.set(- 500, - 500, - 500);
scene.add(light);
// texture
var manager = new THREE.LoadingManager();
manager.onProgress = function (item, loaded, total) {
console.log(item, loaded, total);
};
var texture = new THREE.Texture();
var onProgress = function (xhr) {
if (xhr.lengthComputable) {
var percentComplete = xhr.loaded / xhr.total * 100;
console.log(Math.round(percentComplete, 2) + '% downloaded');
}
};
var onError = function (xhr) {
};
var loader = new THREE.ImageLoader(manager);
loader.load('img/UV_Grid_Sm.jpg', function (image) {
texture.image = image;
texture.needsUpdate = true;
});
// model
var loader = new THREE.OBJLoader(manager);
loader.load('obj/shirt.obj', function (object) {
object.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.material.map = texture;
}
});
object.scale.multiplyScalar(0.5);
//object.position.x = - 0.6;
object.position.y = - 0.7;
scene.add(object);
}, onProgress, onError);
// renderer
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(window.devicePixelRatio);
effect = new THREE.AsciiEffect(renderer);
effect.setSize(canvas_width, canvas_height);
container.appendChild(effect.domElement);
// resize
window.addEventListener('resize', onWindowResize, false);
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2;
windowHalfY = window.innerHeight / 2;
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
effect.setSize(window.innerWidth, window.innerHeight);
}
//
function animate() {
requestAnimationFrame(animate);
render();
}
function render() {
var timer = Date.now() - start;
camera.position.x = 0.77;
//scene.rotation.x = Math.sin( timer ) * 5;
scene.position.x = 1;
scene.rotation.y = timer * 0.002;
//scene.rotation.z = timer * 0.0002;
/*
camera.position.x = Math.sin( timer ) * 3;
camera.position.z = Math.cos( timer ) * 3;*/
//camera.lookAt( scene.position );
effect.render(scene, camera);
}
</script>
</div>
<div id="before">
<a href="represent.html">
<< /a>
</div>
<div id="next">
<a href="represent_c.html">></a>
</div>
</body>
</html>