melonjs 20.10.1 → 20.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +3 -5
  2. package/build/application/application.d.ts.map +1 -1
  3. package/build/application/defaultApplicationSettings.d.ts +1 -0
  4. package/build/application/defaultApplicationSettings.d.ts.map +1 -1
  5. package/build/application/settings.d.ts +48 -1
  6. package/build/application/settings.d.ts.map +1 -1
  7. package/build/audio/audio.d.ts +14 -4
  8. package/build/audio/audio.d.ts.map +1 -1
  9. package/build/audio/playback.d.ts.map +1 -1
  10. package/build/audio/types.d.ts +19 -1
  11. package/build/audio/types.d.ts.map +1 -1
  12. package/build/camera/camera2d.d.ts +48 -4
  13. package/build/camera/camera2d.d.ts.map +1 -1
  14. package/build/camera/effects/shake_effect.d.ts +3 -1
  15. package/build/camera/effects/shake_effect.d.ts.map +1 -1
  16. package/build/index.d.ts +4 -2
  17. package/build/index.d.ts.map +1 -1
  18. package/build/index.js +3174 -1038
  19. package/build/index.js.map +4 -4
  20. package/build/level/tiled/TMXLayer.d.ts +1 -1
  21. package/build/level/tiled/TMXLayer.d.ts.map +1 -1
  22. package/build/level/tiled/TMXObject.d.ts +196 -1
  23. package/build/level/tiled/TMXObject.d.ts.map +1 -1
  24. package/build/level/tiled/TMXObjectFactory.d.ts +18 -5
  25. package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
  26. package/build/level/tiled/TMXTile.d.ts.map +1 -1
  27. package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
  28. package/build/level/tiled/TMXTileset.d.ts +17 -1
  29. package/build/level/tiled/TMXTileset.d.ts.map +1 -1
  30. package/build/level/tiled/TMXUtils.d.ts.map +1 -1
  31. package/build/level/tiled/factories/shape.d.ts.map +1 -1
  32. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
  33. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
  34. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
  35. package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
  36. package/build/lighting/light2d.d.ts +30 -0
  37. package/build/lighting/light2d.d.ts.map +1 -1
  38. package/build/particles/emitter.d.ts.map +1 -1
  39. package/build/particles/particle.d.ts.map +1 -1
  40. package/build/particles/settings.d.ts +25 -0
  41. package/build/particles/settings.d.ts.map +1 -1
  42. package/build/physics/builtin/raycast.d.ts.map +1 -1
  43. package/build/physics/builtin/sat.d.ts +40 -1
  44. package/build/physics/builtin/sat.d.ts.map +1 -1
  45. package/build/renderable/animation.d.ts +10 -1
  46. package/build/renderable/animation.d.ts.map +1 -1
  47. package/build/renderable/colorlayer.d.ts.map +1 -1
  48. package/build/renderable/container.d.ts +22 -2
  49. package/build/renderable/container.d.ts.map +1 -1
  50. package/build/renderable/frameAnimation.d.ts.map +1 -1
  51. package/build/renderable/imagelayer.d.ts.map +1 -1
  52. package/build/renderable/renderable.d.ts +69 -1
  53. package/build/renderable/renderable.d.ts.map +1 -1
  54. package/build/renderable/sprite.d.ts +19 -7
  55. package/build/renderable/sprite.d.ts.map +1 -1
  56. package/build/renderable/sprite3d.d.ts +5 -3
  57. package/build/renderable/sprite3d.d.ts.map +1 -1
  58. package/build/renderable/text/text.d.ts.map +1 -1
  59. package/build/state/stage.d.ts +9 -2
  60. package/build/state/stage.d.ts.map +1 -1
  61. package/build/system/timer.d.ts +1 -0
  62. package/build/system/timer.d.ts.map +1 -1
  63. package/build/utils/fetchdata.d.ts.map +1 -1
  64. package/build/video/buffer/vertex.d.ts.map +1 -1
  65. package/build/video/canvas/canvas_renderer.d.ts +7 -7
  66. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  67. package/build/video/effects/ambientlight.d.ts +2 -0
  68. package/build/video/effects/ambientlight.d.ts.map +1 -0
  69. package/build/video/effects/bloom.d.ts +7 -9
  70. package/build/video/effects/bloom.d.ts.map +1 -1
  71. package/build/video/effects/blur.d.ts +3 -2
  72. package/build/video/effects/blur.d.ts.map +1 -1
  73. package/build/video/effects/chromaticAberration.d.ts +3 -2
  74. package/build/video/effects/chromaticAberration.d.ts.map +1 -1
  75. package/build/video/effects/dissolve.d.ts +5 -2
  76. package/build/video/effects/dissolve.d.ts.map +1 -1
  77. package/build/video/effects/dropShadow.d.ts +15 -3
  78. package/build/video/effects/dropShadow.d.ts.map +1 -1
  79. package/build/video/effects/flash.d.ts +6 -2
  80. package/build/video/effects/flash.d.ts.map +1 -1
  81. package/build/video/effects/frame.d.ts +48 -0
  82. package/build/video/effects/frame.d.ts.map +1 -0
  83. package/build/video/effects/glow.d.ts +8 -4
  84. package/build/video/effects/glow.d.ts.map +1 -1
  85. package/build/video/effects/glsl_realization.d.ts.map +1 -1
  86. package/build/video/effects/hologram.d.ts +5 -2
  87. package/build/video/effects/hologram.d.ts.map +1 -1
  88. package/build/video/effects/outline.d.ts +8 -4
  89. package/build/video/effects/outline.d.ts.map +1 -1
  90. package/build/video/effects/pixelate.d.ts +3 -2
  91. package/build/video/effects/pixelate.d.ts.map +1 -1
  92. package/build/video/effects/radialGradient.d.ts +9 -4
  93. package/build/video/effects/radialGradient.d.ts.map +1 -1
  94. package/build/video/effects/rgba.d.ts +2 -0
  95. package/build/video/effects/rgba.d.ts.map +1 -0
  96. package/build/video/effects/shadereffect.d.ts +13 -0
  97. package/build/video/effects/shadereffect.d.ts.map +1 -1
  98. package/build/video/effects/shine.d.ts +5 -2
  99. package/build/video/effects/shine.d.ts.map +1 -1
  100. package/build/video/effects/squish.d.ts.map +1 -1
  101. package/build/video/effects/sway.d.ts +64 -0
  102. package/build/video/effects/sway.d.ts.map +1 -0
  103. package/build/video/effects/tintPulse.d.ts +5 -2
  104. package/build/video/effects/tintPulse.d.ts.map +1 -1
  105. package/build/video/effects/wave.d.ts +17 -0
  106. package/build/video/effects/wave.d.ts.map +1 -1
  107. package/build/video/effects/wgsl/scaffold.d.ts.map +1 -1
  108. package/build/video/effects/wgsl_realization.d.ts.map +1 -1
  109. package/build/video/gpu/frame.d.ts +2 -0
  110. package/build/video/gpu/frame.d.ts.map +1 -0
  111. package/build/video/renderer.d.ts +35 -11
  112. package/build/video/renderer.d.ts.map +1 -1
  113. package/build/video/rendertarget/canvasrendertarget.d.ts +14 -4
  114. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  115. package/build/video/rendertarget/rendertarget.d.ts +12 -16
  116. package/build/video/rendertarget/rendertarget.d.ts.map +1 -1
  117. package/build/video/texture/atlas.d.ts +23 -4
  118. package/build/video/texture/atlas.d.ts.map +1 -1
  119. package/build/video/texture/cache.d.ts.map +1 -1
  120. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  121. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  122. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  123. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  124. package/build/video/webgl/glshader.d.ts.map +1 -1
  125. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  126. package/build/video/webgl/shaders/frameclamp.d.ts +2 -0
  127. package/build/video/webgl/shaders/frameclamp.d.ts.map +1 -0
  128. package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
  129. package/build/video/webgl/shaders/multitexture.d.ts.map +1 -1
  130. package/build/video/webgl/utils/uniforms.d.ts.map +1 -1
  131. package/build/video/webgl/webgl_renderer.d.ts +0 -21
  132. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  133. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +2 -1
  134. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -1
  135. package/build/video/webgpu/batchers/quad_batcher.d.ts +2 -2
  136. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
  137. package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -1
  138. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  139. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
  140. package/package.json +21 -19
  141. package/skills/melonjs-audio/SKILL.md +22 -1
  142. package/skills/melonjs-camera-and-drawing/SKILL.md +63 -1
  143. package/skills/melonjs-display-and-scaling/SKILL.md +98 -2
  144. package/skills/melonjs-effects-and-shaders/SKILL.md +89 -7
  145. package/skills/melonjs-lighting/SKILL.md +39 -5
  146. package/skills/melonjs-math/SKILL.md +21 -1
  147. package/skills/melonjs-particles-and-trails/SKILL.md +36 -2
  148. package/skills/melonjs-performance/SKILL.md +1 -0
  149. package/skills/melonjs-renderables/SKILL.md +42 -3
  150. package/skills/melonjs-sprites-and-animation/SKILL.md +19 -3
  151. package/skills/melonjs-tilemaps/SKILL.md +126 -4
@@ -1 +1 @@
1
- {"version":3,"file":"dropShadow.d.ts","sourceRoot":"","sources":["../../../src/video/effects/dropShadow.js"],"names":[],"mappings":"AAyCA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;;;;;OAQG;IACH,sBARW,QAAQ,YAEhB;QAAyB,OAAO;QACP,OAAO;QACL,KAAK;QACP,OAAO;QACL,WAAW;KACxC,EA0CA;IAED;;;;OAIG;IACH,aAHW,MAAM,KACN,MAAM,QAIhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBA9HwB,mBAAmB;0BAOnB,gBAAgB"}
1
+ {"version":3,"file":"dropShadow.d.ts","sourceRoot":"","sources":["../../../src/video/effects/dropShadow.js"],"names":[],"mappings":"AA6CA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACC;;;;;;;;OAQG;IACH,sBARW,QAAQ,YAEhB;QAAyB,OAAO;QACP,OAAO;QACL,KAAK;QACP,OAAO;QACL,WAAW;KACxC,EA0CA;IAED;;;;OAIG;IACH,aAHW,MAAM,KACN,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBA/IwB,mBAAmB;0BAOnB,gBAAgB"}
@@ -18,12 +18,16 @@
18
18
  * @example
19
19
  * // red flash
20
20
  * const flash = new FlashEffect(renderer, { color: [1.0, 0.0, 0.0] });
21
+ * @example
22
+ * // a hit flash that only half covers the sprite, even at full intensity
23
+ * const hit = new FlashEffect(renderer, { color: [1.0, 1.0, 1.0, 0.5] });
24
+ * hit.setIntensity(1.0);
21
25
  */
22
26
  export default class FlashEffect extends ShaderEffect {
23
27
  /**
24
28
  * @param {Renderer} renderer - the current renderer instance
25
29
  * @param {object} [options] - effect options
26
- * @param {number[]} [options.color=[1.0, 1.0, 1.0]] - flash color as [r, g, b] (0.0–1.0)
30
+ * @param {number[]} [options.color=[1.0, 1.0, 1.0]] - flash color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha scales the intensity
27
31
  * @param {number} [options.intensity=0.0] - initial flash intensity (0.0–1.0)
28
32
  */
29
33
  constructor(renderer: Renderer, options?: {
@@ -38,7 +42,7 @@ export default class FlashEffect extends ShaderEffect {
38
42
  setIntensity(value: number): void;
39
43
  /**
40
44
  * set the flash color
41
- * @param {number[]} color - flash color as [r, g, b] (0.0–1.0)
45
+ * @param {number[]} color - flash color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha scales the intensity
42
46
  */
43
47
  setColor(color: number[]): void;
44
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flash.d.ts","sourceRoot":"","sources":["../../../src/video/effects/flash.js"],"names":[],"mappings":"AAuBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACC;;;;;OAKG;IACH,sBALW,QAAQ,YAEhB;QAA2B,KAAK;QACP,SAAS;KACpC,EAkBA;IAJA,kBAAyC;IAM1C;;;OAGG;IACH,oBAFW,MAAM,QAKhB;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;CACD;yBAtFwB,mBAAmB;0BAOnB,gBAAgB"}
1
+ {"version":3,"file":"flash.d.ts","sourceRoot":"","sources":["../../../src/video/effects/flash.js"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;IACC;;;;;OAKG;IACH,sBALW,QAAQ,YAEhB;QAA2B,KAAK;QACP,SAAS;KACpC,EAmBA;IAJA,kBAAyC;IAM1C;;;OAGG;IACH,oBAFW,MAAM,QAKhB;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;CACD;yBA5FwB,mBAAmB;0BAOnB,gBAAgB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Keeping an effect's samples inside the sprite's own frame.
3
+ *
4
+ * A sprite drawn from an atlas or a tileset shows one frame of a bigger
5
+ * texture, and the texture goes on past that frame into the neighbouring
6
+ * ones. An effect that samples away from the fragment it shades (a glow, an
7
+ * outline, a blur, a shadow, a distortion) reads those neighbours along the
8
+ * frame's edge, and draws them. `frameTexel()` reads a texel of the frame
9
+ * the effect draws, `ME_frame` (its UV rect: left, top, right, bottom):
10
+ * transparent outside it, and kept half a texel (`ME_frame_half`, in UV)
11
+ * inside it, so filtering never reaches over the edge. Only where another
12
+ * frame could be: a side of the frame that is the texture's own edge is
13
+ * left unbounded, and so is a pass over a whole texture (a render target
14
+ * blit, a mesh). There, sampling is what it always was.
15
+ *
16
+ * On a sprite, `ME_frame` comes with the quad: every sprite vertex carries
17
+ * the UV of its quad's opposite corner (`aFrame`), and the effect's vertex
18
+ * stage turns it into the frame. Sprites drawn from different frames
19
+ * through the same effect so share one draw. Only `ME_frame_half`, which
20
+ * changes with the texture, is a uniform (`ShaderEffect#_setFrameTexel`).
21
+ * On a mesh, which carries no frame, `ME_frame` is a uniform, left
22
+ * unbounded.
23
+ * @ignore
24
+ */
25
+ /**
26
+ * the frame, the half texel and `frameTexel()`, for a GLSL effect body. The
27
+ * sprite program defines `ME_SPRITE_FRAME` and computes the varying in its
28
+ * vertex stage (see glsl_realization.js); a mesh hosting the body reads the
29
+ * uniform
30
+ * @ignore
31
+ */
32
+ export const FRAME_GLSL: "\n#ifdef ME_SPRITE_FRAME\nvarying vec4 ME_frame;\n#else\nuniform vec4 ME_frame;\n#endif\nuniform vec2 ME_frame_half;\nvec4 frameTexel(vec2 p) {\n\tvec2 inside = step(ME_frame.xy, p) * step(p, ME_frame.zw);\n\tvec2 q = clamp(p, ME_frame.xy + ME_frame_half, ME_frame.zw - ME_frame_half);\n\treturn texture2D(uSampler, q) * (inside.x * inside.y);\n}\n";
33
+ /**
34
+ * the members to add to a WGSL effect's uniform struct, which `frameTexel()`
35
+ * reads through the effect's `fx` binding. On a sprite the scaffold reads
36
+ * the frame from the quad instead of `fx.ME_frame` (see wgsl/scaffold.js),
37
+ * which a mesh hosting the body still reads
38
+ * @ignore
39
+ */
40
+ export const FRAME_WGSL_MEMBERS: "\n\tME_frame : vec4f,\n\tME_frame_half : vec2f,";
41
+ /**
42
+ * `frameTexel()` for a WGSL effect body, sampling with implicit derivatives
43
+ * (uniform control flow only), and `frameTexelLevel()`, sampling level 0,
44
+ * which works anywhere
45
+ * @ignore
46
+ */
47
+ export const FRAME_WGSL: "\nfn frameUV(p : vec2f) -> vec2f {\n\treturn clamp(p, fx.ME_frame.xy + fx.ME_frame_half, fx.ME_frame.zw - fx.ME_frame_half);\n}\nfn frameInside(p : vec2f) -> f32 {\n\tlet inside = step(fx.ME_frame.xy, p) * step(p, fx.ME_frame.zw);\n\treturn inside.x * inside.y;\n}\nfn frameTexel(p : vec2f) -> vec4f {\n\treturn textureSample(uTexture, uSampler, frameUV(p)) * frameInside(p);\n}\nfn frameTexelLevel(p : vec2f) -> vec4f {\n\treturn textureSampleLevel(uTexture, uSampler, frameUV(p), 0.0) * frameInside(p);\n}\n";
48
+ //# sourceMappingURL=frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../../src/video/effects/frame.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;GAMG;AACH,wXAYE;AAEF;;;;;;GAMG;AACH,mFAEyB;AAEzB;;;;;GAKG;AACH,yhBAcE"}
@@ -10,15 +10,18 @@
10
10
  * color: [0.2, 0.5, 1.0],
11
11
  * intensity: 1.5,
12
12
  * }));
13
+ * @example
14
+ * // a faint white halo: the color's alpha is the halo's opacity
15
+ * mySprite.addPostEffect(new GlowEffect(renderer, { color: [1.0, 1.0, 1.0, 0.5] }));
13
16
  */
14
17
  export default class GlowEffect extends ShaderEffect {
15
18
  /**
16
19
  * @param {Renderer} renderer - the current renderer instance
17
20
  * @param {object} [options] - effect options
18
- * @param {number[]} [options.color=[1.0, 1.0, 1.0]] - glow color as [r, g, b] (0.0–1.0)
21
+ * @param {number[]} [options.color=[1.0, 1.0, 1.0]] - glow color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha is the halo's opacity
19
22
  * @param {number} [options.width=3.0] - glow spread in pixels
20
23
  * @param {number} [options.intensity=1.0] - glow brightness multiplier
21
- * @param {number[]} [options.textureSize=[256, 256]] - texture dimensions [width, height]
24
+ * @param {number[]} [options.textureSize] - the size, `[width, height]`, of the texture its spread is measured in; by default the texture it draws (a sprite's own, the screen for a camera's effect)
22
25
  */
23
26
  constructor(renderer: Renderer, options?: {
24
27
  color?: number[] | undefined;
@@ -29,7 +32,7 @@ export default class GlowEffect extends ShaderEffect {
29
32
  intensity: number;
30
33
  /**
31
34
  * set the glow color
32
- * @param {number[]} color - glow color as [r, g, b] (0.0–1.0)
35
+ * @param {number[]} color - glow color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha is the halo's opacity
33
36
  */
34
37
  setColor(color: number[]): void;
35
38
  /**
@@ -38,7 +41,8 @@ export default class GlowEffect extends ShaderEffect {
38
41
  */
39
42
  setIntensity(value: number): void;
40
43
  /**
41
- * set the texture size
44
+ * Measure the effect's spread in the texels of a texture of this size,
45
+ * rather than of the texture it draws (the default)
42
46
  * @param {number} width - texture width in pixels
43
47
  * @param {number} height - texture height in pixels
44
48
  */
@@ -1 +1 @@
1
- {"version":3,"file":"glow.d.ts","sourceRoot":"","sources":["../../../src/video/effects/glow.js"],"names":[],"mappings":"AAuCA;;;;;;;;;;;;GAYG;AACH;IACC;;;;;;;OAOG;IACH,sBAPW,QAAQ,YAEhB;QAA2B,KAAK;QACP,KAAK;QACL,SAAS;QACP,WAAW;KACxC,EAsCA;IANA,kBAAyC;IAQ1C;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;IAED;;;OAGG;IACH,oBAFW,MAAM,QAKhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBA7HwB,mBAAmB;0BAOnB,gBAAgB"}
1
+ {"version":3,"file":"glow.d.ts","sourceRoot":"","sources":["../../../src/video/effects/glow.js"],"names":[],"mappings":"AA2CA;;;;;;;;;;;;;;;GAeG;AACH;IACC;;;;;;;OAOG;IACH,sBAPW,QAAQ,YAEhB;QAA2B,KAAK;QACP,KAAK;QACL,SAAS;QACP,WAAW;KACxC,EAyCA;IAPA,kBAAyC;IAS1C;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;IAED;;;OAGG;IACH,oBAFW,MAAM,QAKhB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBAtIwB,mBAAmB;0BAOnB,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"glsl_realization.d.ts","sourceRoot":"","sources":["../../../src/video/effects/glsl_realization.js"],"names":[],"mappings":"AAoHA;;;;;;;;GAQG;AACH,+CALW,MAAM,GACJ;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,CAoCvH"}
1
+ {"version":3,"file":"glsl_realization.d.ts","sourceRoot":"","sources":["../../../src/video/effects/glsl_realization.js"],"names":[],"mappings":"AAmJA;;;;;;;;GAQG;AACH,+CALW,MAAM,GACJ;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,CAsCvH"}
@@ -10,12 +10,15 @@
10
10
  * mySprite.addPostEffect(holo);
11
11
  * // update each frame
12
12
  * holo.setTime(performance.now() / 1000);
13
+ * @example
14
+ * // a faint cyan tint, the scan lines and flicker unchanged
15
+ * mySprite.addPostEffect(new HologramEffect(renderer, { color: [0.1, 0.7, 1.0, 0.4] }));
13
16
  */
14
17
  export default class HologramEffect extends ShaderEffect {
15
18
  /**
16
19
  * @param {Renderer} renderer - the current renderer instance
17
20
  * @param {object} [options] - effect options
18
- * @param {number[]} [options.color=[0.1, 0.7, 1.0]] - hologram tint color [r, g, b]
21
+ * @param {number[]} [options.color=[0.1, 0.7, 1.0]] - hologram tint color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha scales the intensity
19
22
  * @param {number} [options.intensity=0.5] - effect intensity (0.0–1.0)
20
23
  */
21
24
  constructor(renderer: Renderer, options?: {
@@ -24,7 +27,7 @@ export default class HologramEffect extends ShaderEffect {
24
27
  });
25
28
  /**
26
29
  * set the hologram tint color
27
- * @param {number[]} color - color as [r, g, b] (0.0–1.0)
30
+ * @param {number[]} color - color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha scales the intensity
28
31
  */
29
32
  setColor(color: number[]): void;
30
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hologram.d.ts","sourceRoot":"","sources":["../../../src/video/effects/hologram.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;GAYG;AACH;IACC;;;;;OAKG;IACH,sBALW,QAAQ,YAEhB;QAA2B,KAAK;QACP,SAAS;KACpC,EAyBA;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;CACD;yBApFwB,mBAAmB;0BAOnB,gBAAgB"}
1
+ {"version":3,"file":"hologram.d.ts","sourceRoot":"","sources":["../../../src/video/effects/hologram.js"],"names":[],"mappings":"AAiCA;;;;;;;;;;;;;;;GAeG;AACH;IACC;;;;;OAKG;IACH,sBALW,QAAQ,YAEhB;QAA2B,KAAK;QACP,SAAS;KACpC,EA0BA;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;CACD;yBAzFwB,mBAAmB;0BAOnB,gBAAgB"}
@@ -12,6 +12,9 @@
12
12
  * width: 2.0,
13
13
  * }));
14
14
  * @example
15
+ * // a half-transparent white outline
16
+ * mySprite.addPostEffect(new OutlineEffect(renderer, { color: [1, 1, 1, 0.5] }));
17
+ * @example
15
18
  * // remove the effect
16
19
  * mySprite.removePostEffect(outline);
17
20
  */
@@ -19,9 +22,9 @@ export default class OutlineEffect extends ShaderEffect {
19
22
  /**
20
23
  * @param {Renderer} renderer - the current renderer instance
21
24
  * @param {object} [options] - effect options
22
- * @param {number[]} [options.color=[1.0, 1.0, 1.0]] - outline color as [r, g, b] (0.0–1.0)
25
+ * @param {number[]} [options.color=[1.0, 1.0, 1.0]] - outline color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha is the outline's opacity
23
26
  * @param {number} [options.width=1.0] - outline width in pixels
24
- * @param {number[]} [options.textureSize] - texture dimensions [width, height] (defaults to renderer size)
27
+ * @param {number[]} [options.textureSize] - the size, `[width, height]`, of the texture its width is measured in; by default the texture it draws (a sprite's own, the screen for a camera's effect)
25
28
  */
26
29
  constructor(renderer: Renderer, options?: {
27
30
  color?: number[] | undefined;
@@ -30,7 +33,7 @@ export default class OutlineEffect extends ShaderEffect {
30
33
  });
31
34
  /**
32
35
  * set the outline color
33
- * @param {number[]} color - outline color as [r, g, b] (0.0–1.0)
36
+ * @param {number[]} color - outline color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha is the outline's opacity
34
37
  */
35
38
  setColor(color: number[]): void;
36
39
  /**
@@ -39,7 +42,8 @@ export default class OutlineEffect extends ShaderEffect {
39
42
  */
40
43
  setWidth(width: number): void;
41
44
  /**
42
- * set the texture size for accurate outline width calculation
45
+ * Measure the effect's width in the texels of a texture of this size,
46
+ * rather than of the texture it draws (the default)
43
47
  * @param {number} width - texture width in pixels
44
48
  * @param {number} height - texture height in pixels
45
49
  */
@@ -1 +1 @@
1
- {"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../../src/video/effects/outline.js"],"names":[],"mappings":"AAyCA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;;;;;OAMG;IACH,sBANW,QAAQ,YAEhB;QAA2B,KAAK;QACP,KAAK;QACH,WAAW;KACxC,EAsCA;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBAjIwB,mBAAmB;0BAOnB,gBAAgB"}
1
+ {"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../../src/video/effects/outline.js"],"names":[],"mappings":"AA6CA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IACC;;;;;;OAMG;IACH,sBANW,QAAQ,YAEhB;QAA2B,KAAK;QACP,KAAK;QACH,WAAW;KACxC,EA4CA;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBA7IwB,mBAAmB;0BAOnB,gBAAgB"}
@@ -15,7 +15,7 @@ export default class PixelateEffect extends ShaderEffect {
15
15
  * @param {Renderer} renderer - the current renderer instance
16
16
  * @param {object} [options] - effect options
17
17
  * @param {number} [options.size=4.0] - pixel size in texels (higher = more pixelated)
18
- * @param {number[]} [options.textureSize=[256, 256]] - texture dimensions [width, height]
18
+ * @param {number[]} [options.textureSize] - the size, `[width, height]`, of the texture its pixel size is measured in; by default the texture it draws (a sprite's own, the screen for a camera's effect)
19
19
  */
20
20
  constructor(renderer: Renderer, options?: {
21
21
  size?: number | undefined;
@@ -28,7 +28,8 @@ export default class PixelateEffect extends ShaderEffect {
28
28
  */
29
29
  setSize(size: number): void;
30
30
  /**
31
- * set the texture size
31
+ * Measure the effect's pixel size in the texels of a texture of this size,
32
+ * rather than of the texture it draws (the default)
32
33
  * @param {number} width - texture width in pixels
33
34
  * @param {number} height - texture height in pixels
34
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"pixelate.d.ts","sourceRoot":"","sources":["../../../src/video/effects/pixelate.js"],"names":[],"mappings":"AAyBA;;;;;;;;;;;GAWG;AACH;IACC;;;;;OAKG;IACH,sBALW,QAAQ,YAEhB;QAAyB,IAAI;QACF,WAAW;KACxC,EAoBA;IALA,aAA+B;IAOhC;;;OAGG;IACH,cAFW,MAAM,QAKhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBAlFwB,mBAAmB;0BAOnB,gBAAgB"}
1
+ {"version":3,"file":"pixelate.d.ts","sourceRoot":"","sources":["../../../src/video/effects/pixelate.js"],"names":[],"mappings":"AA0BA;;;;;;;;;;;GAWG;AACH;IACC;;;;;OAKG;IACH,sBALW,QAAQ,YAEhB;QAAyB,IAAI;QACF,WAAW;KACxC,EAqBA;IALA,aAA+B;IAOhC;;;OAGG;IACH,cAFW,MAAM,QAKhB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;CACD;yBApFwB,mBAAmB;0BAOnB,gBAAgB"}
@@ -77,12 +77,17 @@
77
77
  * color: new Color(80, 160, 255),
78
78
  * intensity: 0.4,
79
79
  * });
80
+ * @example
81
+ * // a half-strength warm spot: the Color's alpha scales the whole gradient
82
+ * const dim = new RadialGradientEffect(renderer, {
83
+ * color: new Color(255, 220, 120, 0.5),
84
+ * });
80
85
  */
81
86
  export default class RadialGradientEffect extends ShaderEffect {
82
87
  /**
83
88
  * @param {Renderer} renderer - the current renderer instance
84
89
  * @param {object} [options] - initial uniform values
85
- * @param {Color} [options.color] - center color (0..255 RGB); defaults to white
90
+ * @param {Color} [options.color] - center color (0..255 RGB, and its alpha scales the gradient); defaults to opaque white
86
91
  * @param {number} [options.intensity=1] - peak alpha at the center (0..1+)
87
92
  */
88
93
  constructor(renderer: Renderer, options?: {
@@ -90,9 +95,9 @@ export default class RadialGradientEffect extends ShaderEffect {
90
95
  intensity?: number | undefined;
91
96
  });
92
97
  /**
93
- * Set the center color. RGB only — alpha is ignored (the radial
94
- * falloff supplies the per-pixel alpha).
95
- * @param {Color} color - 0..255 RGB color
98
+ * Set the center color. Its alpha scales the whole gradient, on top of
99
+ * the falloff, so a half-transparent color gives a half-strength spot.
100
+ * @param {Color} color - 0..255 RGB color, with its alpha
96
101
  */
97
102
  setColor(color: Color): void;
98
103
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"radialGradient.d.ts","sourceRoot":"","sources":["../../../src/video/effects/radialGradient.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH;IACC;;;;;OAKG;IACH,sBALW,QAAQ,YAEhB;QAAwB,KAAK;QACJ,SAAS;KACpC,EA+DA;IAhBA;;;OAGG;IACH,qCAAoC;IAcrC;;;;OAIG;IACH,gBAFW,KAAK,QAOf;IAED;;;;OAIG;IACH,wBAFW,MAAM,QAIhB;CACD;yBA9KwB,mBAAmB;2BAIlB,qBAAqB;0BAKtB,gBAAgB"}
1
+ {"version":3,"file":"radialGradient.d.ts","sourceRoot":"","sources":["../../../src/video/effects/radialGradient.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH;IACC;;;;;OAKG;IACH,sBALW,QAAQ,YAEhB;QAAwB,KAAK;QACJ,SAAS;KACpC,EAmEA;IAjBA;;;OAGG;IACH,qCAAoC;IAerC;;;;OAIG;IACH,gBAFW,KAAK,QAQf;IAED;;;;OAIG;IACH,wBAFW,MAAM,QAIhB;CACD;yBAxLwB,mBAAmB;2BAIlB,qBAAqB;0BAKtB,gBAAgB"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=rgba.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgba.d.ts","sourceRoot":"","sources":["../../../src/video/effects/rgba.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,4BALW,MAAM,EAAE,GAAC,YAAY,GACnB,YAAY,CAgBxB"}
@@ -59,12 +59,25 @@ export default class ShaderEffect {
59
59
  * vectors and matrices take an array, a `Float32Array`, or any object
60
60
  * exposing `toArray()` — which is every {@link Vector2d},
61
61
  * {@link Vector3d}, {@link Color} and {@link Matrix3d}.
62
+ *
63
+ * Sprites drawn one after the other through the same effect share one
64
+ * draw call. A new value draws the sprites queued before it first, so
65
+ * each sprite draws with the values it was given; the value it already
66
+ * has changes nothing, and keeps the draw shared.
62
67
  * @example
63
68
  * // a scalar the body declares as `uniform float uStrength;`
64
69
  * fx.setUniform("uStrength", 0.5);
65
70
  * // a vec3 — an array, or anything with toArray()
66
71
  * fx.setUniform("uTint", [1.0, 0.82, 0.55]);
67
72
  * fx.setUniform("uOrigin", new me.Vector2d(0.5, 0.5));
73
+ * @example
74
+ * // one outline shared by every enemy: drawn in a single call. Marked
75
+ * // shared, so the first enemy destroyed does not destroy it for the rest
76
+ * const outline = new me.OutlineEffect(renderer, { color: [1, 1, 1] });
77
+ * outline.shared = true;
78
+ * for (const enemy of enemies) {
79
+ * enemy.addPostEffect(outline);
80
+ * }
68
81
  */
69
82
  setUniform(name: string, value: number | boolean | number[] | Float32Array | object): void;
70
83
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"shadereffect.d.ts","sourceRoot":"","sources":["../../../src/video/effects/shadereffect.js"],"names":[],"mappings":"AAwJA;IAiCC;;;;;;;;;;;;;;;;;;OAkBG;IACH,sBAlBW,QAAQ,QACR,MAAM,GAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,cAerC,MAAM,EAgLhB;IAjOD;;;;;;OAMG;IACH,SAFU,OAAO,CAED;IAEhB;;;;;;;OAOG;IACH,oBAHU,OAAO,CAGC;IAElB;;;;;;;;;;OAUG;IACH,QAHU,OAAO,CAGF;IAsBd;;;;;;;OAOG;IACH,oBAAyB;IAEzB;;;;;;OAMG;IACH;eAnCyB,MAAM;eAAS,MAAM;MAmCrB;IACzB;;;OAGG;IACH,+BAA2B;IAE3B;;;;;;;;;;;;OAYG;IACH,cAJU;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,CAIE;IAoBlC;;;;;;;OAOG;IACH,0CAA+B;IAE/B;;;;;OAKG;IACH,0CAA+B;IAE/B;;;;OAIG;IACH,8BAAgC;IAQ/B;;;;;;OAMG;IACH,wBAJU,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC,CAIK;IACpD;;;OAGG;IACH,iBAAkC;IAClC;;;;;;OAMG;IACH,eAA6B;IAC7B;;;OAGG;IACH,mBAAqC;IAErC;;;OAGG;IACH,8BAKC;IAyBD;;;OAGG;IACH,mDAAkC;IAsBpC;;;;OAIG;IACH,uBAsBC;IAjBA;;;OAGG;IACH,2CAAyC;IAe1C;;;;OAIG;IACH,2BAQC;IAED;;;;;;;;;;;;;;OAcG;IACH,iBAbW,MAAM,SACN,MAAM,GAAC,OAAO,GAAC,MAAM,EAAE,GAAC,YAAY,GAAC,MAAM,QAsCrD;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,iBAbW,MAAM,GACJ,YAAY,CAoDxB;IAED;;;;;;;;;;;;OAYG;IACH,gBAJW,MAAM,QA0BhB;IAbC;;;OAGG;IACH,aAAkB;IAWpB;;;;;;;;;;;;;;OAcG;IACH,6BATW,MAAM,gBACN,MAAM,eACN,MAAM,gBACN,MAAM,MACN,MAAM,MACN,MAAM,QAqDhB;IAED;;;;;;;OAOG;IACH,8DAaC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,iBAnBW,MAAM,SACN,SAAS,GAAC,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,WAAW,WACxE,QAAQ,GAAC,UAAU,GAAC,UAAU,GAAC,WAAW,GACxC,YAAY,CA0GxB;IAED;;;;;;;;;OASG;IACH,0BAJW,MAAM,QAgGhB;IA/DI;;;OAGG;IACH,4CAAkC;IA6DvC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SATa,YAAY,CAsDxB;IAKD;;;OAGG;IACH,aAIC;IAED;;;OAGG;IACH,qCAIC;IAED;;;OAGG;IACH,iEAIC;IAED;;;OAGG;IACH,mCAEC;IAED;;;OAGG;IACH,kBAEC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,qBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;;OAIG;IACH,gBAyCC;CACD;0BAriCwB,gBAAgB;qBATpB,sBAAsB;kCAET,uBAAuB;sBAHnC,yBAAyB"}
1
+ {"version":3,"file":"shadereffect.d.ts","sourceRoot":"","sources":["../../../src/video/effects/shadereffect.js"],"names":[],"mappings":"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"}
@@ -33,12 +33,15 @@
33
33
  *
34
34
  * // update each frame
35
35
  * coinShine.setTime(timer.getTime() / 1000);
36
+ * @example
37
+ * // a gentler glint: the color's alpha scales its strength
38
+ * mySprite.addPostEffect(new ShineEffect(renderer, { color: [1.0, 1.0, 1.0, 0.4] }));
36
39
  */
37
40
  export default class ShineEffect extends ShaderEffect {
38
41
  /**
39
42
  * @param {Renderer} renderer - the current renderer instance
40
43
  * @param {object} [options] - effect options
41
- * @param {number[]} [options.color=[1.0, 1.0, 1.0]] - shine color as [r, g, b] (0.0–1.0)
44
+ * @param {number[]} [options.color=[1.0, 1.0, 1.0]] - shine color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha scales the glint
42
45
  * @param {number} [options.speed=0.5] - sweeps per second
43
46
  * @param {number} [options.width=0.15] - glint half-width as a fraction of one tile (0.0–1.0)
44
47
  * @param {number} [options.intensity=0.5] - maximum highlight strength
@@ -59,7 +62,7 @@ export default class ShineEffect extends ShaderEffect {
59
62
  });
60
63
  /**
61
64
  * set the shine color
62
- * @param {number[]} color - shine color as [r, g, b] (0.0–1.0)
65
+ * @param {number[]} color - shine color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha scales the glint
63
66
  */
64
67
  setColor(color: number[]): void;
65
68
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"shine.d.ts","sourceRoot":"","sources":["../../../src/video/effects/shine.js"],"names":[],"mappings":"AAkDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH;IACC;;;;;;;;;;;OAWG;IACH,sBAXW,QAAQ,YAEhB;QAA2B,KAAK;QACP,KAAK;QACL,KAAK;QACL,SAAS;QACT,KAAK;QACL,KAAK;QACL,UAAU;QACV,UAAU;KACrC,EAgEA;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,oBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;CACD;yBAnMwB,mBAAmB;0BAOnB,gBAAgB"}
1
+ {"version":3,"file":"shine.d.ts","sourceRoot":"","sources":["../../../src/video/effects/shine.js"],"names":[],"mappings":"AAoDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH;IACC;;;;;;;;;;;OAWG;IACH,sBAXW,QAAQ,YAEhB;QAA2B,KAAK;QACP,KAAK;QACL,KAAK;QACL,SAAS;QACT,KAAK;QACL,KAAK;QACL,UAAU;QACV,UAAU;KACrC,EA8DA;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,oBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAIhB;CACD;yBArMwB,mBAAmB;0BAOnB,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"squish.d.ts","sourceRoot":"","sources":["../../../src/video/effects/squish.js"],"names":[],"mappings":"AAoCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH;IACC;;;;OAIG;IACH,sBAJW,QAAQ,YAEhB;QAAyB,KAAK;KAChC,EA6CA;IAjBA;;;;OAIG;IACH,eAAe;IAEf;;;;;OAKG;IACH,kCAA4C;IAM7C;;;OAGG;IACH,gBAFW,MAAM,QAWhB;IAED;;;;;;;OAOG;IACH,kHAcC;IAED;;;OAGG;IACH,SAFa,YAAY,CAOxB;CACD;yBA5LwB,mBAAmB;0BAOnB,gBAAgB"}
1
+ {"version":3,"file":"squish.d.ts","sourceRoot":"","sources":["../../../src/video/effects/squish.js"],"names":[],"mappings":"AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH;IACC;;;;OAIG;IACH,sBAJW,QAAQ,YAEhB;QAAyB,KAAK;KAChC,EAoDA;IAjBA;;;;OAIG;IACH,eAAe;IAEf;;;;;OAKG;IACH,kCAA4C;IAM7C;;;OAGG;IACH,gBAFW,MAAM,QAWhB;IAED;;;;;;;OAOG;IACH,kHAcC;IAED;;;OAGG;IACH,SAFa,YAAY,CAOxB;CACD;yBAtMwB,mBAAmB;0BAOnB,gBAAgB"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * A shader effect that leans a sprite from side to side, as if a breeze went
3
+ * through it: each row is drawn a little to the left or right by a sine of
4
+ * the time, and by more the further above its anchor row it is, so the top
5
+ * sways most and everything from the anchor down stays put. For grass, trees,
6
+ * reeds or a whole background layer: anything planted at its bottom.
7
+ *
8
+ * It is a {@link WaveEffect} with an anchor and sway-sized defaults, so it
9
+ * shares its shader rather than adding one. The difference is the time:
10
+ * {@link SwayEffect#setTime} wraps the phase to one turn on the CPU before
11
+ * the shader sees it. A raw clock grows without bound, and a medium-precision
12
+ * float, the default on most phones, runs out of digits a few minutes into a
13
+ * session and the sway starts to stutter; a wrapped phase never grows.
14
+ * @category Effects
15
+ * @see {@link Renderable#addPostEffect} for usage
16
+ * @example
17
+ * // a tree whose trunk is planted at 90% of its height
18
+ * const sway = new SwayEffect(renderer, { strength: 0.02, anchor: 0.9 });
19
+ * tree.addPostEffect(sway);
20
+ * // each frame
21
+ * sway.setTime(timer.getTime() / 1000);
22
+ */
23
+ export default class SwayEffect extends WaveEffect {
24
+ /**
25
+ * @param {Renderer} renderer - the current renderer instance
26
+ * @param {object} [options] - effect options
27
+ * @param {number} [options.strength=0.02] - how far the top moves each way, as a fraction of the texture's width
28
+ * @param {number} [options.anchor=1.0] - the row that stays put, as a fraction of the height from the top (1 = the bottom row)
29
+ * @param {number} [options.speed=1.5] - how fast it sways, in radians per second
30
+ * @param {number} [options.frequency=3.0] - how much the sway bends along the height: low values lean the whole sprite as one, high ones ripple it
31
+ */
32
+ constructor(renderer: Renderer, options?: {
33
+ strength?: number | undefined;
34
+ anchor?: number | undefined;
35
+ speed?: number | undefined;
36
+ frequency?: number | undefined;
37
+ });
38
+ /**
39
+ * how fast it sways, in radians per second
40
+ * @type {number}
41
+ */
42
+ speed: number;
43
+ /**
44
+ * advance the sway to a moment in time
45
+ * @param {number} seconds - the time, in seconds (any clock: only its rate matters)
46
+ * @returns {SwayEffect} this effect for chaining
47
+ */
48
+ setTime(seconds: number): SwayEffect;
49
+ /**
50
+ * set how far the top moves each way
51
+ * @param {number} strength - a fraction of the texture's width
52
+ */
53
+ setStrength(strength: number): void;
54
+ /**
55
+ * Create an independent copy of this effect, swaying the same way. A
56
+ * plain {@link ShaderEffect#clone} would copy the uniforms but not the
57
+ * speed, nor the wrapping of the time that keeps the sway smooth.
58
+ * @returns {SwayEffect} a new effect
59
+ */
60
+ clone(): SwayEffect;
61
+ }
62
+ import WaveEffect from "./wave.js";
63
+ import type Renderer from "../renderer.js";
64
+ //# sourceMappingURL=sway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sway.d.ts","sourceRoot":"","sources":["../../../src/video/effects/sway.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IACC;;;;;;;OAOG;IACH,sBAPW,QAAQ,YAEhB;QAAyB,QAAQ;QACR,MAAM;QACN,KAAK;QACL,SAAS;KACpC,EAeA;IALA;;;OAGG;IACH,OAFU,MAAM,CAEiB;IAGlC;;;;OAIG;IACH,iBAHW,MAAM,GACJ,UAAU,CAKtB;IAED;;;OAGG;IACH,sBAFW,MAAM,QAIhB;IAED;;;;;OAKG;IACH,SAFa,UAAU,CAetB;CACD;uBA/FsB,WAAW;0BAIT,gBAAgB"}
@@ -14,12 +14,15 @@
14
14
  *
15
15
  * // update each frame
16
16
  * poison.setTime(timer.getTime() / 1000);
17
+ * @example
18
+ * // a subtle pulse: the color's alpha caps how far it tints
19
+ * mySprite.addPostEffect(new TintPulseEffect(renderer, { color: [1.0, 0.8, 0.0, 0.35] }));
17
20
  */
18
21
  export default class TintPulseEffect extends ShaderEffect {
19
22
  /**
20
23
  * @param {Renderer} renderer - the current renderer instance
21
24
  * @param {object} [options] - effect options
22
- * @param {number[]} [options.color=[1.0, 0.0, 0.0]] - pulse color as [r, g, b] (0.0–1.0)
25
+ * @param {number[]} [options.color=[1.0, 0.0, 0.0]] - pulse color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha scales the intensity
23
26
  * @param {number} [options.speed=2.0] - pulse speed (oscillations per second)
24
27
  * @param {number} [options.intensity=0.3] - maximum tint strength (0.0–1.0)
25
28
  */
@@ -30,7 +33,7 @@ export default class TintPulseEffect extends ShaderEffect {
30
33
  });
31
34
  /**
32
35
  * set the pulse color
33
- * @param {number[]} color - pulse color as [r, g, b] (0.0–1.0)
36
+ * @param {number[]} color - pulse color as [r, g, b] or [r, g, b, a] (0.0–1.0); the alpha scales the intensity
34
37
  */
35
38
  setColor(color: number[]): void;
36
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tintPulse.d.ts","sourceRoot":"","sources":["../../../src/video/effects/tintPulse.js"],"names":[],"mappings":"AA0BA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;;;;;OAMG;IACH,sBANW,QAAQ,YAEhB;QAA2B,KAAK;QACP,KAAK;QACL,SAAS;KACpC,EAqBA;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;CACD;yBAhFwB,mBAAmB;0BAOnB,gBAAgB"}
1
+ {"version":3,"file":"tintPulse.d.ts","sourceRoot":"","sources":["../../../src/video/effects/tintPulse.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IACC;;;;;;OAMG;IACH,sBANW,QAAQ,YAEhB;QAA2B,KAAK;QACP,KAAK;QACL,SAAS;KACpC,EAsBA;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAIlB;CACD;yBArFwB,mBAAmB;0BAOnB,gBAAgB"}
@@ -2,6 +2,12 @@
2
2
  * A shader effect that applies a sine wave distortion to the sprite.
3
3
  * Commonly used for underwater, heat haze, or dream sequence effects.
4
4
  * The `time` uniform should be updated each frame for animation.
5
+ *
6
+ * With an `anchor`, the wave fades out toward a row instead of moving the
7
+ * whole sprite: full at the top, nothing at the anchor and below. That is
8
+ * how {@link SwayEffect} leans a sprite while its feet stay planted. Rows
9
+ * are measured across the texture the effect samples, so on a sprite cut
10
+ * from an atlas the anchor is a row of the atlas.
5
11
  * @category Effects
6
12
  * @see {@link Renderable#addPostEffect} for usage
7
13
  * @example
@@ -9,6 +15,10 @@
9
15
  * mySprite.addPostEffect(wave);
10
16
  * // update each frame
11
17
  * wave.setTime(performance.now() / 1000);
18
+ * @example
19
+ * // seaweed: the tips wave, the roots on the bottom row stay planted
20
+ * const seaweed = new WaveEffect(renderer, { amplitude: 0.02, frequency: 6.0, anchor: 1.0 });
21
+ * mySprite.addPostEffect(seaweed);
12
22
  */
13
23
  export default class WaveEffect extends ShaderEffect {
14
24
  /**
@@ -17,11 +27,13 @@ export default class WaveEffect extends ShaderEffect {
17
27
  * @param {number} [options.amplitude=0.01] - wave displacement strength (in UV space, 0.01 = subtle)
18
28
  * @param {number} [options.frequency=10.0] - number of waves across the sprite
19
29
  * @param {number} [options.speed=2.0] - wave animation speed
30
+ * @param {number} [options.anchor=0] - the row the wave fades out at, as a fraction of the height from the top (0..1); 0 waves every row alike
20
31
  */
21
32
  constructor(renderer: Renderer, options?: {
22
33
  amplitude?: number | undefined;
23
34
  frequency?: number | undefined;
24
35
  speed?: number | undefined;
36
+ anchor?: number | undefined;
25
37
  });
26
38
  /**
27
39
  * set the wave amplitude
@@ -33,6 +45,11 @@ export default class WaveEffect extends ShaderEffect {
33
45
  * @param {number} frequency - number of waves
34
46
  */
35
47
  setFrequency(frequency: number): void;
48
+ /**
49
+ * set the row the wave fades out at
50
+ * @param {number} anchor - a fraction of the height from the top (0..1); 0 waves every row alike
51
+ */
52
+ setAnchor(anchor: number): void;
36
53
  }
37
54
  import ShaderEffect from "./shadereffect.js";
38
55
  import type Renderer from "../renderer.js";
@@ -1 +1 @@
1
- {"version":3,"file":"wave.d.ts","sourceRoot":"","sources":["../../../src/video/effects/wave.js"],"names":[],"mappings":"AA2BA;;;;;;;;;;;GAWG;AACH;IACC;;;;;;OAMG;IACH,sBANW,QAAQ,YAEhB;QAAyB,SAAS;QACT,SAAS;QACT,KAAK;KAChC,EAqBA;IAED;;;OAGG;IACH,wBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAIhB;CACD;yBApFwB,mBAAmB;0BAOnB,gBAAgB"}
1
+ {"version":3,"file":"wave.d.ts","sourceRoot":"","sources":["../../../src/video/effects/wave.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IACC;;;;;;;OAOG;IACH,sBAPW,QAAQ,YAEhB;QAAyB,SAAS;QACT,SAAS;QACT,KAAK;QACL,MAAM;KACjC,EA0BA;IAED;;;OAGG;IACH,wBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,kBAFW,MAAM,QAIhB;CACD;yBA/GwB,mBAAmB;0BAOnB,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../../../src/video/effects/wgsl/scaffold.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;GASG;AACH,8CANW,MAAM,GACJ;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAC,CA2BxG;AAED;;;;;;;;GAQG;AACH,sCAPW,MAAM,UACN,MAAM,GACJ;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CA0G5C"}
1
+ {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../../../src/video/effects/wgsl/scaffold.js"],"names":[],"mappings":"AA4BA;;;;;;;;;GASG;AACH,8CANW,MAAM,GACJ;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAC,CA2BxG;AAED;;;;;;;;GAQG;AACH,sCAPW,MAAM,UACN,MAAM,GACJ;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CA6I5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"wgsl_realization.d.ts","sourceRoot":"","sources":["../../../src/video/effects/wgsl_realization.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH;IACC;;;;OAIG;IACH,kBAFW,MAAM,EA2EhB;IAtEA;;;OAGG;IACH,OAFU,OAAO,CAEc;IAC/B,0BAA0B;IAC1B,OADW,MAAM,GAAC,IAAI,CAC+B;IAMrD;;;;OAIG;IACH,MAFU,MAAM,CAEA;IAChB,wEAAwE;IACxE,2BAAoB;IACpB,iEAAiE;IACjE,YAA2B;IAC3B,4DAA4D;IAC5D,gBAAmC;IACnC,iDAAiD;IACjD,cAA+B;IAC/B,0BAA0B;IAC1B,cAA+B;IAG/B,8CAA8C;IAC9C,yBAAuB;IACvB,mEAAmE;IACnE,oCAAsC;IAEtC;;;;;OAKG;IACH,uCAA4B;IAG5B,6BAAwD;IACxD,2CAAqC;IACrC,yCAAmC;IACnC,0CAAoC;IAIpC,gDAAmC;IAEnC;;;;OAIG;IACH,QAFU,GAAG,CAAC,MAAM,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,CAEf;IAIvB,6BAAuB;IAEvB;;;;OAIG;IACH,KAFU,MAAM,GAAC,IAAI,CAEN;IAGhB;;;;;;OAMG;IACH,iBALW,MAAM,SACN,MAAM,GAAC,MAAM,EAAE,GAAC,YAAY,GAAC;QAAC,GAAG,EAAE,YAAY,CAAA;KAAC,GAE9C,OAAO,CAwDnB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,mBAEC;IAED;;;;;;;;;;;OAWG;IACH,uBALW,MAAM,GACJ,MAAM,CAWlB;CACD"}
1
+ {"version":3,"file":"wgsl_realization.d.ts","sourceRoot":"","sources":["../../../src/video/effects/wgsl_realization.js"],"names":[],"mappings":"AA8BA;;;;;;;;;;;;;;;GAeG;AACH;IACC;;;;OAIG;IACH,kBAFW,MAAM,EAwFhB;IAnFA;;;OAGG;IACH,OAFU,OAAO,CAEc;IAC/B,0BAA0B;IAC1B,OADW,MAAM,GAAC,IAAI,CAC+B;IAMrD;;;;OAIG;IACH,MAFU,MAAM,CAEA;IAChB,wEAAwE;IACxE,2BAAoB;IACpB,iEAAiE;IACjE,YAA2B;IAC3B,4DAA4D;IAC5D,gBAAmC;IACnC,iDAAiD;IACjD,cAA+B;IAC/B,0BAA0B;IAC1B,cAA+B;IAG/B,8CAA8C;IAC9C,yBAAuB;IACvB,mEAAmE;IACnE,oCAAsC;IAEtC;;;;;OAKG;IACH,uCAA4B;IAG5B,6BAAwD;IACxD,2CAAqC;IACrC,yCAAmC;IACnC,0CAAoC;IAIpC,gDAAmC;IAEnC;;;;OAIG;IACH,QAFU,GAAG,CAAC,MAAM,EAAE,MAAM,GAAC,MAAM,EAAE,CAAC,CAEf;IAIvB,6BAAuB;IAEvB;;;;OAIG;IACH,KAFU,MAAM,GAAC,IAAI,CAEN;IAEf;;;;;;;;;;OAUG;IACH,iBAJU,CAAC,MAAM,IAAI,CAAC,GAAC,IAAI,CAIA;IAG5B;;;;;;OAMG;IACH,iBALW,MAAM,SACN,MAAM,GAAC,MAAM,EAAE,GAAC,YAAY,GAAC;QAAC,GAAG,EAAE,YAAY,CAAA;KAAC,GAE9C,OAAO,CA8DnB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,mBAEC;IAED;;;;;;;;;;;OAWG;IACH,uBALW,MAAM,GACJ,MAAM,CAWlB;CACD"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../../src/video/gpu/frame.js"],"names":[],"mappings":"AAmBA;;;;;;;;GAQG;AACH,kCALW;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAC,GACf,OAAO,CAOnB;AAaD;;;;;;;;;;GAUG;AACH,yCALW;IAAC,QAAQ,EAAE;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,uBAAuB,CAAC,EAAE,MAAM,MAAM,CAAA;CAAC,GAClG,MAAM,CAelB;AAlED;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,8BAA+B,CAAC,GAAG,CAAC;AAgBpC;;;;;;;;GAQG;AACH;;;;GAA0E"}