melonjs 20.7.0 → 20.8.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 (243) hide show
  1. package/README.md +6 -3
  2. package/build/application/defaultApplicationSettings.d.ts +5 -0
  3. package/build/application/defaultApplicationSettings.d.ts.map +1 -1
  4. package/build/application/header.d.ts.map +1 -1
  5. package/build/application/settings.d.ts +88 -0
  6. package/build/application/settings.d.ts.map +1 -1
  7. package/build/audio/backend/engine.d.ts +0 -1
  8. package/build/audio/backend/sound.d.ts +0 -1
  9. package/build/camera/camera2d.d.ts.map +1 -1
  10. package/build/camera/camera3d.d.ts +95 -8
  11. package/build/camera/camera3d.d.ts.map +1 -1
  12. package/build/geometries/box3d.d.ts +24 -6
  13. package/build/geometries/box3d.d.ts.map +1 -1
  14. package/build/geometries/ellipse.d.ts +14 -0
  15. package/build/geometries/ellipse.d.ts.map +1 -1
  16. package/build/geometries/polygon.d.ts +14 -0
  17. package/build/geometries/polygon.d.ts.map +1 -1
  18. package/build/geometries/sphere.d.ts +35 -6
  19. package/build/geometries/sphere.d.ts.map +1 -1
  20. package/build/index.d.ts +9 -2
  21. package/build/index.d.ts.map +1 -1
  22. package/build/index.js +2770 -538
  23. package/build/index.js.map +4 -4
  24. package/build/input/pointerevent.d.ts +8 -0
  25. package/build/input/pointerevent.d.ts.map +1 -1
  26. package/build/level/gltf/GLTFModel.d.ts +17 -31
  27. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  28. package/build/level/gltf/GLTFScene.d.ts +40 -1
  29. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  30. package/build/level/level.d.ts +35 -0
  31. package/build/level/level.d.ts.map +1 -1
  32. package/build/level/tiled/TMXLayer.d.ts +5 -2
  33. package/build/level/tiled/TMXLayer.d.ts.map +1 -1
  34. package/build/level/tiled/TMXObject.d.ts +0 -1
  35. package/build/level/tiled/TMXTile.d.ts +2 -1
  36. package/build/level/tiled/TMXTile.d.ts.map +1 -1
  37. package/build/level/tiled/TMXTileMap.d.ts +7 -4
  38. package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
  39. package/build/level/tiled/TMXTileset.d.ts +1 -1
  40. package/build/level/tiled/TMXTileset.d.ts.map +1 -1
  41. package/build/level/tiled/TMXTilesetGroup.d.ts +5 -0
  42. package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -1
  43. package/build/level/tiled/factories/shape.d.ts +0 -1
  44. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +6 -5
  45. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
  46. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +5 -0
  47. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
  48. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +8 -7
  49. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
  50. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +5 -0
  51. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
  52. package/build/level/tiled/renderer/TMXRenderer.d.ts +19 -4
  53. package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
  54. package/build/level/tiled/renderer/autodetect.d.ts +0 -4
  55. package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
  56. package/build/loader/loader.d.ts +9 -0
  57. package/build/loader/loader.d.ts.map +1 -1
  58. package/build/loader/loadingscreen.d.ts +1 -2
  59. package/build/loader/loadingscreen.d.ts.map +1 -1
  60. package/build/loader/parsers/shader.d.ts +0 -2
  61. package/build/math/color.d.ts +27 -4
  62. package/build/math/color.d.ts.map +1 -1
  63. package/build/particles/emitter.d.ts.map +1 -1
  64. package/build/particles/particle.d.ts +22 -1
  65. package/build/particles/particle.d.ts.map +1 -1
  66. package/build/particles/settings.d.ts +69 -0
  67. package/build/particles/settings.d.ts.map +1 -1
  68. package/build/physics/adapter.d.ts +9 -1
  69. package/build/physics/adapter.d.ts.map +1 -1
  70. package/build/physics/builtin/body.d.ts +3 -2
  71. package/build/physics/builtin/body.d.ts.map +1 -1
  72. package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
  73. package/build/physics/builtin/detector.d.ts +0 -1
  74. package/build/physics/builtin/detector.d.ts.map +1 -1
  75. package/build/physics/builtin/sat.d.ts +0 -7
  76. package/build/physics/builtin/sat3d.d.ts +46 -0
  77. package/build/physics/builtin/sat3d.d.ts.map +1 -1
  78. package/build/physics/response.d.ts +45 -62
  79. package/build/physics/response.d.ts.map +1 -1
  80. package/build/renderable/collectable.d.ts +6 -1
  81. package/build/renderable/collectable.d.ts.map +1 -1
  82. package/build/renderable/colorlayer.d.ts +4 -4
  83. package/build/renderable/colorlayer.d.ts.map +1 -1
  84. package/build/renderable/container.d.ts +23 -17
  85. package/build/renderable/container.d.ts.map +1 -1
  86. package/build/renderable/entity/entity.d.ts +12 -16
  87. package/build/renderable/entity/entity.d.ts.map +1 -1
  88. package/build/renderable/frameAnimation.d.ts +1 -1
  89. package/build/renderable/groundshadow.d.ts +1 -0
  90. package/build/renderable/groundshadow.d.ts.map +1 -1
  91. package/build/renderable/imagelayer.d.ts +12 -5
  92. package/build/renderable/imagelayer.d.ts.map +1 -1
  93. package/build/renderable/instanced_mesh.d.ts +2 -9
  94. package/build/renderable/instanced_mesh.d.ts.map +1 -1
  95. package/build/renderable/mesh.d.ts +283 -4
  96. package/build/renderable/mesh.d.ts.map +1 -1
  97. package/build/renderable/nineslicesprite.d.ts +3 -13
  98. package/build/renderable/nineslicesprite.d.ts.map +1 -1
  99. package/build/renderable/renderable.d.ts +90 -27
  100. package/build/renderable/renderable.d.ts.map +1 -1
  101. package/build/renderable/sprite.d.ts +5 -19
  102. package/build/renderable/sprite.d.ts.map +1 -1
  103. package/build/renderable/sprite3d.d.ts +27 -16
  104. package/build/renderable/sprite3d.d.ts.map +1 -1
  105. package/build/renderable/text/bitmaptext.d.ts +13 -3
  106. package/build/renderable/text/bitmaptext.d.ts.map +1 -1
  107. package/build/renderable/text/bitmaptextdata.d.ts +0 -4
  108. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
  109. package/build/renderable/text/text.d.ts +5 -3
  110. package/build/renderable/text/text.d.ts.map +1 -1
  111. package/build/renderable/text/textmetrics.d.ts +2 -0
  112. package/build/renderable/text/textmetrics.d.ts.map +1 -1
  113. package/build/renderable/trail.d.ts +0 -1
  114. package/build/renderable/trail.d.ts.map +1 -1
  115. package/build/renderable/trigger.d.ts +27 -5
  116. package/build/renderable/trigger.d.ts.map +1 -1
  117. package/build/renderable/ui/progressbar.d.ts +194 -0
  118. package/build/renderable/ui/progressbar.d.ts.map +1 -0
  119. package/build/renderable/ui/uibaseelement.d.ts +48 -3
  120. package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
  121. package/build/renderable/ui/uispriteelement.d.ts +19 -3
  122. package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
  123. package/build/system/legacy_pool.d.ts +2 -2
  124. package/build/system/legacy_pool.d.ts.map +1 -1
  125. package/build/system/pool.d.ts +10 -0
  126. package/build/system/pool.d.ts.map +1 -1
  127. package/build/tweens/tween.d.ts +49 -2
  128. package/build/tweens/tween.d.ts.map +1 -1
  129. package/build/video/canvas/canvas_renderer.d.ts +34 -23
  130. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  131. package/build/video/effects/blendEffect.d.ts +0 -1
  132. package/build/video/effects/bloom.d.ts +72 -0
  133. package/build/video/effects/bloom.d.ts.map +1 -0
  134. package/build/video/effects/blur.d.ts +3 -2
  135. package/build/video/effects/blur.d.ts.map +1 -1
  136. package/build/video/effects/chromaticAberration.d.ts +3 -2
  137. package/build/video/effects/chromaticAberration.d.ts.map +1 -1
  138. package/build/video/effects/colorMatrix.d.ts +3 -2
  139. package/build/video/effects/colorMatrix.d.ts.map +1 -1
  140. package/build/video/effects/desaturate.d.ts +10 -2
  141. package/build/video/effects/desaturate.d.ts.map +1 -1
  142. package/build/video/effects/dissolve.d.ts +3 -2
  143. package/build/video/effects/dissolve.d.ts.map +1 -1
  144. package/build/video/effects/dropShadow.d.ts +3 -2
  145. package/build/video/effects/dropShadow.d.ts.map +1 -1
  146. package/build/video/effects/flash.d.ts +3 -2
  147. package/build/video/effects/flash.d.ts.map +1 -1
  148. package/build/video/effects/glow.d.ts +3 -2
  149. package/build/video/effects/glow.d.ts.map +1 -1
  150. package/build/video/effects/hologram.d.ts +3 -2
  151. package/build/video/effects/hologram.d.ts.map +1 -1
  152. package/build/video/effects/invert.d.ts +10 -2
  153. package/build/video/effects/invert.d.ts.map +1 -1
  154. package/build/video/effects/outline.d.ts +3 -2
  155. package/build/video/effects/outline.d.ts.map +1 -1
  156. package/build/video/effects/pixelate.d.ts +3 -2
  157. package/build/video/effects/pixelate.d.ts.map +1 -1
  158. package/build/video/effects/radialGradient.d.ts +8 -3
  159. package/build/video/effects/radialGradient.d.ts.map +1 -1
  160. package/build/video/effects/scanline.d.ts +3 -2
  161. package/build/video/effects/scanline.d.ts.map +1 -1
  162. package/build/video/effects/sepia.d.ts +10 -2
  163. package/build/video/effects/sepia.d.ts.map +1 -1
  164. package/build/video/effects/shadereffect.d.ts +10 -4
  165. package/build/video/effects/shadereffect.d.ts.map +1 -1
  166. package/build/video/effects/shine.d.ts +3 -2
  167. package/build/video/effects/shine.d.ts.map +1 -1
  168. package/build/video/effects/tintPulse.d.ts +3 -2
  169. package/build/video/effects/tintPulse.d.ts.map +1 -1
  170. package/build/video/effects/tonemap.d.ts +121 -0
  171. package/build/video/effects/tonemap.d.ts.map +1 -0
  172. package/build/video/effects/vignette.d.ts +3 -2
  173. package/build/video/effects/vignette.d.ts.map +1 -1
  174. package/build/video/effects/wave.d.ts +3 -2
  175. package/build/video/effects/wave.d.ts.map +1 -1
  176. package/build/video/gpu/vertexformat.d.ts +26 -0
  177. package/build/video/gpu/vertexformat.d.ts.map +1 -1
  178. package/build/video/gradient.d.ts +0 -1
  179. package/build/video/gradient.d.ts.map +1 -1
  180. package/build/video/renderer.d.ts +111 -7
  181. package/build/video/renderer.d.ts.map +1 -1
  182. package/build/video/renderstate.d.ts +2 -0
  183. package/build/video/renderstate.d.ts.map +1 -1
  184. package/build/video/rendertarget/canvasrendertarget.d.ts +3 -4
  185. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  186. package/build/video/rendertarget/render_target_pool.d.ts +0 -1
  187. package/build/video/rendertarget/webglrendertarget.d.ts +0 -1
  188. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  189. package/build/video/rendertarget/webgpurendertarget.d.ts +18 -2
  190. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
  191. package/build/video/texture/atlas.d.ts +1 -0
  192. package/build/video/texture/atlas.d.ts.map +1 -1
  193. package/build/video/texture/cache.d.ts +1 -3
  194. package/build/video/texture/frametexture.d.ts +0 -1
  195. package/build/video/texture/frametexture.d.ts.map +1 -1
  196. package/build/video/texture/noise_texture2d.d.ts +1 -0
  197. package/build/video/texture/noise_texture2d.d.ts.map +1 -1
  198. package/build/video/utils/autodetect.d.ts +0 -2
  199. package/build/video/webgl/batchers/batcher.d.ts +0 -9
  200. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  201. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +11 -0
  202. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  203. package/build/video/webgl/batchers/material_batcher.d.ts +4 -2
  204. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  205. package/build/video/webgl/batchers/mesh_batcher.d.ts +0 -3
  206. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  207. package/build/video/webgl/batchers/quad_batcher.d.ts +4 -0
  208. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  209. package/build/video/webgl/buffer/index.d.ts +0 -1
  210. package/build/video/webgl/buffer/retained_geometry.d.ts +0 -1
  211. package/build/video/webgl/glshader.d.ts +5 -3
  212. package/build/video/webgl/glshader.d.ts.map +1 -1
  213. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +0 -4
  214. package/build/video/webgl/texture/store.d.ts +0 -1
  215. package/build/video/webgl/webgl_renderer.d.ts +63 -24
  216. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  217. package/build/video/webgpu/batchers/mesh_batcher.d.ts +0 -3
  218. package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
  219. package/build/video/webgpu/batchers/quad_batcher.d.ts +0 -2
  220. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
  221. package/build/video/webgpu/batchers/webgpu_batcher.d.ts +0 -2
  222. package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -1
  223. package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
  224. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +0 -2
  225. package/build/video/webgpu/texture/frametexture.d.ts +0 -2
  226. package/build/video/webgpu/texture/frametexture.d.ts.map +1 -1
  227. package/build/video/webgpu/texture/store.d.ts +0 -1
  228. package/build/video/webgpu/webgpu_renderer.d.ts +7 -75
  229. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
  230. package/package.json +1 -1
  231. package/skills/melonjs-3d/SKILL.md +277 -19
  232. package/skills/melonjs-3d-assets/SKILL.md +76 -9
  233. package/skills/melonjs-camera-and-drawing/SKILL.md +57 -1
  234. package/skills/melonjs-effects-and-shaders/SKILL.md +341 -29
  235. package/skills/melonjs-input/SKILL.md +48 -4
  236. package/skills/melonjs-particles-and-trails/SKILL.md +106 -4
  237. package/skills/melonjs-performance/SKILL.md +79 -2
  238. package/skills/melonjs-physics/SKILL.md +101 -27
  239. package/skills/melonjs-renderables/SKILL.md +2 -1
  240. package/skills/melonjs-scenes-and-state/SKILL.md +121 -1
  241. package/skills/melonjs-ui-and-text/SKILL.md +165 -4
  242. package/build/level/gltf/srgb.d.ts +0 -20
  243. package/build/level/gltf/srgb.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: melonjs-ui-and-text
3
- description: "Use this skill for HUDs, buttons, menus, dialogue panels and on-screen text in melonJS. Covers UIBaseElement/UISpriteElement/UITextButton, Draggable and DropTarget, the floating screen-space container pattern, Text and BitmapText, web font loading, and NineSliceSprite panels. Triggers on: UI, HUD, button, UIBaseElement, UISpriteElement, UITextButton, Draggable, DropTarget, menu, dialogue, Text, BitmapText, font, fontface, wordWrapWidth, NineSliceSprite, score display, floating."
3
+ description: "Use this skill for HUDs, buttons, menus, dialogue panels, progress bars and on-screen text in melonJS. Covers UIBaseElement/UISpriteElement/UITextButton, ProgressBar, Draggable and DropTarget, the floating screen-space container pattern, which of two overlapping panels gets the pointer, Text and BitmapText, web font loading, and NineSliceSprite panels. Triggers on: UI, HUD, button, UIBaseElement, UISpriteElement, UITextButton, ProgressBar, progress bar, health bar, gauge, Draggable, DropTarget, menu, dialogue, overlapping panels, moveToTop, onOver, onClick, Tween, easing, animate a label, Text, BitmapText, fillStyle, fillGradient, gradient text, tint, font, fontface, wordWrapWidth, NineSliceSprite, score display, floating."
4
4
  license: MIT
5
5
  ---
6
6
 
@@ -51,8 +51,24 @@ deliberate fade across a two-line title wants.
51
51
 
52
52
  The ramp colours the **fill only** — `Text` strokes in a separate pass, so
53
53
  an outline keeps its own colour without any luminance trickery — and it works on
54
- Canvas2D, which a post effect does not. `fillStyle.alpha` still gates the fill,
55
- and the property still reads back as a `Color`.
54
+ Canvas2D, which a post effect does not.
55
+
56
+ ### The gradient does not live in `fillStyle`
57
+
58
+ `fillStyle` ACCEPTS a `Gradient`; it never HOLDS one. The constructor routes it
59
+ to `fillGradient` and leaves `fillStyle` as the pooled `Color` it always is,
60
+ which is what keeps `fillStyle.alpha` gating the fill and keeps the colour
61
+ owned by the pool.
62
+
63
+ So changing the ramp later means assigning the field it actually landed in:
64
+
65
+ ```js
66
+ label.fillGradient = ramp; // ✓
67
+ label.fillStyle = ramp; // ✗ TS2740: Gradient is not a Color
68
+ ```
69
+
70
+ The ramp is authored for ONE line height, so a label that changes size needs a
71
+ new one built at the new size; there is nothing that rescales it for you.
56
72
 
57
73
  ## BitmapText: `size` is a RATIO, not pixels
58
74
 
@@ -96,6 +112,19 @@ loader.preload([
96
112
  Reach for it over `Text` when the text is mostly static, has to stay crisp at
97
113
  integer scales, or wants recolouring without a re-bake.
98
114
 
115
+ ### `fillStyle` means two different things
116
+
117
+ The name is shared and the behaviour is not, which is the trap when moving a
118
+ label from one class to the other:
119
+
120
+ | | `Text` | `BitmapText` |
121
+ |---|---|---|
122
+ | what `fillStyle` holds | a real `Color`, the fill | `Renderable#tint`, under another name |
123
+ | white | white glyphs | the ABSENCE of a tint |
124
+ | gradient | yes, via `fillGradient` | no: a tint is one colour over a page image |
125
+ | stroke | `strokeStyle` + `lineWidth` | none |
126
+ | `size` | pixels | a RATIO of the authored size |
127
+
99
128
  ## The HUD pattern
100
129
 
101
130
  A HUD is a `floating` container at a high z, built once and re-added:
@@ -129,6 +158,79 @@ Three things matter here:
129
158
  real accessor is `depth` (an alias for `pos.z`); `addChild(child, z)` sets it
130
159
  for you.
131
160
 
161
+ ### Bars and gauges: `ProgressBar`
162
+
163
+ A health bar, a shield gauge, a cooldown and a loading bar are one object. Set
164
+ `value`; it redraws.
165
+
166
+ ```js
167
+ const hp = new ProgressBar(20, 20, {
168
+ width: 200, height: 24,
169
+ min: 0, max: 100, value: 100, // min/max default to 0 and 1
170
+ trackColor: "#0000001a",
171
+ fillColor: "#c0392b",
172
+ borderColor: "black", borderWidth: 2,
173
+ padding: 2, // inset of the fill inside the track
174
+ radius: 6, // 0 is square
175
+ });
176
+ hud.addChild(hp);
177
+
178
+ hp.value -= 15; // clamps; `ratio` reads back 0..1
179
+ ```
180
+
181
+ `direction` takes `"left-to-right"` (the default), `"right-to-left"`,
182
+ `"top-to-bottom"` or `"bottom-to-top"`, each growing from its own edge.
183
+
184
+ **The colour follows the value by mutating the `Color` you passed.** This is
185
+ the one non-obvious part, and it is deliberate: every game wants a different
186
+ rule, and most want the colour somewhere else too, next to a shader uniform or
187
+ a glow. The bar re-reads `fillColor` every frame, so it never has to know:
188
+
189
+ ```js
190
+ const full = new Color().parseCSS("#7fe0ff");
191
+ const empty = new Color().parseCSS("#ff2a1e");
192
+ const mixed = new Color();
193
+
194
+ const shield = new ProgressBar(x, y, {
195
+ width: 190, height: 13,
196
+ trackColor: null, // hollow: the scene shows through
197
+ borderColor: "rgba(122, 190, 235, 0.8)",
198
+ padding: 2,
199
+ fillColor: mixed, // KEPT, not copied
200
+ });
201
+
202
+ // each frame
203
+ mixed.copy(empty).lerp(full, hp); // the bar follows, and so can a shader
204
+ shield.value = hp;
205
+ ```
206
+
207
+ Blinking is the same story: `setOpacity()` already does it, on whatever clock
208
+ the game is already keeping. Neither is built in.
209
+
210
+ **`bindEvent` takes the value from an event instead**, and the subscription
211
+ then lives exactly as long as the bar:
212
+
213
+ ```js
214
+ const bar = new ProgressBar(0, y, {
215
+ width: renderer.width, height: 4,
216
+ trackColor: "black", fillColor: "#55aa00",
217
+ bindEvent: event.LOADER_PROGRESS,
218
+ });
219
+ ```
220
+
221
+ Hold that subscription anywhere else and it outlives the bar, firing into a
222
+ renderable whose `pos` has already been released. The engine's own loading
223
+ screen is built on exactly this.
224
+
225
+ Two more worth knowing:
226
+
227
+ - **The border is four filled rects, not a stroke** (unless the bar is
228
+ rounded). A stroke is centred on the path, so half of it falls outside and a
229
+ bordered bar paints over its neighbour; and `strokeRect` adds corner joins
230
+ only above a line width of 1, so at exactly 1 a corner pixel goes missing.
231
+ - **`trackColor: null` leaves the bar hollow**, which is what a HUD over a busy
232
+ scene usually wants: the border is then the only chrome.
233
+
132
234
  ### Buttons: extend the handlers, do not bind listeners
133
235
 
134
236
  `UISpriteElement` is a `Sprite` that already registers itself for pointer
@@ -139,7 +241,7 @@ events, so a button is made by overriding methods rather than by wiring
139
241
  |---|---|---|
140
242
  | `onClick(event)` | pressed | `false` to stop the event propagating |
141
243
  | `onRelease(event)` | pressed and released | `false` to stop propagating |
142
- | `onOver(event)` | pointer enters | — |
244
+ | `onOver(event)` | pointer enters | `false` to stop propagating |
143
245
  | `onOut(event)` | pointer leaves | — |
144
246
  | `onHold()` | pressed and held | — |
145
247
 
@@ -163,6 +265,59 @@ default on a plain `Renderable` — is skipped by the broadphase and receives
163
265
  nothing. `UISpriteElement` and `UIBaseElement` clear it for you; anything else
164
266
  you make clickable has to clear it itself.
165
267
 
268
+ ### `z` is container-local
269
+
270
+ `addChild(child, z)` writes a depth that means something **only among that
271
+ container's own children**. `autoDepth` numbers them from 1, so a button at
272
+ `z = 8` inside one panel and a whole second panel at `z = 2` are not comparable
273
+ numbers, and the second panel is still the one on top. Drawing and hit-testing
274
+ both resolve a cross-container pair the same way: walk up to the common parent
275
+ and compare the two siblings there.
276
+
277
+ So a panel is raised by raising **the panel**, not its contents:
278
+
279
+ ```js
280
+ this.ancestor.moveToTop(panel); // reorders, and sets z past its neighbour
281
+ ```
282
+
283
+ Giving a child a huge `z` to "put it in front" lifts it only within its own
284
+ panel. This is also why a widget's `z` never has to be coordinated with
285
+ anything outside its own container.
286
+
287
+ ### An opaque panel has to say so
288
+
289
+ The hit test asks the topmost renderable first and then keeps walking down, so
290
+ consuming is what stops a widget underneath answering too. A panel that can
291
+ overlap another one therefore wants both:
292
+
293
+ ```js
294
+ class Panel extends UIBaseElement {
295
+ onClick() {
296
+ this.ancestor.moveToTop(this); // and bring it to the front
297
+ return false; // consumed
298
+ }
299
+ onOver() {
300
+ return false; // the frame the pointer crosses in
301
+ }
302
+ onActivateEvent() {
303
+ super.onActivateEvent();
304
+ // and every frame after that, when the pointer is ALREADY inside and
305
+ // `onOver` no longer fires
306
+ input.registerPointerEvent("pointermove", this, () => false);
307
+ }
308
+ onDeactivateEvent() {
309
+ input.releasePointerEvent("pointermove", this);
310
+ super.onDeactivateEvent();
311
+ }
312
+ }
313
+ ```
314
+
315
+ Leave `onOut` alone: an element that suppresses its own leave stays lit after
316
+ the pointer has gone. It fires for the covered element too, not only when the
317
+ pointer leaves its bounds, so a button half under the panel goes dark as soon as
318
+ the pointer slides onto the panel, which never takes it out of the button's
319
+ bounds.
320
+
166
321
  ### In a 3D scene, a HUD needs a SMALL depth
167
322
 
168
323
  `floating` opts a renderable out of the camera transform. It does **not** opt it
@@ -187,3 +342,9 @@ Give a HUD the huge z that would put it on top in 2D and it lands at the far end
187
342
  of the level instead, with the scenery drawing over it. Both shipped idioms are
188
343
  the same rule: afterBurner's HUD sits at `-150`, and the glTF, Billboard, Night
189
344
  City and Instanced Forest examples park a floating sky at `-10000` or `100000`.
345
+
346
+ ## Related skills
347
+
348
+ - `melonjs-scenes-and-state` — `Tween` and the easing families, for animating any of this
349
+ - `melonjs-input` — which object gets a pointer event, and how to consume it
350
+ - `melonjs-loading-assets` — web fonts have to be loaded before a `Text` bakes
@@ -1,20 +0,0 @@
1
- /**
2
- * Color-space bridge for glTF material factors.
3
- *
4
- * glTF 2.0 defines `pbrMetallicRoughness.baseColorFactor` in **linear** space
5
- * (spec §3.9.2), while a melonJS `tint` is an 8-bit **sRGB** value — the same
6
- * space as a CSS color or a texel out of a PNG. Handing the linear number
7
- * straight to `tint.setColor(f * 255)` therefore displays every untextured
8
- * glTF material far too light and desaturated: a linear `0.29` shows up as
9
- * sRGB `0.58`, so an authored mid-green renders as pale mint.
10
- *
11
- * The encode below is the standard sRGB transfer function.
12
- * @module level/gltf/srgb
13
- */
14
- /**
15
- * Encode one linear channel (0..1) to an 8-bit sRGB value (0..255).
16
- * @param {number} c - linear channel value
17
- * @returns {number} the sRGB-encoded channel, rounded to 0..255
18
- */
19
- export function linearToSrgb8(c: number): number;
20
- //# sourceMappingURL=srgb.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"srgb.d.ts","sourceRoot":"","sources":["../../../src/level/gltf/srgb.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AACH,iCAHW,MAAM,GACJ,MAAM,CAQlB"}