Fractal garden
A Game-class scene — no physics, no player. Two procedural fractals turn slowly on a lit stage; drag to orbit, scroll to zoom.
The whole game
ts
import * as THREE from 'three';
import { Game } from '@maomi/sge';
import { defaultLights } from '@maomi/sge/lights';
import { stageBackdrop } from '@maomi/sge/backdrop';
import * as Fractal from './fractals';
/* A Game-class scene (no physics, no player): procedural fractals slowly turning on a lit
stage. Drag to orbit, scroll to zoom. */
export const createGame = (): HTMLElement => {
const game = new Game();
game.scene.background = stageBackdrop('#1d2440', '#0a0d1a', 'rgba(255,255,255,0.045)');
game.scene.add(defaultLights({ shadowExtent: 30 }));
const broccoli = Fractal.RomanescoBroccoli(0, 1.6, 3);
broccoli.position.set(-5, 2, 0);
game.scene.add(broccoli);
const sponge = Fractal.MengerSponge(2, 4);
sponge.position.set(5, 2, 0);
game.scene.add(sponge);
game.onFrame = (delta) => {
broccoli.rotation.y += delta * 0.4;
sponge.rotation.y -= delta * 0.25;
};
const el = game.start(0, 8, 14);
game.orbit.enabled = true;
game.orbit.target.set(0, 2, 0);
game.orbit.update();
return el;
};Things to notice:
Game.start(x, y, z)positions the camera and starts the loop — the returned element is the whole game.onFrameis per-frame logic without owning the render loop.stageBackdroppaintsscene.background— a lit stage instead of a flat clear color.