Skip to content

Add live-webcam Teblid AR example + examples index (#36) - #37

Merged
kalwalt merged 2 commits into
devfrom
feat/teblid-webcam-example
Jun 12, 2026
Merged

Add live-webcam Teblid AR example + examples index (#36)#37
kalwalt merged 2 commits into
devfrom
feat/teblid-webcam-example

Conversation

@kalwalt

@kalwalt kalwalt commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

Adds a working live-webcam AR example using the Teblid tracker, plus an index.html landing page for all examples. This implements the webcam half of #36; the examples-cleanup half (retiring the broken demos) is intentionally deferred — nothing existing is modified or removed here.

  • 4 new example files + 1 design doc, ~664 insertions, 0 deletions.
  • No library changes, no rebuild — uses the dist/WebARKit.js already on dev (post WebARKitLib#45).

What & why

The existing webcam examples are broken. This is a clean, working live-camera reference built on the now-correct library: it consumes the corrected GL pose (matrixGL_RH) directly — no render-side pose hack — and combines the static example's conventions with a continuous bufferCopy ping-pong loop and a getUserMedia feed.

video → drawImage → getImageData → set() into a recycled ArrayBuffer
   → worker.postMessage(transfer) → process_raw(RGBA)
   → tracker (convert2Grayscale internally) → getMarker(matrixGL_RH)
   → postMessage(transfer buffer BACK) → main → setMatrix(root.matrix) → process() next

Files

File Role
examples/worker_teblid_webcam_threejs.js dedicated worker — bufferCopy ping-pong (returns the frame buffer each reply), emits matrixGL_RH
examples/threejs_teblid_webcam_worker_ES6.js start() module — scene + cube/axes, live loop, hides content when not found
examples/threejs_teblid_webcam_ES6_example.html page + camera bootstrap (initCamera, actual videoWidth/Height, CAPTURE_W/H constants)
examples/index.html grouped landing page linking every example
docs/design-webcam-teblid-example.md design + full decision log

Design decisions (see the design doc for the full log)

  • bufferCopy ping-pong — recycle one transferable ArrayBuffer (avoids per-frame GC); the chosen perf path.
  • RGBA end-to-end — the tracker converts to grayscale internally (convert2Grayscale).
  • Match-aspect, projection as-is#video + #canvas share the capture aspect and object-fit:cover, so AR overlays the video exactly; projection used unscaled.
  • No mirroring of the processed feed (keeps tracker handedness correct).
  • 640×480 environment default, resolution as a constant for the higher-res check.
  • On-screen status ("Marker tracked" / "Searching…") with console logging preserved.

Testing

Manual / on-device: open examples/threejs_teblid_webcam_ES6_example.html over localhost, allow camera, point at a printed data/pinball.jpg. Verified live tracking with the cube + axes anchored on the marker, right-handed (red→right, green→up, blue→toward viewer); content hides when the marker leaves frame; status badge flips correctly.

Review checklist

  • No existing example modified/removed (diff is additive)
  • index.html links resolve from examples/
  • No leftover debug scaffolding in the new files
  • Camera permission failure shows a message and degrades gracefully

Risks / known limitations

Related

Refs #36

🤖 Generated with Claude Code

kalwalt and others added 2 commits June 10, 2026 17:32
New live-camera AR example using the Teblid tracker, built on the static example's conventions (consume matrixGL_RH directly, projection as-is, no pose correction) + a continuous bufferCopy main<->worker ping-pong loop + a getUserMedia feed. RGBA end-to-end (tracker converts internally). Cube + axes anchored at the marker origin, hidden when not found; on-screen Marker-tracked/Searching status (console logging kept).

- examples/worker_teblid_webcam_threejs.js (dedicated bufferCopy worker, emits matrixGL_RH) - examples/threejs_teblid_webcam_worker_ES6.js (start() module / live loop) - examples/threejs_teblid_webcam_ES6_example.html (page + camera bootstrap) - examples/index.html (grouped landing page) - docs/design-webcam-teblid-example.md (design + decision log)

No existing example modified or removed. No library changes / no rebuild. Known limitation (not this PR): tracking is not declared lost when the marker leaves frame -- see webarkit/WebARKitLib#46.

Refs #36

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add an in-code comment by the tracking-status logic explaining that found/tracked reflects the library's isValid(), which does not reliably clear when the marker leaves frame (stale lock). Points readers to webarkit/WebARKitLib#46.

Refs #36, webarkit/WebARKitLib#46

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant