-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkarno.html
More file actions
624 lines (548 loc) · 26.4 KB
/
karno.html
File metadata and controls
624 lines (548 loc) · 26.4 KB
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
<!DOCTYPE html>
<html lang="uk">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Топологія Карти Карно: Тор ➔ Прямокутник</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<style>
body { margin: 0; background-color: #111; overflow: hidden; font-family: Arial, sans-serif; }
canvas { display: block; }
/* UI Elements */
#top-bar {
position: absolute;
top: 10px;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
pointer-events: none;
z-index: 10;
}
#title-text {
color: white;
font-size: 18px;
text-shadow: 0 2px 4px rgba(0,0,0,0.8);
background: rgba(0, 0, 0, 0.5);
padding: 5px 15px;
border-radius: 15px;
}
#controls-container {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
width: 90%;
max-width: 600px;
padding: 15px;
background: rgba(0, 0, 0, 0.6);
border-radius: 12px;
backdrop-filter: blur(5px);
box-sizing: border-box;
display: flex;
align-items: center;
gap: 15px;
z-index: 10;
}
.slider {
-webkit-appearance: none;
flex-grow: 1;
height: 6px;
background: #555;
border-radius: 3px;
outline: none;
transition: background .2s;
}
.slider:hover { background: #666; }
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
width: 18px;
height: 18px;
background: #00ff00;
border-radius: 50%;
cursor: pointer;
box-shadow: 0 0 5px rgba(0,255,0,0.5);
}
button {
padding: 8px 16px;
background: #00ff00;
color: #000;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
font-size: 14px;
transition: transform 0.1s, background 0.2s;
}
button:hover { background: #33ff33; transform: scale(1.05); }
button:active { transform: scale(0.95); }
#info-btn {
position: absolute;
top: 20px;
right: 20px;
background: #2196F3;
color: white;
z-index: 20;
box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
#info-btn:hover { background: #42A5F5; }
/* Modal Styles */
.modal {
display: none;
position: fixed;
z-index: 100;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.85);
overflow-y: auto;
}
.modal-content {
background-color: #1e1e1e;
color: #ddd;
margin: 5% auto;
padding: 30px;
border: 1px solid #444;
width: 80%;
max-width: 800px;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0,0,0,0.9);
position: relative;
line-height: 1.6;
}
.close-btn {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
cursor: pointer;
}
.close-btn:hover { color: #fff; }
h2 { color: #00ff00; margin-top: 0; }
h3 { color: #2196F3; margin-bottom: 5px; }
.highlight-blue { color: #5588ff; font-weight: bold; }
.highlight-red { color: #ff5555; font-weight: bold; }
hr { border: 0; border-top: 1px solid #444; margin: 20px 0; }
.diagram-hint {
background: #333;
padding: 10px;
border-left: 4px solid #00ff00;
margin: 10px 0;
font-style: italic;
font-size: 0.9em;
}
</style>
</head>
<body>
<div id="top-bar">
<div id="title-text">Трансформація: Тор ➔ Циліндр ➔ Прямокутник (Карта Карно)</div>
</div>
<button id="info-btn">📖 Теорія / Довідка</button>
<div id="controls-container">
<button id="play-pause-button">Pause</button>
<input type="range" min="0" max="1000" value="0" class="slider" id="progress-slider">
</div>
<div id="modal" class="modal">
<div class="modal-content">
<span class="close-btn">×</span>
<h2>Топологія Карти Карно</h2>
<p>Карта Карно — це не просто плоска таблиця. Це розгортка багатовимірного куба на площину. Для того, щоб зберегти властивість сусідства (код Грея), карту слід розглядати як об'єкт на поверхні <strong>Тора</strong>.</p>
<div class="diagram-hint">
💡 <strong>Інтерактив:</strong> Використовуйте повзунок знизу, щоб побачити, як плоска карта згортається назад у Тор.
</div>
<h3>1. Чому краї з'єднані? (Циліндр)</h3>
<p>У карті Карно клітинка крайнього лівого стовпця вважається сусідньою до клітинки крайнього правого стовпця (в тому ж рядку). </p>
<ul>
<li>На площині вони далекі одна від одної.</li>
<li>Якщо ми склеїмо лівий і правий краї карти, ми отримаємо <strong>Циліндр</strong>. На поверхні циліндра ці клітинки торкаються.</li>
</ul>
<hr>
<h3>2. Чому верх і низ з'єднані? (Тор)</h3>
<p>Аналогічно, верхній рядок є сусіднім до нижнього. </p>
<ul>
<li><span class="highlight-red">Червоні точки</span> на симуляції показують клітинки на верхній та нижній межі.</li>
<li>Коли ми згинаємо циліндр і склеюємо його верхнє та нижнє коло, ми отримуємо <strong>Тор</strong> (форму бублика).</li>
<li>У цей момент червоні точки фізично зустрічаються і стають сусідами.</li>
</ul>
<hr>
<h3>3. Феномен кутів (Сині точки)</h3>
<p>Найцікавіше відбувається з чотирма кутами карти:</p>
<ul>
<li><span class="highlight-blue">Сині точки</span> позначають чотири кутові клітинки карти (наприклад, 0000, 0010, 1000, 1010).</li>
<li>На площині вони максимально віддалені.</li>
<li>Але на Торі всі чотири кути сходяться в <strong>одну точку</strong> (або тісну область).</li>
</ul>
<p>Саме тому в методі карт Карно ми можемо об'єднувати чотири кутові одиниці в одну групу — топологічно вони утворюють єдиний кластер на поверхні тора.</p>
</div>
</div>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.160.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { ParametricGeometry } from 'three/addons/geometries/ParametricGeometry.js';
let scene, camera, renderer, controls;
let torusMesh, cylinderMesh, rectMesh, material;
let slider, clock, playPauseButton;
// --- КОНСТАНТИ АНІМАЦІЇ ---
const R0 = 6;
const r0 = 4;
const finalWidth = 2 * Math.PI * r0;
const finalHeight = 2 * Math.PI * R0;
const minTheta = 0.01;
const loopDuration = 10;
// --- ЕТАПИ ТРАНСФОРМАЦІЇ ---
const t_TorusToCyl_End = 0.49;
const t_Cyl_Start = 0.51;
const t_CylToRect_End = 0.99;
// --- СТАН АНІМАЦІЇ ---
let manualControl = false;
let lastProgress = 0;
let animStartTime = 0;
let isPlaying = true;
// --- Змінні для параметричних функцій ---
let current_R, u_start, u_end;
let current_r;
let current_gap_u = 0.0;
let current_gap_v = 0.0;
// --- Змінні для Карти Карно ---
let kMapGroup;
let kMapLines = [];
let kMapMarkers = [];
const kMapLineMat = new THREE.LineBasicMaterial({ color: 0xffa500, linewidth: 2 });
const vertexMatRed = new THREE.MeshStandardMaterial({ color: 0xff0000, emissive: 0x550000 });
const vertexMatBlue = new THREE.MeshStandardMaterial({ color: 0x3366ff, emissive: 0x112255 });
const EDGE_SEGMENTS = 40;
const MAX_EDGE_SPLITS = 4;
const tempVec = new THREE.Vector3();
const mod = (n, m) => ((n % m) + m) % m;
function init() {
clock = new THREE.Clock();
scene = new THREE.Scene();
// Темніший фон для кращого контрасту з поясненнями
scene.background = new THREE.Color(0x1a1a1a);
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(finalWidth * 0.8, finalHeight * 0.8, finalHeight * 0.8);
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
document.body.appendChild(renderer.domElement);
controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.target.set(0, 0, 0);
const ambientLight = new THREE.AmbientLight(0x404040, 3);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 2);
directionalLight.position.set(10, 20, 10);
scene.add(directionalLight);
// Grid
const gridHelper = new THREE.GridHelper(
Math.max(finalWidth, finalHeight) * 2,
20,
0x444444, 0x222222
);
gridHelper.position.y = -5;
scene.add(gridHelper);
// Основний матеріал поверхні (напівпрозорий)
material = new THREE.MeshStandardMaterial({
color: 0x004400,
wireframe: false,
side: THREE.DoubleSide,
transparent: true,
opacity: 0.6,
roughness: 0.2,
metalness: 0.1
});
torusMesh = new THREE.Mesh(new THREE.BufferGeometry(), material);
scene.add(torusMesh);
cylinderMesh = new THREE.Mesh(new THREE.BufferGeometry(), material);
scene.add(cylinderMesh);
const rectGeo = new THREE.PlaneGeometry(finalHeight, finalWidth);
rectGeo.rotateX(-Math.PI / 2);
rectMesh = new THREE.Mesh(rectGeo, material);
rectMesh.position.y = 0;
rectMesh.visible = false;
scene.add(rectMesh);
// --- Ініціалізація ТІЛЬКИ Карти Карно ---
initKarnaughMap();
// --- Обробники UI ---
slider = document.getElementById('progress-slider');
slider.addEventListener('input', () => {
const progress = parseFloat(slider.value) / 1000.0;
updateAnimation(progress);
lastProgress = progress;
});
slider.addEventListener('pointerdown', () => {
manualControl = true;
if (isPlaying) { playPauseButton.textContent = 'Play'; }
});
slider.addEventListener('pointerup', () => {
manualControl = false;
lastProgress = parseFloat(slider.value) / 1000.0;
animStartTime = clock.getElapsedTime();
if (isPlaying) { playPauseButton.textContent = 'Pause'; }
});
playPauseButton = document.getElementById('play-pause-button');
playPauseButton.addEventListener('click', togglePlayPause);
// --- Modal Logic ---
const modal = document.getElementById("modal");
const btn = document.getElementById("info-btn");
const span = document.getElementsByClassName("close-btn")[0];
btn.onclick = function() {
modal.style.display = "block";
}
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
// Відкриваємо модальне вікно при старті
setTimeout(() => { modal.style.display = "block"; }, 500);
window.addEventListener('resize', onWindowResize, false);
updateAnimation(0);
}
function togglePlayPause() {
isPlaying = !isPlaying;
if (isPlaying) {
playPauseButton.textContent = 'Pause';
animStartTime = clock.getElapsedTime();
} else {
playPauseButton.textContent = 'Play';
lastProgress = parseFloat(slider.value) / 1000.0;
}
}
// --- Блок: Карта Карно ---
function initKarnaughMap() {
kMapGroup = new THREE.Group();
kMapLines = [];
kMapMarkers = [];
scene.add(kMapGroup);
// 1. Лінії сітки (4x4)
const lineDefs = [];
for (let i = 0; i <= 4; i++) { // Вертикальні
const u = i * 0.25;
lineDefs.push({ start_uv: {u_norm: u, v_norm: 0.0}, end_uv: {u_norm: u, v_norm: 1.0} });
}
for (let i = 0; i <= 4; i++) { // Горизонтальні
const v = i * 0.25;
lineDefs.push({ start_uv: {u_norm: 0.0, v_norm: v}, end_uv: {u_norm: 1.0, v_norm: v} });
}
for (const def of lineDefs) {
const edgeGroup = new THREE.Group();
edgeGroup.userData = def;
edgeGroup.userData.linePool = [];
for (let i = 0; i < MAX_EDGE_SPLITS; i++) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array((EDGE_SEGMENTS + 1) * 3), 3));
const line = new THREE.Line(geometry, kMapLineMat);
line.visible = false;
edgeGroup.userData.linePool.push(line);
edgeGroup.add(line);
}
kMapLines.push(edgeGroup);
kMapGroup.add(edgeGroup);
}
// 2. Маркери
const markerGeo = new THREE.SphereGeometry(0.6, 24, 24);
const cellCenter = 0.125; // Центр першої клітинки
// СИНІ: Кути (0,0), (3,0), (0,3), (3,3)
const blueCoords = [
{ u: cellCenter, v: cellCenter },
{ u: 1.0 - cellCenter, v: cellCenter },
{ u: cellCenter, v: 1.0 - cellCenter },
{ u: 1.0 - cellCenter, v: 1.0 - cellCenter }
];
// ЧЕРВОНІ: Сусідство верх-низ (середина таблиці)
// Клітинки (1,0) та (1,3)
const redCoords = [
{ u: cellCenter + 0.25, v: cellCenter },
{ u: cellCenter + 0.25, v: 1.0 - cellCenter }
];
for (const uv of blueCoords) {
const mesh = new THREE.Mesh(markerGeo, vertexMatBlue);
mesh.userData = { uv: uv };
kMapMarkers.push(mesh);
kMapGroup.add(mesh);
}
for (const uv of redCoords) {
const mesh = new THREE.Mesh(markerGeo, vertexMatRed);
mesh.userData = { uv: uv };
kMapMarkers.push(mesh);
kMapGroup.add(mesh);
}
}
// --- Геометричні функції ---
function getCurrentSurfacePoint(u_norm, v_norm, progress, target) {
const u = mod(u_norm, 1.0);
const v = mod(v_norm, 1.0);
if (progress < t_TorusToCyl_End) {
torusCutFunc(u, v, target);
} else if (progress < t_Cyl_Start) {
cylinderFunc(u, v, target);
} else if (progress < t_CylToRect_End) {
cylinderCutFunc(u, v, target);
} else {
// Прямокутник
const x = THREE.MathUtils.lerp(-finalHeight / 2, finalHeight / 2, u);
const z = THREE.MathUtils.lerp(-finalWidth / 2, finalWidth / 2, v);
target.set(x, 0, z);
}
}
function updateLineGroup(edgeGroup, progress, start_uv, end_uv) {
const u_seam_is_open = current_gap_u > 0.001;
const v_seam_is_open = current_gap_v > 0.001;
const linePool = edgeGroup.userData.linePool;
let du = end_uv.u_norm - start_uv.u_norm;
let dv = end_uv.v_norm - start_uv.v_norm;
let u_prev = start_uv.u_norm;
let v_prev = start_uv.v_norm;
let linePoolIndex = 0;
let currentLine = linePool[linePoolIndex];
currentLine.visible = true;
let currentPos = currentLine.geometry.attributes.position;
let pointIndex = 0;
getCurrentSurfacePoint(u_prev, v_prev, progress, tempVec);
currentPos.setXYZ(pointIndex++, tempVec.x, tempVec.y, tempVec.z);
for (let i = 1; i <= EDGE_SEGMENTS; i++) {
const t = i / EDGE_SEGMENTS;
const u_curr = start_uv.u_norm + du * t;
const v_curr = start_uv.v_norm + dv * t;
const u_boundary_crossed = Math.floor(u_curr) !== Math.floor(u_prev);
const v_boundary_crossed = Math.floor(v_curr) !== Math.floor(v_prev);
u_prev = u_curr;
v_prev = v_curr;
let split = false;
if (u_boundary_crossed && u_seam_is_open) split = true;
if (v_boundary_crossed && v_seam_is_open) split = true;
getCurrentSurfacePoint(u_curr, v_curr, progress, tempVec);
if (split) {
currentPos.needsUpdate = true;
for (let k = pointIndex; k <= EDGE_SEGMENTS; k++) currentPos.setXYZ(k, tempVec.x, tempVec.y, tempVec.z);
linePoolIndex++;
if (linePoolIndex >= linePool.length) break;
currentLine = linePool[linePoolIndex];
currentLine.visible = true;
currentPos = currentLine.geometry.attributes.position;
pointIndex = 0;
currentPos.setXYZ(pointIndex++, tempVec.x, tempVec.y, tempVec.z);
} else {
if (pointIndex <= EDGE_SEGMENTS) {
currentPos.setXYZ(pointIndex++, tempVec.x, tempVec.y, tempVec.z);
}
}
}
currentPos.needsUpdate = true;
for (let k = pointIndex; k <= EDGE_SEGMENTS; k++) currentPos.setXYZ(k, tempVec.x, tempVec.y, tempVec.z);
for (let i = linePoolIndex + 1; i < linePool.length; i++) linePool[i].visible = false;
}
function updateKarnaughMap(progress) {
if (!kMapGroup) return;
// Лінії
for (let j = 0; j < kMapLines.length; j++) {
const edgeGroup = kMapLines[j];
updateLineGroup(edgeGroup, progress, edgeGroup.userData.start_uv, edgeGroup.userData.end_uv);
}
// Маркери
for (const marker of kMapMarkers) {
const { u, v } = marker.userData.uv;
getCurrentSurfacePoint(u, v, progress, marker.position);
}
}
// --- Параметричні функції ---
function torusCutFunc(u_norm, v_norm, target) {
const u = THREE.MathUtils.lerp(u_start, u_end, u_norm);
const v = THREE.MathUtils.lerp(-Math.PI, Math.PI, v_norm);
target.x = (current_R + r0 * Math.cos(v)) * Math.cos(u);
target.y = (current_R + r0) + (current_R + r0 * Math.cos(v)) * Math.sin(u);
target.z = r0 * Math.sin(v);
}
function cylinderFunc(u_norm, v_norm, target) {
const h = THREE.MathUtils.lerp(-finalHeight / 2, finalHeight / 2, u_norm);
const v_angle = THREE.MathUtils.lerp(-Math.PI, Math.PI, v_norm);
target.x = h;
target.y = r0 - r0 * Math.cos(v_angle);
target.z = r0 * Math.sin(v_angle);
}
function cylinderCutFunc(u_norm, v_norm, target) {
const h = THREE.MathUtils.lerp(-finalHeight / 2, finalHeight / 2, u_norm);
current_r = (Math.PI * r0) / (Math.PI - current_gap_v);
const v_angle = THREE.MathUtils.lerp(-(Math.PI - current_gap_v), (Math.PI - current_gap_v), v_norm);
target.x = h;
target.y = current_r - current_r * Math.cos(v_angle);
target.z = current_r * Math.sin(v_angle);
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
function updateAnimation(progress) {
torusMesh.visible = false;
cylinderMesh.visible = false;
rectMesh.visible = false;
current_gap_u = 0.0;
current_gap_v = 0.0;
let geom;
const segmentsU = 80;
const segmentsV = 40;
if (progress < t_TorusToCyl_End) {
torusMesh.visible = true;
const p1 = progress / t_TorusToCyl_End;
current_gap_u = THREE.MathUtils.lerp(0, Math.PI - minTheta, p1);
current_R = (Math.PI * R0) / (Math.PI - current_gap_u);
u_start = (3 * Math.PI / 2) - (Math.PI - current_gap_u);
u_end = (3 * Math.PI / 2) + (Math.PI - current_gap_u);
geom = new ParametricGeometry(torusCutFunc, segmentsU, segmentsV);
torusMesh.geometry.dispose();
torusMesh.geometry = geom;
} else if (progress < t_Cyl_Start) {
cylinderMesh.visible = true;
current_gap_u = Math.PI - minTheta;
if (!cylinderMesh.geometry.attributes.position || manualControl) {
geom = new ParametricGeometry(cylinderFunc, segmentsU, segmentsV);
cylinderMesh.geometry.dispose();
cylinderMesh.geometry = geom;
}
} else if (progress < t_CylToRect_End) {
cylinderMesh.visible = true;
current_gap_u = Math.PI - minTheta;
const p2 = (progress - t_Cyl_Start) / (t_CylToRect_End - t_Cyl_Start);
current_gap_v = THREE.MathUtils.lerp(0, Math.PI - minTheta, p2);
geom = new ParametricGeometry(cylinderCutFunc, segmentsU, segmentsV);
cylinderMesh.geometry.dispose();
cylinderMesh.geometry = geom;
} else {
rectMesh.visible = true;
current_gap_u = Math.PI - minTheta;
current_gap_v = Math.PI - minTheta;
}
// Завжди оновлюємо Карту Карно
updateKarnaughMap(progress);
}
function animate() {
requestAnimationFrame(animate);
if (!manualControl && isPlaying) {
const timeSinceResume = clock.getElapsedTime() - animStartTime;
const progress = (lastProgress + (timeSinceResume / loopDuration)) % 1.0;
updateAnimation(progress);
slider.value = progress * 1000;
}
controls.update();
renderer.render(scene, camera);
}
init();
animate();
</script>
</body>
</html>