Bring your local webcam into Garry’s Mod with a tiny, self‑hosted Node.js server.
Use it inside a DHTML panel or render it onto a 3D2D surface with GLua — all privacy‑first.
Getting Started • Requirements • Security • Troubleshooting • Roadmap • Contributing
- Shows your local webcam feed inside Garry’s Mod.
- Runs a tiny Node.js server that you host yourself.
- Can be embedded in a DHTML panel or rendered onto a 3D2D surface using GLua.
- Privacy‑first: your camera never touches third‑party services unless you expose the server.
- Garry’s Mod (client)
- Node.js 18+ (recommended)
- A modern webcam
- (Optional) HTTPS certificate for camera permissions on some systems
Note
Chromium/CEF usually requires a secure context for getUserMedia.
localhost is generally treated as secure; for LAN use HTTPS.
git clone https://github.com/maryblackfild/webcam_in_gmod.git
cd webcam_in_gmod
npm install# .env
PORT=3000 # change if you like
HOST=127.0.0.1 # 0.0.0.0 to allow LAN
ORIGIN=* # lock this down to your client if needed# If package.json defines a start script:
npm start
# Otherwise:
node server.jsYou should see the server listening (e.g. http://127.0.0.1:3000).
- Local-first: keep
HOST=127.0.0.1for single‑PC use. Use0.0.0.0only when you need LAN access. - Restrict origins: set
ORIGINto your exact URL if you add CORS. - HTTPS is strongly recommended when accessing from devices other than
localhost.
Quick self-signed HTTPS (optional)
mkdir -p certs
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout certs/key.pem -out certs/cert.pem \
-subj "/CN=localhost"Then (if your server.js supports it) run with HTTPS env flags, or adapt server.js to use Node’s https.createServer with those certs.
Tip
Work through these from top to bottom—most issues are permission or context related.
- Black/empty video → ensure camera permission is granted. Use HTTPS if not on
localhost. - CEF prompt not visible → reload the DHTML, or temporarily open the page in an external browser to approve permissions first.
- Nothing loads → verify the Node server is running and the URL/port matches your
.env. - LAN clients can’t see it → set
HOST=0.0.0.0, open the firewall for the port, and browse tohttp://PC_IP:PORTfrom GMod. - Performance → keep panel dimensions reasonable (e.g., 640×360–1280×720).
- Toggleable audio capture (mic) with mute button
- UI overlay: FPS/readout, camera switcher, quality slider
- Server auth for exposed instances (simple token/Bearer)
- Multi‑client rooms with per‑player visibility
- OBS/NDI passthrough mode for streamers
PRs and issues are welcome. (keeplove)