|
@@ -24,12 +24,13 @@ import AR from '../main';
|
24
|
24
|
import Speedy from 'speedy-vision';
|
25
|
25
|
import { SpeedySize } from 'speedy-vision/types/core/speedy-size';
|
26
|
26
|
import { SpeedyPromise } from 'speedy-vision/types/core/speedy-promise';
|
27
|
|
-import { Nullable } from '../utils/utils';
|
28
|
|
-import { Resolution } from '../utils/resolution';
|
29
|
|
-import { Utils } from '../utils/utils';
|
30
|
27
|
import { SessionMode } from './session';
|
31
|
28
|
import { HUD, HUDContainer } from './hud';
|
32
|
29
|
import { FullscreenButton } from '../ui/fullscreen-button';
|
|
30
|
+import { Vector2 } from '../geometry/vector2';
|
|
31
|
+import { Resolution } from '../utils/resolution';
|
|
32
|
+import { Nullable } from '../utils/utils';
|
|
33
|
+import { Utils } from '../utils/utils';
|
33
|
34
|
import { AREvent, AREventTarget, AREventListener } from '../utils/ar-events';
|
34
|
35
|
import { IllegalArgumentError, IllegalOperationError, NotSupportedError, AccessDeniedError } from '../utils/errors';
|
35
|
36
|
|
|
@@ -979,6 +980,23 @@ export class Viewport extends ViewportEventTarget
|
979
|
980
|
}
|
980
|
981
|
|
981
|
982
|
/**
|
|
983
|
+ * Convert a position given in normalized units to a corresponding pixel
|
|
984
|
+ * position in canvas space. Normalized units range from -1 to +1. The
|
|
985
|
+ * center of the canvas is at (0,0). The top right corner is at (1,1).
|
|
986
|
+ * The bottom left corner is at (-1,-1).
|
|
987
|
+ * @param position in normalized units
|
|
988
|
+ * @returns an equivalent pixel position in canvas space
|
|
989
|
+ */
|
|
990
|
+ convertToPixels(position: Vector2): Vector2
|
|
991
|
+ {
|
|
992
|
+ const canvas = this.canvas;
|
|
993
|
+ const x = 0.5 * (1 + position.x) * canvas.width;
|
|
994
|
+ const y = -0.5 * (1 + position.y) * canvas.height;
|
|
995
|
+
|
|
996
|
+ return new Vector2(x, y);
|
|
997
|
+ }
|
|
998
|
+
|
|
999
|
+ /**
|
982
|
1000
|
* Initialize the viewport (when the session starts)
|
983
|
1001
|
* @param getMediaSize
|
984
|
1002
|
* @param sessionMode
|