How ohzinteractive/core works
Project Type and Purpose
• This is a core library (“OHZI Core”) for WebGL development.
• Its purpose is to provide building blocks that speed up the development of complex WebGL applications.
• It works in complementary fashion with existing libraries such as three.js and PIT.
Analyzing the File Structure
• The top-level directory contains configuration files (like package.json, rollup.config.mjs, and TypeScript declaration files) as well as the README, indicating a well-organized library.
• The “src” folder is the heart of the library. Inside, you have numerous subdirectories dedicated to various aspects of rendering:
– Base application and browser integration (e.g., BaseApplication.js, Browser.js).
– Camera handling with different camera types (PerspectiveCamera, OrthographicCamera) and camera management.
– Resource loading and asset management, found under “loaders”, “resource_loader”, and “assets_loader”.
– Rendering engine components such as RenderLoop, various render modes (in the “render_mode” folder) and shader/material definitions (in the “materials” and “shaders” folders).
– UI and view components (under “ui” and “view_components”) that manage user interface elements and transitions.
– Specialized functionality like GPU particle systems, static batchers, and action sequencers to handle animations or state transitions.
– Utility functions, helpers, and data textures, along with editor and debugging tools.
• The library is split into modules that separately handle input, graphics, resource management, and shader management, among others.
Key Components
a. Core Application & Initialization:
• BaseApplication.js, Initializer.js, and Browser.js define the core setup.
• They likely establish the rendering context and manage overall application life-cycle.
b. Rendering Engine:
• RenderLoop.js, RenderLayers, and the “render_mode” modules (NormalRender, DeferredRender, BloomRender, etc.) form the backbone of WebGL rendering.
• Materials and shaders (located in “materials” and “shaders”) implement various visual effects.
c. Scene and Camera Management:
• SceneManager.js and different camera modules (PerspectiveCamera, OrthographicCamera, CameraManager.js) handle different viewpoints and scene composition.
d. Asset and Resource Loaders:
• A set of loaders (in “loaders” and “resource_loader”) ensure asynchronous loading of textures, models, fonts, and sounds.
e. UI and View Components:
• UI.js, view_components, and the “editor” folder provide interactive elements for editing and scene transitions.
f. Specialized Modules:
• Action Sequencer (action_sequencer folder) for managing animations and events.
• GPU particles (gpu_particles) and static batcher for performance optimizations.
• Utilities across the project that support geometry, easing, and various common operations.
Architectural Relationships and Patterns
• The library is organized in a modular fashion. Each module (rendering, loading, UI, etc.) should be represented as a distinct component that interacts with the central application core.
• Many modules follow separation-of-concerns by isolating specific tasks: for instance, the rendering modules only handle graphics, while asset loaders deal with external resources.