DreamSpaces
Relevant source files
The following files were used as context for generating this wiki page:
DreamSpaces is a core creative and immersive module within the TAMV MD-X4 ecosystem, providing 3D/VR environments for co-creation, meditation, and social interaction. It utilizes a combination of React Three Fiber, Three.js, and spatial audio to create multisensorial experiences integrated with the project's broader FederationSystem and quantum coherence metrics.
As a "Creative Federation," DreamSpaces facilitates multi-user collaboration in environments ranging from "Quantum" plazas to "Cosmic" observatories. Access to these spaces is governed by user roles (Public, Creator, Pro) and specific Quantum Coherence requirements, ensuring that the immersive experience aligns with the user's standing within the civilizatory ecosystem.
Sources: src/systems/FederationSystem.ts:182-197, src/pages/DreamSpaces.tsx:50-100, README_TAMV_COMPLETO.md:38-44
System Architecture
The DreamSpaces architecture is built on a modular stack that separates the UI management, the 3D rendering engine, and the underlying data persistence layer.
Core Components and Logic
The system uses DreamSpaceViewer as the primary rendering engine, which leverages @react-three/fiber and @react-three/drei. Key architectural elements include:
- FirstPersonController: Manages movement using WASD/Arrow keys and synchronizes the binaural audio listener position with the camera.
- SpaceEnvironmentAdvanced: A dynamic environment system that adjusts fog, lighting, and presets based on the space type (Quantum, Forest, Cosmic, Crystal).
- Avatar System: Renders both local and remote participants as interactive 3D capsules with floating animations and dynamic name tags.
Sources: src/components/dreamspaces/DreamSpaceViewer.tsx:103-157, src/components/dreamspaces/DreamSpaceViewer.tsx:210-230, src/components/dreamspaces/DreamSpaceViewer.tsx:14-63
Logical Flow: Entering a Space
The following diagram illustrates the validation and entry sequence when a user attempts to join a DreamSpace.
Sources: src/pages/DreamSpaces.tsx:64-90
Data Model and Persistence
DreamSpaces data is persisted in Supabase via the dream_spaces table. This table tracks ownership, configuration, and current participant counts.
Database Schema
| Field | Type | Constraints | Description |
|---|---|---|---|
id | UUID | PRIMARY KEY | Unique identifier for the space. |
owner_id | UUID | NOT NULL | Reference to the profile of the creator. |
space_type | TEXT | CHECK (personal, collaborative, event, gallery, concert) | The functional category of the space. |
theme | TEXT | DEFAULT 'quantum' | Visual preset used by the environment. |
config | JSONB | DEFAULT '{}' | Custom settings for the 3D scene. |
access_level | TEXT | CHECK (public, friends, private, premium) | Governance rules for entry. |
| Sources: supabase/migrations/20251024005602_26440f5d-289f-4821-9cc0-7520dacde20f.sql:133-150 |
Performance and Optimization
To maintain stability across devices, the system adheres to strict performance guidelines, targeting 60 FPS in optimal conditions.
Optimization Strategies
- Code-Splitting: Routes are loaded lazily to reduce initial bundle size.
- LOD (Level of Detail): The system implements automatic quality adjustments based on active FPS thresholds.
- Resource Management: Explicit disposal of Three.js geometries and materials in
useEffectcleanup phases to prevent memory leaks. - Audio Throttling: FFT analysis for audio-reactive elements is limited to ~30fps to save CPU cycles.
Sources: 02_MODULOS/M03_XR/INTERNO/XR-PERFORMANCE-GUIDELINES.md:1-60
Multisensorial Integration
DreamSpaces is heavily integrated with the KAOS Audio System to provide 4D spatial audio.
Audio Features
- Binaural HRTF: Implements Head-Related Transfer Function for immersive soundscapes that respond to the user's 3D position.
- Interactive Audio Sources: Icosahedron meshes within the scene act as spatial audio triggers, such as playing binaural theta waves for relaxation.
- Haptic Sync: Planned integration to synchronize audio pulses with visual effects and haptic feedback.
Sources: src/components/dreamspaces/DreamSpaceViewer.tsx:185-208, src/systems/FederationSystem.ts:200-213, src/pages/DreamSpaces.tsx:102-110
Governance
Governance of DreamSpaces is handled by the DAO-Experiencia, which has the authority to define visual and auditory intensity limits and accessibility standards. However, economic parameters such as access prices are restricted from DAO control and managed by the Economy System.
Sources: PLAN-TAMV-MODULAR.md:120-128, 02_MODULOS/M03_XR/INTERNO/XR-PERFORMANCE-GUIDELINES.md:85-93
Feature Summary
| Component | Description | Source File |
|---|---|---|
DreamSpaceViewer | Main Canvas and 3D orchestration | DreamSpaceViewer.tsx |
QuantumPortal | Visual transition markers in 3D space | DreamSpaceViewer.tsx |
Avatar | 3D representation of users with MeshDistortMaterial | DreamSpaceViewer.tsx |
useQuantumState | Hook managing coherence and entry logic | useQuantumState.ts |
| Sources: src/components/dreamspaces/DreamSpaceViewer.tsx:14-101, src/pages/DreamSpaces.tsx:64-90 |
DreamSpaces represents the "HyperReal" front of the TAMV ecosystem, merging high-performance 3D rendering with civilizatory governance and multisensorial feedback to create a unique digital environment.