-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Added support for VR headsets that do not provide stageParameters #3000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
bb747ff
f1284ea
20da7d5
cd29160
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| var registerComponent = require('../core/component').registerComponent; | ||
| var THREE = require('../lib/three'); | ||
| var DEFAULT_CAMERA_HEIGHT = require('../constants').DEFAULT_CAMERA_HEIGHT; | ||
| var bind = require('../utils/bind'); | ||
|
|
||
| // To avoid recalculation at every mouse movement tick | ||
|
|
@@ -17,7 +18,9 @@ module.exports.Component = registerComponent('look-controls', { | |
| enabled: {default: true}, | ||
| hmdEnabled: {default: true}, | ||
| reverseMouseDrag: {default: false}, | ||
| standing: {default: true} | ||
| standing: {default: true}, | ||
| userHeight: {default: 0}, | ||
| headElement: {type: 'selector'} | ||
|
||
| }, | ||
|
|
||
| init: function () { | ||
|
|
@@ -54,11 +57,21 @@ module.exports.Component = registerComponent('look-controls', { | |
| var data = this.data; | ||
| if (!data.enabled) { return; } | ||
| this.controls.standing = data.standing; | ||
| this.controls.userHeight = this.getUserHeight(); | ||
| this.controls.update(); | ||
| this.updateOrientation(); | ||
| this.updatePosition(); | ||
| }, | ||
|
|
||
| /** | ||
| * Return user height to use for standing poses, where a device doesn't provide an offset. | ||
| */ | ||
| getUserHeight: function () { | ||
| var headEl = this.data.headElement || this.el.sceneEl.camera.el; | ||
|
||
| var headCamera = headEl.components.camera; | ||
| return (headCamera ? headCamera.data.userHeight : 0) || DEFAULT_CAMERA_HEIGHT; | ||
| }, | ||
|
|
||
| play: function () { | ||
| this.addEventListeners(); | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| var CANVAS_GRAB_CLASS = 'a-grab-cursor'; | ||
| var GRABBING_CLASS = 'a-grabbing'; | ||
| var DEFAULT_USER_HEIGHT = 1.6; | ||
|
|
||
| suite('look-controls', function () { | ||
| setup(function (done) { | ||
|
|
@@ -52,4 +53,27 @@ suite('look-controls', function () { | |
| window.dispatchEvent(new Event('mouseup')); | ||
| }); | ||
| }); | ||
|
|
||
| suite('head-height', function () { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the tests! |
||
| test('Return head height from camera device', function (done) { | ||
| var el = this.sceneEl; | ||
| var cameraEl = el.camera.el; | ||
| var cameraHeight = 2.5; | ||
| var lookControls = el.camera.el.components['look-controls']; | ||
| cameraEl.setAttribute('camera', 'userHeight', cameraHeight); | ||
|
|
||
| assert.shallowDeepEqual(lookControls.getUserHeight(), cameraHeight); | ||
| done(); | ||
| }); | ||
|
|
||
| test('Return default head height for poses where device does not provide an offset', function (done) { | ||
| var el = this.sceneEl; | ||
| var lookControls = el.camera.el.components['look-controls']; | ||
| var cameraEl = el.camera.el; | ||
| cameraEl.components.camera = null; | ||
|
|
||
| assert.shallowDeepEqual(lookControls.getUserHeight(), DEFAULT_USER_HEIGHT); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using this property anywhere? it seems you are using
userHeightfrom the camera component ingetUserHeight