@@ -4,17 +4,20 @@ import { Effect } from "./Effect.js";
44import fragmentShader from "./glsl/lens-distortion.frag" ;
55
66/**
7- * Lens distortion effect.
7+ * A lens distortion effect.
8+ *
89 * Original shader ported from https://github.com/ycw/three-lens-distortion
910 */
11+
1012export class LensDistortionEffect extends Effect {
1113
1214 /**
1315 * Constructs a new lens distortion effect.
16+ *
1417 * @param {Object } [options] - The options.
15- * @param {Vector2 } [options.distortion={x: 0, y: 0 } ] - The distortion value as vec2 .
16- * @param {Vector2 } [options.principalPoint={x: 0, y: 0} ] - The center point as vec2 .
17- * @param {Vector2 } [options.focalLength={x: 1, y: 1} ] - The focal length as vec2 .
18+ * @param {Vector2 } [options.distortion] - The distortion value.
19+ * @param {Vector2 } [options.principalPoint] - The center point.
20+ * @param {Vector2 } [options.focalLength] - The focal length.
1821 * @param {Number } [options.skew=0] - The skew value.
1922 */
2023 constructor ( {
@@ -26,7 +29,7 @@ export class LensDistortionEffect extends Effect {
2629
2730 super ( "LensDistortionEffect" , fragmentShader , {
2831 uniforms : new Map ( [
29- [ "distortion" , new Uniform ( distortion ) ] , // radial distortion coeff 0 // radial distortion coeff of term r^2
32+ [ "distortion" , new Uniform ( distortion ) ] ,
3033 [ "principalPoint" , new Uniform ( principalPoint ) ] ,
3134 [ "focalLength" , new Uniform ( focalLength ) ] ,
3235 [ "skew" , new Uniform ( skew ) ]
@@ -36,79 +39,71 @@ export class LensDistortionEffect extends Effect {
3639 }
3740
3841 /**
39- * Get distortion uniform value
42+ * The radial distortion coefficients. Default is (0, 0).
43+ *
4044 * @type {Vector2 }
4145 */
46+
4247 get distortion ( ) {
4348
4449 return this . uniforms . get ( "distortion" ) . value ;
4550
4651 }
4752
48- /**
49- * Set distortion uniform value
50- * @param {Vector2 } the distortion value
51- */
5253 set distortion ( value ) {
5354
5455 this . uniforms . get ( "distortion" ) . value = value ;
5556
5657 }
5758
5859 /**
59- * Get principal point uniform value
60+ * The principal point. Default is (0, 0).
61+ *
6062 * @type {Vector2 }
6163 */
64+
6265 get principalPoint ( ) {
6366
6467 return this . uniforms . get ( "principalPoint" ) . value ;
6568
6669 }
6770
68- /**
69- * Set principal point uniform value
70- * @param {Vector2 } the principle center point value
71- */
7271 set principalPoint ( value ) {
7372
7473 this . uniforms . get ( "principalPoint" ) . value = value ;
7574
7675 }
7776
7877 /**
79- * Get focal length uniform value
78+ * The focal length. Default is (1, 1).
79+ *
8080 * @type {Vector2 }
8181 */
82+
8283 get focalLength ( ) {
8384
8485 return this . uniforms . get ( "focalLength" ) . value ;
8586
8687 }
8788
88- /**
89- * Set focal length uniform value
90- * @param {Vector2 } the focal length value
91- */
9289 set focalLength ( value ) {
9390
9491 this . uniforms . get ( "focalLength" ) . value = value ;
9592
9693 }
9794
9895 /**
99- * Get skew uniform value
100- * @type {Vector2 }
96+ * The skew factor in radians.
97+ *
98+ * @type {Number }
10199 */
100+
102101 get skew ( ) {
103102
104103 return this . uniforms . get ( "skew" ) . value ;
105104
106105 }
107106
108- /**
109- * Set skew uniform value
110- * @param {Number } the skew value
111- */
112107 set skew ( value ) {
113108
114109 this . uniforms . get ( "skew" ) . value = value ;
0 commit comments