Skip to content

feat(video): support cameraFacing on VideoSourceInput#11

Merged
msilivonik-sc merged 3 commits into
Snapchat:mainfrom
gsasson-sc:gsasson/video-camera-facing
Jun 30, 2026
Merged

feat(video): support cameraFacing on VideoSourceInput#11
msilivonik-sc merged 3 commits into
Snapchat:mainfrom
gsasson-sc:gsasson/video-camera-facing

Conversation

@gsasson-sc

Copy link
Copy Markdown
Contributor

What

Adds optional cameraFacing ("user" | "environment") to VideoSourceInput, passed to createVideoSource as cameraType.

Why

cameraType propagates beyond the web media plumbing into the lens runtime: it sets cameraInfo.type (front/back), which lens scripts read (DeviceCamera front-facing) and engine subsystems branch on (gyroscope inversion, world-render provider, depth). Camera sources can already set facing via options.cameraFacing; video sources had no way to, so back-facing / world video sources (e.g. recorded world-tracking clips) were always treated as front-facing.

Changes

  • types.ts — add VideoSourceInput.cameraFacing?: CameraFacing (documented).
  • internal/sourceUtils.ts — forward it to createVideoSource as cameraType; combines with trackingData.
  • internal/sourceUtils.test.ts — tests for cameraFacing pass-through and combined with tracking data.

Defaults to "user" (front) — no behavior change when unset.

Test

npm test (26 passing, incl. 2 new), npm run build, npm run typecheck, Prettier — all clean.

🤖 Generated with Claude Code

Add optional `cameraFacing` ("user" | "environment") to VideoSourceInput,
passed to `createVideoSource` as `cameraType`. The camera type propagates to
the lens (DeviceCamera front/back-facing) and engine tracking, so back-facing
/ world video sources can be flagged correctly. Defaults to "user" (front).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@msilivonik-sc msilivonik-sc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few comments. Thanks for the contributions!

Comment thread src/internal/sourceUtils.ts
Comment thread src/internal/sourceUtils.ts Outdated
Comment thread src/types.ts Outdated
- VideoSourceInput gains optional fpsLimit, passed to createVideoSource.
- Pass options object directly (createVideoSource defaults undefined fields).
- Reword cameraFacing doc per review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gsasson-sc

Copy link
Copy Markdown
Contributor Author

Thanks! Addressed in 4f00086:

  • Added fpsLimit to VideoSourceInput, passed through to createVideoSource.
  • Pass the options object directly ({ trackingData, cameraType, fpsLimit }) instead of the conditional build.
  • Reworded the cameraFacing doc — adapted slightly since a video source doesn't open a camera via getUserMedia, so it only maps to CameraKit's cameraType.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@msilivonik-sc msilivonik-sc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@msilivonik-sc msilivonik-sc merged commit 7ce4666 into Snapchat:main Jun 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants