forked from MozillaReality/webvr-spec
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebvr_en.html
1330 lines (1067 loc) · 83.1 KB
/
webvr_en.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>WebVR</title>
<style>
@media print {
html { margin: 0 !important; }
body { font-family: serif; }
th, td { font-family: inherit; }
a { color: inherit !important; }
.example:before { font-family: serif !important; }
a:link, a:visited { text-decoration: none !important; }
a:link:after, a:visited:after { /* create a cross-ref "see..." */; }
}
@page {
margin: 1.5cm 1.1cm;
}
h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
figure, div.figure, div.sidefigure, pre, table.propdef, table.propdef-extra,
.example { page-break-inside: avoid; }
dt { page-break-after: avoid; }
body {
background: white;
/* background-image: floating-margin-image-goes-here; */
background-position: top left;
background-attachment: fixed;
background-repeat: no-repeat;
color: black;
counter-reset: exampleno figure issue;
font-family: sans-serif;
line-height: 1.5;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
/* General structural markup */
h1, h2, h3, h4, h5, h6 { text-align: left; }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif; }
h2 { font: 140% sans-serif; }
h3 { font: 120% sans-serif; }
h4 { font: bold 100% sans-serif; }
h5 { font: italic 100% sans-serif; }
h6 { font: small-caps 100% sans-serif; }
h2, h3, h4, h5, h6 { margin-top: 3em; }
h1 + h2 { margin-top: 0em; }
h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 1.2em; }
.head { margin-bottom: 1em; }
.head h1 { margin-top: 2em; clear: both; }
.head table { margin-left: 2em; margin-top: 2em; }
.head dd { margin-bottom: 0; }
p.copyright { font-size: small; }
p.copyright small { font-size: small; }
pre { margin: 1em 0 1em 2em; overflow: auto; }
pre, code, .idl-code {
font-size: .9em;
font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
}
pre .idl-code, pre code { font-size: 1em; }
dt dfn code { font-size: inherit; }
dfn { font-weight: bolder; }
dfn var { font-style: normal; }
s, del {text-decoration: line-through; color: red; }
u, ins {text-decoration: underline; background: #bfa; }
sup {
vertical-align: super;
font-size: 80%
}
details { display: block; }
dt { font-weight: bold; }
dd { margin: 0 0 1em 2em; }
ul, ol { margin-left: 0; padding-left: 2em; }
li { margin: 0.25em 2em 0.5em 0; padding-left: 0; }
[data-md] > :first-child { margin-top: 0; }
[data-md] > :last-child { margin-bottom: 0; }
td.pre {
white-space: pre-wrap;
}
.css, .property { color: #005a9c; }
.property { white-space: nowrap; }
/* Boilerplate sections */
ul.indexlist { margin-left: 0; columns: 13em; }
ul.indexlist li { margin-left: 0; list-style: none }
ul.indexlist li li { margin-left: 1em; }
ul.indexlist a { font-weight: bold; }
ul.indexlist ul, ul.indexlist dl { font-size: smaller; }
ul.indexlist dl { margin-top: 0; }
ul.indexlist dt { margin: .2em 0 .2em 20px; }
ul.indexlist dd { margin: .2em 0 .2em 40px; }
.toc {
font-weight: bold;
line-height: 1.3;
list-style: none;
margin: 1em 0 0 5em;
padding: 0;
}
.toc ul { margin: 0; padding: 0; font-weight: normal; }
.toc ul ul { margin: 0 0 0 2em; font-style: italic; }
.toc ul ul ul { margin: 0}
.toc > li { margin: 1.5em 0; padding: 0; }
.toc li { clear: both; }
.toc ul.toc li { margin: 0.3em 0 0 0; }
.toc a { border-bottom-style: none; }
.toc a:hover, ul.toc a:focus { border-bottom-style: solid; }
/* Section numbers in a column of their own */
.toc span.secno {float: left; width: 4em; margin-left: -5em}
.toc ul ul span.secno { margin-left: -7em; }
table.proptable {
font-size: small;
border-collapse: collapse;
border-spacing: 0;
text-align: left;
margin: 1em 0;
}
table.proptable td, table.proptable th {
padding: 0.4em;
text-align: center;
}
table.proptable tr:hover td { background: #DEF; }
/* Links */
a[href] { color: inherit; border-bottom: 1px solid silver; text-decoration: none; }
a[href]:hover { background: #ffa; }
a[href]:active { color: #C00; background: transparent; }
img, a.logo { border-style: none; }
.heading, .issue, .note, .example, li, dt { position: relative; }
/* CSS-ish link types */
[data-link-type="property"]::before,
[data-link-type="propdesc"]::before,
[data-link-type="descriptor"]::before,
[data-link-type="value"]::before,
[data-link-type="function"]::before,
[data-link-type="at-rule"]::before,
[data-link-type="selector"]::before,
[data-link-type="maybe"]::before {content: "“";}
[data-link-type="property"]::after,
[data-link-type="propdesc"]::after,
[data-link-type="descriptor"]::after,
[data-link-type="value"]::after,
[data-link-type="function"]::after,
[data-link-type="at-rule"]::after,
[data-link-type="selector"]::after,
[data-link-type="maybe"]::after {content: "”";}
[data-link-type].production::before,
[data-link-type].production::after,
.prod [data-link-type]::before,
.prod [data-link-type]::after { content: ""; }
/* Element-type link styling */
[data-link-type=element] { font-family: monospace; }
[data-link-type=element]::before { content: "<" }
[data-link-type=element]::after { content: ">" }
/* Self-links */
a.self-link {
position: absolute;
top: 0;
left: -2.5em;
width: 2em;
height: 2em;
text-align: center;
border: none;
transition: opacity .2s;
opacity: .5;
}
a.self-link:hover {
opacity: 1;
}
.heading > a.self-link {
font-size: 83%;
}
li > a.self-link {
left: -3.5em;
}
dfn > a.self-link {
top: auto;
left: auto;
opacity: 0;
width: 1.5em;
height: 1.5em;
background: gray;
color: white;
font-style: normal;
transition: opacity .2s, background-color .2s, color .2s;
}
dfn:hover > a.self-link {
opacity: 1;
}
dfn > a.self-link:hover {
color: black;
}
a.self-link::before { content: "¶"; }
.heading > a.self-link::before { content: "§"; }
dfn > a.self-link::before { content: "#"; }
/* Figures */
figure {
display: block;
text-align: center;
margin: 2.5em 0;
}
figure.sidefigure {
float: right;
width: 50%;
margin: 0 0 0.5em 0.5em
}
figure pre {
text-align: left;
display: table;
margin: 1em auto;
}
figure table {
margin: auto;
}
figure img, figure object {
display: block;
margin: auto;
max-width: 100%
}
figcaption {
counter-increment: figure;
font-size: 90%;
font-style: italic;
text-align: center;
}
figcaption::before {
content: "Figure " counter(figure) ". ";
font-weight: bold;
}
dd figure { margin-left: -2em; }
/* Definition tables */
table.definition {
border-spacing: 0;
padding: 0 1em 0.5em;
width: 100%;
table-layout: fixed;
margin: 1.2em 0;
}
table.definition td, table.definition th {
padding: 0.5em;
vertical-align: baseline;
border-bottom: 1px solid #bbd7e9;
}
table.definition th:first-child {
font-style: italic;
font-weight: normal;
text-align: left;
width: 8.3em;
padding-left: 1em;
}
table.definition > tbody > tr:last-child > th,
table.definition > tbody > tr:last-child > td {
border-bottom: none;
}
table.definition tr:first-child > th,
table.definition tr:first-child > td {
padding-top: 1em;
}
/* Footnotes at the bottom of a definition table */
table.definition td.footnote {
font-style: normal;
padding-top: .6em;
width: auto;
}
table.definition td.footnote::before {
content: " ";
display: block;
height: 0.6em;
width: 4em;
border-top: thin solid;
}
/* IDL fragments */
pre.idl {
padding: .5em 1em;
margin: 1.2em 0;
}
pre.idl :link, pre.idl :visited {
color:inherit;
background:transparent;
}
/* Data tables */
/* Comes in plain, long, complex, or define varieties */
.data {
margin: 1em auto;
border-collapse: collapse;
width: 100%;
border: hidden;
}
.data {
text-align: center;
width: auto;
}
.data caption {
width: 100%;
}
.data td, .data th {
padding: 0.5em;
border-width: 1px;
border-color: silver;
border-top-style: solid;
}
.data thead td:empty {
padding: 0;
border: 0;
}
.data thead th[scope="row"] {
text-align: right;
color: inherit;
}
.data thead,
.data tbody {
color: inherit;
border-bottom: 2px solid;
}
.data colgroup {
border-left: 2px solid;
}
.data tbody th:first-child,
.data tbody td[scope="row"]:first-child {
text-align: right;
color: inherit;
border-right: 2px solid;
border-top: 1px solid silver;
padding-right: 1em;
}
.data.define td:last-child {
text-align: left;
}
.data tbody th[rowspan],
.data tbody td[rowspan] {
border-left: 1px solid silver;
}
.data tbody th[rowspan]:first-child,
.data tbody td[rowspan]:first-child {
border-left: 0;
border-right: 1px solid silver;
}
.data.complex th,
.data.complex td {
border: 1px solid silver;
}
.data td.long {
vertical-align: baseline;
text-align: left;
}
.data img {
vertical-align: middle;
}
/* Switch/case <dl>s */
dl.switch {
padding-left: 2em;
}
dl.switch > dt {
text-indent: -1.5em;
}
dl.switch > dt:before {
content: '↪';
padding: 0 0.5em 0 0;
display: inline-block;
width: 1em;
text-align: right;
line-height: 0.5em;
}
/* Style for At Risk features (intended as editorial aid, not intended for publishing) */
.atrisk::before {
position: absolute;
margin-left: -5em;
margin-top: -2px;
padding: 4px;
border: 1px solid;
content: 'At risk';
font-size: small;
background-color: white;
color: gray;
border-radius: 1em;
text-align: center;
}
/* Obsoletion notice */
details.annoying-warning[open] {
background: #fdd;
color: red;
font-weight: bold;
text-align: center;
padding: .5em;
border: thick solid red;
border-radius: 1em;
position: fixed;
left: 1em;
right: 1em;
bottom: 1em;
z-index: 1000;
}
details.annoying-warning:not([open]) > summary {
background: #fdd;
color: red;
font-weight: bold;
text-align: center;
padding: .5em;
}
/* Examples */
.example {
counter-increment: exampleno;
}
.example::before {
content: "Example";
content: "Example " counter(exampleno);
min-width: 7.5em;
text-transform: uppercase;
display: block;
}
.illegal-example::before {
content: "Invalid Example";
content: "Invalid Example" counter(exampleno);
}
.example, .illegal-example, .html, .illegal-html, .xml, .illegal-xml {
padding: 0.5em;
margin: 1em 0;
position: relative;
clear: both;
}
pre.example, pre.illegal-example, pre.html,
pre.illegal-html, pre.xml, pre.illegal-xml {
padding-top: 1.5em;
}
.illegal-example { color: red; }
.illegal-example p { color: black; }
.html { color: #600; }
.illegal-html { color: red; }
.illegal-html p { color: black; }
.xml { color: #600; }
.illegal-xml { color: red; }
.illegal-xml p { color: black; }
code.css { font-family: inherit; font-size: 100% }
code.html { color: #600 } /* inline HTML */
code.xml { color: #600 } /* inline XML */
/* Issues */
.issue {
border-color: #E05252;
background: #FBE9E9;
counter-increment: issue;
}
.issue:before {
content: "Issue " counter(issue);
padding-right: 1em;
text-transform: uppercase;
color: #E05252;
}
/* Whys */
details.why > summary {
font-style: italic;
}
details.why[open] > summary {
border-bottom: 1px silver solid;
}
/* All the blocks get similarly styled */
table.definition, pre.idl, .example, .note, details.why, .issue {
border: none;
border-left: .5em solid black;
border-left: .5rem solid black;
}
.issue, .note, .example, .why {
padding: .5em;
margin-top: 1em;
margin-bottom: 1em;
}
table.definition, pre.idl {
background: hsl(210, 70%, 95%);
border-color: hsl(210, 80%, 75%);
}
.example {
background: hsl(50, 70%, 95%);
border-color: hsl(50, 70%, 60%);
}
.example::before {
color: hsl(50, 70%, 60%);
}
.note, details.why {
background: hsl(120, 70%, 95%);
border-color: hsl(120, 70%, 60%);
}
.note::before {
color: hsl(120, 70%, 60%);
}
.issue {
background: hsl(0, 70%, 95%);
border-color: hsl(0, 70%, 60%);
}
.issue::before {
color: hsl(0, 70%, 60%);
}
span.issue, span.note {
padding: .1em .5em .15em;
border-right-width: .5em;
border-right-style: solid;
}
</style>
<meta content="Bikeshed 1.0.0" name="generator">
</head>
<body class="h-entry">
<div class="head">
<p data-fill-with="logo"></p>
<h1 class="p-name no-ref" id="title">WebVR</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft,
<time class="dt-updated" datetime="2015-05-14">14 May 2015</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
<dd><a class="u-url" href="https://github.com/MozVR/webvr-spec/blob/master/webvr.html">https://github.com/MozVR/webvr-spec/blob/master/webvr.html</a>
<dt>Feedback:
<dd><span><a href="mailto:[email protected]?subject=%5Bwebvr%5D%20feedback">[email protected]</a> with subject line “<kbd>[webvr] <var>… message topic …</var></kbd>” (<a href="https://mail.mozilla.org/pipermail/web-vr-discuss/" rel="discussion">archives</a>)</span>
<dt class="editor">Editors:
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:[email protected]">Vladimir Vukicevic</a> (<a class="p-org org" href="http://mozilla.com/">Mozilla</a>)
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:[email protected]">Brandon Jones</a> (<a class="p-org org" href="http://google.com/">Google</a>)
</dl>
</div>
<div data-fill-with="warning"></div>
<p class="copyright" data-fill-with="copyright"><a href="http://creativecommons.org/publicdomain/zero/1.0/" rel="license"><img alt="CC0" src="https://licensebuttons.net/p/zero/1.0/80x15.png"></a>
To the extent possible under law, the editors have waived all copyright
and related or neighboring rights to this work.
In addition, as of 14 May 2015,
the editors have made this specification available under the
<a href="http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0" rel="license">Open Web Foundation Agreement Version 1.0</a>,
which is available at http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0.
Parts of this work may be from another specification document. If so, those parts are instead covered by the license of that specification document.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
<div class="p-summary" data-fill-with="abstract">
<p>This specification describes support for accessing virtual reality devices, including sensors and head-mounted displays on the Web.</p>
</div>
<div data-fill-with="at-risk"></div>
<h2 class="no-num no-toc no-ref heading settled" id="contents"><span class="content">Table of Contents</span></h2>
<div data-fill-with="table-of-contents" role="navigation">
<ul class="toc" role="directory">
<li><a href="#intro"><span class="secno">1</span> <span class="content">Introduction</span></a>
<li><a href="#devtypes"><span class="secno">2</span> <span class="content">Supported Device Types</span></a>
<li><a href="#security"><span class="secno">3</span> <span class="content">Security</span></a>
<li><a href="#dom"><span class="secno">4</span> <span class="content">DOM Interfaces</span></a>
<ul class="toc">
<li><a href="#vreye"><span class="secno">4.1</span> <span class="content">VREye</span></a>
<li><a href="#vrfieldofview"><span class="secno">4.2</span> <span class="content">VRFieldOfView</span></a>
<li><a href="#vrpositionstate"><span class="secno">4.3</span> <span class="content">VRPositionState</span></a>
<ul class="toc">
<li><a href="#vrpositionstateattributes"><span class="secno">4.3.1</span> <span class="content">Attributes</span></a>
</ul>
<li><a href="#vreyeparameters"><span class="secno">4.4</span> <span class="content">VREyeParameters</span></a>
<ul class="toc">
<li><a href="#vreyeparametersattributes"><span class="secno">4.4.1</span> <span class="content">Attributes</span></a>
</ul>
<li><a href="#vrdevice"><span class="secno">4.5</span> <span class="content">VRDevice</span></a>
<ul class="toc">
<li><a href="#vrdeviceattributes"><span class="secno">4.5.1</span> <span class="content">Attributes</span></a>
</ul>
<li><a href="#hmdvrdevice"><span class="secno">4.6</span> <span class="content">HMDVRDevice</span></a>
<ul class="toc">
<li><a href="#hmdvrdevicemethods"><span class="secno">4.6.1</span> <span class="content">Methods</span></a>
</ul>
<li><a href="#positionsensorvrdevice"><span class="secno">4.7</span> <span class="content">PositionSensorVRDevice</span></a>
<ul class="toc">
<li><a href="#positionsensorvrdevicemethods"><span class="secno">4.7.1</span> <span class="content">Methods</span></a>
</ul>
<li><a href="#navigator-interface-extension"><span class="secno">4.8</span> <span class="content">Navigator Interface extension</span></a>
<ul class="toc">
<li><a href="#navigatormethods"><span class="secno">4.8.1</span> <span class="content">Methods</span></a>
</ul>
</ul>
<li><a href="#ack"><span class="secno">5</span> <span class="content">Acknowledgements</span></a>
<li><a href="#conformance"><span class="secno"></span> <span class="content">
Conformance</span></a>
<li><a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
<ul class="toc">
<li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
<li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
</ul>
<li><a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ul class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
</ul>
<li><a href="#idl-index"><span class="secno"></span> <span class="content">IDL Index</span></a>
</ul></div>
<main>
<h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content">Introduction</span><a class="self-link" href="#intro"></a></h2>
<p>Hardware that enables Virtual Reality applications requires high-precision, low-latency interfaces to deliver an acceptable experience.
Other interfaces, such as device orientation events, can be repurposed to surface VR input but doing so dilutes the interface’s original
intent and often does not provide the precision necessary for high-quality VR. The WebVR API provides purpose-built interfaces
to VR hardware to allow developers to build compelling, comfortable VR experiences.</p>
<h2 class="heading settled" data-level="2" id="devtypes"><span class="secno">2. </span><span class="content">Supported Device Types</span><a class="self-link" href="#devtypes"></a></h2>
<p>At this time there are two defined variants of VRDevice, each of which is intended to describe a specific capability of a piece of hardware
rather than all aspects of that hardware. For example, a typical Head-Mounted Display such as an Oculus Rift will be exposed as two VRDevices:
An HMDVRDevice that describes the optical properties of the device, including Field of View and Interpupillary Distance, and a
PositionSensorVRDevice, which describes the HMD’s position and orientation in space.</p>
<p>A PositionSensorVRDevice could also be provided without a corresponding HMDVRDevice to represent a piece of hardware that tracks position
but does not have a display, such as a Six-degrees-of-freedom controller.</p>
<p>Additional VRDevice types may be added over time to expose new hardware types or features as they becomes available to consumers.
Eye tracking is an example of a potential future interface.</p>
<h2 class="heading settled" data-level="3" id="security"><span class="secno">3. </span><span class="content">Security</span><a class="self-link" href="#security"></a></h2>
<p>Some information about security considerations here.</p>
<h2 class="heading settled" data-level="4" id="dom"><span class="secno">4. </span><span class="content">DOM Interfaces</span><a class="self-link" href="#dom"></a></h2>
<p>This section describes the interfaces and functionality added to the DOM to support runtime access to the functionality described above.</p>
<h3 class="heading settled" data-level="4.1" id="vreye"><span class="secno">4.1. </span><span class="content">VREye</span><a class="self-link" href="#vreye"></a></h3>
<pre class="idl">enum <dfn class="idl-code" data-dfn-type="enum" data-export="" data-global-name="" id="enumdef-vreye">VREye<a class="self-link" href="#enumdef-vreye"></a></dfn> { "left", "right" };
</pre>
<h3 class="heading settled" data-level="4.2" id="vrfieldofview"><span class="secno">4.2. </span><span class="content">VRFieldOfView</span><a class="self-link" href="#vrfieldofview"></a></h3>
<p>The <code class="idl"><a data-link-type="idl" href="#vrfieldofview0">VRFieldOfView</a></code> interface represents a field of view, as given by 4 degrees describing the view from a center point.</p>
<pre class="idl">interface <dfn class="idl-code" data-dfn-type="interface" data-export="" data-global-name="" id="vrfieldofviewreadonly">VRFieldOfViewReadOnly<a class="self-link" href="#vrfieldofviewreadonly"></a></dfn> {
readonly attribute double <dfn class="idl-code" data-dfn-for="VRFieldOfViewReadOnly" data-dfn-type="attribute" data-export="" data-global-name="VRFieldOfViewReadOnly<interface>/upDegrees<attribute>" data-readonly="" data-type="double " id="dom-vrfieldofviewreadonly-updegrees">upDegrees<a class="self-link" href="#dom-vrfieldofviewreadonly-updegrees"></a></dfn>;
readonly attribute double <dfn class="idl-code" data-dfn-for="VRFieldOfViewReadOnly" data-dfn-type="attribute" data-export="" data-global-name="VRFieldOfViewReadOnly<interface>/rightDegrees<attribute>" data-readonly="" data-type="double " id="dom-vrfieldofviewreadonly-rightdegrees">rightDegrees<a class="self-link" href="#dom-vrfieldofviewreadonly-rightdegrees"></a></dfn>;
readonly attribute double <dfn class="idl-code" data-dfn-for="VRFieldOfViewReadOnly" data-dfn-type="attribute" data-export="" data-global-name="VRFieldOfViewReadOnly<interface>/downDegrees<attribute>" data-readonly="" data-type="double " id="dom-vrfieldofviewreadonly-downdegrees">downDegrees<a class="self-link" href="#dom-vrfieldofviewreadonly-downdegrees"></a></dfn>;
readonly attribute double <dfn class="idl-code" data-dfn-for="VRFieldOfViewReadOnly" data-dfn-type="attribute" data-export="" data-global-name="VRFieldOfViewReadOnly<interface>/leftDegrees<attribute>" data-readonly="" data-type="double " id="dom-vrfieldofviewreadonly-leftdegrees">leftDegrees<a class="self-link" href="#dom-vrfieldofviewreadonly-leftdegrees"></a></dfn>;
};
dictionary <dfn class="idl-code" data-dfn-type="dictionary" data-export="" data-global-name="" id="dictdef-vrfieldofviewinit">VRFieldOfViewInit<a class="self-link" href="#dictdef-vrfieldofviewinit"></a></dfn> {
double <dfn class="idl-code" data-default="0.0" data-dfn-for="VRFieldOfViewInit" data-dfn-type="dict-member" data-export="" data-global-name="VRFieldOfViewInit<dictionary>/upDegrees<dict-member>" data-type="double " id="dom-vrfieldofviewinit-updegrees">upDegrees<a class="self-link" href="#dom-vrfieldofviewinit-updegrees"></a></dfn> = 0.0;
double <dfn class="idl-code" data-default="0.0" data-dfn-for="VRFieldOfViewInit" data-dfn-type="dict-member" data-export="" data-global-name="VRFieldOfViewInit<dictionary>/rightDegrees<dict-member>" data-type="double " id="dom-vrfieldofviewinit-rightdegrees">rightDegrees<a class="self-link" href="#dom-vrfieldofviewinit-rightdegrees"></a></dfn> = 0.0;
double <dfn class="idl-code" data-default="0.0" data-dfn-for="VRFieldOfViewInit" data-dfn-type="dict-member" data-export="" data-global-name="VRFieldOfViewInit<dictionary>/downDegrees<dict-member>" data-type="double " id="dom-vrfieldofviewinit-downdegrees">downDegrees<a class="self-link" href="#dom-vrfieldofviewinit-downdegrees"></a></dfn> = 0.0;
double <dfn class="idl-code" data-default="0.0" data-dfn-for="VRFieldOfViewInit" data-dfn-type="dict-member" data-export="" data-global-name="VRFieldOfViewInit<dictionary>/leftDegrees<dict-member>" data-type="double " id="dom-vrfieldofviewinit-leftdegrees">leftDegrees<a class="self-link" href="#dom-vrfieldofviewinit-leftdegrees"></a></dfn> = 0.0;
};
[<dfn class="idl-code" data-dfn-for="VRFieldOfView" data-dfn-type="constructor" data-export="" data-global-name="VRFieldOfView<interface>/VRFieldOfView(fov)<constructor>" data-lt="VRFieldOfView(fov)" id="dom-vrfieldofview-vrfieldofviewfov">Constructor<a class="self-link" href="#dom-vrfieldofview-vrfieldofviewfov"></a></dfn>(optional <a data-link-type="idl-name" href="#dictdef-vrfieldofviewinit">VRFieldOfViewInit</a> <dfn class="idl-code" data-dfn-for="VRFieldOfView/VRFieldOfView(fov)" data-dfn-type="argument" data-export="" data-global-name="VRFieldOfView<interface>/VRFieldOfView(fov)<method>/fov<argument>" id="dom-vrfieldofview-vrfieldofviewfov-fov">fov<a class="self-link" href="#dom-vrfieldofview-vrfieldofviewfov-fov"></a></dfn>),
<dfn class="idl-code" data-dfn-for="VRFieldOfView" data-dfn-type="constructor" data-export="" data-global-name="VRFieldOfView<interface>/VRFieldOfView(upDegrees, rightDegrees, downDegrees, leftDegrees)<constructor>" data-lt="VRFieldOfView(upDegrees, rightDegrees, downDegrees, leftDegrees)" id="dom-vrfieldofview-vrfieldofviewupdegrees-rightdegrees-downdegrees-leftdegrees">Constructor<a class="self-link" href="#dom-vrfieldofview-vrfieldofviewupdegrees-rightdegrees-downdegrees-leftdegrees"></a></dfn>(double <dfn class="idl-code" data-dfn-for="VRFieldOfView/VRFieldOfView(upDegrees, rightDegrees, downDegrees, leftDegrees)" data-dfn-type="argument" data-export="" data-global-name="VRFieldOfView<interface>/VRFieldOfView(upDegrees, rightDegrees, downDegrees, leftDegrees)<method>/upDegrees<argument>" id="dom-vrfieldofview-vrfieldofviewupdegrees-rightdegrees-downdegrees-leftdegrees-updegrees">upDegrees<a class="self-link" href="#dom-vrfieldofview-vrfieldofviewupdegrees-rightdegrees-downdegrees-leftdegrees-updegrees"></a></dfn>, double <dfn class="idl-code" data-dfn-for="VRFieldOfView/VRFieldOfView(upDegrees, rightDegrees, downDegrees, leftDegrees)" data-dfn-type="argument" data-export="" data-global-name="VRFieldOfView<interface>/VRFieldOfView(upDegrees, rightDegrees, downDegrees, leftDegrees)<method>/rightDegrees<argument>" id="dom-vrfieldofview-vrfieldofviewupdegrees-rightdegrees-downdegrees-leftdegrees-rightdegrees">rightDegrees<a class="self-link" href="#dom-vrfieldofview-vrfieldofviewupdegrees-rightdegrees-downdegrees-leftdegrees-rightdegrees"></a></dfn>, double <dfn class="idl-code" data-dfn-for="VRFieldOfView/VRFieldOfView(upDegrees, rightDegrees, downDegrees, leftDegrees)" data-dfn-type="argument" data-export="" data-global-name="VRFieldOfView<interface>/VRFieldOfView(upDegrees, rightDegrees, downDegrees, leftDegrees)<method>/downDegrees<argument>" id="dom-vrfieldofview-vrfieldofviewupdegrees-rightdegrees-downdegrees-leftdegrees-downdegrees">downDegrees<a class="self-link" href="#dom-vrfieldofview-vrfieldofviewupdegrees-rightdegrees-downdegrees-leftdegrees-downdegrees"></a></dfn>, double <dfn class="idl-code" data-dfn-for="VRFieldOfView/VRFieldOfView(upDegrees, rightDegrees, downDegrees, leftDegrees)" data-dfn-type="argument" data-export="" data-global-name="VRFieldOfView<interface>/VRFieldOfView(upDegrees, rightDegrees, downDegrees, leftDegrees)<method>/leftDegrees<argument>" id="dom-vrfieldofview-vrfieldofviewupdegrees-rightdegrees-downdegrees-leftdegrees-leftdegrees">leftDegrees<a class="self-link" href="#dom-vrfieldofview-vrfieldofviewupdegrees-rightdegrees-downdegrees-leftdegrees-leftdegrees"></a></dfn>)]
interface <dfn class="idl-code" data-dfn-type="interface" data-export="" data-global-name="" id="vrfieldofview0">VRFieldOfView<a class="self-link" href="#vrfieldofview0"></a></dfn> : <a data-link-type="idl-name" href="#vrfieldofviewreadonly">VRFieldOfViewReadOnly</a> {
inherit attribute double <dfn class="idl-code" data-dfn-for="VRFieldOfView" data-dfn-type="attribute" data-export="" data-global-name="VRFieldOfView<interface>/upDegrees<attribute>" data-type="double " id="dom-vrfieldofview-updegrees">upDegrees<a class="self-link" href="#dom-vrfieldofview-updegrees"></a></dfn>;
inherit attribute double <dfn class="idl-code" data-dfn-for="VRFieldOfView" data-dfn-type="attribute" data-export="" data-global-name="VRFieldOfView<interface>/rightDegrees<attribute>" data-type="double " id="dom-vrfieldofview-rightdegrees">rightDegrees<a class="self-link" href="#dom-vrfieldofview-rightdegrees"></a></dfn>;
inherit attribute double <dfn class="idl-code" data-dfn-for="VRFieldOfView" data-dfn-type="attribute" data-export="" data-global-name="VRFieldOfView<interface>/downDegrees<attribute>" data-type="double " id="dom-vrfieldofview-downdegrees">downDegrees<a class="self-link" href="#dom-vrfieldofview-downdegrees"></a></dfn>;
inherit attribute double <dfn class="idl-code" data-dfn-for="VRFieldOfView" data-dfn-type="attribute" data-export="" data-global-name="VRFieldOfView<interface>/leftDegrees<attribute>" data-type="double " id="dom-vrfieldofview-leftdegrees">leftDegrees<a class="self-link" href="#dom-vrfieldofview-leftdegrees"></a></dfn>;
};
</pre>
<div class="example" id="example-32e55d23"><a class="self-link" href="#example-32e55d23"></a>
The following code snippet creates a WebGL-compatible projection matrix from a
<code class="idl"><a data-link-type="idl" href="#vrfieldofview0">VRFieldOfView</a></code>.
<pre>function fieldOfViewToProjectionMatrix(fov, zNear, zFar) {
var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
var xScale = 2.0 / (leftTan + rightTan);
var yScale = 2.0 / (upTan + downTan);
var out = new Float32Array(16);
out[0] = xScale;
out[1] = 0.0;
out[2] = 0.0;
out[3] = 0.0;
out[4] = 0.0;
out[5] = yScale;
out[6] = 0.0;
out[7] = 0.0;
out[8] = -((leftTan - rightTan) * xScale * 0.5);
out[9] = ((upTan - downTan) * yScale * 0.5);
out[10] = -(zNear + zFar) / (zFar - zNear);
out[11] = -1.0;
out[12] = 0.0;
out[13] = 0.0;
out[14] = -(2.0 * zFar * zNear) / (zFar - zNear);
out[15] = 0.0;
return out;
}
</pre>
</div>
<h3 class="heading settled" data-level="4.3" id="vrpositionstate"><span class="secno">4.3. </span><span class="content">VRPositionState</span><a class="self-link" href="#vrpositionstate"></a></h3>
<p>The <code class="idl"><a data-link-type="idl" href="#vrpositionstate0">VRPositionState</a></code> interface represents a sensor’s state at a given timestamp.</p>
<pre class="idl">interface <dfn class="idl-code" data-dfn-type="interface" data-export="" data-global-name="" id="vrpositionstate0">VRPositionState<a class="self-link" href="#vrpositionstate0"></a></dfn> {
readonly attribute double <a class="idl-code" data-global-name="VRPositionState<interface>/timeStamp<attribute>" data-link-type="attribute" data-readonly="" data-type="double " href="#dom-vrpositionstate-timestamp">timeStamp</a>;
readonly attribute boolean <a class="idl-code" data-global-name="VRPositionState<interface>/hasPosition<attribute>" data-link-type="attribute" data-readonly="" data-type="boolean " href="#dom-vrpositionstate-hasposition">hasPosition</a>;
readonly attribute <a data-link-type="idl-name" href="http://dev.w3.org/fxtf/geometry/#dompoint">DOMPoint</a>? <a class="idl-code" data-global-name="VRPositionState<interface>/position<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMPoint? " href="#dom-vrpositionstate-position">position</a>;
readonly attribute <a data-link-type="idl-name" href="http://dev.w3.org/fxtf/geometry/#dompoint">DOMPoint</a>? <a class="idl-code" data-global-name="VRPositionState<interface>/linearVelocity<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMPoint? " href="#dom-vrpositionstate-linearvelocity">linearVelocity</a>;
readonly attribute <a data-link-type="idl-name" href="http://dev.w3.org/fxtf/geometry/#dompoint">DOMPoint</a>? <a class="idl-code" data-global-name="VRPositionState<interface>/linearAcceleration<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMPoint? " href="#dom-vrpositionstate-linearacceleration">linearAcceleration</a>;
readonly attribute boolean <a class="idl-code" data-global-name="VRPositionState<interface>/hasOrientation<attribute>" data-link-type="attribute" data-readonly="" data-type="boolean " href="#dom-vrpositionstate-hasorientation">hasOrientation</a>;
// XXX should be DOMQuaternion as soon as we add that
readonly attribute <a data-link-type="idl-name" href="http://dev.w3.org/fxtf/geometry/#dompoint">DOMPoint</a>? <a class="idl-code" data-global-name="VRPositionState<interface>/orientation<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMPoint? " href="#dom-vrpositionstate-orientation">orientation</a>;
readonly attribute <a data-link-type="idl-name" href="http://dev.w3.org/fxtf/geometry/#dompoint">DOMPoint</a>? <a class="idl-code" data-global-name="VRPositionState<interface>/angularVelocity<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMPoint? " href="#dom-vrpositionstate-angularvelocity">angularVelocity</a>;
readonly attribute <a data-link-type="idl-name" href="http://dev.w3.org/fxtf/geometry/#dompoint">DOMPoint</a>? <a class="idl-code" data-global-name="VRPositionState<interface>/angularAcceleration<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMPoint? " href="#dom-vrpositionstate-angularacceleration">angularAcceleration</a>;
};
</pre>
<h4 class="heading settled" data-level="4.3.1" id="vrpositionstateattributes"><span class="secno">4.3.1. </span><span class="content">Attributes</span><a class="self-link" href="#vrpositionstateattributes"></a></h4>
<p><dfn class="idl-code" data-dfn-for="VRPositionState" data-dfn-type="attribute" data-export="" id="dom-vrpositionstate-timestamp">timeStamp<a class="self-link" href="#dom-vrpositionstate-timestamp"></a></dfn>
Monotonically increasing value that allows the author to determine if position
state data been updated from the hardware. Since values are monotonically
increasing they can be compared to determine the ordering of updates, as newer
values will always be greater than or equal to older values.</p>
<p><dfn class="idl-code" data-dfn-for="VRPositionState" data-dfn-type="attribute" data-export="" id="dom-vrpositionstate-hasposition">hasPosition<a class="self-link" href="#dom-vrpositionstate-hasposition"></a></dfn>
True if the <code class="idl"><a data-link-type="idl" href="#dom-vrpositionstate-position">position</a></code> attribute is valid. If false, <code class="idl"><a data-link-type="idl" href="#dom-vrpositionstate-position">position</a></code> MUST be null.</p>
<p><dfn class="idl-code" data-dfn-for="VRPositionState" data-dfn-type="attribute" data-export="" id="dom-vrpositionstate-position">position<a class="self-link" href="#dom-vrpositionstate-position"></a></dfn>
Position of the sensor at <code class="idl"><a data-link-type="idl" href="#dom-vrpositionstate-timestamp">timeStamp</a></code> as a 3D vector. Position is given in
meters from an origin point, which is either the position the sensor was first
read at or the position of the sensor at the point that resetSensor was last
called. The coordinate system uses these axis definitions:</p>
<ul>
<li>Positive X is to the user’s right.
<li>Positive Y is up.
<li>Positive Z is behind the user.
</ul>
All positions are given relative to the identity orientation. The w component
MUST be 0. May be null if the sensor is incapable of providing positional data.
<p><dfn class="idl-code" data-dfn-for="VRPositionState" data-dfn-type="attribute" data-export="" id="dom-vrpositionstate-linearvelocity">linearVelocity<a class="self-link" href="#dom-vrpositionstate-linearvelocity"></a></dfn>
Linear velocity of the sensor at <code class="idl"><a data-link-type="idl" href="#dom-vrpositionstate-timestamp">timeStamp</a></code>. The w component MUST be 0.
May be null if the sensor is incapable of providing linear velocity.</p>
<p><dfn class="idl-code" data-dfn-for="VRPositionState" data-dfn-type="attribute" data-export="" id="dom-vrpositionstate-linearacceleration">linearAcceleration<a class="self-link" href="#dom-vrpositionstate-linearacceleration"></a></dfn>
Linear acceleration of the sensor at <code class="idl"><a data-link-type="idl" href="#dom-vrpositionstate-timestamp">timeStamp</a></code>. The w component MUST be 0.
May be null if the sensor is incapable of providing linear acceleration.</p>
<p><dfn class="idl-code" data-dfn-for="VRPositionState" data-dfn-type="attribute" data-export="" id="dom-vrpositionstate-hasorientation">hasOrientation<a class="self-link" href="#dom-vrpositionstate-hasorientation"></a></dfn>
True if the <code class="idl"><a data-link-type="idl" href="#dom-vrpositionstate-orientation">orientation</a></code> attribute is valid. If false, <code class="idl"><a data-link-type="idl" href="#dom-vrpositionstate-orientation">orientation</a></code> MUST be
null.</p>
<p><dfn class="idl-code" data-dfn-for="VRPositionState" data-dfn-type="attribute" data-export="" id="dom-vrpositionstate-orientation">orientation<a class="self-link" href="#dom-vrpositionstate-orientation"></a></dfn>
Orientation of the sensor at <code class="idl"><a data-link-type="idl" href="#dom-vrpositionstate-timestamp">timeStamp</a></code> as a quaternion. The orientation yaw
(rotation around the Y axis) is relative to the initial yaw of the sensor when
it was first read or the yaw of the sensor at the point that resetSensor was
last called. An orientation of {x: 0, y: 0, z: 0, w: 1} is considered to be
"forward". May be null if the sensor is incapable of providing
orientation data.</p>
<p><dfn class="idl-code" data-dfn-for="VRPositionState" data-dfn-type="attribute" data-export="" id="dom-vrpositionstate-angularvelocity">angularVelocity<a class="self-link" href="#dom-vrpositionstate-angularvelocity"></a></dfn>
Angular velocity of the sensor at <code class="idl"><a data-link-type="idl" href="#dom-vrpositionstate-timestamp">timeStamp</a></code>. The w component MUST be 0.
May be null if the sensor is incapable of providing angular velocity.</p>
<p><dfn class="idl-code" data-dfn-for="VRPositionState" data-dfn-type="attribute" data-export="" id="dom-vrpositionstate-angularacceleration">angularAcceleration<a class="self-link" href="#dom-vrpositionstate-angularacceleration"></a></dfn>
Angular acceleration of the sensor at <code class="idl"><a data-link-type="idl" href="#dom-vrpositionstate-timestamp">timeStamp</a></code>. The w component MUST be 0.
May be null if the sensor is incapable of providing angular acceleration.</p>
<h3 class="heading settled" data-level="4.4" id="vreyeparameters"><span class="secno">4.4. </span><span class="content">VREyeParameters</span><a class="self-link" href="#vreyeparameters"></a></h3>
<p>The <code class="idl"><a data-link-type="idl" href="#vreyeparameters0">VREyeParameters</a></code> interface represents all the information required to correctly render a scene for a given eye.</p>
<pre class="idl">interface <dfn class="idl-code" data-dfn-type="interface" data-export="" data-global-name="" id="vreyeparameters0">VREyeParameters<a class="self-link" href="#vreyeparameters0"></a></dfn> {
/* These values are expected to be static per-device/per-user. */
readonly attribute <a data-link-type="idl-name" href="#vrfieldofview0">VRFieldOfView</a> <a class="idl-code" data-global-name="VREyeParameters<interface>/minimumFieldOfView<attribute>" data-link-type="attribute" data-readonly="" data-type="VRFieldOfView " href="#dom-vreyeparameters-minimumfieldofview">minimumFieldOfView</a>;
readonly attribute <a data-link-type="idl-name" href="#vrfieldofview0">VRFieldOfView</a> <a class="idl-code" data-global-name="VREyeParameters<interface>/maximumFieldOfView<attribute>" data-link-type="attribute" data-readonly="" data-type="VRFieldOfView " href="#dom-vreyeparameters-maximumfieldofview">maximumFieldOfView</a>;
readonly attribute <a data-link-type="idl-name" href="#vrfieldofview0">VRFieldOfView</a> <a class="idl-code" data-global-name="VREyeParameters<interface>/recommendedFieldOfView<attribute>" data-link-type="attribute" data-readonly="" data-type="VRFieldOfView " href="#dom-vreyeparameters-recommendedfieldofview">recommendedFieldOfView</a>;
readonly attribute <a data-link-type="idl-name" href="http://dev.w3.org/fxtf/geometry/#dompoint">DOMPoint</a> <a class="idl-code" data-global-name="VREyeParameters<interface>/eyeTranslation<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMPoint " href="#dom-vreyeparameters-eyetranslation">eyeTranslation</a>;
/* These values will vary after a FOV has been set. */
readonly attribute <a data-link-type="idl-name" href="#vrfieldofview0">VRFieldOfView</a> <a class="idl-code" data-global-name="VREyeParameters<interface>/currentFieldOfView<attribute>" data-link-type="attribute" data-readonly="" data-type="VRFieldOfView " href="#dom-vreyeparameters-currentfieldofview">currentFieldOfView</a>;
readonly attribute <a data-link-type="idl-name" href="http://dev.w3.org/fxtf/geometry/#domrect">DOMRect</a> <a class="idl-code" data-global-name="VREyeParameters<interface>/renderRect<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMRect " href="#dom-vreyeparameters-renderrect">renderRect</a>;
};
</pre>
<h4 class="heading settled" data-level="4.4.1" id="vreyeparametersattributes"><span class="secno">4.4.1. </span><span class="content">Attributes</span><a class="self-link" href="#vreyeparametersattributes"></a></h4>
<p><dfn class="idl-code" data-dfn-for="VREyeParameters" data-dfn-type="attribute" data-export="" id="dom-vreyeparameters-minimumfieldofview">minimumFieldOfView<a class="self-link" href="#dom-vreyeparameters-minimumfieldofview"></a></dfn>
Describes the minimum supported field of view for the eye.</p>
<p><dfn class="idl-code" data-dfn-for="VREyeParameters" data-dfn-type="attribute" data-export="" id="dom-vreyeparameters-maximumfieldofview">maximumFieldOfView<a class="self-link" href="#dom-vreyeparameters-maximumfieldofview"></a></dfn>
Describes the maximum supported field of view for the eye.</p>
<p><dfn class="idl-code" data-dfn-for="VREyeParameters" data-dfn-type="attribute" data-export="" id="dom-vreyeparameters-recommendedfieldofview">recommendedFieldOfView<a class="self-link" href="#dom-vreyeparameters-recommendedfieldofview"></a></dfn>
Describes the recommended field of view for the eye. It is RECOMMENDED that this
be set to a value based on user calibration.</p>
<p><dfn class="idl-code" data-dfn-for="VREyeParameters" data-dfn-type="attribute" data-export="" id="dom-vreyeparameters-eyetranslation">eyeTranslation<a class="self-link" href="#dom-vreyeparameters-eyetranslation"></a></dfn>
Offset from the center of the user’s head to the eye in meters. This value SHOULD
represent the user’s interpupillary distance (IPD), but may also represent the
distance from the center point of the headset to the center point of the lens for
the given eye. Values for the left eye MUST be negative; values for the right
eye MUST be positive.</p>
<p><dfn class="idl-code" data-dfn-for="VREyeParameters" data-dfn-type="attribute" data-export="" id="dom-vreyeparameters-currentfieldofview">currentFieldOfView<a class="self-link" href="#dom-vreyeparameters-currentfieldofview"></a></dfn>
The current field of view for the eye, as specified by setFieldOfView.
Defaults to <code class="idl"><a data-link-type="idl" href="#dom-vreyeparameters-recommendedfieldofview">recommendedFieldOfView</a></code>.</p>
<p><dfn class="idl-code" data-dfn-for="VREyeParameters" data-dfn-type="attribute" data-export="" id="dom-vreyeparameters-renderrect">renderRect<a class="self-link" href="#dom-vreyeparameters-renderrect"></a></dfn>
Describes the viewport of a canvas into which visuals for this eye should be
rendered. The <code class="idl"><a data-link-type="idl" href="#dom-vreyeparameters-renderrect">renderRect</a></code> for the left eye and right eye MUST NOT overlap,
and the <code class="idl"><a data-link-type="idl" href="#dom-vreyeparameters-renderrect">renderRect</a></code> for the rightEye MUST be to the right of the
<code class="idl"><a data-link-type="idl" href="#dom-vreyeparameters-renderrect">renderRect</a></code> for the left eye.</p>
<p>The union of the <code class="idl"><a data-link-type="idl" href="#dom-vreyeparameters-renderrect">renderRect</a></code>s for both eyes SHOULD describe the optimal
rendering resolution for the HMD when using <code class="idl"><a data-link-type="idl" href="#dom-vreyeparameters-currentfieldofview">currentFieldOfView</a></code>, such that
the center of the user’s view maintains a 1:1 pixel ratio after any distortion
to correct for HMD optics applied to the rendering.</p>
<div class="example" id="example-68926c2f"><a class="self-link" href="#example-68926c2f"></a>
Many HMDs will distort the rendered image to counteract undesired effects
introduced by the headset optics. Because of this the optimal resolution of the
canvas will often be larger than the HMD’s physical resolution to ensure that
the final image presented to the user has a 1:1 pixel ratio at the center of the
user’s view. The optimal canvas resolution can be calculated from the
<code class="idl"><a data-link-type="idl" href="#dom-vreyeparameters-renderrect">renderRect</a></code> for both eyes as follows:
<pre>var leftEyeParams = hmd.getEyeParameters("left");
var rightEyeParams = hmd.getEyeParameters("right");
var leftEyeRect = leftEyeParams.renderRect;
var rightEyeRect = rightEyeParams.renderRect;
canvas.width = rightEyeRect.x + rightEyeRect.width;
canvas.height = Math.max(leftEyeRect.y + leftEyeRect.height,
rightEyeRect.y + rightEyeRect.height);
</pre>
</div>
<h3 class="heading settled" data-level="4.5" id="vrdevice"><span class="secno">4.5. </span><span class="content">VRDevice</span><a class="self-link" href="#vrdevice"></a></h3>
<p>The <code class="idl"><a data-link-type="idl" href="#vrdevice0">VRDevice</a></code> interface forms the base of all VR devices supported by this API. It includes generic information such as device IDs and descriptions.</p>
<pre class="idl">interface <dfn class="idl-code" data-dfn-type="interface" data-export="" data-global-name="" id="vrdevice0">VRDevice<a class="self-link" href="#vrdevice0"></a></dfn> {
readonly attribute DOMString <a class="idl-code" data-global-name="VRDevice<interface>/hardwareUnitId<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMString " href="#dom-vrdevice-hardwareunitid">hardwareUnitId</a>;
readonly attribute DOMString <a class="idl-code" data-global-name="VRDevice<interface>/deviceId<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMString " href="#dom-vrdevice-deviceid">deviceId</a>;
readonly attribute DOMString <a class="idl-code" data-global-name="VRDevice<interface>/deviceName<attribute>" data-link-type="attribute" data-readonly="" data-type="DOMString " href="#dom-vrdevice-devicename">deviceName</a>;
};
</pre>
<h4 class="heading settled" data-level="4.5.1" id="vrdeviceattributes"><span class="secno">4.5.1. </span><span class="content">Attributes</span><a class="self-link" href="#vrdeviceattributes"></a></h4>
<p><dfn class="idl-code" data-dfn-for="VRDevice" data-dfn-type="attribute" data-export="" id="dom-vrdevice-hardwareunitid">hardwareUnitId<a class="self-link" href="#dom-vrdevice-hardwareunitid"></a></dfn>
An identifier for the distinct hardware unit that this <code class="idl"><a data-link-type="idl" href="#vrdevice0">VRDevice</a></code> is a part
of. Any <code class="idl"><a data-link-type="idl" href="#vrdevice0">VRDevice</a></code> that comes from the same physical piece of hardware will
have the same <code class="idl"><a data-link-type="idl" href="#dom-vrdevice-hardwareunitid">hardwareUnitId</a></code>.</p>
<p><dfn class="idl-code" data-dfn-for="VRDevice" data-dfn-type="attribute" data-export="" id="dom-vrdevice-deviceid">deviceId<a class="self-link" href="#dom-vrdevice-deviceid"></a></dfn>
An identifier for this distinct sensor/device on a physical hardware device.
This shouldn’t change across browser restarts, allowing configuration data to be
saved based on it.</p>
<p><dfn class="idl-code" data-dfn-for="VRDevice" data-dfn-type="attribute" data-export="" id="dom-vrdevice-devicename">deviceName<a class="self-link" href="#dom-vrdevice-devicename"></a></dfn>
A user-readable name identifying the device.</p>
<h3 class="heading settled" data-level="4.6" id="hmdvrdevice"><span class="secno">4.6. </span><span class="content">HMDVRDevice</span><a class="self-link" href="#hmdvrdevice"></a></h3>
<p>The <code class="idl"><a data-link-type="idl" href="#hmdvrdevice0">HMDVRDevice</a></code> interface represents a <code class="idl"><a data-link-type="idl" href="#vrdevice0">VRDevice</a></code> for a head-mounted display. It contains configuration and information about the HMD.</p>
<pre class="idl">interface <dfn class="idl-code" data-dfn-type="interface" data-export="" data-global-name="" id="hmdvrdevice0">HMDVRDevice<a class="self-link" href="#hmdvrdevice0"></a></dfn> : <a data-link-type="idl-name" href="#vrdevice0">VRDevice</a> {
<a data-link-type="idl-name" href="#vreyeparameters0">VREyeParameters</a> <a class="idl-code" data-global-name="HMDVRDevice<interface>/getEyeParameters(whichEye)<method>" data-link-type="method" href="#dom-hmdvrdevice-geteyeparameterswhicheye">getEyeParameters</a>(<a data-link-type="idl-name" href="#enumdef-vreye">VREye</a> <dfn class="idl-code" data-dfn-for="HMDVRDevice/getEyeParameters(whichEye)" data-dfn-type="argument" data-export="" data-global-name="HMDVRDevice<interface>/getEyeParameters(whichEye)<method>/whichEye<argument>" id="dom-hmdvrdevice-geteyeparameterswhicheye-whicheye">whichEye<a class="self-link" href="#dom-hmdvrdevice-geteyeparameterswhicheye-whicheye"></a></dfn>);
void <a class="idl-code" data-global-name="HMDVRDevice<interface>/setFieldOfView(leftFOV, rightFOV, zNear, zFar)<method>/setFieldOfView(leftFOV, rightFOV, zNear)<method>/setFieldOfView(leftFOV, rightFOV)<method>/setFieldOfView(leftFOV)<method>/setFieldOfView()<method>" data-link-type="method" href="#dom-hmdvrdevice-setfieldofviewleftfov-rightfov-znear-zfar">setFieldOfView</a>(optional <a data-link-type="idl-name" href="#dictdef-vrfieldofviewinit">VRFieldOfViewInit</a> <dfn class="idl-code" data-dfn-for="HMDVRDevice/setFieldOfView(leftFOV, rightFOV, zNear, zFar)" data-dfn-type="argument" data-export="" data-global-name="HMDVRDevice<interface>/setFieldOfView(leftFOV, rightFOV, zNear, zFar)<method>/leftFOV<argument>" id="dom-hmdvrdevice-setfieldofviewleftfov-rightfov-znear-zfar-leftfov">leftFOV<a class="self-link" href="#dom-hmdvrdevice-setfieldofviewleftfov-rightfov-znear-zfar-leftfov"></a></dfn>,
optional <a data-link-type="idl-name" href="#dictdef-vrfieldofviewinit">VRFieldOfViewInit</a> <dfn class="idl-code" data-dfn-for="HMDVRDevice/setFieldOfView(leftFOV, rightFOV, zNear, zFar)" data-dfn-type="argument" data-export="" data-global-name="HMDVRDevice<interface>/setFieldOfView(leftFOV, rightFOV, zNear, zFar)<method>/rightFOV<argument>" id="dom-hmdvrdevice-setfieldofviewleftfov-rightfov-znear-zfar-rightfov">rightFOV<a class="self-link" href="#dom-hmdvrdevice-setfieldofviewleftfov-rightfov-znear-zfar-rightfov"></a></dfn>,
optional double <dfn class="idl-code" data-dfn-for="HMDVRDevice/setFieldOfView(leftFOV, rightFOV, zNear, zFar)" data-dfn-type="argument" data-export="" data-global-name="HMDVRDevice<interface>/setFieldOfView(leftFOV, rightFOV, zNear, zFar)<method>/zNear<argument>" id="dom-hmdvrdevice-setfieldofviewleftfov-rightfov-znear-zfar-znear">zNear<a class="self-link" href="#dom-hmdvrdevice-setfieldofviewleftfov-rightfov-znear-zfar-znear"></a></dfn> = 0.01,
optional double <dfn class="idl-code" data-dfn-for="HMDVRDevice/setFieldOfView(leftFOV, rightFOV, zNear, zFar)" data-dfn-type="argument" data-export="" data-global-name="HMDVRDevice<interface>/setFieldOfView(leftFOV, rightFOV, zNear, zFar)<method>/zFar<argument>" id="dom-hmdvrdevice-setfieldofviewleftfov-rightfov-znear-zfar-zfar">zFar<a class="self-link" href="#dom-hmdvrdevice-setfieldofviewleftfov-rightfov-znear-zfar-zfar"></a></dfn> = 10000.0);
};
</pre>
<h4 class="heading settled" data-level="4.6.1" id="hmdvrdevicemethods"><span class="secno">4.6.1. </span><span class="content">Methods</span><a class="self-link" href="#hmdvrdevicemethods"></a></h4>
<p><dfn class="idl-code" data-dfn-for="HMDVRDevice" data-dfn-type="method" data-export="" data-lt="getEyeParameters(whichEye)" id="dom-hmdvrdevice-geteyeparameterswhicheye">getEyeParameters(VREye whichEye)<a class="self-link" href="#dom-hmdvrdevice-geteyeparameterswhicheye"></a></dfn>