user1773603
user1773603

Reputation:

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.

Upvotes: 6

Views: 398

Answers (1)

WestLangley
WestLangley

Reputation: 104843

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

arrowHelper.cone.visible = false;

three.js r.80

Upvotes: 5

Related Questions