Skip to content
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

Add generic Renderer type and Color4 #741

Conversation

schwyzl
Copy link
Contributor

@schwyzl schwyzl commented Jan 9, 2024

Added type definitions for the new generic Renderer type for the WebGPU Renderer. Also added the new Color4 type referenced by Renderer.

Copy link
Contributor

@Methuselah96 Methuselah96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

export default class Color4 extends Color {
constructor(r: number, g: number, b: number, a?: number);

set(...args: [color: Color4Representation] | [r: number, g: number, b: number, a?: number]): this;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like Color4.set can handle a Color4 correctly. Maybe we should just stick with ColorRepresentation instead of Color4Representation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to try

@@ -255,7 +255,7 @@ export class Color {
* Copies given color.
* @param color Color to copy.
*/
copy(color: Color): this;
copy(color: this): this;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a benefit to changing the parameter to this? Seems like it could still just take a Color (and Color4.copy() could take a Color4)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The benefit was that it wouldn't need redefinition in Color4, but I neglected to remove the definition from Color4.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer me to make the change and remove the definition from color4 or define in both color and color4?

Copy link
Contributor

@Methuselah96 Methuselah96 Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine either way, I can't think of a situation where it would make a difference.

/**
* @default true
*/
isRenderer: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually type these as readonly since they're not supposed to be modified:

readonly isRenderer: true;

Comment on lines 121 to 129
/**
* Sets the custom opaque sort function for the RenderLists. Pass null to use the default painterSortStable function.
*/
setOpaqueSort(method: (a: any, b: any) => number): void;

/**
* Sets the custom transparent sort function for the RenderLists. Pass null to use the default reversePainterSortStable function.
*/
setTransparentSort(method: (a: any, b: any) => number): void;
Copy link
Contributor

@Methuselah96 Methuselah96 Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use unknown instead of any?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I can amend that no problem

@@ -0,0 +1,11 @@
import { Color, ColorRepresentation } from '../../../../src/math/Color.ts';

export type Color4Representation = ColorRepresentation | Color4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this type is unused now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I will remove

Copy link
Contributor

@Methuselah96 Methuselah96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Methuselah96 Methuselah96 merged commit 7ae6a96 into three-types:master Jan 15, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants