-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a mouse based cursor / raycaster and applies to the link traversa…
…l example
- Loading branch information
Showing
13 changed files
with
124 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
examples/showcase/link-traversal/js/components/camera-position.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* global AFRAME */ | ||
AFRAME.registerComponent('camera-position', { | ||
schema: { | ||
mobile: {type: 'vec3', default: '0 1.6 3'}, | ||
desktop: {type: 'vec3', default: '0 1.6 3'} | ||
}, | ||
init: function () { | ||
this.onCameraSetActive = this.onCameraSetActive.bind(this); | ||
this.resetCamera = this.resetCamera.bind(this); | ||
this.el.addEventListener('camera-set-active', this.onCameraSetActive); | ||
this.el.addEventListener('exit-vr', this.onCameraSetActive); | ||
this.el.addEventListener('enter-vr', this.resetCamera); | ||
}, | ||
|
||
onCameraSetActive: function () { | ||
var cameraEl = this.el.camera.el; | ||
var data = this.data; | ||
var isMobile = AFRAME.utils.device.isMobile(); | ||
var position = isMobile ? data.mobile : data.desktop; | ||
var savedPose = cameraEl.components.camera.savedPose; | ||
if (savedPose) { savedPose.position.z = position.z; } | ||
this.el.camera.el.setAttribute('position', position); | ||
}, | ||
|
||
resetCamera: function () { | ||
var cameraEl = this.el.camera.el; | ||
var position = cameraEl.getAttribute('position'); | ||
cameraEl.setAttribute('position', { | ||
x: position.x, | ||
y: position.y, | ||
z: 0 | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters