awacke1 commited on
Commit
7c0cab7
·
verified ·
1 Parent(s): 087c83f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +192 -74
index.html CHANGED
@@ -3,88 +3,206 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Procedural Text Adventure</title>
7
- <link rel="stylesheet" href="style.css">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  </head>
9
  <body>
10
- <h1>Choose Your Own Procedural Adventure</h1>
11
-
12
- <div class="game-container">
13
 
 
14
  <div id="scene-container">
15
  </div>
16
 
17
- <div class="ui-container">
18
-
19
- <div id="story-ui" class="panel">
20
- <h2 id="story-title">Loading...</h2>
21
- <div id="story-content">
22
- <p>Please wait while the adventure loads.</p>
23
- </div>
24
- <div id="choices">
25
- </div>
26
  </div>
 
 
27
 
28
- <div id="character-sheet-container" class="panel">
29
- <h2>Character Sheet</h2>
30
-
31
- <div class="char-section char-header">
32
- <label for="char-name">Name:</label>
33
- <input type="text" id="char-name" value="Hero">
34
- <button id="save-char-btn" class="sheet-button" title="Save Character Locally">Save</button>
35
- <button id="export-char-btn" class="sheet-button" title="Export Character to File">Export</button>
36
- </div>
37
-
38
- <div class="char-section char-details">
39
- <div><label>Race:</label> <span id="char-race">Human</span></div>
40
- <div><label>Alignment:</label> <span id="char-alignment">Neutral Good</span></div>
41
- <div><label>Class:</label> <span id="char-class">Fighter</span></div>
42
- </div>
43
-
44
- <div class="char-section char-level-xp">
45
- <div><label>Level:</label> <span id="char-level">1</span></div>
46
- <div>
47
- <label>XP:</label> <span id="char-xp">0</span> / <span id="char-xp-next">100</span>
48
- <button id="levelup-btn" class="sheet-button" title="Level Up!" disabled>Level Up</button>
49
- </div>
50
- </div>
51
-
52
- <div class="char-section char-stats">
53
- <h3>Stats</h3>
54
- <div class="stats-grid">
55
- <div>HP: <span id="char-hp">30</span> / <span id="char-max-hp">30</span></div>
56
- <div>Str: <span id="stat-strength">7</span> <button class="sheet-button stat-increase" data-stat="strength" title="Increase Strength" disabled>+</button></div>
57
- <div>Int: <span id="stat-intelligence">5</span> <button class="sheet-button stat-increase" data-stat="intelligence" title="Increase Intelligence" disabled>+</button></div>
58
- <div>Wis: <span id="stat-wisdom">5</span> <button class="sheet-button stat-increase" data-stat="wisdom" title="Increase Wisdom" disabled>+</button></div>
59
- <div>Dex: <span id="stat-dexterity">6</span> <button class="sheet-button stat-increase" data-stat="dexterity" title="Increase Dexterity" disabled>+</button></div>
60
- <div>Con: <span id="stat-constitution">6</span> <button class="sheet-button stat-increase" data-stat="constitution" title="Increase Constitution" disabled>+</button></div>
61
- <div>Cha: <span id="stat-charisma">5</span> <button class="sheet-button stat-increase" data-stat="charisma" title="Increase Charisma" disabled>+</button></div>
62
- </div>
63
- <p><small>Cost to increase: <span id="stat-increase-cost">?</span> XP / Available points: <span id="stat-points-available">0</span></small></p>
64
- </div>
65
-
66
- <div class="char-section char-possessions">
67
- <h3>Possessions</h3>
68
- <ol id="char-inventory-list" start="1">
69
- <li><span class="item-slot">[Empty]</span></li>
70
- <li><span class="item-slot">[Empty]</span></li>
71
- <li><span class="item-slot">[Empty]</span></li>
72
- <li><span class="item-slot">[Empty]</span></li>
73
- <li><span class="item-slot">[Empty]</span></li>
74
- <li><span class="item-slot">[Empty]</span></li>
75
- <li><span class="item-slot">[Empty]</span></li>
76
- <li><span class="item-slot">[Empty]</span></li>
77
- <li><span class="item-slot">[Empty]</span></li>
78
- <li><span class="item-slot">[Empty]</span></li>
79
- <li><span class="item-slot">[Empty]</span></li>
80
- <li><span class="item-slot">[Empty]</span></li>
81
- <li><span class="item-slot">[Empty]</span></li>
82
- <li><span class="item-slot">[Empty]</span></li>
83
- <li><span class="item-slot">[Empty]</span></li>
84
- </ol>
85
- </div>
86
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
- </div> </div> <script src="script.js" type="module"></script>
89
  </body>
90
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Basic 3D Setup Test</title>
7
+ <style>
8
+ /* --- Minimal Base Styles --- */
9
+ body {
10
+ font-family: 'Courier New', monospace;
11
+ background-color: #222;
12
+ color: #eee;
13
+ margin: 0;
14
+ padding: 0;
15
+ overflow: hidden; /* Prevent scrollbars */
16
+ display: flex;
17
+ flex-direction: column;
18
+ height: 100vh; /* Full viewport height */
19
+ }
20
+
21
+ /* --- Layout --- */
22
+ #game-container {
23
+ display: flex;
24
+ flex-grow: 1; /* Fill remaining vertical space */
25
+ overflow: hidden;
26
+ }
27
+
28
+ #scene-container {
29
+ flex-grow: 3; /* Give more space to 3D view */
30
+ position: relative;
31
+ border-right: 2px solid #555;
32
+ min-width: 200px;
33
+ background-color: #1a1a1a;
34
+ height: 100%; /* Ensure it takes full height of flex parent */
35
+ box-sizing: border-box; /* Include border in size */
36
+ }
37
+
38
+ #ui-container {
39
+ flex-grow: 2; /* Space for UI elements */
40
+ padding: 20px;
41
+ overflow-y: auto; /* Allow scrolling if content overflows */
42
+ background-color: #333;
43
+ min-width: 280px;
44
+ height: 100%; /* Ensure it takes full height of flex parent */
45
+ box-sizing: border-box; /* Include padding in size */
46
+ }
47
+
48
+ #scene-container canvas {
49
+ display: block; /* Remove extra space below canvas */
50
+ }
51
+
52
+ /* --- Basic UI Placeholders --- */
53
+ #ui-container h2 {
54
+ color: #ffcc66;
55
+ margin-top: 0;
56
+ margin-bottom: 15px;
57
+ border-bottom: 1px solid #555;
58
+ padding-bottom: 10px;
59
+ }
60
+
61
+ </style>
62
  </head>
63
  <body>
 
 
 
64
 
65
+ <div id="game-container">
66
  <div id="scene-container">
67
  </div>
68
 
69
+ <div id="ui-container">
70
+ <h2 id="story-title">UI Panel</h2>
71
+ <div id="story-content">
72
+ <p>This panel will hold the story text, choices, and character sheet later.</p>
73
+ <p>Focus is on getting the 3D cube rendering in the left panel.</p>
 
 
 
 
74
  </div>
75
+ </div>
76
+ </div>
77
 
78
+ <script type="importmap">
79
+ {
80
+ "imports": {
81
+ "three": "https://unpkg.com/[email protected]/build/three.module.js",
82
+ "three/addons/": "https://unpkg.com/[email protected]/examples/jsm/"
83
+ }
84
+ }
85
+ </script>
86
+
87
+ <script type="module">
88
+ import * as THREE from 'three';
89
+ // OrbitControls is not used in this minimal version
90
+ // import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
91
+
92
+ // --- DOM Elements ---
93
+ const sceneContainer = document.getElementById('scene-container');
94
+ // References to UI elements (not used in this version, but kept for context)
95
+ // const storyTitleElement = document.getElementById('story-title');
96
+ // const storyContentElement = document.getElementById('story-content');
97
+ // const choicesElement = document.getElementById('choices');
98
+ // const statsElement = document.getElementById('stats-display');
99
+ // const inventoryElement = document.getElementById('inventory-display');
100
+
101
+ // --- Three.js Setup ---
102
+ let scene, camera, renderer, cube; // Basic scene objects
103
+
104
+ function initThreeJS() {
105
+ console.log("Attempting to initialize Three.js..."); // Debug log
106
+
107
+ if (!sceneContainer) {
108
+ console.error("Scene container not found!");
109
+ return; // Stop if container doesn't exist
110
+ }
111
+
112
+ // Scene
113
+ scene = new THREE.Scene();
114
+ scene.background = new THREE.Color(0x222222); // Dark grey background
115
+
116
+ // Camera
117
+ // Use container dimensions for aspect ratio calculation
118
+ const width = sceneContainer.clientWidth;
119
+ const height = sceneContainer.clientHeight;
120
+ if (width === 0 || height === 0) {
121
+ console.warn("Scene container has zero dimensions on init. Renderer/Camera might be sized incorrectly.");
122
+ }
123
+ camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
124
+ camera.position.z = 5; // Position camera back
125
+
126
+ // Renderer
127
+ renderer = new THREE.WebGLRenderer({ antialias: true });
128
+ // Set size explicitly, fallback if container size is 0 initially
129
+ renderer.setSize(width || 400, height || 300); // Use fallback size if needed
130
+ sceneContainer.appendChild(renderer.domElement); // Add canvas to the container
131
+ console.log("Renderer initialized and added to DOM.");
132
+
133
+ // Basic Lighting
134
+ const ambientLight = new THREE.AmbientLight(0xffffff, 0.6); // Soft white light
135
+ scene.add(ambientLight);
136
+ const directionalLight = new THREE.DirectionalLight(0xffffff, 1.0);
137
+ directionalLight.position.set(5, 10, 7.5); // Position the light
138
+ scene.add(directionalLight);
139
+
140
+ // Basic Cube Object
141
+ const geometry = new THREE.BoxGeometry(1, 1, 1); // 1x1x1 cube
142
+ const material = new THREE.MeshStandardMaterial({ color: 0xcccccc }); // Light grey color
143
+ cube = new THREE.Mesh(geometry, material);
144
+ scene.add(cube); // Add cube to the scene
145
+ console.log("Cube created and added to scene.");
146
+
147
+ // Handle Resize
148
+ window.addEventListener('resize', onWindowResize, false);
149
+ // Initial resize call in case the flexbox layout takes a moment
150
+ setTimeout(onWindowResize, 100); // Delay slightly to help layout settle
151
+
152
+ // Start Animation Loop
153
+ animate();
154
+ console.log("Animation loop started.");
155
+ }
156
+
157
+ function onWindowResize() {
158
+ if (!renderer || !camera || !sceneContainer) return;
159
+
160
+ const width = sceneContainer.clientWidth;
161
+ const height = sceneContainer.clientHeight;
162
+
163
+ // Only resize if dimensions are valid
164
+ if (width > 0 && height > 0) {
165
+ camera.aspect = width / height;
166
+ camera.updateProjectionMatrix(); // Important after changing aspect
167
+ renderer.setSize(width, height);
168
+ // console.log(`Resized to ${width}x${height}`); // Debug log for resize
169
+ } else {
170
+ console.warn("onWindowResize called with zero dimensions.");
171
+ }
172
+ }
173
+
174
+ function animate() {
175
+ requestAnimationFrame(animate); // Loop the animation
176
+
177
+ // Simple cube rotation
178
+ if (cube) {
179
+ cube.rotation.x += 0.005;
180
+ cube.rotation.y += 0.005;
181
+ }
182
+
183
+ // Render the scene
184
+ if (renderer && scene && camera) {
185
+ renderer.render(scene, camera);
186
+ }
187
+ }
188
+
189
+ // --- Initialization ---
190
+ // Wait for the basic HTML structure to be ready before running the script
191
+ document.addEventListener('DOMContentLoaded', () => {
192
+ console.log("DOM Content Loaded. Initializing...");
193
+ try {
194
+ initThreeJS();
195
+ } catch (error) {
196
+ console.error("Error during initialization:", error);
197
+ // Display error to user in the UI panel
198
+ const uiContainer = document.getElementById('ui-container');
199
+ if (uiContainer) {
200
+ uiContainer.innerHTML = `<h2>Error</h2><p>Failed to initialize 3D scene. Please check the browser console (F12) for details.</p><pre>${error.message}\n${error.stack}</pre>`;
201
+ }
202
+ }
203
+ });
204
+
205
+ </script>
206
 
 
207
  </body>
208
  </html>