Skip to content

Commit 64bd1c5

Browse files
committed
linting
1 parent 0c5767f commit 64bd1c5

File tree

4 files changed

+86
-68
lines changed

4 files changed

+86
-68
lines changed

dist/super-hands.js

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -845,25 +845,30 @@ AFRAME.registerComponent('grabbable', inherit(base, {
845845
this.yFactor = (this.data.invert ? -1 : 1) * !this.data.suppressY;
846846
},
847847
tick: function () {
848-
var entityPosition;
849-
if (this.grabber) {
850-
// reflect on z-axis to point in same direction as the laser
851-
this.targetPosition.copy(this.grabDirection);
852-
this.targetPosition.applyQuaternion(this.grabber.object3D.getWorldQuaternion()).setLength(this.grabDistance).add(this.grabber.object3D.getWorldPosition()).add(this.grabOffset);
853-
if (this.deltaPositionIsValid) {
854-
// relative position changes work better with nested entities
855-
this.deltaPosition.sub(this.targetPosition);
856-
entityPosition = this.el.getAttribute('position');
857-
this.destPosition.x = entityPosition.x - this.deltaPosition.x * this.xFactor;
858-
this.destPosition.y = entityPosition.y - this.deltaPosition.y * this.yFactor;
859-
this.destPosition.z = entityPosition.z - this.deltaPosition.z * this.zFactor;
860-
this.el.setAttribute('position', this.destPosition);
861-
} else {
862-
this.deltaPositionIsValid = true;
848+
var q = new THREE.Quaternion();
849+
var v = new THREE.Vector3();
850+
851+
return function () {
852+
var entityPosition;
853+
if (this.grabber) {
854+
// reflect on z-axis to point in same direction as the laser
855+
this.targetPosition.copy(this.grabDirection);
856+
this.targetPosition.applyQuaternion(this.grabber.object3D.getWorldQuaternion(q)).setLength(this.grabDistance).add(this.grabber.object3D.getWorldPosition(v)).add(this.grabOffset);
857+
if (this.deltaPositionIsValid) {
858+
// relative position changes work better with nested entities
859+
this.deltaPosition.sub(this.targetPosition);
860+
entityPosition = this.el.getAttribute('position');
861+
this.destPosition.x = entityPosition.x - this.deltaPosition.x * this.xFactor;
862+
this.destPosition.y = entityPosition.y - this.deltaPosition.y * this.yFactor;
863+
this.destPosition.z = entityPosition.z - this.deltaPosition.z * this.zFactor;
864+
this.el.setAttribute('position', this.destPosition);
865+
} else {
866+
this.deltaPositionIsValid = true;
867+
}
868+
this.deltaPosition.copy(this.targetPosition);
863869
}
864-
this.deltaPosition.copy(this.targetPosition);
865-
}
866-
},
870+
};
871+
}(),
867872
remove: function () {
868873
this.el.removeEventListener(this.GRAB_EVENT, this.start);
869874
this.el.removeEventListener(this.UNGRAB_EVENT, this.end);
@@ -914,19 +919,23 @@ AFRAME.registerComponent('grabbable', inherit(base, {
914919
}
915920
},
916921
resetGrabber: function () {
917-
let raycaster;
918-
if (!this.grabber) {
919-
return false;
920-
}
921-
raycaster = this.grabber.getAttribute('raycaster');
922-
this.deltaPositionIsValid = false;
923-
this.grabDistance = this.el.object3D.getWorldPosition().distanceTo(this.grabber.object3D.getWorldPosition());
924-
if (raycaster) {
925-
this.grabDirection = raycaster.direction;
926-
this.grabOffset = raycaster.origin;
927-
}
928-
return true;
929-
},
922+
var objPos = new THREE.Vector3();
923+
var grabPos = new THREE.Vector3();
924+
return function () {
925+
let raycaster;
926+
if (!this.grabber) {
927+
return false;
928+
}
929+
raycaster = this.grabber.getAttribute('raycaster');
930+
this.deltaPositionIsValid = false;
931+
this.grabDistance = this.el.object3D.getWorldPosition(objPos).distanceTo(this.grabber.object3D.getWorldPosition(grabPos));
932+
if (raycaster) {
933+
this.grabDirection = raycaster.direction;
934+
this.grabOffset = raycaster.origin;
935+
}
936+
return true;
937+
};
938+
}(),
930939
lostGrabber: function (evt) {
931940
let i = this.grabbers.indexOf(evt.relatedTarget);
932941
// if a queued, non-physics grabber leaves the collision zone, forget it

dist/super-hands.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/build.js

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -81870,25 +81870,30 @@ AFRAME.registerComponent('grabbable', inherit(base, {
8187081870
this.yFactor = (this.data.invert ? -1 : 1) * !this.data.suppressY;
8187181871
},
8187281872
tick: function () {
81873-
var entityPosition;
81874-
if (this.grabber) {
81875-
// reflect on z-axis to point in same direction as the laser
81876-
this.targetPosition.copy(this.grabDirection);
81877-
this.targetPosition.applyQuaternion(this.grabber.object3D.getWorldQuaternion()).setLength(this.grabDistance).add(this.grabber.object3D.getWorldPosition()).add(this.grabOffset);
81878-
if (this.deltaPositionIsValid) {
81879-
// relative position changes work better with nested entities
81880-
this.deltaPosition.sub(this.targetPosition);
81881-
entityPosition = this.el.getAttribute('position');
81882-
this.destPosition.x = entityPosition.x - this.deltaPosition.x * this.xFactor;
81883-
this.destPosition.y = entityPosition.y - this.deltaPosition.y * this.yFactor;
81884-
this.destPosition.z = entityPosition.z - this.deltaPosition.z * this.zFactor;
81885-
this.el.setAttribute('position', this.destPosition);
81886-
} else {
81887-
this.deltaPositionIsValid = true;
81873+
var q = new THREE.Quaternion();
81874+
var v = new THREE.Vector3();
81875+
81876+
return function () {
81877+
var entityPosition;
81878+
if (this.grabber) {
81879+
// reflect on z-axis to point in same direction as the laser
81880+
this.targetPosition.copy(this.grabDirection);
81881+
this.targetPosition.applyQuaternion(this.grabber.object3D.getWorldQuaternion(q)).setLength(this.grabDistance).add(this.grabber.object3D.getWorldPosition(v)).add(this.grabOffset);
81882+
if (this.deltaPositionIsValid) {
81883+
// relative position changes work better with nested entities
81884+
this.deltaPosition.sub(this.targetPosition);
81885+
entityPosition = this.el.getAttribute('position');
81886+
this.destPosition.x = entityPosition.x - this.deltaPosition.x * this.xFactor;
81887+
this.destPosition.y = entityPosition.y - this.deltaPosition.y * this.yFactor;
81888+
this.destPosition.z = entityPosition.z - this.deltaPosition.z * this.zFactor;
81889+
this.el.setAttribute('position', this.destPosition);
81890+
} else {
81891+
this.deltaPositionIsValid = true;
81892+
}
81893+
this.deltaPosition.copy(this.targetPosition);
8188881894
}
81889-
this.deltaPosition.copy(this.targetPosition);
81890-
}
81891-
},
81895+
};
81896+
}(),
8189281897
remove: function () {
8189381898
this.el.removeEventListener(this.GRAB_EVENT, this.start);
8189481899
this.el.removeEventListener(this.UNGRAB_EVENT, this.end);
@@ -81939,19 +81944,23 @@ AFRAME.registerComponent('grabbable', inherit(base, {
8193981944
}
8194081945
},
8194181946
resetGrabber: function () {
81942-
let raycaster;
81943-
if (!this.grabber) {
81944-
return false;
81945-
}
81946-
raycaster = this.grabber.getAttribute('raycaster');
81947-
this.deltaPositionIsValid = false;
81948-
this.grabDistance = this.el.object3D.getWorldPosition().distanceTo(this.grabber.object3D.getWorldPosition());
81949-
if (raycaster) {
81950-
this.grabDirection = raycaster.direction;
81951-
this.grabOffset = raycaster.origin;
81952-
}
81953-
return true;
81954-
},
81947+
var objPos = new THREE.Vector3();
81948+
var grabPos = new THREE.Vector3();
81949+
return function () {
81950+
let raycaster;
81951+
if (!this.grabber) {
81952+
return false;
81953+
}
81954+
raycaster = this.grabber.getAttribute('raycaster');
81955+
this.deltaPositionIsValid = false;
81956+
this.grabDistance = this.el.object3D.getWorldPosition(objPos).distanceTo(this.grabber.object3D.getWorldPosition(grabPos));
81957+
if (raycaster) {
81958+
this.grabDirection = raycaster.direction;
81959+
this.grabOffset = raycaster.origin;
81960+
}
81961+
return true;
81962+
};
81963+
}(),
8195581964
lostGrabber: function (evt) {
8195681965
let i = this.grabbers.indexOf(evt.relatedTarget);
8195781966
// if a queued, non-physics grabber leaves the collision zone, forget it

reaction_components/grabbable.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ AFRAME.registerComponent('grabbable', inherit(base, {
4141
var q = new THREE.Quaternion()
4242
var v = new THREE.Vector3()
4343

44-
return function(){
44+
return function () {
4545
var entityPosition
4646
if (this.grabber) {
4747
// reflect on z-axis to point in same direction as the laser
@@ -68,7 +68,7 @@ AFRAME.registerComponent('grabbable', inherit(base, {
6868
this.deltaPosition.copy(this.targetPosition)
6969
}
7070
}
71-
})(),
71+
})(),
7272
remove: function () {
7373
this.el.removeEventListener(this.GRAB_EVENT, this.start)
7474
this.el.removeEventListener(this.UNGRAB_EVENT, this.end)
@@ -113,7 +113,7 @@ AFRAME.registerComponent('grabbable', inherit(base, {
113113
}
114114
if (evt.preventDefault) { evt.preventDefault() }
115115
},
116-
resetGrabber: function () {
116+
resetGrabber: (function () {
117117
var objPos = new THREE.Vector3()
118118
var grabPos = new THREE.Vector3()
119119
return function () {
@@ -129,8 +129,8 @@ AFRAME.registerComponent('grabbable', inherit(base, {
129129
this.grabOffset = raycaster.origin
130130
}
131131
return true
132-
};
133-
}(),
132+
}
133+
})(),
134134
lostGrabber: function (evt) {
135135
let i = this.grabbers.indexOf(evt.relatedTarget)
136136
// if a queued, non-physics grabber leaves the collision zone, forget it

0 commit comments

Comments
 (0)