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"use client"
import { useEffect, useRef, useState } from "react"
import * as THREE from "three"
import { createMuseumLayout } from "@/lib/museum-generator"
import { createHolographicMaterial, createNeonMaterial, updateShaderUniforms } from "@/lib/shaders"
import { setupDesktopControls, setupMobileControls } from "@/lib/controls"
import { createExhibits } from "@/lib/exhibits"
import { createPuzzles } from "@/lib/puzzles"
import { setupPostProcessing } from "@/lib/post-processing"
import CyberpunkHUD from "@/components/ui/cyberpunk-hud"
import InteractionPrompt from "@/components/ui/interaction-prompt"
import DataTerminal from "@/components/ui/data-terminal"
export default function NonEuclideanMuseum() {
const containerRef = useRef<HTMLDivElement>(null)
const isMobileRef = useRef(false)
const [scanMode, setScanMode] = useState(false)
const [showInteractionPrompt, setShowInteractionPrompt] = useState(false)
const [currentInteraction, setCurrentInteraction] = useState({
action: "Hack Terminal",
key: "E",
description: "Access museum data network",
})
const [showTerminal, setShowTerminal] = useState(false)
const [terminalData, setTerminalData] = useState({
title: "VRTX NEURAL INTERFACE",
content: [
"Initializing non-Euclidean data stream...",
"Connecting to VRTX neural network...",
"Access granted to museum subsystems.",
"WARNING: Spatial anomalies detected in sector 7.",
"Reality distortion factor: 87.3%",
"Use caution when traversing non-Euclidean spaces.",
"Memory corruption detected in local cache.",
"Running diagnostics...",
"Neural sync established. Proceed with caution.",
],
accessLevel: "VISITOR",
})
const [notifications, setNotifications] = useState<
Array<{
id: string
message: string
type: "warning" | "info" | "error" | "success"
}>
>([])
// Add notification function
const addNotification = (message: string, type: "warning" | "info" | "error" | "success" = "info") => {
const id = Date.now().toString()
setNotifications((prev) => [...prev, { id, message, type }])
// Remove notification after 5 seconds
setTimeout(() => {
setNotifications((prev) => prev.filter((notification) => notification.id !== id))
}, 5000)
}
useEffect(() => {
if (!containerRef.current) return
// Show welcome notification after a short delay
setTimeout(() => {
addNotification("Neural link established. Welcome to the Non-Euclidean Museum.", "info")
}, 1500)
// Check if mobile
isMobileRef.current = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
// Initialize ThreeJS
const scene = new THREE.Scene()
scene.background = new THREE.Color(0x05070d)
scene.fog = new THREE.FogExp2(0x080a1f, 0.03)
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
camera.position.set(0, 1.6, 0) // Set camera at eye level
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance",
})
renderer.setSize(window.innerWidth, window.innerHeight)
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))
renderer.shadowMap.enabled = true
renderer.shadowMap.type = THREE.PCFSoftShadowMap
renderer.outputEncoding = THREE.sRGBEncoding
containerRef.current.appendChild(renderer.domElement)
// Setup post-processing
const composer = setupPostProcessing(renderer, scene, camera)
// Add lighting
const ambientLight = new THREE.AmbientLight(0x101820, 0.5)
scene.add(ambientLight)
// Add multiple point lights with different colors for cyberpunk feel
const createPointLight = (x: number, y: number, z: number, color: number, intensity: number, distance: number) => {
const light = new THREE.PointLight(color, intensity, distance)
light.position.set(x, y, z)
light.castShadow = true
light.shadow.bias = -0.001
light.shadow.mapSize.width = 1024
light.shadow.mapSize.height = 1024
scene.add(light)
// Add small glowing sphere at light position
const lightSphere = new THREE.Mesh(new THREE.SphereGeometry(0.1, 16, 16), new THREE.MeshBasicMaterial({ color }))
lightSphere.position.copy(light.position)
scene.add(lightSphere)
return light
}
// Add cyberpunk colored lights
createPointLight(5, 2, 5, 0x00ffff, 1, 10) // Cyan
createPointLight(-5, 3, -5, 0xff00ff, 1, 10) // Magenta
createPointLight(10, 2, -3, 0xffff00, 0.7, 15) // Yellow
createPointLight(-10, 4, 8, 0x00ff99, 0.8, 12) // Green
// Add subtle directional light
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.3)
directionalLight.position.set(1, 10, 1)
directionalLight.castShadow = true
directionalLight.shadow.mapSize.width = 2048
directionalLight.shadow.mapSize.height = 2048
directionalLight.shadow.camera.far = 50
directionalLight.shadow.camera.left = -20
directionalLight.shadow.camera.right = 20
directionalLight.shadow.camera.top = 20
directionalLight.shadow.camera.bottom = -20
scene.add(directionalLight)
// Create museum layout
const museumLayout = createMuseumLayout(7) // More rooms for cyberpunk feel
scene.add(museumLayout)
// Add exhibits
const exhibits = createExhibits()
scene.add(exhibits)
// Add puzzles
const puzzles = createPuzzles()
scene.add(puzzles)
// Add neon lights around the environment
const addNeonTube = (startPoint: THREE.Vector3, endPoint: THREE.Vector3, color: THREE.Color, thickness = 0.05) => {
const direction = new THREE.Vector3().subVectors(endPoint, startPoint)
const length = direction.length()
direction.normalize()
const tubeMaterial = createNeonMaterial(color)
const tube = new THREE.Mesh(new THREE.CylinderGeometry(thickness, thickness, length, 8), tubeMaterial)
// Position and rotate the tube
tube.position.copy(startPoint)
tube.position.add(direction.clone().multiplyScalar(length / 2))
// Align the tube with the direction
const axis = new THREE.Vector3(0, 1, 0)
tube.quaternion.setFromUnitVectors(axis, direction)
scene.add(tube)
return tube
}
// Add neon tubes along the walls and ceiling
const neonPositions = [
{
start: new THREE.Vector3(-10, 2.5, -10),
end: new THREE.Vector3(10, 2.5, -10),
color: new THREE.Color(0xff00ff),
},
{ start: new THREE.Vector3(10, 2.5, -10), end: new THREE.Vector3(10, 2.5, 10), color: new THREE.Color(0x00ffff) },
{ start: new THREE.Vector3(10, 2.5, 10), end: new THREE.Vector3(-10, 2.5, 10), color: new THREE.Color(0xff00ff) },
{
start: new THREE.Vector3(-10, 2.5, 10),
end: new THREE.Vector3(-10, 2.5, -10),
color: new THREE.Color(0x00ffff),
},
{ start: new THREE.Vector3(0, 0.2, -8), end: new THREE.Vector3(0, 0.2, 8), color: new THREE.Color(0xff5500) },
]
neonPositions.forEach((pos) => {
addNeonTube(pos.start, pos.end, pos.color)
})
// Add holographic projections
const addHologram = (position: THREE.Vector3, size = 1, color: THREE.Color = new THREE.Color(0x00ffff)) => {
const hologramMaterial = createHolographicMaterial(color)
const hologram = new THREE.Mesh(
new THREE.CylinderGeometry(size / 2, size / 2, size * 1.5, 16, 1, true),
hologramMaterial,
)
hologram.position.copy(position)
scene.add(hologram)
// Add base for hologram
const baseMaterial = createNeonMaterial(color)
const base = new THREE.Mesh(new THREE.CylinderGeometry(size / 2 + 0.1, size / 2 + 0.2, 0.1, 16), baseMaterial)
base.position.set(position.x, position.y - size * 0.75, position.z)
scene.add(base)
return { hologram, base }
}
// Add holograms to the scene
const hologramPositions = [
{ position: new THREE.Vector3(3, 1, 3), size: 0.8, color: new THREE.Color(0x00ffff) },
{ position: new THREE.Vector3(-3, 1, -3), size: 0.6, color: new THREE.Color(0xff00ff) },
{ position: new THREE.Vector3(5, 1, -5), size: 1, color: new THREE.Color(0x00ff99) },
]
hologramPositions.forEach((pos) => {
addHologram(pos.position, pos.size, pos.color)
})
// Setup controls based on device
let controls
if (isMobileRef.current) {
controls = setupMobileControls(camera, renderer.domElement)
} else {
controls = setupDesktopControls(camera, renderer.domElement)
}
// Handle window resize
const handleResize = () => {
camera.aspect = window.innerWidth / window.innerHeight
camera.updateProjectionMatrix()
renderer.setSize(window.innerWidth, window.innerHeight)
composer.setSize(window.innerWidth, window.innerHeight)
}
window.addEventListener("resize", handleResize)
// Set up interaction/proximity detection
const raycaster = new THREE.Raycaster()
const checkInteractions = () => {
// Check for interactive objects near the camera
raycaster.set(camera.position, new THREE.Vector3(0, 0, -1).applyQuaternion(camera.quaternion))
const intersects = raycaster.intersectObjects(scene.children, true)
// Show interaction prompt if we're close to an interactive object
if (intersects.length > 0 && intersects[0].distance < 3) {
// Check what kind of object we're interacting with
const interactiveObj = intersects[0].object
if (interactiveObj.name === "terminal" || interactiveObj.name.includes("data")) {
setCurrentInteraction({
action: "Access Terminal",
key: "E",
description: "Connect to neural interface",
})
setShowInteractionPrompt(true)
// Handle interaction (E key press)
const handleKeyPress = (e: KeyboardEvent) => {
if (e.key.toLowerCase() === "e") {
setShowTerminal(true)
addNotification("Neural interface connection established", "success")
}
}
window.addEventListener("keydown", handleKeyPress)
return () => window.removeEventListener("keydown", handleKeyPress)
} else if (interactiveObj.name.includes("hologram") || interactiveObj.name.includes("exhibit")) {
setCurrentInteraction({
action: "Examine",
key: "E",
description: "Analyze non-Euclidean data structure",
})
setShowInteractionPrompt(true)
} else if (interactiveObj.name.includes("puzzle")) {
setCurrentInteraction({
action: "Solve Puzzle",
key: "E",
description: "Attempt to realign spatial dimensions",
})
setShowInteractionPrompt(true)
} else {
setShowInteractionPrompt(false)
}
} else {
setShowInteractionPrompt(false)
}
}
// Animation loop
const clock = new THREE.Clock()
const animate = () => {
const delta = clock.getDelta()
const elapsedTime = clock.getElapsedTime()
// Update controls
if (controls.update) {
controls.update(delta)
}
// Update shader uniforms
updateShaderUniforms(scene, elapsedTime)
// Check for interactions
checkInteractions()
// Update post-processing
if (composer.updatePostProcessing) {
composer.updatePostProcessing(elapsedTime)
}
// Render scene with post-processing
composer.render()
requestAnimationFrame(animate)
}
animate()
// Cleanup
return () => {
window.removeEventListener("resize", handleResize)
if (containerRef.current) {
containerRef.current.removeChild(renderer.domElement)
}
renderer.dispose()
}
}, [])
// Toggle scan mode
const toggleScanMode = () => {
setScanMode(!scanMode)
if (!scanMode) {
addNotification("Neural scan mode activated. Analyzing spatial anomalies...", "info")
} else {
addNotification("Neural scan mode deactivated", "info")
}
}
return (
<div className="relative w-full h-full">
<div ref={containerRef} className="w-full h-full" />
{/* Cyberpunk HUD */}
<CyberpunkHUD
health={92}
objective="Navigate the non-Euclidean museum and discover its secrets. Use neural scanning to detect spatial anomalies."
location="Sector 7 - Reality Distortion Zone"
scanMode={scanMode}
toggleScanMode={toggleScanMode}
notifications={notifications}
/>
{/* Interaction Prompt */}
<InteractionPrompt
isVisible={showInteractionPrompt}
action={currentInteraction.action}
keyPrompt={currentInteraction.key}
description={currentInteraction.description}
onInteract={() => setShowTerminal(true)}
/>
{/* Data Terminal */}
<DataTerminal isOpen={showTerminal} onClose={() => setShowTerminal(false)} terminalData={terminalData} />
{/* Screen vignette overlay */}
<div className="pointer-events-none fixed inset-0 bg-gradient-radial from-transparent to-black/40 mix-blend-overlay" />
{/* Subtle scan lines */}
<div className="pointer-events-none fixed inset-0 bg-scanlines opacity-5" />
{/* Custom CSS */}
<style jsx global>{`
.bg-scanlines {
background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1) 75%, transparent 75%, transparent);
background-size: 4px 4px;
}
.bg-gradient-radial {
background: radial-gradient(circle, transparent 0%, rgba(0, 0, 0, 0.4) 100%);
}
`}</style>
</div>
)
}