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

Improvement to WebGL Rendering: Handle Negative Scales #738

Merged
merged 2 commits into from
Sep 21, 2024
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
44 changes: 29 additions & 15 deletions build/two.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ var Two = (() => {
canvas: "CanvasRenderer"
},
Version: "v0.8.15",
PublishDate: "2024-07-09T17:21:48.285Z",
PublishDate: "2024-09-21T04:27:00.542Z",
Identifier: "two-",
Resolution: 12,
AutoCalculateImportedMatrices: true,
Expand Down Expand Up @@ -9475,13 +9475,16 @@ var Two = (() => {
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 @@ -9671,13 +9674,16 @@ var Two = (() => {
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 @@ -9970,13 +9976,16 @@ var Two = (() => {
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 @@ -10147,11 +10156,16 @@ var Two = (() => {
if (!(this._renderer.scale instanceof Vector)) {
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
4 changes: 2 additions & 2 deletions build/two.min.js

Large diffs are not rendered by default.

44 changes: 29 additions & 15 deletions build/two.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ var Constants = {
canvas: "CanvasRenderer"
},
Version: "v0.8.15",
PublishDate: "2024-07-09T17:21:48.285Z",
PublishDate: "2024-09-21T04:27:00.542Z",
Identifier: "two-",
Resolution: 12,
AutoCalculateImportedMatrices: true,
Expand Down Expand Up @@ -9456,13 +9456,16 @@ var 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 @@ -9652,13 +9655,16 @@ var 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 @@ -9951,13 +9957,16 @@ var 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 @@ -10128,11 +10137,16 @@ var webgl = {
if (!(this._renderer.scale instanceof Vector)) {
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
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
Loading