I am facing an issue with two different code snippets for drawing a vector along a direction defined by the directionVectorLocal
vector.
The first snippet is as follows:
var transportedVector = {
coordLocal,
arrowHelper,
directionVectorLocal,
directionVector
};
var arrowHelperTest = new THREE.ArrowHelper(transportedVector.directionVectorLocal.normalize(), originLocalBasis, 100);
camera.add(arrowHelperTest);
In this case, the arrow arrowHelperTest
appears correctly on the scene.
Now, moving on to the second snippet:
var arrowHelper;
var transportedVector = {
coordLocal,
arrowHelper,
directionVectorLocal,
directionVector
};
transportedVector.arrowHelper = new THREE.ArrowHelper(transportedVector.directionVectorLocal.normalize(), originLocalBasis, 100);
camera.add(transportedVector.arrowHelper);
In this case, the arrow transportedVector.arrowHelper
does not appear.
To resolve this issue, I have found that declaring "var arrowHelper;
" just before defining the transportedVector
object prevents a "
ReferenceError: arrowHelper is not defined
" error.
I am looking for a way to dynamically declare and define transportedVector.arrowHelper
within the transportedVector
object and display it in the scene. Any insights or solutions would be greatly appreciated.
Thank you.