src/components/raycaster.js
function (length) {
    var data = this.data;
    var el = this.el;
    var endVec3;

    // Switch each time vector so line update triggered and to avoid unnecessary vector clone.
    endVec3 = this.lineData.end === this.lineEndVec3
      ? this.otherLineEndVec3
      : this.lineEndVec3;

    // Treat Infinity as 1000m for the line.
    if (length === undefined) {
      length = data.far === Infinity ? 1000 : data.far;
    }

    // Update the length of the line if given. `unitLineEndVec3` is the direction
    // given by data.direction, then we apply a scalar to give it a length.
    this.lineData.start = data.origin;
    this.lineData.end = endVec3.copy(this.unitLineEndVec3).multiplyScalar(length);
    el.setAttribute('line', this.lineData);
  }
function (length) {
    var data = this.data;
    var el = this.el;
    var endVec3;

    // Switch each time vector so line update triggered and to avoid unnecessary vector clone.
    endVec3 = this.lineData.end === this.lineEndVec3
      ? this.otherLineEndVec3
      : this.lineEndVec3;

    // Treat Infinity as 1000m for the line.
    if (length === undefined) {
      length = data.far === Infinity ? 1000 : data.far;
    }

    // Update the length of the line if given. `unitLineEndVec3` is the direction
    // given by data.direction, then we apply a scalar to give it a length.
    this.lineData.start = data.origin;
    this.lineData.end = endVec3.copy(this.unitLineEndVec3).multiplyScalar(length);
    el.setAttribute('line', this.lineData);
  }
function ( length ) { var data = this . data ; var el = this . el ; var endVec3 ; // Switch each time vector so line update triggered and to avoid unnecessary vector clone. endVec3 = this . lineData . end === this . lineEndVec3 ? this . otherLineEndVec3 : this . lineEndVec3 ; // Treat Infinity as 1000m for the line. if ( length === undefined ) { length = data . far === Infinity ? 1000 : data . far ; } // Update the length of the line if given. `unitLineEndVec3` is the direction // given by data.direction, then we apply a scalar to give it a length. this . lineData . start = data . origin ; this . lineData . end = endVec3 . copy ( this . unitLineEndVec3 ) . multiplyScalar ( length ) ; el . setAttribute ( 'line' , this . lineData ) ; }
Create or update line to give raycaster visual representation.
Customize the line through through line component.
We draw the line in the raycaster component to customize the line to the
raycaster's origin, direction, and far.

Unlike the raycaster, we create the line as a child of the object. The line will
be affected by the transforms of the objects, so we don't have to calculate transforms
like we do with the raycaster.

@param {number} length - Length of line. Pass in to shorten the line to the intersection
point. If not provided, length will default to the max length, `raycaster.far`.
Create or update line to give raycaster visual representation . Customize the line through through line component . We draw the line in the raycaster component to customize the line to the raycaster s origin direction and far .