-
-
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
feat: adds customizable colors to CameraHelper #23829
Conversation
const colorFrustum = new Color( 0xffaa00 ); | ||
const colorCone = new Color( 0xff0000 ); | ||
const colorUp = new Color( 0x00aaff ); | ||
const colorTarget = new Color( 0xffffff ); | ||
const colorCross = new Color( 0x333333 ); | ||
const _colorFrustum = new Color( colorFrustum ); | ||
const _colorCone = new Color( colorCone ); | ||
const _colorUp = new Color( colorUp ); | ||
const _colorTarget = new Color( colorTarget ); | ||
const _colorCross = new Color( colorCross ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This naming convention here is ugly, but I'd rather the arguments have the nice names - as they are user-facing
@@ -18,7 +18,7 @@ const _camera = /*@__PURE__*/ new Camera(); | |||
|
|||
class CameraHelper extends LineSegments { | |||
|
|||
constructor( camera ) { | |||
constructor( camera, colorFrustum = 0xffaa00, colorCone = 0xff0000, colorUp = 0x00aaff, colorTarget = 0xffffff, colorCross = 0x333333 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative API would be passing an object with all colors as
{
frustum: 0xff0000,
cone: 0xff00ff,
// ...etc
}
But I can't recall objects that also use this pattern, so this felt more appropriate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the object is a better approach. And it will also solve the naming problem.
How about... const helper = new THREE.CameraHelper( camera ).setColors( frustum, cone, up, target, cross ); |
@mrdoob that API would be nice indeed, but it would require require rebuilding the vertices and colors attributes OR a possibly signifcant refactor of the class to just update the colors buffer - moving the two buffers creation to a method. Think it's worth pursuing? 🤔 |
In the past we have agreed to no introduce larger ctor signatures nor
|
I'll give that a shot 👍 |
I think it's more clear if |
Closing in favor of #24235. |
Found myself needing to color-code camera helpers and wanting to use toned-down colors in other occasions.
This PR wouldn't let users change the colors after construction, but it could be a good middle ground - as helpers are cheap to rebuild anyway
Usage:
TODO