Skip to content

Commit 287d608

Browse files
committed
feat: WebGL stack at js/webgl, npm regl/twgl, smoke tests and CI
- Rename js/regl to js/webgl; renderer defaults to webgl; URL regl aliases to webgl - Pin regl and twgl in package.json; postinstall vendors to lib/; drop duplicate lib/regl.js - Holoplay forces WebGL when renderer=webgpu would be selected - Playwright: effects, versions, image+local bg, gallery; WebGPU when available - CI runs npm ci, playwright test; module check without clobbering package.json - Track package-lock.json; add RENDERING.md and update README/SECURITY/DEV_README Made-with: Cursor
1 parent e5e70c4 commit 287d608

35 files changed

Lines changed: 11032 additions & 10763 deletions

.github/agents/matrix-rain-operator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ This is a **static ES-module web application** - key architectural points:
8585

8686
### Core Technologies
8787

88-
1. **WebGL Rendering** (`js/regl/`):
88+
1. **WebGL Rendering** (`js/webgl/`):
8989
- Uses REGL functional wrapper
9090
- Shaders in `/shaders` directory (GLSL)
9191
- Main passes: rain computation, bloom effects, final composite
@@ -194,7 +194,7 @@ matrix/
194194
│ ├── main.js # Application bootstrap
195195
│ ├── config.js # URL parameter parsing
196196
│ ├── utils.js # Shared utilities (formatModeName, etc.)
197-
│ ├── regl/ # WebGL implementation
197+
│ ├── webgl/ # WebGL implementation
198198
│ │ ├── main.js # REGL renderer entry
199199
│ │ ├── rainPass.js # Core rain computation
200200
│ │ └── bloomPass.js # Bloom effects

.github/agents/matrix-red-pill-debugger.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ function refactorAllEffects() { ... }
366366
// shaders/rain-pass.glsl
367367
uniform int effectMode; // Added missing uniform
368368

369-
// js/regl/rainPass.js
369+
// js/webgl/rainPass.js
370370
effectMode: config.effect === 'rainbow' ? 1 : 0, // Pass to shader
371371
```
372372

.github/copilot-agents/matrix-rain-operator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ This is a **static ES-module web application** - key architectural points:
8585

8686
### Core Technologies
8787

88-
1. **WebGL Rendering** (`js/regl/`):
88+
1. **WebGL Rendering** (`js/webgl/`):
8989
- Uses REGL functional wrapper
9090
- Shaders in `/shaders` directory (GLSL)
9191
- Main passes: rain computation, bloom effects, final composite
@@ -194,7 +194,7 @@ matrix/
194194
│ ├── main.js # Application bootstrap
195195
│ ├── config.js # URL parameter parsing
196196
│ ├── utils.js # Shared utilities (formatModeName, etc.)
197-
│ ├── regl/ # WebGL implementation
197+
│ ├── webgl/ # WebGL implementation
198198
│ │ ├── main.js # REGL renderer entry
199199
│ │ ├── rainPass.js # Core rain computation
200200
│ │ └── bloomPass.js # Bloom effects

.github/copilot-agents/matrix-red-pill-debugger.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ function refactorAllEffects() { ... }
366366
// shaders/rain-pass.glsl
367367
uniform int effectMode; // Added missing uniform
368368

369-
// js/regl/rainPass.js
369+
// js/webgl/rainPass.js
370370
effectMode: config.effect === 'rainbow' ? 1 : 0, // Pass to shader
371371
```
372372

.github/copilot-instructions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ cp msdfgen/build/msdfgen out/
9696
- `js/config.js` - URL parameter parsing and configuration management
9797
- `js/utils.js` - Shared utility functions (formatModeName, etc.)
9898
- `js/music-integration.js` - Spotify music synchronization
99-
- `js/regl/` - WebGL implementation using REGL library
99+
- `js/webgl/` - WebGL implementation (regl npm runtime, vendored to `lib/regl.min.js`)
100100
- `js/webgpu/` - WebGPU implementation (next-generation graphics)
101101
- `shaders/` - GLSL and WGSL shader source files
102102

103103
### Key Renderer Files
104-
- `js/regl/main.js` - REGL WebGL renderer entry point
104+
- `js/webgl/main.js` - WebGL renderer entry point
105105
- `js/webgpu/main.js` - WebGPU renderer entry point
106-
- `js/regl/rainPass.js` & `js/webgpu/rainPass.js` - Core Matrix rain computation
107-
- `js/regl/bloomPass.js` & `js/webgpu/bloomPass.js` - Glow/bloom effects
106+
- `js/webgl/rainPass.js` & `js/webgpu/rainPass.js` - Core Matrix rain computation
107+
- `js/webgl/bloomPass.js` & `js/webgpu/bloomPass.js` - Glow/bloom effects
108108

109109
### Asset Files
110110
- `assets/` - Matrix fonts (TrueType) and MSDF texture atlases
@@ -168,7 +168,7 @@ npx prettier --write --use-tabs --print-width 160 "js/**/*.js"
168168

169169
### Making Visual Changes
170170
1. **Modify shader code** in `/shaders` directory for rendering effects
171-
2. **Update pass configurations** in `js/regl/` or `js/webgpu/` directories
171+
2. **Update pass configurations** in `js/webgl/` or `js/webgpu/` directories
172172
3. **Test immediately** by refreshing browser - no build step needed
173173
4. **Always validate** with multiple Matrix versions and effects
174174

@@ -236,7 +236,7 @@ The service worker (`service-worker.js`) implements offline PWA functionality:
236236

237237
### Changes Requiring Full Validation
238238
- **Shader files** (`/shaders`): Test all Matrix versions and effects
239-
- **Renderer files** (`js/regl/`, `js/webgpu/`): Test WebGL and WebGPU modes
239+
- **Renderer files** (`js/webgl/`, `js/webgpu/`): Test WebGL and WebGPU modes
240240
- **Config changes** (`js/config.js`): Test URL parameter parsing
241241
- **Main entry points** (`index.html`, `js/main.js`): Full application test
242242
- **Service worker** (`service-worker.js`): Test offline functionality and cache updates
@@ -261,7 +261,7 @@ The service worker (`service-worker.js`) implements offline PWA functionality:
261261

262262
## Browser Compatibility
263263

264-
- **WebGL 2.0**: Widely supported, battle-tested (js/regl/)
264+
- **WebGL 2.0**: Widely supported, battle-tested (`js/webgl/`)
265265
- **WebGPU**: Cutting-edge, modern browsers only (js/webgpu/)
266266
- **Software Fallback**: Works with SwiftShader when hardware acceleration disabled
267267
- **Mobile Support**: Responsive design, touch interactions for effects

.github/workflows/master-branch-protection.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@ jobs:
3434
- name: Validate code formatting with Prettier
3535
run: |
3636
echo "Checking code formatting..."
37-
npx prettier --check --use-tabs --print-width 160 "index.html" "./js/**/*.js" "./lib/gpu-buffer.js" || {
37+
npx prettier --check --use-tabs --print-width 160 "index.html" "./js/**/*.js" "./lib/gpu-buffer.js" "./scripts/**/*.mjs" "./tests/**/*.js" || {
3838
echo "❌ Code formatting check failed!"
39-
echo "Run: npx prettier --write --use-tabs --print-width 160 \"index.html\" \"./js/**/*.js\" \"./lib/gpu-buffer.js\""
39+
echo "Run: npx prettier --write --use-tabs --print-width 160 \"index.html\" \"./js/**/*.js\" \"./lib/gpu-buffer.js\" \"./scripts/**/*.mjs\" \"./tests/**/*.js\""
4040
exit 1
4141
}
4242
echo "✅ Code formatting is correct"
43+
44+
- name: Install dependencies and run automated tests
45+
run: |
46+
npm ci
47+
npx playwright install --with-deps chromium
48+
npm test
4349
4450
- name: Start Matrix application server
4551
run: |
@@ -111,14 +117,11 @@ jobs:
111117
exit 1
112118
fi
113119
114-
# Validate ES6 module syntax by creating a temporary package.json
115-
echo '{"type": "module"}' > package.json
116120
node --check js/main.js
117121
node --check js/config.js
118122
node --check js/effects.js
119-
node --check js/regl/stripePass.js
123+
node --check js/webgl/stripePass.js
120124
node --check js/webgpu/stripePass.js
121-
rm package.json
122125
123126
echo "✅ JavaScript modules are valid"
124127

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ build/
55

66
# Dependencies
77
node_modules/
8-
package-lock.json
98

109
# IDE
1110
.idea/

DEV_README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ float alpha = smoothstep(0.5 - fwidth(distance), 0.5 + fwidth(distance), distanc
7272
- 🔗 [GPU Buffer Management](https://github.com/brendan-duncan/wgsl_reflect) - WGSL shader reflection
7373
- 💡 **Why it matters**: WebGPU provides compute shaders and better performance - essential for real-time particle systems like our rain
7474

75-
### REGL: Functional WebGL
75+
### WebGL path (`js/webgl/`) and regl
7676

77-
- 🔗 [REGL Documentation](https://regl.party/) - WebGL made functional
78-
- 💡 **Philosophy**: Treat graphics as pure functions - given the same inputs, always produce the same output. Very Matrix-like in its deterministic perfection.
77+
- 🔗 [regl on npm](https://www.npmjs.com/package/regl) / [regl docs](https://regl.party/) — the WebGL renderer loads the package output from `lib/regl.min.js` (refreshed by `npm install`).
78+
- 🔗 [RENDERING.md](RENDERING.md) — WebGPU vs WebGL, Holoplay constraints, and twgl for future glue code.
79+
- 💡 **Philosophy**: Treat graphics as pure functions — given the same inputs, always produce the same output. Very Matrix-like in its deterministic perfection.
7980

8081
### Signed Distance Fields in Graphics
8182

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ _Concept_
6262

6363
## About
6464

65-
This project is a web implementation of the raining green code seen in the _Matrix_ franchise. It's built right on top of the functional WebGL wrapper, [REGL](https://regl.party), with beta support for the upcoming graphics API [WebGPU](https://github.com/gpuweb/gpuweb); its previous Three.js version is maintained in a separate branch.
65+
This project is a web implementation of the raining green code seen in the _Matrix_ franchise. The WebGL path ([`js/webgl/`](js/webgl/)) uses the [regl](https://www.npmjs.com/package/regl) package (vendored to `lib/regl.min.js` after install); there is also a [WebGPU](https://github.com/gpuweb/gpuweb) implementation under [`js/webgpu/`](js/webgpu/). See [RENDERING.md](RENDERING.md) for how the two stacks relate. Its previous Three.js version is maintained in a separate branch.
6666

6767
This project runs right in the web browser; you can serve it with any HTTP/HTTPS server, with no additional setup. For example, on a Mac you can point a Terminal shell at a local copy of the project and run a simple HTTP server with Python: `cd /path/to/the/project ; python3 -m http.server`
6868

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ matrix-{version}.zip
114114
├── js/ # JavaScript modules
115115
│ ├── main.js
116116
│ ├── config.js
117-
│ ├── regl/ # WebGL renderer
117+
│ ├── webgl/ # WebGL renderer
118118
│ └── webgpu/ # WebGPU renderer
119119
├── lib/ # Third-party libraries
120120
│ ├── regl.min.js

0 commit comments

Comments
 (0)