Skip to content

Commit cbe1a32

Browse files
committed
JSDoc improvements
1 parent e08b538 commit cbe1a32

12 files changed

Lines changed: 258 additions & 75 deletions

File tree

src/gameobjects/pointlight/PointLight.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var Render = require('./PointLightRender');
1313

1414
/**
1515
* @classdesc
16-
*
1716
* TODO
1817
*
1918
* @class PointLight

src/math/RandomXYZW.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ var RandomXYZW = function (vec4, scale)
1919
{
2020
if (scale === undefined) { scale = 1; }
2121

22-
// TODO: Not spherical; should fix this for more uniform distribution
2322
vec4.x = (Math.random() * 2 - 1) * scale;
2423
vec4.y = (Math.random() * 2 - 1) * scale;
2524
vec4.z = (Math.random() * 2 - 1) * scale;

src/math/Vector4.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,6 @@ var Vector4 = new Class({
482482
*/
483483
transformQuat: function (q)
484484
{
485-
// TODO: is this really the same as Vector3?
486-
// Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/
487-
// benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations
488485
var x = this.x;
489486
var y = this.y;
490487
var z = this.z;
@@ -527,7 +524,6 @@ var Vector4 = new Class({
527524

528525
});
529526

530-
// TODO: Check if these are required internally, if not, remove.
531527
Vector4.prototype.sub = Vector4.prototype.subtract;
532528
Vector4.prototype.mul = Vector4.prototype.multiply;
533529
Vector4.prototype.div = Vector4.prototype.divide;

src/math/angle/ShortestBetween.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* greater than 0 then it's a counter-clockwise rotation, if < 0 then it's
1616
* a clockwise rotation.
1717
*
18-
* TODO: Wrap the angles in this function?
19-
*
2018
* @function Phaser.Math.Angle.ShortestBetween
2119
* @since 3.0.0
2220
*

src/physics/arcade/World.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@ var World = new Class({
15651565
overlap /= 2;
15661566
}
15671567

1568-
// TODO this is inadequate for circle-rectangle separation
1568+
// Note: This is inadequate for circle-rectangle separation
15691569

15701570
var angle = AngleBetweenPoints(body1.center, body2.center);
15711571
var overlapX = (overlap + MATH_CONST.EPSILON) * Math.cos(angle);

src/renderer/webgl/PipelineManager.js

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@ var UtilityPipeline = require('./pipelines/UtilityPipeline');
2121
/**
2222
* @classdesc
2323
* The Pipeline Manager is responsible for the creation, activation, running and destruction
24-
* of WebGL Pipelines in Phaser 3.
24+
* of WebGL Pipelines and Post FX Pipelines in Phaser 3.
2525
*
2626
* The `WebGLRenderer` owns a single instance of the Pipeline Manager, which you can access
2727
* via the `WebGLRenderer.pipelines` property.
2828
*
29-
* By default, there are 5 pipelines installed into the Pipeline Manager when Phaser boots:
29+
* By default, there are 8 pipelines installed into the Pipeline Manager when Phaser boots:
3030
*
31-
* 1. The Multi Pipeline. Responsible for all multi-texture rendering, i.e. Sprites, Shapes.
32-
* 2. The Single Pipeline. Responsible for rendering Game Objects that explicitly require one bound texture.
31+
* 1. The Multi Pipeline. Responsible for all multi-texture rendering, i.e. Sprites and Tilemaps.
32+
* 2. The Graphics Pipeline. Responsible for rendering Graphics and Shape objects.
3333
* 3. The Rope Pipeline. Responsible for rendering the Rope Game Object.
3434
* 4. The Light Pipeline. Responsible for rendering the Light Game Object.
35-
* 5. The Bitmap Mask Pipeline. Responsible for Bitmap Mask rendering.
35+
* 5. The Point Light Pipeline. Responsible for rendering the Point Light Game Object.
36+
* 6. The Single Pipeline. Responsible for rendering Game Objects that explicitly require one bound texture.
37+
* 7. The Bitmap Mask Pipeline. Responsible for Bitmap Mask rendering.
38+
* 8. The Utility Pipeline. Responsible for providing lots of handy texture manipulation functions.
3639
*
3740
* You can add your own custom pipeline via the `PipelineManager.add` method. Pipelines are
3841
* identified by unique string-based keys.
@@ -770,9 +773,7 @@ var PipelineManager = new Class({
770773
*/
771774
copyFrame: function (source, target, brightness, clear, clearAlpha)
772775
{
773-
var pipeline = this.setUtility(this.UTILITY_PIPELINE.copyShader);
774-
775-
pipeline.copyFrame(source, target, brightness, clear, clearAlpha);
776+
this.setUtility(this.UTILITY_PIPELINE.copyShader).copyFrame(source, target, brightness, clear, clearAlpha);
776777

777778
return this;
778779
},
@@ -794,9 +795,7 @@ var PipelineManager = new Class({
794795
*/
795796
copyToGame: function (source)
796797
{
797-
var pipeline = this.setUtility(this.UTILITY_PIPELINE.copyShader);
798-
799-
pipeline.copyToGame(source);
798+
this.setUtility(this.UTILITY_PIPELINE.copyShader).copyToGame(source);
800799

801800
return this;
802801
},
@@ -824,9 +823,7 @@ var PipelineManager = new Class({
824823
*/
825824
drawFrame: function (source, target, clearAlpha, colorMatrix)
826825
{
827-
var pipeline = this.setUtility(this.UTILITY_PIPELINE.colorMatrixShader);
828-
829-
pipeline.drawFrame(source, target, clearAlpha, colorMatrix);
826+
this.setUtility(this.UTILITY_PIPELINE.colorMatrixShader).drawFrame(source, target, clearAlpha, colorMatrix);
830827

831828
return this;
832829
},
@@ -850,9 +847,7 @@ var PipelineManager = new Class({
850847
*/
851848
blendFrames: function (source1, source2, target, strength, clearAlpha)
852849
{
853-
var pipeline = this.setUtility(this.UTILITY_PIPELINE.linearShader);
854-
855-
pipeline.blendFrames(source1, source2, target, strength, clearAlpha);
850+
this.setUtility(this.UTILITY_PIPELINE.linearShader).blendFrames(source1, source2, target, strength, clearAlpha);
856851

857852
return this;
858853
},
@@ -876,9 +871,7 @@ var PipelineManager = new Class({
876871
*/
877872
blendFramesAdditive: function (source1, source2, target, strength, clearAlpha)
878873
{
879-
var pipeline = this.setUtility(this.UTILITY_PIPELINE.addShader);
880-
881-
pipeline.blendFrames(source1, source2, target, strength, clearAlpha);
874+
this.setUtility(this.UTILITY_PIPELINE.addShader).blendFramesAdditive(source1, source2, target, strength, clearAlpha);
882875

883876
return this;
884877
},
@@ -891,6 +884,8 @@ var PipelineManager = new Class({
891884
*
892885
* @param {Phaser.Renderer.WebGL.RenderTarget} target - The Render Target to clear.
893886
* @param {boolean} [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
887+
*
888+
* @return {this} This Pipeline Manager instance.
894889
*/
895890
clearFrame: function (target, clearAlpha)
896891
{
@@ -899,6 +894,64 @@ var PipelineManager = new Class({
899894
return this;
900895
},
901896

897+
/**
898+
* Copy the `source` Render Target to the `target` Render Target.
899+
*
900+
* The difference with this copy is that no resizing takes place. If the `source`
901+
* Render Target is larger than the `target` then only a portion the same size as
902+
* the `target` dimensions is copied across.
903+
*
904+
* You can optionally set the brightness factor of the copy.
905+
*
906+
* @method Phaser.Renderer.WebGL.PipelineManager#blitFrame
907+
* @since 3.50.0
908+
*
909+
* @param {Phaser.Renderer.WebGL.RenderTarget} source - The source Render Target.
910+
* @param {Phaser.Renderer.WebGL.RenderTarget} target - The target Render Target.
911+
* @param {number} [brightness=1] - The brightness value applied to the frame copy.
912+
* @param {boolean} [clear=true] - Clear the target before copying?
913+
* @param {boolean} [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
914+
* @param {boolean} [eraseMode=false] - Erase source from target using ERASE Blend Mode?
915+
*
916+
* @return {this} This Pipeline Manager instance.
917+
*/
918+
blitFrame: function (source, target, brightness, clear, clearAlpha, eraseMode)
919+
{
920+
this.setUtility(this.UTILITY_PIPELINE.copyShader).blitFrame(source, target, brightness, clear, clearAlpha, eraseMode);
921+
922+
return this;
923+
},
924+
925+
/**
926+
* Binds the `source` Render Target and then copies a section of it to the `target` Render Target.
927+
*
928+
* This method is extremely fast because it uses `gl.copyTexSubImage2D` and doesn't
929+
* require the use of any shaders. Remember the coordinates are given in standard WebGL format,
930+
* where x and y specify the lower-left corner of the section, not the top-left. Also, the
931+
* copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes
932+
* place.
933+
*
934+
* @method Phaser.Renderer.WebGL.PipelineManager#copyFrameRect
935+
* @since 3.50.0
936+
*
937+
* @param {Phaser.Renderer.WebGL.RenderTarget} source - The source Render Target.
938+
* @param {Phaser.Renderer.WebGL.RenderTarget} target - The target Render Target.
939+
* @param {number} x - The x coordinate of the lower left corner where to start copying.
940+
* @param {number} y - The y coordinate of the lower left corner where to start copying.
941+
* @param {number} width - The width of the texture.
942+
* @param {number} height - The height of the texture.
943+
* @param {boolean} [clear=true] - Clear the target before copying?
944+
* @param {boolean} [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
945+
*
946+
* @return {this} This Pipeline Manager instance.
947+
*/
948+
copyFrameRect: function (source, target, x, y, width, height, clear, clearAlpha)
949+
{
950+
this.UTILITY_PIPELINE.copyFrameRect(source, target, x, y, width, height, clear, clearAlpha);
951+
952+
return this;
953+
},
954+
902955
/**
903956
* Returns `true` if the current pipeline is forced to use texture unit zero.
904957
*

src/renderer/webgl/pipelines/BitmapMaskPipeline.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ var WebGLPipeline = require('../WebGLPipeline');
1414

1515
/**
1616
* @classdesc
17-
*
1817
* The Bitmap Mask Pipeline handles all of the bitmap mask rendering in WebGL for applying
1918
* alpha masks to Game Objects. It works by sampling two texture on the fragment shader and
2019
* using the fragments alpha to clip the region.

src/renderer/webgl/pipelines/LightPipeline.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ var tempVec2 = new Vec2();
4141
* `inTintEffect` (float, offset 20)
4242
* `inTint` (vec4, offset 24, normalized)
4343
*
44-
* The default shader uniforms for this pipeline are:
44+
* The default shader uniforms for this pipeline are those from the Multi Pipeline, plus:
4545
*
46-
* `uProjectionMatrix` (mat4)
47-
* `uViewMatrix` (mat4)
48-
* `uModelMatrix` (mat4)
4946
* `uMainSampler` (sampler2D)
5047
* `uNormSampler` (sampler2D)
5148
* `uCamera` (vec4)

src/renderer/webgl/pipelines/PointLightPipeline.js

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,35 @@ var PointLightShaderSourceFS = require('../shaders/PointLight-frag.js');
1010
var PointLightShaderSourceVS = require('../shaders/PointLight-vert.js');
1111
var WebGLPipeline = require('../WebGLPipeline');
1212

13+
/**
14+
* @classdesc
15+
* The Point Light Pipeline handles rendering the Point Light Game Objects in WebGL.
16+
*
17+
* The fragment shader it uses can be found in `shaders/src/BitmapMask.frag`.
18+
* The vertex shader it uses can be found in `shaders/src/BitmapMask.vert`.
19+
*
20+
* The default shader attributes for this pipeline are:
21+
*
22+
* `inPosition` (vec2)
23+
* `inLightPosition` (vec2)
24+
* `inLightRadius` (float)
25+
* `inLightAttenuation` (float)
26+
* `inLightColor` (vec4)
27+
*
28+
* The default shader uniforms for this pipeline are:
29+
*
30+
* `uProjectionMatrix` (mat4)
31+
* `uResolution` (vec2)
32+
* `uCameraZoom` (sampler2D)
33+
*
34+
* @class PointLightPipeline
35+
* @extends Phaser.Renderer.WebGL.WebGLPipeline
36+
* @memberof Phaser.Renderer.WebGL.Pipelines
37+
* @constructor
38+
* @since 3.50.0
39+
*
40+
* @param {Phaser.Types.Renderer.WebGL.WebGLPipelineConfig} config - The configuration options for this pipeline.
41+
*/
1342
var PointLightPipeline = new Class({
1443

1544
Extends: WebGLPipeline,
@@ -32,9 +61,6 @@ var PointLightPipeline = new Class({
3261
{
3362
name: 'inLightRadius'
3463
},
35-
{
36-
name: 'inLightFalloff'
37-
},
3864
{
3965
name: 'inLightAttenuation'
4066
},
@@ -53,12 +79,30 @@ var PointLightPipeline = new Class({
5379
this.set1f('uCameraZoom', camera.zoom);
5480
},
5581

82+
/**
83+
* Adds a Point Light Game Object to the batch, flushing if required.
84+
*
85+
* @method Phaser.Renderer.WebGL.Pipelines.PointLightPipeline#batchPointLight
86+
* @since 3.50.0
87+
*
88+
* @param {Phaser.GameObjects.PointLight} light - The Point Light Game Object.
89+
* @param {Phaser.Cameras.Scene2D.Camera} camera - The camera rendering the Point Light.
90+
* @param {number} x0 - The top-left x position.
91+
* @param {number} y0 - The top-left y position.
92+
* @param {number} x1 - The bottom-left x position.
93+
* @param {number} y1 - The bottom-left y position.
94+
* @param {number} x2 - The bottom-right x position.
95+
* @param {number} y2 - The bottom-right y position.
96+
* @param {number} x3 - The top-right x position.
97+
* @param {number} y3 - The top-right y position.
98+
* @param {number} lightX - The horizontal center of the light.
99+
* @param {number} lightY - The vertical center of the light.
100+
*/
56101
batchPointLight: function (light, camera, x0, y0, x1, y1, x2, y2, x3, y3, lightX, lightY)
57102
{
58103
var color = light.color;
59104
var intensity = light.intensity;
60105
var radius = light.radius;
61-
var falloff = light.falloff;
62106
var attenuation = light.attenuation;
63107

64108
var r = color.r * intensity;
@@ -71,15 +115,35 @@ var PointLightPipeline = new Class({
71115
this.flush();
72116
}
73117

74-
this.batchLightVert(x0, y0, lightX, lightY, radius, falloff, attenuation, r, g, b, a);
75-
this.batchLightVert(x1, y1, lightX, lightY, radius, falloff, attenuation, r, g, b, a);
76-
this.batchLightVert(x2, y2, lightX, lightY, radius, falloff, attenuation, r, g, b, a);
77-
this.batchLightVert(x0, y0, lightX, lightY, radius, falloff, attenuation, r, g, b, a);
78-
this.batchLightVert(x2, y2, lightX, lightY, radius, falloff, attenuation, r, g, b, a);
79-
this.batchLightVert(x3, y3, lightX, lightY, radius, falloff, attenuation, r, g, b, a);
118+
this.batchLightVert(x0, y0, lightX, lightY, radius, attenuation, r, g, b, a);
119+
this.batchLightVert(x1, y1, lightX, lightY, radius, attenuation, r, g, b, a);
120+
this.batchLightVert(x2, y2, lightX, lightY, radius, attenuation, r, g, b, a);
121+
this.batchLightVert(x0, y0, lightX, lightY, radius, attenuation, r, g, b, a);
122+
this.batchLightVert(x2, y2, lightX, lightY, radius, attenuation, r, g, b, a);
123+
this.batchLightVert(x3, y3, lightX, lightY, radius, attenuation, r, g, b, a);
80124
},
81125

82-
batchLightVert: function (x, y, lightX, lightY, radius, falloff, attenuation, r, g, b, a)
126+
/**
127+
* Adds a single Point Light vertex to the current vertex buffer and increments the
128+
* `vertexCount` property by 1.
129+
*
130+
* This method is called directly by `batchPointLight`.
131+
*
132+
* @method Phaser.Renderer.WebGL.Pipelines.PointLightPipeline#batchLightVert
133+
* @since 3.50.0
134+
*
135+
* @param {number} x - The vertex x position.
136+
* @param {number} y - The vertex y position.
137+
* @param {number} lightX - The horizontal center of the light.
138+
* @param {number} lightY - The vertical center of the light.
139+
* @param {number} radius - The radius of the light.
140+
* @param {number} attenuation - The attenuation of the light.
141+
* @param {number} r - The red color channel of the light.
142+
* @param {number} g - The green color channel of the light.
143+
* @param {number} b - The blue color channel of the light.
144+
* @param {number} a - The alpha color channel of the light.
145+
*/
146+
batchLightVert: function (x, y, lightX, lightY, radius, attenuation, r, g, b, a)
83147
{
84148
var vertexViewF32 = this.vertexViewF32;
85149

@@ -90,7 +154,6 @@ var PointLightPipeline = new Class({
90154
vertexViewF32[++vertexOffset] = lightX;
91155
vertexViewF32[++vertexOffset] = lightY;
92156
vertexViewF32[++vertexOffset] = radius;
93-
vertexViewF32[++vertexOffset] = falloff;
94157
vertexViewF32[++vertexOffset] = attenuation;
95158
vertexViewF32[++vertexOffset] = r;
96159
vertexViewF32[++vertexOffset] = g;

0 commit comments

Comments
 (0)