How gkjohnson/batched-material-properties-demo works
Project type and purpose
• This is a single‐page front-end demo (no backend services) built with three.js.
File structure
• Top level:
• index.html – the HTML container
• index.js – demo entry point, scene setup, animation loop
• three.module.js – three.js core library
• src/ directory: three custom modules
• BatchedPropertiesTexture.js – builds a RGBA texture atlas encoding material properties
• BatchedStandardMaterial.js – extends three.js’ StandardMaterial shader to sample that texture
• RenderTarget2DArray.js – helper to allocate and manage a 2D array render target on the GPU
• No build system: assets are loaded directly by the browser.
Extracted insights from README
• The demo runs entirely in the browser, no server logic.
• It exercises three.js’ BatchedMesh API by providing per‐instance material data via textures.
Main components and their relationships
a. Browser (client)
b. Static host (GitHub Pages or any static web server)
c. Assets loaded by Browser:
• index.html → includes three.module.js & index.js
• JavaScript modules in src/
d. three.js rendering engine
e. Custom modules:
• BatchedPropertiesTexture → constructs data texture
• BatchedStandardMaterial → custom shader logic to read from that texture
• RenderTarget2DArray → manages offscreen GPU buffers if needed
Architectural patterns and design principles
• Modular JS: one file per concern (texture creation, material extension, render target management)
• Data‐driven design: material properties are not hard-coded but loaded from a texture