"use client"; import { useState, useRef, useEffect } from "react"; export default function XgridsWizard() { const [files, setFiles] = useState([]); const [status, setStatus] = useState("Waiting for upload..."); const [isProcessing, setIsProcessing] = useState(false); const workerRef = useRef(null); useEffect(() => { const worker = new Worker( new URL("./workers/converter.worker.ts", import.meta.url), ); workerRef.current = worker; worker.onmessage = (e) => { const { type, message, data } = e.data; if (type === "LOG") setStatus(message); if (type === "DONE") { setIsProcessing(false); setStatus("Pipeline Complete!"); data.files.forEach((file: { name: string; blob: Blob }) => { downloadFile(file.blob, file.name); }); } }; return () => worker.terminate(); }, []); const downloadFile = (blob: Blob, name: string) => { const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = name; a.click(); URL.revokeObjectURL(url); }; const handleFolderUpload = (e: React.ChangeEvent) => { const uploadedFiles = Array.from(e.target.files || []); if (uploadedFiles.length > 0) { setFiles(uploadedFiles); setStatus(`Loaded ${uploadedFiles.length} files. Ready to convert.`); } }; const startPipeline = async () => { if (!files.length || !workerRef.current) return; setIsProcessing(true); setStatus("Preparing files for Worker..."); const mainLcc = files.find((f) => f.name.toLowerCase().endsWith(".lcc")); const filesData = await Promise.all( files.map(async (f) => ({ name: f.name, buffer: await f.arrayBuffer(), })), ); // Send EVERYTHING to the worker. // The worker will now handle Collision, Environment, SOG, and LODs. workerRef.current.postMessage( { type: "START_CONVERSION", filesData, mainLccName: mainLcc?.name, fileName: mainLcc?.name.replace(".lcc", ""), }, filesData.map((f) => f.buffer), ); }; return (

Xgrids Scene Wizard

Targeting collision.lci + scene.lcc

{"> "} {status}

); }