diff --git a/src/effects/DotScreenEffect.js b/src/effects/DotScreenEffect.js index 703ef200c..7dbc8b3ca 100644 --- a/src/effects/DotScreenEffect.js +++ b/src/effects/DotScreenEffect.js @@ -40,13 +40,14 @@ export class DotScreenEffect extends Effect { get angle() { - return Math.acos(this.uniforms.get("angle").value.y); + return this._angle; } set angle(value) { this.uniforms.get("angle").value.set(Math.sin(value), Math.cos(value)); + this._angle = value; } diff --git a/src/effects/HueSaturationEffect.js b/src/effects/HueSaturationEffect.js index b0954f993..09fd1b24f 100644 --- a/src/effects/HueSaturationEffect.js +++ b/src/effects/HueSaturationEffect.js @@ -87,8 +87,7 @@ export class HueSaturationEffect extends Effect { get hue() { - const hue = this.uniforms.get("hue").value; - return Math.acos((hue.x * 3.0 - 1.0) / 2.0); + return this._hue; } @@ -101,6 +100,7 @@ export class HueSaturationEffect extends Effect { (-Math.sqrt(3.0) * s - c + 1.0) / 3.0, (Math.sqrt(3.0) * s - c + 1.0) / 3.0 ); + this._hue = value; } diff --git a/src/effects/TiltShiftEffect.js b/src/effects/TiltShiftEffect.js index 748babd35..03f58ef9b 100644 --- a/src/effects/TiltShiftEffect.js +++ b/src/effects/TiltShiftEffect.js @@ -141,7 +141,7 @@ export class TiltShiftEffect extends Effect { get rotation() { - return Math.acos(this.uniforms.get("rotation").value.x); + return this._rotation; } @@ -149,6 +149,7 @@ export class TiltShiftEffect extends Effect { this.uniforms.get("rotation").value.set(Math.cos(value), Math.sin(value)); this.blurPass.blurMaterial.rotation = value; + this._rotation = value; } diff --git a/src/materials/TiltShiftBlurMaterial.js b/src/materials/TiltShiftBlurMaterial.js index c4acbe120..6d772dd20 100644 --- a/src/materials/TiltShiftBlurMaterial.js +++ b/src/materials/TiltShiftBlurMaterial.js @@ -95,13 +95,14 @@ export class TiltShiftBlurMaterial extends KawaseBlurMaterial { get rotation() { - return Math.acos(this.uniforms.rotation.value.x); + return this._rotation; } set rotation(value) { this.uniforms.rotation.value.set(Math.cos(value), Math.sin(value)); + this._rotation = value; } diff --git a/test/effects/DotScreenEffect.js b/test/effects/DotScreenEffect.js index d1a824e6a..c2856726d 100644 --- a/test/effects/DotScreenEffect.js +++ b/test/effects/DotScreenEffect.js @@ -9,3 +9,18 @@ test("can be created and destroyed", t => { t.pass(); }); + +test("returns the angle it was set to, including negative angles", t => { + + const object = new DotScreenEffect(); + + for(const value of [-2.5, -0.5, 0, 0.5, 2.5]) { + + object.angle = value; + t.true(Math.abs(object.angle - value) < 1e-6, `set ${value}, got ${object.angle}`); + + } + + object.dispose(); + +}); diff --git a/test/effects/HueSaturationEffect.js b/test/effects/HueSaturationEffect.js index cb37fb98f..a4ffb81f5 100644 --- a/test/effects/HueSaturationEffect.js +++ b/test/effects/HueSaturationEffect.js @@ -9,3 +9,18 @@ test("can be created and destroyed", t => { t.pass(); }); + +test("returns the hue it was set to, including negative angles", t => { + + const object = new HueSaturationEffect(); + + for(const value of [-2.5, -0.5, 0, 0.5, 2.5]) { + + object.hue = value; + t.true(Math.abs(object.hue - value) < 1e-6, `set ${value}, got ${object.hue}`); + + } + + object.dispose(); + +}); diff --git a/test/effects/TiltShiftEffect.js b/test/effects/TiltShiftEffect.js index 12ce62e34..7fe58c36c 100644 --- a/test/effects/TiltShiftEffect.js +++ b/test/effects/TiltShiftEffect.js @@ -9,3 +9,18 @@ test("can be created and destroyed", t => { t.pass(); }); + +test("returns the rotation it was set to, including negative angles", t => { + + const object = new TiltShiftEffect(); + + for(const value of [-2.5, -0.5, 0, 0.5, 2.5]) { + + object.rotation = value; + t.true(Math.abs(object.rotation - value) < 1e-6, `set ${value}, got ${object.rotation}`); + + } + + object.dispose(); + +}); diff --git a/test/materials/TiltShiftBlurMaterial.js b/test/materials/TiltShiftBlurMaterial.js index 27d2e8bb4..f7daa5eda 100644 --- a/test/materials/TiltShiftBlurMaterial.js +++ b/test/materials/TiltShiftBlurMaterial.js @@ -6,3 +6,18 @@ test("can be created", t => { t.truthy(new TiltShiftBlurMaterial()); }); + +test("returns the rotation it was set to, including negative angles", t => { + + const object = new TiltShiftBlurMaterial(); + + for(const value of [-2.5, -0.5, 0, 0.5, 2.5]) { + + object.rotation = value; + t.true(Math.abs(object.rotation - value) < 1e-6, `set ${value}, got ${object.rotation}`); + + } + + object.dispose(); + +});