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 scaleInPlace to Color3 and Color4 #12734

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions packages/dev/core/src/Maths/math.color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,26 @@ export class Color3 {
}

/**
* Multiplies in place each rgb value by scale
* @param scale defines the scaling factor
* @returns the updated Color3
* Creates a new Color3 with the current Color3 values multiplied by scale
* @param scale defines the scaling factor to apply
* @returns a new Color3 object
*/
public scale(scale: number): Color3 {
return new Color3(this.r * scale, this.g * scale, this.b * scale);
}

/**
* Multiplies the Color3 values by the float "scale"
* @param scale defines the scaling factor to apply
* @returns the current updated Color3
*/
public scaleInPlace(scale: number): Color3 {
this.r *= scale;
this.g *= scale;
this.b *= scale;
return this;
}

/**
* Multiplies the rgb values by scale and stores the result into "result"
* @param scale defines the scaling factor
Expand Down Expand Up @@ -799,6 +811,19 @@ export class Color4 {
return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
}

/**
* Multiplies the Color4 values by the float "scale"
* @param scale defines the scaling factor to apply
* @returns the current updated Color4
*/
public scaleInPlace(scale: number): Color4 {
this.r *= scale;
this.g *= scale;
this.b *= scale;
this.a *= scale;
return this;
}

/**
* Multiplies the current Color4 values by scale and stores the result in "result"
* @param scale defines the scaling factor to apply
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/core/src/Meshes/transformNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export class TransformNode extends Node {
}

/**
* Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
* Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (1.0, 1.0, 1.0)).
*/
public get scaling(): Vector3 {
return this._scaling;
Expand Down