Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three.js - Remove the head of an ArrowHelper

I have created in my code an ArrowHelper and I update its parameters by calling the function below (each call of this function updates the ArrowHelper dimensions) :

function updateArrowHelper() {

    // Update parameters for transportedVector
    transportedVector.arrowHelper.setLength(transportedVector.coordLocal.length(), headLengthVector, headWidthVector);
  transportedVector.arrowHelper.setDirection(directionVector.normalize());
  transportedVector.arrowHelper.position.copy(coordTorus);
  transportedVector.arrowHelper.line.material.linewidth = widthVector;
  transportedVector.arrowHelper.setColor(hexVector);
  // Set head length and width to zero if dirVector.length is zero
  if (transportedVector.coordLocal.length() == 0.0)
        transportedVector.arrowHelper.setLength(0, 0, 0);    
}

I would like to make disappear the head of ArrowHelper if its length (given by transportedVector.coordLocal.length()) is zero, what I have done with :

 // Set head length and width to zero if dirVector.length is zero
      if (transportedVector.coordLocal.length() == 0.0)
        transportedVector.arrowHelper.setLength(0, 0, 0);

But at the execution, this doesn't work : even the length is null, once function is called, the head is still displayed and I don't know why ?

If anyone could see what's wrong.

Thanks in advance.

like image 575
youpilat13 Avatar asked Aug 26 '16 02:08

youpilat13


1 Answers

You can hide the head of the ArrowHelperby using this pattern:

arrowHelper.cone.visible = false;

three.js r.80

like image 196
WestLangley Avatar answered Oct 15 '22 11:10

WestLangley