File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title: hide-on-enter-vr
3+ type: components
4+ layout: docs
5+ parent_section: components
6+ source_code: src/components/hide-on-enter-vr.js
7+ examples: [ ]
8+ ---
9+
10+ When the user enters VR this component will hide the entity by toggling it's ` visible ` state.
11+
12+ Depending on the immersive mode: VR or AR one might want to show / hide different entities.
13+
14+ ## Example
15+
16+ ``` html
17+ <a-entity hide-on-enter-vr ></a-entity >
18+ ```
19+
20+ ## Properties
21+
22+ None
23+
24+ ## Events
25+
26+ None
Original file line number Diff line number Diff line change 1+ var register = require ( '../core/component' ) . registerComponent ;
2+
3+ module . exports . Component = register ( 'hide-on-enter-vr' , {
4+ init : function ( ) {
5+ var self = this ;
6+ this . el . sceneEl . addEventListener ( 'enter-vr' , function ( ) {
7+ if ( self . el . sceneEl . is ( 'vr-mode' ) ) {
8+ self . el . object3D . visible = false ;
9+ }
10+ } ) ;
11+ this . el . sceneEl . addEventListener ( 'exit-vr' , function ( ) {
12+ self . el . object3D . visible = true ;
13+ } ) ;
14+ }
15+ } ) ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ require('./hand-tracking-controls');
1010require ( './hand-tracking-grab-controls' ) ;
1111require ( './hand-controls' ) ;
1212require ( './hide-on-enter-ar' ) ;
13+ require ( './hide-on-enter-vr' ) ;
1314require ( './hp-mixed-reality-controls' ) ;
1415require ( './layer' ) ;
1516require ( './laser-controls' ) ;
You can’t perform that action at this time.
0 commit comments