Skip to content

Commit

Permalink
motion-controller: Update version (aframe 1.5.0, aframe-typescript, a…
Browse files Browse the repository at this point in the history
…frame-typescript-helpers)
  • Loading branch information
mrxz committed Feb 5, 2024
1 parent 8d64596 commit 2c113c4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 38 deletions.
2 changes: 1 addition & 1 deletion motion-controller/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Fern A-Frame Components | Motion Controller</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<script src="https://aframe.io/releases/1.4.2/aframe.min.js"></script>
<script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
<script src="/js/aframe-motion-controller.umd.min.js"></script>
<script></script>
</head>
Expand Down
4 changes: 2 additions & 2 deletions motion-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"@rollup/plugin-typescript": "^11.1.1",
"@types/animejs": "3.1.0",
"@types/three": "0.147.1",
"aframe-types": "0.8.16",
"aframe-typescript": "0.8.1",
"aframe-types": "0.8.22",
"aframe-typescript": "0.8.2",
"concurrently": "^7.1.0",
"esbuild": "^0.18.17",
"rimraf": "^5.0.1",
Expand Down
6 changes: 3 additions & 3 deletions motion-controller/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'aframe';
export * from './motion-controller-model.component';
export * from './motion-controller-space.component';
export { MotionControllerSystem } from './motion-controller.system';
import './motion-controller-model.component';
import './motion-controller-space.component';
import './motion-controller.system';
2 changes: 1 addition & 1 deletion motion-controller/src/motion-controller-model.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type EnhancedVisualResponse = VisualResponse & {
maxNode?: THREE.Object3D
};

export const MotionControllerModelComponent = AFRAME.registerComponent('motion-controller-model', strict<{
const MotionControllerModelComponent = AFRAME.registerComponent('motion-controller-model', strict<{
motionControllerSystem: AFRAME.Systems['motion-controller'],
inputSourceRecord: InputSourceRecord|null,
motionController: MotionController|null,
Expand Down
2 changes: 1 addition & 1 deletion motion-controller/src/motion-controller-space.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as AFRAME from 'aframe';
import { strict } from 'aframe-typescript';

export const MotionControllerSpaceComponent = AFRAME.registerComponent('motion-controller-space', strict<{
const MotionControllerSpaceComponent = AFRAME.registerComponent('motion-controller-space', strict<{
motionControllerSystem: AFRAME.Systems['motion-controller'],
inputSource: XRInputSource|undefined,
}>().component({
Expand Down
19 changes: 8 additions & 11 deletions motion-controller/src/motion-controller.system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface InputSourceRecord {
jointState?: {poses: Float32Array, radii: Float32Array},
};

export const MotionControllerSystem = AFRAME.registerSystem('motion-controller', strict<{
const MotionControllerSystem = AFRAME.registerSystem('motion-controller', strict<{
/* Currently active XR session */
xrSession: XRSession|null;
/* List of active input sources */
Expand All @@ -37,10 +37,7 @@ export const MotionControllerSystem = AFRAME.registerSystem('motion-controller',
this.right = null;

if(this.data.enableHands && this.data.enableHandTracking) {
// DEBUG
//webXROptionalAttributes.push('hand-tracking');
(this.sceneEl as any).setAttribute('webxr', {optionalFeatures: ['hand-tracking']});
//sceneEl.setAttribute('webxr', {optionalFeatures: webXROptionalAttributes});
this.sceneEl.setAttribute('webxr', {optionalFeatures: ['hand-tracking']});
}

const onInputSourcesChange = (event: XRInputSourceChangeEvent) => {
Expand Down Expand Up @@ -95,7 +92,7 @@ export const MotionControllerSystem = AFRAME.registerSystem('motion-controller',
}

this.el.sceneEl.addEventListener('enter-vr', _ => {
this.xrSession = (<any>this.el.sceneEl).xrSession as XRSession;
this.xrSession = this.el.sceneEl.xrSession!;
if(this.xrSession) {
this.xrSession.addEventListener('inputsourceschange', onInputSourcesChange);
}
Expand Down Expand Up @@ -150,25 +147,25 @@ export const MotionControllerSystem = AFRAME.registerSystem('motion-controller',
if(newState.values.state !== oldButtonState) {
if(oldButtonState === 'touched') {
// No longer touched -> touchend
this.el.emit('touchend' as keyof AFRAME.EntityEvents, eventDetails);
this.el.emit('touchend', eventDetails);
} else if(oldButtonState === 'pressed') {
// No longer pressed -> buttonup
this.el.emit('buttonup' as keyof AFRAME.EntityEvents, eventDetails);
this.el.emit('buttonup', eventDetails);
}

if(newState.values.state === 'touched') {
// Now touched -> touchstart
this.el.emit('touchstart' as keyof AFRAME.EntityEvents, eventDetails);
this.el.emit('touchstart', eventDetails);
} else if(newState.values.state === 'pressed') {
// Now pressed -> buttondown
this.el.emit('buttondown' as keyof AFRAME.EntityEvents, eventDetails);
this.el.emit('buttondown', eventDetails);
}
}

if(newState.type === 'thumbstick' || newState.type === 'touchpad') {
if(oldXAxis !== newState.values.xAxis || oldYAxis !== newState.values.yAxis) {
// Value along axis changed
this.el.emit('axismove' as keyof AFRAME.EntityEvents, eventDetails);
this.el.emit('axismove', eventDetails);
}
}
}
Expand Down
27 changes: 8 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ __metadata:
"@types/animejs": "npm:3.1.0"
"@types/three": "npm:0.147.1"
"@webxr-input-profiles/motion-controllers": "npm:^1.0.0"
aframe-types: "npm:0.8.16"
aframe-typescript: "npm:0.8.1"
aframe-types: "npm:0.8.22"
aframe-typescript: "npm:0.8.2"
concurrently: "npm:^7.1.0"
esbuild: "npm:^0.18.17"
rimraf: "npm:^5.0.1"
Expand Down Expand Up @@ -666,16 +666,6 @@ __metadata:
languageName: node
linkType: hard

"aframe-types@npm:0.8.16":
version: 0.8.16
resolution: "aframe-types@npm:0.8.16"
peerDependencies:
"@types/animejs": 3.1.0
"@types/three": 0.147.1
checksum: e96d8c9899fd5321a6026b75e0a46896588b737769f3c443f75c98900b82977749170df56425affdfdb94f52f9ba42b98756a93126e3dcb28d8d4b596687145f
languageName: node
linkType: hard

"aframe-types@npm:0.8.20":
version: 0.8.20
resolution: "aframe-types@npm:0.8.20"
Expand All @@ -686,14 +676,13 @@ __metadata:
languageName: node
linkType: hard

"aframe-typescript@npm:0.8.1":
version: 0.8.1
resolution: "aframe-typescript@npm:0.8.1"
"aframe-types@npm:0.8.22":
version: 0.8.22
resolution: "aframe-types@npm:0.8.22"
peerDependencies:
"@types/animejs": "*"
"@types/three": "*"
aframe-types: "*"
checksum: 0ce636c425d53b6256a9bc0c62d11619bdb36e49982f22508f37858b8490db34de38767c9ff00c0b846c8baa6c7925d0033328d766cb0c68b5328b4edb2736ea
"@types/animejs": 3.1.0
"@types/three": 0.147.1
checksum: ecf7cd1f14af89dc84450281e1544a9fbf75222cf810c407fbdf3b0cfd3ada82b65a9c13040f5f9f91d0767c2d309eb4c535b7853257c0158a238d27f14b857e
languageName: node
linkType: hard

Expand Down

0 comments on commit 2c113c4

Please sign in to comment.