Skip to content

Commit

Permalink
Handle negative scale values
Browse files Browse the repository at this point in the history
  • Loading branch information
jonobr1 committed Sep 21, 2024
1 parent 3e63c35 commit 0d683eb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
42 changes: 28 additions & 14 deletions src/renderers/webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,16 @@ const webgl = {
if (!(this._renderer.scale instanceof Vector)) {
this._renderer.scale = new Vector();
}
let sx, sy;
if (this._scale instanceof Vector) {
this._renderer.scale.x = this._scale.x * parent._renderer.scale.x;
this._renderer.scale.y = this._scale.y * parent._renderer.scale.y;
sx = this._scale.x * parent._renderer.scale.x;
sy = this._scale.y * parent._renderer.scale.y;
} else {
this._renderer.scale.x = this._scale * parent._renderer.scale.x;
this._renderer.scale.y = this._scale * parent._renderer.scale.y;
sx = this._scale * parent._renderer.scale.x;
sy = this._scale * parent._renderer.scale.y;
}
this._renderer.scale.x = sx < 0 ? -sx : sx;
this._renderer.scale.y = sy < 0 ? -sy : sy;

if (parentChanged) {
this._renderer.parent = parent;
Expand Down Expand Up @@ -839,13 +842,16 @@ const webgl = {
if (!(this._renderer.scale instanceof Vector)) {
this._renderer.scale = new Vector();
}
let sx, sy;
if (this._scale instanceof Vector) {
this._renderer.scale.x = this._scale.x * parent._renderer.scale.x;
this._renderer.scale.y = this._scale.y * parent._renderer.scale.y;
sx = this._scale.x * parent._renderer.scale.x;
sy = this._scale.y * parent._renderer.scale.y;
} else {
this._renderer.scale.x = this._scale * parent._renderer.scale.x;
this._renderer.scale.y = this._scale * parent._renderer.scale.y;
sx = this._scale * parent._renderer.scale.x;
sy = this._scale * parent._renderer.scale.y;
}
this._renderer.scale.x = sx < 0 ? -sx : sx;
this._renderer.scale.y = sy < 0 ? -sy : sy;

if (parentChanged) {
this._renderer.parent = parent;
Expand Down Expand Up @@ -1270,13 +1276,16 @@ const webgl = {
if (!(this._renderer.scale instanceof Vector)) {
this._renderer.scale = new Vector();
}
let sx, sy;
if (this._scale instanceof Vector) {
this._renderer.scale.x = this._scale.x * parent._renderer.scale.x;
this._renderer.scale.y = this._scale.y * parent._renderer.scale.y;
sx = this._scale.x * parent._renderer.scale.x;
sy = this._scale.y * parent._renderer.scale.y;
} else {
this._renderer.scale.x = this._scale * parent._renderer.scale.x;
this._renderer.scale.y = this._scale * parent._renderer.scale.y;
sx = this._scale * parent._renderer.scale.x;
sy = this._scale * parent._renderer.scale.y;
}
this._renderer.scale.x = sx < 0 ? -sx : sx;
this._renderer.scale.y = sy < 0 ? -sy : sy;

if (parentChanged) {
this._renderer.parent = parent;
Expand Down Expand Up @@ -1516,11 +1525,16 @@ const webgl = {
this._renderer.scale = new Vector();
}

let sx, sy;
if (this._scale instanceof Vector) {
this._renderer.scale.copy(this._scale);
sx = this._scale.x;
sy = this._scale.y;
} else {
this._renderer.scale.set(this._scale, this._scale);
sx = this._scale;
sy = this._scale;
}
this._renderer.scale.x = sx < 0 ? -sx : sx;
this._renderer.scale.y = sy < 0 ? -sy : sy;
}

return this.flagReset();
Expand Down
1 change: 1 addition & 0 deletions wiki/changelog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. The format

## Nightly

+ `Two.WebGLRenderer` correctly handles negative scale values
+ `Two.Path.noStroke`, `Two.Text.noStroke`, and derivative methods now include setting both the stroke color to `"none"` and the line width to 0
+ Fixed `Two.Arc` flag behavior for `Two.Arc.width` and `Two.Arc.height` properties

Expand Down

0 comments on commit 0d683eb

Please sign in to comment.