@wemap/camera 5.1.8 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26877,23 +26877,6 @@ var CameraUtils = /*#__PURE__*/Object.freeze({
26877
26877
  calcDisplayedFov: calcDisplayedFov
26878
26878
  });
26879
26879
 
26880
- const GENERIC_HARDWARE_VERTICAL_FOV = 60;
26881
-
26882
- const parameters = {
26883
- sourceWidth: 640,
26884
- sourceHeight: 480
26885
- };
26886
-
26887
- const userMediaConstraints = {
26888
- audio: false,
26889
- video: {
26890
- facingMode: 'environment',
26891
- width: { ideal: parameters.sourceWidth },
26892
- height: { ideal: parameters.sourceHeight }
26893
- }
26894
- };
26895
-
26896
-
26897
26880
  // Helped from https://github.com/jeromeetienne/AR.js/blob/master/three.js/src/threex/threex-artoolkitsource.js
26898
26881
 
26899
26882
  // Camera preview will fill component bounds without transformations.
@@ -26901,6 +26884,14 @@ const userMediaConstraints = {
26901
26884
  // camera preview is extended then cropped.
26902
26885
  class Camera extends EventEmitter {
26903
26886
 
26887
+ static DEFAULT_OPTIONS = {
26888
+ width: 1024,
26889
+ height: 768,
26890
+ resizeOnWindowChange: false
26891
+ };
26892
+
26893
+ static GENERIC_HARDWARE_VERTICAL_FOV = 60;
26894
+
26904
26895
  videoContainer;
26905
26896
  videoElement;
26906
26897
 
@@ -26908,20 +26899,31 @@ class Camera extends EventEmitter {
26908
26899
 
26909
26900
  _isStarted = false;
26910
26901
 
26911
- _hardwareVerticalFov = GENERIC_HARDWARE_VERTICAL_FOV;
26902
+ _hardwareVerticalFov = Camera.GENERIC_HARDWARE_VERTICAL_FOV;
26912
26903
  _resizeOnWindowChange;
26913
26904
 
26914
26905
  /**
26915
26906
  * @param {Node} container
26916
- * @param {boolean} resizeOnWindowChange
26907
+ * @param {{width: number, height: number, resizeOnWindowChange: boolean}} options
26917
26908
  */
26918
- constructor(container, resizeOnWindowChange = false) {
26909
+ constructor(container, options = {}) {
26919
26910
  super();
26920
26911
 
26912
+ options = Object.assign({}, Camera.DEFAULT_OPTIONS, options);
26913
+
26921
26914
  SharedCameras$1._add(this, container);
26922
26915
 
26923
26916
  this.videoContainer = container;
26924
- this._resizeOnWindowChange = resizeOnWindowChange;
26917
+
26918
+ this._resizeOnWindowChange = options.resizeOnWindowChange;
26919
+ this._userMediaConstraints = {
26920
+ audio: false,
26921
+ video: {
26922
+ facingMode: 'environment',
26923
+ width: { ideal: options.width },
26924
+ height: { ideal: options.height }
26925
+ }
26926
+ };
26925
26927
 
26926
26928
  this.videoContainer.style.overflow = 'hidden';
26927
26929
 
@@ -26943,7 +26945,7 @@ class Camera extends EventEmitter {
26943
26945
 
26944
26946
  await Camera.checkAvailability();
26945
26947
 
26946
- const stream = await navigator.mediaDevices.getUserMedia(userMediaConstraints);
26948
+ const stream = await navigator.mediaDevices.getUserMedia(this._userMediaConstraints);
26947
26949
 
26948
26950
  // Listeners have to be set before srcObject assigment or they can be never called
26949
26951
  this.videoElement.oncanplaythrough = () => this.videoElement.play();
@@ -27013,7 +27015,7 @@ class Camera extends EventEmitter {
27013
27015
  }
27014
27016
 
27015
27017
  if (testUserMedia) {
27016
- const stream = await navigator.mediaDevices.getUserMedia(userMediaConstraints);
27018
+ const stream = await navigator.mediaDevices.getUserMedia(this._userMediaConstraints);
27017
27019
  if (stream.stop) {
27018
27020
  stream.stop();
27019
27021
  } else {