-
Notifications
You must be signed in to change notification settings - Fork 0
/
exhibition_booth.html
782 lines (556 loc) · 22 KB
/
exhibition_booth.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
<html>
<title>Exhibition Booth</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
color: grey;
overflow: hidden;
width: auto;
height: auto;
}
canvas {
border: 0;
width: 100%;
height: 100%;
position: absolute;
display: block;
}
#title {
position: absolute;
left: 50%;
transform: translateX(-50%);
top: 5%;
}
a {
text-decoration: none;
color: blue;
}
/*
.progress-bar {
height: 24px;
width: 30%;
border: 1px solid black;
padding: 2px;
margin: 0 auto;
top: 45%;
left: 35%;
z-index: 9;
position: absolute;
text-align: center;
line-height: 60px;
}
.progress-fill {
background-color: gray;
height: 100%;
} */
</style>
<body>
<!--
<div>temporary mobile console area:<div id="tmpConsole"></div>
</div>-->
<div id="title">Exhibition Booth</div>
<!--
<div class="progress-bar">
<div class="progress-fill" style="width: 50%;"></div>
loading...
</div>
-->
<canvas id="canvas"></canvas>
<script id="vertex-shader-3d" type="x-shader/x-vertex">
uniform mat4 u_worldViewProjection;
attribute vec4 a_position;
attribute vec2 a_texcoord;
varying vec2 v_texCoord;
void main() {
v_texCoord = a_texcoord;
gl_Position = u_worldViewProjection * a_position;
}
</script>
<script id="fragment-shader-3d" type="x-shader/x-fragment">
precision highp float;
varying vec2 v_texCoord;
uniform sampler2D u_diffuse;
void main() {
vec4 diffuseColor = texture2D(u_diffuse, v_texCoord);
gl_FragColor = diffuseColor;
//gl_FragColor = vec4(1.0, 0.8, 0.0, 1.0);
}
</script>
<script id="pick-vertex-shader-3d" type="x-shader/x-vertex">
uniform mat4 u_worldViewProjection;
attribute vec4 a_position;
void main() {
gl_Position = u_worldViewProjection * a_position;
}
</script>
<script id="pick-fragment-shader-3d" type="x-shader/x-fragment">
precision lowp float;
uniform vec4 u_id;
void main() {
gl_FragColor = u_id;
//gl_FragColor = vec4(1.0, 0.8, 0.0, 1.0);
}
</script>
<script src="./webgl-utils.js"></script>
<script src="https://webglfundamentals.org/webgl/resources/m4.js"></script>
<script>
"use strict";
function main() {
//const tmpConsole = document.getElementById("tmpConsole");
let x1 = 0, x2 = 0, y1 = 0, y2 = 0, delta0, delta1;
//内容区
const loader = document.getElementsByClassName("progress-bar")[0];
const title = document.getElementById("title");
//const subtitles = ["<a href='./gallery-subscene-v2.html'>前往自动观赏模式</a>", "《秋光里的穿行》", "《通往仙境的道路》", "《西湖落日飞车》", "《镀金的西湖》", "《人在画中游》", "《西湖可以是任何一个湖》"];
//tmp
function createBtns(i) {
const button = document.createElement("button");
button.innerText = picNum - i;
button.id = picNum - i;
button.addEventListener('click', tweenRotate, false);
//btn.appendChild(button);
}
//互动区
const up = [0, 1, 0];
let aspect = window.innerWidth / window.innerHeight;
let id = -1, viewMatrix = [];
let cameraPosition = [0, 0, 40], target = [0, 0, -1000];
//let cameraPosition=[-55*aspect,5*aspect,-130], target=[-50,0,-1000];
//let newCamPosStart = [0, 0, 10], newTargetPosStart=[100,0,-1000];
//类似打牌效果:
let newCamPosStart = [0, 20, 80], newTargetPosStart = [0, 0, -1];
let camMov = [0, 0, 0], targetMov = [0, 0, 0];
let tweenCount = 30;
let radius = 15;
let isTweenReady = false, isTweening = false;
//gl初始化
var canvas = document.querySelector("#canvas");
var gl = canvas.getContext("webgl");
if (!gl) {
return;
}
//controllers区
//let isMouseDown = false;
//贴图区
const picNum = 3;
let loaded = 0;
let isLoaded = false;
let textures = [];
let objects = [];
function loadImage(url, callback) {
var image = new Image();
image.src = url;
image.onload = callback;
return image;
}
var images = [];
function loadImages(urls, callback) {
//var images = [];
var imagesToLoad = urls.length;
// Called each time an image finished
// loading.
var onImageLoad = function () {
--imagesToLoad;
// If all the images are loaded call the callback.
if (imagesToLoad === 0) {
callback(images);
loader.style.display = 'none';
}
};
for (var ii = 0; ii < imagesToLoad; ++ii) {
var image = loadImage(urls[ii], onImageLoad);
images.push(image);
}
}
gl.enable(gl.DEPTH_TEST);
const targetTexture = gl.createTexture();
/* 加入depth buffer(1/3) */
const depthBuffer = gl.createRenderbuffer();
const fb = gl.createFramebuffer();
var arrays = {
position: { numComponents: 3, data: [-15.835, -10, 0, 15.835, -10, 0, -15.835, 10, 0, 15.835, 10, 0], },
texcoord: { numComponents: 2, data: [0, 1, 1, 1, 0, 0, 1, 0], },
indices: { numComponents: 3, data: [0, 1, 2, 1, 2, 3], },
};
var bufferInfo = webglUtils.createBufferInfoFromArrays(gl, arrays);
var programInfo = webglUtils.createProgramInfo(gl, ["vertex-shader-3d", "fragment-shader-3d"]);
var pickProgramInfo = webglUtils.createProgramInfo(gl, ["pick-vertex-shader-3d", "pick-fragment-shader-3d"]);
function degToRad(d) {
return d * Math.PI / 180;
}
var fieldOfViewRadians = degToRad(60);
var uniformsThatAreComputedForEachObject = {
u_worldViewProjection: m4.identity(),
};
var pickUniforms = {
u_worldViewProjection: m4.identity(),
};
function drawScene() {
resizeCanvasToDisplaySize(canvas);
aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;
//需要一个viewMatrix
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
// Tell WebGL how to convert from clip space to pixels
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
gl.clearColor(0.9, 0.9, 0.9, 1.0);
// Clear the canvas AND the depth buffer.
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
var projectionMatrix = m4.perspective(fieldOfViewRadians, aspect, 1, 2000);
var viewProjectionMatrix = m4.multiply(projectionMatrix, viewMatrix);
gl.useProgram(programInfo.program);
// Setup all the needed buffers and attributes.
webglUtils.setBuffersAndAttributes(gl, programInfo, bufferInfo);
objects.forEach(function (object) {
var worldMatrix = m4.xRotation(0);
worldMatrix = m4.yRotate(worldMatrix, object.yRotation);
worldMatrix = m4.translate(worldMatrix, object.xTranslation, object.yTranslation, object.zTranslation);
m4.multiply(viewProjectionMatrix, worldMatrix, uniformsThatAreComputedForEachObject.u_worldViewProjection);
webglUtils.setUniforms(programInfo, uniformsThatAreComputedForEachObject);
webglUtils.setUniforms(programInfo, object.materialUniforms);
gl.drawElements(gl.TRIANGLES, bufferInfo.numElements, gl.UNSIGNED_SHORT, 0);
});
if (isTweening) {
requestAnimationFrame(tween);
}
//console.log('drawScene');
}
function renderPicking(e) {
resizeCanvasToDisplaySize(canvas);
aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;
//render picking
//创建frame buffer
gl.bindTexture(gl.TEXTURE_2D, targetTexture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.canvas.width * 2, gl.canvas.height * 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
// 加入depth buffer(2/3)
gl.bindRenderbuffer(gl.RENDERBUFFER, depthBuffer);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, gl.canvas.width * 2, gl.canvas.height * 2);
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, targetTexture, 0);
// 加入depth buffer(3/3)
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthBuffer);
gl.bindTexture(gl.TEXTURE_2D, targetTexture);
// gl.disable(gl.BLEND);
// 创建mouse event对frustum matrix的转换通讯
const near = 1, far = 2000;
const top = Math.tan(degToRad(60) * 0.5) * near;
const bottom = -top;
const left = aspect * bottom;
const right = aspect * top;
const width = Math.abs(right - left);
const height = Math.abs(top - bottom);
const rect = canvas.getBoundingClientRect();
const pixelX = (e.clientX - rect.left) * gl.canvas.width / gl.canvas.clientWidth;
const pixelY = gl.canvas.height - (e.clientY - rect.top) * gl.canvas.height / gl.canvas.clientHeight - 1;
const subLeft = left + pixelX * width / gl.canvas.width;
const subBottom = bottom + pixelY * height / gl.canvas.height;
const subWidth = width / gl.canvas.width;
const subHeight = height / gl.canvas.height;
// Tell WebGL how to convert from clip space to pixels
gl.viewport(0, 0, 1, 1);
// Clear the canvas AND the depth buffer.
gl.clear(gl.COLOR_BUFFER_BIT); //| gl.DEPTH_BUFFER_BIT
var projectionMatrix = m4.frustum(subLeft, subLeft + subWidth, subBottom, subBottom + subHeight, near, far);
var viewProjectionMatrix = m4.multiply(projectionMatrix, viewMatrix);
gl.useProgram(pickProgramInfo.program);
webglUtils.setBuffersAndAttributes(gl, pickProgramInfo, bufferInfo);
webglUtils.setUniforms(pickProgramInfo, pickUniforms);
objects.forEach(function (object) {
var worldMatrix = m4.xRotation(0);
worldMatrix = m4.yRotate(worldMatrix, object.yRotation);
worldMatrix = m4.translate(worldMatrix, object.xTranslation, object.yTranslation, object.zTranslation);
// Multiply the matrices.
m4.multiply(viewProjectionMatrix, worldMatrix, pickUniforms.u_worldViewProjection);
// Set the uniforms we just computed
webglUtils.setUniforms(pickProgramInfo, pickUniforms);
webglUtils.setUniforms(pickProgramInfo, object.pickIDUniform);
gl.drawElements(gl.TRIANGLES, bufferInfo.numElements, gl.UNSIGNED_SHORT, 0);
});
//阅读物体id
const pixels = new Uint8Array(4);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
id = pixels[0];
if (id == 255) { id = 0 }
//console.log(id);
}
function camPos() {
if (id < 0) {
var cameraMatrix = m4.lookAt(cameraPosition, target, up, m4.identity());
viewMatrix = m4.inverse(cameraMatrix);
} else if (id == 0) {
cameraPosition = [0, 0, 0];
target = [0, 0, -1000];
}
else {
/*
cameraPosition = [(1*id-15)*aspect, id*aspect, -20*id-20];
target = [(1*id+5)*aspect, id*aspect, -1000];
*/
cameraPosition = [(-12 * (id - 1) + 2) * aspect, (id - 1) * aspect, -20 * (id - 1) - 28];
//target = [(-12*(id-1)+5)*aspect,(id-1)*aspect,-1000];
}
}
function tweenRotate(e) {
if (!isTweening) {
id = e.target.id;
camPos();
tween();
// title.innerHTML = subtitles[id];
}
}
function tween() {
if (tweenCount > 0) {
if (!isTweenReady) {
prepareTween();
}
isTweening = true;
tweenCount -= 1;
newCamPosStart[0] += camMov[0];
newCamPosStart[1] += camMov[1];
newCamPosStart[2] += camMov[2];
newTargetPosStart[0] += targetMov[0];
newTargetPosStart[1] += targetMov[1];
newTargetPosStart[2] += targetMov[2];
var cameraMatrix = m4.lookAt(newCamPosStart, newTargetPosStart, up, m4.identity());
viewMatrix = m4.inverse(cameraMatrix);
requestAnimationFrame(drawScene);
} else {
isTweenReady = false;
isTweening = false;
//这里考虑清空并初始化初始值和差值,以准备重新开始prepareTween
newCamPosStart = cameraPosition;
newTargetPosStart = target;
tweenCount = 10;
}
}
function prepareTween() {
const newCamPosEnd = cameraPosition;
const newTargetPosEnd = target;
camMov[0] = (newCamPosEnd[0] - newCamPosStart[0]) / tweenCount;
camMov[1] = (newCamPosEnd[1] - newCamPosStart[1]) / tweenCount;
camMov[2] = (newCamPosEnd[2] - newCamPosStart[2]) / tweenCount;
targetMov[0] = (newTargetPosEnd[0] - newTargetPosStart[0]) / tweenCount;
targetMov[1] = (newTargetPosEnd[1] - newTargetPosStart[1]) / tweenCount;
targetMov[2] = (newTargetPosEnd[2] - newTargetPosStart[2]) / tweenCount;
isTweenReady = true;
}
function resizeCanvasToDisplaySize(canvas, multiplier) {
multiplier = multiplier || 2;
const width = canvas.clientWidth * multiplier | 0;
const height = canvas.clientHeight * multiplier | 0;
if (canvas.width !== width || canvas.height !== height) {
canvas.width = width;
canvas.height = height;
aspect = width / height;
return true;
}
return false;
//drawScene();
}
function init() {
camPos();
drawScene();
//tween();
loadImages([
"./nrh/3.jpeg",
"./nrh/2.jpeg",
"./nrh/1.jpeg",
], () => {
for (var ii = 0; ii < picNum; ++ii) {
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
// Set the parameters so we can render any size image.
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
// Upload the image into the texture.
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, images[ii]);
// add the texture to the array of textures.
textures.push(texture);
}
const object1 = {
yRotation: -Math.PI / 2,
xTranslation: 0,
yTranslation: 0,
zTranslation: -15.835,
materialUniforms: {
u_diffuse: textures[0],
},
pickIDUniform: {
u_id: [(0 + 1) / 255, 0, 0, 1],
}
}
const object2 = {
yRotation: 0,
xTranslation: 0,
yTranslation: 0,
zTranslation: -15.835,
materialUniforms: {
u_diffuse: textures[1],
},
pickIDUniform: {
u_id: [(1 + 1) / 255, 0, 0, 1],
}
}
const object3 = {
yRotation: Math.PI / 2,
xTranslation: 0,
yTranslation: 0,
zTranslation: -15.835,
materialUniforms: {
u_diffuse: textures[2],
},
pickIDUniform: {
u_id: [(2 + 1) / 255, 0, 0, 1],
}
}
objects.push(object1, object2, object3);
/*
for (var ii = 0; ii < picNum; ++ii) {
objects.push({
yRotation: 0,
xTranslation: (12*ii+5)*aspect,
yTranslation: ii*aspect,
zTranslation: -20*ii - 50,
materialUniforms: {
u_diffuse: textures[ii],
},
pickIDUniform: {
u_id: [(ii+1)/255, 0,0,1],
}
});
}*/
tween();
});
}
function pick(e) {
if (!isTweening) {
//console.log('pick');
renderPicking(e);
//camPos();
//tween();
//title.innerHTML = subtitles[id];
}
}
init();
function onMouseWheel(e) {
//console.log(e.deltaY);
cameraPosition[0] = 0;
cameraPosition[1] = 0;
radius += e.deltaY;
radius = Math.min(60, Math.max(1, radius));
//console.log(radius);
cameraPosition[2] = radius;
target = [0, 0, 0];
var cameraMatrix = m4.lookAt(cameraPosition, target, up, m4.identity());
viewMatrix = m4.inverse(cameraMatrix);
drawScene();
}
function onMouseDown(e) {
//isMouseDown = true;
canvas.addEventListener('mousemove', onMouseMove, false);
x1 = e.clientX, y1 = e.clientY;
}
let rad = 0;
function onMouseMove(e) {
target = [0, 0, 0];
x2 = e.clientX, y2 = e.clientY;
rad -= (x2 - x1) / 50;
cameraPosition[0] = radius * Math.cos(rad);
cameraPosition[2] = radius * Math.sin(rad);
//console.log(cameraPosition);
var cameraMatrix = m4.lookAt(cameraPosition, target, up, m4.identity());
viewMatrix = m4.inverse(cameraMatrix);
drawScene();
x1 = x2;
y1 = y2;
}
function onMouseUp() {
x1 = 0;
x2 = 0;
y1 = 0;
y2 = 0;
//isMouseDown = false;
canvas.removeEventListener('mousemove', onMouseMove, false);
}
function touchstart(e) {
switch (e.targetTouches.length) {
case 1:
x1 = e.pageX;
break;
default:
const deltaX = e.targetTouches[0].pageX - e.targetTouches[1].pageX;
const deltaY = e.targetTouches[0].pageY - e.targetTouches[1].pageY;
delta0 = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
//tmpConsole.innerText = delta0;
break;
}
window.addEventListener('touchmove', touchmove, false);
window.addEventListener('touchend', touchend, false);
}
function touchmove(e) {
e.preventDefault();
switch (e.targetTouches.length) {
case 1:
target = [0, 0, 0];
x2 = e.pageX, y2 = e.pageY;
rad -= (x2 - x1) / 50;
cameraPosition[0] = radius * Math.cos(rad);
cameraPosition[2] = radius * Math.sin(rad);
//console.log(cameraPosition);
var cameraMatrix = m4.lookAt(cameraPosition, target, up, m4.identity());
viewMatrix = m4.inverse(cameraMatrix);
drawScene();
x1 = x2;
y1 = y2;
break;
default:
const deltaX = e.targetTouches[0].pageX - e.targetTouches[1].pageX;
const deltaY = e.targetTouches[0].pageY - e.targetTouches[1].pageY;
if (!delta0) {
delta0 = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
} else {
delta1 = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
cameraPosition[0] = 0;
cameraPosition[1] = 0;
radius -= (delta1 - delta0);
radius = Math.min(60, Math.max(1, radius));
//tmpConsole.innerText = radius;
cameraPosition[2] = radius;
target = [0, 0, 0];
var cameraMatrix = m4.lookAt(cameraPosition, target, up, m4.identity());
viewMatrix = m4.inverse(cameraMatrix);
drawScene();
delta0 = delta1;
}
break;
}
}
function touchend() {
x1 = 0;
x2 = 0;
y1 = 0;
y2 = 0;
window.removeEventListener('touchmove', touchmove, false);
window.removeEventListener('touchend', touchend, false);
}
//canvas.addEventListener('click', pick, false);
window.addEventListener('resize', drawScene, false);
//canvas.addEventListener('mousemove', renderPicking, false);
//window.addEventListener('load', init, false);
canvas.addEventListener('mousedown', onMouseDown, false);
canvas.addEventListener('mouseup', onMouseUp, false);
canvas.addEventListener('wheel', onMouseWheel, { passive: false });
window.addEventListener('touchstart', touchstart, false);
document.addEventListener('gesturestart', function (event) { event.preventDefault() }, false);
}
main();
</script>
</body>
</html>