How funsoftwaretechologies/planettech works
Main Components
• Core Engine: This is housed in the src/engine folder. It includes modules such as geometry, primitives, quadtree (for LOD), and threading. This core handles the planet generation logic and GPU-intensive calculations.
• Shader System: Found in the src/shaders directory, split between two shader language implementations (TSL and WGSL). These files (like functions.js, noise.js, utils.js) implement procedural noise and other visual effects which are applied by the GPU.
• Utilities: Located in src/utils, these offer support functions and miscellaneous helpers used across the project.
• Examples & Assets: The examples folder contains various demos (HTML, JS examples) that illustrate how to use the library in a simple webpage context. The assets folder holds media resources like logos.
• Project Integration & Configuration: The root directory with index.js, package.json, and additional configuration (like .gitignore, .vscode) files ties everything together.
• Service Worker Integration: The examples/coi-serviceworker.js file indicates that there’s support for progressive loading/offline capabilities through a service worker, which is significant when integrating PlanetTech into a broader application.
Relationships and Interactions
• The Core Engine interacts with the Shader System to efficiently generate and modify visuals on the GPU. For example, the quadtree from the engine drives the level-of-detail mechanisms that feed into shader functions.
• The Utilities support both engine and shader functionalities, providing common functions, error handling, or miscellaneous utilities.
• The examples serve as a front-end demonstration of how to integrate the engine (planet generation) and shaders into an HTML environment, possibly leveraging both THREE.js and React elements.
• For integration in end-user projects, there is an interaction between the library and a React UI (as mentioned in the README) that acts as an editor for planet properties.
• Although the README mentioned that WebWorkers are not required at this stage, there is a _worker.js file indicating that threading or worker processes might be set up for handling complex computations if needed.
Architectural Patterns and Design Principles
• Modularity: The project is cleanly separated into engine, shader, and utilities modules.
• GPU-Centric Design: Emphasize that nearly all heavy computations are offloaded to the GPU via shader code.
• Procedural Generation with Quadtree LOD: This design pattern helps in handling massive scale (from sky to ground) with progressive detail adjustment.
• Separation of Concerns: There is a clear divide between core generation logic (src/engine), rendering effects (src/shaders), and support functions (src/utils).