PointLightHelper and SpotLightHelper positioning problem
See original GitHub issueDescription of the problem
When added to the light, PointLightHelper
and SpotLightHelper
have wrong position.
Their position relative to the light is the same as the position of the light in world coordinates, which causes displacement.
You can see it in the fiddle for PointLightHelper
, the box is of size (2,2,2) and the light is displaced by 1 along the x-axis. Correct behavior would be that the origin of the marker coincides with box side, however, it is double the distance.
https://jsfiddle.net/c14r0qmt/8/
I’ve found that the problem comes from copying the world matrix of the original light:
this.matrix = light.matrixWorld;
this.matrixAutoUpdate = false;
https://github.com/mrdoob/three.js/blob/dev/src/helpers/PointLightHelper.js#L14-L15 https://github.com/mrdoob/three.js/blob/dev/src/helpers/SpotLightHelper.js#L18-L19
Removing those lines solves the problem
Three.js version
- r120
Browser
- Chrome
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (3 by maintainers)
Top GitHub Comments
The management of helpers in
three.js
is not consistent and sometimes confusing as this issue proves. I personally think it’s way more intuitive if helper objects are attached to their reference objects and not added to the scene.I’m not sure if this topic was ever discussed at GitHub but this is a good opportunity to do so.
I have a suggestion.
I think we can override
updateMatrixWorld
in helpers so it just copies thematrixWorld
of the target object.That way it would not matter where in the scenegraph the user places the helper.
Helpers would behave as expected and users won’t have to think about this.
@WestLangley what do you think?