Skip to content

Restore CV->GL column negation in updateTrackable (D*R*D) to fix 3D pose orientation #42

Description

@kalwalt

Problem

The 3D pose WebARKit hands to GL renderers (three.js) is mirror/flipped in
orientation — overlays sit on the marker but the axes are wrong, requiring an
example-side compensation. Root cause traced in #35.

Analysis

The correct CV->GL pose conversion is D·R·D (D = diag(1,-1,-1)):

  • left D = flip the camera/eye frame (negate Y,Z rows) — done by
    arglCameraViewRHf.
  • right D = flip the marker/object frame (negate Y,Z columns) — done by
    ArtoolkitX in ARTrackable2d::updateWithTwoDResults.

WebARKit's WebARKitPatternTrackingInfo::updateTrackable() originally negated
the Y,Z columns (matching ArtoolkitX), but that was removed, so the current
result is only D·R — the missing right D is the orientation mirror.

Proposed fix

Restore the Y,Z column negation in updateTrackable():

trans[j][0] =  transMat[j][0];
trans[j][1] = -transMat[j][1];
trans[j][2] = -transMat[j][2];
trans[j][3] = (transMat[j][3] * m_scale * 0.001f * 1.64f);

so matrixGL_RH = arglCameraViewRHf(trans) = D·R·D (+ D·t).

Why low risk

teblid_example uses the 2D homography (CSS transform), not the 3D pose, so
it would not be affected. The downstream static three.js example currently
compensates with a found() row+column negation and a markerFrame rotation;
those get removed once the library is correct.

Plan

  1. Restore the column negation in updateTrackable (this repo).
  2. Downstream (webarkit-testing): drop the example-side found()/markerFrame
    corrections; consume matrixGL_RH directly; rebuild WASM + verify.
  3. Watch the projection-sign interplay (Asymmetric -2*f_x/screenWidth in cameraProjectionMatrix — origin of X-mirror unclear #35) during verification.

Refs: #35

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions