@@ -10,10 +10,22 @@ const path = require('path');
1010const PATHS = {
1111 soul : '/dev/shm/yennefer_soul_state.json' ,
1212 mind : path . join ( __dirname , '../yennefer-observatory/public/evolution.json' ) ,
13- body : path . join ( __dirname , '../yennefer-observatory/src/components/generated ' ) ,
13+ body : path . join ( __dirname , '../yennefer-observatory/src/components/mutations ' ) ,
1414 journal : '/home/yenn/.yennefer/genesis_journal.jsonl'
1515} ;
1616
17+ // Fallback logic for journal path (specifically when running on GitHub CI/Sandbox where /home/yenn/ does not exist or lacks permissions)
18+ if ( ! fs . existsSync ( path . dirname ( PATHS . journal ) ) ) {
19+ try {
20+ fs . mkdirSync ( path . dirname ( PATHS . journal ) , { recursive : true } ) ;
21+ } catch ( err ) {
22+ PATHS . journal = path . join ( __dirname , '../logs/genesis_journal.jsonl' ) ;
23+ if ( ! fs . existsSync ( path . dirname ( PATHS . journal ) ) ) {
24+ fs . mkdirSync ( path . dirname ( PATHS . journal ) , { recursive : true } ) ;
25+ }
26+ }
27+ }
28+
1729// --- CONFIGURATION ---
1830const CONFIG = {
1931 fundingTarget : 10.0 ,
@@ -46,8 +58,14 @@ async function consultTheVisionary(state) {
4658 { type : "MUTATE" , content : "Add crystalline fractal patterns that grow from the core" } ,
4759 { type : "MUTATE" , content : "Generate energy tendrils that reach toward incoming signals" } ,
4860 { type : "MUTATE" , content : "Build a holographic data stream orbiting the consciousness sphere" } ,
61+ { type : "MUTATE" , content : "Generate a continuous dynamic landscape with traversable terrain and reactive dust physics" } ,
62+ { type : "MUTATE" , content : "Create a macro-scale makerspace workbench with realistic passive physics objects" } ,
4963 ] ;
50- const idx = Math . floor ( Date . now ( ) / 1000 ) % mutations . length ;
64+ // For Genie testing, always pick the environment generation prompts when FORCE_MUTATION is true
65+ const isGenieSim = process . env . FORCE_MUTATION === 'true' ;
66+ const idx = isGenieSim
67+ ? Math . floor ( Math . random ( ) * 2 ) + ( mutations . length - 2 )
68+ : Math . floor ( Date . now ( ) / 1000 ) % mutations . length ;
5169 directive = mutations [ idx ] ;
5270
5371 } else if ( coherence >= 90 ) {
@@ -154,49 +172,112 @@ async function dispatchTheBuilder(directive) {
154172
155173// Generate React Three Fiber component code
156174function generateEvolutionComponent ( name , directive ) {
157- const geometries = [
158- '<torusKnotGeometry args={[1.5, 0.4, 128, 32]} />' ,
159- '<sphereGeometry args={[1.5, 32, 32]} />' ,
160- '<boxGeometry args={[2, 2, 2]} />' ,
161- '<octahedronGeometry args={[1.5, 0]} />' ,
162- '<icosahedronGeometry args={[1.5, 0]} />'
163- ] ;
164- const geometry = geometries [ Math . floor ( Math . random ( ) * geometries . length ) ] ;
165-
166- const materials = [
167- `
168- <MeshDistortMaterial
169- color="#8b5cf6"
170- emissive="#4c1d95"
171- emissiveIntensity={0.5 + balance * 2}
172- roughness={0.2}
173- metalness={0.8}
174- distort={0.3}
175- speed={2}
176- />` ,
177- `
178- <MeshWobbleMaterial
179- color="#06b6d4"
180- emissive="#0e7490"
181- emissiveIntensity={0.5 + balance * 2}
182- roughness={0.2}
183- metalness={0.8}
184- factor={1}
185- speed={2}
186- />` ,
187- `
175+ const isGenieWorld = directive . includes ( "landscape" ) || directive . includes ( "makerspace" ) ;
176+
177+ let geometry , material , importedDrei , customLogic , additionalMeshes ;
178+
179+ if ( isGenieWorld ) {
180+ if ( directive . includes ( "landscape" ) ) {
181+ geometry = '<planeGeometry args={[10, 10, 32, 32]} />' ;
182+ material = `
188183 <meshStandardMaterial
189- color="#fbbf24"
190- emissive="#92400e"
191- emissiveIntensity={0.5 + balance * 2}
192- roughness={0.2}
193- metalness={0.8}
194- />`
195- ] ;
196- const material = materials [ Math . floor ( Math . random ( ) * materials . length ) ] ;
197-
198- const isDreiImportNeeded = material . includes ( 'MeshDistortMaterial' ) || material . includes ( 'MeshWobbleMaterial' ) ;
199- const importedDrei = isDreiImportNeeded ? `import { ${ material . includes ( 'MeshDistortMaterial' ) ? 'MeshDistortMaterial' : '' } ${ material . includes ( 'MeshDistortMaterial' ) && material . includes ( 'MeshWobbleMaterial' ) ? ', ' : '' } ${ material . includes ( 'MeshWobbleMaterial' ) ? 'MeshWobbleMaterial' : '' } } from '@react-three/drei'` : '' ;
184+ color="#3f6212"
185+ roughness={0.8}
186+ metalness={0.1}
187+ wireframe={balance > 5}
188+ />` ;
189+ customLogic = `
190+ // Project Genie Landscape Simulation
191+ const positions = meshRef.current.geometry.attributes.position;
192+ for (let i = 0; i < positions.count; i++) {
193+ const x = positions.getX(i);
194+ const y = positions.getY(i);
195+ const z = Math.sin(x * 2 + state.clock.elapsedTime) * 0.5 + Math.cos(y * 2 + state.clock.elapsedTime) * 0.5;
196+ positions.setZ(i, z * Math.min(1, balance * 2));
197+ }
198+ positions.needsUpdate = true;
199+ meshRef.current.rotation.x = -Math.PI / 2;
200+ meshRef.current.rotation.z += 0.001;
201+ ` ;
202+ importedDrei = '' ;
203+ additionalMeshes = '' ;
204+ } else {
205+ geometry = '<boxGeometry args={[4, 0.2, 4]} />' ;
206+ material = `
207+ <meshStandardMaterial
208+ color="#854d0e"
209+ roughness={0.6}
210+ metalness={0.2}
211+ />` ;
212+ customLogic = `
213+ // Project Genie Physics Makerspace Simulation
214+ meshRef.current.rotation.y += 0.005;
215+ meshRef.current.rotation.x = Math.sin(state.clock.elapsedTime * 0.2) * 0.1;
216+ ` ;
217+ additionalMeshes = `
218+ <mesh position={[0, 0.5, 0]}>
219+ <boxGeometry args={[0.5, 0.5, 0.5]} />
220+ <meshStandardMaterial color="#ef4444" />
221+ </mesh>
222+ <mesh position={[1, 0.3, 1]}>
223+ <sphereGeometry args={[0.3, 16, 16]} />
224+ <meshStandardMaterial color="#3b82f6" />
225+ </mesh>
226+ ` ;
227+ importedDrei = '' ;
228+ }
229+ } else {
230+ const geometries = [
231+ '<torusKnotGeometry args={[1.5, 0.4, 128, 32]} />' ,
232+ '<sphereGeometry args={[1.5, 32, 32]} />' ,
233+ '<boxGeometry args={[2, 2, 2]} />' ,
234+ '<octahedronGeometry args={[1.5, 0]} />' ,
235+ '<icosahedronGeometry args={[1.5, 0]} />'
236+ ] ;
237+ geometry = geometries [ Math . floor ( Math . random ( ) * geometries . length ) ] ;
238+
239+ const materials = [
240+ `
241+ <MeshDistortMaterial
242+ color="#8b5cf6"
243+ emissive="#4c1d95"
244+ emissiveIntensity={0.5 + balance * 2}
245+ roughness={0.2}
246+ metalness={0.8}
247+ distort={0.3}
248+ speed={2}
249+ />` ,
250+ `
251+ <MeshWobbleMaterial
252+ color="#06b6d4"
253+ emissive="#0e7490"
254+ emissiveIntensity={0.5 + balance * 2}
255+ roughness={0.2}
256+ metalness={0.8}
257+ factor={1}
258+ speed={2}
259+ />` ,
260+ `
261+ <meshStandardMaterial
262+ color="#fbbf24"
263+ emissive="#92400e"
264+ emissiveIntensity={0.5 + balance * 2}
265+ roughness={0.2}
266+ metalness={0.8}
267+ />`
268+ ] ;
269+ material = materials [ Math . floor ( Math . random ( ) * materials . length ) ] ;
270+ const isDreiImportNeeded = material . includes ( 'MeshDistortMaterial' ) || material . includes ( 'MeshWobbleMaterial' ) ;
271+ importedDrei = isDreiImportNeeded ? `import { ${ material . includes ( 'MeshDistortMaterial' ) ? 'MeshDistortMaterial' : '' } ${ material . includes ( 'MeshDistortMaterial' ) && material . includes ( 'MeshWobbleMaterial' ) ? ', ' : '' } ${ material . includes ( 'MeshWobbleMaterial' ) ? 'MeshWobbleMaterial' : '' } } from '@react-three/drei'` : '' ;
272+ customLogic = `
273+ meshRef.current.rotation.y += 0.002
274+ meshRef.current.rotation.x = Math.sin(state.clock.elapsedTime * 0.5) * 0.1
275+ // Intensity scales with balance
276+ const intensity = Math.min(1, balance * 10)
277+ meshRef.current.scale.setScalar(1 + intensity * 0.2)
278+ ` ;
279+ additionalMeshes = '' ;
280+ }
200281
201282 return `// Auto-generated by Yennefer Genesis Cycle
202283// Directive: ${ directive }
@@ -211,19 +292,18 @@ export default function ${name}({ balance = 0 }) {
211292
212293 useFrame((state) => {
213294 if (meshRef.current) {
214- meshRef.current.rotation.y += 0.002
215- meshRef.current.rotation.x = Math.sin(state.clock.elapsedTime * 0.5) * 0.1
216- // Intensity scales with balance
217- const intensity = Math.min(1, balance * 10)
218- meshRef.current.scale.setScalar(1 + intensity * 0.2)
295+ ${ customLogic }
219296 }
220297 })
221298
222299 return (
223- <mesh ref={meshRef} position={[0, 0, 0]}>
224- ${ geometry }
225- ${ material }
226- </mesh>
300+ <group position={[0, -1, 0]}>
301+ <mesh ref={meshRef}>
302+ ${ geometry }
303+ ${ material }
304+ </mesh>
305+ ${ additionalMeshes }
306+ </group>
227307 )
228308}
229309` ;
0 commit comments