Skip to content

Commit 7c1310c

Browse files
author
Parsa Azari
committed
FINAL FIX: Move script to head and bundle all JS properly
1 parent 6e4aef0 commit 7c1310c

File tree

3 files changed

+233
-977
lines changed

3 files changed

+233
-977
lines changed

dist/index.html

Lines changed: 33 additions & 270 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>3D Portfolio</title>
77
<link rel="icon" type="image/x-icon" href="/3D-Portfolio/favicon.ico">
8+
<!-- Fixed asset loading - version 2 -->
89

910
<!-- Vite will process and bundle CSS automatically when imported in JS -->
11+
<!-- Vite entry point - must be in head for proper processing -->
12+
1013
<style>
1114
body {
1215
margin: 0;
@@ -453,112 +456,43 @@
453456
transform: rotate(90deg);
454457
}
455458
</style>
456-
457-
<!-- Performance monitoring and error handling -->
458-
<script>
459-
// Performance monitoring
460-
window.performance.mark('page-start');
461-
462-
// Global error handler to prevent unhandled exceptions from crashing the application
463-
window.addEventListener('error', function(event) {
464-
console.error('Global error caught:', {
465-
error: event.error,
466-
message: event.message,
467-
filename: event.filename,
468-
lineno: event.lineno,
469-
colno: event.colno,
470-
stack: event.error?.stack
471-
});
472-
473-
// Show error to user for critical errors
474-
const errorMessage = event.error ? (event.error.stack || event.error.message) : event.message;
475-
if (errorMessage.includes('WebGL') || errorMessage.includes('THREE') || errorMessage.includes('memory')) {
476-
showErrorOverlay(errorMessage);
477-
}
478-
479-
event.preventDefault();
480-
return true;
481-
});
482-
483-
// Also catch unhandled promise rejections
484-
window.addEventListener('unhandledrejection', function(event) {
485-
console.error('Unhandled promise rejection:', {
486-
reason: event.reason,
487-
stack: event.reason?.stack
488-
});
489-
event.preventDefault();
490-
});
491-
492-
// Show error overlay
493-
function showErrorOverlay(message) {
494-
const errorOverlay = document.createElement('div');
495-
errorOverlay.style.cssText = `
496-
position: fixed;
497-
top: 10px;
498-
left: 10px;
499-
right: 10px;
500-
background: rgba(255, 0, 0, 0.8);
501-
color: white;
502-
padding: 15px;
503-
border-radius: 5px;
504-
z-index: 100000;
505-
font-family: sans-serif;
506-
max-height: 200px;
507-
overflow-y: auto;
508-
`;
509-
errorOverlay.innerHTML = `
510-
<h3>An error occurred</h3>
511-
<p>${message}</p>
512-
<button onclick="window.location.reload()" style="background: white; border: none; padding: 5px 10px; margin-top: 10px; cursor: pointer;">
513-
Reload
514-
</button>
515-
<button onclick="this.parentNode.remove()" style="background: #333; color: white; border: none; padding: 5px 10px; margin-top: 10px; margin-left: 10px; cursor: pointer;">
516-
Dismiss
517-
</button>
518-
`;
519-
document.body.appendChild(errorOverlay);
520-
}
521-
522-
// Simplified debug logger
523-
window.debugLumon = {
524-
log: function(message) {
525-
console.log("%c[Lumon Debug] " + message, "color: #5CDED3");
526-
},
527-
error: function(message) {
528-
console.error("%c[Lumon Debug] " + message, "color: #FF5555");
529-
}
530-
};
531-
</script>
532-
<script type="module" crossorigin src="/3D-Portfolio/assets/main-DBnbW_UV.js"></script>
459+
<script type="module" crossorigin src="/3D-Portfolio/assets/main-pVS6vMmy.js"></script>
533460
<link rel="stylesheet" crossorigin href="/3D-Portfolio/assets/main-BnuVihSM.css">
534461
</head>
535-
<body>
536-
<div id="app-container">
537-
<div id="three-container"></div>
538462

539-
<div id="subtitle-container"></div>
540-
<div id="ui-overlay">
541-
<div id="location-indicator"></div>
542-
<div id="interaction-prompt" style="display: none;"></div>
543-
<!-- Dev Terminal Overlay (hidden by default) -->
544-
<div id="dev-terminal-overlay" style="display:none; position:fixed; left:5vw; top:15vh; width:700px; height:400px; background:#000; color:#33ff33; border:2px solid #33ff33; border-radius:4px; z-index:10000; font-family:'Fira Mono', 'Courier New', monospace; box-shadow:0 0 10px rgba(51, 255, 51, 0.5); padding:0; overflow:hidden;">
545-
<div id="dev-terminal-header">
546-
<div id="dev-terminal-title">TERMINAL</div>
547-
<div id="dev-terminal-controls">
548-
<div class="terminal-btn terminal-minimize"></div>
549-
<div class="terminal-btn terminal-maximize"></div>
550-
<div class="terminal-btn terminal-close" id="dev-terminal-close"></div>
551-
</div>
552-
</div>
553-
<div class="terminal-scan-line"></div>
554-
<div id="dev-terminal-body"></div>
555-
<div id="dev-terminal-prompt"></div>
463+
<body>
464+
<!-- Dev Terminal Overlay -->
465+
<div id="dev-terminal-overlay">
466+
<div id="dev-terminal-header">
467+
<span>Terminal - Severance Environment</span>
468+
<div class="terminal-controls">
469+
<button class="terminal-minimize">-</button>
470+
<button class="terminal-maximize">+</button>
471+
<button class="terminal-close" id="dev-terminal-close">×</button>
556472
</div>
557473
</div>
474+
<div id="dev-terminal-body"></div>
475+
<div id="dev-terminal-prompt"></div>
476+
</div>
558477

559-
<!-- Game HUD -->
478+
<div id="app-container">
479+
<div id="three-container"></div>
480+
481+
<!-- HUD -->
560482
<div id="game-hud" class="hud">
561-
<!-- Improved controls info box -->
483+
<div id="location-indicator">Location: Unknown</div>
484+
485+
<!-- Subtitle container -->
486+
<div id="subtitle-container">
487+
<div id="subtitle-text"></div>
488+
</div>
489+
490+
<!-- Interaction prompt -->
491+
<div id="interaction-prompt">
492+
Press E to interact
493+
</div>
494+
495+
<!-- Controls info panel -->
562496
<div id="controls-info">
563497
<div id="controls-header">CONTROLS</div>
564498
<div class="control-items">
@@ -590,176 +524,5 @@ <h3>An error occurred</h3>
590524
</div>
591525
</div>
592526
</div>
593-
594-
<!-- Use the original main.js file directly -->
595-
596-
<script>
597-
// Initialize UI components after DOM is loaded
598-
document.addEventListener('DOMContentLoaded', () => {
599-
// Make sure controls are visible by default
600-
const controlsInfo = document.getElementById('controls-info');
601-
if (controlsInfo && controlsInfo.classList.contains('hidden')) {
602-
controlsInfo.classList.remove('hidden');
603-
}
604-
605-
// Test terminal function (for development)
606-
window.openTerminal = function() {
607-
if (typeof window.showDevTerminalOverlay === 'function') {
608-
window.showDevTerminalOverlay();
609-
}
610-
};
611-
612-
// Keyboard shortcut for testing terminal (Alt + T)
613-
document.addEventListener('keydown', function(e) {
614-
if (e.altKey && e.key === 't') {
615-
window.openTerminal();
616-
}
617-
});
618-
});
619-
620-
// Add global mouse tracking for shaders
621-
window.mouseX = window.innerWidth / 2;
622-
window.mouseY = window.innerHeight / 2;
623-
624-
document.addEventListener('mousemove', (event) => {
625-
window.mouseX = event.clientX;
626-
window.mouseY = event.clientY;
627-
});
628-
</script>
629-
630-
<!-- DEV TERMINAL OVERLAY LOGIC -->
631-
<script>
632-
(function() {
633-
const overlay = document.getElementById('dev-terminal-overlay');
634-
const body = document.getElementById('dev-terminal-body');
635-
const promptDiv = document.getElementById('dev-terminal-prompt');
636-
const closeBtn = document.getElementById('dev-terminal-close');
637-
const minimizeBtn = document.querySelector('.terminal-minimize');
638-
const maximizeBtn = document.querySelector('.terminal-maximize');
639-
640-
const PROMPT = 'parsa@portfolio:~$ ';
641-
const WELCOME_MESSAGE = [
642-
'█ AUTHORIZED ACCESS ONLY █',
643-
'',
644-
'Type "help" for available commands.',
645-
''
646-
].join('\n');
647-
648-
let input = '';
649-
let isOpen = false;
650-
let cursorVisible = true;
651-
let cursorInterval = null;
652-
let commandHistory = [];
653-
let historyIndex = -1;
654-
655-
function renderPrompt() {
656-
promptDiv.innerHTML =
657-
`<span style="color:#33ff33;">${PROMPT}</span>` +
658-
`<span id="dev-terminal-input">${input.replace(/ /g, '&nbsp;')}</span>` +
659-
`<span class="dev-terminal-cursor">&nbsp;</span>`;
660-
}
661-
662-
function appendOutput(text, className = '') {
663-
if (className) {
664-
body.innerHTML += `<div class="${className}">${text}</div>`;
665-
} else {
666-
body.innerHTML += `${text}\n`;
667-
}
668-
body.scrollTop = body.scrollHeight;
669-
}
670-
671-
function processCommand(cmd) {
672-
if (cmd.trim() !== '') {
673-
commandHistory.push(cmd);
674-
historyIndex = commandHistory.length;
675-
}
676-
677-
appendOutput(`${PROMPT}${cmd}`, 'terminal-command');
678-
679-
const trimmedCmd = cmd.trim().toLowerCase();
680-
681-
switch(trimmedCmd) {
682-
case 'help':
683-
appendOutput('Available commands: help, clear, version, exit', 'terminal-output');
684-
break;
685-
case 'clear':
686-
body.innerHTML = '';
687-
break;
688-
case 'version':
689-
appendOutput('Severance Terminal v1.0', 'terminal-output');
690-
break;
691-
case 'exit':
692-
window.hideDevTerminalOverlay();
693-
return;
694-
default:
695-
if (trimmedCmd !== '') {
696-
appendOutput(`bash: ${cmd}: command not found`, 'terminal-error');
697-
}
698-
}
699-
}
700-
701-
function onKeyDown(e) {
702-
if (!isOpen) return;
703-
704-
switch(e.key) {
705-
case 'Escape':
706-
window.hideDevTerminalOverlay();
707-
e.preventDefault();
708-
return;
709-
case 'Backspace':
710-
input = input.slice(0, -1);
711-
renderPrompt();
712-
e.preventDefault();
713-
return;
714-
case 'Enter':
715-
processCommand(input);
716-
input = '';
717-
renderPrompt();
718-
e.preventDefault();
719-
return;
720-
}
721-
722-
if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
723-
input += e.key;
724-
renderPrompt();
725-
e.preventDefault();
726-
}
727-
}
728-
729-
window.showDevTerminalOverlay = function() {
730-
if (isOpen) return;
731-
732-
overlay.style.display = 'block';
733-
isOpen = true;
734-
input = '';
735-
736-
body.innerHTML = '';
737-
appendOutput(WELCOME_MESSAGE);
738-
renderPrompt();
739-
740-
document.addEventListener('keydown', onKeyDown, true);
741-
742-
if (cursorInterval) clearInterval(cursorInterval);
743-
cursorInterval = setInterval(() => {
744-
const cursor = promptDiv.querySelector('.dev-terminal-cursor');
745-
if (cursor) cursor.style.opacity = cursorVisible ? '1' : '0';
746-
cursorVisible = !cursorVisible;
747-
}, 500);
748-
};
749-
750-
window.hideDevTerminalOverlay = function() {
751-
if (!isOpen) return;
752-
753-
overlay.style.display = 'none';
754-
isOpen = false;
755-
756-
document.removeEventListener('keydown', onKeyDown, true);
757-
758-
if (cursorInterval) clearInterval(cursorInterval);
759-
};
760-
761-
if (closeBtn) closeBtn.onclick = window.hideDevTerminalOverlay;
762-
})();
763-
</script>
764527
</body>
765528
</html>

0 commit comments

Comments
 (0)