-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2067 lines (1796 loc) · 86.8 KB
/
index.html
File metadata and controls
2067 lines (1796 loc) · 86.8 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
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
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VR WebOS v2.0 - Enhanced Virtual Reality Operating System</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background: #000;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
user-select: none;
}
#canvas3d {
width: 100%;
height: 100%;
display: block;
cursor: none;
}
/* Enhanced UI Design */
#ui {
position: fixed;
top: 20px;
left: 20px;
background: rgba(0,0,0,0.85);
backdrop-filter: blur(15px);
color: white;
padding: 25px;
border-radius: 15px;
border: 1px solid rgba(255,255,255,0.1);
z-index: 1000;
max-width: 350px;
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
animation: slideIn 0.5s ease-out;
}
@keyframes slideIn {
from { transform: translateX(-100%); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
.btn {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 12px 20px;
margin: 8px 0;
border-radius: 8px;
cursor: pointer;
width: 100%;
font-size: 14px;
font-weight: 500;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}
.btn:active {
transform: translateY(0);
}
input {
width: 100%;
padding: 12px;
margin: 8px 0;
border: 1px solid rgba(255,255,255,0.2);
border-radius: 8px;
background: rgba(255,255,255,0.05);
color: white;
font-size: 14px;
transition: all 0.3s ease;
}
input:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}
input::placeholder {
color: rgba(255,255,255,0.5);
}
.app-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
margin: 15px 0;
}
.app-btn {
background: rgba(255,255,255,0.08);
color: white;
border: none;
padding: 20px 8px;
border-radius: 10px;
cursor: pointer;
font-size: 11px;
transition: all 0.3s ease;
text-align: center;
border: 1px solid rgba(255,255,255,0.1);
}
.app-btn:hover {
background: rgba(255,255,255,0.15);
transform: scale(1.05) translateY(-2px);
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
h3 {
margin: 0 0 20px 0;
text-align: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
font-size: 24px;
font-weight: 600;
}
/* System Windows */
.window {
position: fixed;
background: rgba(0,0,10,0.95);
backdrop-filter: blur(20px);
border: 2px solid rgba(102, 126, 234, 0.6);
border-radius: 15px;
color: white;
display: none;
z-index: 2000;
min-width: 500px;
min-height: 400px;
box-shadow: 0 20px 60px rgba(0,0,0,0.8);
animation: windowOpen 0.3s ease-out;
}
@keyframes windowOpen {
from { transform: scale(0.8) translateY(50px); opacity: 0; }
to { transform: scale(1) translateY(0); opacity: 1; }
}
.window-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 15px 20px;
border-radius: 13px 13px 0 0;
display: flex;
justify-content: space-between;
align-items: center;
cursor: move;
font-weight: 500;
}
.window-content {
padding: 25px;
max-height: 400px;
overflow-y: auto;
}
.close-btn {
background: rgba(255,255,255,0.2);
border: none;
color: white;
font-size: 16px;
cursor: pointer;
width: 30px;
height: 30px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
}
.close-btn:hover {
background: rgba(255,0,0,0.6);
transform: scale(1.1);
}
/* Status Bar */
#status-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: rgba(0,0,0,0.8);
backdrop-filter: blur(10px);
color: white;
padding: 12px 20px;
font-size: 12px;
z-index: 1000;
display: flex;
justify-content: space-between;
align-items: center;
border-top: 1px solid rgba(255,255,255,0.1);
}
/* File Items */
.file-item {
padding: 12px 15px;
border-radius: 8px;
cursor: pointer;
margin: 4px 0;
display: flex;
align-items: center;
transition: all 0.2s ease;
border: 1px solid transparent;
}
.file-item:hover {
background: rgba(102, 126, 234, 0.2);
border-color: rgba(102, 126, 234, 0.4);
transform: translateX(5px);
}
/* Terminal Styling */
.terminal-content {
background: #0a0a0a;
font-family: 'Courier New', monospace;
font-size: 14px;
line-height: 1.4;
border-radius: 0 0 13px 13px;
}
.terminal-line {
color: #00ff00;
margin: 2px 0;
}
.terminal-input-line {
display: flex;
align-items: center;
color: #00ff00;
margin-top: 10px;
}
.terminal-prompt {
margin-right: 8px;
font-weight: bold;
}
#terminal-input {
background: none;
border: none;
color: #00ff00;
flex: 1;
font-family: inherit;
font-size: inherit;
}
/* Version Badge */
.version-badge {
position: fixed;
top: 20px;
right: 20px;
background: rgba(102, 126, 234, 0.9);
color: white;
padding: 8px 15px;
border-radius: 20px;
font-size: 12px;
font-weight: 500;
z-index: 1000;
}
/* Performance Monitor */
.perf-monitor {
position: fixed;
top: 70px;
right: 20px;
background: rgba(0,0,0,0.8);
color: white;
padding: 10px 15px;
border-radius: 8px;
font-size: 11px;
z-index: 1000;
font-family: monospace;
}
/* Loading Screen */
#loading-screen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, #0a0a2e 0%, #16213e 50%, #0f3460 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 10000;
color: white;
font-size: 18px;
}
.loading-spinner {
width: 50px;
height: 50px;
border: 3px solid rgba(255,255,255,0.3);
border-top: 3px solid #667eea;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 20px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Responsive Design */
@media (max-width: 768px) {
#ui {
max-width: 280px;
padding: 15px;
}
.app-grid {
grid-template-columns: repeat(2, 1fr);
}
.window {
min-width: 90%;
min-height: 60%;
top: 5%;
left: 5%;
}
}
</style>
</head>
<body>
<!-- Loading Screen -->
<div id="loading-screen">
<div class="loading-spinner"></div>
<div>VR WebOS v2.0</div>
<div style="font-size: 14px; margin-top: 10px;">Initializing Virtual Environment...</div>
</div>
<!-- Version Badge -->
<div class="version-badge">v2.0</div>
<!-- Performance Monitor -->
<div class="perf-monitor" id="perf-monitor">
<div>FPS: <span id="fps">60</span></div>
<div>Objects: <span id="object-count">0</span></div>
<div>Memory: <span id="memory-usage">0</span>MB</div>
</div>
<!-- Main Canvas -->
<canvas id="canvas3d"></canvas>
<!-- Control Panel -->
<div id="ui">
<h3>🖥️ VR WebOS v2.0</h3>
<div class="app-grid">
<button class="app-btn" onclick="VRWebOS.openApp('files')">📁<br>Files</button>
<button class="app-btn" onclick="VRWebOS.openApp('terminal')">⚡<br>Terminal</button>
<button class="app-btn" onclick="VRWebOS.openApp('browser')">🌐<br>Browser</button>
<button class="app-btn" onclick="VRWebOS.openApp('games')">🎮<br>Games</button>
<button class="app-btn" onclick="VRWebOS.openApp('media')">🎵<br>Media</button>
<button class="app-btn" onclick="VRWebOS.openApp('code')">💻<br>Code</button>
<button class="app-btn" onclick="VRWebOS.openApp('chat')">💬<br>Chat</button>
<button class="app-btn" onclick="VRWebOS.openApp('tools')">🔧<br>Tools</button>
<button class="app-btn" onclick="VRWebOS.openApp('settings')">⚙️<br>Settings</button>
</div>
<input type="text" id="url-input" placeholder="🌐 Enter URL or search term...">
<button class="btn" onclick="VRWebOS.createWebDesktop()">🚀 Create Web Desktop</button>
<input type="file" id="file-input" multiple onchange="VRWebOS.uploadFiles(event)" style="font-size: 12px; padding: 8px;">
<button class="btn" onclick="VRWebOS.enterVR()">🥽 Enter VR Mode</button>
<button class="btn" onclick="VRWebOS.arrangeDesktops()">📐 Auto Arrange</button>
<button class="btn" onclick="VRWebOS.resetEnvironment()">🔄 Reset Environment</button>
<div style="font-size: 12px; margin-top: 15px; text-align: center; opacity: 0.7;">
Desktops: <span id="desktop-count">0</span> •
Files: <span id="file-count">0</span> •
Uptime: <span id="uptime">00:00</span>
</div>
</div>
<!-- Enhanced File Manager -->
<div id="file-window" class="window" style="top: 8%; left: 25%;">
<div class="window-header">
<span>📁 Advanced File Manager</span>
<button class="close-btn" onclick="VRWebOS.closeWindow('file-window')">✕</button>
</div>
<div class="window-content">
<div style="margin-bottom: 15px;">
<button class="btn" onclick="VRWebOS.createFile()" style="width: auto; margin: 0 5px 0 0;">➕ New File</button>
<button class="btn" onclick="VRWebOS.createFolder()" style="width: auto; margin: 0 5px 0 0;">📁 New Folder</button>
<button class="btn" onclick="VRWebOS.importFile()" style="width: auto; margin: 0;">📥 Import</button>
</div>
<div style="border-top: 1px solid rgba(255,255,255,0.1); padding-top: 15px;">
<div id="file-breadcrumb" style="margin-bottom: 10px; font-size: 12px; opacity: 0.7;"></div>
<div id="file-list"></div>
</div>
</div>
</div>
<!-- Enhanced Terminal -->
<div id="terminal-window" class="window" style="top: 10%; left: 30%;">
<div class="window-header">
<span>⚡ VR WebOS Terminal v2.0</span>
<button class="close-btn" onclick="VRWebOS.closeWindow('terminal-window')">✕</button>
</div>
<div class="window-content terminal-content">
<div class="terminal-line">VR WebOS Terminal v2.0 - Enhanced Command Interface</div>
<div class="terminal-line">Type 'help' for available commands, 'about' for system info</div>
<div class="terminal-line">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</div>
<div id="terminal-output"></div>
<div class="terminal-input-line">
<span class="terminal-prompt">vrwebos@system:~$</span>
<input type="text" id="terminal-input" onkeypress="VRWebOS.handleCommand(event)" autocomplete="off">
</div>
</div>
</div>
<!-- Status Bar -->
<div id="status-bar">
<div>
🖱️ WASD + Mouse: Navigate • Click: Focus Desktop •
<span id="active-desktop">Active: None</span>
</div>
<div>
<span id="system-time">--:--:--</span> •
Storage: <span id="storage-info">0 KB</span> •
Network: <span id="network-status">Online</span>
</div>
</div>
<script>
// VR WebOS v2.0 - Enhanced Virtual Reality Operating System
window.VRWebOS = {
// Version Info
version: '2.0.0',
buildDate: new Date().toISOString().split('T')[0],
// Core 3D System
canvas: null,
ctx: null,
width: 0,
height: 0,
// Enhanced 3D Environment
camera: {
x: 0, y: 1.6, z: -6,
rotX: 0, rotY: 0,
fov: 70,
speed: 0.12
},
// System Components
desktops: [],
files: {},
processes: [],
particles: [],
lights: [],
// Enhanced Controls
keys: {},
mouseDown: false,
touchSupport: false,
// Performance Monitoring
performance: {
fps: 0,
frameCount: 0,
lastTime: 0,
memory: 0
},
// System State
startTime: Date.now(),
currentPath: '/',
// Initialize Enhanced VR WebOS
async init() {
console.log("🚀 Booting VR WebOS v2.0...");
// Show loading screen
this.showBootSequence();
// Initialize core systems
await this.initializeCore();
await this.loadSystemData();
await this.setupEnhancedEnvironment();
await this.startSystemServices();
// Hide loading and show interface
setTimeout(() => {
document.getElementById('loading-screen').style.display = 'none';
this.animate();
console.log("✅ VR WebOS v2.0 Ready!");
}, 2000);
},
showBootSequence() {
const messages = [
"Loading 3D Engine...",
"Initializing File System...",
"Starting Network Services...",
"Loading Virtual Environment...",
"Preparing VR Interface..."
];
let i = 0;
const loadingText = document.querySelector('#loading-screen div:last-child');
const interval = setInterval(() => {
if (i < messages.length) {
loadingText.textContent = messages[i];
i++;
} else {
clearInterval(interval);
}
}, 400);
},
async initializeCore() {
this.canvas = document.getElementById('canvas3d');
this.ctx = this.canvas.getContext('2d');
// Check for touch support
this.touchSupport = 'ontouchstart' in window;
this.resize();
this.setupEnhancedControls();
// Initialize 3D environment
this.createEnhancedParticles();
this.createDynamicLighting();
},
async loadSystemData() {
const saved = localStorage.getItem('vrwebos-v2-data');
if (saved) {
try {
const data = JSON.parse(saved);
this.files = data.files || {};
this.desktops = data.desktops || [];
this.camera = {...this.camera, ...data.camera};
} catch (e) {
console.warn("Failed to load saved data, using defaults");
this.createDefaultFiles();
}
} else {
this.createDefaultFiles();
}
if (this.desktops.length === 0) {
this.createWelcomeDesktop();
}
this.updateAllCounters();
},
createDefaultFiles() {
this.files = {
'Documents': {
'welcome-v2.txt': 'Welcome to VR WebOS v2.0!\n\nNew Features:\n- Enhanced 3D graphics\n- Better performance\n- More applications\n- Improved file system\n- Advanced terminal\n\nEnjoy exploring your virtual workspace!',
'changelog.md': '# VR WebOS v2.0 Changelog\n\n## New Features\n- Enhanced UI design\n- Performance monitoring\n- Better 3D rendering\n- Mobile support\n- Advanced terminal commands\n\n## Bug Fixes\n- Improved stability\n- Better error handling\n- Memory optimizations'
},
'Downloads': {},
'Programs': {
'calculator.exe': 'Advanced Calculator v2.0',
'notepad.exe': 'Enhanced Text Editor v2.0',
'browser.exe': 'VR Web Browser v2.0',
'mediaplayer.exe': 'VR Media Player v2.0'
},
'Games': {
'tetris.rom': 'Classic Tetris ROM',
'snake.rom': 'Snake Game ROM',
'pong.rom': 'Pong Game ROM'
},
'System': {
'config.json': '{"theme":"dark","performance":"high","vr":"enabled","version":"2.0.0"}',
'logs.txt': 'System startup log...'
}
};
},
setupEnhancedControls() {
// Resize handler
window.addEventListener('resize', () => this.resize());
// Keyboard controls
document.addEventListener('keydown', (e) => {
this.keys[e.code] = true;
// System shortcuts
if (e.ctrlKey) {
switch(e.key) {
case 's':
e.preventDefault();
this.saveSystemData();
break;
case 'o':
e.preventDefault();
this.openApp('files');
break;
case '`':
e.preventDefault();
this.openApp('terminal');
break;
}
}
});
document.addEventListener('keyup', (e) => {
this.keys[e.code] = false;
});
// Enhanced mouse controls
this.canvas.addEventListener('mousedown', (e) => {
this.mouseDown = true;
this.clickDesktop(e);
});
document.addEventListener('mouseup', () => {
this.mouseDown = false;
});
document.addEventListener('mousemove', (e) => {
if (this.mouseDown && document.pointerLockElement === this.canvas) {
this.camera.rotY += e.movementX * 0.003;
this.camera.rotX += e.movementY * 0.003;
this.camera.rotX = Math.max(-1.5, Math.min(1.5, this.camera.rotX));
}
});
// Touch controls for mobile
if (this.touchSupport) {
this.setupTouchControls();
}
// Pointer lock
this.canvas.addEventListener('click', () => {
this.canvas.requestPointerLock();
});
},
setupTouchControls() {
let touchStartX, touchStartY;
this.canvas.addEventListener('touchstart', (e) => {
e.preventDefault();
const touch = e.touches[0];
touchStartX = touch.clientX;
touchStartY = touch.clientY;
});
this.canvas.addEventListener('touchmove', (e) => {
e.preventDefault();
if (e.touches.length === 1) {
const touch = e.touches[0];
const deltaX = touch.clientX - touchStartX;
const deltaY = touch.clientY - touchStartY;
this.camera.rotY += deltaX * 0.01;
this.camera.rotX += deltaY * 0.01;
this.camera.rotX = Math.max(-1.5, Math.min(1.5, this.camera.rotX));
touchStartX = touch.clientX;
touchStartY = touch.clientY;
}
});
this.canvas.addEventListener('touchend', (e) => {
e.preventDefault();
if (e.changedTouches.length === 1) {
this.clickDesktop(e.changedTouches[0]);
}
});
},
createEnhancedParticles() {
this.particles = [];
for (let i = 0; i < 40; i++) {
this.particles.push({
x: (Math.random() - 0.5) * 50,
y: Math.random() * 15 + 2,
z: (Math.random() - 0.5) * 50,
vx: (Math.random() - 0.5) * 0.02,
vy: (Math.random() - 0.5) * 0.01,
vz: (Math.random() - 0.5) * 0.02,
color: ['#667eea', '#764ba2', '#f093fb', '#f5576c'][Math.floor(Math.random() * 4)],
size: Math.random() * 0.1 + 0.05,
life: 1.0
});
}
},
createDynamicLighting() {
this.lights = [
{ x: 10, y: 5, z: 10, color: '#667eea', intensity: 0.8 },
{ x: -10, y: 5, z: 10, color: '#764ba2', intensity: 0.6 },
{ x: 0, y: 8, z: -10, color: '#f093fb', intensity: 0.7 }
];
},
async setupEnhancedEnvironment() {
// Create welcome desktop if none exist
if (this.desktops.length === 0) {
this.createWelcomeDesktop();
}
},
async startSystemServices() {
// System time updater
setInterval(() => {
const now = new Date();
document.getElementById('system-time').textContent =
now.toLocaleTimeString();
// Update uptime
const uptime = Math.floor((Date.now() - this.startTime) / 1000);
const minutes = Math.floor(uptime / 60);
const seconds = uptime % 60;
document.getElementById('uptime').textContent =
`${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
}, 1000);
// Performance monitor
setInterval(() => {
this.updatePerformanceMonitor();
}, 2000);
// Auto-save system data
setInterval(() => {
this.saveSystemData();
}, 30000);
// Network status simulation
setInterval(() => {
document.getElementById('network-status').textContent =
navigator.onLine ? 'Online' : 'Offline';
}, 5000);
},
updatePerformanceMonitor() {
// Calculate FPS
const now = performance.now();
this.performance.fps = Math.round(1000 / (now - this.performance.lastTime));
this.performance.lastTime = now;
// Update memory usage (approximation)
this.performance.memory = Math.round(
(JSON.stringify(this.files).length +
this.desktops.length * 100 +
this.particles.length * 50) / 1024
);
// Update display
document.getElementById('fps').textContent = this.performance.fps || 60;
document.getElementById('object-count').textContent =
this.desktops.length + this.particles.length;
document.getElementById('memory-usage').textContent = this.performance.memory;
},
resize() {
this.width = window.innerWidth;
this.height = window.innerHeight;
this.canvas.width = this.width;
this.canvas.height = this.height;
},
saveSystemData() {
const data = {
files: this.files,
desktops: this.desktops,
camera: this.camera,
version: this.version,
lastSave: Date.now()
};
try {
localStorage.setItem('vrwebos-v2-data', JSON.stringify(data));
this.updateAllCounters();
console.log("💾 System data saved");
} catch (e) {
console.error("Failed to save system data:", e);
}
},
updateAllCounters() {
// Update file count
let fileCount = 0;
const countFiles = (obj) => {
for (let key in obj) {
if (typeof obj[key] === 'string') fileCount++;
else countFiles(obj[key]);
}
};
countFiles(this.files);
document.getElementById('file-count').textContent = fileCount;
// Update desktop count
document.getElementById('desktop-count').textContent = this.desktops.length;
// Update storage info
const size = new Blob([JSON.stringify(this.files)]).size;
document.getElementById('storage-info').textContent = `${Math.round(size/1024)} KB`;
},
createWelcomeDesktop() {
this.desktops.push({
id: 0,
x: 0, y: 1.6, z: 4,
type: 'welcome',
title: '🏠 Welcome to VR WebOS v2.0',
content: 'Enhanced Virtual Reality Operating System',
color: '#667eea',
active: true,
scale: 1.0,
rotation: 0
});
this.updateAllCounters();
},
// Enhanced Camera Movement
updateCamera() {
const speed = this.camera.speed;
const cos = Math.cos(this.camera.rotY);
const sin = Math.sin(this.camera.rotY);
// Smooth movement with acceleration
if (this.keys['KeyW'] || this.keys['ArrowUp']) {
this.camera.x += sin * speed;
this.camera.z += cos * speed;
}
if (this.keys['KeyS'] || this.keys['ArrowDown']) {
this.camera.x -= sin * speed;
this.camera.z -= cos * speed;
}
if (this.keys['KeyA'] || this.keys['ArrowLeft']) {
this.camera.x -= cos * speed;
this.camera.z += sin * speed;
}
if (this.keys['KeyD'] || this.keys['ArrowRight']) {
this.camera.x += cos * speed;
this.camera.z -= sin * speed;
}
if (this.keys['Space']) {
this.camera.y += speed;
}
if (this.keys['ShiftLeft'] || this.keys['ControlLeft']) {
this.camera.y -= speed;
}
// Speed adjustment
if (this.keys['KeyQ']) {
this.camera.speed = Math.min(0.3, this.camera.speed + 0.01);
}
if (this.keys['KeyE']) {
this.camera.speed = Math.max(0.05, this.camera.speed - 0.01);
}
},
// Enhanced 3D Projection
project3D(x, y, z) {
// Transform to camera space
const dx = x - this.camera.x;
const dy = y - this.camera.y;
const dz = z - this.camera.z;
// Apply camera rotation
const cos = Math.cos(-this.camera.rotY);
const sin = Math.sin(-this.camera.rotY);
const newX = dx * cos - dz * sin;
const newZ = dx * sin + dz * cos;
const cosX = Math.cos(-this.camera.rotX);
const sinX = Math.sin(-this.camera.rotX);
const finalY = dy * cosX - newZ * sinX;
const finalZ = dy * sinX + newZ * cosX;
if (finalZ <= 0.1) return null;
// Enhanced perspective projection
const fovScale = Math.tan(this.camera.fov * Math.PI / 360);
const scale = (this.height / 2) / (finalZ * fovScale);
return {
x: this.width/2 + newX * scale,
y: this.height/2 + finalY * scale,
scale: scale,
depth: finalZ
};
},
// Enhanced Rendering System
render() {
// Enhanced gradient background
const gradient = this.ctx.createRadialGradient(
this.width/2, this.height/2, 0,
this.width/2, this.height/2, Math.max(this.width, this.height)
);
gradient.addColorStop(0, '#0a0a2e');
gradient.addColorStop(0.5, '#16213e');
gradient.addColorStop(1, '#0f1419');
this.ctx.fillStyle = gradient;
this.ctx.fillRect(0, 0, this.width, this.height);
// Draw enhanced grid
this.drawEnhancedGrid();
// Update and draw particles
this.updateParticles();
this.drawParticles();
// Draw desktops (depth sorted)
const sortedDesktops = [...this.desktops].sort((a, b) => {
const depthA = Math.sqrt((a.x - this.camera.x)**2 + (a.z - this.camera.z)**2);
const depthB = Math.sqrt((b.x - this.camera.x)**2 + (b.z - this.camera.z)**2);
return depthB - depthA;
});
sortedDesktops.forEach(desktop => this.drawEnhancedDesktop(desktop));
// Draw enhanced UI elements
this.drawEnhancedCrosshair();
this.drawCompass();
},
drawEnhancedGrid() {
const gridSize = 100;
const spacing = 3;
this.ctx.strokeStyle = 'rgba(102, 126, 234, 0.15)';
this.ctx.lineWidth = 1;
// Main grid lines
for (let i = -gridSize; i <= gridSize; i += spacing) {
const start1 = this.project3D(i, 0, -gridSize);
const end1 = this.project3D(i, 0, gridSize);
const start2 = this.project3D(-gridSize, 0, i);
const end2 = this.project3D(gridSize, 0, i);
if (start1 && end1) {
this.ctx.beginPath();
this.ctx.moveTo(start1.x, start1.y);
this.ctx.lineTo(end1.x, end1.y);
this.ctx.stroke();
}
if (start2 && end2) {
this.ctx.beginPath();
this.ctx.moveTo(start2.x, start2.y);
this.ctx.lineTo(end2.x, end2.y);
this.ctx.stroke();
}
}
// Center axis lines
this.ctx.strokeStyle = 'rgba(102, 126, 234, 0.4)';
this.ctx.lineWidth = 2;
const centerX1 = this.project3D(0, 0, -gridSize);
const centerX2 = this.project3D(0, 0, gridSize);
const centerZ1 = this.project3D(-gridSize, 0, 0);
const centerZ2 = this.project3D(gridSize, 0, 0);
if (centerX1 && centerX2) {
this.ctx.beginPath();
this.ctx.moveTo(centerX1.x, centerX1.y);
this.ctx.lineTo(centerX2.x, centerX2.y);
this.ctx.stroke();
}
if (centerZ1 && centerZ2) {
this.ctx.beginPath();
this.ctx.moveTo(centerZ1.x, centerZ1.y);
this.ctx.lineTo(centerZ2.x, centerZ2.y);
this.ctx.stroke();
}
},
updateParticles() {
this.particles.forEach(particle => {
// Update position
particle.x += particle.vx;
particle.y += particle.vy;
particle.z += particle.vz;
// Gravity and physics
particle.vy -= 0.001;
// Boundary wrapping
if (particle.x > 25) particle.x = -25;
if (particle.x < -25) particle.x = 25;