-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PointLightHelper and SpotLightHelper positioning problem #20311
Comments
The implementation assumes that both helpers are always added to the scene and not as a child to their reference object. |
Got it, I was led by the reimplementation of Thinking about it, does it make sense to add the helper separately though? IMHO, adding it to the light and not having to care about it separately afterwards makes more sense. |
The management of helpers in I'm not sure if this topic was ever discussed at GitHub but this is a good opportunity to do so. |
This topic has been discussed, and the convention from the early days of three.js has been helpers must be added a child of the scene. The exception, now, is To make light helpers internally-consistent, see #14658, the primary objective of which is to remove targets from lights. EDIT: To clarify, if lights were governed by their quaternion, then we could add all light helpers as a child of the light. |
Any chances to share the respective GitHub issue? Besides, only because it was discussed once it does not mean the right decision was made. |
#3470 is from 2013. Maybe it will be helpful in understanding the history of this. |
I have a suggestion. I think we can override 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? |
As a test, I got your idea to work with I had to use |
I think |
I'd be keen to help out with this. |
BTW: If this.matrix = light.matrixWorld; I mean changing the value of I think it would be better if Object.defineProperties( this, {
position: {
configurable: true,
enumerable: true,
value: position
},
rotation: {
configurable: true,
enumerable: true,
value: rotation
},
quaternion: {
configurable: true,
enumerable: true,
value: quaternion
},
scale: {
configurable: true,
enumerable: true,
value: scale
},
modelViewMatrix: {
value: new Matrix4()
},
normalMatrix: {
value: new Matrix3()
}
} ); |
Unfortunately, this design can easily lead to frame-late effects like described in #21427. Having a reference of the target object's world matrix does not mean it is up-to-date. |
The OP's original problem was actually solved. Closing. |
Description of the problem
When added to the light,
PointLightHelper
andSpotLightHelper
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:
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
Browser
The text was updated successfully, but these errors were encountered: