melonjs 19.8.0 → 19.9.1

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 (111) hide show
  1. package/README.md +3 -0
  2. package/build/application/application.d.ts.map +1 -1
  3. package/build/application/resize.d.ts.map +1 -1
  4. package/build/audio/audio.d.ts +1 -1
  5. package/build/audio/audio.d.ts.map +1 -1
  6. package/build/audio/backend.d.ts +21 -2
  7. package/build/audio/backend.d.ts.map +1 -1
  8. package/build/audio/playback.d.ts +8 -28
  9. package/build/audio/playback.d.ts.map +1 -1
  10. package/build/camera/camera2d.d.ts.map +1 -1
  11. package/build/geometries/path2d.d.ts +188 -75
  12. package/build/geometries/path2d.d.ts.map +1 -1
  13. package/build/geometries/rectangle.d.ts.map +1 -1
  14. package/build/index.d.ts +5 -1
  15. package/build/index.d.ts.map +1 -1
  16. package/build/index.js +3367 -634
  17. package/build/index.js.map +4 -4
  18. package/build/loader/cache.d.ts +1 -0
  19. package/build/loader/cache.d.ts.map +1 -1
  20. package/build/loader/loader.d.ts +61 -3
  21. package/build/loader/loader.d.ts.map +1 -1
  22. package/build/loader/parsers/fetchdata.d.ts +14 -0
  23. package/build/loader/parsers/fetchdata.d.ts.map +1 -1
  24. package/build/loader/parsers/shader.d.ts +47 -0
  25. package/build/loader/parsers/shader.d.ts.map +1 -0
  26. package/build/loader/parsers/video.d.ts.map +1 -1
  27. package/build/math/color.d.ts.map +1 -1
  28. package/build/math/matrix2d.d.ts.map +1 -1
  29. package/build/math/noise.d.ts +141 -0
  30. package/build/math/noise.d.ts.map +1 -0
  31. package/build/math/observableVector2d.d.ts +1 -1
  32. package/build/math/observableVector2d.d.ts.map +1 -1
  33. package/build/math/observableVector3d.d.ts +1 -1
  34. package/build/math/observableVector3d.d.ts.map +1 -1
  35. package/build/math/vector2d.d.ts +1 -1
  36. package/build/math/vector2d.d.ts.map +1 -1
  37. package/build/math/vector3d.d.ts +1 -1
  38. package/build/math/vector3d.d.ts.map +1 -1
  39. package/build/particles/particle.d.ts.map +1 -1
  40. package/build/particles/settings.d.ts +3 -1
  41. package/build/particles/settings.d.ts.map +1 -1
  42. package/build/physics/adapter.d.ts +4 -3
  43. package/build/physics/adapter.d.ts.map +1 -1
  44. package/build/renderable/anchorPoint.d.ts +80 -0
  45. package/build/renderable/anchorPoint.d.ts.map +1 -0
  46. package/build/renderable/collectable.d.ts +7 -1
  47. package/build/renderable/collectable.d.ts.map +1 -1
  48. package/build/renderable/container.d.ts.map +1 -1
  49. package/build/renderable/entity/entity.d.ts +5 -2
  50. package/build/renderable/entity/entity.d.ts.map +1 -1
  51. package/build/renderable/frameAnimation.d.ts.map +1 -1
  52. package/build/renderable/imagelayer.d.ts +5 -2
  53. package/build/renderable/imagelayer.d.ts.map +1 -1
  54. package/build/renderable/mesh.d.ts +26 -2
  55. package/build/renderable/mesh.d.ts.map +1 -1
  56. package/build/renderable/nineslicesprite.d.ts +5 -7
  57. package/build/renderable/nineslicesprite.d.ts.map +1 -1
  58. package/build/renderable/renderable.d.ts +6 -1
  59. package/build/renderable/renderable.d.ts.map +1 -1
  60. package/build/renderable/sprite.d.ts +13 -7
  61. package/build/renderable/sprite.d.ts.map +1 -1
  62. package/build/renderable/sprite3d.d.ts +41 -5
  63. package/build/renderable/sprite3d.d.ts.map +1 -1
  64. package/build/renderable/text/bitmaptext.d.ts +24 -12
  65. package/build/renderable/text/bitmaptext.d.ts.map +1 -1
  66. package/build/renderable/text/bitmaptextdata.d.ts +24 -1
  67. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
  68. package/build/renderable/text/text.d.ts +50 -12
  69. package/build/renderable/text/text.d.ts.map +1 -1
  70. package/build/state/stage.d.ts.map +1 -1
  71. package/build/system/event.d.ts +18 -2
  72. package/build/system/event.d.ts.map +1 -1
  73. package/build/video/canvas/canvas_renderer.d.ts +4 -0
  74. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  75. package/build/video/renderer.d.ts +41 -1
  76. package/build/video/renderer.d.ts.map +1 -1
  77. package/build/video/rendertarget/render_target_pool.d.ts +17 -6
  78. package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
  79. package/build/video/texture/atlas.d.ts +2 -1
  80. package/build/video/texture/atlas.d.ts.map +1 -1
  81. package/build/video/texture/cache.d.ts +55 -6
  82. package/build/video/texture/cache.d.ts.map +1 -1
  83. package/build/video/texture/frametexture.d.ts +73 -0
  84. package/build/video/texture/frametexture.d.ts.map +1 -0
  85. package/build/video/texture/noise_texture2d.d.ts +176 -0
  86. package/build/video/texture/noise_texture2d.d.ts.map +1 -0
  87. package/build/video/texture/parser/aseprite.d.ts.map +1 -1
  88. package/build/video/texture/texture2d.d.ts +83 -0
  89. package/build/video/texture/texture2d.d.ts.map +1 -0
  90. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  91. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +30 -4
  92. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  93. package/build/video/webgl/batchers/material_batcher.d.ts +39 -3
  94. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  95. package/build/video/webgl/batchers/mesh_batcher.d.ts +1 -1
  96. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  97. package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
  98. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  99. package/build/video/webgl/buffer/index.d.ts +13 -0
  100. package/build/video/webgl/buffer/index.d.ts.map +1 -1
  101. package/build/video/webgl/effects/hologram.d.ts +0 -5
  102. package/build/video/webgl/effects/hologram.d.ts.map +1 -1
  103. package/build/video/webgl/effects/shine.d.ts +0 -5
  104. package/build/video/webgl/effects/shine.d.ts.map +1 -1
  105. package/build/video/webgl/glshader.d.ts +29 -0
  106. package/build/video/webgl/glshader.d.ts.map +1 -1
  107. package/build/video/webgl/shadereffect.d.ts +183 -0
  108. package/build/video/webgl/shadereffect.d.ts.map +1 -1
  109. package/build/video/webgl/webgl_renderer.d.ts +41 -1
  110. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  111. package/package.json +7 -7
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Shared `settings.anchorPoint` resolution for every renderable that accepts
3
+ * it (Sprite, Entity, Collectable, ImageLayer, Text, BitmapText, Sprite3d).
4
+ * Same normalized convention as {@link Renderable#anchorPoint}: x 0=left →
5
+ * 1=right, y 0=top → 1=bottom.
6
+ */
7
+ /**
8
+ * Named anchor-point presets accepted anywhere `settings.anchorPoint` is —
9
+ * self-documenting shorthands for the common `{x, y}` pairs.
10
+ * @ignore
11
+ */
12
+ export declare const ANCHOR_POINT_PRESETS: Readonly<{
13
+ center: Readonly<{
14
+ x: 0.5;
15
+ y: 0.5;
16
+ }>;
17
+ top: Readonly<{
18
+ x: 0.5;
19
+ y: 0;
20
+ }>;
21
+ bottom: Readonly<{
22
+ x: 0.5;
23
+ y: 1;
24
+ }>;
25
+ left: Readonly<{
26
+ x: 0;
27
+ y: 0.5;
28
+ }>;
29
+ right: Readonly<{
30
+ x: 1;
31
+ y: 0.5;
32
+ }>;
33
+ "top-left": Readonly<{
34
+ x: 0;
35
+ y: 0;
36
+ }>;
37
+ "top-right": Readonly<{
38
+ x: 1;
39
+ y: 0;
40
+ }>;
41
+ "bottom-left": Readonly<{
42
+ x: 0;
43
+ y: 1;
44
+ }>;
45
+ "bottom-right": Readonly<{
46
+ x: 1;
47
+ y: 1;
48
+ }>;
49
+ }>;
50
+ /**
51
+ * An anchor value as accepted by `settings.anchorPoint`: a preset name or
52
+ * any object with numeric `x`/`y` (plain object, Vector2d, ObservablePoint).
53
+ * @ignore
54
+ */
55
+ export type AnchorPointValue = keyof typeof ANCHOR_POINT_PRESETS | {
56
+ x: number;
57
+ y: number;
58
+ };
59
+ /**
60
+ * Resolve a `settings.anchorPoint` value — a preset name or an `{x, y}`
61
+ * object — into a fresh `{x, y}` pair (never a shared/frozen object).
62
+ * Values are passed through unclamped: anchors outside 0..1 are legal.
63
+ *
64
+ * Invalid values (unknown preset, malformed object, non-finite numbers) are
65
+ * handled per surface:
66
+ * - with a `fallback` (the legacy 2D classes): logs a console warning and
67
+ * returns the fallback — full backward compatibility with the historical
68
+ * silent `set(undefined, undefined)` → `(0, 0)` outcome, nothing that
69
+ * constructed before can start throwing;
70
+ * - without (new surfaces, e.g. Sprite3d): throws.
71
+ * @ignore
72
+ */
73
+ export declare function resolveAnchorPoint(value: unknown, owner?: string, fallback?: {
74
+ x: number;
75
+ y: number;
76
+ }): {
77
+ x: number;
78
+ y: number;
79
+ };
80
+ //# sourceMappingURL=anchorPoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchorPoint.d.ts","sourceRoot":"","sources":["../../src/renderable/anchorPoint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU/B,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACzB,MAAM,OAAO,oBAAoB,GACjC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAe5B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,OAAO,EACd,KAAK,SAAe,EACpB,QAAQ,CAAC,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAyB1B"}
@@ -7,8 +7,14 @@ export default class Collectable extends Sprite {
7
7
  * @param {number} x - the x coordinates of the collectable
8
8
  * @param {number} y - the y coordinates of the collectable
9
9
  * @param {object} settings - See {@link Sprite}
10
+ * @param {string|Vector2d|{x:number,y:number}} [settings.anchorPoint={x:0,y:0}] - anchor point (note the backward-compatible `(0, 0)` default, unlike Sprite's centered one). Also accepts the named presets `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"`.
10
11
  */
11
- constructor(x: number, y: number, settings: object);
12
+ constructor(x: number, y: number, settings: {
13
+ anchorPoint?: string | Vector2d | {
14
+ x: number;
15
+ y: number;
16
+ };
17
+ });
12
18
  name: any;
13
19
  type: any;
14
20
  id: any;
@@ -1 +1 @@
1
- {"version":3,"file":"collectable.d.ts","sourceRoot":"","sources":["../../src/renderable/collectable.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IACC;;;;OAIG;IACH,eAJW,MAAM,KACN,MAAM,YACN,MAAM,EA4ChB;IAtCA,UAAyB;IACzB,UAAyB;IACzB,QAAqB;IAoBrB;;;;;;MAOC;CAUF;mBAvDkB,aAAa"}
1
+ {"version":3,"file":"collectable.d.ts","sourceRoot":"","sources":["../../src/renderable/collectable.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH;IACC;;;;;OAKG;IACH,eALW,MAAM,KACN,MAAM,YAEd;QAAuD,WAAW,GAA1D,MAAM,GAAC,QAAQ,GAAC;YAAC,CAAC,EAAC,MAAM,CAAC;YAAA,CAAC,EAAC,MAAM,CAAA;SAAC;KAC7C,EA+CA;IA1CA,UAAyB;IACzB,UAAyB;IACzB,QAAqB;IAoBrB;;;;;;MAOC;CAcF;mBA5DkB,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/renderable/container.js"],"names":[],"mappings":"AA8GA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;GASG;AACH;IACC;;;;;;;OAOG;IACH,gBAPW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,SACN,OAAO,EA0GjB;IAnGA;;;OAGG;IACH,iBAAuB;IAEvB;;;;OAIG;IACH,MAHU,OAAO,CAGD;IAEhB;;;OAGG;IACH,4BAAyB;IAEzB;;;;;OAKG;IACH,SAHU,MAAM,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Aa,GAAC,eAAe,GAAC,YAAY,GAAC,IAAI,GAAC,UAAU,QAapL;IAED;;;OAGG;IACH,oBAFW,UAAU,GAAC,MAAM,GAAC,MAAM,GAAC,WAAW,GAAC,OAAO,GAAC,SAAS,GAAC,UAAU,GAAC,eAAe,GAAC,UAAU,GAAC,UAAU,aAAS,aAAa,GAAC,eAAe,GAAC,YAAY,GAAC,IAAI,GAAC,UAAU,QAiBpL;IAED;;;OAGG;IACH,iBAFW,OAAO,QA8BjB;IAED;;;;;;;;OAQG;IACH,oBAFW,OAAO,QAoBjB;IAgBD;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,sCAEC;IAED;;;;;;;;;;;;;;;OAeG;IACH,mCAiBC;IAED;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,+BAEC;CA0JD;uBAttCsB,iBAAiB;2BAyGhB,oBAAoB;wBACrB,oBAAoB;wBACpB,aAAa;6BACR,kBAAkB;yBACtB,cAAc;+BACR,gBAAgB;gCACf,gBAAgB;iCACf,sBAAsB;4BAC3B,iBAAiB;4BACjB,iBAAiB;+BAEd,uBAAuB;iCACrB,yBAAyB;8BAC5B,sBAAsB;sBAC9B,gBAAgB;4BACV,sBAAsB;4BACxB,wBAAwB"}
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/renderable/container.js"],"names":[],"mappings":"AA8GA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;GASG;AACH;IACC;;;;;;;OAOG;IACH,gBAPW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,SACN,OAAO,EA0GjB;IAnGA;;;OAGG;IACH,iBAAuB;IAEvB;;;;OAIG;IACH,MAHU,OAAO,CAGD;IAEhB;;;OAGG;IACH,4BAAyB;IAEzB;;;;;OAKG;IACH,SAHU,MAAM,CAGE;IAClB,wCAA8B;IAE9B;;;;OAIG;IACH,UAHU,OAAO,CAGG;IAEpB;;;;OAIG;IACH,WAHU,OAAO,CAGI;IAErB;;;;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AM,GAAC,WAAW,GAAC,OAAO,GAAC,SAAS,GAAC,UAAU,GAAC,eAAe,GAAC,UAAU,GAAC,UAAU,aAAS,aAAa,GAAC,eAAe,GAAC,YAAY,GAAC,IAAI,GAAC,UAAU,QAiBpL;IAED;;;OAGG;IACH,iBAFW,OAAO,QA8BjB;IAED;;;;;;;;OAQG;IACH,oBAFW,OAAO,QAoBjB;IAgBD;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,sCAEC;IAED;;;;;;;;;;;;;;;OAeG;IACH,mCAiBC;IAED;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,+BAEC;CAgKD;uBA9tCsB,iBAAiB;2BAyGhB,oBAAoB;wBACrB,oBAAoB;wBACpB,aAAa;6BACR,kBAAkB;yBACtB,cAAc;+BACR,gBAAgB;gCACf,gBAAgB;iCACf,sBAAsB;4BAC3B,iBAAiB;4BACjB,iBAAiB;+BAEd,uBAAuB;iCACrB,yBAAyB;8BAC5B,sBAAsB;sBAC9B,gBAAgB;4BACV,sBAAsB;4BACxB,wBAAwB"}
@@ -161,7 +161,7 @@ export default class Entity extends Renderable {
161
161
  * @param {string} [settings.name] - object entity name
162
162
  * @param {string} [settings.id] - object unique IDs
163
163
  * @param {Image|string} [settings.image] - resource name of a spritesheet to use for the entity renderable component
164
- * @param {Vector2d} [settings.anchorPoint=0.0] - Entity anchor point
164
+ * @param {string|Vector2d|{x:number,y:number}} [settings.anchorPoint=0.0] - Entity anchor point. Also accepts the named presets `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"`.
165
165
  * @param {number} [settings.framewidth=settings.width] - width of a single frame in the given spritesheet
166
166
  * @param {number} [settings.frameheight=settings.width] - height of a single frame in the given spritesheet
167
167
  * @param {string} [settings.type] - object type
@@ -175,7 +175,10 @@ export default class Entity extends Renderable {
175
175
  name?: string | undefined;
176
176
  id?: string | undefined;
177
177
  image?: string | (new (width?: number, height?: number) => HTMLImageElement) | undefined;
178
- anchorPoint?: any;
178
+ anchorPoint?: string | Vector2d | {
179
+ x: number;
180
+ y: number;
181
+ };
179
182
  framewidth?: number | undefined;
180
183
  frameheight?: number | undefined;
181
184
  type?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/renderable/entity/entity.js"],"names":[],"mappings":"AAOA;;;;;;;;IAQI;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6IG;AACH;IACC,mCAAkC;IAElC;;;;;;;;;;;;;;;;;OAiBG;IACH,eAjBW,MAAM,KACN,MAAM,YAGd;QAAyB,KAAK,EAAtB,MAAM;QACW,MAAM,EAAvB,MAAM;QACY,IAAI;QACJ,EAAE;QACI,KAAK;QACT,WAAW;QACb,UAAU;QACV,WAAW;QACX,IAAI;QACJ,aAAa;QACc,MAAM;KAC3D,EAsFF;IA1EA;;;OAGG;IACH,gBAAkB;IAiFnB,sBAPU,UAAU,EAmBnB;IArBD;;;OAGG;IAEH,kBAHU,UAAU,CAKnB;IAnDA;;;OAGG;IACH,IAFU,MAAM,CAEW;IAE3B;;;;OAIG;IACH,OAFU,OAAO,CAEA;IAwDlB,cAAc;IACd,yBAKC;IAED;;;;OAIG;IACH,wBAHW,OAAO,GACL,MAAM,CA0BlB;IAED;;OAEG;IACH,qBAEC;IAED,6BAkBC;IAoCD;;OAEG;IACH,0BAIC;CACD;uBAzYsB,kBAAkB;4BAQhB,2BAA2B;0BAH7B,iCAAiC;6BAE9B,6BAA6B;0BAHhC,4BAA4B;6BAEzB,+BAA+B"}
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/renderable/entity/entity.js"],"names":[],"mappings":"AAQA;;;;;;;;IAQI;AAEJ;;;;;;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GA;IAEhB;;;;OAIG;IACH,aAHU,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAGL;IAE7B,qDAAqD;IACrD,MAD2C,MAAM,CACnC;IAEd,uEAAuE;IACvE,uFAA0B;IAE1B,wCAAwC;IACxC,SAD8B,MAAM,CAiBnC;IAED,kEAAkE;IAClE,IADwD,MAAM,CACnD;IAEX,qEAAqE;IACrE,gBAD2D,MAAM,CACxC;IAEzB,6DAA6D;IAC7D,gBADkD,OAAO,CAC9B;IAE3B,6DAA6D;IAC7D,mBAAmB;IAEnB,8EAA8E;IAC9E,mBAAsB;IAGvB;;;;;;OAMG;IACH,mBALW,MAAM,SACN,MAAM,EAAE,GAAC,MAAM,EAAE,GAAC,MAAM,EAAE,mBAC1B,MAAM,GACJ,MAAM,CAoElB;IAED;;;;;;OAMG;IACH,0BALW,MAAM,cACN,MAAM,cAAU,MAAM,gBACtB,OAAO,GACL,MAAM,CAuDlB;IAED;;;;;OAKG;IACH,wBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,yBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;OAEG;IACH,qBAFa,MAAM,EAAE,CAIpB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,MAAM,CAiBlB;IAED;;;;OAIG;IACH,0BAHW,MAAM,GACJ,MAAM,CAOlB;IAED;;OAEG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,mBAGC;IAED;;;OAGG;IACH,eAKC;IAED;;;;;;;;OAQG;IACH,WAHW,MAAM,GACJ,OAAO,CAyCnB;IAED;;;OAGG;IACH,gBAOC;CACD"}
1
+ {"version":3,"file":"frameAnimation.d.ts","sourceRoot":"","sources":["../../src/renderable/frameAnimation.js"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IACC;;;;;;;;;;;OAWG;IACH,kBAXW,MAAM,cAMN,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,EA2DlC;IArDA;;;;OAIG;IACH,MAHU,MAAM,CAGA;IAEhB;;;;OAIG;IACH,aAHU,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAGL;IAE7B,qDAAqD;IACrD,MAD2C,MAAM,CACnC;IAEd,uEAAuE;IACvE,uFAA0B;IAE1B,wCAAwC;IACxC,SAD8B,MAAM,CAiBnC;IAED,kEAAkE;IAClE,IADwD,MAAM,CACnD;IAEX,qEAAqE;IACrE,gBAD2D,MAAM,CACxC;IAEzB,6DAA6D;IAC7D,gBADkD,OAAO,CAC9B;IAE3B,6DAA6D;IAC7D,mBAAmB;IAEnB,8EAA8E;IAC9E,mBAAsB;IAGvB;;;;;;OAMG;IACH,mBALW,MAAM,SACN,MAAM,EAAE,GAAC,MAAM,EAAE,GAAC,MAAM,EAAE,mBAC1B,MAAM,GACJ,MAAM,CAoElB;IAED;;;;;;OAMG;IACH,0BALW,MAAM,cACN,MAAM,cAAU,MAAM,gBACtB,OAAO,GACL,MAAM,CA4DlB;IAED;;;;;OAKG;IACH,wBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,yBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;OAEG;IACH,qBAFa,MAAM,EAAE,CAIpB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,MAAM,CAiBlB;IAED;;;;OAIG;IACH,0BAHW,MAAM,GACJ,MAAM,CAOlB;IAED;;OAEG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,mBAGC;IAED;;;OAGG;IACH,eAKC;IAED;;;;;;;;OAQG;IACH,WAHW,MAAM,GACJ,OAAO,CAiDnB;IAED;;;OAGG;IACH,gBAOC;CACD"}
@@ -16,7 +16,7 @@ export default class ImageLayer extends Sprite {
16
16
  * @param {number} [settings.z=0] - z-index position
17
17
  * @param {number|Vector2d} [settings.ratio=1.0] - Scrolling ratio to be applied. See {@link ImageLayer#ratio}
18
18
  * @param {"repeat"|"repeat-x"|"repeat-y"|"no-repeat"} [settings.repeat="repeat"] - define if and how an Image Layer should be repeated. See {@link ImageLayer#repeat}
19
- * @param {number|Vector2d} [settings.anchorPoint=<0.0,0.0>] - Define how the image is anchored to the viewport bound. By default, its upper-left corner is anchored to the viewport bounds upper left corner.
19
+ * @param {number|string|Vector2d|{x:number,y:number}} [settings.anchorPoint=<0.0,0.0>] - Define how the image is anchored to the viewport bound. By default, its upper-left corner is anchored to the viewport bounds upper left corner. Also accepts the named presets `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"` (anchored relative to the viewport, e.g. `"bottom"` = bottom-center of the viewport); a bare number anchors both axes.
20
20
  * @example
21
21
  * // create a repetitive background pattern on the X axis using the citycloud image asset
22
22
  * app.world.addChild(new me.ImageLayer(0, 0, {
@@ -30,7 +30,10 @@ export default class ImageLayer extends Sprite {
30
30
  z?: number | undefined;
31
31
  ratio?: number | Vector2d | undefined;
32
32
  repeat?: "repeat" | "no-repeat" | "repeat-x" | "repeat-y" | undefined;
33
- anchorPoint?: number | Vector2d | undefined;
33
+ anchorPoint?: string | number | Vector2d | {
34
+ x: number;
35
+ y: number;
36
+ } | undefined;
34
37
  });
35
38
  /**
36
39
  * Define the image scrolling ratio<br>
@@ -1 +1 @@
1
- {"version":3,"file":"imagelayer.d.ts","sourceRoot":"","sources":["../../src/renderable/imagelayer.js"],"names":[],"mappings":"AAYA;;;GAGG;AAEH;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;OAgBG;IACH,eAhBW,MAAM,KACN,MAAM,YAEd;QAA4E,KAAK,EAAzE,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,MAAM;QACvC,IAAI;QACJ,CAAC;QACQ,KAAK;QACsB,MAAM;QACjC,WAAW;KAC9C,EAoDF;IAhCA;;;;;;;;;OASG;IACH,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AqB"}
@@ -15,7 +15,10 @@
15
15
  * mesh under a transformed parent to pivot elsewhere). Consequently, on the
16
16
  * `Camera3d` world-space path the mesh opts out of the anchor offset entirely
17
17
  * (see {@link Renderable#applyAnchorTransform}); the legacy 2D path still
18
- * honors `anchorPoint` for backward compatibility.
18
+ * honors `anchorPoint` for backward compatibility. Subclasses that bake the
19
+ * anchor into their vertex data instead (e.g. {@link Sprite3d}, via the
20
+ * internal `_anchorBaked` flag) opt out on **both** paths — for those, the
21
+ * vertex bake is the single anchoring mechanism.
19
22
  * @category Game Objects
20
23
  */
21
24
  export default class Mesh extends Renderable {
@@ -35,7 +38,7 @@ export default class Mesh extends Renderable {
35
38
  * @param {boolean} [settings.normalize=true] - fit the source geometry into a `[-0.5, 0.5]` unit cube before scaling, so `width`/`height` behave like a Sprite. Set `false` to keep the geometry's real-world coordinates — required when several meshes share one coordinate space (e.g. nodes of an imported glTF scene) so their relative scale and layout are preserved.
36
39
  * @param {number} [settings.scale] - world-space scale (pixels per source unit) for the Camera3d path; defaults to `width`. Set this when `width`/`height` describe the renderable's world bounds (frustum culling) rather than the geometry scale — see {@link Mesh#meshScale}.
37
40
  * @param {boolean} [settings.rightHanded=false] - treat the source as right-handed (Y-up, e.g. glTF) under the `Camera3d` world path. The default Y-up→Y-down bridge negates Y only (a reflection, which mirrors the scene left/right); `true` negates Y **and** Z (a rotation) so chirality is preserved and the result matches the authoring tool. See {@link Mesh#rightHanded}.
38
- * @param {string} [settings.textureRepeat] - texture wrap mode (`"repeat"` / `"repeat-x"` / `"repeat-y"` / `"no-repeat"`) applied to the resolved texture. Use `"repeat"` when the geometry's UVs fall outside the `[0, 1]` range and rely on the texture tiling (e.g. glTF assets, whose default sampler wrap is REPEAT) — otherwise the texture clamps to its edge texels and looks flat. Ignored for the white-pixel fallback. Note: REPEAT on a non-power-of-two texture requires WebGL 2.
41
+ * @param {string} [settings.textureRepeat] - texture wrap mode (`"repeat"` / `"repeat-x"` / `"repeat-y"` / `"no-repeat"`) this mesh samples its texture with (per-mesh — it does not modify the shared texture, so other meshes/sprites using the same image are unaffected). Use `"repeat"` when the geometry's UVs fall outside the `[0, 1]` range and rely on the texture tiling (e.g. glTF assets, whose default sampler wrap is REPEAT) — otherwise the texture clamps to its edge texels and looks flat. Ignored for the white-pixel fallback. Note: REPEAT on a non-power-of-two texture requires WebGL 2.
39
42
  * @param {string} [settings.textureFilter] - texture magnification filter (`"nearest"` for crisp pixel-art upscaling, `"linear"` for smooth) applied to the resolved texture. Omit to keep the renderer's global `antiAlias` default. WebGL only (ignored by the Canvas renderer).
40
43
  * @param {number} [settings.alphaCutoff=0] - alpha cutout threshold. Fragments whose final alpha is below this value are discarded (hard-edged cutout — foliage, fences, decals — with no blending or sorting). `0` disables the cutout. Set automatically by the glTF loader from a material's `alphaMode: "MASK"`. WebGL mesh path only.
41
44
  * @param {number[]|Float32Array} [settings.emissive] - emissive (self-illumination) color `[r, g, b]` (0..1, may exceed 1 for HDR glow) added on top of the lit/unlit color so the surface glows regardless of scene lights (neon, lava, screens). Omit / all-zero for no emission. Set automatically by the glTF loader (`emissiveFactor`) and OBJ loader (MTL `Ke`). WebGL mesh path only.
@@ -238,6 +241,25 @@ export default class Mesh extends Renderable {
238
241
  */
239
242
  vertexColors: Uint32Array;
240
243
  texture: any;
244
+ /**
245
+ * Per-mesh texture wrap mode (`"repeat"` / `"repeat-x"` / `"repeat-y"`
246
+ * / `"no-repeat"`), or `undefined` to sample with the texture's own
247
+ * wrap. Some assets author UVs outside the `[0, 1]` range and rely on
248
+ * the sampler repeating the texture (this is the glTF default sampler
249
+ * behavior); the mesh would otherwise clamp to the edge texels and
250
+ * look flat / untextured.
251
+ *
252
+ * Kept on the mesh and threaded to the batcher at draw time — sampler
253
+ * state per use, like a GL sampler object — so it never mutates the
254
+ * per-image `TextureAtlas` shared with every other consumer of the
255
+ * same image (#1503). Two meshes (or a mesh and a sprite) can point
256
+ * at one image with different wrap modes; the texture cache keys GL
257
+ * units by `(source, repeat)` so each wrap gets its own GL texture.
258
+ * Applied only to a real texture — never the shared white-pixel
259
+ * fallback, which is global and must stay `"no-repeat"`.
260
+ * @type {string|undefined}
261
+ */
262
+ textureRepeat: string | undefined;
241
263
  /**
242
264
  * Projection matrix applied automatically before the model transform in draw().
243
265
  * Defaults to a perspective projection (45° FOV, camera at z=-2.5) suitable for
@@ -247,6 +269,8 @@ export default class Mesh extends Renderable {
247
269
  */
248
270
  projectionMatrix: Matrix3d;
249
271
  /** @ignore */
272
+ _anchorBaked: boolean;
273
+ /** @ignore */
250
274
  _hullPoints: Vector2d[];
251
275
  /** @ignore */
252
276
  _hullPolygon: Polygon | null;
@@ -1 +1 @@
1
- {"version":3,"file":"mesh.d.ts","sourceRoot":"","sources":["../../src/renderable/mesh.js"],"names":[],"mappings":"AAyGA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgEG;IACH,eAhEW,MAAM,KACN,MAAM,YAEd;QAA0B,KAAK;QACU,QAAQ;QACR,GAAG;QACJ,OAAO;QACS,OAAO;QACrC,QAAQ;QACT,KAAK,EAAtB,MAAM;QACY,MAAM;QACL,aAAa;QACb,SAAS;QACV,KAAK;QACJ,WAAW;QACZ,aAAa;QACb,aAAa;QACb,WAAW;QACI,QAAQ;KACjD,EAoaF;IA7WC;;;OAGG;IACH,kBAFU,YAAY,CAEkB;IAExC;;;OAGG;IACH,KAFU,YAAY,CAEA;IAQtB;;;OAGG;IACH,aAFU,MAAM,CAEsB;IAmCvC,2BAAoC;IAGpC;;;OAGG;IACH,UAFU,YAAY,CAEgC;IAEtD;;;;;OAKG;IACH,iBAFU,YAAY,GAAC,SAAS,CAOnB;IAUb;;;;;;;;;OASG;IACH,KAHU,OAAO,CAGe;IAEhC;;;;;;;;;OASG;IACH,aAHU,MAAM,CAIoD;IAEpE;;;;;;;;;OASG;IACH,UAFU,YAAY,GAAC,SAAS,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AC,SAAS,CAKb;IAsBb;;;;;;OAMG;IACH,kBAFU,QAAQ,CAEoB;IAqBtC,cAAc;IACd,sBAAyB;IAOzB,cAAc;IACd,wBAEE;IACF,cAAc;IACd,6BAAwB;IAGzB;;;;;;;OAOG;IACH,2BALW,MAAM,YACN,MAAM,WACN,MAAM,QAiBhB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,+BALW,MAAM,WACN,MAAM,WACN,MAAM,QAqChB;IAED;;;;;;;;;;;;OAYG;IACH,6BA8BC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,yBAqBC;IAHC,sBAA2B;IAE5B,iCAAuB;IAoBvB,oCAAuD;IAGxD;;;;;;;;;;;;;;;OAeG;IACH,eAFa,MAAM,CAWlB;IAPC,cAAc;IACd,8BAA6B;IAkI/B;;;;;;;;;;;;OAYG;IACH,YATa,iBAAiB,CAoH7B;IAED;;;;;;;OAOG;IACH,iBALa,OAAO,CAAC,WAAW,CAAC,CAOhC;CACD;uBA3hCsB,iBAAiB;sBAZlB,kBAAkB;yBACf,qBAAqB;yBACrB,qBAAqB;wBAJtB,0BAA0B;uBAU3B,iCAAiC;6BAE3B,6BAA6B"}
@@ -1,8 +1,3 @@
1
- /**
2
- * additional import for TypeScript
3
- * @import {Color} from "./../math/color.ts";
4
- * @import { TextureAtlas } from "./../video/texture/atlas.js";
5
- */
6
1
  /**
7
2
  * A NineSliceSprite is similar to a Sprite, but it uses 9-slice scaling to stretch its inner area to fit the size of the Renderable,
8
3
  * by proportionally scaling a sprite by splitting it in a grid of nine parts (with only parts 1, 3, 7, 9 not being scaled). <br>
@@ -27,7 +22,7 @@ export default class NineSliceSprite extends Sprite {
27
22
  * @param {string|Color} [settings.tint] - a tint to be applied to this sprite
28
23
  * @param {number} [settings.flipX] - flip the sprite on the horizontal axis
29
24
  * @param {number} [settings.flipY] - flip the sprite on the vertical axis
30
- * @param {Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] - Anchor point to draw the frame at (defaults to the center of the frame).
25
+ * @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"`.
31
26
  * @example
32
27
  * this.panelSprite = new me.NineSliceSprite(0, 0, {
33
28
  * image : game.texture,
@@ -49,7 +44,10 @@ export default class NineSliceSprite extends Sprite {
49
44
  tint?: string | Color | undefined;
50
45
  flipX?: number | undefined;
51
46
  flipY?: number | undefined;
52
- anchorPoint?: any;
47
+ anchorPoint?: string | Vector2d | {
48
+ x: number;
49
+ y: number;
50
+ };
53
51
  });
54
52
  set width(value: number);
55
53
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"nineslicesprite.d.ts","sourceRoot":"","sources":["../../src/renderable/nineslicesprite.js"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH;;;;;;GAMG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAxBW,MAAM,KACN,MAAM,YAEd;QAAyB,KAAK,EAAtB,MAAM;QACW,MAAM,EAAvB,MAAM;QACY,MAAM;QACN,MAAM;QACyD,KAAK,EAAtF,gBAAgB,GAAC,iBAAiB,GAAC,YAAY,GAAC,eAAe,GAAC,MAAM;QACpD,IAAI;QACJ,MAAM;QACN,UAAU;QACV,WAAW;QACL,IAAI;QACV,KAAK;QACL,KAAK;QACH,WAAW;KACvC,EA8BF;IASD,iBALU,MAAM,EAOf;IATD;;;OAGG;IACH,aAFU,MAAM,CAIf;IAYD,kBALU,MAAM,EAOf;IATD;;;OAGG;IACH,cAFU,MAAM,CAIf;IAxBA,kBAA2B;IAC3B,mBAA6B;IAE7B,2BAA6B;IAC7B,2BAA6B;IAyB9B;;OAEG;IACH,0BA4JC;CACD;mBAvPkB,aAAa;kCAKC,6BAA6B;2BADtC,oBAAoB"}
1
+ {"version":3,"file":"nineslicesprite.d.ts","sourceRoot":"","sources":["../../src/renderable/nineslicesprite.js"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAxBW,MAAM,KACN,MAAM,YAEd;QAAyB,KAAK,EAAtB,MAAM;QACW,MAAM,EAAvB,MAAM;QACY,MAAM;QACN,MAAM;QACyD,KAAK,EAAtF,gBAAgB,GAAC,iBAAiB,GAAC,YAAY,GAAC,eAAe,GAAC,MAAM;QACpD,IAAI;QACJ,MAAM;QACN,UAAU;QACV,WAAW;QACL,IAAI;QACV,KAAK;QACL,KAAK;QACwB,WAAW,GAA1D,MAAM,GAAC,QAAQ,GAAC;YAAC,CAAC,EAAC,MAAM,CAAC;YAAA,CAAC,EAAC,MAAM,CAAA;SAAC;KAC3C,EA8BF;IASD,iBALU,MAAM,EAOf;IATD;;;OAGG;IACH,aAFU,MAAM,CAIf;IAYD,kBALU,MAAM,EAOf;IATD;;;OAGG;IACH,cAFU,MAAM,CAIf;IAxBA,kBAA2B;IAC3B,mBAA6B;IAE7B,2BAA6B;IAC7B,2BAA6B;IAkD9B;;OAEG;IACH,0BA6EC;CACD;mBA3MkB,aAAa;kCAKC,6BAA6B;2BADtC,oBAAoB"}
@@ -25,7 +25,12 @@ export default class Renderable extends Rect {
25
25
  * a Renderable's anchor point defaults to (0.5,0.5), which corresponds to the center position.<br>
26
26
  * <br>
27
27
  * <i><b>Note:</b> Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation.
28
- * To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`. </i>
28
+ * To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`, or (since 19.9) a plain string preset such as `bottom`. </i>
29
+ * <br>
30
+ * At construction time, `settings.anchorPoint` also accepts the named presets
31
+ * `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`,
32
+ * `"bottom-left"`, `"bottom-right"` on every renderable that consumes it
33
+ * (Sprite, Entity, Collectable, ImageLayer, Text, BitmapText, Sprite3d and subclasses).
29
34
  * @type {ObservablePoint}
30
35
  * @default <0.5,0.5>
31
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;IAaI;AAEJ;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;OAUG;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;;;;;;;OAOG;IACH,OAHU,MAAM,CAGA;IAEhB;;;;OAIG;IACH,UAHU,SAAS,GAAC,MAAM,CAGD;IAEzB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAlBU,IAAI,GAAC,SAAS,GAAC,OAAO,GAAC,IAAI,GAAC,OAAO,CAkBxB;IAErB;;;;;;;;;;;;;;OAcG;IACH,aAVU,KAAK,CAAC,QAAQ,GAAC,YAAY,CAAC,CAUjB;IAErB;;;OAGG;IACH,4BAA+B;IAE/B;;;;;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A4B;6BAG1B,iCAAiC;gCAC9B,sCAAsC;+BACvC,oCAAoC"}
@@ -12,7 +12,7 @@ export default class Sprite extends Renderable {
12
12
  * @param {number} x - the x coordinates of the sprite object
13
13
  * @param {number} y - the y coordinates of the sprite object
14
14
  * @param {object} settings - Configuration parameters for the Sprite object
15
- * @param {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|TextureAtlas|CompressedImage|string} settings.image - reference to spritesheet image, a texture atlas, a video element, a compressed texture, or to a texture atlas
15
+ * @param {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|Texture2d|TextureAtlas|CompressedImage|string} settings.image - reference to a spritesheet image, a {@link Texture2d} asset (e.g. a {@link TextureAtlas}), a video element, a compressed texture, or a loader key
16
16
  * @param {string} [settings.name=""] - name of this object
17
17
  * @param {string} [settings.region] - region name of a specific region to use when using a texture atlas, see {@link TextureAtlas}
18
18
  * @param {number} [settings.framewidth] - Width of a single frame within the spritesheet
@@ -20,8 +20,8 @@ export default class Sprite extends Renderable {
20
20
  * @param {string|Color} [settings.tint] - a tint to be applied to this sprite
21
21
  * @param {number} [settings.flipX] - flip the sprite on the horizontal axis
22
22
  * @param {number} [settings.flipY] - flip the sprite on the vertical axis
23
- * @param {Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] - Anchor point to draw the frame at (defaults to the center of the frame).
24
- * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|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).
23
+ * @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
+ * @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).
25
25
  * @example
26
26
  * // create a single sprite from a standalone image, with anchor in the center
27
27
  * let sprite = new me.Sprite(0, 0, {
@@ -52,7 +52,7 @@ export default class Sprite extends Renderable {
52
52
  * videoSprite.play();
53
53
  */
54
54
  constructor(x: number, y: number, settings: {
55
- image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | TextureAtlas | CompressedImage | string;
55
+ image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Texture2d | TextureAtlas | CompressedImage | string;
56
56
  name?: string | undefined;
57
57
  region?: string | undefined;
58
58
  framewidth?: number | undefined;
@@ -60,8 +60,11 @@ export default class Sprite extends Renderable {
60
60
  tint?: string | Color | undefined;
61
61
  flipX?: number | undefined;
62
62
  flipY?: number | undefined;
63
- anchorPoint?: Vector2d | undefined;
64
- normalMap?: string | ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | undefined;
63
+ anchorPoint?: string | Vector2d | {
64
+ x: number;
65
+ y: number;
66
+ } | undefined;
67
+ normalMap?: string | ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | Texture2d | undefined;
65
68
  });
66
69
  _frameAnim: FrameAnimation;
67
70
  /**
@@ -118,6 +121,8 @@ export default class Sprite extends Renderable {
118
121
  * @ignore
119
122
  */
120
123
  removeStatePauseListener: (() => void) | undefined;
124
+ _lastVideoFrameVersion: number | undefined;
125
+ _videoFrameHandle: any;
121
126
  set normalMap(value: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | null);
122
127
  /**
123
128
  * The optional normal-map image paired with this sprite's color
@@ -244,7 +249,7 @@ export default class Sprite extends Renderable {
244
249
  * this.setCurrentAnimation("walk");
245
250
  *
246
251
  * // set "walk" animation if it is not the current animation
247
- * if (this.isCurrentAnimation("walk")) {
252
+ * if (!this.isCurrentAnimation("walk")) {
248
253
  * this.setCurrentAnimation("walk");
249
254
  * }
250
255
  *
@@ -366,5 +371,6 @@ import FrameAnimation from "./frameAnimation.js";
366
371
  import type { Vector2d } from "../math/vector2d.js";
367
372
  import { TextureAtlas } from "./../video/texture/atlas.js";
368
373
  import type Renderer from "./../video/renderer.js";
374
+ import Texture2d from "./../video/texture/texture2d.ts";
369
375
  import { Color } from "../math/color.ts";
370
376
  //# sourceMappingURL=sprite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sprite.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite.js"],"names":[],"mappings":"AAYA;;;;GAIG;AAEH;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,eA1CW,MAAM,KACN,MAAM,YAEd;QAA0G,KAAK,EAAvG,gBAAgB,GAAC,iBAAiB,GAAC,gBAAgB,GAAC,YAAY,GAAC,eAAe,GAAC,MAAM;QACrE,IAAI;QACJ,MAAM;QACN,UAAU;QACV,WAAW;QACL,IAAI;QACV,KAAK;QACL,KAAK;QACH,WAAW;QACkD,SAAS;KAClG,EA4QF;IAtOA,2BAEE;IAEF;;;;OAIG;IACH,QAHU,QAAQ,CAGkB;IAEpC;;;;OAIG;IACH,SAHU,OAAO,CAGG;IAEpB;;;;OAIG;IAGH;;;OAGG;IACH,QAFU,YAAY,CAEJ;IAElB;;;;OAIG;IACH,wFAAsB;IAEtB;;;OAGG;IACH;;;;;MAKC;IAKA,WAAqC;IACrC,kBAAkC;IAiCjC,WAG8C;IAC9C,YAGgD;IA0LnD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H,oBAHW,MAAM,QA0ChB;IAED;;;;;;;OAOG;IACH,0BANW,MAAM,GACJ,MAAM,CAQlB;IAED;;;OAGG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;IAsDD;;;;;;OAMG;IACH,kBAFW,QAAQ,QAWlB;IAED;;;OAGG;IACH,mBAFW,QAAQ,QAQlB;IAED;;;;OAIG;IACH,eAHW,QAAQ,QAuDlB;IAED;;;OAGG;IACH,gBAyBC;CACD;uBAj5BsB,iBAAiB;2BADb,qBAAqB;8BAQrB,qBAAqB;6BAXnB,6BAA6B;0BAYjC,wBAAwB;sBAX3B,iCAAiC;sBAJjC,kBAAkB"}
@@ -24,6 +24,14 @@
24
24
  * world-space path; under a 2D `Camera2d` it falls back to the mesh's
25
25
  * self-projection and **billboarding has no effect** (a 2D scene has no camera
26
26
  * orientation to face). Use a regular {@link Sprite} for 2D.
27
+ *
28
+ * **Anchoring.** Unlike its {@link Mesh} parent — where `anchorPoint` is inert
29
+ * on the 3D path and transforms pivot at the model origin — Sprite3d's
30
+ * `anchorPoint` is live: the anchor is baked into the quad's local vertices
31
+ * (never applied as a renderer transform on either camera path) and can be
32
+ * changed at runtime via `anchorPoint.set(...)`, which re-bakes the quad and
33
+ * re-derives the cull bounds. Same key, convention and centered default as
34
+ * the 2D {@link Sprite}, including the named presets (`"bottom"`, …).
27
35
  * @augments Mesh
28
36
  * @category Game Objects
29
37
  * @example
@@ -57,13 +65,22 @@
57
65
  * coin.setCurrentAnimation("spin");
58
66
  * coin.flipX(); // face the other way (mirrors the sprite)
59
67
  * app.world.addChild(coin);
68
+ *
69
+ * // a character anchored at the feet, so `pos` sits on the ground plane
70
+ * // instead of at the sprite's geometric center
71
+ * const hero = new Sprite3d(0, 0, {
72
+ * image: "hero",
73
+ * width: 48, height: 64,
74
+ * billboard: "cylindrical",
75
+ * anchorPoint: "bottom", // == { x: 0.5, y: 1 }
76
+ * });
60
77
  */
61
78
  export default class Sprite3d extends Mesh {
62
79
  /**
63
80
  * @param {number} x - world x position
64
81
  * @param {number} y - world y position
65
82
  * @param {object} settings - configuration
66
- * @param {HTMLImageElement|TextureAtlas|string} [settings.image] - the sprite texture (image name, image, or atlas). Alias: `settings.texture`.
83
+ * @param {HTMLImageElement|Texture2d|string} [settings.image] - the sprite texture (image name, image, or a {@link Texture2d} asset such as a {@link TextureAtlas}). Alias: `settings.texture`.
67
84
  * @param {number} [settings.width=settings.framewidth] - quad width in world units (pixels)
68
85
  * @param {number} [settings.height=settings.width] - quad height in world units
69
86
  * @param {number} [settings.framewidth] - width of a single frame within a spritesheet (enables frame animation)
@@ -72,6 +89,7 @@ export default class Sprite3d extends Mesh {
72
89
  * @param {object[]} [settings.anims] - predefined animations (same shape as {@link Sprite})
73
90
  * @param {number} [settings.z=0] - 3D depth (world z); also settable later via `.depth`
74
91
  * @param {boolean|string} [settings.billboard=false] - billboard mode: `false` (fixed orientation), `true` / `"cylindrical"` (faces the camera but stays upright — the 2.5D default), or `"spherical"` (faces the camera on all axes). Only applies under a `Camera3d`.
92
+ * @param {string|Vector2d|{x:number,y:number}} [settings.anchorPoint={x:0.5,y:0.5}] - anchor of the quad relative to `pos` — same key, normalized 0..1 convention (`x`: 0 left→1 right, `y`: 0 top→1 bottom) and centered default as the 2D {@link Sprite}. Also accepts the named presets `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"`. Baked into the quad's local vertices (composes with billboarding, flips, and trimmed/rotated atlas frames) — never applied as a renderer transform on either camera path. Mutable at runtime via `this.anchorPoint.set(...)` (re-bakes the quad and re-derives the cull bounds). Invalid values throw.
75
93
  * @param {boolean} [settings.flipX=false] - mirror the sprite horizontally (see {@link Sprite3d#flipX})
76
94
  * @param {boolean} [settings.flipY=false] - mirror the sprite vertically (see {@link Sprite3d#flipY})
77
95
  * @param {boolean} [settings.lit=false] - shade through the lit mesh batcher (see {@link Mesh})
@@ -79,7 +97,7 @@ export default class Sprite3d extends Mesh {
79
97
  * @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.
80
98
  */
81
99
  constructor(x: number, y: number, settings: {
82
- image?: string | HTMLImageElement | TextureAtlas | undefined;
100
+ image?: string | HTMLImageElement | Texture2d | undefined;
83
101
  width?: number | undefined;
84
102
  height?: number | undefined;
85
103
  framewidth?: number | undefined;
@@ -88,6 +106,10 @@ export default class Sprite3d extends Mesh {
88
106
  anims?: object[] | undefined;
89
107
  z?: number | undefined;
90
108
  billboard?: string | boolean | undefined;
109
+ anchorPoint?: string | Vector2d | {
110
+ x: number;
111
+ y: number;
112
+ };
91
113
  flipX?: boolean | undefined;
92
114
  flipY?: boolean | undefined;
93
115
  lit?: boolean | undefined;
@@ -103,6 +125,10 @@ export default class Sprite3d extends Mesh {
103
125
  /** @ignore */
104
126
  _halfH: number;
105
127
  /** @ignore */
128
+ _anchorOffsetX: number;
129
+ /** @ignore */
130
+ _anchorOffsetY: number;
131
+ /** @ignore */
106
132
  _refLw: number;
107
133
  /** @ignore */
108
134
  _refLh: number;
@@ -147,6 +173,15 @@ export default class Sprite3d extends Mesh {
147
173
  billboard: boolean | string;
148
174
  /** the camera captured at draw time for the billboard projection @ignore */
149
175
  _billboardCam: Camera3d | null;
176
+ /**
177
+ * anchorPoint changed at runtime (the ObservablePoint callback wired in
178
+ * the constructor): recompute the baked local offset from the live anchor
179
+ * and the art size, re-bake the quad, and re-derive the frustum-cull
180
+ * bounds. Preserves the base ObservablePoint contract (updateBounds +
181
+ * isDirty, see Renderable's anchorPoint callback).
182
+ * @ignore
183
+ */
184
+ _onAnchorChanged(): void;
150
185
  /**
151
186
  * defined animations, keyed by id (see {@link Sprite3d#addAnimation}).
152
187
  * @type {object}
@@ -277,8 +312,9 @@ export default class Sprite3d extends Mesh {
277
312
  * {@link Sprite}'s sub-texture / size / anchor swap). Rewrites both the quad's
278
313
  * UVs (the atlas sub-rect, with a 90° corner permutation for packer-rotated
279
314
  * regions) and its local vertices (the trimmed art's sub-rectangle within the
280
- * logical frame, scaled into the quad's world footprint), so trimmed and
281
- * rotated `TextureAtlas` regions render at full parity with the 2D `Sprite`.
315
+ * logical frame, scaled into the quad's world footprint, then shifted by the
316
+ * anchor offset), so trimmed and rotated `TextureAtlas` regions render at
317
+ * full parity with the 2D `Sprite`.
282
318
  * @param {object} region - the texture region object
283
319
  * @ignore
284
320
  */
@@ -310,5 +346,5 @@ export default class Sprite3d extends Mesh {
310
346
  import Mesh from "./mesh.js";
311
347
  import FrameAnimation from "./frameAnimation.js";
312
348
  import Camera3d from "../camera/camera3d.ts";
313
- import { TextureAtlas } from "../video/texture/atlas.js";
349
+ import Texture2d from "../video/texture/texture2d.ts";
314
350
  //# sourceMappingURL=sprite3d.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sprite3d.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite3d.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH;IACC;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAlBW,MAAM,KACN,MAAM,YAEd;QAAwD,KAAK;QACnC,KAAK;QACL,MAAM;QACN,UAAU;QACV,WAAW;QACX,MAAM;QACJ,KAAK;QACP,CAAC;QACO,SAAS;QAChB,KAAK;QACL,KAAK;QACL,GAAG;QACW,QAAQ;QACvB,WAAW;KACvC,EAiMA;IAnHA;;;;OAIG;IACH,QAHU,MAAM,CAGA;IAChB,cAAc;IACd,eAAgB;IAIhB,cAAc;IACd,eAAe;IACf,cAAc;IACd,eAAe;IAKf,cAAc;IACd,gBAAmB;IACnB,cAAc;IACd,gBAAmB;IAEnB,cAAc;IACd,uBAAmB;IAKnB;;;OAGG;IACH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InB;IAED;;OAEG;IACH,qBAFa,MAAM,EAAE,CAIpB;IAED;;OAEG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,mCAJW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;;;;;;;OAUG;IACH,oBAHW,MAAM,QAoGhB;IAgBD;;;;OAIG;IACH,gBAIC;IAED;;;;;;;;;OASG;IACH,eAJW,cAAc,GAAC,aAAa,aAC5B,QAAQ,QAMlB;IAED;;;;OAIG;IACH,sEA2DC;CACD;iBA5tBgB,WAAW;2BADD,qBAAqB;qBAJ3B,uBAAuB;6BAGf,2BAA2B"}
1
+ {"version":3,"file":"sprite3d.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite3d.js"],"names":[],"mappings":"AAmEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH;IACC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAnBW,MAAM,KACN,MAAM,YAEd;QAAqD,KAAK;QAChC,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,WAAW;KACvC,EAmOA;IAtIA;;;;OAIG;IACH,QAHU,MAAM,CAGA;IAChB,cAAc;IACd,eAAgB;IAIhB,cAAc;IACd,uBAAmC;IACnC,cAAc;IACd,uBAAmC;IAgBnC,cAAc;IACd,eAAe;IACf,cAAc;IACd,eAAe;IAKf,cAAc;IACd,gBAAmB;IACnB,cAAc;IACd,gBAAmB;IAEnB,cAAc;IACd,uBAAmB;IAKnB;;;OAGG;IACH,kBAAwB;IACxB,sDAAsD;IACtD,YAA0B;IAM1B,0CAA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H,qBAFa,MAAM,EAAE,CAIpB;IAED;;OAEG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,mCAJW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;;;;;;;;OAWG;IACH,oBAHW,MAAM,QA2GhB;IAgBD;;;;OAIG;IACH,gBAIC;IAED;;;;;;;;;OASG;IACH,eAJW,cAAc,GAAC,aAAa,aAC5B,QAAQ,QAMlB;IAED;;;;OAIG;IACH,sEA4DC;CACD;iBAx2BgB,WAAW;2BADD,qBAAqB;qBAL3B,uBAAuB;sBAGtB,+BAA+B"}
@@ -1,5 +1,11 @@
1
1
  /**
2
- * a bitmap font object
2
+ * a bitmap font object.
3
+ *
4
+ * The font descriptor uses the AngelCode BMFont format and may be supplied in
5
+ * either flavour — the **text** (`.fnt`) or the **XML** form — the
6
+ * serialisation is auto-detected, so packs that ship an `.xml` descriptor load
7
+ * as-is, with no conversion step. Load the descriptor as a `binary` asset and
8
+ * its page image as an `image` asset, then reference both by the same name.
3
9
  * @category Text
4
10
  */
5
11
  export default class BitmapText extends Renderable {
@@ -7,29 +13,32 @@ export default class BitmapText extends Renderable {
7
13
  * @param {number} x - position of the text object
8
14
  * @param {number} y - position of the text object
9
15
  * @param {object} settings - the text configuration
10
- * @param {string|Image} settings.font - a font name to identify the corresponing source image
11
- * @param {string} [settings.fontData=settings.font] - the bitmap font data corresponding name, or the bitmap font data itself
16
+ * @param {string|Image} settings.font - a font name to identify the corresponding source image
17
+ * @param {string} [settings.fontData=settings.font] - the bitmap font data corresponding name, or the bitmap font data itself (AngelCode BMFont, `.fnt` text or `.xml`)
12
18
  * @param {number} [settings.size] - size a scaling ratio
13
19
  * @param {Color|string} [settings.fillStyle] - a CSS color value used to tint the bitmapText (@see BitmapText.tint)
14
20
  * @param {number} [settings.lineWidth=1] - line width, in pixels, when drawing stroke
15
21
  * @param {string} [settings.textAlign="left"] - horizontal text alignment
16
22
  * @param {string} [settings.textBaseline="top"] - the text baseline
17
23
  * @param {number} [settings.lineHeight=1.0] - line spacing height
18
- * @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] - anchor point to draw the text at
24
+ * @param {string|Vector2d|{x:number,y:number}} [settings.anchorPoint={x:0.0, y:0.0}] - anchor point to draw the text at. Also accepts the named presets `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"`.
19
25
  * @param {number} [settings.wordWrapWidth] - the maximum length in CSS pixel for a single segment of text
20
26
  * @param {(string|string[])} [settings.text] - a string, or an array of strings
21
27
  * @example
22
- * // Use loader.preload or loader.load to load assets
28
+ * // Load the BMFont descriptor as a "binary" asset and its page as an "image".
29
+ * // Both the text (.fnt) and XML (.xml) BMFont flavours are accepted and
30
+ * // auto-detected, so an .xml descriptor can be used directly:
23
31
  * loader.preload([
32
+ * // text (.fnt) BMFont
24
33
  * { name: "arial", type: "binary", src: "data/font/arial.fnt" },
25
- * { name: "arial", type: "image", src: "data/font/arial.png" },
34
+ * { name: "arial", type: "image", src: "data/font/arial.png" },
35
+ * // XML BMFont (exported by many bitmap-font tools) — loaded as-is
36
+ * { name: "pixel", type: "binary", src: "data/font/pixel.xml" },
37
+ * { name: "pixel", type: "image", src: "data/font/pixel.png" },
26
38
  * ])
27
39
  * // Then create an instance of your bitmap font:
28
- * let myFont = new BitmapText(x, y, {font:"arial", text:"Hello"});
29
- * // two possibilities for using "myFont"
30
- * // either call the draw function from your Renderable draw function
31
- * myFont.draw(renderer, "Hello!", 0, 0);
32
- * // or just add it to the world container
40
+ * let myFont = new BitmapText(x, y, { font: "arial", text: "Hello" });
41
+ * // add it to the world container
33
42
  * app.world.addChild(myFont);
34
43
  */
35
44
  constructor(x: number, y: number, settings: {
@@ -41,7 +50,10 @@ export default class BitmapText extends Renderable {
41
50
  textAlign?: string | undefined;
42
51
  textBaseline?: string | undefined;
43
52
  lineHeight?: number | undefined;
44
- anchorPoint?: any;
53
+ anchorPoint?: string | Vector2d | {
54
+ x: number;
55
+ y: number;
56
+ };
45
57
  wordWrapWidth?: number | undefined;
46
58
  text?: string | string[] | undefined;
47
59
  });