-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdodefractal.html
More file actions
375 lines (329 loc) · 16.7 KB
/
dodefractal.html
File metadata and controls
375 lines (329 loc) · 16.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<!DOCTYPE html>
<html lang="pt-PT">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dodecaedro Sagrado - Interface Compacta</title>
<style>
body { margin: 0; overflow: hidden; background-color: #000; font-family: 'Segoe UI', system-ui, sans-serif; color: #00d2ff; }
canvas { display: block; }
/* Botão de Engrenagem */
#settings-btn {
position: absolute;
top: 15px;
right: 15px;
width: 35px;
height: 35px;
cursor: pointer;
z-index: 110;
fill: #0044ff;
filter: drop-shadow(0 0 8px #0022aa);
transition: transform 0.3s ease;
}
#settings-btn:hover { transform: rotate(90deg); fill: #00d2ff; }
/* Painel Único Adaptável (Glassmorphism) */
#main-panel {
position: absolute;
top: 60px;
right: 15px;
width: 260px;
max-width: calc(100vw - 30px);
background: rgba(0, 5, 15, 0.85);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(0, 102, 255, 0.3);
border-radius: 12px;
padding: 15px;
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.9);
display: none;
z-index: 100;
max-height: calc(100vh - 80px);
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: #0044ff transparent;
}
#main-panel.active { display: block; animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
h2 { margin: 0 0 12px 0; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; text-align: center; border-bottom: 1px solid rgba(0, 102, 255, 0.2); padding-bottom: 8px; }
.view-content { display: none; }
.view-content.active { display: block; }
.control-group { margin-bottom: 10px; }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
label { display: block; font-size: 9px; margin-bottom: 3px; opacity: 0.7; text-transform: uppercase; }
input[type="range"] {
width: 100%; cursor: pointer; accent-color: #0066ff;
background: rgba(0, 102, 255, 0.1); border-radius: 5px; height: 3px; -webkit-appearance: none;
}
input[type="color"] { border: none; width: 22px; height: 22px; cursor: pointer; background: none; padding: 0; }
button {
background: rgba(0, 102, 255, 0.15); border: 1px solid rgba(0, 162, 255, 0.3);
color: #00d2ff; padding: 6px; border-radius: 4px; cursor: pointer;
font-size: 9px; text-transform: uppercase; width: 100%; transition: all 0.2s;
}
button:hover { background: rgba(0, 102, 255, 0.3); border-color: #00d2ff; }
/* Estilos dos Slots de Memória */
.slot-item {
display: grid; grid-template-columns: 35px 1fr 1fr; gap: 5px;
align-items: center; margin-bottom: 6px; padding-bottom: 6px;
border-bottom: 1px solid rgba(0, 102, 255, 0.1);
}
.slot-num { font-size: 10px; opacity: 0.6; }
.btn-save { background: rgba(0, 255, 120, 0.05); border-color: rgba(0, 255, 120, 0.2); }
.btn-load { background: rgba(0, 120, 255, 0.05); border-color: rgba(0, 120, 255, 0.2); }
.slot-empty { opacity: 0.3; pointer-events: none; }
#ui-hint {
position: absolute; bottom: 15px; left: 15px; color: #0044ff;
pointer-events: none; text-transform: uppercase; letter-spacing: 1.5px;
font-size: 9px; opacity: 0.5;
}
</style>
</head>
<body>
<div id="ui-hint">Arraste para rodar • Pinça/Scroll para zoom</div>
<svg id="settings-btn" viewBox="0 0 24 24" onclick="toggleMainPanel()">
<path d="M12 15a3 3 0 100-6 3 3 0 000 6z" />
<path d="M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-2 2 2 2 0 01-2-2v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83 0 2 2 0 010-2.83l.06-.06a1.65 1.65 0 00.33-1.82 1.65 1.65 0 00-1.51-1H3a2 2 0 01-2-2 2 2 0 012-2h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 010-2.83 2 2 0 012.83 0l.06.06a1.65 1.65 0 001.82.33H9a1.65 1.65 0 001-1.51V3a2 2 0 012-2 2 2 0 012 2v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 0 2 2 0 010 2.83l-.06.06a1.65 1.65 0 00-.33 1.82V9a1.65 1.65 0 001.51 1H21a2 2 0 012 2 2 2 0 01-2 2h-.09a1.65 1.65 0 00-1.51 1z" />
</svg>
<div id="main-panel">
<!-- VISTA: PARÂMETROS -->
<div id="view-settings" class="view-content active">
<h2>Configurações</h2>
<div class="control-group">
<label>Cores</label>
<div class="control-row">
<input type="color" id="p-col1" value="#000033">
<input type="color" id="p-col2" value="#00d2ff">
</div>
</div>
<div class="control-group">
<label>Giro Mandala</label>
<input type="range" id="p-m-speed" min="0" max="5" step="0.1" value="1.5">
</div>
<div class="control-group">
<label>Ritmo Fractal</label>
<input type="range" id="p-k-speed" min="0" max="5" step="0.1" value="1.0">
</div>
<div class="control-group">
<label>Velocidade Ondas</label>
<input type="range" id="p-speed" min="0" max="5" step="0.1" value="2.5">
</div>
<div class="control-group">
<label>Complexidade</label>
<input type="range" id="p-complexity" min="1" max="5" step="1" value="3">
</div>
<div class="control-group">
<label>Brilho (Glow)</label>
<input type="range" id="p-glow" min="0.1" max="2.0" step="0.05" value="1.0">
</div>
<div class="control-group">
<label>Escala</label>
<input type="range" id="p-scale" min="1" max="4" step="0.1" value="1.9">
</div>
<div class="control-group">
<label>Lados (Simetria)</label>
<input type="range" id="p-slices" min="3" max="15" step="1" value="5">
</div>
<div class="control-group">
<label>Rotação 3D</label>
<input type="range" id="p-rot" min="0" max="4" step="0.1" value="1.2">
</div>
<button onclick="switchView('view-presets')">Slots de Memória (1-10)</button>
</div>
<!-- VISTA: PRESETS (SLOTS) -->
<div id="view-presets" class="view-content">
<h2>Gestão de Memória</h2>
<div id="slots-list"></div>
<button onclick="switchView('view-settings')" style="margin-top: 10px; background: rgba(0, 50, 150, 0.4);">Voltar aos Ajustes</button>
</div>
</div>
<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.js"></script>
<script id="vertexShader" type="x-shader/x-vertex">
varying vec3 vNormal;
varying vec3 vLocalPos;
void main() {
vNormal = normalize(normal);
vLocalPos = position;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
</script>
<script id="fragmentShader" type="x-shader/x-fragment">
uniform float u_time;
uniform float u_mandala_time;
uniform float u_kaleido_time;
uniform float u_complexity;
uniform float u_glow;
uniform float u_scale;
uniform float u_slices;
uniform vec3 u_color1;
uniform vec3 u_color2;
varying vec3 vNormal;
varying vec3 vLocalPos;
#define PI 3.14159265359
vec3 getPalette(float t) {
vec3 black = vec3(0.0, 0.0, 0.0);
vec3 col = mix(black, u_color1, smoothstep(0.0, 0.5, t));
col = mix(col, u_color2, smoothstep(0.3, 1.0, t));
return col;
}
void main() {
vec3 normal = normalize(vNormal);
vec3 helper = abs(normal.y) < 0.99 ? vec3(0.0, 1.0, 0.0) : vec3(1.0, 0.0, 0.0);
vec3 tangent = normalize(cross(normal, helper));
vec3 bitangent = cross(normal, tangent);
vec2 uv = vec2(dot(vLocalPos, tangent), dot(vLocalPos, bitangent)) * u_scale;
vec2 uv0 = uv;
vec3 finalColor = vec3(0.0);
for (float i = 0.0; i < 5.0; i++) {
if (i >= u_complexity) break;
float a = atan(uv.y, uv.x) + u_mandala_time * (0.3 + i * 0.15);
float r = length(uv);
float sliceSize = (2.0 * PI) / u_slices;
float foldA = mod(a, sliceSize) - sliceSize * 0.5;
foldA = abs(foldA);
uv = vec2(cos(foldA), sin(foldA)) * r;
uv = fract(uv * (1.5 + 0.2 * sin(u_kaleido_time * 0.4))) - 0.5;
float d = length(uv) * exp(-length(uv0));
vec3 col = getPalette(fract(length(uv0) * 0.5 + i * 0.2));
d = sin(d * 12.0 - u_time * 3.0) / 12.0;
d = abs(d);
d = pow(0.012 * u_glow / d, 1.1);
finalColor += col * d;
}
float r0 = length(uv0);
for(float j = 1.0; j <= 2.0; j++) {
float ring = smoothstep(0.03, 0.0, abs(r0 - j * 0.18) - 0.01 * sin(u_time * 6.0));
finalColor += u_color1 * ring * (0.8 / j);
}
finalColor += u_color2 * smoothstep(0.09, 0.0, r0) * 1.5;
finalColor *= smoothstep(1.5, 0.5, r0) * 0.5 + 0.5;
gl_FragColor = vec4(clamp(finalColor, 0.0, 1.0), 1.0);
}
</script>
<script>
// --- LOGICA DE UI E PERSISTENCIA ---
const PRESET_KEY = 'mandala_slot_v2_';
function toggleMainPanel() {
document.getElementById('main-panel').classList.toggle('active');
}
function switchView(viewId) {
document.querySelectorAll('.view-content').forEach(v => v.classList.remove('active'));
document.getElementById(viewId).classList.add('active');
if(viewId === 'view-presets') renderSlots();
}
function saveToSlot(id) {
const data = {
c1: document.getElementById('p-col1').value,
c2: document.getElementById('p-col2').value,
ms: document.getElementById('p-m-speed').value,
ks: document.getElementById('p-k-speed').value,
s: document.getElementById('p-speed').value,
cp: document.getElementById('p-complexity').value,
g: document.getElementById('p-glow').value,
sc: document.getElementById('p-scale').value,
sl: document.getElementById('p-slices').value,
r: document.getElementById('p-rot').value
};
localStorage.setItem(PRESET_KEY + id, JSON.stringify(data));
renderSlots();
}
function loadFromSlot(id) {
const raw = localStorage.getItem(PRESET_KEY + id);
if (!raw) return;
const d = JSON.parse(raw);
document.getElementById('p-col1').value = d.c1;
document.getElementById('p-col2').value = d.c2;
document.getElementById('p-m-speed').value = d.ms;
document.getElementById('p-k-speed').value = d.ks;
document.getElementById('p-speed').value = d.s;
document.getElementById('p-complexity').value = d.cp;
document.getElementById('p-glow').value = d.g;
document.getElementById('p-scale').value = d.sc;
document.getElementById('p-slices').value = d.sl;
document.getElementById('p-rot').value = d.r;
}
function renderSlots() {
const container = document.getElementById('slots-list');
container.innerHTML = '';
for (let i = 1; i <= 10; i++) {
const hasData = localStorage.getItem(PRESET_KEY + i);
const item = document.createElement('div');
item.className = 'slot-item';
item.innerHTML = `
<div class="slot-num">${i}</div>
<button class="btn-save" onclick="saveToSlot(${i})">Salvar</button>
<button class="btn-load ${!hasData ? 'slot-empty' : ''}" onclick="loadFromSlot(${i})">${hasData ? 'Abrir' : '---'}</button>
`;
container.appendChild(item);
}
}
function hexToRgb(hex) {
const r = parseInt(hex.slice(1, 3), 16) / 255;
const g = parseInt(hex.slice(3, 5), 16) / 255;
const b = parseInt(hex.slice(5, 7), 16) / 255;
return new THREE.Vector3(r, g, b);
}
// --- THREE.JS LOGIC ---
window.onload = function() {
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(0, 0, 5);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
document.body.appendChild(renderer.domElement);
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.08;
const geometry = new THREE.DodecahedronGeometry(1.6, 0);
const uniforms = {
u_time: { value: 0.0 }, u_mandala_time: { value: 0.0 }, u_kaleido_time: { value: 0.0 },
u_complexity: { value: 3.0 }, u_glow: { value: 1.0 }, u_scale: { value: 1.9 },
u_slices: { value: 5.0 }, u_color1: { value: new THREE.Vector3() }, u_color2: { value: new THREE.Vector3() }
};
const material = new THREE.ShaderMaterial({
uniforms: uniforms,
vertexShader: document.getElementById('vertexShader').textContent,
fragmentShader: document.getElementById('fragmentShader').textContent,
side: THREE.FrontSide
});
const mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
let lastTime = 0, accT = 0, accM = 0, accK = 0;
function animate(now) {
requestAnimationFrame(animate);
const dt = (now - lastTime) * 0.001;
lastTime = now;
const s = parseFloat(document.getElementById('p-speed').value);
const ms = parseFloat(document.getElementById('p-m-speed').value);
const ks = parseFloat(document.getElementById('p-k-speed').value);
const rot = parseFloat(document.getElementById('p-rot').value);
accT += dt * s;
accM += dt * ms;
accK += dt * ks;
uniforms.u_time.value = accT;
uniforms.u_mandala_time.value = accM;
uniforms.u_kaleido_time.value = accK;
uniforms.u_complexity.value = parseFloat(document.getElementById('p-complexity').value);
uniforms.u_glow.value = parseFloat(document.getElementById('p-glow').value);
uniforms.u_scale.value = parseFloat(document.getElementById('p-scale').value);
uniforms.u_slices.value = parseFloat(document.getElementById('p-slices').value);
uniforms.u_color1.value.copy(hexToRgb(document.getElementById('p-col1').value));
uniforms.u_color2.value.copy(hexToRgb(document.getElementById('p-col2').value));
const tRot = now * 0.0004 * rot;
mesh.rotation.x = Math.sin(tRot * 0.7) * 0.4 + Math.cos(tRot * 0.3) * 0.2;
mesh.rotation.y = Math.sin(tRot * 0.5) * 0.5 + Math.cos(tRot * 0.8) * 0.3;
mesh.rotation.z += 0.002 * rot;
controls.update();
renderer.render(scene, camera);
}
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
animate(0);
};
</script>
</body>
</html>