Skip to content

Commit c7736c4

Browse files
authored
Allow components to define before/after constraints (#5478)
* Allow components to define before/after constraints * Fix bug preventing runtime registered components from being sorted into componentOrder * Move order logic into a-scene.js and introduce callComponentBehaviors method --------- Co-authored-by: Noeri Huisman <mrxz@users.noreply.github.com>
1 parent 81f9626 commit c7736c4

17 files changed

+486
-192
lines changed

‎examples/showcase/tracked-controls/components/grab.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Updates its position to move along the controller.
77
*/
88
AFRAME.registerComponent('grab', {
9+
after: ['tracked-controls-webxr'],
10+
before: ['aabb-collider'],
911
init: function () {
1012
this.GRABBED_STATE = 'grabbed';
1113
// Bind event handlers
@@ -67,6 +69,7 @@ AFRAME.registerComponent('grab', {
6769
y: position.y + this.deltaPosition.y,
6870
z: position.z + this.deltaPosition.z
6971
});
72+
hitEl.object3D.updateMatrixWorld();
7073
},
7174

7275
updateDelta: function () {

‎src/components/cursor.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ module.exports.Component = registerComponent('cursor', {
5353
rayOrigin: {default: 'entity', oneOf: ['mouse', 'entity', 'xrselect']}
5454
},
5555

56+
after: ['tracked-controls'],
57+
5658
multiple: true,
5759

5860
init: function () {

‎src/components/generic-tracked-controller-controls.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module.exports.Component = registerComponent('generic-tracked-controller-control
4242
disabled: {default: false}
4343
},
4444

45+
after: ['tracked-controls'],
46+
4547
/**
4648
* Button IDs:
4749
* 0 - trackpad

‎src/components/hand-controls.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ module.exports.Component = registerComponent('hand-controls', {
5555
handModelStyle: {default: 'lowPoly', oneOf: ['lowPoly', 'highPoly', 'toon']}
5656
},
5757

58+
after: ['tracked-controls'],
59+
5860
init: function () {
5961
var self = this;
6062
var el = this.el;

‎src/components/hand-tracking-controls.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ module.exports.Component = registerComponent('hand-tracking-controls', {
5656
modelOpacity: {default: 1.0}
5757
},
5858

59+
after: ['tracked-controls'],
60+
5961
bindMethods: function () {
6062
this.onControllersUpdate = this.onControllersUpdate.bind(this);
6163
this.checkIfControllerPresent = this.checkIfControllerPresent.bind(this);

‎src/components/oculus-touch-controls.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
197197
orientationOffset: {type: 'vec3', default: {x: 43, y: 0, z: 0}}
198198
},
199199

200+
after: ['tracked-controls'],
201+
200202
mapping: INPUT_MAPPING,
201203

202204
bindMethods: function () {

‎src/components/tracked-controls.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ module.exports.Component = registerComponent('tracked-controls', {
2626
space: {type: 'string', oneOf: ['targetRaySpace', 'gripSpace'], default: 'targetRaySpace'}
2727
},
2828

29+
// Run after both tracked-controls-webvr and tracked-controls-webxr to allow other components
30+
// to be after either without having to list them both.
31+
after: ['tracked-controls-webvr', 'tracked-controls-webxr'],
32+
2933
update: function () {
3034
var data = this.data;
3135
var el = this.el;

‎src/components/valve-index-controls.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ module.exports.Component = registerComponent('valve-index-controls', {
5555
orientationOffset: {type: 'vec3'}
5656
},
5757

58+
after: ['tracked-controls'],
59+
5860
mapping: {
5961
axes: {
6062
trackpad: [0, 1],

‎src/components/vive-controls.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ module.exports.Component = registerComponent('vive-controls', {
6565
orientationOffset: {type: 'vec3'}
6666
},
6767

68+
after: ['tracked-controls'],
69+
6870
mapping: INPUT_MAPPING,
6971

7072
init: function () {

‎src/components/vive-focus-controls.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ module.exports.Component = registerComponent('vive-focus-controls', {
5555
armModel: {default: true}
5656
},
5757

58+
after: ['tracked-controls'],
59+
5860
mapping: INPUT_MAPPING,
5961

6062
bindMethods: function () {

0 commit comments

Comments
 (0)