Implement Phase 31: Autonomous 'Nexus' Expansion & Architecture DELIVERABLES: - agent/nexus_architect.py: AI agent for natural language to Three.js conversion * Prompt engineering for LLM-driven immersive environment generation * Mental state integration for dynamic aesthetic tuning * Mood preset system (contemplative, energetic, mysterious, etc.) * Room and portal design generation - tools/nexus_build_tool.py: Build tool interface with functions: * create_room(name, description, style) - Generate room modules * create_portal(from_room, to_room, style) - Generate portal connections * add_lighting(room, type, color, intensity) - Add Three.js lighting * add_geometry(room, shape, position, material) - Add 3D objects * generate_scene_from_mood(mood_description) - Mood-based generation * deploy_nexus_module(module_code, test=True) - Deploy and test - agent/nexus_deployment.py: Real-time deployment system * Hot-reload Three.js modules without page refresh * Validation (syntax check, Three.js API compliance) * Rollback on error with version history * Module versioning and status tracking - config/nexus-templates/: Template library * base_room.js - Base room template (Three.js r128+) * portal_template.js - Portal template (circular, rectangular, stargate) * lighting_presets.json - Warm, cool, dramatic, serene, crystalline presets * material_presets.json - 15 material presets including Timmy's gold, Allegro blue - tests/test_nexus_architect.py: Comprehensive test coverage * Unit tests for all components * Integration tests for full workflow * Template file validation DESIGN PRINCIPLES: - Modular architecture (each room = separate JS module) - Valid Three.js code (r128+ compatible) - Hot-reloadable (no page refresh needed) - Mental state integration (SOUL.md values influence aesthetic) NEXUS AESTHETIC GUIDELINES: - Timmy's color: warm gold (#D4AF37) - Allegro's color: motion blue (#4A90E2) - Sovereignty theme: crystalline structures, clean lines - Service theme: open spaces, welcoming lighting - Default mood: contemplative, expansive, hopeful
201 lines
5.3 KiB
JavaScript
201 lines
5.3 KiB
JavaScript
/**
|
|
* Nexus Base Room Template
|
|
*
|
|
* This is the base template for all Nexus rooms.
|
|
* Copy and customize this template for new room types.
|
|
*
|
|
* Compatible with Three.js r128+
|
|
*/
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
/**
|
|
* Configuration object for the room
|
|
*/
|
|
const CONFIG = {
|
|
name: 'base_room',
|
|
dimensions: {
|
|
width: 20,
|
|
height: 10,
|
|
depth: 20
|
|
},
|
|
colors: {
|
|
primary: '#1A1A2E',
|
|
secondary: '#16213E',
|
|
accent: '#D4AF37', // Timmy's gold
|
|
light: '#E0F7FA', // Sovereignty crystal
|
|
},
|
|
lighting: {
|
|
ambientIntensity: 0.3,
|
|
accentIntensity: 0.8,
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Create the base room
|
|
* @returns {THREE.Group} The room group
|
|
*/
|
|
function createBaseRoom() {
|
|
const room = new THREE.Group();
|
|
room.name = CONFIG.name;
|
|
|
|
// Create floor
|
|
createFloor(room);
|
|
|
|
// Create walls
|
|
createWalls(room);
|
|
|
|
// Setup lighting
|
|
setupLighting(room);
|
|
|
|
// Add room features
|
|
addFeatures(room);
|
|
|
|
return room;
|
|
}
|
|
|
|
/**
|
|
* Create the floor
|
|
*/
|
|
function createFloor(room) {
|
|
const floorGeo = new THREE.PlaneGeometry(
|
|
CONFIG.dimensions.width,
|
|
CONFIG.dimensions.depth
|
|
);
|
|
const floorMat = new THREE.MeshStandardMaterial({
|
|
color: CONFIG.colors.primary,
|
|
roughness: 0.8,
|
|
metalness: 0.2,
|
|
});
|
|
const floor = new THREE.Mesh(floorGeo, floorMat);
|
|
floor.rotation.x = -Math.PI / 2;
|
|
floor.receiveShadow = true;
|
|
floor.name = 'floor';
|
|
room.add(floor);
|
|
}
|
|
|
|
/**
|
|
* Create the walls
|
|
*/
|
|
function createWalls(room) {
|
|
const wallMat = new THREE.MeshStandardMaterial({
|
|
color: CONFIG.colors.secondary,
|
|
roughness: 0.9,
|
|
metalness: 0.1,
|
|
side: THREE.DoubleSide
|
|
});
|
|
|
|
const { width, height, depth } = CONFIG.dimensions;
|
|
|
|
// Back wall
|
|
const backWall = new THREE.Mesh(
|
|
new THREE.PlaneGeometry(width, height),
|
|
wallMat
|
|
);
|
|
backWall.position.set(0, height / 2, -depth / 2);
|
|
backWall.receiveShadow = true;
|
|
room.add(backWall);
|
|
|
|
// Left wall
|
|
const leftWall = new THREE.Mesh(
|
|
new THREE.PlaneGeometry(depth, height),
|
|
wallMat
|
|
);
|
|
leftWall.position.set(-width / 2, height / 2, 0);
|
|
leftWall.rotation.y = Math.PI / 2;
|
|
leftWall.receiveShadow = true;
|
|
room.add(leftWall);
|
|
|
|
// Right wall
|
|
const rightWall = new THREE.Mesh(
|
|
new THREE.PlaneGeometry(depth, height),
|
|
wallMat
|
|
);
|
|
rightWall.position.set(width / 2, height / 2, 0);
|
|
rightWall.rotation.y = -Math.PI / 2;
|
|
rightWall.receiveShadow = true;
|
|
room.add(rightWall);
|
|
}
|
|
|
|
/**
|
|
* Setup lighting
|
|
*/
|
|
function setupLighting(room) {
|
|
// Ambient light
|
|
const ambientLight = new THREE.AmbientLight(
|
|
CONFIG.colors.primary,
|
|
CONFIG.lighting.ambientIntensity
|
|
);
|
|
ambientLight.name = 'ambient';
|
|
room.add(ambientLight);
|
|
|
|
// Accent light (Timmy's gold)
|
|
const accentLight = new THREE.PointLight(
|
|
CONFIG.colors.accent,
|
|
CONFIG.lighting.accentIntensity,
|
|
50
|
|
);
|
|
accentLight.position.set(0, 8, 0);
|
|
accentLight.castShadow = true;
|
|
accentLight.name = 'accent';
|
|
room.add(accentLight);
|
|
}
|
|
|
|
/**
|
|
* Add room features
|
|
* Override this function in custom rooms
|
|
*/
|
|
function addFeatures(room) {
|
|
// Base room has minimal features
|
|
// Custom rooms should override this
|
|
|
|
// Example: Add a center piece
|
|
const centerGeo = new THREE.SphereGeometry(1, 32, 32);
|
|
const centerMat = new THREE.MeshStandardMaterial({
|
|
color: CONFIG.colors.accent,
|
|
emissive: CONFIG.colors.accent,
|
|
emissiveIntensity: 0.3,
|
|
roughness: 0.3,
|
|
metalness: 0.8,
|
|
});
|
|
const centerPiece = new THREE.Mesh(centerGeo, centerMat);
|
|
centerPiece.position.set(0, 2, 0);
|
|
centerPiece.castShadow = true;
|
|
centerPiece.name = 'centerpiece';
|
|
room.add(centerPiece);
|
|
|
|
// Animation hook
|
|
centerPiece.userData.animate = function(time) {
|
|
this.position.y = 2 + Math.sin(time) * 0.2;
|
|
this.rotation.y = time * 0.5;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Dispose of room resources
|
|
*/
|
|
function disposeRoom(room) {
|
|
room.traverse((child) => {
|
|
if (child.isMesh) {
|
|
child.geometry.dispose();
|
|
if (Array.isArray(child.material)) {
|
|
child.material.forEach(m => m.dispose());
|
|
} else {
|
|
child.material.dispose();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Export
|
|
if (typeof module !== 'undefined' && module.exports) {
|
|
module.exports = { createBaseRoom, disposeRoom, CONFIG };
|
|
} else if (typeof window !== 'undefined') {
|
|
window.NexusRooms = window.NexusRooms || {};
|
|
window.NexusRooms.base_room = createBaseRoom;
|
|
}
|
|
|
|
return { createBaseRoom, disposeRoom, CONFIG };
|
|
})();
|