melonjs 20.6.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 (265) 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 +10 -3
  21. package/build/index.d.ts.map +1 -1
  22. package/build/index.js +23361 -20195
  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/lang/deprecated.d.ts.map +1 -1
  27. package/build/level/gltf/GLTFModel.d.ts +17 -31
  28. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  29. package/build/level/gltf/GLTFScene.d.ts +40 -1
  30. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  31. package/build/level/level.d.ts +36 -0
  32. package/build/level/level.d.ts.map +1 -1
  33. package/build/level/tiled/TMXLayer.d.ts +5 -2
  34. package/build/level/tiled/TMXLayer.d.ts.map +1 -1
  35. package/build/level/tiled/TMXObject.d.ts +0 -1
  36. package/build/level/tiled/TMXTile.d.ts +2 -1
  37. package/build/level/tiled/TMXTile.d.ts.map +1 -1
  38. package/build/level/tiled/TMXTileMap.d.ts +7 -4
  39. package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
  40. package/build/level/tiled/TMXTileset.d.ts +1 -1
  41. package/build/level/tiled/TMXTileset.d.ts.map +1 -1
  42. package/build/level/tiled/TMXTilesetGroup.d.ts +5 -0
  43. package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -1
  44. package/build/level/tiled/factories/shape.d.ts +0 -1
  45. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +6 -5
  46. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
  47. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +5 -0
  48. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
  49. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +8 -7
  50. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
  51. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +5 -0
  52. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
  53. package/build/level/tiled/renderer/TMXRenderer.d.ts +19 -4
  54. package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
  55. package/build/level/tiled/renderer/autodetect.d.ts +0 -4
  56. package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
  57. package/build/lighting/light2d.d.ts +68 -2
  58. package/build/lighting/light2d.d.ts.map +1 -1
  59. package/build/lighting/light3d.d.ts.map +1 -1
  60. package/build/loader/loader.d.ts +63 -0
  61. package/build/loader/loader.d.ts.map +1 -1
  62. package/build/loader/loadingscreen.d.ts +1 -2
  63. package/build/loader/loadingscreen.d.ts.map +1 -1
  64. package/build/loader/parsers/fontface.d.ts +2 -0
  65. package/build/loader/parsers/fontface.d.ts.map +1 -1
  66. package/build/loader/parsers/mtl.d.ts.map +1 -1
  67. package/build/loader/parsers/shader.d.ts +0 -2
  68. package/build/math/color.d.ts +27 -4
  69. package/build/math/color.d.ts.map +1 -1
  70. package/build/particles/emitter.d.ts.map +1 -1
  71. package/build/particles/particle.d.ts +22 -1
  72. package/build/particles/particle.d.ts.map +1 -1
  73. package/build/particles/settings.d.ts +69 -0
  74. package/build/particles/settings.d.ts.map +1 -1
  75. package/build/physics/adapter.d.ts +152 -3
  76. package/build/physics/adapter.d.ts.map +1 -1
  77. package/build/physics/builtin/body.d.ts +9 -18
  78. package/build/physics/builtin/body.d.ts.map +1 -1
  79. package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
  80. package/build/physics/builtin/detector.d.ts +0 -1
  81. package/build/physics/builtin/detector.d.ts.map +1 -1
  82. package/build/physics/builtin/sat.d.ts +0 -7
  83. package/build/physics/builtin/sat.d.ts.map +1 -1
  84. package/build/physics/builtin/sat3d.d.ts +46 -0
  85. package/build/physics/builtin/sat3d.d.ts.map +1 -1
  86. package/build/physics/physicseditor.d.ts +2 -0
  87. package/build/physics/physicseditor.d.ts.map +1 -0
  88. package/build/physics/response.d.ts +45 -62
  89. package/build/physics/response.d.ts.map +1 -1
  90. package/build/renderable/collectable.d.ts +6 -1
  91. package/build/renderable/collectable.d.ts.map +1 -1
  92. package/build/renderable/colorlayer.d.ts +4 -4
  93. package/build/renderable/colorlayer.d.ts.map +1 -1
  94. package/build/renderable/container.d.ts +23 -17
  95. package/build/renderable/container.d.ts.map +1 -1
  96. package/build/renderable/entity/entity.d.ts +14 -16
  97. package/build/renderable/entity/entity.d.ts.map +1 -1
  98. package/build/renderable/frameAnimation.d.ts +1 -1
  99. package/build/renderable/groundshadow.d.ts +1 -0
  100. package/build/renderable/groundshadow.d.ts.map +1 -1
  101. package/build/renderable/imagelayer.d.ts +12 -5
  102. package/build/renderable/imagelayer.d.ts.map +1 -1
  103. package/build/renderable/instanced_mesh.d.ts +2 -9
  104. package/build/renderable/instanced_mesh.d.ts.map +1 -1
  105. package/build/renderable/mesh.d.ts +306 -5
  106. package/build/renderable/mesh.d.ts.map +1 -1
  107. package/build/renderable/nineslicesprite.d.ts +3 -13
  108. package/build/renderable/nineslicesprite.d.ts.map +1 -1
  109. package/build/renderable/renderable.d.ts +129 -28
  110. package/build/renderable/renderable.d.ts.map +1 -1
  111. package/build/renderable/sprite.d.ts +77 -19
  112. package/build/renderable/sprite.d.ts.map +1 -1
  113. package/build/renderable/sprite3d.d.ts +27 -16
  114. package/build/renderable/sprite3d.d.ts.map +1 -1
  115. package/build/renderable/text/bitmaptext.d.ts +13 -3
  116. package/build/renderable/text/bitmaptext.d.ts.map +1 -1
  117. package/build/renderable/text/bitmaptextdata.d.ts +0 -4
  118. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
  119. package/build/renderable/text/text.d.ts +5 -3
  120. package/build/renderable/text/text.d.ts.map +1 -1
  121. package/build/renderable/text/textmetrics.d.ts +2 -0
  122. package/build/renderable/text/textmetrics.d.ts.map +1 -1
  123. package/build/renderable/trail.d.ts +0 -1
  124. package/build/renderable/trail.d.ts.map +1 -1
  125. package/build/renderable/trigger.d.ts +39 -14
  126. package/build/renderable/trigger.d.ts.map +1 -1
  127. package/build/renderable/ui/progressbar.d.ts +194 -0
  128. package/build/renderable/ui/progressbar.d.ts.map +1 -0
  129. package/build/renderable/ui/uibaseelement.d.ts +48 -3
  130. package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
  131. package/build/renderable/ui/uispriteelement.d.ts +19 -3
  132. package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
  133. package/build/state/stage.d.ts +22 -0
  134. package/build/state/stage.d.ts.map +1 -1
  135. package/build/system/legacy_pool.d.ts +2 -2
  136. package/build/system/legacy_pool.d.ts.map +1 -1
  137. package/build/system/pool.d.ts +10 -0
  138. package/build/system/pool.d.ts.map +1 -1
  139. package/build/tweens/tween.d.ts +49 -2
  140. package/build/tweens/tween.d.ts.map +1 -1
  141. package/build/video/buffer/vertex.d.ts.map +1 -1
  142. package/build/video/canvas/canvas_renderer.d.ts +34 -23
  143. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  144. package/build/video/effects/blendEffect.d.ts +0 -1
  145. package/build/video/effects/bloom.d.ts +72 -0
  146. package/build/video/effects/bloom.d.ts.map +1 -0
  147. package/build/video/effects/blur.d.ts +3 -2
  148. package/build/video/effects/blur.d.ts.map +1 -1
  149. package/build/video/effects/chromaticAberration.d.ts +3 -2
  150. package/build/video/effects/chromaticAberration.d.ts.map +1 -1
  151. package/build/video/effects/colorMatrix.d.ts +3 -2
  152. package/build/video/effects/colorMatrix.d.ts.map +1 -1
  153. package/build/video/effects/desaturate.d.ts +10 -2
  154. package/build/video/effects/desaturate.d.ts.map +1 -1
  155. package/build/video/effects/dissolve.d.ts +3 -2
  156. package/build/video/effects/dissolve.d.ts.map +1 -1
  157. package/build/video/effects/dropShadow.d.ts +3 -2
  158. package/build/video/effects/dropShadow.d.ts.map +1 -1
  159. package/build/video/effects/flash.d.ts +3 -2
  160. package/build/video/effects/flash.d.ts.map +1 -1
  161. package/build/video/effects/glow.d.ts +3 -2
  162. package/build/video/effects/glow.d.ts.map +1 -1
  163. package/build/video/effects/hologram.d.ts +3 -2
  164. package/build/video/effects/hologram.d.ts.map +1 -1
  165. package/build/video/effects/invert.d.ts +10 -2
  166. package/build/video/effects/invert.d.ts.map +1 -1
  167. package/build/video/effects/outline.d.ts +3 -2
  168. package/build/video/effects/outline.d.ts.map +1 -1
  169. package/build/video/effects/pixelate.d.ts +3 -2
  170. package/build/video/effects/pixelate.d.ts.map +1 -1
  171. package/build/video/effects/radialGradient.d.ts +8 -3
  172. package/build/video/effects/radialGradient.d.ts.map +1 -1
  173. package/build/video/effects/scanline.d.ts +3 -2
  174. package/build/video/effects/scanline.d.ts.map +1 -1
  175. package/build/video/effects/sepia.d.ts +10 -2
  176. package/build/video/effects/sepia.d.ts.map +1 -1
  177. package/build/video/effects/shadereffect.d.ts +10 -4
  178. package/build/video/effects/shadereffect.d.ts.map +1 -1
  179. package/build/video/effects/shine.d.ts +3 -2
  180. package/build/video/effects/shine.d.ts.map +1 -1
  181. package/build/video/effects/tintPulse.d.ts +3 -2
  182. package/build/video/effects/tintPulse.d.ts.map +1 -1
  183. package/build/video/effects/tonemap.d.ts +121 -0
  184. package/build/video/effects/tonemap.d.ts.map +1 -0
  185. package/build/video/effects/vignette.d.ts +3 -2
  186. package/build/video/effects/vignette.d.ts.map +1 -1
  187. package/build/video/effects/wave.d.ts +3 -2
  188. package/build/video/effects/wave.d.ts.map +1 -1
  189. package/build/video/gpu/meshmaterial.d.ts +2 -0
  190. package/build/video/gpu/meshmaterial.d.ts.map +1 -0
  191. package/build/video/gpu/vertexformat.d.ts +26 -0
  192. package/build/video/gpu/vertexformat.d.ts.map +1 -1
  193. package/build/video/gradient.d.ts +0 -1
  194. package/build/video/gradient.d.ts.map +1 -1
  195. package/build/video/renderer.d.ts +111 -7
  196. package/build/video/renderer.d.ts.map +1 -1
  197. package/build/video/renderstate.d.ts +2 -0
  198. package/build/video/renderstate.d.ts.map +1 -1
  199. package/build/video/rendertarget/canvasrendertarget.d.ts +3 -4
  200. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  201. package/build/video/rendertarget/render_target_pool.d.ts +0 -1
  202. package/build/video/rendertarget/webglrendertarget.d.ts +0 -1
  203. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  204. package/build/video/rendertarget/webgpurendertarget.d.ts +18 -2
  205. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
  206. package/build/video/texture/atlas.d.ts +1 -0
  207. package/build/video/texture/atlas.d.ts.map +1 -1
  208. package/build/video/texture/cache.d.ts +1 -3
  209. package/build/video/texture/frametexture.d.ts +0 -1
  210. package/build/video/texture/frametexture.d.ts.map +1 -1
  211. package/build/video/texture/noise_texture2d.d.ts +1 -0
  212. package/build/video/texture/noise_texture2d.d.ts.map +1 -1
  213. package/build/video/utils/autodetect.d.ts +0 -2
  214. package/build/video/webgl/batchers/batcher.d.ts +0 -9
  215. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  216. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +13 -1
  217. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  218. package/build/video/webgl/batchers/material_batcher.d.ts +4 -2
  219. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  220. package/build/video/webgl/batchers/mesh_batcher.d.ts +2 -3
  221. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  222. package/build/video/webgl/batchers/quad_batcher.d.ts +4 -0
  223. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  224. package/build/video/webgl/buffer/index.d.ts +0 -1
  225. package/build/video/webgl/buffer/retained_geometry.d.ts +0 -1
  226. package/build/video/webgl/glshader.d.ts +5 -3
  227. package/build/video/webgl/glshader.d.ts.map +1 -1
  228. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +0 -4
  229. package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
  230. package/build/video/webgl/texture/store.d.ts +0 -1
  231. package/build/video/webgl/webgl_renderer.d.ts +63 -24
  232. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  233. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +17 -0
  234. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -1
  235. package/build/video/webgpu/batchers/mesh_batcher.d.ts +0 -3
  236. package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
  237. package/build/video/webgpu/batchers/quad_batcher.d.ts +0 -2
  238. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
  239. package/build/video/webgpu/batchers/webgpu_batcher.d.ts +0 -2
  240. package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -1
  241. package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
  242. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +0 -2
  243. package/build/video/webgpu/texture/frametexture.d.ts +0 -2
  244. package/build/video/webgpu/texture/frametexture.d.ts.map +1 -1
  245. package/build/video/webgpu/texture/store.d.ts +0 -1
  246. package/build/video/webgpu/texture/store.d.ts.map +1 -1
  247. package/build/video/webgpu/webgpu_renderer.d.ts +8 -75
  248. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
  249. package/package.json +1 -1
  250. package/skills/melonjs-3d/SKILL.md +293 -19
  251. package/skills/melonjs-3d-assets/SKILL.md +123 -13
  252. package/skills/melonjs-camera-and-drawing/SKILL.md +57 -1
  253. package/skills/melonjs-effects-and-shaders/SKILL.md +341 -29
  254. package/skills/melonjs-input/SKILL.md +48 -4
  255. package/skills/melonjs-lighting/SKILL.md +45 -1
  256. package/skills/melonjs-loading-assets/SKILL.md +1 -1
  257. package/skills/melonjs-particles-and-trails/SKILL.md +106 -4
  258. package/skills/melonjs-performance/SKILL.md +79 -2
  259. package/skills/melonjs-physics/SKILL.md +420 -29
  260. package/skills/melonjs-renderables/SKILL.md +15 -1
  261. package/skills/melonjs-scenes-and-state/SKILL.md +121 -1
  262. package/skills/melonjs-tilemaps/SKILL.md +9 -0
  263. package/skills/melonjs-ui-and-text/SKILL.md +165 -4
  264. package/build/level/gltf/srgb.d.ts +0 -20
  265. package/build/level/gltf/srgb.d.ts.map +0 -1
@@ -17,6 +17,16 @@ export default class Renderable extends Rect {
17
17
  * `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`,
18
18
  * `"bottom-left"`, `"bottom-right"` on every renderable that consumes it
19
19
  * (Sprite, Entity, Collectable, ImageLayer, Text, BitmapText, Sprite3d and subclasses).
20
+ * <br>
21
+ * <i><b>Note:</b> a body's collision shapes are measured from the same frame this
22
+ * places the renderable in, so a shape of `Rect(0, 0, width, height)` covers the
23
+ * renderable whatever the anchor is (since 20.7; before that shapes were measured
24
+ * from `pos` regardless, and a non-corner anchor collided where it was not drawn).
25
+ * A shape's own `pos` still offsets it inside that frame. A renderable that has
26
+ * cleared {@link Renderable#applyAnchorTransform} takes no offset at all, on the
27
+ * drawing or on its shapes. Note also that the adapters read the anchor when the
28
+ * body is created, so changing it afterwards moves the drawing but not an
29
+ * already-built body.</i>
20
30
  * @type {ObservablePoint}
21
31
  * @default <0.5,0.5>
22
32
  */
@@ -88,9 +98,37 @@ export default class Renderable extends Rect {
88
98
  * Typical fields: `type` (`"static"`/`"dynamic"`/`"kinematic"`),
89
99
  * `shapes`, `collisionType`, `collisionMask`, `restitution`,
90
100
  * `frictionAir`, `density`, `gravityScale`, `isSensor`,
91
- * `maxVelocity`, `fixedRotation`. See {@link BodyDefinition}.
101
+ * `maxVelocity`, `fixedRotation`. See {@link BodyDefinitionInit}.
102
+
103
+ *
104
+ * `shapes` is normally a list of collision shapes, but it can also
105
+ * name a collision shape file preloaded as JSON, paired with `id`
106
+ * naming the body to read out of it. The file is resolved before any
107
+ * adapter sees the definition, so the same one works unchanged on
108
+ * every backend.
92
109
  * @type {object|undefined}
93
110
  * @default undefined
111
+ * @example
112
+ * // a shape authored in code
113
+ * this.bodyDef = {
114
+ * type: "dynamic",
115
+ * shapes: [new me.Rect(0, 0, this.width, this.height)],
116
+ * };
117
+ *
118
+ * @example
119
+ * // shapes drawn in a physics-shape editor, preloaded as JSON with
120
+ * // { name: "shapes", type: "json", src: "data/physics/shapes.json" }
121
+ * this.bodyDef = { type: "dynamic", shapes: "shapes", id: "hotdog" };
122
+ *
123
+ * // the density, friction and bounce the shapes were authored with
124
+ * // come with them, unless the definition states otherwise (each is
125
+ * // honoured by whichever backends support it):
126
+ * this.bodyDef = {
127
+ * type: "dynamic",
128
+ * shapes: "shapes",
129
+ * id: "hotdog",
130
+ * restitution: 0.9, // wins over whatever the file carries
131
+ * };
94
132
  */
95
133
  bodyDef: object | undefined;
96
134
  /**
@@ -277,6 +315,36 @@ export default class Renderable extends Rect {
277
315
  * @default true
278
316
  */
279
317
  isKinematic: boolean;
318
+ /**
319
+ * whether a single post effect on this renderable needs an offscreen
320
+ * capture instead of the renderer's shader-swap fast path.
321
+ *
322
+ * One effect is normally applied by drawing the renderable with the
323
+ * effect's own program rather than capturing and post-processing it,
324
+ * which costs no render target. That is only equivalent when everything
325
+ * the renderable draws is a textured quad. `fillRect` and the shape
326
+ * dispatch go through a batcher that never looks at that shader, so a
327
+ * single effect on a renderable that draws with primitives silently
328
+ * does nothing. Set this and the capture is used instead, at the cost
329
+ * of a render target while the effect is active.
330
+ *
331
+ * Two or more effects always capture, so this only ever changes the
332
+ * single-effect case.
333
+ * @type {boolean}
334
+ * @default false
335
+ * @example
336
+ * class Bar extends Renderable {
337
+ * constructor(x, y, w, h) {
338
+ * super(x, y, w, h);
339
+ * // this draws itself with primitives, not as a sprite
340
+ * this.postEffectNeedsCapture = true;
341
+ * }
342
+ * draw(renderer) {
343
+ * renderer.fillRect(this.pos.x, this.pos.y, this.width, this.height);
344
+ * }
345
+ * }
346
+ */
347
+ postEffectNeedsCapture: boolean;
280
348
  /**
281
349
  * returns the parent application (or game) to which this renderable is attached to
282
350
  * @return {Application} the parent application or undefined if not attached to any container/app
@@ -306,6 +374,31 @@ export default class Renderable extends Rect {
306
374
  * @type {number}
307
375
  */
308
376
  get depth(): number;
377
+ /**
378
+ * Move this renderable, optionally in three dimensions.
379
+ *
380
+ * `pos` holds an `ObservableVector3d`, but the geometry this class
381
+ * inherits from declares it as a 2D vector, so from TypeScript
382
+ * `pos.set(x, y)` takes two arguments and silently writes a zero z.
383
+ * Anything with a depth then drops to the near plane. Reaching past that
384
+ * previously meant a double cast or assigning `pos.x`, `pos.y` and
385
+ * `depth` by hand, which is why that pattern is written out dozens of
386
+ * times across the examples.
387
+ *
388
+ * **Omitting `z` leaves the depth exactly as it was**, rather than
389
+ * zeroing it. That is the whole difference from `pos.set(x, y)`, and it
390
+ * is what makes this safe to call on a 2D sprite that happens to sit at
391
+ * a depth, or on a `Camera2d`, without having to know whether it does.
392
+ * @param {number} x - the new x position
393
+ * @param {number} y - the new y position
394
+ * @param {number} [z] - the new depth; left untouched when omitted
395
+ * @returns {Renderable} this renderable, for chaining
396
+ * @example
397
+ * sprite.setPosition(120, 64); // 2D: depth unchanged
398
+ * mesh.setPosition(0, -20, 140); // 3D
399
+ * camera.setPosition(0, 0, -300).lookAt(player);
400
+ */
401
+ setPosition(x: number, y: number, z?: number): Renderable;
309
402
  set inViewport(value: boolean);
310
403
  /**
311
404
  * Whether the renderable object is visible and within the viewport
@@ -365,11 +458,6 @@ export default class Renderable extends Rect {
365
458
  * @type {boolean}
366
459
  */
367
460
  public get isFlippedY(): boolean;
368
- /**
369
- * returns the bounding box for this renderable
370
- * @returns {Bounds} bounding box Rectangle object
371
- */
372
- getBounds(): Bounds;
373
461
  /**
374
462
  * get the renderable alpha channel value<br>
375
463
  *
@@ -401,9 +489,9 @@ export default class Renderable extends Rect {
401
489
  * multiply the renderable currentTransform with the given matrix
402
490
  * @see Renderable#currentTransform
403
491
  * @param {Matrix2d|Matrix3d} m - the transformation matrix
404
- * @returns {Renderable} Reference to this object for method chaining
492
+ * @returns {this} Reference to this object for method chaining
405
493
  */
406
- transform(m: Matrix2d | Matrix3d): Renderable;
494
+ transform(m: Matrix2d | Matrix3d): this;
407
495
  /**
408
496
  * return the angle to the specified target
409
497
  * @param {Renderable|Vector2d|Vector3d} target
@@ -428,9 +516,9 @@ export default class Renderable extends Rect {
428
516
  * When called with an angle and a Vector3d axis, rotates around that axis in 3D.
429
517
  * @param {number} angle - The angle to rotate (in radians)
430
518
  * @param {Vector3d} [v] - the axis to rotate around (defaults to Z axis for 2D)
431
- * @returns {Renderable} Reference to this object for method chaining
519
+ * @returns {this} Reference to this object for method chaining
432
520
  */
433
- rotate(angle: number, v?: Vector3d): Renderable;
521
+ rotate(angle: number, v?: Vector3d): this;
434
522
  /**
435
523
  * scale the renderable around his anchor point. Scaling actually applies changes
436
524
  * to the currentTransform member which is used by the renderer to scale the object
@@ -440,23 +528,23 @@ export default class Renderable extends Rect {
440
528
  * @param {number} x - a number representing the abscissa of the scaling vector.
441
529
  * @param {number} [y=x] - a number representing the ordinate of the scaling vector.
442
530
  * @param {number} [z=1] - a number representing the depth of the scaling vector.
443
- * @returns {Renderable} Reference to this object for method chaining
531
+ * @returns {this} Reference to this object for method chaining
444
532
  */
445
- scale(x: number, y?: number, z?: number): Renderable;
533
+ scale(x: number, y?: number, z?: number): this;
446
534
  /**
447
535
  * scale the renderable around his anchor point
448
536
  * @param {Vector2d} v - scaling vector
449
- * @returns {Renderable} Reference to this object for method chaining
537
+ * @returns {this} Reference to this object for method chaining
450
538
  */
451
- scaleV(v: Vector2d): Renderable;
539
+ scaleV(v: Vector2d): this;
452
540
  /**
453
541
  * Translate the renderable by the specified offset.
454
- * @param {number} x - x offset
455
- * @param {number} [y=0] - y offset
456
- * @param {number} [z=0] - z offset
457
- * @returns {Renderable} Reference to this object for method chaining
542
+ * @param {number|Vector2d|Vector3d} x - x offset, or a vector to translate by
543
+ * @param {number} [y=0] - y offset, ignored when the first argument is a vector
544
+ * @param {number} [z=0] - z offset, ignored when the first argument is a vector
545
+ * @returns {this} Reference to this object for method chaining
458
546
  */
459
- translate(x: number, y?: number, z?: number): Renderable;
547
+ translate(x: number | Vector2d | Vector3d, y?: number, z?: number): this;
460
548
  /**
461
549
  * update function (automatically called by melonJS).
462
550
  * @param {number} dt - time since the last update in milliseconds.
@@ -580,9 +668,9 @@ export default class Renderable extends Rect {
580
668
  * This will apply any defined transforms, anchor point, tint or blend mode and translate the context accordingly to this renderable position.
581
669
  * @see Renderable#draw
582
670
  * @see Renderable#postDraw
583
- * @param {CanvasRenderer|WebGLRenderer} renderer - a renderer object
671
+ * @param {Renderer} renderer - a renderer object
584
672
  */
585
- preDraw(renderer: CanvasRenderer | WebGLRenderer): void;
673
+ preDraw(renderer: Renderer): void;
586
674
  /**
587
675
  * Draw this renderable (automatically called by melonJS).
588
676
  * All draw operations for renderable are made respectively
@@ -596,17 +684,22 @@ export default class Renderable extends Rect {
596
684
  * `(0, 0)` places the shape at the container's origin instead.
597
685
  * @see Renderable#preDraw
598
686
  * @see Renderable#postDraw
599
- * @param {CanvasRenderer|WebGLRenderer} renderer - a renderer instance
600
- * @param {Camera2d} [viewport] - the viewport to (re)draw
687
+ * @param {Renderer} renderer - a renderer instance
688
+ * @param {Camera2d|Container} [viewport] - the frame this draw happens in:
689
+ * the camera drawing it, or -- when a camera is itself the renderable being
690
+ * drawn -- the container it draws. `Camera2d#draw` takes the second, and
691
+ * declaring only the first here meant a camera was not assignable to the
692
+ * `Renderable` it extends, which cascaded into every signature mentioning
693
+ * either of them
601
694
  */
602
- draw(renderer: CanvasRenderer | WebGLRenderer, viewport?: Camera2d): void;
695
+ draw(renderer: Renderer, viewport?: Camera2d | Container): void;
603
696
  /**
604
697
  * restore the rendering context after drawing (automatically called by melonJS).
605
698
  * @see Renderable#preDraw
606
699
  * @see Renderable#draw
607
- * @param {CanvasRenderer|WebGLRenderer} renderer - a renderer object
700
+ * @param {Renderer} renderer - a renderer object
608
701
  */
609
- postDraw(renderer: CanvasRenderer | WebGLRenderer): void;
702
+ postDraw(renderer: Renderer): void;
610
703
  /**
611
704
  * Legacy collision callback — fires every frame this renderable body is
612
705
  * overlapping another body. Kept for backward compatibility with code
@@ -676,13 +769,21 @@ export default class Renderable extends Rect {
676
769
  import { Rect } from "./../geometries/rectangle.ts";
677
770
  import { ObservablePoint } from "../geometries/observablePoint.ts";
678
771
  import { Matrix3d } from "../math/matrix3d.ts";
772
+ import type { PhysicsBody } from "../physics/adapter.ts";
679
773
  import type Container from "./container.js";
680
774
  import type Entity from "./entity/entity.js";
681
775
  import type { RoundRect } from "./../geometries/roundrect.ts";
682
776
  import type { Polygon } from "../geometries/polygon.ts";
683
777
  import type { Line } from "./../geometries/line.ts";
684
778
  import type { Ellipse } from "./../geometries/ellipse.ts";
779
+ import type GLShader from "../video/webgl/glshader.js";
780
+ import type ShaderEffect from "../video/effects/shadereffect.js";
781
+ import type { Vector3d } from "../math/vector3d.ts";
782
+ import type { Color } from "../math/color.ts";
685
783
  import type Application from "./../application/application.ts";
686
- import type CanvasRenderer from "./../video/canvas/canvas_renderer.js";
687
- import type WebGLRenderer from "./../video/webgl/webgl_renderer.js";
784
+ import type { Matrix2d } from "../math/matrix2d.ts";
785
+ import type { Vector2d } from "../math/vector2d.ts";
786
+ import type { Bounds } from "../physics/bounds.ts";
787
+ import type Renderer from "../video/renderer.js";
788
+ import type Camera2d from "../camera/camera2d.ts";
688
789
  //# sourceMappingURL=renderable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"AA6CA;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;;;;;;OAeG;IACH,aAHU,eAAe,CAMvB;IAGD;;;;;;;OAOG;IACH,kBAFU,QAAQ,CAEoB;IAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,MAlCU,WAAW,CAkCA;IAErB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAHU,MAAM,GAAC,SAAS,CAGF;IAExB;;;;;OAKG;IACH,MAFU,MAAM,CAEK;IAErB;;;;;;;;;;OAUG;IACH,6BAAmC;IAEnC;;;;OAIG;IACH,cAHU,OAAO,CAGQ;IAEzB;;;;OAIG;IACH,kBAHU,OAAO,CAGY;IAE7B;;;;OAIG;IACH,cAHU,OAAO,CAGQ;IAEzB;;;;;OAKG;IACH,UAHU,OAAO,CAGI;IAErB;;;;;;;OAOG;IACH,qBAHU,OAAO,CAGe;IAEhC;;;;;;;;;;;;;;;;OAgBG;IACH,eAdU,OAAO,CAcQ;IAEzB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sBAJU,OAAO,CAIe;IAEhC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OANU,MAAM,CAMA;IAEhB;;;;OAIG;IACH,UAHU,SAAS,GAAC,MAAM,CAGD;IAEzB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAlBU,IAAI,GAAC,SAAS,GAAC,OAAO,GAAC,IAAI,GAA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GACL,MAAM,CAwClB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,uBAHa,QAAQ,CAapB;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,iCALW,QAAQ,GAEN,QAAQ,CAoCpB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiDG;IACH,uBAfW,QAAQ,GAEN,QAAQ,CAsCpB;IAED;;;;;;OAMG;IACH,kBAFW,QAAQ,QA+FlB;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IAEH,eATW,QAAQ,aACR,QAAQ,GAAC,SAAS,QAU5B;IAED;;;;;OAKG;IACH,mBAFW,QAAQ,QAqBlB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IAEH,sBAfW,OAAO,wBAAwB,EAAE,OAAO,SACxC,UAAU,GACR,OAAO,CAqBnB;IAkCD;;;;OAIG;IACH,8BA0EC;IAED;;;;;;;OAOG;IACH,yBAFc,GAAC,EAAA,QAId;IAED;;;;;;;;OAQG;IACH,0BAHc,GAAC,EAAA,QAKd;IAED;;;;;;;OAOG;IACH,4BAHc,GAAC,EAAA,QAKd;CACD;qBAx/CoB,8BAA8B;gCADnB,kCAAkC;yBAKzC,qBAAqB;iCAwBhB,uBAAuB;2BAd3B,gBAAgB;wBADnB,oBAAoB;+BAKf,8BAA8B;6BADhC,0BAA0B;0BAF7B,yBAAyB;6BACtB,4BAA4B;0BAU7B,4BAA4B;8BAGxB,kCAAkC;8BAEpC,qBAAqB;2BANxB,kBAAkB;6BANd,iCAAiC;8BAQlC,qBAAqB;8BAGrB,qBAAqB;4BAPvB,sBAAsB;0BAStB,sBAAsB;0BARtB,uBAAuB"}
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * additional import for TypeScript
3
- * @import {Vector2d} from "../math/vector2d.js";
3
+ * @import {Vector2d} from "../math/vector2d.ts";
4
4
  * @import Renderer from "./../video/renderer.js";
5
+ * @import {CompressedImage} from "../loader/parsers/compressed_textures/compressed_image.js";
5
6
  */
6
7
  /**
7
8
  * An object to display a fixed or animated sprite on screen.
@@ -22,6 +23,8 @@ export default class Sprite extends Renderable {
22
23
  * @param {number} [settings.flipY] - flip the sprite on the vertical axis
23
24
  * @param {string|Vector2d|{x:number,y:number}} [settings.anchorPoint={x:0.5, y:0.5}] - Anchor point to draw the frame at (defaults to the center of the frame). Also accepts the named presets `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"`. For spritesheet atlases the anchor also becomes the cached atlas's per-frame pivot (see {@link TextureAtlas}).
24
25
  * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|Texture2d|string} [settings.normalMap] - optional normal-map texture used for per-pixel lighting (SpriteIlluminator-style). Same layout/UVs as `settings.image`. When omitted (default), the sprite renders unlit and pays no extra cost. Ignored by the Canvas renderer. Note: `HTMLVideoElement` is intentionally not supported — normal maps encode static surface directions in RGB, and the engine caches the GL texture per image reference (a video would freeze on frame 0).
26
+ * @param {object} [settings.bodyDef] - declarative, adapter-portable body definition, applied when this sprite is added to a container. Its `shapes` may name a collision shape file preloaded as JSON, paired with `id`. See {@link Renderable#bodyDef} and {@link BodyDefinitionInit}
27
+ * @param {number} [settings.shininess=0] - specular exponent: how tight this sprite's highlight is, or 0 for none. Needs a `normalMap` — see {@link Sprite#shininess}
25
28
  * @example
26
29
  * // create a single sprite from a standalone image, with anchor in the center
27
30
  * let sprite = new me.Sprite(0, 0, {
@@ -65,6 +68,8 @@ export default class Sprite extends Renderable {
65
68
  y: number;
66
69
  } | undefined;
67
70
  normalMap?: string | ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | Texture2d | undefined;
71
+ bodyDef?: object | undefined;
72
+ shininess?: number | undefined;
68
73
  });
69
74
  /**
70
75
  * global offset for the position to draw from on the source image.
@@ -88,10 +93,59 @@ export default class Sprite extends Renderable {
88
93
  * @type {TextureAtlas}
89
94
  */
90
95
  source: TextureAtlas;
91
- image: any;
96
+ /**
97
+ * How tight this sprite's specular highlight is, or `0` (the default)
98
+ * for none.
99
+ *
100
+ * A normal map tells the light which way each texel FACES, which gives
101
+ * a sprite shape; this decides whether it also SHINES. The highlight
102
+ * only appears where a texel happens to reflect a light toward the
103
+ * screen, so it slides across the surface as the light moves, rather
104
+ * than the whole sprite merely brightening — the difference between
105
+ * armour that glints as you walk past and armour that is just lit.
106
+ *
107
+ * Low values give a broad sheen (worn metal, wet stone), high values a
108
+ * tight glint (polished steel, glass). Gated on the exponent exactly
109
+ * as MTL `Ns` and {@link Mesh#shininess} are, so `0` means "matte"
110
+ * however bright the scene is, and every existing sprite is unchanged.
111
+ *
112
+ * **Needs a `normalMap`**: with no surface directions there is nothing
113
+ * to reflect, and the sprite stays matte whatever this is set to. The
114
+ * normal map's ALPHA channel masks it per texel, so one sprite can
115
+ * have a shiny blade and a matte leather grip; a normal map with no
116
+ * alpha detail (the usual case) shines uniformly.
117
+ *
118
+ * Ignored by the Canvas renderer.
119
+ * @type {number}
120
+ * @default 0
121
+ * @see [Normal Map example](https://melonjs.github.io/melonJS/examples/#/normal-map) — three orbs across the
122
+ * exponent's range, on a normal-mapped wall, lit by two moving lights
123
+ * @example
124
+ * // a polished blade: the highlight slides across it as a torch
125
+ * // moves past, instead of the sprite merely brightening
126
+ * const sword = new Sprite(x, y, {
127
+ * image: "sword",
128
+ * normalMap: "sword_n",
129
+ * shininess: 64, // a tight, metallic glint
130
+ * });
131
+ * @example
132
+ * // masked per texel: the normal map's ALPHA channel decides where
133
+ * // the sprite is glossy, so one sprite can be a shiny blade with a
134
+ * // matte leather grip. 255 = fully reflective, 0 = dead matte.
135
+ * const nm = document.createElement("canvas");
136
+ * // ...draw the normals into RGB, the gloss mask into A...
137
+ * const axe = new Sprite(x, y, {
138
+ * image: "axe",
139
+ * normalMap: nm,
140
+ * shininess: 96,
141
+ * });
142
+ * @example
143
+ * // matte again at runtime
144
+ * axe.shininess = 0;
145
+ */
146
+ shininess: number;
147
+ image: HTMLVideoElement | import("./../video/texture/texture2d.ts").Texture2dSource | CompressedImage;
92
148
  textureAtlas: any;
93
- width: any;
94
- height: any;
95
149
  set animationpause(value: boolean);
96
150
  /**
97
151
  * pause the frame animation, freezing the current frame.
@@ -110,6 +164,23 @@ export default class Sprite extends Renderable {
110
164
  *
111
165
  * Silently ignored by the Canvas renderer.
112
166
  * @type {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|null}
167
+ * @see {@link Sprite#shininess} to add a specular highlight on top
168
+ * @see [Normal Map example](https://melonjs.github.io/melonJS/examples/#/normal-map)
169
+ * @see [SpriteIlluminator example](https://melonjs.github.io/melonJS/examples/#/sprite-illuminator)
170
+ * @example
171
+ * // the sidecar pattern: one `_n` image beside each diffuse image
172
+ * await loader.preload([
173
+ * { name: "hero", type: "image", src: "data/img/hero.png" },
174
+ * { name: "hero_n", type: "image", src: "data/img/hero_n.png" },
175
+ * ]);
176
+ * const hero = new Sprite(x, y, { image: "hero", normalMap: "hero_n" });
177
+ *
178
+ * // ...or assigned later, from any image-like source
179
+ * hero.normalMap = loader.getImage("hero_n");
180
+ *
181
+ * // an atlas can carry one for every region it packs, which a Sprite
182
+ * // built from that atlas picks up in preference to its own setting
183
+ * const atlas = new TextureAtlas(json, image, { normalMap });
113
184
  */
114
185
  get normalMap(): HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | null;
115
186
  atlasIndices: any;
@@ -302,19 +373,6 @@ export default class Sprite extends Renderable {
302
373
  * @returns {number} current animation frame index
303
374
  */
304
375
  getCurrentAnimationFrame(): number;
305
- /**
306
- * Prepare the rendering context before drawing this sprite (automatically called by melonJS).
307
- * Extends `Renderable.preDraw` to publish this sprite's `normalMap` (if any)
308
- * on the renderer so the WebGL lit pipeline can pair it with the next
309
- * `drawImage` call. Cleared back in `postDraw`.
310
- * @param {Renderer} renderer - a renderer instance
311
- */
312
- preDraw(renderer: Renderer): void;
313
- /**
314
- * restore the rendering context after drawing this sprite (automatically called by melonJS).
315
- * @param {Renderer} renderer - a renderer instance
316
- */
317
- postDraw(renderer: Renderer): void;
318
376
  /**
319
377
  * draw this sprite (automatically called by melonJS)
320
378
  * @param {Renderer} renderer - a renderer instance
@@ -322,9 +380,9 @@ export default class Sprite extends Renderable {
322
380
  draw(renderer: Renderer): void;
323
381
  }
324
382
  import Renderable from "./renderable.js";
325
- import FrameAnimation from "./frameAnimation.js";
326
- import type { Vector2d } from "../math/vector2d.js";
383
+ import type { Vector2d } from "../math/vector2d.ts";
327
384
  import { TextureAtlas } from "./../video/texture/atlas.js";
385
+ import type { CompressedImage } from "../loader/parsers/compressed_textures/compressed_image.js";
328
386
  import type Renderer from "./../video/renderer.js";
329
387
  import Texture2d from "./../video/texture/texture2d.ts";
330
388
  import { Color } from "../math/color.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"sprite.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite.js"],"names":[],"mappings":"AAcA;;;;GAIG;AAEH;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,eA1CW,MAAM,KACN,MAAM,YAEd;QAAoH,KAAK,EAAjH,gBAAgB,GAAC,iBAAiB,GAAC,gBAAgB,GAAC,SAAS,GAAC,YAAY,GAAC,eAAe,GAAC,MAAM;QAC/E,IAAI;QACJ,MAAM;QACN,UAAU;QACV,WAAW;QACL,IAAI;QACV,KAAK;QACL,KAAK;QACwB,WAAW;eAAvC,MAAM;eAAG,MAAM;;QACyD,SAAS;KAC5G,EA0UF;IA1RA;;;OAGG;IACH,2BAEE;IAEF;;;;OAIG;IACH,QAHU,QAAQ,CAGkB;IAEpC;;;;OAIG;IACH,SAHU,OAAO,CAGG;IAEpB;;;;OAIG;IAGH;;;OAGG;IACH,QAFU,YAAY,CAEJ;IAElB;;;;;OAKG;IACH,wFAAsB;IAEtB;;;;OAIG;IACH;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;;;;;;;;;;;;;;;;OAoCG;IACH,0BAlCW,MAAM,cACN,MAAM,cAAU,MAAM,gBACtB,OAAO,GACL,MAAM,CAkClB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,GACJ,MAAM,CASlB;IAED;;;;;;;;OAQG;IACH,yBAPW,MAAM,GACJ,OAAO,CAQnB;IAED;;;;;;;;OAQG;IACH,qBANa,MAAM,EAAE,CAQpB;IAED;;;;;;;;OAQG;IACH,kBANW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;OAOG;IACH,oBAJW,MAAM,QA2ChB;IAED;;;;;;;OAOG;IACH,0BANW,MAAM,GACJ,MAAM,CAQlB;IAED;;;OAGG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;IAwFD;;;OAGG;IACH,eAFW,QAAQ,QAsDlB;IAED;;;;OAIG;IACH,gBAyBC;CACD;uBAngCsB,iBAAiB;2BADb,qBAAqB;8BAQrB,qBAAqB;6BAXnB,6BAA6B;qCAaxB,2DAA2D;0BADpE,wBAAwB;sBAX3B,iCAAiC;sBAJjC,kBAAkB"}
@@ -96,9 +96,17 @@ export default class Sprite3d extends Mesh {
96
96
  * @param {number[]|Float32Array} [settings.emissive] - emissive color (see {@link Mesh})
97
97
  * @param {number} [settings.shadowGroundY] - world Y of the floor the blob shadow lands on. Omit and it falls back to the sprite's own base — which for a billboard moves with the camera, so a scene that knows where its floor is should say so.
98
98
  * @param {number} [settings.shadowOpacity=0.45] - opacity of the shadow directly beneath the sprite, before any height fade
99
+ * @param {number} [settings.shadowScale=1] - multiplier for the ground shadow's footprint; non-positive or non-finite values hide the shadow
100
+ * @param {number} [settings.shadowOffset=0] - how far to slide the shadow along its direction, in multiples of the blob's own radius; needs `shadowGroundY` (see {@link Mesh#shadowOffset})
101
+ * @param {number} [settings.shadowStretch=1] - how much longer the blob is along its direction, clamped to 3
102
+ * @param {number} [settings.shadowDirectionX=0] - x of the ground direction the shadow is cast along
103
+ * @param {number} [settings.shadowDirectionZ=0] - z of the ground direction the shadow is cast along
104
+ * @param {number[]|Vector3d} [settings.shadowGroundNormal] - the UP normal of the floor the shadow lands on; needs `shadowGroundY` (see {@link Mesh#shadowGroundNormal})
105
+ * @param {Light3d} [settings.shadowLight] - a {@link Light3d} to take that direction from instead
99
106
  * @param {boolean} [settings.castGroundShadow] - give this sprite a blob ground shadow, overriding the application's `castGroundShadow` setting in both directions. Omit to inherit. Needs a GPU backend and a {@link Camera3d}.
100
107
  * @param {boolean} [settings.fog] - set `false` to exempt this sprite from the camera's distance fog ({@link Camera3d#setFog}); omit to fog whenever the camera does. A sun or a moon wants this — everything else at that distance dissolves into the haze, and so would it.
101
108
  * @param {boolean} [settings.transparent] - draw in the transparent pass (blended, back-to-front, no depth write) instead of the opaque one. Omit and the sprite goes transparent whenever its draw alpha is fractional; `true` for a soft-alpha sprite such as an additive glow; `false` to stay opaque however faded.
109
+ * @param {boolean} [settings.depthTest=true] - whether geometry in front of this sprite hides it. `false` draws it over whatever is already there, for a glow or an overlay with no surface to be occluded ON — a flat billboard left depth tested is cut along a hard straight line wherever nearer geometry crosses it. Separate from the depth WRITE the transparent pass turns off on its own. See {@link Mesh#depthTest}.
102
110
  * @param {number} [settings.alphaCutoff=0.5] - alpha cutout threshold (see {@link Mesh}). The mesh pass is opaque (no alpha blending), so this defaults to `0.5` to discard a sprite's transparent background (clean cutout silhouette, correct depth, no sorting). Set `0` for a fully-opaque quad, or tune the threshold.
103
111
  */
104
112
  constructor(x: number, y: number, settings: {
@@ -114,16 +122,24 @@ export default class Sprite3d extends Mesh {
114
122
  anchorPoint?: string | Vector2d | {
115
123
  x: number;
116
124
  y: number;
117
- };
125
+ } | undefined;
118
126
  flipX?: boolean | undefined;
119
127
  flipY?: boolean | undefined;
120
128
  lit?: boolean | undefined;
121
129
  emissive?: number[] | Float32Array<ArrayBufferLike> | undefined;
122
130
  shadowGroundY?: number | undefined;
123
131
  shadowOpacity?: number | undefined;
132
+ shadowScale?: number | undefined;
133
+ shadowOffset?: number | undefined;
134
+ shadowStretch?: number | undefined;
135
+ shadowDirectionX?: number | undefined;
136
+ shadowDirectionZ?: number | undefined;
137
+ shadowGroundNormal?: number[] | Vector3d | undefined;
138
+ shadowLight?: any;
124
139
  castGroundShadow?: boolean | undefined;
125
140
  fog?: boolean | undefined;
126
141
  transparent?: boolean | undefined;
142
+ depthTest?: boolean | undefined;
127
143
  alphaCutoff?: number | undefined;
128
144
  });
129
145
  /**
@@ -142,11 +158,14 @@ export default class Sprite3d extends Mesh {
142
158
  *
143
159
  * **Only applies under a `Camera3d`**; ignored on the 2D path.
144
160
  *
145
- * Note: while billboarding, orientation comes from the camera, so the
146
- * renderable's `currentTransform` (`rotate()` / `scale()` / parent-container
147
- * transforms) and `meshScale` are **not** applied — only `pos` / `depth`,
148
- * `flipX` / `flipY`, and the quad's authored size. With billboarding `false`
149
- * the standard {@link Mesh} world transform applies as usual.
161
+ * Note: while billboarding, **orientation** comes from the camera, so an
162
+ * in-plane `rotate()` has no effect (a card that faces the camera has no
163
+ * free rotation left to give) — use `billboard: false` and orient the quad
164
+ * yourself for a streak or an exhaust. Everything that is not an
165
+ * orientation still applies: `pos` / `depth`, `flipX` / `flipY`, the quad's
166
+ * authored size, and `scale()` / {@link Mesh#meshScale}, which size the
167
+ * card in its own plane. With billboarding `false` the standard
168
+ * {@link Mesh} world transform applies as usual.
150
169
  * @type {boolean|string}
151
170
  * @default false
152
171
  */
@@ -218,14 +237,6 @@ export default class Sprite3d extends Mesh {
218
237
  * @returns {Sprite3d} Reference to this object for method chaining
219
238
  */
220
239
  flipY(flip?: boolean): Sprite3d;
221
- /**
222
- * @returns {boolean} true if the sprite is mirrored horizontally.
223
- */
224
- isFlippedX(): boolean;
225
- /**
226
- * @returns {boolean} true if the sprite is mirrored vertically.
227
- */
228
- isFlippedY(): boolean;
229
240
  /**
230
241
  * Play (and optionally switch to) an animation, identical to {@link Sprite#play}.
231
242
  * @param {string} [name] - animation id to play; omit to resume
@@ -270,7 +281,7 @@ export default class Sprite3d extends Mesh {
270
281
  getCurrentAnimationFrame(): number;
271
282
  }
272
283
  import Mesh from "./mesh.js";
273
- import FrameAnimation from "./frameAnimation.js";
274
- import Camera3d from "../camera/camera3d.ts";
275
284
  import Texture2d from "../video/texture/texture2d.ts";
285
+ import type { Vector2d } from "../math/vector2d.ts";
286
+ import { Vector3d } from "../math/vector3d.ts";
276
287
  //# sourceMappingURL=sprite3d.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sprite3d.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite3d.js"],"names":[],"mappings":"AAoEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAxBW,MAAM,KACN,MAAM,YAEd;QAAuE,KAAK;QAClD,KAAK;QACL,MAAM;QACN,UAAU;QACV,WAAW;QACX,MAAM;QACJ,KAAK;QACP,CAAC;QACO,SAAS;QACY,WAAW,GAA1D,MAAM,GAAC,QAAQ,GAAC;YAAC,CAAC,EAAC,MAAM,CAAC;YAAA,CAAC,EAAC,MAAM,CAAA;SAAC;QAChB,KAAK;QACL,KAAK;QACL,GAAG;QACW,QAAQ;QACvB,aAAa;QACb,aAAa;QACZ,gBAAgB;QAChB,GAAG;QACH,WAAW;QACZ,WAAW;KACvC,EA4SA;IAvLA;;;;;OAKG;IACH,QAJU,MAAM,CAIA;IAChB;;;OAGG;IACH,eAAgB;IAIhB;;;OAGG;IACH,uBAAmC;IACnC;;;OAGG;IACH,uBAAmC;IAoBnC;;;OAGG;IACH,eAAe;IACf;;;OAGG;IACH,eAAe;IAKf;;;OAGG;IACH,gBAAmB;IACnB;;;OAGG;IACH,gBAAmB;IAEnB;;;OAGG;IACH,uBAAmB;IAKnB;;;OAGG;IACH,kBAAwB;IACxB;;;;OAIG;I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,CAInB;IAED;;OAEG;IACH,qBAFa,MAAM,EAAE,CAIpB;IAED;;OAEG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,mCALW,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;;;;;;;OAYG;IACH,oBAJW,MAAM,QAgHhB;IA6BD;;;;;;;;;;OAUG;IACH,eALW,cAAc,GAAC,aAAa,aAC5B,QAAQ,QAOlB;IAED;;;;;OAKG;IACH,sEAMC;IAED;;;;;;;;;OASG;IACH,mBAJa,OAAO,CA6CnB;IA4CD;;;;;;OAMG;IACH,yEAiBC;CACD;iBAvgCgB,WAAW;2BADD,qBAAqB;qBAN3B,uBAAuB;sBAItB,+BAA+B"}
1
+ {"version":3,"file":"sprite3d.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite3d.js"],"names":[],"mappings":"AAwEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,eAhCW,MAAM,KACN,MAAM,YAEd;QAAuE,KAAK;QAClD,KAAK;QACL,MAAM;QACN,UAAU;QACV,WAAW;QACX,MAAM;QACJ,KAAK;QACP,CAAC;QACO,SAAS;QACY,WAAW;eAAvC,MAAM;eAAG,MAAM;;QACf,KAAK;QACL,KAAK;QACL,GAAG;QACW,QAAQ;QACvB,aAAa;QACb,aAAa;QACb,WAAW;QACX,YAAY;QACZ,aAAa;QACb,gBAAgB;QAChB,gBAAgB;QACL,kBAAkB;QAC5B,WAAW;QACX,gBAAgB;QAChB,GAAG;QACH,WAAW;QACX,SAAS;QACV,WAAW;KACvC,EAsUA;IAvMA;;;;;OAKG;IACH,QAJU,MAAM,CAIA;IAChB;;;OAGG;IACH,eAAgB;IAIhB;;;OAGG;IACH,uBAAmC;IACnC;;;OAGG;IACH,uBAAmC;IAInC;;;OAGG;IACH,gBAAgB;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IA+BD;;;;;OAKG;IACH,YAJW,MAAM,YACN,MAAM,cAAU,MAAM,GACpB,QAAQ,CAQpB;IAED;;;OAGG;IACH,SAFa,QAAQ,CAKpB;IAED;;;OAGG;IACH,QAFa,QAAQ,CAMpB;IAED;;;;OAIG;IACH,0BAHW,MAAM,GACJ,QAAQ,CAKpB;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,QAAQ,CAKpB;IAED;;;OAGG;IACH,yBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;OAEG;IACH,qBAFa,MAAM,EAAE,CAIpB;IAED;;OAEG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,mCALW,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;;;;;;;OAYG;IACH,oBAJW,MAAM,QAgHhB;IA6BD;;;;;;;;;;OAUG;IACH,eALW,QAAQ,aACR,QAAQ,QAOlB;IAED;;;;;OAKG;IACH,sEAMC;IAED;;;;;;;;;;OAUG;IACH,mBAJa,OAAO,CA+CnB;IAkDD;;;;;;OAMG;IACH,yEAmBC;CACD;iBA1pCgB,WAAW;2BADD,qBAAqB;qBAN3B,uBAAuB;sBAItB,+BAA+B;8BAO1B,qBAAqB;yBARvB,qBAAqB"}
@@ -1,3 +1,11 @@
1
+ /**
2
+ * additional import for TypeScript
3
+ * @import CanvasRenderer from "../../video/canvas/canvas_renderer.js";
4
+ * @import {Vector2d} from "../../math/vector2d.ts";
5
+ * @import WebGLRenderer from "../../video/webgl/webgl_renderer.js";
6
+ * @import {Bounds} from "../../physics/bounds.ts";
7
+ * @import Renderer from "../../video/renderer.js";
8
+ */
1
9
  /**
2
10
  * a bitmap font object.
3
11
  *
@@ -51,7 +59,7 @@ export default class BitmapText extends Renderable {
51
59
  anchorPoint?: string | Vector2d | {
52
60
  x: number;
53
61
  y: number;
54
- };
62
+ } | undefined;
55
63
  wordWrapWidth?: number | undefined;
56
64
  text?: string | string[] | undefined;
57
65
  });
@@ -189,11 +197,13 @@ export default class BitmapText extends Renderable {
189
197
  measureText(text?: string): TextMetrics;
190
198
  /**
191
199
  * draw the bitmap font
192
- * @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance
200
+ * @param {Renderer} renderer - Reference to the destination renderer instance
193
201
  */
194
- draw(renderer: CanvasRenderer | WebGLRenderer): void;
202
+ draw(renderer: Renderer): void;
195
203
  }
196
204
  import Renderable from "../renderable.js";
197
205
  import { Color } from "../../math/color.ts";
198
206
  import TextMetrics from "./textmetrics.js";
207
+ import type Renderer from "../../video/renderer.js";
208
+ import type { Vector2d } from "../../math/vector2d.ts";
199
209
  //# sourceMappingURL=bitmaptext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bitmaptext.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptext.js"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,eA9BW,MAAM,KACN,MAAM,YAEd;QAA+B,IAAI,EAA3B,MAAM,8DAAM;QACM,QAAQ;QACR,IAAI;QACE,SAAS;QACf,SAAS;QACT,YAAY;QACZ,UAAU;QACmB,WAAW,GAA1D,MAAM,GAAC,QAAQ,GAAC;YAAC,CAAC,EAAC,MAAM,CAAC;YAAA,CAAC,EAAC,MAAM,CAAA;SAAC;QACjB,aAAa;QACF,IAAI;KACzC,EAqIF;IAhHA;;;;;;OAMG;IACH,kBAHU,MAAM,CAG6B;IAE7C;;;;;;OAMG;IACH,qBAHU,MAAM,CAGkC;IAElD;;;;;;OAMG;IACH,mBAHU,MAAM,CAG4B;IAE5C;;;;;;OAMG;IACH,sBAHU,MAAM,CAGiC;IAEjD;;;;;OAKG;IACH,cAAe;IAEf;;;OAGG;IACH,kBAA2C;IAE3C;;;OAGG;IACH,kBAG2B;IAG1B;;;OAGG;IAEH,iBAAgE;IAmOlE,4BAlBU,KAAK,EAyBd;IAjCD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,wBAfU,KAAK,CAiBd;IAnMA;;;OAGG;IACH,2BAA4B;IAG5B,qBAAoC;IAWrC;;;;;OAKG;IACH,eAJW,MAAM,UACN,MAAM,GACJ,UAAU,CAWtB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,MAAM,GAAC,MAAM,EAAE,GACpB,UAAU,CAwBtB;IAoBD,oCAdU,MAAM,EAmBf;IAvBD;;;;;;;;;;;;;OAaG;IACH,gCAVU,MAAM,CAYf;IAyBD,+BAZU,MAAM,EAsBf;IA1BD;;;;;OAKG;IACH,2BAFU,MAAM,CAUf;IAsGD;;;;;;;;;;OAUG;IACH,cATW,MAAM,GAEJ,UAAU,CAiBtB;IAED;;;;;;;;OAQG;IACH,mBAPW,MAAM,GACJ,WAAW,CAQvB;IAED;;;OAGG;IACH,eAFW,cAAc,GAAC,aAAa,QAmGtC;IAED;;;;OAIG;IACH,gBAQC;CACD;uBAxfsB,kBAAkB;sBAHnB,qBAAqB;wBAKnB,kBAAkB"}
1
+ {"version":3,"file":"bitmaptext.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptext.js"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH;;;;;;;;;GASG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,eA9BW,MAAM,KACN,MAAM,YAEd;QAA+B,IAAI,EAA3B,MAAM,8DAAM;QACM,QAAQ;QACR,IAAI;QACE,SAAS;QACf,SAAS;QACT,YAAY;QACZ,UAAU;QACmB,WAAW;eAAvC,MAAM;eAAG,MAAM;;QAChB,aAAa;QACF,IAAI;KACzC,EAqIF;IAhHA;;;;;;OAMG;IACH,kBAHU,MAAM,CAG6B;IAE7C;;;;;;OAMG;IACH,qBAHU,MAAM,CAGkC;IAElD;;;;;;OAMG;IACH,mBAHU,MAAM,CAG4B;IAE5C;;;;;;OAMG;IACH,sBAHU,MAAM,CAGiC;IAEjD;;;;;OAKG;IACH,cAAe;IAEf;;;OAGG;IACH,kBAA2C;IAE3C;;;OAGG;IACH,kBAG2B;IAG1B;;;OAGG;IAEH,iBAAgE;IAmOlE,4BAlBU,KAAK,EAyBd;IAjCD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,wBAfU,KAAK,CAiBd;IAnMA;;;OAGG;IACH,2BAA4B;IAG5B,qBAAoC;IAWrC;;;;;OAKG;IACH,eAJW,MAAM,UACN,MAAM,GACJ,UAAU,CAWtB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,MAAM,GAAC,MAAM,EAAE,GACpB,UAAU,CAwBtB;IAoBD,oCAdU,MAAM,EAmBf;IAvBD;;;;;;;;;;;;;OAaG;IACH,gCAVU,MAAM,CAYf;IAyBD,+BAZU,MAAM,EAsBf;IA1BD;;;;;OAKG;IACH,2BAFU,MAAM,CAUf;IAsGD;;;;;;;;;;OAUG;IACH,cATW,MAAM,GAEJ,UAAU,CAiBtB;IAED;;;;;;;;OAQG;IACH,mBAPW,MAAM,GACJ,WAAW,CAQvB;IAED;;;OAGG;IACH,eAFW,QAAQ,QAmGlB;IAED;;;;OAIG;IACH,gBAQC;CACD;uBAhgBsB,kBAAkB;sBAHnB,qBAAqB;wBAKnB,kBAAkB;0BAQjB,yBAAyB;8BAHvB,wBAAwB"}
@@ -1,4 +1,3 @@
1
- import Glyph from "./glyph.ts";
2
1
  /**
3
2
  * a bitmap font data object — parses the AngelCode BMFont format in both its
4
3
  * text (`.fnt`) and XML serialisations (the flavour is auto-detected).
@@ -14,9 +13,6 @@ export default class BitmapTextData {
14
13
  descent: number;
15
14
  glyphMinTop: number;
16
15
  glyphMaxBottom: number;
17
- glyphs: {
18
- [key: number]: Glyph;
19
- };
20
16
  constructor(data: string);
21
17
  parse(fontData: string): void;
22
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bitmaptextdata.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptextdata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,YAAY,CAAC;AAiF/B;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc;IAClC,MAAM,EAAE,MAAM,CAAK;IACnB,QAAQ,EAAE,MAAM,CAAK;IACrB,SAAS,EAAE,MAAM,CAAK;IACtB,OAAO,EAAE,MAAM,CAAK;IACpB,UAAU,EAAE,MAAM,CAAK;IACvB,SAAS,EAAE,MAAM,CAAK;IACtB,OAAO,EAAE,MAAM,CAAK;IACpB,WAAW,EAAE,MAAM,CAAK;IACxB,cAAc,EAAE,MAAM,CAAK;IAC3B,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE,CAAM;gBAE1B,IAAI,EAAE,MAAM;IAIxB,KAAK,CAAC,QAAQ,EAAE,MAAM;CAkMtB;AAED,eAAO,MAAM,kBAAkB,yEAY7B,CAAC"}
1
+ {"version":3,"file":"bitmaptextdata.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptextdata.ts"],"names":[],"mappings":"AAkFA;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc;IAClC,MAAM,EAAE,MAAM,CAAK;IACnB,QAAQ,EAAE,MAAM,CAAK;IACrB,SAAS,EAAE,MAAM,CAAK;IACtB,OAAO,EAAE,MAAM,CAAK;IACpB,UAAU,EAAE,MAAM,CAAK;IACvB,SAAS,EAAE,MAAM,CAAK;IACtB,OAAO,EAAE,MAAM,CAAK;IACpB,WAAW,EAAE,MAAM,CAAK;IACxB,cAAc,EAAE,MAAM,CAAK;gBAYf,IAAI,EAAE,MAAM;IAIxB,KAAK,CAAC,QAAQ,EAAE,MAAM;CAkMtB;AAED,eAAO,MAAM,kBAAkB,yEAY7B,CAAC"}
@@ -89,7 +89,7 @@ export default class Text extends Renderable {
89
89
  anchorPoint?: string | Vector2d | {
90
90
  x: number;
91
91
  y: number;
92
- };
92
+ } | undefined;
93
93
  wordWrapWidth?: number | undefined;
94
94
  bold?: boolean | undefined;
95
95
  italic?: boolean | undefined;
@@ -257,13 +257,15 @@ export default class Text extends Renderable {
257
257
  measureText(text?: string): TextMetrics;
258
258
  /**
259
259
  * draw a text at the specified coord
260
- * @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance
260
+ * @param {Renderer} renderer - Reference to the destination renderer instance
261
261
  */
262
- draw(renderer: CanvasRenderer | WebGLRenderer): void;
262
+ draw(renderer: Renderer): void;
263
263
  }
264
264
  import Renderable from "../renderable.js";
265
265
  import { Color } from "../../math/color.ts";
266
266
  import { Gradient } from "../../video/gradient.js";
267
267
  import CanvasRenderTarget from "../../video/rendertarget/canvasrendertarget.js";
268
268
  import TextMetrics from "./textmetrics.js";
269
+ import type Renderer from "../../video/renderer.js";
270
+ import type { Vector2d } from "../../math/vector2d.ts";
269
271
  //# sourceMappingURL=text.d.ts.map