Skip to content

Commit 3d8b725

Browse files
authored
fix appearance of raycaster (fixes #4882) (#4884)
1 parent 7b1f945 commit 3d8b725

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/components/raycaster.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ module.exports.Component = registerComponent('raycaster', {
102102
if (data.showLine &&
103103
(data.far !== oldData.far || data.origin !== oldData.origin ||
104104
data.direction !== oldData.direction || !oldData.showLine)) {
105-
// Calculate unit vector for line direction. Can be multiplied via scalar to performantly
106-
// adjust line length.
107-
this.unitLineEndVec3.copy(data.origin).add(data.direction).normalize();
105+
// Calculate unit vector for line direction. Can be multiplied via scalar and added
106+
// to orign to adjust line length.
107+
this.unitLineEndVec3.copy(data.direction).normalize();
108108
this.drawLine();
109109
}
110110

@@ -386,9 +386,10 @@ module.exports.Component = registerComponent('raycaster', {
386386
}
387387

388388
// Update the length of the line if given. `unitLineEndVec3` is the direction
389-
// given by data.direction, then we apply a scalar to give it a length.
389+
// given by data.direction, then we apply a scalar to give it a length and the
390+
// origin point to offset it.
390391
this.lineData.start = data.origin;
391-
this.lineData.end = endVec3.copy(this.unitLineEndVec3).multiplyScalar(length);
392+
this.lineData.end = endVec3.copy(this.unitLineEndVec3).multiplyScalar(length).add(data.origin);
392393
this.lineData.color = data.lineColor;
393394
this.lineData.opacity = data.lineOpacity;
394395
el.setAttribute('line', this.lineData);

0 commit comments

Comments
 (0)