Skip to content

Commit

Permalink
Fix: remove this.camera.
Browse files Browse the repository at this point in the history
  • Loading branch information
extraymond committed Jul 4, 2019
1 parent 1edd01c commit 6e5c326
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import AFRAME from "aframe";

AFRAME.registerSystem("track-cursor", {
init: function() {
this.el.addEventListener("camera-set-active", () => {
this.el.setAttribute("cursor", { rayOrigin: "mouse" });
})
this.el.setAttribute("cursor", { rayOrigin: "mouse" });
}
});

Expand Down Expand Up @@ -34,7 +32,7 @@ AFRAME.registerComponent("dragndrop", {
} else if (e.detail == "dragging") {
this.dist = this.el.object3D.position
.clone()
.sub(this.camera.object3D.position)
.sub(this.el.sceneEl.camera.el.object3D.position)
.length();
}
},
Expand All @@ -48,8 +46,6 @@ AFRAME.registerComponent("dragndrop", {
},
init: function() {
this.range = 0;
this.scene = this.el.sceneEl;
this.camera = this.scene.camera.el;
this.dist = 0;
this.direction = new AFRAME.THREE.Vector3();
this.target = new AFRAME.THREE.Vector3();
Expand All @@ -62,11 +58,12 @@ AFRAME.registerComponent("dragndrop", {
});
},
updateDirection: function() {
this.direction.copy(this.scene.getAttribute("raycaster").direction);
this.direction.copy(this.el.sceneEl.getAttribute("raycaster").direction);
},
updateTarget: function() {
let camera = this.el.sceneEl.camera.el
this.target.copy(
this.camera.object3D.position
camera.object3D.position
.clone()
.add(this.direction.clone().multiplyScalar(this.dist + this.range))
);
Expand Down

0 comments on commit 6e5c326

Please sign in to comment.