wireframe_patterns_v1 / generator /webXOS_geometrica.html
webxos's picture
Rename webXOS_geometrica.html to generator/webXOS_geometrica.html
8038919 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GEOMETRICA v2.0 - by webXOS 2026</title>
<!-- Libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gif.js@0.2.0/dist/gif.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ccapture.js@1.1.0/build/CCapture.all.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Courier New', monospace;
background: #000000;
color: #00ff00;
overflow: hidden;
height: 100vh;
display: flex;
flex-direction: column;
}
/* Header */
#header {
background: rgba(0, 30, 0, 0.95);
border-bottom: 2px solid #00ff00;
padding: 10px 20px;
display: flex;
justify-content: space-between;
align-items: center;
z-index: 100;
height: 60px;
box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}
.logo {
font-size: 22px;
font-weight: bold;
color: #00ff00;
text-shadow: 0 0 10px #00ff00;
letter-spacing: 2px;
}
.logo-sub {
font-size: 12px;
color: #00cc00;
margin-left: 10px;
}
.status-indicator {
display: flex;
align-items: center;
gap: 10px;
}
.live-dot {
width: 12px;
height: 12px;
border-radius: 50%;
background: #ff0000;
box-shadow: 0 0 10px #ff0000;
animation: pulse 1s infinite;
}
.live-dot.active {
background: #00ff00;
box-shadow: 0 0 15px #00ff00;
}
.header-buttons {
display: flex;
gap: 10px;
}
.header-btn {
background: transparent;
border: 1px solid #00ff00;
color: #00ff00;
padding: 8px 15px;
font-family: 'Courier New', monospace;
cursor: pointer;
font-size: 14px;
transition: all 0.3s;
}
.header-btn:hover {
background: rgba(0, 255, 0, 0.1);
box-shadow: 0 0 10px #00ff00;
}
.header-btn.active {
background: rgba(0, 255, 0, 0.2);
box-shadow: 0 0 15px #00ff00;
animation: neonPulse 1.5s infinite alternate;
}
/* Main Content */
#main-content {
display: flex;
flex: 1;
overflow: hidden;
}
/* Config Panel */
#config-panel {
flex: 0 0 400px;
background: rgba(0, 20, 0, 0.95);
border-right: 2px solid #00ff00;
padding: 20px;
overflow-y: auto;
z-index: 10;
box-shadow: 5px 0 15px rgba(0, 255, 0, 0.2);
}
.config-section {
margin-bottom: 25px;
padding-bottom: 15px;
border-bottom: 1px solid rgba(0, 255, 0, 0.2);
}
.config-title {
color: #00ff00;
font-size: 16px;
margin-bottom: 15px;
text-shadow: 0 0 5px #00ff00;
}
.config-group {
margin-bottom: 12px;
}
.config-label {
color: #00cc00;
font-size: 13px;
margin-bottom: 5px;
display: block;
}
.config-input {
width: 100%;
background: rgba(0, 30, 0, 0.8);
border: 1px solid #00ff00;
color: #00ff00;
padding: 8px 10px;
font-family: 'Courier New', monospace;
font-size: 14px;
border-radius: 3px;
}
.config-input:focus {
outline: none;
box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}
.config-select {
width: 100%;
background: rgba(0, 30, 0, 0.8);
border: 1px solid #00ff00;
color: #00ff00;
padding: 8px 10px;
font-family: 'Courier New', monospace;
font-size: 14px;
}
.config-checkbox {
margin-right: 8px;
}
.config-slider {
width: 100%;
margin: 10px 0;
}
.config-value {
color: #00ff00;
font-size: 12px;
float: right;
}
/* Visualization */
#visualization {
flex: 1;
position: relative;
background: #000;
}
#threeCanvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: block;
}
/* Stats Panel */
#stats-panel {
position: absolute;
bottom: 20px;
right: 20px;
background: rgba(0, 30, 0, 0.9);
border: 2px solid #00ff00;
padding: 15px;
font-size: 12px;
width: 300px;
z-index: 5;
backdrop-filter: blur(5px);
}
.stat-row {
display: flex;
justify-content: space-between;
margin: 6px 0;
padding: 3px 0;
border-bottom: 1px solid rgba(0, 255, 0, 0.1);
}
.stat-label {
color: #00cc00;
}
.stat-value {
color: #00ff00;
font-weight: bold;
}
/* Dataset Panel */
#dataset-panel {
position: absolute;
top: 20px;
right: 20px;
background: rgba(0, 30, 0, 0.9);
border: 2px solid #00ff00;
padding: 15px;
font-size: 12px;
width: 350px;
z-index: 5;
backdrop-filter: blur(5px);
}
.dataset-progress {
width: 100%;
height: 10px;
background: rgba(0, 0, 0, 0.5);
border: 1px solid #00ff00;
margin: 10px 0;
overflow: hidden;
}
.dataset-progress-fill {
height: 100%;
background: linear-gradient(90deg, #00ff00, #00cc00);
width: 0%;
transition: width 0.5s ease-out;
}
/* Animations */
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
@keyframes neonPulse {
0% { box-shadow: 0 0 10px #00ff00; }
100% { box-shadow: 0 0 20px #00ff00, 0 0 30px #00ff00; }
}
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
}
.cursor {
animation: blink 1s infinite;
}
/* Scrollbar */
#config-panel::-webkit-scrollbar {
width: 8px;
}
#config-panel::-webkit-scrollbar-track {
background: rgba(0, 20, 0, 0.5);
}
#config-panel::-webkit-scrollbar-thumb {
background: #00ff00;
border-radius: 5px;
}
/* Pattern Card */
.pattern-card {
background: rgba(0, 40, 0, 0.8);
border: 1px solid #00ff00;
padding: 15px;
margin-bottom: 15px;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s;
}
.pattern-card:hover {
background: rgba(0, 60, 0, 0.9);
box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
}
.pattern-name {
color: #00ff00;
font-size: 16px;
margin-bottom: 10px;
}
.pattern-metrics {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
font-size: 12px;
}
.metric-value {
color: #00ff00;
font-weight: bold;
}
/* Parameter Panel */
#param-panel {
position: absolute;
top: 20px;
left: 20px;
background: rgba(0, 30, 0, 0.9);
border: 2px solid #00ff00;
padding: 15px;
font-size: 12px;
width: 250px;
z-index: 5;
backdrop-filter: blur(5px);
}
.param-group {
margin-bottom: 10px;
}
.param-label {
color: #00cc00;
font-size: 11px;
display: block;
margin-bottom: 3px;
}
.param-slider {
width: 100%;
margin: 5px 0;
}
.param-value {
color: #00ff00;
font-size: 11px;
float: right;
}
</style>
</head>
<body>
<!-- Header -->
<div id="header">
<div>
<div class="logo">GEOMETRICA v2.0 // webXOS 2026</div>
<span class="logo-sub">Wireframe Pattern Dataset Generator</span>
</div>
<div class="status-indicator">
<div class="live-dot" id="liveDot"></div>
<span id="statusText">INITIALIZING</span>
</div>
<div class="header-buttons">
<button class="header-btn" onclick="toggleAnimation()" id="animateBtn">▶ ANIMATE</button>
<button class="header-btn" onclick="toggleCapture()" id="captureBtn">⏺ CAPTURE</button>
<button class="header-btn" onclick="exportDataset()">📤 EXPORT DATASET</button>
<button class="header-btn" onclick="randomizePattern()">🎲 RANDOMIZE</button>
</div>
</div>
<!-- Main Content -->
<div id="main-content">
<!-- Configuration Panel -->
<div id="config-panel">
<div class="config-section">
<div class="config-title">DATASET CONFIGURATION</div>
<div class="config-group">
<label class="config-label">Dataset Name</label>
<input type="text" id="datasetName" class="config-input" value="wireframe_patterns_v1">
</div>
<div class="config-group">
<label class="config-label">Dataset Size (frames)</label>
<input type="range" id="datasetSize" class="config-slider" min="10" max="1000" value="100" step="10">
<span id="datasetSizeValue" class="config-value">100</span>
</div>
<div class="config-group">
<label class="config-label">Pattern Type</label>
<select id="patternType" class="config-select">
<option value="spiral_tower">Spiral Tower</option>
<option value="fractal_sphere">Fractal Sphere</option>
<option value="lattice">3D Lattice</option>
<option value="helix">Double Helix</option>
<option value="cube_field">Cube Field</option>
<option value="wireframe_mesh">Wireframe Mesh</option>
</select>
</div>
<div class="config-group">
<label class="config-label">Export Format</label>
<select id="exportFormat" class="config-select">
<option value="huggingface">Hugging Face Dataset</option>
<option value="images">Image Sequence (PNG)</option>
<option value="gif">Animated GIF</option>
<option value="json">JSON Parameters</option>
</select>
</div>
</div>
<div class="config-section">
<div class="config-title">WIREFRAME STYLE</div>
<div class="config-group">
<label class="config-label">Line Color</label>
<input type="color" id="lineColor" class="config-input" value="#00ff00" style="height: 40px;">
</div>
<div class="config-group">
<label class="config-label">Background Color</label>
<input type="color" id="bgColor" class="config-input" value="#000000" style="height: 40px;">
</div>
<div class="config-group">
<label>
<input type="checkbox" id="enableGlow" class="config-checkbox" checked>
<span class="config-label">Enable Line Glow</span>
</label>
</div>
<div class="config-group">
<label>
<input type="checkbox" id="enableAnimation" class="config-checkbox" checked>
<span class="config-label">Enable Animation</span>
</label>
</div>
</div>
<div class="config-section">
<div class="config-title">PRESET PATTERNS</div>
<div id="patternCards">
<div class="pattern-card" onclick="loadPreset('infinity_spiral')">
<div class="pattern-name">∞ Infinity Spiral</div>
<div class="pattern-metrics">
<div>Complexity: <span class="metric-value">High</span></div>
<div>Frames: <span class="metric-value">360</span></div>
</div>
</div>
<div class="pattern-card" onclick="loadPreset("quantum_lattice")">
<div class="pattern-name">Quantum Lattice</div>
<div class="pattern-metrics">
<div>Complexity: <span class="metric-value">Medium</span></div>
<div>Frames: <span class="metric-value">240</span></div>
</div>
</div>
<div class="pattern-card" onclick="loadPreset("neural_web")">
<div class="pattern-name">Neural Web</div>
<div class="pattern-metrics">
<div>Complexity: <span class="metric-value">High</span></div>
<div>Frames: <span class="metric-value">180</span></div>
</div>
</div>
</div>
</div>
<div class="config-section">
<div class="config-title">EXPORT SETTINGS</div>
<div class="config-group">
<label>
<input type="checkbox" id="exportMetadata" class="config-checkbox" checked>
<span class="config-label">Export Metadata</span>
</label>
</div>
<div class="config-group">
<label>
<input type="checkbox" id="exportParams" class="config-checkbox" checked>
<span class="config-label">Export Parameters</span>
</label>
</div>
<div class="config-group">
<label>
<input type="checkbox" id="exportPreviews" class="config-checkbox" checked>
<span class="config-label">Export Preview Images</span>
</label>
</div>
<div class="config-group">
<label class="config-label">Frame Rate (GIF)</label>
<input type="range" id="frameRate" class="config-slider" min="5" max="60" value="30" step="5">
<span id="frameRateValue" class="config-value">30 FPS</span>
</div>
</div>
</div>
<!-- Visualization -->
<div id="visualization">
<canvas id="threeCanvas"></canvas>
<!-- Dataset Panel -->
<div id="dataset-panel">
<div class="stat-row">
<span class="stat-label">STATUS:</span>
<span class="stat-value" id="datasetStatus">READY</span>
</div>
<div class="stat-row">
<span class="stat-label">CAPTURED FRAMES:</span>
<span class="stat-value" id="capturedFrames">0</span>
</div>
<div class="stat-row">
<span class="stat-label">TARGET FRAMES:</span>
<span class="stat-value" id="targetFrames">100</span>
</div>
<div class="dataset-progress">
<div id="captureProgress" class="dataset-progress-fill"></div>
</div>
<div class="stat-row">
<span class="stat-label">MEMORY USAGE:</span>
<span class="stat-value" id="memoryUsage">0 MB</span>
</div>
</div>
<!-- Stats Panel -->
<div id="stats-panel">
<div class="stat-row">
<span class="stat-label">PATTERN:</span>
<span class="stat-value" id="patternName">Spiral Tower</span>
</div>
<div class="stat-row">
<span class="stat-label">FPS:</span>
<span class="stat-value" id="fpsCounter">0</span>
</div>
<div class="stat-row">
<span class="stat-label">VERTICES:</span>
<span class="stat-value" id="vertexCount">0</span>
</div>
<div class="stat-row">
<span class="stat-label">EDGES:</span>
<span class="stat-value" id="edgeCount">0</span>
</div>
<div class="stat-row">
<span class="stat-label">ANIMATION TIME:</span>
<span class="stat-value" id="animationTime">0.0s</span>
</div>
</div>
<!-- Parameter Panel -->
<div id="param-panel">
<div class="param-group">
<span class="param-label">COMPLEXITY</span>
<span id="complexityValue" class="param-value">5</span>
<input type="range" id="complexity" class="param-slider" min="1" max="10" value="5" step="1">
</div>
<div class="param-group">
<span class="param-label">SIZE</span>
<span id="sizeValue" class="param-value">50</span>
<input type="range" id="size" class="param-slider" min="10" max="100" value="50" step="5">
</div>
<div class="param-group">
<span class="param-label">DETAIL</span>
<span id="detailValue" class="param-value">32</span>
<input type="range" id="detail" class="param-slider" min="4" max="64" value="32" step="4">
</div>
<div class="param-group">
<span class="param-label">SPEED</span>
<span id="speedValue" class="param-value">1.0</span>
<input type="range" id="speed" class="param-slider" min="0.1" max="3.0" value="1.0" step="0.1">
</div>
<div class="param-group">
<span class="param-label">TWIST</span>
<span id="twistValue" class="param-value">2.0</span>
<input type="range" id="twist" class="param-slider" min="0" max="5" value="2.0" step="0.1">
</div>
</div>
</div>
</div>
<script>
// ==================== GLOBAL STATE ====================
let animationRunning = false;
let capturingFrames = false;
let animationId = null;
let capturer = null;
let capturedFrames = [];
let capturedCount = 0;
let targetFrames = 100;
let animationTime = 0;
let lastFrameTime = performance.now();
let fps = 0;
let frameCount = 0;
let fpsLastTime = performance.now();
// Pattern parameters
let patternParams = {
type: 'spiral_tower',
complexity: 5,
size: 50,
detail: 32,
speed: 1.0,
twist: 2.0,
lineColor: '#00ff00',
bgColor: '#000000',
glow: true,
animate: true
};
// Three.js components
let scene, camera, renderer, controls;
let patternMesh = null;
let patternLines = null;
// Presets
const presets = {
'infinity_spiral': {
type: 'spiral_tower',
complexity: 8,
size: 60,
detail: 48,
speed: 1.5,
twist: 3.0,
lineColor: '#00ffff'
},
'quantum_lattice': {
type: 'lattice',
complexity: 7,
size: 40,
detail: 24,
speed: 0.8,
twist: 1.0,
lineColor: '#00ff00'
},
'neural_web': {
type: 'wireframe_mesh',
complexity: 9,
size: 70,
detail: 36,
speed: 1.2,
twist: 0.5,
lineColor: '#ff00ff'
}
};
// ==================== PATTERN GENERATORS ====================
function generateSpiralTower(params) {
const geometry = new THREE.BufferGeometry();
const vertices = [];
const indices = [];
const layers = Math.floor(params.complexity * 3);
const radius = params.size;
const height = params.size * 2;
const twist = params.twist;
const segments = params.detail;
// Generate vertices
for (let layer = 0; layer < layers; layer++) {
const y = (layer / layers) * height - height / 2;
const layerRadius = radius * (1 - layer / layers * 0.3);
const angleOffset = (layer / layers) * Math.PI * twist;
for (let i = 0; i < segments; i++) {
const angle = (i / segments) * Math.PI * 2 + angleOffset;
const x = Math.cos(angle) * layerRadius;
const z = Math.sin(angle) * layerRadius;
vertices.push(x, y, z);
// Connect to next vertex in same layer
if (i < segments - 1) {
const currentIndex = layer * segments + i;
indices.push(currentIndex, currentIndex + 1);
} else {
// Connect last to first
const currentIndex = layer * segments + i;
indices.push(currentIndex, layer * segments);
}
// Connect to vertex in layer above
if (layer < layers - 1) {
const currentIndex = layer * segments + i;
const nextIndex = (layer + 1) * segments + i;
indices.push(currentIndex, nextIndex);
}
}
}
geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
geometry.setIndex(indices);
return geometry;
}
function generateFractalSphere(params) {
const geometry = new THREE.IcosahedronGeometry(params.size, params.complexity);
const wireframe = new THREE.WireframeGeometry(geometry);
// Add fractal displacement
const positions = wireframe.attributes.position.array;
for (let i = 0; i < positions.length; i += 3) {
const x = positions[i], y = positions[i+1], z = positions[i+2];
const noise = 0.1 * (Math.sin(x) + Math.cos(y) + Math.sin(z));
positions[i] *= 1 + noise;
positions[i+1] *= 1 + noise;
positions[i+2] *= 1 + noise;
}
return wireframe;
}
function generateLattice(params) {
const geometry = new THREE.BufferGeometry();
const vertices = [];
const indices = [];
const gridSize = Math.floor(params.complexity);
const spacing = params.size / gridSize;
// Create grid points
for (let x = 0; x <= gridSize; x++) {
for (let y = 0; y <= gridSize; y++) {
for (let z = 0; z <= gridSize; z++) {
const px = (x - gridSize/2) * spacing;
const py = (y - gridSize/2) * spacing;
const pz = (z - gridSize/2) * spacing;
// Add some noise for organic feel
const noiseX = (Math.random() - 0.5) * spacing * 0.3;
const noiseY = (Math.random() - 0.5) * spacing * 0.3;
const noiseZ = (Math.random() - 0.5) * spacing * 0.3;
vertices.push(px + noiseX, py + noiseY, pz + noiseZ);
}
}
}
// Connect points in grid
const totalPoints = (gridSize + 1) * (gridSize + 1) * (gridSize + 1);
for (let i = 0; i < totalPoints; i++) {
const x = i % (gridSize + 1);
const y = Math.floor(i / (gridSize + 1)) % (gridSize + 1);
const z = Math.floor(i / ((gridSize + 1) * (gridSize + 1)));
// Connect to right neighbor
if (x < gridSize) {
const rightIndex = i + 1;
indices.push(i, rightIndex);
}
// Connect to above neighbor
if (y < gridSize) {
const aboveIndex = i + (gridSize + 1);
indices.push(i, aboveIndex);
}
// Connect to forward neighbor
if (z < gridSize) {
const forwardIndex = i + (gridSize + 1) * (gridSize + 1);
indices.push(i, forwardIndex);
}
}
geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
geometry.setIndex(indices);
return geometry;
}
function generateDoubleHelix(params) {
const geometry = new THREE.BufferGeometry();
const vertices = [];
const indices = [];
const segments = params.detail * 2;
const radius = params.size / 2;
const height = params.size * 1.5;
// Create two interwoven helices
for (let strand = 0; strand < 2; strand++) {
const strandOffset = strand * Math.PI;
for (let i = 0; i < segments; i++) {
const t = i / segments;
const y = (t - 0.5) * height;
const angle = t * Math.PI * 4 + strandOffset;
const x = Math.cos(angle) * radius;
const z = Math.sin(angle) * radius;
vertices.push(x, y, z);
// Connect segments
if (i < segments - 1) {
const currentIndex = strand * segments + i;
indices.push(currentIndex, currentIndex + 1);
}
}
}
// Connect strands with cross-links
const crossLinks = Math.floor(params.complexity * 2);
for (let i = 0; i < crossLinks; i++) {
const t = i / crossLinks;
const index1 = Math.floor(t * segments);
const index2 = segments + Math.floor((1 - t) * segments);
indices.push(index1, index2);
}
geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
geometry.setIndex(indices);
return geometry;
}
function generateCubeField(params) {
const geometry = new THREE.BufferGeometry();
const vertices = [];
const indices = [];
const count = Math.floor(params.complexity);
const spacing = params.size * 1.5 / count;
// Create grid of cubes
let vertexIndex = 0;
for (let x = 0; x < count; x++) {
for (let y = 0; y < count; y++) {
for (let z = 0; z < count; z++) {
const px = (x - count/2) * spacing;
const py = (y - count/2) * spacing;
const pz = (z - count/2) * spacing;
const size = spacing * 0.3;
// Cube vertices
const cubeVertices = [
[px-size, py-size, pz-size], [px+size, py-size, pz-size],
[px+size, py+size, pz-size], [px-size, py+size, pz-size],
[px-size, py-size, pz+size], [px+size, py-size, pz+size],
[px+size, py+size, pz+size], [px-size, py+size, pz+size]
];
// Add cube vertices
cubeVertices.forEach(v => {
vertices.push(...v);
});
// Cube edges
const cubeEdges = [
[0,1], [1,2], [2,3], [3,0], // bottom
[4,5], [5,6], [6,7], [7,4], // top
[0,4], [1,5], [2,6], [3,7] // sides
];
// Add cube edges with offset
cubeEdges.forEach(edge => {
indices.push(vertexIndex + edge[0], vertexIndex + edge[1]);
});
vertexIndex += 8;
}
}
}
geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
geometry.setIndex(indices);
return geometry;
}
function generateWireframeMesh(params) {
const geometry = new THREE.BufferGeometry();
const vertices = [];
const indices = [];
const points = params.detail * 4;
const radius = params.size;
// Create random points on sphere surface
for (let i = 0; i < points; i++) {
// Random point on sphere
const theta = Math.random() * Math.PI * 2;
const phi = Math.acos(2 * Math.random() - 1);
const x = radius * Math.sin(phi) * Math.cos(theta);
const y = radius * Math.sin(phi) * Math.sin(theta);
const z = radius * Math.cos(phi);
vertices.push(x, y, z);
}
// Connect points based on proximity
const maxConnections = Math.floor(params.complexity * 2);
for (let i = 0; i < points; i++) {
const connections = [];
const ix = i * 3;
for (let j = 0; j < points; j++) {
if (i === j) continue;
const jx = j * 3;
const dx = vertices[ix] - vertices[jx];
const dy = vertices[ix+1] - vertices[jx+1];
const dz = vertices[ix+2] - vertices[jx+2];
const distance = Math.sqrt(dx*dx + dy*dy + dz*dz);
connections.push({index: j, distance: distance});
}
// Sort by distance and connect to closest ones
connections.sort((a, b) => a.distance - b.distance);
for (let k = 0; k < Math.min(maxConnections, connections.length); k++) {
indices.push(i, connections[k].index);
}
}
geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
geometry.setIndex(indices);
return geometry;
}
// ==================== THREE.JS SETUP ====================
function initThreeJS() {
try {
// Scene
scene = new THREE.Scene();
scene.background = new THREE.Color(patternParams.bgColor);
// Camera
const canvas = document.getElementById('threeCanvas');
camera = new THREE.PerspectiveCamera(60, canvas.clientWidth / canvas.clientHeight, 0.1, 1000);
camera.position.set(0, 50, 150);
// Renderer
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setSize(canvas.clientWidth, canvas.clientHeight);
renderer.setPixelRatio(window.devicePixelRatio);
// Controls
controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
// Lighting
const ambientLight = new THREE.AmbientLight(0xffffff, 0.3);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.7);
directionalLight.position.set(50, 100, 50);
scene.add(directionalLight);
// Initialize pattern
updatePattern();
console.log('[Three.js] Initialized successfully');
return true;
} catch (error) {
console.error('[Three.js] Error:', error);
return false;
}
}
function updatePattern() {
// Remove old pattern
if (patternLines) {
scene.remove(patternLines);
}
// Generate new pattern based on type
let geometry;
switch(patternParams.type) {
case 'spiral_tower':
geometry = generateSpiralTower(patternParams);
break;
case 'fractal_sphere':
geometry = generateFractalSphere(patternParams);
break;
case 'lattice':
geometry = generateLattice(patternParams);
break;
case 'helix':
geometry = generateDoubleHelix(patternParams);
break;
case 'cube_field':
geometry = generateCubeField(patternParams);
break;
case 'wireframe_mesh':
geometry = generateWireframeMesh(patternParams);
break;
default:
geometry = generateSpiralTower(patternParams);
}
// Create line material with glow effect
const lineColor = new THREE.Color(patternParams.lineColor);
const material = new THREE.LineBasicMaterial({
color: lineColor,
linewidth: patternParams.glow ? 2 : 1,
transparent: true,
opacity: 0.9
});
// Create line segments
patternLines = new THREE.LineSegments(geometry, material);
scene.add(patternLines);
// Update stats
updateStats();
}
function updatePatternAnimation(deltaTime) {
if (!patternLines || !patternParams.animate || !animationRunning) return;
// Different animations for different patterns
switch(patternParams.type) {
case 'spiral_tower':
patternLines.rotation.y += deltaTime * patternParams.speed * 0.5;
patternLines.rotation.x = Math.sin(animationTime * 0.5) * 0.1;
break;
case 'fractal_sphere':
patternLines.rotation.x += deltaTime * patternParams.speed * 0.3;
patternLines.rotation.y += deltaTime * patternParams.speed * 0.4;
break;
case 'lattice':
patternLines.rotation.y += deltaTime * patternParams.speed * 0.6;
const scale = 1 + Math.sin(animationTime) * 0.05;
patternLines.scale.setScalar(scale);
break;
case 'helix':
patternLines.rotation.y += deltaTime * patternParams.speed * 0.8;
break;
case 'cube_field':
patternLines.rotation.x += deltaTime * patternParams.speed * 0.2;
patternLines.rotation.y += deltaTime * patternParams.speed * 0.3;
break;
case 'wireframe_mesh':
patternLines.rotation.x = Math.sin(animationTime * 0.3) * 0.3;
patternLines.rotation.y = Math.cos(animationTime * 0.4) * 0.3;
break;
}
}
// ==================== CAPTURE & DATASET ====================
function startCapture() {
if (capturingFrames) return;
capturingFrames = true;
capturedFrames = [];
capturedCount = 0;
targetFrames = parseInt(document.getElementById('datasetSize').value);
document.getElementById('captureBtn').classList.add('active');
document.getElementById('captureBtn').textContent = '⏹ STOP CAPTURE';
document.getElementById('datasetStatus').textContent = 'CAPTURING';
console.log(`[Capture] Starting capture of ${targetFrames} frames`);
}
function stopCapture() {
capturingFrames = false;
document.getElementById('captureBtn').classList.remove('active');
document.getElementById('captureBtn').textContent = '⏺ CAPTURE';
document.getElementById('datasetStatus').textContent = 'READY';
console.log(`[Capture] Stopped capture. Captured ${capturedFrames.length} frames`);
}
function captureFrame() {
if (!capturingFrames || capturedCount >= targetFrames) return;
const canvas = document.getElementById('threeCanvas');
const imageData = canvas.toDataURL('image/png');
const frameData = {
frame: capturedCount,
timestamp: Date.now(),
animationTime: animationTime,
params: {...patternParams},
camera: {
position: {x: camera.position.x, y: camera.position.y, z: camera.position.z},
rotation: {x: camera.rotation.x, y: camera.rotation.y, z: camera.rotation.z}
}
};
capturedFrames.push({
data: frameData,
image: imageData
});
capturedCount++;
// Update UI
document.getElementById('capturedFrames').textContent = capturedCount;
document.getElementById('targetFrames').textContent = targetFrames;
const progress = (capturedCount / targetFrames) * 100;
document.getElementById('captureProgress').style.width = progress + '%';
// Update memory usage
const memory = Math.round(JSON.stringify(capturedFrames).length / 1024);
document.getElementById('memoryUsage').textContent = memory + ' KB';
// Stop if reached target
if (capturedCount >= targetFrames) {
stopCapture();
}
}
async function exportDataset() {
if (capturedFrames.length === 0) {
alert('No frames captured! Start capture first.');
return;
}
console.log('[Export] Preparing dataset export...');
try {
const zip = new JSZip();
const datasetName = document.getElementById('datasetName').value;
const exportFormat = document.getElementById('exportFormat').value;
// 1. Dataset metadata
const metadata = {
name: datasetName,
version: "2.0",
created: new Date().toISOString(),
frames: capturedFrames.length,
patternType: patternParams.type,
exportFormat: exportFormat,
description: "Wireframe geometric pattern dataset generated by Geometrica v2.0",
license: "MIT",
citation: "@misc{wireframe_patterns_2024,\n title={Wireframe Geometric Patterns},\n author={Geometrica v2.0},\n year={2024},\n url={https://github.com/your-username/dataset}\n}"
};
zip.file("metadata.json", JSON.stringify(metadata, null, 2));
// 2. Frames data
if (document.getElementById('exportParams').checked) {
const framesData = capturedFrames.map(f => f.data);
zip.file("frames.json", JSON.stringify(framesData, null, 2));
}
// 3. Images
if (exportFormat === 'images' || exportFormat === 'huggingface') {
const imgFolder = zip.folder("images");
for (let i = 0; i < capturedFrames.length; i++) {
const base64Data = capturedFrames[i].image.replace(/^data:image\/png;base64,/, "");
imgFolder.file(`frame_${i.toString().padStart(4, '0')}.png`, base64Data, {base64: true});
}
}
// 4. Configuration
const config = {
patternParams: patternParams,
cameraSettings: {
position: camera.position,
rotation: camera.rotation,
fov: camera.fov
},
generationSettings: {
targetFrames: targetFrames,
capturedFrames: capturedCount,
animationEnabled: patternParams.animate,
glowEnabled: patternParams.glow
}
};
zip.file("config.json", JSON.stringify(config, null, 2));
// 5. README
const readme = generateReadme(metadata, config);
zip.file("README.md", readme);
// 6. Generate and download
const content = await zip.generateAsync({type: "blob"});
const filename = `${datasetName}_${exportFormat}_${Date.now()}.zip`;
saveAs(content, filename);
console.log(`[Export] Dataset exported: ${filename}`);
console.log(`[Export] Total frames: ${capturedFrames.length}`);
console.log(`[Export] Size: ${(content.size / 1024 / 1024).toFixed(2)} MB`);
} catch (error) {
console.error('[Export] Error:', error);
alert('Export failed: ' + error.message);
}
}
function generateReadme(metadata, config) {
return `# ${metadata.name}
## Dataset Description
This dataset contains wireframe geometric patterns generated using Geometrica v2.0, focusing on procedural generation of abstract geometric structures with infinite loop animations.
## Dataset Contents
- **Total Frames:** ${metadata.frames}
- **Pattern Type:** ${metadata.patternType}
- **Generation Date:** ${metadata.created}
- **Export Format:** ${metadata.exportFormat}
## Pattern Parameters
- **Complexity:** ${config.patternParams.complexity}
- **Size:** ${config.patternParams.size}
- **Detail Level:** ${config.patternParams.detail}
- **Animation Speed:** ${config.patternParams.speed}
- **Line Color:** ${config.patternParams.lineColor}
- **Background Color:** ${config.patternParams.bgColor}
## File Structure
\`\`\`
dataset.zip/
├── metadata.json # Dataset information
├── config.json # Generation parameters
├── frames.json # Frame-by-frame data (optional)
├── images/ # PNG images of each frame
│ └── frame_*.png
└── README.md # This file
\`\`\`
## Usage Examples
### Python (Loading Images)
\`\`\`python
import os
from PIL import Image
import json
# Load metadata
with open('metadata.json', 'r') as f:
metadata = json.load(f)
# Load images
images = []
for i in range(metadata['frames']):
img_path = f'images/frame_{i:04d}.png'
img = Image.open(img_path)
images.append(img)
\`\`\`
### JavaScript (Three.js Recreation)
\`\`\`javascript
// Load configuration
const config = await fetch('config.json').then(r => r.json());
// Recreate pattern based on parameters
function recreatePattern(params) {
// Implementation depends on pattern type
// Use the parameters from config.patternParams
}
\`\`\`
## Citation
If you use this dataset in your research, please cite:
\`\`\`bibtex
${metadata.citation}
\`\`\`
## License
${metadata.license} License
## Contact
Generated by Geometrica v2.0 - Wireframe Pattern Dataset Generator
`;
}
// ==================== GIF CAPTURE ====================
function startGifCapture() {
const frameRate = parseInt(document.getElementById('frameRate').value);
capturer = new CCapture({
format: 'gif',
workersPath: '',
verbose: false,
framerate: frameRate,
quality: 90,
timeLimit: 5,
autoSaveTime: 0
});
capturer.start();
console.log('[GIF] Started recording');
}
function stopGifCapture() {
if (capturer) {
capturer.stop();
capturer.save();
capturer = null;
console.log('[GIF] Saved recording');
}
}
// ==================== UI CONTROLS ====================
function toggleAnimation() {
animationRunning = !animationRunning;
const btn = document.getElementById('animateBtn');
if (animationRunning) {
btn.classList.add('active');
btn.textContent = '⏸ PAUSE';
document.getElementById('statusText').textContent = 'ANIMATING';
document.getElementById('liveDot').classList.add('active');
if (!animationId) {
lastFrameTime = performance.now();
animationId = requestAnimationFrame(animationLoop);
}
} else {
btn.classList.remove('active');
btn.textContent = '▶ ANIMATE';
document.getElementById('statusText').textContent = 'PAUSED';
document.getElementById('liveDot').classList.remove('active');
}
}
function toggleCapture() {
if (capturingFrames) {
stopCapture();
} else {
startCapture();
}
}
function randomizePattern() {
const types = ['spiral_tower', 'fractal_sphere', 'lattice', 'helix', 'cube_field', 'wireframe_mesh'];
const colors = ['#00ff00', '#00ffff', '#ff00ff', '#ffff00', '#ff0000', '#ffffff'];
patternParams.type = types[Math.floor(Math.random() * types.length)];
patternParams.complexity = Math.floor(Math.random() * 10) + 1;
patternParams.size = Math.floor(Math.random() * 50) + 20;
patternParams.detail = Math.floor(Math.random() * 10) * 4 + 8;
patternParams.speed = Math.random() * 2 + 0.5;
patternParams.twist = Math.random() * 5;
patternParams.lineColor = colors[Math.floor(Math.random() * colors.length)];
// Update UI
document.getElementById('patternType').value = patternParams.type;
document.getElementById('lineColor').value = patternParams.lineColor;
document.getElementById('complexity').value = patternParams.complexity;
document.getElementById('size').value = patternParams.size;
document.getElementById('detail').value = patternParams.detail;
document.getElementById('speed').value = patternParams.speed;
document.getElementById('twist').value = patternParams.twist;
updateUIValues();
updatePattern();
console.log('[Pattern] Randomized:', patternParams);
}
function loadPreset(presetName) {
if (presets[presetName]) {
patternParams = {...patternParams, ...presets[presetName]};
// Update UI
document.getElementById('patternType').value = patternParams.type;
document.getElementById('lineColor').value = patternParams.lineColor;
document.getElementById('complexity').value = patternParams.complexity;
document.getElementById('size').value = patternParams.size;
document.getElementById('detail').value = patternParams.detail;
document.getElementById('speed').value = patternParams.speed;
document.getElementById('twist').value = patternParams.twist;
updateUIValues();
updatePattern();
updatePatternName();
console.log(`[Pattern] Loaded preset: ${presetName}`);
}
}
// ==================== ANIMATION LOOP ====================
function animationLoop(currentTime) {
const deltaTime = (currentTime - lastFrameTime) / 1000;
lastFrameTime = currentTime;
// Update animation time
if (animationRunning) {
animationTime += deltaTime * patternParams.speed;
document.getElementById('animationTime').textContent = animationTime.toFixed(1) + 's';
}
// Update pattern animation
updatePatternAnimation(deltaTime);
// Update controls
controls.update();
// Render
renderer.render(scene, camera);
// Capture frame if capturing
if (animationRunning && capturingFrames) {
captureFrame();
}
// Capture GIF frame
if (capturer) {
capturer.capture(renderer.domElement);
}
// Update FPS
frameCount++;
if (currentTime - fpsLastTime >= 1000) {
fps = Math.round((frameCount * 1000) / (currentTime - fpsLastTime));
frameCount = 0;
fpsLastTime = currentTime;
document.getElementById('fpsCounter').textContent = fps;
}
animationId = requestAnimationFrame(animationLoop);
}
// ==================== UI UPDATES ====================
function updateStats() {
if (patternLines && patternLines.geometry) {
const vertices = patternLines.geometry.attributes.position.count;
const edges = patternLines.geometry.index ? patternLines.geometry.index.count / 2 : vertices * 1.5;
document.getElementById('vertexCount').textContent = vertices;
document.getElementById('edgeCount').textContent = Math.floor(edges);
}
}
function updatePatternName() {
const select = document.getElementById('patternType');
document.getElementById('patternName').textContent = select.options[select.selectedIndex].text;
}
function updateUIValues() {
document.getElementById('complexityValue').textContent = patternParams.complexity;
document.getElementById('sizeValue').textContent = patternParams.size;
document.getElementById('detailValue').textContent = patternParams.detail;
document.getElementById('speedValue').textContent = patternParams.speed.toFixed(1);
document.getElementById('twistValue').textContent = patternParams.twist.toFixed(1);
}
// ==================== INITIALIZATION ====================
function initialize() {
console.log('[System] Initializing Geometric Pattern Generator...');
try {
// Initialize Three.js
initThreeJS();
// Setup event listeners
setupEventListeners();
// Start animation loop
lastFrameTime = performance.now();
animationId = requestAnimationFrame(animationLoop);
// Update UI
document.getElementById('statusText').textContent = 'READY';
updatePatternName();
updateUIValues();
// Set initial target frames
targetFrames = parseInt(document.getElementById('datasetSize').value);
document.getElementById('targetFrames').textContent = targetFrames;
console.log('[System] Initialization complete');
} catch (error) {
console.error('[System] Initialization failed:', error);
}
}
function setupEventListeners() {
// Pattern type
document.getElementById('patternType').addEventListener('change', function() {
patternParams.type = this.value;
updatePattern();
updatePatternName();
});
// Line color
document.getElementById('lineColor').addEventListener('input', function() {
patternParams.lineColor = this.value;
scene.background = new THREE.Color(document.getElementById('bgColor').value);
updatePattern();
});
// Background color
document.getElementById('bgColor').addEventListener('input', function() {
patternParams.bgColor = this.value;
scene.background = new THREE.Color(this.value);
});
// Glow effect
document.getElementById('enableGlow').addEventListener('change', function() {
patternParams.glow = this.checked;
updatePattern();
});
// Animation
document.getElementById('enableAnimation').addEventListener('change', function() {
patternParams.animate = this.checked;
});
// Dataset size
const datasetSize = document.getElementById('datasetSize');
const datasetSizeValue = document.getElementById('datasetSizeValue');
datasetSize.addEventListener('input', function() {
const value = parseInt(this.value);
datasetSizeValue.textContent = value;
targetFrames = value;
document.getElementById('targetFrames').textContent = value;
});
// Frame rate
const frameRate = document.getElementById('frameRate');
const frameRateValue = document.getElementById('frameRateValue');
frameRate.addEventListener('input', function() {
frameRateValue.textContent = this.value + ' FPS';
});
// Parameter sliders
const sliders = ['complexity', 'size', 'detail', 'speed', 'twist'];
sliders.forEach(id => {
const slider = document.getElementById(id);
const valueSpan = document.getElementById(id + 'Value');
slider.addEventListener('input', function() {
const value = this.name === 'speed' || this.name === 'twist' ?
parseFloat(this.value) : parseInt(this.value);
patternParams[this.name || id] = value;
valueSpan.textContent = this.name === 'speed' || this.name === 'twist' ?
value.toFixed(1) : value;
updatePattern();
});
});
}
function handleResize() {
if (camera && renderer) {
const canvas = document.getElementById('threeCanvas');
camera.aspect = canvas.clientWidth / canvas.clientHeight;
camera.updateProjectionMatrix();
renderer.setSize(canvas.clientWidth, canvas.clientHeight);
}
}
// Start the system
window.addEventListener('load', initialize);
window.addEventListener('resize', handleResize);
// Export to global scope for button clicks
window.toggleAnimation = toggleAnimation;
window.toggleCapture = toggleCapture;
window.exportDataset = exportDataset;
window.randomizePattern = randomizePattern;
window.loadPreset = loadPreset;
</script>
</body>
</html>