How hytopiagg/world-editor works
Project type and purpose
• This is a single-page, client-side world editor built with Create React App. Its purpose is to let users import or procedurally generate Minecraft-style worlds in the browser, view and manipulate blocks, models, and textures in 3D, and export or save their creations.
File structure
• Top-level:
• package.json, .env, build scripts (scripts/generate-model-manifest.js) – typical CRA config
• public/ – static assets (blocks, models, sounds, UI images, certificates) served by the web server
• src/ – application source code
• src/index.js + App.js – React entry point and root component
• src/css/ & src/images – static styling and images consumed by components
• src/js/ – the core JavaScript modules, organized by function:
• components/ – React UI panel, toolbar, editors, wizard steps
• tools/ – user actions (GroundTool, WallTool, SeedGeneratorTool, etc.)
• managers/ – high-level orchestration (BlockTypesManager, SpatialGridManager)
• utils/ – helper libraries (PerlinNoise, NBTParser, AnvilParser)
• workers/ – Web Workers for CPU-intensive tasks (SpatialHashWorker, minecraftParserWorker)
• DatabaseManager.js – in-browser storage abstraction (IndexedDB or similar)
• EnvironmentBuilder.js, TerrainBuilder.js, Camera.js, Sound.js – 3D scene and media orchestration
README for additional insights
• Confirms Create React App, static hosting, development vs. production builds. No server-side code beyond static file serving.
Main components & their interactions
a. Frontend React Application
– React UI Layer (components/*) orchestrates user interactions, renders toolbars, sidebars, modals.
– Uses CSS modules (src/css) for styling.
b. Asset & Data Layer
– Asset Loader (public/assets + generate-model-manifest.js) fetches glTF, textures, sounds.
– DatabaseManager persists user sessions, undo history, imported world data.
c. Engine Layer
– EnvironmentBuilder, TerrainBuilder, ChunkManager build and update 3D scene graph.
– Camera controls via Camera.js.
– Sound manager (Sound.js) streams audio assets.
d. Tools & Managers
– ToolManager delegates pointer events to specific tools (e.g., Block placement, PipeTool, SchematicPlacementTool).
– BlockTypesManager and SpatialGridManager maintain metadata and spatial partitioning for fast lookups.
e. Web Workers
– spatialHashWorker: builds/queries spatial hash grid off main thread.
– minecraftParserWorker: parses NBT/Anvil files into world data asynchronously.
f. External Libraries & Frameworks
– React, React-DOM, Webpack (CRA), Three.js (implied by glTF usage), Web Workers API, possibly Tone.js or Web Audio API for sounds.
Architectural patterns & design principles
• Modular, feature-based code organization
• Separation of Concerns: UI (React) vs. business logic (managers, tools) vs. rendering engine vs. data parsing (workers)
• Asynchronous parsing and heavy computation offloaded to Web Workers
• In-browser persistence via DatabaseManager (IndexedDB or localStorage)
• Asset pipeline: static assets (public/) + manifest generation script