reset camera functioning

This commit is contained in:
Juni
2023-01-12 10:41:09 -05:00
parent 82fce7819d
commit 2abefd1896
12 changed files with 143 additions and 72 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,69 @@
/**
* Reset camera using rig element
*/
AFRAME.registerComponent('recenter-camera', {
schema: {
enabled: {default: true}
},
init: function () {
this.resetPosition = { x: 0, y:1.6, z:0 }
this.stepSize = .026
this.sceneEl = this.el.sceneEl;
this.recenterCamera = this.recenterCamera.bind(this);
this.upCamera = this.upCamera.bind(this);
this.downCamera = this.downCamera.bind(this);
this.rigEl = this.el;
this.el.sceneEl.addEventListener('recenter-camera', this.recenterCamera);
this.el.sceneEl.addEventListener('up-camera', this.upCamera);
this.el.sceneEl.addEventListener('down-camera', this.downCamera);
},
recenterCamera: function () {
console.log(this);
//if (!this.data.enabled) { return; }
const cameraEl = this.sceneEl.camera.el;
const cameraPosition = cameraEl.getAttribute("position");
const adjustedPosition = {
x: this.resetPosition.x - cameraPosition.x,
y: this.resetPosition.y - cameraPosition.y,
z: this.resetPosition.z - cameraPosition.z
}
this.rigEl.setAttribute("position", adjustedPosition);
},
upCamera: function () {
console.log(this);
this.resetPosition.y += this.stepSize;
//if (!this.data.enabled) { return; }
const rigPosition = this.rigEl.getAttribute("position");
const adjustedPosition = {
x: rigPosition.x,
y: rigPosition.y + this.stepSize,
z: this.rigPosition.z
}
this.rigEl.setAttribute("position", adjustedPosition);
},
downCamera: function () {
console.log(this);
this.resetPosition.y -= this.stepSize;
//if (!this.data.enabled) { return; }
const rigPosition = this.rigEl.getAttribute("position");
const adjustedPosition = {
x: rigPosition.x,
y: rigPosition.y - this.stepSize,
z: this.rigPosition.z
}
this.rigEl.setAttribute("position", adjustedPosition);
},
});

View File

@@ -26,6 +26,7 @@ AFRAME.registerComponent('recenter', {
var translationMatrix = new THREE.Matrix4();
return function () {
console.log("recenter called");
const el = this.el;
if (!this.data.enabled) { return; }

View File

@@ -133,7 +133,7 @@
sub-object="from: #cursorLaser; name: glow"></a-mixin>
<!-- Player. -->
<a-entity id="cameraRig">
<a-entity id="cameraRig" recenter-camera>
<a-entity id="camera" position="0 1.6 0.5" camera look-controls wasd-controls>
<a-entity
id="cameraCollider"
@@ -144,9 +144,8 @@
proxy-event__wallhitend="event: hitend; to: a-scene; as: wallhitend"
visible="false"></a-entity>
</a-entity>
</a-entity>
<a-entity
<a-entity
id="controllerRig"
proxy-event="event: recentered; to: #cameraRig; captureBubbles: true; as: recenter">
{% macro saber (hand, otherHand, bladeColor, beamColor) %}
@@ -237,6 +236,7 @@
{{ saber('right', 'left', '#256c43', 'cyan') }}
{{ saber('left', 'right', '#850e3e', 'pink') }}
</a-entity>
</a-entity>
<a-entity
id="stepback"

View File

@@ -54,6 +54,16 @@
proxy-event="event: click; to: a-scene; as: gamemenuexit">
<a-entity mixin="gameMenuButtonText" text="value: EXIT TO MENU"></a-entity>
</a-entity>
<a-entity
id="recenterButton"
mixin="gameMenuButton"
bind__visible="!isVictory"
bind-toggle__raycastable="isPaused || isGameOver"
position="0 -1.05 0"
proxy-event="event: click; to: a-scene; as: recenter-camera">
<a-entity mixin="gameMenuButtonText" text="value: Recenter Camera"></a-entity>
</a-entity>
<!-- Song info. -->
<a-entity id="gameMenuSongInfoContainer" position="0 -1.10421 0.15473" rotation="-20 0 0">

View File

@@ -287,23 +287,6 @@
proxy-event__accept="event: superkeyboardinput; to: a-scene; as: keyboardclose">
</a-entity>
<a-entity id="genreButtons" position="-0.55 0.2 -1.9">
<a-entity id="genreButton"
mixin="bigMenuButton"
bind-toggle__raycastable="menuActive && !genreMenuOpen && !isSearching && !genre"
bind__visible="menuActive && !genreMenuOpen && !isSearching && !genre"
proxy-event="event: click; to: a-scene; as: genremenuopen">
<a-entity mixin="font" text="align: center; color: #FFF; wrapCount: 20; value: BROWSE GENRES" position="0 -0.07 0.01"></a-entity>
</a-entity>
<a-entity id="clearGenreButton"
mixin="bigMenuButton"
bind-toggle__raycastable="menuActive && !!genre"
bind__visible="menuActive && !!genre"
proxy-event="event: click; to: a-scene; as: searchclear">
<a-entity mixin="font" text="align: center; color: #FFF; wrapCount: 20; value: CLEAR GENRE" position="0 -0.07 0.01"></a-entity>
</a-entity>
</a-entity>
<a-entity
id="backButton"
@@ -315,7 +298,7 @@
<a-entity mixin="font" text="align: center; color: #FFF; wrapCount: 20; value: BACK" position="0 -0.07 0.01"></a-entity>
</a-entity>
<a-entity id="searchButtons" position="0.55 0.2 -1.9">
<a-entity id="searchButtons" position="0 0.2 -1.9">
<a-entity id="searchButton"
mixin="bigMenuButton"
bind-toggle__raycastable="menuActive && !genreMenuOpen && !isSearching && !search.query"

View File

@@ -12,6 +12,6 @@
<a-entity
id="newsText"
mixin="font"
text="align: center; color: #FAFAFA; baseline: center; width: 1.6; value: Super Saber has been released!\n\nWe're still ironing out some bugs\nsuch as diagonal hits counting as misses\nand to be able to auto-adjust to your height.\n\nThanks for checking it out! \nLet us know of any issues.\n\nsupermedium.com/discord"
text="align: center; color: #FAFAFA; baseline: center; width: 1.6; value: Juni Saber?\n\nThis is a fork of Super Saber\nand is still a work in progress\n\nThanks for checking it out!"
position="0 -0.06621702172771315 0.001"></a-entity>
</a-entity>

View File

@@ -52,8 +52,8 @@
<a-entity id="logo" bind__visible="menuActive || isVictory" position="0 6 -7.5" rotation="90 0 0">
<a-entity id="logoGodraysObj" obj-model="obj: #logoGodraysObj" materials="name: logoadditive"></a-entity>
<a-entity id="logoBody" obj-model="obj: #logoObj" materials="name: logo"></a-entity>
<a-entity id="logoFrontU" obj-model="obj: #logofrontUObj" materials="name: logo" logoflicker="delay: 1200" bind__logoflicker="active: menuActive || isVictory"></a-entity>
<!-- <a-entity id="logoBody" obj-model="obj: #logoObj" materials="name: logo"></a-entity> -->
<!-- <a-entity id="logoFrontU" obj-model="obj: #logofrontUObj" materials="name: logo" logoflicker="delay: 1200" bind__logoflicker="active: menuActive || isVictory"></a-entity> -->
<a-entity id="logoGlowObj" obj-model="obj: #logoGlowObj" materials="name: logoadditive"></a-entity>
</a-entity>

View File

@@ -63415,7 +63415,7 @@ function extend() {
},{}],51:[function(_dereq_,module,exports){
module.exports={
"name": "aframe",
"version": "0.9.1",
"version": "0.9.2",
"description": "A web framework for building virtual reality experiences.",
"homepage": "https://aframe.io/",
"main": "dist/aframe-master.js",
@@ -63434,7 +63434,7 @@ module.exports={
"lint:fix": "semistandard --fix",
"precommit": "npm run lint",
"prepush": "node scripts/testOnlyCheck.js",
"prerelease": "node scripts/release.js 0.9.0 0.9.1",
"prerelease": "node scripts/release.js 0.9.1 0.9.2",
"start": "npm run dev",
"start:https": "cross-env SSL=true npm run dev",
"test": "karma start ./tests/karma.conf.js",
@@ -72590,7 +72590,7 @@ var proto = Object.create(ANode.prototype, {
destroy: {
value: function () {
var key;
if (this.el.parentNode) {
if (this.parentNode) {
warn('Entity can only be destroyed if detached from scenegraph.');
return;
}
@@ -74445,6 +74445,34 @@ module.exports.AScene = registerElement('a-scene', {
initMetaTags(this);
initWakelock(this);
// Handler to exit VR (e.g., Oculus Browser back button).
this.onVRPresentChangeBound = bind(this.onVRPresentChange, this);
window.addEventListener('vrdisplaypresentchange', this.onVRPresentChangeBound);
// Bind functions.
this.enterVRBound = function () { self.enterVR(); };
this.exitVRBound = function () { self.exitVR(); };
this.exitVRTrueBound = function () { self.exitVR(true); };
this.pointerRestrictedBound = function () { self.pointerRestricted(); };
this.pointerUnrestrictedBound = function () { self.pointerUnrestricted(); };
if (!isWebXRAvailable) {
// Exit VR on `vrdisplaydeactivate` (e.g. taking off Rift headset).
window.addEventListener('vrdisplaydeactivate', this.exitVRBound);
// Exit VR on `vrdisplaydisconnect` (e.g. unplugging Rift headset).
window.addEventListener('vrdisplaydisconnect', this.exitVRTrueBound);
// Register for mouse restricted events while in VR
// (e.g. mouse no longer available on desktop 2D view)
window.addEventListener('vrdisplaypointerrestricted', this.pointerRestrictedBound);
// Register for mouse unrestricted events while in VR
// (e.g. mouse once again available on desktop 2D view)
window.addEventListener('vrdisplaypointerunrestricted',
this.pointerUnrestrictedBound);
}
// Camera set up by camera system.
this.addEventListener('cameraready', function () {
self.attachedCallbackPostCamera();
@@ -74477,36 +74505,6 @@ module.exports.AScene = registerElement('a-scene', {
// Add to scene index.
scenes.push(this);
// Handler to exit VR (e.g., Oculus Browser back button).
this.onVRPresentChangeBound = bind(this.onVRPresentChange, this);
window.addEventListener('vrdisplaypresentchange', this.onVRPresentChangeBound);
// bind functions
this.enterVRBound = function () { self.enterVR(); };
this.exitVRBound = function () { self.exitVR(); };
this.exitVRTrueBound = function () { self.exitVR(true); };
this.pointerRestrictedBound = function () { self.pointerRestricted(); };
this.pointerUnrestrictedBound = function () { self.pointerUnrestricted(); };
if (!isWebXRAvailable) {
// Enter VR on `vrdisplayactivate` (e.g. putting on Rift headset).
window.addEventListener('vrdisplayactivate', this.enterVRBound);
// Exit VR on `vrdisplaydeactivate` (e.g. taking off Rift headset).
window.addEventListener('vrdisplaydeactivate', this.exitVRBound);
// Exit VR on `vrdisplaydisconnect` (e.g. unplugging Rift headset).
window.addEventListener('vrdisplaydisconnect', this.exitVRTrueBound);
// Register for mouse restricted events while in VR
// (e.g. mouse no longer available on desktop 2D view)
window.addEventListener('vrdisplaypointerrestricted', this.pointerRestrictedBound);
// Register for mouse unrestricted events while in VR
// (e.g. mouse once again available on desktop 2D view)
window.addEventListener('vrdisplaypointerunrestricted', this.pointerUnrestrictedBound);
}
},
writable: window.debug
},
@@ -74638,6 +74636,11 @@ module.exports.AScene = registerElement('a-scene', {
enterVRSuccess();
});
} else {
if (vrDisplay.isPresenting &&
!window.hasNativeWebVRImplementation) {
enterVRSuccess();
return Promise.resolve();
}
var rendererSystem = this.getAttribute('renderer');
var presentationAttributes = {
highRefreshRate: rendererSystem.highRefreshRate,
@@ -75157,6 +75160,11 @@ function requestFullscreen (canvas) {
}
function exitFullscreen () {
var fullscreenEl =
document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement;
if (!fullscreenEl) { return; }
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
@@ -75300,7 +75308,7 @@ var constants = _dereq_('../../constants/');
var extend = _dereq_('../../utils').extend;
var MOBILE_HEAD_TAGS = module.exports.MOBILE_HEAD_TAGS = [
Meta({name: 'viewport', content: 'width=device-width,initial-scale=1,maximum-scale=1,shrink-to-fit=no,user-scalable=no,minimal-ui'}),
Meta({name: 'viewport', content: 'width=device-width,initial-scale=1,maximum-scale=1,shrink-to-fit=no,user-scalable=no,minimal-ui,viewport-fit=cover'}),
// W3C-standardised meta tags.
Meta({name: 'mobile-web-app-capable', content: 'yes'}),
@@ -77016,7 +77024,7 @@ _dereq_('./core/a-mixin');
_dereq_('./extras/components/');
_dereq_('./extras/primitives/');
console.log('A-Frame Version: 0.9.1 (Date 2019-04-18, Commit #0ea981b)');
console.log('A-Frame Version: 0.9.2 (Date 2019-05-06, Commit #f57a1fa)');
console.log('three Version (https://github.com/supermedium/three.js):',
pkg.dependencies['super-three']);
console.log('WebVR Polyfill Version:', pkg.dependencies['webvr-polyfill']);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long