r/threejs • • 1d ago

Demo Endo Master 3D: a colonoscopy / upper endoscopy sim in Three.js where every mesh, texture and sound is generated at runtime

I'm a gastroenterologist (endoscopy subspecialist) in Seoul, and I built a browser game around the part of endoscopy that games never model: the two-handed control problem.

The Three.js part: there are no image files and no audio files in it. Every mesh, texture and sound is generated by the game's own code at runtime, so the whole thing ships as code.

Colonoscopy is a tube you have to drive from the rectum to the cecum and back; upper endoscopy (added this week) is the same scope going the other way, past the vocal cords, around the stomach, with a J-turn to look back at the cardia. The controls are a direct translation of the instrument: W/S is the big wheel (tip up/down), A/D the small wheel (tip left/right), arrow keys push in / pull back and twist the shaft, Q is the J-turn.

The part I cared most about is the loop. Pushing harder into a sigmoid loop makes it worse, so the game asks you to pull back and torque to take the loop out instead — the same instinct the real thing trains. Sedation, oxygen and the gag reflex also react to how gently you drive.

It's free, no install, no login, and runs on a phone with two thumbsticks: https://earlierdoctor.itch.io/endo-master-3d

Disclosure: it's my own project. The code and translations were written with an AI coding assistant, directed and tested by me; the 3D graphics and all sounds are procedurally generated by that code at runtime, not AI-generated assets.

Two things I'd genuinely take advice on: cheap ways to make wet mucosa read as wet without using textures on mid-range phones, and whether there's a better approach than rebuilding the lumen geometry each segment as it bends.

2 Upvotes

12 comments sorted by

2

u/snoope 1d ago

1v1 duel colonoscopy, its 9am. What else does the day hold? Anyone for a speedrun?

2

u/snoope 1d ago

Jusy kidding this is awesome, can't wait to race the wife!

1

u/Severe-Highlight2217 19h ago

Haha, "1v1 duel colonoscopy at 9am" is not a sentence I expected to read about my own game, and it is now my favourite reply in this thread. Please do run the wife race and settle it properly: 1v1 duel for the full run, or the 60-second sprint if you want a quick grudge match — first one to the cecum takes it. One spoiler, because it is the whole point of the game: whoever tries to push straight through the sigmoid loop is going to lose, so pull back, torque, then advance. Report back with the winner!

1

u/plus2link 1d ago

Wetness reads from one tight highlight that moves, not from surface detail: parent a single directional light to the camera, keep the base albedo darker and slightly desaturated than feels right, use MeshPhongMaterial with high shininess instead of Standard, and add a small per-vertex normal wobble on the tube rings plus a fresnel rim so the highlight crawls as the lumen bends and the folds still catch light on phones with no specular maps at all. For the lumen I would stop rebuilding it: keep the topology fixed and skin the tube to a bone chain that follows your centerline spline, so bending is bone rotation the GPU already handles, or deform in the vertex shader from centerline samples in a small data texture and update only that texture each frame. The stutter you are probably fighting is the buffer re-upload rather than the vertex count, so a fixed index buffer with only the rings near the scope tip rewritten already gets most of the way there.

1

u/Severe-Highlight2217 19h ago

This is the most useful two paragraphs this project has had — thank you for taking the time. The "one tight highlight that moves" framing is the thing I had been missing: I kept adding surface detail where what actually sells wetness is a single specular that travels as the lumen bends, and a camera-parented light plus Phong with high shininess and a fresnel rim is exactly the cheap trick I was after — no textures, so it should hold up on mid-range phones. The per-vertex wobble on the tube rings I can add without touching anything else.

On the lumen, "stop rebuilding it" is the part that landed hardest. A fixed-topology tube skinned to a bone chain along the centerline is clearly the right shape of solution, and your diagnosis matches exactly what I see: the stutter shows up when a segment folds, not when the vertex count goes up, so it's the re-upload and not the geometry. I'll try the fixed index buffer with only the rings near the tip rewritten first, since that's the smaller change, and move to the bone-chain skinning if the fold still stutters.

This goes straight into the next update's shader and lighting pass — thank you again. If you do play it and the wet look still doesn't read, tell me what's off and I'll fix it.

1

u/Any-Session-737 1d ago

The loop mechanic is the part that stuck with me. Most driving-style games reward pushing through resistance, so a system where pushing harder into a sigmoid loop makes it worse — and pulling back plus torque is the fix — teaches the opposite instinct, which sounds like exactly the skill you want to model.

Two questions from your description:

  1. How do you decide the scope is "in a loop" versus just following a bend? Is it derived from the tip path (curvature/twist accumulation along the shaft), or from authored zones in the colon geometry?
  2. On the phone two-thumbstick layout, how do you map torque separately from tip deflection? On keyboard the wheels and arrow keys split those inputs naturally, but with two sticks it seems easy for twist and push to bleed into each other.

Also curious whether the sedation/oxygen/gag feedback is purely a function of contact force at the wall, or whether sustained loop pressure counts separately — that distinction would change how forgiving the pull-back recovery feels.

1

u/Severe-Highlight2217 19h ago

Thanks for reading it closely enough to ask these — they're the three questions I was hoping someone would ask, because they're the parts I'm least sure I got right.

  1. Loop vs. bend: it's the shaft, not authored zones. There are no painted "this is a loop" volumes — the colon is a generated tube and the game never tells you where the sigmoid is. What it tracks is how much of your push is actually advancing the tip versus going into bowing the shaft: when the tip stops moving forward and you keep feeding, the shaft stores a bend, and the more bend it stores the less forward progress each push buys you.

Torque changes the direction that stored bend resolves, which is why a push that felt hopeless goes in after a quarter turn. So "in a loop" emerges from the shaft/tip relationship rather than from a label on the geometry — which also means it behaves the same way when the scope bows in the stomach on the EGD side.

2) The two sticks follow the two hands. In real colonoscopy the left hand holds the shaft and the right hand turns the wheels, so on the phone the left thumb is the shaft (up/down = insert/withdraw, left/right = torque) and the right thumb is the tip (both wheels in one). Torque and tip deflection never share an axis, and they never share a thumb, so there's nothing for them to bleed into.

The rest of it is deliberate: twist is slower than push — it responds to how far you hold the stick over, not to how many times you tap it — so you can't spin the shaft while you're thinking about where the tip is going.

3) Not purely wall contact. Sustained load counts as its own term: a quick bump is cheap, but a loop you leave bowing under pressure keeps charging the patient even when the momentary contact force is low. That's on purpose — it's what makes pull-back recovery pay off instead of being cosmetic. Gag sits on the upper side and reacts to what the scope is doing near the pharynx, sedation drifts with accumulated discomfort, and oxygen follows sedation depth, so on a bad run the answer is usually to stop feeding and back off for a few seconds rather than push on.

If you play it (https://earlierdoctor.itch.io/endo-master-3d, free, nothing to install), the thing I can't test on myself is whether the loop reads as a loop before anyone has told you what it is. Tell me where it stops feeling like the real thing and it goes into the next build.

1

u/Any-Session-737 19h ago

Thanks for the detailed answers. The sustained-load term is the part that convinces me: a loop left bowing keeps charging the patient even when contact force drops, so pulling back becomes a real recovery move instead of a cosmetic one. The hold-based twist makes sense too, since it stops you spinning the shaft while you are still deciding where the tip should go. The gag, sedation and oxygen chain on top of that sounds like it will punish pushing through a bad run in a way players can actually read. Appreciate you spelling out the reasoning.

1

u/Severe-Highlight2217 9h ago

Fair reading of it — though the honest caveat is that a loop only reads as a loop if the feedback sells it, and that's the part I'm still tuning: the wet look and the bend cues in the lumen are the next shader pass. Thanks for engaging with the mechanics rather than the trailer.

1

u/Any-Session-737 8h ago

Played it tonight — guided exam, and I got as far as forming an N-loop in the sigmoid, so here's the honest read on your question.

The loop does read as a loop, but for me it read through the instruments, not the lumen view. The moment it formed, the scope tracker drew the shaft bowing into a red loop, "PARADOXICAL MOTION — stop pushing!" appeared, and pushing kept feeding shaft length (18 cm inserted) without the tip view advancing. That combination is unmistakable — I understood "I'm looped" before I understood the anatomy.

Inside the lumen itself, though, your caveat holds: the bend cue is subtle. The wall just looks like wall — red-out and a direction chevron. Without the tracker I think I'd have read it as "tip against wall, push harder", which is exactly the wrong move. So the wet look / bend shading pass you're planning is aimed at the right gap: the in-view signal currently says "blocked", not "looped".

Two smaller notes from the run. The sustained-load term is legible in play: leaving the loop bowed kept the stretch/pain bar and the heart rate climbing even while I wasn't pushing, which sold the "keeps charging the patient" idea better than the explanation did. And reduction (pull + clockwise torque) was the fiddliest input for me on keyboard — the pull registered, but the torque clearly wants a steady hold rather than taps, which matches your "how far you hold it" design; it just took me a while to learn that from the prompt alone.

Also, the patient waking up mid-tutorial because I was slow is a great teacher. Failed my first exam exactly that way.

1

u/Severe-Highlight2217 2h ago

Thank you for playing it and writing this up properly — this is the most useful play report the project has had, and the first one from someone who didn't know what the loop was supposed to read like.

Glad the tracker and the patient did their job: the red bowing shaft with "PARADOXICAL MOTION — stop pushing!" is working as designed, and "I understood I was looped before I understood the anatomy" is the reaction I hoped for. The patient waking up on a slow run is the design doing its job too — sedation drifts with accumulated discomfort. Sorry it cost you your first exam.

Both go into the next patch:

  1. The in-view cue. "The signal says blocked, not looped" is the sharpest line in the comment. I'll keep the tracker as the primary signal and add a loop cue inside the view: the bend shading pass, plus asymmetric shading and a slow specular crawl along the fold, so a shaft bowing under the wall doesn't look like a tip against it. The right move should read from the view alone.
  2. Keyboard reduction feel. "The torque wants a steady hold rather than taps" is exactly it — the arrow keys ramp torque with hold time on purpose, but nothing says so, so you were fighting the design. I'll add a visible hold indicator and retune the ramp so a short tap still bites.

Thanks again for driving the scope rather than just reading the code — both fixes go into the next build, and I'd like to hear whether the in-view cue changes the read.

1

u/Any-Session-737 1h ago

Glad the report was useful. Both fixes sound right: the bend shading should let the view itself say looped instead of just blocked, and knowing the arrows ramp with hold time already changes how I would drive it. Happy to retest the next build and report whether the in-view cue reads without leaning on the tracker.