Refactoring: add Vite to serve JS modules

This commit is contained in:
Dejvino
2025-11-16 13:20:33 +01:00
parent 75c87c9d03
commit 1c2a3c6d3a
17 changed files with 1506 additions and 332 deletions
+8 -5
View File
@@ -1,5 +1,8 @@
import * as THREE from 'three';
import { state } from './state.js';
// --- Utility: Random Color (seeded) ---
function getRandomColor() {
export function getRandomColor() {
const hue = seededRandom();
const saturation = 0.6 + seededRandom() * 0.4;
const lightness = 0.3 + seededRandom() * 0.4;
@@ -11,20 +14,20 @@ function getRandomColor() {
* @param {number} degrees
* @returns {number}
*/
function degToRad(degrees) {
export function degToRad(degrees) {
return degrees * (Math.PI / 180);
}
// --- Seedable Random Number Generator (Mulberry32) ---
function seededRandom() {
let t = seed += 0x6D2B79F5;
export function seededRandom() {
let t = state.seed += 0x6D2B79F5;
t = Math.imul(t ^ t >>> 15, t | 1);
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
return ((t ^ t >>> 14) >>> 0) / 4294967296;
}
// --- Helper function to format seconds into MM:SS ---
function formatTime(seconds) {
export function formatTime(seconds) {
if (isNaN(seconds) || seconds === Infinity || seconds < 0) return '--:--';
const minutes = Math.floor(seconds / 60);
const remainingSeconds = Math.floor(seconds % 60);