Skip to content
abbasmir12Public

About

A 3D bomb-defusal game where your real pulse and breathing set the fuse. Stay calm and it slows down, panic and it races. Built with Presage SmartSpectra, Electron and Three.js.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

COLD SWEAT

A 3D bomb-defusal game where your real pulse and breathing set the fuse.

Stay calm and the fuse slows down. Panic and it races.

Built for the Presage SmartSpectra SDK Challenge on DEV.

Watch the demo · Quick start · How it works · Consent and data

Electron Three.js JavaScript Presage SmartSpectra License: MIT

COLD SWEAT is a fun reaction game, not a medical device. It does not diagnose, detect or assess any health condition.


What it is

You walk around a small hex island, find the bomb, open it up, and cut the right wires using that bomb's manual. The catch: the fuse is wired to you.

The Presage SmartSpectra SDK reads your pulse and breathing live from your webcam. The game compares them with your own calm level and turns the difference into Tension. The higher your Tension, the faster the fuse burns.

Live vitals Real pulse and breathing from the camera, shown with a beating heart and breathing lungs.
Endless levels Every level adds bombs, wires, cuts and rules, and shortens the fuse.
Changing seasons Each level moves to the next season: spring rain, summer storms, autumn leaves, winter snow.
AI bomb designer Optional. An AI designs the wiring and manual of every bomb for your level.
Three camera views Press C for overhead, behind the agent, or first person.

How a run goes

  1. Menu. A 3D lobby in a random season.
  2. Consent. Confirm you are 18 or older and allow the camera. Nothing starts before this.
  3. Ready Check. Pick a camera (a phone through DroidCam works too), press Start camera, and watch Camera, Presage, Face, Pulse and Breathing tick green.
  4. Find your calm. Sit still for 45 seconds. The game learns your resting pulse and breathing.
  5. Mission. Walk to the beacon, open the bomb, read the manual, cut the right wires before the fuse runs out.

Controls

Key Action
W A S D / arrow keys Walk (in behind and eyes views: A/D turn, W/S walk)
E or Space Open the bomb close-up
M Open the bomb's manual
Mouse click Cut a wire
Esc or Q Step back from the bomb
C Change camera view
F11 Fullscreen

Quick start

You need: Node.js 20 or newer, Windows / macOS / Linux, a webcam, and a SmartSpectra API key from physiology.presagetech.com.

git clone https://github.com/abbasmir12/coldsweat.git
cd coldsweat
npm install

1. Get the 3D models. The .glb models are not in git. Download them from the Google Drive link in assets/models/README.md and put them in assets/models/.

2. Add your API key.

copy .env.example .env      # Windows (use cp on macOS / Linux)

Then open .env and set SMARTSPECTRA_API_KEY.

3. Play.

npm start            # live mode: real pulse and breathing from your camera
npm run start:sim    # simulated mode: no camera or key, sliders instead
npm test             # unit tests for the game logic

Tips for a good reading: face a light source (a window works best), keep the camera at face height about an arm's length away, and close other apps that use the camera. SmartSpectra needs about 20 frames per second or more.

VS Code users on Windows: if npm start exits with no window, run $env:ELECTRON_RUN_AS_NODE = $null first.

How it responds to your signals

COLD SWEAT uses two live Presage signals: pulse rate and breathing rate.

camera  ->  SmartSpectra SDK  ->  pulse + breathing  ->  Tension  ->  fuse speed
Step What happens
Camera to SDK The renderer uses SmartSpectraSDK from @smartspectra/node-sdk/renderer. A chosen camera is opened with getUserMedia and passed in with sdk.useMediaStream(). The main process runs the native SDK through bindSmartSpectraIpc().
SDK to numbers Each metrics event is decoded with decodeMetrics() from @smartspectra/node-sdk/messages. The game requests MetricType.PULSE_RATE and breathingMetrics.
Face status validationStatus codes (kOk, kNoFaceFound, kTooDark ...) are shown as hints on the camera view.
Numbers to Tension Values are smoothed with a moving average and compared with your calm level. Above it, Tension rises. At or below it, you get a small calm bonus.
Tension to the game Tension sets the fuse speed (x1.0 and up), pushes the camera in, and switches your agent to a panicking model.

Fair by design

  • Warnings like low light or a low frame rate only show a hint. The game keeps going while pulse and breathing keep arriving.
  • If no face is in view, or readings stop for 6 seconds, the fuse pauses. The game never runs on stale numbers.
  • If SmartSpectra ends a session (for example error 14, frame rate too low), the camera is released and you press Start camera again.

Optional AI bomb designer

Off by default. When you turn it on, an AI designs every bomb for the level you are on: the wiring, the wire colors and the manual's rules, plus a theme like lighthouse keeper or flooded mine. Higher levels get more wires, more cuts and trickier rules.

  • Any OpenAI-compatible provider. OpenRouter is the default. Set these in .env:

    OPENROUTER_API_KEY=your_key        # or AI_API_KEY
    AI_BASE_URL=https://openrouter.ai/api/v1
    AI_MODEL=baidu/ernie-5.5-flash-preview:free
  • The AI never judges. The game's own rule checker validates every design. Anything unfair or broken is replaced with a bomb from the local generator.

  • The AI only gets game settings (level number and counts). Never the camera, pulse, breathing or Tension.

  • It runs in the main process, so the key never reaches the game window.

Consent and data handling

  • Consent first. A consent screen with an I am 18 or older checkbox comes before the camera. The camera never turns on before you agree.
  • Video only. The app only grants camera access to its own page. Microphone access is never allowed.
  • Always visible. A CAMERA ON badge shows whenever the camera runs. The camera stops when you press Stop camera, go back to the menu, finish the game or close the app.
  • Nothing about your body is stored. Pulse, breathing and Tension live in memory only while you play.
  • Saved settings only. The game saves volume, weather effects, your chosen camera and the flip setting in localStorage on your computer.
  • SmartSpectra telemetry. The SDK's telemetry is on (its default). Per Presage's docs, it sends session summaries and readiness reports with device and SDK details, and never video frames or vital signs. It can be turned off with enableTelemetry: false.
  • Optional AI. Off by default. Only game settings are sent to the AI provider you choose.
  • No secrets in git. Keys live in .env, which is gitignored and never logged.

Project structure

main.cjs                 Electron main process, SmartSpectra IPC bridge, camera permission
preload.cjs              Safe bridge between the window and the main process
index.html               Game screens
src/main/                Optional AI bomb designer (main process only)
src/shared/              Pure game logic: Tension, calibration, rulebook, levels, seasons
src/renderer/            Screens, SmartSpectra live source, 3D world, game, HUD
test/                    Unit tests for src/shared
assets/models/           3D models (downloaded separately)

Tech

Electron · Three.js · Presage SmartSpectra Node SDK · esbuild · plain JavaScript

License

MIT

About

A 3D bomb-defusal game where your real pulse and breathing set the fuse. Stay calm and it slows down, panic and it races. Built with Presage SmartSpectra, Electron and Three.js.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages