How bgstaal/multiplewindow3dscene works
Project type and purpose
• This is a front-end web application/demo that runs entirely in the browser. It creates and renders a Three.js-based 3D scene across multiple windows and synchronizes their state via localStorage. There is no backend or server component—everything lives in HTML, JavaScript, and the browser’s storage APIs.
File structure
• index.html: the single entry point, pulls in Three.js and your two scripts.
• three-LICENSE: Three.js license file.
• WindowManager.js: a class that opens new windows, manages their lifecycle, and synchronizes shared state through localStorage and storage events.
• main.js: bootstraps the 3D scene, hooks into WindowManager, handles render loop, resize events, and input.
README for insights
• Confirms the focus on “multiple browser windows,” “scene synchronization,” and “dynamic window management” via localStorage.
• No server, no database; purely in-browser.
• Technologies: HTML, Three.js (r124), ES6 modules or vanilla scripts, localStorage API, window.open and storage events for cross-window comms.
Main components
a. Browser Windows (multiple instances)
• Each window runs the same code: index.html → Three.js + main.js + WindowManager.js
b. Module/Script Layers inside each window
• Three.js library (three.r124.min.js)
• main.js (scene init, render loop)
• WindowManager.js (handles open/close, localStorage sync)
c. Shared State Layer
• Browser localStorage
• StorageEvent API for broadcasting changes
d. User interactions / DOM events
• UI calls WindowManager to open/close windows, or interacts with the 3D scene
e. Render Engine
• Three.js WebGLRenderer drawing to each window’s canvas element
Architectural patterns and principles
• Single-page application pattern across multiple windows
• Publish/subscribe via the browser’s storage event bus
• Modular separation: rendering layer (Three.js) vs. window orchestration (WindowManager) vs. state sync (localStorage)
Relevant technologies/frameworks
• Three.js r124
• ES6 or vanilla JavaScript modules
• HTML5 localStorage and StorageEvent
• Browser window.open() and window lifecycle events
Diagramming details
• Clear labels on every component (e.g., “Three.js Renderer,” “WindowManager,” “localStorage”)
• Arrowheads showing direction of data or event flow