Generátor 360° Ozvučnice body { margin: 0; overflow: hidden; background: #0a0b0d; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: white; } #canvas-container { width: 100vw; height: 100vh; position: absolute; top: 0; left: 0; } #gui-container { position: absolute; top: 15px; right: 15px; z-index: 10; } #stats-panel { position: absolute; bottom: 20px; left: 20px; z-index: 10; background: rgba(15, 15, 20, 0.85); border-left: 3px solid #bf00ff; padding: 15px 20px; border-radius: 4px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); backdrop-filter: blur(5px); width: 260px; pointer-events: none; } .stat-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; } .stat-label { color: #8899aa; } .stat-value { font-weight: bold; font-family: monospace; font-size: 14px; } h3 { margin: 0 0 15px 0; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: #bf00ff; border-bottom: 1px solid #333; padding-bottom: 5px; } { "imports": { "three": "https://unpkg.com/three@0.160.0/build/three.module.js", "three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/" } }

Live Akustické Dáta

Vnútorný objem: -- L
Max. Šírka: -- mm
Celková Výška: -- mm
Status Objemu: OK
import * as THREE from 'three'; import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js'; import { GUI } from 'three/addons/libs/lil-gui.module.min.js'; // --- 1. ZÁKLADNÉ NASTAVENIE SCÉNY --- const container = document.getElementById('canvas-container'); const scene = new THREE.Scene(); scene.fog = new THREE.FogExp2(0x0a0b0d, 0.015); const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 100); camera.position.set(0, 1.5, 6); const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); renderer.toneMapping = THREE.ACESFilmicToneMapping; renderer.toneMappingExposure = 1.2; container.appendChild(renderer.domElement); const controls = new OrbitControls(camera, renderer.domElement); controls.enableDamping = true; // Vypol som auto-rotáciu kamery, budeme rotovať priamo s objektom! controls.autoRotate = false; controls.target.set(0, 1.5, 0); // Osvetlenie const pmremGenerator = new THREE.PMREMGenerator(renderer); scene.environment = pmremGenerator.fromScene(new RoomEnvironment(), 0.04).texture; const keyLight = new THREE.DirectionalLight(0xffffff, 2.0); keyLight.position.set(3, 5, 3); scene.add(keyLight); const rimLight = new THREE.DirectionalLight(0xbf00ff, 2.0); rimLight.position.set(-3, 2, -4); scene.add(rimLight); const bottomLight = new THREE.PointLight(0xffaa00, 1.5, 5); bottomLight.position.set(0, -1, 0); scene.add(bottomLight); // Vytvoríme hlavnú skupinu, ktorou budeme otáčať const productGroup = new THREE.Group(); scene.add(productGroup); // --- 2. VIZUÁLNY REFERENČNÝ MENIČ (Zalícovaný, prechod na hranu) --- const driverGroup = new THREE.Group(); // 1. Vonkajší montážny prstenec (lícuje s dierou ozvučnice na hrúbku steny) const frameMesh = new THREE.Mesh( new THREE.CylinderGeometry(0.55, 0.55, 0.02, 64), new THREE.MeshStandardMaterial({ color: 0x111111, roughness: 0.8 }) ); frameMesh.position.y = 0.01; // 2. Kôš / Membrána (smeruje kužeľom k zemi) const coneMesh = new THREE.Mesh( new THREE.ConeGeometry(0.46, 0.25, 64), new THREE.MeshStandardMaterial({ color: 0x050505, roughness: 0.9 }) ); coneMesh.rotation.x = Math.PI; coneMesh.position.y = -0.105; // 3. Magnet (schovaný vo vnútri) const magnetMesh = new THREE.Mesh( new THREE.CylinderGeometry(0.35, 0.35, 0.3, 32), new THREE.MeshStandardMaterial({ color: 0x222222, metalness: 0.5 }) ); magnetMesh.position.y = 0.17; // 4. Stredový "Phase Plug" detail const plugMesh = new THREE.Mesh( new THREE.ConeGeometry(0.08, 0.15, 32), new THREE.MeshStandardMaterial({ color: 0x333333, metalness: 0.8, roughness: 0.2 }) ); plugMesh.rotation.x = Math.PI; plugMesh.position.y = -0.1; driverGroup.add(frameMesh); driverGroup.add(coneMesh); driverGroup.add(magnetMesh); driverGroup.add(plugMesh); productGroup.add(driverGroup); // Pridáme do hlavnej skupiny // Nosný Kábel const wireMesh = new THREE.Mesh( new THREE.CylinderGeometry(0.04, 0.04, 5, 16), new THREE.MeshStandardMaterial({ color: 0x050505, roughness: 0.9 }) ); productGroup.add(wireMesh); // Pridáme do hlavnej skupiny // --- 3. PARAMETRE A MATERIÁL OZVUČNICE --- const params = { seed: 4285936, // Východzí seed color: 0xe0e0e0, roughness: 0.2, metalness: 0.1, autoMorph: false, morphSpeed: 0.08, rotationSpeed: 0.005, // Rýchlosť otáčania objektu generate: function() { // Seed zväčšený do 10 miliónov (presne 10 000 000) params.seed = Math.floor(Math.random() * 10000000); gui.controllersRecursive().forEach(c => c.updateDisplay()); setTargetShape(params.seed); } }; const material = new THREE.MeshStandardMaterial({ color: params.color, roughness: params.roughness, metalness: params.metalness, side: THREE.DoubleSide }); let speakerMesh = new THREE.Mesh(new THREE.BufferGeometry(), material); productGroup.add(speakerMesh); // Pridáme do hlavnej skupiny // --- 4. GENERATÍVNA MATEMATIKA (S UFO previsom) --- let currentPoints = []; let targetPoints = []; let isMorphing = false; let lastAutoMorph = 0; const NUM_POINTS = 60; function mulberry32(a) { return function() { var t = a += 0x6D2B79F5; t = Math.imul(t ^ t >>> 15, t | 1); t ^= t + Math.imul(t ^ t >>> 7, t | 61); return ((t ^ t >>> 14) >>> 0) / 4294967296; } } function generateProfile(seed) { const rand = mulberry32(seed); const pts = []; const wallThickness = 0.05; const driverR = 0.5; const H = 1.2 + rand() * 1.5; const maxR = 1.0 + rand() * 1.8; // 1. UCHYTENIE MENIČA (Žiadny límec) pts.push(new THREE.Vector2(driverR + wallThickness, 0.0)); // 2. AKUSTICKÁ ZÓNA A PREVYS const type = Math.floor(rand() * 3); if (type === 0) { pts.push(new THREE.Vector2(maxR * 0.7, 0.15)); pts.push(new THREE.Vector2(maxR, H * 0.4)); pts.push(new THREE.Vector2(maxR * 0.4, H * 0.7)); } else if (type === 1) { pts.push(new THREE.Vector2(driverR + 0.4, 0.15)); pts.push(new THREE.Vector2(maxR, H * 0.5)); pts.push(new THREE.Vector2(maxR * 0.6, H * 0.8)); } else { pts.push(new THREE.Vector2(driverR + 0.2, 0.25)); pts.push(new THREE.Vector2(maxR, H * 0.6)); pts.push(new THREE.Vector2(maxR * 0.3, H * 0.85)); } // 3. UCHYTENIE KÁBLA pts.push(new THREE.Vector2(0.15, H - 0.15)); pts.push(new THREE.Vector2(0.04, H)); return pts; } function calculateVolume(points) { let vol = 0; const wall = 0.05; for(let i = 0; i < points.length - 1; i++) { let r1 = Math.max(0, points[i].x - wall); let r2 = Math.max(0, points[i+1].x - wall); let h = points[i+1].y - points[i].y; vol += (Math.PI * h / 3.0) * (r1*r1 + r1*r2 + r2*r2); } return vol; } function enforceAcousticVolume(points) { const minVol = 0.5; let currentVol = calculateVolume(points); let wasScaled = false; if (currentVol < minVol) { const scale = Math.sqrt(minVol / currentVol); for(let i = 1; i { if(p.x > maxX) maxX = p.x; if(p.y > maxY) maxY = p.y; }); document.getElementById('ui-width').innerText = (maxX * 2 * 100).toFixed(0) + " mm"; document.getElementById('ui-height').innerText = (maxY * 100).toFixed(0) + " mm"; const statusEl = document.getElementById('ui-status'); if(wasScaled) { statusEl.innerText = "KORIGOVANÉ (zväčšené pre basy)"; statusEl.style.color = "#ffaa00"; } else { statusEl.innerText = "OK (prirodzený objem)"; statusEl.style.color = "#4CAF50"; } wireMesh.position.y = maxY + 2.5; } function setTargetShape(seed) { let rawPoints = generateProfile(seed); let check = enforceAcousticVolume(rawPoints); const spline = new THREE.SplineCurve(check.pts); targetPoints = spline.getPoints(NUM_POINTS); const finalVol = calculateVolume(targetPoints); updateUI(targetPoints, finalVol, check.wasScaled); if (currentPoints.length === 0) { currentPoints = targetPoints.map(p => p.clone()); rebuildMesh(currentPoints); } else { isMorphing = true; } } function rebuildMesh(pointsArray) { const geo = new THREE.LatheGeometry(pointsArray, 64); speakerMesh.geometry.dispose(); speakerMesh.geometry = geo; } // --- 5. GUI NASTAVENIA --- const gui = new GUI({ container: document.getElementById('gui-container'), width: 300 }); gui.title("Ovládanie"); // Seed zväčšený do 10 000 000 gui.add(params, 'seed', 1, 10000000, 1).name('Architektonický Seed').onChange(v => setTargetShape(v)).listen(); gui.add(params, 'generate').name('🎲 Generovať Nový Tvar'); gui.add(params, 'autoMorph').name('✨ Auto-Prehrávanie'); gui.add(params, 'rotationSpeed', 0, 0.05).name('Rýchlosť otáčania'); const matFolder = gui.addFolder('Materiál Ozvučnice'); matFolder.addColor(params, 'color').name('Farba').onChange(v => material.color.setHex(v)); matFolder.add(params, 'roughness', 0, 1).name('Matnosť').onChange(v => material.roughness = v); matFolder.add(params, 'metalness', 0, 1).name('Kovovosť').onChange(v => material.metalness = v); setTargetShape(params.seed); // --- 6. ANIMAČNÁ SLUČKA --- window.addEventListener('resize', () => { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); }); function animate() { requestAnimationFrame(animate); controls.update(); // NOVINKA: Plynulé otáčanie samotného objektu productGroup.rotation.y += params.rotationSpeed; if (isMorphing) { let done = true; for (let i = 0; i 0.001) { done = false; } } rebuildMesh(currentPoints); if (done) isMorphing = false; } if (params.autoMorph && !isMorphing) { const now = Date.now(); if (now - lastAutoMorph > 2500) { params.generate(); lastAutoMorph = now; } } renderer.render(scene, camera); } animate();