Skip to content

Render Teblid static-image example with correct pose (#31) - #33

Merged
kalwalt merged 2 commits into
devfrom
fix/pose-renders-behind-camera
May 30, 2026
Merged

Render Teblid static-image example with correct pose (#31)#33
kalwalt merged 2 commits into
devfrom
fix/pose-renders-behind-camera

Conversation

@kalwalt

@kalwalt kalwalt commented May 30, 2026

Copy link
Copy Markdown
Member

Summary

Resolves #31. The Teblid static-image example now renders the AR sphere on the marker instead of having it frustum-clipped behind the camera. The fix has two halves:

  • Upstream library (webarkit/WebARKitLib#36) — WebARKitPatternTrackingInfo::updateTrackable() no longer applies a partial CV→GL conversion; getPoseMatrix2() / trans carry the raw OpenCV pose, and downstream conversions (arglCameraViewRHf in JS for matrixGL_RH; WebARKitManager::getGLViewMatrix() in C++) become clean diag(1, -1, -1, 1) * pose modelviews.
  • This repo — the example consumes matrixGL_RH (GL right-handed modelview) instead of the raw pose, and the worker forwards that field.

⚠️ Prerequisite: webarkit/WebARKitLib#36 must merge first. This PR's dist/WebARKit.js was built from that branch and its submodule pointer references the lib commit — both need to be on canonical webarkit/WebARKitLib before this PR's submodule SHA is publicly resolvable.

Changes

Area File(s)
Static-image worker switches to matrixGL_RH and wraps content in a markerFrame rotated 180° around Y so +Z faces the camera examples/threejs_static_image_worker_ES6.js
Shared worker additively forwards matrixGL_RH in the found message examples/worker_threejs.js
<img id="static-image"> rendered full-bleed beneath the canvas overlay so the marker is visible behind the 3D content examples/threejs_teblid_static_image_ES6_example.html
Rebuilt WASM + bundler artifacts dist/WebARKit.js, dist/WebARKit.js.LICENSE.txt, dist/SpeedyVisionSinkImageData.js, dist/GrayScale.js, build/webarkit_ES6_wasm.js, build/webarkit_ES6_wasm.simd.js
Submodule pointer → dab5073 on fix/pose-cv-to-gl (will become a canonical SHA on webarkit/WebARKitLib dev once #36 merges) emscripten/WebARKitLib
npm tooling bump: Babel 7.29.7, webpack 5.107.2, babel-loader 10.1.1, rimraf 6.1.3, webpack-cli 7.0.3 package.json, package-lock.json
Design notes + decision log + risk analysis for the fix docs/design-pose-cv-to-gl-fix.md

Test plan

  • Wait for Fix CV->GL pose conversion in updateTrackable() WebARKitLib#36 to merge
  • Re-resolve submodule pointer if it lands at a different (squash) SHA upstream
  • npm install && serve examples/ over HTTP
  • Open threejs_teblid_static_image_ES6_example.html — console shows Marker tracked ! Num. matches : N, loader fades, sphere appears anchored on the pinball marker (no longer clipped behind the camera)
  • Existing webcam examples unaffected (the shared worker_threejs.js change is additive)

Known follow-up (out of scope)

The 3D axes appear visibly tilted relative to the marker edges — that's an unresolved projection X-mirror in the library, tracked in webarkit/WebARKitLib#35. The pose fix in this PR is independent of that and renders correctly given the current projection.

Refs

🤖 Generated with Claude Code

Static-image example now reads `matrixGL_RH` (the GL right-handed modelview
the library computes after the CV->GL handedness flip) instead of `pose`
(raw OpenCV camera pose), so the tracked object sits in front of the GL
camera and renders on the marker instead of being frustum-clipped behind it.

Library side (pulled in via the submodule bump to fix/pose-cv-to-gl):
- WebARKitPattern::updateTrackable() no longer applies its partial
  rotation-column negation; `trans` / getPoseMatrix2() now carry the raw
  OpenCV pose, and downstream conversions (arglCameraViewRHf in JS for
  matrixGL_RH; WebARKitManager::getGLViewMatrix in C++) become clean
  diag(1, -1, -1, 1) * pose CV->GL conversions.

Example side:
- examples/worker_threejs.js: forward event.data.matrixGL_RH in the `found`
  message (additive; existing `pose` consumers unaffected).
- examples/threejs_static_image_worker_ES6.js: parse msg.matrixGL_RH into
  the root matrix; wrap AR content in a `markerFrame` Object3D rotated 180
  deg around Y so +Z faces the camera (corrects the marker's
  image-coordinate convention to a natural three.js placement).
- examples/threejs_teblid_static_image_ES6_example.html: display the
  static <img> full-bleed under the canvas overlay (matches the webcam
  examples' #video layout) so the marker is visible behind the 3D content.

Also rebuild dist/WebARKit.js and dist/* / build/* artifacts from the new
WASM, and bump the npm tooling to current minor/patch (Babel 7.29.7,
webpack 5.107.2, babel-loader 10.1.1, rimraf 6.1.3) plus webpack-cli to
7.0.3 (major) for build cleanliness.

A remaining projection X-mirror in the library leaves the AR content's
axes visibly tilted relative to the marker edges; this is tracked
separately in webarkit/WebARKitLib#35 and cannot be fully corrected from
the example side.

Refs: #31, webarkit/WebARKitLib#34

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@kalwalt kalwalt self-assigned this May 30, 2026
@kalwalt kalwalt added bug Something isn't working enhancement New feature or request javascript Emscripten / C / C++ all about Emscripten labels May 30, 2026
@kalwalt kalwalt moved this from In progress to Review in progress in New markerless image tracking May 30, 2026
webarkit/WebARKitLib#36 was squash-merged into upstream/dev as 3429eb3
(same content as the prior dab5073 SHA, different hash due to the squash).
Re-pin the submodule pointer to the canonical commit so a fresh `git
submodule update --init` against the .gitmodules URL (canonical
webarkit/WebARKitLib) resolves successfully.

Refs: #31, webarkit/WebARKitLib#34

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@kalwalt kalwalt moved this from Review in progress to Reviewer approved in New markerless image tracking May 30, 2026
@kalwalt
kalwalt merged commit f06ff31 into dev May 30, 2026
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in New markerless image tracking May 30, 2026
@kalwalt
kalwalt deleted the fix/pose-renders-behind-camera branch July 5, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Emscripten / C / C++ all about Emscripten enhancement New feature or request javascript

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant