Skip to content

Switch Camera

Related reference: Scene API / Camera and Photo Capture

The Web plugin supports both "specify the camera when opening for the first time" and "switch the camera while running".

Specify It When Opening

Use the cameraPosition property:

js
await kivicubeIframePlugin.openKivicubeScene(iframe, {
  sceneId,
  cameraPosition: 'front',
});

Available values:

  • front
  • back

The default is back.

Switch at Runtime

The advanced API provides:

js
const next = await api.switchCamera('front');
console.log(next); // 'front' or 'back'

Limitations

Please note:

  • switchCamera() is currently available only on scene SceneApi; collection support will be added later
  • if the scene mode is web3d, the method throws immediately because that mode does not depend on a real camera

So it is best suited to Image AR and Basic AR/Gyroscope scenes.

  • open with the back camera by default, but let users switch to the front camera
  • selfie-oriented interactions
  • integrations where the host page already has its own "flip camera" button

Notes

  • Switching the camera reopens the media stream, so it is a good idea to show a short loading hint.
  • Browser support is not fully consistent, and some environments do not support camera switching at all.
  • If the user's device has only one camera, make sure your UX has a fallback.